From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Looking for a doc section that presents the overload selection rules
Date: Fri, 22 Oct 2021 23:09:48 +0200
Message-ID: <YXMonFWzb8tNNnUo@hjp.at> (raw)
In-Reply-To: <476BE5DC-8D86-422B-9463-C41696271A22@yugabyte.com>
References: <4F35D95E-4974-44FC-AA4B-3F1E94580B82@yugabyte.com>
<b9d87b72-aaf2-1d6a-951a-d67f866fbd66@aklaver.com>
<F71D1FD3-F0A9-48F1-B8F2-9018D6D0DF31@yugabyte.com>
<4f7a9fe8-ea27-e4a3-34ac-f05fcfb7f5c3@aklaver.com>
<B4E55133-926B-4A0D-8E17-C0EE984531E7@yugabyte.com>
<36e3e2a5-cf09-61e2-3f12-3ea6d17e3ccd@aklaver.com>
<476BE5DC-8D86-422B-9463-C41696271A22@yugabyte.com>
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!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: hjp-pgsql@hjp.at
Subject: Re: Looking for a doc section that presents the overload selection rules
In-Reply-To: <YXMonFWzb8tNNnUo@hjp.at>
References: <4F35D95E-4974-44FC-AA4B-3F1E94580B82@yugabyte.com> <b9d87b72-aaf2-1d6a-951a-d67f866fbd66@aklaver.com> <F71D1FD3-F0A9-48F1-B8F2-9018D6D0DF31@yugabyte.com> <4f7a9fe8-ea27-e4a3-34ac-f05fcfb7f5c3@aklaver.com> <B4E55133-926B-4A0D-8E17-C0EE984531E7@yugabyte.com> <36e3e2a5-cf09-61e2-3f12-3ea6d17e3ccd@aklaver.com> <476BE5DC-8D86-422B-9463-C41696271A22@yugabyte.com> <YXMonFWzb8tNNnUo@hjp.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox