X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CF621D1D543 for ; Wed, 21 Jan 2004 13:50:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 30303-02 for ; Wed, 21 Jan 2004 09:50:32 -0400 (AST) Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by svr1.postgresql.org (Postfix) with ESMTP id 6961BD1B4D1 for ; Wed, 21 Jan 2004 09:50:28 -0400 (AST) Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AjIkZ-00047a-00 for ; Wed, 21 Jan 2004 14:50:31 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AjIkW-00047Q-00 for ; Wed, 21 Jan 2004 14:50:28 +0100 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AjIkW-0003Vs-00 for ; Wed, 21 Jan 2004 14:50:28 +0100 From: Harald Fuchs Subject: Re: Trigger question Date: 21 Jan 2004 14:50:26 +0100 Organization: Linux Private Site Lines: 32 Message-ID: References: <400691EA.96598C34@t1.unisoftbg.com> <24605.1074616950@sss.pgh.pa.us> <200401201905.46699.dev@archonet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Complaints-To: usenet@sea.gmane.org X-No-Archive: yes User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/207 X-Sequence-Number: 5381 In article <200401201905.46699.dev@archonet.com>, Richard Huxton writes: > On Tuesday 20 January 2004 16:42, Tom Lane wrote: >> Harald Fuchs writes: >> > Why? If the underlying table has a primary key, finding corresponding >> > pairs is trivial; if there isn't, it's impossible. >> >> Exactly. Nonetheless, the correspondence exists --- the UPDATE >> definitely updated some particular row of the OLD set into some >> particular one of the NEW set. If the trigger API makes it impossible >> to reconstruct the matchup, the API is broken. I would not say so. You could use tables without primary keys, and you could define statement-level triggers on them, but you could not identify a particular row in this very special and probably rare case. > Perhaps they should be cursors? The only sensible way I can think of working > with them would be: > 1. count how many rows affected > 2. step through one row at a time, doing something. When I read about the "insert" and "delete" pseudotables in a book about Transact-SQL, i was enthusiastic about the elegance of this idea: you're operating on multiple (perhaps lots of) rows, and the SQL way of doing that is by set-operations, i.e. single operations affecting a set of rows. Pseudotables extend this idea nicely into the area of statement-level triggers. Your cursor idea doesn't look very SQL-like to me. We really should find an Oracle/DB2/Informix guy who can tell us how to get that right.