ALTER TABLE transaction scope

root@:26257/> BEGIN;
Now adding input for a multi-line SQL transaction client-side.
Press Enter two times to send the SQL text collected so far to the server, or Ctrl+C to cancel.
           -> ALTER TABLE "public"."C" ADD COLUMN "name2" TEXT;
           -> INSERT INTO "public"."C"(name2) VALUES ('a');
           -> COMMIT;
pq: column "name2" does not exist
root@:26257 ERROR>  

Looks like ALTER TABLE can not be followed by a INSERT.
I can’t see in the docs where the transactional behavior of schema changes are specified.
CREATE TABLE mentions it but not ALTER.

Is this a bug? If not are there plans to support it?

Hi @pieter, this is currently documented as a known issue. That suggests that the behavior might change in the future. @vivek, can you shed any light on whether we’ll allow DML statements followed by DDL statements in a single transaction?

In the meantime, though, the workaround is to split the ALTER TABLE and INSERT statements into separate transactions.

We do allow DDL statements in a transaction but not statements that need to run separate backfill operations. In this particular a backfill was not required so we should allow it. I’ll create an issue
https://github.com/cockroachdb/cockroach/issues/16841