Skip to content

Commit b7b8efa

Browse files
authored
deps: bump Spanner to 6.23.3 (#862)
Bumps Spanner to 6.23.3 and modifies SQL script test files to reflect the changes for client side statements for PG. Replaces #788
1 parent 61ba9be commit b7b8efa

25 files changed

+19569
-4288
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<dependency>
6363
<groupId>com.google.cloud</groupId>
6464
<artifactId>google-cloud-spanner-bom</artifactId>
65-
<version>6.21.2</version>
65+
<version>6.23.3</version>
6666
<type>pom</type>
6767
<scope>import</scope>
6868
</dependency>

src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionGeneratedSqlScriptTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.google.cloud.spanner.connection.AbstractSqlScriptVerifier.GenericConnectionProvider;
2727
import com.google.cloud.spanner.connection.ConnectionImplTest;
2828
import com.google.cloud.spanner.connection.ConnectionOptions;
29-
import com.google.cloud.spanner.connection.SqlScriptVerifier;
3029
import com.google.cloud.spanner.jdbc.JdbcSqlScriptVerifier.JdbcGenericConnection;
3130
import java.sql.SQLException;
3231
import org.junit.Test;
@@ -62,7 +61,7 @@ public GenericConnection getConnection() {
6261
ConnectionOptions options = mock(ConnectionOptions.class);
6362
when(options.getUri()).thenReturn(ConnectionImplTest.URI);
6463
com.google.cloud.spanner.connection.Connection spannerConnection =
65-
ConnectionImplTest.createConnection(options);
64+
ConnectionImplTest.createConnection(options, dialect);
6665
when(spannerConnection.getDialect()).thenReturn(dialect);
6766
when(options.getConnection()).thenReturn(spannerConnection);
6867
try {
@@ -82,7 +81,8 @@ public GenericConnection getConnection() {
8281
@Test
8382
public void testGeneratedScript() throws Exception {
8483
JdbcSqlScriptVerifier verifier = new JdbcSqlScriptVerifier(new TestConnectionProvider(dialect));
84+
String prefix = dialect == Dialect.POSTGRESQL ? "PostgreSQL/" : "";
8585
verifier.verifyStatementsInFile(
86-
"ConnectionImplGeneratedSqlScriptTest.sql", SqlScriptVerifier.class, false);
86+
prefix + "ConnectionImplGeneratedSqlScriptTest.sql", getClass(), false);
8787
}
8888
}

src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private com.google.cloud.spanner.ResultSet createSelect1ResultSet() {
7676

7777
private JdbcConnection createConnection(ConnectionOptions options) throws SQLException {
7878
com.google.cloud.spanner.connection.Connection spannerConnection =
79-
ConnectionImplTest.createConnection(options);
79+
ConnectionImplTest.createConnection(options, dialect);
8080
when(spannerConnection.getDialect()).thenReturn(dialect);
8181
when(options.getConnection()).thenReturn(spannerConnection);
8282
return new JdbcConnection(
@@ -157,10 +157,13 @@ public void testRollback() throws SQLException {
157157
// verify that there is no transaction started anymore
158158
assertThat(connection.getSpannerConnection().isTransactionStarted()).isFalse();
159159
// verify that there is no commit timestamp
160-
try (ResultSet rs =
161-
connection.createStatement().executeQuery("show variable commit_timestamp")) {
160+
String showCommitTimestamp =
161+
dialect == Dialect.POSTGRESQL
162+
? "show spanner.commit_timestamp"
163+
: "show variable commit_timestamp";
164+
try (ResultSet rs = connection.createStatement().executeQuery(showCommitTimestamp)) {
162165
assertThat(rs.next()).isTrue();
163-
assertThat(rs.getTimestamp("COMMIT_TIMESTAMP")).isNull();
166+
assertThat(rs.getTimestamp(1)).isNull();
164167
}
165168
}
166169
}

src/test/java/com/google/cloud/spanner/jdbc/JdbcTimeoutSqlTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public static Object[] data() {
4646
@Test
4747
public void testTimeoutScript() throws Exception {
4848
JdbcSqlScriptVerifier verifier = new JdbcSqlScriptVerifier(new TestConnectionProvider(dialect));
49-
verifier.verifyStatementsInFile("TimeoutSqlScriptTest.sql", getClass(), false);
49+
String prefix = dialect == Dialect.POSTGRESQL ? "PostgreSQL/" : "";
50+
verifier.verifyStatementsInFile(prefix + "TimeoutSqlScriptTest.sql", getClass(), false);
5051
}
5152
}

src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcQueryOptionsTest.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,19 @@ public Dialect getDialect() {
110110
return dialect.dialect;
111111
}
112112

113+
private String getNamespace() {
114+
return getDialect() == Dialect.POSTGRESQL ? "SPANNER." : "";
115+
}
116+
113117
private void verifyOptimizerVersion(Connection connection, String expectedVersion)
114118
throws SQLException {
115119
try (ResultSet rs =
116-
connection.createStatement().executeQuery("SHOW VARIABLE OPTIMIZER_VERSION")) {
120+
connection
121+
.createStatement()
122+
.executeQuery(String.format("SHOW VARIABLE %sOPTIMIZER_VERSION", getNamespace()))) {
117123
assertThat(rs.next()).isTrue();
118-
assertThat(rs.getString("OPTIMIZER_VERSION")).isEqualTo(expectedVersion);
124+
assertThat(rs.getString(String.format("%sOPTIMIZER_VERSION", getNamespace())))
125+
.isEqualTo(expectedVersion);
119126
assertThat(rs.next()).isFalse();
120127
}
121128
}
@@ -153,7 +160,9 @@ public void connectionUrlWithInvalidOptimizerVersion() throws SQLException {
153160
public void setOptimizerVersion() throws SQLException {
154161
try (Connection connection = createConnection(env, database)) {
155162
verifyOptimizerVersion(connection, "");
156-
connection.createStatement().execute("SET OPTIMIZER_VERSION='1'");
163+
connection
164+
.createStatement()
165+
.execute(String.format("SET %sOPTIMIZER_VERSION='1'", getNamespace()));
157166
verifyOptimizerVersion(connection, "1");
158167
try (ResultSet rs = connection.createStatement().executeQuery("SELECT 1")) {
159168
assertThat(rs.next()).isTrue();
@@ -167,7 +176,9 @@ public void setOptimizerVersion() throws SQLException {
167176
public void setLatestOptimizerVersion() throws SQLException {
168177
try (Connection connection = createConnection(env, database)) {
169178
verifyOptimizerVersion(connection, "");
170-
connection.createStatement().execute("SET OPTIMIZER_VERSION='LATEST'");
179+
connection
180+
.createStatement()
181+
.execute(String.format("SET %sOPTIMIZER_VERSION='LATEST'", getNamespace()));
171182
verifyOptimizerVersion(connection, "LATEST");
172183
try (ResultSet rs = connection.createStatement().executeQuery("SELECT 1")) {
173184
assertThat(rs.next()).isTrue();
@@ -182,7 +193,9 @@ public void setInvalidOptimizerVersion() throws SQLException {
182193
assumeFalse(
183194
"optimizer version is ignored on emulator", EmulatorSpannerHelper.isUsingEmulator());
184195
try (Connection connection = createConnection(env, database)) {
185-
connection.createStatement().execute("SET OPTIMIZER_VERSION='9999999'");
196+
connection
197+
.createStatement()
198+
.execute(String.format("SET %sOPTIMIZER_VERSION='9999999'", getNamespace()));
186199
try (ResultSet rs = connection.createStatement().executeQuery("SELECT 1")) {
187200
fail("missing expected exception");
188201
} catch (SQLException e) {

src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcReadWriteAutocommitTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ public void test02_WriteMutation() throws Exception {
101101
connection.write(
102102
Mutation.newInsertBuilder("TEST").set("ID").to(9999L).set("NAME").to("FOO").build());
103103
java.sql.Statement statement = connection.createStatement();
104-
statement.execute("SHOW VARIABLE COMMIT_TIMESTAMP");
104+
statement.execute(
105+
String.format(
106+
"SHOW VARIABLE %sCOMMIT_TIMESTAMP",
107+
getDialect() == Dialect.POSTGRESQL ? "SPANNER." : ""));
105108
try (java.sql.ResultSet rs = statement.getResultSet()) {
106109
assertThat(rs.next(), is(true));
107110
assertThat(rs.getTimestamp(1), is(notNullValue()));

0 commit comments

Comments
 (0)