Re: Dferred constraints not deferred?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
Cc: PostgreSQL-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Dferred constraints not deferred?
Date: 2003-02-03 17:03:26
Message-ID: 20030203085855.K90013-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Mon, 3 Feb 2003, Jean-Christian Imbeault wrote:

> I'm trying to drop a table inside a transaction with all constraints
> deferred, and then re-create the table, but PG won't let me ..
>
> TAL=# begin;
> BEGIN
> TAL=# SET CONSTRAINTS ALL DEFERRED;
> SET CONSTRAINTS
> TAL=# drop table invoices;
> NOTICE: constraint $1 on table invoice_admin_memo depends on table invoices
> NOTICE: constraint $1 on table req_dlv_date depends on table invoices
> NOTICE: constraint $1 on table invoice_li depends on table invoices
> NOTICE: constraint $1 on table invoice_emails depends on table invoices
> ERROR: Cannot drop table invoices because other objects depend on it
> Use DROP ... CASCADE to drop the dependent objects too
>
> I tought the point of "SET CONSTRAINTS ALL DEFERRED" was to make
> transaction skip constraint checking until the end of a transaction ...
> But in this case the foreign key constraints a checked right away ...
>
> What I would like is to drop the table and recreate it without having PG
> complain about these FK constraints until the very end of the
> transaction (at which time all data will be consistant) ... is this
> possible?

Not really. Deferrability refers to the "check" time of the constraint
which is unrelated to the drops that are necessary for a table drop which
AFAIR was direct text in the drops.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message gilles Darold 2003-02-03 17:20:29 OpenLDAP / PostgreSQL
Previous Message Greg Stark 2003-02-03 17:02:56 Re: Query plan question, and a memory leak