Description
The autocommit_before_ddl session setting is designed to commit an open transaction before executing a DDL statement. However, it currently skips the auto-commit if the DDL is the first statement in the transaction, leading to unintended use of the legacy schema changer.
Here are the steps to repro:
SET autocommit_before_ddl = ON;
BEGIN;
DROP TABLE t1;
DROP TABLE t2;
COMMIT;
The first DROP TABLE
does not trigger an auto-commit, resulting in the use of the legacy schema changer. The second DROP TABLE
triggers an auto-commit before execution, utilizing the declarative schema changer.
It is expected that both DROP TABLE statements should trigger an auto-commit before execution, ensuring the use of the declarative schema changer for both operations.
I think we should remove the optimization that skips the auto-commit when the transaction contains only a BEGIN statement. This change will ensure that the autocommit_before_ddl setting functions as intended, promoting consistent use of the declarative schema changer.
Jira issue: CRDB-47558
Activity