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

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

On 7 July 2013 21:35, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> On Sun, 2013-07-07 at 17:21 +0200, Szymon Guz wrote:
> > I think that these tests are much better, so they should go into
> > trunk.
> > As for Python 2.5 I think we could modify the code and makefile (with
> > additional documentation info) so the decimal code wouldn't be
> > compiled
> > with python 2.5.
>
> I'd welcome updated tests, if you want to work on that. But they would
> need to work uniformly for Python 2.4 through 3.3.
>
>
>
Well... I don't know what to do and which solution is better.

This patch works, but the tests are not working on some old machines.

This patch works, but changes the plpython functions, so I assume that it
will provide errors to some existing functions. I've noticed yesterday that
you cannot run code like `Decimal(10) - float(10)`. So if a function
accepts a numeric parameter 'x', which currently is converted to float,
then the code like `x - float(10)` currently works, and will not work after
this change.

Introducing decimal.Decimal also breaks python earlier than 2.4, as the
decimal module has been introduced in 2.4. We could use the old conversion
for versions before 2.4, and the new for 2.4 and newer. Do we want it to
work like this? Do we want to have different behaviour for different python
versions? I'm not sure if anyone still uses Python 2.3, but I've already
realised that the patch breaks all the functions for 2.3 which use numeric
argument.

I assume that the patch will be rolled back, if it the tests don't work on
some machines, right?

szymon

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2013-07-07 20:23:26 pgsql: pg_resetxlog: Make --help consistent with man page
Previous Message Bruce Momjian 2013-07-07 19:58:21 pgsql: pg_upgrade: document link options

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-07-07 20:34:31 Re: changeset generation v5-01 - Patches & git tree
Previous Message Dimitri Fontaine 2013-07-07 19:51:42 Re: Review: extension template