Changeset: 0c0bfc98981e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0c0bfc98981e
Modified Files:
sql/server/rel_schema.c
sql/test/miscellaneous/Tests/simple_selects.test
Branch: unlogged
Log Message:
Do not allow foreign key relations between unlogged and logged tables.
diffs (78 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
@@ -443,6 +443,10 @@ column_constraint_type(mvc *sql, const c
(void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT
FOREIGN KEY: cannot create foreign key between temporary and non temporary
tables");
return res;
}
+ if (isUnloggedTable(t) != isUnloggedTable(rt)) { /* 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 res;
+ }
if (!ns || !*ns) { /* add this to be safe */
(void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT
FOREIGN KEY: key name name cannot be empty");
return res;
@@ -697,6 +701,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 (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;
+ }
if (!ns || !*ns) { /* add this to be safe */
(void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT
FOREIGN KEY: key name name cannot be empty");
return SQL_ERR;
diff --git a/sql/test/miscellaneous/Tests/simple_selects.test
b/sql/test/miscellaneous/Tests/simple_selects.test
--- a/sql/test/miscellaneous/Tests/simple_selects.test
+++ b/sql/test/miscellaneous/Tests/simple_selects.test
@@ -1010,6 +1010,18 @@ statement ok
START TRANSACTION
statement ok
+create table foo (i int primary key)
+
+statement error 42000!CONSTRAINT FOREIGN KEY: cannot create foreign key
between temporary and non temporary tables
+create temp table bar (i int, FOREIGN KEY (i) REFERENCES foo(i))
+
+statement ok
+ROLLBACK
+
+statement ok
+START TRANSACTION
+
+statement ok
create temp table foo (i int primary key) on commit preserve rows
statement error 42000!CONSTRAINT FOREIGN KEY: cannot create foreign key
between temporary and non temporary tables
@@ -1018,6 +1030,30 @@ create table bar (i int, FOREIGN KEY (i)
statement ok
ROLLBACK
+statement ok
+START TRANSACTION
+
+statement ok
+create unlogged table foo (i int primary key)
+
+statement error 42000!CONSTRAINT FOREIGN KEY: cannot create foreign key
between logged and unlogged tables
+create table bar (i int, FOREIGN KEY (i) REFERENCES foo(i))
+
+statement ok
+ROLLBACK
+
+statement ok
+START TRANSACTION
+
+statement ok
+create table foo (i int primary key)
+
+statement error 42000!CONSTRAINT FOREIGN KEY: cannot create foreign key
between logged and unlogged tables
+create unlogged table bar (i int, FOREIGN KEY (i) REFERENCES foo(i))
+
+statement ok
+ROLLBACK
+
# some private functions related errors
statement error 42000!SELECT: no such binary operator
'scale_up'(decimal,tinyint)
select scale_up(12.1, 10)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]