Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ufLmK-0063dM-Bs for pgsql-general@arkaria.postgresql.org; Fri, 25 Jul 2025 17:00:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ufLmJ-002ut7-Ee for pgsql-general@arkaria.postgresql.org; Fri, 25 Jul 2025 17:00:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ufLmJ-002usy-0t for pgsql-general@lists.postgresql.org; Fri, 25 Jul 2025 17:00:15 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ufLmH-000kc5-1j for pgsql-general@lists.postgresql.org; Fri, 25 Jul 2025 17:00:14 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-32b5931037eso19169661fa.2 for ; Fri, 25 Jul 2025 10:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753462812; x=1754067612; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9Ji59bwhIsPoe/wGr3I+9Q4ZHCBlWv4+8XDPkKb0mOw=; b=WnM9UZBMh7yOs7NeEqXBUUTV1jhklp2ssP42a7h8OGNd+HCHngG/XUZJDwvWY5N83f JaMF1SsHZk+QGrtnTE6r91lmZQ3OlMvdxAMSPKPjVH27FLu+/YLUIl10pDP52l7Hd8Bm /LYOvyUlDAjGhTksRn/dkhbiHDvVXjvXEdhmIkgAOqw14ML3LMfFhtc8sd0DZH30bxbL TRoEAhCvJTx2kYRFCbMM2Wb77VtMskvwBCiFZ/V2OyMzwuPxQC0QRVxWle3gO3WMsvIs 5H/NWUZgWbMbXwMvhqHWmM8U1TF/tGXAs8SqF9fqBbkppn6ZemgC8IwHTPI+bdiJw3j+ pt0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753462812; x=1754067612; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9Ji59bwhIsPoe/wGr3I+9Q4ZHCBlWv4+8XDPkKb0mOw=; b=cNWOxjGt8WxrZ0WsaBh4tlg8PhHCwOhiHJoQok5xYfUrwKctKXLb+At+8+X9zi8gzU 9gTYuFJ30PmVXoSvgh3RAjEPzzBPfy5LB9hy36x0OzioRNh7MoqBu6jhTiOlkiVP4Wap iCZ0yW4sDn6ICpLYAyWJs29aY3R1LXsmq2DiAXggN1cCC34JStQZT9sRmnzBw341QuRe cjts7zNLF+snRTVYytf//RJk2Ri1PKFzJkAyY2WGJT6+0r87BwEvH5AAIIfrZIRgvVDk d9ML/ux7NcDvbN++0EPRGGGkQFkF6afGN0+kaOImULtanfNZBDZMUFj+fAC5gpDlTYS+ P2dA== X-Gm-Message-State: AOJu0YwZcSvL4eUDtGFGdnirTuWAiDogAEaZHQrcAHm8sNBUV6ptsOl3 oJ10u+LoZ8W3dI81i0Fo/h9eL5AZyojMvyvP7TYjyHfsOGAASPKVBpWk3/0Tfa88XUfT3pcLt8u XZM1MPx/VwWa6fV9u+ssKZRnSU/qgmK+XXKMS X-Gm-Gg: ASbGncvqYUQh4iUESWmagRkzox0R9EQy7WRefwWOgcL6T0lkLazvfsRQjVLptj7YcWA mOmIe4EV6z6jN3m45tadU4xjwdw38FQKsU+qzK0T3sunChDM+W/PSnAHmM7uwXd7lddT2Jy8ikF tg7NdDYrhKejF/3qOAbqaZ+31RVipcoMh+ud5ODySz5FFA9i7tq2MdE0V06ih104BHLIbwLHBDZ kbDGMa9 X-Google-Smtp-Source: AGHT+IHtlFpczzmm+7EaDyR/1tfjUQVcl2Orzx02QaSh3hfPTdxvZ+afv7d6j1BPZJPf8lsOXpyvrPx8jtchKFFSwjY= X-Received: by 2002:a05:6512:1103:b0:553:2c92:fdcb with SMTP id 2adb3069b0e04-55b5f3ee217mr921868e87.3.1753462811245; Fri, 25 Jul 2025 10:00:11 -0700 (PDT) MIME-Version: 1.0 References: <1934172.1753462470@sss.pgh.pa.us> In-Reply-To: <1934172.1753462470@sss.pgh.pa.us> From: Rumpi Gravenstein Date: Fri, 25 Jul 2025 12:59:59 -0400 X-Gm-Features: Ac12FXyS3IHOPW4sQdULm9FTPDHyyda0nYWQOhDdz-xKGtZd5LFp4UP_BbXwTGA Message-ID: Subject: Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array To: Tom Lane Cc: PostgreSQL Content-Type: multipart/alternative; boundary="000000000000fdc0fd063ac3df79" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000fdc0fd063ac3df79 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable No ... just one version: xxxx_pub_dev_2_db=3D# SHOW server_version; server_version ---------------- 16.9 (1 row) xxxx_pub_dev_2_db=3D# DROP FUNCTION if exists _sa_setup_role; DROP FUNCTION xxxx_pub_dev_2_db=3D# 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=3D# 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=3D# select _sa_setup_role('af_repo_app'::varchar); INFO: af_repo_app _sa_setup_role ---------------- Done (1 row) xxxx_pub_dev_2_db=3D# \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) On Fri, Jul 25, 2025 at 12:54=E2=80=AFPM Tom Lane wrote= : > Rumpi Gravenstein writes: > > I've been confound by the following behavior that I see in one of our > > PostgreSQL 16 instances. In this case I am running this script from > psql. > > I'd bet there is another function named _sa_setup_role() that takes > some kind of array, and the parser is resolving the ambiguity by > choosing that one. > > "\df _sa_setup_role" would be illuminating. > > regards, tom lane > --=20 Rumpi Gravenstein --000000000000fdc0fd063ac3df79 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
No ... just one version:

