]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Suppress Coverity warnings about Asserts in get_name_for_var_field.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 11 Aug 2024 16:24:56 +0000 (12:24 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 11 Aug 2024 16:24:56 +0000 (12:24 -0400)
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.

src/backend/utils/adt/ruleutils.c

index 97716991b86a5465c40554edbf953e8fe7431e4e..0191858bd68b050f218415fe94a61e896327b615 100644 (file)
@@ -7298,11 +7298,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)
@@ -7426,11 +7426,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, CteScan));
+                                       Assert(dpns->plan && IsA(dpns->plan, CteScan));
 
                                        tle = get_tle_by_resno(dpns->inner_tlist, attnum);
                                        if (!tle)