Update to pg_statsinfo 10.0 to work with PostgreSQL 11

OK ajacoutot@
This commit is contained in:
jeremy 2019-02-19 05:10:26 +00:00
parent 7cf2bd0896
commit 35199bb658
6 changed files with 28 additions and 135 deletions

View File

@ -1,10 +1,9 @@
# $OpenBSD: Makefile,v 1.11 2018/06/01 14:24:55 sthen Exp $
# $OpenBSD: Makefile,v 1.12 2019/02/19 05:10:26 jeremy Exp $
COMMENT = monitor PostgreSQL activity & statistics
DISTNAME = pg_statsinfo-3.3.0
DISTNAME = pg_statsinfo-10.0
CATEGORIES = databases
REVISION = 0
HOMEPAGE = http://pgstatsinfo.sourceforge.net/

View File

@ -1,2 +1,2 @@
SHA256 (pg_statsinfo-3.3.0.tar.gz) = OOxbFr1QyHZAo1f7qxEhXHknihc+H/+ZFM1rzF1FFQw=
SIZE (pg_statsinfo-3.3.0.tar.gz) = 912251
SHA256 (pg_statsinfo-10.0.tar.gz) = l/IPCUHrYI5JQFvZz83N06rXoZ4eb8TpNaHVkkp4DKM=
SIZE (pg_statsinfo-10.0.tar.gz) = 921560

View File

@ -1,19 +0,0 @@
$OpenBSD: patch-agent_bin_pgut_pgut_c,v 1.1 2017/11/30 16:16:24 jeremy Exp $
Fix build with PostgreSQL 10.
Index: agent/bin/pgut/pgut.c
--- agent/bin/pgut/pgut.c.orig
+++ agent/bin/pgut/pgut.c
@@ -388,7 +388,10 @@ parse_time(const char *value, time_t *time)
static char *
prompt_for_password(void)
{
- return simple_prompt("Password: ", 100, false);
+ char * dest;
+ dest = malloc(100);
+ simple_prompt("Password: ", dest, 100, false);
+ return dest;
}
#if PG_VERSION_NUM < 80300

View File

