diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2023-05-17 10:50:35 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2023-05-17 11:14:04 -0400 |
commit | 867be9c0738bef591544d39985f886b7d8e99bf0 (patch) | |
tree | 443770587224eed89caf32812f15ad2c3b49d5f8 | |
parent | 1a05c1d252993b0a59c58a6daf91a2df9333044f (diff) | |
download | postgresql-867be9c0738bef591544d39985f886b7d8e99bf0.tar.gz |
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
-rw-r--r-- | src/backend/optimizer/plan/setrefs.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index f6f8a79354..a154c71a48 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -2786,7 +2786,7 @@ search_indexed_tlist_for_var(Var *var, indexed_tlist *itlist, Var *newvar = copyVar(var); /* - * Assert that we kept all the nullingrels machinations straight. + * Verify that we kept all the nullingrels machinations straight. * * XXX we skip the check for system columns and whole-row Vars. * 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, * columns, it seems unlikely that a bug in nullingrels logic * would affect only system columns.) */ - Assert(varattno <= 0 || - (nrm_match == NRM_SUBSET ? - bms_is_subset(var->varnullingrels, vinfo->varnullingrels) : - nrm_match == NRM_SUPERSET ? - bms_is_subset(vinfo->varnullingrels, var->varnullingrels) : - bms_equal(vinfo->varnullingrels, var->varnullingrels))); + if (!(varattno <= 0 || + (nrm_match == NRM_SUBSET ? + bms_is_subset(var->varnullingrels, vinfo->varnullingrels) : + nrm_match == NRM_SUPERSET ? + bms_is_subset(vinfo->varnullingrels, var->varnullingrels) : + bms_equal(vinfo->varnullingrels, var->varnullingrels)))) + elog(ERROR, "wrong varnullingrels %s (expected %s) for Var %d/%d", + bmsToString(var->varnullingrels), + bmsToString(vinfo->varnullingrels), + varno, varattno); newvar->varno = newvarno; newvar->varattno = vinfo->resno; @@ -2851,12 +2855,16 @@ search_indexed_tlist_for_phv(PlaceHolderVar *phv, if (phv->phid != subphv->phid) continue; - /* Assert that we kept all the nullingrels machinations straight */ - Assert(nrm_match == NRM_SUBSET ? - bms_is_subset(phv->phnullingrels, subphv->phnullingrels) : - nrm_match == NRM_SUPERSET ? - bms_is_subset(subphv->phnullingrels, phv->phnullingrels) : - bms_equal(subphv->phnullingrels, phv->phnullingrels)); + /* Verify that we kept all the nullingrels machinations straight */ + if (!(nrm_match == NRM_SUBSET ? + bms_is_subset(phv->phnullingrels, subphv->phnullingrels) : + nrm_match == NRM_SUPERSET ? + bms_is_subset(subphv->phnullingrels, phv->phnullingrels) : + bms_equal(subphv->phnullingrels, phv->phnullingrels))) + elog(ERROR, "wrong phnullingrels %s (expected %s) for PlaceHolderVar %d", + bmsToString(phv->phnullingrels), + bmsToString(subphv->phnullingrels), + phv->phid); /* Found a matching subplan output expression */ newvar = makeVarFromTargetEntry(newvarno, tle); |