Skip to content
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

sql: internal error with BUCKET_COUNT = NULL #131212

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

vidit-bhat
Copy link
Contributor

Previously, the EvalShardBucketCount function did not properly handle the case where BUCKET_COUNT was set to NULL, causing evaluation errors. This change adds explicit handling for NULL values, ensuring that BUCKET_COUNT cannot be set to NULL and returns an appropriate error message.

Epic: none
Fixes: #130353
Release note: None

Copy link

blathers-crl bot commented Sep 23, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@vidit-bhat vidit-bhat force-pushed the sql-bucket-count-null-error branch from 69450e1 to ff5e3cd Compare September 23, 2024 15:56
@vidit-bhat vidit-bhat marked this pull request as ready for review September 23, 2024 17:51
@vidit-bhat vidit-bhat requested a review from a team as a code owner September 23, 2024 17:51
Copy link
Contributor

@spilchen spilchen left a comment

Choose a reason for hiding this comment

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

Looks good. I just had a comment on the error message used.

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @vidit-bhat)


pkg/sql/catalog/tabledesc/table.go line 290 at r1 (raw file):

		// Check if shardBuckets is NULL
		if shardBuckets == tree.DNull {
			return 0, pgerror.Newf(pgcode.InvalidParameterValue, `"BUCKET_COUNT" cannot be NULL`)

Can we use invalidBucketCountMsg as the error message? I believe it still makes sense even when the count is NULL.

@vidit-bhat vidit-bhat force-pushed the sql-bucket-count-null-error branch 2 times, most recently from 537d082 to 18ae65a Compare September 25, 2024 19:31
@vidit-bhat
Copy link
Contributor Author

Looks good. I just had a comment on the error message used.

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @vidit-bhat)

pkg/sql/catalog/tabledesc/table.go line 290 at r1 (raw file):

		// Check if shardBuckets is NULL
		if shardBuckets == tree.DNull {
			return 0, pgerror.Newf(pgcode.InvalidParameterValue, `"BUCKET_COUNT" cannot be NULL`)

Can we use invalidBucketCountMsg as the error message? I believe it still makes sense even when the count is NULL.

Done

@vidit-bhat vidit-bhat requested a review from spilchen September 25, 2024 19:58
Copy link
Contributor

@spilchen spilchen left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @vidit-bhat)


pkg/sql/catalog/tabledesc/table.go line 290 at r2 (raw file):

		// Check if shardBuckets is NULL
		if shardBuckets == tree.DNull {
			return 0, pgerror.Newf(pgcode.InvalidParameterValue, invalidBucketCountMsg, buckets)

Can we pass in "NULL" for the 3rd parm? I'm hoping the error message will say we passed in NULL if we do.

Suggestion:

return 0, pgerror.Newf(pgcode.InvalidParameterValue, invalidBucketCountMsg, "NULL")

Previously, the `EvalShardBucketCount` function did
not properly handle the case where `BUCKET_COUNT` was
set to `NULL`, causing evaluation errors. This change
adds explicit handling for `NULL` values, ensuring that
`BUCKET_COUNT` cannot be set to `NULL` and returns an
appropriate error message.

Also added a check for NULL before sanitizing and evaluating shardBuckets
to avoid invalid operations on NULL values.
returns the error `BUCKET_COUNT cannot be NULL`.

Epic: none
Fixes: cockroachdb#130353
Release note: None
@vidit-bhat vidit-bhat force-pushed the sql-bucket-count-null-error branch from 18ae65a to 1bdef16 Compare September 25, 2024 20:34
@vidit-bhat
Copy link
Contributor Author

Reviewed 2 of 2 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @vidit-bhat)

pkg/sql/catalog/tabledesc/table.go line 290 at r2 (raw file):

		// Check if shardBuckets is NULL
		if shardBuckets == tree.DNull {
			return 0, pgerror.Newf(pgcode.InvalidParameterValue, invalidBucketCountMsg, buckets)

Can we pass in "NULL" for the 3rd parm? I'm hoping the error message will say we passed in NULL if we do.

Suggestion:

return 0, pgerror.Newf(pgcode.InvalidParameterValue, invalidBucketCountMsg, "NULL")

Oops yes. Updated.

@vidit-bhat vidit-bhat requested a review from spilchen September 25, 2024 20:57
Copy link
Contributor

@spilchen spilchen left a comment

Choose a reason for hiding this comment

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

:lgtm: Thanks for contributing.

Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @vidit-bhat)

@vidit-bhat
Copy link
Contributor Author

TFTR!
bors r=spilchen

@craig craig bot merged commit ab67a5e into cockroachdb:master Sep 26, 2024
23 checks passed
@rafiss
Copy link
Collaborator

rafiss commented Sep 30, 2024

we should backport this fix, since older branches are affected and the issue was causing a crash

blathers backport 23.1 23.2 24.1 24.2

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: internal error with BUCKET_COUNT = NULL
4 participants