1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

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>
This commit is contained in:
Peter Eisentraut
2017-03-09 15:18:59 -05:00
parent 66b764341b
commit 4cb824699e
36 changed files with 178 additions and 92 deletions

View File

@@ -1412,11 +1412,11 @@ ReplaceVarsFromTargetList_callback(Var *var,
else
{
/* Make a copy of the tlist item to return */
Node *newnode = copyObject(tle->expr);
Expr *newnode = copyObject(tle->expr);
/* Must adjust varlevelsup if tlist item is from higher query */
if (var->varlevelsup > 0)
IncrementVarSublevelsUp(newnode, var->varlevelsup, 0);
IncrementVarSublevelsUp((Node *) newnode, var->varlevelsup, 0);
/*
* Check to see if the tlist item contains a PARAM_MULTIEXPR Param,
@@ -1428,12 +1428,12 @@ ReplaceVarsFromTargetList_callback(Var *var,
* create semantic oddities that users of rules would probably prefer
* not to cope with. So treat it as an unimplemented feature.
*/
if (contains_multiexpr_param(newnode, NULL))
if (contains_multiexpr_param((Node *) newnode, NULL))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("NEW variables in ON UPDATE rules cannot reference columns that are part of a multiple assignment in the subject UPDATE command")));
return newnode;
return (Node *) newnode;
}
}