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

From: "Delaney, Ed" <Ed(dot)Delaney(at)ellucian(dot)com>
To: "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-15 18:12:29
Message-ID: DM8PR02MB7957E9EB0AF94B614520989EF1349@DM8PR02MB7957.namprd02.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thanks for the timely replies.
I've found that either removing the length specification or the cast addresses the issue.
So this all makes sense to me.

I could not find a reference to this change in the release notes, but since it is a breaking change, perhaps it should be noted?
regards
Ed

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Date: Monday, February 14, 2022 at 6:28 PM
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: [EXT]: Re: Postgres 13.5 out parameter argument with explicit cast fails with argument is not writable
"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 Tom Lane 2022-02-15 18:17:57 Re: Postgres 13.5 out parameter argument with explicit cast fails with argument is not writable
Previous Message PG Bug reporting form 2022-02-15 17:32:33 BUG #17406: Segmentation fault on GiST index after 14.2 upgrade