sql/parser: fix WITH_LA lookahead conflict in resource group grammar#170894
Merged
trunk-io[bot] merged 1 commit intoMay 27, 2026
Merged
Conversation
Contributor
|
😎 Merged successfully - details. |
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. |
Contributor
|
[autosolve-response] I've addressed the review comments and pushed updates. Changes made: Please review the updated code. |
3974932 to
e1728ae
Compare
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-ci-fix] CI failures were detected and I've pushed fixes. Changes made: |
e1728ae to
4619045
Compare
bghal
approved these changes
May 26, 2026
Contributor
|
TFTR! /trunk merge |
Contributor
|
[autosolve-response] I reviewed the comments but no code changes were necessary. Analysis: |
rafiss
added a commit
to rafiss/cockroach
that referenced
this pull request
May 27, 2026
The grammar for `with_resource_group_options` previously accepted both `WITH <opt> = <val>, ...` and `WITH (<opt> = <val>, ...)`. Because `BUCKET_COUNT` is in the lexer's `WITH_LA` lookahead set, supporting the unparenthesized form required four grammar alternatives (the `WITH` and `WITH_LA` variants of each), and the generated BNF surfaced this as duplicate `'WITH' ...` lines in `stmt_block.bnf`. PR cockroachdb#170894 made the `Format` methods always emit the parenthesized form, so the unparenthesized grammar paths are no longer needed for the parse/format round-trip. Drop them and require parentheses, matching CRDB convention for arbitrary KV-style option lists (`CREATE TABLE` storage params, `BACKUP ... WITH OPTIONS (...)`, etc.). Resolves: cockroachdb#170788 Release note: None
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.