Re: right join with partitioned table crash

2021-09-17 Thread Tom Lane
Justin Pryzby  writes:
> On Wed, Sep 15, 2021 at 07:53:49PM -0400, Tom Lane wrote:
>> Jaime Casanova  writes:
>>> Here's another crash caught by sqlsmith.

>> Fun.  Looks like it fails back to v12, but not in v11,
>> so it's some optimization we added in v12 that's at fault.

> It seems to be a regression (?) in 12.6 (2021-02-11), from
> | 1cce024fd2 Fix pull_varnos' miscomputation of relids set for a 
> PlaceHolderVar.

Yeah, that patch still had a hole in it.  Fix pushed,
thanks for the report!

regards, tom lane




Re: right join with partitioned table crash

2021-09-15 Thread Justin Pryzby
On Wed, Sep 15, 2021 at 07:53:49PM -0400, Tom Lane wrote:
> Jaime Casanova  writes:
> > Here's another crash caught by sqlsmith.
> 
> Fun.  Looks like it fails back to v12, but not in v11,
> so it's some optimization we added in v12 that's at fault.

It seems to be a regression (?) in 12.6 (2021-02-11), from
| 1cce024fd2 Fix pull_varnos' miscomputation of relids set for a PlaceHolderVar.

-- 
Justin




Re: right join with partitioned table crash

2021-09-15 Thread Tom Lane
Jaime Casanova  writes:
> Here's another crash caught by sqlsmith.

Fun.  Looks like it fails back to v12, but not in v11,
so it's some optimization we added in v12 that's at fault.

(That being the case, this isn't a blocker for 14rc1,
though of course it'd be nice if we fix it in time for that.)

regards, tom lane




right join with partitioned table crash

2021-09-15 Thread Jaime Casanova
Hi everyone,

Here's another crash caught by sqlsmith.

"""
drop table if exists fkpart3_pk5 cascade;
drop table if exists inet_tbl;

create table fkpart3_pk5 (
a integer not null primary key
)
partition by range (a);

create table fkpart3_pk51 partition of fkpart3_pk5
for values from (4000) to (4500);

create table inet_tbl (
c cidr,
i inet
);

select
1 as c0
from
(select null::integer as c9,
ref_0.a as c24
   from fkpart3_pk5 as ref_0
) as subq_0
right join public.inet_tbl as sample_0 on (cast(null as cidr) = c)
where subq_0.c9 <= subq_0.c24
"""


Attached the backtrace.

-- 
Jaime Casanova
Director de Servicios Profesionales
SystemGuards - Consultores de PostgreSQL
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
set = {__val = {4194304, 140736805622640, 2, 6, 556, 
94745029079040, 
4611686018427388799, 139894076431014, 0, 281470681751456, 0, 0, 0, 
0, 0, 0}}
pid = 
tid = 
ret = 
#1  0x7f3ba0830535 in __GI_abort () at abort.c:79
save_stage = 1
act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, 
sa_mask = {__val = {
  0, 0, 0, 0, 0, 139894074187765, 2, 7075777569425871984, 
7003713384980111928, 
  94745029079040, 7003719963994515424, 0, 9449567279706640128, 
140736805622880, 0, 
  140736805623744}}, sa_flags = -1949470720, sa_restorer = 0x0}
sigs = {__val = {32, 0 }}
#2  0x562b8c3818a0 in ExceptionalCondition (
conditionName=0x562b8c527e38 "!bms_overlap(baserel->relids, 
required_outer)", 
errorType=0x562b8c527a26 "FailedAssertion", fileName=0x562b8c527abf 
"relnode.c", 
lineNumber=1313) at assert.c:69
No locals.
#3  0x562b8c0ef355 in get_baserel_parampathinfo (root=0x562b8d3ebd00, 
baserel=0x562b8d3e8ec0, required_outer=0x562b8d40e350) at relnode.c:1313
ppi = 0x562b8d3e8ec0
joinrelids = 0x562b8d40f468
pclauses = 0x562b8d40e490
rows = 6.9533220764192298e-310
lc = 0x562b8d40f4c0
#4  0x562b8c0debbd in create_append_path (root=0x562b8d3ebd00, 
rel=0x562b8d3e8ec0, 
subpaths=0x562b8d40f468, partial_subpaths=0x0, pathkeys=0x0, 
required_outer=0x562b8d40e350, 
parallel_workers=0, parallel_aware=false, rows=-1) at pathnode.c:1270
pathnode = 0x562b8d40f4c0
l = 0x0
#5  0x562b8c06ff7c in add_paths_to_append_rel (root=0x562b8d3ebd00, 
rel=0x562b8d3e8ec0, 
live_childrels=0x562b8d40f060) at allpaths.c:1610
required_outer = 0x562b8d40e350
lcr = 0x0
l__state = {l = 0x562b8d40f1c0, i = 0}
subpaths = 0x562b8d40f468
subpaths_valid = true
partial_subpaths = 0x562b8d40f110
pa_partial_subpaths = 0x562b8d40f168
pa_nonpartial_subpaths = 0x0
partial_subpaths_valid = true
pa_subpaths_valid = true
all_child_pathkeys = 0x0
all_child_outers = 0x562b8d40f1c0
l = 0x562b8d40f1d8
partial_rows = 500
#6  0x562b8c06f47b in set_append_rel_pathlist (root=0x562b8d3ebd00, 
rel=0x562b8d3e8ec0, 
rti=4, rte=0x562b8d3e7df0) at allpaths.c:1269
parentRTindex = 4
live_childrels = 0x562b8d40f060
l = 0x0
#7  0x562b8c06e33a in set_rel_pathlist (root=0x562b8d3ebd00, 
rel=0x562b8d3e8ec0, rti=4, 
rte=0x562b8d3e7df0) at allpaths.c:481
__func__ = "set_rel_pathlist"
#8  0x562b8c06e023 in set_base_rel_pathlists (root=0x562b8d3ebd00) at 
allpaths.c:353
rel = 0x562b8d3e8ec0
rti = 4
#9  0x562b8c06dd72 in make_one_rel (root=0x562b8d3ebd00, 
joinlist=0x562b8d40c8a8)
at allpaths.c:223
rel = 0x8d3ebd00
rti = 6
total_pages = 20
#10 0x562b8c0aab06 in query_planner (root=0x562b8d3ebd00, 
qp_callback=0x562b8c0b07c1 , qp_extra=0x7fffd74e5cc0) 
at planmain.c:276
parse = 0x562b8d3e72f0
joinlist = 0x562b8d40c8a8
final_rel = 0x562b8d3ed520
__func__ = "query_planner"
#11 0x562b8c0ad2bf in grouping_planner (root=0x562b8d3ebd00, 
tuple_fraction=0)
at planner.c:1447
sort_input_targets = 0x562b8d3edec8
sort_input_target_parallel_safe = false
grouping_target = 0x562b8d3ebc70
scanjoin_target = 0x562b8d3edc40
activeWindows = 0x0
qp_extra = {activeWindows = 0x0, groupClause = 0x0}
sort_input_targets_contain_srfs = 0x0
have_grouping = false
wflists = 0x0
gset_data = 0x0
sort_input_target = 0x562b8d3edc98
grouping_targets = 0x562b8c017eee 
grouping_target_parallel_safe = false
scanjoin_targets = 0x562b8d315790
scanjoin_target_parallel_safe = false
grouping_targets_contain_srfs = 0x7fffd74e5d00
scanjoin_targets_contain_srfs = 0x0
scanjoin_target_same_exprs = false
parse = 0x562b8d3e72f0
offset_est = 0
count_est = 0
limit_tuples = -1