Re: CALL and named parameters

Поиск
Список
Период
Сортировка
От Dominique Devienne
Тема Re: CALL and named parameters
Дата
Msg-id CAFCRh-9XkFS==OwSB6jgY84L5d4PkV_Y9MxLgk=NVx0Z8W3o_A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: CALL and named parameters  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: CALL and named parameters
Re: CALL and named parameters
Список pgsql-general
On Wed, Aug 6, 2025 at 8:09 PM Pavel Stehule <pavel.stehule@gmail.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



В списке pgsql-general по дате отправления: