Skip to content

Commit

Permalink
Suppress Coverity warnings about Asserts in get_name_for_var_field.
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit 16e67bc5f98f2f5691fb5c01d5a8310de1c62b81)
  • Loading branch information
tglsfdc authored and shardgupta committed Dec 6, 2024
1 parent 6025dba commit ffdeeba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/backend/utils/adt/ruleutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -7904,11 +7904,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)
Expand Down Expand Up @@ -8035,12 +8035,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)
Expand Down

0 comments on commit ffdeeba

Please sign in to comment.