BUG #3686: Incorrect numeric type conversion to long in plpythonu

From: "Sergi" <sergi(dot)vladykin(at)googlemail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3686: Incorrect numeric type conversion to long in plpythonu
Date: 2007-10-20 13:57:29
Message-ID: 200710201357.l9KDvTMo084049@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 3686
Logged by: Sergi
Email address: sergi(dot)vladykin(at)googlemail(dot)com
PostgreSQL version: 8.2.5
Operating system: Solaris 10 11/06 x86
Description: Incorrect numeric type conversion to long in plpythonu
Details:

Trouble in usage of numeric types in plpythonu.
PostgreSQL 8.2.5 on i386-pc-solaris2.10, compiled by /opt/SUNWspro/bin/cc
-xpentium -xO4 -Xa with Python 2.5.1 also compiled from source.
Problem is that numeric type converts to pythons long
incorrectly. Here is the simple script that shows this.

-----
-----
create or replace function test2(x numeric) returns numeric
as $$
return long(x);
$$ language plpythonu;

select test2(1231312312313956756464);/*not the same as input*/

select 1231312312313956756464=test2(1231312312313956756464);/* expected to
be equal*/

create table test_table(
id numeric(22) not null
);

insert into test_table(id) values (1234567890098765432199);

create or replace function test(n int) returns numeric
as $$
return long(plpy.execute('select id from test_table limit 1 offset
'+str(n))[0]['id']);
$$ language plpythonu;

select test(0);/* expected 1234567890098765432199*/
select count(*) from test_table where id = test(0);/* expected 1 returns
0*/

-----
-----

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2007-10-20 14:36:05 Re: BUG #3682: Incomplete database restore
Previous Message Pavel Velikhov 2007-10-20 10:51:37 BUG #3685: PgAdmin crashes at startup