| From: | Narayanan Venkateswaran <narayananvpostgres(at)gmail(dot)com> |
|---|---|
| To: | idrissaajalloh(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19863: Adding a partition hides a row in a DEFAULT subpartition with reordered columns |
| Date: | 2026-11-26 15:15:53 |
| Message-ID: | CAFjuD9fDtn9wSkzJAHYH+1kjcOVVL0fCeMp-V7rYcyzLdwBF9g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hi Wren,
On Wed, Nov 11, 2026 at 4:02 PM PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> Creating a range partition incorrectly succeeds when the existing DEFAULT
> partition has a subpartition whose physical column order differs from its
> parent and whose CHECK constraint refers to the first physical column.
...
> A likely cause is that the expression used by
> `check_default_partition_contents()` is not mapped to the leaf's reordered
> columns. The CHECK constraint on the leaf's physical attribute 1 (`b`) can
> therefore appear to prove a condition intended for the root's attribute 1
> (`a`), causing the required scan to be skipped.
Thanks for the report and clear reproducer. I reproduced this on
master, and the same problem also happens with LIST partitions and
NOT NULL constraints on a reordered subpartition column.
Your diagnosis is right. check_default_partition_contents() maps the
default partition constraint to the subpartition's attribute numbers for
the scan, but passes the unmapped list to
PartConstraintImpliedByRelConstraint(). That can either falsely skip a
needed scan or miss skipping an unnecessary one. The ATTACH PARTITION
path already maps before checking implication.
Attached is a patch that maps the constraint before the implication
check and adds tests for these cases. Your reproducer and the
regression tests pass with the fix applied.
Narayanan
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Map-Vars-before-checking-default-subpartition-con.patch | application/octet-stream | 10.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Shuntian Jiao | 2026-11-26 15:15:25 | Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773 |