casting zero-length strings

From: Neil Conway <neilc(at)samurai(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Subject: casting zero-length strings
Date: 2004-02-17 03:39:35
Message-ID: 87lln2idc8.fsf@mailbox.samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chris KL recently pointed out to me that we currently don't raise an
error when attempting to cast a zero-length string to a float:

nconway=# select ''::float8;
float8
--------
0
(1 row)

nconway=# select ''::float4;
float4
--------
0
(1 row)

Similarly for oid:

nconway=# select ''::oid;
oid
-----
0
(1 row)

Whereas int and numeric reject zero-length strings:

nconway=# select ''::int;
ERROR: invalid input syntax for integer: ""
nconway=# select ''::numeric;
ERROR: invalid input syntax for type numeric: ""

So, should we fix oid and float?

I'm leaning toward "yes", for the sake of consistency and
sanity. However, we were bitten by backward-compatibility concerns
when we made a similar change to the "int" input rules during the 7.3
cycle, so I'm open to other suggestions.

-Neil

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2004-02-17 03:56:07 Re: [PATCHES] log session end - again
Previous Message Bruce Momjian 2004-02-17 03:16:01 Re: [HACKERS] dollar quoting