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: use bare name string of new pk to compare with pk name when altering primary key #90865

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
2 changes: 1 addition & 1 deletion pkg/sql/alter_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ func validateConstraintNameIsNotUsed(
// If there is no active primary key, then adding one with the exact
// same name is allowed.
if !tableDesc.HasPrimaryKey() &&
tableDesc.PrimaryIndex.Name == name.String() {
tableDesc.PrimaryIndex.Name == string(name) {
return false, nil
}
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/alter_primary_key
Original file line number Diff line number Diff line change
Expand Up @@ -1832,3 +1832,11 @@ CREATE TABLE t_90306 (j INT[], k INT NOT NULL, INVERTED INDEX (j));

statement ok
ALTER TABLE t_90306 ALTER PRIMARY KEY USING COLUMNS (k);

subtest regression_90836

statement ok
CREATE TABLE t_90836(a INT NOT NULL, b INT NOT NULL, CONSTRAINT "constraint" PRIMARY KEY (a));

statement ok
ALTER TABLE t_90836 DROP CONSTRAINT "constraint"; ALTER TABLE t_90836 ADD CONSTRAINT "constraint" PRIMARY KEY (b);