MonetDB: default - Add DECIMAL DELIMITER clause to COPY INTO syntax

2024-04-08 Thread Joeri van Ruth via checkin-list
Changeset: 813e6458abdf for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/813e6458abdf
Modified Files:
sql/server/rel_updates.c
sql/server/sql_parser.y
Branch: default
Log Message:

Add DECIMAL DELIMITER clause to COPY INTO syntax

Because of how the parser works,
DEC DELIMITER and NUMERIC DELIMITER are also accepted.
I kind of like that.


diffs (124 lines):

diff --git a/sql/server/rel_updates.c b/sql/server/rel_updates.c
--- a/sql/server/rel_updates.c
+++ b/sql/server/rel_updates.c
@@ -1555,7 +1555,7 @@ rel_import(mvc *sql, sql_table *t, const
 }
 
 static sql_rel *
-copyfrom(sql_query *query, dlist *qname, dlist *columns, dlist *files, dlist 
*headers, dlist *seps, dlist *nr_offset, str null_string, int best_effort, 
dlist *fwf_widths, int onclient, int escape)
+copyfrom(sql_query *query, dlist *qname, dlist *columns, dlist *files, dlist 
*headers, dlist *seps, dlist *nr_offset, str null_string, int best_effort, 
dlist *fwf_widths, int onclient, int escape, dlist *decimal_seps)
 {
mvc *sql = query->sql;
sql_rel *rel = NULL;
@@ -1570,6 +1570,8 @@ copyfrom(sql_query *query, dlist *qname,
lng offset = (nr_offset)?nr_offset->h->next->data.l_val:0;
list *collist;
int reorder = 0;
+   const char *decsep = decimal_seps->h->data.sval;
+
assert(!nr_offset || nr_offset->h->type == type_lng);
assert(!nr_offset || nr_offset->h->next->type == type_lng);
 
@@ -1583,6 +1585,14 @@ copyfrom(sql_query *query, dlist *qname,
"that will never match, use '\\n' instead");
}
 
+   if (strlen(decsep) != 1
+   || decsep[0] <= ' '
+   || decsep[0] >= 127
+   || decsep[0] == '-' || decsep[0] == '+'
+   || (decsep[0] >= '0' && decsep[0] <= '9')) {
+   return sql_error(sql, 02, SQLSTATE(42000) "COPY INTO: invalid 
decimal separator");
+   }
+
t = find_table_or_view_on_scope(sql, NULL, sname, tname, "COPY INTO", 
false);
if (insert_allowed(sql, t, tname, "COPY INTO", "copy into") == NULL)
return NULL;
@@ -2089,7 +2099,8 @@ rel_updates(sql_query *query, symbol *s)

l->h->next->next->next->next->next->next->next->data.i_val,

l->h->next->next->next->next->next->next->next->next->data.lval,

l->h->next->next->next->next->next->next->next->next->next->data.i_val,
-   
l->h->next->next->next->next->next->next->next->next->next->next->data.i_val);
+   
l->h->next->next->next->next->next->next->next->next->next->next->data.i_val,
+   
l->h->next->next->next->next->next->next->next->next->next->next->next->data.lval);
sql->type = Q_UPDATE;
}
break;
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -490,6 +490,7 @@ int yydebug=1;
opt_referencing_list
opt_schema_element_list
opt_seps
+   opt_decimal_seps
opt_seq_params
opt_typelist
opt_with_encrypted_password
@@ -2918,8 +2919,8 @@ opt_on_location:
   ;
 
 copyfrom_stmt:
-//  12  34 5   678 
  9   10   11 12  13  14
-COPY opt_nr INTO qname opt_column_list FROM string_commalist 
opt_header_list opt_on_location opt_seps opt_escape opt_null_string 
opt_best_effort opt_fwf_widths
+//  12  34 5   678 
  9   10   11   12 13  14   
   15
+COPY opt_nr INTO qname opt_column_list FROM string_commalist 
opt_header_list opt_on_location opt_seps opt_decimal_seps opt_escape 
opt_null_string opt_best_effort opt_fwf_widths
{ dlist *l = L();
  append_list(l, $4);
  append_list(l, $5);
@@ -2927,14 +2928,15 @@ copyfrom_stmt:
  append_list(l, $8);
  append_list(l, $10);
  append_list(l, $2);
- append_string(l, $12);
- append_int(l, $13);
- append_list(l, $14);
+ append_string(l, $13);
+ append_int(l, $14);
+ append_list(l, $15);
  append_int(l, $9);
- append_int(l, $11);
+ append_int(l, $12);
+ append_list(l, $11);
  $$ = _symbol_create_list( SQL_COPYFROM, l ); }
-//  12  34 5   67  8   9   
 10 11  12
-  | COPY opt_nr INTO qname opt_column_list FROM STDIN  opt_header_list 
opt_seps opt_escape opt_null_string opt_best_effort
+//  12  34 5   67  8   9   
 10   11 12  13
+  | COPY opt_nr INTO qname 

MonetDB: default - Implement DECIMAL DELIMITERS clause

2024-04-08 Thread Joeri van Ruth via checkin-list
Changeset: 6b605785c8a8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6b605785c8a8
Modified Files:
monetdb5/modules/mal/tablet.h
sql/backends/monet5/sql.c
sql/backends/monet5/sql_result.c
sql/backends/monet5/sql_result.h
sql/common/sql_types.c
sql/server/rel_updates.c
Branch: default
Log Message:

Implement DECIMAL DELIMITERS clause


diffs (220 lines):

diff --git a/monetdb5/modules/mal/tablet.h b/monetdb5/modules/mal/tablet.h
--- a/monetdb5/modules/mal/tablet.h
+++ b/monetdb5/modules/mal/tablet.h
@@ -30,6 +30,7 @@ typedef struct Column_t {
const char *name;   /* column title */
const char *sep;
const char *rsep;
+   char decsep;
int seplen;
const char *type;
int adt;/* type index */
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
@@ -3112,6 +3112,7 @@ mvc_import_table_wrap(Client cntxt, MalB
const char *fixed_widths = *getArgReference_str(stk, pci, pci->retc + 
9);
int onclient = *getArgReference_int(stk, pci, pci->retc + 10);
bool escape = *getArgReference_int(stk, pci, pci->retc + 11);
+   const char *decsep = *getArgReference_str(stk, pci, pci->retc + 12);
str msg = MAL_SUCCEED;
bstream *s = NULL;
stream *ss;
@@ -3132,7 +3133,7 @@ mvc_import_table_wrap(Client cntxt, MalB
if (strNil(fname))
fname = NULL;
if (fname == NULL) {
-   msg = mvc_import_table(cntxt, , be->mvc, be->mvc->scanner.rs, 
t, tsep, rsep, ssep, ns, sz, offset, besteffort, true, escape);
+   msg = mvc_import_table(cntxt, , be->mvc, be->mvc->scanner.rs, 
t, tsep, rsep, ssep, ns, sz, offset, besteffort, true, escape, decsep);
} else {
if (onclient) {
ss = mapi_request_upload(fname, false, 
be->mvc->scanner.rs, be->mvc->scanner.ws);
@@ -3190,7 +3191,7 @@ mvc_import_table_wrap(Client cntxt, MalB
close_stream(ss);
throw(MAL, "sql.copy_from", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
}
-   msg = mvc_import_table(cntxt, , be->mvc, s, t, tsep, rsep, 
ssep, ns, sz, offset, besteffort, false, escape);
+   msg = mvc_import_table(cntxt, , be->mvc, s, t, tsep, rsep, 
ssep, ns, sz, offset, besteffort, false, escape, decsep);
// This also closes ss:
bstream_destroy(s);
}
@@ -5288,7 +5289,7 @@ static mel_func sql_init_funcs[] = {
  pattern("sql", "export_bin_column", mvc_bin_export_column_wrap, true, "export 
column as binary", args(1, 5, arg("", lng), batargany("col", 1), 
arg("byteswap", bit), arg("filename", str), arg("onclient", int))),
  pattern("sql", "export_bin_column", mvc_bin_export_column_wrap, true, "export 
column as binary", args(1, 5, arg("", lng), argany("val", 1), arg("byteswap", 
bit), arg("filename", str), arg("onclient", int))),
  pattern("sql", "affectedRows", mvc_affected_rows_wrap, true, "export the 
number of affected rows by the current query", args(1,3, 
arg("",int),arg("mvc",int),arg("nr",lng))),
- pattern("sql", "copy_from", mvc_import_table_wrap, true, "Import a table from 
bstream s with the \ngiven tuple and seperators (sep/rsep)", args(1,13, 
batvarargany("",0),arg("t",ptr),arg("sep",str),arg("rsep",str),arg("ssep",str),arg("ns",str),arg("fname",str),arg("nr",lng),arg("offset",lng),arg("best",int),arg("fwf",str),arg("onclient",int),arg("escape",int))),
+ pattern("sql", "copy_from", mvc_import_table_wrap, true, "Import a table from 
bstream s with the \ngiven tuple and seperators (sep/rsep)", args(1,14, 
batvarargany("",0),arg("t",ptr),arg("sep",str),arg("rsep",str),arg("ssep",str),arg("ns",str),arg("fname",str),arg("nr",lng),arg("offset",lng),arg("best",int),arg("fwf",str),arg("onclient",int),arg("escape",int),arg("decsep",str))),
  //we use bat.single now
  //pattern("sql", "single", CMDBATsingle, false, "", args(1,2, 
batargany("",2),argany("x",2))),
  pattern("sql", "importColumn", mvc_bin_import_column_wrap, false, "Import a 
column from the given file", args(2, 8, batargany("", 0),arg("", oid), 
arg("method",str),arg("width",int),arg("bswap",bit),arg("path",str),arg("onclient",int),arg("nrows",oid))),
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -317,7 +317,7 @@ bat_max_length(hge, hge)
} else if (*s == '+'){  
\
s++;
\
}   
   

MonetDB: default - Implement DECIMAL thousands separator

2024-04-08 Thread Joeri van Ruth via checkin-list
Changeset: f2a4a8f53c71 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f2a4a8f53c71
Modified Files:
monetdb5/modules/mal/tablet.h
sql/backends/monet5/sql.c
sql/backends/monet5/sql_result.c
sql/backends/monet5/sql_result.h
sql/common/sql_types.c
sql/server/rel_updates.c
sql/server/sql_parser.y
Branch: default
Log Message:

Implement DECIMAL thousands separator


diffs (251 lines):

