MonetDB: string-dedup - Merge with default branch.

2021-09-22 Thread Sjoerd Mullender
Changeset: 992ad97c0d81 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/992ad97c0d81
Modified Files:
gdk/gdk.h
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_bbp.c
gdk/gdk_group.c
gdk/gdk_heap.c
gdk/gdk_private.h
gdk/gdk_project.c
gdk/gdk_select.c
gdk/gdk_storage.c
gdk/gdk_string.c
monetdb5/extras/rapi/rapi.c
sql/storage/bat/bat_storage.c
testing/Mtest.py.in
Branch: string-dedup
Log Message:

Merge with default branch.


diffs (truncated from 560861 to 300 lines):

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,8 +53,7 @@ test_big_endian(IS_BIG_ENDIAN)
 include(monetdb-functions)
 include(monetdb-findpackages)
 include(monetdb-toolchain)
-monetdb_default_toolchain()
-#monetdb_default_compiler_options()
+monetdb_default_compiler_options()
 
 include(monetdb-defines)
 monetdb_hg_revision()
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -527,7 +527,6 @@ exit 0
 %{_libdir}/monetdb5/lib_capi.so
 %endif
 %{_libdir}/monetdb5/lib_generator.so
-%{_libdir}/monetdb5/lib_udf.so
 %doc %{_mandir}/man1/mserver5.1.gz
 %dir %{_datadir}/doc/MonetDB
 %docdir %{_datadir}/doc/MonetDB
@@ -832,6 +831,7 @@ rm -f %{buildroot}%{_libdir}/monetdb5/ru
 rm -f %{buildroot}%{_libdir}/monetdb5/lib_run_*.so
 rm -f %{buildroot}%{_libdir}/monetdb5/microbenchmark.mal
 rm -f %{buildroot}%{_libdir}/monetdb5/lib_microbenchmark*.so
+rm -f %{buildroot}%{_libdir}/monetdb5/lib_udf*.so
 rm -f %{buildroot}%{_bindir}/monetdb_mtest.sh
 rm -rf %{buildroot}%{_datadir}/monetdb # /cmake
 
