Re: Why don't we accept exponential format for integers?

Поиск
Список
Период
Сортировка
От Bill Moran
Тема Re: Why don't we accept exponential format for integers?
Дата
Msg-id 20101217151629.0db34887.wmoran@potentialtech.com
обсуждение исходный текст
Ответ на Re: Why don't we accept exponential format for integers?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Why don't we accept exponential format for integers?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Why don't we accept exponential format for integers?  (Jeff Janes <jeff.janes@gmail.com>)
Список pgsql-hackers
In response to Tom Lane <tgl@sss.pgh.pa.us>:

> Josh Berkus <josh@agliodbs.com> writes:
> > postgres=# select '1e+01'::Integer
> > postgres-# ;
> > ERROR:  invalid input syntax for integer: "1e+01"
> 
> I have never heard of any programming system anywhere that accepts such
> a syntax for integers (assuming it distinguishes integers from other
> numbers at all).  I'm not excited about being the first.  Why does this
> error surprise you?  It doesn't seem particularly different from arguing
> that 1.000 should be considered an integer, which strikes me as a
> seriously bad idea.

But
SELECT 1.000::Integer;
works.  And so does
SELECT 1.234::Integer;
which I find just as dangerous as
SELECT '1.234e+01'::Integer;

One of the exciting (but possibly wrong) arguments in favor of this is the
fact that some programming languages will output integers in exponential
notation when the numbers are very large (PHP is the only example that
comes to mind, but it's a pretty common language) which may cause numbers
formatted thusly to be included in queries without the programmers prior
realization.

-- 
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: unlogged tables vs. GIST
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Why don't we accept exponential format for integers?