-
Notifications
You must be signed in to change notification settings - Fork 4.1k
CTAS: mistakenly allowed cross-db type references #105393
Copy link
Copy link
Closed
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)v23.1.5
Description
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
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. - It succeeded but
show create table db2.tgives
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)v23.1.5