diff --git a/monetdb5/modules/mal/tablet.h b/monetdb5/modules/mal/tablet.h
--- a/monetdb5/modules/mal/tablet.h
+++ b/monetdb5/modules/mal/tablet.h
@@ -31,6 +31,7 @@ typedef struct Column_t {
const char *sep;
const char *rsep;
char decsep;
+   char decskip;
int seplen;
const char *type;
int adt;/* type index */
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
@@ -3113,6 +3113,7 @@ mvc_import_table_wrap(Client cntxt, MalB
int onclient = *getArgReference_int(stk, pci, pci->retc + 10);
bool escape = *getArgReference_int(stk, pci, pci->retc + 11);
const char *decsep = *getArgReference_str(stk, pci, pci->retc + 12);
+   const char *decskip = *getArgReference_str(stk, pci, pci->retc + 13);
str msg = MAL_SUCCEED;
bstream *s = NULL;
stream *ss;
@@ -3133,7 +3134,7 @@ mvc_import_table_wrap(Client cntxt, MalB
if (strNil(fname))
fname = NULL;
if (fname == NULL) {
-   msg = mvc_import_table(cntxt, , be->mvc, be->mvc->scanner.rs, 
t, tsep, rsep, ssep, ns, sz, offset, besteffort, true, escape, decsep);
+   msg = mvc_import_table(cntxt, , be->mvc, be->mvc->scanner.rs, 
t, tsep, rsep, ssep, ns, sz, offset, besteffort, true, escape, decsep, decskip);
} else {
if (onclient) {
ss = mapi_request_upload(fname, false, 
be->mvc->scanner.rs, be->mvc->scanner.ws);
@@ -3191,7 +3192,7 @@ mvc_import_table_wrap(Client cntxt, MalB
close_stream(ss);
throw(MAL, "sql.copy_from", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
}
-   msg = mvc_import_table(cntxt, , be->mvc, s, t, tsep, rsep, 
ssep, ns, sz, offset, besteffort, false, escape, decsep);
+   msg = mvc_import_table(cntxt, , be->mvc, s, t, tsep, rsep, 
ssep, ns, sz, offset, besteffort, false, escape, decsep, decskip);
// This also closes ss:
bstream_destroy(s);
}
@@ -5289,7 +5290,7 @@ static mel_func sql_init_funcs[] = {
  pattern("sql", "export_bin_column", mvc_bin_export_column_wrap, true, "export 
column as binary", args(1, 5, arg("", lng), batargany("col", 1), 
arg("byteswap", bit), arg("filename", str), arg("onclient", int))),
  pattern("sql", "export_bin_column", mvc_bin_export_column_wrap, true, "export 
column as binary", args(1, 5, arg("", lng), argany("val", 1), arg("byteswap", 
bit), arg("filename", str), arg("onclient", int))),
  pattern("sql", "affectedRows", mvc_affected_rows_wrap, true, "export the 
number of affected rows by the current query", args(1,3, 
arg("",int),arg("mvc",int),arg("nr",lng))),
- pattern("sql", "copy_from", mvc_import_table_wrap, true, "Import a table from 
bstream s with the \ngiven tuple and seperators (sep/rsep)", args(1,14, 
batvarargany("",0),arg("t",ptr),arg("sep",str),arg("rsep",str),arg("ssep",str),arg("ns",str),arg("fname",str),arg("nr",lng),arg("offset",lng),arg("best",int),arg("fwf",str),arg("onclient",int),arg("escape",int),arg("decsep",str))),
+ pattern("sql", "copy_from", mvc_import_table_wrap, true, "Import a table from 
bstream s with the \ngiven tuple and seperators (sep/rsep)", args(1,15, 
batvarargany("",0),arg("t",ptr),arg("sep",str),arg("rsep",str),arg("ssep",str),arg("ns",str),arg("fname",str),arg("nr",lng),arg("offset",lng),arg("best",int),arg("fwf",str),arg("onclient",int),arg("escape",int),arg("decsep",str),arg("decskip",str))),
  //we use bat.single now
  //pattern("sql", "single", CMDBATsingle, false, "", args(1,2, 
