MonetDB: default - Cleaned up blobs at atom2sql. Now back into s...

2020-06-30 Thread Pedro Ferreira
Changeset: 135d53262752 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=135d53262752
Modified Files:
sql/server/sql_atom.c
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.out
Branch: default
Log Message:

Cleaned up blobs at atom2sql. Now back into serious things


diffs (115 lines):

diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c
--- a/sql/server/sql_atom.c
+++ b/sql/server/sql_atom.c
@@ -457,9 +457,16 @@ atom2sql(atom *a)
return res;
} break;
case EC_BLOB: {
-   char *_buf = buf;
-   size_t _bufsiz = BUFSIZ;
-   BLOBtostr(&_buf, &_bufsiz, >data.val.pval, true);
+   char *res;
+   blob *b = (blob*)a->data.val.pval;
+   size_t blob_size = (24 + (b->nitems * 3));
+
+   if ((res = NEW_ARRAY(char, blob_size + 8))) {
+   char *tail = stpcpy(res, "blob '");
+   ssize_t bloblen = BLOBtostr(, _size, b, true);
+   strcpy(res + bloblen + 6, "'");
+   }
+   return res;
} break;
case EC_MONTH:
case EC_SEC: {
diff --git a/sql/test/miscellaneous/Tests/simple_selects.sql 
b/sql/test/miscellaneous/Tests/simple_selects.sql
--- a/sql/test/miscellaneous/Tests/simple_selects.sql
+++ b/sql/test/miscellaneous/Tests/simple_selects.sql
@@ -169,11 +169,13 @@ select greatest(null, null);
 select sql_min(null, null);
 
 start transaction;
-create table tab1(col1 blob);
+create table tab1(col1 blob default blob '1122');
 insert into tab1 values('2233');
 select length(col1) from tab1;
 insert into tab1 values(null), (null), ('11'), ('2233');
 select length(col1) from tab1;
+insert into tab1 values(default);
+select col1 from tab1;
 rollback;
 
 select 'a' like 'a' escape 'a'; --error, like sequence ending with escape 
character 
diff --git a/sql/test/miscellaneous/Tests/simple_selects.stable.out 
b/sql/test/miscellaneous/Tests/simple_selects.stable.out
--- a/sql/test/miscellaneous/Tests/simple_selects.stable.out
+++ b/sql/test/miscellaneous/Tests/simple_selects.stable.out
@@ -116,20 +116,20 @@ stdout of test 'simple_selects` in direc
 % bigint # type
 % 1 # length
 #select cast(sum(42) as bigint) group by 1;
+% .%3 # table_name
+% %3 # name
+% bigint # type
+% 2 # length
+[ 42   ]
+#select cast(sum(42) as bigint) limit 2;
 % .%2 # table_name
 % %2 # name
 % bigint # type
 % 2 # length
 [ 42   ]
-#select cast(sum(42) as bigint) limit 2;
-% .%1 # table_name
-% %1 # name
-% bigint # type
-% 2 # length
-[ 42   ]
 #select cast(sum(42) as bigint) having 42>80;
-% .%1 # table_name
-% %1 # name
+% .%2 # table_name
+% %2 # name
 % bigint # type
 % 1 # length
 #select 1 having false;
@@ -270,8 +270,8 @@ stdout of test 'simple_selects` in direc
 #create table x (a int GENERATED ALWAYS AS IDENTITY);
 #alter table x alter a set default 1; --ok, remove sequence
 #SELECT CAST(COUNT(*) - (SELECT m FROM myvar) AS BIGINT) FROM sequences; --the 
total count, cannot change
-% .%4 # table_name
-% %4 # name
+% .%3 # table_name
+% %3 # name
 % bigint # type
 % 1 # length
 [ 0]
@@ -283,8 +283,8 @@ stdout of test 'simple_selects` in direc
 #create table x (a int GENERATED ALWAYS AS IDENTITY);
 #alter table x alter a drop default; --ok, remove sequence
 #SELECT CAST(COUNT(*) - (SELECT m FROM myvar) AS BIGINT) FROM sequences; --the 
total count, cannot change
-% .%4 # table_name
-% %4 # name
+% .%3 # table_name
+% %3 # name
 % bigint # type
 % 1 # length
 [ 0]
@@ -330,6 +330,19 @@ stdout of test 'simple_selects` in direc
 [ NULL ]
 [ 1]
 [ 2]
+#insert into tab1 values(default);
+[ 1]
+#select col1 from tab1;
+% sys.tab1 # table_name
+% col1 # name
+% blob # type
+% 0 # length
+[ 2233 ]
+[ NULL ]
+[ NULL ]
+[ 11   ]
+[ 2233 ]
+[ 1122 ]
 #rollback;
 #select cast(x as interval second) from (values ('1'), (NULL), ('100'), 
(NULL)) as x(x);
 % .%6 # table_name
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - small fix for properly keeping database location

2020-06-30 Thread Niels Nes
Changeset: 5ca96ca58d9b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5ca96ca58d9b
Modified Files:
tools/monetdbe/monetdbe.c
Branch: default
Log Message:

small fix for properly keeping database location


diffs (22 lines):

diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c
--- a/tools/monetdbe/monetdbe.c
+++ b/tools/monetdbe/monetdbe.c
@@ -429,6 +429,9 @@ monetdbe_shutdown_internal(void) // Call
if (monetdbe_embedded_initialized) {
 malEmbeddedReset();
monetdbe_embedded_initialized = false;
+   if (monetdbe_embedded_url)
+   GDKfree(monetdbe_embedded_url);
+   monetdbe_embedded_url = NULL;
}
 }
 
