1+ /*
2+ * compat.h
3+ * Definitions for function wrappers compatible between PG versions.
4+ *
5+ * Copyright (c) 2015-2022, Postgres Professional
6+ *
7+ * IDENTIFICATION
8+ * contrib/pg_wait_sampling/compat.h
9+ */
10+ #ifndef __COMPAT_H__
11+ #define __COMPAT_H__
12+
113#include "postgres.h"
214
315#include "access/tupdesc.h"
416#include "miscadmin.h"
17+ #include "storage/shm_mq.h"
518
6- #include "pg_wait_sampling.h"
19+ static inline TupleDesc
20+ CreateTemplateTupleDescCompat (int nattrs , bool hasoid )
21+ {
22+ #if PG_VERSION_NUM >= 120000
23+ return CreateTemplateTupleDesc (nattrs );
24+ #else
25+ return CreateTemplateTupleDesc (nattrs , hasoid );
26+ #endif
27+ }
728
8- inline void
29+ static inline void
930shm_mq_detach_compat (shm_mq_handle * mqh , shm_mq * mq )
1031{
1132#if PG_VERSION_NUM >= 100000
@@ -15,7 +36,7 @@ shm_mq_detach_compat(shm_mq_handle *mqh, shm_mq *mq)
1536#endif
1637}
1738
18- inline shm_mq_result
39+ static inline shm_mq_result
1940shm_mq_send_compat (shm_mq_handle * mqh , Size nbytes , const void * data ,
2041 bool nowait , bool force_flush )
2142{
@@ -26,17 +47,7 @@ shm_mq_send_compat(shm_mq_handle *mqh, Size nbytes, const void *data,
2647#endif
2748}
2849
29- inline TupleDesc
30- CreateTemplateTupleDescCompat (int nattrs , bool hasoid )
31- {
32- #if PG_VERSION_NUM >= 120000
33- return CreateTemplateTupleDesc (nattrs );
34- #else
35- return CreateTemplateTupleDesc (nattrs , hasoid );
36- #endif
37- }
38-
39- inline void
50+ static inline void
4051InitPostgresCompat (const char * in_dbname , Oid dboid ,
4152 const char * username , Oid useroid ,
4253 bool load_session_libraries ,
@@ -53,3 +64,5 @@ InitPostgresCompat(const char *in_dbname, Oid dboid,
5364 InitPostgres (in_dbname , dboid , username , useroid , out_dbname );
5465#endif
5566}
67+
68+ #endif
0 commit comments