Skip to content

Commit

Permalink
Merge pull request #131600 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-23.2-131212

release-23.2: sql: internal error with BUCKET_COUNT = NULL
  • Loading branch information
rafiss authored Sep 30, 2024
2 parents 48d0f69 + ff1bb00 commit 74520af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sql/catalog/tabledesc/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,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 @@ -737,6 +737,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

0 comments on commit 74520af

Please sign in to comment.