Re: ADD FOREIGN KEY (was Re: [GENERAL] 7.4Beta)

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jan Wieck <JanWieck(at)Yahoo(dot)com>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>, Peter Childs <Blue(dot)Dragon(at)blueyonder(dot)co(dot)uk>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ADD FOREIGN KEY (was Re: [GENERAL] 7.4Beta)
Date: 2003-09-30 04:37:07
Message-ID: 200309300437.h8U4b7c17142@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Tom Lane wrote:
> > If we go that direction, why don't we just make a GUC variable to
> > disable constraint checking.
>
> You mean in general, even for plain old insert/update/delete changes?
> Yipes. What happened to ACID compliance?
>
> What I actually expected to ensue was a discussion about how we could
> narrow down the effects of a disable-foreign-key-verification switch to
> reduce the odds of shooting oneself in the foot. (For example, maybe
> disallow it from being set in postgresql.conf.) I wasn't expecting
> proposals to enlarge the gauge of the foot-gun ...

Fact is, folks are doing it anyway by modifying pg_class. I know one
guy who did it in a transaction so he was the only one to see the
triggers disabled! The PostgreSQL cookbook page has an example too.
People are always asking how to do this. Why not just make it setable
only by the super-user.

FYI, TODO has:

* Allow triggers to be disabled [trigger]
* With disabled triggers, allow pg_dump to use ALTER TABLE ADD FOREIGN
KEY

The second one is the one we are discussing. If we never want to do it,
I will remove it from the TODO list. However, I think we might be
making things too controlled by not allowing administrators to do this.

> > Also, how does someone turn it on at restore time if they are piping
> > into psql?
>
> Something like
> export PGOPTIONS="-c disable-fk-verification=true"
> then run psql or pg_restore.

How many folks are going to remember to do this? Why make it hard for
them? Someone is going to forget too easily. "Why is this restore
taking so long? Oh, I forgot that switch." Or they put it in a login
file and forget it is set. Seems safer for it to be in the dump file.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-09-30 04:42:59 Re: psql error:cannot open libpq.so.3
Previous Message Stephan Szabo 2003-09-30 04:31:31 Re: ADD FOREIGN KEY (was Re: [GENERAL] 7.4Beta)

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-09-30 04:51:21 Re: signal to send to postgres when log rolling
Previous Message Bruce Momjian 2003-09-30 04:31:41 Re: signal to send to postgres when log rolling