Repository navigation
fix: escape index comments in catalog SQL - #27085
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
[P1] Complete the index-comment serialization/replay closure for backslashes
The INSERT-side change at pkg/sql/compile/util.go:312 correctly stores the comment, but the new regression uses index's comment\with unicode 维度 and only checks that this first SQL string contains sqlquote.String(comment). The reverse path still renders index comments through formatStr in pkg/sql/plan/build_show_util.go:407; that helper doubles quotes but leaves backslashes untouched. buildShowCreateTable then embeds the entire DDL in a double-quoted SQL literal, whose MySQL scanner treats backslash as an escape introducer.
I reproduced the exact current-head path: semantic value "index's comment\\with unicode 维度" produced a pre-scan DDL containing the backslash, but the SHOW CREATE value became "index's commentwith unicode 维度" (preserved=false). The same generated DDL is reparsed by CREATE TABLE LIKE/clone, so that path also silently changes the comment.
Thus the apostrophe write failure is fixed, but the issue's backslash + replay requirement is not closed, and the current unit test gives a false sense that it is. Please make the display/rewrite side preserve the comment across its required escaping layers and add an independent round-trip regression through ConstructCreateTableSQL/the parser (plus the inline and ALTER public paths requested by #27079), asserting the recovered comment equals the original.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review completed on exact head d0aafa7. The previous catalog replay, public SHOW CREATE transport, and end-to-end coverage blockers are closed: the complete DDL now crosses the rewrite SQL boundary through sqlquote.String, quote/backslash/trailing-backslash controls round-trip, the generated mo_indexes INSERT is parsed and its semantic comment asserted, and distributed coverage exercises inline CREATE plus ALTER ADD INDEX through SHOW INDEX/SHOW CREATE and CREATE LIKE. Focused plan and compile tests pass with the required CGO/thirdparties setup; git diff --check is clean.
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed exact head d0aafa7. SQL string quoting now closes catalog INSERT, SHOW CREATE transport, and replay paths for index comments including quotes, backslashes, and Unicode. Focused compile and plan round-trip tests pass; CI is green. Approving. GitHub currently reports a merge conflict with main; refresh before merge.
4fdb27b to
418be22
Compare
418be22 to
1ac5579
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head 1ac5579ef7263e722648e052bbb6953549f836ea against base aa3f1551ca110687d63b932bad7f550eacb7c27c. The prior blockers are closed:
- Catalog INSERT generation now applies the shared default-parser string quoting at the semantic-value boundary; inline CREATE and ALTER ADD INDEX both converge on this path.
- SHOW CREATE / CREATE LIKE replay uses SQL-mode-aware quoting for the inner DDL, while the outer internal SHOW transport uses latest main's shared default-mode formatter.
- Unit and distributed coverage includes quote + backslash + Unicode values, both public DDL entry points, SHOW metadata, and LIKE replay.
Local focused compile/plan tests pass. I also ran an independent default/NO_BACKSLASH_ESCAPES counterexample matrix covering quote + backslash + Unicode, backslash-before-quote, and trailing-backslash comments through inner DDL, outer SHOW transport, and replay; all semantic values round-trip exactly. No blocking correctness, compatibility, or maintainability issue found. CI is still running.
Merge Queue Status
This pull request spent 37 minutes 11 seconds in the queue, with no time running CI. ReasonPull request #27085 has been merged manually at 61d0389 HintYou were too fast! Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #27079
What this PR does / why we need it:
fix: escape index comments in catalog SQL