Re: [GENERAL] Trigger - Mailing list pgsql-general

From Bruce Momjian
Subject Re: [GENERAL] Trigger
Date
Msg-id 200003071436.JAA19804@candle.pha.pa.us
Whole thread Raw
In response to RE: [GENERAL] Trigger  (Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>)
Responses Re: Trigger
List pgsql-general
> Switch to v7.0 beta1 and use FOREIGN KEY. You will save a lot of time.
> Before you really finish your development there will be 7.0 production (this
> is my private estimation).
> Andrzej Mazurkiewicz
>
> > I am trying to create a trigger for a detail table to check that value
> > what is entered exists in master table.
> > For example into CustomerOrder table could not be enterd order for
> > Customer what does not exists.


    Not only that he'll save some time. Without the deferred trigger
    queue manager, watching that one and the same row cannot be modified
    twice inside of one transaction (WRT key changes), it's possible to
    fool the trigger and end up with inconsistent data in a multiuser
    environment.

    And don't forget that the INSERT of the FK and the DELETE of the PK
    can happen simultaneously. Due to MVCC, both transactions don't
    know about each other (thanks to Vadim).


Jan from Philly

--
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-general by date:

Previous
From: Henk van Lingen
Date:
Subject: Compiling 7.0 on Solaris
Next
From: JB
Date:
Subject: Re: [GENERAL] 50 MB Table