Обсуждение: pg_atoi() behavior change? Intentional?

Поиск
Список
Период
Сортировка

pg_atoi() behavior change? Intentional?

От
Adam Haberlach
Дата:
    I've just upgraded to the beta4 in order to fix an RI
deadlock we seemed to be having with 7.0.3 -- and it seems
that one of the engineers has been writing some queries that
cast a text field to an int and take advantage of the
fact that we used to turn text fields with no digits into 0,
much as C's atoi function works.
The new behavior is to throw a parse error, which causes
all kinds of problem.  Is this intentional?  I dimly remember
seeing a whole lot of atoi discussion, but I can't seem to
find it in my last two files of this mailing list.

-- 
Adam Haberlach            | All your base are belong to us.
adam@newsnipple.com       |
http://www.newsnipple.com |
'88 EX500    '00 >^<      |


Re: pg_atoi() behavior change? Intentional?

От
Tom Lane
Дата:
Adam Haberlach <adam@newsnipple.com> writes:
> ... one of the engineers has been writing some queries that
> cast a text field to an int and take advantage of the
> fact that we used to turn text fields with no digits into 0,
> much as C's atoi function works.

>     The new behavior is to throw a parse error, which causes
> all kinds of problem.  Is this intentional?

What new behavior?

regression=# select ''::text::int4;?column?
----------       0
(1 row)

7.0.* behaves the same as far as I can tell.  I think this is actually
a bug, and it *should* throw an error ... but it doesn't.
        regards, tom lane