Re: dropping non-existent tables

From: "Walsh, Richard (Richard)" <richardwalsh(at)avaya(dot)com>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: dropping non-existent tables
Date: 2005-07-27 11:23:22
Message-ID: 73E4F3992055E8429385A496BCCC90EC1073F0A2@bg0007avexu1.global.avaya.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Michael,
I am executing these statements inside an SQL DDL script so I think they
all take place inside a single transaction. I am not using PSQL. I will
try what you suggest and see if executing the drop statements in a
separate tx will work.
Richie.

-----Original Message-----
From: Michael Fuhr [mailto:mike(at)fuhr(dot)org]
Sent: 26 July 2005 23:09
To: Walsh, Richard (Richard)
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] dropping non-existent tables

On Tue, Jul 26, 2005 at 06:04:08PM +0200, Walsh, Richard (Richard)
wrote:
> I have a problem in that I need to drop non-existent tables in a DDL
> script. This is in order that the script can re-build a database
> schema if the tables already exist. However, in Postgres this is
> proving to be a problem because if the table does not exist then the
> DDL execution will stop once it gets an error.

Are you executing the statements inside a transaction? If so then you
could execute the DROP statements in separate transactions (or execute
them outside of any transaction in autocommit mode). Also, if you're
using psql then make sure you don't have ON_ERROR_STOP set.

In PostgreSQL 8.1, psql will have an ON_ERROR_ROLLBACK setting that uses
savepoints to automatically roll back failed statements while allowing
the rest of the transaction to continue.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Stewart 2005-07-27 12:56:24 Daily digest?
Previous Message Terry Lee Tucker 2005-07-27 11:13:53 Re: backend triggers communication with front-end