BUG #15694: Server crash in EXPLAIN with LATERAL and a partitioned table - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15694: Server crash in EXPLAIN with LATERAL and a partitioned table
Date
Msg-id 15694-74f2ca97e7044f7f@postgresql.org
Whole thread Raw
Responses Re: BUG #15694: Server crash in EXPLAIN with LATERAL and a partitioned table  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15694
Logged by:          Alexander Lakhin
Email address:      exclusion@gmail.com
PostgreSQL version: 11.2
Operating system:   Ubuntu 18.04
Description:

The following query:
CREATE TABLE prt1_l (a int) PARTITION BY RANGE(a);
CREATE TABLE prt2_l (a int);

EXPLAIN
SELECT * FROM prt1_l t1 LEFT JOIN LATERAL
  (SELECT t1.a as t1a, prt1_l.a FROM prt1_l) t2 ON t1.a = t2.a;

crashes the server with the stack trace:
Core was generated by `postgres: law regression [local] EXPLAIN
                        '.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007f6548ca5801 in __GI_abort () at abort.c:79
#2  0x000055a1a7906e13 in ExceptionalCondition (
    conditionName=conditionName@entry=0x55a1a7aafb80
"!(bms_is_subset(appendrel->lateral_relids, required_outer))", 
    errorType=errorType@entry=0x55a1a795c61d "FailedAssertion",
fileName=fileName@entry=0x55a1a7aaf164 "relnode.c", 
    lineNumber=lineNumber@entry=1543) at assert.c:54
#3  0x000055a1a7752135 in get_appendrel_parampathinfo
(appendrel=appendrel@entry=0x55a1a8ae5458, 
    required_outer=required_outer@entry=0x0) at relnode.c:1543
#4  0x000055a1a7747783 in create_append_path (root=root@entry=0x0,
rel=rel@entry=0x55a1a8ae5458, 
    subpaths=subpaths@entry=0x0,
partial_subpaths=partial_subpaths@entry=0x0,
required_outer=required_outer@entry=0x0, 
    parallel_workers=parallel_workers@entry=0, parallel_aware=false,
partitioned_rels=0x0, rows=rows@entry=-1)
    at pathnode.c:1250
#5  0x000055a1a7705bf7 in set_dummy_rel_pathlist
(rel=rel@entry=0x55a1a8ae5458) at allpaths.c:2019
#6  0x000055a1a7706e04 in set_subquery_pathlist (rte=<optimized out>,
rti=<optimized out>, rel=<optimized out>, 
    root=<optimized out>) at allpaths.c:2205
#7  set_rel_size (root=root@entry=0x55a1a8ae2158,
rel=rel@entry=0x55a1a8ae5458, rti=rti@entry=4, rte=<optimized out>)
    at allpaths.c:379
#8  0x000055a1a7707dcd in set_base_rel_sizes (root=<optimized out>) at
allpaths.c:281
#9  make_one_rel (root=root@entry=0x55a1a8ae2158,
joinlist=joinlist@entry=0x55a1a8ae5040) at allpaths.c:179
#10 0x000055a1a7729a3a in query_planner (root=root@entry=0x55a1a8ae2158,
tlist=tlist@entry=0x55a1a8ae3e58, 
    qp_callback=qp_callback@entry=0x55a1a772a6c0 <standard_qp_callback>,
qp_extra=qp_extra@entry=0x7ffef88cb520)
    at planmain.c:265
#11 0x000055a1a772e617 in grouping_planner (root=root@entry=0x55a1a8ae2158,

    inheritance_update=inheritance_update@entry=false,
tuple_fraction=<optimized out>, tuple_fraction@entry=0)
    at planner.c:1908
#12 0x000055a1a7730f0b in subquery_planner (glob=glob@entry=0x55a1a8ae20c0,
parse=parse@entry=0x55a1a8a9c928, 
    parent_root=parent_root@entry=0x0,
hasRecursion=hasRecursion@entry=false,
tuple_fraction=tuple_fraction@entry=0)
    at planner.c:966
#13 0x000055a1a773204e in standard_planner (parse=0x55a1a8a9c928,
cursorOptions=256, boundParams=<optimized out>)
    at planner.c:405
#14 0x000055a1a77ec30d in pg_plan_query
(querytree=querytree@entry=0x55a1a8a9c928, cursorOptions=256, 
    boundParams=boundParams@entry=0x0) at postgres.c:832
#15 0x000055a1a7621efe in ExplainOneQuery (query=0x55a1a8a9c928,
cursorOptions=<optimized out>, into=0x0, 
    es=0x55a1a8a30548, 
    queryString=0x55a1a8a0d618 "EXPLAIN\nSELECT * FROM prt1_l t1 LEFT JOIN
LATERAL\n  (SELECT t1.a as t1a, prt1_l.a FROM prt1_l) t2 ON t1.a = t2.a;",
params=0x0, queryEnv=0x0) at explain.c:365
#16 0x000055a1a76224c8 in ExplainQuery (pstate=pstate@entry=0x55a1a8a2e1d8,
stmt=stmt@entry=0x55a1a8a0ee78, 
    queryString=queryString@entry=0x55a1a8a0d618 "EXPLAIN\nSELECT * FROM
prt1_l t1 LEFT JOIN LATERAL\n  (SELECT t1.a as t1a, prt1_l.a FROM prt1_l) t2
ON t1.a = t2.a;", params=params@entry=0x0, queryEnv=queryEnv@entry=0x0, 
    dest=dest@entry=0x55a1a8a304b0) at explain.c:254
#17 0x000055a1a77f263d in standard_ProcessUtility (pstmt=0x55a1a8a0ef48, 
    queryString=0x55a1a8a0d618 "EXPLAIN\nSELECT * FROM prt1_l t1 LEFT JOIN
LATERAL\n  (SELECT t1.a as t1a, prt1_l.a FROM prt1_l) t2 ON t1.a = t2.a;",
context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0,
dest=0x55a1a8a304b0, 
    completionTag=0x7ffef88cb990 "") at utility.c:675
#18 0x000055a1a77ef2f2 in PortalRunUtility (portal=0x55a1a8a74168,
pstmt=0x55a1a8a0ef48, isTopLevel=<optimized out>, 
    setHoldSnapshot=<optimized out>, dest=<optimized out>,
completionTag=0x7ffef88cb990 "") at pquery.c:1178
#19 0x000055a1a77f0207 in FillPortalStore
(portal=portal@entry=0x55a1a8a74168, isTopLevel=isTopLevel@entry=true)
    at pquery.c:1038
#20 0x000055a1a77f0e7d in PortalRun (portal=portal@entry=0x55a1a8a74168,
count=count@entry=9223372036854775807, 
    isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true,
dest=dest@entry=0x55a1a8acabc0, 
    altdest=altdest@entry=0x55a1a8acabc0, completionTag=0x7ffef88cbbc0 "")
at pquery.c:768
#21 0x000055a1a77ec612 in exec_simple_query (
    query_string=0x55a1a8a0d618 "EXPLAIN\nSELECT * FROM prt1_l t1 LEFT JOIN
LATERAL\n  (SELECT t1.a as t1a, prt1_l.a FROM prt1_l) t2 ON t1.a = t2.a;")
at postgres.c:1145
#22 0x000055a1a77ee59d in PostgresMain (argc=<optimized out>,
argv=argv@entry=0x55a1a8a38748, dbname=<optimized out>, 
    username=<optimized out>) at postgres.c:4182
#23 0x000055a1a74c327d in BackendRun (port=0x55a1a8a30e40) at
postmaster.c:4361
#24 BackendStartup (port=0x55a1a8a30e40) at postmaster.c:4033
#25 ServerLoop () at postmaster.c:1706
#26 0x000055a1a776c398 in PostmasterMain (argc=3, argv=0x55a1a8a079f0) at
postmaster.c:1379
#27 0x000055a1a74c4ea9 in main (argc=3, argv=0x55a1a8a079f0) at main.c:228
(gdb) q

git bisect points to 9d6d2b2134.
Thanks to Roman Zharkov for discovering this.


pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #15668: Server crash in transformPartitionRangeBounds
Next
From: Tom Lane
Date:
Subject: Re: BUG #15694: Server crash in EXPLAIN with LATERAL and a partitioned table