forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitbabb399
committed
Fix expression list handling in ATExecAttachPartition()
This commit addresses two issues related to the manipulation of thepartition constraint expression list in ATExecAttachPartition().First, the current use of list_concat() to combine the partition'sconstraint (retrieved via get_qual_from_partbound()) with the parenttable’s partition constraint can lead to memory safety issues. Aftercalling list_concat(), the original constraint (partBoundConstraint)might no longer be safe to access, as list_concat() may free or modifyit.Second, there's a logical error in constructing the constraint forvalidating against the default partition. The current approachincorrectly includes a negated version of the parent table's partitionconstraint, which is redundant, as it always evaluates to false forrows in the default partition.To resolve these issues, list_concat() is replaced withlist_concat_copy(), ensuring that partBoundConstraint remains unchangedand can be safely reused when constructing the validation constraintfor the default partition.This fix is not applied to back-branches, as there is no live bug andthe issue has not caused any reported problems in practice.Nitin Jadhav posted a patch to address the memory safety issue, but Idecided to follow Alvaro Herrera's suggestion from the initialdiscussion, as it allows us to fix both the memory safety and logicalissues.Reported-by: Andres Freund <andres@anarazel.de>Reported-by: Nitin Jadhav <nitinjadhavpostgres@gmail.com>Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>Discussion:https://postgr.es/m/20231115165737.zeulb575cgrbqo74@awork3.anarazel.deDiscussion:https://postgr.es/m/CAMm1aWbmYHM3bqtjyMQ-a+4Ub=dgsb_2E3_up2cn=UGdHNrGTg@mail.gmail.com1 parente2bab2d commitbabb399
1 file changed
+8
-2
lines changedLines changed: 8 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18688 | 18688 |
| |
18689 | 18689 |
| |
18690 | 18690 |
| |
18691 |
| - | |
18692 |
| - | |
| 18691 | + | |
| 18692 | + | |
| 18693 | + | |
| 18694 | + | |
| 18695 | + | |
| 18696 | + | |
| 18697 | + | |
| 18698 | + | |
18693 | 18699 |
| |
18694 | 18700 |
| |
18695 | 18701 |
| |
|
0 commit comments
Comments
(0)