casting zero-length strings

Поиск
Список
Период
Сортировка
От Neil Conway
Тема casting zero-length strings
Дата
Msg-id 87lln2idc8.fsf@mailbox.samurai.com
обсуждение исходный текст
Ответы Re: casting zero-length strings  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [PATCHES] dollar quoting
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [PATCHES] log session end - again