Re: How to return argument data type from sql function

Andrus <kobruleht2@hot.ee>

From: Andrus <kobruleht2@hot.ee>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Adrian Klaver <adrian.klaver@aklaver.com>, pgsql-general <pgsql-general@postgresql.org>
Date: 2022-10-14T21:56:33Z
Lists: pgsql-general
 > 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.