static List *find_typed_table_dependencies(Oid typeOid, const char *typeName,
DropBehavior behavior);
static void ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
- AlterTableCmd *cmd, LOCKMODE lockmode);
+ bool is_view, AlterTableCmd *cmd, LOCKMODE lockmode);
static void ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
ColumnDef *colDef, bool isOid,
bool recurse, bool recursing, LOCKMODE lockmode);
case AT_AddColumn: /* ADD COLUMN */
ATSimplePermissions(rel,
ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
- ATPrepAddColumn(wqueue, rel, recurse, recursing, cmd, lockmode);
+ ATPrepAddColumn(wqueue, rel, recurse, recursing, false, cmd,
+ lockmode);
/* Recursion occurs during execution phase */
pass = AT_PASS_ADD_COL;
break;
case AT_AddColumnToView: /* add column via CREATE OR REPLACE
* VIEW */
ATSimplePermissions(rel, ATT_VIEW);
- ATPrepAddColumn(wqueue, rel, recurse, recursing, cmd, lockmode);
+ ATPrepAddColumn(wqueue, rel, recurse, recursing, true, cmd,
+ lockmode);
/* Recursion occurs during execution phase */
pass = AT_PASS_ADD_COL;
break;
*/
static void
ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
- AlterTableCmd *cmd, LOCKMODE lockmode)
+ bool is_view, AlterTableCmd *cmd, LOCKMODE lockmode)
{
if (rel->rd_rel->reloftype && !recursing)
ereport(ERROR,
if (rel->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
ATTypedTableRecursion(wqueue, rel, cmd, lockmode);
- if (recurse)
+ if (recurse && !is_view)
cmd->subtype = AT_AddColumnRecurse;
}
cdef->location = -1;
cmd->def = (Node *) cdef;
}
- ATPrepAddColumn(wqueue, rel, recurse, false, cmd, lockmode);
+ ATPrepAddColumn(wqueue, rel, recurse, false, false, cmd, lockmode);
if (recurse)
cmd->subtype = AT_AddOidsRecurse;