@ -1,60 +0,0 @@
$OpenBSD: patch-agent_lib_last_xact_activity_c,v 1.3 2017/11/30 16:18:22 jeremy Exp $
Index: agent/lib/last_xact_activity.c
--- agent/lib/last_xact_activity.c.orig
+++ agent/lib/last_xact_activity.c
@@ -97,10 +97,11 @@ static void make_status_snapshot(void);
static statEntry *get_snapshot_entry(int beid);
static Size buffer_size(int nbackends);
#if PG_VERSION_NUM >= 90000
-static void myProcessUtility0(Node *parsetree, const char *queryString);
+static void myProcessUtility0(PlannedStmt *pstmt, const char *queryString);
#if PG_VERSION_NUM >= 90300
-static void myProcessUtility(Node *parsetree, const char *queryString,
+static void myProcessUtility(PlannedStmt *pstmt, const char *queryString,
ProcessUtilityContext context, ParamListInfo params,
+ QueryEnvironment *queryEnv,
DestReceiver *dest, char *completionTag);
#else
static void myProcessUtility(Node *parsetree,
@@ -326,10 +327,11 @@ exit_transaction_if_needed()
}
static void
-myProcessUtility0(Node *parsetree, const char *queryString)
+myProcessUtility0(PlannedStmt *pstmt, const char *queryString)
{
statEntry *entry;
TransactionStmt *stmt;
+ Node *parsetree = pstmt->utilityStmt;
entry = get_stat_entry(MyBackendId);
@@ -412,22 +414,23 @@ myProcessUtility0(Node *parsetree, const char *querySt
*/
#if PG_VERSION_NUM >= 90300
static void
-myProcessUtility(Node *parsetree, const char *queryString,
+myProcessUtility(PlannedStmt *pstmt, const char *queryString,
ProcessUtilityContext context, ParamListInfo params,
+ QueryEnvironment *queryEnv,
DestReceiver *dest, char *completionTag)
{
/*
* Do my process before other hook runs.
*/
- myProcessUtility0(parsetree, queryString);
+ myProcessUtility0(pstmt, queryString);
PG_TRY();
{
if (prev_ProcessUtility_hook)
- prev_ProcessUtility_hook(parsetree, queryString, context, params,
+ prev_ProcessUtility_hook(pstmt, queryString, context, params, queryEnv,
dest, completionTag);
else
- standard_ProcessUtility(parsetree, queryString, context, params,
+ standard_ProcessUtility(pstmt, queryString, context, params, queryEnv,
dest, completionTag);
}
PG_CATCH();

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-agent_lib_libstatsinfo_c,v 1.5 2017/11/30 16:18:22 jeremy Exp $
$OpenBSD: patch-agent_lib_libstatsinfo_c,v 1.6 2019/02/19 05:10:26 jeremy Exp $
Work with PostgreSQL 10.
@ -13,15 +13,6 @@ Index: agent/lib/libstatsinfo.c
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -19,7 +20,7 @@
#include "catalog/pg_control.h"
#include "catalog/pg_tablespace.h"
#include "funcapi.h"
-#include "libpq/ip.h"
+#include "common/ip.h"
#include "libpq/pqsignal.h"
#include "mb/pg_wchar.h"
#include "regex/regex.h"
@@ -37,6 +38,7 @@
#include "utils/tqual.h"
#include "utils/lsyscache.h"
@ -30,15 +21,24 @@ Index: agent/lib/libstatsinfo.c
#if PG_VERSION_NUM >= 90100
#include "catalog/pg_collation.h"
@@ -566,6 +568,7 @@ sample_activity(void)
int waiting;
int running;
@@ -595,6 +597,7 @@ sample_activity(void)
int waiting = 0;
int running = 0;
int i;
+ volatile PGPROC *proc = MyProc;
if (!long_xacts)
{
@@ -1853,9 +1856,11 @@ statsinfo_restart(PG_FUNCTION_ARGS)
@@ -708,7 +711,7 @@ sample_activity(void)
"<IDLE> in transaction", pgstat_track_activity_query_size);
else
strlcpy(entry->query,
- be->st_activity, pgstat_track_activity_query_size);
+ be->st_activity_raw, pgstat_track_activity_query_size);
#else
strlcpy(entry->query,
be->st_activity, pgstat_track_activity_query_size);
@@ -1882,9 +1885,11 @@ statsinfo_restart(PG_FUNCTION_ARGS)
#define NUM_STAT_FIELDS_MIN 6
/* not support a kernel that does not have the required fields at "/proc/stat" */
@ -50,7 +50,7 @@ Index: agent/lib/libstatsinfo.c
/*
* statsinfo_cpustats - get cpu information
@@ -1894,6 +1899,7 @@ statsinfo_cpustats_noarg(PG_FUNCTION_ARGS)
@@ -1923,6 +1928,7 @@ statsinfo_cpustats_noarg(PG_FUNCTION_ARGS)
PG_RETURN_DATUM(get_cpustats(fcinfo, 0, 0, 0, 0));
}
@ -58,7 +58,7 @@ Index: agent/lib/libstatsinfo.c
static Datum
get_cpustats(FunctionCallInfo fcinfo,
int64 prev_cpu_user,
@@ -1906,6 +1912,59 @@ get_cpustats(FunctionCallInfo fcinfo,
@@ -1935,6 +1941,59 @@ get_cpustats(FunctionCallInfo fcinfo,
int64 cpu_system;
int64 cpu_idle;
int64 cpu_iowait;
@ -118,7 +118,7 @@ Index: agent/lib/libstatsinfo.c
List *records = NIL;
List *fields = NIL;
HeapTuple tuple;
@@ -1978,6 +2037,7 @@ get_cpustats(FunctionCallInfo fcinfo,
@@ -2007,6 +2066,7 @@ get_cpustats(FunctionCallInfo fcinfo,
return HeapTupleGetDatum(tuple);
}
@ -126,7 +126,7 @@ Index: agent/lib/libstatsinfo.c
#define NUM_DEVICESTATS_COLS 17
#define TYPE_DEVICE_TABLESPACES TEXTOID
@@ -2151,10 +2211,46 @@ statsinfo_devicestats(PG_FUNCTION_ARGS)
@@ -2180,10 +2240,46 @@ statsinfo_devicestats(PG_FUNCTION_ARGS)
/*
* statsinfo_loadavg - get loadavg information
*/
@ -173,7 +173,7 @@ Index: agent/lib/libstatsinfo.c
int fd;
char buffer[256];
int nbytes;
@@ -2213,6 +2309,7 @@ statsinfo_loadavg(PG_FUNCTION_ARGS)
@@ -2242,6 +2338,7 @@ statsinfo_loadavg(PG_FUNCTION_ARGS)
return HeapTupleGetDatum(tuple);
}
@ -181,7 +181,7 @@ Index: agent/lib/libstatsinfo.c
#define FILE_MEMINFO "/proc/meminfo"
#define NUM_MEMORY_COLS 5
@@ -2232,6 +2329,7 @@ compare_meminfo_table(const void *a, const void *b)
@@ -2261,6 +2358,7 @@ compare_meminfo_table(const void *a, const void *b)
/*
* statsinfo_memory - get memory information
*/
@ -189,7 +189,7 @@ Index: agent/lib/libstatsinfo.c
Datum
statsinfo_memory(PG_FUNCTION_ARGS)
{
@@ -2239,6 +2337,36 @@ statsinfo_memory(PG_FUNCTION_ARGS)
@@ -2268,6 +2366,36 @@ statsinfo_memory(PG_FUNCTION_ARGS)
HeapTuple tuple;
Datum values[NUM_MEMORY_COLS];
bool nulls[NUM_MEMORY_COLS];
@ -226,7 +226,7 @@ Index: agent/lib/libstatsinfo.c
int fd;
char buffer[2048];
int nbytes;
@@ -2337,6 +2465,7 @@ nextline:
@@ -2366,6 +2494,7 @@ nextline:
return HeapTupleGetDatum(tuple);
}
@ -234,7 +234,7 @@ Index: agent/lib/libstatsinfo.c
#define FILE_PROFILE "/proc/systemtap/statsinfo_prof/profile"
#define NUM_PROFILE_COLS 3
@@ -2345,9 +2474,16 @@ nextline:
@@ -2374,9 +2503,16 @@ nextline:
/*
* statsinfo_profile - get profile information
*/
@ -251,7 +251,7 @@ Index: agent/lib/libstatsinfo.c
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
TupleDesc tupdesc;
Tuplestorestate *tupstore;
@@ -2454,6 +2590,7 @@ statsinfo_profile(PG_FUNCTION_ARGS)
@@ -2483,6 +2619,7 @@ statsinfo_profile(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
@ -259,11 +259,3 @@ Index: agent/lib/libstatsinfo.c
static bool
checked_write(int fd, const void *buf, int size)
@@ -2557,7 +2694,6 @@ StartStatsinfoLauncher(void)
worker.bgw_flags = BGWORKER_SHMEM_ACCESS;
worker.bgw_start_time = BgWorkerStart_PostmasterStart;
worker.bgw_restart_time = BGW_NEVER_RESTART;
- worker.bgw_main = StatsinfoLauncherMain;
worker.bgw_main_arg = (Datum) NULL;
#if PG_VERSION_NUM >= 90400
worker.bgw_notify_pid = 0;

View File

@ -1,19 +0,0 @@
$OpenBSD: patch-reporter_pgut_pgut_c,v 1.1 2017/11/30 16:18:22 jeremy Exp $
Work with PostgreSQL 10.
Index: reporter/pgut/pgut.c
--- reporter/pgut/pgut.c.orig
+++ reporter/pgut/pgut.c
@@ -387,7 +387,10 @@ parse_time(const char *value, time_t *time)
static char *
prompt_for_password(void)
{
- return simple_prompt("Password: ", 100, false);
+ char * dest;
+ dest = malloc(100);
+ simple_prompt("Password: ", dest, 100, false);
+ return dest;
}
#if PG_VERSION_NUM < 80300