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

Commit1ab15cf

Browse files
author
Vladimir Ershov
committed
show mwthods for GUC vars
1 parent2030181 commit1ab15cf

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

‎src/memutils.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ MemoryContext init_mem_ctx(const char *name)
1212
ALLOCSET_DEFAULT_MAXSIZE);
1313
}
1414

15+
boolis_worker_context_initialized(void)
16+
{
17+
returnSchedulerWorkerContext==NULL ? false: true;
18+
}
19+
1520
MemoryContextinit_worker_mem_ctx(constchar*name)
1621
{
1722
AssertState(SchedulerWorkerContext==NULL);
@@ -47,6 +52,15 @@ void *worker_alloc(Size size)
4752
returnMemoryContextAlloc(SchedulerWorkerContext,size);
4853
}
4954

55+
voiddrop_worker_context(void)
56+
{
57+
if(SchedulerWorkerContext)
58+
{
59+
MemoryContextDelete(SchedulerWorkerContext);
60+
SchedulerWorkerContext=NULL;
61+
}
62+
}
63+
5064
voiddelete_worker_mem_ctx(MemoryContextold)
5165
{
5266
if(!old)old=TopMemoryContext;

‎src/memutils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ char *_mcopy_string(MemoryContext ctx, char *str);
1616
char*my_copy_string(char*str);
1717
voidcheck_scheduler_context(void);
1818

19+
boolis_worker_context_initialized(void);
20+
voiddrop_worker_context(void);
21+
1922
#endif

‎src/pgpro_scheduler.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
PG_MODULE_MAGIC;
4848
#endif
4949

50+
staticconstchar*show_scheduler_nodename(void);
51+
staticconstchar*show_scheduler_database(void);
52+
5053
volatilesig_atomic_tgot_sighup= false;
5154
volatilesig_atomic_tgot_sigterm= false;
5255

@@ -297,6 +300,41 @@ char *set_schema(const char *name, bool get_old)
297300
returncurrent;
298301
}
299302

303+
staticconstchar*
304+
show_scheduler_nodename(void)
305+
{
306+
staticcharnbuf[256];
307+
char*nname;
308+
309+
nname=get_scheduler_nodename(CurrentMemoryContext);
310+
snprintf(nbuf,sizeof(nbuf),"%s",nname);
311+
pfree(nname);
312+
returnnbuf;
313+
}
314+
315+
staticconstchar*
316+
show_scheduler_database(void)
317+
{
318+
staticcharnbuf[256];
319+
constchar*value;
320+
booldrop_context= false;
321+
322+
if(!is_worker_context_initialized())
323+
{
324+
init_worker_mem_ctx("temp for functions");
325+
drop_context= true;
326+
}
327+
328+
value=check_multimaster_database();
329+
330+
if(!value)
331+
value=GetConfigOption("schedule.database", true, false);
332+
snprintf(nbuf,sizeof(nbuf),"%s",value);
333+
334+
if(drop_context)drop_worker_context();
335+
returnnbuf;
336+
}
337+
300338
char*get_scheduler_nodename(MemoryContextmem)
301339
{
302340
constchar*opt;
@@ -670,7 +708,7 @@ void _PG_init(void)
670708
0,
671709
NULL,
672710
NULL,
673-
NULL
711+
show_scheduler_database
674712
);
675713
DefineCustomStringVariable(
676714
"schedule.nodename",
@@ -682,7 +720,7 @@ void _PG_init(void)
682720
0,
683721
NULL,
684722
NULL,
685-
NULL
723+
show_scheduler_nodename
686724
);
687725
DefineCustomStringVariable(
688726
"schedule.transaction_state",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp