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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/sql/catalog/tabledesc/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ func EvalShardBucketCount(
if paramVal != nil {
shardBuckets = paramVal
}
// Check if shardBuckets is NULL
if shardBuckets == tree.DNull {
return 0, pgerror.Newf(pgcode.InvalidParameterValue, invalidBucketCountMsg, "NULL")
}
typedExpr, err := schemaexpr.SanitizeVarFreeExpr(
ctx, shardBuckets, types.Int, "BUCKET_COUNT", semaCtx, volatility.Volatile, false, /*allowAssignmentCast*/
)
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/create_table
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,10 @@ CREATE TABLE t_bad_param (
a INT PRIMARY KEY USING HASH WITH BUCKET_COUNT = 5 WITH (bucket_count=5)
);

statement error pq: hash sharded index bucket count must be in range \[2, 2048\], got NULL
CREATE TABLE t_bad_param (
a INT PRIMARY KEY USING HASH WITH BUCKET_COUNT = NULL
);

statement error pq: invalid storage param "s2_max_level" on primary key
CREATE TABLE t_bad_param (
Expand Down
Loading