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

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.

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <2691.1062280587@sss.pgh.pa.us>
Permalink:  ../2691.1062280587@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2691.1062280587@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, jan@black-lion.info, cva@pobox.com
  Subject: Re: BEFORE UPDATE Triggers
  In-Reply-To: <2691.1062280587@sss.pgh.pa.us>

* 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