From: Tom Lane Date: Sun, 11 Aug 2024 16:24:56 +0000 (-0400) Subject: Suppress Coverity warnings about Asserts in get_name_for_var_field. X-Git-Tag: REL_16_5~121 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=9db6650a5a66d75234a155b20e18c8dfd7e9c22b;p=postgresql.git Suppress Coverity warnings about Asserts in get_name_for_var_field. Coverity thinks dpns->plan could be null at these points. That shouldn't really be possible, but it's easy enough to modify the Asserts so they'd not core-dump if it were true. These are new in b919a97a6. Back-patch to v13; the v12 version of the patch didn't have these Asserts. --- diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 1168b5ba6c3..59c1bc94835 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -7858,11 +7858,11 @@ get_name_for_var_field(Var *var, int fieldno, { char *dummy_name = palloc(32); - Assert(IsA(dpns->plan, Result)); + Assert(dpns->plan && IsA(dpns->plan, Result)); snprintf(dummy_name, 32, "f%d", fieldno); return dummy_name; } - Assert(IsA(dpns->plan, SubqueryScan)); + Assert(dpns->plan && IsA(dpns->plan, SubqueryScan)); tle = get_tle_by_resno(dpns->inner_tlist, attnum); if (!tle) @@ -7989,12 +7989,12 @@ get_name_for_var_field(Var *var, int fieldno, { char *dummy_name = palloc(32); - Assert(IsA(dpns->plan, Result)); + Assert(dpns->plan && IsA(dpns->plan, Result)); snprintf(dummy_name, 32, "f%d", fieldno); return dummy_name; } - Assert(IsA(dpns->plan, CteScan) || - IsA(dpns->plan, WorkTableScan)); + Assert(dpns->plan && (IsA(dpns->plan, CteScan) || + IsA(dpns->plan, WorkTableScan))); tle = get_tle_by_resno(dpns->inner_tlist, attnum); if (!tle)