diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 16c86ffcc0f..34f8bc801af 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -18688,8 +18688,14 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd, * constraint as well. */ partBoundConstraint = get_qual_from_partbound(rel, cmd->bound); - partConstraint = list_concat(partBoundConstraint, - RelationGetPartitionQual(rel)); + + /* + * Use list_concat_copy() to avoid modifying partBoundConstraint in place, + * since it’s needed later to construct the constraint expression for + * validating against the default partition, if any. + */ + partConstraint = list_concat_copy(partBoundConstraint, + RelationGetPartitionQual(rel)); /* Skip validation if there are no constraints to validate. */ if (partConstraint)