Re: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)anarazel(dot)de>, thibaut(dot)madelaine(at)dalibo(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
Date: 2019-03-06 20:23:33
Message-ID: CAOBaU_YXJ3DPjENmR_aVpVkcAc0QpyvtQU3rTLybKE9USi=3Zg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Mar 6, 2019 at 7:23 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Julien Rouhaud <rjuju123(at)gmail(dot)com> writes:
> > I agree that the RelOptInfo new flag / IS_DUMMY_REL change solution is
> > the best solution. Let's hope there won't be too many extensions
> > relying on the old IS_DUMMY_REL() macro.
>
> I concluded that that actually doesn't work very well. The reason that
> things are set up the way they are, I now remember, is that if we exclude
> all children of an appendrel then what we get is a childless Append path.

Yes, I also realized that on my first try with this approach.

> With the current data structure, that means the appendrel is automatically
> recognized as dummy. If we have a separate flag then we'd have to fix a
> fair number of places to also set the flag. I'm afraid we'd miss some,
> or even more likely that there'd be extensions that would be silently
> broken because that doesn't work the same anymore.

I was wondering if we couldn't transform IS_DUMMY_REL to something like

#define IS_DUMMY_REL(r) \
- ((r)->cheapest_total_path != NULL && \
- IS_DUMMY_PATH((r)->cheapest_total_path))
+ ((r)->is_dummy_rel == true || ((r)->cheapest_total_path != NULL && \
+ IS_DUMMY_PATH((r)->cheapest_total_path)))

This way, any empty AppendRel would still be recognized as a dummy rel
until a projection is added. We would simply have to fix
create_projection_path or any function adding a projection to first
explicitly set the rel->is_dummy_rel flag if it's an empty AppendRel.
We shouldn't miss any spot and it should also work with extensions?

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Ricardo Teixeira 2019-03-06 22:41:47 Instalation Bug
Previous Message Tom Lane 2019-03-06 20:12:15 Re: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)