X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 50EDE563D8 for ; Tue, 8 Mar 2005 23:27:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33812-03 for ; Tue, 8 Mar 2005 23:27:06 +0000 (GMT) Received: from amanda.contactbda.com (ipn36372-e65122.cidr.lightship.net [216.204.66.226]) by svr1.postgresql.org (Postfix) with ESMTP id 2B2B552A59 for ; Tue, 8 Mar 2005 23:27:05 +0000 (GMT) Received: from amanda.contactbda.com (amanda.contactbda.com [192.168.1.2]) by amanda.contactbda.com (8.12.11/8.12.11/Debian-3) with ESMTP id j28NR6cK028801; Tue, 8 Mar 2005 18:27:06 -0500 From: "Jim Buttafuoco" To: pw , pgsql-interfaces@postgresql.org Reply-To: jim@contactbda.com Subject: Re: Question about accessing current row data inside trigger Date: Tue, 8 Mar 2005 18:27:06 -0500 Message-Id: <20050308232604.M14503@contactbda.com> In-Reply-To: <422E2DD4.1070509@telus.net> References: <422E2DD4.1070509@telus.net> X-Mailer: Open WebMail 2.41 20040926 X-OriginatingIP: 192.168.1.1 (jim) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.053 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/27 X-Sequence-Number: 5356 have you looked in the contrib directory (Postgresql 7.4.6). I just checked and the dbmirror/pending.c looks like some good code to follow. Jim ---------- Original Message ----------- From: pw To: pgsql-interfaces@postgresql.org Sent: Tue, 08 Mar 2005 14:57:24 -0800 Subject: [INTERFACES] Question about accessing current row data inside trigger > *previously posted this to pgsql-general* > > -Hello, > - > -I have a trigger function written in C. > -The trigger function is called via: > - > -CREATE TRIGGER after_update AFTER UPDATE ON some_table > - FOR EACH ROW EXECUTE PROCEDURE my_trigger_function(); > - > - Since the trigger is called after each row update the actual > -row data > -should be available in some way to the trigger. > - > - What functionality (SPI ?) do I use to use the column values -from the > -current row in the actual trigger? > - > - Does SPI_cursor_fetch automatically give me the current trigger -row or > -do I need to query again for the proper row? > - > -thanks for any insight, > - > -Peter > > I am now using : > > TupleTableSlot *t = (TupleTableSlot *) PG_GETARG_POINTER(0); > bool isnull; > > char *buffer=(char *)DatumGetPointer(GetAttributeByName(t, > "some_column_name", &isnull)); > > The pointer always comes back NULL though there is data > in the column. > > I'm still not sure this is the correct way to access > the data from the updated row. > > Is this the correct way to get a string back from > the data in the column named 'some_column_name'? > > Do I have the correct TupleTableSlot pointer? > > Thanks for any insight, > > Peter > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) ------- End of Original Message -------