cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
29.99k stars 3.79k forks source link

sql: ALTER TYPE...ADD VALUE hangs if there is any temporary table/view/sequence #97975

Open chengxiong-ruan opened 1 year ago

chengxiong-ruan commented 1 year ago

Describe the problem When adding a value to an enum type, we loop through all tables in the database to find out all regional tables (they could use enum type). And when looping through the tables (including the tmp table), we also do a look up of tables' parent schema descriptor (just for schema name), however, there is no descriptor for the tmp schema, so it error and stuck the job.

To fix this, we may return the temp schema name for temp tables instead of looking from descriptors.

To Reproduce

create type my_enum as enum ('value1', 'value2');
set experimental_enable_temp_tables = on;
create temporary table tmp_table (id int primary key);
insert into tmp_table values (1), (2), (3);
ALTER TYPE my_enum ADD VALUE 'value3';
-- it hangs

Expected behavior ALTER TYPE...ADD VALUE should succeed.

Environment: This bug exists in at least master, 22.2 and 22.1

Jira issue: CRDB-25002

gz#23016

chengxiong-ruan commented 1 year ago

This can be easily solved if we can support resolving temp schemas across sessions by ID as described in https://github.com/cockroachdb/cockroach/issues/97822

daniel-crlabs commented 1 month ago

This bug still a problem, latest: https://github.com/cockroachlabs/support/issues/3062 and https://cockroachdb.zendesk.com/agent/tickets/23016