Re: Postgres 13.5 out parameter argument with explicit cast fails with argument is not writable

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Delaney, Ed" <Ed(dot)Delaney(at)ellucian(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Postgres 13.5 out parameter argument with explicit cast fails with argument is not writable
Date: 2022-02-14 23:28:29
Message-ID: 2959722.1644881309@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Delaney, Ed" <Ed(dot)Delaney(at)ellucian(dot)com> writes:
> create or replace procedure bar ()
> language plpgsql
> as $procedure$
> declare
> lv_somestring character varying (4000);
> begin
> call foo(lv_somestring::character varying); -- note cast
> raise notice 'lv_somestring: %', lv_somestring;
> end;
> $procedure$;

I think you're out of luck on that. Releases before last November
ignored that cast entirely, thinking it a no-op. Current releases
do not ignore it, recognizing that in fact it has to be understood
as casting to varchar-of-unspecified-length. But then the argument
isn't a bare variable anymore.

We debated about whether to back-patch such a behavioral change,
and maybe we shouldn't have. But there are scenarios in which
the old behavior makes it just impossible to do things, eg you
may not be able to get a UNION to produce the desired type.
On balance we felt this was a bug fix.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2022-02-15 00:41:43 Re: BUG #17391: While using --with-ssl=openssl and PG_TEST_EXTRA='ssl' options, SSL tests fail on OpenBSD 7.0
Previous Message David G. Johnston 2022-02-14 23:24:34 Re: Postgres 13.5 out parameter argument with explicit cast fails with argument is not writable