{{ message }}
This repository was archived by the owner on Apr 7, 2026. It is now read-only.
fix: fix unclosed literal error for consecutive backslashes#4387
Merged
Conversation
Contributor
Contributor
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a parsing issue with consecutive backslashes in SQL string literals by toggling the escape state. The changes in SpannerStatementParser.java are logical and the new tests in SpannerStatementParserTest.java effectively validate the fix for removeCommentsAndTrim. I've added a couple of suggestions for further improvement.
rahul2393
approved these changes
Mar 17, 2026
gcf-merge-on-green Bot
pushed a commit
that referenced
this pull request
Mar 17, 2026
🤖 I have created a release *beep* *boop* --- ## [6.112.0](https://togithub.com/googleapis/java-spanner/compare/v6.111.1...v6.112.0) (2026-03-17) ### Features * Ability to update credentials on long running client ([#4371](https://togithub.com/googleapis/java-spanner/issues/4371)) ([e238990](https://togithub.com/googleapis/java-spanner/commit/e238990077badb063b1b05b0d71f58859434f7ee)) * Add SI, adapt, split point related proto ([7aa4d90](https://togithub.com/googleapis/java-spanner/commit/7aa4d90cd4f001713ee2b0b5113303a748b237e0)) * **spanner:** Include cache updates and routing hint into BeginTransaction and Commit request/response respectively ([7aa4d90](https://togithub.com/googleapis/java-spanner/commit/7aa4d90cd4f001713ee2b0b5113303a748b237e0)) ### Bug Fixes * **deps:** Update the Java code generator (gapic-generator-java) to 2.67.0 ([7aa4d90](https://togithub.com/googleapis/java-spanner/commit/7aa4d90cd4f001713ee2b0b5113303a748b237e0)) * Fix unclosed literal error for consecutive backslashes ([#4387](https://togithub.com/googleapis/java-spanner/issues/4387)) ([f4884a8](https://togithub.com/googleapis/java-spanner/commit/f4884a83d15dcff6e246c7db47c8bafc3369a0a3)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Issue: SpannerStatementParser
failed to correctly parse SQL string literals containing consecutive backslashes (e.g., SELECT '\'). When two backslashes were placed together, the parser would incorrectly assume the character immediately following them (like a closing quote) was being escaped. This caused the parser to skip the closing quote and eventually throw an INVALID_ARGUMENT: SQL statement contains an unclosed literal exception on valid SQL.
Fix: Updated SpannerStatementParser.java
to toggle the boolean escape state (lastCharWasEscapeChar = !lastCharWasEscapeChar;) when encountering a backslash. This ensures consecutive backslashes correctly cancel each other out in pairs, perfectly preserving the string literal boundaries.