mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
Reformat code in ATPostAlterTypeParse.
The code in ATPostAlterTypeParse was very deeply indented, mostly because there were two nested switch-case statements, which add a lot of indentation. Use if-else blocks instead, to make the code less indented and more readable. This is in preparation for next patch that makes some actualy changes to the function. These cosmetic parts have been separated to make it easier to see the real changes in the other patch.
This commit is contained in:
parent
716f97f966
commit
1ab9faaecb
@ -8645,9 +8645,9 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
|
|||||||
Node *stm = (Node *) lfirst(list_item);
|
Node *stm = (Node *) lfirst(list_item);
|
||||||
AlteredTableInfo *tab;
|
AlteredTableInfo *tab;
|
||||||
|
|
||||||
switch (nodeTag(stm))
|
tab = ATGetQueueEntry(wqueue, rel);
|
||||||
{
|
|
||||||
case T_IndexStmt:
|
if (IsA(stm, IndexStmt))
|
||||||
{
|
{
|
||||||
IndexStmt *stmt = (IndexStmt *) stm;
|
IndexStmt *stmt = (IndexStmt *) stm;
|
||||||
AlterTableCmd *newcmd;
|
AlterTableCmd *newcmd;
|
||||||
@ -8655,38 +8655,39 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
|
|||||||
if (!rewrite)
|
if (!rewrite)
|
||||||
TryReuseIndex(oldId, stmt);
|
TryReuseIndex(oldId, stmt);
|
||||||
|
|
||||||
tab = ATGetQueueEntry(wqueue, rel);
|
|
||||||
newcmd = makeNode(AlterTableCmd);
|
newcmd = makeNode(AlterTableCmd);
|
||||||
newcmd->subtype = AT_ReAddIndex;
|
newcmd->subtype = AT_ReAddIndex;
|
||||||
newcmd->def = (Node *) stmt;
|
newcmd->def = (Node *) stmt;
|
||||||
tab->subcmds[AT_PASS_OLD_INDEX] =
|
tab->subcmds[AT_PASS_OLD_INDEX] =
|
||||||
lappend(tab->subcmds[AT_PASS_OLD_INDEX], newcmd);
|
lappend(tab->subcmds[AT_PASS_OLD_INDEX], newcmd);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case T_AlterTableStmt:
|
else if (IsA(stm, AlterTableStmt))
|
||||||
{
|
{
|
||||||
AlterTableStmt *stmt = (AlterTableStmt *) stm;
|
AlterTableStmt *stmt = (AlterTableStmt *) stm;
|
||||||
ListCell *lcmd;
|
ListCell *lcmd;
|
||||||
|
|
||||||
tab = ATGetQueueEntry(wqueue, rel);
|
|
||||||
foreach(lcmd, stmt->cmds)
|
foreach(lcmd, stmt->cmds)
|
||||||
{
|
{
|
||||||
AlterTableCmd *cmd = (AlterTableCmd *) lfirst(lcmd);
|
AlterTableCmd *cmd = (AlterTableCmd *) lfirst(lcmd);
|
||||||
Constraint *con;
|
|
||||||
|
|
||||||
switch (cmd->subtype)
|
if (cmd->subtype == AT_AddIndex)
|
||||||
{
|
{
|
||||||
case AT_AddIndex:
|
|
||||||
Assert(IsA(cmd->def, IndexStmt));
|
Assert(IsA(cmd->def, IndexStmt));
|
||||||
|
|
||||||
if (!rewrite)
|
if (!rewrite)
|
||||||
TryReuseIndex(get_constraint_index(oldId),
|
TryReuseIndex(get_constraint_index(oldId),
|
||||||
(IndexStmt *) cmd->def);
|
(IndexStmt *) cmd->def);
|
||||||
|
|
||||||
cmd->subtype = AT_ReAddIndex;
|
cmd->subtype = AT_ReAddIndex;
|
||||||
tab->subcmds[AT_PASS_OLD_INDEX] =
|
tab->subcmds[AT_PASS_OLD_INDEX] =
|
||||||
lappend(tab->subcmds[AT_PASS_OLD_INDEX], cmd);
|
lappend(tab->subcmds[AT_PASS_OLD_INDEX], cmd);
|
||||||
break;
|
}
|
||||||
case AT_AddConstraint:
|
else if (cmd->subtype == AT_AddConstraint)
|
||||||
|
{
|
||||||
|
Constraint *con;
|
||||||
|
|
||||||
Assert(IsA(cmd->def, Constraint));
|
Assert(IsA(cmd->def, Constraint));
|
||||||
|
|
||||||
con = (Constraint *) cmd->def;
|
con = (Constraint *) cmd->def;
|
||||||
con->old_pktable_oid = refRelId;
|
con->old_pktable_oid = refRelId;
|
||||||
/* rewriting neither side of a FK */
|
/* rewriting neither side of a FK */
|
||||||
@ -8696,19 +8697,16 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
|
|||||||
cmd->subtype = AT_ReAddConstraint;
|
cmd->subtype = AT_ReAddConstraint;
|
||||||
tab->subcmds[AT_PASS_OLD_CONSTR] =
|
tab->subcmds[AT_PASS_OLD_CONSTR] =
|
||||||
lappend(tab->subcmds[AT_PASS_OLD_CONSTR], cmd);
|
lappend(tab->subcmds[AT_PASS_OLD_CONSTR], cmd);
|
||||||
break;
|
}
|
||||||
default:
|
else
|
||||||
elog(ERROR, "unexpected statement type: %d",
|
elog(ERROR, "unexpected statement type: %d",
|
||||||
(int) cmd->subtype);
|
(int) cmd->subtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
else
|
||||||
}
|
|
||||||
default:
|
|
||||||
elog(ERROR, "unexpected statement type: %d",
|
elog(ERROR, "unexpected statement type: %d",
|
||||||
(int) nodeTag(stm));
|
(int) nodeTag(stm));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
relation_close(rel, NoLock);
|
relation_close(rel, NoLock);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user