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 1ojSfj-0003BS-P1 for pgsql-general@arkaria.postgresql.org; Fri, 14 Oct 2022 21:56:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ojSfi-0006Yw-7X for pgsql-general@arkaria.postgresql.org; Fri, 14 Oct 2022 21:56:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ojSfh-0006Y6-SU for pgsql-general@lists.postgresql.org; Fri, 14 Oct 2022 21:56:49 +0000 Received: from portal-smtp-out.hot.ee ([194.126.101.125]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ojSfe-0004lq-OS for pgsql-general@postgresql.org; Fri, 14 Oct 2022 21:56:48 +0000 Received: from localhost (localhost [127.0.0.1]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 33A2C345A; Sat, 15 Oct 2022 00:56:45 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at vm-hot-relay10.estpak.ee Received: from portal-smtp-out.hot.ee ([127.0.0.1]) by localhost (vm-hot-relay10.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ORBt3kSHg0EP; Sat, 15 Oct 2022 00:56:42 +0300 (EEST) Received: from mail.hot.ee (hot-relayhost2.estpak.ee [213.180.2.80]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 982D53434; Sat, 15 Oct 2022 00:56:42 +0300 (EEST) Content-Type: multipart/alternative; boundary="------------l2DP8qQJ2dRJab25B8kE26jF" Message-ID: Date: Sat, 15 Oct 2022 00:56:33 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: How to return argument data type from sql function Content-Language: et To: "David G. Johnston" Cc: Tom Lane , Adrian Klaver , pgsql-general References: <86fe1ce7-3d6f-b723-b0fc-0eb796100588@hot.ee> <1185464.1665759357@sss.pgh.pa.us> <12a74d8c-58ac-f14c-39c7-3730362e08e7@hot.ee> From: Andrus In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------l2DP8qQJ2dRJab25B8kE26jF Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit > Adrian Klaver recommends in > > https://stackoverflow.com/questions/74061290/how-to-return-argument-datatype-from-sql-function#comment130780708_74061290 > > at this worked. In this best solution? > > Padding a text typed output with actual significant spaces "works"? It > is not equivalent to a bpchar with insignificant padding spaces... You are right. I need char(n) type and this is not working.  How to use expression in cast, like select torus(charcol) :: CHAR( ColWidth('public', 'test', 'charcol')  ) from test This throws error in Postgres. ColWidth is immutable and called with constant arguments so it should work. How to fix postgres to allow constant ColWidth() expression in cast ? Andrus. --------------l2DP8qQJ2dRJab25B8kE26jF Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit > Adrian Klaver recommends in
Padding a text typed output with actual significant spaces "works"?  It is not equivalent to a bpchar with insignificant padding spaces...

You are right. I need char(n) type and this is not working.  How to use expression in cast, like

select torus(charcol) :: CHAR( ColWidth('public', 'test',  'charcol')  ) from test

This throws error in Postgres. ColWidth is immutable and called with constant arguments so it should work. How to fix postgres to allow constant ColWidth() expression in cast ?

Andrus.

--------------l2DP8qQJ2dRJab25B8kE26jF--