Skip to content

Conversation

@olavloite
Copy link
Collaborator

@olavloite olavloite commented May 4, 2024

Adds support for running DDL statements when a connection is in autocommit=false mode. By default, DDL statements are only allowed when no transaction is active. That is; no query or DML statement has been executed which activated a read/write transaction.

A new flag is added that can be used to revert the behavior back to the original behavior where DDL is always refused when autocommit=false. The same flag can also be used to make the API behave the same as MySQL and Oracle, where any active transaction is automatically committed whenever a DDL statement is encountered.

Concretely this means that the following is now allowed:

set autocommit=false; create table Singers (SingerId INT64, Name STRING(MAX)) PRIMARY KEY (SingerId); 

The following is by default NOT allowed, unless
ddlInTransactionMode=AUTO_COMMIT_TRANSACTION

set autocommit=false; select * from singers; -- This starts a transaction create table Albums (AlbumId INT64) PRIMARY KEY (AlbumId); -- This is not allowed 
Adds support for running DDL statements when a connection is in autocommit=false mode. By default, DDL statements are only allowed when no transaction is active. That is; no query or DML statement has been executed which activated a read/write transaction. A new flag is added that can be used to revert the behavior back to the original behavior where DDL is always refused when autocommit=false. The same flag can also be used to make the API behave the same as MySQL and Oracle, where any active transaction is automatically committed whenever a DDL statement is encountered. Concretely this means that the following is now allowed: ``` set autocommit=false; create table Singers (SingerId INT64, Name STRING(MAX)) PRIMARY KEY (SingerId); ``` The following is by default NOT allowed, unless ddlInTransactionMode=AUTO_COMMIT_TRANSACTION ``` set autocommit=false; select * from singers; -- This starts a transaction create table Albums (AlbumId INT64) PRIMARY KEY (AlbumId); -- This is not allowed ```
@olavloite olavloite requested a review from a team as a code owner May 4, 2024 07:25
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: spanner Issues related to the googleapis/java-spanner-jdbc API. labels May 4, 2024
@olavloite olavloite merged commit a61c25d into main May 4, 2024
@olavloite olavloite deleted the ddl-in-autocommit-false branch May 4, 2024 08:00
gcf-merge-on-green bot pushed a commit that referenced this pull request May 4, 2024
🤖 I have created a release *beep* *boop* --- ## [2.18.0](https://togithub.com/googleapis/java-spanner-jdbc/compare/v2.17.1...v2.18.0) (2024-05-04) ### Features * Allow DDL with autocommit=false ([#1600](https://togithub.com/googleapis/java-spanner-jdbc/issues/1600)) ([a61c25d](https://togithub.com/googleapis/java-spanner-jdbc/commit/a61c25d8f90460ec507b383dbaee0ca686104ba8)) * Support concurrent transactions on the emulator ([#1601](https://togithub.com/googleapis/java-spanner-jdbc/issues/1601)) ([7123991](https://togithub.com/googleapis/java-spanner-jdbc/commit/71239912a8078569dcd985314810131e593c0ed7)) ### Bug Fixes * ClassCastException in Spring Data JDBC sample ([#1595](https://togithub.com/googleapis/java-spanner-jdbc/issues/1595)) ([e96a86a](https://togithub.com/googleapis/java-spanner-jdbc/commit/e96a86a4b82ac4b47bd1ce25e810f01299597339)) ### Dependencies * Update dependency com.google.cloud:google-cloud-spanner-bom to v6.66.0 ([#1599](https://togithub.com/googleapis/java-spanner-jdbc/issues/1599)) ([84ea11a](https://togithub.com/googleapis/java-spanner-jdbc/commit/84ea11ac27635dbe6fb101134767d14488dde8c2)) * Update dependency com.google.cloud:sdk-platform-java-config to v3.30.0 ([#1597](https://togithub.com/googleapis/java-spanner-jdbc/issues/1597)) ([40a7212](https://togithub.com/googleapis/java-spanner-jdbc/commit/40a721237c79882e55d86d48402c64cc09782522)) * Update dependency org.mybatis.dynamic-sql:mybatis-dynamic-sql to v1.5.1 ([#1596](https://togithub.com/googleapis/java-spanner-jdbc/issues/1596)) ([f54beb2](https://togithub.com/googleapis/java-spanner-jdbc/commit/f54beb20d6bbe3f4974385c4758ba77d31d25ce3)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/java-spanner-jdbc API. size: m Pull request size is medium.

1 participant