Re: [sqlsmith] Failed assertion in adjust_appendrel_attrs_mutator

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andreas Seltenreich <seltenreich(at)gmx(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [sqlsmith] Failed assertion in adjust_appendrel_attrs_mutator
Date: 2017-10-23 09:07:20
Message-ID: 6c4c8cbc-1ff5-2b6c-18a8-9d961efe998d@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017/10/23 2:07, Tom Lane wrote:
> Andreas Seltenreich <seltenreich(at)gmx(dot)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

Attachment Content-Type Size
inh-translate-ignore-joinalias-vars.patch text/plain 633 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ivan Kartyshov 2017-10-23 09:29:03 Re: make async slave to wait for lsn to be replayed
Previous Message Andres Freund 2017-10-23 08:27:43 Re: legitimacy of using PG_TRY , PG_CATCH , PG_END_TRY in C function