Changeset: 1ccc04ab7ea3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1ccc04ab7ea3
Added Files:
        sql/test/BugTracker-2023/Tests/temp-table-foreign-key-crash-7378.test
Modified Files:
        sql/server/rel_schema.c
        sql/test/BugTracker-2023/Tests/All
Branch: Sep2022
Log Message:

add test and fix for bug #7378 (no foreign keys on temp tables)


diffs (33 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
@@ -711,6 +711,10 @@ table_foreign_key(mvc *sql, const char *
                        (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT 
FOREIGN KEY: cannot create foreign key between temporary and non temporary 
tables");
                        return SQL_ERR;
                }
+               if (isTempTable(ft) && !isGlobal(ft) && ft != t) { /* disable 
foreign key on local temporary table */
+                       (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT 
FOREIGN KEY: cannot create foreign key with local temporary tables");
+                       return SQL_ERR;
+               }
                if (isUnloggedTable(t) != isUnloggedTable(ft)) { /* disable 
foreign key between logged and unlogged */
                        (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT 
FOREIGN KEY: cannot create foreign key between logged and unlogged tables");
                        return SQL_ERR;
diff --git a/sql/test/BugTracker-2023/Tests/All 
b/sql/test/BugTracker-2023/Tests/All
--- a/sql/test/BugTracker-2023/Tests/All
+++ b/sql/test/BugTracker-2023/Tests/All
@@ -1,1 +1,2 @@
 ambiguous-identifiers-7372
+temp-table-foreign-key-crash-7378
diff --git 
a/sql/test/BugTracker-2023/Tests/temp-table-foreign-key-crash-7378.test 
b/sql/test/BugTracker-2023/Tests/temp-table-foreign-key-crash-7378.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2023/Tests/temp-table-foreign-key-crash-7378.test
@@ -0,0 +1,8 @@
+statement ok
+START TRANSACTION;
+
+statement ok
+CREATE TEMPORARY TABLE temptest3(col int PRIMARY KEY) ON COMMIT DROP;
+
+statement error
+CREATE TEMPORARY TABLE temptest4(col int, FOREIGN KEY (col) REFERENCES 
temptest3);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to