-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: restricted DDL / DML inside transactions #26508
Copy link
Copy link
Open
Labels
A-schema-changesA-schema-transactionalA-sql-pgcompatSemantic compatibility with PostgreSQLSemantic compatibility with PostgreSQLC-questionA question rather than an issue. No code/spec/doc change needed.A question rather than an issue. No code/spec/doc change needed.O-communityOriginated from the communityOriginated from the communityT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)X-anchored-telemetryThe issue number is anchored by telemetry references.The issue number is anchored by telemetry references.
Description
FEATURE REQUEST / BUG REPORT
I noticed the following sequences cannot be performed within a transaction. I tested using CockroachDB v1.1.8 and v2.0.2.
- Add a field to a table, then add a constraint on that field.
create table foo ();
begin;
savepoint cockroach_restart;
ALTER TABLE foo ADD COLUMN bar VARCHAR;
ALTER TABLE foo ADD CONSTRAINT bar CHECK (foo IN ('a', 'b', 'c', 'd'));
release savepoint cockroach_restart;
commit;
- Add a field to a table, then SELECT that field.
create table foo ();
begin;
savepoint cockroach_restart;
ALTER TABLE foo ADD COLUMN bar VARCHAR;
SELECT bar from foo;
release savepoint cockroach_restart;
commit;
Interestingly, you can select on an existing field:
create table foo (baz varchar);
begin;
savepoint cockroach_restart;
ALTER TABLE foo ADD COLUMN bar VARCHAR;
SELECT baz from foo;
release savepoint cockroach_restart;
commit;
I figured I'd list these here as they were not mentioned in the relevant known issues section here:
https://www.cockroachlabs.com/docs/stable/known-limitations.html#schema-changes-within-transactions
Jira issue: CRDB-5005
Epic CRDB-104
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-schema-changesA-schema-transactionalA-sql-pgcompatSemantic compatibility with PostgreSQLSemantic compatibility with PostgreSQLC-questionA question rather than an issue. No code/spec/doc change needed.A question rather than an issue. No code/spec/doc change needed.O-communityOriginated from the communityOriginated from the communityT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)X-anchored-telemetryThe issue number is anchored by telemetry references.The issue number is anchored by telemetry references.