Bug #963: Weird plpython trigger(?) behaviour in 7.3.2 - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject Bug #963: Weird plpython trigger(?) behaviour in 7.3.2
Date
Msg-id 20030502161352.47634476380@postgresql.org
Whole thread Raw
Responses Re: Bug #963: Weird plpython trigger(?) behaviour in 7.3.2
List pgsql-bugs
Indrek Jarve (incx@inversion.ee) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
Weird plpython trigger(?) behaviour in 7.3.2

Long Description
Hi,

using an plpython BEFORE INSERT FOR EACH ROW trigger that modifies the
inserted row on the schema attached below seems to cause weird side effects: when the trigger modifies field1 (in this
casevarchar(300)) contents to be longer than the size of field2 (in this case varchar(16)), the backend refuses to
insertthe row and replies: "ERROR: value too long for type character varying(16)", even when field2 is a shorter string
andis NOT modified by the trigger. Removing the limit from field2 (for example declaring it as text) causes the error
todisappear.  

System: Redhat 9 with updates on a dual-p3, PostgreSQL 7.3.2 installed from RPM packages that came with it.

Regards,
Indrek

Sample Code
Used SQL:

CREATE TABLE items (
    field1 character varying(300),
    field2 varchar(16)
);

CREATE FUNCTION test_func () RETURNS "trigger"
    AS '
# Set field1 LONGER than 16 chars
TD[''new''][''field1''] = ''aabaaaaaaaaaaaaaaa''
return ''MODIFY''
'
    LANGUAGE plpython;

COPY items (field1, field2) FROM stdin;
asdf1   asdf2
\.

CREATE TRIGGER test_trig
    BEFORE INSERT ON items
    FOR EACH ROW
    EXECUTE PROCEDURE test_func ();

insert into items ( field2 ) values ( '' );

psql result:

[incx@hercules incx]$ psql incx < bugine.txt
CREATE TABLE
CREATE FUNCTION
CREATE TRIGGER
ERROR:  value too long for type character varying(16)

No file was uploaded with this report

pgsql-bugs by date:

Previous
From: "A.Bhuvaneswaran"
Date:
Subject: Re: Bug #962: can't drop column
Next
From: Josh Berkus
Date:
Subject: Very bizarre bug with corrupted index