create database db1;
create type db1.typ as enum('a', 'b', 'c');
create table db1.t (i int primary key, j db1.typ);
create database db2;
create table db2.t as table db1.t; -- Troubling stmt
There are two issues of the last CTAS stmt:
- It succeeded even if column
j references a user-defined type in another database. We should disallow this because if we were to create this table db2.t manually, we get ERROR: cross database type references are not supported: db1.public.typ.
- It succeeded but
show create table db2.t gives
CREATE TABLE public.t (
i INT8 NULL,
j db1.public.typ NULL,
rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
CONSTRAINT t_pkey PRIMARY KEY (rowid ASC)
)
where a new rowid column is inserted as primary key but the original table (db1.t) does not have it and instead has column i as its primary key column.
Jira issue: CRDB-29013
Epic CRDB-27601
There are two issues of the last CTAS stmt:
jreferences a user-defined type in another database. We should disallow this because if we were to create this tabledb2.tmanually, we getERROR: cross database type references are not supported: db1.public.typ.show create table db2.tgiveswhere a new
rowidcolumn is inserted as primary key but the original table (db1.t) does not have it and instead has columnias its primary key column.Jira issue: CRDB-29013
Epic CRDB-27601