MonetDB: unlock - merged with default
Changeset: cfe944b8521f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cfe944b8521f Added Files: sql/test/miscellaneous/Tests/create_func_temp.sql sql/test/miscellaneous/Tests/create_func_temp.stable.err sql/test/miscellaneous/Tests/create_func_temp.stable.out Modified Files: clients/examples/perl/sqlsample.pl clients/odbc/driver/ODBCConvert.c clients/odbc/driver/ODBCUtil.c clients/odbc/driver/SQLPrepare.c common/utils/mstring.h gdk/gdk.h gdk/gdk_analytic.h gdk/gdk_utils.c geom/lib/libgeom.c geom/monetdb5/geom.c monetdb5/modules/kernel/status.c monetdb5/modules/mal/mal_io.c sql/backends/monet5/rel_bin.c sql/server/rel_psm.c sql/server/rel_rel.c sql/server/rel_select.c sql/server/rel_unnest.c sql/server/rel_unnest.h sql/server/sql_mvc.c sql/server/sql_scan.c sql/server/sql_scan.h sql/storage/store.c sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.out sql/test/BugTracker-2014/Tests/copy-into.Bug-3481.SQL.py sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.sql sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.stable.err sql/test/BugTracker-2014/Tests/utf8bom.Bug-3436.SQL.py sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.sql sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.stable.out sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.stable.out.int128 sql/test/BugTracker-2017/Tests/error-clean-cache.Bug-6351.sql sql/test/BugTracker-2017/Tests/error-clean-cache.Bug-6351.stable.err sql/test/BugTracker-2017/Tests/error-clean-cache.Bug-6351.stable.out sql/test/BugTracker-2019/Tests/copy-into-from-stdin-empty-line.Bug-6669.sql sql/test/BugTracker-2019/Tests/insert-into-select.Bug-6718.sql sql/test/BugTracker-2019/Tests/python-loader-string.Bug-6759.py sql/test/Tests/hot-snapshot.py sql/test/Tests/session_vars.sql sql/test/Tests/session_vars.stable.err sql/test/Tests/session_vars.stable.out sql/test/Tests/unicode.sql sql/test/Tests/unicode.stable.out sql/test/Users/Tests/copyinto.SQL.py sql/test/Users/Tests/copyinto.stable.err sql/test/mapi/Tests/perl_dbi.stable.out sql/test/miscellaneous/Tests/All sql/test/miscellaneous/Tests/declared_tables.sql sql/test/miscellaneous/Tests/declared_tables.stable.err sql/test/pg_regress/Tests/timestamp.sql sql/test/pg_regress/Tests/timestamptz.sql sql/test/ssqq/Tests/insert_query.stable.err sql/test/ssqq/Tests/insert_query.stable.out sql/test/ssqq/Tests/insert_queue.stable.err sql/test/ssqq/Tests/insert_queue.stable.out sql/test/ssqq/Tests/insert_quser.stable.err sql/test/ssqq/Tests/insert_quser.stable.out sql/test/subquery/Tests/subquery3.stable.err sql/test/subquery/Tests/subquery5.sql sql/test/subquery/Tests/subquery5.stable.err sql/test/subquery/Tests/subquery5.stable.out testing/difflib.c tools/merovingian/utils/utils.c Branch: unlock Log Message: merged with default diffs (truncated from 2683 to 300 lines): diff --git a/clients/examples/perl/sqlsample.pl b/clients/examples/perl/sqlsample.pl --- a/clients/examples/perl/sqlsample.pl +++ b/clients/examples/perl/sqlsample.pl @@ -48,6 +48,9 @@ my $dbh = DBI->connect( $dsn, $sth->bind_param( 1, 7 , DBI::SQL_INTEGER() ); $sth->bind_param( 2,'seven' ); $sth->execute; + $sth->bind_param( 1,42 , DBI::SQL_INTEGER() ); + $sth->bind_param( 2, '\\n' ); + $sth->execute; } { my $sth = $dbh->prepare('select * from perl_table;'); diff --git a/clients/odbc/driver/ODBCConvert.c b/clients/odbc/driver/ODBCConvert.c --- a/clients/odbc/driver/ODBCConvert.c +++ b/clients/odbc/driver/ODBCConvert.c @@ -3197,6 +3197,7 @@ ODBCStore(ODBCStmt *stmt, case SQL_WCHAR: case SQL_WVARCHAR: case SQL_WLONGVARCHAR: + assign(buf, bufpos, buflen, 'r', stmt); /* RAW string */ assign(buf, bufpos, buflen, '\'', stmt); switch (ctype) { case SQL_C_CHAR: @@ -3205,22 +3206,11 @@ ODBCStore(ODBCStmt *stmt, for (i = 0; i < slen; i++) { unsigned char c = (unsigned char) sval[i]; - if (c == 0) { + if (c == 0) break; - } else if (c < 0x20 /* || c >= 0x7F */) { - assign(buf, bufpos, buflen, '\\', stmt); - assign(buf, bufp
MonetDB: unlock - initial steps for a new storage layer
Changeset: 8395e5ba9aa2 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8395e5ba9aa2 Added Files: gdk/gdk_logger_old.c Modified Files: gdk/Makefile.ag gdk/gdk_logger.c gdk/gdk_logger.h gdk/gdk_logger_internals.h geom/monetdb5/geom.c geom/monetdb5/geom.h geom/monetdb5/geom_upgrade.c monetdb5/mal/mal_runtime.c sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_gencode.h sql/backends/monet5/sql_scenario.c sql/common/sql_backend.c sql/common/sql_backend.h sql/common/sql_types.c sql/server/sql_mvc.c sql/storage/bat/bat_logger.c sql/storage/bat/bat_storage.c sql/storage/sql_storage.h sql/storage/store.c Branch: unlock Log Message: initial steps for a new storage layer all tables will be stored directly (no more insert bats) the deletes will be bit-typed, ie equaly long as the normal columns this step is the rewrite of the logger (part of it), the logger is now fully based on object id's. No strings other than data are stored. The log it self is re-read (or skipped) by the logmanager. And simplified to the bare minimum (start,end transaction, update/bulk, create/destroy bat, clear and sequence numbers). Todo compressed single row and skipping/or fast read (needs change of the atom api). And Local d* bats need to be converted from oid into bits. diffs (truncated from 8290 to 300 lines): diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag --- a/gdk/Makefile.ag +++ b/gdk/Makefile.ag @@ -23,7 +23,7 @@ lib_gdk = { gdk_group.c \ gdk_join.c \ gdk_firstn.c \ - gdk_logger.c gdk_logger.h gdk_logger_internals.h \ + gdk_logger.c gdk_logger.h gdk_logger_internals.h gdk_logger_old.c \ gdk_batop.c \ gdk_bat.c \ gdk_hash.c gdk_hash.h \ diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -6,53 +6,6 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -/* - * (author) N. J. Nes - * - * In the philosophy of MonetDB, transaction management overhead - * should only be paid when necessary. Transaction management is for - * this purpose implemented as a separate module and applications are - * required to obey the transaction policy, e.g. obtaining/releasing - * locks. - * - * This module is designed to support efficient logging of the SQL - * database. Once loaded, the SQL compiler will insert the proper - * calls at transaction commit to include the changes in the log file. - * - * The logger uses a directory to store its log files. One master log - * file stores information about the version of the logger and the - * transaction log files. This file is a simple ascii file with the - * following format: - * {6DIGIT-VERSION\n[log file number \n]*]*} - * The transaction log files have a binary format, which stores fixed - * size logformat headers (flag,nr,bid), where the flag is the type of - * update logged. The nr field indicates how many changes there were - * (in case of inserts/deletes). The bid stores the bid identifier. - * - * The key decision to be made by the user is the location of the log - * file. Ideally, it should be stored in fail-safe environment, or at - * least the log and databases should be on separate disk columns. - * - * This file system may reside on the same hardware as the database - * server and therefore the writes are done to the same disk, but - * could also reside on another system and then the changes are - * flushed through the network. The logger works under the assumption - * that it is called to safeguard updates on the database when it has - * an exclusive lock on the latest version. This lock should be - * guaranteed by the calling transaction manager first. - * - * Finding the updates applied to a BAT is relatively easy, because - * each BAT contains a delta structure. On commit these changes are - * written to the log file and the delta management is reset. Since - * each commit is written to the same log file, the beginning and end - * are marked by a log identifier. - * - * A server restart should only (re)process blocks which are - * completely written to disk. A log replay therefore ends in a commit - * or abort on the changed bats. Once all logs have been read, the - * changes to the bats are made persistent, i.e. a bbp sub-commit is - * done. - */ #include "monetdb_config.h" #include "gdk.h" #include "gdk_private.h" @@ -60,29 +13,26 @@ #include "gdk_logger_internals.h" #include +static gdk_return logger_add_bat(logger *lg, BAT *b, log_id id); +static gdk_return logger_del_bat(logger *lg, log_bid bid); /* - * The log record encoding is geared at reduced storage space, but at - * the expense of readability. A user can not easily inspect the log a - * posteriori to check what has happened. - * + *
MonetDB: Jun2020 - Defensive lines, if exp_exist fails, return
Changeset: 08f95b894652 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=08f95b894652 Modified Files: sql/server/rel_select.c sql/server/rel_unnest.c Branch: Jun2020 Log Message: Defensive lines, if exp_exist fails, return diffs (48 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -2034,11 +2034,10 @@ rel_exists_value_exp(sql_query *query, s le = rel_value_exp(query, rel, sc->data.sym, f, ek); if (!le) return NULL; - e = exp_exist(query, rel ? *rel : NULL, le, sc->token == SQL_EXISTS); - if (e) { - /* only freevar should have CARD_AGGR */ - e->card = CARD_ATOM; - } + if (!(e = exp_exist(query, rel ? *rel : NULL, le, sc->token == SQL_EXISTS))) + return NULL; + /* only freevar should have CARD_AGGR */ + e->card = CARD_ATOM; return e; } @@ -2057,11 +2056,10 @@ rel_exists_exp(sql_query *query, sql_rel assert(!is_sql_sel(f)); if (sq) { sql_exp *e = exp_rel(sql, sq); - e = exp_exist(query, rel, e, sc->token == SQL_EXISTS); - if (e) { - /* only freevar should have CARD_AGGR */ - e->card = CARD_ATOM; - } + if (!(e = exp_exist(query, rel, e, sc->token == SQL_EXISTS))) + return NULL; + /* only freevar should have CARD_AGGR */ + e->card = CARD_ATOM; rel = rel_select_add_exp(sql->sa, rel, e); return rel; } 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 @@ -2479,7 +2479,8 @@ rewrite_exists(mvc *sql, sql_rel *rel, s return NULL; if (is_project(rel->op) && rel_has_freevar(sql, sq)) - le = exp_exist(sql, le, ne, is_exists(sf)); + if (!(le = exp_exist(sql, le, ne, is_exists(sf + return NULL; if (exp_name(e)) exp_prop_alias(sql->sa, le, e); } else { /* rewrite into semi/anti join */ ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - If calculating the supertype of a list of val...
Changeset: 7b22d96b8acf for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7b22d96b8acf Modified Files: sql/server/rel_select.c Branch: Jun2020 Log Message: If calculating the supertype of a list of values gives an error, return immediately diffs (43 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -904,7 +904,8 @@ rel_values(sql_query *query, symbol *tab } /* loop to check types */ for (m = exps->h; m; m = m->next) - m->data = exp_values_set_supertype(sql, (sql_exp*) m->data); + if (!(m->data = exp_values_set_supertype(sql, (sql_exp*) m->data))) + return NULL; r = rel_project(sql->sa, NULL, exps); r->nrcols = list_length(exps); @@ -2106,7 +2107,7 @@ rel_in_value_exp(sql_query *query, sql_r /* list of values or subqueries */ if (n->type == type_list) { sql_exp *values; - list *vals = sa_list(sql->sa); + list *vals = sa_list(sql->sa), *nvalues; n = dl->h->next; n = n->data.lval->h; @@ -2131,14 +2132,15 @@ rel_in_value_exp(sql_query *query, sql_r values = exp_values(sql->sa, vals); exp_label(sql->sa, values, ++sql->label); - if (is_tuple) { - values = exp_tuples_set_supertype(sql, exp_get_values(le), values); - list *nvalues = tuples_check_types(sql, exp_get_values(le), values); - if (!nvalues) + if (is_tuple) { + if (!(values = exp_tuples_set_supertype(sql, exp_get_values(le), values))) + return NULL; + if (!(nvalues = tuples_check_types(sql, exp_get_values(le), values))) return NULL; le->f = nvalues; } else { /* if it's not a tuple, enforce coersion on the type for every element on the list */ - values = exp_values_set_supertype(sql, values); + if (!(values = exp_values_set_supertype(sql, values))) + return NULL; if (rel_binop_check_types(sql, rel ? *rel : NULL, le, values, 0) < 0) return NULL; } ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Added missing "sql_join" properties
Changeset: 7834a2592315 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7834a2592315 Modified Files: sql/server/rel_select.c Branch: Jun2020 Log Message: Added missing "sql_join" properties diffs (23 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -5828,8 +5828,8 @@ rel_joinquery_(sql_query *query, sql_rel for (; n; n = n->next) { char *nm = n->data.sval; sql_exp *cond; - sql_exp *ls = rel_bind_column(sql, t1, nm, sql_where, 0); - sql_exp *rs = rel_bind_column(sql, t2, nm, sql_where, 0); + sql_exp *ls = rel_bind_column(sql, t1, nm, sql_where | sql_join, 0); + sql_exp *rs = rel_bind_column(sql, t2, nm, sql_where | sql_join, 0); if (!ls || !rs) return sql_error(sql, 02, SQLSTATE(42000) "JOIN: tables '%s' and '%s' do not have a matching column '%s'", rel_name(t1)?rel_name(t1):"", rel_name(t2)?rel_name(t2):"", nm); @@ -5955,7 +5955,7 @@ rel_unionjoinquery(sql_query *query, sql rexps = new_exp_list(sql->sa); for (m = lexps->h; m; m = m->next) { sql_exp *le = m->data; - sql_exp *rc = rel_bind_column(sql, rv, exp_name(le), sql_where, 0); + sql_exp *rc = rel_bind_column(sql, rv, exp_name(le), sql_where | sql_join, 0); if (!rc && all) break; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Small bugfix, when attempting to perform a na...
Changeset: 37c862d04e0f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=37c862d04e0f Modified Files: sql/server/rel_select.c sql/test/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.err Branch: Jun2020 Log Message: Small bugfix, when attempting to perform a natural outer join on two non comparable columns (eg interval and boolean), te server would crash, because it was not checked the result of rel_compare diffs (96 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -1890,9 +1890,8 @@ rel_compare(sql_query *query, sql_rel *r ls = rel_value_exp(query, &rel, lo, f, ek); if (!ls) return NULL; - if (ls && rel && exp_has_freevar(sql, ls) && (is_sql_sel(f) || is_sql_having(f))) { + if (ls && rel && exp_has_freevar(sql, ls) && (is_sql_sel(f) || is_sql_having(f))) ls = rel_project_add_exp(sql, rel, ls); - } if (quantifier) ek.card = card_set; @@ -5467,7 +5466,8 @@ join_on_column_name(sql_query *query, sq if (re) { found = 1; - rel = rel_compare_exp(query, rel, le, re, "=", NULL, TRUE, 0, 0); + if (!(rel = rel_compare_exp(query, rel, le, re, "=", NULL, TRUE, 0, 0))) + return NULL; if (full) { sql_exp *cond = rel_unop_(sql, rel, le, NULL, "isnull", card_value); set_has_no_nil(cond); @@ -5482,11 +5482,8 @@ join_on_column_name(sql_query *query, sq append(outexps, le); } } - if (!found) { - sql_error(sql, 02, SQLSTATE(42000) "JOIN: no columns of tables '%s' and '%s' match", rel_name(t1)?rel_name(t1):"", rel_name(t2)?rel_name(t2):""); - rel_destroy(rel); - return NULL; - } + if (!found) + return sql_error(sql, 02, SQLSTATE(42000) "JOIN: no columns of tables '%s' and '%s' match", rel_name(t1)?rel_name(t1):"", rel_name(t2)?rel_name(t2):""); for (n = r_exps->h; n; n = n->next) { sql_exp *re = n->data; if (r_nil) @@ -5806,12 +5803,8 @@ rel_joinquery_(sql_query *query, sql_rel if (!t1 || !t2) return NULL; - if (!lateral && rel_name(t1) && rel_name(t2) && strcmp(rel_name(t1), rel_name(t2)) == 0) { - sql_error(sql, 02, SQLSTATE(42000) "SELECT: '%s' on both sides of the JOIN expression", rel_name(t1)); - rel_destroy(t1); - rel_destroy(t2); - return NULL; - } + if (!lateral && rel_name(t1) && rel_name(t2) && strcmp(rel_name(t1), rel_name(t2)) == 0) + return sql_error(sql, 02, SQLSTATE(42000) "SELECT: '%s' on both sides of the JOIN expression", rel_name(t1)); inner = rel = rel_crossproduct(sql->sa, t1, t2, op_join); inner->op = op; @@ -5838,12 +5831,10 @@ rel_joinquery_(sql_query *query, sql_rel sql_exp *ls = rel_bind_column(sql, t1, nm, sql_where, 0); sql_exp *rs = rel_bind_column(sql, t2, nm, sql_where, 0); - if (!ls || !rs) { - sql_error(sql, 02, SQLSTATE(42000) "JOIN: tables '%s' and '%s' do not have a matching column '%s'", rel_name(t1)?rel_name(t1):"", rel_name(t2)?rel_name(t2):"", nm); - rel_destroy(rel); + if (!ls || !rs) + return sql_error(sql, 02, SQLSTATE(42000) "JOIN: tables '%s' and '%s' do not have a matching column '%s'", rel_name(t1)?rel_name(t1):"", rel_name(t2)?rel_name(t2):"", nm); + if (!(rel = rel_compare_exp(query, rel, ls, rs, "=", NULL, TRUE, 0, 0))) return NULL; - } - rel = rel_compare_exp(query, rel, ls, rs, "=", NULL, TRUE, 0, 0); if (op != op_join) { cond = rel_unop_(sql, rel, ls, NULL, "isnull", card_value); set_has_no_nil(cond); 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 @@ -139,3 +139,9 @@ SELECT 1, 2 INTO myvar; --error, number declare table x (a int); declare table x (c int); --error table x already declared drop table if exists x; + +create table myx (a boolean); +create table myy (a interval second); +select * from myx natural full outer join myy; --error, types boolean(1,0) and sec_interval(13,0) are not equal +drop table myx; +drop table myy; diff --git a/sql/test/miscellaneous
MonetDB: Jun2020 - Allow correlations on with and values clauses...
Changeset: efa6a2d5acbb for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=efa6a2d5acbb Modified Files: sql/server/rel_select.c sql/test/subquery/Tests/subquery5.sql sql/test/subquery/Tests/subquery5.stable.err sql/test/subquery/Tests/subquery5.stable.out Branch: Jun2020 Log Message: Allow correlations on with and values clauses when used as subqueries diffs (108 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -5141,18 +5141,18 @@ rel_value_exp2(sql_query *query, sql_rel if (is_psm_call(f)) return sql_error(sql, 02, SQLSTATE(42000) "CALL: subqueries not allowed inside CALL statements"); + if (rel && *rel) + query_push_outer(query, *rel, f); if (se->token == SQL_WITH) { r = rel_with_query(query, se); } else if (se->token == SQL_VALUES) { r = rel_values(query, se); } else { assert(se->token == SQL_SELECT); - if (rel && *rel) - query_push_outer(query, *rel, f); r = rel_subquery(query, NULL, se, ek); - if (rel && *rel) - *rel = query_pop_outer(query); - } + } + if (rel && *rel) + *rel = query_pop_outer(query); if (!r) return NULL; if (ek.type == type_value && ek.card <= card_set && is_project(r->op) && list_length(r->exps) > 1) diff --git a/sql/test/subquery/Tests/subquery5.sql b/sql/test/subquery/Tests/subquery5.sql --- a/sql/test/subquery/Tests/subquery5.sql +++ b/sql/test/subquery/Tests/subquery5.sql @@ -120,6 +120,25 @@ SELECT (SELECT CAST(SUM(col2 - 1) AS BIG SELECT (SELECT CAST(SUM(col2 + 1) AS BIGINT) GROUP BY SUM(col2 + 1)) FROM another_t; -- 1238 +SELECT (WITH a AS (SELECT col1) SELECT a.col1 FROM a) FROM another_t; + -- 1 + -- 11 + -- 111 + -- + +SELECT (VALUES(col1)) FROM another_t; + -- 1 + -- 11 + -- 111 + -- + +SELECT CAST((VALUES(SUM(col1 + col2))) AS BIGINT) FROM another_t; + -- 3702 + +SELECT (VALUES(col1, col2)) FROM another_t; --error, subquery must return only one column + +SELECT (VALUES(col1), (col2)) FROM another_t; --error, more than one row returned by a subquery used as an expression + DROP FUNCTION evilfunction(INT); DROP TABLE tbl_ProductSales; DROP TABLE another_T; diff --git a/sql/test/subquery/Tests/subquery5.stable.err b/sql/test/subquery/Tests/subquery5.stable.err --- a/sql/test/subquery/Tests/subquery5.stable.err +++ b/sql/test/subquery/Tests/subquery5.stable.err @@ -110,6 +110,14 @@ MAPI = (monetdb) /var/tmp/mtest-92118/. QUERY = SELECT (SELECT SUM(SUM(t2.col1)) FROM another_t t2) FROM another_t t1; --error, aggregate function calls cannot be nested ERROR = !SUM: aggregate functions cannot be nested CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-577635/.s.monetdb.34590 +QUERY = SELECT (VALUES(col1, col2)) FROM another_t; --error, subquery must return only one column +ERROR = !SELECT: subquery must return only one column +CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-577635/.s.monetdb.34590 +QUERY = SELECT (VALUES(col1), (col2)) FROM another_t; --error, more than one row returned by a subquery used as an expression +ERROR = !Cardinality violation, scalar value expected +CODE = 21000 # 08:41:39 > # 08:41:39 > "Done." diff --git a/sql/test/subquery/Tests/subquery5.stable.out b/sql/test/subquery/Tests/subquery5.stable.out --- a/sql/test/subquery/Tests/subquery5.stable.out +++ b/sql/test/subquery/Tests/subquery5.stable.out @@ -130,6 +130,30 @@ stdout of test 'subquery5` in directory % bigint # type % 4 # length [ 2472 ] +#SELECT (WITH a AS (SELECT col1) SELECT a.col1 FROM a) FROM another_t; +% .%1 # table_name +% %1 # name +% int # type +% 4 # length +[ 1] +[ 11 ] +[ 111 ] +[ ] +#SELECT (VALUES(col1)) FROM another_t; +% .%1 # table_name +% %1 # name +% int # type +% 4 # length +[ 1] +[ 11 ] +[ 111 ] +[ ] +#SELECT CAST((VALUES(SUM(col1 + col2))) AS BIGINT) FROM another_t; +% .%1 # table_name +% %1 # name +% bigint # type +% 4 # length +[ 3702 ] #DROP FUNCTION evilfunction(INT); #DROP TABLE tbl_ProductSales; #DROP TABLE another_T; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: scoping - Updated sql_alter_table according to scoping ...
Changeset: 42bbfb274155 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=42bbfb274155 Modified Files: sql/server/rel_schema.c Branch: scoping Log Message: Updated sql_alter_table according to scoping rules diffs (truncated from 363 to 300 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 @@ -1430,189 +1430,194 @@ sql_alter_table(sql_query *query, dlist char *sname = qname_schema(qname); char *tname = qname_schema_object(qname); sql_schema *s = cur_schema(sql); - sql_table *t = NULL; + sql_table *t = NULL, *nt = NULL; + sql_rel *res = NULL, *r; + sql_exp **updates, *e; if (sname && !(s = mvc_bind_schema(sql, sname))) { if (if_exists) return rel_psm_block(sql->sa, new_exp_list(sql->sa)); return sql_error(sql, 02, SQLSTATE(3F000) "ALTER TABLE: no such schema '%s'", sname); } - - if ((t = mvc_bind_table(sql, s, tname)) == NULL) { - if (mvc_bind_table(sql, tmp_schema(sql), tname) != NULL) - return sql_error(sql, 02, SQLSTATE(42S02) "ALTER TABLE: not supported on TEMPORARY table '%s'", tname); + if (!sname) + t = stack_find_table(sql, tname); + if (!t) + t = mvc_bind_table(sql, s, tname); + if (!t) { if (if_exists) return rel_psm_block(sql->sa, new_exp_list(sql->sa)); return sql_error(sql, 02, SQLSTATE(42S02) "ALTER TABLE: no such table '%s' in schema '%s'", tname, s->base.name); - } else { - sql_rel *res = NULL, *r; - sql_table *nt = NULL; - sql_exp **updates, *e; + } + + if (isDeclaredTable(t)) + return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE: can't alter declared table '%s'", tname); + if (isTempSchema(t->s)) + return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE: can't alter temporary table '%s'", tname); + + assert(te); + if (t->persistence != SQL_DECLARED_TABLE) + sname = s->base.name; + + if ((te->token == SQL_TABLE || te->token == SQL_DROP_TABLE)) { + dlist *nqname = te->data.lval->h->data.lval; + sql_schema *spt = NULL; + sql_table *pt = NULL; + char *nsname = qname_schema(nqname); + char *ntname = qname_schema_object(nqname); + + /* partition sname */ + if (!nsname) + nsname = sname; + + if (nsname && !(spt = mvc_bind_schema(sql, nsname))) + return sql_error(sql, 02, SQLSTATE(3F000) "ALTER TABLE: no such schema '%s'", sname); + if (!nsname) + pt = stack_find_table(sql, ntname); + if (!pt && !(pt = mvc_bind_table(sql, spt, ntname))) + return sql_error(sql, 02, SQLSTATE(42S02) "ALTER TABLE: no such table '%s' in schema '%s'", ntname, spt->base.name); - assert(te); - if (t->persistence != SQL_DECLARED_TABLE) - sname = s->base.name; + if (isView(pt)) + return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE: can't add/drop a view into a %s", + TABLE_TYPE_DESCRIPTION(t->type, t->properties)); + if (isDeclaredTable(pt)) + return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE: can't add/drop a declared table into a %s", + TABLE_TYPE_DESCRIPTION(t->type, t->properties)); + if (isTempSchema(pt->s)) + return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE: can't add/drop a temporary table into a %s", + TABLE_TYPE_DESCRIPTION(t->type, t->properties)); + if (strcmp(sname, nsname) != 0) + return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE: all children tables of '%s.%s' must be " + "part of schema '%s'", sname, tname, sname); + + if (te->token == SQL_TABLE) { + symbol *extra = dl->h->next->next->next->data.sym; + + if (!extra) { + if (isRangePartitionTable(t)) { + return sql_error(sql, 02,SQLSTATE(42000) "ALTER TABLE: a range partition is required while adding under a %s", + TABLE_TYPE_DESCRIPTION(t->type, t->properties)); + } else if (isListPartitionTable(t)) { + r
MonetDB: scoping - Declared tables on the stack don't have a schema
Changeset: 3cb1fecae265 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3cb1fecae265 Modified Files: sql/server/rel_dump.c Branch: scoping Log Message: Declared tables on the stack don't have a schema diffs (12 lines): diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -397,7 +397,7 @@ rel_print_(mvc *sql, stream *fout, sql_ if (!t && c) { mnstr_printf(fout, "dict(%s.%s)", c->t->base.name, c->base.name); } else { - const char *sname = t->s->base.name; /* All tables, including declared ones have schema */ + const char *sname = t->s ? t->s->base.name : NULL; /* All tables, but declared ones on the stack have schema */ const char *tname = t->base.name; if (isRemote(t)) { ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: scoping - If a schema.table qualifier is provided, it s...
Changeset: ef8f2d132964 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ef8f2d132964 Modified Files: sql/server/rel_psm.c sql/server/rel_schema.c sql/server/rel_select.c sql/server/rel_updates.c sql/server/sql_mvc.c sql/server/sql_privileges.c sql/test/scoping/Tests/scoping02.sql sql/test/scoping/Tests/scoping02.stable.err sql/test/scoping/Tests/scoping02.stable.out Branch: scoping Log Message: If a schema.table qualifier is provided, it should never bind to a table declared on the stack, otherwise is a fallacy because declared tables on the stack don't have a schema diffs (truncated from 569 to 300 lines): diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c --- a/sql/server/rel_psm.c +++ b/sql/server/rel_psm.c @@ -472,9 +472,9 @@ rel_psm_return( sql_query *query, sql_su if (sname && !(s = mvc_bind_schema(sql, sname))) return sql_error(sql, 02, SQLSTATE(3F000) "RETURN: no such schema '%s'", sname); - if ((t = stack_find_table(sql, tname))) { + if (!sname && (t = stack_find_table(sql, tname))) { rel = rel_table(sql, ddl_create_table, s->base.name, t, SQL_DECLARED_TABLE); - } else if ((t = find_sql_table(s, tname))) { + } else if ((t = mvc_bind_table(sql, s, tname))) { rel = rel_basetable(sql, t, t->base.name); for (node *n = rel->exps->h ; n ; n = n->next) { sql_exp *e = (sql_exp *) n->data; @@ -1304,8 +1304,14 @@ create_trigger(sql_query *query, dlist * if (create && !mvc_schema_privs(sql, ss)) return sql_error(sql, 02, SQLSTATE(42000) "%s TRIGGER: access denied for %s to schema '%s'", base, sqlvar_get_string(find_global_var(sql, mvc_bind_schema(sql, "sys"), "current_user")), ss->base.name); - if (create && !(t = mvc_bind_table(sql, ss, tname))) - return sql_error(sql, 02, SQLSTATE(42000) "%s TRIGGER: unknown table '%s'", base, tname); + if (create) { + if (!sname) + t = stack_find_table(sql, tname); + if (t) + return sql_error(sql, 02, SQLSTATE(42000) "%s TRIGGER: declared tables cannot have triggers", base); + if (!(t = mvc_bind_table(sql, ss, tname))) + return sql_error(sql, 02, SQLSTATE(42000) "%s TRIGGER: unknown table '%s'", base, tname); + } if (create && isView(t)) return sql_error(sql, 02, SQLSTATE(42000) "%s TRIGGER: cannot create trigger on view '%s'", base, tname); if (triggerschema && strcmp(triggerschema, ss->base.name) != 0) @@ -1522,13 +1528,18 @@ create_table_from_loader(sql_query *quer char *sname = qname_schema(qname); char *tname = qname_schema_object(qname); sql_subfunc *loader = NULL; - sql_rel* rel = NULL; + sql_rel *rel = NULL; + sql_table *t = NULL; if (sname && !(s = mvc_bind_schema(sql, sname))) return sql_error(sql, 02, SQLSTATE(3F000) "CREATE TABLE FROM LOADER: no such schema '%s'", sname); if (!mvc_schema_privs(sql, s)) return sql_error(sql, 02, SQLSTATE(42000) "CREATE TABLE FROM LOADER: insufficient privileges for user '%s' in schema '%s'", sqlvar_get_string(find_global_var(sql, mvc_bind_schema(sql, "sys"), "current_user")), s->base.name); - if (mvc_bind_table(sql, s, tname)) + if (!sname) + t = stack_find_table(sql, tname); + if (!t) + t = mvc_bind_table(sql, s, tname); + if (t) return sql_error(sql, 02, SQLSTATE(42S01) "CREATE TABLE FROM LOADER: name '%s' already in use", tname); rel = rel_loader_function(query, fcall, new_exp_list(sql->sa), &loader); 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 @@ -513,12 +513,18 @@ table_foreign_key(mvc *sql, char *name, char *rsname = qname_schema(n->data.lval); char *rtname = qname_schema_object(n->data.lval); sql_schema *fs = ss; - sql_table *ft; + sql_table *ft = NULL; if (rsname && !(fs = mvc_bind_schema(sql, rsname))) { (void) sql_error(sql, 02, SQLSTATE(3F000) "CONSTRAINT FOREIGN KEY: no such schema '%s'", rsname); return SQL_ERR; } + if (!rsname) + ft = stack_find_table(sql, rtname); + if (ft) { + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: not possible to create a foreign key on a declared table"); + return SQL_ERR; + } ft = mvc_bind_table(sql, fs, rtname); /* self referenced table */ if (!ft && t->s == fs && strcmp(t->base.name, rtname) == 0) @@ -856,7 +862,10 @@ table_element(
MonetDB: scoping - Merged with default
Changeset: 0461e2869d91 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0461e2869d91 Modified Files: sql/server/rel_select.c sql/server/rel_unnest.c sql/server/rel_unnest.h sql/test/Tests/hot-snapshot.py sql/test/subquery/Tests/subquery3.stable.err sql/test/subquery/Tests/subquery5.stable.err Branch: scoping Log Message: Merged with default diffs (truncated from 329 to 300 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -1194,7 +1194,7 @@ rel_column_ref(sql_query *query, sql_rel if (exp) break; } - if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && (!is_sql_aggr(f) || is_sql_farg(f))) + if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && !is_sql_aggr(f)) return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s' in query results without an aggregate function", name); if (exp && outer && !is_sql_aggr(f)) { if (query_outer_used_exp( query, i, exp, f)) { @@ -1258,7 +1258,7 @@ rel_column_ref(sql_query *query, sql_rel if (exp) break; } - if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && (!is_sql_aggr(f) || is_sql_farg(f))) + if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && !is_sql_aggr(f)) return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s.%s' in query results without an aggregate function", tname, cname); if (exp && outer && !is_sql_aggr(f)) { if (query_outer_used_exp( query, i, exp, f)) { @@ -3358,14 +3358,16 @@ static sql_exp * exps = sa_list(sql->sa); if (args && args->data.sym) { - int ungrouped_col = -1, i, all_aggr = query_has_outer(query); + int i, all_aggr = query_has_outer(query); + bool found_nested_aggr = false; + list *ungrouped_cols = NULL; + all_freevar = 1; - bool found_nested_aggr = false; for (i = 0; args && args->data.sym; args = args->next, i++) { int base = (!groupby || !is_project(groupby->op) || is_base(groupby->op) || is_processed(groupby)); - bool found_one = false; - sql_rel *outer = NULL, *gl = base?groupby:groupby->l, *ogl = gl; /* handle case of subqueries without correlation */ - sql_exp *e = rel_value_exp(query, &gl, args->data.sym, (f | sql_aggr)& ~sql_farg, ek), *a = NULL; + sql_rel *gl = base?groupby:groupby->l, *ogl = gl; /* handle case of subqueries without correlation */ + sql_exp *e = rel_value_exp(query, &gl, args->data.sym, (f | sql_aggr)& ~sql_farg, ek); + bool found_one_freevar = false; has_args = true; if (gl && gl != ogl) { @@ -3393,38 +3395,15 @@ static sql_exp * return e; } - if (is_freevar(e) && e->type == e_column) { - if ((outer = query_fetch_outer(query, is_freevar(e)-1))) { - if ((a = rel_find_exp(outer, e)) && is_aggr(a->type)) - return sql_error(sql, 05, SQLSTATE(42000) "SELECT: aggregate function calls cannot be nested"); - } - } - - if (all_aggr) { - /* get expression from outer */ - int aggr = 0; - if (a) - aggr = is_aggr(a->type); - else if (outer && outer->grouped) - ungrouped_col = i; - all_aggr &= aggr; - } else { - all_aggr &= (exp_card(e) <= CARD_AGGR && !exp_is_atom(e) && is_aggr(e->type) && !is_func(e->type) && (!groupby || !is_groupby(groupby->op) || !groupby->r || !exps_find_exp(groupby->r, e))); - } - all_freevar &= (exp_only_freevar(query, e, &found_one, &found_nested_aggr) && found_one); + all_aggr &= (exp_card(e) <= CARD_AGGR && !exp_is_atom(e) && is_aggr(e->type) && !is_func(e->type) && (!groupby || !is_groupby(groupby->op) || !
MonetDB: default - Merged with Jun2020
Changeset: bcc9a1485c4b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bcc9a1485c4b Modified Files: sql/server/rel_select.c sql/server/rel_unnest.c sql/server/rel_unnest.h sql/test/Tests/hot-snapshot.py sql/test/subquery/Tests/subquery3.stable.err sql/test/subquery/Tests/subquery5.stable.err Branch: default Log Message: Merged with Jun2020 diffs (truncated from 329 to 300 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -1191,7 +1191,7 @@ rel_column_ref(sql_query *query, sql_rel if (exp) break; } - if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && (!is_sql_aggr(f) || is_sql_farg(f))) + if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && !is_sql_aggr(f)) return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s' in query results without an aggregate function", name); if (exp && outer && !is_sql_aggr(f)) { if (query_outer_used_exp( query, i, exp, f)) { @@ -1257,7 +1257,7 @@ rel_column_ref(sql_query *query, sql_rel if (exp) break; } - if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && (!is_sql_aggr(f) || is_sql_farg(f))) + if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && !is_sql_aggr(f)) return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s.%s' in query results without an aggregate function", tname, cname); if (exp && outer && !is_sql_aggr(f)) { if (query_outer_used_exp( query, i, exp, f)) { @@ -3349,14 +3349,16 @@ static sql_exp * exps = sa_list(sql->sa); if (args && args->data.sym) { - int ungrouped_col = -1, i, all_aggr = query_has_outer(query); + int i, all_aggr = query_has_outer(query); + bool found_nested_aggr = false; + list *ungrouped_cols = NULL; + all_freevar = 1; - bool found_nested_aggr = false; for (i = 0; args && args->data.sym; args = args->next, i++) { int base = (!groupby || !is_project(groupby->op) || is_base(groupby->op) || is_processed(groupby)); - bool found_one = false; - sql_rel *outer = NULL, *gl = base?groupby:groupby->l, *ogl = gl; /* handle case of subqueries without correlation */ - sql_exp *e = rel_value_exp(query, &gl, args->data.sym, (f | sql_aggr)& ~sql_farg, ek), *a = NULL; + sql_rel *gl = base?groupby:groupby->l, *ogl = gl; /* handle case of subqueries without correlation */ + sql_exp *e = rel_value_exp(query, &gl, args->data.sym, (f | sql_aggr)& ~sql_farg, ek); + bool found_one_freevar = false; has_args = true; if (gl && gl != ogl) { @@ -3384,38 +3386,15 @@ static sql_exp * return e; } - if (is_freevar(e) && e->type == e_column) { - if ((outer = query_fetch_outer(query, is_freevar(e)-1))) { - if ((a = rel_find_exp(outer, e)) && is_aggr(a->type)) - return sql_error(sql, 05, SQLSTATE(42000) "SELECT: aggregate function calls cannot be nested"); - } - } - - if (all_aggr) { - /* get expression from outer */ - int aggr = 0; - if (a) - aggr = is_aggr(a->type); - else if (outer && outer->grouped) - ungrouped_col = i; - all_aggr &= aggr; - } else { - all_aggr &= (exp_card(e) <= CARD_AGGR && !exp_is_atom(e) && is_aggr(e->type) && !is_func(e->type) && (!groupby || !is_groupby(groupby->op) || !groupby->r || !exps_find_exp(groupby->r, e))); - } - all_freevar &= (exp_only_freevar(query, e, &found_one, &found_nested_aggr) && found_one); + all_aggr &= (exp_card(e) <= CARD_AGGR && !exp_is_atom(e) && is_aggr(e->type) && !is_func(e->type) && (!groupby || !is_groupby(groupby->op) || !
MonetDB: Jun2020 - Code cleanup
Changeset: 8b537565d892 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8b537565d892 Modified Files: sql/server/rel_select.c Branch: Jun2020 Log Message: Code cleanup diffs (29 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -3357,7 +3357,7 @@ static sql_exp * for (i = 0; args && args->data.sym; args = args->next, i++) { int base = (!groupby || !is_project(groupby->op) || is_base(groupby->op) || is_processed(groupby)); sql_rel *gl = base?groupby:groupby->l, *ogl = gl; /* handle case of subqueries without correlation */ - sql_exp *e = rel_value_exp(query, &gl, args->data.sym, (f | sql_aggr)& ~sql_farg, ek), *a = NULL; + sql_exp *e = rel_value_exp(query, &gl, args->data.sym, (f | sql_aggr)& ~sql_farg, ek); bool found_one_freevar = false; has_args = true; @@ -3386,15 +3386,7 @@ static sql_exp * return e; } - if (all_aggr) { - /* get expression from outer */ - int aggr = 0; - if (a) - aggr = is_aggr(a->type); - all_aggr &= aggr; - } else { - all_aggr &= (exp_card(e) <= CARD_AGGR && !exp_is_atom(e) && is_aggr(e->type) && !is_func(e->type) && (!groupby || !is_groupby(groupby->op) || !groupby->r || !exps_find_exp(groupby->r, e))); - } + all_aggr &= (exp_card(e) <= CARD_AGGR && !exp_is_atom(e) && is_aggr(e->type) && !is_func(e->type) && (!groupby || !is_groupby(groupby->op) || !groupby->r || !exps_find_exp(groupby->r, e))); exp_only_freevar(query, e, &all_freevar, &found_one_freevar, &found_nested_aggr, &ungrouped_cols); all_freevar &= found_one_freevar; /* no uncorrelated variables must be found, plus at least one correlated variable to push this aggregate to an outer query */ list_append(exps, e); ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Allow correlation of more complex aggregates,...
Changeset: d7e2b18a6343 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d7e2b18a6343 Modified Files: sql/server/rel_select.c sql/server/rel_unnest.c sql/server/rel_unnest.h sql/test/subquery/Tests/subquery3.stable.err sql/test/subquery/Tests/subquery5.stable.err Branch: Jun2020 Log Message: Allow correlation of more complex aggregates, as long they contain solely correlated variables inside subqueries. diffs (truncated from 313 to 300 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -1191,7 +1191,7 @@ rel_column_ref(sql_query *query, sql_rel if (exp) break; } - if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && (!is_sql_aggr(f) || is_sql_farg(f))) + if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && !is_sql_aggr(f)) return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s' in query results without an aggregate function", name); if (exp && outer && !is_sql_aggr(f)) { if (query_outer_used_exp( query, i, exp, f)) { @@ -1257,7 +1257,7 @@ rel_column_ref(sql_query *query, sql_rel if (exp) break; } - if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && (!is_sql_aggr(f) || is_sql_farg(f))) + if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && !is_sql_aggr(f)) return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s.%s' in query results without an aggregate function", tname, cname); if (exp && outer && !is_sql_aggr(f)) { if (query_outer_used_exp( query, i, exp, f)) { @@ -3349,14 +3349,16 @@ static sql_exp * exps = sa_list(sql->sa); if (args && args->data.sym) { - int ungrouped_col = -1, i, all_aggr = query_has_outer(query); + int i, all_aggr = query_has_outer(query); + bool found_nested_aggr = false; + list *ungrouped_cols = NULL; + all_freevar = 1; - bool found_nested_aggr = false; for (i = 0; args && args->data.sym; args = args->next, i++) { int base = (!groupby || !is_project(groupby->op) || is_base(groupby->op) || is_processed(groupby)); - bool found_one = false; - sql_rel *outer = NULL, *gl = base?groupby:groupby->l, *ogl = gl; /* handle case of subqueries without correlation */ + sql_rel *gl = base?groupby:groupby->l, *ogl = gl; /* handle case of subqueries without correlation */ sql_exp *e = rel_value_exp(query, &gl, args->data.sym, (f | sql_aggr)& ~sql_farg, ek), *a = NULL; + bool found_one_freevar = false; has_args = true; if (gl && gl != ogl) { @@ -3384,38 +3386,23 @@ static sql_exp * return e; } - if (is_freevar(e) && e->type == e_column) { - if ((outer = query_fetch_outer(query, is_freevar(e)-1))) { - if ((a = rel_find_exp(outer, e)) && is_aggr(a->type)) - return sql_error(sql, 05, SQLSTATE(42000) "SELECT: aggregate function calls cannot be nested"); - } - } - if (all_aggr) { /* get expression from outer */ int aggr = 0; if (a) aggr = is_aggr(a->type); - else if (outer && outer->grouped) - ungrouped_col = i; all_aggr &= aggr; } else { all_aggr &= (exp_card(e) <= CARD_AGGR && !exp_is_atom(e) && is_aggr(e->type) && !is_func(e->type) && (!groupby || !is_groupby(groupby->op) || !groupby->r || !exps_find_exp(groupby->r, e))); } - all_freevar &= (exp_only_freevar(query, e, &found_one, &found_nested_aggr) && found_one); + exp_only_freevar(query, e, &all_freevar, &found_one_freevar, &found_nested_aggr, &ungrouped_cols); + all_freevar &= found_one_freevar; /* no uncorrelated variables must be found
MonetDB: Jun2020 - Close client connection and server at the end...
Changeset: ca31457891e9 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ca31457891e9 Modified Files: sql/test/Tests/hot-snapshot.py Branch: Jun2020 Log Message: Close client connection and server at the end of test diffs (14 lines): diff --git a/sql/test/Tests/hot-snapshot.py b/sql/test/Tests/hot-snapshot.py --- a/sql/test/Tests/hot-snapshot.py +++ b/sql/test/Tests/hot-snapshot.py @@ -108,6 +108,10 @@ def main(): # uncommitted1 and uncommitted2 should not be present assert foo == [('committed1',)] +cur3.close() +conn3.close() +server.terminate() + finally: if os.path.exists(mydbdir): shutil.rmtree(mydbdir) ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list