@@ -550,7 +553,7 @@ monetdbe_startup(monetdbe_database_inter
goto cleanup;
 
monetdbe_embedded_initialized = true;
-   monetdbe_embedded_url = dbdir;
+   monetdbe_embedded_url = dbdir?GDKstrdup(dbdir):NULL;
GDKfataljumpenable = 0;
 cleanup:
if (mdbe->msg)
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Upgrade fixes.

2020-06-30 Thread Pedro Ferreira
Changeset: e3881246bb95 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e3881246bb95
Modified Files:
sql/backends/monet5/sql_upgrades.c
Branch: default
Log Message:

Upgrade fixes.

1. Disable 'semantics' flag to more out-of-box functions in the SQL catalog.
2. Print semantics upgrade query for debugging purposes later if needed.
3. Placed the same upgrade query inside other default upgrades, so the update 
query will run only once.


diffs (68 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -2773,7 +2773,6 @@ sql_update_jun2020_bam(Client c, mvc *m,
return err;
 }
 
-
 #ifdef HAVE_HGE
 static str
 sql_update_jun2020_sp1_hugeint(Client c, const char *prev_schema)
@@ -2832,19 +2831,6 @@ sql_update_jun2020_sp1_hugeint(Client c,
 #endif
 
 static str
-sql_update_semantics(Client c)
-{
-   char* update_query =
-   "update sys.functions set semantics = false where type <> 6 and func 
not ilike '%CREATE FUNCTION%' and name in 
('length','octet_length','>','>=','<','<=','min','max','sql_min','sql_max','least','greatest','sum','prod','mod','and',\n"
-   
"'xor','not','sql_mul','sql_div','sql_sub','sql_add','bit_and','bit_or','bit_xor','bit_not','left_shift','right_shift','abs','sign','scale_up','scale_down','round','power','floor','ceil','ceiling','sin','cos','tan','asin',\n"
-   
"'acos','atan','sinh','cot','cosh','tanh','sqrt','exp','log','ln','log10','log2','pi','curdate','current_date','curtime','current_time','current_timestamp','localtime','localtimestamp','local_timezone','century','decade','year',\n"
-   
"'quarter','month','day','dayofyear','weekofyear','dayofweek','dayofmonth','week','hour','minute','second','strings','locate','charindex','splitpart','substring','substr','truncate','concat','ascii','code','right','left','upper',\n"
-   
"'ucase','lower','lcase','trim','ltrim','rtrim','lpad','rpad','insert','replace','repeat','space','char_length','character_length','soundex','qgramnormalize');";
-
-   return SQLstatementIntern(c, _query, "update", true, false, 
NULL);
-}
-
-static str
 sql_update_default_lidar(Client c)
 {
char *query =
@@ -2858,7 +2844,7 @@ sql_update_default_lidar(Client c)
 static str
 sql_update_default(Client c, mvc *sql, const char *prev_schema)
 {
-   size_t bufsize = 4096, pos = 0;
+   size_t bufsize = 8192, pos = 0;
char *err = NULL, *buf = GDKmalloc(bufsize);
sql_schema *sys = mvc_bind_schema(sql, "sys");
res_table *output;
@@ -3011,6 +2997,14 @@ sql_update_default(Client c, mvc *sql, c
}
insert_functions(sql->session->tr, mvc_bind_table(sql, 
sys, "functions"), functions, mvc_bind_table(sql, sys, "args"));
 
+   pos += snprintf(buf + pos, bufsize - pos,
+   "update sys.functions set semantics = false 
where type <> 6 and ((func not ilike '%%CREATE FUNCTION%%' and name in 
('length','octet_length','>','>=','<','<=','min','max','sql_min','sql_max','least','greatest','sum','prod','mod','and',\n"
+   
"'xor','not','sql_mul','sql_div','sql_sub','sql_add','bit_and','bit_or','bit_xor','bit_not','left_shift','right_shift','abs','sign','scale_up','scale_down','round','power','floor','ceil','ceiling','sin','cos','tan','asin',\n"
+   
"'acos','atan','sinh','cot','cosh','tanh','sqrt','exp','log','ln','log10','log2','pi','curdate','current_date','curtime','current_time','current_timestamp','localtime','localtimestamp','local_timezone','century','decade','year',\n"
+   
"'quarter','month','day','dayofyear','weekofyear','dayofweek','dayofmonth','week','hour','minute','second','strings','locate','charindex','splitpart','substring','substr','truncate','concat','ascii','code','right','left','upper',\n"
+   
"'ucase','lower','lcase','trim','ltrim','rtrim','lpad','rpad','insert','replace','repeat','space','char_length','character_length','soundex','qgramnormalize','degrees','radians'))
 or \n"
+   "(system = true and name in 
('like','ilike','str_to_date','date_to_str','str_to_time','time_to_str','str_to_timestamp','timestamp_to_str','date_trunc','epoch')));\n");
+
pos += snprintf(buf + pos, bufsize - pos, "set schema 
\"%s\";\n", prev_schema);
assert(pos < bufsize);
 
@@ -3021,12 +3015,6 @@ sql_update_default(Client c, mvc *sql, c
}
res_table_destroy(output);
GDKfree(buf);
-
-   if (err)
-   return err;
-
-   err = sql_update_semantics(c);
-
return err; /* usually MAL_SUCCEED */
 }
 int
___
checkin-list mailing list
checkin-list@monetdb.org

MonetDB: default - monetdbe example_append_raw - removed name fr...

2020-06-30 Thread Thodoris Zois
Changeset: fe821ce3fe8d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fe821ce3fe8d
Modified Files:
ctest/tools/monetdbe/example_append_raw.c
Branch: default
Log Message:

monetdbe example_append_raw - removed name from monetdbe_column


diffs (47 lines):

diff --git a/ctest/tools/monetdbe/example_append_raw.c 
b/ctest/tools/monetdbe/example_append_raw.c
--- a/ctest/tools/monetdbe/example_append_raw.c
+++ b/ctest/tools/monetdbe/example_append_raw.c
@@ -36,11 +36,11 @@ main(void)
int32_t i1 = 42;
int32_t i2 = *(int32_t*)monetdbe_null(mdbe, monetdbe_int32_t);
int32_t ints[2] = { i1, i2 };
-   monetdbe_column col0 = { .name = "x", .type = monetdbe_int32_t, .data = 
, .count = 2 };
+   monetdbe_column col0 = { .type = monetdbe_int32_t, .data = , 
.count = 2 };

// str
char* dstr[2] = { "Hello", "World" };
-   monetdbe_column col1 = { .name = "y", .type = monetdbe_str, .data = 
, .count = 2 };
+   monetdbe_column col1 = { .type = monetdbe_str, .data = , .count = 
2 };
 
// timestamp
monetdbe_data_date dt = { .day = 2, .month = 3, .year = 2020 };
@@ -48,25 +48,25 @@ main(void)
monetdbe_data_timestamp t1 = { .date = dt, .time = tm };
monetdbe_data_timestamp t2 = 
*(monetdbe_data_timestamp*)monetdbe_null(mdbe, monetdbe_timestamp);
monetdbe_data_timestamp tss[2] = { t1, t2 };
-   monetdbe_column col2 = { .name = "ts", .type = monetdbe_timestamp, 
.data = , .count = 2 };
+   monetdbe_column col2 = { .type = monetdbe_timestamp, .data = , 
.count = 2 };
 
// date 
monetdbe_data_date d1 = dt;
monetdbe_data_date d2 = *(monetdbe_data_date*)monetdbe_null(mdbe, 
monetdbe_date);
monetdbe_data_date dts[2] = { d1, d2 };
-   monetdbe_column col3 = { .name = "dt", .type = monetdbe_date, .data = 
, .count = 2 };
+   monetdbe_column col3 = { .type = monetdbe_date, .data = , .count = 
2 };
 
// time
monetdbe_data_time tm1 = tm;
monetdbe_data_time tm2 = *(monetdbe_data_time*)monetdbe_null(mdbe, 
monetdbe_time);
monetdbe_data_time tms[2] = { tm1, tm2 };
-   monetdbe_column col4 = { .name = "t", .type = monetdbe_time, .data = 
, .count = 2 };
+   monetdbe_column col4 = { .type = monetdbe_time, .data = , .count = 
2 };
 
// blob
monetdbe_data_blob b1 = { .size = 1, .data = "33" };
monetdbe_data_blob b2 = *(monetdbe_data_blob*)monetdbe_null(mdbe, 
monetdbe_blob);
monetdbe_data_blob bs[2] = { b1, b2 };
-   monetdbe_column col5 = { .name = "b", .type = monetdbe_blob, .data = 
, .count = 2 };
+   monetdbe_column col5 = { .type = monetdbe_blob, .data = , .count = 2 
};
 
monetdbe_column* dcol[6] = { , , , , ,  };
if ((err = monetdbe_append(mdbe, "sys", "test", (monetdbe_column**) 
, 6)) != NULL)
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Made test give the same output on non 128 int...

2020-06-30 Thread Pedro Ferreira
Changeset: 21a11a36a02a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=21a11a36a02a
Modified Files:
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.err
Branch: Jun2020
Log Message:

Made test give the same output on non 128 int platforms


diffs (26 lines):

diff --git a/sql/test/miscellaneous/Tests/simple_selects.sql 
b/sql/test/miscellaneous/Tests/simple_selects.sql
--- a/sql/test/miscellaneous/Tests/simple_selects.sql
+++ b/sql/test/miscellaneous/Tests/simple_selects.sql
@@ -164,5 +164,5 @@ select 'a' like 'a' escape 'a'; --error,
 select cast(x as interval second) from (values ('1'), (NULL), ('100'), (NULL)) 
as x(x);
 select cast(x as interval month) from (values ('1'), (NULL), ('100'), (NULL)) 
as x(x);
 
-select cast(9223372036854775808 as interval month); --error value to large for 
a month interval
+select cast(92233720368547750 as interval month); --error value too large for 
a month interval
 select cast(92233720368547750 as interval second); --error, overflow in 
conversion for interval second
diff --git a/sql/test/miscellaneous/Tests/simple_selects.stable.err 
b/sql/test/miscellaneous/Tests/simple_selects.stable.err
--- a/sql/test/miscellaneous/Tests/simple_selects.stable.err
+++ b/sql/test/miscellaneous/Tests/simple_selects.stable.err
@@ -193,9 +193,9 @@ MAPI  = (monetdb) /var/tmp/mtest-400226/
 QUERY = select 'a' like 'a' escape 'a'; --error, like sequence ending with 
escape character 
 ERROR = !Illegal argument: (I)LIKE pattern must not end with escape character
 CODE  = 22019
-MAPI  = (monetdb) /var/tmp/mtest-107867/.s.monetdb.37815
-QUERY = select cast(9223372036854775808 as interval month); --error value to 
large for a month interval
-ERROR = !Value too large to fit at a month_interval
+MAPI  = (monetdb) /var/tmp/mtest-30988/.s.monetdb.33670
+QUERY = select cast(92233720368547750 as interval month); --error value too 
large for a month interval
+ERROR = !Value 92233720368547750 too large to fit at a month_interval
 CODE  = 22003
 MAPI  = (monetdb) /var/tmp/mtest-107867/.s.monetdb.37815
 QUERY = select cast(92233720368547750 as interval second); --error, overflow 
in conversion for interval second
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Updated ChangeLog

2020-06-30 Thread Pedro Ferreira
Changeset: 2e078ca5094d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2e078ca5094d
Modified Files:
sql/ChangeLog
Branch: default
Log Message:

Updated ChangeLog


diffs (21 lines):

diff --git a/sql/ChangeLog b/sql/ChangeLog
--- a/sql/ChangeLog
+++ b/sql/ChangeLog
@@ -37,3 +37,17 @@
 
 * Tue Jun 16 2020 Pedro Ferreira 
 - Removed obsolete json.output(json) function.
+
+* Tue Jun 30 2020 Pedro Ferreira 
+- Removed compability between interval types and other numeric types in
+  favor for a more strict SQL standard compliance. This means operations
+  between temporal types and other numeric types such as INT and 
+  DECIMAL are no longer possible, instead use interval types.
+  e.g. SELECT date '2020-01-01' + 1; now gives the error. Instead do:
+  SELECT date '2020-01-01' + interval '1' day; if 1 was meant to be a
+  day interval.
+  Setting an interval variable such as the session's current timezone
+  with a number e.g. SET current_timezone = 1; is no longer possible.
+  Instead do SET current_timezone = interval '1' hour;
+  Casting between interval and other numeric types is no longer possible
+  as well, because they are not compatible.
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Approved output

2020-06-30 Thread Pedro Ferreira
Changeset: 727679829446 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=727679829446
Modified Files:
sql/test/miscellaneous/Tests/simple_plans.stable.out.single
sql/test/pg_regress/Tests/interval.stable.err
sql/test/pg_regress/Tests/interval.stable.out
Branch: default
Log Message:

Approved output


diffs (159 lines):

diff --git a/sql/test/miscellaneous/Tests/simple_plans.stable.out.single 
b/sql/test/miscellaneous/Tests/simple_plans.stable.out.single
--- a/sql/test/miscellaneous/Tests/simple_plans.stable.out.single
+++ b/sql/test/miscellaneous/Tests/simple_plans.stable.out.single
@@ -188,8 +188,8 @@ project (
 % 166 # length
 function user.s24_0():void;
 X_2:void := querylog.define("explain select 1 from another_t t1 inner join 
another_t t2 on t1.col1 between t2.col1 and t2.col1;":str, "default_pipe":str, 
23:int);
-X_32:bat[:str] := bat.pack(".%3":str);
-X_33:bat[:str] := bat.pack("%3":str);
+X_32:bat[:str] := bat.pack(".%5":str);
+X_33:bat[:str] := bat.pack("%5":str);
 X_34:bat[:str] := bat.pack("tinyint":str);
 X_35:bat[:int] := bat.pack(1:int);
 X_36:bat[:int] := bat.pack(0:int);
@@ -237,8 +237,8 @@ end user.s24_0;
 % 174 # length
 function user.s26_0():void;
 X_4:void := querylog.define("explain select 1 from another_t t1 inner join 
another_t t2 on t1.col1 between t2.col1 - 1 and t2.col1 + 1;":str, 
"default_pipe":str, 35:int);
-X_49:bat[:str] := bat.pack(".%12":str);
-X_50:bat[:str] := bat.pack("%12":str);
+X_49:bat[:str] := bat.pack(".%14":str);
+X_50:bat[:str] := bat.pack("%14":str);
 X_51:bat[:str] := bat.pack("tinyint":str);
 X_52:bat[:int] := bat.pack(1:int);
 X_53:bat[:int] := bat.pack(0:int);
@@ -289,8 +289,8 @@ end user.s26_0;
 % 160 # length
 function user.s28_0():void;
 X_3:void := querylog.define("explain select 1 from another_t t1 inner join 
another_t t2 on t1.col1 between t2.col1 and 2;":str, "default_pipe":str, 
26:int);
-X_36:bat[:str] := bat.pack(".%3":str);
-X_37:bat[:str] := bat.pack("%3":str);
+X_36:bat[:str] := bat.pack(".%5":str);
+X_37:bat[:str] := bat.pack("%5":str);
 X_38:bat[:str] := bat.pack("tinyint":str);
 X_39:bat[:int] := bat.pack(1:int);
 X_40:bat[:int] := bat.pack(0:int);
@@ -339,8 +339,8 @@ end user.s28_0;
 % 189 # length
 function user.s30_0():void;
 X_2:void := querylog.define("explain select 1 from tbl_productsales t1 
inner join tbl_productsales t2 on t1.product_category like 
t2.product_category;":str, "default_pipe":str, 24:int);
-X_32:bat[:str] := bat.pack(".%3":str);
-X_33:bat[:str] := bat.pack("%3":str);
+X_32:bat[:str] := bat.pack(".%5":str);
+X_33:bat[:str] := bat.pack("%5":str);
 X_34:bat[:str] := bat.pack("tinyint":str);
 X_35:bat[:int] := bat.pack(1:int);
 X_36:bat[:int] := bat.pack(0:int);
@@ -388,8 +388,8 @@ end user.s30_0;
 % 148 # length
 function user.s32_0():void;
 X_2:void := querylog.define("explain select 1 from another_t t1 inner join 
another_t t2 on t1.col1 > t2.col1;":str, "default_pipe":str, 23:int);
-X_30:bat[:str] := bat.pack(".%3":str);
-X_31:bat[:str] := bat.pack("%3":str);
+X_30:bat[:str] := bat.pack(".%5":str);
+X_31:bat[:str] := bat.pack("%5":str);
 X_32:bat[:str] := bat.pack("tinyint":str);
 X_33:bat[:int] := bat.pack(1:int);
 X_34:bat[:int] := bat.pack(0:int);
diff --git a/sql/test/pg_regress/Tests/interval.stable.err 
b/sql/test/pg_regress/Tests/interval.stable.err
--- a/sql/test/pg_regress/Tests/interval.stable.err
+++ b/sql/test/pg_regress/Tests/interval.stable.err
@@ -54,7 +54,11 @@ MAPI  = (monetdb) /var/tmp/mtest-3604/.s
 QUERY = SELECT cast('10 years -11 month -12 days +13:14' as interval second) 
AS "9 years...";
 ERROR = !Wrong format (10 years -11 month -12 days +13:14)
 CODE  = 42000
-MAPI  = (monetdb) /var/tmp/mtest-3604/.s.monetdb.35433
+MAPI  = (monetdb) /var/tmp/mtest-149583/.s.monetdb.38425
+QUERY = INSERT INTO INTERVAL_TBL (f1) VALUES (60 * 60 * 24 * 365 * 2014);
+ERROR = !types bigint(37,0) and sec_interval(13,0) are not equal
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-149583/.s.monetdb.38425
 QUERY = INSERT INTO INTERVAL_TBL (f1) VALUES ('123456789012345678');
 ERROR = !Wrong format (123456789012345678)
 CODE  = 42000
@@ -144,7 +148,19 @@ QUERY = SELECT '' AS nine, INTERVAL_TBL.
WHERE INTERVAL_TBL.f1 > cast('@ 3 seconds ago' as interval second);
 ERROR = !Wrong format (@ 3 seconds ago)
 CODE  = 42000
-MAPI  = (monetdb) /var/tmp/mtest-45764/.s.monetdb.39324
+MAPI  = (monetdb) /var/tmp/mtest-149583/.s.monetdb.38425
+QUERY = select avg(f1) from interval_tbl;
+ERROR = !types sec_interval(13,0) and month_interval(32,0) are not equal for 
column 'f1'
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-149583/.s.monetdb.38425
+QUERY = select avg(cast(f1 as double)) from interval_tbl;
+ERROR = !types sec_interval(13,0) and double(53,0) are not equal for column 
'f1'
+CODE  = 42000
+MAPI  = 

MonetDB: default - Merged with Jun2020

2020-06-30 Thread Pedro Ferreira
Changeset: 63d49ec1360c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=63d49ec1360c
Modified Files:
sql/server/sql_atom.c
sql/test/miscellaneous/Tests/simple_selects.sql
sql/test/miscellaneous/Tests/simple_selects.stable.err
Branch: default
Log Message:

Merged with Jun2020

___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Fix upgrade from Nov2019 release: don't do th...

2020-06-30 Thread Sjoerd Mullender
Changeset: 4b7c0745a7a3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4b7c0745a7a3
Modified Files:
sql/backends/monet5/sql_upgrades.c
Branch: Jun2020
Log Message:

Fix upgrade from Nov2019 release: don't do things twice.
With failing transactions and thus a bad update as a result.


diffs (44 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -2754,40 +2754,6 @@ sql_update_jun2020(Client c, mvc *sql, c
" external name \"sql\".\"corr\";\n"
"GRANT EXECUTE ON WINDOW corr(INTERVAL MONTH, INTERVAL 
MONTH) TO PUBLIC;\n");
 
-#ifdef HAVE_HGE
-   if (have_hge) {
-   /* 39_analytics_hge.sql */
-   pos += snprintf(buf + pos, bufsize - pos,
-   "create window stddev_samp(val HUGEINT) returns 
DOUBLE\n"
-   " external name \"sql\".\"stdev\";\n"
-   "GRANT EXECUTE ON WINDOW stddev_samp(HUGEINT) TO 
PUBLIC;\n"
-   "create window stddev_pop(val HUGEINT) returns DOUBLE\n"
-   " external name \"sql\".\"stdevp\";\n"
-   "GRANT EXECUTE ON WINDOW stddev_pop(HUGEINT) TO 
PUBLIC;\n"
-   "create window var_samp(val HUGEINT) returns DOUBLE\n"
-   " external name \"sql\".\"variance\";\n"
-   "GRANT EXECUTE ON WINDOW var_samp(HUGEINT) TO PUBLIC;\n"
-   "create window var_pop(val HUGEINT) returns DOUBLE\n"
-   " external name \"sql\".\"variancep\";\n"
-   "GRANT EXECUTE ON WINDOW var_pop(HUGEINT) TO PUBLIC;\n"
-   "create aggregate covar_samp(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
-   " external name \"aggr\".\"covariance\";\n"
-   "GRANT EXECUTE ON AGGREGATE covar_samp(HUGEINT, 
HUGEINT) TO PUBLIC;\n"
-   "create window covar_samp(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
-   " external name \"sql\".\"covariance\";\n"
-   "GRANT EXECUTE ON WINDOW covar_samp(HUGEINT, HUGEINT) 
TO PUBLIC;\n"
-   "create aggregate covar_pop(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
-   " external name \"aggr\".\"covariancep\";\n"
-   "GRANT EXECUTE ON AGGREGATE covar_pop(HUGEINT, HUGEINT) 
TO PUBLIC;\n"
-   "create window covar_pop(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
-   " external name \"sql\".\"covariancep\";\n"
-   "GRANT EXECUTE ON WINDOW covar_pop(HUGEINT, HUGEINT) TO 
PUBLIC;\n"
-   "create window corr(e1 HUGEINT, e2 HUGEINT) returns 
DOUBLE\n"
-   " external name \"sql\".\"corr\";\n"
-   "GRANT EXECUTE ON WINDOW corr(HUGEINT, HUGEINT) TO 
PUBLIC;\n");
-   }
-#endif
-
pos += snprintf(buf + pos, bufsize - pos,
"create window sys.group_concat(str STRING) returns STRING\n"
" external name \"sql\".\"str_group_concat\";\n"
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - add buildrequirments for source rpms

2020-06-30 Thread Arjen de Rijke
Changeset: 430352698962 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=430352698962
Modified Files:
cmake/monetdb-rpm-packages.cmake
Branch: default
Log Message:

add buildrequirments for source rpms


diffs (70 lines):

diff --git a/cmake/monetdb-rpm-packages.cmake b/cmake/monetdb-rpm-packages.cmake
--- a/cmake/monetdb-rpm-packages.cmake
+++ b/cmake/monetdb-rpm-packages.cmake
@@ -135,3 +135,66 @@ set(CPACK_RPM_selinux_PACKAGE_SUMMARY "S
 set(CPACK_RPM_selinux_PACKAGE_ARCHITECTURE "noarch")
 set(CPACK_RPM_selinux_PACKAGE_REQUIRES_POST "MonetDB5-server%{?_isa} = 
%{version}-%{release}, %{name}-SQL-server5%{?_isa} = %{version}-%{release}, 
/usr/sbin/semodule, /sbin/restorecon, /sbin/fixfiles")
 set(CPACK_RPM_selinux_PACKAGE_REQUIRES_POSTUN "MonetDB5-server%{?_isa} = 
%{version}-%{release}, %{name}-SQL-server5%{?_isa} = %{version}-%{release}, 
/usr/sbin/semodule, /sbin/restorecon, /sbin/fixfiles")
+
+# Determine the build requires settings for the source build
+# This add buildsrequirement based on the packages that are
+# found on the machine that generates the packages. This might
+# not be what we want when distributing the source rpm, so we
+# might change this, or add the option to generate one based
+# on the cmake options.
+set(buildrequireslist
+  "gcc"
+  "bison"
+  "/usr/bin/python3")
+
+# RHEL >= 7, and all current Fedora
+LIST(APPEND buildrequireslist
+  "/usr/lib/rpm/macros.d/macros.systemd"
+  "checkpolicy"
+  "selinux-policy-devel"
+  "hardlink")
+
+if(BZIP2_FOUND)
+  LIST(APPEND buildrequireslist "bzip2-devel")
+endif()
+
+if(CFITSIO_FOUND)
+  LIST(APPEND buildrequireslist "pkgconfig(cfitsio)")
+endif()
+
+if(GEOS_FOUND)
+  LIST(APPEND buildrequireslist "geos-devel > 3.4.0")
+endif()
+
+if(CURL_FOUND)
+  LIST(APPEND buildrequireslist "pkgconfig(libcurl)")
+endif()
+
+if(LIBLZMA_FOUND)
+  LIST(APPEND buildrequireslist "pkgconfig(liblzma)")
+endif()
+
+if(READLINE_FOUND)
+  LIST(APPEND buildrequireslist "readline-devel")
+endif()
+
+if(ODBC_FOUND)
+  LIST(APPEND buildrequireslist "unixODBC-devel")
+endif()
+
+if(ZLIB_FOUND)
+  LIST(APPEND buildrequireslist "pkgconfig(zlib)")
+endif()
+
+if(PY3INTEGRATION)
+  LIST(APPEND buildrequireslist "python3-devel >= 3.5")
+  LIST(APPEND buildrequireslist "python3-numpy")
+endif()
+
+if(LIBR_FOUND)
+  LIST(APPEND buildrequireslist "R-core-devel")
+endif()
+
+LIST(JOIN buildrequireslist ", " buildrequires)
+
+set(CPACK_RPM_BUILDREQUIRES ${buildrequires})
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Minor comment as a note in example_append_raw

2020-06-30 Thread Thodoris Zois
Changeset: ac7236bc4ecc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ac7236bc4ecc
Modified Files:
ctest/tools/monetdbe/example_append_raw.c
Branch: default
Log Message:

Minor comment as a note in example_append_raw


diffs (12 lines):

diff --git a/ctest/tools/monetdbe/example_append_raw.c 
b/ctest/tools/monetdbe/example_append_raw.c
--- a/ctest/tools/monetdbe/example_append_raw.c
+++ b/ctest/tools/monetdbe/example_append_raw.c
@@ -32,6 +32,8 @@ main(void)
error(err)
 
// fill the empty table with data using append
+   // it is important to match column order below with the column order of 
the table
+
// int_32
int32_t i1 = 42;
int32_t i2 = *(int32_t*)monetdbe_null(mdbe, monetdbe_int32_t);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - It's impossible to do this right, so give tes...

2020-06-30 Thread Sjoerd Mullender
Changeset: 844e8a384f90 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=844e8a384f90
Modified Files:
sql/backends/monet5/vaults/shp/shp.h
Branch: Jun2020
Log Message:

It's impossible to do this right, so give test machines priority.


diffs (11 lines):

diff --git a/sql/backends/monet5/vaults/shp/shp.h 
b/sql/backends/monet5/vaults/shp/shp.h
--- a/sql/backends/monet5/vaults/shp/shp.h
+++ b/sql/backends/monet5/vaults/shp/shp.h
@@ -17,7 +17,6 @@
 #undef PACKAGE_TARNAME
 #undef PACKAGE_URL
 #undef PACKAGE_VERSION
-#undef HAVE_CXX11
 #include 
 #include 
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Backported recent default branch fixes into J...

2020-06-30 Thread Pedro Ferreira
Changeset: a07ba4ace956 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a07ba4ace956
Modified Files:
sql/server/sql_atom.c
Branch: Jun2020
Log Message:

Backported recent default branch fixes into Jun2020


diffs (48 lines):

diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c
--- a/sql/server/sql_atom.c
+++ b/sql/server/sql_atom.c
@@ -10,6 +10,7 @@
 #include "sql_atom.h"
 #include "sql_string.h"
 #include "sql_decimal.h"
+#include "blob.h"
 #include "gdk_time.h"
 
 void
@@ -455,9 +456,18 @@ atom2sql(atom *a)
c_delete(val);
return res;
} break;
-   case EC_BLOB:
-   /* TODO atom to string */
-   break;
+   case EC_BLOB: {
+   char *res;
+   blob *b = (blob*)a->data.val.pval;
+   size_t blob_size = (24 + (b->nitems * 3));
+
+   if ((res = NEW_ARRAY(char, blob_size + 8))) {
+   char *tail = stpcpy(res, "blob '");
+   ssize_t bloblen = BLOBtostr(, _size, b, true);
+   strcpy(res + bloblen + 6, "'");
+   }
+   return res;
+   } break;
case EC_MONTH:
case EC_SEC: {
lng v;
@@ -503,13 +513,7 @@ atom2sql(atom *a)
case 13:/* second */
break;
}
-   if (a->tpe.digits < 4) {
-   sprintf(buf, LLFMT, v);
-   } else {
-   lng sec = v/1000;
-   lng msec = v%1000;
-   sprintf(buf, LLFMT "." LLFMT, sec, msec);
-   }
+   sprintf(buf, "interval '" LLFMT "' %s", ec == EC_MONTH ? v : 
v/1000, ec == EC_MONTH ? "month" : "second");
break;
}
case EC_NUM:
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merge with Jun2020 branch.

2020-06-30 Thread Sjoerd Mullender
Changeset: 795b4a189ea3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=795b4a189ea3
Modified Files:
gdk/gdk_bat.c
sql/backends/monet5/vaults/shp/shp.h
sql/server/rel_optimizer.c
sql/server/rel_unnest.c
Branch: default
Log Message:

Merge with Jun2020 branch.


diffs (173 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -2317,6 +2317,8 @@ BATassertProps(BAT *b)
BATloop(b, p, q) {
valp = BUNtail(bi, p);
bool isnil = cmpf(valp, nilp) == 0;
+   assert(b->ttype != TYPE_flt || 
!isinf(*(flt*)valp));
+   assert(b->ttype != TYPE_dbl || 
!isinf(*(dbl*)valp));
if (maxval && !isnil) {
cmp = cmpf(maxval, valp);
assert(cmp >= 0);
@@ -2396,6 +2398,8 @@ BATassertProps(BAT *b)
BUN prb;
valp = BUNtail(bi, p);
bool isnil = cmpf(valp, nilp) == 0;
+   assert(b->ttype != TYPE_flt || 
!isinf(*(flt*)valp));
+   assert(b->ttype != TYPE_dbl || 
!isinf(*(dbl*)valp));
if (maxval && !isnil) {
cmp = cmpf(maxval, valp);
assert(cmp >= 0);
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
@@ -5415,115 +5415,6 @@ rel_join2semijoin(visitor *v, sql_rel *r
return rel;
 }
 
-typedef struct {
-   sql_rel *p; /* the found join's parent */
-   sql_rel *j; /* the found join relation itself */
-} found_join;
-
-static void
-rel_find_joins(mvc *sql, sql_rel *parent, sql_rel *rel, list *l, int depth)
-{
-   if (!rel || depth == 5) /* limit to 5 relations below in the tree */
-   return;
-
-   switch (rel->op) {
-   case op_basetable:
-   case op_table:
-   case op_ddl:
-   case op_truncate:
-   break;
-   case op_join:
-   case op_left:
-   case op_right:
-   case op_full:
-   case op_semi:
-   case op_anti: {
-   found_join *fl = SA_NEW(sql->sa, found_join);
-   fl->p = parent;
-   fl->j = rel;
-   list_append(l, fl);
-
-   if (rel->l)
-   rel_find_joins(sql, rel, rel->l, l, depth + 1);
-   if (rel->r)
-   rel_find_joins(sql, rel, rel->r, l, depth + 1);
-   } break;
-   case op_union:
-   case op_inter:
-   case op_except: {
-   if (rel->l)
-   rel_find_joins(sql, rel, rel->l, l, depth + 1);
-   if (rel->r)
-   rel_find_joins(sql, rel, rel->r, l, depth + 1);
-   } break;
-   case op_groupby:
-   case op_project:
-   case op_select:
-   case op_topn:
-   case op_sample: {
-   if (rel->l)
-   rel_find_joins(sql, rel, rel->l, l, depth + 1);
-   } break;
-   case op_insert:
-   case op_update:
-   case op_delete: {
-   if (rel->r)
-   rel_find_joins(sql, rel, rel->r, l, depth + 1);
-   } break;
-   }
-}
-
-/* find identical joins in diferent branches of the relational plan and merge 
them together */
-static sql_rel *
-rel_merge_identical_joins(visitor *v, sql_rel *rel)
-{
-   if (is_joinop(rel->op) && rel->l && rel->r) {
-   list *l1 = sa_list(v->sql->sa), *l2 = sa_list(v->sql->sa);
-
-   rel_find_joins(v->sql, rel, rel->l, l1, 0);
-   rel_find_joins(v->sql, rel, rel->r, l2, 0);
-
-   if (list_length(l1) && list_length(l2)) { /* found joins on 
both */
-   for (node *n1 = l1->h ; n1; n1 = n1->next) {
-   found_join *f1 = (found_join*) n1->data;
-   for (node *n2 = l2->h ; n2; n2 = n2->next) {
-   found_join *f2 = (found_join*) n2->data;
-   sql_rel *j1 = f1->j, *j2 = f2->j, *j1_l 
= j1->l, *j1_r = j1->r, *j2_l = j2->l, *j2_r = j2->r;
-   bool sides_equal = false;
-
-   if (j1 != j2) {
-   const char *j1_ln = 
rel_name(j1_l), *j1_rn = 

MonetDB: Jun2020 - Fix for bug 6911, ie never call exp_convert o...

2020-06-30 Thread Pedro Ferreira
Changeset: 890beb553c41 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=890beb553c41
Modified Files:
sql/backends/monet5/sql.c
sql/server/rel_exp.c
sql/server/rel_exp.h
sql/server/rel_optimizer.c
sql/server/rel_propagate.c
sql/server/rel_psm.c
sql/server/rel_schema.c
sql/server/rel_select.c
sql/server/rel_select.h
sql/server/rel_sequence.c
sql/server/rel_unnest.c
sql/server/rel_updates.c
sql/server/rel_xml.c
sql/server/sql_atom.c
sql/server/sql_atom.h
sql/test/SQLancer/Tests/All
sql/test/SQLancer/Tests/sqlancer02.stable.out
Branch: Jun2020
Log Message:

Fix for bug 6911, ie never call exp_convert on any expression without knowing 
if it will be compatible with the output type.
Removed the superfluous exp_convert calls and moved rel_check_type to rel_exp.h 
and renamed it to exp_check_type to make it more widely available.


diffs (truncated from 1368 to 300 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
@@ -338,7 +338,7 @@ create_table_or_view(mvc *sql, char* sna
_DELETE(typestr);
r = rel_parse(sql, s, buf, m_deps);
if (!r || !is_project(r->op) || !r->exps || 
list_length(r->exps) != 1 ||
-   rel_check_type(sql, >type, r, 
r->exps->h->data, type_equal) == NULL) {
+   exp_check_type(sql, >type, r, 
r->exps->h->data, type_equal) == NULL) {
if (r)
rel_destroy(r);
sa_destroy(sql->sa);
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -497,6 +497,13 @@ exp_null(sql_allocator *sa, sql_subtype 
return exp_atom(sa, a);
 }
 
+sql_exp *
+exp_zero(sql_allocator *sa, sql_subtype *tpe)
+{
+   atom *a = atom_zero_value(sa, tpe);
+   return exp_atom(sa, a);
+}
+
 atom *
 exp_value(mvc *sql, sql_exp *e, atom **args, int maxarg)
 {
@@ -2626,6 +2633,205 @@ exps_reset_freevar(list *exps)
}
 }
 
+int
+rel_set_type_param(mvc *sql, sql_subtype *type, sql_rel *rel, sql_exp 
*rel_exp, int upcast)
+{
+   sql_rel *r = rel;
+   int is_rel = exp_is_rel(rel_exp);
+
+   if (!type || !rel_exp || (rel_exp->type != e_atom && rel_exp->type != 
e_column && !is_rel))
+   return -1;
+
+   /* use largest numeric types */
+   if (upcast && type->type->eclass == EC_NUM)
+#ifdef HAVE_HGE
+   type = sql_bind_localtype(have_hge ? "hge" : "lng");
+#else
+   type = sql_bind_localtype("lng");
+#endif
+   if (upcast && type->type->eclass == EC_FLT)
+   type = sql_bind_localtype("dbl");
+
+   if (is_rel)
+   r = (sql_rel*) rel_exp->l;
+
+   if ((rel_exp->type == e_atom && (rel_exp->l || rel_exp->r || 
rel_exp->f)) || rel_exp->type == e_column || is_rel) {
+   /* it's not a parameter set possible parameters below */
+   const char *relname = exp_relname(rel_exp), *expname = 
exp_name(rel_exp);
+   if (rel_set_type_recurse(sql, type, r, , ) < 0)
+   return -1;
+   } else if (set_type_param(sql, type, rel_exp->flag) != 0)
+   return -1;
+
+   rel_exp->tpe = *type;
+   return 0;
+}
+
+/* try to do an in-place conversion
+ *
+ * in-place conversion is only possible if the exp is a variable.
+ * This is only done to be able to map more cached queries onto the same
+ * interface.
+ */
+
+static void
+convert_atom(atom *a, sql_subtype *rt)
+{
+   if (atom_null(a)) {
+   if (a->data.vtype != rt->type->localtype) {
+   const void *p;
+
+   a->data.vtype = rt->type->localtype;
+   p = ATOMnilptr(a->data.vtype);
+   VALset(>data, a->data.vtype, (ptr) p);
+   }
+   }
+   a->tpe = *rt;
+}
+
+static sql_exp *
+exp_convert_inplace(mvc *sql, sql_subtype *t, sql_exp *exp)
+{
+   atom *a;
+
+   /* exclude named variables and variable lists */
+   if (exp->type != e_atom || exp->r /* named */ || exp->f /* list */ || 
!exp->l /* not direct atom */)
+   return NULL;
+
+   a = exp->l;
+   if (t->scale && t->type->eclass != EC_FLT)
+   return NULL;
+
+   if (a && atom_cast(sql->sa, a, t)) {
+   convert_atom(a, t);
+   exp->tpe = *t;
+   return exp;
+   }
+   return NULL;
+}
+
+sql_exp *
+exp_numeric_supertype(mvc *sql, sql_exp *e )
+{
+   sql_subtype *tp = exp_subtype(e);
+
+   if (tp->type->eclass == EC_DEC) {
+   sql_subtype *dtp = sql_bind_localtype("dbl");
+
+   return exp_check_type(sql, dtp, NULL, e, 

MonetDB: default - Merged with Jun2020

2020-06-30 Thread Pedro Ferreira
Changeset: a6023133240b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a6023133240b
Modified Files:
sql/backends/monet5/sql.c
sql/backends/monet5/sql_upgrades.c
sql/server/rel_exp.c
sql/server/rel_exp.h
sql/server/rel_optimizer.c
sql/server/rel_propagate.c
sql/server/rel_psm.c
sql/server/rel_schema.c
sql/server/rel_select.c
sql/server/rel_select.h
sql/server/rel_sequence.c
sql/server/rel_unnest.c
sql/server/rel_updates.c
sql/server/rel_xml.c
sql/server/sql_atom.c
sql/server/sql_atom.h
sql/test/SQLancer/Tests/All
sql/test/SQLancer/Tests/sqlancer02.stable.out
Branch: default
Log Message:

Merged with Jun2020


diffs (truncated from 1405 to 300 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
@@ -326,7 +326,7 @@ create_table_or_view(mvc *sql, char* sna
}
r = rel_parse(sql, s, sa_message(sql->sa, "select %s;", 
c->def), m_deps);
if (!r || !is_project(r->op) || !r->exps || 
list_length(r->exps) != 1 ||
-   rel_check_type(sql, >type, r, 
r->exps->h->data, type_equal) == NULL) {
+   exp_check_type(sql, >type, r, 
r->exps->h->data, type_equal) == NULL) {
if (r)
rel_destroy(r);
sa_destroy(sql->sa);
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -2548,40 +2548,6 @@ sql_update_jun2020(Client c, mvc *sql, c
" external name \"sql\".\"corr\";\n"
"GRANT EXECUTE ON WINDOW corr(INTERVAL MONTH, INTERVAL 
MONTH) TO PUBLIC;\n");
 
-#ifdef HAVE_HGE
-   if (have_hge) {
-   /* 39_analytics_hge.sql */
-   pos += snprintf(buf + pos, bufsize - pos,
-   "create window stddev_samp(val HUGEINT) returns 
DOUBLE\n"
-   " external name \"sql\".\"stdev\";\n"
-   "GRANT EXECUTE ON WINDOW stddev_samp(HUGEINT) TO 
PUBLIC;\n"
-   "create window stddev_pop(val HUGEINT) returns DOUBLE\n"
-   " external name \"sql\".\"stdevp\";\n"
-   "GRANT EXECUTE ON WINDOW stddev_pop(HUGEINT) TO 
PUBLIC;\n"
-   "create window var_samp(val HUGEINT) returns DOUBLE\n"
-   " external name \"sql\".\"variance\";\n"
-   "GRANT EXECUTE ON WINDOW var_samp(HUGEINT) TO PUBLIC;\n"
-   "create window var_pop(val HUGEINT) returns DOUBLE\n"
-   " external name \"sql\".\"variancep\";\n"
-   "GRANT EXECUTE ON WINDOW var_pop(HUGEINT) TO PUBLIC;\n"
-   "create aggregate covar_samp(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
-   " external name \"aggr\".\"covariance\";\n"
-   "GRANT EXECUTE ON AGGREGATE covar_samp(HUGEINT, 
HUGEINT) TO PUBLIC;\n"
-   "create window covar_samp(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
-   " external name \"sql\".\"covariance\";\n"
-   "GRANT EXECUTE ON WINDOW covar_samp(HUGEINT, HUGEINT) 
TO PUBLIC;\n"
-   "create aggregate covar_pop(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
-   " external name \"aggr\".\"covariancep\";\n"
-   "GRANT EXECUTE ON AGGREGATE covar_pop(HUGEINT, HUGEINT) 
TO PUBLIC;\n"
-   "create window covar_pop(e1 HUGEINT, e2 HUGEINT) 
returns DOUBLE\n"
-   " external name \"sql\".\"covariancep\";\n"
-   "GRANT EXECUTE ON WINDOW covar_pop(HUGEINT, HUGEINT) TO 
PUBLIC;\n"
-   "create window corr(e1 HUGEINT, e2 HUGEINT) returns 
DOUBLE\n"
-   " external name \"sql\".\"corr\";\n"
-   "GRANT EXECUTE ON WINDOW corr(HUGEINT, HUGEINT) TO 
PUBLIC;\n");
-   }
-#endif
-
pos += snprintf(buf + pos, bufsize - pos,
"create window sys.group_concat(str STRING) returns STRING\n"
" external name \"sql\".\"str_group_concat\";\n"
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -498,6 +498,13 @@ exp_null(sql_allocator *sa, sql_subtype 
return exp_atom(sa, a);
 }
 
+sql_exp *
+exp_zero(sql_allocator *sa, sql_subtype *tpe)
+{
+   atom *a = atom_zero_value(sa, tpe);
+   return exp_atom(sa, a);
+}
+
 atom *
 exp_value(mvc *sql, sql_exp *e, atom **args, int maxarg)
 {
@@ -2759,6 +2766,205 @@ exps_reset_freevar(list *exps)

MonetDB: default - Reverse function has no null semantics too

2020-06-30 Thread Pedro Ferreira
Changeset: 8792601338d2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8792601338d2
Modified Files:
sql/backends/monet5/sql_upgrades.c
Branch: default
Log Message:

Reverse function has no null semantics too


diffs (12 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -2969,7 +2969,7 @@ sql_update_default(Client c, mvc *sql, c

"'acos','atan','sinh','cot','cosh','tanh','sqrt','exp','log','ln','log10','log2','pi','curdate','current_date','curtime','current_time','current_timestamp','localtime','localtimestamp','local_timezone','century','decade','year',\n"

"'quarter','month','day','dayofyear','weekofyear','dayofweek','dayofmonth','week','hour','minute','second','strings','locate','charindex','splitpart','substring','substr','truncate','concat','ascii','code','right','left','upper',\n"

"'ucase','lower','lcase','trim','ltrim','rtrim','lpad','rpad','insert','replace','repeat','space','char_length','character_length','soundex','qgramnormalize','degrees','radians'))
 or \n"
-   "(system = true and name in 
('like','ilike','str_to_date','date_to_str','str_to_time','time_to_str','str_to_timestamp','timestamp_to_str','date_trunc','epoch')));\n");
+   "(system = true and name in 
('like','ilike','str_to_date','date_to_str','str_to_time','time_to_str','str_to_timestamp','timestamp_to_str','date_trunc','epoch','reverse')));\n");
 
pos += snprintf(buf + pos, bufsize - pos, "set schema 
\"%s\";\n", prev_schema);
assert(pos < bufsize);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Work around problems with coredumpctl, and pr...

2020-06-30 Thread Sjoerd Mullender
Changeset: 0f6bfbed3773 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0f6bfbed3773
Modified Files:
testing/Mtest.py.in
Branch: Jun2020
Log Message:

Work around problems with coredumpctl, and provide proper stack trace.


diffs (70 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1603,6 +1603,32 @@ def expandvars(path, environ = os.enviro
 i = j
 return path
 
+def coredumpctl(pid):
+import tempfile
+# can't use tempfile.NamedTemporaryFile because it opens the file
+# exclusively
+fd, name = tempfile.mkstemp(suffix='.sh')
+fd2, name2 = tempfile.mkstemp()
+os.close(fd2)
+os.write(fd, b'#!/bin/sh\ngdb -nx -batch -ex "thread apply all bt" "$@" > 
%s\n' % name2.encode('utf-8'))
+os.close(fd)
+os.chmod(name, 0o700)
+if procdebug:
+print('Starting: coredumpctl -q --debugger=%s gdb %d' % (name, pid))
+with process.Popen(['coredumpctl', '-q', '--debugger=%s' % name, 'gdb', 
str(pid)],
+   stdout=process.PIPE,
+   stderr=process.PIPE,
+   text=True) as p:
+out, err = p.communicate()
+os.unlink(name)
+s = []
+for l in out.split('\n'):
+if not l.startswith(''):
+s.append(l)
+out = '\n'.join(s) + open(name2).read()
+os.unlink(name2)
+return out, err
+
 def returnCode(proc, f = None):
 '''Interpret the return code of a process.
 If second arg sepcified, write a message to it.'''
@@ -1635,14 +1661,8 @@ def returnCode(proc, f = None):
 if os.path.exists('/usr/bin/coredumpctl'):
 # wait a few seconds for the core to be dumped
 time.sleep(10)
-if procdebug:
-print('Starting: coredumpctl -q info %d' % proc.pid)
-p = process.Popen(['coredumpctl', '-q' ,'info', 
str(proc.pid)],
-  stdout=process.PIPE,
-  stderr=process.PIPE,
-  text=True)
-out, err = p.communicate()
-if not err and out:
+out, err = coredumpctl(proc.pid)
+if out:
 f.write(out)
 f.flush()
 return 'segfault'   # Segmentation fault
@@ -1657,14 +1677,8 @@ def returnCode(proc, f = None):
 if os.path.exists('/usr/bin/coredumpctl'):
 # wait a few seconds for the core to be dumped
 time.sleep(10)
-if procdebug:
-print('Starting: coredumpctl -q info %d' % proc.pid)
-p = process.Popen(['coredumpctl', '-q' ,'info', 
str(proc.pid)],
-  stdout=process.PIPE,
-  stderr=process.PIPE,
-  text=True)
-out, err = p.communicate()
-if not err and out:
+out, err = coredumpctl(proc.pid)
+if out:
 f.write(out)
 f.flush()
 return 'abort'  # Aborted
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Modernize: use text instead of universal_newl...

2020-06-30 Thread Sjoerd Mullender
Changeset: f9b94247ae68 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f9b94247ae68
Modified Files:
testing/Mtest.py.in
testing/process.py
Branch: Jun2020
Log Message:

Modernize: use text instead of universal_newlines.


diffs (truncated from 367 to 300 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1475,7 +1475,7 @@ def ApproveOutput (env, TST) :
 f = openutf8(patch + '.0', 'w')
 proc = process.Popen(['diff', '-Bb', '-I^[#=]', '-I^MAPI *=', 
'-U0',
   stableOUTPUT, testOUTPUT],
- stdout = f, universal_newlines = True)
+ stdout=f, text=True)
 proc.wait()
 f.close()
 if os.path.getsize(patch + ".0"):
@@ -1519,12 +1519,12 @@ def ApproveOutput (env, TST) :
 if not verbose:
 patchcmd.append('--quiet')
 proc = process.Popen(patchcmd + [stableOUTPUT, patch + '.1'],
- universal_newlines = True)
+ text=True)
 proc.wait()
 f = openutf8(patch, 'w')
 proc = process.Popen(['diff', '-u', stableOUTPUT + '.ORG',
   stableOUTPUT],
- stdout = f, universal_newlines = True)
+ stdout=f, text=True)
 proc.wait()
 f.close()
 remove(stableOUTPUT + ".ORG")
@@ -1544,7 +1544,7 @@ def ApproveOutput (env, TST) :
 elif f != thefile and test.match(f):
 remove(os.path.join(dir or os.curdir, f + '.rej'))
 remove(os.path.join(dir or os.curdir, f + '.orig'))
-proc = process.Popen(patchcmd + ['--forward', 
os.path.join(dir or os.curdir, f)], stdin = openutf8(patch), universal_newlines 
= True)
+proc = process.Popen(patchcmd + ['--forward', 
os.path.join(dir or os.curdir, f)], stdin=openutf8(patch), text=True)
 proc.wait()
 if os.path.exists(os.path.join(dir or os.curdir, f 
+ '.rej')):
 list.append(f)
@@ -1638,9 +1638,9 @@ def returnCode(proc, f = None):
 if procdebug:
 print('Starting: coredumpctl -q info %d' % proc.pid)
 p = process.Popen(['coredumpctl', '-q' ,'info', 
str(proc.pid)],
-  stdout = process.PIPE,
-  stderr = process.PIPE,
-  universal_newlines = True)
+  stdout=process.PIPE,
+  stderr=process.PIPE,
+  text=True)
 out, err = p.communicate()
 if not err and out:
 f.write(out)
@@ -1660,9 +1660,9 @@ def returnCode(proc, f = None):
 if procdebug:
 print('Starting: coredumpctl -q info %d' % proc.pid)
 p = process.Popen(['coredumpctl', '-q' ,'info', 
str(proc.pid)],
-  stdout = process.PIPE,
-  stderr = process.PIPE,
-  universal_newlines = True)
+  stdout=process.PIPE,
+  stderr=process.PIPE,
+  text=True)
 out, err = p.communicate()
 if not err and out:
 f.write(out)
@@ -1700,8 +1700,8 @@ def GetBitsAndModsAndThreads(env) :
 if procdebug:
 print('GetBitsAndModsAndThreads: starting process "%s" (inpipe, 
outpipe, errpipe)\n' % '" "'.join(cmd))
 setpgrp = True
-proc = process.Popen(cmd, stdin = process.PIPE, stdout = process.PIPE,
- stderr = process.PIPE, universal_newlines = True)
+proc = process.Popen(cmd, stdin=process.PIPE, stdout=process.PIPE,
+ stderr=process.PIPE, text=True)
 proc.killed = False
 proc.onechild = True
 t = Timer(float(par['TIMEOUT']), killProc, args = [proc, proc.stderr, cmd])
@@ -1720,7 +1720,7 @@ def GetBitsAndModsAndThreads(env) :
 if procdebug:
 print('GetBitsAndModsAndThreads: starting process "%s" 
(inpipe, outpipe, errpipe)\n' % '" "'.join(cmd))
 clnt = process.Popen(cmd, stdin=process.PIPE, stdout=process.PIPE,
- stderr=process.PIPE, universal_newlines=True)
+ stderr=process.PIPE, text=True)
 input = '''\
 c