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 }}
Repository navigation
Commit 8359bb5
Browse filesBrowse the repository at this point in the historyBrowse files
[fix](stream) Decode the STREAM comment string literal per sql mode
### What problem does this PR solve?
Issue Number: close#65388, related #65418
Related PR: #65810
Problem Summary:
Review follow-up for this PR. Two problems were found in the first revision.
1. `visitAlterStreamComment` decoded the comment with `stripQuotes`, which only
removes the outer delimiters. `ALTER STREAM s SET COMMENT 'a''b'` therefore
stored `a''b` instead of `a'b`, and with the default sql mode
`COMMENT '\n'` stored a backslash plus `n` instead of a newline. The value is
exposed by `information_schema.table_streams.STREAM_COMMENT` and printed by
`SHOW CREATE STREAM`, so the stored metadata was simply wrong.
`visitCreateStream` had the other half of the problem: it decoded backslash
escapes (`LogicalPlanBuilderAssistant.escapeBackSlash`) but did not collapse
doubled quotes and ignored `NO_BACKSLASH_ESCAPES`, so the same literal produced
different comments depending on whether it went through CREATE or ALTER.
Both now use `SqlLiteralUtils.parseStringLiteral`, which collapses doubled
quotes and honours the sql mode exactly like the lexer does
(`NereidsParser` feeds `SqlModeHelper.hasNoBackSlashEscapes()` to the lexer).
Not addressed here: `Env.addTableComment` wraps the comment in single quotes
but only escapes double quotes (`SqlUtils.escapeQuota`), so a comment holding
a single quote makes `SHOW CREATE` emit non-parsable DDL. That is pre-existing,
shared by all 19 call sites of every table type, and is not stream specific.
2. The two new regression suites did not follow the repository test standards:
names were indirected through `def`, deterministic results were asserted by
hand instead of a generated `.out`, and both dropped their fixtures at the end.
Fixed all three. While converting, the skip guard of
`test_binlog_property_alter_exception` turned out to be dead: it compared the
config name against `enable_feature_binlog`, but `SHOW FRONTEND CONFIG` reports
the EXPERIMENTAL config as `experimental_enable_feature_binlog`, so the suite
skipped itself unconditionally, in CI as well. It now uses the framework helper
`getSyncer().checkEnableFeatureBinlog()`, and the suite actually runs.
### Release note
None (the behaviour change of this PR is described in the first commit).
### Check List (For Author)
- Test:
- Unit Test: `AlterTableStreamCommentTest#testAlterStreamCommentStringLiteral`
covers doubled single quotes, doubled double quotes, `\n`/`\t` and
`NO_BACKSLASH_ESCAPES`. Both tests of the class pass locally
(`Tests run: 2, Failures: 0, Errors: 0`).
- Regression test: `test_table_stream_alter_comment` (the `.out` was generated
with `-genOut` against a local cluster, then verified by a second run without
it) and `test_binlog_property_alter_exception`, both pass locally and the six
expected error messages were observed in the run log.
- Behavior changed: Yes. A stream comment containing a doubled quote or a
backslash escape is now stored decoded, and the sql mode is honoured.
- Does this need documentation: No (the statement itself is documented by the
first commit's doc PR).
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xx7TgjXJCiChnzLYa6hgtL
0 commit comments