sql/parser: fix WITH_LA lookahead conflict in resource group grammar#170894
Draft
cockroach-teamcity wants to merge 1 commit into
Draft
sql/parser: fix WITH_LA lookahead conflict in resource group grammar#170894cockroach-teamcity wants to merge 1 commit into
cockroach-teamcity wants to merge 1 commit into
Conversation
Contributor
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Member
Author
Contributor
|
[autosolve-ci-fix] CI failures were detected but appear to be flaky tests or pre-existing issues, not caused by this PR. Analysis: A human may want to re-run CI or investigate the flaky tests. |
Contributor
Triager Review Feedback
Requested Changesdiff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y
index eda3473fa7f..cc9d03f5eea 100644
--- a/pkg/sql/parser/sql.y
+++ b/pkg/sql/parser/sql.y
@@ -4319,7 +4319,7 @@ resource_group_option:
// %Help: CREATE RESOURCE GROUP - create a resource group for the resource manager
// %Category: Misc
// %Text:
-// CREATE RESOURCE GROUP [IF NOT EXISTS] <name> WITH <option> = <value>, ...
+// CREATE RESOURCE GROUP [IF NOT EXISTS] <name> WITH (<option> = <value>, ...)
//
// Options:
// cpu_weight = <int> relative CPU share (must be > 0)
@@ -4345,7 +4345,7 @@ create_resource_group_stmt:
// %Help: ALTER RESOURCE GROUP - alter an existing resource group
// %Category: Misc
// %Text:
-// ALTER RESOURCE GROUP [IF EXISTS] <name> WITH <option> = <value>, ...
+// ALTER RESOURCE GROUP [IF EXISTS] <name> WITH (<option> = <value>, ...)
//
// Only the options named are updated; unspecified options are left unchanged.
alter_resource_group_stmt:Please apply these changes to the branch. |
The `Format` methods for `CreateResourceGroup` and `AlterResourceGroup` emitted `WITH <options>` without parentheses. When an option key happened to be `BUCKET_COUNT` (a keyword), the lexer's 1-token lookahead converted `WITH` to `WITH_LA`, but `with_resource_group_options` only accepted plain `WITH`, causing a syntax error on re-parse. This broke the parse-format-reparse round-trip that `TestRandomSyntaxGeneration` validates. Fix by: 1. Changing `Format` to always emit parentheses: `WITH (...)`. This prevents the lexer from seeing `WITH BUCKET_COUNT` directly, avoiding the `WITH_LA` conversion entirely. 2. Adding `WITH_LA` alternatives to the `with_resource_group_options` grammar rule for robustness, mirroring how `with_clause` and other rules handle this pattern. The canonical form is now `WITH (...)` (parenthesized), and the unparenthesized form is accepted but normalized. Resolves: cockroachdb#170788 Epic: none Release note: None Generated by Claude Code Auto-Solver Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
[autosolve-response] I've addressed the review comments and pushed updates. Changes made: Please review the updated code. |
3974932 to
e1728ae
Compare
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.
The
Formatmethods forCreateResourceGroupandAlterResourceGroupemitted
WITH <options>without parentheses. When an option key happenedto be
BUCKET_COUNT(a keyword), the lexer's 1-token lookahead convertedWITHtoWITH_LA, butwith_resource_group_optionsonly acceptedplain
WITH, causing a syntax error on re-parse. This broke theparse-format-reparse round-trip that
TestRandomSyntaxGenerationvalidates.
Fix by:
Formatto always emit parentheses:WITH (...). Thisprevents the lexer from seeing
WITH BUCKET_COUNTdirectly, avoidingthe
WITH_LAconversion entirely.WITH_LAalternatives to thewith_resource_group_optionsgrammar rule for robustness, mirroring how
with_clauseand otherrules handle this pattern.
The canonical form is now
WITH (...)(parenthesized), and theunparenthesized form is accepted but normalized.
Resolves: #170788
Epic: none
Release note: None
Generated by Claude Code Auto-Solver
Co-Authored-By: Claude noreply@anthropic.com
This PR was auto-generated by issue-autosolve using Claude Code.
Please review carefully before approving.