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

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Rumpi Gravenstein <rgravens(at)gmail(dot)com>
Cc: 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 20:44:35
Message-ID: c6d327b17ba73a17d455e88ef002ebbd242f87ab.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2025-07-25 at 14:10 -0400, Tom Lane wrote:
> After looking at the code I remembered that the parser might be taking
> this as a type coercion request.  With that idea, I can duplicate the
> observed behavior like so:
>
> regression=# select _sa_setup_role('af_repo_app');
> INFO:  af_repo_app
>  _sa_setup_role
> ----------------
>  Done
> (1 row)
>
> regression=# create domain _sa_setup_role as varchar[];
> CREATE DOMAIN
> regression=# 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.
>
> So ... any chance you have a data type named _sa_setup_role?

... it could also be a type "sa_setup_role", and "_sa_setup_role"
is interpreted as the corresponding array type:

CREATE DOMAIN sa_setup_role AS varchar;

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.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2025-07-25 20:52:09 Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array
Previous Message Tom Lane 2025-07-25 18:10:40 Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array