pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org, Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Subject: Re: BUG #17161: Assert failed on opening a relation that exists in two schemas via the LANGUAGE SQL function
Date: Tue, 31 Aug 2021 07:00:00 +0300
Message-ID: <042970a6-8d93-cbb0-0e55-1bfb82a99c1e@gmail.com> (raw)
In-Reply-To: <1568218.1630377575@sss.pgh.pa.us>
References: <17161-048a1cdff8422800@postgresql.org>
	<25f71277-c45a-8ef2-ef9a-9054c3d6e0b0@gmail.com>
	<1568218.1630377575@sss.pgh.pa.us>

31.08.2021 05:39, Tom Lane wrote:
> Alexander Lakhin <exclusion@gmail.com> writes:
>> My initial conclusion was incorrect. Duplicate relation is not needed in
>> the second schema. It's sufficient to just change search_path to another
>> schema:
> Actually, you don't need to mess with search_path at all: inlining of
> set-returning SQL functions just plain does not work, if they are
> new-style.  The reason is that we forgot to apply AcquireRewriteLocks
> in that code path.  That leads to the assertion failure you show here.
> Even without that, we risk problems with JOINs on dropped columns, which
> is another thing that AcquireRewriteLocks is charged with cleaning up.
Oops, sorry for the noisy reproduction and incorrect conclusions.
I simplified an initial crashing script (thousand lines generated with a
fuzzer)
but was in hot haste and couldn't think of such a simple explanation.
> The regression tests fail to show this problem because, while they do
> test inlining of a new-style SRF, the solitary test case contains no
> relation references.
>
> I looked around at other places that consult prosqlbody, and saw
> that the only one that accounts for the lock issue is init_sql_fcache.
> fmgr_sql_validator and print_function_sqlbody are also being cavalier
> about this, and I doubt that either one of them is really safe.
> (You could maybe argue that print_function_sqlbody doesn't need locks,
> but in view of the dropped-JOIN-column issue, I don't think I believe
> it.  Likewise in fmgr_sql_validator, which wasn't applying the rewriter
> at all, which I doubt is OK considering the older code path does it.)
>
> Proposed patch attached.
This patch fixes the issue for me. Thank you!

Best regards,
Alexander





view thread (5+ messages)  latest in thread

Message-ID: <042970a6-8d93-cbb0-0e55-1bfb82a99c1e@gmail.com>
Permalink:  ../042970a6-8d93-cbb0-0e55-1bfb82a99c1e@gmail.com/
Also on:    postgresql.org/message-id/042970a6-8d93-cbb0-0e55-1bfb82a99c1e@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: exclusion@gmail.com, tgl@sss.pgh.pa.us, peter.eisentraut@enterprisedb.com
  Subject: Re: BUG #17161: Assert failed on opening a relation that exists in two schemas via the LANGUAGE SQL function
  In-Reply-To: <042970a6-8d93-cbb0-0e55-1bfb82a99c1e@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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