Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request citusdata#5879 from citusdata/marcocitus/fix-uniqu…
Browse files Browse the repository at this point in the history
…e-index
  • Loading branch information
marcocitus authored Apr 7, 2022
2 parents 67fdecf + 2304815 commit 54f97c7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/backend/distributed/relay/relay_event_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ RelayEventExtendNames(Node *parseTree, char *schemaName, uint64 shardId)
AccessShareLock,
missingOk);

if (constraint->contype == CONSTR_PRIMARY && constraint->indexname)
if (constraint->indexname)
{
char **indexName = &(constraint->indexname);
AppendShardIdToName(indexName, shardId);
Expand Down
15 changes: 14 additions & 1 deletion src/test/regress/expected/multi_alter_table_add_constraints.out
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,23 @@ ORDER BY
localhost | 57638 | t |
(2 rows)

CREATE TABLE alter_add_unique(x int, y int);
CREATE UNIQUE INDEX CONCURRENTLY alter_unique_idx ON alter_add_unique(x);
SELECT create_distributed_table('alter_add_unique', 'x');
create_distributed_table
---------------------------------------------------------------------

(1 row)

ALTER TABLE alter_add_unique ADD CONSTRAINT unique_constraint_test UNIQUE USING INDEX alter_unique_idx;
NOTICE: ALTER TABLE / ADD CONSTRAINT USING INDEX will rename index "alter_unique_idx" to "unique_constraint_test"
ALTER TABLE alter_add_unique DROP CONSTRAINT unique_constraint_test;
SET search_path TO 'public';
DROP SCHEMA sc1 CASCADE;
NOTICE: drop cascades to table sc1.alter_add_prim_key
DROP SCHEMA sc2 CASCADE;
NOTICE: drop cascades to table sc2.alter_add_prim_key
DROP SCHEMA sc3 CASCADE;
NOTICE: drop cascades to table sc3.alter_add_prim_key
NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to table sc3.alter_add_prim_key
drop cascades to table sc3.alter_add_unique
7 changes: 7 additions & 0 deletions src/test/regress/sql/multi_alter_table_add_constraints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,13 @@ SELECT (run_command_on_workers($$
ORDER BY
1,2,3,4;

CREATE TABLE alter_add_unique(x int, y int);
CREATE UNIQUE INDEX CONCURRENTLY alter_unique_idx ON alter_add_unique(x);
SELECT create_distributed_table('alter_add_unique', 'x');

ALTER TABLE alter_add_unique ADD CONSTRAINT unique_constraint_test UNIQUE USING INDEX alter_unique_idx;
ALTER TABLE alter_add_unique DROP CONSTRAINT unique_constraint_test;

SET search_path TO 'public';

DROP SCHEMA sc1 CASCADE;
Expand Down

0 comments on commit 54f97c7

Please sign in to comment.