pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: wieck@debis.com
To: mig@utdt.edu
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Rules and referential integrity
Date: Fri, 12 Nov 1999 17:13:50 +0100 (MET)
Message-ID: <m11mJKg-0003kLC@orion.SAPserv.Hamburg.dsh.de> (raw)
In-Reply-To: <199911121528.MAA07053@ant.utdt>

> Now: why not define a function (in pltcl; could be something else?)
>
>  create function err(bpchar) returns bpchar
>    as 'error $1' language 'pltcl'
>
> Then, if the value of a column does not appear in another table, you
> could rewrite the query to (for instance)
>       select err('your message')
>
> This will raise a PGRES_FATAL_ERROR , with error message
> ERROR:  pltcl: your message
>
> So: it is possible. Why it is better (or worse) than a trigger, I do
> not know. Views on that?

    Depends  on  the  data  and  usage.  If  only  few tuples are
    affected by a statement, a trigger will usually do  a  better
    job.  Especially  if  the  path  to  find  that tuple is very
    complicated, because the rule has to follow this path another
    time.

    OTOH  if one statement affects thousands of rows, a rule will
    perform better because it is executed in one  internal  extra
    query  instead of invoking the trigger for each single tuple.

    There is no general "this is better than that".


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: <m11mJKg-0003kLC@orion.SAPserv.Hamburg.dsh.de>
Permalink:  ../m11mJKg-0003kLC@orion.SAPserv.Hamburg.dsh.de/
Also on:    postgresql.org/message-id/m11mJKg-0003kLC@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, mig@utdt.edu
  Subject: Re: [SQL] Rules and referential integrity
  In-Reply-To: <m11mJKg-0003kLC@orion.SAPserv.Hamburg.dsh.de>
  References: <199911121528.MAA07053@ant.utdt> <m11mJKg-0003kLC@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