Changeset: 818aeabc2109 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=818aeabc2109
Added Files:
sql/test/BugTracker-2016/Tests/analyze-quotes-incorrectly.Bug-4021.sql
sql/test/BugTracker-2016/Tests/analyze-quotes-incorrectly.Bug-4021.stable.err
sql/test/BugTracker-2016/Tests/analyze-quotes-incorrectly.Bug-4021.stable.out
sql/test/BugTracker-2016/Tests/boolean-evaluation.Bug-4025.sql
sql/test/BugTracker-2016/Tests/boolean-evaluation.Bug-4025.stable.err
sql/test/BugTracker-2016/Tests/boolean-evaluation.Bug-4025.stable.out
sql/test/bugs/Tests/select_select_bug.sql
sql/test/bugs/Tests/select_select_bug.stable.err
sql/test/bugs/Tests/select_select_bug.stable.out
Modified Files:
clients/Tests/SQL-dump.stable.out
clients/Tests/SQL-dump.stable.out.int128
clients/odbc/driver/SQLConnect.c
clients/odbc/driver/SQLTables.c
sql/backends/monet5/sql_statistics.c
sql/backends/monet5/sql_upgrades.c
sql/common/sql_list.c
sql/server/rel_select.c
sql/server/sql_privileges.c
sql/test/BugTracker-2016/Tests/All
sql/test/bugs/Tests/All
sql/test/leaks/Tests/check1.stable.out.int128
sql/test/leaks/Tests/check2.stable.out.int128
sql/test/leaks/Tests/check3.stable.out.int128
sql/test/leaks/Tests/check4.stable.out.int128
sql/test/leaks/Tests/check5.stable.out.int128
Branch: default
Log Message:
merged with jun2016
diffs (truncated from 831 to 300 lines):
diff --git a/clients/Tests/SQL-dump.stable.out
b/clients/Tests/SQL-dump.stable.out
--- a/clients/Tests/SQL-dump.stable.out
+++ b/clients/Tests/SQL-dump.stable.out
@@ -5281,6 +5281,7 @@ drop function pcre_replace(string, strin
[ "alpha", "public", 16, "monetdb", 0 ]
[ "date_to_str", "public", 16, "monetdb", 0 ]
[ "degrees", "public", 16, "monetdb", 0 ]
+[ "env", "public", 16, NULL, 0 ]
[ "epoch", "public", 16, "monetdb", 0 ]
[ "epoch", "public", 16, "monetdb", 0 ]
[ "epoch", "public", 16, "monetdb", 0 ]
diff --git a/clients/Tests/SQL-dump.stable.out.int128
b/clients/Tests/SQL-dump.stable.out.int128
--- a/clients/Tests/SQL-dump.stable.out.int128
+++ b/clients/Tests/SQL-dump.stable.out.int128
@@ -5648,6 +5648,7 @@ drop function pcre_replace(string, strin
[ "alpha", "public", 16, "monetdb", 0 ]
[ "date_to_str", "public", 16, "monetdb", 0 ]
[ "degrees", "public", 16, "monetdb", 0 ]
+[ "env", "public", 16, NULL, 0 ]
[ "epoch", "public", 16, "monetdb", 0 ]
[ "epoch", "public", 16, "monetdb", 0 ]
[ "epoch", "public", 16, "monetdb", 0 ]
diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c
--- a/clients/odbc/driver/SQLConnect.c
+++ b/clients/odbc/driver/SQLConnect.c
@@ -258,9 +258,7 @@ MNDBConnect(ODBCDbc *dbc,
mapi_setAutocommit(mid, dbc->sql_attr_autocommit ==
SQL_AUTOCOMMIT_ON);
set_timezone(mid);
get_serverinfo(dbc);
- if (dbc->major > 11 ||
- (dbc->major == 11 && dbc->minor >= 5))
- mapi_set_size_header(mid, 1);
+ mapi_set_size_header(mid, 1);
/* set timeout after we're connected */
mapi_timeout(mid, dbc->sql_attr_connection_timeout * 1000);
}
diff --git a/clients/odbc/driver/SQLTables.c b/clients/odbc/driver/SQLTables.c
--- a/clients/odbc/driver/SQLTables.c
+++ b/clients/odbc/driver/SQLTables.c
@@ -232,87 +232,69 @@ MNDBTables(ODBCStmt *stmt,
strcpy(query_end, "with ot as (");
query_end += strlen(query_end);
- if (stmt->Dbc->major < 11 || (stmt->Dbc->major == 11 &&
stmt->Dbc->minor < 21)) {
- strcpy(query_end,
- "select e.value as table_cat, "
- "s.name as table_schem, "
- "t.name as table_name, "
- "case when t.type = 0 and "
- "t.system = false and "
- "t.temporary = 0 and "
- "s.name <> 'tmp' "
- "then cast('TABLE' as varchar(20)) "
- "when t.type = 0 and "
- "t.system = false and "
- "t.temporary = 0 and "
- "s.name = 'tmp' "
- "then cast('GLOBAL TEMPORARY' as
varchar(20)) "
- "when t.type = 0 and "
- "t.system = true and "
- "t.temporary = 0 "
- "then cast('SYSTEM TABLE' as
varchar(20)) "
- "when t.type = 1 and "
- "t.system = true and "
- "t.temporary = 0 "
- "then cast('SYSTEM VIEW' as
varchar(20)) "
- "when t.type = 1 "
- "then cast('VIEW' as varchar(20)) "
- "when t.type = 0 and "
- "t.system = false and "
- "t.temporary = 1 "
- "then cast('LOCAL TEMPORARY' as
varchar(20)) "
- "else cast('INTERNAL TABLE TYPE' as
varchar(20)) end as table_type, "
- "cast(null as varchar(1)) as remarks "
- "from sys.schemas s, "
- "sys.tables t, "
- "sys.env() e "
- "where s.id = t.schema_id and "
- "e.name = 'gdk_dbname'");
- } else {
- strcpy(query_end,
- "select e.value as table_cat, "
- "s.name as table_schem, "
- "t.name as table_name, "
- "case when t.type = 0 and "
- "t.system = false and "
- "t.temporary = 0 and "
- "s.name <> 'tmp' "
- "then cast('TABLE' as varchar(20)) "
- "when t.type = 10 and "
- "t.system = true and "
- "t.temporary = 0 "
- "then cast('SYSTEM TABLE' as
varchar(20)) "
- "when t.type = 11 and "
- "t.system = true and "
- "t.temporary = 0 "
- "then cast('SYSTEM VIEW' as
varchar(20)) "
- "when t.type = 1 "
- "then cast('VIEW' as varchar(20)) "
- "when t.type = 3 "
- "then cast('MERGE TABLE' as
varchar(20)) "
- "when t.type = 4 "
- "then cast('STREAM TABLE' as
varchar(20)) "
- "when t.type = 5 "
- "then cast('REMOTE TABLE' as
varchar(20)) "
- "when t.type = 6 "
- "then cast('REPLICA TABLE' as
varchar(20)) "
- "when t.type = 20 and "
- "t.system = false and "
- "t.temporary = 1 and "
- "s.name = 'tmp' "
- "then cast('GLOBAL TEMPORARY' as
varchar(20)) "
- "when t.type = 30 and "
- "t.system = false and "
- "t.temporary = 1 "
- "then cast('LOCAL TEMPORARY' as
varchar(20)) "
- "else cast('INTERNAL TABLE TYPE' as
varchar(20)) end as table_type, "
- "cast(null as varchar(1)) as remarks "
- "from sys.schemas s, "
- "sys.tables t, "
- "sys.env() e "
- "where s.id = t.schema_id and "
- "e.name = 'gdk_dbname'");
- }
+ strcpy(query_end,
+ "select e.value as table_cat, "
+ "s.name as table_schem, "
+ "t.name as table_name, "
+ "case when t.type = 0 and "
+ "t.system = false and "
+ "t.temporary = 0 and "
+ "s.name <> 'tmp' "
+ "then cast('TABLE' as varchar(20)) "
+/* start <= 11.21.X (at some point this code can be removed) */
+ "when t.type = 0 and "
+ "t.system = false and "
+ "t.temporary = 0 and "
+ "s.name = 'tmp' "
+ "then cast('GLOBAL TEMPORARY' as
varchar(20)) "
+ "when t.type = 0 and "
+ "t.system = true and "
+ "t.temporary = 0 "
+ "then cast('SYSTEM TABLE' as varchar(20)) "
+ "when t.type = 0 and "
+ "t.system = false and "
+ "t.temporary = 1 "
+ "then cast('LOCAL TEMPORARY' as varchar(20))
"
+ "when t.type = 1 and "
+ "t.system = true and "
+ "t.temporary = 0 "
+ "then cast('SYSTEM VIEW' as varchar(20)) "
+/* end <= 11.21.X */
+ "when t.type = 1 "
+ "then cast('VIEW' as varchar(20)) "
+ "when t.type = 3 "
+ "then cast('MERGE TABLE' as varchar(20)) "
+ "when t.type = 4 "
+ "then cast('STREAM TABLE' as varchar(20)) "
+ "when t.type = 5 "
+ "then cast('REMOTE TABLE' as varchar(20)) "
+ "when t.type = 6 "
+ "then cast('REPLICA TABLE' as varchar(20)) "
+ "when t.type = 10 and "
+ "t.system = true and "
+ "t.temporary = 0 "
+ "then cast('SYSTEM TABLE' as varchar(20)) "
+ "when t.type = 11 and "
+ "t.system = true and "
+ "t.temporary = 0 "
+ "then cast('SYSTEM VIEW' as varchar(20)) "
+ "when t.type = 20 and "
+ "t.system = false and "
+ "t.temporary = 1 and "
+ "s.name = 'tmp' "
+ "then cast('GLOBAL TEMPORARY' as
varchar(20)) "
+ "when t.type = 30 and "
+ "t.system = false and "
+ "t.temporary = 1 "
+ "then cast('LOCAL TEMPORARY' as varchar(20))
"
+ "else cast('INTERNAL TABLE TYPE' as
varchar(20)) "
+ "end as table_type, "
+ "cast(null as varchar(1)) as remarks "
+ "from sys.schemas s, "
+ "sys.tables t, "
+ "sys.env() e "
+ "where s.id = t.schema_id and "
+ "e.name = 'gdk_dbname'");
assert(strlen(query) < 1100);
query_end += strlen(query_end);
diff --git a/sql/backends/monet5/sql_statistics.c
b/sql/backends/monet5/sql_statistics.c
--- a/sql/backends/monet5/sql_statistics.c
+++ b/sql/backends/monet5/sql_statistics.c
@@ -21,6 +21,37 @@ analysis by optimizers.
#include "sql_statistics.h"
#include "sql_scenario.h"
+#define atommem(TYPE, size) \
+ do { \
+ if (*dst == NULL || *len < (int) (size)) { \
+ GDKfree(*dst); \
+ *len = (size); \
+ *dst = (TYPE *) GDKmalloc(*len); \
+ if (*dst == NULL) \
+ return -1; \
+ } \
+ } while (0)
+
+static int
+strToStrSQuote(char **dst, int *len, const void *src)
+{
+ int l = 0;
+
+ if (GDK_STRNIL((str) src)) {
+ atommem(char, 4);
+
+ return snprintf(*dst, *len, "nil");
+ } else {
+ int sz = escapedStrlen(src, NULL, NULL, '\'');
+ atommem(char, sz + 3);
+ l = escapedStr((*dst) + 1, src, *len - 1, NULL, NULL, '\'');
+ l++;
+ (*dst)[0] = (*dst)[l++] = '"';
+ (*dst)[l] = 0;
+ }
+ return l;
+}
+
str
sql_analyze(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
@@ -86,10 +117,13 @@ sql_analyze(Client cntxt, MalBlkPtr mb,
BAT *bn =
store_funcs.bind_col(tr, c, RDONLY), *br;
BAT *bsample;
lng sz = BATcount(bn);
- int (*tostr)(str*,int*,const
void*) = BATatoms[bn->ttype].atomToStr; \
+ int (*tostr)(str*,int*,const
void*) = BATatoms[bn->ttype].atomToStr;
int len = 0;
void *val=0;
+ if (tostr ==
BATatoms[TYPE_str].atomToStr)
+ tostr = strToStrSQuote;
+
if (col && strcmp(bc->name,
col))
continue;
snprintf(dquery, 8192, "delete
from sys.statistics where \"column_id\" = %d;", c->base.id);
@@ -132,8 +166,8 @@ sql_analyze(Client cntxt, MalBlkPtr mb,
tostr(&minval,
&len,val);
GDKfree(val);
} else {
- maxval = (char *)
GDKzalloc(4);
- minval = (char *)
GDKzalloc(4);
+ maxval = GDKmalloc(4);
+ minval = GDKmalloc(4);
snprintf(maxval, 4,
"nil");
snprintf(minval, 4,
"nil");
}
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
@@ -1749,6 +1749,7 @@ void
SQLupgrades(Client c, mvc *m)
{
sql_subtype tp;
+ sql_subfunc *f;
char *err;
sql_schema *s = mvc_bind_schema(m, "sys");
@@ -1823,6 +1824,14 @@ SQLupgrades(Client c, mvc *m)
}
}
+ f = sql_bind_func_(m->sa, s, "env", NULL, F_UNION);
+ if (f && sql_privilege(m, ROLE_PUBLIC, f->func->base.id, PRIV_EXECUTE,
0) != PRIV_EXECUTE) {
+ sql_table *privs = find_sql_table(s, "privileges");
+ int pub = ROLE_PUBLIC, p = PRIV_EXECUTE, zero = 0;
+
+ table_funcs.table_insert(m->session->tr, privs,
&f->func->base.id, &pub, &p, &zero, &zero);
+ }
+
/* If the point type exists, but the geometry type does not
* exist any more at the "sys" schema (i.e., the first part of
* the upgrade has been completed succesfully), then move on
diff --git a/sql/common/sql_list.c b/sql/common/sql_list.c
--- a/sql/common/sql_list.c
+++ b/sql/common/sql_list.c
@@ -314,7 +314,10 @@ list_cmp(list *l1, list *l2, fcmp cmp)
if (l1 == l2)
return 0;
-
+ if (!l1 && l2 && list_empty(l2))
+ return 0;
+ if (!l2 && l1 && list_empty(l1))
+ return 0;
if (!l1 || !l2 || (list_length(l1) != list_length(l2)))
return -1;
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list