25.08.2021 23:00, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference: 17161
> Logged by: Alexander Lakhin
> Email address: exclusion@gmail.com
> PostgreSQL version: 14beta3
> Operating system: Ubuntu 20.04
> Description:
>
> When executing the following query (based on the create_function_3 test):
> CREATE TABLE functest2 (a int, b int);
>
> CREATE SCHEMA temp_func_test;
> SET search_path TO temp_func_test, public;
> CREATE TABLE functest2 (a int, b int);
>
> CREATE FUNCTION functest_sri1() RETURNS SETOF int
> LANGUAGE SQL
> STABLE
> RETURN (SELECT count(a) FROM functest2);
>
> SELECT * FROM functest_sri1();
>
My initial conclusion was incorrect. Duplicate relation is not needed in
the second schema. It's sufficient to just change search_path to another
schema:
CREATE TABLE functest2 (a int, b int);
CREATE SCHEMA temp_func_test;
SET search_path TO temp_func_test, public;
CREATE FUNCTION functest_sri1() RETURNS SETOF int
LANGUAGE SQL
STABLE
RETURN (SELECT count(a) FROM functest2);
SELECT * FROM functest_sri1();
Best regards,
Alexander