Re: [COMMITTERS] pgsql: PL/Python: Convert numeric to Decimal

From: Szymon Guz <mabewlun(at)gmail(dot)com>
To: Claudio Freire <klaussfreire(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL-Dev <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [COMMITTERS] pgsql: PL/Python: Convert numeric to Decimal
Date: 2013-07-06 20:14:55
Message-ID: CAFjNrYsxWNr-Xs5bgX69opzp5EOVWStT++yt5U4KNrcagpqJ2A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 6 July 2013 17:58, Claudio Freire <klaussfreire(at)gmail(dot)com> wrote:

> Look at that:
>
> return x
> $$ LANGUAGE plpythonu;
> SELECT * FROM test_type_conversion_numeric(100);
> ! INFO: (Decimal('100'), 'Decimal')
> CONTEXT: PL/Python function "test_type_conversion_numeric"
> test_type_conversion_numeric
> ------------------------------
> --- 219,225 ----
> return x
> $$ LANGUAGE plpythonu;
> SELECT * FROM test_type_conversion_numeric(100);
> ! INFO: (Decimal("100"), 'Decimal')
> CONTEXT: PL/Python function "test_type_conversion_numeric"
> test_type_conversion_numeric
> ------------------------------
>
> " instead of '
>
> All the more reason to use as_tuple
>
>
>
> On Sat, Jul 6, 2013 at 9:16 AM, Andrew Dunstan <andrew(at)dunslane(dot)net>
> wrote:
> >
> > On 07/06/2013 01:52 AM, Claudio Freire wrote:
> >>
> >> On Sat, Jul 6, 2013 at 2:39 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >>>
> >>> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> >>>>
> >>>> PL/Python: Convert numeric to Decimal
> >>>
> >>> Assorted buildfarm members don't like this patch.
> >>
> >>
> >> Do you have failure details?
> >>
> >> This is probably an attempt to operate decimals vs floats.
> >>
> >> Ie: Decimal('3.0') > 0 works, but Decimal('3.0') > 1.3 doesn't
> >> (decimal is explicitly forbidden from operating on floats, some design
> >> decision that can only be disabled in 3.3).
> >>
> >>
> >
> >
> > Instead of speculating, you can actually see for yourself. The dashboard
> is
> > at <http://www.pgbuildfarm.org/cgi-bin/show_status.pl> Pick one of the
> > machines failing at PLCheck-C and click its 'Details' link. Then scroll
> down
> > a bit and you'll see what is failing.
> >
> > cheers
> >
> > andrew
> >
>
>
Hi,
I've modifled the tests to check the numeric->decimal conversion some other
way. They check now conversion to float/int and to string, and also tuple
values.

I've checked that on decimal and cdecimal on python 2.7 and 3.3. The
outputs are the same regardles the Python and decimal versions.

thanks,
Szymon

Attachment Content-Type Size
fix_plpython_decimal_tests.patch application/octet-stream 21.6 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Jeff Davis 2013-07-06 20:48:43 pgsql: Handle posix_fallocate() errors.
Previous Message Michael Meskes 2013-07-06 20:14:11 pgsql: Also escape double quotes for ECPG's #line statement.

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Meskes 2013-07-06 20:15:18 Re: [9.3 bug fix] ECPG does not escape backslashes
Previous Message Joshua Berkus 2013-07-06 19:42:04 Re: [9.4 CF 1] The Commitfest Slacker List