Silence compiler warnings
authorJoe Conway <mail@joeconway.com>
Mon, 2 Jan 2017 22:12:04 +0000 (14:12 -0800)
committerJoe Conway <mail@joeconway.com>
Mon, 2 Jan 2017 22:12:04 +0000 (14:12 -0800)
In GetCachedPlan(), initialize 'plan' to silence a compiler warning, but
also add an Assert() to make sure we don't ever actually fall through
with 'plan' still being set to NULL, since we are about to dereference
it.

Back-patch back to 9.2.

Author: Stephen Frost
Discussion: https://postgr.es/m/20161129152102.GR13284%40tamriel.snowman.net

src/backend/utils/cache/plancache.c

index 5eefa74a61d84a6bb27d8344cbf9ff72660abad6..ca9ac23937c767a9b07ea7fbd0cd6dc23fa48565 100644 (file)
@@ -1125,7 +1125,7 @@ CachedPlan *
 GetCachedPlan(CachedPlanSource *plansource, ParamListInfo boundParams,
              bool useResOwner)
 {
-   CachedPlan *plan;
+   CachedPlan *plan = NULL;
    List       *qlist;
    bool        customplan;
 
@@ -1207,6 +1207,8 @@ GetCachedPlan(CachedPlanSource *plansource, ParamListInfo boundParams,
        }
    }
 
+   Assert(plan != NULL);
+
    /* Flag the plan as in use by caller */
    if (useResOwner)
        ResourceOwnerEnlargePlanCacheRefs(CurrentResourceOwner);