MonetDB: default - merged with linear-hashing

2020-01-11 Thread Niels Nes
Changeset: a24f92121547 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a24f92121547
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_bbp.c
gdk/gdk_calc.c
gdk/gdk_group.c
gdk/gdk_hash.c
gdk/gdk_hash.h
gdk/gdk_heap.c
gdk/gdk_imprints.c
gdk/gdk_join.c
gdk/gdk_orderidx.c
gdk/gdk_private.h
gdk/gdk_select.c
gdk/gdk_storage.c
gdk/gdk_unique.c
monetdb5/mal/mal_resource.h
monetdb5/modules/kernel/bat5.c
monetdb5/modules/kernel/status.c
monetdb5/modules/mal/tokenizer.c
sql/backends/monet5/sql.c
sql/storage/bat/bat_storage.c
sql/test/mergetables/Tests/sqlsmith-exist-lateral.reqtests
Branch: default
Log Message:

merged with linear-hashing


diffs (truncated from 2500 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -294,8 +294,10 @@ const char *GDKversion(void);
 size_t GDKvm_cursize(void);
 void *GDKzalloc(size_t size) __attribute__((__malloc__)) 
__attribute__((__alloc_size__(1))) __attribute__((__warn_unused_result__));
 void HASHdestroy(BAT *b);
+gdk_return HASHgrowbucket(BAT *b);
 BUN HASHlist(Hash *h, BUN i);
 BUN HASHprobe(const Hash *h, const void *v);
+gdk_return HASHupgradehashheap(BAT *b, BUN cap);
 void HEAP_free(Heap *heap, var_t block);
 void HEAP_initialize(Heap *heap, size_t nbytes, size_t nprivate, int 
alignment);
 var_t HEAP_malloc(Heap *heap, size_t nbytes);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -537,22 +537,6 @@ typedef size_t BUN;
 #endif
 #define BUN_MAX (BUN_NONE - 1) /* maximum allowed size of a BAT */
 
-#define BUN2 2
-#define BUN4 4
-#if SIZEOF_BUN > 4
-#define BUN8 8
-#endif
-typedef uint16_t BUN2type;
-typedef uint32_t BUN4type;
-#if SIZEOF_BUN > 4
-typedef uint64_t BUN8type;
-#endif
-#define BUN2_NONE ((BUN2type) UINT16_C(0x))
-#define BUN4_NONE ((BUN4type) UINT32_C(0x))
-#if SIZEOF_BUN > 4
-#define BUN8_NONE ((BUN8type) UINT64_C(0x))
-#endif
-
 /*
  * @- Checking and Error definitions:
  */
@@ -593,17 +577,7 @@ typedef struct {
bat parentid;   /* cache id of VIEW parent bat */
 } Heap;
 
-typedef struct {
-   int type;   /* type of index entity */
-   int width;  /* width of hash entries */
-   BUN nil;/* nil representation */
-   BUN lim;/* collision list size */
-   BUN mask;   /* number of hash buckets-1 (power of 2) */
-   void *Hash; /* hash table */
-   void *Link; /* collision list */
-   Heap heap;  /* heap where the hash is stored */
-} Hash;
-
+typedef struct Hash Hash;
 typedef struct Imprints Imprints;
 
 /*
@@ -859,7 +833,7 @@ typedef struct BATiter {
  *  HEAPload (Heap *h, str nme,ext, bool trunc);
  * @item int
  * @tab
- *  HEAPsave (Heap *h, str nme,ext);
+ *  HEAPsave (Heap *h, str nme,ext, bool dosync);
  * @item int
  * @tab
  *  HEAPcopy (Heap *dst,*src);
@@ -1895,24 +1869,6 @@ bunfastappVAR(BAT *b, const void *v)
 }
 
 /*
- * @- Built-in Accelerator Functions
- *
- * @multitable @columnfractions 0.08 0.7
- * @item BAT*
- * @tab
- *  BAThash (BAT *b)
- * @end multitable
- *
- * The current BAT implementation supports three search accelerators:
- * hashing, imprints, and ordered index.
- *
- * The routine BAThash makes sure that a hash accelerator on the tail of the
- * BAT exists. GDK_FAIL is returned upon failure to create the supportive
- * structures.
- */
-gdk_export gdk_return BAThash(BAT *b);
-
-/*
  * @- Column Imprints Functions
  *
  * @multitable @columnfractions 0.08 0.7
@@ -2627,62 +2583,6 @@ gdk_export void VIEWbounds(BAT *b, BAT *
for (q = BUNlast(r), p = 0; p < q; p++)
 
 /*
- * @- hash-table supported loop over BUNs
- * The first parameter `b' is a BAT, the second (`h') should point to
- * `b->thash', and `v' a pointer to an atomic value (corresponding
- * to the head column of `b'). The 'hb' is an integer index, pointing
- * out the `hb'-th BUN.
- */
-#define HASHloop(bi, h, hb, v) \
-   for (hb = HASHget(h, HASHprobe((h), v));\
-hb != HASHnil(h);  \
-hb = HASHgetlink(h,hb))\
-   if (ATOMcmp(h->type, v, BUNtail(bi, hb)) == 0)
-#define HASHloop_str_hv(bi, h, hb, v)  \
-   for (hb = HASHget((h),((BUN *) (v))[-1]&(h)->mask); \
-hb != HASHnil(h);  \
-hb = HASHgetlink(h,hb))\
-   if (GDK_STREQ(v, BUNtvar(bi, hb)))
-#define HASHloop_str(bi, h, hb, v) \
-   fo

MonetDB: default - merged with linear-hashing

2020-01-11 Thread Niels Nes
Changeset: 1133a2d35f9e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1133a2d35f9e
Modified Files:
clients/Tests/exports.stable.out
clients/mapiclient/mclient.c
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_bbp.c
gdk/gdk_join.c
gdk/gdk_project.c
gdk/gdk_storage.c
monetdb5/mal/Tests/tst180.stable.err
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_session.c
monetdb5/mal/mal_stack.c
monetdb5/mal/mal_stack.h
monetdb5/optimizer/opt_evaluate.c
tools/merovingian/utils/control.c
Branch: default
Log Message:

merged with linear-hashing


diffs (truncated from 369 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -2054,7 +2054,6 @@ int chkInstruction(Module s, MalBlkPtr m
 str chkProgram(Module s, MalBlkPtr mb);
 str chkTypes(Module s, MalBlkPtr mb, int silent);
 str cleanupTraces(Client cntxt);
-void clearStack(MalStkPtr s);
 void clearTrace(Client cntxt);
 void clearVariable(MalBlkPtr mb, int varid);
 str clear_tableRef;
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -124,6 +124,8 @@ static timertype t0, t1;/* used for tim
 
 #ifdef HAVE_POPEN
 static char *pager = 0;/* use external pager */
+#endif
+#ifdef HAVE_SIGACTION
 #include /* to block SIGPIPE */
 #endif
 static int rowsperpage = 0;/* for SQL pagination */
@@ -1808,36 +1810,27 @@ start_pager(stream **saveFD)
 
if (pager) {
FILE *p;
-   struct sigaction act;
 
-   /* ignore SIGPIPE so that we get an error instead of signal */
-   act.sa_handler = SIG_IGN;
-   (void) sigemptyset(&act.sa_mask);
-   act.sa_flags = 0;
-   if(sigaction(SIGPIPE, &act, NULL) == -1) {
+   p = popen(pager, "w");
+   if (p == NULL)
fprintf(stderr, "Starting '%s' failed\n", pager);
-   } else {
-   p = popen(pager, "w");
-   if (p == NULL)
+   else {
+   *saveFD = toConsole;
+   /* put | in name to indicate that file should be closed 
with pclose */
+   if ((toConsole = file_wastream(p, "|pager")) == NULL) {
+   toConsole = *saveFD;
+   *saveFD = NULL;
fprintf(stderr, "Starting '%s' failed\n", 
pager);
-   else {
-   *saveFD = toConsole;
-   /* put | in name to indicate that file should 
be closed with pclose */
-   if ((toConsole = file_wastream(p, "|pager")) == 
NULL) {
+   }
+#ifdef HAVE_ICONV
+   if (encoding != NULL) {
+   if ((toConsole = iconv_wstream(toConsole, 
encoding, "pager")) == NULL) {
toConsole = *saveFD;
*saveFD = NULL;
fprintf(stderr, "Starting '%s' 
failed\n", pager);
}
-#ifdef HAVE_ICONV
-   if (encoding != NULL) {
-   if ((toConsole = 
iconv_wstream(toConsole, encoding, "pager")) == NULL) {
-   toConsole = *saveFD;
-   *saveFD = NULL;
-   fprintf(stderr, "Starting '%s' 
failed\n", pager);
-   }
-   }
+   }
 #endif
-   }
}
}
 }
@@ -3336,6 +3329,16 @@ main(int argc, char **argv)
exit(2);
}
 #endif
+#ifdef HAVE_SIGACTION
+   struct sigaction act;
+   /* ignore SIGPIPE so that we get an error instead of signal */
+   act.sa_handler = SIG_IGN;
+   (void) sigemptyset(&act.sa_mask);
+   act.sa_flags = 0;
+   if (sigaction(SIGPIPE, &act, NULL) == -1)
+   perror("sigaction");
+#endif
+
toConsole = stdout_stream = file_wastream(stdout, "stdout");
stderr_stream = file_wastream(stderr, "stderr");
if(!stdout_stream || !stderr_stream) {
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1271,7 +1271,7 @@ BUNinplace(BAT *b, BUN p, const void *t,
ptr _ptr;
_ptr = BUNtloc(bi, p);
switch (b->twidth) {
-   case 1:
+   default:/* only three or four cases possible */
 

MonetDB: default - Merged with linear-hashing

2020-01-23 Thread Pedro Ferreira
Changeset: e1008a540147 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e1008a540147
Modified Files:
gdk/gdk_atoms.h
monetdb5/modules/mal/sysmon.c
sql/test/remote/Tests/creds.SQL.py
sql/test/remote/Tests/different_user.SQL.py
sql/test/remote/Tests/invalid_creds.SQL.py
sql/test/remote/Tests/ssbm.SQL.py
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 556 to 300 lines):

diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -165,8 +165,8 @@ gdk_export const ptr ptr_nil;
  * In all algorithms across GDK, you will find switches on the types
  * (bte, sht, int, flt, dbl, lng, hge, str). They respectively
  * represent an octet, a 16-bit int, a 32-bit int, a 32-bit float, a
- * 64-bit double, a 64-bit int, and a pointer-sized location of a
- * char-buffer (ended by a zero char).
+ * 64-bit double, a 64-bit int, a 128-bit int, and a pointer-sized location
+ * of a char-buffer (ended by a zero char).
  *
  * In contrast, the types (bit, ptr, bat, oid) are derived types. They
  * do not occur in the switches. The ATOMstorage macro maps them
diff --git a/monetdb5/modules/mal/sysmon.c b/monetdb5/modules/mal/sysmon.c
--- a/monetdb5/modules/mal/sysmon.c
+++ b/monetdb5/modules/mal/sysmon.c
@@ -63,7 +63,7 @@ SYSMONqueue(Client cntxt, MalBlkPtr mb, 
 
MT_lock_set(&mal_delayLock);
for ( i = 0; i< qtop; i++)
-   if( QRYqueue[i].query && (QRYqueue[i].cntxt->user == MAL_ADMIN || 
QRYqueue[i].cntxt->user == cntxt->user)) {
+   if( QRYqueue[i].query && (cntxt->user == MAL_ADMIN || 
QRYqueue[i].cntxt->user == cntxt->user)) {
qtag = (lng) QRYqueue[i].tag;
if (BUNappend(tag, &qtag, false) != GDK_SUCCEED)
goto bailout;
diff --git a/sql/test/remote/Tests/creds.SQL.py 
b/sql/test/remote/Tests/creds.SQL.py
--- a/sql/test/remote/Tests/creds.SQL.py
+++ b/sql/test/remote/Tests/creds.SQL.py
@@ -89,43 +89,45 @@ def create_workers(fn_template, nworkers
 # Start supervisor database
 supervisorport = freeport()
 os.mkdir(os.path.join(TMPDIR, "supervisor"))
-supervisorproc = process.server(mapiport=supervisorport, dbname="supervisor", 
dbfarm=os.path.join(TMPDIR, "supervisor"), stdin=process.PIPE, 
stdout=process.PIPE)
-supervisorconn = pymonetdb.connect(database='supervisor', port=supervisorport, 
autocommit=True)
-supervisor_uri = 
"mapi:monetdb://localhost:{}/supervisor".format(supervisorport)
-c = supervisorconn.cursor()
+try:
+supervisorproc = process.server(mapiport=supervisorport, 
dbname="supervisor", dbfarm=os.path.join(TMPDIR, "supervisor"), 
stdin=process.PIPE, stdout=process.PIPE)
+supervisorconn = pymonetdb.connect(database='supervisor', 
port=supervisorport, autocommit=True)
+supervisor_uri = 
"mapi:monetdb://localhost:{}/supervisor".format(supervisorport)
+c = supervisorconn.cursor()
 
-# Create the movies table and load the data
-movies_filename=os.getenv("TSTDATAPATH")+"/netflix_data/movies.csv"
-movies_create = "CREATE TABLE movies {}".format(MOVIES_TABLE_DEF)
-c.execute(movies_create)
-load_movies = "COPY INTO movies FROM '{}' USING DELIMITERS 
',','\n','\"'".format(movies_filename)
-c.execute(load_movies)
+# Create the movies table and load the data
+movies_filename=os.getenv("TSTDATAPATH")+"/netflix_data/movies.csv"
+movies_create = "CREATE TABLE movies {}".format(MOVIES_TABLE_DEF)
+c.execute(movies_create)
+load_movies = "COPY INTO movies FROM '{}' USING DELIMITERS 
',','\n','\"'".format(movies_filename)
+c.execute(load_movies)
 
-# Declare the ratings merge table on supervisor
-mtable = "CREATE MERGE TABLE ratings {}".format(RATINGS_TABLE_DEF)
-c.execute(mtable)
+# Declare the ratings merge table on supervisor
+mtable = "CREATE MERGE TABLE ratings {}".format(RATINGS_TABLE_DEF)
+c.execute(mtable)
 
-# Create the workers and load the ratings data
-fn_template=os.getenv("TSTDATAPATH")+"/netflix_data/ratings_sample_{}.csv"
-cmovies = "CREATE REMOTE TABLE movies {} ON '{}' WITH USER 'monetdb' PASSWORD 
'monetdb'".format(MOVIES_TABLE_DEF, supervisor_uri)
-workers = create_workers(fn_template, NWORKERS, cmovies, RATINGS_TABLE_DEF_FK)
+# Create the workers and load the ratings data
+fn_template=os.getenv("TSTDATAPATH")+"/netflix_data/ratings_sample_{}.csv"
+cmovies = "CREATE REMOTE TABLE movies {} ON '{}' WITH USER 'monetdb' 
PASSWORD 'monetdb'".format(MOVIES_TABLE_DEF, supervisor_uri)
+try:
+workers = create_workers(fn_template, NWORKERS, cmovies, 
RATINGS_TABLE_DEF_FK)
 
-# Create the remote tables on supervisor
-for wrec in workers:
-rtable = "CREATE REMOTE TABLE ratings{} {} on '{}' WITH USER 'monetdb' 
PASSWORD 'monetdb'".format(wrec['num'], RATINGS_TABLE_DEF, wrec['mapi'])
-c.execute(rtable)
+# Create the remote tables on supervisor
+for wrec in workers:
+rtable = "CREATE REMOTE TABLE ratings{}

MonetDB: default - Merged with linear-hashing

2020-01-24 Thread Pedro Ferreira
Changeset: 47ad11127c89 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=47ad11127c89
Modified Files:
gdk/gdk_utils.c
Branch: default
Log Message:

Merged with linear-hashing


diffs (73 lines):

diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -404,9 +404,48 @@ MT_init(void)
 #ifdef __linux__
/* limit values to whatever cgroups gives us */
FILE *fc;
+   char buf[1024];
+   char cgr1[1024] = "/sys/fs/cgroup/memory";
+   char cgr2[1024] = "/sys/fs/cgroup";
+   fc = fopen("/proc/self/mountinfo", "r");
+   if (fc != NULL) {
+   while (fgets(buf, (int) sizeof(buf), fc) != NULL) {
+   char *p, *cgr;
+   if ((p = strstr(buf, " - cgroup ")) != NULL &&
+   strstr(p, "memory") != NULL)
+   cgr = cgr1;
+   else if (strstr(buf, " - cgroup2 ") != NULL)
+   cgr = cgr2;
+   else
+   continue;
+   /* buf point at mount ID */
+   p = strchr(buf, ' ');
+   if (p++ == NULL)
+   break;
+   /* p points at parent ID */
+   p = strchr(p, ' ');
+   if (p++ == NULL)
+   break;
+   /* p points at major:minor */
+   p = strchr(p, ' ');
+   if (p++ == NULL)
+   break;
+   /* p points at root */
+   p = strchr(p, ' ');
+   if (p++ == NULL)
+   break;
+   /* p points at mount point */
+   char *dir = p;
+   p = strchr(p, ' ');
+   if (p == NULL)
+   break;
+   *p = 0;
+   strcpy(cgr, dir);
+   }
+   fclose(fc);
+   }
fc = fopen("/proc/self/cgroup", "r");
if (fc != NULL) {
-   char buf[1024];
/* each line is of the form:
 * hierarchy-ID:controller-list:cgroup-path
 *
@@ -440,8 +479,7 @@ MT_init(void)
if (strncmp(buf, "0::", 3) == 0) {
/* cgroup v2 entry */
l = strconcat_len(pth, sizeof(pth),
- "/sys/fs/cgroup",
- buf + 3, "/", NULL);
+ cgr2, buf + 3, "/", NULL);
/* hard limit */
strcpy(pth + l, "memory.max");
f = fopen(pth, "r");
@@ -489,8 +527,7 @@ MT_init(void)
if (strstr(q, "memory") == NULL)
continue;
l = strconcat_len(pth, sizeof(pth),
- "/sys/fs/cgroup/", q,
- p, "/", NULL);
+ cgr1, p, "/", NULL);
/* limit of memory usage */
strcpy(pth + l, "memory.limit_in_bytes");
f = fopen(pth, "r");
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with linear-hashing

2020-01-24 Thread Pedro Ferreira
Changeset: 00d16f0fabf4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=00d16f0fabf4
Modified Files:
sql/server/rel_dump.c
sql/server/rel_psm.c
sql/test/Triggers/Tests/All
sql/test/Triggers/Tests/trigger_action.stable.err
sql/test/Triggers/Tests/trigger_action.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (92 lines):

diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -409,8 +409,12 @@ rel_print_(mvc *sql, stream  *fout, sql_
 
if (rel->r)
exp_print(sql, fout, rel->r, depth, refs, 1, 0);
-   if (rel->l)
-   rel_print_(sql, fout, rel->l, depth+1, refs, decorate);
+   if (rel->l) {
+   if (rel->flag == 2) 
+   mnstr_printf(fout, "rel_dump not yet 
implemented for trigger input");
+   else
+   rel_print_(sql, fout, rel->l, depth+1, refs, 
decorate);
+   }
if (rel->exps)
exps_print(sql, fout, rel->exps, depth, refs, 1, 0);
break;
diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -1288,6 +1288,10 @@ create_trigger(sql_query *query, dlist *
rel = stack_find_rel_view(sql, new_name);
if (!rel && old_name)
rel = stack_find_rel_view(sql, old_name);
+   if (!rel)
+   rel = stack_find_rel_view(sql, "old");
+   if (!rel)
+   rel = stack_find_rel_view(sql, "new");
if (rel)
rel = rel_logical_exp(query, rel, condition, sql_where);
if (!rel) {
diff --git a/sql/test/Triggers/Tests/All b/sql/test/Triggers/Tests/All
--- a/sql/test/Triggers/Tests/All
+++ b/sql/test/Triggers/Tests/All
@@ -2,7 +2,7 @@ cascaded_triggers
 recursive_triggers
 referencing_clause_new
 referencing_clause_old
-KNOWNFAIL?trigger_action
+trigger_action
 trigger_activation
 trigger_owner
 triggers_schema_operations
diff --git a/sql/test/Triggers/Tests/trigger_action.stable.err 
b/sql/test/Triggers/Tests/trigger_action.stable.err
--- a/sql/test/Triggers/Tests/trigger_action.stable.err
+++ b/sql/test/Triggers/Tests/trigger_action.stable.err
@@ -10,6 +10,10 @@ stderr of test 'trigger_action` in direc
 # 21:20:08 >  Mtimeout -timeout 60 MapiClient -lsql -umonetdb -Pmonetdb 
--host=localhost --port=37598  < trigger_action.sql
 # 21:20:08 >  
 
+MAPI  = (monetdb) /var/tmp/mtest-358294/.s.monetdb.33867
+QUERY = update t_4_1 set "name" = 'mo' where "id" = 10;
+ERROR = !SELECT: identifier 'id' ambiguous
+CODE  = 42000
 
 # 21:20:08 >  
 # 21:20:08 >  Done.
diff --git a/sql/test/Triggers/Tests/trigger_action.stable.out 
b/sql/test/Triggers/Tests/trigger_action.stable.out
--- a/sql/test/Triggers/Tests/trigger_action.stable.out
+++ b/sql/test/Triggers/Tests/trigger_action.stable.out
@@ -55,24 +55,16 @@ stdout of test 'trigger_action` in direc
 #create trigger test_4_8
 #  after update on t_4_1 referencing new row as new_row
 #  for each row 
-#  when new_row.id >1000 insert into t_4_1 values(7, 
'update_when_row_false');
-#update t_4_1 set name = 'mo' where id = 10;
-[ 1]
+#  when (new_row."id">1000) insert into t_4_1 values(7, 
'update_when_row_false');
+#select * from t_4_1;
 % sys.t_4_1,   sys.t_4_1 # table_name
 % id,  name # name
 % int, varchar # type
-% 2,   27 # length
-[ 10,  "mo"]
+% 2,   7 # length
+[ 10,  "monetdb"   ]
 [ 20,  "monet" ]
-[ 0,   "update_old_row_statement"  ]
-[ 1,   "update_new_row_statement"  ]
-[ 2,   "update_statement"  ]
-[ 3,   "update_row"]
-[ 4,   "update_when_statement_true"]
-[ 5,   "update_when_row_true"  ]
-[ 6,   "update_when_statement_false"   ]
-[ 7,   "update_when_row_false" ]
-[ 10   ]
+#delete from t_4_1 where "id" >-1;
+[ 2]
 #drop trigger test_4_1;
 #drop trigger test_4_2;
 #drop trigger test_4_3;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with linear-hashing

2020-01-24 Thread Pedro Ferreira
Changeset: f18613bc2371 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f18613bc2371
Modified Files:
sql/storage/bat/bat_storage.c
sql/storage/store.c

sql/test/BugDay_2005-10-06_2.9.3/Tests/huge_expression_and_column_name.SF-921173.sql

sql/test/BugDay_2005-10-06_2.9.3/Tests/huge_expression_and_column_name.SF-921173.stable.out
sql/test/BugTracker-2010/Tests/huge_nr_of_columns.Bug-2609.sql
sql/test/BugTracker-2012/Tests/huge_table_update.Bug-2803.sql
sql/test/BugTracker-2012/Tests/huge_table_update.Bug-2803.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 19879 to 300 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -775,7 +775,7 @@ dup_idx(sql_trans *tr, sql_idx *i, sql_i
 {
int ok = LOG_OK;
 
-   if (!isTable(i->t) || !idx_has_column(i->type))
+   if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type))
return ok;
if (i->data) {
int type = (oid_index(ni->type))?TYPE_oid:TYPE_lng;
@@ -892,9 +892,9 @@ append_col(sql_trans *tr, sql_column *c,
 static int
 append_idx(sql_trans *tr, sql_idx * i, void *ib, int tpe)
 {
+   int ok = LOG_OK;
BAT *b = ib;
sql_delta *bat;
-   int ok = LOG_OK;
 
if (tpe == TYPE_bat && !BATcount(b)) 
return ok;
@@ -908,8 +908,8 @@ append_idx(sql_trans *tr, sql_idx * i, v
else {
i->data = bat;
obat = timestamp_delta(oi->data, i->base.stime);
-   ok = dup_bat(tr, i->t, obat, bat, type, isNew(i), 
isNew(i));
-   if(ok != LOG_ERR)
+   ok = dup_bat(tr, i->t, obat, bat, type, isNew(oi), 
isNew(i));
+   if(ok == LOG_OK)
i->base.allocated = 1;
}
}
@@ -1053,7 +1053,7 @@ delete_tab(sql_trans *tr, sql_table * t,
sql_idx *i = n->data;
sql_delta *bat;
 
-   if (!isTable(i->t) || !idx_has_column(i->type)) 
+   if (!isTable(i->t) || (hash_index(i->type) && 
list_length(i->columns) <= 1) || !idx_has_column(i->type)) 
continue;
if (!i->data) {
sql_idx *oi = tr_find_idx(tr->parent, i);
@@ -1136,7 +1136,7 @@ count_idx(sql_trans *tr, sql_idx *i, int
 {
sql_delta *b;
 
-   if (!isTable(i->t) || !idx_has_column(i->type)) 
+   if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type)) 
return 0;
if (!i->data) {
sql_idx *oi = tr_find_idx(tr->parent, i);
@@ -1189,7 +1189,7 @@ count_idx_upd(sql_trans *tr, sql_idx *i)
 {
sql_delta *b;
 
-   if (!isTable(i->t) || !idx_has_column(i->type)) 
+   if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type)) 
return 0;
if (!i->data) {
sql_idx *oi = tr_find_idx(tr->parent, i);
@@ -1220,7 +1220,7 @@ count_upd(sql_trans *tr, sql_table *t)
for( n = t->idxs.set->h; n; n = n->next) {
sql_idx *i = n->data;
 
-   if (!isTable(i->t) || !idx_has_column(i->type)) 
+   if (!isTable(i->t) || (hash_index(i->type) && 
list_length(i->columns) <= 1) || !idx_has_column(i->type)) 
continue;
if (count_idx_upd(tr, i))
return 1;
@@ -2055,7 +2055,7 @@ clear_col(sql_trans *tr, sql_column *c)
 static BUN
 clear_idx(sql_trans *tr, sql_idx *i)
 {
-   if (!isTable(i->t) || !idx_has_column(i->type))
+   if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type))
return 0;
if (!i->data || !i->base.allocated) {
int type = (oid_index(i->type))?TYPE_oid:TYPE_lng;
@@ -2064,7 +2064,7 @@ clear_idx(sql_trans *tr, sql_idx *i)
if(!bat)
return 0;
obat = timestamp_delta(oi->data, i->base.stime);
-   if(dup_bat(tr, i->t, obat, bat, type, isNew(i), isNew(i)))
+   if(dup_bat(tr, i->t, obat, bat, type, isNew(oi), isNew(i)))
return 0;
i->base.allocated = 1;
}
@@ -2279,7 +2279,7 @@ gtr_update_table(sql_trans *tr, sql_tabl
sql_idx *ci = n->data;
 
/* some indices have no bats */
-   if (!isTable(ci->t) || !idx_has_column(ci->type)) 
+   if (!isTable(ci->t) || (hash_index(ci->type) && 
list_length(ci->columns) <= 1) || !idx_has_column(ci->type)) 
   

MonetDB: default - Merged with linear hashing

2020-01-28 Thread Pedro Ferreira
Changeset: 1bda50c9b8f2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1bda50c9b8f2
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
clients/odbc/samples/testgetinfo.c
gdk/gdk_batop.c
gdk/gdk_cand.h
gdk/gdk_project.c
gdk/gdk_select.c
gdk/gdk_unique.c

monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.err.Windows
monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out

monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows
monetdb5/modules/atoms/uuid.c
monetdb5/modules/mal/01_batcalc.mal
monetdb5/modules/mal/01_batcalc.mal.sh
sql/backends/monet5/generator/generator.c
sql/backends/monet5/sql_scenario.c
sql/benchmarks/ssbm/Tests/check1.sql
sql/benchmarks/tpcds/Tests/79.stable.out
sql/benchmarks/tpcds/Tests/79.stable.out.int128
sql/benchmarks/tpch/Tests/check1.sql
sql/benchmarks/tpch/Tests/lowcardinality.sql
sql/benchmarks/tpch/Tests/lowcardinality.stable.out
sql/test/BugTracker-2019/Tests/rank-nan.Bug-6780.sql
sql/test/BugTracker-2019/Tests/rank-nan.Bug-6780.stable.out
sql/test/BugTracker-2019/Tests/subselect.Bug-6688.sql
sql/test/BugTracker-2019/Tests/subselect.Bug-6688.stable.out
sql/test/BugTracker-2019/Tests/subselect.Bug-6700.sql
sql/test/BugTracker-2019/Tests/subselect.Bug-6700.stable.out
tools/mserver/mserver5.c
Branch: default
Log Message:

Merged with linear hashing


diffs (truncated from 5055 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -700,18 +700,10 @@ stdout of test 'MAL-signatures` in direc
 [ "batbam","reverse_seq",  "command 
batbam.reverse_seq(seqs:bat[:str]):bat[:str] ","reverse_seq_bat;", 
"Reverse a bat of DNA sequences."   ]
 [ "batbam","seq_char", "command batbam.seq_char(ref_pos:int, 
alg_seq:bat[:str], alg_pos:bat[:int], alg_cigar:bat[:str]):bat[:str] ",   
"seq_char_bat;","Calculate the character in the alignment string 
(alg_str) that is aligned to position 'ref_pos', conforming to the given cigar 
string (bat based version)" ]
 [ "batbam","seq_length",   "command 
batbam.seq_length(cigars:bat[:str]):bat[:int] ",   "seq_length_bat;",  
"Calculate the real length of a bat of DNA sequences, given their CIGAR 
string."]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:bit], 
b2:bat[:bit]):bat[:bit] ","CMDbatNE;","Return B1 != B2"   ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:bit], b2:bat[:bit], 
nil_matches:bit):bat[:bit] ",   "CMDbatNE;","Return B1 != B2"   ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:bit], b2:bat[:bit], 
s:bat[:oid]):bat[:bit] ",   "CMDbatNE;","Return B1 != B2 with 
candidates list"  ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:bit], b2:bat[:bit], 
s:bat[:oid], nil_matches:bit):bat[:bit] ",  "CMDbatNE;","Return B1 != 
B2 with candidates list"  ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:blob], 
b2:bat[:blob]):bat[:bit] ",  "CMDbatNE;","Return B1 != B2"   ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:blob], b2:bat[:blob], 
nil_matches:bit):bat[:bit] ", "CMDbatNE;","Return B1 != B2"   ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:blob], b2:bat[:blob], 
s:bat[:oid]):bat[:bit] ", "CMDbatNE;","Return B1 != B2 with candidates 
list"  ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:blob], b2:bat[:blob], 
s:bat[:oid], nil_matches:bit):bat[:bit] ","CMDbatNE;","Return B1 != B2 
with candidates list"  ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:bte], 
b2:bat[:bte]):bat[:bit] ","CMDbatNE;","Return B1 != B2"   ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:bte], b2:bat[:bte], 
nil_matches:bit):bat[:bit] ",   "CMDbatNE;","Return B1 != B2"   ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:bte], b2:bat[:bte], 
s:bat[:oid]):bat[:bit] ",   "CMDbatNE;","Return B1 != B2 with 
candidates list"  ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:bte], b2:bat[:bte], 
s:bat[:oid], nil_matches:bit):bat[:bit] ",  "CMDbatNE;","Return B1 != 
B2 with candidates list"  ]
+[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:any_1], 
b2:bat[:any_1]):bat[:bit] ","CMDbatNE;","Return B1 != B2"   ]
+[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:any_1], b2:bat[:any_1], 
nil_matches:bit):bat[:bit] ",   "CMDbatNE;","Return B1 != B2"   ]
+[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:any_1], b2:bat[:any_1], 
s:bat[:oid]):bat[:bit] ",   "CMDbatNE;","Return B1 != B2 with candidates 
list"  ]
+[ "batca

MonetDB: default - Merged with linear-hashing

2020-01-29 Thread Pedro Ferreira
Changeset: 3f102989da46 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3f102989da46
Removed Files:

sql/test/BugTracker-2008/Tests/too_many_nested_operators.SF-2102167.timeout
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
clients/Tests/exports.stable.out
monetdb5/modules/kernel/alarm.mal
sql/backends/monet5/sql_upgrades.c
sql/benchmarks/tpcds/Tests/79.sql
sql/benchmarks/tpcds/Tests/79.stable.out
sql/benchmarks/tpcds/Tests/79.stable.out.int128
sql/test/BugTracker-2008/Tests/too_many_nested_operators.SF-2102167.sql

sql/test/BugTracker-2008/Tests/too_many_nested_operators.SF-2102167.stable.err

sql/test/BugTracker-2008/Tests/too_many_nested_operators.SF-2102167.stable.out

sql/test/BugTracker-2009/Tests/union_where_combined.SF-2887282.stable.out

sql/test/BugTracker-2009/Tests/use_order_column_first.SF-2686008.stable.out
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/sys-schema/Tests/systemfunctions.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out.int128
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 593 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -760,10 +760,6 @@ stdout of test 'MAL-signatures` in direc
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:flt], b2:bat[:dbl], 
nil_matches:bit):bat[:bit] ",   "CMDbatNE;","Return B1 != B2"   ]
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:flt], b2:bat[:dbl], 
s:bat[:oid]):bat[:bit] ",   "CMDbatNE;","Return B1 != B2 with 
candidates list"  ]
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:flt], b2:bat[:dbl], 
s:bat[:oid], nil_matches:bit):bat[:bit] ",  "CMDbatNE;","Return B1 != 
B2 with candidates list"  ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:flt], 
b2:bat[:flt]):bat[:bit] ","CMDbatNE;","Return B1 != B2"   ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:flt], b2:bat[:flt], 
nil_matches:bit):bat[:bit] ",   "CMDbatNE;","Return B1 != B2"   ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:flt], b2:bat[:flt], 
s:bat[:oid]):bat[:bit] ",   "CMDbatNE;","Return B1 != B2 with 
candidates list"  ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:flt], b2:bat[:flt], 
s:bat[:oid], nil_matches:bit):bat[:bit] ",  "CMDbatNE;","Return B1 != 
B2 with candidates list"  ]
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:flt], 
b2:bat[:int]):bat[:bit] ","CMDbatNE;","Return B1 != B2"   ]
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:flt], b2:bat[:int], 
nil_matches:bit):bat[:bit] ",   "CMDbatNE;","Return B1 != B2"   ]
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:flt], b2:bat[:int], 
s:bat[:oid]):bat[:bit] ",   "CMDbatNE;","Return B1 != B2 with 
candidates list"  ]
@@ -788,10 +784,6 @@ stdout of test 'MAL-signatures` in direc
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:int], b2:bat[:flt], 
nil_matches:bit):bat[:bit] ",   "CMDbatNE;","Return B1 != B2"   ]
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:int], b2:bat[:flt], 
s:bat[:oid]):bat[:bit] ",   "CMDbatNE;","Return B1 != B2 with 
candidates list"  ]
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:int], b2:bat[:flt], 
s:bat[:oid], nil_matches:bit):bat[:bit] ",  "CMDbatNE;","Return B1 != 
B2 with candidates list"  ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:int], 
b2:bat[:int]):bat[:bit] ","CMDbatNE;","Return B1 != B2"   ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:int], b2:bat[:int], 
nil_matches:bit):bat[:bit] ",   "CMDbatNE;","Return B1 != B2"   ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:int], b2:bat[:int], 
s:bat[:oid]):bat[:bit] ",   "CMDbatNE;","Return B1 != B2 with 
candidates list"  ]
-[ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:int], b2:bat[:int], 
s:bat[:oid], nil_matches:bit):bat[:bit] ",  "CMDbatNE;","Return B1 != 
B2 with candidates list"  ]
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:int], 
b2:bat[:lng]):bat[:bit] ","CMDbatNE;","Return B1 != B2"   ]
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:int], b2:bat[:lng], 
nil_matches:bit):bat[:bit] ",   "CMDbatNE;","Return B1 != B2"   ]
 [ "batcalc",   "!=",   "pattern batcalc.!=(b1:bat[:int], b2:bat[:lng], 
s:bat[:oid]):bat[:bit] ",   "CMDbatNE;","Return B1 != B2 with 
candidates list"  ]
@@ -908,10 +900,6 @@ stdout of test 'MAL-signatures` in direc
 [ "batcalc",   "!=",   "pattern batcalc.!=(b:bat[:flt], v:dbl, 
nil_matches:bit):bat[:bit] ",   "CMDbat