diff --git a/NT/mksqlwxs.py b/NT/mksqlwxs.py
--- a/NT/mksqlwxs.py
+++ b/NT/mksqlwxs.py
@@ -191,9 +191,9 @@ def main():
 print(r'')
 print(r'  ')
 id = comp(features, id, 16,
-  [r'lib\monetdb5\{}'.format(x) for x in sorted(filter(lambda x: 
x.startswith('_') and x.endswith('.dll') and ('geom' not in x) and ('pyapi' not 
in x) and ('opt_sql_append' not in x) and ('run_' not in x) and 
('microbenchmark' not in x), os.listdir(os.path.join(sys.argv[3], 'lib', 
'monetdb5'])
+  [r'lib\monetdb5\{}'.format(x) for x in sorted(filter(lambda x: 
x.startswith('_') and x.endswith('.dll') and ('geom' not in x) and ('pyapi' not 
in x) and ('opt_sql_append' not in x) and ('run_' not in x) and 
('microbenchmark' not in x) and ('udf' not in x), 
os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5'])
 id = comp(debug, id, 16,
-  [r'lib\monetdb5\{}'.format(x) for x in sorted(filter(lambda x: 
x.startswith('_') and x.endswith('.pdb') and ('geom' not in x) and 
('opt_sql_append' not in x) and ('run_' not in x) and ('microbenchmark' not in 
x), os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5'])
+  [r'lib\monetdb5\{}'.format(x) for x in sorted(filter(lambda x: 
x.startswith('_') and x.endswith('.pdb') and ('geom' not in x) and 
('opt_sql_append' not in x) and ('run_' not in x) and ('microbenchmark' not in 
x) and ('udf' not in x), os.listdir(os.path.join(sys.argv[3], 'lib', 
'monetdb5'])
 id = comp(geom, id, 16,
   [r'lib\monetdb5\{}'.format(x) for x in sorted(filter(lambda x: 
x.startswith('_') and (x.endswith('.dll') or x.endswith('.pdb')) and ('geom' in 
x), os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5'])
 id = comp(pyapi3, id, 16,
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
@@ -1,697 +1,694 @@
-stdout of test 'MAL-signatures` in directory 'clients` itself:
-
-#select * from sys.malfunctions() order by module, "function", address, 
signature, comment;
 % .%1, .%1,.%1,.%1,.%1 # table_name
 % module,  function,   signature,  address,comment # name
 % clob,clob,   clob,   clob,   clob # type
-% 12,  28, 313,42, 0 # length
-[ "aggr",  "all",  "command aggr.all(X_0:bat[:any_1]):any_1 ", 
"SQLall;",  ""  ]
-[ "aggr",  "allnotequal",  "pattern aggr.allnotequal(X_0:bat[:any_1], 
X_1:bat[:any_1]):bit ",  "SQLallnotequal;",  ""  ]
+% 12,  28, 313,42, 860 # length
+[ "aggr",  "all",  "command aggr.all(X_0:bat[:any_1]):any_1 ", 
"SQLall;",  "if all values in b are equal return this, else nil"]
+[ "aggr",  "allnotequal",  "pattern aggr.allnotequal(X_0:bat[:any_1], 
X_1:bat[:any_1]):bit ",  "SQLallnotequal;",  "if all values in r are 
not equal to l return true, else if r has nil nil else false"   ]
 [ "aggr",  "anyequal", "pattern aggr.anyequal(X_0:any_1, 
X_1:any_1):bit ", "CMDvarEQ;",""  ]
-[ "aggr",  "anyequal", "pattern aggr.anyequal(X_0:bat[:any_1], 
X_1:bat[:any_1]):bit ", "SQLanyequal;", ""  ]
-[ "aggr",  "avg",  "command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], 

MonetDB: string_imprints - Merge heads

2021-09-22 Thread Panagiotis Koutsourakis
Changeset: b38e5d23af12 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b38e5d23af12
Modified Files:
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
Branch: string_imprints
Log Message:

Merge heads


diffs (truncated from 358 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
@@ -9123,6 +9123,7 @@
 [ "optimizer", "mergetable",   "pattern optimizer.mergetable(X_0:str, 
X_1:str):str ",  "OPTwrapper;",  "Resolve the multi-table definitions"   ]
 [ "optimizer", "minimal_fast", "function optimizer.minimal_fast():void;",  
"", ""  ]
 [ "optimizer", "minimal_pipe", "function optimizer.minimal_pipe():void;",  
"", ""  ]
+[ "optimizer", "minimal_strimps_pipe", "function 
optimizer.minimal_strimps_pipe():void;",  "", ""  ]
 [ "optimizer", "minimalfast",  "pattern optimizer.minimalfast():str ", 
"OPTwrapper;",  ""  ]
 [ "optimizer", "minimalfast",  "pattern optimizer.minimalfast(X_0:str, 
X_1:str):str ", "OPTwrapper;",  "Fast compound minimal optimizer pipe"  ]
 [ "optimizer", "mitosis",  "pattern optimizer.mitosis():str ", 
"OPTwrapper;",  ""  ]
@@ -9156,6 +9157,9 @@
 [ "optimizer", "reorder",  "pattern optimizer.reorder():str ", 
"OPTwrapper;",  ""  ]
 [ "optimizer", "reorder",  "pattern optimizer.reorder(X_0:str, 
X_1:str):str ", "OPTwrapper;",  "Reorder by dataflow dependencies"  ]
 [ "optimizer", "sequential_pipe",  "function 
optimizer.sequential_pipe():void;",   "", ""  ]
+[ "optimizer", "strimps",  "pattern optimizer.strimps():str ", 
"OPTwrapper;",  ""  ]
+[ "optimizer", "strimps",  "pattern optimizer.strimps(X_0:str, 
X_1:str):str ", "OPTwrapper;",  "Use strimps index if appropriate"  ]
+[ "optimizer", "strimps_pipe", "function optimizer.strimps_pipe():void;",  
"", ""  ]
 [ "optimizer", "volcano",  "pattern optimizer.volcano():str ", 
"OPTwrapper;",  ""  ]
 [ "optimizer", "volcano",  "pattern optimizer.volcano(X_0:str, 
X_1:str):str ", "OPTwrapper;",  "Simulate volcano style execution"  ]
 [ "optimizer", "volcano_pipe", "function optimizer.volcano_pipe():void;",  
"", ""  ]
@@ -9305,6 +9309,7 @@
 [ "sql",   "covariancep",  "pattern sql.covariancep(X_0:lng, X_1:lng, 
X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ",  "SQLcovar_pop;",
"return the covariance population value of groups"  ]
 [ "sql",   "covariancep",  "pattern sql.covariancep(X_0:sht, X_1:sht, 
X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ",  "SQLcovar_pop;",
"return the covariance population value of groups"  ]
 [ "sql",   "createorderindex", "unsafe pattern 
sql.createorderindex(X_0:str, X_1:str, X_2:str):void ", 
"sql_createorderindex;","Instantiate the order index on a column"   
]
+[ "sql",   "createstrimps","unsafe pattern 
sql.createstrimps(X_0:str, X_1:str, X_2:str):void ","sql_createstrimps;",   
"Instantiate the strimps index on a column" ]
 [ "sql",   "cume_dist","pattern sql.cume_dist(X_0:any_1, X_1:bit, 
X_2:bit):dbl ",  "SQLcume_dist;","return the accumulated 
distribution of the number of rows per group to the total number of partition 
rows" ]
 [ "sql",   "current_time", "pattern sql.current_time():daytime ",  
"SQLcurrent_daytime;",  "Get the clients current daytime"   ]
 [ "sql",   "current_timestamp","pattern 
sql.current_timestamp():timestamp ",   "SQLcurrent_timestamp;","Get the 
clients current timestamp" ]
@@ -9592,6 +9597,10 @@
 [ "streams",   "readStr",  "unsafe command 
streams.readStr(X_0:streams):str ", "mnstr_read_stringwrap;",   "read 
string data from the stream"  ]
 [ "streams",   "writeInt", "unsafe command streams.writeInt(X_0:streams, 
X_1:int):void ",  "mnstr_writeIntwrap;",  "write data on the stream"  ]
 [ "streams",   "writeStr", "unsafe command streams.writeStr(X_0:streams, 
X_1:str):void ",  "mnstr_write_stringwrap;",  "write data on the stream"
  ]
+[ "strimps",   "mkstrimp", "pattern strimps.mkstrimp(X_0:bat[:str], 
X_1:bat[:oid]):void ", "PATstrimpCreate;", "construct the strimp a BAT"]
+[ "strimps",   "strimpfilter", "pattern strimps.strimpfilter(X_0:str, 
X_1:str):bit ",  "PATstrimpFilter;", ""  ]
+[ "strimps",   "strimpfilterjoin", "pattern 
strimps.strimpfilterjoin(X_0:str, X_1:any, X_2:any, X_3:any, X_4:any, X_5:any) 
(X_6:bat[:oid], X_7:bat[:str]) ",   "PATstrimpFilter;", ""  ]
+[ "strimps",   "strimpfilterselect",   "pattern 
strimps.strimpfilterselect(X_0:bat[:str], X_1:bat[:oid], X_2:str, 
X_3:bit):bat[:oid] ","PATstrimpFilterSelect;",   ""  ]
 [ 

MonetDB: string_imprints - Merge with default

2021-09-22 Thread Panagiotis Koutsourakis
Changeset: 3fc32e309cdc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3fc32e309cdc
Modified Files:
gdk/gdk_bbp.c
Branch: string_imprints
Log Message:

Merge with default


diffs (truncated from 2202 to 300 lines):

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,8 +53,7 @@ test_big_endian(IS_BIG_ENDIAN)
 include(monetdb-functions)
 include(monetdb-findpackages)
 include(monetdb-toolchain)
-monetdb_default_toolchain()
-#monetdb_default_compiler_options()
+monetdb_default_compiler_options()
 
 include(monetdb-defines)
 monetdb_hg_revision()
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -382,15 +382,16 @@ dump_foreign_keys(Mapi mid, const char *
if (tname != NULL) {
char *s = sescape(schema);
char *t = sescape(tname);
+   if (s == NULL || t == NULL) {
+   free(s);
+   free(t);
+   goto bailout;
+   }
maxquerylen = 1024 + strlen(t) + strlen(s);
query = malloc(maxquerylen);
-   if (s == NULL || t == NULL || query == NULL) {
-   if (s)
-   free(s);
-   if (t)
-   free(t);
-   if (query)
-   free(query);
+   if (query == NULL) {
+   free(s);
+   free(t);
goto bailout;
}
snprintf(query, maxquerylen,
diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -1255,6 +1255,7 @@ ODBCTranslateSQL(ODBCDbc *dbc, const SQL
strncpy(q, nquery, pr);
for (r = func->repl; *r; r++) {
if (*r == '\1' || *r == 
'\2' || *r == '\3' || *r == '\4') {
+   assert(*r <= 
func->nargs);
if (args[*r - 
1].argstart[0] == '\'')
q[pr++] 
= 'r';
strncpy(q + pr, 
args[*r - 1].argstart, args[*r - 1].arglen);
diff --git a/clients/odbc/driver/SQLTables.c b/clients/odbc/driver/SQLTables.c
--- a/clients/odbc/driver/SQLTables.c
+++ b/clients/odbc/driver/SQLTables.c
@@ -82,6 +82,8 @@ MNDBTables(ODBCStmt *stmt,
  "cast(null as varchar(1)) as remarks "
   "from sys.env() e "
   "where e.name = 'gdk_dbname'");
+   if (query == NULL)
+   goto nomem;
} else if (NameLength1 == 0 &&
   NameLength3 == 0 &&
   SchemaName &&
@@ -96,6 +98,8 @@ MNDBTables(ODBCStmt *stmt,
* schema remarks */
  "cast(null as varchar(1)) as remarks "
   "from sys.schemas order by table_schem");
+   if (query == NULL)
+   goto nomem;
} else if (NameLength1 == 0 &&
   NameLength2 == 0 &&
   NameLength3 == 0 &&
@@ -108,6 +112,8 @@ MNDBTables(ODBCStmt *stmt,
  "table_type_name as table_type, "
  "cast(null as varchar(1)) as remarks "
   "from sys.table_types order by table_type");
+   if (query == NULL)
+   goto nomem;
} else {
/* no special case argument values */
size_t querylen;
@@ -241,8 +247,6 @@ MNDBTables(ODBCStmt *stmt,
free(sch);
if (tab)
free(tab);
-   if (query)
-   free(query);
/* Memory allocation error */
addStmtError(stmt, "HY001", NULL, 0);
return SQL_ERROR;
diff --git a/cmake/monetdb-functions.cmake b/cmake/monetdb-functions.cmake
--- a/cmake/monetdb-functions.cmake
+++ b/cmake/monetdb-functions.cmake
@@ -9,73 +9,60 @@
 function(monetdb_hg_revision)
   # Get the current version control revision
   if(EXISTS "${CMAKE_SOURCE_DIR}/.hg_archival.txt")
-execute_process(COMMAND "sed" "-n" "s/^node: 
\\([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]\\).*/\\1/p"
 ".hg_archival.txt" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" RESULT_VARIABLE 
HG_RETURN_CODE
-  OUTPUT_VARIABLE HG_OUPUT_RES OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(HG_RETURN_CODE EQUAL 0 AND HG_OUPUT_RES)
-  set(MERCURIAL_ID 

MonetDB: default - Merge with Jul2021 branch.

2021-09-22 Thread Sjoerd Mullender
Changeset: 76c3677f74c8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/76c3677f74c8
Modified Files:
gdk/gdk_bbp.c
sql/server/rel_optimizer.c
Branch: default
Log Message:

Merge with Jul2021 branch.


diffs (164 lines):

diff --git a/gdk/ChangeLog.Jul2021 b/gdk/ChangeLog.Jul2021
--- a/gdk/ChangeLog.Jul2021
+++ b/gdk/ChangeLog.Jul2021
@@ -1,6 +1,16 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Wed Sep 22 2021 Sjoerd Mullender 
+- Some deadlock and race condition issues were fixed.
+- Handling of the list of free bats has been improved, leading to less
+  thread contention.
+- A problem was fixed where the server wouldn't start with a message from
+  BBPcheckbats about files being too small.  The issue was not that the
+  file was too small, but that BBPcheckbats was looking at the wrong file.
+- An issue was fixed where a "short read" error was produced when memory
+  was getting tight.
+
 * Wed Aug 11 2021 Sjoerd Mullender 
 - When appending to a string bat, we made an optimization where the string
   heap was sometimes copied completely to avoid having to insert strings
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -958,7 +958,6 @@ BBPheader(FILE *fp, int *lineno, bat *bb
TRC_CRITICAL(GDK, "no BBPsize value found\n");
return 0;
}
-   sz = (int) (sz * BATMARGIN);
if (sz > *bbpsize)
*bbpsize = sz;
if (bbpversion > GDKLIBRARY_MINMAX_POS) {
diff --git a/sql/ChangeLog.Jul2021 b/sql/ChangeLog.Jul2021
--- a/sql/ChangeLog.Jul2021
+++ b/sql/ChangeLog.Jul2021
@@ -1,14 +1,23 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Wed Sep 22 2021 Sjoerd Mullender 
+- If the server has been idle for a while with no active clients, the
+  write-ahead log is now rotated.
+- A problem was fixed where files belonging to bats that had been deleted
+  internally were not cleaned up, leading to a growing database (dbfarm)
+  directory.
+- A leak was fixed where extra bats were created but never cleaned up,
+  each taking up several kilobytes of memory.
+
 * Tue Aug 17 2021 Ying Zhang 
 - [This feature was already released in Jul2021 (11.41.5), but the ChangeLog 
was missing]
   Grant indirect privileges.  With "GRANT SELECT ON  TO
   "  and "GRANT EXECUTE ON FUNCTION  TO
   ", one can grant access to "my_view" and "my_func"
-  to another user who does not have access to the underlying database 
-  objects (e.g. tables, views) used in "my_view" and "my_func".  The 
-  grantee will only be able to access data revealed by "my_view" or 
+  to another user who does not have access to the underlying database
+  objects (e.g. tables, views) used in "my_view" and "my_func".  The
+  grantee will only be able to access data revealed by "my_view" or
   conduct operations provided by "my_func".
 
 * Mon Aug 16 2021 Sjoerd Mullender 
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
@@ -8212,10 +8212,11 @@ exp_merge_range(visitor *v, sql_rel *rel
 static int
 reduce_scale(atom *a)
 {
+   int i = 0;
+
 #ifdef HAVE_HGE
if (a->data.vtype == TYPE_hge) {
hge v = a->data.val.hval;
-   int i = 0;
 
if (v != 0)
while( (v/10)*10 == v ) {
@@ -8223,12 +8224,10 @@ reduce_scale(atom *a)
v /= 10;
}
a->data.val.hval = v;
-   return i;
-   }
+   } else
 #endif
if (a->data.vtype == TYPE_lng) {
lng v = a->data.val.lval;
-   int i = 0;
 
if (v != 0)
while( (v/10)*10 == v ) {
@@ -8236,11 +8235,8 @@ reduce_scale(atom *a)
v /= 10;
}
a->data.val.lval = v;
-   return i;
-   }
-   if (a->data.vtype == TYPE_int) {
+   } else if (a->data.vtype == TYPE_int) {
int v = a->data.val.ival;
-   int i = 0;
 
if (v != 0)
while( (v/10)*10 == v ) {
@@ -8248,11 +8244,8 @@ reduce_scale(atom *a)
v /= 10;
}
a->data.val.ival = v;
-   return i;
-   }
-   if (a->data.vtype == TYPE_sht) {
+   } else if (a->data.vtype == TYPE_sht) {
sht v = a->data.val.shval;
-   int i = 0;
 
if (v != 0)
while( (v/10)*10 == v ) {
@@ -8260,9 +8253,9 @@ reduce_scale(atom *a)
v /= 10;
}
a->data.val.shval = v;
-   return i;
-   }
-   return 0;
+   }
+   a->tpe.scale -= i;
+   return i;
 }
 
 static sql_rel *
diff --git a/sql/test/SQLancer/Tests/sqlancer19.SQL.py 

MonetDB: Jul2021 - Update changelogs.

2021-09-22 Thread Sjoerd Mullender
Changeset: 1a91fbb643e2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1a91fbb643e2
Removed Files:
sql/ChangeLog.linear-hashing
Modified Files:
gdk/ChangeLog.Jul2021
sql/ChangeLog.Jul2021
Branch: Jul2021
Log Message:

Update changelogs.


diffs (62 lines):

diff --git a/gdk/ChangeLog.Jul2021 b/gdk/ChangeLog.Jul2021
--- a/gdk/ChangeLog.Jul2021
+++ b/gdk/ChangeLog.Jul2021
@@ -1,6 +1,16 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Wed Sep 22 2021 Sjoerd Mullender 
+- Some deadlock and race condition issues were fixed.
+- Handling of the list of free bats has been improved, leading to less
+  thread contention.
+- A problem was fixed where the server wouldn't start with a message from
+  BBPcheckbats about files being too small.  The issue was not that the
+  file was too small, but that BBPcheckbats was looking at the wrong file.
+- An issue was fixed where a "short read" error was produced when memory
+  was getting tight.
+
 * Wed Aug 11 2021 Sjoerd Mullender 
 - When appending to a string bat, we made an optimization where the string
   heap was sometimes copied completely to avoid having to insert strings
diff --git a/sql/ChangeLog.Jul2021 b/sql/ChangeLog.Jul2021
--- a/sql/ChangeLog.Jul2021
+++ b/sql/ChangeLog.Jul2021
@@ -1,14 +1,23 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Wed Sep 22 2021 Sjoerd Mullender 
+- If the server has been idle for a while with no active clients, the
+  write-ahead log is now rotated.
+- A problem was fixed where files belonging to bats that had been deleted
+  internally were not cleaned up, leading to a growing database (dbfarm)
+  directory.
+- A leak was fixed where extra bats were created but never cleaned up,
+  each taking up several kilobytes of memory.
+
 * Tue Aug 17 2021 Ying Zhang 
 - [This feature was already released in Jul2021 (11.41.5), but the ChangeLog 
was missing]
   Grant indirect privileges.  With "GRANT SELECT ON  TO
   "  and "GRANT EXECUTE ON FUNCTION  TO
   ", one can grant access to "my_view" and "my_func"
-  to another user who does not have access to the underlying database 
-  objects (e.g. tables, views) used in "my_view" and "my_func".  The 
-  grantee will only be able to access data revealed by "my_view" or 
+  to another user who does not have access to the underlying database
+  objects (e.g. tables, views) used in "my_view" and "my_func".  The
+  grantee will only be able to access data revealed by "my_view" or
   conduct operations provided by "my_func".
 
 * Mon Aug 16 2021 Sjoerd Mullender 
diff --git a/sql/ChangeLog.linear-hashing b/sql/ChangeLog.linear-hashing
deleted file mode 100644
--- a/sql/ChangeLog.linear-hashing
+++ /dev/null
@@ -1,7 +0,0 @@
-# ChangeLog file for sql
-# This file is updated with Maddlog
-
-* Tue Mar  3 2020 Pedro Ferreira 
-- Removed sys.pause(int), sys.resume(int) and sys.stop(int)
-  procedures. They were redundant compared to the bigint versions.
-
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jul2021 - Updated remote plan issues

2021-09-22 Thread Pedro Ferreira
Changeset: a9993be72bc1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a9993be72bc1
Modified Files:
sql/test/SQLancer/Tests/sqlancer19.SQL.py
Branch: Jul2021
Log Message:

Updated remote plan issues


diffs (26 lines):

diff --git a/sql/test/SQLancer/Tests/sqlancer19.SQL.py 
b/sql/test/SQLancer/Tests/sqlancer19.SQL.py
--- a/sql/test/SQLancer/Tests/sqlancer19.SQL.py
+++ b/sql/test/SQLancer/Tests/sqlancer19.SQL.py
@@ -96,10 +96,22 @@ with SQLTestCase() as cli:
 
.assertSucceeded().assertDataResultMatch([(1,),(2,),(2,),(2,),(2,),(5,),(5,),(5,),(5,),(7,)])
 cli.execute("SELECT rt3.c0 FROM rt3 INNER JOIN rt3 myx ON rt3.c0 = myx.c0 
ORDER BY rt3.c0;") \
 
.assertSucceeded().assertDataResultMatch([(1,),(2,),(2,),(2,),(2,),(5,),(5,),(5,),(5,),(7,)])
+
+# Issues related to digits and scale propagation in the sql layer
+cli.execute("SELECT CAST(2 AS DECIMAL) & CAST(3 AS DOUBLE) FROM t3 where 
t3.c0 = 1;") \
+.assertSucceeded().assertDataResultMatch([(Decimal('0.002'),)])
+cli.execute("SELECT CAST(2 AS DECIMAL) & CAST(3 AS DOUBLE) FROM rt3 where 
rt3.c0 = 1;") \
+.assertSucceeded().assertDataResultMatch([(Decimal('0.002'),)])
 cli.execute("SELECT greatest('69', splitpart('', '191', 2)) FROM t3 where 
t3.c0 = 1;") \
 .assertSucceeded().assertDataResultMatch([('69',)])
 cli.execute("SELECT greatest('69', splitpart('', '191', 2)) FROM rt3 where 
rt3.c0 = 1;") \
 .assertSucceeded().assertDataResultMatch([('69',)])
+
+# Issues related to comparisons not being correctly delimited on plans, 
which causes ambiguity
+cli.execute("SELECT TRUE BETWEEN (TRUE BETWEEN FALSE AND FALSE) AND TRUE 
FROM t3 where t3.c0 = 1;") \
+.assertSucceeded().assertDataResultMatch([(True,)])
+cli.execute("SELECT TRUE BETWEEN (TRUE BETWEEN FALSE AND FALSE) AND TRUE 
FROM rt3 where rt3.c0 = 1;") \
+.assertSucceeded().assertDataResultMatch([(True,)])
 cli.execute("SELECT 1 FROM t3 WHERE (t3.c0 BETWEEN t3.c0 AND t3.c0) IS 
NULL;") \
 .assertSucceeded().assertDataResultMatch([])
 cli.execute("SELECT 2 FROM rt3 WHERE (rt3.c0 BETWEEN rt3.c0 AND rt3.c0) IS 
NULL;") \
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jul2021 - Update atom's scale after reducing it

2021-09-22 Thread Pedro Ferreira
Changeset: 5fd6413b6476 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5fd6413b6476
Modified Files:
sql/server/rel_optimizer.c
sql/test/SQLancer/Tests/sqlancer19.SQL.py
Branch: Jul2021
Log Message:

Update atom's scale after reducing it


diffs (83 lines):

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
@@ -8272,10 +8272,11 @@ exp_merge_range(visitor *v, sql_rel *rel
 static int
 reduce_scale(atom *a)
 {
+   int i = 0;
+
 #ifdef HAVE_HGE
if (a->data.vtype == TYPE_hge) {
hge v = a->data.val.hval;
-   int i = 0;
 
if (v != 0)
while( (v/10)*10 == v ) {
@@ -8283,12 +8284,10 @@ reduce_scale(atom *a)
v /= 10;
}
a->data.val.hval = v;
-   return i;
-   }
+   } else
 #endif
if (a->data.vtype == TYPE_lng) {
lng v = a->data.val.lval;
-   int i = 0;
 
if (v != 0)
while( (v/10)*10 == v ) {
@@ -8296,11 +8295,8 @@ reduce_scale(atom *a)
v /= 10;
}
a->data.val.lval = v;
-   return i;
-   }
-   if (a->data.vtype == TYPE_int) {
+   } else if (a->data.vtype == TYPE_int) {
int v = a->data.val.ival;
-   int i = 0;
 
if (v != 0)
while( (v/10)*10 == v ) {
@@ -8308,11 +8304,8 @@ reduce_scale(atom *a)
v /= 10;
}
a->data.val.ival = v;
-   return i;
-   }
-   if (a->data.vtype == TYPE_sht) {
+   } else if (a->data.vtype == TYPE_sht) {
sht v = a->data.val.shval;
-   int i = 0;
 
if (v != 0)
while( (v/10)*10 == v ) {
@@ -8320,9 +8313,9 @@ reduce_scale(atom *a)
v /= 10;
}
a->data.val.shval = v;
-   return i;
-   }
-   return 0;
+   }
+   a->tpe.scale -= i;
+   return i;
 }
 
 static sql_rel *
diff --git a/sql/test/SQLancer/Tests/sqlancer19.SQL.py 
b/sql/test/SQLancer/Tests/sqlancer19.SQL.py
--- a/sql/test/SQLancer/Tests/sqlancer19.SQL.py
+++ b/sql/test/SQLancer/Tests/sqlancer19.SQL.py
@@ -88,6 +88,10 @@ with SQLTestCase() as cli:
 .assertSucceeded().assertDataResultMatch([(Decimal('3.571'),)])
 cli.execute("SELECT 3 / 0.84 FROM rt3 where rt3.c0 = 1;") \
 .assertSucceeded().assertDataResultMatch([(Decimal('3.571'),)])
+cli.execute("SELECT CAST(2 AS DECIMAL) * 0.010 FROM t3 where t3.c0 = 1;") \
+.assertSucceeded().assertDataResultMatch([(Decimal('0.02000'),)])
+cli.execute("SELECT CAST(2 AS DECIMAL) * 0.010 FROM rt3 where rt3.c0 = 
1;") \
+.assertSucceeded().assertDataResultMatch([(Decimal('0.02000'),)])
 cli.execute("SELECT t3.c0 FROM t3 INNER JOIN t3 myx ON t3.c0 = myx.c0 
ORDER BY t3.c0;") \
 
.assertSucceeded().assertDataResultMatch([(1,),(2,),(2,),(2,),(2,),(5,),(5,),(5,),(5,),(7,)])
 cli.execute("SELECT rt3.c0 FROM rt3 INNER JOIN rt3 myx ON rt3.c0 = myx.c0 
ORDER BY rt3.c0;") \
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jul2021 - Don't grow BBPsize unnecessarily.

2021-09-22 Thread Sjoerd Mullender
Changeset: 250994a94a0e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/250994a94a0e
Modified Files:
gdk/gdk_bbp.c
Branch: Jul2021
Log Message:

Don't grow BBPsize unnecessarily.


diffs (11 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -916,7 +916,6 @@ BBPheader(FILE *fp, int *lineno, bat *bb
TRC_CRITICAL(GDK, "no BBPsize value found\n");
return 0;
}
-   sz = (int) (sz * BATMARGIN);
if (sz > *bbpsize)
*bbpsize = sz;
if (bbpversion > GDKLIBRARY_MINMAX_POS) {
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: strheapvacuum - merge with default

2021-09-22 Thread svetlin
Changeset: cebb20f1bd24 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cebb20f1bd24
Modified Files:
gdk/gdk_bbp.c
gdk/gdk_select.c
gdk/gdk_string.c
sql/storage/bat/bat_storage.c
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
Branch: strheapvacuum
Log Message:

merge with default


diffs (truncated from 2193 to 300 lines):

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,8 +53,7 @@ test_big_endian(IS_BIG_ENDIAN)
 include(monetdb-functions)
 include(monetdb-findpackages)
 include(monetdb-toolchain)
-monetdb_default_toolchain()
-#monetdb_default_compiler_options()
+monetdb_default_compiler_options()
 
 include(monetdb-defines)
 monetdb_hg_revision()
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -382,15 +382,16 @@ dump_foreign_keys(Mapi mid, const char *
if (tname != NULL) {
char *s = sescape(schema);
char *t = sescape(tname);
+   if (s == NULL || t == NULL) {
+   free(s);
+   free(t);
+   goto bailout;
+   }
maxquerylen = 1024 + strlen(t) + strlen(s);
query = malloc(maxquerylen);
-   if (s == NULL || t == NULL || query == NULL) {
-   if (s)
-   free(s);
-   if (t)
-   free(t);
-   if (query)
-   free(query);
+   if (query == NULL) {
+   free(s);
+   free(t);
goto bailout;
}
snprintf(query, maxquerylen,
diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -1255,6 +1255,7 @@ ODBCTranslateSQL(ODBCDbc *dbc, const SQL
strncpy(q, nquery, pr);
for (r = func->repl; *r; r++) {
if (*r == '\1' || *r == 
'\2' || *r == '\3' || *r == '\4') {
+   assert(*r <= 
func->nargs);
if (args[*r - 
1].argstart[0] == '\'')
q[pr++] 
= 'r';
strncpy(q + pr, 
args[*r - 1].argstart, args[*r - 1].arglen);
diff --git a/clients/odbc/driver/SQLTables.c b/clients/odbc/driver/SQLTables.c
--- a/clients/odbc/driver/SQLTables.c
+++ b/clients/odbc/driver/SQLTables.c
@@ -82,6 +82,8 @@ MNDBTables(ODBCStmt *stmt,
  "cast(null as varchar(1)) as remarks "
   "from sys.env() e "
   "where e.name = 'gdk_dbname'");
+   if (query == NULL)
+   goto nomem;
} else if (NameLength1 == 0 &&
   NameLength3 == 0 &&
   SchemaName &&
@@ -96,6 +98,8 @@ MNDBTables(ODBCStmt *stmt,
* schema remarks */
  "cast(null as varchar(1)) as remarks "
   "from sys.schemas order by table_schem");
+   if (query == NULL)
+   goto nomem;
} else if (NameLength1 == 0 &&
   NameLength2 == 0 &&
   NameLength3 == 0 &&
@@ -108,6 +112,8 @@ MNDBTables(ODBCStmt *stmt,
  "table_type_name as table_type, "
  "cast(null as varchar(1)) as remarks "
   "from sys.table_types order by table_type");
+   if (query == NULL)
+   goto nomem;
} else {
/* no special case argument values */
size_t querylen;
@@ -241,8 +247,6 @@ MNDBTables(ODBCStmt *stmt,
free(sch);
if (tab)
free(tab);
-   if (query)
-   free(query);
/* Memory allocation error */
addStmtError(stmt, "HY001", NULL, 0);
return SQL_ERROR;
diff --git a/cmake/monetdb-functions.cmake b/cmake/monetdb-functions.cmake
--- a/cmake/monetdb-functions.cmake
+++ b/cmake/monetdb-functions.cmake
@@ -49,33 +49,10 @@ function(monetdb_hg_revision)
   endif()
 endfunction()
 
-function(MT_addCompilerFlag REGEX_EXPRESSION FLAG_TO_ADD OLD_FLAGS BUILD 
NEW_FLAGS)
-  if(NOT "${OLD_FLAGS}" MATCHES "${REGEX_EXPRESSION}")
-set(${NEW_FLAGS} "${OLD_FLAGS} ${FLAG_TO_ADD}" PARENT_SCOPE)
-

MonetDB: default - Merge with Jul2021 branch.

2021-09-22 Thread Sjoerd Mullender
Changeset: 71134493516b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/71134493516b
Modified Files:
cmake/monetdb-functions.cmake
Branch: default
Log Message:

Merge with Jul2021 branch.


diffs (truncated from 506 to 300 lines):

diff --git a/cmake/monetdb-functions.cmake b/cmake/monetdb-functions.cmake
--- a/cmake/monetdb-functions.cmake
+++ b/cmake/monetdb-functions.cmake
@@ -9,40 +9,50 @@
 function(monetdb_hg_revision)
   # Get the current version control revision
   if(EXISTS "${CMAKE_SOURCE_DIR}/.hg_archival.txt")
-execute_process(COMMAND "sed" "-n" "s/^node: 
\\([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]\\).*/\\1/p"
 ".hg_archival.txt" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" RESULT_VARIABLE 
HG_RETURN_CODE
-  OUTPUT_VARIABLE HG_OUPUT_RES OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(HG_RETURN_CODE EQUAL 0 AND HG_OUPUT_RES)
-  set(MERCURIAL_ID "${HG_OUPUT_RES}" PARENT_SCOPE)
+file(READ "${CMAKE_SOURCE_DIR}/.hg_archival.txt" HG_ARCHIVAL)
+if(HG_ARCHIVAL MATCHES ".*node:.*")
+  string(REGEX REPLACE ".*node: 
([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]).*"
 "\\1" HG_NODE "${HG_ARCHIVAL}")
+  if(HG_ARCHIVAL MATCHES ".*local:.*")
+string(REGEX REPLACE ".*local: ([0-9][0-9]*).*" "\\1" HG_LOCAL 
"${HG_ARCHIVAL}")
+set(MERCURIAL_ID "${HG_NODE} ${HG_LOCAL}" PARENT_SCOPE)
+  else()
+set(MERCURIAL_ID "${HG_NODE}" PARENT_SCOPE)
+  endif()
 else()
-  message(FATAL_ERROR "Failed to find mercurial ID")
+  message(WARNING "Failed to find mercurial ID")
+  set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
 endif()
   elseif(EXISTS "${CMAKE_SOURCE_DIR}/.hg")
 find_package(Hg)
 if(HG_FOUND)
   message("hg found: ${HG_EXECUTABLE}")
 else()
-  message(FATAL_ERROR "Failed to find mercurial")
+  message(WARNING "Failed to find mercurial")
+  set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
 endif()
 execute_process(COMMAND "${HG_EXECUTABLE}" "id" "-i" WORKING_DIRECTORY 
"${CMAKE_SOURCE_DIR}" RESULT_VARIABLE HG_RETURN_CODE
   OUTPUT_VARIABLE HG_OUPUT_RES OUTPUT_STRIP_TRAILING_WHITESPACE)
 if(HG_RETURN_CODE EQUAL 0 AND HG_OUPUT_RES)
   set(MERCURIAL_ID "${HG_OUPUT_RES}" PARENT_SCOPE)
 else()
-  message(FATAL_ERROR "Failed to find mercurial ID")
+  message(WARNING "Failed to find mercurial ID")
+  set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
 endif()
   elseif(EXISTS "${CMAKE_SOURCE_DIR}/.git")
 find_package(Git)
 if(GIT_FOUND)
   message("git found: ${GIT_EXECUTABLE}")
 else()
-  message(FATAL_ERROR "Failed to find git")
+  message(WARNING "Failed to find git")
+  set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
 endif()
 execute_process(COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--short" "HEAD" 
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
   RESULT_VARIABLE GIT_RETURN_CODE OUTPUT_VARIABLE GIT_OUPUT_RES 
OUTPUT_STRIP_TRAILING_WHITESPACE)
 if(GIT_RETURN_CODE EQUAL 0 AND GIT_OUPUT_RES)
   set(MERCURIAL_ID "${GIT_OUPUT_RES}" PARENT_SCOPE)
 else()
-  message(FATAL_ERROR "Failed to find git ID")
+  message(WARNING "Failed to find git ID")
+  set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
 endif()
   else()
 set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
diff --git a/cmake/monetdb-toolchain.cmake b/cmake/monetdb-toolchain.cmake
--- a/cmake/monetdb-toolchain.cmake
+++ b/cmake/monetdb-toolchain.cmake
@@ -20,7 +20,11 @@ function(monetdb_default_compiler_option
   add_compile_options("-fsanitize=address")
   add_compile_options("-fno-omit-frame-pointer")
   add_compile_definitions(SANITIZER)
-  add_link_options("-fsanitize=address")
+  if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0")
+add_link_options("-fsanitize=address")
+  else()
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address" PARENT_SCOPE)
+  endif()
 else()
   message(FATAL_ERROR "Sanitizer only supported with GCC")
 endif()
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
@@ -326,7 +326,8 @@ static int
const char *local_tbl = prp->value;
node *n;
int i, q, v, res = 0, added_to_cache = 0,  *lret, *rret;
-   char *lname;
+   size_t len = 1024, nr;
+   char *lname, *buf;
sql_rel *r = rel;
 
if (local_tbl == NULL) {
@@ -386,9 +387,7 @@ static int
 
/* ops */
if (call && call->type == st_list) {
-   node *n;
-
-   for (n = call->op4.lval->h; n; n = n->next) {
+   for (node *n = call->op4.lval->h; n; n = n->next) {
stmt *op = n->data;
sql_subtype *t = tail_type(op);
int type = t->type->localtype;
@@ -413,15 +412,17 @@ static int
}
 
   

MonetDB: Jul2021 - Added test and fix for bug #7178 Clean buffer...

2021-09-22 Thread Pedro Ferreira
Changeset: 805335c934d4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/805335c934d4
Added Files:
sql/test/BugTracker-2021/Tests/remote-table-large.Bug-7178.SQL.py
Modified Files:
sql/backends/monet5/sql_gencode.c
sql/test/BugTracker-2021/Tests/All
Branch: Jul2021
Log Message:

Added test and fix for bug #7178 Clean buffer reallocation code at MAL remote 
plans generation and added defensive lines


diffs (298 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
@@ -326,7 +326,8 @@ static int
const char *local_tbl = prp->value;
node *n;
int i, q, v, res = 0, added_to_cache = 0,  *lret, *rret;
-   char *lname;
+   size_t len = 1024, nr;
+   char *lname, *buf;
sql_rel *r = rel;
 
if (local_tbl == NULL) {
@@ -386,9 +387,7 @@ static int
 
/* ops */
if (call && call->type == st_list) {
-   node *n;
-
-   for (n = call->op4.lval->h; n; n = n->next) {
+   for (node *n = call->op4.lval->h; n; n = n->next) {
stmt *op = n->data;
sql_subtype *t = tail_type(op);
int type = t->type->localtype;
@@ -413,15 +412,17 @@ static int
}
 
/* declare return variables */
-   for (i = 0, n = r->exps->h; n; n = n->next, i++) {
-   sql_exp *e = n->data;
-   int type = exp_subtype(e)->type->localtype;
+   if (!list_empty(r->exps)) {
+   for (i = 0, n = r->exps->h; n; n = n->next, i++) {
+   sql_exp *e = n->data;
+   int type = exp_subtype(e)->type->localtype;
 
-   type = newBatType(type);
-   p = newFcnCall(curBlk, batRef, newRef);
-   p = pushType(curBlk, p, getBatType(type));
-   setArgType(curBlk, p, 0, type);
-   lret[i] = getArg(p, 0);
+   type = newBatType(type);
+   p = newFcnCall(curBlk, batRef, newRef);
+   p = pushType(curBlk, p, getBatType(type));
+   setArgType(curBlk, p, 0, type);
+   lret[i] = getArg(p, 0);
+   }
}
 
/* q := remote.connect("schema.table", "msql"); */
@@ -451,99 +452,96 @@ static int
o = pushStr(curBlk, o, lname);
p = pushArgument(curBlk, p, getArg(o,0));
 
-   {
-   int len = 1024, nr = 0;
-   char *s, *buf = GDKmalloc(len);
-   if (!buf) {
+   if (!(buf = rel2str(m, rel))) {
GDKfree(lname);
sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
return -1;
}
-   s = rel2str(m, rel);
-   if (!s) {
-   GDKfree(lname);
-   GDKfree(buf);
-   sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
-   return -1;
-   }
o = newFcnCall(curBlk, remoteRef, putRef);
o = pushArgument(curBlk, o, q);
-   o = pushStr(curBlk, o, s);  /* relational plan */
+   o = pushStr(curBlk, o, buf);/* relational plan */
p = pushArgument(curBlk, p, getArg(o,0));
-   free(s);
-
-   s = "";
-   if (call && call->type == st_list) { /* Send existing variables in the 
plan */
-   node *n;
-
-   buf[0] = 0;
-   for (n = call->op4.lval->h; n; n = n->next) {
-   stmt *op = n->data;
-   sql_subtype *t = tail_type(op);
-   const char *nme = 
(op->op3)?op->op3->op4.aval->data.val.sval:op->cname;
+   free(buf);
 
-   if ((nr + 100) > len) {
-   char *tmp = GDKrealloc(buf, len*=2);
-   if (tmp == NULL) {
-   GDKfree(buf);
-   buf = NULL;
-   break;
-   }
-   buf = tmp;
-   }
-
-   nr += snprintf(buf+nr, len-nr, "%s %s(%u,%u)%c", nme, 
t->type->base.name, t->digits, t->scale, n->next?',':' ');
-   }
-   s = buf;
-   }
-   if (buf) {
-   o = newFcnCall(curBlk, remoteRef, putRef);
-   o = pushArgument(curBlk, o, q);
-   o = pushStr(curBlk, o, s);  /* signature */
-   p = pushArgument(curBlk, p, getArg(o,0));
-   } else {
+   if (!(buf = GDKmalloc(len))) {
GDKfree(lname);
sql_error(m, 001, SQLSTATE(HY013) MAL_MALLOC_FAIL);
return -1;
}
 
buf[0] = 0;
-   nr = 0;
-   for (n = r->exps->h; n; n = n->next) { /* Send SQL types of the 
projection's expressions */
-   sql_exp *e = n->data;
-   

MonetDB: Jul2021 - Don't be melodramatic: continue if revision n...

2021-09-22 Thread Sjoerd Mullender
Changeset: 3eb8eaaff36d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3eb8eaaff36d
Modified Files:
cmake/monetdb-functions.cmake
Branch: Jul2021
Log Message:

Don't be melodramatic: continue if revision number can't be found.


diffs (49 lines):

diff --git a/cmake/monetdb-functions.cmake b/cmake/monetdb-functions.cmake
--- a/cmake/monetdb-functions.cmake
+++ b/cmake/monetdb-functions.cmake
@@ -19,35 +19,40 @@ function(monetdb_hg_revision)
 set(MERCURIAL_ID "${HG_NODE}" PARENT_SCOPE)
   endif()
 else()
-  message(FATAL_ERROR "Failed to find mercurial ID")
+  message(WARNING "Failed to find mercurial ID")
+  set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
 endif()
   elseif(EXISTS "${CMAKE_SOURCE_DIR}/.hg")
 find_package(Hg)
 if(HG_FOUND)
   message("hg found: ${HG_EXECUTABLE}")
 else()
-  message(FATAL_ERROR "Failed to find mercurial")
+  message(WARNING "Failed to find mercurial")
+  set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
 endif()
 execute_process(COMMAND "${HG_EXECUTABLE}" "id" "-i" WORKING_DIRECTORY 
"${CMAKE_SOURCE_DIR}" RESULT_VARIABLE HG_RETURN_CODE
   OUTPUT_VARIABLE HG_OUPUT_RES OUTPUT_STRIP_TRAILING_WHITESPACE)
 if(HG_RETURN_CODE EQUAL 0 AND HG_OUPUT_RES)
   set(MERCURIAL_ID "${HG_OUPUT_RES}" PARENT_SCOPE)
 else()
-  message(FATAL_ERROR "Failed to find mercurial ID")
+  message(WARNING "Failed to find mercurial ID")
+  set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
 endif()
   elseif(EXISTS "${CMAKE_SOURCE_DIR}/.git")
 find_package(Git)
 if(GIT_FOUND)
   message("git found: ${GIT_EXECUTABLE}")
 else()
-  message(FATAL_ERROR "Failed to find git")
+  message(WARNING "Failed to find git")
+  set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
 endif()
 execute_process(COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--short" "HEAD" 
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
   RESULT_VARIABLE GIT_RETURN_CODE OUTPUT_VARIABLE GIT_OUPUT_RES 
OUTPUT_STRIP_TRAILING_WHITESPACE)
 if(GIT_RETURN_CODE EQUAL 0 AND GIT_OUPUT_RES)
   set(MERCURIAL_ID "${GIT_OUPUT_RES}" PARENT_SCOPE)
 else()
-  message(FATAL_ERROR "Failed to find git ID")
+  message(WARNING "Failed to find git ID")
+  set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
 endif()
   else()
 set(MERCURIAL_ID "Unknown" PARENT_SCOPE)
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jul2021 - Add local revision number to --version output...

2021-09-22 Thread Sjoerd Mullender
Changeset: be87bee659fe for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/be87bee659fe
Modified Files:
cmake/monetdb-functions.cmake
Branch: Jul2021
Log Message:

Add local revision number to --version output if built from tar ball and 
available.


diffs (23 lines):

diff --git a/cmake/monetdb-functions.cmake b/cmake/monetdb-functions.cmake
--- a/cmake/monetdb-functions.cmake
+++ b/cmake/monetdb-functions.cmake
@@ -9,10 +9,15 @@
 function(monetdb_hg_revision)
   # Get the current version control revision
   if(EXISTS "${CMAKE_SOURCE_DIR}/.hg_archival.txt")
-execute_process(COMMAND "sed" "-n" "s/^node: 
\\([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]\\).*/\\1/p"
 ".hg_archival.txt" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" RESULT_VARIABLE 
HG_RETURN_CODE
-  OUTPUT_VARIABLE HG_OUPUT_RES OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(HG_RETURN_CODE EQUAL 0 AND HG_OUPUT_RES)
-  set(MERCURIAL_ID "${HG_OUPUT_RES}" PARENT_SCOPE)
+file(READ "${CMAKE_SOURCE_DIR}/.hg_archival.txt" HG_ARCHIVAL)
+if(HG_ARCHIVAL MATCHES ".*node:.*")
+  string(REGEX REPLACE ".*node: 
([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]).*"
 "\\1" HG_NODE "${HG_ARCHIVAL}")
+  if(HG_ARCHIVAL MATCHES ".*local:.*")
+string(REGEX REPLACE ".*local: ([0-9][0-9]*).*" "\\1" HG_LOCAL 
"${HG_ARCHIVAL}")
+set(MERCURIAL_ID "${HG_NODE} ${HG_LOCAL}" PARENT_SCOPE)
+  else()
+set(MERCURIAL_ID "${HG_NODE}" PARENT_SCOPE)
+  endif()
 else()
   message(FATAL_ERROR "Failed to find mercurial ID")
 endif()
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - make sure we keep the order of sql.* function...

2021-09-22 Thread Niels Nes
Changeset: 8272a8fcc270 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8272a8fcc270
Modified Files:
monetdb5/optimizer/opt_reorder.c
Branch: default
Log Message:

make sure we keep the order of sql.* functions depending on the mvc input var


diffs (19 lines):

diff --git a/monetdb5/optimizer/opt_reorder.c b/monetdb5/optimizer/opt_reorder.c
--- a/monetdb5/optimizer/opt_reorder.c
+++ b/monetdb5/optimizer/opt_reorder.c
@@ -86,6 +86,7 @@ OPTreorderImplementation(Client cntxt, M
k =  getVarConstant(mb, getArg(p, 
p->argc-2)).val.ival;
assert( k < MAXSLICES);
depth[getArg(p,0)] = k;
+   depth[getArg(p,p->retc)] = k; /* keep order of 
mvc input var */
}
} else
if( getModuleId(p) == sqlRef && getFunctionId(p) == bindRef && 
p->argc == 8){
@@ -93,6 +94,7 @@ OPTreorderImplementation(Client cntxt, M
k =  getVarConstant(mb, getArg(p, 
p->argc-2)).val.ival;
assert( k < MAXSLICES);
depth[getArg(p,0)] = k;
+   depth[getArg(p,p->retc)] = k; /* keep order of 
mvc input var */
}
} else {
for(j= p->retc; j argc; j++){
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list