pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: samuel.horwitz@gmail.com, PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14876: Segmentation fault with JSONB column used in store proc that gets used by view and later altered
Date: Thu, 26 Oct 2017 16:42:36 -0400
Message-ID: <26672.1509050556@sss.pgh.pa.us> (raw)
In-Reply-To: <CAB7nPqTxBZ5GorM8bejJ0z1aQo0Z93ChRJ9gCV5zu8B=ZrARVg@mail.gmail.com>
References: <20171026184035.1471.82810@wrigleys.postgresql.org>
	<CAB7nPqTxBZ5GorM8bejJ0z1aQo0Z93ChRJ9gCV5zu8B=ZrARVg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Michael Paquier <michael.paquier@gmail.com> writes:
> I haven't looked at this thing in details. But this data may not be
> present forever, say github.com is down or is removed from existence.
> So if you can, please always attach any self-contained test case in a
> way that it is saved in the archives of postgresql.org. In this case,
> that would have been to email directly pgsql-bugs instead of using the
> website form.

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.

			regards, tom lane

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

Attachments:

make-expandRTE-cope-with-new-columns.patch (text/x-diff, 1.4K) download diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index ca32a37..dae6fb9 100644 *** a/src/backend/parser/parse_relation.c --- b/src/backend/parser/parse_relation.c *************** expandRTE(RangeTblEntry *rte, int rtinde *** 2207,2217 **** if (colnames) { ! /* Assume there is one alias per target item */ ! char *label = strVal(lfirst(aliasp_item)); *colnames = lappend(*colnames, makeString(pstrdup(label))); - aliasp_item = lnext(aliasp_item); } if (colvars) --- 2207,2235 ---- if (colnames) { ! char *label; ! ! /* ! * We prefer to use the outer query's column aliases ! * as column names. However, in scenarios where ! * columns have been added to a view since the outer ! * query was originally parsed, there could be more ! * tlist items in the subquery than the outer query ! * knew about. In such cases, use the subquery's ! * column names if it has any, else fall back to ! * "?column?". ! */ ! if (aliasp_item) ! { ! label = strVal(lfirst(aliasp_item)); ! aliasp_item = lnext(aliasp_item); ! } ! else if (te->resname) ! label = te->resname; ! else ! label = "?column?"; *colnames = lappend(*colnames, makeString(pstrdup(label))); } if (colvars)

view thread (8+ messages)  latest in thread

Message-ID: <26672.1509050556@sss.pgh.pa.us>
Permalink:  ../26672.1509050556@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26672.1509050556@sss.pgh.pa.us

 ·  · 

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: tgl@sss.pgh.pa.us, michael.paquier@gmail.com
  Subject: Re: BUG #14876: Segmentation fault with JSONB column used in store proc that gets used by view and later altered
  In-Reply-To: <26672.1509050556@sss.pgh.pa.us>

* 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