MonetDB: default - Merged with linear-hashing

2020-01-30 Thread Pedro Ferreira
Changeset: 524b3deabf60 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=524b3deabf60
Added Files:
sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.sql
sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.stable.err
sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.stable.out
Modified Files:
gdk/gdk_hash.h
sql/server/rel_dump.c
sql/server/rel_optimizer.c
sql/server/rel_propagate.c
sql/server/rel_select.c
sql/server/rel_unnest.c
sql/test/BugTracker-2020/Tests/All
sql/test/miscellaneous/Tests/groupby_error.sql
sql/test/miscellaneous/Tests/groupby_error.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (289 lines):

diff --git a/gdk/gdk_hash.h b/gdk/gdk_hash.h
--- a/gdk/gdk_hash.h
+++ b/gdk/gdk_hash.h
@@ -9,7 +9,7 @@
 #ifndef _GDK_SEARCH_H_
 #define _GDK_SEARCH_H_
 
-typedef struct Hash {
+struct Hash {
int type;   /* type of index entity */
uint8_t width;  /* width of hash entries */
BUN mask1;  /* .mask1 < .nbucket <= .mask2 */
@@ -22,7 +22,7 @@ typedef struct Hash {
void *Link; /* collision list, points into .heaplink */
Heap heaplink;  /* heap where the hash links are stored */
Heap heapbckt;  /* heap where the hash buckets are stored */
-} Hash;
+};
 
 static inline BUN
 HASHbucket(const Hash *h, BUN v)
diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -118,7 +118,7 @@ exp_print(mvc *sql, stream *fout, sql_ex
break;
}
case e_convert: {
-   char *to_type = sql_subtype_string(&e->tpe);
+   char *to_type = sql_subtype_string(exp_subtype(e));
mnstr_printf(fout, "%s[", to_type);
exp_print(sql, fout, e->l, depth, refs, 0, 0);
mnstr_printf(fout, "]");
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -5889,10 +5889,21 @@ rel_groupby_distinct(int *changes, mvc *
for (n=rel->exps->h; n; n = n->next) {
sql_exp *e = n->data;
if (e != distinct) {
-   e = exp_ref(sql->sa, e);
-   append(ngbe, e);
-   append(exps, e);
-   e = exp_ref(sql->sa, e);
+   if (e->type == e_aggr) { /* copy the arguments 
to the aggregate */
+   list *args = e->l;
+   sql_exp *dargs = args->h->data;
+
+   list_append(ngbe, exp_copy(sql, dargs));
+   list_append(exps, exp_copy(sql, dargs));
+   } else {
+   e = exp_ref(sql->sa, e);
+   append(ngbe, e);
+   append(exps, e);
+   }
+   if (e->type == e_aggr) /* aggregates must be 
copied */
+   e = exp_copy(sql, e);
+   else
+   e = exp_ref(sql->sa, e);
append(nexps, e);
}
}
diff --git a/sql/server/rel_propagate.c b/sql/server/rel_propagate.c
--- a/sql/server/rel_propagate.c
+++ b/sql/server/rel_propagate.c
@@ -187,11 +187,11 @@ create_range_partition_anti_rel(sql_quer
sql_exp *range1, *range2;
e1 = exp_copy(sql, pmin);
if (subtype_cmp(exp_subtype(pmin), &tpe) != 0)
-   e1 = exp_convert(sql->sa, e1, &e1->tpe, &tpe);
+   e1 = exp_convert(sql->sa, e1, exp_subtype(e1), &tpe);
 
e2 = exp_copy(sql, pmax);
if (subtype_cmp(exp_subtype(e2), &tpe) != 0)
-   e2 = exp_convert(sql->sa, e2, &e2->tpe, &tpe);
+   e2 = exp_convert(sql->sa, e2, exp_subtype(e2), &tpe);
 
range1 = exp_compare(sql->sa, exp_copy(sql, anti_le), e1, 3);
range2 = exp_compare(sql->sa, exp_copy(sql, anti_le), e2, 1);
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -510,14 +510,15 @@ find_table_function_type(mvc *sql, sql_s
for (n = exps->h, m = (*sf)->func->ops->h; n && m; n = 
n->next, m = m->next) {
sql_arg *a = m->data;
sql_exp *e = n->data;
+   sql_subtype *t = exp_subtype(e);
 
if (!aa && a->type.type->ec

MonetDB: default - Merged with linear-hashing

2020-02-03 Thread Pedro Ferreira
Changeset: 069b61f984e4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=069b61f984e4
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sql_statement.h
sql/server/rel_exp.c
sql/server/rel_select.c
sql/server/sql_semantic.c

sql/test/BugDay_2005-12-19_2.9.3/Tests/bogus_prepare.SF-1377079.stable.err

sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare-where.SF-1238867.1238959.1238965.1240124.stable.err

sql/test/BugTracker-2017/Tests/wrong_aggregation_count.Bug-6257.stable.out

sql/test/BugTracker-2019/Tests/alter_table_set_schema.Bug-6701.stable.out
sql/test/miscellaneous/Tests/groupby_error.sql
sql/test/miscellaneous/Tests/groupby_error.stable.err
sql/test/miscellaneous/Tests/groupby_error.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 1023 to 300 lines):

diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2226,6 +2226,7 @@ rel2bin_semijoin(backend *be, sql_rel *r
list *l; 
node *en = NULL, *n;
stmt *left = NULL, *right = NULL, *join = NULL, *jl, *jr, *c;
+   int semi_used = 0;
 
if (rel->op == op_anti && !list_empty(rel->exps) && 
list_length(rel->exps) == 1 && ((sql_exp*)rel->exps->h->data)->flag == 
mark_notin)
return rel2bin_antijoin(be, rel, refs);
@@ -2243,7 +2244,37 @@ rel2bin_semijoin(backend *be, sql_rel *r
 *  first cheap join(s) (equality or idx) 
 *  second selects/filters 
 */
-   if (rel->exps) {
+   if (rel->op != op_anti && rel->exps && list_length(rel->exps) == 1) {
+   sql_exp *e = rel->exps->h->data;
+
+   if (e->type == e_cmp && (e->flag == cmp_equal || e->flag == 
mark_in) && !e->anti && !e->f) {
+   stmt *r, *l = exp_bin(be, e->l, left, NULL, NULL, NULL, 
NULL, NULL);
+   int swap = 0;
+
+   if (!l) {
+   swap = 1;
+   l = exp_bin(be, e->l, right, NULL, NULL, NULL, 
NULL, NULL);
+   }
+   r = exp_bin(be, e->r, left, right, NULL, NULL, NULL, 
NULL);
+
+   if (swap) {
+   stmt *t = l;
+   l = r;
+   r = t;
+   }
+
+   if (!l || !r)
+   return NULL;
+   join = stmt_semijoin(be, l, r); 
+   if (join)
+   join = stmt_result(be, join, 0);
+   if (!join)
+   return NULL;
+   semi_used = 1;
+   }
+   }
+   
+   if (!semi_used && rel->exps) {
int idx = 0;
list *jexps = sa_list(sql->sa);
list *lje = sa_list(sql->sa);
@@ -2317,13 +2348,14 @@ rel2bin_semijoin(backend *be, sql_rel *r
stmt *r = bin_first_column(be, right);
join = stmt_join(be, l, r, 0, cmp_all); 
}
-   } else {
+   } else if (!semi_used) {
stmt *l = bin_first_column(be, left);
stmt *r = bin_first_column(be, right);
join = stmt_join(be, l, r, 0, cmp_all); 
}
-   jl = stmt_result(be, join, 0);
-   if (en) {
+   if (!semi_used)
+   jl = stmt_result(be, join, 0);
+   if (!semi_used && en) {
stmt *sub, *sel = NULL;
list *nl;
 
@@ -2373,13 +2405,15 @@ rel2bin_semijoin(backend *be, sql_rel *r
/* construct relation */
l = sa_list(sql->sa);
 
-   /* We did a full join, thats too much. 
-  Reduce this using difference and intersect */
-   c = stmt_mirror(be, left->op4.lval->h->data);
-   if (rel->op == op_anti) {
-   join = stmt_tdiff(be, c, jl);
-   } else {
-   join = stmt_tinter(be, c, jl);
+   if (!semi_used) {
+   /* We did a full join, thats too much. 
+   Reduce this using difference and intersect */
+   c = stmt_mirror(be, left->op4.lval->h->data);
+   if (rel->op == op_anti) {
+   join = stmt_tdiff(be, c, jl);
+   } else {
+   join = stmt_tinter(be, c, jl);
+   }
}
 
/* project all the left columns */
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -792,7 +792,7 @@ backend_dumpproc(backend *be, Client c, 
sql_type *

MonetDB: default - Merged with linear-hashing

2020-02-04 Thread Pedro Ferreira
Changeset: a94facf62cf5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a94facf62cf5
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk_atoms.c
gdk/gdk_atoms.h
gdk/gdk_group.c
gdk/gdk_hash.h
gdk/gdk_private.h
gdk/gdk_string.c
geom/monetdb5/geom.c
monetdb5/mal/mal_authorize.c
monetdb5/mal/mal_interpreter.c
monetdb5/modules/atoms/blob.c
monetdb5/modules/atoms/color.c
monetdb5/modules/atoms/inet.c
monetdb5/modules/atoms/json.c
monetdb5/modules/atoms/mtime.c
monetdb5/modules/atoms/str.c
monetdb5/modules/atoms/url.c
monetdb5/modules/atoms/uuid.c
monetdb5/modules/atoms/xml.c
monetdb5/modules/kernel/batcolor.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_rank.c
sql/backends/monet5/sql_result.c
sql/backends/monet5/sql_round_impl.h
sql/server/rel_optimizer.c
sql/server/rel_psm.c
sql/server/rel_select.c
sql/server/sql_atom.c
sql/server/sql_mvc.c
sql/server/sql_parser.y
sql/server/sql_symbol.c
sql/server/sql_symbol.h
sql/server/sql_tokens.h
sql/test/analytics/Tests/analytics01.stable.out
sql/test/analytics/Tests/analytics02.sql
sql/test/analytics/Tests/analytics02.stable.err
sql/test/analytics/Tests/analytics02.stable.out
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.out
sql/test/sample/Tests/sample.15.sql
sql/test/sample/Tests/sample.15.stable.err
sql/test/sample/Tests/sample.15.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 2333 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -510,8 +510,6 @@ ssize_t shtToStr(str *dst, size_t *len, 
 const sht sht_nil;
 ssize_t strFromStr(const char *restrict src, size_t *restrict len, str 
*restrict dst, bool external);
 BUN strHash(const char *s);
-size_t strLen(const char *s);
-int strNil(const char *s);
 const char str_nil[2];
 gdk_return void_inplace(BAT *b, oid id, const void *val, bool force) 
__attribute__((__warn_unused_result__));
 int win_mkdir(const char *, const int mode);
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -450,7 +450,7 @@ bitFromStr(const char *src, size_t *len,
 
**dst = bit_nil;
 
-   if (GDK_STRNIL(src))
+   if (strNil(src))
return 1;
 
while (GDKisspace(*p))
@@ -508,7 +508,7 @@ batFromStr(const char *src, size_t *len,
 
atommem(sizeof(bat));
 
-   if (GDK_STRNIL(src)) {
+   if (strNil(src)) {
**dst = bat_nil;
return 1;
}
@@ -665,7 +665,7 @@ numFromStr(const char *src, size_t *len,
 * values */
atommem(sz);
 
-   if (GDK_STRNIL(src)) {
+   if (strNil(src)) {
memcpy(*dst, ATOMnilptr(tp), sz);
return 1;
}
@@ -903,7 +903,7 @@ ptrFromStr(const char *src, size_t *len,
atommem(sizeof(ptr));
 
**dst = ptr_nil;
-   if (GDK_STRNIL(src))
+   if (strNil(src))
return 1;
 
while (GDKisspace(*p))
@@ -956,7 +956,7 @@ dblFromStr(const char *src, size_t *len,
/* alloc memory */
atommem(sizeof(dbl));
 
-   if (GDK_STRNIL(src)) {
+   if (strNil(src)) {
**dst = dbl_nil;
return 1;
}
@@ -1029,7 +1029,7 @@ fltFromStr(const char *src, size_t *len,
/* alloc memory */
atommem(sizeof(flt));
 
-   if (GDK_STRNIL(src)) {
+   if (strNil(src)) {
**dst = flt_nil;
return 1;
}
@@ -1110,7 +1110,7 @@ OIDfromStr(const char *src, size_t *len,
atommem(sizeof(oid));
 
**dst = oid_nil;
-   if (GDK_STRNIL(src))
+   if (strNil(src))
return 1;
 
while (GDKisspace(*p))
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -69,8 +69,6 @@ gdk_export ssize_t dblToStr(str *dst, si
 gdk_export ssize_t GDKstrFromStr(unsigned char *restrict dst, const unsigned 
char *restrict src, ssize_t len);
 gdk_export ssize_t strFromStr(const char *restrict src, size_t *restrict len, 
str *restrict dst, bool external);
 gdk_export BUN strHash(const char *s);
-gdk_export size_t strLen(const char *s);
-gdk_export int strNil(const char *s);
 gdk_export size_t escapedStrlen(const char *restrict src, const char *sep1, 
const char *sep2, int quote);
 gdk_export size_t escapedStr(char *restrict dst, const char *restrict src, 
size_t dstlen, const char *sep1, const char *sep2, int quote);
 /*
@@ -323,11 +321,31 @@ ATOMreplaceVAR(int type, Heap *heap, var
  * though we have t

MonetDB: default - Merged with linear-hashing

2020-02-05 Thread Pedro Ferreira
Changeset: 265c4ba3cd79 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=265c4ba3cd79
Added Files:
sql/test/BugTracker-2020/Tests/alter-table-add-column-Bug-6816.py

sql/test/BugTracker-2020/Tests/alter-table-add-column-Bug-6816.stable.err

sql/test/BugTracker-2020/Tests/alter-table-add-column-Bug-6816.stable.out
sql/test/miscellaneous/Tests/pk_fk_stress.py
sql/test/miscellaneous/Tests/pk_fk_stress.stable.err
sql/test/miscellaneous/Tests/pk_fk_stress.stable.out
Modified Files:
clients/mapiclient/mhelp.c
monetdb5/mal/Tests/tst051.stable.out
monetdb5/mal/Tests/tst180.stable.err
monetdb5/mal/mal_instruction.c
sql/backends/monet5/rel_bin.c
sql/rel.txt
sql/server/sql_parser.y
sql/storage/bat/bat_storage.c
sql/storage/store.c
sql/test/BugTracker-2020/Tests/All
sql/test/miscellaneous/Tests/All
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 612 to 300 lines):

diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c
--- a/clients/mapiclient/mhelp.c
+++ b/clients/mapiclient/mhelp.c
@@ -281,6 +281,11 @@ SQLhelp sqlhelp1[] = {
 "CURRENT_USER | USER",
 NULL,
 NULL},
+   {"DEALLOCATE",
+"Deallocates a prepared statement or all from the client's session 
cache",
+"DEALLOCATE [ PREPARE ] { intnr | ** | ALL }",
+NULL,
+NULL},
{"DEBUG",
 "Debug a SQL statement using MAL debugger",
 "DEBUG statement",
@@ -373,7 +378,7 @@ SQLhelp sqlhelp1[] = {
 NULL},
{"EXECUTE",
 "Execute a prepared SQL statement with supplied parameter values",
-"EXECUTE {intnr | **} '(' [ value [, ...] ] ')'",
+"EXECUTE { intnr | ** } '(' [ value [, ...] ] ')'",
 NULL,
 "See also 
https://www.monetdb.org/Documentation/Manuals/SQLreference/PrepareExec"},
{"EXPLAIN",
diff --git a/monetdb5/mal/Tests/tst051.stable.out 
b/monetdb5/mal/Tests/tst051.stable.out
--- a/monetdb5/mal/Tests/tst051.stable.out
+++ b/monetdb5/mal/Tests/tst051.stable.out
@@ -48,10 +48,10 @@ stdout of test 'tst051` in directory 'mo
 [ "orld" ]
 [ 0 ]
 [ 0 ]
-[ 0 ]
-[ 0 ]
-[ 0 ]
-[ 0 ]
+[ nil  ]
+[ nil  ]
+[ nil  ]
+[ nil  ]
 [ "abcabcabc" ]
 [ nil ]
 [ "hellobrave new world" ]
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2227,6 +2227,7 @@ rel2bin_semijoin(backend *be, sql_rel *r
node *en = NULL, *n;
stmt *left = NULL, *right = NULL, *join = NULL, *jl, *jr, *c;
int semi_used = 0;
+   int semi_disabled = mvc_debug_on(sql, 2048);
 
if (rel->op == op_anti && !list_empty(rel->exps) && 
list_length(rel->exps) == 1 && ((sql_exp*)rel->exps->h->data)->flag == 
mark_notin)
return rel2bin_antijoin(be, rel, refs);
@@ -2244,7 +2245,7 @@ rel2bin_semijoin(backend *be, sql_rel *r
 *  first cheap join(s) (equality or idx) 
 *  second selects/filters 
 */
-   if (rel->op != op_anti && rel->exps && list_length(rel->exps) == 1) {
+   if (!semi_disabled && rel->op != op_anti && rel->exps && 
list_length(rel->exps) == 1) {
sql_exp *e = rel->exps->h->data;
 
if (e->type == e_cmp && (e->flag == cmp_equal || e->flag == 
mark_in) && !e->anti && !e->f) {
diff --git a/sql/rel.txt b/sql/rel.txt
--- a/sql/rel.txt
+++ b/sql/rel.txt
@@ -63,20 +63,20 @@ GROUPBY  (card ATOM (no group by exps), 
-> ris list of group by expressions
 
 TOPN   (card ATOM, AGGR, or MULTI (same card as lower relation))
-   -> exps (list) int limit, [ int offset ]
+   -> exps (list) lng limit, [ lng offset ]
-> lis relation
-> flag (bounds for limit can be including (1) or excluding (0) 
(ie later just returns the topN, including will return atleast N)
 
 SAMPLE (card ATOM, AGGR, or MULTI (same card as lower relation))
-   -> exps int rownumbers, (todo: double between [0,1] for 
percentage)
+   -> exps first is either an lng for rownumbers or double between 
[0,1] for percentage. An optional second contains an int for the seed value
-> lis relation
-> flag (0) no flags
 
-INSERT|DELETE|UPDATE   (card MULTI)
+INSERT|DELETE|UPDATE|TRUNCATE  (card MULTI)
-> lis relation to modify
-> rto be inserted/deleted/updated relation
For update the ->r projection joins in current
-   values for 'none' updated columns.
+   values for 'none' updated columns. Not used in truncate.
 
-> flag (if set don't insert (is done already))
 only (UPDATE)
@@ -108,29 +108,38 @@ e_cmp
-> lleft sub expression
-> rright sub exp

MonetDB: default - Merged with linear-hashing

2020-02-06 Thread Pedro Ferreira
Changeset: 0ae485c5a45e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0ae485c5a45e
Modified Files:
sql/server/rel_select.c
sql/test/miscellaneous/Tests/simple_selects.stable.out
sql/test/pg_regress/Tests/numeric_big.stable.err
sql/test/pg_regress/Tests/numeric_big.stable.err.int128
Branch: default
Log Message:

Merged with linear-hashing


diffs (189 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -164,7 +164,7 @@ static sql_rel *
 rel_orderby(mvc *sql, sql_rel *l)
 {
sql_rel *rel = rel_create(sql->sa);
-   if(!rel)
+   if (!rel)
return NULL;
 
assert(l->op == op_project && !l->r);
@@ -272,7 +272,7 @@ rel_with_query(sql_query *query, symbol 
symbol *next = d->next->data.sym;
sql_rel *rel;
 
-   if(!stack_push_frame(sql, "WITH"))
+   if (!stack_push_frame(sql, "WITH"))
return sql_error(sql, 02, SQLSTATE(HY013) MAL_MALLOC_FAIL);
/* first handle all with's (ie inlined views) */
for (d = d->data.lval->h; d; d = d->next) {
@@ -290,7 +290,7 @@ rel_with_query(sql_query *query, symbol 
stack_pop_frame(sql);
return NULL;
}
-   if(!stack_push_rel_view(sql, name, nrel)) {
+   if (!stack_push_rel_view(sql, name, nrel)) {
stack_pop_frame(sql);
return sql_error(sql, 02, SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
}
@@ -645,9 +645,9 @@ rel_named_table_function(sql_query *quer
for (m = sf->func->ops->h; m; m = m->next, i++) {
sql_arg *func_arg = m->data;
sql_exp *proj_parameter = (sql_exp*) 
list_fetch(rel->exps, i);
-   if(proj_parameter) {
+   if (proj_parameter) {
sql_arg *prep_arg = (sql_arg*) 
list_fetch(sql->params, proj_parameter->flag);
-   if(prep_arg && !prep_arg->type.type)
+   if (prep_arg && !prep_arg->type.type)
prep_arg->type = func_arg->type;
}
}
@@ -4469,7 +4469,7 @@ calculate_window_bound(sql_query *query,
return sql_error(sql, 02, SQLSTATE(42000) 
"Values on %s boundary aren't decimals while on input are", bound_desc);
if (bclass != EC_SEC && iet->type->eclass == EC_TIME) {
char *err = subtype2string(iet);
-   if(!err)
+   if (!err)
return sql_error(sql, 02, 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
(void) sql_error(sql, 02, SQLSTATE(42000) "For 
%s input the %s boundary must be an interval type up to the day", err, 
bound_desc);
_DELETE(err);
@@ -4671,16 +4671,13 @@ rel_rankop(sql_query *query, sql_rel **r
distinct = dn->next->data.i_val;
if (!dl || is_ntile) { /* pass an input column for analytic 
functions that don't require it */
in = rel_first_column(sql, p);
-   if (is_atom(in->type)) {
-   in = exp_copy(sql, in);
-   } else {
-   if (!exp_name(in))
-   exp_label(sql->sa, in, ++sql->label);
-   in = exp_ref(sql->sa, in);
-   }
if (!in)
return NULL;
+   if (!exp_name(in))
+   exp_label(sql->sa, in, ++sql->label);
+   in = exp_ref(sql->sa, in);
append(fargs, in);
+   in = exp_ref_save(sql, in);
nfargs++;
}
if (dl)
@@ -4832,68 +4829,68 @@ rel_rankop(sql_query *query, sql_rel **r
   *rend = wend->data.lval->h->data.sym;
int excl = d->next->next->next->data.i_val;
frame_type = d->next->next->data.i_val;
-   sql_exp *ie = obe ? exp_copy(sql, obe->t->data) : in;
-
-   if(!supports_frames)
+   sql_exp *ie = obe ? exp_ref(sql->sa, (sql_exp*) obe->t->data) : 
in;
+
+   if (!supports_frames)
return sql_error(sql, 02, SQLSTATE(42000) "OVER: frame 
extend only possible with aggregation and first_value, last_value and nth_value 
functions");
-   if(!obe && frame_type == FRAME_GROUPS)
+   if (!obe && frame_type == FRAME_GROUPS)
return sql_error(sql, 02, SQLSTATE(42000) "GROUPS frame 
requires an order by expre

MonetDB: default - Merged with linear-hashing

2020-02-07 Thread Pedro Ferreira
Changeset: a353d519760b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a353d519760b
Modified Files:
sql/rel.txt
sql/server/rel_exp.c
sql/server/rel_exp.h
sql/server/rel_optimizer.c
sql/server/rel_select.c
sql/server/rel_unnest.c
Branch: default
Log Message:

Merged with linear-hashing


diffs (246 lines):

diff --git a/sql/rel.txt b/sql/rel.txt
--- a/sql/rel.txt
+++ b/sql/rel.txt
@@ -146,6 +146,8 @@ e_aggr
-> ffunc / aggr
 for aggr
-> flag DISTINCT and NO_NIL could be set
+for window functions
+   -> r contains a list with two values: the first is a list with the 
partition by expressions, and the second a list with order by expressions
 
 e_column
-> rname alias for the relation (i.e., alias of ->l, used by higher 
expressions)
@@ -155,7 +157,6 @@ e_column
-> rexpression name
-> type 
 
-   
 e_psm
-> flag
psm_declare name 
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -22,7 +22,7 @@
 #include "blob.h"
 
 comp_type
-compare_str2type( char *compare_op)
+compare_str2type(const char *compare_op)
 {
comp_type type = cmp_filter;
 
@@ -243,7 +243,7 @@ exp_in_func(mvc *sql, sql_exp *le, sql_e
 }
 
 sql_exp *
-exp_compare_func(mvc *sql, sql_exp *le, sql_exp *re, sql_exp *oe, char 
*compareop, int quantifier)
+exp_compare_func(mvc *sql, sql_exp *le, sql_exp *re, sql_exp *oe, const char 
*compareop, int quantifier)
 {
sql_subfunc *cmp_func = NULL;
sql_exp *e;
@@ -789,7 +789,7 @@ exp_rel(mvc *sql, sql_rel *rel)
 }
 
 sql_exp *
-exp_exception(sql_allocator *sa, sql_exp *cond, char* error_message)
+exp_exception(sql_allocator *sa, sql_exp *cond, const char *error_message)
 {
sql_exp *e = exp_create(sa, e_psm);
 
@@ -2217,7 +2217,7 @@ exps_intern(list *exps)
return 0;
 }
 
-char *
+const char *
 compare_func( comp_type t, int anti )
 {
switch(t) {
diff --git a/sql/server/rel_exp.h b/sql/server/rel_exp.h
--- a/sql/server/rel_exp.h
+++ b/sql/server/rel_exp.h
@@ -23,7 +23,7 @@
 
 #define is_notequal_func(sf) (!sf->func->s && strcmp(sf->func->base.name, 
"<>") == 0)
 
-extern comp_type compare_str2type(char *compare_op);
+extern comp_type compare_str2type(const char *compare_op);
 extern comp_type swap_compare( comp_type t );
 extern comp_type range2lcompare( int r );
 extern comp_type range2rcompare( int r );
@@ -35,7 +35,7 @@ extern sql_exp *exp_filter(sql_allocator
 extern sql_exp *exp_or(sql_allocator *sa, list *l, list *r, int anti);
 extern sql_exp *exp_in(sql_allocator *sa, sql_exp *l, list *r, int cmptype);
 extern sql_exp *exp_in_func(mvc *sql, sql_exp *le, sql_exp *vals, int 
anyequal, int is_tuple);
-extern sql_exp *exp_compare_func(mvc *sql, sql_exp *le, sql_exp *re, sql_exp 
*oe, char *compareop, int quantifier);
+extern sql_exp *exp_compare_func(mvc *sql, sql_exp *le, sql_exp *re, sql_exp 
*oe, const char *compareop, int quantifier);
 
 #define exp_fromtype(e)((list*)e->r)->h->data
 #define exp_totype(e)  ((list*)e->r)->h->next->data
@@ -92,7 +92,7 @@ extern sql_exp * exp_var(sql_allocator *
 extern sql_exp * exp_table(sql_allocator *sa, const char *name, sql_table *t, 
int level);
 extern sql_exp * exp_return(sql_allocator *sa, sql_exp *val, int level);
 extern sql_exp * exp_while(sql_allocator *sa, sql_exp *cond, list *stmts);
-extern sql_exp * exp_exception(sql_allocator *sa, sql_exp *cond, char* 
error_message);
+extern sql_exp * exp_exception(sql_allocator *sa, sql_exp *cond, const char 
*error_message);
 extern sql_exp * exp_if(sql_allocator *sa, sql_exp *cond, list *if_stmts, list 
*else_stmts);
 extern sql_exp * exp_rel(mvc *sql, sql_rel * r);
 
@@ -173,7 +173,7 @@ extern void exps_fix_card( list *exps, u
 extern void exps_setcard( list *exps, unsigned int card);
 extern int exps_intern(list *exps);
 
-extern char *compare_func( comp_type t, int anti );
+extern const char *compare_func( comp_type t, int anti );
 extern int is_identity( sql_exp *e, sql_rel *r);
 
 extern atom *exp_flatten(mvc *sql, sql_exp *e);
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -3413,7 +3413,6 @@ exp_simplify_math( mvc *sql, sql_exp *e,
 static sql_rel *
 rel_simplify_math(int *changes, mvc *sql, sql_rel *rel) 
 {
-   
if ((is_project(rel->op) || (rel->op == op_ddl && rel->flag == 
ddl_psm)) && rel->exps) {
list *exps = rel->exps;
node *n;
@@ -3444,6 +3443,66 @@ rel_simplify_math(int *changes, mvc *sql
 }
 
 static sql_rel *
+rel_push_down_bounds(int *changes, mvc *sql, sql_rel *rel) 
+{
+   if (is_simple_project(rel->op) && rel->exps) {
+   list *exps = rel->exps;
+   node *n;
+
+   for (n = exps->h; n ; n = n->next) { 
+   sql_exp *e = n->data;
+ 

MonetDB: default - Merged with linear-hashing

2020-02-09 Thread Pedro Ferreira
Changeset: f926113c24fe for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f926113c24fe
Added Files:
sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.sql
sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.stable.err
sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.stable.out
Modified Files:
gdk/gdk_cand.c
sql/backends/monet5/sql_cat.c
sql/server/rel_optimizer.c
sql/test/merge-partitions/Tests/mergepart01.stable.err
sql/test/merge-partitions/Tests/mergepart01.stable.out
sql/test/merge-partitions/Tests/mergepart05.stable.err
sql/test/merge-partitions/Tests/mergepart07.stable.err
sql/test/merge-partitions/Tests/mergepart18.stable.err
sql/test/merge-partitions/Tests/mergepart19.stable.err
sql/test/mergetables/Tests/All
sql/test/mergetables/Tests/addtable.stable.err
sql/test/mergetables/Tests/doubletable.stable.err
sql/test/subquery/Tests/subquery3.sql
sql/test/subquery/Tests/subquery3.stable.err
sql/test/subquery/Tests/subquery3.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 609 to 300 lines):

diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c
--- a/gdk/gdk_cand.c
+++ b/gdk/gdk_cand.c
@@ -393,11 +393,6 @@ canditer_init(struct canditer *ci, BAT *
ci->oids = (const oid *) s->theap.base;
ci->seq = ci->oids[0];
ci->noids = cnt;
-   if (ci->oids[ci->noids - 1] - ci->oids[0] == ci->noids - 1) {
-   /* actually dense */
-   ci->tpe = cand_dense;
-   ci->oids = NULL;
-   }
} else {
/* materialized dense: no exceptions */
ci->tpe = cand_dense;
@@ -405,47 +400,34 @@ canditer_init(struct canditer *ci, BAT *
switch (ci->tpe) {
case cand_materialized:
if (b != NULL) {
-   if (ci->oids[ci->noids - 1] < b->hseqbase) {
+   BUN p = binsearchcand(ci->oids, cnt - 1, b->hseqbase);
+   /* p == cnt means candidate list is completely
+* before b */
+   ci->offset = p;
+   ci->oids += p;
+   cnt -= p;
+   if (cnt > 0) {
+   cnt = binsearchcand(ci->oids, cnt  - 1,
+   b->hseqbase + BATcount(b));
+   /* cnt == 0 means candidate list is
+* completely after b */
+   }
+   if (cnt == 0) {
+   /* no overlap */
*ci = (struct canditer) {
.tpe = cand_dense,
.s = s,
};
return 0;
}
-   if (ci->oids[0] < b->hseqbase) {
-   BUN lo = 0;
-   BUN hi = cnt - 1;
-   const oid o = b->hseqbase;
-   /* loop invariant:
-* ci->oids[lo] < o <= ci->oids[hi] */
-   while (hi - lo > 1) {
-   BUN mid = (lo + hi) / 2;
-   if (ci->oids[mid] >= o)
-   hi = mid;
-   else
-   lo = mid;
-   }
-   ci->offset = hi;
-   cnt -= hi;
-   ci->oids += hi;
-   ci->seq = ci->oids[0];
+   ci->seq = ci->oids[0];
+   ci->noids = cnt;
+   if (ci->oids[cnt - 1] - ci->seq == cnt - 1) {
+   /* actually dense */
+   ci->tpe = cand_dense;
+   ci->oids = NULL;
+   ci->noids = 0;
}
-   if (ci->oids[cnt - 1] >= b->hseqbase + BATcount(b)) {
-   BUN lo = 0;
-   BUN hi = cnt - 1;
-   const oid o = b->hseqbase + BATcount(b);
-   /* loop invariant:
-* ci->oids[lo] < o <= ci->oids[hi] */
-   while (hi - lo > 1) {
-   BUN mid = (lo + hi) / 2;
-   if (ci->oids[mid] >= o)
-   hi = mid;
-

MonetDB: default - Merged with linear-hashing

2020-02-11 Thread Pedro Ferreira
Changeset: b4f90020ff3f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b4f90020ff3f
Modified Files:
configure.ag
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_execute.c
sql/backends/monet5/sql_gencode.c
sql/common/sql_types.c
sql/common/sql_types.h
sql/server/rel_select.c
sql/server/rel_unnest.c
sql/server/sql_partition.c
sql/storage/bat/bat_storage.c
sql/storage/sql_storage.h
sql/storage/store.c
sql/test/BugTracker-2010/Tests/prepare_stmt.Bug-2533.Bug-2534.stable.err
sql/test/BugTracker/Tests/bind_with_cast.SF-1720934.stable.err
sql/test/subquery/Tests/subquery3.sql
sql/test/subquery/Tests/subquery3.stable.err
sql/test/subquery/Tests/subquery3.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 1068 to 300 lines):

diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -1147,7 +1147,7 @@ AS_VAR_IF([have_bz2], [no], [], [
[AC_SUBST([PKG_BZIP2], [bzip2])])
AS_VAR_IF([have_bz2], [yes],
[AC_DEFINE([HAVE_LIBBZ2], 1, [Define if you have the bz2 
library])])])
-AM_CONDITIONAL([HAVE_LIBBZ2], [test x"$have_libbz2" != xno])
+AM_CONDITIONAL([HAVE_LIBBZ2], [test x"$have_bz2" != xno])
 
 
 
@@ -1556,12 +1556,12 @@ AC_ARG_WITH([lzma],
[include lzma support (default=yes)])],
[have_lzma=$withval])
 AS_VAR_IF([have_lzma], [no], [], [
-   PKG_CHECK_MODULES([liblzma], [liblzma], [have_liblzma=yes], 
[have_liblzma=no; why_not_liblzma="(liblzma not found, install xz-libs and 
xz-devel)"])
-   AS_VAR_IF([have_liblzma], [yes], [
+   PKG_CHECK_MODULES([liblzma], [liblzma], [have_lzma=yes], [have_lzma=no; 
why_not_liblzma="(liblzma not found, install xz-libs and xz-devel)"])
+   AS_VAR_IF([have_lzma], [yes], [
AC_SUBST([PKG_LIBLZMA], [liblzma])])
-   AS_VAR_IF([have_liblzma], [yes], [
+   AS_VAR_IF([have_lzma], [yes], [
AC_DEFINE([HAVE_LIBLZMA], 1, [Define if you have the lzma 
library])])])
-AM_CONDITIONAL([HAVE_LIBLZMA], [test x"$have_liblzma" != xno])
+AM_CONDITIONAL([HAVE_LIBLZMA], [test x"$have_lzma" != xno])
 
 org_have_valgrind=no
 have_valgrind=$org_have_valgrind
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -1694,10 +1694,11 @@ rel2bin_table(backend *be, sql_rel *rel,
nme = number2name(name, sizeof(name), ++sql->remote);
 
l = rel2bin_args(be, rel->l, sa_list(sql->sa));
-   if(!l)
+   if (!l)
return NULL;
sub = stmt_list(be, l);
-   sub = stmt_func(be, sub, sa_strdup(sql->sa, nme), rel->l, 0);
+   if (!(sub = stmt_func(be, sub, sa_strdup(sql->sa, nme), rel->l, 
0)))
+   return NULL;
fr = rel->l;
l = sa_list(sql->sa);
for(i = 0, n = rel->exps->h; n; n = n->next, i++ ) {
diff --git a/sql/backends/monet5/sql_execute.c 
b/sql/backends/monet5/sql_execute.c
--- a/sql/backends/monet5/sql_execute.c
+++ b/sql/backends/monet5/sql_execute.c
@@ -953,7 +953,7 @@ RAstatement2(Client cntxt, MalBlkPtr mb,
if (rel)
rel = sql_processrelation(m, rel, 0);
if (!rel || monet5_create_relational_function(m, *mod, *nme, rel, NULL, 
ops, 0) < 0)
-   throw(SQL, "sql.register", SQLSTATE(42000) "Cannot register 
%s", buf);
+   throw(SQL, "sql.register", SQLSTATE(42000) "Cannot register %s: 
%s", buf, m->errstr);
rel_destroy(rel);
sqlcleanup(m, 0);
return msg;
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -145,15 +145,19 @@ static int
 
backup = c->curprg;
curPrg = c->curprg = newFunction(putName(mod), putName(name), 
FUNCTIONsymbol);
-   if( curPrg == NULL)
+   if( curPrg == NULL) {
+   sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
return -1;
+   }
 
curBlk = c->curprg->def;
curInstr = getInstrPtr(curBlk, 0);
 
curInstr = relational_func_create_result(m, curBlk, curInstr, r);
-   if( curInstr == NULL)
+   if( curInstr == NULL) {
+   sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
return -1;
+   }
setVarUDFtype(curBlk, 0);
 
/* ops */
@@ -235,6 +239,7 @@ static int
c->curprg->def->errors = msg;
}
if (c->curprg->def->errors) {
+   sql_error(m, 003, SQLSTATE(42000) "Internal error while 
compiling statement: %s", c->curprg->def->errors);
freeSymbol(curPrg);
res = -1;
}
@@ -252,17 +257,14

MonetDB: default - Merged with linear-hashing

2020-02-11 Thread Pedro Ferreira
Changeset: bf1a803ee260 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bf1a803ee260
Modified Files:
.hgtags
MonetDB.spec
NT/monetdb_config.h.in
NT/rules.msc
clients/mapilib/mapi.rc
clients/odbc/driver/driver.rc
clients/odbc/winsetup/setup.rc
configure.ag
debian/changelog
gdk/libbat.rc
libversions
monetdb5/tools/libmonetdb5.rc
sql/server/rel_select.c
sql/storage/store.c
sql/test/BugTracker-2018/Tests/prepared-statement-with-udf.Bug-6650.sql

sql/test/BugTracker-2018/Tests/prepared-statement-with-udf.Bug-6650.stable.out
vertoo.data
Branch: default
Log Message:

Merged with linear-hashing


diffs (184 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -750,3 +750,5 @@ e0719bdebf32967ca0a0043f556b3f48f93e0ce0
 8d4258444e2a0a809468fb85be7999a407d47e04 Nov2019_9
 e0719bdebf32967ca0a0043f556b3f48f93e0ce0 Nov2019_SP1_release
 8d4258444e2a0a809468fb85be7999a407d47e04 Nov2019_SP1_release
+c35ea84b568b792c5fd073f6a1e1a24372de0e20 Nov2019_11
+c35ea84b568b792c5fd073f6a1e1a24372de0e20 Nov2019_SP2_release
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -105,7 +105,7 @@ Group: Applications/Databases
 License: MPLv2.0
 URL: https://www.monetdb.org/
 BugURL: https://bugs.monetdb.org/
-Source: 
https://www.monetdb.org/downloads/sources/Nov2019-SP1/%{name}-%{version}.tar.bz2
+Source: 
https://www.monetdb.org/downloads/sources/Nov2019-SP2/%{name}-%{version}.tar.bz2
 
 # we need systemd for the _unitdir macro to exist
 # we need checkpolicy and selinux-policy-devel for the SELinux policy
@@ -941,6 +941,15 @@ fi
 %postun -p /sbin/ldconfig
 
 %changelog
+* Tue Feb 11 2020 Sjoerd Mullender  - 11.35.11-20200211
+- Rebuilt.
+- BZ#6805: Using the cascade operator in a drop table statement ends in
+  an exit from the Monetdb shell.
+- BZ#6807: Median_avg and quantile_avg ignore NULL values
+- BZ#6815: query with ifthenelse() crashes mserver5
+- BZ#6816: Monetdb Crashes on INSERT statement after ALTER statement in
+  another connection
+
 * Wed Dec 18 2019 Sjoerd Mullender  - 11.35.9-20191218
 - Rebuilt.
 - BZ#6804: DNS resolution of 0.0.0.0 fails on recent Ubuntus
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,15 @@
+monetdb (11.35.11) unstable; urgency=low
+
+  * Rebuilt.
+  * BZ#6805: Using the cascade operator in a drop table statement ends in
+an exit from the Monetdb shell.
+  * BZ#6807: Median_avg and quantile_avg ignore NULL values
+  * BZ#6815: query with ifthenelse() crashes mserver5
+  * BZ#6816: Monetdb Crashes on INSERT statement after ALTER statement in
+another connection
+
+ -- Sjoerd Mullender   Tue, 11 Feb 2020 14:07:49 +0100
+
 monetdb (11.35.9) unstable; urgency=low
 
   * Rebuilt.
diff --git a/libversions b/libversions
--- a/libversions
+++ b/libversions
@@ -36,13 +36,13 @@
 
 # version of the GDK library (subdirectory gdk; also includes
 # common/options and common/utils)
-GDK_VERSION=19:2:0
+GDK_VERSION=19:3:0
 
 # version of the MAPI library (subdirectory clients/mapilib)
-MAPI_VERSION=12:2:0
+MAPI_VERSION=12:3:0
 
 # version of the MONETDB5 library (subdirectory monetdb5, not including extras 
or sql)
-MONETDB5_VERSION=28:3:0
+MONETDB5_VERSION=28:4:0
 
 # version of the STREAM library (subdirectory common/stream)
 STREAM_VERSION=13:3:0
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -675,10 +675,10 @@ rel_named_table_function(sql_query *quer
}
 
if (sq) {
-   for (node *n = sq->exps->h, *m = sf->res->h ; n && m ; n = 
n->next, m = m->next) {
+   for (node *n = sq->exps->h, *m = sf->func->ops->h ; n && m ; n 
= n->next, m = m->next) {
sql_exp *e = (sql_exp*) n->data;
-   sql_subtype *t = (sql_subtype*) m->data;
-   if (!exp_subtype(e) && rel_set_type_param(sql, t, sq, 
e, 0) < 0)
+   sql_arg *a = (sql_arg*) m->data;
+   if (!exp_subtype(e) && rel_set_type_param(sql, 
&(a->type), sq, e, 0) < 0)
return NULL;
}
}
@@ -6023,10 +6023,10 @@ rel_loader_function(sql_query *query, sy
return sql_error(sql, 02, SQLSTATE(42000) "SELECT: no such 
operator '%s'", fname);
 
if (sq) {
-   for (node *n = sq->exps->h, *m = sf->res->h ; n && m ; n = 
n->next, m = m->next) {
+   for (node *n = sq->exps->h, *m = sf->func->ops->h ; n && m ; n 
= n->next, m = m->next) {
sql_exp *e = (sql_exp*) n->data;
-   sql_subtype *t = (sql_subtype*) m->data;
-   if (!exp_subtype(e) && rel_set_type_param(sql, t, sq, 
e, 0) < 0)
+   sql_arg *a = (sql_arg*) m->data;
+ 

MonetDB: default - Merged with linear-hashing

2020-02-12 Thread Pedro Ferreira
Changeset: 1bf5f938f502 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1bf5f938f502
Modified Files:
.hgtags
MonetDB.spec
NT/monetdb_config.h.in
NT/rules.msc
clients/mapilib/mapi.rc
clients/odbc/driver/driver.rc
clients/odbc/winsetup/setup.rc
configure.ag
debian/changelog
gdk/libbat.rc
monetdb5/tools/libmonetdb5.rc
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_optimizer.c

sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.py
vertoo.data
Branch: default
Log Message:

Merged with linear-hashing


diffs (209 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -752,3 +752,6 @@ e0719bdebf32967ca0a0043f556b3f48f93e0ce0
 8d4258444e2a0a809468fb85be7999a407d47e04 Nov2019_SP1_release
 c35ea84b568b792c5fd073f6a1e1a24372de0e20 Nov2019_11
 c35ea84b568b792c5fd073f6a1e1a24372de0e20 Nov2019_SP2_release
+4eb6068f63cf87fc6996daed59fbcc917c8b2881 Nov2019_13
+c35ea84b568b792c5fd073f6a1e1a24372de0e20 Nov2019_SP2_release
+4eb6068f63cf87fc6996daed59fbcc917c8b2881 Nov2019_SP2_release
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -941,6 +941,9 @@ fi
 %postun -p /sbin/ldconfig
 
 %changelog
+* Wed Feb 12 2020 Sjoerd Mullender  - 11.35.13-20200212
+- Rebuilt.
+
 * Tue Feb 11 2020 Sjoerd Mullender  - 11.35.11-20200211
 - Rebuilt.
 - BZ#6805: Using the cascade operator in a drop table statement ends in
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+monetdb (11.35.13) unstable; urgency=low
+
+  * Rebuilt.
+
+ -- Sjoerd Mullender   Wed, 12 Feb 2020 11:03:15 +0100
+
 monetdb (11.35.11) unstable; urgency=low
 
   * Rebuilt.
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -203,6 +203,7 @@ static int
}
}
if (curBlk->errors) {
+   sql_error(m, 003, SQLSTATE(42000) "Internal error while 
compiling statement: %s", curBlk->errors);
freeSymbol(curPrg);
return -1;
}
@@ -762,8 +763,10 @@ backend_callinline(backend *be, Client c
}
}
c->curprg->def = curBlk;
-   if (curBlk->errors)
+   if (curBlk->errors) {
+   sql_error(m, 003, SQLSTATE(42000) "Internal error while 
compiling statement: %s", curBlk->errors);
return -1;
+   }
return 0;
 }
 
@@ -935,8 +938,14 @@ backend_call(backend *be, Client c, cq *
}
}
}
-   if (!q || mb->errors)
+   if (!q) {
+   sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
return -1;
+   }
+   if (mb->errors) {
+   sql_error(m, 003, SQLSTATE(42000) "Internal error while 
compiling statement: %s", mb->errors);
+   return -1;
+   }
return 0;
 }
 
@@ -1227,7 +1236,6 @@ backend_create_sql_func(backend *be, sql
f->sql--;
return -1;
}
-   assert(r);
 
backup = c->curprg;
curPrg = c->curprg = newFunction(userRef, putName(f->base.name), 
FUNCTIONsymbol);
diff --git 
a/sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.py 
b/sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.py
--- 
a/sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.py
+++ 
b/sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.py
@@ -37,65 +37,66 @@ os.mkdir(os.path.join(farm_dir, 'node2')
 
 # node1 is the worker
 prt1 = freeport()
-prc1 = process.server(mapiport=prt1, dbname='node1', 
dbfarm=os.path.join(farm_dir, 'node1'), stdin=process.PIPE, 
stdout=process.PIPE, stderr=process.PIPE)
-conn1 = pymonetdb.connect(database='node1', port=prt1, autocommit=True)
+try:
+prc1 = process.server(mapiport=prt1, dbname='node1', 
dbfarm=os.path.join(farm_dir, 'node1'), stdin=process.PIPE, 
stdout=process.PIPE, stderr=process.PIPE)
+conn1 = pymonetdb.connect(database='node1', port=prt1, autocommit=True)
 
-q = "create table s1 (i int)"
-print(q); conn1.execute(q)
-q = "insert into s1 values (23), (42)"
-print(q); conn1.execute(q)
-q = "create table t1 (s varchar(10))"
-print(q); conn1.execute(q)
-q = "insert into t1 values ('abc'), ('efg')"
-print(q); conn1.execute(q)
+q = "create table s1 (i int)"
+print(q); conn1.execute(q)
+q = "insert into s1 values (23), (42)"
+print(q); conn1.execute(q)
+q = "create table t1 (s varchar(10))"
+print(q); conn1.execute(q)
+q = "insert into t1 values ('abc'), ('efg')"
+print(q); conn1.execute(q)
 
-# node2 is the master
-prt2 = freeport()
-prc2 = process.server(mapiport=prt2, dbname='node2', 
dbfarm=os.path.join(farm_dir, 'node2'), stdin=process.PIPE,

MonetDB: default - Merged with linear-hashing

2020-02-13 Thread Pedro Ferreira
Changeset: 75c12c463c50 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=75c12c463c50
Added Files:
sql/test/BugTracker-2020/Tests/alter-table-add-column.Bug-6816.py

sql/test/BugTracker-2020/Tests/alter-table-add-column.Bug-6816.stable.err

sql/test/BugTracker-2020/Tests/alter-table-add-column.Bug-6816.stable.out
sql/test/BugTracker-2020/Tests/analyze-stream-table.Bug-6817.sql
sql/test/BugTracker-2020/Tests/analyze-stream-table.Bug-6817.stable.err
sql/test/BugTracker-2020/Tests/analyze-stream-table.Bug-6817.stable.out
sql/test/BugTracker-2020/Tests/select-where-in-rtrim-crash.Bug-6818.sql

sql/test/BugTracker-2020/Tests/select-where-in-rtrim-crash.Bug-6818.stable.err

sql/test/BugTracker-2020/Tests/select-where-in-rtrim-crash.Bug-6818.stable.out
Removed Files:
sql/test/BugTracker-2020/Tests/alter-table-add-column-Bug-6816.py

sql/test/BugTracker-2020/Tests/alter-table-add-column-Bug-6816.stable.err

sql/test/BugTracker-2020/Tests/alter-table-add-column-Bug-6816.stable.out
Modified Files:
common/utils/mstring.h
gdk/gdk.h
gdk/gdk_bbp.c
monetdb5/mal/mal_instruction.c
sql/backends/monet5/sql_statistics.c
sql/server/rel_select.c
sql/storage/bat/bat_logger.c
sql/test/BugTracker-2009/Tests/lost_update.SF-2790020.py

sql/test/BugTracker-2017/Tests/statistics_nils_not_eq_zero.Bug-6331.stable.err

sql/test/BugTracker-2017/Tests/statistics_nils_not_eq_zero.Bug-6331.stable.out
sql/test/BugTracker-2020/Tests/All
sql/test/analytics/Tests/analytics00.sql
sql/test/analytics/Tests/analytics00.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 764 to 300 lines):

diff --git a/common/utils/mstring.h b/common/utils/mstring.h
--- a/common/utils/mstring.h
+++ b/common/utils/mstring.h
@@ -23,7 +23,6 @@ strcpy_len(char *restrict dst, const cha
return i;
}
dst[n - 1] = 0;
-   return n-1;
}
return strlen(src);
 }
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1534,10 +1534,14 @@ typedef struct {
BAT *cache; /* if loaded: BAT* handle */
char *logical;  /* logical name (may point at bak) */
char bak[16];   /* logical name backup (tmp_%o) */
+   BAT *desc;  /* the BAT descriptor */
+   char *options;  /* A string list of options */
+#if SIZEOF_VOID_P == 4
+   char physical[20];  /* dir + basename for storage */
+#else
+   char physical[24];  /* dir + basename for storage */
+#endif
bat next;   /* next BBP slot in linked list */
-   BAT *desc;  /* the BAT descriptor */
-   char physical[20];  /* dir + basename for storage */
-   str options;/* A string list of options */
int refs;   /* in-memory references on which the loaded 
status of a BAT relies */
int lrefs;  /* logical references on which the existence of 
a BAT relies */
volatile unsigned status; /* status mask used for spin locking */
@@ -1545,19 +1549,20 @@ typedef struct {
 } BBPrec;
 
 gdk_export bat BBPlimit;
+#if SIZEOF_VOID_P == 4
 #define N_BBPINIT  1000
-#if SIZEOF_VOID_P == 4
 #define BBPINITLOG 11
 #else
+#define N_BBPINIT  1
 #define BBPINITLOG 14
 #endif
 #define BBPINIT(1 << BBPINITLOG)
 /* absolute maximum number of BATs is N_BBPINIT * BBPINIT
  * this also gives the longest possible "physical" name and "bak" name
- * of a BAT: the "bak" name is "tmp_%o", so at most 12 + \0 bytes on
+ * of a BAT: the "bak" name is "tmp_%o", so at most 14 + \0 bytes on
  * 64 bit architecture and 11 + \0 on 32 bit architecture; the
  * physical name is a bit more complicated, but the longest possible
- * name is 17 + \0 bytes (16 + \0 on 32 bits) */
+ * name is 22 + \0 bytes (16 + \0 on 32 bits) */
 gdk_export BBPrec *BBP[N_BBPINIT];
 
 /* fast defines without checks; internal use only  */
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1046,7 +1046,7 @@ BBPreadEntries(FILE *fp, unsigned bbpver
uint64_t batid;
uint16_t status;
char headname[129];
-   char filename[20];
+   char filename[sizeof(BBP_physical(0))];
unsigned int properties;
int nread, n;
char *s, *options = NULL;
@@ -1054,8 +1054,6 @@ BBPreadEntries(FILE *fp, unsigned bbpver
uint64_t count, capacity, base = 0;
int Thashash;
 
-   static_assert(sizeof(BBP_physical(0)) == sizeof(filename),
-   "filename should be same size as BBPrec.physical");
if ((s = strchr(buf, '\r')) != NULL

MonetDB: default - Merged with linear-hashing

2020-02-14 Thread Pedro Ferreira
Changeset: d086c0e6d032 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d086c0e6d032
Modified Files:
gdk/gdk_bbp.c
sql/server/rel_unnest.c
sql/storage/store.c
sql/test/BugTracker-2020/Tests/analyze-stream-table.Bug-6817.sql
sql/test/BugTracker-2020/Tests/analyze-stream-table.Bug-6817.stable.err
sql/test/BugTracker-2020/Tests/analyze-stream-table.Bug-6817.stable.out
sql/test/BugTracker-2020/Tests/select-where-in-rtrim-crash.Bug-6818.sql

sql/test/BugTracker-2020/Tests/select-where-in-rtrim-crash.Bug-6818.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (181 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1415,6 +1415,15 @@ BBPinit(void)
unsigned bbpversion = 0;
int i;
 
+   /* the maximum number of BATs allowed in the system and the
+* size of the "physical" array are linked in a complicated
+* manner.  The expression below shows the relationship */
+   static_assert((uint64_t) N_BBPINIT * BBPINIT < (UINT64_C(1) << (3 * 
((sizeof(BBP[0][0].physical) + 2) * 2 / 5))), "\"physical\" array in BBPrec is 
too small");
+   /* similarly, the maximum number of BATs allowed also has a
+* (somewhat simpler) relation with the size of the "bak"
+* array */
+   static_assert((uint64_t) N_BBPINIT * BBPINIT < (UINT64_C(1) << (3 * 
(sizeof(BBP[0][0].bak) - 5))), "\"bak\" array in BBPrec is too small");
+
if (!GDKinmemory()) {
str bbpdirstr, backupbbpdirstr;
 
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -1640,7 +1640,7 @@ rewrite_simplify(mvc *sql, sql_rel *rel)
if (!rel)
return rel;
 
-   if ((is_select(rel->op) || is_join(rel->op)) && !list_empty(rel->exps))
+   if ((is_select(rel->op) || is_join(rel->op) || is_semi(rel->op)) && 
!list_empty(rel->exps))
rel->exps = exps_simplify_exp(sql, rel->exps);
return rel;
 }
@@ -1773,7 +1773,7 @@ rewrite_aggregates(mvc *sql, sql_rel *re
 static sql_rel *
 rewrite_or_exp(mvc *sql, sql_rel *rel)
 {
-   if ((is_select(rel->op) || is_join(rel->op)) && !list_empty(rel->exps)) 
{
+   if ((is_select(rel->op) || is_join(rel->op) || is_semi(rel->op)) && 
!list_empty(rel->exps)) {
for(node *n=rel->exps->h; n; n=n->next) {
sql_exp *e = n->data;
 
@@ -2561,7 +2561,7 @@ rewrite_compare_exps(mvc *sql, list *exp
 static sql_rel *
 rewrite_compare_exp(mvc *sql, sql_rel *rel)
 {
-   if ((is_select(rel->op) || is_join(rel->op)) && !list_empty(rel->exps))
+   if ((is_select(rel->op) || is_join(rel->op) || is_semi(rel->op)) && 
!list_empty(rel->exps))
rel->exps = rewrite_compare_exps(sql, rel->exps);
return rel;
 }
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -5613,7 +5613,7 @@ sql_trans_add_table(sql_trans *tr, sql_t
p->t = mt;
base_init(tr->sa, &p->base, pt->base.id, TR_NEW, pt->base.name);
cs_add(&mt->members, p, TR_NEW);
-   mt->s->base.wtime = mt->base.wtime = pt->s->base.wtime = pt->base.wtime 
= tr->wtime = tr->wstime;
+   mt->s->base.wtime = mt->base.wtime = pt->s->base.wtime = pt->base.wtime 
= p->base.wtime = tr->wtime = tr->wstime;
table_funcs.table_insert(tr, sysobj, &mt->base.id, p->base.name, 
&p->base.id);
return mt;
 }
@@ -5917,7 +5917,7 @@ sql_trans_del_table(sql_trans *tr, sql_t
pt->p = NULL;
table_funcs.table_delete(tr, sysobj, obj_oid);
 
-   mt->s->base.wtime = mt->base.wtime = pt->s->base.wtime = pt->base.wtime 
= tr->wtime = tr->wstime;
+   mt->s->base.wtime = mt->base.wtime = pt->s->base.wtime = pt->base.wtime 
= p->base.wtime = tr->wtime = tr->wstime;
 
if (drop_action == DROP_CASCADE)
sql_trans_drop_table(tr, mt->s, pt->base.id, drop_action);
diff --git a/sql/test/BugTracker-2020/Tests/analyze-stream-table.Bug-6817.sql 
b/sql/test/BugTracker-2020/Tests/analyze-stream-table.Bug-6817.sql
--- a/sql/test/BugTracker-2020/Tests/analyze-stream-table.Bug-6817.sql
+++ b/sql/test/BugTracker-2020/Tests/analyze-stream-table.Bug-6817.sql
@@ -1,25 +1,30 @@
 delete from statistics;
 select count(*) from statistics;
 
-CREATE STREAM TABLE "sys"."strt" (
+CREATE SCHEMA "ttt";
+
+CREATE TABLE "ttt"."a"("id" INTEGER);
+
+CREATE STREAM TABLE "ttt"."strt" (
 "id" INTEGER   NOT NULL,
 "nm" VARCHAR(123)  NOT NULL,
 CONSTRAINT "strt_id_pkey" PRIMARY KEY ("id")
 );
 
-select * from "sys"."strt";
+select * from "ttt"."strt";
 
-analyze "sys"."strt";
+analyze "ttt"."strt";
 -- Error: Table 'strt' is not persistent   SQLState:  42S02
 select (count(*) > 0) as has_rows from statistics;
 
-analyze sys; --not an error, skip stream table "strt"
+analyze ttt; --not 

MonetDB: default - Merged with linear-hashing

2020-02-17 Thread Pedro Ferreira
Changeset: b5f141bea920 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b5f141bea920
Added Files:
sql/test/BugTracker-2020/Tests/functions-not-persist.Bug-6819.py
sql/test/BugTracker-2020/Tests/functions-not-persist.Bug-6819.stable.err
sql/test/BugTracker-2020/Tests/functions-not-persist.Bug-6819.stable.out
Modified Files:
sql/server/rel_psm.c
sql/server/rel_schema.c
sql/test/BugTracker-2020/Tests/All
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 312 to 300 lines):

diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -919,36 +919,42 @@ rel_create_func(sql_query *query, dlist 
return sql_error(sql, 01, SQLSTATE(42000) 
"CREATE %s: failed to get restype", F);
}
if (body && LANG_EXT(lang)) {
-   char *lang_body = body->h->data.sval, *mod = NULL, 
*slang = NULL;
+   const char *lang_body = body->h->data.sval, *mod = 
"unknown", *slang = "Unknown";
switch (lang) {
-   case FUNC_LANG_R:
-   mod = "rapi";
-   slang = "R";
-   break;
-   case FUNC_LANG_C:
-   mod = "capi";
-   slang = "C";
-   break;
-   case FUNC_LANG_CPP:
-   mod = "capi";
-   slang = "CPP";
-   break;
-   case FUNC_LANG_J:
-   mod = "japi";
-   slang = "Javascript";
-   break;
-   case FUNC_LANG_PY:
-   case FUNC_LANG_PY3:
-   mod = "pyapi3";
-   slang = "Python";
-   break;
-   case FUNC_LANG_MAP_PY:
-   case FUNC_LANG_MAP_PY3:
-   mod = "pyapi3map";
-   slang = "Python";
-   break;
-   default:
-   assert(0);
+   case FUNC_LANG_R:
+   mod = "rapi";
+   slang = "R";
+   break;
+   case FUNC_LANG_C:
+   mod = "capi";
+   slang = "C";
+   break;
+   case FUNC_LANG_CPP:
+   mod = "capi";
+   slang = "CPP";
+   break;
+   case FUNC_LANG_J:
+   mod = "japi";
+   slang = "Javascript";
+   break;
+   case FUNC_LANG_PY:
+   mod = "pyapi";
+   slang = "Python";
+   break;
+   case FUNC_LANG_MAP_PY:
+   mod = "pyapimap";
+   slang = "Python";
+   break;
+   case FUNC_LANG_PY3:
+   mod = "pyapi3";
+   slang = "Python";
+   break;
+   case FUNC_LANG_MAP_PY3:
+   mod = "pyapi3map";
+   slang = "Python";
+   break;
+   default:
+   assert(0);
}
 
if (type == F_LOADER && !(lang == FUNC_LANG_PY || lang 
== FUNC_LANG_PY3))
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -435,7 +435,7 @@ column_option(
char buf[512] = {0};
 
if (!opt_name)
-   opt_name = column_constraint_name(sym, cs, t, buf, 512);
+   opt_name = column_constraint_name(sym, cs, t, buf, 
sizeof(buf));
res = column_constraint_type(sql, opt_name, sym, ss, t, cs);
}   break;
case SQL_DEFAULT: {
diff --git a/sql/test/BugTracker-2020/Tests/All 
b/sql/test/BugTracker-2020/Tests/All
--- a/sql/test/BugTracker-2020/Tests/All
+++ b/sql/test/BugTracker-2020/Tests/All
@@ -3,3 +3,4 @@ ifthenelse-crash.Bug-6

MonetDB: default - Merged with linear-hashing

2020-02-18 Thread Pedro Ferreira
Changeset: a9c8b842f3ed for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a9c8b842f3ed
Added Files:
sql/test/rename/Tests/rename12.stable.err
sql/test/rename/Tests/rename12.stable.out
Modified Files:
sql/server/sql_mvc.c
sql/storage/bat/bat_storage.c
sql/storage/sql_storage.h
sql/storage/store.c
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 565 to 300 lines):

diff --git a/sql/server/sql_mvc.c b/sql/server/sql_mvc.c
--- a/sql/server/sql_mvc.c
+++ b/sql/server/sql_mvc.c
@@ -1055,7 +1055,7 @@ mvc_bind_trigger(mvc *m, sql_schema *s, 
 }
 
 sql_type *
-mvc_create_type(mvc *sql, sql_schema * s, const char *name, int digits, int 
scale, int radix, const char *impl)
+mvc_create_type(mvc *sql, sql_schema *s, const char *name, int digits, int 
scale, int radix, const char *impl)
 {
sql_type *t = NULL;

@@ -1355,7 +1355,7 @@ mvc_create_column(mvc *m, sql_table *t, 
TRC_DEBUG(SQL_MVC, "Create column: %s %s %s\n", t->base.name, name, 
tpe->type->sqlname);
if (t->persistence == SQL_DECLARED_TABLE && (!t->s || 
strcmp(t->s->base.name, dt_schema))) 
/* declared tables should not end up in the catalog */
-   return create_sql_column(m->sa, t, name, tpe);
+   return create_sql_column(m->session->tr, t, name, tpe);
else
return sql_trans_create_column(m->session->tr, t, name, tpe);
 }
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -2822,7 +2822,7 @@ update_table(sql_trans *tr, sql_table *f
}
}
 
-   dup_sql_type(tr, ft->s, &(cc->type), &(oc->type));
+   dup_sql_type(tr->parent, ft->s, &(cc->type), &(oc->type));
oc->colnr = cc->colnr;
oc->null = cc->null;
oc->unique = cc->unique;
diff --git a/sql/storage/sql_storage.h b/sql/storage/sql_storage.h
--- a/sql/storage/sql_storage.h
+++ b/sql/storage/sql_storage.h
@@ -470,7 +470,7 @@ extern int sql_trans_check_dependency(sq
 extern list* sql_trans_owner_schema_dependencies(sql_trans *tr, sqlid id);
 
 extern sql_table *create_sql_table(sql_allocator *sa, const char *name, sht 
type, bit system, int persistence, int commit_action, bit properties);
-extern sql_column *create_sql_column(sql_allocator *sa, sql_table *t, const 
char *name, sql_subtype *tpe);
+extern sql_column *create_sql_column(sql_trans *tr, sql_table *t, const char 
*name, sql_subtype *tpe);
 extern sql_ukey *create_sql_ukey(sql_allocator *sa, sql_table *t, const char 
*nme, key_type kt);
 extern sql_fkey *create_sql_fkey(sql_allocator *sa, sql_table *t, const char 
*nme, key_type kt, sql_key *rkey, int on_delete, int on_update );
 extern sql_key *create_sql_kc(sql_allocator *sa, sql_key *k, sql_column *c);
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1549,7 +1549,9 @@ create_sql_table(sql_allocator *sa, cons
 void
 dup_sql_type(sql_trans *tr, sql_schema *os, sql_subtype *oc, sql_subtype *nc)
 {
-   *nc = *oc;
+   nc->digits = oc->digits;
+   nc->scale = oc->scale;
+   nc->type = oc->type;
if (nc->type->s) { /* user type */
sql_type *lt = NULL;
 
@@ -3407,6 +3409,8 @@ type_dup(sql_trans *tr, int flags, sql_t
t->bits = ot->bits;
t->localtype = ot->localtype;
t->s = s;
+   if (isNew(ot) && newFlagSet(flags) && tr->parent == gtrans)
+   removeNewFlag(ot);
return t;
 }
 
@@ -3453,11 +3457,13 @@ func_dup(sql_trans *tr, int flags, sql_f
}
f->s = s;
f->sa = sa;
+   if (isNew(of) && newFlagSet(flags) && tr->parent == gtrans)
+   removeNewFlag(of);
return f;
 }
 
 static sql_sequence *
-seq_dup(sql_trans *tr, int flags, sql_sequence *oseq, sql_schema * s)
+seq_dup(sql_trans *tr, int flags, sql_sequence *oseq, sql_schema *s)
 {
sql_allocator *sa = (newFlagSet(flags))?tr->parent->sa:tr->sa;
sql_sequence *seq = SA_ZNEW(sa, sql_sequence);
@@ -3471,6 +3477,8 @@ seq_dup(sql_trans *tr, int flags, sql_se
seq->cacheinc = oseq->cacheinc;
seq->cycle = oseq->cycle;
seq->s = s;
+   if (isNew(oseq) && newFlagSet(flags) && tr->parent == gtrans)
+   removeNewFlag(oseq);
return seq;
 }
 
@@ -3617,6 +3625,30 @@ trans_init(sql_trans *tr, backend_stack 
assert(0);
}
}
+   if (ps->seqs.set && s->seqs.set)
+   for (k = ps->seqs.set->h, l = s->seqs.set->h; k && l; k 
= k->next, l = l->next ) { 
+   sql_sequence *pt = k->data; /* parent 
transactions sequence */
+   sql_sequence *t = l->data; 

MonetDB: default - merged with linear-hashing

2020-02-18 Thread Niels Nes
Changeset: 1c2c1cbdd417 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1c2c1cbdd417
Modified Files:
sql/storage/store.c
Branch: default
Log Message:

merged with linear-hashing


diffs (12 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1552,7 +1552,7 @@ dup_sql_type(sql_trans *tr, sql_schema *
nc->digits = oc->digits;
nc->scale = oc->scale;
nc->type = oc->type;
-   if (nc->type->s) { /* user type */
+   if (os && nc->type->s) { /* user type */
sql_type *lt = NULL;
 
if (os->base.id == nc->type->s->base.id) {
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with linear-hashing

2020-02-19 Thread Pedro Ferreira
Changeset: 9791dfb0613e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9791dfb0613e
Modified Files:
sql/server/rel_exp.c
sql/test/miscellaneous/Tests/groupby_error.sql
sql/test/miscellaneous/Tests/groupby_error.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (114 lines):

diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -1593,7 +1593,7 @@ exp_is_true(mvc *sql, sql_exp *e)
}
}
if (e->type == e_cmp && e->flag == cmp_equal)
-   return (exp_is_true(sql, e->l) && exp_is_true(sql, e->r));
+   return (exp_is_true(sql, e->l) && exp_is_true(sql, e->r) && 
exp_match_exp(e->l, e->r));
return 0;
 }
 
diff --git a/sql/test/miscellaneous/Tests/groupby_error.sql 
b/sql/test/miscellaneous/Tests/groupby_error.sql
--- a/sql/test/miscellaneous/Tests/groupby_error.sql
+++ b/sql/test/miscellaneous/Tests/groupby_error.sql
@@ -6,14 +6,25 @@ SELECT parent."sys_id" FROM "kagami_dump
 
 DROP SCHEMA "kagami_dump" CASCADE;
 
-
 CREATE TABLE tab0(col0 INTEGER, col1 INTEGER, col2 INTEGER);
 INSERT INTO tab0 VALUES(97,1,99), (15,81,47), (87,21,10);
+CREATE TABLE tab1(col0 INTEGER, col1 INTEGER, col2 INTEGER);
+INSERT INTO tab1 VALUES (51,14,96), (85,5,59), (91,47,68);
 
 SELECT CAST(+ col1 * - col1 AS BIGINT) AS col2 FROM tab0 GROUP BY col2, col0, 
col1 HAVING + - col0 / - AVG ( ALL + col2 ) - - - AVG ( DISTINCT + col0 ) + 
col0 IS NULL;
 SELECT DISTINCT + 40 / + + col0 AS col2 FROM tab0 GROUP BY col0, col0, col2 
HAVING NOT ( NOT + - 80 BETWEEN NULL AND + - 73 ) OR NOT ( + col0 >= - COUNT ( 
* ) + - COUNT ( DISTINCT - col0 ) );
 SELECT ALL * FROM tab0 AS cor0 WHERE col2 NOT IN ( 22, 18, CAST ( NULL AS 
INTEGER ) + - 77 );
 
+SELECT * FROM tab0 AS cor0 WHERE NOT - 39 <> 11; --empty
+SELECT DISTINCT * FROM tab0 WHERE NOT - - 12 <> + + 96; --empty
+SELECT * FROM tab0 AS cor0 WHERE - 52 = + 32; --empty
+SELECT ALL * FROM tab0 WHERE 68 = - + 83; --empty
+
+SELECT 11 FROM tab1 AS cor0 LEFT JOIN tab0 ON 80 = 70;
+   -- 11
+   -- 11
+   -- 11
+
 prepare select col0 from tab0 where (?) in (select col0 from tab0);
 prepare select col0 from tab0 where (?,?) in (select col0,col1 from tab0);
 prepare select col0 from tab0 where (col1,col1) in (select col0,? from tab0);
@@ -46,6 +57,7 @@ prepare select ? is null from tab0; --er
 prepare select max(?); --error
 prepare select max(?) over (); --error
 
+drop table tab1;
 CREATE TABLE tab1(col0 INTEGER, col1 STRING);
 prepare select 1 from tab1 where (col0,col1) in (select ?,? from tab1);
 
diff --git a/sql/test/miscellaneous/Tests/groupby_error.stable.out 
b/sql/test/miscellaneous/Tests/groupby_error.stable.out
--- a/sql/test/miscellaneous/Tests/groupby_error.stable.out
+++ b/sql/test/miscellaneous/Tests/groupby_error.stable.out
@@ -71,6 +71,9 @@ stdout of test 'groupby_error` in direct
 #CREATE TABLE tab0(col0 INTEGER, col1 INTEGER, col2 INTEGER);
 #INSERT INTO tab0 VALUES(97,1,99), (15,81,47), (87,21,10);
 [ 3]
+#CREATE TABLE tab1(col0 INTEGER, col1 INTEGER, col2 INTEGER);
+#INSERT INTO tab1 VALUES (51,14,96), (85,5,59), (91,47,68);
+[ 3]
 #SELECT CAST(+ col1 * - col1 AS BIGINT) AS col2 FROM tab0 GROUP BY col2, col0, 
col1 HAVING + - col0 / - AVG ( ALL + col2 ) - - - AVG ( DISTINCT + col0 ) + 
col0 IS NULL;
 % sys. # table_name
 % col2 # name
@@ -86,6 +89,34 @@ stdout of test 'groupby_error` in direct
 % col0,col1,   col2 # name
 % int, int,int # type
 % 1,   1,  1 # length
+#SELECT * FROM tab0 AS cor0 WHERE NOT - 39 <> 11; --empty
+% sys.cor0,sys.cor0,   sys.cor0 # table_name
+% col0,col1,   col2 # name
+% int, int,int # type
+% 1,   1,  1 # length
+#SELECT DISTINCT * FROM tab0 WHERE NOT - - 12 <> + + 96; --empty
+% sys.tab0,sys.tab0,   sys.tab0 # table_name
+% col0,col1,   col2 # name
+% int, int,int # type
+% 1,   1,  1 # length
+#SELECT * FROM tab0 AS cor0 WHERE - 52 = + 32; --empty
+% sys.cor0,sys.cor0,   sys.cor0 # table_name
+% col0,col1,   col2 # name
+% int, int,int # type
+% 1,   1,  1 # length
+#SELECT ALL * FROM tab0 WHERE 68 = - + 83; --empty
+% sys.tab0,sys.tab0,   sys.tab0 # table_name
+% col0,col1,   col2 # name
+% int, int,int # type
+% 1,   1,  1 # length
+#SELECT 11 FROM tab1 AS cor0 LEFT JOIN tab0 ON 80 = 70;
+% . # table_name
+% single_value # name
+% tinyint # type
+% 2 # length
+[ 11   ]
+[ 11   ]
+[ 11   ]
 #prepare select col0 from tab0 where (?) in (select col0 from tab0);
 #prepare select col0 from tab0 where (?) in (select col0 from tab0);
 % .prepare,.prepare,   .prepare,   .prepare,   .prepare,   
.prepare # table_name
@@ -222,6 +253,7 @@ stdout of test 'groupby_error` in direct
 [ "tinyint",   1,  0,  "", "%1",   "%1"]
 [ "tinyint",   1,  0,  NULL,   NULL,   NULL]
 [ "tinyint",   1,  0, 

MonetDB: default - Merged with linear-hashing

2020-02-20 Thread Pedro Ferreira
Changeset: 349b1d58c101 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=349b1d58c101
Added Files:
geom/BugTracker/Tests/SingleServer
geom/sql/conformance/Tests/SingleServer
geom/sql/functions/Tests/SingleServer
geom/sql/pg_regression/Tests/SingleServer
sql/backends/monet5/generator/Tests/SingleServer
sql/test/SQLite_regress/sqllogictest/Tests/select1.stable.err
sql/test/SQLite_regress/sqllogictest/Tests/select1.stable.err-noapprove
sql/test/SQLite_regress/sqllogictest/Tests/select1.stable.out
sql/test/SQLite_regress/sqllogictest/Tests/select1.stable.out-noapprove
sql/test/SQLite_regress/sqllogictest/Tests/select1.test
sql/test/SQLite_regress/sqllogictest/Tests/select1.timeout
sql/test/SQLite_regress/sqllogictest/Tests/select2.stable.err
sql/test/SQLite_regress/sqllogictest/Tests/select2.stable.err-noapprove
sql/test/SQLite_regress/sqllogictest/Tests/select2.stable.out
sql/test/SQLite_regress/sqllogictest/Tests/select2.stable.out-noapprove
sql/test/SQLite_regress/sqllogictest/Tests/select2.test
sql/test/SQLite_regress/sqllogictest/Tests/select2.timeout
sql/test/SQLite_regress/sqllogictest/Tests/select3.stable.err
sql/test/SQLite_regress/sqllogictest/Tests/select3.stable.err-noapprove
sql/test/SQLite_regress/sqllogictest/Tests/select3.stable.out
sql/test/SQLite_regress/sqllogictest/Tests/select3.stable.out-noapprove
sql/test/SQLite_regress/sqllogictest/Tests/select3.test
sql/test/SQLite_regress/sqllogictest/Tests/select3.timeout
sql/test/SQLite_regress/sqllogictest/Tests/select4.stable.err
sql/test/SQLite_regress/sqllogictest/Tests/select4.stable.err-noapprove
sql/test/SQLite_regress/sqllogictest/Tests/select4.stable.out
sql/test/SQLite_regress/sqllogictest/Tests/select4.stable.out-noapprove
sql/test/SQLite_regress/sqllogictest/Tests/select4.test
sql/test/SQLite_regress/sqllogictest/Tests/select4.timeout
sql/test/SQLite_regress/sqllogictest/Tests/select5.stable.err
sql/test/SQLite_regress/sqllogictest/Tests/select5.stable.err-noapprove
sql/test/SQLite_regress/sqllogictest/Tests/select5.stable.out
sql/test/SQLite_regress/sqllogictest/Tests/select5.stable.out-noapprove
sql/test/SQLite_regress/sqllogictest/Tests/select5.test
sql/test/SQLite_regress/sqllogictest/Tests/select5.timeout
testing/mktest.py
testing/sqllogictest.py
Removed Files:
geom/sql/Tests/All
geom/sql/Tests/T19.stable.err
geom/sql/Tests/T19.stable.out
geom/sql/Tests/T20.stable.err
geom/sql/Tests/T20.stable.out
geom/sql/Tests/T9.stable.err
geom/sql/Tests/T9.stable.out
geom/sql/Tests/area.sql
geom/sql/Tests/asBinary.sql
geom/sql/Tests/asBinary.stable.err
geom/sql/Tests/asBinary.stable.out
geom/sql/Tests/basic.modules
geom/sql/Tests/basic.sql
geom/sql/Tests/basic.stable.err
geom/sql/Tests/basic.stable.out
geom/sql/Tests/binary.sql
geom/sql/Tests/binary.stable.err
geom/sql/Tests/binary.stable.out
geom/sql/Tests/centroid.sql
geom/sql/Tests/distance.sql
geom/sql/Tests/example.modules
geom/sql/Tests/example.sql
geom/sql/Tests/example.stable.err
geom/sql/Tests/example.stable.out
geom/sql/Tests/geom-null-tests.modules
geom/sql/Tests/geom-null-tests.sql
geom/sql/Tests/geom-null-tests.stable.err
geom/sql/Tests/geom-null-tests.stable.out
geom/sql/Tests/geom_curve.modules
geom/sql/Tests/geom_curve.sql
geom/sql/Tests/geom_curve.stable.err
geom/sql/Tests/geom_curve.stable.out
geom/sql/Tests/geom_geometry.modules
geom/sql/Tests/geom_geometry.sql
geom/sql/Tests/geom_geometry.stable.err
geom/sql/Tests/geom_geometry.stable.out
geom/sql/Tests/geom_linestring.modules
geom/sql/Tests/geom_linestring.sql
geom/sql/Tests/geom_linestring.stable.err
geom/sql/Tests/geom_linestring.stable.out
geom/sql/Tests/geom_mbr.modules
geom/sql/Tests/geom_mbr.sql
geom/sql/Tests/geom_mbr.stable.err
geom/sql/Tests/geom_mbr.stable.out
geom/sql/Tests/geom_multi.modules
geom/sql/Tests/geom_multi.sql
geom/sql/Tests/geom_multi.stable.err
geom/sql/Tests/geom_multi.stable.out
geom/sql/Tests/geom_point.modules
geom/sql/Tests/geom_point.sql
geom/sql/Tests/geom_point.stable.err
geom/sql/Tests/geom_point.stable.out
geom/sql/Tests/geom_polygon.modules
geom/sql/Tests/geom_polygon.sql
geom/sql/Tests/geom_polygon.stable.err
geom/sql/Tests/geom_polygon.stable.out
geom/sql/Tests/geom_surface.modules
geom/sql/Tests/geom_surface.sql
   

MonetDB: default - Merged with linear-hashing

2020-02-20 Thread Pedro Ferreira
Changeset: 074d9ec14bc9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=074d9ec14bc9
Added Files:
sql/backends/monet5/UDF/udf/Tests/SingleServer
sql/benchmarks/tpch/LOCKED/Tests/SingleServer
sql/benchmarks/tpch/Tests/SingleServer
sql/jdbc/tests/Tests/SingleServer
sql/odbc/samples/Tests/SingleServer
sql/test/BugTracker-2020/Tests/cume-dist-wrong-results.Bug-6827.sql

sql/test/BugTracker-2020/Tests/cume-dist-wrong-results.Bug-6827.stable.err

sql/test/BugTracker-2020/Tests/cume-dist-wrong-results.Bug-6827.stable.out
sql/test/BugTracker-2020/Tests/window-order-by-extract.Bug-6828.sql

sql/test/BugTracker-2020/Tests/window-order-by-extract.Bug-6828.stable.err

sql/test/BugTracker-2020/Tests/window-order-by-extract.Bug-6828.stable.out
sql/test/sys-schema/Tests/SingleServer
Removed Files:
sql/benchmarks/tpch/LOCKED/Tests/01-22.SQL.bat
sql/benchmarks/tpch/LOCKED/Tests/01-22.SQL.sh
sql/benchmarks/tpch/LOCKED/Tests/01-22.reqtests
sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.err
sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out
sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out.int128
sql/benchmarks/tpch/Tests/01-22.SQL.bat
sql/benchmarks/tpch/Tests/01-22.SQL.sh
sql/benchmarks/tpch/Tests/01-22.reqtests
sql/benchmarks/tpch/Tests/01-22.stable.err
sql/benchmarks/tpch/Tests/01-22.stable.out
sql/benchmarks/tpch/Tests/01-22.stable.out.int128
Modified Files:
sql/backends/monet5/sql_rank.c
sql/benchmarks/tpch/LOCKED/Tests/All
sql/benchmarks/tpch/Tests/All
sql/server/rel_select.c

sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.stable.out
sql/test/BugTracker-2020/Tests/All
sql/test/analytics/Tests/analytics02.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 7211 to 300 lines):

diff --git a/sql/backends/monet5/UDF/udf/Tests/SingleServer 
b/sql/backends/monet5/UDF/udf/Tests/SingleServer
new file mode 100644
diff --git a/sql/backends/monet5/sql_rank.c b/sql/backends/monet5/sql_rank.c
--- a/sql/backends/monet5/sql_rank.c
+++ b/sql/backends/monet5/sql_rank.c
@@ -621,6 +621,7 @@ SQLcume_dist(Client cntxt, MalBlkPtr mb,
if (*np) {
ncnt = no - bo2;
cnt_cast = (dbl) ncnt;
+   j = 0;
for (; bo2  
-# 12:45:23 >  Mtimeout -timeout 1500 Mserver 
"--config=/var/tmp/_PREFIX_MONET_GNU_32_d__/etc/monet.conf" --debug=10 --set 
"monet_mod_path=/var/tmp/_PREFIX_SQL_GNU_32_d__/lib/MonetDB:/var/tmp/_PREFIX_MONET_GNU_32_d__/lib/MonetDB"
 --set "gdk_dbfarm=/var/tmp/_PREFIX_MONET_GNU_32_d__/var/MonetDB/dbfarm" --set 
"sql_logdir=/var/tmp/_PREFIX_MONET_GNU_32_d__/var/MonetDB/log" --set 
mapi_port=41160 --set sql_port=55567 --set monet_prompt= --trace 
"--dbname=mTests_src_benchmarks_tpch" 
"/var/tmp/_BUILD_SQL_GNU_32_d__/src/backends/monet4/sql_server.mil" ; echo ; 
echo Over..
-# 12:45:23 >  
-
-
-# 12:45:24 >  
-# 12:45:24 >  Mtimeout -timeout 1380 ./01-22.SQL 01-22 
-# 12:45:24 >  
-
-
-# 12:45:24 >  
-# 12:45:24 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:24 >  
-
-
-# 12:45:24 >  
-# 12:45:24 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:24 >  
-
-
-# 12:45:25 >  
-# 12:45:25 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:25 >  
-
-
-# 12:45:25 >  
-# 12:45:25 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:25 >  
-
-
-# 12:45:25 >  
-# 12:45:25 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:25 >  
-
-
-# 12:45:25 >  
-# 12:45:25 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:25 >  
-
-
-# 12:45:25 >  
-# 12:45:25 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:25 >  
-
-
-# 12:45:25 >  
-# 12:45:25 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:25 >  
-
-
-# 12:45:25 >  
-# 12:45:25 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:25 >  
-
-
-# 12:45:25 >  
-# 12:45:25 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:25 >  
-
-
-# 12:45:25 >  
-# 12:45:25 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:25 >  
-
-
-# 12:45:25 >  
-# 12:45:25 >  Mtimeout -timeout 60 Msql -u monetdb -P monetdb --host=draco 
--port=55567 --trace
-# 12:45:25 >  
-
-
-# 12:45:26 >  
-# 1

MonetDB: default - Merged with linear-hashing

2020-02-21 Thread Pedro Ferreira
Changeset: be5a9838fe23 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=be5a9838fe23
Added Files:
monetdb5/extras/mal_optimizer_template/Tests/SingleServer
monetdb5/extras/rapi/Tests/SingleServer
monetdb5/modules/atoms/Tests/SingleServer
monetdb5/modules/kernel/Tests/SingleServer
monetdb5/scheduler/Tests/SingleServer
sql/test/BugTracker-2009/Tests/SingleServer
sql/test/BugTracker-2009/Tests/create_on_ro_db_crash.SF-2830238.SQL.py
sql/test/BugTracker-2009/Tests/lost_update.SF-2790020.SQL.py
sql/test/BugTracker-2010/Tests/SingleServer
sql/test/BugTracker-2010/Tests/new-readonly-db.Bug-2695.SQL.py

sql/test/BugTracker-2010/alter-table-restart-crash.SF-2975018/Tests/SingleServer

sql/test/BugTracker-2010/alter-table-restart-crash.SF-2975022/Tests/SingleServer
sql/test/BugTracker-2011/Tests/SingleServer

sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.SQL.py
sql/test/BugTracker-2012/Tests/SingleServer
sql/test/BugTracker-2013/Tests/SingleServer
sql/test/BugTracker-2013/Tests/corrupt-after-restart.Bug-3282.SQL.py
sql/test/BugTracker-2014/Tests/SingleServer
sql/test/BugTracker-2015/Tests/SingleServer
sql/test/BugTracker-2016/Tests/SingleServer
sql/test/BugTracker-2017/Tests/SingleServer
sql/test/BugTracker-2017/Tests/shutdown.Bug-6182.SQL.py
sql/test/BugTracker-2018/Tests/SingleServer
sql/test/BugTracker-2018/Tests/grant-role-not-idempotent.Bug-6660.SQL.py
sql/test/BugTracker-2019/Tests/SingleServer
sql/test/BugTracker-2020/Tests/SingleServer
sql/test/BugTracker-2020/Tests/functions-not-persist.Bug-6819.SQL.py
sql/test/BugTracker/Tests/SingleServer
sql/test/BugTracker/Tests/connect_crash.SF-1436626.SQL.py
sql/test/BugTracker/Tests/mdb_starts_with_sql_debug_64.SF-1999354.SQL.py
sql/test/BugTracker/Tests/set_a_new_user_password.SF-1844050.SQL.py

sql/test/BugTracker/Tests/set_sql_debug_64__breaking_the_DB.SF-1906287.SQL.py
sql/test/Skyserver/bugs/Tests/SingleServer
sql/test/UserDump/Tests/SingleServer
sql/test/VOC/Tests/SingleServer
sql/test/remote/Tests/SingleServer
sql/test/rename/Tests/SingleServer
sql/test/rename/Tests/rename00.SQL.py
sql/test/sql_xml/Tests/SingleServer
Removed Files:
sql/test/BugTracker-2009/Tests/create_on_ro_db_crash.SF-2830238.py
sql/test/BugTracker-2009/Tests/lost_update.SF-2790020.py
sql/test/BugTracker-2010/Tests/new-readonly-db.Bug-2695.py
sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.py
sql/test/BugTracker-2013/Tests/corrupt-after-restart.Bug-3282.py
sql/test/BugTracker-2017/Tests/shutdown.Bug-6182.sql
sql/test/BugTracker-2018/Tests/grant-role-not-idempotent.Bug-6660.py
sql/test/BugTracker-2020/Tests/functions-not-persist.Bug-6819.py
sql/test/BugTracker/Tests/connect_crash.SF-1436626.py
sql/test/BugTracker/Tests/mdb_starts_with_sql_debug_64.SF-1999354.py
sql/test/BugTracker/Tests/set_a_new_user_password.SF-1844050.py

sql/test/BugTracker/Tests/set_sql_debug_64__breaking_the_DB.SF-1906287.py
sql/test/rename/Tests/rename00.py
Modified Files:
.hgtags
MonetDB.spec
NT/monetdb_config.h.in
NT/rules.msc
clients/mapilib/mapi.rc
clients/odbc/driver/driver.rc
clients/odbc/winsetup/setup.rc
configure.ag
debian/changelog
debian/rules
gdk/libbat.rc
libversions
monetdb5/mal/mal_import.c
monetdb5/optimizer/Tests/SingleServer
monetdb5/tools/libmonetdb5.rc
sql/backends/monet5/UDF/pyapi/Tests/SingleServer
sql/test/BugTracker-2019/Tests/alter_table_drop_column.Bug-6749.py
sql/test/BugTracker-2019/Tests/grant-select-column.Bug-6765.py
sql/test/BugTracker-2019/Tests/msqldump-mapi-cache.Bug-6777.py
sql/test/BugTracker-2019/Tests/python-loader-string.Bug-6759.py
sql/test/BugTracker-2020/Tests/alter-table-add-column.Bug-6816.py
sql/test/merge-partitions/Tests/mergepart23.SQL.py
sql/test/merge-partitions/Tests/mergepart23.stable.out
sql/test/scripts/Tests/alastair_udf_mergetable_bug.stable.out
sql/test/scripts/Tests/fsum.stable.out
testing/Mtest.py.in
vertoo.data
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 1264 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -758,3 +758,5 @@ 4eb6068f63cf87fc6996daed59fbcc917c8b2881
 7186b517a584f0244e20eb7abe61f7a7c0c9ea1b Nov2019_15
 4eb6068f63cf87fc6996daed59fbcc917c8b2881 Nov2019_SP2_release
 7186b517a584f0244e20eb7abe61f7a7c0c9ea1b Nov2019_SP2_release
+e1c7c70bceb205cf23b8a35179b628563871f949 Nov2019_17
+e1c7c70bceb205cf23b8a3

MonetDB: default - Merged with linear-hashing

2020-02-22 Thread Pedro Ferreira
Changeset: c189e3ba6264 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c189e3ba6264
Added Files:
clients/Tests/SingleServer
clients/mapiclient/Tests/SingleServer
monetdb5/mal/Tests/SingleServer
monetdb5/modules/mal/Tests/SingleServer
sql/test/SQLite_regress/sqllogictest/Tests/SingleServer
sql/test/ssqq/Tests/SingleServer
Modified Files:
.hgtags
MonetDB.spec
NT/monetdb_config.h.in
NT/rules.msc
buildtools/selinux/monetdb.fc
buildtools/selinux/monetdb.te
clients/mapilib/mapi.rc
clients/odbc/driver/driver.rc
clients/odbc/winsetup/setup.rc
configure.ag
debian/changelog
gdk/gdk_analytic_func.c
gdk/libbat.rc
libversions
monetdb5/tools/libmonetdb5.rc
vertoo.data
Branch: default
Log Message:

Merged with linear-hashing


diffs (247 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -760,3 +760,6 @@ 4eb6068f63cf87fc6996daed59fbcc917c8b2881
 7186b517a584f0244e20eb7abe61f7a7c0c9ea1b Nov2019_SP2_release
 e1c7c70bceb205cf23b8a35179b628563871f949 Nov2019_17
 e1c7c70bceb205cf23b8a35179b628563871f949 Nov2019_SP3_release
+179977ed07cd8095f99a6a07968b8e9d1affa753 Nov2019_19
+e1c7c70bceb205cf23b8a35179b628563871f949 Nov2019_SP3_release
+179977ed07cd8095f99a6a07968b8e9d1affa753 Nov2019_SP3_release
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -789,7 +789,9 @@ do
   /usr/sbin/semodule -s ${selinuxvariant} -i \
 %{_datadir}/selinux/${selinuxvariant}/monetdb.pp &> /dev/null || :
 done
-/sbin/restorecon -R %{_localstatedir}/monetdb5 %{_localstatedir}/log/monetdb 
%{_rundir}/monetdb %{_bindir}/monetdbd %{_bindir}/mserver5 
%{_unitdir}/monetdbd.service &> /dev/null || :
+# use /var/run/monetdb since that's what it says in the monetdb.fc file
+# it says that because /run/monetdb for some reason doesn't work
+/sbin/restorecon -R %{_localstatedir}/monetdb5 %{_localstatedir}/log/monetdb 
/var/run/monetdb %{_bindir}/monetdbd %{_bindir}/mserver5 
%{_unitdir}/monetdbd.service &> /dev/null || :
 /usr/bin/systemctl try-restart monetdbd.service
 
 %postun selinux
@@ -941,6 +943,10 @@ fi
 %postun -p /sbin/ldconfig
 
 %changelog
+* Sat Feb 22 2020 Sjoerd Mullender  - 11.35.19-20200222
+- Rebuilt.
+- BZ#6829: NTILE window function returns incorrect results
+
 * Fri Feb 21 2020 Sjoerd Mullender  - 11.35.17-20200221
 - Rebuilt.
 - BZ#6827: CUME_DIST window function returns incorrect results
diff --git a/buildtools/selinux/monetdb.fc b/buildtools/selinux/monetdb.fc
--- a/buildtools/selinux/monetdb.fc
+++ b/buildtools/selinux/monetdb.fc
@@ -4,6 +4,6 @@
 /var/log/monetdb(/.*)? 
gen_context(system_u:object_r:monetdbd_log_t,s0)
 /var/monetdb5/dbfarm(/.*)? 
gen_context(system_u:object_r:mserver5_db_t,s0)
 /var/monetdb5/dbfarm/\.merovingian_properties  --  
gen_context(system_u:object_r:monetdbd_etc_t,s0)
-/run/monetdb(/.*)? 
gen_context(system_u:object_r:monetdbd_var_run_t,s0)
+/var/run/monetdb(/.*)? 
gen_context(system_u:object_r:monetdbd_var_run_t,s0)
 /var/monetdb5/dbfarm/\.merovingian_lock--  
gen_context(system_u:object_r:monetdbd_lock_t,s0)
 /var/monetdb5/dbfarm/.*/\.gdk_lock --  
gen_context(system_u:object_r:mserver5_lock_t,s0)
diff --git a/buildtools/selinux/monetdb.te b/buildtools/selinux/monetdb.te
--- a/buildtools/selinux/monetdb.te
+++ b/buildtools/selinux/monetdb.te
@@ -1,4 +1,4 @@
-policy_module(monetdb, 0.8)
+policy_module(monetdb, 0.9)
 # The above line declares that this file is a SELinux policy file. Its
 # name is monetdb, so the file should be saved as monetdb.te
 
diff --git a/clients/Tests/SingleServer b/clients/Tests/SingleServer
new file mode 100644
--- /dev/null
+++ b/clients/Tests/SingleServer
@@ -0,0 +1,2 @@
+--set embedded_py=2
+--set embedded_r=true
diff --git a/clients/mapiclient/Tests/SingleServer 
b/clients/mapiclient/Tests/SingleServer
new file mode 100644
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+monetdb (11.35.19) unstable; urgency=low
+
+  * Rebuilt.
+  * BZ#6829: NTILE window function returns incorrect results
+
+ -- Sjoerd Mullender   Sat, 22 Feb 2020 08:49:38 +0100
+
 monetdb (11.35.17) unstable; urgency=low
 
   * Rebuilt.
diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c
--- a/gdk/gdk_analytic_func.c
+++ b/gdk/gdk_analytic_func.c
@@ -133,7 +133,7 @@ GDKanalyticaldiff(BAT *r, BAT *b, BAT *p
return GDK_SUCCEED;
 }
 
-#define NTILE_CALC(TPE, NEXT_VALUE, NEXT_CAST) \
+#define NTILE_CALC(TPE, NEXT_VALUE, CAST1, CAST2, CAST3)   \
do {\
for (TPE i = 0; rb < rp; i++, rb++) {   \
TPE val = NEXT_VALUE; \
@@ -141,23 +141,23 @@

MonetDB: default - Merged with linear-hashing

2020-02-23 Thread Pedro Ferreira
Changeset: 5d39a0ed4347 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5d39a0ed4347
Modified Files:
gdk/gdk_analytic_func.c
sql/storage/store.c
Branch: default
Log Message:

Merged with linear-hashing


diffs (287 lines):

diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c
--- a/gdk/gdk_analytic_func.c
+++ b/gdk/gdk_analytic_func.c
@@ -133,7 +133,7 @@ GDKanalyticaldiff(BAT *r, BAT *b, BAT *p
return GDK_SUCCEED;
 }
 
-#define NTILE_CALC(TPE, NEXT_VALUE, CAST1, CAST2, CAST3)   \
+#define NTILE_CALC(TPE, NEXT_VALUE, LNG_HGE, UPCAST)   \
do {\
for (TPE i = 0; rb < rp; i++, rb++) {   \
TPE val = NEXT_VALUE; \
@@ -141,14 +141,14 @@ GDKanalyticaldiff(BAT *r, BAT *b, BAT *p
has_nils = true;\
*rb = TPE##_nil;\
} else { \
-   TPE nval = CAST1; \
-   if ((CAST2) nval >= (CAST3) ncnt) { \
+   UPCAST nval = (UPCAST) LNG_HGE; \
+   if (nval >= ncnt) { \
*rb = i + 1;  \
} else { \
-   BUN bsize = ncnt / nval; \
-   BUN top = ncnt - nval * bsize; \
-   BUN small = top * (bsize + 1); \
-   if ((CAST2) i < (CAST3) small) \
+   UPCAST bsize = ncnt / nval; \
+   UPCAST top = ncnt - nval * bsize; \
+   UPCAST small = top * (bsize + 1); \
+   if ((UPCAST) i < small) \
*rb = (TPE)(1 + i / (bsize + 
1)); \
else \
*rb = (TPE)(1 + top + (i - 
small) / bsize); \
@@ -157,9 +157,10 @@ GDKanalyticaldiff(BAT *r, BAT *b, BAT *p
} \
} while (0)
 
-#define ANALYTICAL_NTILE_IMP(TPE, NEXT_VALUE, CAST1, CAST2, CAST3) \
+#define ANALYTICAL_NTILE_IMP(TPE, NEXT_VALUE, LNG_HGE, UPCAST) \
do {\
TPE *rp, *rb;   \
+   UPCAST ncnt; \
rb = rp = (TPE*)Tloc(r, 0); \
if (p) {\
pnp = np = (bit*)Tloc(p, 0);\
@@ -168,36 +169,37 @@ GDKanalyticaldiff(BAT *r, BAT *b, BAT *p
if (*np) {  \
ncnt = np - pnp;\
rp += ncnt; \
-   NTILE_CALC(TPE, NEXT_VALUE, CAST1, 
CAST2, CAST3);\
+   NTILE_CALC(TPE, NEXT_VALUE, LNG_HGE, 
UPCAST);\
pnp = np;   \
}   \
}   \
ncnt = np - pnp;\
rp += ncnt; \
-   NTILE_CALC(TPE, NEXT_VALUE, CAST1, CAST2, CAST3);   
\
+   NTILE_CALC(TPE, NEXT_VALUE, LNG_HGE, UPCAST);   \
} else {\
+   ncnt = (UPCAST) cnt; \
rp += cnt;  \
-   NTILE_CALC(TPE, NEXT_VALUE, CAST1, CAST2, CAST3);   
\
+   NTILE_CALC(TPE, NEXT_VALUE, LNG_HGE, UPCAST);   \
}   \
} while (0)
 
-#define ANALYTICAL_NTILE_SINGLE_IMP(TPE, CAST1, CAST2, CAST3) \
+#define ANALYTICAL_NTILE_SINGLE_IMP(TPE, LNG_HGE, UPCAST) \
do {\
TPE ntl = *(TPE*) ntile; \
-   ANALYTICAL_NTILE_IMP(TPE, ntl, CAST1, CAST2, CAST3); \
+   ANALYTICAL_NTILE_IMP(TPE, ntl, LNG_HGE, UPCAST); \
} while (0)
 
-#define ANALYTICAL_NTILE_MULTI_IMP(TPE, CAST1, CAST2, CAST3) \
+#define ANALYTICAL_NTILE_MULTI_IMP(TPE, LNG_HGE, UPCAST) \
do {\
BUN k = 0; \
TPE *restrict nn = (TPE*)Tloc(n, 0);\
-   ANALYTICAL_NTILE_IMP(TPE, nn[k++], CAST1, CAST2, CAST3); \
+   ANALYTICAL_NTILE_IMP(TPE, nn[k++], LNG_HGE, UPCAST); \
} while (0)
 
 gdk_return
 GDKanalyticalntile(BAT *r, BAT *b, BAT *p, BAT *n, int tpe, const void 
*restrict ntile)
 {
-   BUN cnt = BATcount(b), ncnt = cnt;
+   BUN cnt = BATcount(b);
bit *np, *pnp, *end;
bool has_nils = false;

MonetDB: default - Merged with linear-hashing

2020-02-25 Thread Pedro Ferreira
Changeset: 5528cb409945 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5528cb409945
Removed Files:
sql/test/BugTracker-2019/Tests/msqldump-mapi-cache.Bug-6777.timeout
Modified Files:
monetdb5/modules/mal/mal_io.c
monetdb5/modules/mal/pcre.c
monetdb5/modules/mal/projectionpath.c
monetdb5/optimizer/opt_mergetable.c
sql/backends/monet5/sql_execute.c
sql/backends/monet5/wlr.c
sql/server/rel_dump.c
sql/server/rel_updates.c
sql/server/rel_updates.h

sql/test/BugTracker-2015/Tests/local-remotetable-crash.Bug-3754.stable.err
sql/test/BugTracker-2019/Tests/msqldump-mapi-cache.Bug-6777.py
sql/test/BugTracker-2019/Tests/msqldump-mapi-cache.Bug-6777.stable.out

sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.py
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 2994 to 300 lines):

diff --git a/monetdb5/modules/mal/mal_io.c b/monetdb5/modules/mal/mal_io.c
--- a/monetdb5/modules/mal/mal_io.c
+++ b/monetdb5/modules/mal/mal_io.c
@@ -48,6 +48,8 @@ io_stdin(Client cntxt, MalBlkPtr mb, Mal
 {
bstream **ret= (bstream**) getArgReference(stk,pci,0);
(void) mb;
+   if( cntxt->fdin == NULL)
+   throw(MAL, "io.print", SQLSTATE(HY002) "Input channel missing");
*ret = cntxt->fdin;
return MAL_SUCCEED;
 }
@@ -57,6 +59,8 @@ io_stdout(Client cntxt, MalBlkPtr mb, Ma
 {
stream **ret= (stream**) getArgReference(stk,pci,0);
(void) mb;
+   if( cntxt->fdout == NULL)
+   throw(MAL, "io.print", SQLSTATE(HY002) "Output channel 
missing");
*ret = cntxt->fdout;
return MAL_SUCCEED;
 }
@@ -69,6 +73,8 @@ IOprintBoth(Client cntxt, MalBlkPtr mb, 
stream *fp = cntxt->fdout;
 
(void) mb;
+   if( cntxt->fdout == NULL)
+   throw(MAL, "io.print", SQLSTATE(HY002) "Output channel 
missing");
 
if (tpe == TYPE_any)
tpe = stk->stk[pci->argv[indx]].vtype;
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -714,6 +714,7 @@ re_likeselect(BAT **bnp, BAT *b, BAT *s,
oid o, off;
const char *v;
RE *re = NULL;
+   uint32_t *wpat = NULL;
 
assert(ATOMstorage(b->ttype) == TYPE_str);
 
@@ -735,7 +736,6 @@ re_likeselect(BAT **bnp, BAT *b, BAT *s,
 
if (use_strcmp) {
if (caseignore) {
-   uint32_t *wpat;
wpat = utf8stoucs(pat);
if (wpat == NULL)
throw(MAL, "pcre.likeselect", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -746,6 +746,7 @@ re_likeselect(BAT **bnp, BAT *b, BAT *s,
candscanloop(v && *v != '\200' &&
 
mywstrcasecmp(v, wpat) == 0);
GDKfree(wpat);
+   wpat = NULL;
} else {
if (anti)
candscanloop(v && *v != '\200' &&
@@ -786,7 +787,6 @@ re_likeselect(BAT **bnp, BAT *b, BAT *s,
}
if (use_strcmp) {
if (caseignore) {
-   uint32_t *wpat;
wpat = utf8stoucs(pat);
if (wpat == NULL)
throw(MAL, "pcre.likeselect", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -797,6 +797,7 @@ re_likeselect(BAT **bnp, BAT *b, BAT *s,
scanloop(v && *v != '\200' &&
 mywstrcasecmp(v, wpat) 
== 0);
GDKfree(wpat);
+   wpat = NULL;
} else {
if (anti)
scanloop(v && *v != '\200' &&
@@ -834,6 +835,7 @@ re_likeselect(BAT **bnp, BAT *b, BAT *s,
 
   bunins_failed:
re_destroy(re);
+   GDKfree(wpat);
BBPreclaim(bn);
*bnp = NULL;
throw(MAL, "pcre.likeselect", OPERATION_FAILED);
diff --git a/monetdb5/modules/mal/projectionpath.c 
b/monetdb5/modules/mal/projectionpath.c
--- a/monetdb5/modules/mal/projectionpath.c
+++ b/monetdb5/modules/mal/projectionpath.c
@@ -15,13 +15,14 @@ ALGprojectionpath(Client cntxt, MalBlkPt
int i;
bat bid;
bat *r = getArgReference_bat(stk, pci, 0);
-   BAT *b, **joins = (BAT**)GDKzalloc(pci->argc * sizeof(BAT*)); 
+   BAT *b, **joins = NULL;
 
(void) mb;
(void) cntxt;
 
if(pci->argc <= 1)
throw(MAL, "algebra.projectionpath", SQLSTATE(HY013) "INTERNAL 
ERROR");
+   joins = 

MonetDB: default - Merged with linear-hashing

2020-02-25 Thread Pedro Ferreira
Changeset: 9c8c54a87acf for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9c8c54a87acf
Added Files:
sql/test/merge-statements/Tests/mergestmt04.sql
sql/test/merge-statements/Tests/mergestmt04.stable.err
sql/test/merge-statements/Tests/mergestmt04.stable.out
sql/test/miscellaneous/Tests/groupings.sql
sql/test/miscellaneous/Tests/groupings.stable.err
sql/test/miscellaneous/Tests/groupings.stable.out
Modified Files:
monetdb5/modules/atoms/str.c
monetdb5/optimizer/opt_json.c
monetdb5/optimizer/opt_macro.c
monetdb5/optimizer/opt_mergetable.c
monetdb5/optimizer/opt_pipes.c
monetdb5/optimizer/opt_pushselect.c
sql/backends/monet5/UDF/pyapi3/connection3.c
sql/backends/monet5/sql.c
sql/test/merge-statements/Tests/All
sql/test/miscellaneous/Tests/All
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 544 to 300 lines):

diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -3108,14 +3108,12 @@ strEpilogue(void *ret)
 // (1 + ((UC) > 0x7F) + ((UC) > 0x7FF) + ((UC) > 0x))
 
 static inline size_t
-UTF8_strlen(const char *s)
+UTF8_strlen(const char *s) /* This function assumes, s is never nil */
 {
size_t pos = 0;
 
UTF8_assert(s);
-
-   if (strNil(s))
-   return 1;
+   assert(!strNil(s));
 
while (*s) {
/* just count leading bytes of encoded code points; only works
diff --git a/monetdb5/optimizer/opt_json.c b/monetdb5/optimizer/opt_json.c
--- a/monetdb5/optimizer/opt_json.c
+++ b/monetdb5/optimizer/opt_json.c
@@ -44,6 +44,7 @@ OPTjsonImplementation(Client cntxt, MalB
q = addArgument(mb, q, bu);
q = addArgument(mb, q, br);
q = addArgument(mb, q, bj);
+   pushInstruction(mb,q);
j = getArg(q,0);
p= getInstrPtr(mb,0);
setDestVar(q, newTmpVariable(mb, TYPE_str));
diff --git a/monetdb5/optimizer/opt_macro.c b/monetdb5/optimizer/opt_macro.c
--- a/monetdb5/optimizer/opt_macro.c
+++ b/monetdb5/optimizer/opt_macro.c
@@ -169,8 +169,11 @@ inlineMALblock(MalBlkPtr mb, int pc, Mal
 
/* copy the instruction and fix variable references */
ns[k] = copyInstruction(q);
-   if( ns[k] == NULL)
+   if( ns[k] == NULL){
+   GDKfree(nv);
+   GDKfree(ns);
return -1;
+   }
 
for (n = 0; n < q->argc; n++)
getArg(ns[k], n) = nv[getArg(q, n)];
@@ -311,8 +314,11 @@ replaceMALblock(MalBlkPtr mb, int pc, Ma
 
p = getInstrPtr(mb, pc);
q = copyInstruction(getInstrPtr(mc, 0));/* the signature */
-   if( q == NULL)
+   if( q == NULL){
+   GDKfree(cvar);
+   GDKfree(mvar);
return -1;
+   }
q->token = ASSIGNsymbol;
mb->stmt[pc] = q;
 
diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -309,8 +309,10 @@ mat_delta(matlist_t *ml, MalBlkPtr mb, I
for(j=1; j < mat[m].mi->argc; j++) {
if (overlap(ml, getArg(mat[e].mi, k), 
getArg(mat[m].mi, j), k, j, 0)){
InstrPtr q = copyInstruction(p);
-   if(!q)
+   if(!q){
+   freeInstruction(r);
return NULL;
+   }
 
/* remove last argument (inserts only 
on last part) */
if (k < mat[m].mi->argc-1)
@@ -777,6 +779,7 @@ mat_join2(MalBlkPtr mb, InstrPtr p, matl
if(propagatePartnr(ml, getArg(mat[m].mi, k), 
getArg(q,0), nr) ||
   propagatePartnr(ml, getArg(mat[n].mi, j), 
getArg(q,1), nr)) {
freeInstruction(r);
+   freeInstruction(l);
return -1;
}
 
@@ -1156,8 +1159,10 @@ mat_group_project(MalBlkPtr mb, InstrPtr
getArg(q,1) = getArg(mat[e].mi,k);
getArg(q,2) = getArg(mat[a].mi,k);
pushInstruction(mb,q);
-   if(setPartnr(ml, getArg(mat[a].mi,k), getArg(q,0), k))
+   if(setPartnr(ml, getArg(mat[a].mi,k), getArg(q,0), k)){
+   freeInstruction(ai1);
return -1;
+ 

MonetDB: default - Merged with linear-hashing

2020-02-26 Thread Pedro Ferreira
Changeset: 947f7ca4dde3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=947f7ca4dde3
Modified Files:
gdk/gdk_calc.c
gdk/gdk_calc_compare.h
gdk/gdk_string.c
geom/monetdb5/geom.c
monetdb5/extras/rapi/converters.c.h
monetdb5/modules/atoms/identifier.c
monetdb5/modules/atoms/json.c
monetdb5/modules/atoms/mtime.c
monetdb5/modules/kernel/batstr.c
monetdb5/modules/mal/clients.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/pcre.c
monetdb5/modules/mal/remote.c
sql/backends/monet5/UDF/capi/capi.c
sql/backends/monet5/UDF/pyapi3/conversion3.c
sql/backends/monet5/UDF/udf/udf.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_cat.c
sql/backends/monet5/sql_transaction.c
sql/server/rel_schema.c
sql/server/sql_mvc.c
sql/server/sql_partition.c
sql/server/sql_privileges.c
sql/storage/store.c
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 1011 to 300 lines):

diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -3456,7 +3456,7 @@ addstr_loop(BAT *b1, const char *l, BAT 
l = BUNtvar(b1i, i);
if (b2)
r = BUNtvar(b2i, i);
-   if (strcmp(l, str_nil) == 0 || strcmp(r, str_nil) == 0) {
+   if (strNil(l) || strNil(r)) {
nils++;
if (tfastins_nocheckVAR(bn, i, str_nil, Tsize(bn)) != 
GDK_SUCCEED)
goto bunins_failed;
@@ -13640,7 +13640,7 @@ convert_str_any(BAT *b, int tp, void *re
nils++;
}
s = BUNtvar(bi, i);
-   if (strcmp(s, str_nil) == 0) {
+   if (strNil(s)) {
memcpy(dst, nil, len);
nils++;
} else {
@@ -14365,7 +14365,7 @@ VARconvert(ValPtr ret, const ValRecord *
if (VALinit(ret, ret->vtype, ATOMnilptr(ret->vtype)) == NULL)
nils = BUN_NONE;
} else if (v->vtype == TYPE_str) {
-   if (v->val.sval == NULL || strcmp(v->val.sval, str_nil) == 0) {
+   if (v->val.sval == NULL || strNil(v->val.sval)) {
if (VALinit(ret, ret->vtype, ATOMnilptr(ret->vtype)) == 
NULL)
nils = BUN_NONE;
} else if (ATOMstorage(ret->vtype) == TYPE_ptr) {
diff --git a/gdk/gdk_calc_compare.h b/gdk/gdk_calc_compare.h
--- a/gdk/gdk_calc_compare.h
+++ b/gdk/gdk_calc_compare.h
@@ -708,12 +708,12 @@ op_typeswitchloop(const void *lft, int t
const char *s1, *s2;
s1 = hp1 ? hp1 + VarHeapVal(lft, i, wd1) : (const char 
*) lft;
s2 = hp2 ? hp2 + VarHeapVal(rgt, j, wd2) : (const char 
*) rgt;
-   if (s1 == NULL || strcmp(s1, str_nil) == 0 ||
-   s2 == NULL || strcmp(s2, str_nil) == 0) {
+   if (s1 == NULL || strNil(s1) ||
+   s2 == NULL || strNil(s2)) {
 #ifdef NIL_MATCHES_FLAG
if (nil_matches) {
-   dst[k] = OP(s1 == NULL || strcmp(s1, 
str_nil) == 0,
-   s2 == NULL || strcmp(s2, 
str_nil) == 0);
+   dst[k] = OP(s1 == NULL || strNil(s1),
+   s2 == NULL || strNil(s2));
} else
 #endif
{
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -366,7 +366,7 @@ GDKstrFromStr(unsigned char *restrict ds
bool escaped = false;
int mask = 0, n, c, utf8char = 0;
 
-   if (len >= 2 && strcmp((const char *) src, str_nil) == 0) {
+   if (len >= 2 && strNil((const char *) src)) {
strcpy((char *) dst, str_nil);
return 1;
}
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -415,8 +415,8 @@ wkbTransform(wkb **transformedWKB, wkb *
if (is_wkb_nil(*geomWKB) ||
is_int_nil(*srid_src) ||
is_int_nil(*srid_dst) ||
-   strcmp(*proj4_src_str, str_nil) == 0 ||
-   strcmp(*proj4_dst_str, str_nil) == 0) {
+   strNil(*proj4_src_str) ||
+   strNil(*proj4_dst_str)) {
if ((*transformedWKB = wkbNULLcopy()) == NULL)
throw(MAL, "geom.Transform", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
return MAL_SUCCEED;
@@ -2430,7 +2430,7 @@ wkbFromBinary(wkb **geomWKB, const cha

MonetDB: default - Merged with linear-hashing

2020-02-26 Thread Pedro Ferreira
Changeset: 1cc38036b6ee for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1cc38036b6ee
Added Files:
tools/merovingian/client/Tests/monetdb_status.stable.err
tools/merovingian/client/Tests/monetdb_status.stable.out
Modified Files:
gdk/gdk_calc.c
gdk/gdk_calc_compare.h
monetdb5/modules/atoms/json.c
monetdb5/modules/kernel/batstr.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/remote.c
sql/backends/monet5/UDF/capi/capi.c
sql/backends/monet5/UDF/udf/udf.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_cat.c
sql/backends/monet5/sql_transaction.c
sql/server/rel_dump.c
sql/server/rel_schema.c
sql/server/rel_unnest.c
sql/server/sql_privileges.c
sql/storage/store.c
sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.stable.out
sql/test/subquery/Tests/subquery3.sql
sql/test/subquery/Tests/subquery3.stable.err
sql/test/subquery/Tests/subquery3.stable.out
tools/merovingian/client/Tests/monetdb_status.py
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 678 to 300 lines):

diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -14365,7 +14365,7 @@ VARconvert(ValPtr ret, const ValRecord *
if (VALinit(ret, ret->vtype, ATOMnilptr(ret->vtype)) == NULL)
nils = BUN_NONE;
} else if (v->vtype == TYPE_str) {
-   if (v->val.sval == NULL || strNil(v->val.sval)) {
+   if (strNil(v->val.sval)) {
if (VALinit(ret, ret->vtype, ATOMnilptr(ret->vtype)) == 
NULL)
nils = BUN_NONE;
} else if (ATOMstorage(ret->vtype) == TYPE_ptr) {
diff --git a/gdk/gdk_calc_compare.h b/gdk/gdk_calc_compare.h
--- a/gdk/gdk_calc_compare.h
+++ b/gdk/gdk_calc_compare.h
@@ -708,12 +708,10 @@ op_typeswitchloop(const void *lft, int t
const char *s1, *s2;
s1 = hp1 ? hp1 + VarHeapVal(lft, i, wd1) : (const char 
*) lft;
s2 = hp2 ? hp2 + VarHeapVal(rgt, j, wd2) : (const char 
*) rgt;
-   if (s1 == NULL || strNil(s1) ||
-   s2 == NULL || strNil(s2)) {
+   if (strNil(s1) || strNil(s2)) {
 #ifdef NIL_MATCHES_FLAG
if (nil_matches) {
-   dst[k] = OP(s1 == NULL || strNil(s1),
-   s2 == NULL || strNil(s2));
+   dst[k] = OP(strNil(s1), strNil(s2));
} else
 #endif
{
diff --git a/monetdb5/modules/kernel/batstr.c b/monetdb5/modules/kernel/batstr.c
--- a/monetdb5/modules/kernel/batstr.c
+++ b/monetdb5/modules/kernel/batstr.c
@@ -131,7 +131,7 @@ do_batstr_int(bat *ret, const bat *l, co
 
BATloop(b, p, q) {
x = (str) BUNtvar(bi, p);
-   if (x == 0 || strNil(x)) {
+   if (strNil(x)) {
y = int_nil;
bn->tnonil = false;
bn->tnil = true;
@@ -180,7 +180,7 @@ do_batstr_str(bat *ret, const bat *l, co
BATloop(b, p, q) {
y = NULL;
x = (str) BUNtvar(bi, p);
-   if (x != 0 && !strNil(x) &&
+   if (!strNil(x) &&
(msg = (*func)(&y, &x)) != MAL_SUCCEED)
goto bailout;
if (y == NULL)
@@ -227,7 +227,7 @@ do_batstr_conststr_str(bat *ret, const b
BATloop(b, p, q) {
y = NULL;
x = (str) BUNtvar(bi, p);
-   if (x != 0 && !strNil(x) &&
+   if (!strNil(x) &&
(msg = (*func)(&y, &x, s2)) != MAL_SUCCEED)
goto bailout;
if (y == NULL)
@@ -281,8 +281,8 @@ do_batstr_batstr_str(bat *ret, const bat
y = NULL;
x = (str) BUNtvar(bi, p);
x2 = (str) BUNtvar(bi2, p);
-   if (x != 0 && !strNil(x) &&
-   x2 != 0 && !strNil(x2) &&
+   if (!strNil(x) &&
+   !strNil(x2) &&
(msg = (*func)(&y, &x, &x2)) != MAL_SUCCEED)
goto bailout;
if (y == NULL)
@@ -330,7 +330,7 @@ do_batstr_constint_str(bat *ret, const b
BATloop(b, p, q) {
y = NULL;
x = (str) BUNtvar(bi, p);
-   if (x != 0 && !strNil(x) &&
+   if (!strNil(x) &&
(msg = (*func)(&y, &x, n)) != MAL_SUCCEED)
goto bailout;
if (y == NULL)
@@ -385,7 +385,7 @@ do_batstr_batint_str(bat *ret, const bat
y = NULL;
x =

MonetDB: default - merged with linear-hashing

2020-02-26 Thread Niels Nes
Changeset: 131439ac0d89 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=131439ac0d89
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sql_statement.h
sql/include/sql_catalog.h
sql/include/sql_relation.h
sql/server/rel_dump.c
sql/server/rel_exp.c
sql/server/rel_unnest.c
sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out

sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.stable.out
sql/test/analytics/Tests/analytics13.stable.out
Branch: default
Log Message:

merged with linear-hashing


diffs (truncated from 1040 to 300 lines):

diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -332,7 +332,7 @@ handle_in_exps(backend *be, sql_exp *ce,
if (sel) 
s = stmt_uselect(be, 
stmt_const(be, bin_first_column(be, left), s), 
-   stmt_bool(be, 1), cmp_equal, sel, 0); 
+   stmt_bool(be, 1), cmp_equal, sel, 0, 0); 
} else if (list_length(nl) < 16) {
comp_type cmp = (in)?cmp_equal:cmp_notequal;
 
@@ -345,13 +345,13 @@ handle_in_exps(backend *be, sql_exp *ce,
return NULL;
 
if (in) { 
-   i = stmt_uselect(be, c, i, cmp, sel, 0); 
+   i = stmt_uselect(be, c, i, cmp, sel, 0, 0); 
if (s)
s = stmt_tunion(be, s, i); 
else
s = i;
} else {
-   s = stmt_uselect(be, c, i, cmp, s, 0); 
+   s = stmt_uselect(be, c, i, cmp, s, 0, 0); 
}
}
} else {
@@ -369,7 +369,7 @@ handle_in_exps(backend *be, sql_exp *ce,
s = stmt_project(be, stmt_selectnonil(be, s, NULL), s);
}
 
-   s = stmt_join(be, c, s, in, cmp_left);
+   s = stmt_join(be, c, s, in, cmp_left, 0);
s = stmt_result(be, s, 0);
 
if (!in) {
@@ -383,7 +383,7 @@ handle_in_exps(backend *be, sql_exp *ce,
   Ugly trick to return empty candidate list, 
because for all x it holds that: (x == null) == false.
   list* singleton_bat = sa_list(sql->sa);
   list_append(singleton_bat, null_value); */
-   s = stmt_uselect(be, c, last_null_value, 
cmp_equal, NULL, 0);
+   s = stmt_uselect(be, c, last_null_value, 
cmp_equal, NULL, 0, 0);
return s;
}
else {
@@ -645,7 +645,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
l = nl;
 
}
-   es = stmt_uselect(be, es, 
stmt_bool(be,1), cmp_equal, NULL, 0);
+   es = stmt_uselect(be, es, 
stmt_bool(be,1), cmp_equal, NULL, 0, 0);
} else /* need a condition */
cond_execution = es;
}
@@ -830,9 +830,9 @@ exp_bin(backend *be, sql_exp *e, stmt *l

predicate = stmt_const(be, predicate, 
stmt_bool(be, 1));
if (s->nrcols == 0)
-   s = stmt_uselect(be, predicate, 
s, cmp_equal, sel1, anti);
+   s = stmt_uselect(be, predicate, 
s, cmp_equal, sel1, anti, is_semantics(c));
else
-   s = stmt_uselect(be, predicate, 
sel1, cmp_equal, s, anti);
+   s = stmt_uselect(be, predicate, 
sel1, cmp_equal, s, anti, is_semantics(c));
}
sel1 = s;
}
@@ -857,9 +857,9 @@ exp_bin(backend *be, sql_exp *e, stmt *l

predicate = stmt_const(be, predicate, 
stmt_bool(be, 1));
if (s->nrcols == 0)
-   s = stmt_uselect(be, predicate, 
s, cmp_equal, sel2, anti);
+   s = stmt_uselect(be, predicate, 
s, cmp_equal, sel2, anti, 0);
 

MonetDB: default - Merged with linear-hashing

2020-02-27 Thread Pedro Ferreira
Changeset: 8e332bf1b4de for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8e332bf1b4de
Added Files:
sql/benchmarks/arno_flt/Tests/SingleServer
sql/benchmarks/nobench/Tests/SingleServer
sql/test/Users/Tests/metadataConsistency.sql
sql/test/Users/Tests/metadataConsistency.stable.err
sql/test/Users/Tests/metadataConsistency.stable.out
Removed Files:
sql/test/Tests/testlz4.lz4
Modified Files:
clients/odbc/driver/ODBCEnv.c
geom/monetdb5/geom.c
monetdb5/mal/mal_import.c
monetdb5/mal/mal_parser.c
monetdb5/modules/atoms/json.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_result.c
sql/benchmarks/nobench/Tests/nobench.sql
sql/benchmarks/nobench/Tests/nobench.stable.out
sql/server/rel_optimizer.c
sql/server/rel_propagate.c
sql/server/rel_schema.c
sql/storage/bat/bat_logger.c

sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.stable.out.Windows

sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out
sql/test/Users/Tests/All
sql/test/wlcr/Tests/All
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 1172 to 300 lines):

diff --git a/clients/odbc/driver/ODBCEnv.c b/clients/odbc/driver/ODBCEnv.c
--- a/clients/odbc/driver/ODBCEnv.c
+++ b/clients/odbc/driver/ODBCEnv.c
@@ -113,7 +113,7 @@ ODBCError *
 getEnvError(ODBCEnv *env)
 {
assert(isValidEnv(env));
-   return env->Error;;
+   return env->Error;
 }
 
 
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -4652,8 +4652,7 @@ mbrrelation_wkb(bit *out, wkb **geom1WKB
return ret;
 }
 
-/*returns true if the two
- * mbrs overlap */
+/*returns true if the two mbrs overlap */
 str
 mbrOverlaps(bit *out, mbr **b1, mbr **b2)
 {
@@ -5579,7 +5578,7 @@ wkbaHASH(const wkba *wArray)
 int
 wkbaCOMP(const wkba *l, const wkba *r)
 {
-   int i, res = 0;;
+   int i, res = 0;
 
//compare the number of items
if (l->itemsNum != r->itemsNum)
diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c
--- a/monetdb5/mal/mal_import.c
+++ b/monetdb5/mal/mal_import.c
@@ -136,7 +136,7 @@ malLoadScript(str name, bstream **fdin)
assert(c->glb == 0 || c->glb == oldglb); /* detect leak */ \
c->glb = oldglb; \
c->usermodule = oldusermodule; \
-   c->curmodule = oldcurmodule;; \
+   c->curmodule = oldcurmodule; \
c->curprg = oldprg;
 #define restoreClient \
restoreClient1 \
@@ -167,7 +167,7 @@ malInclude(Client c, str name, int listi
 
MalStkPtr oldglb = c->glb;
Module oldusermodule = c->usermodule;
-   Module oldcurmodule = c->curmodule; 
+   Module oldcurmodule = c->curmodule;
Symbol oldprg = c->curprg;
 
c->prompt = GDKstrdup("");  /* do not produce visible prompts */
@@ -253,14 +253,14 @@ malInclude(Client c, str name, int listi
  */
 str
 evalFile(str fname, int listing)
-{  
+{
Client c;
stream *fd;
str filename;
str msg = MAL_SUCCEED;
 
filename = malResolveFile(fname);
-   if (filename == NULL) 
+   if (filename == NULL)
throw(MAL, "mal.eval","could not open file: %s\n", fname);
fd = malOpenSource(filename);
GDKfree(filename);
@@ -475,7 +475,7 @@ callString(Client cntxt, str s, int list
if(msg == MAL_SUCCEED && cntxt->phase[0] != c->phase[0]){
cntxt->phase[0] = c->phase[0];
cntxt->state[0] = c->state[0];
-   msg = (str) (*cntxt->phase[0])(cntxt);  // force 
re-initialize client context
+   msg = (str) (*cntxt->phase[0])(cntxt);  // force 
re-initialize client context
}
//}
c->usermodule = 0; // keep it around
diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c
--- a/monetdb5/mal/mal_parser.c
+++ b/monetdb5/mal/mal_parser.c
@@ -116,7 +116,7 @@ parseError(Client cntxt, str msg)
if (old){
strcpy(new, old);
GDKfree(old);
-   } 
+   }
strcat(new,line);
strcat(new,marker);
 
@@ -129,7 +129,7 @@ parseError(Client cntxt, str msg)
  * This command should be executed at the beginning of a parse
  * request and each time we encounter EOL.
 */
-static void 
+static void
 echoInput(Client cntxt)
 {
char *c = CURRENT(cntxt);
@@ -229,7 +229,7 @@ idLength(Client cntxt)
// skip remainder
while (idCharacter2[(unsigned char) (*s)])
s++;
-   return (int) (s-t);;
+   return (int) (s-t);
 }
 
 /* Simple type identifiers can not be marked with a type variable. */
@@ -722,7 +722,7 @@ parseTypeId(Client cntxt, int defaultTyp
 
if (currChar(cntxt) !=

MonetDB: default - Merged with linear-hashing

2020-02-28 Thread Pedro Ferreira
Changeset: 541220c5cdec for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=541220c5cdec
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_gencode.c
sql/server/rel_dump.c
sql/server/rel_schema.c
sql/server/rel_select.c
sql/server/sql_privileges.c
sql/server/sql_semantic.c
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.err
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 630 to 300 lines):

diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -193,7 +193,7 @@ static int
char buf[64];
 
if (e->type == e_atom)
-   snprintf(buf,64,"A%d",e->flag);
+   snprintf(buf,64,"A%u",e->flag);
else
snprintf(buf,64,"A%s",exp_name(e));
varid = newVariable(curBlk, (char *)buf, strlen(buf), 
type);
diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -156,7 +156,7 @@ exp_print(mvc *sql, stream *fout, sql_ex
list *l = e->f;
exps_print(sql, fout, l, depth, refs, 0, 0);
} else { /* numbered arguments */
-   mnstr_printf(fout, "A%d", e->flag);
+   mnstr_printf(fout, "A%u", e->flag);
}
}
}   break;
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -358,9 +358,12 @@ column_constraint_type(mvc *sql, const c
}
 */
 
-   if (rsname) 
-   rs = mvc_bind_schema(sql, rsname);
-   else 
+   if (rsname) {
+   if (!(rs = mvc_bind_schema(sql, rsname))) {
+   (void) sql_error(sql, 02, SQLSTATE(3F000) 
"CONSTRAINT FOREIGN KEY: no such schema '%s'", rsname);
+   return res;
+   }
+   } else 
rs = cur_schema(sql);
rt = _bind_table(t, ss, rs, rtname);
if (!rt) {
@@ -532,9 +535,13 @@ table_foreign_key(mvc *sql, char *name, 
sql_schema *fs;
sql_table *ft;
 
-   if (rsname)
-   fs = mvc_bind_schema(sql, rsname);
-   else
+
+   if (rsname) {
+   if (!(fs = mvc_bind_schema(sql, rsname))) {
+   (void) sql_error(sql, 02, SQLSTATE(3F000) "CONSTRAINT 
FOREIGN KEY: no such schema '%s'", rsname);
+   return SQL_ERR;
+   }
+   } else 
fs = ss;
ft = mvc_bind_table(sql, fs, rtname);
/* self referenced table */
@@ -1151,7 +1158,7 @@ rel_create_view(sql_query *query, sql_sc
mvc *sql = query->sql;
char *name = qname_table(qname);
char *sname = qname_schema(qname);
-   sql_schema *s = NULL;
+   sql_schema *s = cur_schema(sql);
sql_table *t = NULL;
int instantiate = (sql->emode == m_instantiate || !persistent);
int deps = (sql->emode == m_deps);
@@ -1162,12 +1169,9 @@ rel_create_view(sql_query *query, sql_sc
(void) check;   /* Stefan: unused!? */
if (sname && !(s = mvc_bind_schema(sql, sname))) 
return sql_error(sql, 02, SQLSTATE(3F000) "CREATE VIEW: no such 
schema '%s'", sname);
-   if (s == NULL)
-   s = cur_schema(sql);
 
-   if (create && (!mvc_schema_privs(sql, s) && !(isTempSchema(s) && 
persistent == SQL_LOCAL_TEMP))) {
+   if (create && (!mvc_schema_privs(sql, s) && !(isTempSchema(s) && 
persistent == SQL_LOCAL_TEMP)))
return sql_error(sql, 02, SQLSTATE(42000) "%s VIEW: access 
denied for %s to schema '%s'", base, stack_get_string(sql, "current_user"), 
s->base.name);
-   }
 
if (create && (t = mvc_bind_table(sql, s, name)) != NULL) {
if (replace) {
@@ -1288,12 +1292,10 @@ rel_drop_type(mvc *sql, dlist *qname, in
 {
char *name = qname_table(qname);
char *sname = qname_schema(qname);
-   sql_schema *s = NULL;
+   sql_schema *s = cur_schema(sql);
 
if (sname && !(s = mvc_bind_schema(sql, sname))) 
return sql_error(sql, 02, SQLSTATE(3F000) "DROP TYPE: no such 
schema '%s'", sname);
-   if (s == NULL)
-   s = cur_schema(sql);
 
if (schema_bind_type(sql, s, name) == NULL) {
return sql_error(sql, 02, SQLSTATE(42S01) "DROP TYPE: type '%s' 
does not exist", name);
@@ -1308,12 +1310,10 @@ rel_create_type(mvc *sql, dlist *qname, 
 {

MonetDB: default - Merged with linear-hashing

2020-02-28 Thread Pedro Ferreira
Changeset: d9db2840e7f0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d9db2840e7f0
Modified Files:
sql/backends/monet5/sql_cat.c
sql/server/rel_psm.c
sql/server/rel_schema.c
sql/test/Tests/ifexists-views.sql
testing/Mtest.py.in
Branch: default
Log Message:

Merged with linear-hashing


diffs (153 lines):

diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c
--- a/sql/backends/monet5/sql_cat.c
+++ b/sql/backends/monet5/sql_cat.c
@@ -719,9 +719,9 @@ drop_func(mvc *sql, char *sname, char *n
if (mvc_drop_func(sql, s, func, action))
throw(SQL,"sql.drop_func", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
}
-   } else if (fid == -2) { //if exists option
+   } else if (fid == -2) { /* if exists option */
return MAL_SUCCEED;
-   } else { //fid == -1
+   } else { /* fid == -1 */
node *n = NULL;
list *list_func = schema_bind_func(sql, s, name, type);
int res;
diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -1113,21 +1113,21 @@ rel_drop_func(mvc *sql, dlist *qname, dl
char *F = NULL, *fn = NULL;
 
FUNC_TYPE_STR(type)
-   (void) fn;
 
-   if (sname && !(s = mvc_bind_schema(sql, sname)))
+   if (sname && !(s = mvc_bind_schema(sql, sname)) && !if_exists)
return sql_error(sql, 02, SQLSTATE(3F000) "DROP %s: no such 
schema '%s'", F, sname);
 
-   func = resolve_func(sql, s, name, typelist, type, "DROP", if_exists);
+   if (s)
+   func = resolve_func(sql, s, name, typelist, type, "DROP", 
if_exists);
if (!func && !sname) {
s = tmp_schema(sql);
func = resolve_func(sql, s, name, typelist, type, "DROP", 
if_exists);
}
-   if (func)
+   if (func && s)
return rel_drop_function(sql->sa, s->base.name, name, 
func->base.id, type, drop_action);
-   else if (if_exists && !sql->session->status)
-   return rel_drop_function(sql->sa, s->base.name, name, -2, type, 
drop_action);
-   return NULL;
+   if (if_exists)
+   return rel_drop_function(sql->sa, sname, name, -2, type, 
drop_action);
+   return sql_error(sql, 02, SQLSTATE(42000) "DROP %s: %s %s not found", 
F, fn, name);
 }
 
 static sql_rel* 
@@ -1346,8 +1346,11 @@ drop_trigger(mvc *sql, dlist *qname, int
const char *tname = qname_table(qname);
sql_schema *ss = cur_schema(sql);
 
-   if (sname && !(ss = mvc_bind_schema(sql, sname)))
+   if (sname && !(ss = mvc_bind_schema(sql, sname))) {
+   if (if_exists)
+   return rel_drop_trigger(sql, sname, tname, if_exists);
return sql_error(sql, 02, SQLSTATE(3F000) "DROP TRIGGER: no 
such schema '%s'", sname);
+   }
 
if (!mvc_schema_privs(sql, ss)) 
return sql_error(sql, 02, SQLSTATE(3F000) "DROP TRIGGER: access 
denied for %s to schema '%s'", stack_get_string(sql, "current_user"), 
ss->base.name);
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -1057,12 +1057,10 @@ rel_create_table(sql_query *query, sql_s
sname = s->base.name;
 
if (mvc_bind_table(sql, s, name)) {
-   if (if_not_exists) {
+   char *cd = (temp == SQL_DECLARED_TABLE)?"DECLARE":"CREATE";
+   if (if_not_exists)
return rel_psm_block(sql->sa, new_exp_list(sql->sa));
-   } else {
-   char *cd = (temp == 
SQL_DECLARED_TABLE)?"DECLARE":"CREATE";
-   return sql_error(sql, 02, SQLSTATE(42S01) "%s TABLE: 
name '%s' already in use", cd, name);
-   }
+   return sql_error(sql, 02, SQLSTATE(42S01) "%s TABLE: name '%s' 
already in use", cd, name);
} else if (temp != SQL_DECLARED_TABLE && (!mvc_schema_privs(sql, s) && 
!(isTempSchema(s) && temp == SQL_LOCAL_TEMP))){
return sql_error(sql, 02, SQLSTATE(42000) "CREATE TABLE: 
insufficient privileges for user '%s' in schema '%s'", stack_get_string(sql, 
"current_user"), s->base.name);
} else if (table_elements_or_subquery->token == SQL_CREATE_TABLE) {
@@ -1379,24 +1377,17 @@ rel_create_schema(sql_query *query, dlis
char *auth = schema_auth(auth_name);
sqlid auth_id = sql->role_id;
 
-   if (auth && (auth_id = sql_find_auth(sql, auth)) < 0) {
-   sql_error(sql, 02, SQLSTATE(28000) "CREATE SCHEMA: no such 
authorization '%s'", auth);
-   return NULL;
-   }
-   if (sql->user_id != USER_MONETDB && sql->role_id != ROLE_SYSADMIN) {
-   sql_error(sql, 02, SQLSTATE(42000) "CREATE SCHEMA: insufficient 
privileges for user '%s'", stack_get_string(sql, "current_user")

MonetDB: default - Merged with linear-hashing

2020-03-02 Thread Pedro Ferreira
Changeset: 9d75acab2037 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9d75acab2037
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
monetdb5/modules/kernel/alarm.c
monetdb5/modules/kernel/alarm.mal
monetdb5/modules/mal/clients.c
monetdb5/modules/mal/sysmon.c
sql/backends/monet5/sql_upgrades.c
sql/scripts/22_clients.sql
sql/scripts/25_debug.sql
sql/scripts/26_sysmon.sql
sql/test/Users/Tests/sessioncontrol.stable.err
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/sys-schema/Tests/systemfunctions.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out.int128
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 1008 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -565,9 +565,9 @@ stdout of test 'MAL-signatures` in direc
 [ "aggr",  "variancep","command aggr.variancep(b:bat[:any_2]):dbl ",   
"ALGvariancep;","Gives the variance of all tail values" ]
 [ "alarm", "ctime","unsafe command alarm.ctime():str ",
"ALARMctime;",  "Return the current time as a C-time string."   ]
 [ "alarm", "epoch","unsafe command alarm.epoch():int ",
"ALARMepoch;",  "Return time since Jan 1, 1970 in seconds." ]
-[ "alarm", "sleep","unsafe pattern 
alarm.sleep(msecs:bat[:int]):bat[:int] ",   "ALARMsleep;",  "Sleep a few 
milliseconds and return the slept value"   ]
-[ "alarm", "sleep","unsafe pattern alarm.sleep(msecs:int):int ",   
"ALARMsleep;",  "Sleep a few milliseconds and return the slept value"   ]
-[ "alarm", "sleep","unsafe pattern alarm.sleep(msecs:int):void ",  
"ALARMsleep;",  "Sleep a few milliseconds"  ]
+[ "alarm", "sleep","unsafe pattern alarm.sleep(msecs:any_1):any_1 
",   "ALARMsleep;",  "Sleep a few milliseconds and return the slept value"  
 ]
+[ "alarm", "sleep","unsafe pattern alarm.sleep(msecs:any_1):void 
","ALARMsleep;",  "Sleep a few milliseconds"  ]
+[ "alarm", "sleep","unsafe pattern 
alarm.sleep(msecs:bat[:any_1]):bat[:any_1] ",   "ALARMsleep;",  "Sleep a few 
milliseconds and return the slept value"   ]
 [ "alarm", "time", "unsafe command alarm.time():int ", "ALARMtime;",   
"Return time since program start in milliseconds."  ]
 [ "alarm", "usec", "unsafe command alarm.usec():lng ", "ALARMusec;",   
"Return time since Jan 1, 1970 in microseconds."]
 [ "algebra",   "antijoin", "function algebra.antijoin(l:bat[:any_1], 
r:bat[:any_1], sl:bat[:oid], sr:bat[:oid], nil_matches:bit, estimate:lng) 
(X_0:bat[:oid], X_1:bat[:oid]);",   "", ""  ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -674,9 +674,9 @@ stdout of test 'MAL-signatures` in direc
 [ "aggr",  "variancep","command aggr.variancep(b:bat[:any_2]):dbl ",   
"ALGvariancep;","Gives the variance of all tail values" ]
 [ "alarm", "ctime","unsafe command alarm.ctime():str ",
"ALARMctime;",  "Return the current time as a C-time string."   ]
 [ "alarm", "epoch","unsafe command alarm.epoch():int ",
"ALARMepoch;",  "Return time since Jan 1, 1970 in seconds." ]
-[ "alarm", "sleep","unsafe pattern 
alarm.sleep(msecs:bat[:int]):bat[:int] ",   "ALARMsleep;",  "Sleep a few 
milliseconds and return the slept value"   ]
-[ "alarm", "sleep","unsafe pattern alarm.sleep(msecs:int):int ",   
"ALARMsleep;",  "Sleep a few milliseconds and return the slept value"   ]
-[ "alarm", "sleep","unsafe pattern alarm.sleep(msecs:int):void ",  
"ALARMsleep;",  "Sleep a few milliseconds"  ]
+[ "alarm", "sleep","unsafe pattern alarm.sleep(msecs:any_1):any_1 
",   "ALARMsleep;",  "Sleep a few milliseconds and return the slept value"  
 ]
+[ "alarm", "sleep","unsafe pattern alarm.sleep(msecs:any_1):void 
","ALARMsleep;",  "Sleep a few milliseconds"  ]
+[ "alarm", "sleep","unsafe pattern 
alarm.sleep(msecs:bat[:any_1]):bat[:any_1] ",   "ALARMsleep;",  "Sleep a few 
milliseconds and return the slept value"   ]
 [ "alarm", "time", "unsafe command alarm.time():int ", "ALARMtime;",   
"Return time since program start in milliseconds."  ]
 [ "alarm", "usec", "unsafe command alarm.usec():lng ", "ALARMusec;",   
"Return time since Jan 1, 1970 in microseconds."]
 [ "algebra",   "antijo

MonetDB: default - Merged with linear-hashing

2020-03-03 Thread Pedro Ferreira
Changeset: a87d6754f7f1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a87d6754f7f1
Added Files:
sql/ChangeLog.linear-hashing
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
clients/Tests/exports.stable.out
debian/control
monetdb5/mal/mal_client.c
monetdb5/modules/mal/clients.c
monetdb5/modules/mal/clients.h
monetdb5/modules/mal/clients.mal
monetdb5/modules/mal/sysmon.c
sql/backends/monet5/sql_upgrades.c
sql/scripts/26_sysmon.sql
sql/server/rel_select.c

sql/test/BugTracker-2010/Tests/TypeException_with_missing_function.Bug-2674.stable.err
sql/test/BugTracker-2012/Tests/create_function.Bug-3172.stable.err

sql/test/BugTracker-2012/Tests/table_function_with_column_subselects.Bug-3172.stable.err

sql/test/BugTracker-2012/Tests/table_returning_func_returns_too_many_columns.Bug-3077.stable.err

sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.err
sql/test/BugTracker-2016/Tests/invalidcolumns.Bug-3968.stable.err

sql/test/BugTracker-2017/Tests/udf_crash_subquery_scalar_paramters.Bug-6399.stable.err

sql/test/BugTracker-2018/Tests/crash-after-call-non-existing-loader.stable.err
sql/test/Tests/drop-function-if-exists.stable.err
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.err
sql/test/sys-schema/Tests/systemfunctions.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out.int128
testing/Mtest.py.in
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 1507 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -10466,7 +10466,7 @@ stdout of test 'MAL-signatures` in direc
 [ "clients",   "stopsession",  "pattern clients.stopsession(sid:int):void ",   
"CLTstopSession;",  "Stop a particular session" ]
 [ "clients",   "stopsession",  "pattern clients.stopsession(sid:sht):void ",   
"CLTstopSession;",  ""  ]
 [ "clients",   "suspend",  "pattern clients.suspend(id:int):void ",
"CLTsuspend;",  "Put a client process to sleep for some time.\nIt will simple 
sleep for a second at a time, until\nthe awake bit has been set in its 
descriptor"]
-[ "clients",   "wakeup",   "command clients.wakeup(id:int):void ", 
"CLTwakeup;",   "Wakeup a client process"   ]
+[ "clients",   "wakeup",   "pattern clients.wakeup(id:int):void ", 
"CLTwakeup;",   "Wakeup a client process"   ]
 [ "color", "#fromstr", "command color.#fromstr():void ",   
"color_fromstr;",   ""  ]
 [ "color", "#tostr",   "command color.#tostr():void ", "color_tostr;", 
""  ]
 [ "color", "blue", "command color.blue(c:color):int ", "CLRblue;", 
"Extracts blue component from a color atom" ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -14872,7 +14872,7 @@ stdout of test 'MAL-signatures` in direc
 [ "clients",   "stopsession",  "pattern clients.stopsession(sid:int):void ",   
"CLTstopSession;",  "Stop a particular session" ]
 [ "clients",   "stopsession",  "pattern clients.stopsession(sid:sht):void ",   
"CLTstopSession;",  ""  ]
 [ "clients",   "suspend",  "pattern clients.suspend(id:int):void ",
"CLTsuspend;",  "Put a client process to sleep for some time.\nIt will simple 
sleep for a second at a time, until\nthe awake bit has been set in its 
descriptor"]
-[ "clients",   "wakeup",   "command clients.wakeup(id:int):void ", 
"CLTwakeup;",   "Wakeup a client process"   ]
+[ "clients",   "wakeup",   "pattern clients.wakeup(id:int):void ", 
"CLTwakeup;",   "Wakeup a client process"   ]
 [ "color", "#fromstr", "command color.#fromstr():void ",   
"color_fromstr;",   ""  ]
 [ "color", "#tostr",   "command color.#tostr():void ", "color_tostr;", 
""  ]
 [ "color", "blue", "command color.blue(c:color):int ", "CLRblue;", 
"Extracts blue component from a color atom" ]
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -992,7 +992,7 @@ str CLTshutdown(Client cntxt, MalBlkPtr 
 str CLTstop(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CLTstopSession(Client cntxt, MalBlkPtr mb, MalS

MonetDB: default - Merged with linear-hashing

2020-03-03 Thread Pedro Ferreira
Changeset: 4438e1e6e0f1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4438e1e6e0f1
Modified Files:
geom/sql/functions/Tests/ST_IsSimple.stable.out
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_upgrades.c
sql/rel.txt
sql/server/rel_select.c

sql/test/BugTracker-2010/Tests/LIMIT_OFFSET_big-endian.Bug-2622.stable.out
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128

sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 1700 to 300 lines):

diff --git a/geom/sql/functions/Tests/ST_IsSimple.stable.out 
b/geom/sql/functions/Tests/ST_IsSimple.stable.out
--- a/geom/sql/functions/Tests/ST_IsSimple.stable.out
+++ b/geom/sql/functions/Tests/ST_IsSimple.stable.out
@@ -28,7 +28,7 @@ stdout of test 'ST_IsSimple` in director
 % %1 # name
 % boolean # type
 % 5 # length
-[ true ]
+[ false]
 #SELECT ST_IsSimple(ST_GeomFromText('LINESTRING(1 1,2 2,2 3.5,1 3,1 2,2 1)'));
 % . # table_name
 % %1 # name
@@ -43,7 +43,7 @@ stdout of test 'ST_IsSimple` in director
 % %1 # name
 % boolean # type
 % 5 # length
-[ true ]
+[ false]
 #drop table geo;
 #create table geo (g geometry(linestring, 4326));
 #insert into geo values(ST_GeomFromText('LINESTRING(1 1,2 2,2 3.5,1 3,1 2,2 
1)', 4326));
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2795,11 +2795,12 @@ sql_reorder(backend *be, stmt *order, st
 }
 
 static sql_exp*
-topn_limit( sql_rel *rel )
+topn_limit(mvc *sql, sql_rel *rel)
 {
if (rel->exps) {
sql_exp *limit = rel->exps->h->data;
-
+   if (exp_is_null(sql, limit)) /* If the limit is NULL, ignore 
the value */
+   return NULL;
return limit;
}
return NULL;
@@ -2826,7 +2827,7 @@ rel2bin_project(backend *be, sql_rel *re
stmt *l = NULL;
 
if (topn) {
-   sql_exp *le = topn_limit(topn);
+   sql_exp *le = topn_limit(sql, topn);
sql_exp *oe = topn_offset(topn);
 
if (!le) { /* Don't push only offset */
@@ -3185,7 +3186,7 @@ rel2bin_topn(backend *be, sql_rel *rel, 
if (!sub) 
return NULL;
 
-   le = topn_limit(rel);
+   le = topn_limit(sql, rel);
oe = topn_offset(rel);
 
n = sub->op4.lval->h;
@@ -3245,13 +3246,12 @@ rel2bin_sample(backend *be, sql_rel *rel
const char *cname = column_name(sql->sa, sc);
const char *tname = table_name(sql->sa, sc);
 
-   sample_size = exp_bin(be, rel->exps->h->data, NULL, NULL, NULL, 
NULL, NULL, NULL);
-   if (!sample_size)
-   sample_size = stmt_atom_lng_nil(be);
+if (!(sample_size = exp_bin(be, rel->exps->h->data, NULL, 
NULL, NULL, NULL, NULL, NULL)))
+   return NULL;
 
if (rel->exps->cnt == 2) {
seed = exp_bin(be, rel->exps->h->next->data, NULL, 
NULL, NULL, NULL, NULL, NULL);
-   if(!seed)
+   if (!seed)
return NULL;
}
 
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -2485,9 +2485,6 @@ sql_update_linear_hashing(Client c, mvc 
"update sys.functions set system = true where schema_id 
= (select id from sys.schemas where name = 'sys')"
" and name = 'queue' and type = %d;\n", (int) F_UNION);
pos += snprintf(buf + pos, bufsize - pos,
-  

MonetDB: default - Merged with linear-hashing

2020-03-04 Thread Pedro Ferreira
Changeset: 32d8c9110131 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=32d8c9110131
Modified Files:
monetdb5/modules/kernel/mmath.c
monetdb5/modules/mal/txtsim.c
sql/backends/monet5/sql.c
sql/common/sql_types.c
sql/jdbc/tests/Tests/Test_PSsomeamount.timeout
sql/server/rel_select.c
sql/server/sql_atom.c
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128

sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.err
sql/test/miscellaneous/Tests/simple_selects.stable.out
sql/test/subquery/Tests/subquery3.sql
sql/test/subquery/Tests/subquery3.stable.err
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 746 to 300 lines):

diff --git a/monetdb5/modules/kernel/mmath.c b/monetdb5/modules/kernel/mmath.c
--- a/monetdb5/modules/kernel/mmath.c
+++ b/monetdb5/modules/kernel/mmath.c
@@ -312,4 +312,3 @@ MATHpi(dbl *pi)
*pi = 3.14159265358979323846;
return MAL_SUCCEED;
 }
-
diff --git a/monetdb5/modules/mal/txtsim.c b/monetdb5/modules/mal/txtsim.c
--- a/monetdb5/modules/mal/txtsim.c
+++ b/monetdb5/modules/mal/txtsim.c
@@ -107,6 +107,11 @@ levenshtein_impl(int *result, str *S, st
int sz; /* number of cells in matrix */
int diag2 = 0, cost2 = 0;
 
+   if (strNil(*S) || strNil(*T)) {
+   *result = int_nil;
+   return MAL_SUCCEED;
+   }
+
/* Step 1 */
n = (int) strlen(s);/* 64bit: assume strings are less than 2 GB */
m = (int) strlen(t);
@@ -812,6 +817,11 @@ fstrcmp_impl(dbl *ret, str *S1, str *S2,
static int *fdiag_buf;
static size_t fdiag_max;
 
+   if (strNil(*S1) || strNil(*S2) || is_dbl_nil(*minimum)) {
+   *ret = dbl_nil;
+   return MAL_SUCCEED;
+   }
+
/* set the info for each string.  */
string[0].data = string1;
string[0].data_length = (int) strlen(string1); /* 64bit: assume string 
not too long */
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -3544,6 +3544,10 @@ str
 second_interval_2_daytime(daytime *res, const lng *s, const int *digits)
 {
daytime d;
+   if (is_lng_nil(*s)) {
+   *res = daytime_nil;
+   return MAL_SUCCEED;
+   }
d = daytime_add_usec(daytime_create(0, 0, 0, 0), *s * 1000);
return daytime_2time_daytime(res, &d, digits);
 }
@@ -3802,32 +3806,38 @@ str
 month_interval(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
int *ret = getArgReference_int(stk, pci, 0);
-   int k = digits2ek(*getArgReference_int(stk, pci, 2));
-   int r;
+   int k = digits2ek(*getArgReference_int(stk, pci, 2)), r = 0, isnil = 0;
 
(void) cntxt;
-   (void) mb;
+   *ret = int_nil;
switch (getArgType(mb, pci, 1)) {
case TYPE_bte:
r = stk->stk[getArg(pci, 1)].val.btval;
+   isnil = (stk->stk[getArg(pci, 1)].val.btval == bte_nil);
break;
case TYPE_sht:
r = stk->stk[getArg(pci, 1)].val.shval;
+   isnil = (stk->stk[getArg(pci, 1)].val.shval == sht_nil);
break;
case TYPE_int:
r = stk->stk[getArg(pci, 1)].val.ival;
+   isnil = (stk->stk[getArg(pci, 1)].val.ival == int_nil);
break;
case TYPE_lng:
r = (int) stk->stk[getArg(pci, 1)].val.lval;
+   isnil = (stk->stk[getArg(pci, 1)].val.lval == lng_nil);
break;
 #ifdef HAVE_HGE
case TYPE_hge

MonetDB: default - Merged with linear-hashing

2020-03-05 Thread Pedro Ferreira
Changeset: 1cb74d115c00 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1cb74d115c00
Removed Files:
sql/test/rdf/Tests/q8_v_small.reqtests
sql/test/rdf/Tests/q8_v_small.sql
sql/test/rdf/Tests/q8_v_small.stable.err
sql/test/rdf/Tests/q8_v_small.stable.out
Modified Files:
monetdb5/modules/mal/mkey.c
monetdb5/modules/mal/pcre.c
sql/server/rel_rel.h
sql/server/rel_select.c
sql/server/rel_updates.c
sql/server/sql_atom.c
sql/server/sql_semantic.c
sql/test/BugTracker-2009/Tests/AVG_of_SQRT.SF-2757642.timeout
sql/test/BugTracker-2015/Tests/window_function_crash.Bug-3861.sql
sql/test/BugTracker-2015/Tests/window_function_crash.Bug-3861.stable.err
sql/test/BugTracker-2015/Tests/window_function_crash.Bug-3861.stable.out
sql/test/merge-partitions/Tests/mergepart20.sql
sql/test/merge-partitions/Tests/mergepart20.stable.out
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.out
sql/test/rdf/Tests/All
sql/test/rdf/Tests/q8_v.stable.err
sql/test/rdf/Tests/q8_v.stable.out
sql/test/rdf/Tests/q8_v.timeout
sql/test/subquery/Tests/correlated.stable.err
sql/test/subquery/Tests/subquery.sql
sql/test/subquery/Tests/subquery.stable.err
sql/test/subquery/Tests/subquery.stable.out
sql/test/subquery/Tests/subquery3.sql
sql/test/subquery/Tests/subquery3.stable.err
sql/test/subquery/Tests/subquery3.stable.out
sql/test/subquery/Tests/subquery4.sql
sql/test/subquery/Tests/subquery4.stable.err
sql/test/subquery/Tests/subquery4.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 2627 to 300 lines):

diff --git a/monetdb5/modules/mal/mkey.c b/monetdb5/modules/mal/mkey.c
--- a/monetdb5/modules/mal/mkey.c
+++ b/monetdb5/modules/mal/mkey.c
@@ -51,6 +51,8 @@ MKEYhash(Client cntxt, MalBlkPtr mb, Mal
val= getArgReference(stk,p,1);
switch (ATOMstorage(tpe)) {
case TYPE_void:
+   *res = lng_nil; /* It can be called from SQL */
+   break;
case TYPE_bat:
case TYPE_ptr:
// illegal types, avoid falling into the default case.
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -1542,7 +1542,6 @@ PCREindex(int *res, const pcre *pattern,
 #endif
 }
 
-
 str
 PCREpatindex(int *ret, const str *pat, const str *val)
 {
@@ -1550,6 +1549,11 @@ PCREpatindex(int *ret, const str *pat, c
pcre *re = NULL;
char *ppat = NULL, *msg;
 
+   if (strNil(*pat) || strNil(*val)) {
+   *ret = int_nil;
+   return MAL_SUCCEED;
+   }
+
if ((msg = pat2pcre(&ppat, *pat)) != MAL_SUCCEED)
return msg;
if ((msg = pcre_compile_wrap(&re, ppat, FALSE)) != MAL_SUCCEED) {
@@ -1591,7 +1595,6 @@ PCREquote(str *ret, const str *val)
return MAL_SUCCEED;
 }
 
-
 str
 PCREsql2pcre(str *ret, const str *pat, const str *esc)
 {
diff --git a/sql/server/rel_rel.h b/sql/server/rel_rel.h
--- a/sql/server/rel_rel.h
+++ b/sql/server/rel_rel.h
@@ -13,31 +13,35 @@
 #include "sql_relation.h"
 #include "sql_semantic.h"
 
-#define sql_from 1
-#define sql_where2
-#define sql_sel  4
-#define sql_having   8
-#define sql_orderby 16
-#define sql_groupby 32 //ORed
-#define sql_aggr64 //ORed
-#define sql_farg   128 //ORed
-#define sql_window 256 //ORed
-#define sql_join   512 //ORed
-#define sql_outer 1024 //ORed
-#define sql_group_totals 2048 //ORed
+#define sql_from (1 << 0)
+#define sql_where(1 << 1)
+#define sql_sel  (1 << 2)
+#define sql_having   (1 << 3)
+#define sql_orderby  (1 << 4)
+#define sql_groupby  (1 << 5)  //ORed
+#define sql_aggr (1 << 6)  //ORed
+#define sql_farg (1 << 7)  //ORed
+#define sql_window   (1 << 8)  //ORed
+#define sql_join (1 << 9)  //ORed
+#define sql_outer(1 << 10) //ORed
+#define sql_group_totals (1 << 11) //ORed
+#define sql_update_set   (1 << 12) //ORed
+#define sql_update_where (1 << 13) //ORed
 
-#define is_sql_from(X)((X & sql_from) == sql_from)
-#define is_sql_where(X)   ((X & sql_where) == sql_where)
-#define is_sql_sel(X) ((X & sql_sel) == sql_sel)
-#define is_sql_having(X)  ((X & sql_having) == sql_having)
-#define is_sql_orderby(X) ((X & sql_orderby) == sql_orderby)
-#define is_sql_groupby(X) ((X & sql_groupby) == sql_groupby)
-#define is_sql_aggr(X)((X & sql_aggr) == sql_aggr)
-#define is_sql_farg(X)((X & sql_farg) == sql_farg)
-#define is_sql_window(X)  ((X & sql_window) == sql_window)
-#define is_sql_join(X)((X & sql_join) == sql_join)
-#define is_sql_outer(X)   ((X & sql_outer) == sql_outer)
+#define is_sql_from(X) ((X & sql_from) == sq

MonetDB: default - Merged with linear-hashing

2020-03-06 Thread Pedro Ferreira
Changeset: b165c80af1f8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b165c80af1f8
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
monetdb5/modules/mal/wlc.mal
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_cat.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sqlcatalog.mal
sql/backends/monet5/wlr.mal
sql/scripts/22_clients.sql
sql/server/rel_propagate.c
sql/server/rel_psm.c
sql/server/rel_rel.h
sql/server/rel_select.c
sql/server/rel_updates.c
sql/test/BugTracker-2015/Tests/window_function_crash.Bug-3861.stable.err
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/subquery/Tests/subquery3.sql
sql/test/subquery/Tests/subquery3.stable.err
sql/test/subquery/Tests/subquery4.sql
sql/test/subquery/Tests/subquery4.stable.err
sql/test/subquery/Tests/subquery4.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 840 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -11572,6 +11572,7 @@ stdout of test 'MAL-signatures` in direc
 [ "sqlcatalog","alter_add_value_partition","pattern 
sqlcatalog.alter_add_value_partition(sname:str, mtnme:str, psnme:str, 
ptnme:str, nills:int, update:int):void ",
"SQLalter_add_value_partition;","Catalog operation 
alter_add_value_partition"   ]
 [ "sqlcatalog","alter_add_value_partition","pattern 
sqlcatalog.alter_add_value_partition(sname:str, mtnme:str, psnme:str, 
ptnme:str, nills:int, update:int, arg:any...):void ",
"SQLalter_add_value_partition;","Catalog operation 
alter_add_value_partition"   ]
 [ "sqlcatalog","alter_del_table",  "pattern 
sqlcatalog.alter_del_table(sname:str, mtnme:str, psnme:str, ptnme:str, 
action:int):void ", "SQLalter_del_table;",  "Catalog operation 
alter_del_table" ]
+[ "sqlcatalog","alter_seq","pattern 
sqlcatalog.alter_seq(sname:str, seqname:str, seq:ptr, val:bat[:lng]):void ",   
"SQLalter_seq;","Catalog operation alter_seq"   ]
 [ "sqlcatalog","alter_seq","pattern 
sqlcatalog.alter_seq(sname:str, seqname:str, seq:ptr, val:lng):void ", 
"SQLalter_seq;","Catalog operation alter_seq"   ]
 [ "sqlcatalog","alter_set_table",  "pattern 
sqlcatalog.alter_set_table(sname:str, tnme:str, access:int):void ",
"SQLalter_set_table;",  "Catalog operation alter_set_table" ]
 [ "sqlcatalog","alter_table",  "pattern 
sqlcatalog.alter_table(sname:str, tname:str, tbl:ptr, action:int):void ",  
"SQLalter_table;",  "Catalog operation alter_table" ]
@@ -11789,6 +11790,7 @@ stdout of test 'MAL-signatures` in direc
 [ "wlc",   "alter_add_value_partition","pattern 
wlc.alter_add_value_partition(sname:str, mtnme:str, psnme:str, ptnme:str, 
nills:int, update:int):void ",   "WLCgeneric;",  "Catalog operation 
alter_add_value_partition"   ]
 [ "wlc",   "alter_add_value_partition","pattern 
wlc.alter_add_value_partition(sname:str, mtnme:str, psnme:str, ptnme:str, 
nills:int, update:int, arg:str...):void ",   "WLCgeneric;",  "Catalog operation 
alter_add_value_partition"   ]
 [ "wlc",   "alter_del_table",  "pattern wlc.alter_del_table(sname:str, 
mtnme:str, psnme:str, ptnme:str, action:int):void ","WLCgeneric;",  
"Catalog operation alter_del_table" ]
+[ "wlc",   "alter_seq","pattern wlc.alter_seq(sname:str, seqname:str, 
seq:ptr, val:bat[:lng]):void ",  "WLCgeneric;",  "Catalog operation alter_seq"  
 ]
 [ "wlc",   "alter_seq","pattern wlc.alter_seq(sname:str, seqname:str, 
val:lng):void ", "WLCgeneric;",  "Catalog operation alter_seq"   ]
 [ "wlc",   "alter_set_table",  "pattern wlc.alter_set_table(sname:str, 
tnme:str, access:int):void ",   "WLCgeneric;",  "Catalog operation 
alter_set_table" ]
 [ "wlc",   "alter_table",  "pattern wlc.alter_table(sname:str, tname:str, 
action:int):void ",  "WLCgeneric;",  "Catalog operation alter_table" ]
@@ -11858,6 +11860,7 @@ stdout of test 'MAL-signatures` in direc
 [ "wlr",   "alter_add_value_partition","pattern 
wlr.alter_add_value_partition(sname:str, mtnme:str, psnme:str, ptnme:str, 
nills:int, update:int):void ",   "WLRgeneric;",  "Catalog operation 
alter_add_value_partition"   ]
 [ "wlr",   "alter_add_value_partition","pattern 
wlr.alter_add_value_partition(sname:str, mtnme:str, psnme:str, ptnme:str, 
nills:int, update:int, arg:str...):void ",   "WLRgeneric;",  "Catalog operation 
alter_add_value_partition"   ]
 [ "wlr",   "alter_del_table", 

MonetDB: default - Merged with linear-hashing

2020-03-06 Thread Pedro Ferreira
Changeset: 33b3ac62dc82 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=33b3ac62dc82
Modified Files:
sql/backends/monet5/rel_bin.c
sql/include/sql_relation.h
sql/rel.txt
sql/server/rel_dump.c
sql/server/rel_optimizer.c
sql/server/rel_rel.c
sql/server/rel_unnest.c
sql/test/subquery/Tests/subquery3.sql
sql/test/subquery/Tests/subquery4.sql
sql/test/subquery/Tests/subquery4.stable.err
sql/test/subquery/Tests/subquery4.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out.int128
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 335 to 300 lines):

diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -1613,7 +1613,7 @@ rel2bin_table(backend *be, sql_rel *rel,
node *en, *n;
sql_exp *op = rel->r;
 
-   if (rel->flag == 2) {
+   if (rel->flag == TRIGGER_WRAPPER) {
trigger_input *ti = rel->l;
l = sa_list(sql->sa);
 
@@ -1693,11 +1693,7 @@ rel2bin_table(backend *be, sql_rel *rel,
}
}
}
-   if (rel->flag == TABLE_PROD_FUNC && sub && sub->nrcols) { 
-   assert(0);
-   list_merge(l, sub->op4.lval, NULL);
-   osub = sub;
-   }
+   assert(rel->flag != TABLE_PROD_FUNC || !sub || !(sub->nrcols));
sub = stmt_list(be, l);
} else if (rel->l) { /* handle sub query via function */
int i;
@@ -3614,7 +3610,7 @@ sql_stack_add_inserted( mvc *sql, const 
 
append(exps, ne);
}
-   r = rel_table_func(sql->sa, NULL, NULL, exps, 2);
+   r = rel_table_func(sql->sa, NULL, NULL, exps, TRIGGER_WRAPPER);
r->l = ti;
 
return stack_push_rel_view(sql, name, r) ? 1 : 0;
@@ -4561,7 +4557,7 @@ sql_stack_add_updated(mvc *sql, const ch
append(exps, ne);
}
}
-   r = rel_table_func(sql->sa, NULL, NULL, exps, 2);
+   r = rel_table_func(sql->sa, NULL, NULL, exps, TRIGGER_WRAPPER);
r->l = ti;
 
/* put single table into the stack with 2 names, needed for the psm 
code */
@@ -4837,7 +4833,7 @@ sql_stack_add_deleted(mvc *sql, const ch
 
append(exps, ne);
}
-   r = rel_table_func(sql->sa, NULL, NULL, exps, 2);
+   r = rel_table_func(sql->sa, NULL, NULL, exps, TRIGGER_WRAPPER);
r->l = ti;
 
return stack_push_rel_view(sql, name, r) ? 1 : 0;
diff --git a/sql/include/sql_relation.h b/sql/include/sql_relation.h
--- a/sql/include/sql_relation.h
+++ b/sql/include/sql_relation.h
@@ -59,8 +59,11 @@ typedef struct expression {
void *p;/* properties for the optimizer */
 } sql_exp;
 
-#define TABLE_PROD_FUNC0
-#define TABLE_FROM_RELATION1
+#define TABLE_PROD_FUNC1
+#define TABLE_FROM_RELATION2
+#define TRIGGER_WRAPPER4
+
+#define IS_TABLE_PROD_FUNC(X)  ((X & TABLE_PROD_FUNC) == TABLE_PROD_FUNC)
 
 /* or-ed with the above TABLE_PROD_FUNC */
 #define UPD_COMP   2
diff --git a/sql/rel.txt b/sql/rel.txt
--- a/sql/rel.txt
+++ b/sql/rel.txt
@@ -5,12 +5,12 @@ BASETABLE
-> l(sql_table)
 
 TABLE  (card MULTI)
-   -> flagsTABLE_PROD_FUNC, TABLE_FROM_RELATION
+   -> flagsTABLE_PROD_FUNC, TABLE_FROM_RELATION, TRIGGER_WRAPPER
cases 
TABLE_PROD_FUNC) TABLE producing function 
TABLE_FROM_RELATION) RELATIONAL subquery which is 
dynamically wrapped
into function call (needed of remote calls)
-   2) WRAPPER for triggers inserts, deletes and updates 
(new/old values)
+   TRIGGER_WRAPPER) for triggers inserts, deletes and 
updates (new/old values)
flags 
r is list of stmts
-> exps is list of column expressions (also used for aliases)
diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -411,7 +411,7 @@ rel_print_(mvc *sql, stream  *fout, sql_
if (rel->r)
exp_print(sql, fout, rel->r, depth, refs, 1, 0);
if (rel->l) {
-   if (rel->flag == 2) 
+   if (rel->flag == TRIGGER_WRAPPER) 
mnstr_printf(fout, "rel_dump not yet 
implemented for trigger input");
else
rel_print_(sql, fout, rel->l, depth+1, refs, 
decorate);
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_op

MonetDB: default - merged with linear-hashing

2020-03-06 Thread Niels Nes
Changeset: 937a410afccf for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=937a410afccf
Modified Files:
sql/backends/monet5/rel_bin.c
sql/server/rel_unnest.c
sql/test/subquery/Tests/subquery3.sql
sql/test/subquery/Tests/subquery3.stable.err
sql/test/subquery/Tests/subquery3.stable.out
Branch: default
Log Message:

merged with linear-hashing


diffs (241 lines):

diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -562,6 +562,8 @@ exp_bin(backend *be, sql_exp *e, stmt *l
return stmt_table(be, r, 1);
} else if (e->flag & PSM_EXCEPTION) {
stmt *cond = exp_bin(be, e->l, left, right, grp, ext, 
cnt, sel);
+   if (!cond)
+   return NULL;
return stmt_exception(be, cond, (const char *) e->r, 0);
}
break;
@@ -2218,8 +2220,12 @@ rel2bin_antijoin(backend *be, sql_rel *r
assert(list_length(mexps) == 1);
for( en = mexps->h; en; en = en->next ) {
sql_exp *e = en->data;
-   stmt *ls = exp_bin(be, e->l, left, right, NULL, NULL, 
NULL, NULL);
-   stmt *rs = exp_bin(be, e->r, left, right, NULL, NULL, 
NULL, NULL);
+   stmt *ls = exp_bin(be, e->l, left, right, NULL, NULL, 
NULL, NULL), *rs;
+   if (!ls)
+   return NULL;
+
+   if (!(rs = exp_bin(be, e->r, left, right, NULL, NULL, 
NULL, NULL)))
+   return NULL;
 
if (ls->nrcols == 0)
ls = stmt_const(be, bin_first_column(be, left), 
ls);
@@ -5327,7 +5333,7 @@ rel2bin_psm(backend *be, sql_rel *rel)
for (n = rel->exps->h; n; n = n->next) {
sql_exp *e = n->data;
stmt *s = exp_bin(be, e, sub, NULL, NULL, NULL, NULL, NULL);
-   if(!s)
+   if (!s)
return NULL;
 
if (s && s->type == st_table) /* relational statement */
@@ -5349,6 +5355,8 @@ rel2bin_partition_limits(backend *be, sq
l = subrel_bin(be, rel->l, refs);
if (rel->r)  /* first construct the sub relation */
r = subrel_bin(be, rel->r, refs);
+   if (!l || !r)
+   return NULL;
 
assert(rel->exps);
assert(rel->flag == ddl_alter_table_add_range_partition || rel->flag == 
ddl_alter_table_add_list_partition);
@@ -5357,6 +5365,8 @@ rel2bin_partition_limits(backend *be, sq
for (n = rel->exps->h; n; n = n->next) {
sql_exp *e = n->data;
stmt *s = exp_bin(be, e, l, r, NULL, NULL, NULL, NULL);
+   if (!s)
+   return NULL;
append(slist, s);
}
}
@@ -5377,11 +5387,15 @@ rel2bin_exception(backend *be, sql_rel *
l = subrel_bin(be, rel->l, refs);
 if (rel->r)  /* first construct the sub relation */
r = subrel_bin(be, rel->r, refs);
+   if (!l || !r)
+   return NULL;
 
if (rel->exps) {
for (n = rel->exps->h; n; n = n->next) {
sql_exp *e = n->data;
stmt *s = exp_bin(be, e, l, r, NULL, NULL, NULL, NULL);
+   if (!s)
+   return NULL;
append(slist, s);
}
} else { /* if there is no exception condition, just generate a 
statement list */
@@ -5401,7 +5415,7 @@ rel2bin_seq(backend *be, sql_rel *rel, l
 
if (rel->l) { /* first construct the sub relation */
sl = subrel_bin(be, rel->l, refs);
-   if(!sl)
+   if (!sl)
return NULL;
}
 
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -51,6 +51,9 @@ exp_set_freevar(mvc *sql, sql_exp *e, sq
set_freevar(e, 0);
break;
case e_atom: 
+   if (e->f)
+   exps_set_freevar(sql, e->f, r);
+   break;
case e_psm: 
break;
}
@@ -114,8 +117,11 @@ exp_has_freevar(mvc *sql, sql_exp *e)
if (exp_is_rel(e))
return rel_has_freevar(sql, e->l);
break;
-   case e_column: 
case e_atom: 
+   if (e->f)
+   return exps_have_freevar(sql, e->f);
+   break;
+   case e_column:
default:
return 0;
}
@@ -238,6 +244,9 @@ exp_freevar(mvc *sql, sql_exp *e)
return rel_freevar

MonetDB: default - Merged with linear-hashing

2020-03-06 Thread Pedro Ferreira
Changeset: 325f33aa6ef6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=325f33aa6ef6
Modified Files:
sql/backends/monet5/rel_bin.c
sql/server/rel_unnest.c
Branch: default
Log Message:

Merged with linear-hashing


diffs (49 lines):

diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -5355,7 +5355,7 @@ rel2bin_partition_limits(backend *be, sq
l = subrel_bin(be, rel->l, refs);
if (rel->r)  /* first construct the sub relation */
r = subrel_bin(be, rel->r, refs);
-   if (!l || !r)
+   if ((rel->l && !l) || (rel->r && !r))
return NULL;
 
assert(rel->exps);
@@ -5385,9 +5385,9 @@ rel2bin_exception(backend *be, sql_rel *
 
if (rel->l)  /* first construct the sub relation */
l = subrel_bin(be, rel->l, refs);
-if (rel->r)  /* first construct the sub relation */
+   if (rel->r)  /* first construct the sub relation */
r = subrel_bin(be, rel->r, refs);
-   if (!l || !r)
+   if ((rel->l && !l) || (rel->r && !r))
return NULL;
 
if (rel->exps) {
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -1382,7 +1382,10 @@ static sql_rel *
 
switch (rel->op) {
case op_basetable:
+   break;
case op_table:
+   if (IS_TABLE_PROD_FUNC(rel->flag) || rel->flag == 
TABLE_FROM_RELATION)
+   rel->l = _rel_unnest(sql, rel->l);
break;
case op_join: 
case op_left: 
@@ -1432,7 +1435,10 @@ rel_reset_subquery(sql_rel *rel)
rel->subquery = 0;
switch(rel->op){
case op_basetable:
+   break;
case op_table:
+   if ((IS_TABLE_PROD_FUNC(rel->flag) || rel->flag == 
TABLE_FROM_RELATION) && rel->l)
+   rel_reset_subquery(rel->l);
break;
case op_ddl:
rel_reset_subquery(rel->l);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with linear-hashing

2020-03-09 Thread Pedro Ferreira
Changeset: a22012862e2a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a22012862e2a
Modified Files:
sql/test/subquery/Tests/subquery3.sql
Branch: default
Log Message:

Merged with linear-hashing


diffs (16 lines):

diff --git a/sql/test/subquery/Tests/subquery3.sql 
b/sql/test/subquery/Tests/subquery3.sql
--- a/sql/test/subquery/Tests/subquery3.sql
+++ b/sql/test/subquery/Tests/subquery3.sql
@@ -452,7 +452,11 @@ FROM another_T; --error, col0 doesn't ex
 
 SELECT
(SELECT outt FROM evilfunction((SELECT col1))) 
-FROM another_T; --error, more than one row returned by a subquery used as an 
expression
+FROM another_T;
+   -- 1
+   -- 11
+   -- 111
+   -- 
 
 SELECT
(SELECT outt FROM evilfunction((SELECT col1 FROM tbl_ProductSales))) 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with linear-hashing

2020-03-12 Thread Pedro Ferreira
Changeset: 909aa065524e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=909aa065524e
Added Files:
sql/test/Tests/mediumint.sql
sql/test/Tests/mediumint.stable.err
sql/test/Tests/mediumint.stable.out
sql/test/sys-schema/Tests/utilities.sql
sql/test/sys-schema/Tests/utilities.stable.err
sql/test/sys-schema/Tests/utilities.stable.out
Modified Files:
clients/odbc/driver/ODBCConvert.c
clients/odbc/driver/ODBCDbc.h
clients/odbc/driver/ODBCStmt.h
clients/odbc/driver/ODBCUtil.c
clients/odbc/driver/SQLBrowseConnect.c
clients/odbc/driver/SQLColumnPrivileges.c
clients/odbc/driver/SQLColumns.c
clients/odbc/driver/SQLConnect.c
clients/odbc/driver/SQLDriverConnect.c
clients/odbc/driver/SQLExecDirect.c
clients/odbc/driver/SQLForeignKeys.c
clients/odbc/driver/SQLGetTypeInfo.c
clients/odbc/driver/SQLNativeSql.c
clients/odbc/driver/SQLPrepare.c
clients/odbc/driver/SQLPrimaryKeys.c
clients/odbc/driver/SQLProcedureColumns.c
clients/odbc/driver/SQLProcedures.c
clients/odbc/driver/SQLSetCursorName.c
clients/odbc/driver/SQLSpecialColumns.c
clients/odbc/driver/SQLStatistics.c
clients/odbc/driver/SQLTablePrivileges.c
clients/odbc/driver/SQLTables.c
gdk/gdk_join.c
sql/test/Tests/All
sql/test/subquery/Tests/subquery3.stable.err
sql/test/sys-schema/Tests/All
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 2993 to 300 lines):

diff --git a/clients/odbc/driver/ODBCConvert.c 
b/clients/odbc/driver/ODBCConvert.c
--- a/clients/odbc/driver/ODBCConvert.c
+++ b/clients/odbc/driver/ODBCConvert.c
@@ -2868,7 +2868,7 @@ ODBCStore(ODBCStmt *stmt,
  char **bufp,
  size_t *bufposp,
  size_t *buflenp,
- char *sep)
+ const char *sep)
 {
ODBCDescRec *ipdrec, *apdrec;
SQLPOINTER ptr;
diff --git a/clients/odbc/driver/ODBCDbc.h b/clients/odbc/driver/ODBCDbc.h
--- a/clients/odbc/driver/ODBCDbc.h
+++ b/clients/odbc/driver/ODBCDbc.h
@@ -137,7 +137,7 @@ ODBCError *getDbcError(ODBCDbc *dbc);
  */
 void destroyODBCDbc(ODBCDbc *dbc);
 
-int ODBCGetKeyAttr(SQLCHAR **conn, SQLSMALLINT *nconn, char **key, char 
**attr);
+int ODBCGetKeyAttr(const SQLCHAR **conn, SQLSMALLINT *nconn, char **key, char 
**attr);
 SQLRETURN ODBCConnectionString(SQLRETURN rc, ODBCDbc *dbc,
   SQLCHAR *OutConnectionString,
   SQLSMALLINT BufferLength,
@@ -146,7 +146,7 @@ SQLRETURN ODBCConnectionString(SQLRETURN
   const char *pwd, const char *host,
   int port, const char *database);
 SQLRETURN MNDBAllocStmt(ODBCDbc *dbc, SQLHANDLE *pnOutputHandle);
-SQLRETURN MNDBConnect(ODBCDbc *dbc, SQLCHAR *szDataSource, SQLSMALLINT 
nDataSourceLength, SQLCHAR *szUID, SQLSMALLINT nUIDLength, SQLCHAR *szPWD, 
SQLSMALLINT nPWDLength, const char *host, int port, const char *schema);
+SQLRETURN MNDBConnect(ODBCDbc *dbc, const SQLCHAR *szDataSource, SQLSMALLINT 
nDataSourceLength, const SQLCHAR *szUID, SQLSMALLINT nUIDLength, const SQLCHAR 
*szPWD, SQLSMALLINT nPWDLength, const char *host, int port, const char *schema);
 SQLRETURN MNDBGetConnectAttr(ODBCDbc *dbc, SQLINTEGER Attribute, SQLPOINTER 
ValuePtr, SQLINTEGER BufferLength, SQLINTEGER *StringLength);
 SQLRETURN MNDBSetConnectAttr(ODBCDbc *dbc, SQLINTEGER Attribute, SQLPOINTER 
ValuePtr, SQLINTEGER StringLength);
 
diff --git a/clients/odbc/driver/ODBCStmt.h b/clients/odbc/driver/ODBCStmt.h
--- a/clients/odbc/driver/ODBCStmt.h
+++ b/clients/odbc/driver/ODBCStmt.h
@@ -180,7 +180,7 @@ SQLRETURN ODBCFetch(ODBCStmt *stmt, SQLU
SQLULEN row);
 SQLRETURN ODBCStore(ODBCStmt *stmt, SQLUSMALLINT param, SQLLEN offset,
SQLULEN row, char **bufp, size_t *bufposp, size_t *buflenp,
-   char *sep);
+   const char *sep);
 SQLRETURN ODBCFreeStmt_(ODBCStmt *stmt);
 SQLRETURN ODBCInitResult(ODBCStmt *stmt);
 const char *ODBCGetTypeInfo(int concise_type, int *data_type,
@@ -198,7 +198,7 @@ SQLRETURN MNDBColAttribute(ODBCStmt *stm
   SQLUSMALLINT nFieldIdentifier,
   SQLPOINTER pszValue, SQLSMALLINT nValueLengthMax,
   SQLSMALLINT *pnValueLength, LENP_OR_POINTER_T 
pnValue);
-SQLRETURN MNDBExecDirect(ODBCStmt *stmt, SQLCHAR *szSqlStr,
+SQLRETURN MNDBExecDirect(ODBCStmt *stmt, const SQLCHAR *szSqlStr,
 SQLINTEGER nSqlStr);
 SQLRETURN MNDBExecute(ODBCStmt *stmt);
 SQLRETURN MNDBFetch(ODBCStmt *stmt, SQLUSMALLINT *RowStatusArray);
@@ -208,7 +208,7 @@ SQLRETURN MNDBFreeStmt(ODBCStmt *stmt, S
 SQLRETURN MNDBGetStmtAttr(ODBCStmt *stmt, SQLINTEGER Attribute,
  SQLPOINTER Value, SQLINTEGER BufferLength,