pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Bill Parker <wp02855@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: Lack of Sanity Checking in file 'pctcl.c' for PostgreSQL 9.4.x
Date: Sat, 18 Jul 2015 17:54:21 +0200
Message-ID: <20150718155421.GZ2301@postgresql.org> (raw)
In-Reply-To: <CAB7nPqSE2vmAdrv0LWBKkM-uBntscU6vdRRhUmKTOwjLNhJ7Lg@mail.gmail.com>
References: <CAFrbyQwyLDYXfBOhPfoBGqnvuZO_Y90YgqFM11T2jvnxjLFmqw@mail.gmail.com>
	<CAB7nPqRmXz2DymNd_BX8HkaRJuQCTUyhh2d5Zx+d0aHNvpTw0Q@mail.gmail.com>
	<20150612194716.GQ133018@postgresql.org>
	<4457.1434166911@sss.pgh.pa.us>
	<CAB7nPqSE2vmAdrv0LWBKkM-uBntscU6vdRRhUmKTOwjLNhJ7Lg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Michael Paquier wrote:
> On Sat, Jun 13, 2015 at 12:41 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> >> Michael Paquier wrote:
> >>> By the way, your patch does not compile properly and is not in-line
> >>> with the project's code format. See the updated patch attached ;)
> >
> >> ... or the conventions for allocating memory.  Why not just use palloc()?
> >
> > That's hardly the fault of the proposed patch.  But yeah, it seems like
> > much the best fix here is to get rid of the malloc (and strdup) calls in
> > this code in favor of using the palloc infrastructure.  Even the calls
> > that *do* have manual failure checks are not compliant with our usual
> > coding standards.
> 
> Hm. Regarding the code path mentioned by Bill something like the patch
> attached is enough with a memory context for the query description.

Right.  Note this no longer needs the individual pfree() when aborting,
because the MemoryContextDelete would remove the whole thing.  (Don't
bother resubmitting; I have already fixed it.)  Will push shortly.

> Now, perhaps we could do more efforts with prodesc as well, see for
> example compile_pltcl_function for pltcl and similarly for plperl.
> Thoughts?

Right.  It would simplify the code: create a memory context child of
TopTransactionContext, then compile the function, and if successful,
then MemoryContextSetParent to some longer-lived context.  When the
function is invalidated, it's sufficient to delete the context and
create a new one.  Creating the context as child of
TopTransactionContext allows you to avoid an explicit
MemoryContextDelete() in the elog(ERROR) cases while compiling.

I do wonder how many users this code has ...

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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



view thread (11+ messages)  latest in thread

Message-ID: <20150718155421.GZ2301@postgresql.org>
Permalink:  ../20150718155421.GZ2301@postgresql.org/
Also on:    postgresql.org/message-id/20150718155421.GZ2301@postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@2ndquadrant.com, michael.paquier@gmail.com, tgl@sss.pgh.pa.us, wp02855@gmail.com
  Subject: Re: Lack of Sanity Checking in file 'pctcl.c' for PostgreSQL 9.4.x
  In-Reply-To: <20150718155421.GZ2301@postgresql.org>
  References: <CAFrbyQwyLDYXfBOhPfoBGqnvuZO_Y90YgqFM11T2jvnxjLFmqw@mail.gmail.com> <CAB7nPqRmXz2DymNd_BX8HkaRJuQCTUyhh2d5Zx+d0aHNvpTw0Q@mail.gmail.com> <20150612194716.GQ133018@postgresql.org> <4457.1434166911@sss.pgh.pa.us> <CAB7nPqSE2vmAdrv0LWBKkM-uBntscU6vdRRhUmKTOwjLNhJ7Lg@mail.gmail.com> <20150718155421.GZ2301@postgresql.org>

* 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