pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: xi@resolvent.net
To: pgsql-bugs@postgresql.org
Subject: BUG #6559: PLPython INSERT trigger fails with composite types
Date: Mon, 26 Mar 2012 18:16:12 +0000
Message-ID: <E1SCESi-0005Nq-Dd@wrigleys.postgresql.org> (raw)

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=# 
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"





Message-ID: <E1SCESi-0005Nq-Dd@wrigleys.postgresql.org>
Permalink:  ../E1SCESi-0005Nq-Dd@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1SCESi-0005Nq-Dd@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: xi@resolvent.net
  Subject: Re: BUG #6559: PLPython INSERT trigger fails with composite types
  In-Reply-To: <E1SCESi-0005Nq-Dd@wrigleys.postgresql.org>
  References: <E1SCESi-0005Nq-Dd@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox