From d4702da898f2c1cbf277a8a3b3fbc8a60b614b67 Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <postgres@jeltef.nl>
Date: Wed, 3 Dec 2025 23:33:18 +0100
Subject: [PATCH v1 6/6] Inline functions that have now become trivial

The refactor in the previous commit made some functions trivial, this
inlines those.
---
 src/backend/commands/prepare.c      | 17 +++--------------
 src/backend/commands/sequence.c     | 16 +++-------------
 src/backend/utils/cache/funccache.c | 24 +++++-------------------
 3 files changed, 11 insertions(+), 46 deletions(-)

diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index 6817d7f3461..005321abc48 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -48,7 +48,6 @@
  */
 static HTAB *prepared_queries = NULL;
 
-static void InitQueryHashTable(void);
 static ParamListInfo EvaluateParams(ParseState *pstate,
 									PreparedStatement *pstmt, List *params,
 									EState *estate);
@@ -366,18 +365,6 @@ EvaluateParams(ParseState *pstate, PreparedStatement *pstmt, List *params,
 	return paramLI;
 }
 
-
-/*
- * Initialize query hash table upon first use.
- */
-static void
-InitQueryHashTable(void)
-{
-	prepared_queries = hash_make(PreparedStatement, stmt_name,
-								 "Prepared Queries", 32,
-								 .mcxt = TopMemoryContext);
-}
-
 /*
  * Store all the data pertaining to a query in the hash table using
  * the specified key.  The passed CachedPlanSource should be "unsaved"
@@ -395,7 +382,9 @@ StorePreparedStatement(const char *stmt_name,
 
 	/* Initialize the hash table, if necessary */
 	if (!prepared_queries)
-		InitQueryHashTable();
+		prepared_queries = hash_make(PreparedStatement, stmt_name,
+									"Prepared Queries", 32,
+									.mcxt = TopMemoryContext);
 
 	/* Add entry to hash table */
 	entry = (PreparedStatement *) hash_search(prepared_queries,
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index bbd7d2805e6..4b36cebc879 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -89,7 +89,6 @@ static SeqTableData *last_used_seq = NULL;
 static void fill_seq_with_data(Relation rel, HeapTuple tuple);
 static void fill_seq_fork_with_data(Relation rel, HeapTuple tuple, ForkNumber forkNum);
 static Relation lock_and_open_sequence(SeqTable seq);
-static void create_seq_hashtable(void);
 static void init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel);
 static Form_pg_sequence_data read_seq_tuple(Relation rel,
 											Buffer *buf, HeapTuple seqdatatuple);
@@ -1119,17 +1118,6 @@ lock_and_open_sequence(SeqTable seq)
 	return sequence_open(seq->relid, NoLock);
 }
 
-/*
- * Creates the hash table for storing sequence data
- */
-static void
-create_seq_hashtable(void)
-{
-	seqhashtab = hash_make(SeqTableData, relid,
-						   "Sequence values", 16,
-						   .mcxt = TopMemoryContext);
-}
-
 /*
  * Given a relation OID, open and lock the sequence.  p_elm and p_rel are
  * output parameters.
@@ -1143,7 +1131,9 @@ init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel)
 
 	/* Find or create a hash table entry for this sequence */
 	if (seqhashtab == NULL)
-		create_seq_hashtable();
+		seqhashtab = hash_make(SeqTableData, relid,
+							"Sequence values", 16,
+							.mcxt = TopMemoryContext);
 
 	elm = (SeqTable) hash_search(seqhashtab, &relid, HASH_ENTER, &found);
 
diff --git a/src/backend/utils/cache/funccache.c b/src/backend/utils/cache/funccache.c
index 4d4dcf9f2c9..55edf3d6a48 100644
--- a/src/backend/utils/cache/funccache.c
+++ b/src/backend/utils/cache/funccache.c
@@ -50,24 +50,6 @@ static uint32 cfunc_hash(const void *key, Size keysize);
 static int	cfunc_match(const void *key1, const void *key2, Size keysize);
 
 
-/*
- * Initialize the hash table on first use.
- *
- * The hash table will be in TopMemoryContext regardless of caller's context.
- */
-static void
-cfunc_hashtable_init(void)
-{
-	/* don't allow double-initialization */
-	Assert(cfunc_hashtable == NULL);
-
-	cfunc_hashtable = hash_make(CachedFunctionHashEntry, key,
-								"Cached function hash", FUNCS_PER_USER,
-								.hash = cfunc_hash,
-								.match = cfunc_match,
-								.mcxt = TopMemoryContext);
-}
-
 /*
  * cfunc_hash: hash function for cfunc hash table
  *
@@ -166,7 +148,11 @@ cfunc_hashtable_insert(CachedFunction *function,
 	bool		found;
 
 	if (cfunc_hashtable == NULL)
-		cfunc_hashtable_init();
+		cfunc_hashtable = hash_make(CachedFunctionHashEntry, key,
+									"Cached function hash", FUNCS_PER_USER,
+									.hash = cfunc_hash,
+									.match = cfunc_match,
+									.mcxt = TopMemoryContext);
 
 	hentry = (CachedFunctionHashEntry *) hash_search(cfunc_hashtable,
 													 func_key,
-- 
2.56.1

