Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a23a9ed

Browse files
author
Sergey Shinderuk
committed
Drop support for Postgres < 12.
1 parent 174a786 commit a23a9ed

File tree

5 files changed

+8
-75
lines changed

5 files changed

+8
-75
lines changed

.travis.yml

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

collector.c

Lines changed: 1 addition & 7 deletions
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
{

compat.h

Lines changed: 1 addition & 23 deletions
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

pg_wait_sampling.c

Lines changed: 5 additions & 38 deletions
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
}

pg_wait_sampling.h

Lines changed: 1 addition & 6 deletions
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)