]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Shorten pg_attribute_always_inline to pg_always_inline
authorTomas Vondra <tomas.vondra@postgresql.org>
Sat, 11 Jul 2026 13:14:50 +0000 (15:14 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Sat, 11 Jul 2026 14:17:58 +0000 (16:17 +0200)
The pg_attribute_always_inline macro name is so long it forces pgindent
to format the code in strange ways. Which may incentivize patch authors
to either structure the code in strange ways (e.g. reorder prototypes),
use shorter names, etc. Neither is very desirable for code readability.

This shortens the name by removing the _attribute_ part. It also makes
it more consistent with pg_noinline, which does not have the _attribute_
part either.

Backpatched to all supported branches, to prevent conflicts when
backpatching other fixes. The backbranches however keep both the old and
new macro name, so that existing code keeps working.

Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/bqqdehahpoa36igpictuqyn2s2mexk3t3ehidh2ffd2slb35e5@rzgksuiszgbg
Backpatch-through: 14

13 files changed:
src/backend/access/heap/heapam.c
src/backend/access/transam/xlog.c
src/backend/commands/copyfromparse.c
src/backend/commands/copyto.c
src/backend/executor/execExprInterp.c
src/backend/executor/execTuples.c
src/backend/executor/nodeHashjoin.c
src/backend/nodes/queryjumblefuncs.c
src/backend/storage/buffer/bufmgr.c
src/backend/utils/adt/json.c
src/backend/utils/cache/catcache.c
src/include/c.h
src/include/executor/execScan.h

index 6203e3d7f8d0e2b051a5139b5dee85ee3798ed73..aff02cb003e8c8f021088d624c8759ac23e14b86 100644 (file)
@@ -500,7 +500,7 @@ heap_setscanlimits(TableScanDesc sscan, BlockNumber startBlk, BlockNumber numBlk
  * multiple times, with constant arguments for all_visible,
  * check_serializable.
  */
-pg_attribute_always_inline
+pg_always_inline
 static int
 page_collect_tuples(HeapScanDesc scan, Snapshot snapshot,
                                        Page page, Buffer buffer,
index e07cb9103515f02a1c156ea2e544bf21f164657f..2fd06e379996b4e0912361810777534b42a3cbb4 100644 (file)
@@ -1105,9 +1105,9 @@ XLogInsertRecord(XLogRecData *rdata,
  *
  * NB: Testing shows that XLogInsertRecord runs faster if this code is inlined;
  * however, because there are two call sites, the compiler is reluctant to
- * inline. We use pg_attribute_always_inline here to try to convince it.
+ * inline. We use pg_always_inline here to try to convince it.
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 ReserveXLogInsertLocation(int size, XLogRecPtr *StartPos, XLogRecPtr *EndPos,
                                                  XLogRecPtr *PrevPtr)
 {
index f5fc346e2013bb2332a7521d203eeb1a0ec2f920..fedaf78ba5e9b1b41b5a1777cdabf1fa6f42e66a 100644 (file)
@@ -147,15 +147,15 @@ static int        CopyReadAttributesCSV(CopyFromState cstate);
 static Datum CopyReadBinaryAttribute(CopyFromState cstate, FmgrInfo *flinfo,
                                                                         Oid typioparam, int32 typmod,
                                                                         bool *isnull);
-static pg_attribute_always_inline bool CopyFromTextLikeOneRow(CopyFromState cstate,
-                                                                                                                         ExprContext *econtext,
-                                                                                                                         Datum *values,
-                                                                                                                         bool *nulls,
-                                                                                                                         bool is_csv);
-static pg_attribute_always_inline bool NextCopyFromRawFieldsInternal(CopyFromState cstate,
-                                                                                                                                        char ***fields,
-                                                                                                                                        int *nfields,
-                                                                                                                                        bool is_csv);
+static pg_always_inline bool CopyFromTextLikeOneRow(CopyFromState cstate,
+                                                                                                       ExprContext *econtext,
+                                                                                                       Datum *values,
+                                                                                                       bool *nulls,
+                                                                                                       bool is_csv);
+static pg_always_inline bool NextCopyFromRawFieldsInternal(CopyFromState cstate,
+                                                                                                                  char ***fields,
+                                                                                                                  int *nfields,
+                                                                                                                  bool is_csv);
 
 
 /* Low-level communications functions */
@@ -763,11 +763,11 @@ NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields)
  *
  * NOTE: force_not_null option are not applied to the returned fields.
  *
- * We use pg_attribute_always_inline to reduce function call overhead
+ * We use pg_always_inline to reduce function call overhead
  * and to help compilers to optimize away the 'is_csv' condition when called
  * by internal functions such as CopyFromTextLikeOneRow().
  */
-static pg_attribute_always_inline bool
+static pg_always_inline bool
 NextCopyFromRawFieldsInternal(CopyFromState cstate, char ***fields, int *nfields, bool is_csv)
 {
        int                     fldct;
@@ -930,10 +930,10 @@ CopyFromCSVOneRow(CopyFromState cstate, ExprContext *econtext, Datum *values,
 /*
  * Workhorse for CopyFromTextOneRow() and CopyFromCSVOneRow().
  *
- * We use pg_attribute_always_inline to reduce function call overhead
+ * We use pg_always_inline to reduce function call overhead
  * and to help compilers to optimize away the 'is_csv' condition.
  */
-static pg_attribute_always_inline bool
+static pg_always_inline bool
 CopyFromTextLikeOneRow(CopyFromState cstate, ExprContext *econtext,
                                           Datum *values, bool *nulls, bool is_csv)
 {
index ea6f18f2c80085cb4e70533af18ac359c20c2741..307366e5ead408d97e044cbdc4fe42310a278613 100644 (file)
@@ -257,10 +257,10 @@ CopyToCSVOneRow(CopyToState cstate, TupleTableSlot *slot)
 /*
  * Workhorse for CopyToTextOneRow() and CopyToCSVOneRow().
  *
- * We use pg_attribute_always_inline to reduce function call overhead
+ * We use pg_always_inline to reduce function call overhead
  * and to help compilers to optimize away the 'is_csv' condition.
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 CopyToTextLikeOneRow(CopyToState cstate,
                                         TupleTableSlot *slot,
                                         bool is_csv)
index e5d8345de54fee29846292153333d490efed0620..f6093f36afaf2f6c93da1bee8d67c474141ca6ee 100644 (file)
@@ -176,24 +176,24 @@ static Datum ExecJustHashInnerVarVirt(ExprState *state, ExprContext *econtext, b
 static Datum ExecJustHashOuterVarStrict(ExprState *state, ExprContext *econtext, bool *isnull);
 
 /* execution helper functions */
-static pg_attribute_always_inline void ExecEvalArrayCompareInternal(FunctionCallInfo fcinfo,
-                                                                                                                                       ArrayType *arr,
-                                                                                                                                       int16 typlen,
-                                                                                                                                       bool typbyval,
-                                                                                                                                       char typalign,
-                                                                                                                                       bool useOr,
-                                                                                                                                       Datum *result,
-                                                                                                                                       bool *resultnull);
-static pg_attribute_always_inline void ExecAggPlainTransByVal(AggState *aggstate,
-                                                                                                                         AggStatePerTrans pertrans,
-                                                                                                                         AggStatePerGroup pergroup,
-                                                                                                                         ExprContext *aggcontext,
-                                                                                                                         int setno);
-static pg_attribute_always_inline void ExecAggPlainTransByRef(AggState *aggstate,
-                                                                                                                         AggStatePerTrans pertrans,
-                                                                                                                         AggStatePerGroup pergroup,
-                                                                                                                         ExprContext *aggcontext,
-                                                                                                                         int setno);
+static pg_always_inline void ExecEvalArrayCompareInternal(FunctionCallInfo fcinfo,
+                                                                                                                 ArrayType *arr,
+                                                                                                                 int16 typlen,
+                                                                                                                 bool typbyval,
+                                                                                                                 char typalign,
+                                                                                                                 bool useOr,
+                                                                                                                 Datum *result,
+                                                                                                                 bool *resultnull);
+static pg_always_inline void ExecAggPlainTransByVal(AggState *aggstate,
+                                                                                                       AggStatePerTrans pertrans,
+                                                                                                       AggStatePerGroup pergroup,
+                                                                                                       ExprContext *aggcontext,
+                                                                                                       int setno);
+static pg_always_inline void ExecAggPlainTransByRef(AggState *aggstate,
+                                                                                                       AggStatePerTrans pertrans,
+                                                                                                       AggStatePerGroup pergroup,
+                                                                                                       ExprContext *aggcontext,
+                                                                                                       int setno);
 static char *ExecGetJsonValueItemString(JsonbValue *item, bool *resnull);
 
 /*
@@ -2550,7 +2550,7 @@ get_cached_rowtype(Oid type_id, int32 typmod,
  */
 
 /* implementation of ExecJust(Inner|Outer|Scan)Var */
-static pg_attribute_always_inline Datum
+static pg_always_inline Datum
 ExecJustVarImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
 {
        ExprEvalStep *op = &state->steps[1];
@@ -2588,7 +2588,7 @@ ExecJustScanVar(ExprState *state, ExprContext *econtext, bool *isnull)
 }
 
 /* implementation of ExecJustAssign(Inner|Outer|Scan)Var */
-static pg_attribute_always_inline Datum
+static pg_always_inline Datum
 ExecJustAssignVarImpl(ExprState *state, TupleTableSlot *inslot, bool *isnull)
 {
        ExprEvalStep *op = &state->steps[1];
@@ -2683,7 +2683,7 @@ ExecJustConst(ExprState *state, ExprContext *econtext, bool *isnull)
 }
 
 /* implementation of ExecJust(Inner|Outer|Scan)VarVirt */
-static pg_attribute_always_inline Datum
+static pg_always_inline Datum
 ExecJustVarVirtImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
 {
        ExprEvalStep *op = &state->steps[0];
@@ -2726,7 +2726,7 @@ ExecJustScanVarVirt(ExprState *state, ExprContext *econtext, bool *isnull)
 }
 
 /* implementation of ExecJustAssign(Inner|Outer|Scan)VarVirt */
-static pg_attribute_always_inline Datum
+static pg_always_inline Datum
 ExecJustAssignVarVirtImpl(ExprState *state, TupleTableSlot *inslot, bool *isnull)
 {
        ExprEvalStep *op = &state->steps[0];
@@ -2805,7 +2805,7 @@ ExecJustHashInnerVarWithIV(ExprState *state, ExprContext *econtext,
 }
 
 /* implementation of ExecJustHash(Inner|Outer)Var */
-static pg_attribute_always_inline Datum
+static pg_always_inline Datum
 ExecJustHashVarImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
 {
        ExprEvalStep *fetchop = &state->steps[0];
@@ -2843,7 +2843,7 @@ ExecJustHashInnerVar(ExprState *state, ExprContext *econtext, bool *isnull)
 }
 
 /* implementation of ExecJustHash(Inner|Outer)VarVirt */
-static pg_attribute_always_inline Datum
+static pg_always_inline Datum
 ExecJustHashVarVirtImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
 {
        ExprEvalStep *var = &state->steps[0];
@@ -4105,7 +4105,7 @@ ExecEvalScalarArrayOp(ExprState *state, ExprEvalStep *op)
  * Callers must handle the strict LHS-is-NULL; return NULL fast path prior to
  * calling this.
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 ExecEvalArrayCompareInternal(FunctionCallInfo fcinfo, ArrayType *arr,
                                                         int16 typlen, bool typbyval, char typalign,
                                                         bool useOr, Datum *result, bool *resultnull)
@@ -5903,7 +5903,7 @@ ExecEvalAggOrderedTransTuple(ExprState *state, ExprEvalStep *op,
 }
 
 /* implementation of transition function invocation for byval types */
-static pg_attribute_always_inline void
+static pg_always_inline void
 ExecAggPlainTransByVal(AggState *aggstate, AggStatePerTrans pertrans,
                                           AggStatePerGroup pergroup,
                                           ExprContext *aggcontext, int setno)
@@ -5935,7 +5935,7 @@ ExecAggPlainTransByVal(AggState *aggstate, AggStatePerTrans pertrans,
 }
 
 /* implementation of transition function invocation for byref types */
-static pg_attribute_always_inline void
+static pg_always_inline void
 ExecAggPlainTransByRef(AggState *aggstate, AggStatePerTrans pertrans,
                                           AggStatePerGroup pergroup,
                                           ExprContext *aggcontext, int setno)
index 8e02d68824fad80a2c39b926a37547c9e5bcc7ba..ebe32b411a5da0b8ff6424819921a9bd081409c0 100644 (file)
@@ -72,8 +72,8 @@
 
 static TupleDesc ExecTypeFromTLInternal(List *targetList,
                                                                                bool skipjunk);
-static pg_attribute_always_inline void slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
-                                                                                                                         int natts);
+static pg_always_inline void slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
+                                                                                                       int natts);
 static inline void tts_buffer_heap_store_tuple(TupleTableSlot *slot,
                                                                                           HeapTuple tuple,
                                                                                           Buffer buffer,
@@ -1118,7 +1118,7 @@ slot_deform_heap_tuple_internal(TupleTableSlot *slot, HeapTuple tuple,
  * This is marked as always inline, so the different offp for different types
  * of slots gets optimized away.
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
                                           int natts)
 {
index 5661ad768300422ddefac06a9ae5b79a5e5d06c4..039d43ea54112634a5d08968a7f5504baaf7c68d 100644 (file)
@@ -217,7 +217,7 @@ static void ExecParallelHashJoinPartitionOuter(HashJoinState *hjstate);
  *                       the other one is "outer".
  * ----------------------------------------------------------------
  */
-static pg_attribute_always_inline TupleTableSlot *
+static pg_always_inline TupleTableSlot *
 ExecHashJoinImpl(PlanState *pstate, bool parallel)
 {
        HashJoinState *node = castNode(HashJoinState, pstate);
index 31f971519772d5266e8bb51937b3c66d4bff6cc4..3ce073beb537df7899525ab7a18d580315bf5a07 100644 (file)
@@ -230,7 +230,7 @@ DoJumble(JumbleState *jstate, Node *node)
  *
  * Note: Callers must ensure that size > 0.
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 AppendJumbleInternal(JumbleState *jstate, const unsigned char *item,
                                         Size size)
 {
@@ -306,7 +306,7 @@ AppendJumble(JumbleState *jstate, const unsigned char *value, Size size)
  * AppendJumbleNull
  *             For jumbling NULL pointers
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 AppendJumbleNull(JumbleState *jstate)
 {
        jstate->pending_nulls++;
@@ -373,7 +373,7 @@ AppendJumble64(JumbleState *jstate, const unsigned char *value)
  *
  * Note: Callers must ensure that there's at least 1 pending NULL.
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 FlushPendingNulls(JumbleState *jstate)
 {
        Assert(jstate->pending_nulls > 0);
index a5b4bc5b7d58bdee18e78e5dc69f0c39b9b2d233..9a771c81cb14210d95a760146c863c0bc99bd0c8 100644 (file)
@@ -1097,7 +1097,7 @@ ZeroAndLockBuffer(Buffer buffer, ReadBufferMode mode, bool already_valid)
  * already present, or false if more work is required to either read it in or
  * zero it.
  */
-static pg_attribute_always_inline Buffer
+static pg_always_inline Buffer
 PinBufferForBlock(Relation rel,
                                  SMgrRelation smgr,
                                  char persistence,
@@ -1180,7 +1180,7 @@ PinBufferForBlock(Relation rel,
  *
  * smgr is required, rel is optional unless using P_NEW.
  */
-static pg_attribute_always_inline Buffer
+static pg_always_inline Buffer
 ReadBuffer_common(Relation rel, SMgrRelation smgr, char smgr_persistence,
                                  ForkNumber forkNum,
                                  BlockNumber blockNum, ReadBufferMode mode,
@@ -1261,7 +1261,7 @@ ReadBuffer_common(Relation rel, SMgrRelation smgr, char smgr_persistence,
        return buffer;
 }
 
-static pg_attribute_always_inline bool
+static pg_always_inline bool
 StartReadBuffersImpl(ReadBuffersOperation *operation,
                                         Buffer *buffers,
                                         BlockNumber blockNum,
@@ -2005,7 +2005,7 @@ AsyncReadBuffers(ReadBuffersOperation *operation, int *nblocks_progress)
  *
  * No locks are held either at entry or exit.
  */
-static pg_attribute_always_inline BufferDesc *
+static pg_always_inline BufferDesc *
 BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
                        BlockNumber blockNum,
                        BufferAccessStrategy strategy,
@@ -6803,7 +6803,7 @@ EvictRelUnpinnedBuffers(Relation rel, int32 *buffers_evicted,
  * part of error handling, which in turn could lead to the buffer being
  * replaced while IO is ongoing.
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 buffer_stage_common(PgAioHandle *ioh, bool is_write, bool is_temp)
 {
        uint64     *io_data;
@@ -7049,7 +7049,7 @@ buffer_readv_encode_error(PgAioResult *result,
  * Helper for AIO readv completion callbacks, supporting both shared and temp
  * buffers. Gets called once for each buffer in a multi-page read.
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 buffer_readv_complete_one(PgAioTargetData *td, uint8 buf_off, Buffer buffer,
                                                  uint8 flags, bool failed, bool is_temp,
                                                  bool *buffer_invalid,
@@ -7193,7 +7193,7 @@ buffer_readv_complete_one(PgAioTargetData *td, uint8 buf_off, Buffer buffer,
  *
  * Shared between shared and local buffers, to reduce code duplication.
  */
-static pg_attribute_always_inline PgAioResult
+static pg_always_inline PgAioResult
 buffer_readv_complete(PgAioHandle *ioh, PgAioResult prior_result,
                                          uint8 cb_data, bool is_temp)
 {
index 51452755f5868bc8a9c0f04c8555779672de9a0f..c1d3de602ae7f516f968dcc4c7ee9458aebd0378 100644 (file)
@@ -1558,7 +1558,7 @@ json_object_two_arg(PG_FUNCTION_ARGS)
  * escape_json_char
  *             Inline helper function for escape_json* functions
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 escape_json_char(StringInfo buf, char c)
 {
        switch (c)
index c1bca66a09274788215e23d3a02c5cc583ec0519..a2253e5209e8d759207b11343d96b565a2781a88 100644 (file)
@@ -1070,7 +1070,7 @@ RehashCatCacheLists(CatCache *cp)
  *
  * Call CatalogCacheInitializeCache() if not yet done.
  */
-pg_attribute_always_inline
+pg_always_inline
 static void
 ConditionalCatalogCacheInitializeCache(CatCache *cache)
 {
index 508c007cedd3f200f286a4932d6f598924306bec..ae9dbaf22f3abbd1b580120ac5bee3a2dd6fa6ca 100644 (file)
 #endif
 
 /*
- * Use "pg_attribute_always_inline" in place of "inline" for functions that
+ * Use "pg_always_inline" in place of "inline" for functions that
  * we wish to force inlining of, even when the compiler's heuristics would
  * choose not to.  But, if possible, don't force inlining in unoptimized
  * debug builds.
+ *
+ * XXX The "pg_attribute_always_inline" variant is kept for backwards
+ * compatibility with existing code. All new code should use the shorter
+ * variant "pg_always_inline."
  */
 #if (defined(__GNUC__) && __GNUC__ > 3 && defined(__OPTIMIZE__)) || defined(__SUNPRO_C)
 /* GCC > 3 and Sunpro support always_inline via __attribute__ */
+#define pg_always_inline __attribute__((always_inline)) inline
 #define pg_attribute_always_inline __attribute__((always_inline)) inline
 #elif defined(_MSC_VER)
 /* MSVC has a special keyword for this */
+#define pg_always_inline __forceinline
 #define pg_attribute_always_inline __forceinline
 #else
 /* Otherwise, the best we can do is to say "inline" */
+#define pg_always_inline inline
 #define pg_attribute_always_inline inline
 #endif
 
index 2003cbc7ed562cb0f9fefe9376d8a9e83c3a4502..2a66639eed4e039628048e5275fe65ad08996977 100644 (file)
  * This routine substitutes a test tuple if inside an EvalPlanQual recheck.
  * Otherwise, it simply executes the access method's next-tuple routine.
  *
- * The pg_attribute_always_inline attribute allows the compiler to inline
- * this function into its caller. When EPQState is NULL, the EvalPlanQual
- * logic is completely eliminated at compile time, avoiding unnecessary
- * run-time checks and code for cases where EPQ is not required.
+ * The pg_always_inline attribute allows the compiler to inline this function
+ * into its caller. When EPQState is NULL, the EvalPlanQual logic is completely
+ * eliminated at compile time, avoiding unnecessary run-time checks and code
+ * for cases where EPQ is not required.
  */
-static pg_attribute_always_inline TupleTableSlot *
+static pg_always_inline TupleTableSlot *
 ExecScanFetch(ScanState *node,
                          EPQState *epqstate,
                          ExecScanAccessMtd accessMtd,
@@ -144,9 +144,9 @@ ExecScanFetch(ScanState *node,
  * conditions enforced by the access method.
  *
  * This function is an alternative to ExecScan, used when callers may omit
- * 'qual' or 'projInfo'. The pg_attribute_always_inline attribute allows the
- * compiler to eliminate non-relevant branches at compile time, avoiding
- * run-time checks in those cases.
+ * 'qual' or 'projInfo'. The pg_always_inline attribute allows the compiler
+ * to eliminate non-relevant branches at compile time, avoiding run-time
+ * checks in those cases.
  *
  * Conditions:
  *     -- The AMI "cursor" is positioned at the previously returned tuple.
@@ -156,7 +156,7 @@ ExecScanFetch(ScanState *node,
  *     positioned before the first qualifying tuple.
  * ----------------------------------------------------------------
  */
-static pg_attribute_always_inline TupleTableSlot *
+static pg_always_inline TupleTableSlot *
 ExecScanExtended(ScanState *node,
                                 ExecScanAccessMtd accessMtd,   /* function returning a tuple */
                                 ExecScanRecheckMtd recheckMtd,