summaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2025-10-22 11:36:26 +1300
committerDavid Rowley <drowley@postgresql.org>2025-10-22 11:36:26 +1300
commit2470ca435c452fe4def9dcc4a831b5101691d541 (patch)
treea8b9fc7ecd1e7dbdf3816f112a4350f4219a5975 /src/backend/access
parentfba60a1b107df425ec9676b8cf759830a70def03 (diff)
Use CompactAttribute more often, when possible
5983a4cff added CompactAttribute for storing commonly used fields from FormData_pg_attribute. 5983a4cff didn't go to the trouble of adjusting every location where we can use CompactAttribute rather than FormData_pg_attribute, so here we change the remaining ones. There are some locations where I've left the code using FormData_pg_attribute. These are mostly in the ALTER TABLE code. Using CompactAttribute here seems more risky as often the TupleDesc is being changed and those changes may not have been flushed to the CompactAttribute yet. I've also left record_recv(), record_send(), record_cmp(), record_eq() and record_image_eq() alone as it's not clear to me that accessing the CompactAttribute is a win here due to the FormData_pg_attribute still having to be accessed for most cases. Switching the relevant parts to use CompactAttribute would result in having to access both for common cases. Careful benchmarking may reveal that something can be done to make this better, but in absence of that, the safer option is to leave these alone. In ReorderBufferToastReplace(), there was a check to skip attnums < 0 while looping over the TupleDesc. Doing this is redundant since TupleDescs don't store < 0 attnums. Removing that code allows us to move to using CompactAttribute. The change in validateDomainCheckConstraint() just moves fetching the FormData_pg_attribute into the ERROR path, which is cold due to calling errstart_cold() and results in code being moved out of the common path. Author: David Rowley <dgrowleyml@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CAApHDvrMy90o1Lgkt31F82tcSuwRFHq3vyGewSRN=-QuSEEvyQ@mail.gmail.com
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/gin/gininsert.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c
index 1d3ab22556d..3d71b442aa9 100644
--- a/src/backend/access/gin/gininsert.c
+++ b/src/backend/access/gin/gininsert.c
@@ -499,7 +499,7 @@ ginFlushBuildState(GinBuildState *buildstate, Relation index)
&attnum, &key, &category, &nlist)) != NULL)
{
/* information about the key */
- Form_pg_attribute attr = TupleDescAttr(tdesc, (attnum - 1));
+ CompactAttribute *attr = TupleDescCompactAttr(tdesc, (attnum - 1));
/* GIN tuple and tuple length */
GinTuple *tup;