Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfbef434

Browse files
committed
Make CREATE OR REPLACE VIEW internally more consistent
The way that columns are added to a view is by callingAlterTableInternal with special subtype AT_AddColumnToView; but thatsubtype is changed to AT_AddColumnRecurse by ATPrepAddColumn. This hasno visible effect in the current code, since views cannot haveinheritance children (thus the recursion step is a no-op) and adding acolumn to a view is executed identically to doing it to a table; but itdoes make a difference for future event trigger code keeping track ofcommands, because the current situation leads to confusing the case witha normal ALTER TABLE ADD COLUMN.Fix the problem by passing a flag to ATPrepAddColumn to prevent it fromchanging the command subtype. The event trigger code can then properlyignore the subcommand. (We could remove the call to ATPrepAddColumn,since views are never typed, and there is never a need for recursion,which are the two conditions that are checked by ATPrepAddColumn; but itseems more future-proof to keep the call in place.)
1 parentf65e827 commitfbef434

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ static void ATTypedTableRecursion(List **wqueue, Relation rel, AlterTableCmd *cm
325325
staticList*find_typed_table_dependencies(OidtypeOid,constchar*typeName,
326326
DropBehaviorbehavior);
327327
staticvoidATPrepAddColumn(List**wqueue,Relationrel,boolrecurse,boolrecursing,
328-
AlterTableCmd*cmd,LOCKMODElockmode);
328+
boolis_view,AlterTableCmd*cmd,LOCKMODElockmode);
329329
staticvoidATExecAddColumn(List**wqueue,AlteredTableInfo*tab,Relationrel,
330330
ColumnDef*colDef,boolisOid,
331331
boolrecurse,boolrecursing,LOCKMODElockmode);
@@ -3085,14 +3085,16 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
30853085
caseAT_AddColumn:/* ADD COLUMN */
30863086
ATSimplePermissions(rel,
30873087
ATT_TABLE |ATT_COMPOSITE_TYPE |ATT_FOREIGN_TABLE);
3088-
ATPrepAddColumn(wqueue,rel,recurse,recursing,cmd,lockmode);
3088+
ATPrepAddColumn(wqueue,rel,recurse,recursing, false,cmd,
3089+
lockmode);
30893090
/* Recursion occurs during execution phase */
30903091
pass=AT_PASS_ADD_COL;
30913092
break;
30923093
caseAT_AddColumnToView:/* add column via CREATE OR REPLACE
30933094
* VIEW */
30943095
ATSimplePermissions(rel,ATT_VIEW);
3095-
ATPrepAddColumn(wqueue,rel,recurse,recursing,cmd,lockmode);
3096+
ATPrepAddColumn(wqueue,rel,recurse,recursing, true,cmd,
3097+
lockmode);
30963098
/* Recursion occurs during execution phase */
30973099
pass=AT_PASS_ADD_COL;
30983100
break;
@@ -4576,7 +4578,7 @@ check_of_type(HeapTuple typetuple)
45764578
*/
45774579
staticvoid
45784580
ATPrepAddColumn(List**wqueue,Relationrel,boolrecurse,boolrecursing,
4579-
AlterTableCmd*cmd,LOCKMODElockmode)
4581+
boolis_view,AlterTableCmd*cmd,LOCKMODElockmode)
45804582
{
45814583
if (rel->rd_rel->reloftype&& !recursing)
45824584
ereport(ERROR,
@@ -4586,7 +4588,7 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
45864588
if (rel->rd_rel->relkind==RELKIND_COMPOSITE_TYPE)
45874589
ATTypedTableRecursion(wqueue,rel,cmd,lockmode);
45884590

4589-
if (recurse)
4591+
if (recurse&& !is_view)
45904592
cmd->subtype=AT_AddColumnRecurse;
45914593
}
45924594

@@ -5026,7 +5028,7 @@ ATPrepAddOids(List **wqueue, Relation rel, bool recurse, AlterTableCmd *cmd, LOC
50265028
cdef->location=-1;
50275029
cmd->def= (Node*)cdef;
50285030
}
5029-
ATPrepAddColumn(wqueue,rel,recurse, false,cmd,lockmode);
5031+
ATPrepAddColumn(wqueue,rel,recurse, false,false,cmd,lockmode);
50305032

50315033
if (recurse)
50325034
cmd->subtype=AT_AddOidsRecurse;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp