Skip to content

Commit

Permalink
feat: support PG show transaction isolation level (#1777)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
olavloite authored Mar 24, 2022
1 parent 6550a9d commit 111f74c
Show file tree
Hide file tree
Showing 6 changed files with 9,820 additions and 9,803 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,6 @@ StatementResult statementSetPgSessionCharacteristicsTransactionMode(
StatementResult statementSetRPCPriority(Priority priority);

StatementResult statementShowRPCPriority();

StatementResult statementShowTransactionIsolationLevel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.SHOW_RPC_PRIORITY;
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.SHOW_STATEMENT_TAG;
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.SHOW_STATEMENT_TIMEOUT;
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.SHOW_TRANSACTION_ISOLATION_LEVEL;
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.SHOW_TRANSACTION_TAG;
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.START_BATCH_DDL;
import static com.google.cloud.spanner.connection.StatementResult.ClientSideStatementType.START_BATCH_DML;
Expand Down Expand Up @@ -436,4 +437,9 @@ public StatementResult statementShowRPCPriority() {
: getConnection().getRPCPriority(),
SHOW_RPC_PRIORITY);
}

@Override
public StatementResult statementShowTransactionIsolationLevel() {
return resultSet("transaction_isolation", "serializable", SHOW_TRANSACTION_ISOLATION_LEVEL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ enum ClientSideStatementType {
RUN_BATCH,
ABORT_BATCH,
SET_RPC_PRIORITY,
SHOW_RPC_PRIORITY
SHOW_RPC_PRIORITY,
SHOW_TRANSACTION_ISOLATION_LEVEL
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@
"method": "statementShowRPCPriority",
"exampleStatements": ["show spanner.rpc_priority","show variable spanner.rpc_priority"]
},
{
"name": "SHOW [VARIABLE] TRANSACTION ISOLATION LEVEL",
"executorName": "ClientSideStatementNoParamExecutor",
"resultType": "RESULT_SET",
"regex": "(?is)\\A\\s*show\\s+(?:variable\\s+)?transaction\\s*isolation\\s*level\\s*\\z",
"method": "statementShowTransactionIsolationLevel",
"exampleStatements": ["show transaction isolation level","show variable transaction isolation level"]
},
{
"name": "{START | BEGIN} [TRANSACTION | WORK] [{ (READ ONLY|READ WRITE) | (ISOLATION LEVEL (DEFAULT|SERIALIZABLE)) }]",
"executorName": "ClientSideStatementPgBeginExecutor",
Expand Down
Loading

0 comments on commit 111f74c

Please sign in to comment.