Re: [GENERAL] 7.3 -> pg_atoi: zero-length string

Поиск
Список
Период
Сортировка
От Henner Zeller
Тема Re: [GENERAL] 7.3 -> pg_atoi: zero-length string
Дата
Msg-id Pine.LNX.4.44.0212031733490.6323-100000@kupfersulfat.toxine.lan
обсуждение исходный текст
Ответ на Re: [GENERAL] 7.3 -> pg_atoi: zero-length string  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-hackers
Hi,| > What is the solution of other dbs ( oracle, db2 .. ) to:| > insert into table (num) value (''); ? | | I assume
theywould fail too.
 

The Oracle behaviour is:
---
oracle> create table foonum (x number(5));
oracle> insert into foonum values ('');
oracle> select * from foonum;
--------+  X    |
--------+[NULL] |
--------+
---

so, '' as numeric value is regarded as NULL. But Oracle 
braindeadly interprets the varchar '' as well as NULL in a varchar 
column so is probably not paragon ...

IMHO, if PostgreSQL is to support an empty string for numerics at all, 
then it should be interpreted as not-a-value and as such as NULL. 
Interpreting it as numeric value '0' could lead to subtle bugs since this 
would probably not the expected behaviour (at least not mine).
The number '0' is arbitrary, except that we happend to start counting with 
it. Someone else could argue why not interpret  not-a-value as '1' 
(non-computer guys tend to start counting with '1') or even '42' (since 
this is the answer to everything).

I personally would be prefer to raise an error on an empty string; but 
interpreting it as NULL would be reasonable as well. But interpreting it 
as '0' will yield many unseen programming errors and should be avoided.

my 2cent,-hen



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Magnus Naeslund(f)"
Дата:
Сообщение: Re: Backend crash with tsearch
Следующее
От: Hannu Krosing
Дата:
Сообщение: Re: 7.4 Wishlist