Re: Looking for a doc section that presents the overload selection rules

Поиск
Список
Период
Сортировка
От Peter J. Holzer
Тема Re: Looking for a doc section that presents the overload selection rules
Дата
Msg-id YXMonFWzb8tNNnUo@hjp.at
обсуждение исходный текст
Ответ на Re: Looking for a doc section that presents the overload selection rules  (Bryn Llewellyn <bryn@yugabyte.com>)
Список pgsql-general
On 2021-10-22 10:26:38 -0700, Bryn Llewellyn wrote:
> There could, so easily, have been three “to_char()” overloads for these three
> data types that honored the spirit of the “::text” typecast by rendering only
> what’s meaningful, despite what the template asks for.

I think to_date() is very much intended to produce fixed-width output
even when that makes little sense given the input data. For example:

hjp=> select to_char(3::int, '999.999');
╔══════════╗
║ to_char  ║
╟──────────╢
║    3.000 ║
╚══════════╝
(1 row)

An int has no fractional part, but I asked for 3 digits after the
decimal point so I got them.

hjp=> select to_char(34567::int, '999.999');
╔══════════╗
║ to_char  ║
╟──────────╢
║  ###.### ║
╚══════════╝
(1 row)


34567 doesn't fit into the 3 digits before the point I asked for, so I
just get hashes.

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Вложения

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

Предыдущее
От: Bryn Llewellyn
Дата:
Сообщение: Re: Looking for a doc section that presents the overload selection rules
Следующее
От: Дмитрий Иванов
Дата:
Сообщение: Python3 for PostgreSQL 14