From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: autocommit vs TRUNCATE et al |
Date: | 2002-10-21 23:08:10 |
Message-ID: | 200210212308.g9LN8Am21198@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Tom Lane wrote:
> >> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-10-21 23:10:14 | Re: autocommit vs TRUNCATE et al |
Previous Message | Justin Clift | 2002-10-21 23:05:19 | German version of the PostgreSQL "Advocacy and Marketing" site is ready |