Re: [GENERAL] drop/rename table and transactions - Mailing list pgsql-general

From Lincoln Yeoh
Subject Re: [GENERAL] drop/rename table and transactions
Date
Msg-id 3.0.5.32.19991126090804.008af890@pop.mecomb.po.my
Whole thread Raw
In response to drop/rename table and transactions  (Jaco de Groot <jaco@gospelsjop.com>)
Responses Re: [GENERAL] locking/insert into table and transactions
List pgsql-general
>If this happens, all my database connections get this error when trying
>to access the database and I need to restart postgresql. The problem
>causing this error needs to be something like this:
>
>  create table table2 (col1 text);
>  insert into table2 (col1) values ('some data');
>  begin work;
>  drop table table1;
>  alter table table2 rename to table1;
>  commit;

What happens if two different connections try to "drop table table1"? Try
doing it step by step in two different connections?

I did a vaguely similar thing.

I did a BEGIN, DROP TABLE, ROLLBACK. And yes I know you're not supposed to
be able to rollback a drop table, but I could not recreate the table- I had
to do a manual file system delete of the table. If a connection gets broken
during a transaction, and you get a rollback, you could encounter the same
problem.

I did what I did coz I was curious. But creating/Dropping tables in a
transaction does not appear to be a "good thing", and that's not just for
PostgreSQL. I believe doing data definition stuff in transactions is not
recommended.

Is it possible to achieve your goals by using things like
"delete * from table1 where id!=stuffIwant" instead of dropping it?

Cheerio,

Link.


pgsql-general by date:

Previous
From: "Reto H."
Date:
Subject: bug or feature?
Next
From: marten@feki.toppoint.de
Date:
Subject: Re: [GENERAL] Re: Is PostgreSQL ready for mission criticalapplications?