Thread: plpython bug

plpython bug

From
Mage
Date:
          Hello!

create or replace function trigger_keywords_maintain() returns trigger as $$
    return 'MODIFY'
$$ language plpythonu;

update table set id = id where id = 7

ERROR:  invalid input syntax for type timestamp: "2005-05-03
14:07:33,279213"

I see that Python's timestamp format is not accepted by postgresql.

       Mage

Re: plpython bug

From
Mage
Date:
Update:

it might be not plpython, but similar to the plperl bug I found last time.

The script which can produce the bug:

--------

create table test (id int, date timestamp);

create or replace function trigger_test() returns trigger as $$
plpy.info(TD['new'])
return 'MODIFY'
$$ language plpythonu;

create trigger test_update before update on test for each row execute
procedure trigger_test();

insert into test values (1, now());
insert into test values (2, now());

update test set id = 3;

create or replace function test_perl() returns boolean as $$
    use locale;
    use POSIX qw(locale_h);
    setlocale(LC_COLLATE,'hu_HU');
    setlocale(LC_CTYPE,'hu_HU');
    setlocale(LC_NUMERIC,'hu_HU');
    return True
$$ language plperlu;

create or replace function trigger_test() returns trigger as $$
plpy.info(TD['new'])
plpy.execute('select * from test_perl()')
return 'MODIFY'
$$ language plpythonu;

update test set id = 4;

---------


CREATE TABLE
CREATE FUNCTION
CREATE TRIGGER
INSERT 9138862 1
INSERT 9138863 1
INFO:  ({'date': '2005-05-05 13:20:43.793551', 'id': 3},)
INFO:  ({'date': '2005-05-05 13:20:43.794401', 'id': 3},)
UPDATE 2
CREATE FUNCTION
CREATE FUNCTION
INFO:  ({'date': '2005-05-05 13:20:43.793551', 'id': 4},)
ERROR:  invalid input syntax for type timestamp: "2005-05-05
13:20:43.793551"

-------


I don't think that plperl or plperlu with locales should be used in
production environment.

       Mage