Skip to content

Commit ed9f977

Browse files
author
Sergey Shinderuk
committed
Drop support for Postgres < 12
1 parent cfdf2f4 commit ed9f977

File tree

6 files changed

+12
-79
lines changed

6 files changed

+12
-79
lines changed

Diff for: .travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ env:
77
- PG_MAJOR=14
88
- PG_MAJOR=13
99
- PG_MAJOR=12
10-
- PG_MAJOR=11
1110
before_script:
1211
- curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
1312
- echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee -a /etc/apt/sources.list

Diff for: README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Introduction
88
------------
99

10-
PostgreSQL 9.6+ provides an information about current wait event of particular
10+
PostgreSQL provides information about current wait event of particular
1111
process. However, in order to gather descriptive statistics of server
1212
behavior user have to sample current wait event multiple times.
1313
`pg_wait_sampling` is an extension for collecting sampling statistics of wait
@@ -47,7 +47,7 @@ PostgreSQL installation. It is available from
4747
[github](https://github.com/postgrespro/pg_wait_sampling)
4848
under the same license as
4949
[PostgreSQL](http://www.postgresql.org/about/licence/)
50-
and supports PostgreSQL 9.6+.
50+
and supports PostgreSQL 12+.
5151

5252
Installation
5353
------------
@@ -58,10 +58,10 @@ repository: https://download.postgresql.org/pub/repos/
5858
Manual build
5959
------------
6060

61-
`pg_wait_sampling` is PostgreSQL extension which requires PostgreSQL 9.6 or
61+
`pg_wait_sampling` is PostgreSQL extension which requires PostgreSQL 12 or
6262
higher. Before build and install you should ensure following:
6363

64-
* PostgreSQL version is 9.6 or higher.
64+
* PostgreSQL version is 12 or higher.
6565
* You have development package of PostgreSQL installed or you built
6666
PostgreSQL from source.
6767
* Your PATH variable is configured so that `pg_config` command available, or

Diff for: collector.c

+1-7
Original file line numberDiff line numberDiff line change
@@ -423,15 +423,9 @@ pgws_collector_main(Datum main_arg)
423423
* Wait until next sample time or request to do something through
424424
* shared memory.
425425
*/
426-
#if PG_VERSION_NUM >= 100000
427426
rc = WaitLatch(&MyProc->procLatch, WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
428427
Min(history_period - (int)history_diff,
429428
profile_period - (int)profile_diff), PG_WAIT_EXTENSION);
430-
#else
431-
rc = WaitLatch(&MyProc->procLatch, WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
432-
Min(history_period - (int)history_diff,
433-
profile_period - (int)profile_diff));
434-
#endif
435429

436430
if (rc & WL_POSTMASTER_DEATH)
437431
proc_exit(1);
@@ -482,7 +476,7 @@ pgws_collector_main(Datum main_arg)
482476
default:
483477
Assert(false);
484478
}
485-
shm_mq_detach_compat(mqh, pgws_collector_mq);
479+
shm_mq_detach(mqh);
486480
}
487481
else if (request == PROFILE_RESET)
488482
{

Diff for: compat.h

+1-23
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,6 @@
1717
#include "storage/shm_mq.h"
1818
#include "utils/guc_tables.h"
1919

20-
static inline TupleDesc
21-
CreateTemplateTupleDescCompat(int nattrs, bool hasoid)
22-
{
23-
#if PG_VERSION_NUM >= 120000
24-
return CreateTemplateTupleDesc(nattrs);
25-
#else
26-
return CreateTemplateTupleDesc(nattrs, hasoid);
27-
#endif
28-
}
29-
30-
static inline void
31-
shm_mq_detach_compat(shm_mq_handle *mqh, shm_mq *mq)
32-
{
33-
#if PG_VERSION_NUM >= 100000
34-
shm_mq_detach(mqh);
35-
#else
36-
shm_mq_detach(mq);
37-
#endif
38-
}
39-
4020
static inline shm_mq_result
4121
shm_mq_send_compat(shm_mq_handle *mqh, Size nbytes, const void *data,
4222
bool nowait, bool force_flush)
@@ -61,11 +41,9 @@ InitPostgresCompat(const char *in_dbname, Oid dboid,
6141
#elif PG_VERSION_NUM >= 150000
6242
InitPostgres(in_dbname, dboid, username, useroid, load_session_libraries,
6343
override_allow_connections, out_dbname);
64-
#elif PG_VERSION_NUM >= 110000
44+
#else
6545
InitPostgres(in_dbname, dboid, username, useroid, out_dbname,
6646
override_allow_connections);
67-
#else
68-
InitPostgres(in_dbname, dboid, username, useroid, out_dbname);
6947
#endif
7048
}
7149

Diff for: pg_wait_sampling.c

+5-38
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
#include "optimizer/planner.h"
1919
#include "pgstat.h"
2020
#include "postmaster/autovacuum.h"
21-
#if PG_VERSION_NUM >= 120000
2221
#include "replication/walsender.h"
23-
#endif
2422
#include "storage/ipc.h"
2523
#include "storage/pg_shmem.h"
2624
#include "storage/procarray.h"
@@ -119,9 +117,7 @@ get_max_procs_count(void)
119117
* Starting with pg12, wal senders aren't part of MaxConnections anymore
120118
* and have to be accounted for.
121119
*/
122-
#if PG_VERSION_NUM >= 120000
123120
count += max_wal_senders;
124-
#endif /* pg 12+ */
125121
#endif /* pg 15- */
126122
/* End of MaxBackends calculation. */
127123

@@ -331,16 +327,9 @@ pgws_shmem_startup(void)
331327
else
332328
{
333329
toc = shm_toc_attach(PG_WAIT_SAMPLING_MAGIC, pgws);
334-
335-
#if PG_VERSION_NUM >= 100000
336330
pgws_collector_hdr = shm_toc_lookup(toc, 0, false);
337331
pgws_collector_mq = shm_toc_lookup(toc, 1, false);
338332
pgws_proc_queryids = shm_toc_lookup(toc, 2, false);
339-
#else
340-
pgws_collector_hdr = shm_toc_lookup(toc, 0);
341-
pgws_collector_mq = shm_toc_lookup(toc, 1);
342-
pgws_proc_queryids = shm_toc_lookup(toc, 2);
343-
#endif
344333
}
345334

346335
shmem_initialized = true;
@@ -366,7 +355,7 @@ static void
366355
pgws_cleanup_callback(int code, Datum arg)
367356
{
368357
elog(DEBUG3, "pg_wait_sampling cleanup: detaching shm_mq and releasing queue lock");
369-
shm_mq_detach_compat(recv_mqh, recv_mq);
358+
shm_mq_detach(recv_mqh);
370359
LockRelease(&queueTag, ExclusiveLock, false);
371360
}
372361

@@ -463,7 +452,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
463452
params->ts = GetCurrentTimestamp();
464453

465454
funcctx->user_fctx = params;
466-
tupdesc = CreateTemplateTupleDescCompat(4, false);
455+
tupdesc = CreateTemplateTupleDesc(4);
467456
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "pid",
468457
INT4OID, -1, 0);
469458
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "type",
@@ -651,7 +640,7 @@ receive_array(SHMRequest request, Size item_size, Size *count)
651640
PG_END_ENSURE_ERROR_CLEANUP(pgws_cleanup_callback, 0);
652641

