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

Commit8b55719

Browse files
committed
fa70830 isn't correct.
Fix the bug by creating child context of entry->dictCtx.
1 parentfa70830 commit8b55719

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

‎Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ endif
2323

2424
# Disabled because these tests require "shared_preload_libraries=shared_ispell",
2525
# which typical installcheck users do not have (e.g. buildfarm clients).
26-
installcheck: REGRESS=
26+
#installcheck: REGRESS=

‎src/shared_ispell.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,15 @@ clean_dict_affix(IspellDict *dict)
283283
* of the shared memory (using SegmentInfo->lock).
284284
*/
285285
staticvoid
286-
init_shared_dict(DictInfo*info,char*dictFile,char*affFile,char*stopFile)
286+
init_shared_dict(DictInfo*info,MemoryContextinfoCntx,
287+
char*dictFile,char*affFile,char*stopFile)
287288
{
288289
intsize;
289290
SharedIspellDict*shdict=NULL;
290291
SharedStopList*shstop=NULL;
292+
MemoryContextoldctx;
293+
294+
oldctx=MemoryContextSwitchTo(infoCntx);
291295

292296
/* DICTIONARY + AFFIXES */
293297

@@ -413,8 +417,9 @@ init_shared_dict(DictInfo *info, char *dictFile, char *affFile, char *stopFile)
413417
else
414418
memset(info->stopFile,0,sizeof(info->stopFile));
415419

420+
MemoryContextSwitchTo(oldctx);
416421
/* save current context as long-lived */
417-
info->saveCntx=CurrentMemoryContext;
422+
info->infoCntx=infoCntx;
418423
}
419424

420425
Datumdispell_init(PG_FUNCTION_ARGS);
@@ -576,7 +581,15 @@ dispell_init(PG_FUNCTION_ARGS)
576581
/* search if the dictionary is already initialized */
577582
LWLockAcquire(segment_info->lock,LW_EXCLUSIVE);
578583

579-
init_shared_dict(info,dictFile,affFile,stopFile);
584+
/*
585+
* Current context is a long lived context. Create child context to store
586+
* DictInfo internal data.
587+
*/
588+
info->infoCntx=AllocSetContextCreate(CurrentMemoryContext,
589+
"shared_ispell context",
590+
ALLOCSET_DEFAULT_SIZES);
591+
592+
init_shared_dict(info,info->infoCntx,dictFile,affFile,stopFile);
580593

581594
LWLockRelease(segment_info->lock);
582595

@@ -605,8 +618,7 @@ dispell_lexize(PG_FUNCTION_ARGS)
605618
/* do we need to reinit the dictionary? was the dict reset since the lookup */
606619
if (timestamp_cmp_internal(info->lookup,segment_info->lastReset)<0)
607620
{
608-
DictInfosaveInfo=*info;
609-
MemoryContextctx;
621+
DictInfosaveInfo=*info;
610622

611623
/* relock in exclusive mode */
612624
LWLockRelease(segment_info->lock);
@@ -617,15 +629,11 @@ dispell_lexize(PG_FUNCTION_ARGS)
617629
* info here
618630
*/
619631

620-
MemoryContextResetAndDeleteChildren(saveInfo.saveCntx);
621-
ctx=MemoryContextSwitchTo(saveInfo.saveCntx);
622-
632+
MemoryContextResetAndDeleteChildren(saveInfo.infoCntx);
623633
MemSet(info,0,sizeof(*info));
624634

625-
init_shared_dict(info,saveInfo.dictFile,
635+
init_shared_dict(info,saveInfo.infoCntx,saveInfo.dictFile,
626636
saveInfo.affixFile,saveInfo.stopFile);
627-
628-
MemoryContextSwitchTo(ctx);
629637
}
630638

631639
res=NINormalizeWord(&(info->dict),txt);

‎src/shared_ispell.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ typedef struct DictInfo
6969
SharedStopList*shstop;
7070

7171
/* MemoryContext of dict local content */
72-
MemoryContextsaveCntx;
72+
MemoryContextinfoCntx;
7373
}DictInfo;
7474

7575
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp