summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/aggregatecmds.c4
-rw-r--r--src/backend/commands/analyze.c6
-rw-r--r--src/backend/commands/async.c8
-rw-r--r--src/backend/commands/collationcmds.c2
-rw-r--r--src/backend/commands/constraint.c2
-rw-r--r--src/backend/commands/copy.c12
-rw-r--r--src/backend/commands/createas.c5
-rw-r--r--src/backend/commands/dropcmds.c4
-rw-r--r--src/backend/commands/explain.c16
-rw-r--r--src/backend/commands/functioncmds.c7
-rw-r--r--src/backend/commands/matview.c3
-rw-r--r--src/backend/commands/opclasscmds.c9
-rw-r--r--src/backend/commands/tablecmds.c16
-rw-r--r--src/backend/commands/trigger.c4
-rw-r--r--src/backend/commands/user.c4
-rw-r--r--src/backend/commands/view.c3
16 files changed, 41 insertions, 64 deletions
diff --git a/src/backend/commands/aggregatecmds.c b/src/backend/commands/aggregatecmds.c
index 02ea254cd49..23411293518 100644
--- a/src/backend/commands/aggregatecmds.c
+++ b/src/backend/commands/aggregatecmds.c
@@ -109,13 +109,13 @@ DefineAggregate(ParseState *pstate, List *name, List *args, bool oldstyle, List
aggKind = AGGKIND_ORDERED_SET;
else
numDirectArgs = 0;
- args = (List *) linitial(args);
+ args = castNode(List, linitial(args));
}
/* Examine aggregate's definition clauses */
foreach(pl, parameters)
{
- DefElem *defel = (DefElem *) lfirst(pl);
+ DefElem *defel = castNode(DefElem, lfirst(pl));
/*
* sfunc1, stype1, and initcond1 are accepted as obsolete spellings
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index e3e1a530727..c9f6afeb1aa 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -722,9 +722,9 @@ compute_index_stats(Relation onerel, double totalrows,
econtext->ecxt_scantuple = slot;
/* Set up execution state for predicate. */
- predicate = (List *)
- ExecPrepareExpr((Expr *) indexInfo->ii_Predicate,
- estate);
+ predicate = castNode(List,
+ ExecPrepareExpr((Expr *) indexInfo->ii_Predicate,
+ estate));
/* Compute and save index expression values */
exprvals = (Datum *) palloc(numrows * attr_cnt * sizeof(Datum));
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 6d0ce7a3580..e32d7a1d4ec 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -1636,7 +1636,7 @@ AtSubCommit_Notify(void)
List *parentPendingActions;
List *parentPendingNotifies;
- parentPendingActions = (List *) linitial(upperPendingActions);
+ parentPendingActions = castNode(List, linitial(upperPendingActions));
upperPendingActions = list_delete_first(upperPendingActions);
Assert(list_length(upperPendingActions) ==
@@ -1647,7 +1647,7 @@ AtSubCommit_Notify(void)
*/
pendingActions = list_concat(parentPendingActions, pendingActions);
- parentPendingNotifies = (List *) linitial(upperPendingNotifies);
+ parentPendingNotifies = castNode(List, linitial(upperPendingNotifies));
upperPendingNotifies = list_delete_first(upperPendingNotifies);
Assert(list_length(upperPendingNotifies) ==
@@ -1679,13 +1679,13 @@ AtSubAbort_Notify(void)
*/
while (list_length(upperPendingActions) > my_level - 2)
{
- pendingActions = (List *) linitial(upperPendingActions);
+ pendingActions = castNode(List, linitial(upperPendingActions));
upperPendingActions = list_delete_first(upperPendingActions);
}
while (list_length(upperPendingNotifies) > my_level - 2)
{
- pendingNotifies = (List *) linitial(upperPendingNotifies);
+ pendingNotifies = castNode(List, linitial(upperPendingNotifies));
upperPendingNotifies = list_delete_first(upperPendingNotifies);
}
}
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index 8d4d5b7b63b..e165d4b2a6b 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -61,7 +61,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters)
foreach(pl, parameters)
{
- DefElem *defel = (DefElem *) lfirst(pl);
+ DefElem *defel = castNode(DefElem, lfirst(pl));
DefElem **defelp;
if (pg_strcasecmp(defel->defname, "from") == 0)
diff --git a/src/backend/commands/constraint.c b/src/backend/commands/constraint.c
index 77cf8ceee76..e9eeacd03a9 100644
--- a/src/backend/commands/constraint.c
+++ b/src/backend/commands/constraint.c
@@ -37,7 +37,7 @@
Datum
unique_key_recheck(PG_FUNCTION_ARGS)
{
- TriggerData *trigdata = (TriggerData *) fcinfo->context;
+ TriggerData *trigdata = castNode(TriggerData, fcinfo->context);
const char *funcname = "unique_key_recheck";
HeapTuple new_row;
ItemPointerData tmptid;
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index f9362be031a..949844d9791 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -1026,7 +1026,7 @@ ProcessCopyOptions(ParseState *pstate,
/* Extract options from the statement node tree */
foreach(option, options)
{
- DefElem *defel = (DefElem *) lfirst(option);
+ DefElem *defel = castNode(DefElem, lfirst(option));
if (strcmp(defel->defname, "format") == 0)
{
@@ -1139,7 +1139,7 @@ ProcessCopyOptions(ParseState *pstate,
errmsg("conflicting or redundant options"),
parser_errposition(pstate, defel->location)));
if (defel->arg && IsA(defel->arg, List))
- cstate->force_notnull = (List *) defel->arg;
+ cstate->force_notnull = castNode(List, defel->arg);
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@@ -1154,7 +1154,7 @@ ProcessCopyOptions(ParseState *pstate,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
if (defel->arg && IsA(defel->arg, List))
- cstate->force_null = (List *) defel->arg;
+ cstate->force_null = castNode(List, defel->arg);
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@@ -1176,7 +1176,7 @@ ProcessCopyOptions(ParseState *pstate,
parser_errposition(pstate, defel->location)));
cstate->convert_selectively = true;
if (defel->arg == NULL || IsA(defel->arg, List))
- cstate->convert_select = (List *) defel->arg;
+ cstate->convert_select = castNode(List, defel->arg);
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@@ -1479,7 +1479,7 @@ BeginCopy(ParseState *pstate,
/* examine queries to determine which error message to issue */
foreach(lc, rewritten)
{
- Query *q = (Query *) lfirst(lc);
+ Query *q = castNode(Query, lfirst(lc));
if (q->querySource == QSRC_QUAL_INSTEAD_RULE)
ereport(ERROR,
@@ -1496,7 +1496,7 @@ BeginCopy(ParseState *pstate,
errmsg("multi-statement DO INSTEAD rules are not supported for COPY")));
}
- query = (Query *) linitial(rewritten);
+ query = castNode(Query, linitial(rewritten));
/* The grammar allows SELECT INTO, but we don't support that */
if (query->utilityStmt != NULL &&
diff --git a/src/backend/commands/createas.c b/src/backend/commands/createas.c
index cee3b4d50b5..02cfcd182d0 100644
--- a/src/backend/commands/createas.c
+++ b/src/backend/commands/createas.c
@@ -224,7 +224,7 @@ ObjectAddress
ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
ParamListInfo params, char *completionTag)
{
- Query *query = (Query *) stmt->query;
+ Query *query = castNode(Query, stmt->query);
IntoClause *into = stmt->into;
bool is_matview = (into->viewQuery != NULL);
DestReceiver *dest;
@@ -261,11 +261,10 @@ ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
* The contained Query could be a SELECT, or an EXECUTE utility command.
* If the latter, we just pass it off to ExecuteQuery.
*/
- Assert(IsA(query, Query));
if (query->commandType == CMD_UTILITY &&
IsA(query->utilityStmt, ExecuteStmt))
{
- ExecuteStmt *estmt = (ExecuteStmt *) query->utilityStmt;
+ ExecuteStmt *estmt = castNode(ExecuteStmt, query->utilityStmt);
Assert(!is_matview); /* excluded by syntax */
ExecuteQuery(estmt, into, queryString, params, dest, completionTag);
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index 8cfbcf43f79..ff3108ce72b 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -222,12 +222,10 @@ type_in_list_does_not_exist_skipping(List *typenames, const char **msg,
foreach(l, typenames)
{
- TypeName *typeName = (TypeName *) lfirst(l);
+ TypeName *typeName = castNode(TypeName, lfirst(l));
if (typeName != NULL)
{
- Assert(IsA(typeName, TypeName));
-
if (!OidIsValid(LookupTypeNameOid(NULL, typeName, true)))
{
/* type doesn't exist, try to find why */
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index f9fb27658f7..5d61a0195ed 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -1493,25 +1493,25 @@ ExplainNode(PlanState *planstate, List *ancestors,
planstate, es);
break;
case T_Agg:
- show_agg_keys((AggState *) planstate, ancestors, es);
+ show_agg_keys(castNode(AggState, planstate), ancestors, es);
show_upper_qual(plan->qual, "Filter", planstate, ancestors, es);
if (plan->qual)
show_instrumentation_count("Rows Removed by Filter", 1,
planstate, es);
break;
case T_Group:
- show_group_keys((GroupState *) planstate, ancestors, es);
+ show_group_keys(castNode(GroupState, planstate), ancestors, es);
show_upper_qual(plan->qual, "Filter", planstate, ancestors, es);
if (plan->qual)
show_instrumentation_count("Rows Removed by Filter", 1,
planstate, es);
break;
case T_Sort:
- show_sort_keys((SortState *) planstate, ancestors, es);
- show_sort_info((SortState *) planstate, es);
+ show_sort_keys(castNode(SortState, planstate), ancestors, es);
+ show_sort_info(castNode(SortState, planstate), es);
break;
case T_MergeAppend:
- show_merge_append_keys((MergeAppendState *) planstate,
+ show_merge_append_keys(castNode(MergeAppendState, planstate),
ancestors, es);
break;
case T_Result:
@@ -1523,11 +1523,11 @@ ExplainNode(PlanState *planstate, List *ancestors,
planstate, es);
break;
case T_ModifyTable:
- show_modifytable_info((ModifyTableState *) planstate, ancestors,
+ show_modifytable_info(castNode(ModifyTableState, planstate), ancestors,
es);
break;
case T_Hash:
- show_hash_info((HashState *) planstate, es);
+ show_hash_info(castNode(HashState, planstate), es);
break;
default:
break;
@@ -2183,7 +2183,6 @@ show_tablesample(TableSampleClause *tsc, PlanState *planstate,
static void
show_sort_info(SortState *sortstate, ExplainState *es)
{
- Assert(IsA(sortstate, SortState));
if (es->analyze && sortstate->sort_Done &&
sortstate->tuplesortstate != NULL)
{
@@ -2217,7 +2216,6 @@ show_hash_info(HashState *hashstate, ExplainState *es)
{
HashJoinTable hashtable;
- Assert(IsA(hashstate, HashState));
hashtable = hashstate->hashtable;
if (hashtable)
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 22aecb24f92..ec833c382dc 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -578,9 +578,8 @@ update_proconfig_value(ArrayType *a, List *set_items)
foreach(l, set_items)
{
- VariableSetStmt *sstmt = (VariableSetStmt *) lfirst(l);
+ VariableSetStmt *sstmt = castNode(VariableSetStmt, lfirst(l));
- Assert(IsA(sstmt, VariableSetStmt));
if (sstmt->kind == VAR_RESET_ALL)
a = NULL;
else
@@ -971,9 +970,7 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
{
ListCell *lc;
- Assert(IsA(transformDefElem, List));
-
- foreach(lc, (List *) transformDefElem)
+ foreach(lc, castNode(List, transformDefElem))
{
Oid typeid = typenameTypeId(NULL, lfirst(lc));
Oid elt = get_base_element_type(typeid);
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index 6b5a9b6fe81..b7daf1ca0a0 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -264,8 +264,7 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
* The stored query was rewritten at the time of the MV definition, but
* has not been scribbled on by the planner.
*/
- dataQuery = (Query *) linitial(actions);
- Assert(IsA(dataQuery, Query));
+ dataQuery = castNode(Query, linitial(actions));
/*
* Check for active uses of the relation in the current transaction, such
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 7cfcc6de84a..bc43483b94a 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -462,13 +462,12 @@ DefineOpClass(CreateOpClassStmt *stmt)
*/
foreach(l, stmt->items)
{
- CreateOpClassItem *item = lfirst(l);
+ CreateOpClassItem *item = castNode(CreateOpClassItem, lfirst(l));
Oid operOid;
Oid funcOid;
Oid sortfamilyOid;
OpFamilyMember *member;
- Assert(IsA(item, CreateOpClassItem));
switch (item->itemtype)
{
case OPCLASS_ITEM_OPERATOR:
@@ -847,13 +846,12 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
*/
foreach(l, items)
{
- CreateOpClassItem *item = lfirst(l);
+ CreateOpClassItem *item = castNode(CreateOpClassItem, lfirst(l));
Oid operOid;
Oid funcOid;
Oid sortfamilyOid;
OpFamilyMember *member;
- Assert(IsA(item, CreateOpClassItem));
switch (item->itemtype)
{
case OPCLASS_ITEM_OPERATOR:
@@ -981,12 +979,11 @@ AlterOpFamilyDrop(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
*/
foreach(l, items)
{
- CreateOpClassItem *item = lfirst(l);
+ CreateOpClassItem *item = castNode(CreateOpClassItem, lfirst(l));
Oid lefttype,
righttype;
OpFamilyMember *member;
- Assert(IsA(item, CreateOpClassItem));
switch (item->itemtype)
{
case OPCLASS_ITEM_OPERATOR:
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index c4b0011bdd6..04b5d9a943c 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -5932,12 +5932,11 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options,
colName)));
/* Generate new proposed attoptions (text array) */
- Assert(IsA(options, List));
datum = SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions,
&isnull);
newOptions = transformRelOptions(isnull ? (Datum) 0 : datum,
- (List *) options, NULL, NULL, false,
- isReset);
+ castNode(List, options), NULL, NULL,
+ false, isReset);
/* Validate new options */
(void) attribute_reloptions(newOptions, true);
@@ -7141,8 +7140,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
bool found = false;
ObjectAddress address;
- Assert(IsA(cmd->def, Constraint));
- cmdcon = (Constraint *) cmd->def;
+ cmdcon = castNode(Constraint, cmd->def);
conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
@@ -9348,9 +9346,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
IndexStmt *indstmt;
Oid indoid;
- Assert(IsA(cmd->def, IndexStmt));
-
- indstmt = (IndexStmt *) cmd->def;
+ indstmt = castNode(IndexStmt, cmd->def);
indoid = get_constraint_index(oldId);
if (!rewrite)
@@ -9373,9 +9369,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
{
Constraint *con;
- Assert(IsA(cmd->def, Constraint));
-
- con = (Constraint *) cmd->def;
+ con = castNode(Constraint, cmd->def);
con->old_pktable_oid = refRelId;
/* rewriting neither side of a FK */
if (con->contype == CONSTR_FOREIGN &&
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 68fa7acfb17..f067d0a7bb9 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -340,9 +340,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
foreach(lc, varList)
{
- TriggerTransition *tt = (TriggerTransition *) lfirst(lc);
-
- Assert(IsA(tt, TriggerTransition));
+ TriggerTransition *tt = castNode(TriggerTransition, lfirst(lc));
if (!(tt->isTable))
ereport(ERROR,
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index e6fdac34aea..b746982d2ee 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -1396,11 +1396,9 @@ roleSpecsToIds(List *memberNames)
foreach(l, memberNames)
{
- RoleSpec *rolespec = (RoleSpec *) lfirst(l);
+ RoleSpec *rolespec = castNode(RoleSpec, lfirst(l));
Oid roleid;
- Assert(IsA(rolespec, RoleSpec));
-
roleid = get_rolespec_oid(rolespec, false);
result = lappend_oid(result, roleid);
}
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index 1f008b07566..7d76f567a8e 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -516,9 +516,8 @@ DefineView(ViewStmt *stmt, const char *queryString,
foreach(targetList, viewParse->targetList)
{
- TargetEntry *te = (TargetEntry *) lfirst(targetList);
+ TargetEntry *te = castNode(TargetEntry, lfirst(targetList));
- Assert(IsA(te, TargetEntry));
/* junk columns don't get aliases */
if (te->resjunk)
continue;