public inbox for [email protected]
help / color / mirror / Atom feedFrom: Rumpi Gravenstein <[email protected]>
To: David G. Johnston <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: Laurenz Albe <[email protected]>
Cc: PostgreSQL <[email protected]>
Subject: Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array
Date: Wed, 6 Aug 2025 17:29:26 -0400
Message-ID: <CAEpg1wA=sJ4Cvs3hUN9rfYBwTC74uFWYUzQGfcfZC4u-K1AH7w@mail.gmail.com> (raw)
In-Reply-To: <CAKFQuwZJJQz=Ap_S7taL1iJwS6tT0AvrVGThpxWMgQk9ZLSy2w@mail.gmail.com>
References: <CAEpg1wBxp=25isxj6yt2cf97KtvbwxvJfrJ9qYF8UQxGSBJ93Q@mail.gmail.com>
<[email protected]>
<CAEpg1wCDL+iYbG7ByjHcgfvJy7m3m-rDp-xKiYovvxeKTbG7iQ@mail.gmail.com>
<[email protected]>
<CAEpg1wALRocK=uDSNyJqdc=vhNGjYFmT3H_TNzihSOMS88WHfg@mail.gmail.com>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<CAEpg1wBUcKjbM+vqP=JLHQUCOW9ct=aVRo1gBEtAZ5SuMY6cYQ@mail.gmail.com>
<CAKFQuwZJJQz=Ap_S7taL1iJwS6tT0AvrVGThpxWMgQk9ZLSy2w@mail.gmail.com>
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=> 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=>
xxx_pub_dev_2_db=> drop table if exists rumpi_test;
DROP TABLE
xxx_pub_dev_2_db=>
xxx_pub_dev_2_db=> create table rumpi_test( col1 varchar, col2 varchar);
CREATE TABLE
xxx_pub_dev_2_db=>
xxx_pub_dev_2_db=>
xxx_pub_dev_2_db=>
xxx_pub_dev_2_db=> drop function if exists rumpi_test;
NOTICE: function rumpi_test() does not exist, skipping
DROP FUNCTION
xxx_pub_dev_2_db=>
xxx_pub_dev_2_db=> 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=>
xxx_pub_dev_2_db=>
xxx_pub_dev_2_db=>
xxx_pub_dev_2_db=> 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=>
On Wed, Aug 6, 2025 at 4:43 PM David G. Johnston <[email protected]>
wrote:
> On Wednesday, August 6, 2025, Rumpi Gravenstein <[email protected]>
> wrote:
>
>>
>> xxx_pub_dev_2_db=# drop FUNCTION if exists _sa_setup_role;
>> DROP FUNCTION
>> xxx_pub_dev_2_db=# select proname, pronamespace, oid from pg_proc where
>> proname like '%sa_setup%';
>> proname | pronamespace | oid
>> ---------+--------------+-----
>> (0 rows)
>>
>> xxx_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.
>> xxx_pub_dev_2_db=#
>>
>
> Yeah, we’ve 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.
>
>
--
Rumpi Gravenstein
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array
In-Reply-To: <CAEpg1wA=sJ4Cvs3hUN9rfYBwTC74uFWYUzQGfcfZC4u-K1AH7w@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox