Re: autocommit vs TRUNCATE et al - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: autocommit vs TRUNCATE et al
Date
Msg-id 200210212308.g9LN8Am21198@candle.pha.pa.us
Whole thread Raw
In response to Re: autocommit vs TRUNCATE et al  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: autocommit vs TRUNCATE et al  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Tom Lane wrote:
> >> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> >>> Maybe we can throw a WARNING when autocommit is on.  Would that make
> >>> everyone happy?
> >> 
> >> I doubt it, because by the time you read the WARNING it's too late:
> >> the statement's already committed.
> 
> > I assume the same limitation would hold for VACUUM, right, that you have
> > to turn on autocommit mode to use it?
> 
> Yeah, it would, unless we wanted to throw in some additional hack to
> distinguish VACUUM from the "more dangerous" cases.

From my perspective, I think it would be consistent to disallow all
transaction-unsafe commands and tell people they have to turn autocommit
on to execute them, so it would be:
SET autocommit TO 'on';VACUUM;SET autocommit TO 'off';

That is a pain, but it is probably the safest, as you explained.

One particularly nasty problem is issuing a VACUUM or TRUNCATE in cases
where you don't know the autocommit mode.  You could set autocommit to
'on', and issue the command, but how do you know if you need to turn
autocommit back off again?  I suppose you have to conditionally test the
autocommit value and reset it after the command if needed.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: Justin Clift
Date:
Subject: German version of the PostgreSQL "Advocacy and Marketing" site is ready
Next
From: Tom Lane
Date:
Subject: Re: autocommit vs TRUNCATE et al