Skip to content

Commit

Permalink
sql: add hint for ALTER PARTITION OF INDEX error
Browse files Browse the repository at this point in the history
If a user accidentally passes a table name (or some other non-existent
index name) to ALTER PARTITION ... OF INDEX, they now get a helpful hint
suggesting that the use the <tablename>@<indexname> syntax to specify
the index.

Fixes #39477

Release note: None
  • Loading branch information
solongordon committed Sep 12, 2019
1 parent 34e9175 commit 1f9c8d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/ccl/logictestccl/testdata/logic_test/zone
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ CREATE INDEX x2 ON t2 (x) PARTITION BY LIST (x) (
statement ok
ALTER PARTITION p1 OF INDEX t2@* CONFIGURE ZONE USING num_replicas = 1

statement error index "t2" does not exist\nHINT: try specifying the index as <tablename>@<indexname>
ALTER PARTITION p1 OF INDEX t2 CONFIGURE ZONE USING num_replicas = 1

query TT
SELECT * FROM [SHOW ALL ZONE CONFIGURATIONS] WHERE target LIKE '%t2@%'
----
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/set_zone_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ func (n *setZoneConfigNode) startExec(params runParams) error {
// descriptor.
table, err := params.p.resolveTableForZone(params.ctx, &n.zoneSpecifier)
if err != nil {
if n.zoneSpecifier.TargetsIndex() && n.zoneSpecifier.TableOrIndex.Table.TableName == "" {
return errors.WithHint(err, "try specifying the index as <tablename>@<indexname>")
}
return err
}

Expand Down

0 comments on commit 1f9c8d6

Please sign in to comment.