pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Wieck <JanWieck@Yahoo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Chris Anderson <cva@pobox.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: BEFORE UPDATE Triggers
Date: Sun, 31 Aug 2003 22:12:02 -0400
Message-ID: <3F52AAF2.2000104@Yahoo.com> (raw)
In-Reply-To: <2691.1062280587@sss.pgh.pa.us>
References: <69957C94-D9A1-11D7-8266-000393D3B384@pobox.com>
	<3F5010EB.9080807@black-lion.info>
	<2691.1062280587@sss.pgh.pa.us>



Tom Lane wrote:
> Jan Wieck <jan@black-lion.info> writes:
>> Unfortunately, you're right. There is no way do distinguish in a trigger 
>> or rule if a value in the new row did result from the UPDATE query or 
>> from target list expansion with OLD values.
> 
>> It would not be terribly hard to examine the original query during 
>> executor start, looking for bare OLD referencing Var nodes, and stick 
>> something like a flag array into the trigger information.
> 
> People keep suggesting this, but I've never thought it was a very sane
> idea.  What if some BEFORE trigger upstream of yours changes the column?
> You won't find that out unless you actually compare the OLD and NEW
> column values.  If you assume the column has not changed just because
> the original query text didn't change it, you are in for a world of hurt.

That's exactly why I allways ask to look at it from a business process 
point of view. The NEW data that will be persistent when the transaction 
commits has to match the new status of the business process. Where this 
data exactly is coming from, got manipulated or how it got there is not 
really relevant. What counts is that the system transforms from one 
consistent state into another in an ACID transaction.


Jan

-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #




view thread (4+ messages)

Message-ID: <3F52AAF2.2000104@Yahoo.com>
Permalink:  ../3F52AAF2.2000104@Yahoo.com/
Also on:    postgresql.org/message-id/3F52AAF2.2000104@Yahoo.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: JanWieck@Yahoo.com, tgl@sss.pgh.pa.us, cva@pobox.com
  Subject: Re: BEFORE UPDATE Triggers
  In-Reply-To: <3F52AAF2.2000104@Yahoo.com>

* 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