batargany("",2),argany("x",2))),
  pattern("sql", "importColumn", mvc_bin_import_column_wrap, false, "Import a 
column from the given file", args(2, 8, batargany("", 0),arg("", oid), 
arg("method",str),arg("width",int),arg("bswap",bit),arg("path",str),arg("onclient",int),arg("nrows",oid))),
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -318,6 +318,8 @@ bat_max_length(hge, hge)
s++;
\
}   
\
for (i = 0; *s && *s != c->decsep && ((res 

MonetDB: default - Switch to DECIMAL AS

2024-04-08 Thread Joeri van Ruth via checkin-list
Changeset: e29ee223f64d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e29ee223f64d
Modified Files:
sql/server/sql_parser.y
Branch: default
Log Message:

Switch to DECIMAL AS


diffs (17 lines):

diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -3059,11 +3059,11 @@ opt_decimal_seps:
{ dlist *l = L();
  append_string(l, sa_strdup(SA, "."));
  $$ = l; }
-   | sqlDECIMAL DELIMITERS string
+   | sqlDECIMAL opt_as string
{ dlist *l = L();
  append_string(l, $3);
  $$ = l; }
-   | sqlDECIMAL DELIMITERS string ',' string
+   | sqlDECIMAL opt_as string ',' string
{ dlist *l = L();
  append_string(l, $3);
  append_string(l, $5);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Add a test

2024-04-08 Thread Joeri van Ruth via checkin-list
Changeset: 356f67458c17 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/356f67458c17
Added Files:
sql/test/copy/Tests/decimal_separators.test
Modified Files:
sql/test/copy/Tests/All
Branch: default
Log Message:

Add a test


diffs (105 lines):

diff --git a/sql/test/copy/Tests/All b/sql/test/copy/Tests/All
--- a/sql/test/copy/Tests/All
+++ b/sql/test/copy/Tests/All
@@ -4,6 +4,7 @@ escaped_char
 null_as_string
 null_as_string_errors
 null_as_string_output
+decimal_separators
 int_parse_best
 int_parse
 load_stdin_incorrect_line_nr
diff --git a/sql/test/copy/Tests/decimal_separators.test 
b/sql/test/copy/Tests/decimal_separators.test
new file mode 100644
--- /dev/null
+++ b/sql/test/copy/Tests/decimal_separators.test
@@ -0,0 +1,89 @@
+statement ok
+START TRANSACTION
+
+statement ok
+CREATE TABLE decimals(id INT, d DECIMAL(8,2))
+
+--
+-- this is the default behavior
+--
+
+statement ok
+COPY 3 RECORDS INTO decimals FROM STDIN
+
+1| 123.45
+2|+123.45
+3|-123.45
+
+query T
+SELECT d FROM decimals ORDER BY id
+
+123.45
+123.45
+-123.45
+
+statement ok
+DELETE FROM decimals
+
+--
+-- customize the decimal separator
+--
+
+statement ok
+COPY 3 RECORDS INTO decimals FROM STDIN DECIMAL AS ','
+
+1| 123,45
+2|+123,45
+3|-123,45
+
+query T
+SELECT d FROM decimals ORDER BY id
+
+123.45
+123.45
+-123.45
+
+statement ok
+DELETE FROM decimals
+
+--
+-- also set a thousands separator
+--
+
+statement ok
+COPY 3 RECORDS INTO decimals FROM STDIN DECIMAL AS ',', '_'
+
+1| 1_23,45
+2|+1_23,45
+3|-1_23,45
+
+query T
+SELECT d FROM decimals ORDER BY id
+
+123.45
+123.45
+-123.45
+
+statement ok
+DELETE FROM decimals
+
+--
+-- the 'AS' is optional
+--
+
+statement ok
+COPY 3 RECORDS INTO decimals FROM STDIN DECIMAL ',', '_'
+
+1| 1_23,45
+2|+1_23,4__5
+3|-1_23,_45
+
+query T
+SELECT d FROM decimals ORDER BY id
+
+123.45
+123.45
+-123.45
+
+statement ok
+DELETE FROM decimals
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Implement DECIMAL AS for interval types

2024-04-08 Thread Joeri van Ruth via checkin-list
Changeset: e30fddb940f0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e30fddb940f0
Modified Files:
sql/backends/monet5/sql_result.c
sql/test/copy/Tests/decimal_separators.test
Branch: default
Log Message:

Implement DECIMAL AS for interval types


diffs (133 lines):

diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -405,7 +405,11 @@ sec_frstr(Column *c, int type, const cha
neg = 0;
s++;
}
-   for (i = 0; i < (19 - 3) && *s && *s != '.'; i++, s++) {
+   for (i = 0; i < (19 - 3) && *s && *s != c->decsep; i++, s++) {
+   if (c->decskip && *s == c->decskip) {
+   i--;
+   continue;
+   }
if (!isdigit((unsigned char) *s))
return NULL;
res *= 10;
@@ -413,10 +417,14 @@ sec_frstr(Column *c, int type, const cha
}
i = 0;
if (*s) {
-   if (*s != '.')
+   if (*s != c->decsep)
return NULL;
s++;
for (; *s && i < 3; i++, s++) {
+   if (c->decskip && *s == c->decskip) {
+   i--;
+   continue;
+   }
if (!isdigit((unsigned char) *s))
return NULL;
res *= 10;
@@ -624,8 +632,8 @@ mvc_import_table(Client cntxt, BAT ***ba
} else if (col->type.type->eclass == EC_SEC) {
fmt[i].tostr = _tostr;
fmt[i].frstr = _frstr;
-   fmt[i].decsep = '.';  // not sure if it should 
be affected by DECIMAL DELIMITERS clause
-   fmt[i].decskip = '\0';
+   fmt[i].decsep = decsep[0];  // apply DECIMAL 
DELIMITERS clause
+   fmt[i].decskip = decskip[0];
}
fmt[i].size = ATOMsize(fmt[i].adt);
}
diff --git a/sql/test/copy/Tests/decimal_separators.test 
b/sql/test/copy/Tests/decimal_separators.test
--- a/sql/test/copy/Tests/decimal_separators.test
+++ b/sql/test/copy/Tests/decimal_separators.test
@@ -4,6 +4,12 @@ START TRANSACTION
 statement ok
 CREATE TABLE decimals(id INT, d DECIMAL(8,2))
 
+statement ok
+CREATE TABLE secs(id INT, i INTERVAL SECOND)
+
+statement ok
+CREATE TABLE days(id INT, i INTERVAL DAY)
+
 --
 -- this is the default behavior
 --
@@ -87,3 +93,73 @@ 123.45
 
 statement ok
 DELETE FROM decimals
+
+
+--
+-- interval types, default behavior
+--
+
+statement ok
+COPY 2 RECORDS INTO secs FROM STDIN
+
+1|1.000
+2|1800.000
+
+query T
+SELECT i FROM secs ORDER BY id
+
+0:00:01
+0:30:00
+
+statement ok
+DELETE FROM secs
+
+-- is this really how we copy day intervals from csv?
+statement ok
+COPY 2 RECORDS INTO days FROM STDIN
+
+1|86400
+2|1814400.00
+
+query T
+SELECT i FROM days ORDER BY id
+
+1
+21
+
+statement ok
+DELETE FROM days
+
+--
+-- interval types, behavior with decimal comma and thousands separator
+--
+
+statement ok
+COPY 2 RECORDS INTO secs FROM STDIN DECIMAL AS ',', '_'
+
+1|1,00_0
+2|1_800,00_0
+
+query T
+SELECT i FROM secs ORDER BY id
+
+0:00:01
+0:30:00
+
+statement ok
+DELETE FROM secs
+
+statement ok
+COPY 2 RECORDS INTO days FROM STDIN DECIMAL AS ',', '_'
+
+1|86_400
+2|1_814_400,00
+
+query T
+SELECT i FROM days ORDER BY id
+
+1
+21
+
+statement ok
+DELETE FROM days
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - align terminal numbering comment

2024-04-08 Thread Joeri van Ruth via checkin-list
Changeset: f0f680a02575 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f0f680a02575
Modified Files:
sql/server/sql_parser.y
Branch: default
Log Message:

align terminal numbering comment


diffs (12 lines):

diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -2918,7 +2918,7 @@ opt_on_location:
   ;
 
 copyfrom_stmt:
-//  12  34 5678
   9   10   11 12  13  14
+//  12  34 5   678 
  9   10   11 12  13  14
 COPY opt_nr INTO qname opt_column_list FROM string_commalist 
opt_header_list opt_on_location opt_seps opt_escape opt_null_string 
opt_best_effort opt_fwf_widths
{ dlist *l = L();
  append_list(l, $4);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge 'decimaldelimiters' into 'default'

2024-04-08 Thread Joeri van Ruth via checkin-list
Changeset: 700573773140 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/700573773140
Modified Files:
sql/backends/monet5/sql.c
sql/backends/monet5/sql_result.c
sql/backends/monet5/vaults/csv/csv.c
sql/common/sql_types.c
sql/server/rel_updates.c
sql/server/sql_parser.y
Branch: default
Log Message:

Merge 'decimaldelimiters' into 'default'


diffs (truncated from 856 to 300 lines):

diff --git a/monetdb5/modules/mal/tablet.h b/monetdb5/modules/mal/tablet.h
--- a/monetdb5/modules/mal/tablet.h
+++ b/monetdb5/modules/mal/tablet.h
@@ -30,6 +30,8 @@ typedef struct Column_t {
const char *name;   /* column title */
const char *sep;
const char *rsep;
+   char decsep;
+   char decskip;
int seplen;
const char *type;
int adt;/* type index */
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
@@ -3140,6 +3140,8 @@ mvc_import_table_wrap(Client cntxt, MalB
const char *fixed_widths = *getArgReference_str(stk, pci, pci->retc + 
9);
int onclient = *getArgReference_int(stk, pci, pci->retc + 10);
bool escape = *getArgReference_int(stk, pci, pci->retc + 11);
+   const char *decsep = *getArgReference_str(stk, pci, pci->retc + 12);
+   const char *decskip = *getArgReference_str(stk, pci, pci->retc + 13);
str msg = MAL_SUCCEED;
bstream *s = NULL;
stream *ss;
@@ -3149,6 +3151,10 @@ mvc_import_table_wrap(Client cntxt, MalB
return msg;
if (onclient && !cntxt->filetrans)
throw(MAL, "sql.copy_from", SQLSTATE(42000) "Cannot transfer 
files from client");
+   if (strNil(decsep))
+   throw(MAL, "sql.copy_from", SQLSTATE(42000) "decimal separator 
cannot be nil");
+   if (strNil(decskip))
+   decskip = NULL;
 
be = cntxt->sqlcontext;
/* The CSV parser expects ssep to have the value 0 if the user does not
@@ -3160,7 +3166,7 @@ mvc_import_table_wrap(Client cntxt, MalB
if (strNil(fname))
fname = NULL;
if (fname == NULL) {
-   msg = mvc_import_table(cntxt, , be->mvc, be->mvc->scanner.rs, 
t, tsep, rsep, ssep, ns, sz, offset, besteffort, true, escape);
+   msg = mvc_import_table(cntxt, , be->mvc, be->mvc->scanner.rs, 
t, tsep, rsep, ssep, ns, sz, offset, besteffort, true, escape, decsep, decskip);
} else {
if (onclient) {
ss = mapi_request_upload(fname, false, 
be->mvc->scanner.rs, be->mvc->scanner.ws);
@@ -3218,7 +3224,7 @@ mvc_import_table_wrap(Client cntxt, MalB
close_stream(ss);
throw(MAL, "sql.copy_from", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
}
-   msg = mvc_import_table(cntxt, , be->mvc, s, t, tsep, rsep, 
ssep, ns, sz, offset, besteffort, false, escape);
+   msg = mvc_import_table(cntxt, , be->mvc, s, t, tsep, rsep, 
ssep, ns, sz, offset, besteffort, false, escape, decsep, decskip);
// This also closes ss:
bstream_destroy(s);
}
@@ -5314,7 +5320,7 @@ static mel_func sql_init_funcs[] = {
  pattern("sql", "export_bin_column", mvc_bin_export_column_wrap, true, "export 
column as binary", args(1, 5, arg("", lng), batargany("col", 1), 
arg("byteswap", bit), arg("filename", str), arg("onclient", int))),
  pattern("sql", "export_bin_column", mvc_bin_export_column_wrap, true, "export 
column as binary", args(1, 5, arg("", lng), argany("val", 1), arg("byteswap", 
bit), arg("filename", str), arg("onclient", int))),
  pattern("sql", "affectedRows", mvc_affected_rows_wrap, true, "export the 
number of affected rows by the current query", args(1,3, 
arg("",int),arg("mvc",int),arg("nr",lng))),
- pattern("sql", "copy_from", mvc_import_table_wrap, true, "Import a table from 
bstream s with the \ngiven tuple and seperators (sep/rsep)", args(1,13, 
batvarargany("",0),arg("t",ptr),arg("sep",str),arg("rsep",str),arg("ssep",str),arg("ns",str),arg("fname",str),arg("nr",lng),arg("offset",lng),arg("best",int),arg("fwf",str),arg("onclient",int),arg("escape",int))),
+ pattern("sql", "copy_from", mvc_import_table_wrap, true, "Import a table from 
bstream s with the \ngiven tuple and seperators (sep/rsep)", args(1,15, 
batvarargany("",0),arg("t",ptr),arg("sep",str),arg("rsep",str),arg("ssep",str),arg("ns",str),arg("fname",str),arg("nr",lng),arg("offset",lng),arg("best",int),arg("fwf",str),arg("onclient",int),arg("escape",int),arg("decsep",str),arg("decskip",str))),
  //we use bat.single now
  //pattern("sql", "single", CMDBATsingle, false, "", args(1,2, 
batargany("",2),argany("x",2))),
  pattern("sql", "importColumn", mvc_bin_import_column_wrap, false, "Import a 
column from the given file", args(2, 8, batargany("", 0),arg("", oid), 

MonetDB: default - Adapt test to changed sys.copyfrom signature

2024-04-08 Thread Joeri van Ruth via checkin-list
Changeset: 1142f4d64b76 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1142f4d64b76
Modified Files:

sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320-Windows.test
sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test
Branch: default
Log Message:

Adapt test to changed sys.copyfrom signature


diffs (48 lines):

diff --git 
a/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320-Windows.test 
b/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320-Windows.test
--- a/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320-Windows.test
+++ b/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320-Windows.test
@@ -11,11 +11,11 @@ insert(
 | table("sys"."cm_tmp") [ "cm_tmp"."i" NOT NULL UNIQUE, "cm_tmp"."%TID%" NOT 
NULL UNIQUE ]
 | union (
 | | project (
-| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "\\file1", bigint(19) "-1", bigint(19) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1"), 
+| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "\\file1", bigint(19) "-1", bigint(19) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1", varchar ".", varchar 
NULL), 
 | | | ) [ "cm_tmp"."i" ]
 | | ) [ "cm_tmp"."i" ],
 | | project (
-| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "\\file2", bigint(19) "-1", bigint(19) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1"), 
+| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "\\file2", bigint(19) "-1", bigint(19) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1", varchar ".", varchar 
NULL), 
 | | | ) [ "cm_tmp"."i" ]
 | | ) [ "cm_tmp"."i" ]
 | ) [ int(31) NULL ]
@@ -28,11 +28,11 @@ insert(
 | table("sys"."cm_tmp") [ "cm_tmp"."i" NOT NULL UNIQUE, "cm_tmp"."%TID%" NOT 
NULL UNIQUE ]
 | union (
 | | project (
-| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "a:\\file1", bigint(19) "-1", bigint(19) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1"), 
+| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "a:\\file1", bigint(19) "-1", bigint(19) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1", varchar ".", varchar 
NULL), 
 | | | ) [ "cm_tmp"."i" ]
 | | ) [ "cm_tmp"."i" ],
 | | project (
-| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "Z:/file2", bigint(19) "-1", bigint(19) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1"), 
+| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "Z:/file2", bigint(19) "-1", bigint(19) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1", varchar ".", varchar 
NULL), 
 | | | ) [ "cm_tmp"."i" ]
 | | ) [ "cm_tmp"."i" ]
 | ) [ int(31) NULL ]
diff --git a/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test 
b/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test
--- a/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test
+++ b/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test
@@ -8,11 +8,11 @@ insert(
 | table("sys"."cm_tmp") [ "cm_tmp"."i" NOT NULL UNIQUE, "cm_tmp"."%TID%" NOT 
NULL UNIQUE ]
 | union (
 | | project (
-| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "/file1", bigint(18) "-1", bigint(18) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1"), 
+| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "/file1", bigint(18) "-1", bigint(18) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1", varchar ".", varchar 
NULL), 
 | | | ) [ "cm_tmp"."i" ]
 | | ) [ "cm_tmp"."i" ],
 | | project (
-| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "/file2", bigint(18) "-1", bigint(18) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1"), 
+| | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n", 
varchar NULL, varchar "null", varchar "/file2", bigint(18) "-1", bigint(18) 
"0", int(9) "0", varchar NULL, int(9) "0", int(9) "1", varchar ".", varchar 
NULL), 
 | | | ) [ "cm_tmp"."i" ]
 | | ) [ "cm_tmp"."i" ]
 | ) [ int(31) NULL ]
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Adapt CSV loader to changed sys.copyfrom sign...

2024-04-08 Thread Joeri van Ruth via checkin-list
Changeset: c05adc9d94f4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c05adc9d94f4
Modified Files:
sql/backends/monet5/vaults/csv/csv.c
Branch: default
Log Message:

Adapt CSV loader to changed sys.copyfrom signature


diffs (60 lines):

diff --git a/sql/backends/monet5/vaults/csv/csv.c 
b/sql/backends/monet5/vaults/csv/csv.c
--- a/sql/backends/monet5/vaults/csv/csv.c
+++ b/sql/backends/monet5/vaults/csv/csv.c
@@ -488,7 +488,7 @@ csv_load(void *BE, sql_subfunc *f, char 
/* (res bats) := import(table T, 'delimit', '\n', 'quote', str:nil, 
fname, lng:nil, 0/1, 0, str:nil, int:nil, * int:nil ); */
 
/* lookup copy_from */
-   sql_subfunc *cf = sql_find_func(sql, "sys", "copyfrom", 12, F_UNION, 
true, NULL);
+   sql_subfunc *cf = sql_find_func(sql, "sys", "copyfrom", 14, F_UNION, 
true, NULL);
cf->res = f->res;
 
sql_subtype tpe;
@@ -506,27 +506,27 @@ csv_load(void *BE, sql_subfunc *f, char 
rsep[0] = '\n';
rsep[1] = 0;
}
-   list *args = append( append( append( append( append( 
new_exp_list(sql->sa),
-   exp_atom_ptr(sql->sa, t)),
-   exp_atom_str(sql->sa, tsep, )),
-   exp_atom_str(sql->sa, rsep, )),
-   exp_atom_str(sql->sa, ssep, )),
-   exp_atom_str(sql->sa, "", ));
+   list *args = new_exp_list(sql->sa);
+
+   append(args, exp_atom_ptr(sql->sa, t));
+   append(args, exp_atom_str(sql->sa, tsep, ));
+   append(args, exp_atom_str(sql->sa, rsep, ));
+   append(args, exp_atom_str(sql->sa, ssep, ));
 
-   append( args, exp_atom_str(sql->sa, filename, ));
-   sql_exp *import = exp_op(sql->sa,
-   append(
-   append(
-   append(
-   append(
-   append(
-   append(args, topn?topn:
-  exp_atom_lng(sql->sa, -1)),
-   exp_atom_lng(sql->sa, 
r->has_header?2:1)),
-   exp_atom_int(sql->sa, 0)),
-   exp_atom_str(sql->sa, NULL, )),
-   exp_atom_int(sql->sa, 0)),
-   exp_atom_int(sql->sa, 0)), cf);
+   append(args, exp_atom_str(sql->sa, "", ));
+   append(args, exp_atom_str(sql->sa, filename, ));
+   append(args, topn ? topn: exp_atom_lng(sql->sa, -1));
+   append(args, exp_atom_lng(sql->sa, r->has_header?2:1));
+
+   append(args, exp_atom_int(sql->sa, 0));
+   append(args, exp_atom_str(sql->sa, NULL, ));
+   append(args, exp_atom_int(sql->sa, 0));
+   append(args, exp_atom_int(sql->sa, 0));
+
+   append(args, exp_atom_str(sql->sa, ".", ));
+   append(args, exp_atom_str(sql->sa, NULL, ));
+
+   sql_exp *import = exp_op(sql->sa, args, cf);
 
return exp_bin(be, import, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0);
 }
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Implement DECIMAL AS for floats

2024-04-08 Thread Joeri van Ruth via checkin-list
Changeset: 2402505ea2a8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2402505ea2a8
Modified Files:
sql/backends/monet5/sql.c
sql/backends/monet5/sql_result.c
sql/test/copy/Tests/decimal_separators.test
Branch: default
Log Message:

Implement DECIMAL AS for floats


diffs (205 lines):

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
@@ -3123,6 +3123,10 @@ mvc_import_table_wrap(Client cntxt, MalB
return msg;
if (onclient && !cntxt->filetrans)
throw(MAL, "sql.copy_from", SQLSTATE(42000) "Cannot transfer 
files from client");
+   if (strNil(decsep))
+   throw(MAL, "sql.copy_from", SQLSTATE(42000) "decimal separator 
cannot be nil");
+   if (strNil(decskip))
+   decskip = NULL;
 
be = cntxt->sqlcontext;
/* The CSV parser expects ssep to have the value 0 if the user does not
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -447,6 +447,64 @@ sec_frstr(Column *c, int type, const cha
return (void *) r;
 }
 
+static void *
+fltdbl_frStr(Column *c, int type, const char *s)
+{
+   // The regular fltFromStr/dblFromStr functions do not take decimal 
commas
+   // and thousands separators into account. When these are in use, this
+   // function first converts them to decimal dots and empty strings,
+   // respectively. We use a fixed size buffer so abnormally long floats 
such
+   // as
+   // 
+001.5e1
+   // will be rejected.
+
+   if (c->decskip || c->decsep != '.') {
+   // According to Stack Overflow 
https://stackoverflow.com/questions/1701055/what-is-the-maximum-length-in-chars-needed-to-represent-any-double-value
+   // 24 bytes is a reasonable buffer but we'll make it a bit 
larger.
+   char tmp[120];
+   char *p = [0];
+
+   while (GDKisspace(*s))
+   s++;
+   while (*s != '\0') {
+   if (p >= tmp + sizeof(tmp) - 1) {
+   // If the input is this big it's probably an 
error.
+   // Exception: only whitespace remains.
+   while (GDKisspace(*s))
+   s++;
+   if (*s == '\0') {
+   // there was only trailing whitespace
+   break;
+   } else {
+   // not just trailing whitespace, abort!
+   return NULL;
+   }
+   }
+   char ch = *s++;
+   if (ch == c->decskip) {
+   continue;
+   } else if (ch == c->decsep) {
+   ch = '.';
+   } else if (ch == '.') {
+   // We're mapping c->decsep to '.', if there are 
already
+   // periods in the input we're losing information
+   return NULL;
+   }
+   *p++ = ch;
+   }
+   // If we're here either we either encountered the end of s or 
the buffer is
+   // full. In the latter case we still need to write the NUL.
+   // We left room for it.
+   *p = '\0';
+
+   // now process the converted text rather than the original
+   s = [0];
+   }
+
+   ssize_t len = (*BATatoms[type].atomFromStr) (s, >len, >data, 
false);
+   return (len > 0) ? c->data : NULL;
+}
+
 /* Literal parsing for SQL all pass through this routine */
 static void *
 _ASCIIadt_frStr(Column *c, int type, const char *s)
@@ -599,8 +657,8 @@ mvc_import_table(Client cntxt, BAT ***ba
fmt[i].sep = (n->next) ? sep : rsep;
fmt[i].rsep = rsep;
fmt[i].seplen = _strlen(fmt[i].sep);
-   fmt[i].decsep = '\0',
-   fmt[i].decskip = '\0',
+   fmt[i].decsep = decsep[0],
+   fmt[i].decskip = decskip != NULL ? decskip[0] : '\0',
fmt[i].type = sql_subtype_string(m->ta, >type);
fmt[i].adt = ATOMindex(col->type.type->impl);
fmt[i].tostr = &_ASCIIadt_toStr;
@@ -627,13 +685,12 @@ mvc_import_table(Client cntxt, BAT ***ba
if (col->type.type->eclass == EC_DEC) {
fmt[i].tostr = _tostr;
fmt[i].frstr = 

MonetDB: default - approved new copy_from interface

2024-04-08 Thread Niels Nes via checkin-list
Changeset: 2d76f6b61636 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2d76f6b61636
Modified Files:
clients/Tests/MAL-signatures-hge.test
Branch: default
Log Message:

approved new copy_from interface


diffs (12 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -48925,7 +48925,7 @@ mvc_clear_table_wrap;
 Clear the table sname.tname.
 sql
 copy_from
-unsafe pattern sql.copy_from(X_0:ptr, X_1:str, X_2:str, X_3:str, X_4:str, 
X_5:str, X_6:lng, X_7:lng, X_8:int, X_9:str, X_10:int, X_11:int):bat[:any]...
+unsafe pattern sql.copy_from(X_0:ptr, X_1:str, X_2:str, X_3:str, X_4:str, 
X_5:str, X_6:lng, X_7:lng, X_8:int, X_9:str, X_10:int, X_11:int, X_12:str, 
X_13:str):bat[:any]...
 mvc_import_table_wrap;
 Import a table from bstream s with the @given tuple and seperators (sep/rsep)
 sql
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - no popcnt64 on 32 bit windows

2024-04-08 Thread Niels Nes via checkin-list
Changeset: d73ba7630731 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d73ba7630731
Modified Files:
sql/server/rel_optimize_sel.c
Branch: default
Log Message:

no popcnt64 on 32 bit windows


diffs (16 lines):

diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c
--- a/sql/server/rel_optimize_sel.c
+++ b/sql/server/rel_optimize_sel.c
@@ -2049,7 +2049,12 @@ popcount64(uint64_t x)
 #if defined(__GNUC__)
return (uint32_t) __builtin_popcountll(x);
 #elif defined(_MSC_VER)
+#if SIZEOF_OID == 4
+   /* no __popcnt64 on 32 bit Windows */
+   return (int) (__popcnt((uint32_t) x) + __popcnt((uint32_t) (x >> 32)));
+#else
return (uint32_t) __popcnt64(x);
+#endif
 #else
x = (x & 0xULL) + ((x >> 1) & 0xULL);
x = (x & 0xULL) + ((x >> 2) & 0xULL);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - use floats for number of steps for floating p...

2024-04-08 Thread Niels Nes via checkin-list
Changeset: 852c9602954d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/852c9602954d
Modified Files:
sql/backends/monet5/generator/generator.c
Branch: default
Log Message:

use floats for number of steps for floating point types.


diffs (47 lines):

diff --git a/sql/backends/monet5/generator/generator.c 
b/sql/backends/monet5/generator/generator.c
--- a/sql/backends/monet5/generator/generator.c
+++ b/sql/backends/monet5/generator/generator.c
@@ -96,6 +96,30 @@ VLTgenerator_noop(Client cntxt, MalBlkPt
bn->trevsorted = s < 0 || n <= 1;   
\
} while (0)
 
+#define VLTmaterialize_flt(TPE)
\
+   do {
\
+   TPE *v, f, l, s;
\
+   f = *getArgReference_##TPE(stk, pci, 1);
\
+   l = *getArgReference_##TPE(stk, pci, 2);
\
+   if ( pci->argc == 3)
\
+   s = f 0 && f > l) || (s < 0 && f < l) || 
is_##TPE##_nil(f) || is_##TPE##_nil(l)) \
+   throw(MAL, "generator.table",   
\
+ SQLSTATE(42000) "Illegal generator range");   
\
+   n = (BUN) ((l - f) / s);
\
+   if ((TPE) (n * s + f) != l) 
\
+   n++;
\
+   bn = COLnew(0, TYPE_##TPE, n, TRANSIENT);   
\
+   if (bn == NULL) 
\
+   throw(MAL, "generator.table", SQLSTATE(HY013) 
MAL_MALLOC_FAIL); \
+   v = (TPE*) Tloc(bn, 0); 
\
+   for (c = 0; c < n; c++) 
\
+   *v++ = (TPE) (f + c * s);   
\
+   bn->tsorted = s > 0 || n <= 1;  
\
+   bn->trevsorted = s < 0 || n <= 1;   
\
+   } while (0)
+
 static str
 VLTgenerator_table_(BAT **result, Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci)
 {
@@ -125,10 +149,10 @@ VLTgenerator_table_(BAT **result, Client
break;
 #endif
case TYPE_flt:
-   VLTmaterialize(flt);
+   VLTmaterialize_flt(flt);
break;
case TYPE_dbl:
-   VLTmaterialize(dbl);
+   VLTmaterialize_flt(dbl);
break;
default:
if (tpe == TYPE_timestamp) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: no_type_bat - Merge with default branch.

2024-04-08 Thread Sjoerd Mullender via checkin-list
Changeset: 91147e78f0be for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/91147e78f0be
Modified Files:
sql/server/rel_optimize_sel.c
Branch: no_type_bat
Log Message:

Merge with default branch.


diffs (134 lines):

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
@@ -462,10 +462,10 @@ popcount64(uint64_t x)
return (int) __popcnt64(x);
 #endif
 #else
-   x = (x & 0xULL) + ((x >> 1) & 0xULL);
-   x = (x & 0xULL) + ((x >> 2) & 0xULL);
-   x = (x & 0x0F0F0F0F0F0F0F0FULL) + ((x >> 4) & 0x0F0F0F0F0F0F0F0FULL);
-   return (int) ((x * 0x0101010101010101ULL) >> 56);
+   x = (x & UINT64_C(0x)) + ((x >> 1) & 
UINT64_C(0x));
+   x = (x & UINT64_C(0x)) + ((x >> 2) & 
UINT64_C(0x));
+   x = (x & UINT64_C(0x0F0F0F0F0F0F0F0F)) + ((x >> 4) & 
UINT64_C(0x0F0F0F0F0F0F0F0F));
+   return (int) ((x * UINT64_C(0x0101010101010101)) >> 56);
 #endif
 }
 
@@ -501,10 +501,10 @@ str_alphabet_bitmap(str_item *s)
 {
int i;
 
-   s->abm = 0ULL;
+   s->abm = UINT64_C(0);
 
for (i = 0; i < s->len; i++)
-   s->abm |= 1ULL << (s->cp_sequence[i] % 64);
+   s->abm |= UINT64_C(1) << (s->cp_sequence[i] % 64);
 
s->abm_popcount = popcount64(s->abm);
 }
diff --git a/sql/backends/monet5/generator/generator.c 
b/sql/backends/monet5/generator/generator.c
--- a/sql/backends/monet5/generator/generator.c
+++ b/sql/backends/monet5/generator/generator.c
@@ -78,7 +78,36 @@ VLTgenerator_noop(Client cntxt, MalBlkPt
if (s == 0 || (s > 0 && f > l) || (s < 0 && f < l) || 
is_##TPE##_nil(f) || is_##TPE##_nil(l)) \
throw(MAL, "generator.table",   
\
  SQLSTATE(42000) "Illegal generator range");   
\
-   n = (BUN) ((l - f) / s);
\
+   if (s < 0)  
\
+   n = ((BUN)f - l);   
\
+   else
\
+   n = ((BUN)l - f);   
\
+   step = s<0?-s:s;
\
+   n = n/step; 
\
+   if ((TPE) (n * s + f) != l) 
\
+   n++;
\
+   bn = COLnew(0, TYPE_##TPE, n, TRANSIENT);   
\
+   if (bn == NULL) 
\
+   throw(MAL, "generator.table", SQLSTATE(HY013) 
MAL_MALLOC_FAIL); \
+   v = (TPE*) Tloc(bn, 0); 
\
+   for (c = 0; c < n; c++) 
\
+   *v++ = (TPE) (f + c * s);   
\
+   bn->tsorted = s > 0 || n <= 1;  
\
+   bn->trevsorted = s < 0 || n <= 1;   
\
+   } while (0)
+
+#define VLTmaterialize_flt(TPE)
\
+   do {
\
+   TPE *v, f, l, s;
\
+   f = *getArgReference_##TPE(stk, pci, 1);
\
+   l = *getArgReference_##TPE(stk, pci, 2);
\
+   if ( pci->argc == 3)
\
+   s = f 0 && f > l) || (s < 0 && f < l) || 

MonetDB: default - The "official" (portable) way of writing a ui...

2024-04-08 Thread Sjoerd Mullender via checkin-list
Changeset: 2c49803bf7c7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2c49803bf7c7
Modified Files:
monetdb5/modules/mal/txtsim.c
sql/server/rel_optimize_sel.c
Branch: default
Log Message:

The "official" (portable) way of writing a uint64_t constant uses UINT64_C().


diffs (49 lines):

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
@@ -462,10 +462,10 @@ popcount64(uint64_t x)
return (int) __popcnt64(x);
 #endif
 #else
-   x = (x & 0xULL) + ((x >> 1) & 0xULL);
-   x = (x & 0xULL) + ((x >> 2) & 0xULL);
-   x = (x & 0x0F0F0F0F0F0F0F0FULL) + ((x >> 4) & 0x0F0F0F0F0F0F0F0FULL);
-   return (int) ((x * 0x0101010101010101ULL) >> 56);
+   x = (x & UINT64_C(0x)) + ((x >> 1) & 
UINT64_C(0x));
+   x = (x & UINT64_C(0x)) + ((x >> 2) & 
UINT64_C(0x));
+   x = (x & UINT64_C(0x0F0F0F0F0F0F0F0F)) + ((x >> 4) & 
UINT64_C(0x0F0F0F0F0F0F0F0F));
+   return (int) ((x * UINT64_C(0x0101010101010101)) >> 56);
 #endif
 }
 
@@ -501,10 +501,10 @@ str_alphabet_bitmap(str_item *s)
 {
int i;
 
-   s->abm = 0ULL;
+   s->abm = UINT64_C(0);
 
for (i = 0; i < s->len; i++)
-   s->abm |= 1ULL << (s->cp_sequence[i] % 64);
+   s->abm |= UINT64_C(1) << (s->cp_sequence[i] % 64);
 
s->abm_popcount = popcount64(s->abm);
 }
diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c
--- a/sql/server/rel_optimize_sel.c
+++ b/sql/server/rel_optimize_sel.c
@@ -2056,10 +2056,10 @@ popcount64(uint64_t x)
return (uint32_t) __popcnt64(x);
 #endif
 #else
-   x = (x & 0xULL) + ((x >> 1) & 0xULL);
-   x = (x & 0xULL) + ((x >> 2) & 0xULL);
-   x = (x & 0x0F0F0F0F0F0F0F0FULL) + ((x >> 4) & 0x0F0F0F0F0F0F0F0FULL);
-   return (x * 0x0101010101010101ULL) >> 56;
+   x = (x & UINT64_C(0x)) + ((x >> 1) & 
UINT64_C(0x));
+   x = (x & UINT64_C(0x)) + ((x >> 2) & 
UINT64_C(0x));
+   x = (x & UINT64_C(0x0F0F0F0F0F0F0F0F)) + ((x >> 4) & 
UINT64_C(0x0F0F0F0F0F0F0F0F));
+   return (x * UINT64_C(0x0101010101010101)) >> 56;
 #endif
 }
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - protect against overflow and floating point e...

2024-04-08 Thread Niels Nes via checkin-list
Changeset: c2ca5122d90e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c2ca5122d90e
Modified Files:
sql/backends/monet5/generator/generator.c
sql/test/BugTracker-2024/Tests/VLTgenerator_table-Bug-7474.test
Branch: default
Log Message:

protect against overflow and floating point exception.
Fixes issue # 7474


diffs (40 lines):

diff --git a/sql/backends/monet5/generator/generator.c 
b/sql/backends/monet5/generator/generator.c
--- a/sql/backends/monet5/generator/generator.c
+++ b/sql/backends/monet5/generator/generator.c
@@ -78,7 +78,12 @@ VLTgenerator_noop(Client cntxt, MalBlkPt
if (s == 0 || (s > 0 && f > l) || (s < 0 && f < l) || 
is_##TPE##_nil(f) || is_##TPE##_nil(l)) \
throw(MAL, "generator.table",   
\
  SQLSTATE(42000) "Illegal generator range");   
\
-   n = (BUN) ((l - f) / s);
\
+   if (s < 0)  
\
+   n = ((BUN)f - l);   
\
+   else
\
+   n = ((BUN)l - f);   
\
+   step = s<0?-s:s;
\
+   n = n/step; 
\
if ((TPE) (n * s + f) != l) 
\
n++;
\
bn = COLnew(0, TYPE_##TPE, n, TRANSIENT);   
\
@@ -94,7 +99,7 @@ VLTgenerator_noop(Client cntxt, MalBlkPt
 static str
 VLTgenerator_table_(BAT **result, Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci)
 {
-   BUN c, n;
+   BUN c, n, step;
BAT *bn;
int tpe;
(void) cntxt;
diff --git a/sql/test/BugTracker-2024/Tests/VLTgenerator_table-Bug-7474.test 
b/sql/test/BugTracker-2024/Tests/VLTgenerator_table-Bug-7474.test
--- a/sql/test/BugTracker-2024/Tests/VLTgenerator_table-Bug-7474.test
+++ b/sql/test/BugTracker-2024/Tests/VLTgenerator_table-Bug-7474.test
@@ -10,8 +10,7 @@ SELECT ( NULLIF ( -1 , 255 ) ) FROM GENE
 -1
 -1
 
-skipif knownfail
 query I nosort
-SELECT ( NULLIF ( -1 , 255 ) ) FROM GENERATE_SERIES ( 2147483647 , -1 )
+SELECT count(*) FROM GENERATE_SERIES ( 2147483647 , -2, -1000 )
 
--1
+215
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: check - persist check condition in the catalog

2024-04-08 Thread Yunus Koning via checkin-list
Changeset: b94c34073d77 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b94c34073d77
Modified Files:
sql/server/rel_schema.c
sql/server/sql_mvc.c
sql/server/sql_mvc.h
sql/storage/sql_storage.h
sql/storage/store.c
Branch: check
Log Message:

persist check condition in the catalog


diffs (125 lines):

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
@@ -610,18 +610,29 @@ column_constraint_type(sql_query *query,
sql_rel *rel = rel_project_exp(sql, e);
(void) rel;
 
-   char* rel_str = rel2str(sql, rel);
+   char* check = rel2str(sql, rel);
 
int pos = 0;
list *refs = sa_list(sql->sa);
-   sql_rel* rel2 = rel_read(sql, rel_str, , refs);
-   (void) rel_str;
+   sql_rel* rel2 = rel_read(sql, check, , refs);
+   (void) check;
(void) rel2;
char *err = NULL, *r;
r = symbol2string(sql, s->data.sym, 0, );
(void) r;
-   (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT CHECK: 
check constraints not supported");
-   return SQL_ERR;
+
+   switch (mvc_check(sql, cs, check)) {
+   case -1:
+   (void) sql_error(sql, 02, SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+   return SQL_ERR;
+   case -2:
+   case -3:
+   (void) sql_error(sql, 02, SQLSTATE(42000) 
"CHECK CONSTRAINT: transaction conflict detected");
+   return SQL_ERR;
+   default:
+   break;
+   }
+   res = SQL_OK;
}   break;
default:{
res = SQL_ERR;
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
@@ -1496,6 +1496,18 @@ mvc_storage(mvc *m, sql_column *col, cha
 }
 
 int
+mvc_check(mvc *m, sql_column *col, char *check)
+{
+   TRC_DEBUG(SQL_TRANS, "Check: %s %s\n", col->base.name, check);
+   if (col->t->persistence == SQL_DECLARED_TABLE) {
+   col->check = check?sa_strdup(m->sa, check):NULL;
+   return 0;
+   } else {
+   return sql_trans_alter_check(m->session->tr, col, check);
+   }
+}
+
+int
 mvc_access(mvc *m, sql_table *t, sht access)
 {
TRC_DEBUG(SQL_TRANS, "Access: %s %d\n", t->base.name, access);
diff --git a/sql/server/sql_mvc.h b/sql/server/sql_mvc.h
--- a/sql/server/sql_mvc.h
+++ b/sql/server/sql_mvc.h
@@ -226,6 +226,7 @@ sql_export int mvc_create_column(sql_col
 extern int mvc_create_column_(sql_column **col, mvc *m, sql_table *t, const 
char *name, const char *type, unsigned int digits);
 extern int mvc_null(mvc *c, sql_column *col, int flag);
 extern int mvc_default(mvc *c, sql_column *col, char *val);
+extern int mvc_check(mvc *m, sql_column *col, char *check);
 extern int mvc_drop_default(mvc *c, sql_column *col);
 extern int mvc_storage(mvc *c, sql_column *col, char *storage);
 extern int mvc_access(mvc *m, sql_table *t, sht access);
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
@@ -410,6 +410,7 @@ extern int sql_trans_drop_column(sql_tra
 extern int sql_trans_alter_null(sql_trans *tr, sql_column *col, int isnull);
 extern int sql_trans_alter_default(sql_trans *tr, sql_column *col, char *val);
 extern int sql_trans_alter_storage(sql_trans *tr, sql_column *col, char 
*storage);
+extern int sql_trans_alter_check(sql_trans *tr, sql_column *col, char *check);
 extern int sql_trans_is_sorted(sql_trans *tr, sql_column *col);
 extern int sql_trans_is_unique(sql_trans *tr, sql_column *col);
 extern int sql_trans_is_duplicate_eliminated(sql_trans *tr, sql_column *col);
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -6432,6 +6432,39 @@ sql_trans_alter_storage(sql_trans *tr, s
 }
 
 int
+sql_trans_alter_check(sql_trans *tr, sql_column *col, char *check)
+{
+   int res = LOG_OK;
+   sqlstore *store = tr->store;
+
+   if ((col->check || check) && (!col->check || !check || 
strcmp(col->check, check) != 0)) {
+   void *p = check ? check : (void *) ATOMnilptr(TYPE_str);
+   sql_schema *syss = find_sql_schema(tr, 
isGlobal(col->t)?"sys":"tmp");
+   sql_table *syscolumn = find_sql_table(tr, syss, "_columns");
+   sql_column *col_ids = find_sql_column(syscolumn, "id");
+   sql_column *col_chks = find_sql_column(syscolumn, "check");
+   oid rid = store->table_api.column_find_row(tr, col_ids, 
>base.id, NULL);
+   sql_column *dup = NULL;
+
+   if (is_oid_nil(rid))
+

MonetDB: check - add "check" column to _columns tables

2024-04-08 Thread Yunus Koning via checkin-list
Changeset: 387d76d5c476 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/387d76d5c476
Modified Files:
sql/include/sql_catalog.h
sql/storage/store.c
Branch: check
Log Message:

add "check" column to _columns tables


diffs (126 lines):

diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -618,6 +618,7 @@ typedef struct sql_column {
char unique;/* 0 NOT UNIQUE, 1 SUB_UNIQUE, 2 UNIQUE */
int drop_action;/* only used for alter statements */
char *storage_type;
+   char *check; /* check condition*/
size_t dcount;
void *min;
void *max;
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -545,7 +545,7 @@ load_column(sql_trans *tr, sql_table *t,
sql_schema *syss = find_sql_schema(tr, "sys");
sql_table *columns = find_sql_table(tr, syss, "_columns");
sqlstore *store = tr->store;
-   str v, def, tpe, st;
+   str v, def, tpe, st, ch;
int sz, d;
 
sqlid cid = *(sqlid*)store->table_api.table_fetch_value(rt_cols, 
find_sql_column(columns, "id"));
@@ -576,6 +576,10 @@ load_column(sql_trans *tr, sql_table *t,
st = (char*)store->table_api.table_fetch_value(rt_cols, 
find_sql_column(columns, "storage"));
if (!strNil(st))
c->storage_type =_STRDUP(st);
+   c->check = NULL;
+   ch = (char*)store->table_api.table_fetch_value(rt_cols, 
find_sql_column(columns, "check"));
+   if (!strNil(ch))
+   c->check =_STRDUP(ch);
ATOMIC_PTR_INIT(>data, NULL);
c->t = t;
if (isTable(c->t))
@@ -1489,7 +1493,7 @@ insert_schemas(sql_trans *tr)
sql_column *c = o->data;
 
if ((res = store->table_api.table_insert(tr, 
syscolumn, >base.id, >base.name, >type.type->base.name, 
>type.digits, >type.scale,
-   
>base.id, (c->def) ? >def : , >null, >colnr, 
(c->storage_type)? >storage_type : )))
+   
>base.id, (c->def) ? >def : , >null, >colnr, 
(c->storage_type)? >storage_type : , (c->check)? >check : 
)))
return res;
}
}
@@ -1593,6 +1597,7 @@ bootstrap_create_column(sql_trans *tr, s
col->t = t;
col->unique = 0;
col->storage_type = NULL;
+   col->check = NULL;
if (ol_add(t->columns, >base))
return NULL;
 
@@ -1680,6 +1685,11 @@ dup_sql_column(sql_allocator *sa, sql_ta
col->storage_type = SA_STRDUP(sa, c->storage_type);
if (ol_add(t->columns, >base))
return NULL;
+   col->check = NULL;
+   if (c->check)
+   col->check = SA_STRDUP(sa, c->check);
+   if (ol_add(t->columns, >base))
+   return NULL;
return col;
 }
 
@@ -2017,6 +2027,7 @@ store_load(sqlstore *store, sql_allocato
bootstrap_create_column(tr, t, "null", 2084, "boolean", 1) == 
NULL ||
bootstrap_create_column(tr, t, "number", 2085, "int", 31) == 
NULL ||
bootstrap_create_column(tr, t, "storage", 2086, "varchar", 
2048) == NULL ||
+   bootstrap_create_column(tr, t, "check", 2165, "varchar", 2048) 
== NULL ||
 
(t = bootstrap_create_table(tr, s, "keys", 2087)) == NULL ||
bootstrap_create_column(tr, t, "id", 2088, "int", 31) == NULL ||
@@ -2078,6 +2089,7 @@ store_load(sqlstore *store, sql_allocato
bootstrap_create_column(tr, t, "null", 2132, "boolean", 1) == 
NULL ||
bootstrap_create_column(tr, t, "number", 2133, "int", 31) == 
NULL ||
bootstrap_create_column(tr, t, "storage", 2134, "varchar", 
2048) == NULL ||
+   bootstrap_create_column(tr, t, "check", 2166, "varchar", 2048) 
== NULL ||
 
(t = bootstrap_create_table(tr, s, "keys", 2135)) == NULL ||
bootstrap_create_column(tr, t, "id", 2136, "int", 31) == NULL ||
@@ -2976,6 +2988,9 @@ column_dup(sql_trans *tr, sql_column *oc
c->storage_type = NULL;
if (oc->storage_type)
c->storage_type =_STRDUP(oc->storage_type);
+   c->check = NULL;
+   if (oc->check)
+   c->check =_STRDUP(oc->check);
ATOMIC_PTR_INIT(>data, NULL);
 
if (isTable(c->t)) {
@@ -3642,6 +3657,9 @@ sql_trans_copy_column( sql_trans *tr, sq
col->storage_type = NULL;
if (c->storage_type)
col->storage_type =_STRDUP(c->storage_type);
+   col->check = NULL;
+   if (c->check)
+   col->check =_STRDUP(c->check);
 
if ((res = ol_add(t->columns, >base)))
return res;
@@ -3666,7 +3684,8 @@ 

MonetDB: default - some more optional bats, ie reducing number o...

2024-04-08 Thread Niels Nes via checkin-list
Changeset: 8e983ad5d13d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8e983ad5d13d
Modified Files:
clients/Tests/MAL-signatures-hge.test
sql/backends/monet5/sql.c
Branch: default
Log Message:

some more optional bats, ie reducing number of mel function definitions


diffs (234 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -34230,142 +34230,72 @@ SQLvar_pop;
 return the variance population of groups
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:bte]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:dbl]):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:bte]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:flt]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:hge]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:int]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:lng]):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:dbl]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat[:sht]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bte):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:dbl):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:flt]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:flt):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:hge]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:hge):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:int]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:int):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:lng):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:lng]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:sht):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:bte]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:dbl]):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:any_1], X_1:int, X_2:int, X_3:int, 
X_4:bat?[:sht]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:flt]):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat?[:bte]):bat[:oid]
 SQLwindow_bound;
 computes window ranges for each row
 batsql
 window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:hge]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:int]):bat[:oid]
-SQLwindow_bound;
-computes window ranges for each row
-batsql
-window_bound
-pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, X_5:bat[:lng]):bat[:oid]
+pattern batsql.window_bound(X_0:bat[:bit], X_1:bat[:any_1], X_2:int, X_3:int, 
X_4:int, 

MonetDB: default - Adds tests for union corresponding

2024-04-08 Thread stefanos mavros via checkin-list
Changeset: b432afbb534c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b432afbb534c
Added Files:
sql/test/Tests/union-corresponding.test
Modified Files:
sql/test/Tests/All
Branch: default
Log Message:

Adds tests for union corresponding


diffs (140 lines):

diff --git a/sql/test/Tests/All b/sql/test/Tests/All
--- a/sql/test/Tests/All
+++ b/sql/test/Tests/All
@@ -141,6 +141,7 @@ meltdown
 savepoints1
 savepoints2
 union
+union-corresponding
 ## Queries from the old AS3AP benchmark.
 ## Since we don't have the data, let's just execute the queries here
 as3ap
diff --git a/sql/test/Tests/union-corresponding.test 
b/sql/test/Tests/union-corresponding.test
new file mode 100644
--- /dev/null
+++ b/sql/test/Tests/union-corresponding.test
@@ -0,0 +1,124 @@
+statement ok
+create table foo (a int, b text)
+
+statement ok
+insert into foo values
+ (1, 'alice'),
+ (2, 'bob')
+
+statement ok
+create table bar (c text, a int)
+
+statement ok
+insert into bar values
+ ('hello', 3),
+ ('world', 4)
+
+statement ok
+create table buz (a int, c text)
+
+statement ok
+insert into buz values
+ (5, 'one'),
+ (6, 'two')
+
+statement ok
+create table empty_a (a int, c text)
+
+statement ok
+create table empty_b (c int, a text)
+
+query I rowsort
+SELECT * FROM foo
+UNION CORRESPONDING
+SELECT * FROM bar
+
+1
+2
+3
+4
+
+query IT rowsort
+SELECT * FROM foo
+UNION
+SELECT * FROM buz
+
+1
+alice
+2
+bob
+5
+one
+6
+two
+
+query I rowsort
+SELECT * FROM foo
+UNION CORRESPONDING
+SELECT * FROM buz
+
+1
+2
+5
+6
+
+query I rowsort
+SELECT a FROM foo
+NATURAL FULL JOIN buz
+
+1
+2
+5
+6
+
+statement error
+SELECT * FROM foo
+UNION 
+SELECT * FROM bar
+UNION 
+SELECT * FROM buz
+
+query I rowsort
+SELECT * FROM foo
+UNION CORRESPONDING
+SELECT * FROM bar
+UNION CORRESPONDING
+SELECT * FROM buz
+
+1
+2
+3
+4
+5
+6
+
+statement error
+SELECT * FROM buz
+UNION
+SELECT * FROM bar
+
+query IT rowsort
+SELECT * FROM buz
+UNION CORRESPONDING
+SELECT * FROM bar
+
+3
+hello
+4
+world
+5
+one
+6
+two
+
+query I rowsort
+SELECT * FROM buz
+UNION CORRESPONDING BY (a)
+SELECT * FROM bar
+
+3
+4
+5
+6
+
+
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Dec2023 - English.

2024-04-08 Thread Sjoerd Mullender via checkin-list
Changeset: 756ce48c5553 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/756ce48c5553
Modified Files:
sql/ChangeLog.Dec2023
Branch: Dec2023
Log Message:

English.


diffs (12 lines):

diff --git a/sql/ChangeLog.Dec2023 b/sql/ChangeLog.Dec2023
--- a/sql/ChangeLog.Dec2023
+++ b/sql/ChangeLog.Dec2023
@@ -2,6 +2,6 @@
 # This file is updated with Maddlog
 
 * Tue Mar 19 2024 Sjoerd Mullender 
-- Fixed issue where equal column aliases where created. When those
-  aliases where parsed on the remote side it could give crashes.
+- Fixed issue where equal column aliases were created. When those
+  aliases were parsed on the remote side it could give crashes.
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Dec2023 - Make a copy of the string heap hash table whi...

2024-04-08 Thread Sjoerd Mullender via checkin-list
Changeset: 69c30038c87d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/69c30038c87d
Modified Files:
gdk/gdk_bat.c
Branch: Dec2023
Log Message:

Make a copy of the string heap hash table while locked.
Fixes bug #7495.


diffs (46 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -801,6 +801,7 @@ COLcopy(BAT *b, int tt, bool writable, r
bool slowcopy = false;
BAT *bn = NULL;
BATiter bi;
+   char strhash[GDK_STRHASHSIZE];
 
BATcheck(b, NULL);
assert(tt != TYPE_bat);
@@ -814,7 +815,24 @@ COLcopy(BAT *b, int tt, bool writable, r
return NULL;
}
 
-   bi = bat_iterator(b);
+   /* in case of a string bat, we save the string heap hash table
+* while we have the lock so that we can restore it in the copy;
+* this is because during our operation, a parallel thread could
+* be adding strings to the vheap which would modify the hash
+* table and that would result in buckets containing values
+* beyond the original vheap that we're copying */
+   MT_lock_set(>theaplock);
+   bi = bat_iterator_nolock(b);
+   if (ATOMstorage(b->ttype) == TYPE_str && b->tvheap->free >= 
GDK_STRHASHSIZE)
+   memcpy(strhash, b->tvheap->base, GDK_STRHASHSIZE);
+
+#ifndef NDEBUG
+   bi.locked = true;
+#endif
+   HEAPincref(bi.h);
+   if (bi.vh)
+   HEAPincref(bi.vh);
+   MT_lock_unset(>theaplock);
 
/* first try case (1); create a view, possibly with different
 * atom-types */
@@ -894,6 +912,8 @@ COLcopy(BAT *b, int tt, bool writable, r
memcpy(bn->tvheap->base, bi.vh->base, 
bi.vhfree);
bn->tvheap->free = bi.vhfree;
bn->tvheap->dirty = true;
+   if (ATOMstorage(b->ttype) == TYPE_str && 
b->tvheap->free >= GDK_STRHASHSIZE)
+   memcpy(b->tvheap->base, strhash, 
GDK_STRHASHSIZE);
}
 
/* make sure we use the correct capacity */
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Dec2023 branch.

2024-04-08 Thread Sjoerd Mullender via checkin-list
Changeset: 90066d9863df for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/90066d9863df
Modified Files:
sql/test/BugTracker-2022/Tests/incomplete-sql-script.Bug-7298.SQL.py
testing/sqllogictest.py
Branch: default
Log Message:

Merge with Dec2023 branch.


diffs (truncated from 2912 to 300 lines):

diff --git a/documentation/monetdbe/manual_pages/monetdbe_options.rst 
b/documentation/monetdbe/manual_pages/monetdbe_options.rst
--- a/documentation/monetdbe/manual_pages/monetdbe_options.rst
+++ b/documentation/monetdbe/manual_pages/monetdbe_options.rst
@@ -31,9 +31,9 @@ MonetDBe options struct. Object can be p
 (2) int querytimeout. Gracefully terminate query after a few seconds.
 (3) int sessiontimeout. Graceful terminate the session after a few seconds.
 (4) int nr_threads. Maximum number of worker treads, limits level of 
parallelism.
-(5) monetdbe_remote* remote. Pointer to a monetdbe_remote object.
-(6) monetdbe_mapi_server* mapi_server. Pointer to a monetdbe_mapi_server 
object.
-(7) const char *trace_file. File to which log output should be written.
+(5) monetdbe_remote\* remote. Pointer to a monetdbe_remote object.
+(6) monetdbe_mapi_server\* mapi_server. Pointer to a monetdbe_mapi_server 
object.
+(7) const char \*trace_file. File to which log output should be written.
 
 EXAMPLES
 
diff --git a/geom/sql/functions/Tests/All b/geom/sql/functions/Tests/All
--- a/geom/sql/functions/Tests/All
+++ b/geom/sql/functions/Tests/All
@@ -3,18 +3,15 @@ HAVE_GEOM?loadTestWKT
 HAVE_GEOM?ST_PointFromText
 HAVE_GEOM?ST_LineFromText
 HAVE_GEOM?ST_PolygonFromText
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_MPointFromText
-HAVE_GEOM_VERSION>=3.12.0?ST_MPointFromText-3.12
+HAVE_GEOM?ST_MPointFromText
 HAVE_GEOM?ST_MLineFromText
 HAVE_GEOM?ST_MPolygonFromText
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_GeomFromText
-HAVE_GEOM_VERSION>=3.12.0?ST_GeomFromText-3.12
+HAVE_GEOM?ST_GeomFromText
 
 HAVE_GEOM?dropTestWKT
 
 HAVE_GEOM?ST_MakePoint
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_Collect
-HAVE_GEOM_VERSION>=3.12.0?ST_Collect-3.12
+HAVE_GEOM?ST_Collect
 HAVE_GEOM?ST_MakeLine
 HAVE_GEOM?loadTestPolygons
 HAVE_GEOM?ST_Intersects
@@ -27,50 +24,38 @@ HAVE_GEOM?ST_DWithinRTree
 HAVE_GEOM?loadTestGeometries
 
 
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_GeometryType
-HAVE_GEOM_VERSION>=3.12.0?ST_GeometryType-3.12
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_AsText
-HAVE_GEOM_VERSION>=3.12.0?ST_AsText-3.12
+HAVE_GEOM?ST_GeometryType
+HAVE_GEOM?ST_AsText
 
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_IsClosed
-HAVE_GEOM_VERSION>=3.12.0?ST_IsClosed-3.12
+HAVE_GEOM?ST_IsClosed
 HAVE_GEOM?ST_IsEmpty
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_IsSimple
-HAVE_GEOM_VERSION>=3.12.0?ST_IsSimple-3.12
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_IsValid
-HAVE_GEOM_VERSION>=3.12.0?ST_IsValid-3.12
+HAVE_GEOM?ST_IsSimple
+HAVE_GEOM?ST_IsValid
 HAVE_GEOM?ST_IsRing
 
 HAVE_GEOM?XYZ
 HAVE_GEOM?XYZMinMax
 #HAVE_GEOM?srid
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_GeometryN
-HAVE_GEOM_VERSION>=3.12.0?ST_GeometryN-3.12
+HAVE_GEOM?ST_GeometryN
 HAVE_GEOM?ST_NumGeometries
 HAVE_GEOM?ST_NumPoints
 HAVE_GEOM?ST_NPoints
 
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_NumInteriorRings
-HAVE_GEOM_VERSION>=3.12.0?ST_NumInteriorRings-3.12
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_NRings
-HAVE_GEOM_VERSION>=3.12.0?ST_NRings-3.12
+HAVE_GEOM?ST_NumInteriorRings
+HAVE_GEOM?ST_NRings
 
 #HAVE_GEOM?transform
 
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_Contains
-HAVE_GEOM_VERSION>=3.12.0?ST_Contains-3.12
+HAVE_GEOM?ST_Contains
 
 #HAVE_GEOM?equals
 
-HAVE_GEOM_VERSION>=3.11.1&!GEOS_VERSION>=3.12.0?ST_Boundary
-HAVE_GEOM_VERSION>=3.11.1_VERSION>=3.12.0?ST_Boundary-3.12
+HAVE_GEOM_VERSION>=3.11.1?ST_Boundary
 
 HAVE_GEOM?ST_Dimension
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_CoordDim
-HAVE_GEOM_VERSION>=3.12.0?ST_CoordDim-3.12
+HAVE_GEOM?ST_CoordDim
 
-HAVE_GEOM&!GEOS_VERSION>=3.12.0?ST_AsEWKT
-HAVE_GEOM_VERSION>=3.12.0?ST_AsEWKT-3.12
+HAVE_GEOM?ST_AsEWKT
 
 #HAVE_GEOM?ST_Covers #Look at ST_Covers.sql for more details on the problem
 #HAVE_GEOM?ST_CoveredBy #Look at ST_CoveredBy.sql for more details on the 
problem
@@ -92,7 +77,6 @@ HAVE_GEOM?ST_MakeBox2D
 
 HAVE_GEOM?dropTestGeometries
 HAVE_GEOM?ST_DWithin2
-HAVE_GEOM&!GEOS_VERSION>=3.12.0_PROJ?ST_Transform
-HAVE_GEOM_VERSION>=3.12.0_PROJ?ST_Transform-3.12
+HAVE_GEOM_PROJ?ST_Transform
 
 HAVE_GEOM?geomcasts
diff --git a/geom/sql/functions/Tests/ST_AsEWKT-3.12.reqtests 
b/geom/sql/functions/Tests/ST_AsEWKT-3.12.reqtests
deleted file mode 100644
--- a/geom/sql/functions/Tests/ST_AsEWKT-3.12.reqtests
+++ /dev/null
@@ -1,1 +0,0 @@
-loadTestGeometries
diff --git a/geom/sql/functions/Tests/ST_AsEWKT-3.12.test 
b/geom/sql/functions/Tests/ST_AsEWKT-3.12.test
deleted file mode 100644
--- a/geom/sql/functions/Tests/ST_AsEWKT-3.12.test
+++ /dev/null
@@ -1,219 +0,0 @@
-query T rowsort
-select st_asEWKT(st_pointfromtext('point(10 10)'))
-
-SRID:0;POINT (10 10)
-
-query T rowsort
-select st_asEWKT(st_pointfromtext('point(20 20)', 4326))
-
-SRID:4326;POINT (20 20)
-
-query T rowsort

MonetDB: Dec2023 - Allow for decimal point in MULTIPOINT coordin...

2024-04-08 Thread Sjoerd Mullender via checkin-list
Changeset: 70db02f12ee8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/70db02f12ee8
Modified Files:
testing/sqllogictest.py
Branch: Dec2023
Log Message:

Allow for decimal point in MULTIPOINT coordinates.


diffs (15 lines):

diff --git a/testing/sqllogictest.py b/testing/sqllogictest.py
--- a/testing/sqllogictest.py
+++ b/testing/sqllogictest.py
@@ -58,9 +58,9 @@ import difflib
 # this stuff is for geos pre 3.12: 3.12 introduced an extra set of
 # parentheses in MULTIPOINT values
 geosre = re.compile(r'MULTIPOINT *\((?P[^()]*)\)')
-ptsre = re.compile(r'-?\d+ -?\d+')
+ptsre = re.compile(r'-?\d+(?:\.\d+)? -?\d+(?:\.\d+)?')
 geoszre = re.compile(r'MULTIPOINT *Z *\((?P[^()]*)\)')
-ptszre = re.compile(r'-?\d+ -?\d+ -?\d+')
+ptszre = re.compile(r'-?\d+(?:\.\d+)? -?\d+(?:\.\d+)? -?\d+(?:\.\d+)?')
 
 architecture = platform.machine()
 if architecture == 'AMD64': # Windows :-(
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge no_type_bat branch into default.

2024-04-08 Thread Sjoerd Mullender via checkin-list
Changeset: 28e30df8358d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/28e30df8358d
Branch: default
Log Message:

Merge no_type_bat branch into default.


diffs (truncated from 162784 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -679,7 +679,6 @@ This package contains files needed to de
 
 %files SQL-server5-devel
 %defattr(-,root,root)
-%{_includedir}/monetdb/exception_buffer.h
 %{_includedir}/monetdb/opt_backend.h
 %{_includedir}/monetdb/rel_*.h
 %{_includedir}/monetdb/sql*.h
diff --git a/NT/mksqlwxs.py b/NT/mksqlwxs.py
--- a/NT/mksqlwxs.py
+++ b/NT/mksqlwxs.py
@@ -187,7 +187,7 @@ def main():
 print(r'')
 print(r'  ')
 id = comp(extend, id, 16,
-  sorted([r'include\monetdb\{}'.format(x) for x in filter(lambda 
x: (x.startswith('gdk') or x.startswith('monet') or x.startswith('mal') or 
x.startswith('sql') or x.startswith('rel') or x.startswith('store') or 
x.startswith('exception') or x.startswith('opt_backend')) and x.endswith('.h'), 
os.listdir(os.path.join(sys.argv[3], 'include', 'monetdb')))] +
+  sorted([r'include\monetdb\{}'.format(x) for x in filter(lambda 
x: (x.startswith('gdk') or x.startswith('monet') or x.startswith('mal') or 
x.startswith('sql') or x.startswith('rel') or x.startswith('store') or 
x.startswith('opt_backend')) and x.endswith('.h'), 
os.listdir(os.path.join(sys.argv[3], 'include', 'monetdb')))] +
  [r'include\monetdb\copybinary.h',
   r'include\monetdb\mapi.h',
   r'include\monetdb\mapi_querytype.h',
diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -5,51302 +5,50987 @@ select * from sys.malfunctions() order b
 
 aggr
 Collect
-command aggr.Collect(X_0:bat[:wkb]):wkb 
+command aggr.Collect(X_0:bat[:wkb]):wkb
 wkbCollectAggr;
 TODO
 aggr
 MakeLine
-command aggr.MakeLine(X_0:bat[:wkb]):wkb 
+command aggr.MakeLine(X_0:bat[:wkb]):wkb
 wkbMakeLineAggr;
 Gets a BAT with point or linestring geometries and returns a single linestring 
geometry
 aggr
 all
-command aggr.all(X_0:bat[:any_1]):any_1 
+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 
+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, return 
nil, else return false
 aggr
 anyequal
-pattern aggr.anyequal(X_0:any_1, X_1:any_1):bit 
+pattern aggr.anyequal(X_0:any_1, X_1:any_1):bit
 CMDvarEQ;
 (empty)
 aggr
 anyequal
-pattern aggr.anyequal(X_0:bat[:any_1], X_1:bat[:any_1]):bit 
+pattern aggr.anyequal(X_0:bat[:any_1], X_1:bat[:any_1]):bit
 SQLanyequal;
 if any value in r is equal to l, return true, else if r has nil, return nil, 
else return false
 aggr
 avg
-command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on bte
 aggr
 avg
-command aggr.avg(X_0:bat[:dbl], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:dbl], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on dbl
 aggr
 avg
-command aggr.avg(X_0:bat[:flt], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:flt], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on flt
 aggr
 avg
-command aggr.avg(X_0:bat[:hge], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:hge], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on hge
 aggr
 avg
-command aggr.avg(X_0:bat[:int], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:int], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on int
 aggr
 avg
-command aggr.avg(X_0:bat[:lng], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:lng], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on lng
 aggr
 avg
-command aggr.avg(X_0:bat[:sht], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:sht], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on sht
 aggr
 avg
-command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl] 
+command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl]
 AGGRavg14_dbl;
 Grouped tail average on bte
 aggr
 avg
-command aggr.avg(X_0:bat[:dbl], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl] 
+command aggr.avg(X_0:bat[:dbl], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl]
 AGGRavg14_dbl;
 Grouped tail average on dbl
 aggr
 avg
-command aggr.avg(X_0:bat[:flt], X_1:bat[:oid], 

MonetDB: ascii-flag - Merge with default branch.

2024-04-08 Thread Sjoerd Mullender via checkin-list
Changeset: b955590aeba4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b955590aeba4
Modified Files:
clients/Tests/MAL-signatures-hge.test
clients/Tests/MAL-signatures.test
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_bbp.c
gdk/gdk_string.c
monetdb5/modules/kernel/batstr.c
sql/backends/monet5/sql_result.c
Branch: ascii-flag
Log Message:

Merge with default branch.


diffs (truncated from 164856 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -679,7 +679,6 @@ This package contains files needed to de
 
 %files SQL-server5-devel
 %defattr(-,root,root)
-%{_includedir}/monetdb/exception_buffer.h
 %{_includedir}/monetdb/opt_backend.h
 %{_includedir}/monetdb/rel_*.h
 %{_includedir}/monetdb/sql*.h
diff --git a/NT/mksqlwxs.py b/NT/mksqlwxs.py
--- a/NT/mksqlwxs.py
+++ b/NT/mksqlwxs.py
@@ -187,7 +187,7 @@ def main():
 print(r'')
 print(r'  ')
 id = comp(extend, id, 16,
-  sorted([r'include\monetdb\{}'.format(x) for x in filter(lambda 
x: (x.startswith('gdk') or x.startswith('monet') or x.startswith('mal') or 
x.startswith('sql') or x.startswith('rel') or x.startswith('store') or 
x.startswith('exception') or x.startswith('opt_backend')) and x.endswith('.h'), 
os.listdir(os.path.join(sys.argv[3], 'include', 'monetdb')))] +
+  sorted([r'include\monetdb\{}'.format(x) for x in filter(lambda 
x: (x.startswith('gdk') or x.startswith('monet') or x.startswith('mal') or 
x.startswith('sql') or x.startswith('rel') or x.startswith('store') or 
x.startswith('opt_backend')) and x.endswith('.h'), 
os.listdir(os.path.join(sys.argv[3], 'include', 'monetdb')))] +
  [r'include\monetdb\copybinary.h',
   r'include\monetdb\mapi.h',
   r'include\monetdb\mapi_querytype.h',
diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -5,34707 +5,34387 @@ select * from sys.malfunctions() order b
 
 aggr
 Collect
-command aggr.Collect(X_0:bat[:wkb]):wkb 
+command aggr.Collect(X_0:bat[:wkb]):wkb
 wkbCollectAggr;
 TODO
 aggr
 MakeLine
-command aggr.MakeLine(X_0:bat[:wkb]):wkb 
+command aggr.MakeLine(X_0:bat[:wkb]):wkb
 wkbMakeLineAggr;
 Gets a BAT with point or linestring geometries and returns a single linestring 
geometry
 aggr
 all
-command aggr.all(X_0:bat[:any_1]):any_1 
+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 
+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, return 
nil, else return false
 aggr
 anyequal
-pattern aggr.anyequal(X_0:any_1, X_1:any_1):bit 
+pattern aggr.anyequal(X_0:any_1, X_1:any_1):bit
 CMDvarEQ;
 (empty)
 aggr
 anyequal
-pattern aggr.anyequal(X_0:bat[:any_1], X_1:bat[:any_1]):bit 
+pattern aggr.anyequal(X_0:bat[:any_1], X_1:bat[:any_1]):bit
 SQLanyequal;
 if any value in r is equal to l, return true, else if r has nil, return nil, 
else return false
 aggr
 avg
-command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on bte
 aggr
 avg
-command aggr.avg(X_0:bat[:dbl], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:dbl], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on dbl
 aggr
 avg
-command aggr.avg(X_0:bat[:flt], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:flt], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on flt
 aggr
 avg
-command aggr.avg(X_0:bat[:hge], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:hge], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on hge
 aggr
 avg
-command aggr.avg(X_0:bat[:int], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:int], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on int
 aggr
 avg
-command aggr.avg(X_0:bat[:lng], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:lng], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on lng
 aggr
 avg
-command aggr.avg(X_0:bat[:sht], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl] 
+command aggr.avg(X_0:bat[:sht], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
 AGGRavg13_dbl;
 Grouped tail average on sht
 aggr
 avg
-command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl] 
+command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl]
 AGGRavg14_dbl;
 

MonetDB: default - Merge with Dec2023 branch.

2024-04-08 Thread Sjoerd Mullender via checkin-list
Changeset: 2752bc2cf798 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2752bc2cf798
Modified Files:
testing/sqllogictest.py
Branch: default
Log Message:

Merge with Dec2023 branch.


diffs (15 lines):

diff --git a/testing/sqllogictest.py b/testing/sqllogictest.py
--- a/testing/sqllogictest.py
+++ b/testing/sqllogictest.py
@@ -58,9 +58,9 @@ import difflib
 # this stuff is for geos pre 3.12: 3.12 introduced an extra set of
 # parentheses in MULTIPOINT values
 geosre = re.compile(r'MULTIPOINT *\((?P[^()]*)\)')
-ptsre = re.compile(r'-?\d+ -?\d+')
+ptsre = re.compile(r'-?\d+(?:\.\d+)? -?\d+(?:\.\d+)?')
 geoszre = re.compile(r'MULTIPOINT *Z *\((?P[^()]*)\)')
-ptszre = re.compile(r'-?\d+ -?\d+ -?\d+')
+ptszre = re.compile(r'-?\d+(?:\.\d+)? -?\d+(?:\.\d+)? -?\d+(?:\.\d+)?')
 
 architecture = platform.machine()
 if architecture == 'AMD64': # Windows :-(
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Dec2023 branch.

2024-04-08 Thread Sjoerd Mullender via checkin-list
Changeset: 44ee8948ade0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/44ee8948ade0
Modified Files:
gdk/gdk_bat.c
Branch: default
Log Message:

Merge with Dec2023 branch.


diffs (58 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -798,6 +798,7 @@ COLcopy(BAT *b, int tt, bool writable, r
bool slowcopy = false;
BAT *bn = NULL;
BATiter bi;
+   char strhash[GDK_STRHASHSIZE];
 
BATcheck(b, NULL);
 
@@ -810,7 +811,24 @@ COLcopy(BAT *b, int tt, bool writable, r
return NULL;
}
 
-   bi = bat_iterator(b);
+   /* in case of a string bat, we save the string heap hash table
+* while we have the lock so that we can restore it in the copy;
+* this is because during our operation, a parallel thread could
+* be adding strings to the vheap which would modify the hash
+* table and that would result in buckets containing values
+* beyond the original vheap that we're copying */
+   MT_lock_set(>theaplock);
+   bi = bat_iterator_nolock(b);
+   if (ATOMstorage(b->ttype) == TYPE_str && b->tvheap->free >= 
GDK_STRHASHSIZE)
+   memcpy(strhash, b->tvheap->base, GDK_STRHASHSIZE);
+
+#ifndef NDEBUG
+   bi.locked = true;
+#endif
+   HEAPincref(bi.h);
+   if (bi.vh)
+   HEAPincref(bi.vh);
+   MT_lock_unset(>theaplock);
 
/* first try case (1); create a view, possibly with different
 * atom-types */
@@ -887,6 +905,8 @@ COLcopy(BAT *b, int tt, bool writable, r
memcpy(bn->tvheap->base, bi.vh->base, 
bi.vhfree);
bn->tvheap->free = bi.vhfree;
bn->tvheap->dirty = true;
+   if (ATOMstorage(b->ttype) == TYPE_str && 
b->tvheap->free >= GDK_STRHASHSIZE)
+   memcpy(b->tvheap->base, strhash, 
GDK_STRHASHSIZE);
}
 
/* make sure we use the correct capacity */
diff --git a/sql/ChangeLog.Dec2023 b/sql/ChangeLog.Dec2023
--- a/sql/ChangeLog.Dec2023
+++ b/sql/ChangeLog.Dec2023
@@ -2,6 +2,6 @@
 # This file is updated with Maddlog
 
 * Tue Mar 19 2024 Sjoerd Mullender 
-- Fixed issue where equal column aliases where created. When those
-  aliases where parsed on the remote side it could give crashes.
+- Fixed issue where equal column aliases were created. When those
+  aliases were parsed on the remote side it could give crashes.
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Dec2023 - Fix typo.

2024-04-08 Thread Sjoerd Mullender via checkin-list
Changeset: d107c382f3c7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d107c382f3c7
Modified Files:
gdk/gdk_bat.c
Branch: Dec2023
Log Message:

Fix typo.


diffs (14 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -912,8 +912,8 @@ COLcopy(BAT *b, int tt, bool writable, r
memcpy(bn->tvheap->base, bi.vh->base, 
bi.vhfree);
bn->tvheap->free = bi.vhfree;
bn->tvheap->dirty = true;
-   if (ATOMstorage(b->ttype) == TYPE_str && 
b->tvheap->free >= GDK_STRHASHSIZE)
-   memcpy(b->tvheap->base, strhash, 
GDK_STRHASHSIZE);
+   if (ATOMstorage(b->ttype) == TYPE_str && 
bi.vhfree >= GDK_STRHASHSIZE)
+   memcpy(bn->tvheap->base, strhash, 
GDK_STRHASHSIZE);
}
 
/* make sure we use the correct capacity */
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org