Re: [GENERAL] drop/rename table and transactions

From: Lincoln Yeoh <lylyeoh(at)mecomb(dot)com>
To: Jaco de Groot <jaco(at)gospelsjop(dot)com>, pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] drop/rename table and transactions
Date: 1999-11-26 01:08:04
Message-ID: 3.0.5.32.19991126090804.008af890@pop.mecomb.po.my
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

>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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alain TESIO 1999-11-26 02:50:47 A script which drops a column
Previous Message Mike Mascari 1999-11-26 00:25:11 Re: [GENERAL] drop/rename table and transactions

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 1999-11-26 01:08:24 RE: [HACKERS] Concurrent VACUUM: first results
Previous Message Mike Mascari 1999-11-26 00:25:11 Re: [GENERAL] drop/rename table and transactions