Skip to content

Commit 111f74c

Browse files
authored
feat: support PG show transaction isolation level (#1777)
* feat: support PG show transaction isolation level Adds support for the PostgreSQL statement SHOW TRANSACTION ISOLATION LEVEL. This statement is used by the PG JDBC driver to get the isolation level of a connection. The statement will always return the static string 'serializable', as that is the only isolation level Spangres supports. * build: force rebuild
1 parent 6550a9d commit 111f74c

File tree

6 files changed

+9820
-9803
lines changed

6 files changed

+9820
-9803
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionStatementExecutor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,6 @@ StatementResult statementSetPgSessionCharacteristicsTransactionMode(
109109
StatementResult statementSetRPCPriority(Priority priority);
110110

111111
StatementResult statementShowRPCPriority();
112+
113+
StatementResult statementShowTransactionIsolationLevel();
112114
}

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionStatementExecutorImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.SHOW_RPC_PRIORITY;
5050
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.SHOW_STATEMENT_TAG;
5151
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.SHOW_STATEMENT_TIMEOUT;
52+
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.SHOW_TRANSACTION_ISOLATION_LEVEL;
5253
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.SHOW_TRANSACTION_TAG;
5354
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.START_BATCH_DDL;
5455
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.START_BATCH_DML;
@@ -436,4 +437,9 @@ public StatementResult statementShowRPCPriority() {
436437
: getConnection().getRPCPriority(),
437438
SHOW_RPC_PRIORITY);
438439
}
440+
441+
@Override
442+
public StatementResult statementShowTransactionIsolationLevel() {
443+
return resultSet("transaction_isolation", "serializable", SHOW_TRANSACTION_ISOLATION_LEVEL);
444+
}
439445
}

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/StatementResult.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ enum ClientSideStatementType {
8282
RUN_BATCH,
8383
ABORT_BATCH,
8484
SET_RPC_PRIORITY,
85-
SHOW_RPC_PRIORITY
85+
SHOW_RPC_PRIORITY,
86+
SHOW_TRANSACTION_ISOLATION_LEVEL
8687
}
8788

8889
/**

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@
125125
"method": "statementShowRPCPriority",
126126
"exampleStatements": ["show spanner.rpc_priority","show variable spanner.rpc_priority"]
127127
},
128+
{
129+
"name": "SHOW [VARIABLE] TRANSACTION ISOLATION LEVEL",
130+
"executorName": "ClientSideStatementNoParamExecutor",
131+
"resultType": "RESULT_SET",
132+
"regex": "(?is)\\A\\s*show\\s+(?:variable\\s+)?transaction\\s*isolation\\s*level\\s*\\z",
133+
"method": "statementShowTransactionIsolationLevel",
134+
"exampleStatements": ["show transaction isolation level","show variable transaction isolation level"]
135+
},
128136
{
129137
"name": "{START | BEGIN} [TRANSACTION | WORK] [{ (READ ONLY|READ WRITE) | (ISOLATION LEVEL (DEFAULT|SERIALIZABLE)) }]",
130138
"executorName": "ClientSideStatementPgBeginExecutor",

0 commit comments

Comments
 (0)