Re: CALL and named parameters

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: CALL and named parameters
Date: 2025-08-07 12:44:51
Message-ID: CAFCRh-9XkFS==OwSB6jgY84L5d4PkV_Y9MxLgk=NVx0Z8W3o_A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Aug 6, 2025 at 8:09 PM Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> Maybe there is another issue?

Indeed. Thanks Pavel, Andrian, Christoph, for demonstrating I was wrong.
I misinterpreted the signals I got, and accepted the AI's interpretation on
success (after a long day) when the inderlying isse was elsewhere.

My mistake was in
> I verify the names of the parameters, in my CALL with named arguments. OK.

I verified against the embedded PL/pgSQL in my code, not what was in the DB.
I had renamed an argument in the code, but the schema was instantiated
using the earlier code.
And because I was using the named-argument syntax, but a wrong
arg-name, it fails.

What's not nice is in the way it failed IMHO. I guess I persist it's
not a user friendly message :)

Can you overload a function solely by changing an argument name?
If not, as I suspect, then function lookup doesn't strictly depend on
argument names (like in C++).
So the function did exist, with the correct "signature" (ignoring
argument names).
And I was "just" using the wrong arg-name. That tripped me up.

The AI's suggestion, to go positional, while based on crap reasoning,
did help me, in a way :).

So mea culpa. Apologies for the misguided rant (and smaller re-rant above :)).

PS: below's my psql session that led me to the wrong conclusion.

dd_v185=> call "Epos-DBA".db_grant_connect_to(grantee_role => 'dd_joe');
ERROR: procedure Epos-DBA.db_grant_connect_to(grantee_role =>
unknown) does not exist
LINE 1: call "Epos-DBA".db_grant_connect_to(grantee_role => 'dd_joe'...
^
HINT: No procedure matches the given name and argument types. You
might need to add explicit type casts.
dd_v185=> call "Epos-DBA".db_grant_connect_to(grantee_role => 'dd_joe'::name);
ERROR: procedure Epos-DBA.db_grant_connect_to(grantee_role => name)
does not exist
LINE 1: call "Epos-DBA".db_grant_connect_to(grantee_role => 'dd_joe'...
^
HINT: No procedure matches the given name and argument types. You
might need to add explicit type casts.
dd_v185=> \df "Epos-DBA".db_grant_connect_to
List of functions
Schema | Name | Result data type | Argument data types | Type
----------+---------------------+------------------+---------------------+------
Epos-DBA | db_grant_connect_to | | IN login_role name | proc
(1 row)

dd_v185=> select has_schema_privilege('Epos-DBA', 'usage');
has_schema_privilege
----------------------
t
(1 row)

dd_v185=> select
has_function_privilege('"Epos-DBA".db_grant_connect_to(name)',
'execute');
has_function_privilege
------------------------
t
(1 row)

dd_v185=> call "Epos-DBA".db_grant_connect_to('dd_joe');
CALL

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2025-08-07 13:30:30 Re: CALL and named parameters
Previous Message suporte02@unitsistemas.com.br 2025-08-07 12:14:27 Re: Libpq.dll