aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-03-09 15:18:59 -0500
committerPeter Eisentraut <peter_e@gmx.net>2017-03-28 21:59:23 -0400
commit4cb824699e12c39fad97fb3d9085ced0d14c067c (patch)
tree9a835d8efb7739e6436d3fc24b4b5a290b95df7d /src/backend/utils/cache
parent66b764341ba12206f01e2600713bdc3abdb070b3 (diff)
downloadpostgresql-4cb824699e12c39fad97fb3d9085ced0d14c067c.tar.gz
postgresql-4cb824699e12c39fad97fb3d9085ced0d14c067c.zip
Cast result of copyObject() to correct type
copyObject() is declared to return void *, which allows easily assigning the result independent of the input, but it loses all type checking. If the compiler supports typeof or something similar, cast the result to the input type. This creates a greater amount of type safety. In some cases, where the result is assigned to a generic type such as Node * or Expr *, new casts are now necessary, but in general casts are now unnecessary in the normal case and indicate that something unusual is happening. Reviewed-by: Mark Dilger <hornschnorter@gmail.com>
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r--src/backend/utils/cache/plancache.c14
-rw-r--r--src/backend/utils/cache/relcache.c8
2 files changed, 11 insertions, 11 deletions
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c
index d284ab7d3df..043085d3a76 100644
--- a/src/backend/utils/cache/plancache.c
+++ b/src/backend/utils/cache/plancache.c
@@ -361,7 +361,7 @@ CompleteCachedPlan(CachedPlanSource *plansource,
"CachedPlanQuery",
ALLOCSET_START_SMALL_SIZES);
MemoryContextSwitchTo(querytree_context);
- querytree_list = (List *) copyObject(querytree_list);
+ querytree_list = copyObject(querytree_list);
}
plansource->query_context = querytree_context;
@@ -734,7 +734,7 @@ RevalidateCachedQuery(CachedPlanSource *plansource)
ALLOCSET_START_SMALL_SIZES);
oldcxt = MemoryContextSwitchTo(querytree_context);
- qlist = (List *) copyObject(tlist);
+ qlist = copyObject(tlist);
/*
* Use the planner machinery to extract dependencies. Data is saved in
@@ -909,7 +909,7 @@ BuildCachedPlan(CachedPlanSource *plansource, List *qlist,
if (qlist == NIL)
{
if (!plansource->is_oneshot)
- qlist = (List *) copyObject(plansource->query_list);
+ qlist = copyObject(plansource->query_list);
else
qlist = plansource->query_list;
}
@@ -953,7 +953,7 @@ BuildCachedPlan(CachedPlanSource *plansource, List *qlist,
*/
MemoryContextSwitchTo(plan_context);
- plist = (List *) copyObject(plist);
+ plist = copyObject(plist);
}
else
plan_context = CurrentMemoryContext;
@@ -1367,9 +1367,9 @@ CopyCachedPlan(CachedPlanSource *plansource)
"CachedPlanQuery",
ALLOCSET_START_SMALL_SIZES);
MemoryContextSwitchTo(querytree_context);
- newsource->query_list = (List *) copyObject(plansource->query_list);
- newsource->relationOids = (List *) copyObject(plansource->relationOids);
- newsource->invalItems = (List *) copyObject(plansource->invalItems);
+ newsource->query_list = copyObject(plansource->query_list);
+ newsource->relationOids = copyObject(plansource->relationOids);
+ newsource->invalItems = copyObject(plansource->invalItems);
if (plansource->search_path)
newsource->search_path = CopyOverrideSearchPath(plansource->search_path);
newsource->query_context = querytree_context;
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index bc52183bfb0..bc220989a15 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4697,7 +4697,7 @@ RelationGetIndexExpressions(Relation relation)
/* Quick exit if we already computed the result. */
if (relation->rd_indexprs)
- return (List *) copyObject(relation->rd_indexprs);
+ return copyObject(relation->rd_indexprs);
/* Quick exit if there is nothing to do. */
if (relation->rd_indextuple == NULL ||
@@ -4733,7 +4733,7 @@ RelationGetIndexExpressions(Relation relation)
/* Now save a copy of the completed tree in the relcache entry. */
oldcxt = MemoryContextSwitchTo(relation->rd_indexcxt);
- relation->rd_indexprs = (List *) copyObject(result);
+ relation->rd_indexprs = copyObject(result);
MemoryContextSwitchTo(oldcxt);
return result;
@@ -4760,7 +4760,7 @@ RelationGetIndexPredicate(Relation relation)
/* Quick exit if we already computed the result. */
if (relation->rd_indpred)
- return (List *) copyObject(relation->rd_indpred);
+ return copyObject(relation->rd_indpred);
/* Quick exit if there is nothing to do. */
if (relation->rd_indextuple == NULL ||
@@ -4802,7 +4802,7 @@ RelationGetIndexPredicate(Relation relation)
/* Now save a copy of the completed tree in the relcache entry. */
oldcxt = MemoryContextSwitchTo(relation->rd_indexcxt);
- relation->rd_indpred = (List *) copyObject(result);
+ relation->rd_indpred = copyObject(result);
MemoryContextSwitchTo(oldcxt);
return result;