pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #5783: plpythonu bool behavior change
3+ messages / 2 participants
[nested] [flat]

* BUG #5783: plpythonu bool behavior change
@ 2010-12-05 00:25  Adrian Klaver <adrian.klaver@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Adrian Klaver @ 2010-12-05 00:25 UTC (permalink / raw)
  To: pgsql-bugs


The following bug has been logged online:

Bug reference:      5783
Logged by:          Adrian Klaver
Email address:      adrian.klaver@gmail.com
PostgreSQL version: 9.0.1
Operating system:   Linux Ubuntu 10.04
Description:        plpythonu bool behavior change
Details: 

Seems there was a change in behavior for plpythonu with regards to boolean
fields from 8.4 to 9.0. Previously, setting a field inside a plpythonu
function to "f" would work, now that returns a 't' in the database field. To
get the 'f' to appear I have to specify False inside the function.  The only
thing I can find in recent commits that would apply is:
http://git.postgresql.org/gitweb?p=postgresql.git;a=commit;h=09130e5867d49c7
2ef0f11bef30c5385d83bf194

Below is test case that illustrates what I am seeing in 9.0.1:

DROP TABLE IF EXISTS plpython_type;
CREATE TABLE plpython_type
    (id integer,
    txt_fld text,
    bool_fld boolean
    );
    
DROP FUNCTION IF EXISTS plpython_test();
CREATE OR REPLACE FUNCTION plpython_test()
    RETURNS trigger AS
$Body$
TD["new"]["bool_fld"] = "f"
return "MODIFY"
$Body$
LANGUAGE plpythonu;

CREATE TRIGGER plpython_trg
    BEFORE INSERT
    ON plpython_type
    FOR EACH ROW
    EXECUTE PROCEDURE plpython_test();
    
INSERT INTO plpython_type VALUES (1,'test');

CREATE OR REPLACE FUNCTION plpython_test()
    RETURNS trigger AS
$Body$
TD["new"]["bool_fld"] = False
return "MODIFY"
$Body$
LANGUAGE plpythonu;

INSERT INTO plpython_type VALUES (2,'test');

SELECT * FROM plpython_type;


Result:

id | txt_fld | bool_fld 
----+---------+----------
  1 | test    | t
  2 | test    | f
(2 rows)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #5783: plpythonu bool behavior change
@ 2010-12-05 17:10  Peter Eisentraut <peter_e@gmx.net>
  parent: Adrian Klaver <adrian.klaver@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Peter Eisentraut @ 2010-12-05 17:10 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@gmail.com>; +Cc: pgsql-bugs

On sön, 2010-12-05 at 00:25 +0000, Adrian Klaver wrote:
> Seems there was a change in behavior for plpythonu with regards to
> boolean fields from 8.4 to 9.0. Previously, setting a field inside a
> plpythonu function to "f" would work, now that returns a 't' in the
> database field. To get the 'f' to appear I have to specify False
> inside the function.

That change was intentional.




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #5783: plpythonu bool behavior change
@ 2010-12-05 19:15  Adrian Klaver <adrian.klaver@gmail.com>
  parent: Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 0 replies; 3+ messages in thread

From: Adrian Klaver @ 2010-12-05 19:15 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; +Cc: pgsql-bugs

On Sunday 05 December 2010 9:10:06 am Peter Eisentraut wrote:
> On sön, 2010-12-05 at 00:25 +0000, Adrian Klaver wrote:
> > Seems there was a change in behavior for plpythonu with regards to
> > boolean fields from 8.4 to 9.0. Previously, setting a field inside a
> > plpythonu function to "f" would work, now that returns a 't' in the
> > database field. To get the 'f' to appear I have to specify False
> > inside the function.
>
> That change was intentional.

Alright my mistake, I  finally went past the release notes and read the new docs 
for plpythonu. I see the changes. I do not agree with them, but I should have 
paid more attention in the dev process. The value is being returned to the 
database and should play by the database rules or at least be flagged. I will 
make the necessary changes on my end.

Thanks,
-- 
Adrian Klaver
adrian.klaver@gmail.com



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2010-12-05 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-12-05 00:25 BUG #5783: plpythonu bool behavior change Adrian Klaver <adrian.klaver@gmail.com>
2010-12-05 17:10 ` Peter Eisentraut <peter_e@gmx.net>
2010-12-05 19:15   ` Adrian Klaver <adrian.klaver@gmail.com>

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