Skip to content

Commit

Permalink
Merge #40812
Browse files Browse the repository at this point in the history
40812: sql: another syntax hint for ALTER PARTITION r=solongordon a=solongordon

If a user tries to specify an index in ALTER PARTITION ... OF TABLE,
they now receive a hint to use ALTER PARTITION ... OF INDEX instead.

I added similar logic recently but only for the index wildcard syntax,
<tablename>@*.

Release justification: Low-risk error messaging improvement

Release note: None

Co-authored-by: Solon Gordon <solon@cockroachlabs.com>
  • Loading branch information
craig[bot] and solongordon committed Sep 18, 2019
2 parents 4abcf22 + 1ca0625 commit 7b16a15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/sql/parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2683,6 +2683,14 @@ DETAIL: source SQL:
CREATE STATISTICS a ON col1 FROM t WITH OPTIONS AS OF SYSTEM TIME '-1s' THROTTLING 0.1 AS OF SYSTEM TIME '-2s'
^`,
},
{
`ALTER PARTITION p OF TABLE tbl@idx CONFIGURE ZONE USING num_replicas = 1`,
`at or near "idx": syntax error: index name should not be specified in ALTER PARTITION ... OF TABLE
DETAIL: source SQL:
ALTER PARTITION p OF TABLE tbl@idx CONFIGURE ZONE USING num_replicas = 1
^
HINT: try ALTER PARTITION ... OF INDEX`,
},
{
`ALTER PARTITION p OF TABLE tbl@* CONFIGURE ZONE USING num_replicas = 1`,
`at or near "configure": syntax error: index wildcard unsupported in ALTER PARTITION ... OF TABLE
Expand Down
6 changes: 6 additions & 0 deletions pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,12 @@ alter_zone_partition_stmt:
s.AllIndexes = true
$$.val = s
}
| ALTER PARTITION partition_name OF TABLE table_name '@' error
{
err := errors.New("index name should not be specified in ALTER PARTITION ... OF TABLE")
err = errors.WithHint(err, "try ALTER PARTITION ... OF INDEX")
return setErr(sqllex, err)
}
| ALTER PARTITION partition_name OF TABLE table_name '@' '*' error
{
err := errors.New("index wildcard unsupported in ALTER PARTITION ... OF TABLE")
Expand Down

0 comments on commit 7b16a15

Please sign in to comment.