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

Commit76f0ccc

Browse files
committed
Add compability with pg10
1 parent6d53f88 commit76f0ccc

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

‎.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.deps
22
*.o
3-
*.so
3+
*.so
4+
/results

‎collector.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
#include"storage/spin.h"
2222
#include"utils/memutils.h"
2323
#include"utils/resowner.h"
24+
#include"pgstat.h"
2425

2526
#include"pg_wait_sampling.h"
2627

2728
staticvolatilesig_atomic_tshutdown_requested= false;
2829

2930
staticvoidhandle_sigterm(SIGNAL_ARGS);
30-
staticvoidcollector_main(Datummain_arg);
3131

3232
/*
3333
* Register background worker for collecting waits history.
@@ -41,8 +41,13 @@ register_wait_collector(void)
4141
worker.bgw_flags=BGWORKER_SHMEM_ACCESS;
4242
worker.bgw_start_time=BgWorkerStart_ConsistentState;
4343
worker.bgw_restart_time=0;
44-
worker.bgw_main=collector_main;
4544
worker.bgw_notify_pid=0;
45+
#ifPG_VERSION_NUM >=100000
46+
memcpy(worker.bgw_library_name,"pg_wait_sampling",BGW_MAXLEN);
47+
memcpy(worker.bgw_function_name,CppAsString(collector_main),BGW_MAXLEN);
48+
#else
49+
worker.bgw_main=collector_main;
50+
#endif
4651
snprintf(worker.bgw_name,BGW_MAXLEN,"pg_wait_sampling collector");
4752
worker.bgw_main_arg= (Datum)0;
4853
RegisterBackgroundWorker(&worker);
@@ -263,7 +268,7 @@ millisecs_diff(TimestampTz tz1, TimestampTz tz2)
263268
/*
264269
* Main routine of wait history collector.
265270
*/
266-
staticvoid
271+
void
267272
collector_main(Datummain_arg)
268273
{
269274
HTAB*profile_hash=NULL;
@@ -351,9 +356,15 @@ collector_main(Datum main_arg)
351356
* Wait until next sample time or request to do something through
352357
* shared memory.
353358
*/
359+
#ifPG_VERSION_NUM >=100000
360+
rc=WaitLatch(&MyProc->procLatch,WL_LATCH_SET |WL_TIMEOUT |WL_POSTMASTER_DEATH,
361+
Min(history_period- (int)history_diff,
362+
profile_period- (int)profile_diff),PG_WAIT_EXTENSION);
363+
#else
354364
rc=WaitLatch(&MyProc->procLatch,WL_LATCH_SET |WL_TIMEOUT |WL_POSTMASTER_DEATH,
355365
Min(history_period- (int)history_diff,
356366
profile_period- (int)profile_diff));
367+
#endif
357368

358369
if (rc&WL_POSTMASTER_DEATH)
359370
proc_exit(1);

‎expected/load_1.out

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CREATE EXTENSION pg_wait_sampling;
2+
\d pg_wait_sampling_current
3+
View "public.pg_wait_sampling_current"
4+
Column | Type | Collation | Nullable | Default
5+
------------+---------+-----------+----------+---------
6+
pid | integer | | |
7+
event_type | text | | |
8+
event | text | | |
9+
10+
\d pg_wait_sampling_history
11+
View "public.pg_wait_sampling_history"
12+
Column | Type | Collation | Nullable | Default
13+
------------+--------------------------+-----------+----------+---------
14+
pid | integer | | |
15+
ts | timestamp with time zone | | |
16+
event_type | text | | |
17+
event | text | | |
18+
19+
DROP EXTENSION pg_wait_sampling;

‎pg_wait_sampling.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,13 @@ pgws_shmem_startup(void)
205205
{
206206
toc=shm_toc_attach(PG_WAIT_SAMPLING_MAGIC,pgws);
207207

208+
#ifPG_VERSION_NUM >=100000
209+
collector_hdr=shm_toc_lookup(toc,0, false);
210+
collector_mq=shm_toc_lookup(toc,1, false);
211+
#else
208212
collector_hdr=shm_toc_lookup(toc,0);
209213
collector_mq=shm_toc_lookup(toc,1);
214+
#endif
210215
}
211216

212217
shmem_initialized= true;

‎pg_wait_sampling.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@ extern void init_lock_tag(LOCKTAG *tag, uint32 lock);
7777
/* collector.c */
7878
externvoidregister_wait_collector(void);
7979
externvoidalloc_history(History*,int);
80+
externvoidcollector_main(Datummain_arg);
8081

8182
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp