Issue (#59): Build failed using gcc-9 and 10.
The issue only occurs when compiled using -fno-common flag.pull/65/head
parent
1a82b7566d
commit
8918017134
10
guc.c
10
guc.c
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#include "pg_stat_monitor.h"
|
#include "pg_stat_monitor.h"
|
||||||
|
|
||||||
|
GucVariable conf[12];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define (or redefine) custom GUC variables.
|
* Define (or redefine) custom GUC variables.
|
||||||
*/
|
*/
|
||||||
|
@ -57,7 +59,7 @@ init_guc(void)
|
||||||
conf[i++] = (GucVariable) {
|
conf[i++] = (GucVariable) {
|
||||||
.guc_name = "pg_stat_monitor.pgsm_normalized_query",
|
.guc_name = "pg_stat_monitor.pgsm_normalized_query",
|
||||||
.guc_desc = "Selects whether save query in normalized format.",
|
.guc_desc = "Selects whether save query in normalized format.",
|
||||||
.guc_default = 0,
|
.guc_default = 1,
|
||||||
.guc_min = 0,
|
.guc_min = 0,
|
||||||
.guc_max = 0,
|
.guc_max = 0,
|
||||||
.guc_restart = false
|
.guc_restart = false
|
||||||
|
@ -275,3 +277,9 @@ init_guc(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GucVariable*
|
||||||
|
get_conf(int i)
|
||||||
|
{
|
||||||
|
return &conf[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
20
hash_query.c
20
hash_query.c
|
@ -33,21 +33,12 @@ hash_init(const char *hash_name, int key_size, int entry_size, int hash_size)
|
||||||
return ShmemInitHash(hash_name, hash_size, hash_size, &info, HASH_ELEM | HASH_BLOBS);
|
return ShmemInitHash(hash_name, hash_size, hash_size, &info, HASH_ELEM | HASH_BLOBS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* shmem_startup hook: allocate or attach to shared memory,
|
|
||||||
* then load any pre-existing statistics from file.
|
|
||||||
* Also create and load the query-texts file, which is expected to exist
|
|
||||||
* (even if empty) while the module is enabled.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
pgss_shmem_startup(void)
|
pgss_startup(void)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int32 i;
|
int32 i;
|
||||||
|
|
||||||
if (prev_shmem_startup_hook)
|
|
||||||
prev_shmem_startup_hook();
|
|
||||||
|
|
||||||
/* reset in case this is a restart within the postmaster */
|
/* reset in case this is a restart within the postmaster */
|
||||||
pgss = NULL;
|
pgss = NULL;
|
||||||
pgss_hash = NULL;
|
pgss_hash = NULL;
|
||||||
|
@ -73,11 +64,11 @@ pgss_shmem_startup(void)
|
||||||
|
|
||||||
for (i = 0; i < PGSM_MAX_BUCKETS; i++)
|
for (i = 0; i < PGSM_MAX_BUCKETS; i++)
|
||||||
{
|
{
|
||||||
unsigned char *buf;
|
unsigned char *buf = (unsigned char *)ShmemAlloc(pgss->query_buf_size_bucket);
|
||||||
pgss_qbuf[i] = (unsigned char *) ShmemAlloc(pgss->query_buf_size_bucket);
|
set_qbuf(i, buf);
|
||||||
buf = pgss_qbuf[i];
|
|
||||||
memset(buf, 0, sizeof (uint64));
|
memset(buf, 0, sizeof (uint64));
|
||||||
}
|
}
|
||||||
|
|
||||||
pgss_hash = hash_init("pg_stat_monitor: Queries hashtable", sizeof(pgssHashKey), sizeof(pgssEntry),PGSM_MAX);
|
pgss_hash = hash_init("pg_stat_monitor: Queries hashtable", sizeof(pgssHashKey), sizeof(pgssEntry),PGSM_MAX);
|
||||||
|
|
||||||
pgss_waiteventshash = hash_init("pg_stat_monitor: Wait Event hashtable", sizeof(pgssWaitEventKey), sizeof(pgssWaitEventEntry), 100);
|
pgss_waiteventshash = hash_init("pg_stat_monitor: Wait Event hashtable", sizeof(pgssWaitEventKey), sizeof(pgssWaitEventEntry), 100);
|
||||||
|
@ -330,7 +321,8 @@ hash_create_query_entry(unsigned int queryid,
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsHashInitialize(void)
|
bool
|
||||||
|
IsHashInitialize(void)
|
||||||
{
|
{
|
||||||
return (pgss || pgss_hash || pgss_object_hash || pgss_buckethash || pgss_waiteventshash);
|
return (pgss || pgss_hash || pgss_object_hash || pgss_buckethash || pgss_waiteventshash);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ static struct rusage rusage_start;
|
||||||
static struct rusage rusage_end;
|
static struct rusage rusage_end;
|
||||||
static volatile sig_atomic_t sigterm = false;
|
static volatile sig_atomic_t sigterm = false;
|
||||||
static void handle_sigterm(SIGNAL_ARGS);
|
static void handle_sigterm(SIGNAL_ARGS);
|
||||||
|
static unsigned char *pgss_qbuf[MAX_BUCKETS];
|
||||||
|
|
||||||
/* Saved hook values in case of unload */
|
/* Saved hook values in case of unload */
|
||||||
static planner_hook_type planner_hook_next = NULL;
|
static planner_hook_type planner_hook_next = NULL;
|
||||||
|
@ -45,7 +46,7 @@ static ExecutorRun_hook_type prev_ExecutorRun = NULL;
|
||||||
static ExecutorFinish_hook_type prev_ExecutorFinish = NULL;
|
static ExecutorFinish_hook_type prev_ExecutorFinish = NULL;
|
||||||
static ExecutorEnd_hook_type prev_ExecutorEnd = NULL;
|
static ExecutorEnd_hook_type prev_ExecutorEnd = NULL;
|
||||||
static ProcessUtility_hook_type prev_ProcessUtility = NULL;
|
static ProcessUtility_hook_type prev_ProcessUtility = NULL;
|
||||||
|
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
|
||||||
|
|
||||||
PG_FUNCTION_INFO_V1(pg_stat_monitor_version);
|
PG_FUNCTION_INFO_V1(pg_stat_monitor_version);
|
||||||
PG_FUNCTION_INFO_V1(pg_stat_monitor_reset);
|
PG_FUNCTION_INFO_V1(pg_stat_monitor_reset);
|
||||||
|
@ -197,6 +198,22 @@ _PG_fini(void)
|
||||||
hash_entry_reset();
|
hash_entry_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* shmem_startup hook: allocate or attach to shared memory,
|
||||||
|
* then load any pre-existing statistics from file.
|
||||||
|
* Also create and load the query-texts file, which is expected to exist
|
||||||
|
* (even if empty) while the module is enabled.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
pgss_shmem_startup(void)
|
||||||
|
{
|
||||||
|
if (prev_shmem_startup_hook)
|
||||||
|
prev_shmem_startup_hook();
|
||||||
|
|
||||||
|
pgss_startup();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Select the version of pg_stat_monitor.
|
* Select the version of pg_stat_monitor.
|
||||||
*/
|
*/
|
||||||
|
@ -2422,16 +2439,22 @@ pg_stat_monitor_settings(PG_FUNCTION_ARGS)
|
||||||
memset(values, 0, sizeof(values));
|
memset(values, 0, sizeof(values));
|
||||||
memset(nulls, 0, sizeof(nulls));
|
memset(nulls, 0, sizeof(nulls));
|
||||||
|
|
||||||
values[j++] = CStringGetTextDatum(conf[i].guc_name);
|
values[j++] = CStringGetTextDatum(get_conf(i)->guc_name);
|
||||||
values[j++] = Int64GetDatumFast(conf[i].guc_variable);
|
values[j++] = Int64GetDatumFast(get_conf(i)->guc_variable);
|
||||||
values[j++] = Int64GetDatumFast(conf[i].guc_default);
|
values[j++] = Int64GetDatumFast(get_conf(i)->guc_default);
|
||||||
values[j++] = CStringGetTextDatum(conf[i].guc_desc);
|
values[j++] = CStringGetTextDatum(get_conf(i)->guc_desc);
|
||||||
values[j++] = Int64GetDatumFast(conf[i].guc_min);
|
values[j++] = Int64GetDatumFast(get_conf(i)->guc_min);
|
||||||
values[j++] = Int64GetDatumFast(conf[i].guc_max);
|
values[j++] = Int64GetDatumFast(get_conf(i)->guc_max);
|
||||||
values[j++] = Int64GetDatumFast(conf[i].guc_restart);
|
values[j++] = Int64GetDatumFast(get_conf(i)->guc_restart);
|
||||||
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
|
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
|
||||||
}
|
}
|
||||||
/* clean up and return the tuplestore */
|
/* clean up and return the tuplestore */
|
||||||
tuplestore_donestoring(tupstore);
|
tuplestore_donestoring(tupstore);
|
||||||
return (Datum)0;
|
return (Datum)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_qbuf(int i, unsigned char *buf)
|
||||||
|
{
|
||||||
|
pgss_qbuf[i] = buf;
|
||||||
|
}
|
||||||
|
|
|
@ -252,7 +252,6 @@ do { \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned char *pgss_qbuf[MAX_BUCKETS];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Struct for tracking locations/lengths of constants during normalization
|
* Struct for tracking locations/lengths of constants during normalization
|
||||||
|
@ -292,6 +291,7 @@ typedef struct pgssJumbleState
|
||||||
|
|
||||||
/* guc.c */
|
/* guc.c */
|
||||||
void init_guc(void);
|
void init_guc(void);
|
||||||
|
GucVariable *get_conf(int i);
|
||||||
|
|
||||||
/* hash_create.c */
|
/* hash_create.c */
|
||||||
void hash_alloc_object_entry(uint64 queryid, char *objects);
|
void hash_alloc_object_entry(uint64 queryid, char *objects);
|
||||||
|
@ -299,7 +299,6 @@ void hash_dealloc_object_entry(uint64 queryid, char *objects);
|
||||||
bool IsHashInitialize(void);
|
bool IsHashInitialize(void);
|
||||||
void pgss_shmem_startup(void);
|
void pgss_shmem_startup(void);
|
||||||
void pgss_shmem_shutdown(int code, Datum arg);
|
void pgss_shmem_shutdown(int code, Datum arg);
|
||||||
shmem_startup_hook_type prev_shmem_startup_hook;
|
|
||||||
int pgsm_get_bucket_size(void);
|
int pgsm_get_bucket_size(void);
|
||||||
pgssSharedState* pgsm_get_ss(void);
|
pgssSharedState* pgsm_get_ss(void);
|
||||||
HTAB* pgsm_get_wait_event_hash(void);
|
HTAB* pgsm_get_wait_event_hash(void);
|
||||||
|
@ -311,19 +310,22 @@ pgssEntry* hash_entry_alloc(pgssSharedState *pgss, pgssHashKey *key, int encodin
|
||||||
Size hash_memsize(void);
|
Size hash_memsize(void);
|
||||||
pgssEntry* hash_create_query_entry(unsigned int queryid, unsigned int userid, unsigned int dbid, unsigned int bucket_id, unsigned int ip);
|
pgssEntry* hash_create_query_entry(unsigned int queryid, unsigned int userid, unsigned int dbid, unsigned int bucket_id, unsigned int ip);
|
||||||
|
|
||||||
/*---- GUC variables ----*/
|
/* hash_query.c */
|
||||||
#define PGSM_MAX conf[0].guc_variable
|
void pgss_startup(void);
|
||||||
#define PGSM_QUERY_MAX_LEN conf[1].guc_variable
|
void set_qbuf(int i, unsigned char *);
|
||||||
#define PGSM_ENABLED conf[2].guc_variable
|
|
||||||
#define PGSM_TRACK_UTILITY conf[3].guc_variable
|
/*---- GUC variables ----*/
|
||||||
#define PGSM_NORMALIZED_QUERY conf[4].guc_variable
|
#define PGSM_MAX get_conf(0)->guc_variable
|
||||||
#define PGSM_MAX_BUCKETS conf[5].guc_variable
|
#define PGSM_QUERY_MAX_LEN get_conf(1)->guc_variable
|
||||||
#define PGSM_BUCKET_TIME conf[6].guc_variable
|
#define PGSM_ENABLED get_conf(2)->guc_variable
|
||||||
#define PGSM_OBJECT_CACHE conf[7].guc_variable
|
#define PGSM_TRACK_UTILITY get_conf(3)->guc_variable
|
||||||
#define PGSM_RESPOSE_TIME_LOWER_BOUND conf[8].guc_variable
|
#define PGSM_NORMALIZED_QUERY get_conf(4)->guc_variable
|
||||||
#define PGSM_RESPOSE_TIME_STEP conf[9].guc_variable
|
#define PGSM_MAX_BUCKETS get_conf(5)->guc_variable
|
||||||
#define PGSM_QUERY_BUF_SIZE conf[10].guc_variable
|
#define PGSM_BUCKET_TIME get_conf(6)->guc_variable
|
||||||
#define PGSM_TRACK_PLANNING conf[11].guc_variable
|
#define PGSM_OBJECT_CACHE get_conf(7)->guc_variable
|
||||||
|
#define PGSM_RESPOSE_TIME_LOWER_BOUND get_conf(8)->guc_variable
|
||||||
|
#define PGSM_RESPOSE_TIME_STEP get_conf(9)->guc_variable
|
||||||
|
#define PGSM_QUERY_BUF_SIZE get_conf(10)->guc_variable
|
||||||
|
#define PGSM_TRACK_PLANNING get_conf(11)->guc_variable
|
||||||
|
|
||||||
GucVariable conf[12];
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue