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

Commit9bb842f

Browse files
author
Richard Guo
committed
Small code simplification
Apply the same code simplification to ATExecAddColumn as was done in7ff9afb: apply GETSTRUCT() once instead of doing it repeatedly inthe same function.Author: Tender WangDiscussion:https://postgr.es/m/CAHewXNkO9+U437jvKT14s0MCu6Qpf6G-p2mZK5J9mAi4cHDgpQ@mail.gmail.com
1 parent490f869 commit9bb842f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7028,6 +7028,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
70287028
Relationpgclass,
70297029
attrdesc;
70307030
HeapTuplereltup;
7031+
Form_pg_class relform;
70317032
Form_pg_attribute attribute;
70327033
intnewattnum;
70337034
charrelkind;
@@ -7161,10 +7162,11 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
71617162
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
71627163
if (!HeapTupleIsValid(reltup))
71637164
elog(ERROR, "cache lookup failed for relation %u", myrelid);
7164-
relkind = ((Form_pg_class) GETSTRUCT(reltup))->relkind;
7165+
relform = (Form_pg_class) GETSTRUCT(reltup);
7166+
relkind = relform->relkind;
71657167

71667168
/* Determine the new attribute's number */
7167-
newattnum =((Form_pg_class) GETSTRUCT(reltup))->relnatts + 1;
7169+
newattnum =relform->relnatts + 1;
71687170
if (newattnum > MaxHeapAttributeNumber)
71697171
ereport(ERROR,
71707172
(errcode(ERRCODE_TOO_MANY_COLUMNS),
@@ -7193,7 +7195,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
71937195
/*
71947196
* Update pg_class tuple as appropriate
71957197
*/
7196-
((Form_pg_class) GETSTRUCT(reltup))->relnatts = newattnum;
7198+
relform->relnatts = newattnum;
71977199

71987200
CatalogTupleUpdate(pgclass, &reltup->t_self, reltup);
71997201

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp