Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbabb399

Browse files
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.com
1 parente2bab2d commitbabb399

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18688,8 +18688,14 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd,
1868818688
* constraint as well.
1868918689
*/
1869018690
partBoundConstraint = get_qual_from_partbound(rel, cmd->bound);
18691-
partConstraint = list_concat(partBoundConstraint,
18692-
RelationGetPartitionQual(rel));
18691+
18692+
/*
18693+
* Use list_concat_copy() to avoid modifying partBoundConstraint in place,
18694+
* since it’s needed later to construct the constraint expression for
18695+
* validating against the default partition, if any.
18696+
*/
18697+
partConstraint = list_concat_copy(partBoundConstraint,
18698+
RelationGetPartitionQual(rel));
1869318699

1869418700
/* Skip validation if there are no constraints to validate. */
1869518701
if (partConstraint)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp