Changeset: 030f1c61a2a5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/030f1c61a2a5
Branch: label
Log Message:
merged with default
diffs (truncated from 408 to 300 lines):
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -1131,14 +1131,15 @@ dump_column_definition(Mapi mid, stream
"SELECT kc.name, " /* 0 */
"kc.nr, " /* 1 */
"k.name, " /* 2 */
- "kc.id " /* 3 */
+ "kc.id, " /* 3 */
+ "k.type " /* 4 */
"FROM sys.objects kc, "
"sys.keys k, "
"sys.schemas s, "
"sys._tables t "
"WHERE kc.id = k.id "
"AND k.table_id = t.id "
- "AND k.type = 1 "
+ "AND k.type in (1, 3) "
"AND t.schema_id = s.id "
"AND s.name = '%s' "
"AND t.name = '%s' "
@@ -1150,6 +1151,7 @@ dump_column_definition(Mapi mid, stream
const char *c_column = mapi_fetch_field(hdl, 0);
const char *kc_nr = mapi_fetch_field(hdl, 1);
const char *k_name = mapi_fetch_field(hdl, 2);
+ const char *k_type = mapi_fetch_field(hdl, 4);
if (mapi_error(mid))
goto bailout;
@@ -1161,7 +1163,7 @@ dump_column_definition(Mapi mid, stream
mnstr_printf(sqlf, "CONSTRAINT ");
dquoted_print(sqlf, k_name, " ");
}
- mnstr_printf(sqlf, "UNIQUE (");
+ mnstr_printf(sqlf, "UNIQUE%s (", strcmp(k_type, "1") ==
0 ? "" : " NULLS NOT DISTINCT");
cnt = 1;
} else
mnstr_printf(sqlf, ", ");
diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c
--- a/clients/mapilib/connect.c
+++ b/clients/mapilib/connect.c
@@ -381,6 +381,22 @@ connect_socket_tcp_addr(Mapi mid, struct
return s;
}
+static const char *
+base_name(const char *file)
+{
+ char *p = strrchr(file, '/');
+#ifdef _MSC_VER
+ char *q = strrchr(file, '\\');
+ if (q != NULL) {
+ if (p == NULL || p < q)
+ p = q;
+ }
+#endif
+ if (p)
+ return p + 1;
+ return file;
+}
+
static void
send_all_clientinfo(Mapi mid)
{
@@ -403,7 +419,7 @@ send_all_clientinfo(Mapi mid)
application_name = get_bin_path();
if (application_name) {
free_this = strdup(application_name);
- application_name = (const char*)
basename((char*)application_name);
+ application_name = base_name(application_name);
}
}
const char *client_remark = msetting_string(mp, MP_CLIENT_REMARK);
diff --git a/clients/odbc/driver/SQLSpecialColumns.c
b/clients/odbc/driver/SQLSpecialColumns.c
--- a/clients/odbc/driver/SQLSpecialColumns.c
+++ b/clients/odbc/driver/SQLSpecialColumns.c
@@ -209,7 +209,7 @@ MNDBSpecialColumns(ODBCStmt *stmt,
}
/* construct the query */
- querylen = 6100 + (sch ? strlen(sch) : 0) + (tab ? strlen(tab)
: 0);
+ querylen = 6130 + (sch ? strlen(sch) : 0) + (tab ? strlen(tab)
: 0);
query = malloc(querylen);
if (query == NULL)
goto nomem;
@@ -235,9 +235,9 @@ MNDBSpecialColumns(ODBCStmt *stmt,
"SELECT \"id\", \"table_id\" FROM \"sys\".\"keys\"
WHERE \"type\" = 0 "
"UNION ALL "
/* and first unique constraint of a table when table
has no pkey */
- "SELECT \"id\", \"table_id\" FROM \"sys\".\"keys\"
WHERE \"type\" = 1 "
+ "SELECT \"id\", \"table_id\" FROM \"sys\".\"keys\"
WHERE \"type\" IN (1, 3) "
"AND \"table_id\" NOT IN (select \"table_id\" from
\"sys\".\"keys\" where \"type\" = 0) "
- "AND (\"table_id\", \"id\") IN (select \"table_id\",
min(\"id\") from \"sys\".\"keys\" where \"type\" = 1 group by \"table_id\"))",
+ "AND (\"table_id\", \"id\") IN (select \"table_id\",
min(\"id\") from \"sys\".\"keys\" where \"type\" IN (1, 3) group by
\"table_id\"))",
querylen - pos);
if (inclTmpKey) {
/* we must also include the primary key or unique
constraint of local temporary tables which are stored in tmp.keys */
@@ -246,9 +246,9 @@ MNDBSpecialColumns(ODBCStmt *stmt,
", tmpkeys as ("
"SELECT \"id\", \"table_id\" FROM \"tmp\".\"keys\"
WHERE \"type\" = 0 "
"UNION ALL "
- "SELECT \"id\", \"table_id\" FROM \"tmp\".\"keys\"
WHERE \"type\" = 1 "
+ "SELECT \"id\", \"table_id\" FROM \"tmp\".\"keys\"
WHERE \"type\" IN (1, 3) "
"AND \"table_id\" NOT IN (select \"table_id\" from
\"tmp\".\"keys\" where \"type\" = 0) "
- "AND (\"table_id\", \"id\") IN (select \"table_id\",
min(\"id\") from \"tmp\".\"keys\" where \"type\" = 1 group by \"table_id\"))",
+ "AND (\"table_id\", \"id\") IN (select \"table_id\",
min(\"id\") from \"tmp\".\"keys\" where \"type\" IN (1, 3) group by
\"table_id\"))",
querylen - pos);
}
/* 3rd cte: tableids */
@@ -310,7 +310,7 @@ MNDBSpecialColumns(ODBCStmt *stmt,
"SELECT c.\"name\", c.\"type\", c.\"type_digits\",
c.\"type_scale\", c.\"number\" "
"FROM tableids t "
"JOIN \"sys\".\"_columns\" c ON t.\"id\" =
c.\"table_id\" "
- "WHERE t.\"id\" NOT IN (SELECT \"table_id\" FROM
\"sys\".\"keys\" WHERE \"type\" in (0, 1))",
+ "WHERE t.\"id\" NOT IN (SELECT \"table_id\" FROM
\"sys\".\"keys\" WHERE \"type\" IN (0, 1, 3))",
querylen - pos);
/* add an extra selection when SQL_NO_NULLS is requested */
if (Nullable == SQL_NO_NULLS) {
@@ -322,7 +322,7 @@ MNDBSpecialColumns(ODBCStmt *stmt,
"SELECT c.\"name\", c.\"type\", c.\"type_digits\",
c.\"type_scale\", c.\"number\" "
"FROM tableids t "
"JOIN \"tmp\".\"_columns\" c ON t.\"id\" =
c.\"table_id\" "
- "WHERE t.\"id\" NOT IN (SELECT \"table_id\" FROM
\"tmp\".\"keys\" WHERE \"type\" in (0, 1))",
+ "WHERE t.\"id\" NOT IN (SELECT \"table_id\" FROM
\"tmp\".\"keys\" WHERE \"type\" IN (0, 1, 3))",
querylen - pos);
/* add an extra selection when SQL_NO_NULLS is
requested */
if (Nullable == SQL_NO_NULLS) {
diff --git a/clients/odbc/driver/SQLStatistics.c
b/clients/odbc/driver/SQLStatistics.c
--- a/clients/odbc/driver/SQLStatistics.c
+++ b/clients/odbc/driver/SQLStatistics.c
@@ -212,7 +212,7 @@ MNDBStatistics(ODBCStmt *stmt,
"join sys.schemas s on t.schema_id = s.id "
"join sys.objects kc on i.id = kc.id "
"join sys._columns c on (t.id = c.table_id and kc.name =
c.name) "
- "%sjoin sys.keys k on (k.name = i.name and i.table_id =
k.table_id and k.type in (0, 1)) "
+ "%sjoin sys.keys k on (k.name = i.name and i.table_id =
k.table_id and k.type in (0, 1, 3)) "
"join sys.storage() st on (st.schema = s.name and st.table =
t.name and st.column = c.name) "
"where 1=1",
SQL_INDEX_HASHED, SQL_INDEX_OTHER,
@@ -261,7 +261,7 @@ MNDBStatistics(ODBCStmt *stmt,
"join sys.schemas s on t.schema_id = s.id "
"join tmp.objects kc on i.id = kc.id "
"join tmp._columns c on (t.id = c.table_id and kc.name
= c.name) "
- "%sjoin tmp.keys k on (k.name = i.name and i.table_id =
k.table_id and k.type in (0, 1))"
+ "%sjoin tmp.keys k on (k.name = i.name and i.table_id =
k.table_id and k.type in (0, 1, 3))"
"left outer join sys.storage() st on (st.schema =
s.name and st.table = t.name and st.column = c.name) "
"where 1=1",
SQL_INDEX_HASHED, SQL_INDEX_OTHER,
@@ -284,7 +284,6 @@ MNDBStatistics(ODBCStmt *stmt,
pos += snprintf(query + pos, querylen - pos, " and %s",
tab);
}
}
- assert(pos < (querylen - 74));
if (sch)
free(sch);
diff --git a/sql/scripts/10_sys_schema_extension.sql
b/sql/scripts/10_sys_schema_extension.sql
--- a/sql/scripts/10_sys_schema_extension.sql
+++ b/sql/scripts/10_sys_schema_extension.sql
@@ -399,7 +399,7 @@ CREATE TABLE sys.key_types (
key_type_name VARCHAR(35) NOT NULL UNIQUE);
-- Values taken from sql/include/sql_catalog.h see typedef enum
--- key_type: pkey, ukey, fkey.
+-- key_type: pkey, ukey, fkey, unndkey, ckey.
INSERT INTO sys.key_types (key_type_id, key_type_name) VALUES
(0, 'Primary Key'),
(1, 'Unique Key'),
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -408,23 +408,30 @@ load_key(sql_trans *tr, sql_table *t, re
nk->columns = list_create((fdestroy) &kc_destroy);
nk->t = t;
- if (ktype == ckey) {
+ switch (ktype) {
+ case ckey:
str ch = (char*)store->table_api.table_fetch_value(rt_keys,
find_sql_column(keys, "check"));
if (!strNil(ch))
nk->check =_STRDUP(ch);
- }
- else if (ktype == ukey || ktype == pkey) {
+ break;
+ case ukey:
+ case unndkey:
+ case pkey: {
sql_ukey *uk = (sql_ukey *) nk;
if (ktype == pkey)
t->pkey = uk;
- } else {
+ break;
+ }
+ case fkey: {
sql_fkey *fk = (sql_fkey *) nk;
int action = *(int*)store->table_api.table_fetch_value(rt_keys,
find_sql_column(keys, "action"));
fk->on_delete = action & 255;
fk->on_update = (action>>8) & 255;
fk->rkey = *(sqlid*)store->table_api.table_fetch_value(rt_keys,
find_sql_column(keys, "rkey"));
+ break;
+ }
}
for ( ; rt_keycols->cur_row < rt_keycols->nr_rows;
rt_keycols->cur_row++) {
diff --git a/sql/test/emptydb/Tests/check.stable.out.int128
b/sql/test/emptydb/Tests/check.stable.out.int128
--- a/sql/test/emptydb/Tests/check.stable.out.int128
+++ b/sql/test/emptydb/Tests/check.stable.out.int128
@@ -5597,7 +5597,7 @@ select 'null in fkeys.delete_action', de
% .%1, .key_types # table_name
% %1, key_type_name # name
% varchar, varchar # type
-% 13, 11 # length
+% 13, 34 # length
[ "sys.key_types", "Check Constraint" ]
[ "sys.key_types", "Foreign Key" ]
[ "sys.key_types", "Primary Key" ]
@@ -6057,26 +6057,26 @@ select 'null in fkeys.delete_action', de
% %237, id, id, name, schema_id, table_id,
table_name, obj_type, sys_table, system # name
% varchar, int, int, varchar, int, int, varchar,
varchar, varchar, boolean # type
% 0, 1, 1, 0, 1, 1, 0, 0, 0, 5 #
length
-% .%5, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys # table_name
-% %5, id, id, table_id, type, name, rkey, action # name
-% varchar, int, int, int, int, varchar, int, int #
type
-% 0, 1, 1, 1, 1, 0, 1, 1 # length
-% .%5, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys # table_name
-% %5, table_id, id, table_id, type, name, rkey, action
# name
-% varchar, int, int, int, int, varchar, int, int #
type
-% 0, 1, 1, 1, 1, 0, 1, 1 # length
-% .%13, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys # table_name
-% %13, table_id, id, table_id, type, name, rkey, action
# name
-% varchar, int, int, int, int, varchar, int, int #
type
-% 0, 1, 1, 1, 1, 0, 1, 1 # length
-% .%5, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys # table_name
-% %5, type, id, table_id, type, name, rkey, action # name
-% varchar, int, int, int, int, varchar, int, int #
type
-% 0, 1, 1, 1, 1, 0, 1, 1 # length
-% .%5, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys # table_name
-% %5, rkey, id, table_id, type, name, rkey, action # name
-% varchar, int, int, int, int, varchar, int, int #
type
-% 0, 1, 1, 1, 1, 0, 1, 1 # length
+% .%5, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys, sys.keys # table_name
+% %5, id, id, table_id, type, name, rkey, action, check #
name
+% varchar, int, int, int, int, varchar, int, int,
varchar # type
+% 0, 1, 1, 1, 1, 0, 1, 1, 0 # length
+% .%5, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys, sys.keys # table_name
+% %5, table_id, id, table_id, type, name, rkey, action,
check # name
+% varchar, int, int, int, int, varchar, int, int,
varchar # type
+% 0, 1, 1, 1, 1, 0, 1, 1, 0 # length
+% .%13, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys, sys.keys # table_name
+% %13, table_id, id, table_id, type, name, rkey, action,
check # name
+% varchar, int, int, int, int, varchar, int, int,
varchar # type
+% 0, 1, 1, 1, 1, 0, 1, 1, 0 # length
+% .%5, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys, sys.keys # table_name
+% %5, type, id, table_id, type, name, rkey, action, check #
name
+% varchar, int, int, int, int, varchar, int, int,
varchar # type
+% 0, 1, 1, 1, 1, 0, 1, 1, 0 # length
+% .%5, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys, sys.keys # table_name
+% %5, rkey, id, table_id, type, name, rkey, action, check #
name
+% varchar, int, int, int, int, varchar, int, int,
varchar # type
+% 0, 1, 1, 1, 1, 0, 1, 1, 0 # length
% .%5, sys.idxs, sys.idxs, sys.idxs, sys.idxs,
sys.idxs # table_name
% %5, id, id, table_id, type, name # name
% varchar, int, int, int, int, varchar # type
@@ -6353,14 +6353,14 @@ select 'null in fkeys.delete_action', de
% %5, partition_id, table_id, partition_id, value # name
% varchar, int, int, int, varchar # type
% 0, 1, 1, 1, 0 # length
-% .%10, .%4, .keys, .keys, .keys, .keys, .keys, .keys #
table_name
-% %10, %4, id, table_id, type, name, rkey, action # name
-% varchar, smallint, int, int, int, varchar, int,
int # type
-% 0, 1, 1, 1, 1, 0, 1, 1 # length
-% .%10, .%4, .keys, .keys, .keys, .keys, .keys, .keys #
table_name
-% %10, %4, id, table_id, type, name, rkey, action # name
-% varchar, smallint, int, int, int, varchar, int,
int # type
-% 0, 1, 1, 1, 1, 0, 1, 1 # length
+% .%10, .%4, .keys, .keys, .keys, .keys, .keys, .keys, .keys #
table_name
+% %10, %4, id, table_id, type, name, rkey, action, check #
name
+% varchar, smallint, int, int, int, varchar, int,
int, varchar # type
+% 0, 1, 1, 1, 1, 0, 1, 1, 0 # length
+% .%10, .%4, .keys, .keys, .keys, .keys, .keys, .keys, .keys #
table_name
+% %10, %4, id, table_id, type, name, rkey, action, check #
name
+% varchar, smallint, int, int, int, varchar, int,
int, varchar # type
+% 0, 1, 1, 1, 1, 0, 1, 1, 0 # length
% .%30, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys,
.fkeys, .fkeys, .fkeys, .fkeys, .fkeys, .fkeys # table_name
% %30, id, table_id, type, name, rkey, id, table_id,
type, name, rkey, update_action_id, update_action,
delete_action_id, delete_action # name
% varchar, int, int, int, varchar, int, int, int,
int, varchar, int, smallint, varchar, smallint,
varchar # type
@@ -6597,30 +6597,30 @@ select 'null in fkeys.delete_action', de
% %1, key_type_name, key_type_id, key_type_name # name
% varchar, varchar, smallint, varchar # type
% 0, 0, 1, 0 # length
-% .%1, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys # table_name
-% %1, id, id, table_id, type, name, rkey, action # name
-% varchar, int, int, int, int, varchar, int, int #
type
-% 0, 1, 1, 1, 1, 0, 1, 1 # length
-% .%1, sys.keys, sys.keys, sys.keys, sys.keys,
sys.keys, sys.keys, sys.keys # table_name
-% %1, table_id, id, table_id, type, name, rkey, action
# name
-% varchar, int, int, int, int, varchar, int, int #
type
-% 0, 1, 1, 1, 1, 0, 1, 1 # length
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]