aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard Guo <rguo@postgresql.org>2024-08-22 11:41:08 +0900
committerRichard Guo <rguo@postgresql.org>2024-08-22 11:41:08 +0900
commit9bb842f95ef3384f0822c386a4c569780e613e4e (patch)
tree6df25395104d3b63388cf6a8fa7119e90cc36f6c /src
parent490f869d92e5db38731b85b9be3cffdc65461808 (diff)
downloadpostgresql-9bb842f95ef3384f0822c386a4c569780e613e4e.tar.gz
postgresql-9bb842f95ef3384f0822c386a4c569780e613e4e.zip
Small code simplification
Apply the same code simplification to ATExecAddColumn as was done in 7ff9afbbd: apply GETSTRUCT() once instead of doing it repeatedly in the same function. Author: Tender Wang Discussion: https://postgr.es/m/CAHewXNkO9+U437jvKT14s0MCu6Qpf6G-p2mZK5J9mAi4cHDgpQ@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/tablecmds.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index dfba5f357b8..13bb8811204 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -7028,6 +7028,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
Relation pgclass,
attrdesc;
HeapTuple reltup;
+ Form_pg_class relform;
Form_pg_attribute attribute;
int newattnum;
char relkind;
@@ -7161,10 +7162,11 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", myrelid);
- relkind = ((Form_pg_class) GETSTRUCT(reltup))->relkind;
+ relform = (Form_pg_class) GETSTRUCT(reltup);
+ relkind = relform->relkind;
/* Determine the new attribute's number */
- newattnum = ((Form_pg_class) GETSTRUCT(reltup))->relnatts + 1;
+ newattnum = relform->relnatts + 1;
if (newattnum > MaxHeapAttributeNumber)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_COLUMNS),
@@ -7193,7 +7195,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
/*
* Update pg_class tuple as appropriate
*/
- ((Form_pg_class) GETSTRUCT(reltup))->relnatts = newattnum;
+ relform->relnatts = newattnum;
CatalogTupleUpdate(pgclass, &reltup->t_self, reltup);