Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e7ozw-0007b9-7s for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Oct 2017 20:43:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e7ozv-0007Xe-OA for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Oct 2017 20:43:27 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e7ozB-00060O-S3 for pgsql-bugs@postgresql.org; Thu, 26 Oct 2017 20:42:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e7oz8-0003gG-G4 for pgsql-bugs@postgresql.org; Thu, 26 Oct 2017 20:42:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v9QKgaPi026673; Thu, 26 Oct 2017 16:42:36 -0400 From: Tom Lane To: Michael Paquier cc: samuel.horwitz@gmail.com, PostgreSQL mailing lists Subject: Re: BUG #14876: Segmentation fault with JSONB column used in store proc that gets used by view and later altered In-reply-to: References: <20171026184035.1471.82810@wrigleys.postgresql.org> Comments: In-reply-to Michael Paquier message dated "Thu, 26 Oct 2017 12:24:06 -0700" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <26200.1509050527.0@sss.pgh.pa.us> Date: Thu, 26 Oct 2017 16:42:36 -0400 Message-ID: <26672.1509050556@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26200.1509050527.1@sss.pgh.pa.us> Michael Paquier 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 ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="make-expandRTE-cope-with-new-columns.patch"; charset="us-ascii" Content-ID: <26200.1509050527.2@sss.pgh.pa.us> Content-Description: make-expandRTE-cope-with-new-columns.patch Content-Transfer-Encoding: quoted-printable 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 **** =20=20 if (colnames) { ! /* Assume there is one alias per target item */ ! char *label =3D strVal(lfirst(aliasp_item)); =20=20 *colnames =3D lappend(*colnames, makeString(pstrdup(label))); - aliasp_item =3D lnext(aliasp_item); } =20=20 if (colvars) --- 2207,2235 ---- =20=20 if (colnames) { ! char *label; !=20 ! /* ! * 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 =3D strVal(lfirst(aliasp_item)); ! aliasp_item =3D lnext(aliasp_item); ! } ! else if (te->resname) ! label =3D te->resname; ! else ! label =3D "?column?"; =20=20 *colnames =3D lappend(*colnames, makeString(pstrdup(label))); } =20=20 if (colvars) ------- =_aaaaaaaaaa0 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs ------- =_aaaaaaaaaa0--