653642
/* We still have to detach and release lock during normal operation. */
654-
shm_mq_detach_compat(recv_mqh, recv_mq);
643+
shm_mq_detach(recv_mqh);
655644
LockRelease(&queueTag, ExclusiveLock, false);
656645

657646
return result;
@@ -684,7 +673,7 @@ pg_wait_sampling_get_profile(PG_FUNCTION_ARGS)
684673
funcctx->max_calls = profile->count;
685674

686675
/* Make tuple descriptor */
687-
tupdesc = CreateTemplateTupleDescCompat(5, false);
676+
tupdesc = CreateTemplateTupleDesc(5);
688677
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "pid",
689678
INT4OID, -1, 0);
690679
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "type",
@@ -801,7 +790,7 @@ pg_wait_sampling_get_history(PG_FUNCTION_ARGS)
801790
funcctx->max_calls = history->count;
802791

803792
/* Make tuple descriptor */
804-
tupdesc = CreateTemplateTupleDescCompat(5, false);
793+
tupdesc = CreateTemplateTupleDesc(5);
805794
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "pid",
806795
INT4OID, -1, 0);
807796
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "sample_ts",
@@ -879,17 +868,6 @@ pgws_planner_hook(Query *parse,
879868
if (MyProc)
880869
{
881870
int i = MyProc - ProcGlobal->allProcs;
882-
#if PG_VERSION_NUM >= 110000
883-
/*
884-
* since we depend on queryId we need to check that its size
885-
* is uint64 as we coded in pg_wait_sampling
886-
*/
887-
StaticAssertExpr(sizeof(parse->queryId) == sizeof(uint64),
888-
"queryId size is not uint64");
889-
#else
890-
StaticAssertExpr(sizeof(parse->queryId) == sizeof(uint32),
891-
"queryId size is not uint32");
892-
#endif
893871
if (!pgws_proc_queryids[i])
894872
pgws_proc_queryids[i] = parse->queryId;
895873

@@ -921,17 +899,6 @@ pgws_ExecutorStart(QueryDesc *queryDesc, int eflags)
921899
if (MyProc)
922900
{
923901
i = MyProc - ProcGlobal->allProcs;
924-
#if PG_VERSION_NUM >= 110000
925-
/*
926-
* since we depend on queryId we need to check that its size
927-
* is uint64 as we coded in pg_wait_sampling
928-
*/
929-
StaticAssertExpr(sizeof(queryDesc->plannedstmt->queryId) == sizeof(uint64),
930-
"queryId size is not uint64");
931-
#else
932-
StaticAssertExpr(sizeof(queryDesc->plannedstmt->queryId) == sizeof(uint32),
933-
"queryId size is not uint32");
934-
#endif
935902
if (!pgws_proc_queryids[i])
936903
pgws_proc_queryids[i] = queryDesc->plannedstmt->queryId;
937904
}

Diff for: pg_wait_sampling.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
#ifndef __PG_WAIT_SAMPLING_H__
1111
#define __PG_WAIT_SAMPLING_H__
1212

13-
#include <postgres.h>
14-
15-
/* Check PostgreSQL version */
16-
#if PG_VERSION_NUM < 90600
17-
#error "You are trying to build pg_wait_sampling with PostgreSQL version lower than 9.6. Please, check you environment."
18-
#endif
13+
#include "postgres.h"
1914

2015
#include "storage/proc.h"
2116
#include "storage/shm_mq.h"

0 commit comments

Comments
 (0)