From: | 金 <jinbinge(at)126(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | If there are more than two functions in different schemas, the functions have the same name and same arguments, \df[+] only display the function that schema first appeared in the search_path. |
Date: | 2023-01-16 06:21:26 |
Message-ID: | 360c392.330b.185b93d644c.Coremail.jinbinge@126.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
I find if there are more than one functions in different schemas,
and the functions have the same name and the same arguments,
\df[+] only display the function that schema earlier appeared in the search_path.
And SELECT pg_function_is_visible(funoid) returns f.
Because in FunctionIsVisible(Oid funcid) function, only use proname to see if the function can be found by FuncnameGetCandidates.
I think \df[+] should display all the functions, and in FunctionIsVisible(Oid funcid) function, should use pronamespace and proname
to see if the function can be found by FuncnameGetCandidates.
Next is my test cases. The PostgreSQL version is 15.1.
CREATE OR REPLACE FUNCTION fun1(arg1 INT, arg2 OUT int, arg3 IN OUT int)
RETURNS RECORD
AS
$$
BEGIN
arg3 := arg1 + arg2;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE PROCEDURE proc1(arg1 INT, arg2 IN OUT INT, arg3 OUT INT)
AS
$$
BEGIN
arg3 := arg1 + arg2;
END;
$$ LANGUAGE plpgsql;
postgres=# \df
List of functions
Schema | Name | Result data type | Argument data types | Type
--------+-------+------------------+-------------------------------------------------------+------
public | fun1 | record | arg1 integer, OUT arg2 integer, INOUT arg3 integer | func
public | proc1 | | IN arg1 integer, INOUT arg2 integer, OUT arg3 integer | proc
(2 rows)
set search_path="$user", public, s1;
CREATE SCHEMA s1;
CREATE OR REPLACE FUNCTION s1.fun1(arg1 INT, arg2 OUT int, arg3 IN OUT int)
RETURNS RECORD
AS
$$
BEGIN
arg3 := arg1 + arg2;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE PROCEDURE s1.proc1(arg1 INT, arg2 IN OUT INT, arg3 OUT INT)
AS
$$
BEGIN
arg3 := arg1 + arg2;
END;
$$ LANGUAGE plpgsql;
postgres=# \df
List of functions
Schema | Name | Result data type | Argument data types | Type
--------+-------+------------------+-------------------------------------------------------+------
public | fun1 | record | arg1 integer, OUT arg2 integer, INOUT arg3 integer | func
public | proc1 | | IN arg1 integer, INOUT arg2 integer, OUT arg3 integer | proc
(2 rows)
postgres=# \df fun1
List of functions
Schema | Name | Result data type | Argument data types | Type
--------+------+------------------+----------------------------------------------------+------
public | fun1 | record | arg1 integer, OUT arg2 integer, INOUT arg3 integer | func
(1 row)
postgres=# select * from pg_proc where proname like 'fun1';
oid | proname | pronamespace | proowner | prolang | procost | prorows | provariadic | prosupport | prokind | prosecdef | proleakproof | proisstrict | proretset | provolatile | proparallel | pronargs | pronargdefa
ults | prorettype | proargtypes | proallargtypes | proargmodes | proargnames | proargdefaults | protrftypes | prosrc | probin | prosqlbody | proconfig | proacl
-------+---------+--------------+----------+---------+---------+---------+-------------+------------+---------+-----------+--------------+-------------+-----------+-------------+-------------+----------+------------
-----+------------+-------------+----------------+-------------+------------------+----------------+-------------+------------------------+--------+------------+-----------+--------
16386 | fun1 | 2200 | 10 | 13677 | 100 | 0 | 0 | - | f | f | f | f | f | v | u | 2 |
0 | 2249 | 23 23 | {23,23,23} | {i,o,b} | {arg1,arg2,arg3} | | | +| | | |
| | | | | | | | | | | | | | | | |
| | | | | | | | BEGIN +| | | |
| | | | | | | | | | | | | | | | |
| | | | | | | | arg3 := arg1 + arg2;+| | | |
| | | | | | | | | | | | | | | | |
| | | | | | | | END; +| | | |
| | | | | | | | | | | | | | | | |
| | | | | | | | | | | |
16389 | fun1 | 16388 | 10 | 13677 | 100 | 0 | 0 | - | f | f | f | f | f | v | u | 2 |
0 | 2249 | 23 23 | {23,23,23} | {i,o,b} | {arg1,arg2,arg3} | | | +| | | |
| | | | | | | | | | | | | | | | |
| | | | | | | | BEGIN +| | | |
| | | | | | | | | | | | | | | | |
| | | | | | | | arg3 := arg1 + arg2;+| | | |
| | | | | | | | | | | | | | | | |
| | | | | | | | END; +| | | |
| | | | | | | | | | | | | | | | |
| | | | | | | | | | | |
(2 rows)
postgres=# SELECT pg_function_is_visible(16386);
pg_function_is_visible
------------------------
t
(1 row)
postgres=# SELECT pg_function_is_visible(16389); --Should display t?
pg_function_is_visible
------------------------
f
(1 row)
From | Date | Subject | |
---|---|---|---|
Next Message | John Naylor | 2023-01-16 06:28:02 | Re: Small miscellaneus fixes (Part II) |
Previous Message | Amit Kapila | 2023-01-16 06:19:36 | Re: Perform streaming logical transactions by background workers and parallel apply |