X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 49208D1B561 for ; Sat, 30 Aug 2003 21:57:17 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 64700-07 for ; Sat, 30 Aug 2003 18:56:47 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 33D29D1B524 for ; Sat, 30 Aug 2003 18:56:45 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h7ULuRjX002692; Sat, 30 Aug 2003 17:56:27 -0400 (EDT) To: Jan Wieck Cc: Chris Anderson , pgsql-sql@postgresql.org Subject: Re: BEFORE UPDATE Triggers In-reply-to: <3F5010EB.9080807@black-lion.info> References: <69957C94-D9A1-11D7-8266-000393D3B384@pobox.com> <3F5010EB.9080807@black-lion.info> Comments: In-reply-to Jan Wieck message dated "Fri, 29 Aug 2003 22:50:19 -0400" Date: Sat, 30 Aug 2003 17:56:27 -0400 Message-ID: <2691.1062280587@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/360 X-Sequence-Number: 14976 Jan Wieck 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