| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
| Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: MERGE/SPLIT PARTITIONS issues/questions |
| Date: | 2026-08-01 09:49:22 |
| Message-ID: | CACJufxFEm=vEa=42H9Fe=vQfOBPBA=2+U-ZEK5FOKvV-65Muag@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs pgsql-hackers |
On Thu, Jul 23, 2026 at 10:29 PM Zsolt Parragi
<zsolt(dot)parragi(at)percona(dot)com> wrote:
>
> > 4. Earlier I wrote that "the data didn't change"... but generated
> > columns can silently change:
>
> This point is a bit worse than my original description, I was able to
> break some constraints with it. See attached reproducer scripts:
>
> * merge-dangling-fk.sql results in a foreign key that appears to be
> validated but contains dangling entries
> * merge-invalid-check.sql breaks a check constraint
> * merge-null-assert.sql inserts a NULL value into a NOT NULL column.
> Crashes the debug build with an assertion, returns inconsistent data
> in production builds.
>
Previously, we assumed that ALTER TABLE ... MERGE PARTITION simply combined the
contents of multiple partitions into a new partition.
However, the generation expressions defined on the partitions may differ from
those of the partitioned table. As a result, if the table contains generated
columns, the data in the newly created partition may not be identical to the
combined contents of the merged partitions.
Therefore, when the partitioned table contains generated columns, we must
reverify NOT NULL constraints, CHECK constraints, and foreign key constraints
for ALTER TABLE ... MERGE PARTITION.
I combined these fixes into one patch.
some of the comments is directly copied from ATRewriteTable.
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-reverify-constraint-for-ALTER-TABLE-MERGE-PARTITION.patch | text/x-patch | 15.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-08-01 11:11:02 | Re: MERGE/SPLIT PARTITIONS issues/questions |
| Previous Message | PG Bug reporting form | 2026-08-01 03:07:25 | BUG #19593: area(circle) silently returns Infinity instead of raising "value out of range: overflow" |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-08-01 11:11:02 | Re: MERGE/SPLIT PARTITIONS issues/questions |
| Previous Message | Chengpeng Yan | 2026-08-01 09:38:43 | Re: a large LIMIT makes some sorts slower |