mirror of https://github.com/citusdata/citus.git
Allow adding a unique constraint with an index
parent
c5797030de
commit
d611a50a80
|
@ -158,7 +158,7 @@ RelayEventExtendNames(Node *parseTree, char *schemaName, uint64 shardId)
|
||||||
AccessShareLock,
|
AccessShareLock,
|
||||||
missingOk);
|
missingOk);
|
||||||
|
|
||||||
if (constraint->contype == CONSTR_PRIMARY && constraint->indexname)
|
if (constraint->indexname)
|
||||||
{
|
{
|
||||||
char **indexName = &(constraint->indexname);
|
char **indexName = &(constraint->indexname);
|
||||||
AppendShardIdToName(indexName, shardId);
|
AppendShardIdToName(indexName, shardId);
|
||||||
|
|
|
@ -617,10 +617,23 @@ ORDER BY
|
||||||
localhost | 57638 | t |
|
localhost | 57638 | t |
|
||||||
(2 rows)
|
(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';
|
SET search_path TO 'public';
|
||||||
DROP SCHEMA sc1 CASCADE;
|
DROP SCHEMA sc1 CASCADE;
|
||||||
NOTICE: drop cascades to table sc1.alter_add_prim_key
|
NOTICE: drop cascades to table sc1.alter_add_prim_key
|
||||||
DROP SCHEMA sc2 CASCADE;
|
DROP SCHEMA sc2 CASCADE;
|
||||||
NOTICE: drop cascades to table sc2.alter_add_prim_key
|
NOTICE: drop cascades to table sc2.alter_add_prim_key
|
||||||
DROP SCHEMA sc3 CASCADE;
|
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
|
||||||
|
|
|
@ -518,6 +518,13 @@ SELECT (run_command_on_workers($$
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1,2,3,4;
|
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';
|
SET search_path TO 'public';
|
||||||
|
|
||||||
DROP SCHEMA sc1 CASCADE;
|
DROP SCHEMA sc1 CASCADE;
|
||||||
|
|
Loading…
Reference in New Issue