Skip to content

sql: autocommit_before_ddl may not commit before first DDL in txn #141034

Closed
@spilchen

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)branch-release-24.1Used to mark GA and release blockers, technical advisories, and bugs for 24.1branch-release-24.2Used to mark GA and release blockers, technical advisories, and bugs for 24.2branch-release-24.3Used to mark GA and release blockers, technical advisories, and bugs for 24.3branch-release-25.1target-release-25.2.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions