Skip to content

fix(databend): keep table names and bound values intact - #4041

Merged
datlechin merged 3 commits into
mainfrom
fix/databend-quoting-and-literals
Nov 4, 2026
Merged

datlechin merged 3 commits into
mainfrom
fix/databend-quoting-and-literals

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • A Databend table whose name holds a backtick, such as orders`backup, was browsed, filtered, edited and exported as another table: the app doubled the backtick, and Databend before 1.2.945 ends a backtick name at the next one. Such a name is now written in double quotes, the spelling the driver already used.
  • The driver's double-quoted spelling doubled every backslash, which Databend keeps as written, so it named another object. Only the quote is doubled now.
  • A bound value holding NUL before an octal digit was written as \0, which Databend reads as one octal escape with the digits, so a grid edit or delete could match another row. NUL is now \x00, as Databend writes it.
  • Binding values into a Databend statement now places each one where Databend's tokenizer reads a placeholder: block comments in both the current and the pre-1.2.884 form, hint bodies, form feeds, stage names, $$ after a name or a number, and operators. A statement older and newer servers read differently, such as one behind /** note **/ or /**/, is refused instead of bound.
  • Binding is refused on a Databend older than 1.2.473 (May 2024), whose tokenizer and decoders differ in ways the binder does not read.
  • Imports and copies into Databend charge a NUL four bytes against the 1 MiB statement budget, the length \x00 takes.
  • StarRocks keeps its binder unchanged, moved to StarRocksLiteral.

Test plan

  • apple/scripts/probes/check-databend-lexing.sh passes against Databend 1.2.880 and 1.2.958 in Docker. Rules from Databend's token.rs and quote.rs, with the changes in fc8867f and ce211e7.
  • Round trips through the real writers: SQLQuotingRoundTripTests.databendIdentifierRoundTrip reads SQLQuoting.databendIdentifier back under both backtick rules, and DatabendLiteralTests.literalRoundTrip reads DatabendLiteral.inline output back through a port of QuotedString.
  • New: DatabendIdentifierQuotingTests (browse, grid writes, builder, MCP export), DatabendLiteralTests (NUL, comment readings, hints, form feed, stage names, $$, operators, version floor), StarRocksLiteralTests, SQLWriteBatchBudgetTests.aNulIsChargedTheFourBytesDatabendWritesForIt.
  • Changed on purpose: DatabendCatalogTests (backslashes kept), DatabendLiteralTests (\x00).

@datlechin datlechin added the backport release/0.85 Merged into main; pick onto release/0.85 label Nov 4, 2026
@datlechin
datlechin enabled auto-merge (squash) November 4, 2026 12:08
@datlechin
datlechin merged commit df1f029 into main Nov 4, 2026
10 checks passed
@datlechin
datlechin deleted the fix/databend-quoting-and-literals branch November 5, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport release/0.85 Merged into main; pick onto release/0.85

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant