Re: pg_typeof equivalent for numeric scale, numeric/timestamp precision?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: pg_typeof equivalent for numeric scale, numeric/timestamp precision?
Дата
Msg-id 20121002215027.GF11163@svana.org
обсуждение исходный текст
Ответ на pg_typeof equivalent for numeric scale, numeric/timestamp precision?  (Craig Ringer <ringerc@ringerc.id.au>)
Ответы Re: pg_typeof equivalent for numeric scale, numeric/timestamp precision?  (Craig Ringer <ringerc@ringerc.id.au>)
Список pgsql-general
On Tue, Oct 02, 2012 at 10:19:18AM +0800, Craig Ringer wrote:
> Hi all
>
> While examining a reported issue with the JDBC driver I'm finding
> myself wanting SQL-level functions to get the scale and precision of
> a numeric result from an operation like:
>
>   select NUMERIC(8,4) '1.9999'
>   union
>   select INTEGER 4;

The typmod in postgres is not maintained very well. In the
wire-protocol the typmod is provided if known (the C interface calls
the function PQfmod) and if it's not there (which is very often,
postgres doesn't try very hard) there's no way to "encourge" postgres
to work it out for you.

As for no SQL level functions, you could probably write a function to
determine the scale/precision of a given *value*, but not for a whole
column.  But once you have to string representation of the value you
have that anyway...

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.
   -- Arthur Schopenhauer

Вложения

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

Предыдущее
От: "David Johnston"
Дата:
Сообщение: Re: stored procedure multiple call call question
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: Thousands of schemas and ANALYZE goes out of memory