Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 867be9c

Browse files
committed
Convert nullingrels match checks from Asserts to test-and-elog.
It seems like the code that these checks are backstopping may have a few bugs left in it. Use a test-and-elog so that the tests are performed even in non-assert builds, and so that we get something more informative than "server closed the connection" on failure. Committed separately with the idea that eventually we'll revert this. It might be awhile though. Discussion: https://postgr.es/m/3014965.1684293045@sss.pgh.pa.us
1 parent 1a05c1d commit 867be9c

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/backend/optimizer/plan/setrefs.c

+21-13
Original file line numberDiff line numberDiff line change
@@ -2786,7 +2786,7 @@ search_indexed_tlist_for_var(Var *var, indexed_tlist *itlist,
27862786
Var *newvar = copyVar(var);
27872787

27882788
/*
2789-
* Assert that we kept all the nullingrels machinations straight.
2789+
* Verify that we kept all the nullingrels machinations straight.
27902790
*
27912791
* XXX we skip the check for system columns and whole-row Vars.
27922792
* That's because such Vars might be row identity Vars, which are
@@ -2799,12 +2799,16 @@ search_indexed_tlist_for_var(Var *var, indexed_tlist *itlist,
27992799
* columns, it seems unlikely that a bug in nullingrels logic
28002800
* would affect only system columns.)
28012801
*/
2802-
Assert(varattno <= 0 ||
2803-
(nrm_match == NRM_SUBSET ?
2804-
bms_is_subset(var->varnullingrels, vinfo->varnullingrels) :
2805-
nrm_match == NRM_SUPERSET ?
2806-
bms_is_subset(vinfo->varnullingrels, var->varnullingrels) :
2807-
bms_equal(vinfo->varnullingrels, var->varnullingrels)));
2802+
if (!(varattno <= 0 ||
2803+
(nrm_match == NRM_SUBSET ?
2804+
bms_is_subset(var->varnullingrels, vinfo->varnullingrels) :
2805+
nrm_match == NRM_SUPERSET ?
2806+
bms_is_subset(vinfo->varnullingrels, var->varnullingrels) :
2807+
bms_equal(vinfo->varnullingrels, var->varnullingrels))))
2808+
elog(ERROR, "wrong varnullingrels %s (expected %s) for Var %d/%d",
2809+
bmsToString(var->varnullingrels),
2810+
bmsToString(vinfo->varnullingrels),
2811+
varno, varattno);
28082812

28092813
newvar->varno = newvarno;
28102814
newvar->varattno = vinfo->resno;
@@ -2851,12 +2855,16 @@ search_indexed_tlist_for_phv(PlaceHolderVar *phv,
28512855
if (phv->phid != subphv->phid)
28522856
continue;
28532857

2854-
/* Assert that we kept all the nullingrels machinations straight */
2855-
Assert(nrm_match == NRM_SUBSET ?
2856-
bms_is_subset(phv->phnullingrels, subphv->phnullingrels) :
2857-
nrm_match == NRM_SUPERSET ?
2858-
bms_is_subset(subphv->phnullingrels, phv->phnullingrels) :
2859-
bms_equal(subphv->phnullingrels, phv->phnullingrels));
2858+
/* Verify that we kept all the nullingrels machinations straight */
2859+
if (!(nrm_match == NRM_SUBSET ?
2860+
bms_is_subset(phv->phnullingrels, subphv->phnullingrels) :
2861+
nrm_match == NRM_SUPERSET ?
2862+
bms_is_subset(subphv->phnullingrels, phv->phnullingrels) :
2863+
bms_equal(subphv->phnullingrels, phv->phnullingrels)))
2864+
elog(ERROR, "wrong phnullingrels %s (expected %s) for PlaceHolderVar %d",
2865+
bmsToString(phv->phnullingrels),
2866+
bmsToString(subphv->phnullingrels),
2867+
phv->phid);
28602868

28612869
/* Found a matching subplan output expression */
28622870
newvar = makeVarFromTargetEntry(newvarno, tle);

0 commit comments

Comments
 (0)