Skip to content

Commit cc121d5

Browse files
committed
Add comments for AlteredTableInfo->rel
The prior commit which introduced it was pretty squalid in terms of code documentation, so add some comments.
1 parent cd03c6e commit cc121d5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/backend/commands/tablecmds.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,16 @@ typedef struct AlteredTableInfo
157157
Oid relid; /* Relation to work on */
158158
char relkind; /* Its relkind */
159159
TupleDesc oldDesc; /* Pre-modification tuple descriptor */
160-
/* Transiently set during Phase 2, normally set to NULL */
160+
161+
/*
162+
* Transiently set during Phase 2, normally set to NULL.
163+
*
164+
* ATRewriteCatalogs sets this when it starts, and closes when ATExecCmd
165+
* returns control. This can be exploited by ATExecCmd subroutines to
166+
* close/reopen across transaction boundaries.
167+
*/
161168
Relation rel;
169+
162170
/* Information saved by Phase 1 for Phase 2: */
163171
List *subcmds[AT_NUM_PASSES]; /* Lists of AlterTableCmd */
164172
/* Information saved by Phases 1/2 for Phase 3: */
@@ -4577,7 +4585,9 @@ ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode,
45774585
continue;
45784586

45794587
/*
4580-
* Appropriate lock was obtained by phase 1, needn't get it again
4588+
* Open the relation and store it in tab. This allows subroutines
4589+
* close and reopen, if necessary. Appropriate lock was obtained
4590+
* by phase 1, needn't get it again.
45814591
*/
45824592
tab->rel = relation_open(tab->relid, NoLock);
45834593

0 commit comments

Comments
 (0)