Re: How to return argument data type from sql function

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Andrus <kobruleht2(at)hot(dot)ee>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to return argument data type from sql function
Date: 2022-10-14 22:14:05
Message-ID: CAKFQuwYd_B6wjgFFUa9_tB14qXw1m8k9Ss1cMFLcAiuLH=SpAA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Oct 14, 2022 at 2:56 PM Andrus <kobruleht2(at)hot(dot)ee> wrote:

> 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 ?
>
ColWidth is NOT IMMUTABLE, your declaration of that property is a lie (the
function in your email actually defines it as volatile though...). It is
STABLE.

You are basically stuck dealing with this one layer up, outside the
server. You would need to execute ColWidth then write the returned value
of the function call into the text body of the SQL Command.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2022-10-14 22:19:39 Re: How to return argument data type from sql function
Previous Message Andrus 2022-10-14 21:56:33 Re: How to return argument data type from sql function