PG-187: Compilation Error for PostgreSQL 11 and PostgreSQL 12.
parent
e0fc683810
commit
96a7603aae
|
@ -59,7 +59,9 @@ void _PG_fini(void);
|
||||||
|
|
||||||
/* Current nesting depth of ExecutorRun+ProcessUtility calls */
|
/* Current nesting depth of ExecutorRun+ProcessUtility calls */
|
||||||
static int nested_level = 0;
|
static int nested_level = 0;
|
||||||
|
#if PG_VERSION_NUM >= 130000
|
||||||
static int plan_nested_level = 0;
|
static int plan_nested_level = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The array to store outer layer query id*/
|
/* The array to store outer layer query id*/
|
||||||
uint64 *nested_queryids;
|
uint64 *nested_queryids;
|
||||||
|
@ -76,10 +78,12 @@ static bool IsSystemInitialized(void);
|
||||||
static void dump_queries_buffer(int bucket_id, unsigned char *buf, int buf_len);
|
static void dump_queries_buffer(int bucket_id, unsigned char *buf, int buf_len);
|
||||||
static double time_diff(struct timeval end, struct timeval start);
|
static double time_diff(struct timeval end, struct timeval start);
|
||||||
|
|
||||||
static PlannedStmt * pgss_planner_hook(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams);
|
|
||||||
|
|
||||||
/* Saved hook values in case of unload */
|
/* Saved hook values in case of unload */
|
||||||
|
|
||||||
|
#if PG_VERSION_NUM >= 130000
|
||||||
static planner_hook_type planner_hook_next = NULL;
|
static planner_hook_type planner_hook_next = NULL;
|
||||||
|
#endif
|
||||||
static post_parse_analyze_hook_type prev_post_parse_analyze_hook = NULL;
|
static post_parse_analyze_hook_type prev_post_parse_analyze_hook = NULL;
|
||||||
static ExecutorStart_hook_type prev_ExecutorStart = NULL;
|
static ExecutorStart_hook_type prev_ExecutorStart = NULL;
|
||||||
static ExecutorRun_hook_type prev_ExecutorRun = NULL;
|
static ExecutorRun_hook_type prev_ExecutorRun = NULL;
|
||||||
|
@ -104,11 +108,6 @@ static int pg_get_application_name(char* application_name);
|
||||||
static PgBackendStatus *pg_get_backend_status(void);
|
static PgBackendStatus *pg_get_backend_status(void);
|
||||||
static Datum intarray_get_datum(int32 arr[], int len);
|
static Datum intarray_get_datum(int32 arr[], int len);
|
||||||
|
|
||||||
#if PG_VERSION_NUM < 130000
|
|
||||||
static void BufferUsageAccumDiff(BufferUsage* bufusage, BufferUsage* pgBufferUsage, BufferUsage* bufusage_start);
|
|
||||||
static PlannedStmt *pgss_planner_hook(Query *parse, int opt, ParamListInfo param);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void pgss_post_parse_analyze(ParseState *pstate, Query *query);
|
static void pgss_post_parse_analyze(ParseState *pstate, Query *query);
|
||||||
static void pgss_ExecutorStart(QueryDesc *queryDesc, int eflags);
|
static void pgss_ExecutorStart(QueryDesc *queryDesc, int eflags);
|
||||||
static void pgss_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once);
|
static void pgss_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once);
|
||||||
|
@ -117,6 +116,7 @@ static void pgss_ExecutorEnd(QueryDesc *queryDesc);
|
||||||
static bool pgss_ExecutorCheckPerms(List *rt, bool abort);
|
static bool pgss_ExecutorCheckPerms(List *rt, bool abort);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= 130000
|
#if PG_VERSION_NUM >= 130000
|
||||||
|
static PlannedStmt * pgss_planner_hook(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams);
|
||||||
static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
|
static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
|
||||||
ProcessUtilityContext context,
|
ProcessUtilityContext context,
|
||||||
ParamListInfo params, QueryEnvironment *queryEnv,
|
ParamListInfo params, QueryEnvironment *queryEnv,
|
||||||
|
@ -124,6 +124,7 @@ static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
|
||||||
QueryCompletion *qc
|
QueryCompletion *qc
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
|
static void BufferUsageAccumDiff(BufferUsage* bufusage, BufferUsage* pgBufferUsage, BufferUsage* bufusage_start);
|
||||||
static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
|
static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
|
||||||
ProcessUtilityContext context, ParamListInfo params,
|
ProcessUtilityContext context, ParamListInfo params,
|
||||||
QueryEnvironment *queryEnv,
|
QueryEnvironment *queryEnv,
|
||||||
|
@ -250,8 +251,10 @@ _PG_init(void)
|
||||||
ExecutorEnd_hook = pgss_ExecutorEnd;
|
ExecutorEnd_hook = pgss_ExecutorEnd;
|
||||||
prev_ProcessUtility = ProcessUtility_hook;
|
prev_ProcessUtility = ProcessUtility_hook;
|
||||||
ProcessUtility_hook = pgss_ProcessUtility;
|
ProcessUtility_hook = pgss_ProcessUtility;
|
||||||
|
#if PG_VERSION_NUM >= 130000
|
||||||
planner_hook_next = planner_hook;
|
planner_hook_next = planner_hook;
|
||||||
planner_hook = pgss_planner_hook;
|
planner_hook = pgss_planner_hook;
|
||||||
|
#endif
|
||||||
emit_log_hook = pgsm_emit_log_hook;
|
emit_log_hook = pgsm_emit_log_hook;
|
||||||
prev_ExecutorCheckPerms_hook = ExecutorCheckPerms_hook;
|
prev_ExecutorCheckPerms_hook = ExecutorCheckPerms_hook;
|
||||||
ExecutorCheckPerms_hook = pgss_ExecutorCheckPerms;
|
ExecutorCheckPerms_hook = pgss_ExecutorCheckPerms;
|
||||||
|
@ -510,7 +513,11 @@ pgss_ExecutorEnd(QueryDesc *queryDesc)
|
||||||
queryDesc->totaltime->total * 1000.0, /* totaltime */
|
queryDesc->totaltime->total * 1000.0, /* totaltime */
|
||||||
queryDesc->estate->es_processed, /* rows */
|
queryDesc->estate->es_processed, /* rows */
|
||||||
&queryDesc->totaltime->bufusage, /* bufusage */
|
&queryDesc->totaltime->bufusage, /* bufusage */
|
||||||
|
#if PG_VERSION_NUM >= 130000
|
||||||
&queryDesc->totaltime->walusage, /* walusage */
|
&queryDesc->totaltime->walusage, /* walusage */
|
||||||
|
#else
|
||||||
|
NULL,
|
||||||
|
#endif
|
||||||
NULL,
|
NULL,
|
||||||
PGSS_EXEC); /* pgssStoreKind */
|
PGSS_EXEC); /* pgssStoreKind */
|
||||||
}
|
}
|
||||||
|
@ -571,6 +578,7 @@ pgss_ExecutorCheckPerms(List *rt, bool abort)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if PG_VERSION_NUM >= 130000
|
||||||
static PlannedStmt*
|
static PlannedStmt*
|
||||||
pgss_planner_hook(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams)
|
pgss_planner_hook(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams)
|
||||||
{
|
{
|
||||||
|
@ -641,6 +649,7 @@ pgss_planner_hook(Query *parse, const char *query_string, int cursorOptions, Par
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ProcessUtility hook
|
* ProcessUtility hook
|
||||||
|
@ -683,13 +692,12 @@ static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
|
||||||
instr_time start;
|
instr_time start;
|
||||||
instr_time duration;
|
instr_time duration;
|
||||||
uint64 rows;
|
uint64 rows;
|
||||||
BufferUsage bufusage_start;
|
|
||||||
BufferUsage bufusage;
|
BufferUsage bufusage;
|
||||||
WalUsage walusage_start;
|
|
||||||
WalUsage walusage;
|
WalUsage walusage;
|
||||||
|
BufferUsage bufusage_start = pgBufferUsage;
|
||||||
bufusage_start = pgBufferUsage;
|
#if PG_VERSION_NUM >= 130000
|
||||||
walusage_start = pgWalUsage;
|
WalUsage walusage_start = pgWalUsage;
|
||||||
|
#endif
|
||||||
INSTR_TIME_SET_CURRENT(start);
|
INSTR_TIME_SET_CURRENT(start);
|
||||||
PG_TRY();
|
PG_TRY();
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,6 +112,15 @@ typedef struct GucVariables
|
||||||
bool guc_restart;
|
bool guc_restart;
|
||||||
} GucVariable;
|
} GucVariable;
|
||||||
|
|
||||||
|
#if PG_VERSION_NUM < 130000
|
||||||
|
typedef struct WalUsage
|
||||||
|
{
|
||||||
|
long wal_records; /* # of WAL records produced */
|
||||||
|
long wal_fpi; /* # of WAL full page images produced */
|
||||||
|
uint64 wal_bytes; /* size of WAL records produced */
|
||||||
|
} WalUsage;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum OVERFLOW_TARGET
|
typedef enum OVERFLOW_TARGET
|
||||||
{
|
{
|
||||||
OVERFLOW_TARGET_NONE = 0,
|
OVERFLOW_TARGET_NONE = 0,
|
||||||
|
|
|
@ -16,16 +16,16 @@ SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C";
|
||||||
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+---------
|
------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+---------
|
||||||
pg_stat_monitor.pgsm_bucket_time | 300 | 300 | Sets the time in seconds per bucket. | 1 | 2147483647 | 1
|
pg_stat_monitor.pgsm_bucket_time | 300 | 300 | Sets the time in seconds per bucket. | 1 | 2147483647 | 1
|
||||||
pg_stat_monitor.pgsm_enable | 1 | 1 | Enable/Disable statistics collector. | 0 | 0 | 0
|
pg_stat_monitor.pgsm_enable | 1 | 1 | Enable/Disable statistics collector. | 0 | 0 | 0
|
||||||
|
pg_stat_monitor.pgsm_enable_query_plan | 0 | 0 | Enable/Disable query plan monitoring | 0 | 0 | 0
|
||||||
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 2147483647 | 1
|
pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 2147483647 | 1
|
||||||
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | 1
|
pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | 1
|
||||||
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | 1
|
pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | 1
|
||||||
pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | 1
|
pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | 1
|
||||||
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | 1
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | 1
|
||||||
pg_stat_monitor.pgsm_normalized_query | 1 | 1 | Selects whether save query in normalized format. | 0 | 0 | 0
|
pg_stat_monitor.pgsm_normalized_query | 1 | 1 | Selects whether save query in normalized format. | 0 | 0 | 0
|
||||||
pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | 1
|
pg_stat_monitor.pgsm_overflow_target | 0 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | 1
|
||||||
pg_stat_monitor.pgsm_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | 1
|
pg_stat_monitor.pgsm_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | 1
|
||||||
pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | 1
|
pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | 1
|
||||||
pg_stat_monitor.pgsm_track_planning | 0 | 1 | Selects whether planning statistics are tracked. | 0 | 0 | 0
|
|
||||||
pg_stat_monitor.pgsm_track_utility | 1 | 1 | Selects whether utility commands are tracked. | 0 | 0 | 0
|
pg_stat_monitor.pgsm_track_utility | 1 | 1 | Selects whether utility commands are tracked. | 0 | 0 | 0
|
||||||
(13 rows)
|
(13 rows)
|
||||||
|
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
CREATE EXTENSION pg_stat_monitor;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
CREATE TABLE foo1(a int);
|
|
||||||
CREATE TABLE foo2(a int);
|
|
||||||
CREATE TABLE foo3(a int);
|
|
||||||
CREATE TABLE foo4(a int);
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT * FROM foo1, foo2, foo3, foo4;
|
|
||||||
a | a | a | a
|
|
||||||
---+---+---+---
|
|
||||||
(0 rows)
|
|
||||||
|
|
||||||
SELECT query, relations from pg_stat_monitor ORDER BY query;
|
|
||||||
query | relations
|
|
||||||
-------------------------------------------------------------+---------------------------------------------------
|
|
||||||
SELECT * FROM foo1, foo2, foo3, foo4 | {public.foo1,public.foo2,public.foo3,public.foo4}
|
|
||||||
SELECT pg_stat_monitor_reset() |
|
|
||||||
SELECT query, relations from pg_stat_monitor ORDER BY query |
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
pg_stat_monitor_reset
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
DROP TABLE foo1;
|
|
||||||
DROP TABLE foo2;
|
|
||||||
DROP TABLE foo3;
|
|
||||||
DROP TABLE foo4;
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
|
Loading…
Reference in New Issue