pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: wieck@debis.com
To: Ed Loehr <eloehr@austin.rr.com>
Cc: roberts@panix.com
Cc: pgsql-hackers@postgreSQL.org
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [HACKERS] Help with pl/pgsql, triggers, and foreign keys
Date: Mon, 31 Jan 2000 10:49:52 +0100 (CET)
Message-ID: <m12FDSy-0003kdC@orion.SAPserv.Hamburg.dsh.de> (raw)
In-Reply-To: <3892A6C1.264C62B7@austin.rr.com>

Ed Loehr wrote:

> At least in 6.5.2, you can definitely implement referential integrity
> (RI) via pl/pgsql.  As someone noted earlier, RI is to be released in
> 7.0, but I suspect it will take a subsequent release or two to
> stabilize before it's fit for consumption by the more conservative
> reliability-focused users among us...

    I hope that this isn't true.

    First, because FOREIGN KEY is implemented as builtin triggers
    written in C.  BETA should turn out most of the  bugs,  which
    could still be in it.

    Second,  RI  cannot  get  implemented  reliable  with regular
    triggers.   You  can  easily  violate  the   semantics   with
    concurrently  running  transactions.   Have first transaction
    inserting a reference, the trigger checks for  key  existence
    and  finds it. Now second transaction deletes the key, and an
    eventually existing ON DELETE CASCADE trigger fired  on  that
    wouldn't  find the reference, because it isn't committed yet.
    Second transaction commits, what finally removes the key. Now
    first  transaction commits, making the reference visible, but
    referencing a non existing key - inconsistency.

    So anyone who needs referential integrity is asked to  stress
    the code as far as he can, at least during BETA.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#========================================= wieck@debis.com (Jan Wieck) #





view thread (4+ messages)

Message-ID: <m12FDSy-0003kdC@orion.SAPserv.Hamburg.dsh.de>
Permalink:  ../m12FDSy-0003kdC@orion.SAPserv.Hamburg.dsh.de/
Also on:    postgresql.org/message-id/m12FDSy-0003kdC@orion.SAPserv.Hamburg.dsh.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: wieck@debis.com, eloehr@austin.rr.com, roberts@panix.com, pgsql-hackers@postgreSQL.org
  Subject: Re: [HACKERS] Help with pl/pgsql, triggers, and foreign keys
  In-Reply-To: <m12FDSy-0003kdC@orion.SAPserv.Hamburg.dsh.de>
  References: <3892A6C1.264C62B7@austin.rr.com> <m12FDSy-0003kdC@orion.SAPserv.Hamburg.dsh.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox