Re: BUG #14876: Segmentation fault with JSONB column used in store proc that gets used by view and later altered

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: samuel(dot)horwitz(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14876: Segmentation fault with JSONB column used in store proc that gets used by view and later altered
Date: 2017-10-26 22:04:59
Message-ID: 31441.1509055499@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> Thanks for posting the reproducer. The attached seems to fix it, but
> now that I've seen this, I wonder if there are other similar cases.

After some not-very-exhaustive looking around, the only thing I've found
that seems closely related is expandRTE's behavior for a function
returning composite in an RTE_FUNCTION RTE. It's clearly possible for
somebody to have added columns to the composite type since the calling
query was parsed, so there is a comparable hazard in that case as well.
But what that code path does is to ignore any columns beyond what it
saw originally (which it's memorialized in funccolcount; see the comment
for struct RangeTblFunction).

To be consistent with that, it seems like what the RTE_SUBQUERY case
ought to do is ignore columns beyond the length of eref->colnames.
This is probably less useful than what I posted first --- it means you
don't get to see any added columns in the result of "subqueryname.*".
But I doubt we want different behaviors in the two cases.

regards, tom lane

Attachment Content-Type Size
make-expandRTE-ignore-new-columns.patch text/x-diff 1.2 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2017-10-26 23:14:19 Re: Connections hang indefinitely while taking a LWLockTranche buffer_content lock.
Previous Message Tom Lane 2017-10-26 20:42:36 Re: BUG #14876: Segmentation fault with JSONB column used in store proc that gets used by view and later altered