Skip to content

sql: restricted DDL / DML inside transactions #26508

@gpaul

Description

@gpaul

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.

  1. 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;
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-schema-changesA-schema-transactionalA-sql-pgcompatSemantic compatibility with PostgreSQLC-questionA question rather than an issue. No code/spec/doc change needed.O-communityOriginated from the communityT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)X-anchored-telemetryThe issue number is anchored by telemetry references.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions