BUG #17161: Assert failed on opening a relation that exists in two schemas via the LANGUAGE SQL function

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #17161: Assert failed on opening a relation that exists in two schemas via the LANGUAGE SQL function
Date: 2021-08-25 20:00:01
Message-ID: 17161-048a1cdff8422800@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17161
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)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();

I get a failed assertion with the following stacktrace:
Core was generated by `postgres: law regression [local] SELECT
'.
Program terminated with signal SIGABRT, Aborted.
#0 __GI_raise (sig=sig(at)entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 __GI_raise (sig=sig(at)entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007fc1c488c859 in __GI_abort () at abort.c:79
#2 0x0000558a9eea3a4a in ExceptionalCondition (
conditionName=conditionName(at)entry=0x558a9f0146e0 "lockmode != NoLock ||
IsBootstrapProcessingMode() || CheckRelationLockedByMe(r, AccessShareLock,
true)", errorType=errorType(at)entry=0x558a9f0145e0 "FailedAssertion",
fileName=fileName(at)entry=0x558a9f0145a0 "relation.c",
lineNumber=lineNumber(at)entry=68) at assert.c:69
#3 0x0000558a9dced3a8 in relation_open (relationId=16389,
lockmode=lockmode(at)entry=0) at relation.c:68
#4 0x0000558a9df2e764 in table_open (relationId=<optimized out>,
lockmode=lockmode(at)entry=0) at table.c:43
#5 0x0000558a9e943bd3 in fireRIRrules (parsetree=0x625000051300,
activeRIRs=activeRIRs(at)entry=0x0)
at rewriteHandler.c:2056
#6 0x0000558a9e944edb in fireRIRonSubLink (node=0x6250000512a8,
activeRIRs=0x0) at rewriteHandler.c:1929
#7 0x0000558a9e5ced9a in expression_tree_walker
(node=node(at)entry=0x62500004d0a0,
walker=walker(at)entry=0x558a9e944e43 <fireRIRonSubLink>,
context=context(at)entry=0x0) at nodeFuncs.c:2159
#8 0x0000558a9e944e94 in fireRIRonSubLink (node=0x62500004d0a0,
activeRIRs=0x0) at rewriteHandler.c:1938
#9 0x0000558a9e5cf0b1 in expression_tree_walker
(node=node(at)entry=0x6250000519b8,
walker=walker(at)entry=0x558a9e944e43 <fireRIRonSubLink>,
context=context(at)entry=0x0) at nodeFuncs.c:2207
#10 0x0000558a9e944e94 in fireRIRonSubLink (node=0x6250000519b8,
activeRIRs=0x0) at rewriteHandler.c:1938
#11 0x0000558a9e5d0156 in query_tree_walker
(query=query(at)entry=0x625000051158,
walker=walker(at)entry=0x558a9e944e43 <fireRIRonSubLink>,
context=context(at)entry=0x0, flags=flags(at)entry=3)
at nodeFuncs.c:2369
#12 0x0000558a9e94455b in fireRIRrules (parsetree=0x625000051158,
activeRIRs=activeRIRs(at)entry=0x0)
at rewriteHandler.c:2120
#13 0x0000558a9e950a7b in QueryRewrite
(parsetree=parsetree(at)entry=0x625000051158) at rewriteHandler.c:4092
#14 0x0000558a9ea63500 in pg_rewrite_query (query=0x625000051158) at
postgres.c:756
#15 0x0000558a9e76f917 in inline_set_returning_function
(root=root(at)entry=0x625000048940, rte=rte(at)entry=0x6250000065c0)
at clauses.c:4978
#16 0x0000558a9e74066e in preprocess_function_rtes
(root=root(at)entry=0x625000048940) at prepjointree.c:656
#17 0x0000558a9e70b5ea in subquery_planner (glob=glob(at)entry=0x6250000066d8,
parse=parse(at)entry=0x625000006238,
parent_root=parent_root(at)entry=0x0,
hasRecursion=hasRecursion(at)entry=false,
tuple_fraction=tuple_fraction(at)entry=0)
at planner.c:667
#18 0x0000558a9e70f237 in standard_planner (parse=0x625000006238,
query_string=<optimized out>, cursorOptions=2048,
boundParams=<optimized out>) at planner.c:400
#19 0x0000558a9e7110a3 in planner (parse=parse(at)entry=0x625000006238,
query_string=query_string(at)entry=0x625000005220 "SELECT * FROM
functest_sri1();",
cursorOptions=cursorOptions(at)entry=2048,
boundParams=boundParams(at)entry=0x0) at planner.c:271
#20 0x0000558a9ea63c01 in pg_plan_query
(querytree=querytree(at)entry=0x625000006238,
query_string=query_string(at)entry=0x625000005220 "SELECT * FROM
functest_sri1();",
cursorOptions=cursorOptions(at)entry=2048,
boundParams=boundParams(at)entry=0x0) at postgres.c:847
#21 0x0000558a9ea64234 in pg_plan_queries (querytrees=0x625000006fb8,
query_string=query_string(at)entry=0x625000005220 "SELECT * FROM
functest_sri1();",
cursorOptions=cursorOptions(at)entry=2048,
boundParams=boundParams(at)entry=0x0) at postgres.c:939
#22 0x0000558a9ea6482d in exec_simple_query (
query_string=query_string(at)entry=0x625000005220 "SELECT * FROM
functest_sri1();") at postgres.c:1133
#23 0x0000558a9ea69c43 in PostgresMain (argc=argc(at)entry=1,
argv=argv(at)entry=0x7fff77497600, dbname=<optimized out>,
dbname(at)entry=0x629000011278 "regression",
username=username(at)entry=0x629000011258 "law") at postgres.c:4486
#24 0x0000558a9e832d79 in BackendRun (port=port(at)entry=0x615000002d80) at
postmaster.c:4506
#25 0x0000558a9e83c19e in BackendStartup (port=port(at)entry=0x615000002d80) at
postmaster.c:4228
#26 0x0000558a9e83c938 in ServerLoop () at postmaster.c:1745
#27 0x0000558a9e83f0dc in PostmasterMain (argc=<optimized out>,
argv=<optimized out>) at postmaster.c:1417
#28 0x0000558a9e544823 in main (argc=3, argv=0x603000000610) at main.c:209

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2021-08-26 05:07:48 BUG #17162: order by clause is not pushed down to foreign scans when a WHERE clause is given in query
Previous Message Tom Lane 2021-08-25 16:19:30 Re: Postgres 9.2.13 on AIX 7.1