BUG #6559: PLPython INSERT trigger fails with composite types

From: xi(at)resolvent(dot)net
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6559: PLPython INSERT trigger fails with composite types
Date: 2012-03-26 18:16:12
Message-ID: E1SCESi-0005Nq-Dd@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 6559
Logged by: Kirill Simonov
Email address: xi(at)resolvent(dot)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=#
postgres=# CREATE TYPE rec_t AS (val INTEGER);
CREATE TYPE
postgres=# CREATE TABLE tbl (rec rec_t, val INTEGER);
CREATE TABLE
postgres=#
postgres=# INSERT INTO tbl (val) VALUES (NULL);
INSERT 0 1
postgres=# INSERT INTO tbl (rec.val) VALUES (NULL);
INSERT 0 1
postgres=#
postgres=# CREATE LANGUAGE plpythonu;
CREATE LANGUAGE
postgres=# CREATE OR REPLACE FUNCTION trg() RETURNS trigger
postgres-# LANGUAGE plpythonu
postgres-# AS $$
postgres$# return 'MODIFY';
postgres$# $$;
CREATE FUNCTION
postgres=#
postgres=# CREATE TRIGGER "!trg()"
postgres-# BEFORE INSERT OR UPDATE ON tbl
postgres-# FOR EACH ROW
postgres-# EXECUTE PROCEDURE trg();
CREATE TRIGGER
postgres=#
postgres=# INSERT INTO tbl (val) VALUES (NULL);
INSERT 0 1
postgres=# 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"

Browse pgsql-bugs by date

  From Date Subject
Next Message Weiss, Wilfried 2012-03-27 09:24:24 BUG #6334: initdb not working
Previous Message sergipanadero 2012-03-26 13:17:44 BUG #6558: installation clusters problems