mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
Make more use of castNode()
This commit is contained in:
@ -543,8 +543,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
|
||||
|
||||
foreach(clist, column->constraints)
|
||||
{
|
||||
constraint = lfirst(clist);
|
||||
Assert(IsA(constraint, Constraint));
|
||||
constraint = castNode(Constraint, lfirst(clist));
|
||||
|
||||
switch (constraint->contype)
|
||||
{
|
||||
@ -1520,9 +1519,8 @@ transformIndexConstraints(CreateStmtContext *cxt)
|
||||
*/
|
||||
foreach(lc, cxt->ixconstraints)
|
||||
{
|
||||
Constraint *constraint = (Constraint *) lfirst(lc);
|
||||
Constraint *constraint = castNode(Constraint, lfirst(lc));
|
||||
|
||||
Assert(IsA(constraint, Constraint));
|
||||
Assert(constraint->contype == CONSTR_PRIMARY ||
|
||||
constraint->contype == CONSTR_UNIQUE ||
|
||||
constraint->contype == CONSTR_EXCLUSION);
|
||||
@ -1842,10 +1840,8 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
||||
List *opname;
|
||||
|
||||
Assert(list_length(pair) == 2);
|
||||
elem = (IndexElem *) linitial(pair);
|
||||
Assert(IsA(elem, IndexElem));
|
||||
opname = (List *) lsecond(pair);
|
||||
Assert(IsA(opname, List));
|
||||
elem = castNode(IndexElem, linitial(pair));
|
||||
opname = castNode(List, lsecond(pair));
|
||||
|
||||
index->indexParams = lappend(index->indexParams, elem);
|
||||
index->excludeOpNames = lappend(index->excludeOpNames, opname);
|
||||
@ -1872,8 +1868,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
||||
|
||||
foreach(columns, cxt->columns)
|
||||
{
|
||||
column = (ColumnDef *) lfirst(columns);
|
||||
Assert(IsA(column, ColumnDef));
|
||||
column = castNode(ColumnDef, lfirst(columns));
|
||||
if (strcmp(column->colname, key) == 0)
|
||||
{
|
||||
found = true;
|
||||
@ -1902,11 +1897,10 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
||||
|
||||
foreach(inher, cxt->inhRelations)
|
||||
{
|
||||
RangeVar *inh = (RangeVar *) lfirst(inher);
|
||||
RangeVar *inh = castNode(RangeVar, lfirst(inher));
|
||||
Relation rel;
|
||||
int count;
|
||||
|
||||
Assert(IsA(inh, RangeVar));
|
||||
rel = heap_openrv(inh, AccessShareLock);
|
||||
/* check user requested inheritance from valid relkind */
|
||||
if (rel->rd_rel->relkind != RELKIND_RELATION &&
|
||||
@ -2586,9 +2580,8 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
case AT_AddColumn:
|
||||
case AT_AddColumnToView:
|
||||
{
|
||||
ColumnDef *def = (ColumnDef *) cmd->def;
|
||||
ColumnDef *def = castNode(ColumnDef, cmd->def);
|
||||
|
||||
Assert(IsA(def, ColumnDef));
|
||||
transformColumnDefinition(&cxt, def);
|
||||
|
||||
/*
|
||||
@ -2693,9 +2686,8 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
*/
|
||||
foreach(l, cxt.alist)
|
||||
{
|
||||
IndexStmt *idxstmt = (IndexStmt *) lfirst(l);
|
||||
IndexStmt *idxstmt = castNode(IndexStmt, lfirst(l));
|
||||
|
||||
Assert(IsA(idxstmt, IndexStmt));
|
||||
idxstmt = transformIndexStmt(relid, idxstmt, queryString);
|
||||
newcmd = makeNode(AlterTableCmd);
|
||||
newcmd->subtype = OidIsValid(idxstmt->indexOid) ? AT_AddIndexConstraint : AT_AddIndex;
|
||||
|
Reference in New Issue
Block a user