xxxx_pub_dev_2_db=3D# SHOW= server_version;
=C2=A0server_version
----------------
=C2=A016.9<= br>(1 row)


xxxx_pub_dev_2_db=3D# DROP FUNCTION if exists _sa_set= up_role;
DROP FUNCTION
xxxx_pub_dev_2_db=3D# CREATE OR REPLACE FUNCTI= ON _sa_setup_role( p_role_to_be_granted varchar)
xxxx_pub_dev_2_db-# RET= URNS 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
xxx= x_pub_dev_2_db$# begin
xxxx_pub_dev_2_db$# raise info '%',p_role= _to_be_granted::varchar;
xxxx_pub_dev_2_db$# =C2=A0 return('Done'= ;);
xxxx_pub_dev_2_db$# end;
xxxx_pub_dev_2_db$# $function$;
CREAT= E FUNCTION
xxxx_pub_dev_2_db=3D# select _sa_setup_role('af_repo_app&= #39;);
ERROR: =C2=A0malformed array literal: "af_repo_app"
= LINE 1: select _sa_setup_role('af_repo_app');
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 ^
DETAIL: =C2=A0Array value must start with "{" = or dimension information.
xxxx_pub_dev_2_db=3D# select _sa_setup_role(&#= 39;af_repo_app'::varchar);
INFO: =C2=A0af_repo_app
=C2=A0_sa_setu= p_role
----------------
=C2=A0Done
(1 row)


xxxx_pub_dev= _2_db=3D# \df _sa_setup_role
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 List of functions
=C2=A0Schema | =C2=A0 =C2=A0 =C2=A0N= ame =C2=A0 =C2=A0 =C2=A0| Result data type =C2=A0| =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0Argument data types =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Type
= --------+----------------+-------------------+-----------------------------= -----------+------
=C2=A0sqlapp | _sa_setup_role | character varying | p= _role_to_be_granted character varying | func
(1 row)

On Fri, Jul 25, 2025 at 12:54=E2=80=AFPM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Rumpi Gravenstein <rgravens@gmail.com> writes: > I've been confound by the following behavior that I see in one of = our
> PostgreSQL 16 instances.=C2=A0 In this case I am running this script f= rom psql.

I'd bet there is another function named _sa_setup_role() that takes
some kind of array, and the parser is resolving the ambiguity by
choosing that one.

"\df _sa_setup_role" would be illuminating.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane


--
Rumpi Gravenstein
--000000000000fdc0fd063ac3df79--