Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita9ed7d9

Browse files
committed
Fix search_path cache initialization.
The cache needs to be available very early, so don't rely onInitializeSearchPath() to initialize the it.Reported-by: Murat EfendioğluDiscussion:https://postgr.es/m/CACbCzujQ4zS8MM1bx-==+tr+D3Hk5G1cjN4XkUQ+Q=cEpwhzqg@mail.gmail.comBackpatch-through: 17
1 parentc3b80a7 commita9ed7d9

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

‎src/backend/catalog/namespace.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,32 @@ static SearchPathCacheEntry *LastSearchPathCacheEntry = NULL;
305305
staticvoid
306306
spcache_init(void)
307307
{
308-
Assert(SearchPathCacheContext);
309-
310308
if (SearchPathCache&&searchPathCacheValid&&
311309
SearchPathCache->members<SPCACHE_RESET_THRESHOLD)
312310
return;
313311

314-
/* make sure we don't leave dangling pointers if nsphash_create fails */
312+
searchPathCacheValid= false;
313+
baseSearchPathValid= false;
314+
315+
/*
316+
* Make sure we don't leave dangling pointers if a failure happens during
317+
* initialization.
318+
*/
315319
SearchPathCache=NULL;
316320
LastSearchPathCacheEntry=NULL;
317321

318-
MemoryContextReset(SearchPathCacheContext);
322+
if (SearchPathCacheContext==NULL)
323+
{
324+
/* Make the context we'll keep search path cache hashtable in */
325+
SearchPathCacheContext=AllocSetContextCreate(TopMemoryContext,
326+
"search_path processing cache",
327+
ALLOCSET_DEFAULT_SIZES);
328+
}
329+
else
330+
{
331+
MemoryContextReset(SearchPathCacheContext);
332+
}
333+
319334
/* arbitrary initial starting size of 16 elements */
320335
SearchPathCache=nsphash_create(SearchPathCacheContext,16,NULL);
321336
searchPathCacheValid= true;
@@ -4742,11 +4757,6 @@ InitializeSearchPath(void)
47424757
}
47434758
else
47444759
{
4745-
/* Make the context we'll keep search path cache hashtable in */
4746-
SearchPathCacheContext=AllocSetContextCreate(TopMemoryContext,
4747-
"search_path processing cache",
4748-
ALLOCSET_DEFAULT_SIZES);
4749-
47504760
/*
47514761
* In normal mode, arrange for a callback on any syscache invalidation
47524762
* that will affect the search_path cache.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp