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 1ujlhg-00BmkP-QJ for pgsql-general@arkaria.postgresql.org; Wed, 06 Aug 2025 21:29:45 +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 1ujlhe-001Hd0-DG for pgsql-general@arkaria.postgresql.org; Wed, 06 Aug 2025 21:29:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ujlhe-001Hcq-09 for pgsql-general@lists.postgresql.org; Wed, 06 Aug 2025 21:29:42 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ujlhb-0018Ti-1h for pgsql-general@lists.postgresql.org; Wed, 06 Aug 2025 21:29:41 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-55b87e13a85so363504e87.3 for ; Wed, 06 Aug 2025 14:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754515778; x=1755120578; 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=HYlAjPJMjyY2yX59wQOn/gtJqsDqk/t6V2e4H0UT2dg=; b=Oc6sovHRgGzh1wPkW3aS/EMxXBz/D85FNFFHFqT2aUm8Yjx4ok1E8+YxyCie7MRTUe YMK620xr/uSpfQPmXSHXCLUmkQ850JRX4L9Eq/pIztiKZo1hWvOlVgr3Z5ckJTsQwM5c 8+tv+5yUsBdko45/ouy8ZyVctiPS5l3FhkDi7S0g0MqRxN6JVJMC3rA5WxU0FpwVJStO 9/oRY3PTC0QQ+oA4tmqnrq0S/1aMYK6eNGTTJnPr7V7zsc9B5JyRmPKZ3eeES/ptqvb7 w5LVXUVSev9PBLG1d+5RWMHljN7c/AAqsrLWY/zCWzj+oZ+LUg3MiQNbdX3XHiK44qy4 exzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754515778; x=1755120578; 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=HYlAjPJMjyY2yX59wQOn/gtJqsDqk/t6V2e4H0UT2dg=; b=SMB2OgALclMeSX5Pn1vUgkO3UQ14cnKt/VlCK9li9Nr6P/Yf0d0Iw95qUMzSBtCN7A yeGWijyNYBElxUu/u4BnOzlyc2i375uvfPqzblVAkEvDe82Qm1FD18Nkr18j5aS09IDh DpL7+T069Z1LV0EmAvxeJaa34GOuu5tWQBoF1CoAy1Iu3SWzlht2zP+EZhpsuBU5rZG3 dfltiE5Wa7Z4NGmDL4PZjPiYs6BecAGraCIn4gYfDCTeaTY3vh2vJ+9gwyRgTftWuUAX nD2DqRyz2j8uwYacUw+u0RswF2zUfGcB3bCyebwoZCMsoLvHDLTkgjUAJkYUQQZf++9e ogUg== X-Forwarded-Encrypted: i=1; AJvYcCU9BK53sshWvLKfL7zzr4r/wed8Y1j1bLHw6YEJqqTOxhNoeS2sOV1N+55aaDw/8sw8INpZi+6hSOO2/T/5@lists.postgresql.org X-Gm-Message-State: AOJu0YzuOerucuj9EvcL7p+nSu04OSVBt2mCLTjRlLPcw4dc1QGfuRds rWpMd7yjqQvX8eENivKBkBKagDKtgr+IluAZiHU4Qk/klQW2CWnLTF2bNL1suIpC093m1PwV5R4 z8Jo4GVHw/fHQxG3MK6k8E77LneHrCpshmFHe X-Gm-Gg: ASbGncu6ODxh5EhvVAQAX2lNho4zF98HetkaIqJVVfL0/I9WITwQpAiQoeTJyuiTZQc hIO/XPl03DUbmz9GXDiYvBzPruKIaFo2qK743AYVWu2zbGqz3IVW/vdJisYW6HrQOQ6SOTdb/+W FCAGw6tJli0MC0AGAO18XMM3f5jjBR/Rr4lyuPZBlJXdkbLq7fqE3Q4L1Ya1Dfyg4iofORKAIzS biD6Z4= X-Google-Smtp-Source: AGHT+IG+DV4Ak+2t0vQKX1kI936JyHS4kL3+K8aY/Nz73pre748k9BYYIq5uC3dArsmNImtOOJmlwH+BdudUkxN0NuU= X-Received: by 2002:a05:6512:b01:b0:55a:26ae:56e9 with SMTP id 2adb3069b0e04-55caf5ee78fmr1237849e87.40.1754515777875; Wed, 06 Aug 2025 14:29:37 -0700 (PDT) MIME-Version: 1.0 References: <1934172.1753462470@sss.pgh.pa.us> <1936547.1753463422@sss.pgh.pa.us> <1940680.1753465819@sss.pgh.pa.us> <1943137.1753467040@sss.pgh.pa.us> <2223785.1753476729@sss.pgh.pa.us> In-Reply-To: From: Rumpi Gravenstein Date: Wed, 6 Aug 2025 17:29:26 -0400 X-Gm-Features: Ac12FXxzHz0nbgrA-1rxcU9nM0QOy1wAXZlwYy-GGrUBPSMfP6_nPhB0-Xpr_XI Message-ID: Subject: Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array To: "David G. Johnston" Cc: Tom Lane , Laurenz Albe , PostgreSQL Content-Type: multipart/alternative; boundary="000000000000b17108063bb9090a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b17108063bb9090a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Here's a reproducible test case that causes the problem in different schemas. The issue appears to be related to creating a table and a function that has the same name as the table with a prepended underscore. rumpi_test -- table name _rumpi_test -- function name Here's the test case; SELECT version(); drop table if exists rumpi_test; create table rumpi_test( col1 varchar, col2 varchar); drop function if exists rumpi_test; CREATE OR REPLACE FUNCTION _rumpi_test( col1 varchar) RETURNS varchar LANGUAGE plpgsql AS $function$ declare begin raise info '%',_col1::varchar; return('Done'); end; $function$; select _rumpi_test('hello'); Here what I get when I run this in psql: xxx_pub_dev_2_db=3D> 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) xxx_pub_dev_2_db=3D> xxx_pub_dev_2_db=3D> drop table if exists rumpi_test; DROP TABLE xxx_pub_dev_2_db=3D> xxx_pub_dev_2_db=3D> create table rumpi_test( col1 varchar, col2 varchar); CREATE TABLE xxx_pub_dev_2_db=3D> xxx_pub_dev_2_db=3D> xxx_pub_dev_2_db=3D> xxx_pub_dev_2_db=3D> drop function if exists rumpi_test; NOTICE: function rumpi_test() does not exist, skipping DROP FUNCTION xxx_pub_dev_2_db=3D> xxx_pub_dev_2_db=3D> CREATE OR REPLACE FUNCTION _rumpi_test( col1 varchar) xxx_pub_dev_2_db-> xxx_pub_dev_2_db-> RETURNS varchar xxx_pub_dev_2_db-> xxx_pub_dev_2_db-> LANGUAGE plpgsql xxx_pub_dev_2_db-> xxx_pub_dev_2_db-> AS xxx_pub_dev_2_db-> xxx_pub_dev_2_db-> $function$ xxx_pub_dev_2_db$> xxx_pub_dev_2_db$> declare xxx_pub_dev_2_db$> xxx_pub_dev_2_db$> begin xxx_pub_dev_2_db$> xxx_pub_dev_2_db$> raise info '%',_col1::varchar; xxx_pub_dev_2_db$> xxx_pub_dev_2_db$> return('Done'); xxx_pub_dev_2_db$> xxx_pub_dev_2_db$> end; xxx_pub_dev_2_db$> xxx_pub_dev_2_db$> $function$; CREATE FUNCTION xxx_pub_dev_2_db=3D> xxx_pub_dev_2_db=3D> xxx_pub_dev_2_db=3D> xxx_pub_dev_2_db=3D> select _rumpi_test('hello'); ERROR: malformed array literal: "hello" LINE 1: select _rumpi_test('hello'); ^ DETAIL: Array value must start with "{" or dimension information. xxx_pub_dev_2_db=3D> On Wed, Aug 6, 2025 at 4:43=E2=80=AFPM David G. Johnston wrote: > On Wednesday, August 6, 2025, Rumpi Gravenstein > wrote: > >> >> xxx_pub_dev_2_db=3D# drop FUNCTION if exists _sa_setup_role; >> DROP FUNCTION >> xxx_pub_dev_2_db=3D# select proname, pronamespace, oid from pg_proc wher= e >> proname like '%sa_setup%'; >> proname | pronamespace | oid >> ---------+--------------+----- >> (0 rows) >> >> xxx_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. >> xxx_pub_dev_2_db=3D# >> > > Yeah, we=E2=80=99ve already pretty much decided this function has nothing= to do > with it. Go look at pg_type per the last example demonstrating the same > error without the involvement of any user-defined function. > > David J. > > --=20 Rumpi Gravenstein --000000000000b17108063bb9090a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Here's a reproducible=C2=A0test case that causes the p= roblem=C2=A0in different schemas.=C2=A0 The issue appears to be related to = creating a table and a function that has the same name as the table with a = prepended underscore.

rumpi_test=C2=A0 -- table name
_rumpi_test -- function name

Here's the= test case;

SELECT = version();

drop table if exists rumpi_test;<= /p>

create table= rumpi_test( col1 varchar, col2 = varchar);


drop function if exists rumpi_test;

CREATE = OR REPLACE FUNCTION _rumpi_test( col1 varchar)

RETURNS varchar

<= p style=3D"margin:0px">= LANGUAGE plpgsql

AS

$function$

declare=

begin

raise info '%',_col1::varchar;

return('Done');

end;

$function$;

select _rumpi_test('hello');

<= /div>


Here what I get when I run this in psql:
xxx_pub_dev_2_db=3D> SELECT version();
=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 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0version
-------------------------------------------------------------= --------------------------------------------
=C2=A0PostgreSQL 16.9 on x8= 6_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-26),= 64-bit
(1 row)


