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

partitionccl: error instead of panic for an invalid partitioning #37689

Merged
merged 1 commit into from
May 21, 2019
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
7 changes: 7 additions & 0 deletions pkg/ccl/logictestccl/testdata/logic_test/partitioning
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ CREATE TABLE t (a INT, b INT, c INT, PRIMARY KEY (a, b, c)) PARTITION BY LIST (a
)
)

# Regression test for #37682
statement error declared partition columns \(a, b\) do not match first 1 columns in index being partitioned \(rowid\)
CREATE TABLE t (a INT DEFAULT 12, b INT DEFAULT 34) PARTITION BY LIST (a, b) (
PARTITION p1 VALUES IN ((1,2)),
PARTITION default VALUES IN (DEFAULT)
)

statement error PARTITION p1: name must be unique \(used twice in index "primary"\)
CREATE TABLE t (a INT, b INT, c INT, PRIMARY KEY (a, b)) PARTITION BY LIST (a) (
PARTITION p1 VALUES IN (1),
Expand Down
4 changes: 3 additions & 1 deletion pkg/ccl/partitionccl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ func createPartitioningImpl(
}
cols = append(cols, *col)
if string(partBy.Fields[i]) != col.Name {
n := colOffset + len(partBy.Fields)
// This used to print the first `colOffset + len(partBy.Fields)` fields
// but there might not be this many columns in the index. See #37682.
n := colOffset + i + 1
return partDesc, pgerror.Newf(pgerror.CodeSyntaxError,
"declared partition columns (%s) do not match first %d columns in index being partitioned (%s)",
partitioningString(), n, strings.Join(indexDesc.ColumnNames[:n], ", "))
Expand Down