v3-0003-Inline-functions-that-have-now-become-trivial.patch
text/x-patch
Filename: v3-0003-Inline-functions-that-have-now-become-trivial.patch
Type: text/x-patch
Part: 2
From eded86a9b53aa33bf2269607d344d5264c663d16 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 v3 3/5] Inline functions that have now become trivial
---
src/backend/commands/prepare.c | 17 +++--------------
src/backend/commands/sequence.c | 16 +++-------------
src/backend/utils/cache/funccache.c | 22 ++++------------------
3 files changed, 10 insertions(+), 45 deletions(-)
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index 0002c6dc993..cc950ce2887 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -46,7 +46,6 @@
*/
static HTAB *prepared_queries = NULL;
-static void InitQueryHashTable(void);
static ParamListInfo EvaluateParams(ParseState *pstate,
PreparedStatement *pstmt, List *params,
EState *estate);
@@ -364,18 +363,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_cxt(PreparedStatement, stmt_name,
- "Prepared Queries", 32,
- TopMemoryContext);
-}
-
/*
* Store all the data pertaining to a query in the hash table using
* the specified key. The passed CachedPlanSource should be "unsaved"
@@ -393,7 +380,9 @@ StorePreparedStatement(const char *stmt_name,
/* Initialize the hash table, if necessary */
if (!prepared_queries)
- InitQueryHashTable();
+ prepared_queries = hash_make_cxt(PreparedStatement, stmt_name,
+ "Prepared Queries", 32,
+ 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 5fbb3ce9030..aa037901613 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);
@@ -1107,17 +1106,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_cxt(SeqTableData, relid,
- "Sequence values", 16,
- TopMemoryContext);
-}
-
/*
* Given a relation OID, open and lock the sequence. p_elm and p_rel are
* output parameters.
@@ -1131,7 +1119,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_cxt(SeqTableData, relid,
+ "Sequence values", 16,
+ 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 34438a9f93b..613fcfdc9f5 100644
--- a/src/backend/utils/cache/funccache.c
+++ b/src/backend/utils/cache/funccache.c
@@ -50,23 +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_fn_cxt(CachedFunctionHashEntry, key,
- "Cached function hash", FUNCS_PER_USER,
- cfunc_hash, cfunc_match,
- TopMemoryContext);
-}
-
/*
* cfunc_hash: hash function for cfunc hash table
*
@@ -165,7 +148,10 @@ cfunc_hashtable_insert(CachedFunction *function,
bool found;
if (cfunc_hashtable == NULL)
- cfunc_hashtable_init();
+ cfunc_hashtable = hash_make_fn_cxt(CachedFunctionHashEntry, key,
+ "Cached function hash", FUNCS_PER_USER,
+ cfunc_hash, cfunc_match,
+ TopMemoryContext);
hentry = (CachedFunctionHashEntry *) hash_search(cfunc_hashtable,
func_key,
--
2.52.0