Re: Looking for a doc section that presents the overload selection rules - Mailing list pgsql-general

From Peter J. Holzer
Subject Re: Looking for a doc section that presents the overload selection rules
Date
Msg-id YXMonFWzb8tNNnUo@hjp.at
Whole thread Raw
In response to Re: Looking for a doc section that presents the overload selection rules  (Bryn Llewellyn <bryn@yugabyte.com>)
List 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!"

Attachment

pgsql-general by date:

Previous
From: Bryn Llewellyn
Date:
Subject: Re: Looking for a doc section that presents the overload selection rules
Next
From: Дмитрий Иванов
Date:
Subject: Python3 for PostgreSQL 14