MonetDB: default - Starting the week with a breakfast crash. Glo...

2022-02-21 Thread Pedro Ferreira
Changeset: 0f4245944458 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0f4245944458
Modified Files:
sql/test/SQLancer/Tests/sqlancer22.test
Branch: default
Log Message:

Starting the week with a breakfast crash. Global aggregate binding issue


diffs (15 lines):

diff --git a/sql/test/SQLancer/Tests/sqlancer22.test 
b/sql/test/SQLancer/Tests/sqlancer22.test
--- a/sql/test/SQLancer/Tests/sqlancer22.test
+++ b/sql/test/SQLancer/Tests/sqlancer22.test
@@ -690,6 +690,11 @@ query I nosort
 SELECT 1 FROM t0 LEFT JOIN (SELECT 2) AS x(x) ON (SELECT t0.c0 UNION ALL 
SELECT x.x) > 0
 
 
+query I nosort
+SELECT min((SELECT CASE t0.c0 WHEN t0.c0 THEN t0.c0 END)) FROM t0
+
+NULL
+
 statement ok
 ROLLBACK
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - More missing cardinality checks

2022-02-21 Thread Pedro Ferreira
Changeset: 01e36114c9d1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/01e36114c9d1
Modified Files:
sql/test/SQLancer/Tests/sqlancer22.test
Branch: default
Log Message:

More missing cardinality checks


diffs (28 lines):

diff --git a/sql/test/SQLancer/Tests/sqlancer22.test 
b/sql/test/SQLancer/Tests/sqlancer22.test
--- a/sql/test/SQLancer/Tests/sqlancer22.test
+++ b/sql/test/SQLancer/Tests/sqlancer22.test
@@ -691,6 +691,11 @@ SELECT 1 FROM t0 LEFT JOIN (SELECT 2) AS
 
 
 query I nosort
+SELECT min((SELECT t0.c0 + t0.c0)) FROM t0
+
+NULL
+
+query I nosort
 SELECT min((SELECT CASE t0.c0 WHEN t0.c0 THEN t0.c0 END)) FROM t0
 
 NULL
@@ -698,6 +703,12 @@ NULL
 statement ok
 ROLLBACK
 
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT y.y BETWEEN 1 AND max(x.x) FROM (SELECT 1) x(x), (SELECT 1) y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT y.y BETWEEN max(x.x) AND 1 FROM (SELECT 1) x(x), (SELECT 1) y(y)
+
 statement error Subquery has too many columns
 select 1 where (2,3) in (select x,y,2 from (values (2, 3), (4, 5)) x(x,y))
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Check for instead of for in...

2022-02-21 Thread Joeri van Ruth
Changeset: 46b04cb523a2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/46b04cb523a2
Modified Files:
tools/merovingian/client/Tests/monetdb_snapshot.py
Branch: default
Log Message:

Check for  instead of for  in test monetdb_snapshot


diffs (14 lines):

diff --git a/tools/merovingian/client/Tests/monetdb_snapshot.py 
b/tools/merovingian/client/Tests/monetdb_snapshot.py
--- a/tools/merovingian/client/Tests/monetdb_snapshot.py
+++ b/tools/merovingian/client/Tests/monetdb_snapshot.py
@@ -31,8 +31,8 @@ with Runner(False) as run:
 header('CHECK SNAPDIR NOT SET')
 output = m.run_monetdbd('get', 'snapshotdir', output=True)
 run.print(' -->', repr(output))
-assert '' in output
-note("""'' in output as expected""")
+assert '' in output
+note("""'' in output as expected""")
 
 header('TRY TO CREATE')
 try:
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - More missing cardinality checks

2022-02-21 Thread Pedro Ferreira
Changeset: 98620b56c7c3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/98620b56c7c3
Modified Files:
sql/test/SQLancer/Tests/sqlancer22.test
Branch: default
Log Message:

More missing cardinality checks


diffs (35 lines):

