mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +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:
@@ -1470,7 +1470,7 @@ BeginCopy(ParseState *pstate,
|
||||
* function and is executed repeatedly. (See also the same hack in
|
||||
* DECLARE CURSOR and PREPARE.) XXX FIXME someday.
|
||||
*/
|
||||
rewritten = pg_analyze_and_rewrite((RawStmt *) copyObject(raw_query),
|
||||
rewritten = pg_analyze_and_rewrite(copyObject(raw_query),
|
||||
pstate->p_sourcetext, NULL, 0);
|
||||
|
||||
/* check that we got back something we can work with */
|
||||
|
@@ -315,7 +315,7 @@ ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
|
||||
* and is executed repeatedly. (See also the same hack in EXPLAIN and
|
||||
* PREPARE.)
|
||||
*/
|
||||
rewritten = QueryRewrite((Query *) copyObject(query));
|
||||
rewritten = QueryRewrite(copyObject(query));
|
||||
|
||||
/* SELECT should never rewrite to more or less than one SELECT query */
|
||||
if (list_length(rewritten) != 1)
|
||||
|
@@ -1869,7 +1869,7 @@ EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt, Oid opfamoid,
|
||||
OperatorFamilyRelationId, opfamoid);
|
||||
command->d.opfam.operators = operators;
|
||||
command->d.opfam.procedures = procedures;
|
||||
command->parsetree = copyObject(stmt);
|
||||
command->parsetree = (Node *) copyObject(stmt);
|
||||
|
||||
currentEventTriggerState->commandList =
|
||||
lappend(currentEventTriggerState->commandList, command);
|
||||
@@ -1902,7 +1902,7 @@ EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt, Oid opcoid,
|
||||
OperatorClassRelationId, opcoid);
|
||||
command->d.createopc.operators = operators;
|
||||
command->d.createopc.procedures = procedures;
|
||||
command->parsetree = copyObject(stmt);
|
||||
command->parsetree = (Node *) copyObject(stmt);
|
||||
|
||||
currentEventTriggerState->commandList =
|
||||
lappend(currentEventTriggerState->commandList, command);
|
||||
@@ -1937,7 +1937,7 @@ EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt, Oid cfgId,
|
||||
command->d.atscfg.dictIds = palloc(sizeof(Oid) * ndicts);
|
||||
memcpy(command->d.atscfg.dictIds, dictIds, sizeof(Oid) * ndicts);
|
||||
command->d.atscfg.ndicts = ndicts;
|
||||
command->parsetree = copyObject(stmt);
|
||||
command->parsetree = (Node *) copyObject(stmt);
|
||||
|
||||
currentEventTriggerState->commandList =
|
||||
lappend(currentEventTriggerState->commandList, command);
|
||||
@@ -1967,7 +1967,7 @@ EventTriggerCollectAlterDefPrivs(AlterDefaultPrivilegesStmt *stmt)
|
||||
command->type = SCT_AlterDefaultPrivileges;
|
||||
command->d.defprivs.objtype = stmt->action->objtype;
|
||||
command->in_extension = creating_extension;
|
||||
command->parsetree = copyObject(stmt);
|
||||
command->parsetree = (Node *) copyObject(stmt);
|
||||
|
||||
currentEventTriggerState->commandList =
|
||||
lappend(currentEventTriggerState->commandList, command);
|
||||
|
@@ -352,7 +352,7 @@ EvaluateParams(PreparedStatement *pstmt, List *params,
|
||||
* We have to run parse analysis for the expressions. Since the parser is
|
||||
* not cool about scribbling on its input, copy first.
|
||||
*/
|
||||
params = (List *) copyObject(params);
|
||||
params = copyObject(params);
|
||||
|
||||
pstate = make_parsestate(NULL);
|
||||
pstate->p_sourcetext = queryString;
|
||||
@@ -554,7 +554,7 @@ FetchPreparedStatementTargetList(PreparedStatement *stmt)
|
||||
tlist = CachedPlanGetTargetList(stmt->plansource);
|
||||
|
||||
/* Copy into caller's context in case plan gets invalidated */
|
||||
return (List *) copyObject(tlist);
|
||||
return copyObject(tlist);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -373,7 +373,7 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
|
||||
* Var node twice. copyObject will expand any multiply-referenced subtree
|
||||
* into multiple copies.
|
||||
*/
|
||||
viewParse = (Query *) copyObject(viewParse);
|
||||
viewParse = copyObject(viewParse);
|
||||
|
||||
/* Create a dummy ParseState for addRangeTableEntryForRelation */
|
||||
pstate = make_parsestate(NULL);
|
||||
|
Reference in New Issue
Block a user