set_deparse_plan: Reuse variable to appease Coverity
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 20 Apr 2022 09:44:08 +0000 (11:44 +0200)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 20 Apr 2022 09:44:08 +0000 (11:44 +0200)
Coverity complains that dpns->outer_plan is deferenced (to obtain
->targetlist) when possibly NULL.  We can avoid this by using
dpns->outer_tlist instead, which was already obtained a few lines up.

The fact that we end up with
  dpns->inner_tlist = dpns->outer_tlist
is a bit suspicious-looking and maybe worthy of more investigation, but
I'll leave that for another day.

Reviewed-by: Michaƫl Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/202204191345.qerjy3kxi3eb@alvherre.pgsql

src/backend/utils/adt/ruleutils.c

index 7e08d7fe6c2121ade56db9a7069ac57a9b8d1c83..5d49f564a2e14612c82460c62339467bd6d21f81 100644 (file)
@@ -4996,7 +4996,7 @@ set_deparse_plan(deparse_namespace *dpns, Plan *plan)
        if (IsA(plan, ModifyTable))
        {
                if (((ModifyTable *) plan)->operation == CMD_MERGE)
-                       dpns->inner_tlist = dpns->outer_plan->targetlist;
+                       dpns->inner_tlist = dpns->outer_tlist;
                else
                        dpns->inner_tlist = ((ModifyTable *) plan)->exclRelTlist;
        }