Repository navigation
fix(databend): read statements as the server does in Safe Mode - #4044
Merged
Merged
Conversation
Safe Mode now also reads Databend text with a port of its tokenizer, shared with the parameter binder. StarRocks bound values keep a form feed raw, and their -- comments end at a carriage return.
datlechin
enabled auto-merge (squash)
November 4, 2026 15:52
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
DROPas aSELECTwhen it sat behind an optimizer hint holding a quote, a stage name,$$or another hint, or, on servers before 1.2.884, behind a comment such as/** x **/. The server read the hint's body as tokens and ran theDROP.SETTINGS (...) DROP TABLE tandCREATE OR REPLACE TABLE中 (...)as plain writes. Databend runs the statement underSETTINGS, and from 1.2.888 ends a keyword where a non-ASCII name starts.DatabendTokenizerin TableProSQLGrammar reads text the way Databend's tokenizer does, with each rule a release since 1.2.473 changed. The parameter binder and the statement gate both use it.\fasf. A--comment ends at a carriage return. A$$inside a name or a number opens nothing, and nothing after a$$the statement leaves open is bound.Test plan
apple/scripts/probes/check-databend-lexing.shpasses against Databend 1.2.880 and 1.2.958 in Docker, now with each text above that dropped or replaced a table.apple/scripts/probes/check-starrocks-literals.shpasses against StarRocks 4.1.7 in Docker.DatabendTokenizerTests,DatabendStatementReadingsTests(TableProSQLGrammarTests),QueryClassifierLexicalTests.databendSkippedHintDoesNotHideADrop,StarRocksLiteralTests(form feed, round trip through a port of StarRocks' reader, carriage return,$$in names and attachments).SQLLexicalFeatureMappingTests, since Databend's grammar gains a fact only the app's table sets.DatabendLiteralTestspass unchanged on the shared tokenizer.