| From: | Guancheng Luo <prajnamort(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | [PATCH] Check operator when creating unique index on partition table |
| Date: | 2020-03-25 10:43:43 |
| Message-ID: | D9C3CEF7-04E8-47A1-8300-CA1DCD5ED40D@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
I found that things could go wrong in some cases, when the unique index and the partition key use different opclass.
For example:
```
CREATE TABLE ptop_test (a int, b int, c int) PARTITION BY LIST (a);
CREATE TABLE ptop_test_p1 PARTITION OF ptop_test FOR VALUES IN ('1');
CREATE TABLE ptop_test_m1 PARTITION OF ptop_test FOR VALUES IN ('-1');
CREATE UNIQUE INDEX ptop_test_unq_abs_a ON ptop_test (a abs_int_btree_ops); -- this should fail
```
In this example, `abs_int_btree_ops` is a opclass whose equality operator is customized to consider ‘-1’ and ‘1’ as equal.
So the unique index should not be allowed to create, since ‘-1’ and ‘1’ will be put in different partition.
The attached patch should fix this problem.
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Check-operator-when-creating-UNIQUE-index-on-PARTITI.patch | application/octet-stream | 10.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | tushar | 2020-03-25 10:44:48 | Re: [Proposal] Global temporary tables |
| Previous Message | Sergei Kornilov | 2020-03-25 10:42:56 | Re: replay pause vs. standby promotion |