summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/setrefs.c
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/optimizer/plan/setrefs.c
parent66b764341ba12206f01e2600713bdc3abdb070b3 (diff)
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/optimizer/plan/setrefs.c')
-rw-r--r--src/backend/optimizer/plan/setrefs.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c
index 5930747eba4..4e3f6ee960f 100644
--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -111,10 +111,10 @@ static Var *search_indexed_tlist_for_var(Var *var,
indexed_tlist *itlist,
Index newvarno,
int rtoffset);
-static Var *search_indexed_tlist_for_non_var(Node *node,
+static Var *search_indexed_tlist_for_non_var(Expr *node,
indexed_tlist *itlist,
Index newvarno);
-static Var *search_indexed_tlist_for_sortgroupref(Node *node,
+static Var *search_indexed_tlist_for_sortgroupref(Expr *node,
Index sortgroupref,
indexed_tlist *itlist,
Index newvarno);
@@ -1440,7 +1440,7 @@ fix_param_node(PlannerInfo *root, Param *p)
elog(ERROR, "unexpected PARAM_MULTIEXPR ID: %d", p->paramid);
return copyObject(list_nth(params, colno - 1));
}
- return copyObject(p);
+ return (Node *) copyObject(p);
}
/*
@@ -1727,7 +1727,7 @@ set_upper_references(PlannerInfo *root, Plan *plan, int rtoffset)
if (tle->ressortgroupref != 0 && !IsA(tle->expr, Var))
{
newexpr = (Node *)
- search_indexed_tlist_for_sortgroupref((Node *) tle->expr,
+ search_indexed_tlist_for_sortgroupref(tle->expr,
tle->ressortgroupref,
subplan_itlist,
OUTER_VAR);
@@ -1810,7 +1810,7 @@ convert_combining_aggrefs(Node *node, void *context)
*/
child_agg->args = NIL;
child_agg->aggfilter = NULL;
- parent_agg = (Aggref *) copyObject(child_agg);
+ parent_agg = copyObject(child_agg);
child_agg->args = orig_agg->args;
child_agg->aggfilter = orig_agg->aggfilter;
@@ -2054,7 +2054,7 @@ search_indexed_tlist_for_var(Var *var, indexed_tlist *itlist,
* so there's a correctness reason not to call it unless that's set.
*/
static Var *
-search_indexed_tlist_for_non_var(Node *node,
+search_indexed_tlist_for_non_var(Expr *node,
indexed_tlist *itlist, Index newvarno)
{
TargetEntry *tle;
@@ -2095,7 +2095,7 @@ search_indexed_tlist_for_non_var(Node *node,
* And it's also faster than search_indexed_tlist_for_non_var.
*/
static Var *
-search_indexed_tlist_for_sortgroupref(Node *node,
+search_indexed_tlist_for_sortgroupref(Expr *node,
Index sortgroupref,
indexed_tlist *itlist,
Index newvarno)
@@ -2229,7 +2229,7 @@ fix_join_expr_mutator(Node *node, fix_join_expr_context *context)
/* See if the PlaceHolderVar has bubbled up from a lower plan node */
if (context->outer_itlist && context->outer_itlist->has_ph_vars)
{
- newvar = search_indexed_tlist_for_non_var((Node *) phv,
+ newvar = search_indexed_tlist_for_non_var((Expr *) phv,
context->outer_itlist,
OUTER_VAR);
if (newvar)
@@ -2237,7 +2237,7 @@ fix_join_expr_mutator(Node *node, fix_join_expr_context *context)
}
if (context->inner_itlist && context->inner_itlist->has_ph_vars)
{
- newvar = search_indexed_tlist_for_non_var((Node *) phv,
+ newvar = search_indexed_tlist_for_non_var((Expr *) phv,
context->inner_itlist,
INNER_VAR);
if (newvar)
@@ -2252,7 +2252,7 @@ fix_join_expr_mutator(Node *node, fix_join_expr_context *context)
/* Try matching more complex expressions too, if tlists have any */
if (context->outer_itlist && context->outer_itlist->has_non_vars)
{
- newvar = search_indexed_tlist_for_non_var(node,
+ newvar = search_indexed_tlist_for_non_var((Expr *) node,
context->outer_itlist,
OUTER_VAR);
if (newvar)
@@ -2260,7 +2260,7 @@ fix_join_expr_mutator(Node *node, fix_join_expr_context *context)
}
if (context->inner_itlist && context->inner_itlist->has_non_vars)
{
- newvar = search_indexed_tlist_for_non_var(node,
+ newvar = search_indexed_tlist_for_non_var((Expr *) node,
context->inner_itlist,
INNER_VAR);
if (newvar)
@@ -2344,7 +2344,7 @@ fix_upper_expr_mutator(Node *node, fix_upper_expr_context *context)
/* See if the PlaceHolderVar has bubbled up from a lower plan node */
if (context->subplan_itlist->has_ph_vars)
{
- newvar = search_indexed_tlist_for_non_var((Node *) phv,
+ newvar = search_indexed_tlist_for_non_var((Expr *) phv,
context->subplan_itlist,
context->newvarno);
if (newvar)
@@ -2380,7 +2380,7 @@ fix_upper_expr_mutator(Node *node, fix_upper_expr_context *context)
/* Try matching more complex expressions too, if tlist has any */
if (context->subplan_itlist->has_non_vars)
{
- newvar = search_indexed_tlist_for_non_var(node,
+ newvar = search_indexed_tlist_for_non_var((Expr *) node,
context->subplan_itlist,
context->newvarno);
if (newvar)