pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Fix expression list handling in ATExecAttachPartition()
5+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2024-10-03 19531968e8 Replace Unicode apostrophe with ASCII apostrophe
* pgsql: Fix expression list handling in ATExecAttachPartition()
@ 2024-10-03 03:01 Amit Langote <amitlan@postgresql.org>
2024-10-03 09:57 ` Re: pgsql: Fix expression list handling in ATExecAttachPartition() Alexander Korotkov <aekorotkov@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Amit Langote @ 2024-10-03 03:01 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix expression list handling in ATExecAttachPartition()
This commit addresses two issues related to the manipulation of the
partition constraint expression list in ATExecAttachPartition().
First, the current use of list_concat() to combine the partition's
constraint (retrieved via get_qual_from_partbound()) with the parent
table’s partition constraint can lead to memory safety issues. After
calling list_concat(), the original constraint (partBoundConstraint)
might no longer be safe to access, as list_concat() may free or modify
it.
Second, there's a logical error in constructing the constraint for
validating against the default partition. The current approach
incorrectly includes a negated version of the parent table's partition
constraint, which is redundant, as it always evaluates to false for
rows in the default partition.
To resolve these issues, list_concat() is replaced with
list_concat_copy(), ensuring that partBoundConstraint remains unchanged
and can be safely reused when constructing the validation constraint
for the default partition.
This fix is not applied to back-branches, as there is no live bug and
the issue has not caused any reported problems in practice.
Nitin Jadhav posted a patch to address the memory safety issue, but I
decided to follow Alvaro Herrera's suggestion from the initial
discussion, as it allows us to fix both the memory safety and logical
issues.
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.de
Discussion: https://postgr.es/m/CAMm1aWbmYHM3bqtjyMQ-a+4Ub=dgsb_2E3_up2cn=UGdHNrGTg@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/babb3993dbe9c805c1d29fa275a5e8f4c2b40922
Modified Files
--------------
src/backend/commands/tablecmds.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Fix expression list handling in ATExecAttachPartition()
2024-10-03 03:01 pgsql: Fix expression list handling in ATExecAttachPartition() Amit Langote <amitlan@postgresql.org>
@ 2024-10-03 09:57 ` Alexander Korotkov <aekorotkov@gmail.com>
2024-10-03 10:12 ` Re: pgsql: Fix expression list handling in ATExecAttachPartition() Amit Langote <amitlangote09@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Alexander Korotkov @ 2024-10-03 09:57 UTC (permalink / raw)
To: Amit Langote <amitlan@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org
Hi, Amit!
On Thu, Oct 3, 2024 at 6:01 AM Amit Langote <amitlan@postgresql.org> wrote:
> Fix expression list handling in ATExecAttachPartition()
+ * since it’s needed later to construct the constraint expression for
I don't think we're good about using unicode apostrophes. Could you,
please, switch to ascii?
------
Regards,
Alexander Korotkov
Supabase
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Fix expression list handling in ATExecAttachPartition()
2024-10-03 03:01 pgsql: Fix expression list handling in ATExecAttachPartition() Amit Langote <amitlan@postgresql.org>
2024-10-03 09:57 ` Re: pgsql: Fix expression list handling in ATExecAttachPartition() Alexander Korotkov <aekorotkov@gmail.com>
@ 2024-10-03 10:12 ` Amit Langote <amitlangote09@gmail.com>
2024-10-03 11:02 ` Re: pgsql: Fix expression list handling in ATExecAttachPartition() Amit Langote <amitlangote09@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Amit Langote @ 2024-10-03 10:12 UTC (permalink / raw)
To: Alexander Korotkov <aekorotkov@gmail.com>; +Cc: Amit Langote <amitlan@postgresql.org>; pgsql-committers@lists.postgresql.org
On Thu, Oct 3, 2024 at 18:57 Alexander Korotkov <aekorotkov@gmail.com>
wrote:
> Hi, Amit!
>
> On Thu, Oct 3, 2024 at 6:01 AM Amit Langote <amitlan@postgresql.org>
> wrote:
> > Fix expression list handling in ATExecAttachPartition()
>
> + * since it’s needed later to construct the constraint expression for
>
> I don't think we're good about using unicode apostrophes. Could you,
> please, switch to ascii?
>
Oh, oops, will fix. Thanks for the heads up.
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Fix expression list handling in ATExecAttachPartition()
2024-10-03 03:01 pgsql: Fix expression list handling in ATExecAttachPartition() Amit Langote <amitlan@postgresql.org>
2024-10-03 09:57 ` Re: pgsql: Fix expression list handling in ATExecAttachPartition() Alexander Korotkov <aekorotkov@gmail.com>
2024-10-03 10:12 ` Re: pgsql: Fix expression list handling in ATExecAttachPartition() Amit Langote <amitlangote09@gmail.com>
@ 2024-10-03 11:02 ` Amit Langote <amitlangote09@gmail.com>
2024-10-03 11:09 ` Re: pgsql: Fix expression list handling in ATExecAttachPartition() Alexander Korotkov <aekorotkov@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Amit Langote @ 2024-10-03 11:02 UTC (permalink / raw)
To: Alexander Korotkov <aekorotkov@gmail.com>; +Cc: Amit Langote <amitlan@postgresql.org>; pgsql-committers@lists.postgresql.org
On Thu, Oct 3, 2024 at 7:12 PM Amit Langote <amitlangote09@gmail.com> wrote:
> On Thu, Oct 3, 2024 at 18:57 Alexander Korotkov <aekorotkov@gmail.com> wrote:
>>
>> Hi, Amit!
>>
>> On Thu, Oct 3, 2024 at 6:01 AM Amit Langote <amitlan@postgresql.org> wrote:
>> > Fix expression list handling in ATExecAttachPartition()
>>
>> + * since it’s needed later to construct the constraint expression for
>>
>> I don't think we're good about using unicode apostrophes. Could you, please, switch to ascii?
>
>
> Oh, oops, will fix. Thanks for the heads up.
Done.
--
Thanks, Amit Langote
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Fix expression list handling in ATExecAttachPartition()
2024-10-03 03:01 pgsql: Fix expression list handling in ATExecAttachPartition() Amit Langote <amitlan@postgresql.org>
2024-10-03 09:57 ` Re: pgsql: Fix expression list handling in ATExecAttachPartition() Alexander Korotkov <aekorotkov@gmail.com>
2024-10-03 10:12 ` Re: pgsql: Fix expression list handling in ATExecAttachPartition() Amit Langote <amitlangote09@gmail.com>
2024-10-03 11:02 ` Re: pgsql: Fix expression list handling in ATExecAttachPartition() Amit Langote <amitlangote09@gmail.com>
@ 2024-10-03 11:09 ` Alexander Korotkov <aekorotkov@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Alexander Korotkov @ 2024-10-03 11:09 UTC (permalink / raw)
To: Amit Langote <amitlangote09@gmail.com>; +Cc: Amit Langote <amitlan@postgresql.org>; pgsql-committers@lists.postgresql.org
On Thu, Oct 3, 2024 at 2:02 PM Amit Langote <amitlangote09@gmail.com> wrote:
> On Thu, Oct 3, 2024 at 7:12 PM Amit Langote <amitlangote09@gmail.com>
> wrote:
> > On Thu, Oct 3, 2024 at 18:57 Alexander Korotkov <aekorotkov@gmail.com>
> wrote:
> >>
> >> Hi, Amit!
> >>
> >> On Thu, Oct 3, 2024 at 6:01 AM Amit Langote <amitlan@postgresql.org>
> wrote:
> >> > Fix expression list handling in ATExecAttachPartition()
> >>
> >> + * since it’s needed later to construct the constraint expression
> for
> >>
> >> I don't think we're good about using unicode apostrophes. Could you,
> please, switch to ascii?
> >
> >
> > Oh, oops, will fix. Thanks for the heads up.
>
> Done.
>
Great, thank you!
------
Regards,
Alexander Korotkov
Supabase
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2024-10-03 11:09 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-10-03 03:01 pgsql: Fix expression list handling in ATExecAttachPartition() Amit Langote <amitlan@postgresql.org>
2024-10-03 09:57 ` Alexander Korotkov <aekorotkov@gmail.com>
2024-10-03 10:12 ` Amit Langote <amitlangote09@gmail.com>
2024-10-03 11:02 ` Amit Langote <amitlangote09@gmail.com>
2024-10-03 11:09 ` Alexander Korotkov <aekorotkov@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox