feat(parser): support MySQL 8.0.19+ INSERT row alias syntax#33
Open
paultyng wants to merge 2 commits intosqlc-dev:mainfrom
Open
feat(parser): support MySQL 8.0.19+ INSERT row alias syntax#33paultyng wants to merge 2 commits intosqlc-dev:mainfrom
paultyng wants to merge 2 commits intosqlc-dev:mainfrom
Conversation
Add parsing support for the `AS row_alias[(col_alias, ...)]` clause in INSERT ... VALUES and INSERT ... SET statements, as introduced in MySQL 8.0.19 (WL #6312) and required since VALUES() was deprecated in MySQL 8.0.20. Examples: INSERT INTO t VALUES (1,2) AS new ON DUPLICATE KEY UPDATE b = new.b; INSERT INTO t VALUES (1,2) AS new(m,n) ON DUPLICATE KEY UPDATE b = m; INSERT INTO t SET a=1,b=2 AS new ON DUPLICATE KEY UPDATE b = new.a; This is a parser-only change; planner/executor support for resolving the alias references is not included. The INSERT ... SELECT form of the row alias is not yet supported. Replays pingcap/tidb#67920. Refs sqlc-dev#22. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
REPLACE does not support the AS row_alias syntax in MySQL. Since ReplaceIntoStmt reuses InsertValues, add a check to reject any row alias parsed via that shared grammar rule. Replays pingcap/tidb#67920. Refs sqlc-dev#22. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Replays pingcap/tidb#67920 into marino. Partial fix for #22.
RowAlias/ColumnAliasestoast.InsertStmtandInsertRowAliasOptgrammar onINSERT ... VALUESandINSERT ... SET.REPLACE(sharedInsertValuesrule).Not covered (follow-up): the
INSERT ... SELECT ... AS newform from #22. Adding it requires extending the fourSelect-branched alternatives ofInsertValuesand may introduce grammar ambiguity withSELECT's ownAStable alias — left for a separate PR.