Changeset: c3f06ac64f73 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c3f06ac64f73
Removed Files:
sql/jdbc/tests/Tests/bogus-auto-generated-keys.SQL.bat
sql/jdbc/tests/Tests/bogus-auto-generated-keys.SQL.sh
sql/jdbc/tests/Tests/bogus-auto-generated-keys.stable.err
sql/jdbc/tests/Tests/bogus-auto-generated-keys.stable.out
Modified Files:
sql/server/rel_optimizer.c
Branch: default
Log Message:
merged with Oct2020
diffs (174 lines):
diff --git a/sql/jdbc/tests/Tests/All b/sql/jdbc/tests/Tests/All
--- a/sql/jdbc/tests/Tests/All
+++ b/sql/jdbc/tests/Tests/All
@@ -1,7 +1,6 @@
HAVE_JDBCTESTS?JDBC_API_Tester
#HAVE_JDBCTESTS?Test_Csendthread # unfortunately has runtime-dependant output
-HAVE_JDBCCLIENT_JAR?Test_JdbcClient
-HAVE_JDBCCLIENT_JAR?bogus-auto-generated-keys
#HAVE_JDBCTESTS?Test_PSlargeamount # scalabity test which is disabled by
default (it takes a long time to run and does not need to be run everytime,
only before a new release)
# next test should be done AFTER all the other tests have completed
+HAVE_JDBCCLIENT_JAR?Test_JdbcClient
HAVE_JDBCCLIENT_JAR?ValidateSystemCatalogTables
diff --git a/sql/jdbc/tests/Tests/bogus-auto-generated-keys.SQL.bat
b/sql/jdbc/tests/Tests/bogus-auto-generated-keys.SQL.bat
deleted file mode 100755
--- a/sql/jdbc/tests/Tests/bogus-auto-generated-keys.SQL.bat
+++ /dev/null
@@ -1,10 +0,0 @@
-@echo off
-
-echo user=monetdb> .monetdb
-echo password=monetdb>> .monetdb
-
-prompt # $t $g
-
-call java org.monetdb.client.JdbcClient -h %HOST% -p %MAPIPORT% -d %TSTDB% -e
-f "%TSTSRCBASE%\%TSTDIR%\Tests\bogus-auto-generated-keys.sql"
-
-@del .monetdb
diff --git a/sql/jdbc/tests/Tests/bogus-auto-generated-keys.SQL.sh
b/sql/jdbc/tests/Tests/bogus-auto-generated-keys.SQL.sh
deleted file mode 100755
--- a/sql/jdbc/tests/Tests/bogus-auto-generated-keys.SQL.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-cat << EOF > .monetdb
-user=monetdb
-password=monetdb
-EOF
-
-java org.monetdb.client.JdbcClient -h $HOST -p $MAPIPORT -d ${TSTDB} -e -f
$TSTSRCBASE/$TSTDIR/Tests/bogus-auto-generated-keys.sql
-
-rm -f .monetdb
diff --git a/sql/jdbc/tests/Tests/bogus-auto-generated-keys.sql
b/sql/jdbc/tests/Tests/bogus-auto-generated-keys.sql
deleted file mode 100644
--- a/sql/jdbc/tests/Tests/bogus-auto-generated-keys.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-START TRANSACTION;
--- generate a simple table with an auto-generated key (id)
-CREATE TABLE gen_keys (
- "id" serial,
- "x" varchar(12)
-);
-
--- perform an update, useless, but illustrates the bug, this time no
--- generated key is reported, which is correct
-UPDATE gen_keys SET "x" = 'bla' WHERE "id" = 12;
-
--- insert some value, should get a generated key
-INSERT INTO gen_keys ("x") VALUES ('boe');
-
--- update again, we expect NO generated key, but we DO get one
-UPDATE gen_keys SET "x" = 'bla' WHERE "id" = 1;
-UPDATE gen_keys SET "x" = 'bla' WHERE "id" = 12;
-
--- ok, cleanup a bit
-DROP TABLE gen_keys;
-ROLLBACK;
diff --git a/sql/jdbc/tests/Tests/bogus-auto-generated-keys.stable.err
b/sql/jdbc/tests/Tests/bogus-auto-generated-keys.stable.err
deleted file mode 100644
--- a/sql/jdbc/tests/Tests/bogus-auto-generated-keys.stable.err
+++ /dev/null
@@ -1,17 +0,0 @@
-stderr of test 'bogus-auto-generated-keys` in directory 'sql/jdbc/tests`
itself:
-
-
-# 19:33:44 >
-# 19:33:44 > "./bogus-auto-generated-keys.SQL.sh" "bogus-auto-generated-keys"
-# 19:33:44 >
-
-
-# 19:33:44 >
-# 19:33:44 > java org.monetdb.client.JdbcClient -h monetdb-nuc2 -p 30491 -d
mTests_sql_jdbc_tests -e -f
"/home/dinther/dev/dev/MonetDB/sql/jdbc/tests/Tests/bogus-auto-generated-keys.sql"
-# 19:33:44 >
-
-
-# 19:33:44 >
-# 19:33:44 > "Done."
-# 19:33:44 >
-
diff --git a/sql/jdbc/tests/Tests/bogus-auto-generated-keys.stable.out
b/sql/jdbc/tests/Tests/bogus-auto-generated-keys.stable.out
deleted file mode 100644
--- a/sql/jdbc/tests/Tests/bogus-auto-generated-keys.stable.out
+++ /dev/null
@@ -1,46 +0,0 @@
-stdout of test 'bogus-auto-generated-keys` in directory 'sql/jdbc/tests`
itself:
-
-
-# 19:33:44 >
-# 19:33:44 > "./bogus-auto-generated-keys.SQL.sh" "bogus-auto-generated-keys"
-# 19:33:44 >
-
-
-# 19:33:44 >
-# 19:33:44 > java org.monetdb.client.JdbcClient -h monetdb-nuc2 -p 30491 -d
mTests_sql_jdbc_tests -e -f
"/home/dinther/dev/dev/MonetDB/sql/jdbc/tests/Tests/bogus-auto-generated-keys.sql"
-# 19:33:44 >
-
-START TRANSACTION;
-Operation successful
--- generate a simple table with an auto-generated key (id)
-CREATE TABLE gen_keys (
- "id" serial,
- "x" varchar(12)
-);
-Operation successful
-
--- perform an update, useless, but illustrates the bug, this time no
--- generated key is reported, which is correct
-UPDATE gen_keys SET "x" = 'bla' WHERE "id" = 12;
-0 affected rows
-
--- insert some value, should get a generated key
-INSERT INTO gen_keys ("x") VALUES ('boe');
-1 affected row, last generated key: 1
-
--- update again, we expect NO generated key, but we DO get one
-UPDATE gen_keys SET "x" = 'bla' WHERE "id" = 1;
-1 affected row, last generated key: 1
-UPDATE gen_keys SET "x" = 'bla' WHERE "id" = 12;
-0 affected rows, last generated key: 1
-
--- ok, cleanup a bit
-DROP TABLE gen_keys;
-Operation successful
-ROLLBACK;
-Operation successful
-
-# 19:33:44 >
-# 19:33:44 > "Done."
-# 19:33:44 >
-
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
@@ -5364,6 +5364,19 @@ find_projection_for_join2semi(sql_rel *r
if (is_project(rel->op) && !is_union(rel->op)) {
if (rel->card < CARD_AGGR) /* const or groupby without group by
exps */
return true;
+
+ if (is_groupby(rel->op)) { /* if just groupby columns are
projected, it will be distinct */
+ bool all_groupby_columns = true;
+
+ if (list_empty(rel->r)) /* global aggregate */
+ return true;
+ for (node *n = rel->exps->h; n && all_groupby_columns;
n = n->next) {
+ sql_exp *e = n->data;
+ all_groupby_columns &= (e->type == e_column &&
(find_prop(e->p, PROP_HASHCOL) || exps_find_exp(rel->r, e)));
+ }
+ if (all_groupby_columns)
+ return true;
+ }
if (list_length(rel->exps) == 1) {
sql_exp *e = rel->exps->h->data;
/* a single group by column in the projection list from
a group by relation is guaranteed to be unique, but not an aggregate */
@@ -5372,8 +5385,7 @@ find_projection_for_join2semi(sql_rel *r
sql_exp *found = NULL;
bool underjoin = false;
- /* if just one groupby column is projected, it
will be distinct */
- if ((is_groupby(rel->op) && list_length(rel->r)
== 1 && exps_find_exp(rel->r, e)) || need_distinct(rel) || find_prop(e->p,
PROP_HASHCOL))
+ if (is_groupby(rel->op) || need_distinct(rel)
|| find_prop(e->p, PROP_HASHCOL))
return true;
if ((found =
rel_find_exp_and_corresponding_rel(rel->l, e, &res, &underjoin)) && !underjoin)
{ /* grouping column on inner relation */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list