pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Cc: Phil Sorber <phil@omniti.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Extension tracking temp table and causing update failure
Date: Thu, 08 Mar 2012 12:19:21 -0500
Message-ID: <13187.1331227161@sss.pgh.pa.us> (raw)
In-Reply-To: <m2y5rbxc36.fsf@2ndQuadrant.fr>
References: <CADAkt-i4kJn_ht=+6x408uVjQG4XKjvy3FbyMKer+oJATLWykQ@mail.gmail.com>
	<21101.1331071837@sss.pgh.pa.us>
	<87linc93iq.fsf@hi-media-techno.com>
	<8167.1331135949@sss.pgh.pa.us>
	<15629.1331145998@sss.pgh.pa.us>
	<m2y5rbxc36.fsf@2ndQuadrant.fr>

Dimitri Fontaine <dimitri@2ndQuadrant.fr> writes:
> Tom Lane <tgl@sss.pgh.pa.us> writes:
>> 1. If you forget to drop the temp table before ending the script,
>> then when the session ends and the temp table is forcibly dropped,
>> the whole extension goes away (following the rule that a forced drop
>> of an extension member makes the whole extension go away).  This is
>> mildly annoying, but since not dropping the temp table is a clear bug
>> in an extension script, I think we can live with it.

> Could we force temp tables created in an extension script to be ON
> COMMIT DROP so that CurrentExtensionObject is still set and your patch
> kicks in, preventing the DROP cascading?

Huh, yeah, that might work.  It's ugly but at least the ugliness is
localized; and there's no obvious reason why such a temp table ought to
survive past the end of the script.

In a quick look, we can't do it exactly like that because
CurrentExtensionObject isn't still set at transaction end; but I think
we could call PreCommit_on_commit_actions just before we clear
CurrentExtensionObject, so that the drops are done a tad early.

> We might want to protect in the same way against temp schema explicitly
> created by the extension script too (IIRC you can actually do that): it
> could be just about documentation, but if that's not too much contorting
> the code it would be better to just ERROR out, I think.

Nah, that's not a reasonable thing for an extension script to do IMO.
We are not in the business of trying to prevent superusers from thinking
of creative ways to break their database.  I'll be satisfied if a
routine CREATE TEMP TABLE in an extension script is safe.

			regards, tom lane



view thread (12+ messages)  latest in thread

Message-ID: <13187.1331227161@sss.pgh.pa.us>
Permalink:  ../13187.1331227161@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/13187.1331227161@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 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: tgl@sss.pgh.pa.us, dimitri@2ndQuadrant.fr, phil@omniti.com
  Subject: Re: Extension tracking temp table and causing update failure
  In-Reply-To: <13187.1331227161@sss.pgh.pa.us>
  References: <CADAkt-i4kJn_ht=+6x408uVjQG4XKjvy3FbyMKer+oJATLWykQ@mail.gmail.com> <21101.1331071837@sss.pgh.pa.us> <87linc93iq.fsf@hi-media-techno.com> <8167.1331135949@sss.pgh.pa.us> <15629.1331145998@sss.pgh.pa.us> <m2y5rbxc36.fsf@2ndQuadrant.fr> <13187.1331227161@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