Re: Oversight in reparameterize_path_by_child leading to executor crash

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Oversight in reparameterize_path_by_child leading to executor crash
Date: 2023-08-01 13:20:14
Message-ID: 3070526.1690896014@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> In this case what we need to do is to adjust the TableSampleClause to
> refer to the correct child relations. We can do that with the help of
> adjust_appendrel_attrs_multilevel(). One problem is that the
> TableSampleClause is stored in RangeTblEntry, and it does not seem like
> a good practice to alter RangeTblEntry in this place.

Ugh. That's why we didn't think to adjust it, obviously. You are right
that we can't just modify the RTE on the fly, since it's shared with
other non-parameterized paths.

> So what I'm thinking is that maybe we can add a new type of path, named
> SampleScanPath, to have the TableSampleClause per path. Then we can
> safely reparameterize the TableSampleClause as needed for each
> SampleScanPath. That's what the attached patch does.

Alternatively, could we postpone the reparameterization until
createplan.c? Having to build reparameterized expressions we might
not use seems expensive, and it would also contribute to the memory
bloat being complained of in nearby threads.

> There are some other plan types that do not have a separate path type
> but may have lateral references in expressions stored in RangeTblEntry,
> such as FunctionScan, TableFuncScan and ValuesScan. But it's not clear
> to me if there are such problems with them too.

Hmm, well, not for partition-wise join anyway.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2023-08-01 13:25:51 Re: Performance degradation on concurrent COPY into a single relation in PG16.
Previous Message Anthonin Bonnefoy 2023-08-01 13:19:41 Re: POC: Extension for adding distributed tracing - pg_tracing