Skip to content

sql: More descriptive error messages in show partitions #39543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2019

Conversation

rohany
Copy link
Contributor

@rohany rohany commented Aug 11, 2019

The show partitions statement suggests use of the index
hint syntax if the user does not use it.

Fixes #39476.

Release note: None

@rohany rohany requested review from solongordon and a team August 11, 2019 17:12
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rohany
Copy link
Contributor Author

rohany commented Aug 11, 2019

[email protected]:50708/movr> create table t (x int, index i(x));
CREATE TABLE

Time: 2.789ms

[email protected]:50708/movr> show partitions from index i;
pq: no table specified. Specify a table using the hint syntax of table@index
[email protected]:50708/movr>

@awoods187
Copy link
Contributor

Excited about this!

@rohany
Copy link
Contributor Author

rohany commented Aug 21, 2019

bump

Copy link
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rohany and @solongordon)


pkg/sql/delegate/show_partitions.go, line 95 at r1 (raw file):

	// Throw a more descriptive error if the user did not use the index hint syntax.
	if tn.TableName == "" {
		return nil, errors.New("no table specified. Specify a table using the hint syntax of table@index")

You might want to take a look at the errors.WithHint function to get slightly nicer output. Also it might be nice to attach a pg error code. Here is an example of both:

err = errors.Wrap(err, "could not validate zone config")
err = pgerror.WithCandidateCode(err, pgcode.InvalidParameterValue)
err = errors.WithHint(err,
"try ALTER ... CONFIGURE ZONE USING <field_name> = COPY FROM PARENT [, ...] to populate the field")
return err

Copy link
Contributor Author

@rohany rohany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @solongordon)


pkg/sql/delegate/show_partitions.go, line 95 at r1 (raw file):

Previously, solongordon (Solon) wrote…

You might want to take a look at the errors.WithHint function to get slightly nicer output. Also it might be nice to attach a pg error code. Here is an example of both:

err = errors.Wrap(err, "could not validate zone config")
err = pgerror.WithCandidateCode(err, pgcode.InvalidParameterValue)
err = errors.WithHint(err,
"try ALTER ... CONFIGURE ZONE USING <field_name> = COPY FROM PARENT [, ...] to populate the field")
return err

Oh, I see. Let me do what this does.

The show partitions statement suggests use of the index
hint syntax if the user does not use it.

Fixes cockroachdb#39476.

Release note: None
@rohany rohany force-pushed the show-partitions-index-hint branch from dbf4dc5 to 103661c Compare August 26, 2019 15:57
@rohany
Copy link
Contributor Author

rohany commented Aug 26, 2019

@solongordon can you take another quick look and see if this is what you were imagining?

Copy link
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, lgtm!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @solongordon)

@rohany
Copy link
Contributor Author

rohany commented Aug 26, 2019

bors r=solongordon

craig bot pushed a commit that referenced this pull request Aug 26, 2019
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]>
@craig
Copy link
Contributor

craig bot commented Aug 26, 2019

Build succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: improve error message for show partitions from index
4 participants