8000 adapt shared_ispell for upcoming PostgreSQL 15 · postgrespro/shared_ispell@64b5868 · GitHub
[go: up one dir, main page]

Skip to content

Commit 64b5868

Browse files
ashutosh108Anton Voloshin
authored andcommitted
adapt shared_ispell for upcoming PostgreSQL 15
1. Only call RequestAddinShmemSpace and RequestNamedLWLockTranche from within our implementation of shmem_request_hook (as required after commit 4f2400cb3 in PostgreSQL 15). 2. While we are here, remove _PG_fini, as it is now officially dead after commit ab02d702e in PostgreSQL 15.
1 parent be08627 commit 64b5868

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/shared_ispell.c

Lines changed: 19 additions & 15 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@
6666
PG_MODULE_MAGIC;
6767

6868
void _PG_init(void);
69-
void _PG_fini(void);
7069

7170
/* Memory for dictionaries in kbytes */
7271
static int max_ispell_mem_size_kb;
7372

74-
/* Saved hook values in case of unload */
73+
/* Saved hook value for proper chaining */
7574
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
7675

7776
/* These are used to allocate data within shared segment */
@@ -97,6 +96,11 @@ max_ispell_mem_size()
9796
return (Size) max_ispell_mem_size_kb * 1024L;
9897
}
9998

99+
#if (PG_VERSION_NUM >= 150000)
100+
static shmem_request_hook_type prev_shmem_request_hook = NULL;
101+
static void shared_ispell_shmem_request(void);
102+
#endif
103+
100104
/*
101105
* Module load callback
102106
*/
@@ -127,33 +131,33 @@ _PG_init(void)
127131

128132
EmitWarningsOnPlaceholders("shared_ispell");
129133

130-
/*
131-
* Request additional shared resources. (These are no-ops if we're not in
132-
* the postmaster process.) We'll allocate or attach to the shared
133-
* resources in ispell_shmem_startup().
134-
*/
134+
#if PG_VERSION_NUM >= 150000
135+
prev_shmem_request_hook = shmem_request_hook;
136+
shmem_request_hook = shared_ispell_shmem_request;
137+
#else
135138
RequestAddinShmemSpace(max_ispell_mem_size());
136139

137140
#if PG_VERSION_NUM >= 90600
138141
RequestNamedLWLockTranche("shared_ispell", 1);
139142
#else
140143
RequestAddinLWLocks(1);
144+
#endif
141145
#endif
142146

143147
/* Install hooks. */
144148
prev_shmem_startup_hook = shmem_startup_hook;
145149
shmem_startup_hook = ispell_shmem_startup;
146150
}
147151

148-
149-
/*
150-
* Module unload callback
151-
*/
152-
void
153-
_PG_fini(void)
152+
static void
153+
shared_ispell_shmem_request(void)
154154
{
155-
/* Uninstall hooks. */
156-
shmem_startup_hook = prev_shmem_startup_hook;
155+
if (prev_shmem_request_hook)
156+
prev_shmem_request_hook();
157+
158+
RequestAddinShmemSpace(max_ispell_mem_size());
159+
160+
RequestNamedLWLockTranche("shared_ispell", 1);
157161
}
158162

159163
/*

0 commit comments

Comments
 (0)
0