Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1me1nZ-0008Kx-CE for pgsql-general@arkaria.postgresql.org; Fri, 22 Oct 2021 21:09:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1me1nX-0003hA-MX for pgsql-general@arkaria.postgresql.org; Fri, 22 Oct 2021 21:09:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1me1nX-0003gz-Cy for pgsql-general@lists.postgresql.org; Fri, 22 Oct 2021 21:09:55 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1me1nS-0004J6-Va for pgsql-general@lists.postgresql.org; Fri, 22 Oct 2021 21:09:55 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id C7F05594B; Fri, 22 Oct 2021 23:09:48 +0200 (CEST) Date: Fri, 22 Oct 2021 23:09:48 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Looking for a doc section that presents the overload selection rules Message-ID: Mail-Followup-To: pgsql-general@lists.postgresql.org References: <4F35D95E-4974-44FC-AA4B-3F1E94580B82@yugabyte.com> <4f7a9fe8-ea27-e4a3-34ac-f05fcfb7f5c3@aklaver.com> <36e3e2a5-cf09-61e2-3f12-3ea6d17e3ccd@aklaver.com> <476BE5DC-8D86-422B-9463-C41696271A22@yugabyte.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="iVgrOMpZ3htXzT4k" Content-Disposition: inline In-Reply-To: <476BE5DC-8D86-422B-9463-C41696271A22@yugabyte.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --iVgrOMpZ3htXzT4k Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2021-10-22 10:26:38 -0700, Bryn Llewellyn wrote: > There could, so easily, have been three =E2=80=9Cto_char()=E2=80=9D overl= oads for these three > data types that honored the spirit of the =E2=80=9C::text=E2=80=9D typeca= st by rendering only > what=E2=80=99s 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=3D> select to_char(3::int, '999.999'); =E2=95=94=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=97 =E2=95=91 to_char =E2=95=91 =E2=95=9F=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=95=A2 =E2=95=91 3.000 =E2=95=91 =E2=95=9A=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=9D (1 row) An int has no fractional part, but I asked for 3 digits after the decimal point so I got them. hjp=3D> select to_char(34567::int, '999.999'); =E2=95=94=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=97 =E2=95=91 to_char =E2=95=91 =E2=95=9F=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=95=A2 =E2=95=91 ###.### =E2=95=91 =E2=95=9A=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=9D (1 row) 34567 doesn't fit into the 3 digits before the point I asked for, so I just get hashes. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --iVgrOMpZ3htXzT4k Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmFzKJcACgkQ8g5IURL+ KF1Y7A/9FdfYUa220vi0TDN04O2m2D2smI+0ulW8K7wYFF33Yd8axH9NrdVyqSLe jpphNkwbVFHG2MLglLnQ8vnjv/yE4L4GhoHaGnJ/IxfQxfmO+6eKntJycNBfvPDk Az2MExEgNIwt/8nrdiMetP4QsUw3Oqoo011hI/ubn532vYjy9b7dVv1XAOb1ZdWR NHcBsAqDYU2pcGbEXModIc+7fnjyD79l1Tyeq7PQSpFwrR2gHplop2iWtxvZu07m gyLRl38+qar+m/RDbnUHpOjT9AWvYtBnODQUIXlw1QtUih2D6WyR2DsgTwFrusEG vqnxNW3i/rDZvkeTOcRyXNDHFBvNgi2ZkWKvxbEtDvX/bt2xSWTdG6s0BHJpJiyQ YOiDfdqZKIJ3OvRNJDm4MQYpswUNVaWAO+Km8rHt5Yrb5Ux4vxpKXCDRJGBrdjOP whuHA31HTEu1swWaraKkm1/Rk9BTDK0ZH1K3pxRhJbyAriMg7x5SxA+zHVt9QzGq ydPLI/DoOv3AjlxOogII9uAZjliv2tTUjxDotZkRED0snPF513w6MN7Jpj15n6Ah 2QVyQchWkWcG/duJbGHzwHSEW813KO14cfDPu+B9blMYq+bqwZqPt9Z3TxSUf1Nv R5oxFEkeILRRhNUly5yq21+6iG/X/twVduKE4d7NglhflK0WOIQ= =6TQ0 -----END PGP SIGNATURE----- --iVgrOMpZ3htXzT4k--