Re: to_char/to_number loses sign

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, List pgsql-hackers <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: to_char/to_number loses sign
Date: 2004-10-25 13:30:22
Message-ID: 1098711022.19187.26.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Sat, 2004-10-23 at 17:25 -0400, Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > SELECT to_number('485-', '999S');
> > to_number
> > -----------
> > 485
>
> > Is this a bug or intentional?
>
> Tracing through this, it looks like the problem is that NUM_processor()
> has no switch case for NUM_S (nor does the default case raise an error,
> which seems a risky practice to me).
>
> Karel, can you verify this and submit a fix?

Yes, you're right. It strange, but NUM_S missing there. The conversion
from string to number is less stable part of formatting.c...

I have already 2000 lines of code of new generation of to_..()
functions. But all will available in 8.1.

The patch is in the attachment.

Karel

--
Karel Zak
http://home.zf.jcu.cz/~zakkr

Attachment Content-Type Size
pgsql-formatting-10252004.patch text/x-patch 775 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2004-10-25 14:28:26 Re: Using ALTER TABLESPACE in pg_dump
Previous Message Reini Urban 2004-10-25 10:18:21 Re: Proposed Query Planner TODO items

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2004-10-25 15:31:55 rmtree() failure on Windows
Previous Message Neil Conway 2004-10-25 06:27:47 Re: (yet) more pfree cast cleanup