pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedcreate/alter/drop within transactions?
4+ messages / 4 participants
[nested] [flat]
* create/alter/drop within transactions?
@ 2003-04-26 00:48 Forest Wilkinson <forest@lyris.com>
2003-04-26 17:16 ` Re: create/alter/drop within transactions? Rajesh Kumar Mallah <rmallah@trade-india.com>
0 siblings, 1 reply; 4+ messages in thread
From: Forest Wilkinson @ 2003-04-26 00:48 UTC (permalink / raw)
To: pgsql-sql
Sorry if this is a FAQ, but I didn't find a definitive and recent
answer in the list archives or the postgres docs. Do transactions
work on create / alter / drop statements? In other words, can I
choose to commit or rollback after a bunch of schema changes?
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: create/alter/drop within transactions?
2003-04-26 00:48 create/alter/drop within transactions? Forest Wilkinson <forest@lyris.com>
@ 2003-04-26 17:16 ` Rajesh Kumar Mallah <rmallah@trade-india.com>
0 siblings, 0 replies; 4+ messages in thread
From: Rajesh Kumar Mallah @ 2003-04-26 17:16 UTC (permalink / raw)
To: Forest Wilkinson <forest@lyris.com>; +Cc: pgsql-sql
On Fri, 25 Apr 2003, Forest Wilkinson wrote:
Yes it does.
As explain by Tom , TRUNCATE IS the only
command which cannot be done inside a transaction.
even that restriction will go away in 7.4 version
Regds
Mallah
> Sorry if this is a FAQ, but I didn't find a definitive and recent
> answer in the list archives or the postgres docs. Do transactions
> work on create / alter / drop statements? In other words, can I
> choose to commit or rollback after a bunch of schema changes?
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* create/alter/drop within transactions?
@ 2003-04-26 00:58 Forest Wilkinson <lyris-pg@tibit.com>
2003-04-26 02:18 ` Re: create/alter/drop within transactions? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Forest Wilkinson @ 2003-04-26 00:58 UTC (permalink / raw)
To: pgsql-sql
Sorry if this is a FAQ, but I didn't find a definitive and recent
answer in the list archives or the postgres docs. Do transactions
work on create / alter / drop statements? In other words, can I
choose to commit or rollback after a bunch of schema changes?
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: create/alter/drop within transactions?
2003-04-26 00:58 create/alter/drop within transactions? Forest Wilkinson <lyris-pg@tibit.com>
@ 2003-04-26 02:18 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2003-04-26 02:18 UTC (permalink / raw)
To: Forest Wilkinson <lyris-pg@tibit.com>; +Cc: pgsql-sql
Forest Wilkinson <lyris-pg@tibit.com> writes:
> Sorry if this is a FAQ, but I didn't find a definitive and recent
> answer in the list archives or the postgres docs. Do transactions
> work on create / alter / drop statements? In other words, can I
> choose to commit or rollback after a bunch of schema changes?
Yes.
AFAIR, the only non-rollback-able command in Postgres is TRUNCATE TABLE
--- and that's fixed for 7.4 ;-)
In any case, anything you might try to do inside a transaction block
will error out if it cannot roll back. For example, in 7.3:
regression=# create table foo(f1 int);
CREATE TABLE
regression=# begin;
BEGIN
regression=# truncate table foo;
ERROR: TRUNCATE TABLE cannot run inside a transaction block
at which point your transaction is aborted and nothing has happened.
If Postgres lets you do it inside BEGIN, we can roll it back.
regards, tom lane
PS: the only real disadvantage of doing tons-of-schema-changes inside
a BEGIN is that you will be grabbing exclusive locks on each table you
change the schema of. This means you are running a nontrivial risk of
deadlock against other transactions --- in which case you probably lose
your work and have to do it over.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2003-04-26 17:16 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-04-26 00:48 create/alter/drop within transactions? Forest Wilkinson <forest@lyris.com>
2003-04-26 17:16 ` Rajesh Kumar Mallah <rmallah@trade-india.com>
2003-04-26 00:58 create/alter/drop within transactions? Forest Wilkinson <lyris-pg@tibit.com>
2003-04-26 02:18 ` Tom Lane <tgl@sss.pgh.pa.us>
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