Skip to content

Commit cc88616

Browse files
craig[bot]rohany
craig[bot]
andcommitted
Merge #39543
39543: sql: More descriptive error messages in show partitions r=solongordon a=rohany The show partitions statement suggests use of the index hint syntax if the user does not use it. Fixes #39476. Release note: None Co-authored-by: Rohan Yadav <[email protected]>
2 parents 497167b + 103661c commit cc88616

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/sql/delegate/show_partitions.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import (
1515

1616
"github.com/cockroachdb/cockroach/pkg/sql/lex"
1717
"github.com/cockroachdb/cockroach/pkg/sql/opt/cat"
18+
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
19+
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
1820
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
21+
"github.com/cockroachdb/errors"
1922
)
2023

2124
func (d *delegator) delegateShowPartitions(n *tree.ShowPartitions) (tree.Statement, error) {
@@ -89,6 +92,14 @@ func (d *delegator) delegateShowPartitions(n *tree.ShowPartitions) (tree.Stateme
8992
flags := cat.Flags{AvoidDescriptorCaches: true, NoTableStats: true}
9093
tn := n.Index.Table
9194

95+
// Throw a more descriptive error if the user did not use the index hint syntax.
96+
if tn.TableName == "" {
97+
err := errors.New("no table specified")
98+
err = pgerror.WithCandidateCode(err, pgcode.InvalidParameterValue)
99+
err = errors.WithHint(err, "Specify a table using the hint syntax of table@index")
100+
return nil, err
101+
}
102+
92103
dataSource, resName, err := d.catalog.ResolveDataSource(d.ctx, flags, &tn)
93104
if err != nil {
94105
return nil, err

0 commit comments

Comments
 (0)