Re: wrong timezone precision using plpythonu trigger

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: maizi <maizi(at)lirmm(dot)fr>
Cc: pgsql-bugs(at)postgresql(dot)org, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: wrong timezone precision using plpythonu trigger
Date: 2010-10-11 04:13:41
Message-ID: 2772.1286770421@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

maizi <maizi(at)lirmm(dot)fr> writes:
> CREATE LANGUAGE plpythonu ;

> CREATE FUNCTION wrong() RETURNS trigger AS $wrong$
> from mx import DateTime

> TD['new']['modif_time'] = DateTime.now()
> return 'MODIFY'
> $wrong$ LANGUAGE plpythonu;

> CREATE TABLE pb ( a TEXT, modif_time TIMESTAMP(0) WITHOUT TIME ZONE ) ;

> CREATE TRIGGER wrong BEFORE UPDATE ON pb FOR EACH ROW EXECUTE PROCEDURE
> wrong() ;

> INSERT INTO pb VALUES ( 'a', now() ) ;
> SELECT * FROM pb ;
> UPDATE pb SET a = 'b' ;
> SELECT * FROM pb ;

> produces this result:

> #========================
> INSERT 0 1
> a | modif_time
> ---+---------------------
> a | 2010-10-10 18:30:30
> (1 ligne)

> UPDATE 1
> a | modif_time
> ---+------------------------
> b | 2010-10-10 18:30:29.74
> (1 ligne)
> #========================

> notice the ".74" and the fact that in this example the modif_time of the
> modified tuple is earlier than the preceding one!

It looks to me like this used to work and got broken by this patch:
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=3ab8b7fa6f9ac2fb04096f8860261dc42d59a570

which lobotomized plpython to not care about passing the right typmod to
I/O functions. This is a regression, and it's particularly annoying
because the other three standard PLs get this case right. Peter?

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Johannes.Meidert 2010-10-11 07:35:05 Re: BUG #5698: pg_dump (8.3.11) does not consider constrains
Previous Message Tom Lane 2010-10-11 03:25:44 Re: BUG #5702: pg fails to use a conditional index even the where clause matches the condition