From: | Arthur Ward <ward005(at)bama(dot)ua(dot)edu> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | 7.3.3 - plpython & trigger problem |
Date: | 2003-06-11 16:52:05 |
Message-ID: | 3EE717E5.1812.ADD2902@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
I'm running "PostgreSQL 7.3.3 on i686-pc-linux-gnu, compiled by
GCC gcc (GCC) 3.2.2", and seeing a problem in trigger functions
written in plpython. This also happens in 7.3.2; I upgraded this
morning to see if the problem was already fixed. For fields of type
char, when a plpython trigger is called, the char fields in the
TD["new"] or TD["old"] maps show as 0 or 1 instead of their actual
value. As far as I've seen right now, it only affects char. The
varchar and text types seem ok, but I have not done any
comprehensive testing of the numerics and other types.
Here's a test script to show the problem:
CREATE TABLE test (
broken CHAR(4),
works VARCHAR(4),
alsoworks TEXT
);
CREATE OR REPLACE FUNCTION pytest() RETURNS TRIGGER
AS '
plpy.info ("TD=%s" % TD)
return None
' LANGUAGE 'plpython';
CREATE TRIGGER test_trig BEFORE INSERT OR UPDATE OR
DELETE ON test
FOR EACH ROW EXECUTE PROCEDURE pytest();
INSERT INTO test VALUES ('test', 'test', 'test');
UPDATE test SET broken='1234', works='1234', alsoworks='1234';
DELETE FROM test;
And here's the output from the last three statements on my system:
award=> INSERT INTO test VALUES ('test', 'test', 'test');
INFO: ("TD={'relid': '3928912', 'old': None, 'name': 'test_trig', 'level':
'ROW', 'new': {'alsoworks': 'test', 'broken': 1, 'works': 'test'}, 'args':
None, 'when': 'BEFORE', 'event': 'INSERT'}",)
INSERT 3928918 1
award=> UPDATE test SET broken='1234', works='1234',
alsoworks='1234';
INFO: ("TD={'relid': '3928912', 'old': {'alsoworks': 'test', 'broken': 1,
'works': 'test'}, 'name': 'test_trig', 'level': 'ROW', 'new': {'alsoworks':
'1234', 'broken': 0, 'works': '1234'}, 'args': None, 'when': 'BEFORE',
'event': 'UPDATE'}",)
UPDATE 1
award=> DELETE FROM test;
INFO: ("TD={'relid': '3928912', 'old': {'alsoworks': '1234', 'broken': 0,
'works': '1234'}, 'name': 'test_trig', 'level': 'ROW', 'new': None, 'args':
None, 'when': 'BEFORE', 'event': 'DELETE'}",)
DELETE 1
--
Arthur Ward
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-06-11 17:34:23 | Re: 7.3.3 - plpython & trigger problem |
Previous Message | Bruce Momjian | 2003-06-11 15:01:16 | Re: missing DLLIMPORT for cpu_index_tuple_cost |