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:
@@ -349,8 +349,8 @@ rewriteRuleAction(Query *parsetree,
|
||||
* Make modifiable copies of rule action and qual (what we're passed are
|
||||
* the stored versions in the relcache; don't touch 'em!).
|
||||
*/
|
||||
rule_action = (Query *) copyObject(rule_action);
|
||||
rule_qual = (Node *) copyObject(rule_qual);
|
||||
rule_action = copyObject(rule_action);
|
||||
rule_qual = copyObject(rule_qual);
|
||||
|
||||
/*
|
||||
* Acquire necessary locks and fix any deleted JOIN RTE entries.
|
||||
@@ -408,7 +408,7 @@ rewriteRuleAction(Query *parsetree,
|
||||
* that rule action's rtable is separate and shares no substructure with
|
||||
* the main rtable. Hence do a deep copy here.
|
||||
*/
|
||||
sub_action->rtable = list_concat((List *) copyObject(parsetree->rtable),
|
||||
sub_action->rtable = list_concat(copyObject(parsetree->rtable),
|
||||
sub_action->rtable);
|
||||
|
||||
/*
|
||||
@@ -1897,7 +1897,7 @@ CopyAndAddInvertedQual(Query *parsetree,
|
||||
CmdType event)
|
||||
{
|
||||
/* Don't scribble on the passed qual (it's in the relcache!) */
|
||||
Node *new_qual = (Node *) copyObject(rule_qual);
|
||||
Node *new_qual = copyObject(rule_qual);
|
||||
acquireLocksOnSubLinks_context context;
|
||||
|
||||
context.for_execute = true;
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user