Issue - (#10): The hist_* is not working in CentOS.

pull/12/head
Ibrar Ahmed 2019-12-03 10:30:59 +00:00
parent 7a0023688b
commit 344b12a3a6
1 changed files with 11 additions and 7 deletions

View File

@ -98,7 +98,7 @@ PG_MODULE_MAGIC;
/* Location of permanent stats file (valid when database is shut down) */ /* Location of permanent stats file (valid when database is shut down) */
#define PGSS_DUMP_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "/pg_stat_monitor.stat" #define PGSS_DUMP_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "/pg_stat_monitor.stat"
#define ArrayGetTextDatum(x) arry_get_datum(x) #define ArrayGetTextDatum(x) array_get_datum(x)
/* /*
* Location of external query text file. We don't keep it in the core * Location of external query text file. We don't keep it in the core
@ -354,7 +354,7 @@ PG_FUNCTION_INFO_V1(pg_stat_monitor);
/* Extended version function prototypes */ /* Extended version function prototypes */
PG_FUNCTION_INFO_V1(pg_stat_agg); PG_FUNCTION_INFO_V1(pg_stat_agg);
static uint pg_get_client_addr(); static uint pg_get_client_addr();
static Datum arry_get_datum(double arr[]); static Datum array_get_datum(double arr[]);
static void update_agg_counters(uint64 queryid, uint64 id, uint64 type); static void update_agg_counters(uint64 queryid, uint64 id, uint64 type);
static void hash_remove_agg(uint64 queryid); static void hash_remove_agg(uint64 queryid);
static pgssAggEntry *agg_entry_alloc(pgssAggHashKey *key); static pgssAggEntry *agg_entry_alloc(pgssAggHashKey *key);
@ -3422,23 +3422,27 @@ comp_location(const void *a, const void *b)
/* Convert array into Text dataum */ /* Convert array into Text dataum */
static Datum static Datum
arry_get_datum(double arr[]) array_get_datum(double arr[])
{ {
int j; int j;
char str[1024]; char str[1024];
bool first = true; char tmp[10];
bool first = true;
/* Need to calculate the actual size, and avoid unnessary memory usage */ /* Need to calculate the actual size, and avoid unnessary memory usage */
memset(str, 0, 1024);
for (j = 0; j < 24; j++) for (j = 0; j < 24; j++)
{ {
if (first) if (first)
{ {
snprintf(str, 1024, "%s %04.1f", str, arr[j]); snprintf(str, 1024, "%s %04.1f", str, arr[j]);
snprintf(tmp, 10, "%04.1f", arr[j]);
strcat(str,tmp);
first = false; first = false;
continue; continue;
} }
sprintf(str, "%s, %04.1f", str, arr[j]); sprintf(str, "%s, %04.1f", str, arr[j]);
snprintf(tmp, 10, ", %04.1f", arr[j]);
strcat(str,tmp);
} }
return CStringGetTextDatum(str); return CStringGetTextDatum(str);
} }