Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id DB0931B2D9D5 for ; Mon, 26 Mar 2012 15:16:29 -0300 (ADT) Received: from mahout.postgresql.org ([98.129.198.123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SCESv-0007iU-TM for pgsql-bugs@postgresql.org; Mon, 26 Mar 2012 18:16:29 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SCESi-0005Nb-QK for pgsql-bugs@postgresql.org; Mon, 26 Mar 2012 18:16:12 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1SCESi-0005Nq-Dd for pgsql-bugs@postgresql.org; Mon, 26 Mar 2012 18:16:12 +0000 Date: Mon, 26 Mar 2012 18:16:12 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6559: PLPython INSERT trigger fails with composite types To: pgsql-bugs@postgresql.org From: xi@resolvent.net X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/180 X-Sequence-Number: 32741 The following bug has been logged on the website: Bug reference: 6559 Logged by: Kirill Simonov Email address: xi@resolvent.net PostgreSQL version: 9.1.3 Operating system: Debian squeeze+backports Description: = A PlPython INSERT trigger fails to modify a row when a column of a composite type is affected. Worked with 8.4. Here is a test case: CREATE TYPE rec_t AS (val INTEGER); CREATE TABLE tbl (rec rec_t, val INTEGER); INSERT INTO tbl (val) VALUES (NULL); INSERT INTO tbl (rec.val) VALUES (NULL); CREATE LANGUAGE plpythonu; CREATE OR REPLACE FUNCTION trg() RETURNS trigger LANGUAGE plpythonu AS $$ return 'MODIFY'; $$; CREATE TRIGGER "!trg()" BEFORE INSERT OR UPDATE ON tbl FOR EACH ROW EXECUTE PROCEDURE trg(); INSERT INTO tbl (val) VALUES (NULL); INSERT INTO tbl (rec.val) VALUES (NULL); The output: $ psql psql (9.1.3) Type "help" for help. postgres=3D# = postgres=3D# CREATE TYPE rec_t AS (val INTEGER); CREATE TYPE postgres=3D# CREATE TABLE tbl (rec rec_t, val INTEGER); CREATE TABLE postgres=3D# = postgres=3D# INSERT INTO tbl (val) VALUES (NULL); INSERT 0 1 postgres=3D# INSERT INTO tbl (rec.val) VALUES (NULL); INSERT 0 1 postgres=3D# = postgres=3D# CREATE LANGUAGE plpythonu; CREATE LANGUAGE postgres=3D# CREATE OR REPLACE FUNCTION trg() RETURNS trigger postgres-# LANGUAGE plpythonu postgres-# AS $$ postgres$# return 'MODIFY'; postgres$# $$; CREATE FUNCTION postgres=3D# = postgres=3D# CREATE TRIGGER "!trg()" postgres-# BEFORE INSERT OR UPDATE ON tbl postgres-# FOR EACH ROW postgres-# EXECUTE PROCEDURE trg(); CREATE TRIGGER postgres=3D# = postgres=3D# INSERT INTO tbl (val) VALUES (NULL); INSERT 0 1 postgres=3D# INSERT INTO tbl (rec.val) VALUES (NULL); ERROR: length of returned sequence did not match number of columns in row CONTEXT: while modifying trigger row PL/Python function "trg"