Skip to content

Commit 1000fdc

Browse files
Support in GoogleSQL dialect
1 parent 1b7f911 commit 1000fdc

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

google-cloud-spanner/src/main/resources/com/google/cloud/spanner/connection/ClientSideStatements.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,24 @@
753753
"converterName": "ClientSideStatementValueConverters$BooleanConverter"
754754
}
755755
},
756+
{
757+
"name": "SET LOCAL DML_BATCH_UPDATE_COUNT = <INT64>",
758+
"executorName": "ClientSideStatementSetExecutor",
759+
"resultType": "NO_RESULT",
760+
"statementType": "SET_DML_BATCH_UPDATE_COUNT",
761+
"regex": "(?is)\\A\\s*set\\s+((?:session|local)\\s+)dml_batch_update_count\\s*(?:=)\\s*(.*)\\z",
762+
"method": "statementSetDmlBatchUpdateCount",
763+
"exampleStatements": [
764+
"set local dml_batch_update_count = 0",
765+
"set local dml_batch_update_count = 100"
766+
],
767+
"setStatement": {
768+
"propertyName": "DML_BATCH_UPDATE_COUNT",
769+
"separator": "(?:=|\\s+TO\\s+)",
770+
"allowedValues": "(\\d{1,19})",
771+
"converterName": "ClientSideStatementValueConverters$LongConverter"
772+
}
773+
},
756774
{
757775
"name": "SHOW VARIABLE READ_LOCK_MODE",
758776
"executorName": "ClientSideStatementNoParamExecutor",

google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionAsyncApiTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,30 @@ public void testDmlBatchUpdateCount() {
365365
}
366366
}
367367

368+
@Test
369+
public void testDmlBatchUpdateCountGoogleSql() {
370+
SpannerPool.closeSpannerPool();
371+
try {
372+
try (Connection connection = createConnection()) {
373+
connection.execute(Statement.of("set local dml_batch_update_count = 1"));
374+
connection.execute(Statement.of("START BATCH DML"));
375+
List<Statement> statements = Arrays.asList(INSERT_STATEMENT, INSERT_STATEMENT);
376+
long[] updateCounts = connection.executeBatchUpdate(statements);
377+
assertThat(updateCounts).asList().containsExactly(1L, 1L);
378+
}
379+
try (Connection connection = createConnection()) {
380+
connection.execute(Statement.of("START BATCH DML"));
381+
List<Statement> statements = Arrays.asList(INSERT_STATEMENT, INSERT_STATEMENT);
382+
long[] updateCounts = connection.executeBatchUpdate(statements);
383+
assertThat(updateCounts).asList().containsExactly(-1L, -1L);
384+
}
385+
} finally {
386+
SpannerPool.closeSpannerPool();
387+
mockSpanner.putStatementResult(
388+
MockSpannerServiceImpl.StatementResult.detectDialectResult(Dialect.GOOGLE_STANDARD_SQL));
389+
}
390+
}
391+
368392
@Test
369393
public void testAutocommitRunBatchAsync() {
370394
try (Connection connection = createConnection()) {

0 commit comments

Comments
 (0)