Changeset: e7eacf25e47d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e7eacf25e47d Modified Files: sql/server/rel_schema.c Branch: unlogged Log Message:
Merge with default. diffs (55 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 @@ -435,6 +435,14 @@ column_constraint_type(mvc *sql, const c } if (!rt) return SQL_ERR; + if (!rt->s) { /* disable foreign key on declared table */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key with declared tables"); + return res; + } + if (isTempSchema(t->s) != isTempSchema(rt->s)) { /* disable foreign key between temp and non temp */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key between temporary and non temporary 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; @@ -681,6 +689,14 @@ table_foreign_key(mvc *sql, const char * int ref_actions = n->next->next->next->next->data.i_val; assert(n->next->next->next->next->type == type_int); + if (!ft->s) { /* disable foreign key on declared table */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key with declared tables"); + return SQL_ERR; + } + if (isTempSchema(t->s) != isTempSchema(ft->s)) { /* disable foreign key between temp and non temp */ + (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT FOREIGN KEY: cannot create foreign key between temporary and non temporary 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 @@ -1006,6 +1006,18 @@ drop index tmp.ups statement ok drop table x +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 +create 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 -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org