xxx_pub_dev_2_db=3D>
xxx_pub_dev_2_db= =3D> drop table if exists rumpi_test;
DROP TABLE
xxx_pub_dev_2_db= =3D>
xxx_pub_dev_2_db=3D> create table rumpi_test( col1 varchar, c= ol2 varchar);
CREATE TABLE
xxx_pub_dev_2_db=3D>
xxx_pub_dev_2_d= b=3D>
xxx_pub_dev_2_db=3D>
xxx_pub_dev_2_db=3D> drop functio= n if exists rumpi_test;
NOTICE: =C2=A0function rumpi_test() does not exi= st, skipping
DROP FUNCTION
xxx_pub_dev_2_db=3D>
xxx_pub_dev_2_d= b=3D> CREATE OR REPLACE FUNCTION _rumpi_test( col1 varchar)
xxx_pub_d= ev_2_db->
xxx_pub_dev_2_db-> RETURNS varchar
xxx_pub_dev_2_db-&= gt;
xxx_pub_dev_2_db-> LANGUAGE plpgsql
xxx_pub_dev_2_db->
x= xx_pub_dev_2_db-> AS
xxx_pub_dev_2_db->
xxx_pub_dev_2_db-> $= function$
xxx_pub_dev_2_db$>
xxx_pub_dev_2_db$> declare
xxx_= pub_dev_2_db$>
xxx_pub_dev_2_db$> begin
xxx_pub_dev_2_db$>xxx_pub_dev_2_db$> raise info '%',_col1::varchar;
xxx_pub_d= ev_2_db$>
xxx_pub_dev_2_db$> =C2=A0 return('Done');
xxx= _pub_dev_2_db$>
xxx_pub_dev_2_db$> end;
xxx_pub_dev_2_db$>xxx_pub_dev_2_db$> $function$;
CREATE FUNCTION
xxx_pub_dev_2_db= =3D>
xxx_pub_dev_2_db=3D>
xxx_pub_dev_2_db=3D>
xxx_pub_de= v_2_db=3D> select _rumpi_test('hello');
ERROR: =C2=A0malforme= d array literal: "hello"
LINE 1: select _rumpi_test('hello= ');
=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.
xxx_pub_dev_2_db=3D>



On Wed, Aug 6, 2025 at 4:43=E2=80=AFPM David G. J= ohnston <david.g.johnston@= gmail.com> wrote:
On Wednesday, August 6, 2025, Rumpi Gravenstein <rgravens@gmail.com> wrot= e:
xxx_pub_dev_2_db=3D# drop FUNCTION if exists _sa_setup_role;
DROP FUNC= TION
xxx_pub_dev_2_db=3D# select proname, pronamespace, oid from pg_proc= where proname like '%sa_setup%';
proname | pronamespace | oid---------+--------------+-----
(0 rows)
=C2=A0
xxx_pub_dev_2_db= =3D# select _sa_setup_role('af_repo_app');
ERROR: =C2=A0malforme= d array literal: "af_repo_app"
LINE 1: select _sa_setup_role(&= #39;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=A0= Array value must start with "{" or dimension information.
xxx_= pub_dev_2_db=3D#

Yeah, we=E2=80=99ve = already pretty much decided this function has nothing to do with it.=C2=A0 = Go look at pg_type per the last example demonstrating the same error withou= t the involvement of any user-defined function.

Da= vid J.



--
Rumpi Gravenstein
--000000000000b17108063bb9090a--