Re: [HACKERS] [sqlsmith] Failed assertion inadjust_appendrel_attrs_mutator - Mailing list pgsql-hackers

From Amit Langote
Subject Re: [HACKERS] [sqlsmith] Failed assertion inadjust_appendrel_attrs_mutator
Date
Msg-id 6c4c8cbc-1ff5-2b6c-18a8-9d961efe998d@lab.ntt.co.jp
Whole thread Raw
In response to Re: [HACKERS] [sqlsmith] Failed assertion in adjust_appendrel_attrs_mutator  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [HACKERS] [sqlsmith] Failed assertion in adjust_appendrel_attrs_mutator
List pgsql-hackers
On 2017/10/23 2:07, Tom Lane wrote:
> Andreas Seltenreich <seltenreich@gmx.de> writes:
>> testing master as of 7c981590c2, sqlsmith just triggered the following
>> assertion:
>> TRAP: FailedAssertion("!(!((((const Node*)(node))->type) == T_SubLink))", File: "prepunion.c", Line: 2231)
> 
> Hmm.  adjust_appendrel_attrs() thinks it's only used after conversion
> of sublinks to subplans, but this is a counterexample.  I wonder if
> that assumption was ever correct?  Or maybe we need to rethink what
> it does when recursing into RTE subqueries.

Looking at the backtrace, the crashing SubLink seems to have been
referenced from a PlaceHolderVar that is in turn referenced by
joinaliasvars of a JOIN rte in query->rtable.

I wonder if we shouldn't just ignore those (joinaliasvars in JOIN rtes)
while adjust_appendrel_attrs() is doing its job on a Query, just like we
ask to ignore subqueries by passing QTW_IGNORE_RC_SUBQUERIES to
query_tree_mutator()?  IOW, it doesn't look like anything critically
depends on the Vars referenced from joinaliasvars being translated at that
point in inheritance_planner(), but I may be missing something.

The attached patch to do the same, while didn't break any existing tests,
fixed the crash reported by OP.

Thoughts?

Thanks,
Amit

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [HACKERS] legitimacy of using PG_TRY , PG_CATCH , PG_END_TRY inC function
Next
From: Ivan Kartyshov
Date:
Subject: Re: [HACKERS] make async slave to wait for lsn to be replayed