casting zero-length strings - Mailing list pgsql-hackers

From Neil Conway
Subject casting zero-length strings
Date
Msg-id 87lln2idc8.fsf@mailbox.samurai.com
Whole thread Raw
Responses Re: casting zero-length strings  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [PATCHES] dollar quoting
Next
From: Bruce Momjian
Date:
Subject: Re: [PATCHES] log session end - again