Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array

From: Rumpi Gravenstein <rgravens(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array
Date: 2025-07-25 17:07:20
Message-ID: CAEpg1wC+3FYk2YxMKr=K+1OAmMNvfk3x+nLvJJrZo9oR0ihjSA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

There is really only one function with this name. A rerun of my test
script with the suggested change:

xxxx_pub_dev_2_db=# SELECT version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 16.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0
20210514 (Red Hat 8.5.0-26), 64-bit
(1 row)

xxxx_pub_dev_2_db=# SHOW server_version;
server_version
----------------
16.9
(1 row)

xxxx_pub_dev_2_db=# DROP FUNCTION if exists _sa_setup_role;
DROP FUNCTION
xxxx_pub_dev_2_db=# CREATE OR REPLACE FUNCTION _sa_setup_role(
p_role_to_be_granted varchar)
xxxx_pub_dev_2_db-# RETURNS varchar
xxxx_pub_dev_2_db-# LANGUAGE plpgsql
xxxx_pub_dev_2_db-# AS
xxxx_pub_dev_2_db-# $function$
xxxx_pub_dev_2_db$# declare
xxxx_pub_dev_2_db$# begin
xxxx_pub_dev_2_db$# raise info '%',p_role_to_be_granted::varchar;
xxxx_pub_dev_2_db$# return('Done');
xxxx_pub_dev_2_db$# end;
xxxx_pub_dev_2_db$# $function$;
CREATE FUNCTION
xxxx_pub_dev_2_db=# select _sa_setup_role('af_repo_app');
ERROR: malformed array literal: "af_repo_app"
LINE 1: select _sa_setup_role('af_repo_app');
^
DETAIL: Array value must start with "{" or dimension information.
xxxx_pub_dev_2_db=# select _sa_setup_role('af_repo_app'::varchar);
INFO: af_repo_app
_sa_setup_role
----------------
Done
(1 row)

xxxx_pub_dev_2_db=# \df *_sa_setup_role
List of functions
Schema | Name | Result data type | Argument data types
| Type
--------+----------------+-------------------+----------------------------------------+------
sqlapp | _sa_setup_role | character varying | p_role_to_be_granted
character varying | func
(1 row)

xxxx_pub_dev_2_db=#
xxxx_pub_dev_2_db=#

On Fri, Jul 25, 2025 at 1:02 PM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> On 7/25/25 09:59, Rumpi Gravenstein wrote:
> > No ... just one version:
> >
>
> >
> > xxxx_pub_dev_2_db=# \df _sa_setup_role
>
> Do:
>
> \df *._sa_setup_role
>
> >
> > --
> > Rumpi Gravenstein
>
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com
>

--
Rumpi Gravenstein

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2025-07-25 17:10:22 Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array
Previous Message Adrian Klaver 2025-07-25 17:02:27 Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array