Changeset: 656978a96fde for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/656978a96fde
Modified Files:
sql/backends/monet5/sql_upgrades.c
sql/server/rel_schema.c
Branch: default
Log Message:
Merge with Aug2024 branch.
diffs (251 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
@@ -279,7 +279,7 @@ mvc_create_remote_as_subquery(mvc *sql,
static char *
table_constraint_name(mvc *sql, symbol *s, sql_schema *ss, sql_table *t)
{
- /* create a descriptive name like table_col_pkey */
+ /* create a descriptive name like table_col1_col2_pkey */
char *suffix; /* stores the type of this constraint */
dnode *nms = NULL;
char *buf;
@@ -287,24 +287,28 @@ table_constraint_name(mvc *sql, symbol *
switch (s->token) {
case SQL_UNIQUE:
- suffix = "_unique";
+ suffix = "unique";
+ nms = s->data.lval->h; /* list of columns */
+ break;
+ case SQL_UNIQUE_NULLS_NOT_DISTINCT:
+ suffix = "nndunique";
nms = s->data.lval->h; /* list of columns */
break;
case SQL_PRIMARY_KEY:
- suffix = "_pkey";
+ suffix = "pkey";
nms = s->data.lval->h; /* list of columns */
break;
case SQL_FOREIGN_KEY:
- suffix = "_fkey";
+ suffix = "fkey";
nms = s->data.lval->h->next->data.lval->h; /* list
of columns */
break;
case SQL_CHECK:
- suffix = "_check";
+ suffix = "check";
char name[512], name2[512], *nme, *nme2;
bool found;
do {
nme = number2name(name, sizeof(name),
++sql->label);
- buflen = snprintf(name2, sizeof(name2),
"%s_%s%s", t->base.name, nme, suffix);
+ buflen = snprintf(name2, sizeof(name2),
"%s_%s_%s", t->base.name, nme, suffix);
nme2 = name2;
found = ol_find_name(t->keys, nme2) ||
mvc_bind_key(sql, ss, nme2);
} while (found);
@@ -312,7 +316,7 @@ table_constraint_name(mvc *sql, symbol *
strcpy(buf, nme2);
return buf;
default:
- suffix = "_?";
+ suffix = "?";
nms = NULL;
}
@@ -340,13 +344,13 @@ table_constraint_name(mvc *sql, symbol *
/* add suffix */
slen = strlen(suffix);
- while (len + slen >= buflen) {
+ while (len + 1 + slen >= buflen) {
size_t nbuflen = buflen + BUFSIZ;
char *nbuf = SA_RENEW_ARRAY(sql->ta, char, buf, nbuflen,
buflen);
buf = nbuf;
buflen = nbuflen;
}
- snprintf(buf + len, buflen - len, "%s", suffix);
+ snprintf(buf + len, buflen - len, "_%s", suffix);
return buf;
}
@@ -398,7 +402,7 @@ static key_type
token2key_type(int token)
{
switch (token) {
- case SQL_UNIQUE: return
ukey;
+ case SQL_UNIQUE: return
ukey;
case SQL_UNIQUE_NULLS_NOT_DISTINCT: return unndkey;
case SQL_PRIMARY_KEY: return pkey;
case SQL_CHECK: return
ckey;
diff --git a/sql/test/2023/Tests/unique_nulls_distinct.test
b/sql/test/2023/Tests/unique_nulls_distinct.test
--- a/sql/test/2023/Tests/unique_nulls_distinct.test
+++ b/sql/test/2023/Tests/unique_nulls_distinct.test
@@ -7,6 +7,16 @@ CREATE TABLE und2 (i1 int, i2 int, UNIQU
statement ok
CREATE TABLE unnd1 (i1 int, i2 int, UNIQUE NULLS NOT DISTINCT (i1, i2))
+query IT rowsort
+SELECT type, name FROM sys.keys WHERE table_id IN (SELECT id FROM sys.tables
WHERE NOT system)
+----
+1
+und1_i1_i2_unique
+1
+und2_i1_i2_unique
+3
+unnd1_i1_i2_nndunique
+
statement ok
INSERT INTO und1 VALUES (NULL, 10)
@@ -56,6 +66,15 @@ statement error
INSERT INTO unnd1 VALUES (30, 10), (30, 10)
statement ok
+DROP TABLE und1
+
+statement ok
+DROP TABLE und2
+
+statement ok
+DROP TABLE unnd1
+
+statement ok
CREATE TABLE und3 (i1 int UNIQUE)
statement ok
@@ -64,6 +83,16 @@ CREATE TABLE und4 (i1 int UNIQUE NULLS D
statement ok
CREATE TABLE unnd2 (i1 int UNIQUE NULLS NOT DISTINCT)
+query IT rowsort
+SELECT type, name FROM sys.keys WHERE table_id IN (SELECT id FROM sys.tables
WHERE NOT system)
+----
+1
+und3_i1_unique
+1
+und4_i1_unique
+3
+unnd2_i1_nndunique
+
statement ok
INSERT INTO und3 VALUES (NULL)
@@ -121,3 +150,29 @@ INSERT INTO unnd2 VALUES (10), (20)
statement error
INSERT INTO unnd2 VALUES (30), (30)
+statement ok
+DROP TABLE und3
+
+statement ok
+DROP TABLE und4
+
+statement ok
+DROP TABLE unnd2
+
+statement ok
+create table abc(c1 int, c2 varchar(9), c3 dec(10,2), c4 double, primary key
(c1, c2), unique (c3, c2), unique nulls not distinct (c4, c2), unique nulls not
distinct (c3, c4))
+
+query IT rowsort
+SELECT type, name FROM sys.keys WHERE table_id IN (SELECT id FROM sys.tables
WHERE NOT system)
+----
+0
+abc_c1_c2_pkey
+1
+abc_c3_c2_unique
+3
+abc_c3_c4_nndunique
+3
+abc_c4_c2_nndunique
+
+statement ok
+DROP TABLE abc
diff --git a/sql/test/BugTracker-2025/Tests/7611_multiple_unnd_constraints.test
b/sql/test/BugTracker-2025/Tests/7611_multiple_unnd_constraints.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2025/Tests/7611_multiple_unnd_constraints.test
@@ -0,0 +1,24 @@
+statement ok
+CREATE TABLE tunnd0(c1 int, c2 varchar(9), c3 dec(10,2), UNIQUE NULLS NOT
DISTINCT (c1, c2), UNIQUE NULLS NOT DISTINCT (c2, c3))
+
+statement ok
+CREATE TABLE tunnd1(c1 int, c2 varchar(9), c3 dec(10,2), UNIQUE NULLS NOT
DISTINCT (c1, c2), UNIQUE NULLS DISTINCT (c2, c3))
+
+query TI rowsort
+SELECT name, type FROM sys.keys WHERE table_id IN (SELECT id FROM sys.tables
WHERE NOT system AND name LIKE 'tunnd%')
+----
+tunnd0_c1_c2_nndunique
+3
+tunnd0_c2_c3_nndunique
+3
+tunnd1_c1_c2_nndunique
+3
+tunnd1_c2_c3_unique
+1
+
+statement ok
+DROP TABLE IF EXISTS tunnd0
+
+statement ok
+DROP TABLE tunnd1
+
diff --git a/sql/test/BugTracker-2025/Tests/All
b/sql/test/BugTracker-2025/Tests/All
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2025/Tests/All
@@ -0,0 +1,1 @@
+7611_multiple_unnd_constraints
diff --git a/sql/test/BugTracker-2025/Tests/SingleServer
b/sql/test/BugTracker-2025/Tests/SingleServer
new file mode 100644
diff --git a/sql/test/bincopy/Tests/bincopy_blobs_on_client.timeout
b/sql/test/bincopy/Tests/bincopy_blobs_on_client.timeout
new file mode 100644
--- /dev/null
+++ b/sql/test/bincopy/Tests/bincopy_blobs_on_client.timeout
@@ -0,0 +1,1 @@
+2
diff --git a/sql/test/bincopy/Tests/bincopy_blobs_on_server.timeout
b/sql/test/bincopy/Tests/bincopy_blobs_on_server.timeout
new file mode 100644
--- /dev/null
+++ b/sql/test/bincopy/Tests/bincopy_blobs_on_server.timeout
@@ -0,0 +1,1 @@
+2
diff --git a/sql/test/testdb/Tests/dump-nogeom.stable.out
b/sql/test/testdb/Tests/dump-nogeom.stable.out
--- a/sql/test/testdb/Tests/dump-nogeom.stable.out
+++ b/sql/test/testdb/Tests/dump-nogeom.stable.out
@@ -101174,7 +101174,8 @@ CREATE TABLE "testschema"."keytest1" (
"key2" INTEGER NOT NULL,
"key3" INTEGER,
CONSTRAINT "keytest1_key1_key2_pkey" PRIMARY KEY ("key1", "key2"),
- CONSTRAINT "keytest1_key3_unique" UNIQUE ("key3")
+ CONSTRAINT "keytest1_key3_unique" UNIQUE ("key3"),
+ CONSTRAINT "keytest1_key1_key3_nndunique" UNIQUE NULLS NOT DISTINCT
("key1", "key3")
);
COPY 4 RECORDS INTO "testschema"."keytest1" FROM stdin USING DELIMITERS
E'\t',E'\n','"';
0 0 0
diff --git a/sql/test/testdb/Tests/dump.stable.out
b/sql/test/testdb/Tests/dump.stable.out
--- a/sql/test/testdb/Tests/dump.stable.out
+++ b/sql/test/testdb/Tests/dump.stable.out
@@ -101174,7 +101174,8 @@ CREATE TABLE "testschema"."keytest1" (
"key2" INTEGER NOT NULL,
"key3" INTEGER,
CONSTRAINT "keytest1_key1_key2_pkey" PRIMARY KEY ("key1", "key2"),
- CONSTRAINT "keytest1_key3_unique" UNIQUE ("key3")
+ CONSTRAINT "keytest1_key3_unique" UNIQUE ("key3"),
+ CONSTRAINT "keytest1_key1_key3_nndunique" UNIQUE NULLS NOT DISTINCT
("key1", "key3")
);
COPY 4 RECORDS INTO "testschema"."keytest1" FROM stdin USING DELIMITERS
E'\t',E'\n','"';
0 0 0
diff --git a/sql/test/testdb/Tests/load.test b/sql/test/testdb/Tests/load.test
--- a/sql/test/testdb/Tests/load.test
+++ b/sql/test/testdb/Tests/load.test
@@ -101244,7 +101244,8 @@ CREATE TABLE "testschema"."keytest1" (
"key2" INTEGER NOT NULL,
"key3" INTEGER,
CONSTRAINT "keytest1_key1_key2_pkey" PRIMARY KEY ("key1", "key2"),
- CONSTRAINT "keytest1_key3_unique" UNIQUE ("key3")
+ CONSTRAINT "keytest1_key3_unique" UNIQUE ("key3"),
+ CONSTRAINT "keytest1_key1_key3_nndunique" UNIQUE NULLS NOT DISTINCT
("key1", "key3")
)
statement ok
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]