You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
OS type and version: Microsoft Windows [Version 10.0.26100.7171]
Java version: openjdk version "21.0.2" 2024-01-16 LTS
version(s): com.google.cloud:google-cloud-spanner-jdbc:2.34.0 working with the latest docker pull gcr.io/cloud-spanner-emulator/emulator
Steps to reproduce
Code example
// Static statements work fineResultSetrs1 = connection.createStatement().executeQuery("select 'test\\\\'");
rs1.next();
println(rs1.getString(1));
// Prepared statements work fine if string literals don't end with \ResultSetrs2 = connection.prepareStatement("select 'test\\\\ '").executeQuery();
rs2.next();
println(rs2.getString(1));
// This failsResultSetrs3 = connection.prepareStatement("select 'test\\\\'").executeQuery();
rs3.next();
println(rs3.getString(1));
A workaround would be this:
select rtrim('test\\\\')
Stack trace
The above prints
test\
test\
com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory$JdbcSqlExceptionImpl: INVALID_ARGUMENT: SQL statement contains an unclosed literal: select 'test\\'
at com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.of(JdbcSqlExceptionFactory.java:221)
at com.google.cloud.spanner.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:63)
at com.google.cloud.spanner.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:149)
at com.google.cloud.spanner.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:143)
at com.google.cloud.spanner.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:64)
at org.jooq.testscripts.JDBC.main(JDBC.java:48)
Caused by: com.google.cloud.spanner.SpannerException: INVALID_ARGUMENT: SQL statement contains an unclosed literal: select 'test\\'
at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerExceptionPreformatted(SpannerExceptionFactory.java:396)
at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:69)
at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:75)
at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:61)
at com.google.cloud.spanner.connection.SpannerStatementParser.removeCommentsAndTrimInternal(SpannerStatementParser.java:210)
at com.google.cloud.spanner.connection.AbstractStatementParser.removeCommentsAndTrim(AbstractStatementParser.java:731)
at com.google.cloud.spanner.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:58)
... 4 more
Environment details
com.google.cloud:google-cloud-spanner-jdbc:2.34.0working with the latest docker pull gcr.io/cloud-spanner-emulator/emulatorSteps to reproduce
Code example
A workaround would be this:
Stack trace
The above prints