diff --git a/sql/test/SQLancer/Tests/sqlancer22.test 
b/sql/test/SQLancer/Tests/sqlancer22.test
--- a/sql/test/SQLancer/Tests/sqlancer22.test
+++ b/sql/test/SQLancer/Tests/sqlancer22.test
@@ -709,6 +709,31 @@ SELECT y.y BETWEEN 1 AND max(x.x) FROM (
 statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
 SELECT y.y BETWEEN max(x.x) AND 1 FROM (SELECT 1) x(x), (SELECT 1) y(y)
 
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT 1 BETWEEN y.y AND max(x.x) FROM (SELECT 1) x(x), (SELECT 1) y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT y.y LIKE max(x.x) FROM (SELECT '1') x(x), (SELECT '1') y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'x.x' in query 
results without an aggregate function
+SELECT max(y.y) LIKE x.x FROM (SELECT '1') x(x), (SELECT '1') y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT [y.y] "like" [max(x.x), '', false] FROM (SELECT '1') x(x), (SELECT '1') 
y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'x.x' in query 
results without an aggregate function
+SELECT [max(y.y)] "like" [x.x, '', false] FROM (SELECT '1') x(x), (SELECT '1') 
y(y)
+
+query I nosort
+SELECT ['1'] "like" [max(x.x), '', false] FROM (SELECT '1') x(x), (SELECT '1') 
y(y)
+
+1
+
+query I nosort
+SELECT [max(y.y)] "like" ['1', '', false] FROM (SELECT '1') x(x), (SELECT '1') 
y(y)
+
+1
+
 statement error Subquery has too many columns
 select 1 where (2,3) in (select x,y,2 from (values (2, 3), (4, 5)) x(x,y))
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - More missing cardinality checks

2022-02-21 Thread Pedro Ferreira
Changeset: 0cb2616ce89c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0cb2616ce89c
Modified Files:
sql/test/SQLancer/Tests/sqlancer22.test
Branch: default
Log Message:

More missing cardinality checks


diffs (44 lines):

diff --git a/sql/test/SQLancer/Tests/sqlancer22.test 
b/sql/test/SQLancer/Tests/sqlancer22.test
--- a/sql/test/SQLancer/Tests/sqlancer22.test
+++ b/sql/test/SQLancer/Tests/sqlancer22.test
@@ -713,6 +713,9 @@ statement error 42000!SELECT: cannot use
 SELECT 1 BETWEEN y.y AND max(x.x) FROM (SELECT 1) x(x), (SELECT 1) y(y)
 
 statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT y.y BETWEEN 1 AND max(x.x) FROM (SELECT 1) x(x), (SELECT 1) y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
 SELECT y.y LIKE max(x.x) FROM (SELECT '1') x(x), (SELECT '1') y(y)
 
 statement error 42000!SELECT: cannot use non GROUP BY column 'x.x' in query 
results without an aggregate function
@@ -724,6 +727,30 @@ SELECT [y.y] "like" [max(x.x), '', false
 statement error 42000!SELECT: cannot use non GROUP BY column 'x.x' in query 
results without an aggregate function
 SELECT [max(y.y)] "like" [x.x, '', false] FROM (SELECT '1') x(x), (SELECT '1') 
y(y)
 
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT y.y IN (max(x.x)) FROM (SELECT 1) x(x), (SELECT 1) y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT y.y AND max(x.x) FROM (SELECT 1) x(x), (SELECT 1) y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT y.y OR max(x.x) FROM (SELECT 1) x(x), (SELECT 1) y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT y.y + max(x.x) FROM (SELECT 1) x(x), (SELECT 1) y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT case y.y when max(x.x) then 1 end FROM (SELECT 1) x(x), (SELECT 1) y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'x.x' in query 
results without an aggregate function
+SELECT case 2 when x.x then min(y.y) end FROM (SELECT 1) x(x), (SELECT 1) y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'x.x' in query 
results without an aggregate function
+SELECT case x.x when 2 then min(y.y) end FROM (SELECT 1) x(x), (SELECT 1) y(y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'x.x' in query 
results without an aggregate function
+SELECT case 1 when 2 then x.x when max(y.y) then 3 end FROM (SELECT 1) x(x), 
(SELECT 1) y(y)
+
 query I nosort
 SELECT ['1'] "like" [max(x.x), '', false] FROM (SELECT '1') x(x), (SELECT '1') 
y(y)
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Two more missing cases. Enough for now

2022-02-21 Thread Pedro Ferreira
Changeset: f382b251586c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f382b251586c
Modified Files:
sql/test/SQLancer/Tests/sqlancer22.test
Branch: default
Log Message:

Two more missing cases. Enough for now


diffs (16 lines):

diff --git a/sql/test/SQLancer/Tests/sqlancer22.test 
b/sql/test/SQLancer/Tests/sqlancer22.test
--- a/sql/test/SQLancer/Tests/sqlancer22.test
+++ b/sql/test/SQLancer/Tests/sqlancer22.test
@@ -751,6 +751,12 @@ SELECT case x.x when 2 then min(y.y) end
 statement error 42000!SELECT: cannot use non GROUP BY column 'x.x' in query 
results without an aggregate function
 SELECT case 1 when 2 then x.x when max(y.y) then 3 end FROM (SELECT 1) x(x), 
(SELECT 1) y(y)
 
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT y.y FROM (SELECT 1) x(x), (SELECT 1) y(y) order by min(x.x)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
+SELECT ntile(y.y) over () FROM (SELECT 1) x(x), (SELECT 1) y(y) order by 
min(x.x)
+
 query I nosort
 SELECT ['1'] "like" [max(x.x), '', false] FROM (SELECT '1') x(x), (SELECT '1') 
y(y)
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: privfuncs - Disable binding private functions from user...

2022-02-21 Thread Pedro Ferreira
Changeset: 645df759eac8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/645df759eac8
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_cat.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sql_upgrades.c
sql/common/sql_types.c
sql/server/rel_dump.c
sql/server/rel_exp.c
sql/server/rel_optimizer.c
sql/server/rel_propagate.c
sql/server/rel_psm.c
sql/server/rel_rel.c
sql/server/rel_select.c
sql/server/rel_sequence.c
sql/server/rel_unnest.c
sql/server/rel_updates.c
sql/server/sql_privileges.c
sql/server/sql_semantic.c
sql/server/sql_semantic.h
Branch: privfuncs
Log Message:

Disable binding private functions from user queries. Some tests need approval


diffs (truncated from 2353 to 300 lines):

diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -66,11 +66,11 @@ sql_unop_(backend *be, const char *fname
sql_subfunc *f = NULL;
 
rt = tail_type(rs);
-   f = sql_bind_func(sql, "sys", fname, rt, NULL, F_FUNC);
+   f = sql_bind_func(sql, "sys", fname, rt, NULL, F_FUNC, true);
/* try to find the function without a type, and convert
 * the value to the type needed by this function!
 */
-   if (!f && (f = sql_find_func(sql, "sys", fname, 1, F_FUNC, NULL)) != 
NULL) {
+   if (!f && (f = sql_find_func(sql, "sys", fname, 1, F_FUNC, true, NULL)) 
!= NULL) {
sql_arg *a = f->func->ops->h->data;
 
sql->session->status = 0;
@@ -439,10 +439,10 @@ handle_in_exps(backend *be, sql_exp *ce,
if (c->nrcols == 0 || depth || !reduce) {
sql_subtype *bt = sql_bind_localtype("bit");
sql_subfunc *cmp = (in)
-   ?sql_bind_func(sql, "sys", "=", tail_type(c), 
tail_type(c), F_FUNC)
-   :sql_bind_func(sql, "sys", "<>", tail_type(c), 
tail_type(c), F_FUNC);
-   sql_subfunc *a = (in)?sql_bind_func(sql, "sys", "or", bt, bt, 
F_FUNC)
-:sql_bind_func(sql, "sys", "and", bt, bt, 
F_FUNC);
+   ?sql_bind_func(sql, "sys", "=", tail_type(c), 
tail_type(c), F_FUNC, true)
+   :sql_bind_func(sql, "sys", "<>", tail_type(c), 
tail_type(c), F_FUNC, true);
+   sql_subfunc *a = (in)?sql_bind_func(sql, "sys", "or", bt, bt, 
F_FUNC, true)
+:sql_bind_func(sql, "sys", "and", bt, bt, 
F_FUNC, true);
 
for( n = nl->h; n; n = n->next) {
sql_exp *e = n->data;
@@ -610,7 +610,7 @@ exp_bin_or(backend *be, sql_exp *e, stmt
return s;
 
if (!sin && sel1 && sel1->nrcols == 0 && s->nrcols == 0) {
-   sql_subfunc *f = sql_bind_func(be->mvc, "sys", 
anti?"or":"and", bt, bt, F_FUNC);
+   sql_subfunc *f = sql_bind_func(be->mvc, "sys", 
anti?"or":"and", bt, bt, F_FUNC, true);
assert(f);
s = stmt_binop(be, sel1, s, sin, f);
} else if (sel1 && (sel1->nrcols == 0 || s->nrcols == 0)) {
@@ -637,7 +637,7 @@ exp_bin_or(backend *be, sql_exp *e, stmt
return s;
 
if (!sin && sel2 && sel2->nrcols == 0 && s->nrcols == 0) {
-   sql_subfunc *f = sql_bind_func(be->mvc, "sys", 
anti?"or":"and", bt, bt, F_FUNC);
+   sql_subfunc *f = sql_bind_func(be->mvc, "sys", 
anti?"or":"and", bt, bt, F_FUNC, true);
assert(f);
s = stmt_binop(be, sel2, s, sin, f);
} else if (sel2 && (sel2->nrcols == 0 || s->nrcols == 0)) {
@@ -652,7 +652,7 @@ exp_bin_or(backend *be, sql_exp *e, stmt
sel2 = s;
}
if (sel1->nrcols == 0 && sel2->nrcols == 0) {
-   sql_subfunc *f = sql_bind_func(be->mvc, "sys", anti?"and":"or", 
bt, bt, F_FUNC);
+   sql_subfunc *f = sql_bind_func(be->mvc, "sys", anti?"and":"or", 
bt, bt, F_FUNC, true);
assert(f);
return stmt_binop(be, sel1, sel2, NULL, f);
}
@@ -680,9 +680,9 @@ exp2bin_case(backend *be, sql_exp *fe, s
int next_cond = 1, single_value = (fe->card <= CARD_ATOM && (!left || 
!left->nrcols));
char name[16], *nme = NULL;
sql_subtype *bt = sql_bind_localtype("bit");
-   sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL, 
F_FUNC);
-   sql_subfunc *or = sql_bind_func(be->mvc, "sys", "or", bt, bt, F_FUNC);
-   sql_subfunc *and = sql_bind_func(be->mvc, "sys", "and", bt, bt, F_FUNC);
+   sql_subfunc *not = sql_bind_func(be->mvc, "sys", "not", bt, NULL, 
F_FUNC, true);
+   sql_subfunc *or = sql_bind_func(be->mvc, "sys", "or", bt, bt, F_FUNC, 
true);
+   

MonetDB: privfuncs - Approved output for new private function ch...

2022-02-21 Thread Pedro Ferreira
Changeset: 07aff7097565 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/07aff7097565
Modified Files:
sql/test/SQLancer/Tests/sqlancer01.test
sql/test/SQLancer/Tests/sqlancer02.test
sql/test/SQLancer/Tests/sqlancer04.test
sql/test/SQLancer/Tests/sqlancer05.test
sql/test/SQLancer/Tests/sqlancer08.test
sql/test/SQLancer/Tests/sqlancer09.test
sql/test/SQLancer/Tests/sqlancer11.test
sql/test/miscellaneous/Tests/simple_selects.test
sql/test/prepare/Tests/sqlancer_prepare.sql
sql/test/prepare/Tests/sqlancer_prepare.stable.err.int128
sql/test/prepare/Tests/sqlancer_prepare.stable.out
sql/test/prepare/Tests/sqlancer_prepare.stable.out.int128
sql/test/sys-schema/Tests/webExamplesComparisonFunctionsOperators.test
sql/test/sys-schema/Tests/webExamplesLogicalFunctionsOperators.test
sql/test/sys-schema/Tests/webExamplesMathematicalFunctionsOperators.test
Branch: privfuncs
Log Message:

Approved output for new private function changes


diffs (truncated from 723 to 300 lines):

diff --git a/sql/test/SQLancer/Tests/sqlancer01.test 
b/sql/test/SQLancer/Tests/sqlancer01.test
--- a/sql/test/SQLancer/Tests/sqlancer01.test
+++ b/sql/test/SQLancer/Tests/sqlancer01.test
@@ -442,13 +442,12 @@ 0.5721433567835664
 1.58919798e+09
 0.10009920106256454
 
-statement error 42000!Argument 2 to round function must be positive
-select max(agg0) from (select max(all cast(0.18525435 as string)) as agg0 from 
t0 where cast(scale_down(- (greatest(greatest(631218936, -562663513), 
cast(-265902058 as int))), cast(0.41370374 as int)) as boolean)
-union all select all max(all cast(0.18525435 as string)) as agg0 from t0 where 
not (cast(scale_down(- (greatest(greatest(631218936, -562663513), 
cast(-265902058 as int))), cast(0.41370374 as int)) as boolean))
-union all select all max(all cast(0.18525435 as string)) as agg0 from t0 where 
(cast(scale_down(- (greatest(greatest(631218936, -562663513), cast(-265902058 
as int))), cast(0.41370374 as int)) as boolean)) is null) as asdf
-
-statement error 25005!Current transaction is aborted (please ROLLBACK)
-select scale_down(-631218936, cast(0.41370374 as int))
+query T rowsort
+select max(agg0) from (select max(all cast(0.18525435 as string)) as agg0 from 
t0 where cast(- (greatest(greatest(631218936, -562663513), cast(-265902058 as 
int))) as boolean)
+union all select all max(all cast(0.18525435 as string)) as agg0 from t0 where 
not (cast(- (greatest(greatest(631218936, -562663513), cast(-265902058 as 
int))) as boolean))
+union all select all max(all cast(0.18525435 as string)) as agg0 from t0 where 
(cast(- (greatest(greatest(631218936, -562663513), cast(-265902058 as int))) as 
boolean)) is null) as asdf
+
+0.18525435
 
 statement ok
 ROLLBACK
diff --git a/sql/test/SQLancer/Tests/sqlancer02.test 
b/sql/test/SQLancer/Tests/sqlancer02.test
--- a/sql/test/SQLancer/Tests/sqlancer02.test
+++ b/sql/test/SQLancer/Tests/sqlancer02.test
@@ -233,14 +233,6 @@ UPDATE t0 SET c2 = '' WHERE (((length('-
 statement ok
 ROLLBACK
 
-statement error 42000!types real(24,0) and boolean(1,0) are not equal
-SELECT 1 WHERE scale_up(CAST(0.89767724 AS REAL), 1)
-
-query R rowsort
-SELECT scale_up(0.2928163, 3)
-
-8784489.000
-
 statement ok
 START TRANSACTION
 
@@ -446,9 +438,8 @@ 0
 0.3672199296718357
 -1.7976931348623157e+308
 
-statement error 22003!Overflow in round
-update t2 set c1 = (scale_down(t2.c1, 
0.39861114390109142480156378951505757868289947509765625))
-where (scale_up(-1155480997, 0.5434124050282382)) is not null
+statement error 22003!overflow in calculation -1.7976931348623157e+308*10.
+update t2 set c1 = t2.c1 * 10 where 2 is not null
 
 statement ok
 ROLLBACK
diff --git a/sql/test/SQLancer/Tests/sqlancer04.test 
b/sql/test/SQLancer/Tests/sqlancer04.test
--- a/sql/test/SQLancer/Tests/sqlancer04.test
+++ b/sql/test/SQLancer/Tests/sqlancer04.test
@@ -642,7 +642,7 @@ create view v40(vc0) as (values ((true) 
 
 statement error 42000!SELECT: cannot use non GROUP BY column 'v20.vc0' in 
query results without an aggregate function
 select cast(sum(count) as bigint) from (select cast(greatest(false, true) as 
int) as count from v37 full outer join
-(select all 1074663557)%(0.8367095941704169)))%(scale_up(v20.vc0, 
0.25281408194923194))), 0.573499282341099
+(select all 1074663557)%(0.8367095941704169)))%(v20.vc0 * 
0.25281408194923194)), 0.573499282341099
 from v20 where true)or(true)))or(true)) group by 2) as sub0 on
 ((case 0.28276833606549456323620006514829583466053009033203125 when 1 then 
v37.vc0 when 1436332976 then 'FALSE'
 when 0.4573545 then v37.vc0 else 'G1hw7' end)not ilike(sql_min('46', 
v37.vc0))) inner join (select (case v3.vc0
@@ -750,7 +750,7 @@ cast(-1695180722 as bigint)))
 
 query I rowsort
 SELECT v3.vc0 FROM v3, v6 CROSS JOIN (SELECT ALL ((sign(0.9241489178039545))*
-(scale_down(0.74460343372682225027148206208948977291584014892578125, 
0.338169586

MonetDB: pushcands - Use correct index for group bat: it's align...

2022-02-21 Thread Sjoerd Mullender
Changeset: 1840d594f301 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1840d594f301
Modified Files:
gdk/gdk_group.c
Branch: pushcands
Log Message:

Use correct index for group bat: it's aligned with candidate list.


diffs (12 lines):

diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -922,7 +922,7 @@ BATgroup_internal(BAT **groups, BAT **ex
 * doled out group ids; note that we can't possibly have
 * more than 65536 goups, so the group id fits in a
 * uint16_t */
-   GRP_small_values(16, 8, (uint16_t) (w[p] | (grps[p] << 8)));
+   GRP_small_values(16, 8, (uint16_t) (w[p] | (grps[r] << 8)));
} else if (g == NULL && t == TYPE_sht) {
/* short-sized values, use 65536 entry array to keep
 * track of doled out group ids; note that we can't
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jan2022 - Use bit manipulation instead of loops.

2022-02-21 Thread Sjoerd Mullender
Changeset: 6e0fa1e53b16 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6e0fa1e53b16
Modified Files:
sql/storage/bat/bat_storage.c
Branch: Jan2022
Log Message:

Use bit manipulation instead of loops.


diffs (141 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -297,18 +297,22 @@ segments2cs(sql_trans *tr, segments *seg
if (used) {
if (lnr < (32-used))
end = used + lnr;
-   for(size_t j=used; j < end; j++, lnr--)
-   cur |= 1U< used);
+   cur |= ((1U << (end - used)) - 1) << 
used;
+   lnr -= end - used;
*dst++ |= cur;
cur = 0;
}
size_t full = lnr/32;
size_t rest = lnr%32;
-   for(size_t i = 0; i 0) {
+   memset(dst, ~0, full * sizeof(*dst));
+   dst += full;
+   lnr -= full * 32;
+   }
+   if (rest > 0) {
+   cur |= (1U << rest) - 1;
+   lnr -= rest;
*dst |= cur;
}
assert(lnr==0);
@@ -324,18 +328,22 @@ segments2cs(sql_trans *tr, segments *seg
if (used) {
if (lnr < (32-used))
end = used + lnr;
-   for(size_t j=used; j < end; j++, lnr--)
-   cur |= 1U< used);
+   cur |= ((1U << (end - used)) - 1) << 
used;
+   lnr -= end - used;
*dst++ |= cur;
cur = 0;
}
size_t full = lnr/32;
size_t rest = lnr%32;
-   for(size_t i = 0; i 0) {
+   memset(dst, ~0, full * sizeof(*dst));
+   dst += full;
+   lnr -= full * 32;
+   }
+   if (rest > 0) {
+   cur |= (1U << rest) - 1;
+   lnr -= rest;
*dst |= cur;
}
assert(lnr==0);
@@ -344,18 +352,22 @@ segments2cs(sql_trans *tr, segments *seg
if (used) {
if (lnr < (32-used))
end = used + lnr;
-   for(size_t j=used; j < end; j++, lnr--)
-   cur |= 1U< used);
+   cur |= ((1U << (end - used)) - 1) << 
used;
+   lnr -= end - used;
*dst++ &= ~cur;
cur = 0;
}
size_t full = lnr/32;
size_t rest = lnr%32;
-   for(size_t i = 0; i 0) {
+   memset(dst, 0, full * sizeof(*dst));
+   dst += full;
+   lnr -= full * 32;
+   }
+   if (rest > 0) {
+   cur |= (1U << rest) - 1;
+   lnr -= rest;
*dst &= ~cur;
}
assert(lnr==0);
@@ -4547,8 +4559,10 @@ segments2cands(storage *S, sql_trans *tr
if (used) {
if (lnr < (32-used))
end = used + lnr;
-   for(size_t j=used; j < end; j++, pos++, lnr--)
-   cur |= 1U< used);
+   cur |= ((1U << (end - used)) - 1) << used;
+   lnr -= end - used;
+   pos += end - used;
if (en

MonetDB: privfuncs - Missing errors while attempting to replace ...

2022-02-21 Thread Pedro Ferreira
Changeset: 03d3bd0645a3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/03d3bd0645a3
Modified Files:
sql/server/rel_psm.c
sql/server/rel_schema.c
Branch: privfuncs
Log Message:

Missing errors while attempting to replace system functions/views


diffs (36 lines):

diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -861,6 +861,9 @@ rel_create_func(sql_query *query, dlist 
} else if (!replace) {
list_destroy(type_list);
return sql_error(sql, 02, SQLSTATE(42000) "CREATE %s: 
name '%s' already in use", F, fname);
+   } else if (replace && !sf->func->s) {
+   list_destroy(type_list);
+   return sql_error(sql, 02, SQLSTATE(42000) "CREATE %s: 
cannot replace system function '%s'", F, fname);
}
} else {
sql->session->status = 0; /* if the function was not found 
clean the error */
@@ -871,6 +874,8 @@ rel_create_func(sql_query *query, dlist 
sql_subfunc *found = NULL;
if ((found = sql_bind_func_(sql, s->base.name, fname, 
type_list, (type == F_FUNC || type == F_FILT) ? F_AGGR : F_FUNC, true))) {
list_destroy(type_list);
+   if (found->func->private) /* cannot create a function 
using a private name or replace a existing one */
+   return sql_error(sql, 02, SQLSTATE(42000) 
"CREATE %s: name '%s' cannot be used", F, fname);
return sql_error(sql, 02, SQLSTATE(42000) "CREATE %s: 
there's %s with the name '%s' and the same parameters, which causes ambiguous 
calls", F,
 IS_AGGR(found->func) ? 
"an aggregate" : IS_FILT(found->func) ? "a filter function" : "a function", 
fname);
}
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
@@ -1420,6 +1420,10 @@ rel_create_view(sql_query *query, dlist 
if (create && (t = mvc_bind_table(sql, s, name))) {
if (!replace)
return sql_error(sql, 02, SQLSTATE(42S01) "%s: name 
'%s' already in use", base, name);
+   if (!isView(t))
+   return sql_error(sql, 02, SQLSTATE(42000) "%s: '%s' is 
not a view", base, name);
+   if (t->system)
+   return sql_error(sql, 02, SQLSTATE(42000) "%s: cannot 
replace system view '%s'", base, name);
foundid = t->base.id; /* when recreating a view, the view 
itself can't be found */
}
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: privfuncs - Merged with default

2022-02-21 Thread Pedro Ferreira
Changeset: f5c2afae23d2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f5c2afae23d2
Modified Files:
sql/server/rel_unnest.c
Branch: privfuncs
Log Message:

Merged with default


diffs (276 lines):

diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -46,7 +46,10 @@ function(monetdb_configure_defines)
   check_include_file("sys/un.h" HAVE_SYS_UN_H)
   check_include_file("sys/wait.h" HAVE_SYS_WAIT_H)
   check_include_file("unistd.h" HAVE_UNISTD_H)
-  check_include_file("uuid/uuid.h" HAVE_UUID_UUID_H)
+  cmake_push_check_state()
+set(CMAKE_REQUIRED_INCLUDES 
"${CMAKE_REQUIRED_INCLUDES};${UUID_INCLUDE_DIR}")
+check_include_file("uuid/uuid.h" HAVE_UUID_UUID_H)
+  cmake_pop_check_state()
   check_include_file("winsock2.h" HAVE_WINSOCK_H)
 
   find_library(GETOPT_LIB "getopt.lib")
diff --git a/gdk/CMakeLists.txt b/gdk/CMakeLists.txt
--- a/gdk/CMakeLists.txt
+++ b/gdk/CMakeLists.txt
@@ -89,6 +89,7 @@ target_sources(bat
 
 target_include_directories(bat
   PUBLIC
+  
$<$:$>
   $
   $
   $
@@ -105,6 +106,7 @@ target_link_libraries(bat
   mutils
   $<$>:m>
   $<$:ws2_32>
+  $<$:UUID::UUID>
   $<$:KVM::KVM>
   ${CMAKE_DL_LIBS}
   Threads::Threads)
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -487,12 +487,12 @@ renderProfilerEvent(Client cntxt, MalBlk
  * We should use an OS define to react to the maximal cores
  */
 
-#define MAXCPU 256
-#define LASTCPU(MAXCPU - 1)
+#define MAXCORES   256
+#define LASTCPU(MAXCORES - 1)
 static struct{
lng user, nice, system, idle, iowait;
double load;
-} corestat[MAXCPU];
+} corestat[MAXCORES];
 
 static int
 getCPULoad(char cpuload[BUFSIZ]){
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -1559,6 +1559,13 @@ rel_unnest_dependent(mvc *sql, sql_rel *
rel->r = l;
rel->op = op_left;
return rel_unnest_dependent(sql, rel);
+   } else if (rel->op == op_left && 
!rel_has_freevar(sql, rel->r) && rel_dependent_var(sql, rel->r, rel->l)) {
+   sql_rel *l = rel->l;
+
+   rel->l = rel->r;
+   rel->r = l;
+   rel->op = op_right;
+   return rel_unnest_dependent(sql, rel);
}
}
}
@@ -1744,7 +1751,13 @@ rewrite_inner(mvc *sql, sql_rel *rel, sq
op = op_left;
 
if (is_join(rel->op)){
-   if (is_right(rel->op))
+   if (rel_has_freevar(sql, inner)) {
+   list *rv = rel_dependent_var(sql, rel->r, inner);
+   if (!list_empty(rv))
+   d = rel->r = rel_crossproduct(sql->sa, rel->r, 
inner, op);
+   else
+   d = rel->l = rel_crossproduct(sql->sa, rel->l, 
inner, op);
+   } else if (is_right(rel->op))
d = rel->l = rel_crossproduct(sql->sa, rel->l, inner, 
op);
else
d = rel->r = rel_crossproduct(sql->sa, rel->r, inner, 
op);
@@ -2246,24 +2259,6 @@ rewrite_aggregates(visitor *v, sql_rel *
return rel;
 }
 
-static sql_exp*
-has_or(visitor *v, sql_rel *rel, sql_exp *e, int depth)
-{
-   (void)rel;
-   (void)depth;
-   if(!v->data && e && is_compare(e->type) && e->flag == cmp_or)
-   v->data = e;
-   return e;
-}
-
-static bool
-exps_have_or_exp(mvc *sql, list *exps)
-{
-   visitor v = { .sql = sql, .data = NULL };
-   exps_exp_visitor_topdown(&v, NULL, exps, 0, &has_or, true);
-   return v.data != NULL;
-}
-
 static inline sql_rel *
 rewrite_split_select_exps(visitor *v, sql_rel *rel)
 {
@@ -2740,10 +2735,8 @@ rewrite_anyequal(visitor *v, sql_rel *re
join = 
(is_full(rel->op)||is_left(rel->op))?rel->r:rel->l;
}
if (rsq) {
-   sql_rel *rewrite = NULL;
-   (void)rewrite_inner(sql, rel, rsq, 
op_left, &rewrite);
-   exp_reset_props(rewrite, re, 
is_left(rewrite->op));
-   join = 
(is_full(rel->op)||is_left(rel->op))?rel->r:rel->l;
+   (void)rewrite_inner(sql, rel, rsq, 
op_left, &join);
+   exp_reset_props(join, re, 
is_left(join->op));
}
 

MonetDB: privfuncs - Added private functions related errors

2022-02-21 Thread Pedro Ferreira
Changeset: 62a0c16e74a0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/62a0c16e74a0
Modified Files:
sql/test/miscellaneous/Tests/simple_selects.test
Branch: privfuncs
Log Message:

Added private functions related errors


diffs (22 lines):

diff --git a/sql/test/miscellaneous/Tests/simple_selects.test 
b/sql/test/miscellaneous/Tests/simple_selects.test
--- a/sql/test/miscellaneous/Tests/simple_selects.test
+++ b/sql/test/miscellaneous/Tests/simple_selects.test
@@ -896,3 +896,18 @@ 1
 statement ok
 drop function dosomething
 
+# some private functions related errors
+statement error 42000!SELECT: no such binary operator 
'scale_up'(decimal,tinyint)
+select scale_up(12.1, 10)
+
+statement error 42000!SELECT: no such unary operator 'sql_exists'(tinyint)
+select sql_exists(1)
+
+statement error 42000!CREATE FUNCTION: name 'scale_down' cannot be used
+create function scale_down(x decimal(8,2), y int) returns decimal(8,2) return 1
+
+statement error 42000!CREATE FUNCTION: name 'scale_down' cannot be used
+create or replace function scale_down(x decimal(8,2), y int) returns 
decimal(8,2) return 1
+
+statement error 42000!DROP FUNCTION: no such function 'any' (boolean, boolean, 
boolean)
+drop function "any"(boolean, boolean, boolean)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Some more corner error cases (Also important)

2022-02-21 Thread Pedro Ferreira
Changeset: 558de659db8e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/558de659db8e
Modified Files:
sql/test/SQLancer/Tests/sqlancer22.test
Branch: default
Log Message:

Some more corner error cases (Also important)


diffs (22 lines):

diff --git a/sql/test/SQLancer/Tests/sqlancer22.test 
b/sql/test/SQLancer/Tests/sqlancer22.test
--- a/sql/test/SQLancer/Tests/sqlancer22.test
+++ b/sql/test/SQLancer/Tests/sqlancer22.test
@@ -757,6 +757,18 @@ SELECT y.y FROM (SELECT 1) x(x), (SELECT
 statement error 42000!SELECT: cannot use non GROUP BY column 'y.y' in query 
results without an aggregate function
 SELECT ntile(y.y) over () FROM (SELECT 1) x(x), (SELECT 1) y(y) order by 
min(x.x)
 
+statement error 42000!SELECT: cannot use non GROUP BY column 'x.y' in query 
results without an aggregate function
+SELECT x.y, EXISTS (SELECT MIN(x.x)) FROM (SELECT 1, 2) x(x,y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'x.y' in query 
results without an aggregate function
+SELECT x.y, (SELECT MIN(x.x)) FROM (SELECT 1, 2) x(x,y)
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'x.y' in query 
results without an aggregate function
+SELECT (SELECT MIN(x.x)) FROM (SELECT 1, 2) x(x,y) ORDER BY x.y
+
+statement error 42000!SELECT: cannot use non GROUP BY column 'x.y' in query 
results without an aggregate function
+SELECT x.y, MIN(x.x + x.y) FROM (SELECT 1, 2) x(x,y)
+
 query I nosort
 SELECT ['1'] "like" [max(x.x), '', false] FROM (SELECT '1') x(x), (SELECT '1') 
y(y)
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: properties - Merged with default

2022-02-21 Thread Pedro Ferreira
Changeset: f294289175c3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f294289175c3
Modified Files:
gdk/gdk.h
gdk/gdk_batop.c
gdk/gdk_bbp.c
gdk/gdk_private.h
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
sql/server/rel_exp.c
sql/server/rel_exp.h
sql/server/rel_optimizer.c
sql/server/rel_rel.c
sql/server/rel_schema.c
sql/server/rel_select.c
sql/server/rel_updates.c
sql/storage/store.c
sql/test/SQLancer/Tests/sqlancer19.SQL.py
tools/monetdbe/monetdbe.c
Branch: properties
Log Message:

Merged with default


diffs (truncated from 159060 to 300 lines):

diff --git a/README.rst b/README.rst
--- a/README.rst
+++ b/README.rst
@@ -109,8 +109,7 @@ The following packages are optional:
 ``unixODBC-devel``, ``valgrind-devel``.
 
 On Ubuntu and Debian the following packages are required:
-``bison``, ``cmake``, ``gcc``, ``libssl-dev``, ``pkg-config``,
-``python3``.
+``bison``, ``cmake``, ``gcc``, ``pkg-config``, ``python3``.
 
 The following packages are optional but recommended:
 ``libbz2-dev``, ``uuid-dev``, ``libpcre3-dev``, ``libreadline-dev``,
diff --git a/clients/ChangeLog.Jan2022 b/clients/ChangeLog.Jan2022
--- a/clients/ChangeLog.Jan2022
+++ b/clients/ChangeLog.Jan2022
@@ -1,3 +1,10 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Wed Feb 16 2022 Sjoerd Mullender 
+- Improved the handling of the \r command in mclient.  It now properly
+  counts the header of table, and when a (very) long table is being
+  printed and aborted part way in the built-in pager, not all data is
+  transferred to the client (and then discarded).  Instead at most 1000
+  rows are transferred.
+
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1447,6 +1447,7 @@ char *monetdbe_error(monetdbe_database d
 char *monetdbe_execute(monetdbe_statement *stmt, monetdbe_result **result, 
monetdbe_cnt *affected_rows);
 char *monetdbe_get_autocommit(monetdbe_database dbhdl, int *result);
 char *monetdbe_get_columns(monetdbe_database dbhdl, const char *schema_name, 
const char *table_name, size_t *column_count, monetdbe_column **columns);
+const char *monetdbe_get_mapi_port(void);
 int monetdbe_in_transaction(monetdbe_database dbhdl);
 const void *monetdbe_null(monetdbe_database dbhdl, monetdbe_types t);
 int monetdbe_open(monetdbe_database *db, char *url, monetdbe_options *opts);
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1320,9 +1320,10 @@ RAWrenderer(MapiHdl hdl)
}
 }
 
-static void
+static int
 SQLheader(MapiHdl hdl, int *len, int fields, char more)
 {
+   int rows = 1;   /* start with the separator row 
*/
SQLseparator(len, fields, '-');
if (mapi_get_name(hdl, 0)) {
int i;
@@ -1339,11 +1340,13 @@ SQLheader(MapiHdl hdl, int *len, int fie
names[i] = mapi_get_name(hdl, i);
numeric[i] = 0;
}
-   SQLrow(len, numeric, names, fields, 1, more);
+   rows += SQLrow(len, numeric, names, fields, 1, more);
+   rows++; /* add a separator row 
*/
SQLseparator(len, fields, '=');
free(names);
free(numeric);
}
+   return rows;
 }
 
 static void
@@ -1560,7 +1563,7 @@ SQLrenderer(MapiHdl hdl)
break;
}
 
-   SQLheader(hdl, len, printfields, fields != printfields);
+   rows = SQLheader(hdl, len, printfields, fields != printfields);
 
while ((rfields = fetch_row(hdl)) != 0) {
if (mnstr_errnr(toConsole))
@@ -1603,8 +1606,10 @@ SQLrenderer(MapiHdl hdl)
if (ps > 0 && rows >= ps && fromConsole != NULL) {
SQLpagemove(len, printfields, &ps, &silent);
rows = 0;
-   if (silent)
-   continue;
+   if (silent) {
+   mapi_finish(hdl);
+   break;
+   }
}
 
rows += SQLrow(len, numeric, rest, printfields, 2, 0);
@@ -3502,7 +3507,7 @@ main(int argc, char **argv)
exit(2);
}
 
-   mapi_cache_limit(mid, -1);
+   mapi_cache_limit(mid, 1000);
mapi_setAutocommit(mid, autocommit);
if (mode == SQL && !settz)
mapi_set_time_zone(mid, 0);
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -3591,7 +3591,6 @@ mapi_param_store(MapiHdl hdl)
free(val);