mirror of
https://github.com/postgres/postgres.git
synced 2025-12-16 16:42:29 +03:00
Allow UNIQUE indexes on partitioned tables
If we restrict unique constraints on partitioned tables so that they must always include the partition key, then our standard approach to unique indexes already works --- each unique key is forced to exist within a single partition, so enforcing the unique restriction in each index individually is enough to have it enforced globally. Therefore we can implement unique indexes on partitions by simply removing a few restrictions (and adding others.) Discussion: https://postgr.es/m/20171222212921.hi6hg6pem2w2t36z@alvherre.pgsql Discussion: https://postgr.es/m/20171229230607.3iib6b62fn3uaf47@alvherre.pgsql Reviewed-by: Simon Riggs, Jesper Pedersen, Peter Eisentraut, Jaime Casanova, Amit Langote
This commit is contained in:
@@ -834,6 +834,12 @@ DROP INDEX cwi_replaced_pkey; -- Should fail; a constraint depends on it
|
||||
|
||||
DROP TABLE cwi_test;
|
||||
|
||||
-- ADD CONSTRAINT USING INDEX is forbidden on partitioned tables
|
||||
CREATE TABLE cwi_test(a int) PARTITION BY hash (a);
|
||||
create unique index on cwi_test (a);
|
||||
alter table cwi_test add primary key using index cwi_test_a_idx ;
|
||||
DROP TABLE cwi_test;
|
||||
|
||||
--
|
||||
-- Check handling of indexes on system columns
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user