2004-10-01 23:03:42 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* pgstatfuncs.c
|
|
|
|
* Functions for accessing the statistics collector data
|
|
|
|
*
|
2019-01-02 18:44:25 +01:00
|
|
|
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
2004-10-01 23:03:42 +02:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/backend/utils/adt/pgstatfuncs.c
|
2004-10-01 23:03:42 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2001-06-22 21:18:36 +02:00
|
|
|
#include "postgres.h"
|
|
|
|
|
2012-08-30 22:15:44 +02:00
|
|
|
#include "access/htup_details.h"
|
2017-03-30 20:18:53 +02:00
|
|
|
#include "catalog/pg_authid.h"
|
2011-09-09 19:23:41 +02:00
|
|
|
#include "catalog/pg_type.h"
|
2016-09-02 12:49:59 +02:00
|
|
|
#include "common/ip.h"
|
2004-10-01 23:03:42 +02:00
|
|
|
#include "funcapi.h"
|
|
|
|
#include "miscadmin.h"
|
2001-06-22 21:18:36 +02:00
|
|
|
#include "pgstat.h"
|
2017-08-31 18:24:47 +02:00
|
|
|
#include "postmaster/bgworker_internals.h"
|
2017-03-27 04:02:22 +02:00
|
|
|
#include "postmaster/postmaster.h"
|
2016-03-10 18:44:09 +01:00
|
|
|
#include "storage/proc.h"
|
|
|
|
#include "storage/procarray.h"
|
2015-03-19 20:02:33 +01:00
|
|
|
#include "utils/acl.h"
|
2006-07-11 19:26:59 +02:00
|
|
|
#include "utils/builtins.h"
|
2005-05-09 13:31:34 +02:00
|
|
|
#include "utils/inet.h"
|
2011-09-09 19:23:41 +02:00
|
|
|
#include "utils/timestamp.h"
|
2001-06-22 21:18:36 +02:00
|
|
|
|
2016-06-10 00:02:36 +02:00
|
|
|
#define UINT32_ACCESS_ONCE(var) ((uint32)(*((volatile uint32 *)&(var))))
|
2016-04-21 20:02:15 +02:00
|
|
|
|
2007-03-30 20:34:56 +02:00
|
|
|
/* Global bgwriter statistics, from bgwriter.c */
|
|
|
|
extern PgStat_MsgBgWriter bgwriterStats;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_numscans(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (tabentry->numscans);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_tuples_returned(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (tabentry->tuples_returned);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (tabentry->tuples_fetched);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (tabentry->tuples_inserted);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_tuples_updated(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (tabentry->tuples_updated);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (tabentry->tuples_deleted);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-20 19:56:33 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_tuples_hot_updated(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatTabEntry *tabentry;
|
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->tuples_hot_updated);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-02 21:59:32 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_get_live_tuples(PG_FUNCTION_ARGS)
|
2007-11-15 22:14:46 +01:00
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatTabEntry *tabentry;
|
|
|
|
|
2007-01-02 21:59:32 +01:00
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->n_live_tuples);
|
2007-11-15 22:14:46 +01:00
|
|
|
|
2007-01-02 21:59:32 +01:00
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
2007-11-15 22:14:46 +01:00
|
|
|
|
2007-01-02 21:59:32 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_get_dead_tuples(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2007-11-15 22:14:46 +01:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatTabEntry *tabentry;
|
2007-01-02 21:59:32 +01:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->n_dead_tuples);
|
2007-11-15 22:14:46 +01:00
|
|
|
|
2007-01-02 21:59:32 +01:00
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-05 15:02:09 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_mod_since_analyze(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatTabEntry *tabentry;
|
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->changes_since_analyze);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-22 21:18:36 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (tabentry->blocks_fetched);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_blocks_hit(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (tabentry->blocks_hit);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
2006-05-19 21:08:27 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_last_vacuum_time(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2006-10-04 02:30:14 +02:00
|
|
|
TimestampTz result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2006-05-19 21:08:27 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = tabentry->vacuum_timestamp;
|
|
|
|
|
|
|
|
if (result == 0)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
else
|
|
|
|
PG_RETURN_TIMESTAMPTZ(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_last_autovacuum_time(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2006-10-04 02:30:14 +02:00
|
|
|
TimestampTz result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2006-05-19 21:08:27 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = tabentry->autovac_vacuum_timestamp;
|
|
|
|
|
|
|
|
if (result == 0)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
else
|
|
|
|
PG_RETURN_TIMESTAMPTZ(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_last_analyze_time(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2006-10-04 02:30:14 +02:00
|
|
|
TimestampTz result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2006-05-19 21:08:27 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = tabentry->analyze_timestamp;
|
|
|
|
|
|
|
|
if (result == 0)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
else
|
|
|
|
PG_RETURN_TIMESTAMPTZ(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_last_autoanalyze_time(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid relid = PG_GETARG_OID(0);
|
2006-10-04 02:30:14 +02:00
|
|
|
TimestampTz result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2006-05-19 21:08:27 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = tabentry->autovac_analyze_timestamp;
|
|
|
|
|
|
|
|
if (result == 0)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
else
|
|
|
|
PG_RETURN_TIMESTAMPTZ(result);
|
|
|
|
}
|
2001-06-22 21:18:36 +02:00
|
|
|
|
2010-08-21 12:59:17 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_vacuum_count(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
2011-04-10 17:42:00 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2010-08-21 12:59:17 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->vacuum_count);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_autovacuum_count(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
2011-04-10 17:42:00 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2010-08-21 12:59:17 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->autovac_vacuum_count);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_analyze_count(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
2011-04-10 17:42:00 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2010-08-21 12:59:17 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->analyze_count);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_autoanalyze_count(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
2011-04-10 17:42:00 +02:00
|
|
|
PgStat_StatTabEntry *tabentry;
|
2010-08-21 12:59:17 +02:00
|
|
|
|
|
|
|
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->autovac_analyze_count);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
2008-05-15 02:17:41 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_function_calls(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2009-06-11 16:49:15 +02:00
|
|
|
Oid funcid = PG_GETARG_OID(0);
|
2008-05-15 02:17:41 +02:00
|
|
|
PgStat_StatFuncEntry *funcentry;
|
|
|
|
|
|
|
|
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
PG_RETURN_INT64(funcentry->f_numcalls);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
2012-04-30 20:02:47 +02:00
|
|
|
pg_stat_get_function_total_time(PG_FUNCTION_ARGS)
|
2008-05-15 02:17:41 +02:00
|
|
|
{
|
2009-06-11 16:49:15 +02:00
|
|
|
Oid funcid = PG_GETARG_OID(0);
|
2008-05-15 02:17:41 +02:00
|
|
|
PgStat_StatFuncEntry *funcentry;
|
|
|
|
|
|
|
|
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
2012-04-30 20:02:47 +02:00
|
|
|
/* convert counter from microsec to millisec for display */
|
|
|
|
PG_RETURN_FLOAT8(((double) funcentry->f_total_time) / 1000.0);
|
2008-05-15 02:17:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_function_self_time(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2009-06-11 16:49:15 +02:00
|
|
|
Oid funcid = PG_GETARG_OID(0);
|
2008-05-15 02:17:41 +02:00
|
|
|
PgStat_StatFuncEntry *funcentry;
|
|
|
|
|
|
|
|
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
2012-04-30 20:02:47 +02:00
|
|
|
/* convert counter from microsec to millisec for display */
|
|
|
|
PG_RETURN_FLOAT8(((double) funcentry->f_self_time) / 1000.0);
|
2008-05-15 02:17:41 +02:00
|
|
|
}
|
|
|
|
|
2001-06-22 21:18:36 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_backend_idset(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2004-10-01 23:03:42 +02:00
|
|
|
FuncCallContext *funcctx;
|
|
|
|
int *fctx;
|
2001-10-25 07:50:21 +02:00
|
|
|
int32 result;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
2004-10-01 23:03:42 +02:00
|
|
|
/* stuff done only on the first call of the function */
|
|
|
|
if (SRF_IS_FIRSTCALL())
|
2001-06-22 21:18:36 +02:00
|
|
|
{
|
2004-10-01 23:03:42 +02:00
|
|
|
/* create a function context for cross-call persistence */
|
|
|
|
funcctx = SRF_FIRSTCALL_INIT();
|
|
|
|
|
|
|
|
fctx = MemoryContextAlloc(funcctx->multi_call_memory_ctx,
|
|
|
|
2 * sizeof(int));
|
|
|
|
funcctx->user_fctx = fctx;
|
2003-07-27 06:53:12 +02:00
|
|
|
|
2004-10-01 23:03:42 +02:00
|
|
|
fctx[0] = 0;
|
|
|
|
fctx[1] = pgstat_fetch_stat_numbackends();
|
2001-06-22 21:18:36 +02:00
|
|
|
}
|
|
|
|
|
2004-10-01 23:03:42 +02:00
|
|
|
/* stuff done on every call of the function */
|
|
|
|
funcctx = SRF_PERCALL_SETUP();
|
|
|
|
fctx = funcctx->user_fctx;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
2004-10-01 23:03:42 +02:00
|
|
|
fctx[0] += 1;
|
|
|
|
result = fctx[0];
|
|
|
|
|
|
|
|
if (result <= fctx[1])
|
2001-06-22 21:18:36 +02:00
|
|
|
{
|
2004-10-01 23:03:42 +02:00
|
|
|
/* do when there is more left to send */
|
|
|
|
SRF_RETURN_NEXT(funcctx, Int32GetDatum(result));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* do when there is no more left */
|
|
|
|
SRF_RETURN_DONE(funcctx);
|
2001-06-22 21:18:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add a generic command progress reporting facility.
Using this facility, any utility command can report the target relation
upon which it is operating, if there is one, and up to 10 64-bit
counters; the intent of this is that users should be able to figure out
what a utility command is doing without having to resort to ugly hacks
like attaching strace to a backend.
As a demonstration, this adds very crude reporting to lazy vacuum; we
just report the target relation and nothing else. A forthcoming patch
will make VACUUM report a bunch of additional data that will make this
much more interesting. But this gets the basic framework in place.
Vinayak Pokale, Rahila Syed, Amit Langote, Robert Haas, reviewed by
Kyotaro Horiguchi, Jim Nasby, Thom Brown, Masahiko Sawada, Fujii Masao,
and Masanori Oyama.
2016-03-09 18:08:58 +01:00
|
|
|
/*
|
|
|
|
* Returns command progress information for the named command.
|
|
|
|
*/
|
|
|
|
Datum
|
|
|
|
pg_stat_get_progress_info(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
#define PG_STAT_GET_PROGRESS_COLS PGSTAT_NUM_PROGRESS_PARAM + 3
|
|
|
|
int num_backends = pgstat_fetch_stat_numbackends();
|
|
|
|
int curr_backend;
|
|
|
|
char *cmd = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
2016-06-10 00:02:36 +02:00
|
|
|
ProgressCommandType cmdtype;
|
Add a generic command progress reporting facility.
Using this facility, any utility command can report the target relation
upon which it is operating, if there is one, and up to 10 64-bit
counters; the intent of this is that users should be able to figure out
what a utility command is doing without having to resort to ugly hacks
like attaching strace to a backend.
As a demonstration, this adds very crude reporting to lazy vacuum; we
just report the target relation and nothing else. A forthcoming patch
will make VACUUM report a bunch of additional data that will make this
much more interesting. But this gets the basic framework in place.
Vinayak Pokale, Rahila Syed, Amit Langote, Robert Haas, reviewed by
Kyotaro Horiguchi, Jim Nasby, Thom Brown, Masahiko Sawada, Fujii Masao,
and Masanori Oyama.
2016-03-09 18:08:58 +01:00
|
|
|
TupleDesc tupdesc;
|
|
|
|
Tuplestorestate *tupstore;
|
|
|
|
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
|
|
|
|
MemoryContext per_query_ctx;
|
|
|
|
MemoryContext oldcontext;
|
|
|
|
|
|
|
|
/* check to see if caller supports us returning a tuplestore */
|
|
|
|
if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
|
|
errmsg("set-valued function called in context that cannot accept a set")));
|
|
|
|
if (!(rsinfo->allowedModes & SFRM_Materialize))
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
|
|
errmsg("materialize mode required, but it is not " \
|
|
|
|
"allowed in this context")));
|
|
|
|
|
|
|
|
/* Build a tuple descriptor for our result type */
|
|
|
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
|
|
|
elog(ERROR, "return type must be a row type");
|
|
|
|
|
|
|
|
/* Translate command name into command type code. */
|
|
|
|
if (pg_strcasecmp(cmd, "VACUUM") == 0)
|
|
|
|
cmdtype = PROGRESS_COMMAND_VACUUM;
|
|
|
|
else
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
|
|
|
errmsg("invalid command name: \"%s\"", cmd)));
|
|
|
|
|
|
|
|
per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
|
|
|
|
oldcontext = MemoryContextSwitchTo(per_query_ctx);
|
|
|
|
|
|
|
|
tupstore = tuplestore_begin_heap(true, false, work_mem);
|
|
|
|
rsinfo->returnMode = SFRM_Materialize;
|
|
|
|
rsinfo->setResult = tupstore;
|
|
|
|
rsinfo->setDesc = tupdesc;
|
|
|
|
MemoryContextSwitchTo(oldcontext);
|
|
|
|
|
|
|
|
/* 1-based index */
|
|
|
|
for (curr_backend = 1; curr_backend <= num_backends; curr_backend++)
|
|
|
|
{
|
2016-06-10 00:02:36 +02:00
|
|
|
LocalPgBackendStatus *local_beentry;
|
|
|
|
PgBackendStatus *beentry;
|
Add a generic command progress reporting facility.
Using this facility, any utility command can report the target relation
upon which it is operating, if there is one, and up to 10 64-bit
counters; the intent of this is that users should be able to figure out
what a utility command is doing without having to resort to ugly hacks
like attaching strace to a backend.
As a demonstration, this adds very crude reporting to lazy vacuum; we
just report the target relation and nothing else. A forthcoming patch
will make VACUUM report a bunch of additional data that will make this
much more interesting. But this gets the basic framework in place.
Vinayak Pokale, Rahila Syed, Amit Langote, Robert Haas, reviewed by
Kyotaro Horiguchi, Jim Nasby, Thom Brown, Masahiko Sawada, Fujii Masao,
and Masanori Oyama.
2016-03-09 18:08:58 +01:00
|
|
|
Datum values[PG_STAT_GET_PROGRESS_COLS];
|
|
|
|
bool nulls[PG_STAT_GET_PROGRESS_COLS];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
MemSet(values, 0, sizeof(values));
|
|
|
|
MemSet(nulls, 0, sizeof(nulls));
|
|
|
|
|
|
|
|
local_beentry = pgstat_fetch_stat_local_beentry(curr_backend);
|
|
|
|
|
|
|
|
if (!local_beentry)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
beentry = &local_beentry->backendStatus;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Report values for only those backends which are running the given
|
|
|
|
* command.
|
|
|
|
*/
|
|
|
|
if (!beentry || beentry->st_progress_command != cmdtype)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Value available to all callers */
|
|
|
|
values[0] = Int32GetDatum(beentry->st_procpid);
|
|
|
|
values[1] = ObjectIdGetDatum(beentry->st_databaseid);
|
|
|
|
|
|
|
|
/* show rest of the values including relid only to role members */
|
|
|
|
if (has_privs_of_role(GetUserId(), beentry->st_userid))
|
|
|
|
{
|
|
|
|
values[2] = ObjectIdGetDatum(beentry->st_progress_command_target);
|
2016-06-10 00:02:36 +02:00
|
|
|
for (i = 0; i < PGSTAT_NUM_PROGRESS_PARAM; i++)
|
|
|
|
values[i + 3] = Int64GetDatum(beentry->st_progress_param[i]);
|
Add a generic command progress reporting facility.
Using this facility, any utility command can report the target relation
upon which it is operating, if there is one, and up to 10 64-bit
counters; the intent of this is that users should be able to figure out
what a utility command is doing without having to resort to ugly hacks
like attaching strace to a backend.
As a demonstration, this adds very crude reporting to lazy vacuum; we
just report the target relation and nothing else. A forthcoming patch
will make VACUUM report a bunch of additional data that will make this
much more interesting. But this gets the basic framework in place.
Vinayak Pokale, Rahila Syed, Amit Langote, Robert Haas, reviewed by
Kyotaro Horiguchi, Jim Nasby, Thom Brown, Masahiko Sawada, Fujii Masao,
and Masanori Oyama.
2016-03-09 18:08:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nulls[2] = true;
|
2016-03-10 12:07:57 +01:00
|
|
|
for (i = 0; i < PGSTAT_NUM_PROGRESS_PARAM; i++)
|
2016-06-10 00:02:36 +02:00
|
|
|
nulls[i + 3] = true;
|
Add a generic command progress reporting facility.
Using this facility, any utility command can report the target relation
upon which it is operating, if there is one, and up to 10 64-bit
counters; the intent of this is that users should be able to figure out
what a utility command is doing without having to resort to ugly hacks
like attaching strace to a backend.
As a demonstration, this adds very crude reporting to lazy vacuum; we
just report the target relation and nothing else. A forthcoming patch
will make VACUUM report a bunch of additional data that will make this
much more interesting. But this gets the basic framework in place.
Vinayak Pokale, Rahila Syed, Amit Langote, Robert Haas, reviewed by
Kyotaro Horiguchi, Jim Nasby, Thom Brown, Masahiko Sawada, Fujii Masao,
and Masanori Oyama.
2016-03-09 18:08:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clean up and return the tuplestore */
|
|
|
|
tuplestore_donestoring(tupstore);
|
|
|
|
|
|
|
|
return (Datum) 0;
|
|
|
|
}
|
|
|
|
|
2015-05-09 01:25:30 +02:00
|
|
|
/*
|
|
|
|
* Returns activity of PG backends.
|
|
|
|
*/
|
2008-05-07 16:41:56 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_activity(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2019-02-01 00:17:45 +01:00
|
|
|
#define PG_STAT_GET_ACTIVITY_COLS 26
|
2015-05-24 03:35:49 +02:00
|
|
|
int num_backends = pgstat_fetch_stat_numbackends();
|
|
|
|
int curr_backend;
|
|
|
|
int pid = PG_ARGISNULL(0) ? -1 : PG_GETARG_INT32(0);
|
|
|
|
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
|
|
|
|
TupleDesc tupdesc;
|
|
|
|
Tuplestorestate *tupstore;
|
|
|
|
MemoryContext per_query_ctx;
|
|
|
|
MemoryContext oldcontext;
|
2015-05-09 01:25:30 +02:00
|
|
|
|
|
|
|
/* check to see if caller supports us returning a tuplestore */
|
|
|
|
if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
|
|
errmsg("set-valued function called in context that cannot accept a set")));
|
|
|
|
if (!(rsinfo->allowedModes & SFRM_Materialize))
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
|
|
errmsg("materialize mode required, but it is not " \
|
|
|
|
"allowed in this context")));
|
|
|
|
|
|
|
|
/* Build a tuple descriptor for our result type */
|
|
|
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
|
|
|
elog(ERROR, "return type must be a row type");
|
|
|
|
|
|
|
|
per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
|
|
|
|
oldcontext = MemoryContextSwitchTo(per_query_ctx);
|
|
|
|
|
|
|
|
tupstore = tuplestore_begin_heap(true, false, work_mem);
|
|
|
|
rsinfo->returnMode = SFRM_Materialize;
|
|
|
|
rsinfo->setResult = tupstore;
|
|
|
|
rsinfo->setDesc = tupdesc;
|
|
|
|
|
|
|
|
MemoryContextSwitchTo(oldcontext);
|
|
|
|
|
|
|
|
/* 1-based index */
|
|
|
|
for (curr_backend = 1; curr_backend <= num_backends; curr_backend++)
|
2008-05-07 16:41:56 +02:00
|
|
|
{
|
|
|
|
/* for each row */
|
2015-05-09 01:25:30 +02:00
|
|
|
Datum values[PG_STAT_GET_ACTIVITY_COLS];
|
|
|
|
bool nulls[PG_STAT_GET_ACTIVITY_COLS];
|
2014-02-25 18:34:04 +01:00
|
|
|
LocalPgBackendStatus *local_beentry;
|
2008-05-07 16:41:56 +02:00
|
|
|
PgBackendStatus *beentry;
|
2016-03-10 18:44:09 +01:00
|
|
|
PGPROC *proc;
|
2017-03-27 04:02:22 +02:00
|
|
|
const char *wait_event_type = NULL;
|
|
|
|
const char *wait_event = NULL;
|
2008-05-07 16:41:56 +02:00
|
|
|
|
|
|
|
MemSet(values, 0, sizeof(values));
|
|
|
|
MemSet(nulls, 0, sizeof(nulls));
|
2009-06-11 16:49:15 +02:00
|
|
|
|
2015-05-09 01:25:30 +02:00
|
|
|
/* Get the next one in the list */
|
|
|
|
local_beentry = pgstat_fetch_stat_local_beentry(curr_backend);
|
|
|
|
if (!local_beentry)
|
2008-05-07 16:41:56 +02:00
|
|
|
{
|
2009-06-11 16:49:15 +02:00
|
|
|
int i;
|
2008-05-07 16:41:56 +02:00
|
|
|
|
2016-09-10 19:49:04 +02:00
|
|
|
/* Ignore missing entries if looking for specific PID */
|
|
|
|
if (pid != -1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (i = 0; i < lengthof(nulls); i++)
|
2008-05-07 16:41:56 +02:00
|
|
|
nulls[i] = true;
|
|
|
|
|
2012-01-19 14:19:20 +01:00
|
|
|
nulls[5] = false;
|
|
|
|
values[5] = CStringGetTextDatum("<backend information not available>");
|
2008-05-07 16:41:56 +02:00
|
|
|
|
2015-05-09 01:25:30 +02:00
|
|
|
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
|
|
|
|
continue;
|
2008-05-07 16:41:56 +02:00
|
|
|
}
|
|
|
|
|
2016-09-10 19:49:04 +02:00
|
|
|
beentry = &local_beentry->backendStatus;
|
|
|
|
|
|
|
|
/* If looking for specific PID, ignore all the others */
|
|
|
|
if (pid != -1 && beentry->st_procpid != pid)
|
|
|
|
continue;
|
|
|
|
|
2008-05-07 16:41:56 +02:00
|
|
|
/* Values available to all callers */
|
2017-03-27 04:02:22 +02:00
|
|
|
if (beentry->st_databaseid != InvalidOid)
|
|
|
|
values[0] = ObjectIdGetDatum(beentry->st_databaseid);
|
|
|
|
else
|
|
|
|
nulls[0] = true;
|
|
|
|
|
2008-05-07 16:41:56 +02:00
|
|
|
values[1] = Int32GetDatum(beentry->st_procpid);
|
2017-03-27 04:02:22 +02:00
|
|
|
|
|
|
|
if (beentry->st_userid != InvalidOid)
|
|
|
|
values[2] = ObjectIdGetDatum(beentry->st_userid);
|
|
|
|
else
|
|
|
|
nulls[2] = true;
|
|
|
|
|
2009-11-29 19:14:32 +01:00
|
|
|
if (beentry->st_appname)
|
|
|
|
values[3] = CStringGetTextDatum(beentry->st_appname);
|
|
|
|
else
|
|
|
|
nulls[3] = true;
|
2008-05-07 16:41:56 +02:00
|
|
|
|
2014-02-25 18:34:04 +01:00
|
|
|
if (TransactionIdIsValid(local_beentry->backend_xid))
|
2016-03-10 18:44:09 +01:00
|
|
|
values[15] = TransactionIdGetDatum(local_beentry->backend_xid);
|
2014-02-25 18:34:04 +01:00
|
|
|
else
|
2016-03-10 18:44:09 +01:00
|
|
|
nulls[15] = true;
|
2014-02-25 18:34:04 +01:00
|
|
|
|
|
|
|
if (TransactionIdIsValid(local_beentry->backend_xmin))
|
2016-03-10 18:44:09 +01:00
|
|
|
values[16] = TransactionIdGetDatum(local_beentry->backend_xmin);
|
2014-02-25 18:34:04 +01:00
|
|
|
else
|
2016-03-10 18:44:09 +01:00
|
|
|
nulls[16] = true;
|
2014-02-25 18:34:04 +01:00
|
|
|
|
2017-03-30 20:18:53 +02:00
|
|
|
/* Values only available to role member or pg_read_all_stats */
|
|
|
|
if (has_privs_of_role(GetUserId(), beentry->st_userid) ||
|
|
|
|
is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS))
|
2008-05-07 16:41:56 +02:00
|
|
|
{
|
2013-12-27 22:26:24 +01:00
|
|
|
SockAddr zero_clientaddr;
|
2017-09-19 20:46:07 +02:00
|
|
|
char *clipped_activity;
|
2013-12-27 22:26:24 +01:00
|
|
|
|
2012-01-19 14:19:20 +01:00
|
|
|
switch (beentry->st_state)
|
|
|
|
{
|
|
|
|
case STATE_IDLE:
|
|
|
|
values[4] = CStringGetTextDatum("idle");
|
|
|
|
break;
|
|
|
|
case STATE_RUNNING:
|
|
|
|
values[4] = CStringGetTextDatum("active");
|
|
|
|
break;
|
|
|
|
case STATE_IDLEINTRANSACTION:
|
|
|
|
values[4] = CStringGetTextDatum("idle in transaction");
|
|
|
|
break;
|
|
|
|
case STATE_FASTPATH:
|
|
|
|
values[4] = CStringGetTextDatum("fastpath function call");
|
|
|
|
break;
|
|
|
|
case STATE_IDLEINTRANSACTION_ABORTED:
|
|
|
|
values[4] = CStringGetTextDatum("idle in transaction (aborted)");
|
|
|
|
break;
|
|
|
|
case STATE_DISABLED:
|
|
|
|
values[4] = CStringGetTextDatum("disabled");
|
|
|
|
break;
|
|
|
|
case STATE_UNDEFINED:
|
|
|
|
nulls[4] = true;
|
|
|
|
break;
|
|
|
|
}
|
2013-04-03 20:13:28 +02:00
|
|
|
|
2017-09-19 20:46:07 +02:00
|
|
|
clipped_activity = pgstat_clip_activity(beentry->st_activity_raw);
|
|
|
|
values[5] = CStringGetTextDatum(clipped_activity);
|
|
|
|
pfree(clipped_activity);
|
2008-05-07 16:41:56 +02:00
|
|
|
|
2016-03-10 18:44:09 +01:00
|
|
|
proc = BackendPidGetProc(beentry->st_procpid);
|
2016-04-21 20:02:15 +02:00
|
|
|
if (proc != NULL)
|
|
|
|
{
|
2016-06-10 00:02:36 +02:00
|
|
|
uint32 raw_wait_event;
|
2016-04-21 20:02:15 +02:00
|
|
|
|
|
|
|
raw_wait_event = UINT32_ACCESS_ONCE(proc->wait_event_info);
|
|
|
|
wait_event_type = pgstat_get_wait_event_type(raw_wait_event);
|
|
|
|
wait_event = pgstat_get_wait_event(raw_wait_event);
|
|
|
|
|
|
|
|
}
|
2017-03-27 04:02:22 +02:00
|
|
|
else if (beentry->st_backendType != B_BACKEND)
|
2016-04-21 20:02:15 +02:00
|
|
|
{
|
2017-03-27 04:02:22 +02:00
|
|
|
/*
|
|
|
|
* For an auxiliary process, retrieve process info from
|
|
|
|
* AuxiliaryProcs stored in shared-memory.
|
|
|
|
*/
|
|
|
|
proc = AuxiliaryPidGetProc(beentry->st_procpid);
|
|
|
|
|
|
|
|
if (proc != NULL)
|
|
|
|
{
|
|
|
|
uint32 raw_wait_event;
|
|
|
|
|
|
|
|
raw_wait_event =
|
|
|
|
UINT32_ACCESS_ONCE(proc->wait_event_info);
|
|
|
|
wait_event_type =
|
|
|
|
pgstat_get_wait_event_type(raw_wait_event);
|
|
|
|
wait_event = pgstat_get_wait_event(raw_wait_event);
|
|
|
|
}
|
2016-04-21 20:02:15 +02:00
|
|
|
}
|
|
|
|
|
2016-03-10 18:44:09 +01:00
|
|
|
if (wait_event_type)
|
|
|
|
values[6] = CStringGetTextDatum(wait_event_type);
|
|
|
|
else
|
|
|
|
nulls[6] = true;
|
|
|
|
|
|
|
|
if (wait_event)
|
|
|
|
values[7] = CStringGetTextDatum(wait_event);
|
2008-05-07 16:41:56 +02:00
|
|
|
else
|
2012-01-19 14:19:20 +01:00
|
|
|
nulls[7] = true;
|
2008-05-07 16:41:56 +02:00
|
|
|
|
2016-03-10 18:44:09 +01:00
|
|
|
if (beentry->st_xact_start_timestamp != 0)
|
|
|
|
values[8] = TimestampTzGetDatum(beentry->st_xact_start_timestamp);
|
2008-05-07 16:41:56 +02:00
|
|
|
else
|
2012-01-19 14:19:20 +01:00
|
|
|
nulls[8] = true;
|
2008-05-07 16:41:56 +02:00
|
|
|
|
2016-03-10 18:44:09 +01:00
|
|
|
if (beentry->st_activity_start_timestamp != 0)
|
|
|
|
values[9] = TimestampTzGetDatum(beentry->st_activity_start_timestamp);
|
2008-05-07 16:41:56 +02:00
|
|
|
else
|
2012-01-19 14:19:20 +01:00
|
|
|
nulls[9] = true;
|
|
|
|
|
2016-03-10 18:44:09 +01:00
|
|
|
if (beentry->st_proc_start_timestamp != 0)
|
|
|
|
values[10] = TimestampTzGetDatum(beentry->st_proc_start_timestamp);
|
2012-01-19 14:19:20 +01:00
|
|
|
else
|
|
|
|
nulls[10] = true;
|
2008-05-07 16:41:56 +02:00
|
|
|
|
2016-03-10 18:44:09 +01:00
|
|
|
if (beentry->st_state_start_timestamp != 0)
|
|
|
|
values[11] = TimestampTzGetDatum(beentry->st_state_start_timestamp);
|
|
|
|
else
|
|
|
|
nulls[11] = true;
|
|
|
|
|
2008-05-07 16:41:56 +02:00
|
|
|
/* A zeroed client addr means we don't know */
|
|
|
|
memset(&zero_clientaddr, 0, sizeof(zero_clientaddr));
|
|
|
|
if (memcmp(&(beentry->st_clientaddr), &zero_clientaddr,
|
2013-12-27 22:26:24 +01:00
|
|
|
sizeof(zero_clientaddr)) == 0)
|
2008-05-07 16:41:56 +02:00
|
|
|
{
|
2012-01-19 14:19:20 +01:00
|
|
|
nulls[12] = true;
|
|
|
|
nulls[13] = true;
|
2016-03-10 18:44:09 +01:00
|
|
|
nulls[14] = true;
|
2008-05-07 16:41:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (beentry->st_clientaddr.addr.ss_family == AF_INET
|
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
|| beentry->st_clientaddr.addr.ss_family == AF_INET6
|
|
|
|
#endif
|
2009-06-11 16:49:15 +02:00
|
|
|
)
|
2008-05-07 16:41:56 +02:00
|
|
|
{
|
2009-06-11 16:49:15 +02:00
|
|
|
char remote_host[NI_MAXHOST];
|
2008-05-07 16:41:56 +02:00
|
|
|
char remote_port[NI_MAXSERV];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
remote_host[0] = '\0';
|
|
|
|
remote_port[0] = '\0';
|
|
|
|
ret = pg_getnameinfo_all(&beentry->st_clientaddr.addr,
|
|
|
|
beentry->st_clientaddr.salen,
|
|
|
|
remote_host, sizeof(remote_host),
|
|
|
|
remote_port, sizeof(remote_port),
|
|
|
|
NI_NUMERICHOST | NI_NUMERICSERV);
|
2011-08-09 17:28:35 +02:00
|
|
|
if (ret == 0)
|
2008-05-07 16:41:56 +02:00
|
|
|
{
|
|
|
|
clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family, remote_host);
|
2016-03-10 18:44:09 +01:00
|
|
|
values[12] = DirectFunctionCall1(inet_in,
|
Phase 3 of pgindent updates.
Don't move parenthesized lines to the left, even if that means they
flow past the right margin.
By default, BSD indent lines up statement continuation lines that are
within parentheses so that they start just to the right of the preceding
left parenthesis. However, traditionally, if that resulted in the
continuation line extending to the right of the desired right margin,
then indent would push it left just far enough to not overrun the margin,
if it could do so without making the continuation line start to the left of
the current statement indent. That makes for a weird mix of indentations
unless one has been completely rigid about never violating the 80-column
limit.
This behavior has been pretty universally panned by Postgres developers.
Hence, disable it with indent's new -lpl switch, so that parenthesized
lines are always lined up with the preceding left paren.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
2017-06-21 21:35:54 +02:00
|
|
|
CStringGetDatum(remote_host));
|
2014-04-02 03:30:08 +02:00
|
|
|
if (beentry->st_clienthostname &&
|
|
|
|
beentry->st_clienthostname[0])
|
2016-03-10 18:44:09 +01:00
|
|
|
values[13] = CStringGetTextDatum(beentry->st_clienthostname);
|
2011-02-17 22:03:28 +01:00
|
|
|
else
|
2016-03-10 18:44:09 +01:00
|
|
|
nulls[13] = true;
|
|
|
|
values[14] = Int32GetDatum(atoi(remote_port));
|
2008-05-07 16:41:56 +02:00
|
|
|
}
|
2011-08-09 17:28:35 +02:00
|
|
|
else
|
|
|
|
{
|
2012-01-19 14:19:20 +01:00
|
|
|
nulls[12] = true;
|
|
|
|
nulls[13] = true;
|
2016-03-10 18:44:09 +01:00
|
|
|
nulls[14] = true;
|
2011-08-09 17:28:35 +02:00
|
|
|
}
|
2008-05-07 16:41:56 +02:00
|
|
|
}
|
|
|
|
else if (beentry->st_clientaddr.addr.ss_family == AF_UNIX)
|
|
|
|
{
|
|
|
|
/*
|
2009-06-11 16:49:15 +02:00
|
|
|
* Unix sockets always reports NULL for host and -1 for
|
|
|
|
* port, so it's possible to tell the difference to
|
|
|
|
* connections we have no permissions to view, or with
|
|
|
|
* errors.
|
2008-05-07 16:41:56 +02:00
|
|
|
*/
|
2012-01-19 14:19:20 +01:00
|
|
|
nulls[12] = true;
|
2016-03-10 18:44:09 +01:00
|
|
|
nulls[13] = true;
|
2018-05-02 21:52:54 +02:00
|
|
|
values[14] = Int32GetDatum(-1);
|
2008-05-07 16:41:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Unknown address type, should never happen */
|
2012-01-19 14:19:20 +01:00
|
|
|
nulls[12] = true;
|
|
|
|
nulls[13] = true;
|
2016-03-10 18:44:09 +01:00
|
|
|
nulls[14] = true;
|
2008-05-07 16:41:56 +02:00
|
|
|
}
|
|
|
|
}
|
2017-03-27 04:02:22 +02:00
|
|
|
/* Add backend type */
|
2017-08-31 18:24:47 +02:00
|
|
|
if (beentry->st_backendType == B_BG_WORKER)
|
|
|
|
{
|
|
|
|
const char *bgw_type;
|
|
|
|
|
|
|
|
bgw_type = GetBackgroundWorkerTypeByPid(beentry->st_procpid);
|
|
|
|
if (bgw_type)
|
|
|
|
values[17] = CStringGetTextDatum(bgw_type);
|
|
|
|
else
|
|
|
|
nulls[17] = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
values[17] =
|
|
|
|
CStringGetTextDatum(pgstat_get_backend_desc(beentry->st_backendType));
|
2019-02-20 11:38:44 +01:00
|
|
|
|
|
|
|
/* SSL information */
|
|
|
|
if (beentry->st_ssl)
|
|
|
|
{
|
|
|
|
values[18] = BoolGetDatum(true); /* ssl */
|
|
|
|
values[19] = CStringGetTextDatum(beentry->st_sslstatus->ssl_version);
|
|
|
|
values[20] = CStringGetTextDatum(beentry->st_sslstatus->ssl_cipher);
|
|
|
|
values[21] = Int32GetDatum(beentry->st_sslstatus->ssl_bits);
|
|
|
|
values[22] = BoolGetDatum(beentry->st_sslstatus->ssl_compression);
|
|
|
|
|
|
|
|
if (beentry->st_sslstatus->ssl_client_dn[0])
|
|
|
|
values[23] = CStringGetTextDatum(beentry->st_sslstatus->ssl_client_dn);
|
|
|
|
else
|
|
|
|
nulls[23] = true;
|
|
|
|
|
|
|
|
if (beentry->st_sslstatus->ssl_client_serial[0])
|
|
|
|
values[24] = DirectFunctionCall3(numeric_in,
|
|
|
|
CStringGetDatum(beentry->st_sslstatus->ssl_client_serial),
|
|
|
|
ObjectIdGetDatum(InvalidOid),
|
|
|
|
Int32GetDatum(-1));
|
|
|
|
else
|
|
|
|
nulls[24] = true;
|
|
|
|
|
|
|
|
if (beentry->st_sslstatus->ssl_issuer_dn[0])
|
|
|
|
values[25] = CStringGetTextDatum(beentry->st_sslstatus->ssl_issuer_dn);
|
|
|
|
else
|
|
|
|
nulls[25] = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
values[18] = BoolGetDatum(false); /* ssl */
|
|
|
|
nulls[19] = nulls[20] = nulls[21] = nulls[22] = nulls[23] = nulls[24] = nulls[25] = true;
|
|
|
|
}
|
2008-05-07 16:41:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* No permissions to view data about this session */
|
2012-01-19 14:19:20 +01:00
|
|
|
values[5] = CStringGetTextDatum("<insufficient privilege>");
|
|
|
|
nulls[4] = true;
|
2008-05-07 16:41:56 +02:00
|
|
|
nulls[6] = true;
|
|
|
|
nulls[7] = true;
|
|
|
|
nulls[8] = true;
|
|
|
|
nulls[9] = true;
|
2009-11-29 00:38:08 +01:00
|
|
|
nulls[10] = true;
|
2011-02-17 22:03:28 +01:00
|
|
|
nulls[11] = true;
|
2012-01-19 14:19:20 +01:00
|
|
|
nulls[12] = true;
|
|
|
|
nulls[13] = true;
|
2016-03-10 18:44:09 +01:00
|
|
|
nulls[14] = true;
|
2017-03-27 04:02:22 +02:00
|
|
|
nulls[17] = true;
|
2019-02-20 11:38:44 +01:00
|
|
|
nulls[18] = true;
|
|
|
|
nulls[19] = true;
|
|
|
|
nulls[20] = true;
|
|
|
|
nulls[21] = true;
|
|
|
|
nulls[22] = true;
|
|
|
|
nulls[23] = true;
|
|
|
|
nulls[24] = true;
|
|
|
|
nulls[25] = true;
|
2008-05-07 16:41:56 +02:00
|
|
|
}
|
|
|
|
|
2015-05-09 01:25:30 +02:00
|
|
|
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
|
2008-05-07 16:41:56 +02:00
|
|
|
|
2015-05-09 01:25:30 +02:00
|
|
|
/* If only a single backend was requested, and we found it, break. */
|
|
|
|
if (pid != -1)
|
|
|
|
break;
|
2008-05-07 16:41:56 +02:00
|
|
|
}
|
2015-05-09 01:25:30 +02:00
|
|
|
|
|
|
|
/* clean up and return the tuplestore */
|
|
|
|
tuplestore_donestoring(tupstore);
|
|
|
|
|
|
|
|
return (Datum) 0;
|
2008-05-07 16:41:56 +02:00
|
|
|
}
|
|
|
|
|
2001-06-22 21:18:36 +02:00
|
|
|
|
2002-07-31 02:40:40 +02:00
|
|
|
Datum
|
2002-08-04 21:51:30 +02:00
|
|
|
pg_backend_pid(PG_FUNCTION_ARGS)
|
2002-07-31 02:40:40 +02:00
|
|
|
{
|
|
|
|
PG_RETURN_INT32(MyProcPid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-22 21:18:36 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_backend_pid(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
int32 beid = PG_GETARG_INT32(0);
|
|
|
|
PgBackendStatus *beentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2006-06-19 03:51:22 +02:00
|
|
|
PG_RETURN_INT32(beentry->st_procpid);
|
2001-06-22 21:18:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_backend_dbid(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
int32 beid = PG_GETARG_INT32(0);
|
|
|
|
PgBackendStatus *beentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2006-06-19 03:51:22 +02:00
|
|
|
PG_RETURN_OID(beentry->st_databaseid);
|
2001-06-22 21:18:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_backend_userid(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
int32 beid = PG_GETARG_INT32(0);
|
|
|
|
PgBackendStatus *beentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2006-06-19 03:51:22 +02:00
|
|
|
PG_RETURN_OID(beentry->st_userid);
|
2001-06-22 21:18:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
int32 beid = PG_GETARG_INT32(0);
|
|
|
|
PgBackendStatus *beentry;
|
|
|
|
const char *activity;
|
2017-11-29 15:24:24 +01:00
|
|
|
char *clipped_activity;
|
|
|
|
text *ret;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
2004-02-12 02:44:22 +01:00
|
|
|
activity = "<backend information not available>";
|
2015-03-19 20:02:33 +01:00
|
|
|
else if (!has_privs_of_role(GetUserId(), beentry->st_userid))
|
2004-02-12 02:44:22 +01:00
|
|
|
activity = "<insufficient privilege>";
|
2017-09-19 20:46:07 +02:00
|
|
|
else if (*(beentry->st_activity_raw) == '\0')
|
2004-02-12 02:44:22 +01:00
|
|
|
activity = "<command string not enabled>";
|
|
|
|
else
|
2017-09-19 20:46:07 +02:00
|
|
|
activity = beentry->st_activity_raw;
|
2003-03-20 19:51:16 +01:00
|
|
|
|
2017-09-19 20:46:07 +02:00
|
|
|
clipped_activity = pgstat_clip_activity(activity);
|
|
|
|
ret = cstring_to_text(activity);
|
|
|
|
pfree(clipped_activity);
|
|
|
|
|
|
|
|
PG_RETURN_TEXT_P(ret);
|
2001-06-22 21:18:36 +02:00
|
|
|
}
|
|
|
|
|
2006-08-19 03:36:34 +02:00
|
|
|
Datum
|
2016-03-10 18:44:09 +01:00
|
|
|
pg_stat_get_backend_wait_event_type(PG_FUNCTION_ARGS)
|
2006-08-19 03:36:34 +02:00
|
|
|
{
|
|
|
|
int32 beid = PG_GETARG_INT32(0);
|
|
|
|
PgBackendStatus *beentry;
|
2016-03-10 18:44:09 +01:00
|
|
|
PGPROC *proc;
|
2016-04-21 20:02:15 +02:00
|
|
|
const char *wait_event_type = NULL;
|
2006-08-19 03:36:34 +02:00
|
|
|
|
|
|
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
2016-03-10 18:44:09 +01:00
|
|
|
wait_event_type = "<backend information not available>";
|
|
|
|
else if (!has_privs_of_role(GetUserId(), beentry->st_userid))
|
|
|
|
wait_event_type = "<insufficient privilege>";
|
2016-04-21 20:02:15 +02:00
|
|
|
else if ((proc = BackendPidGetProc(beentry->st_procpid)) != NULL)
|
2016-03-10 18:44:09 +01:00
|
|
|
wait_event_type = pgstat_get_wait_event_type(proc->wait_event_info);
|
2006-08-19 03:36:34 +02:00
|
|
|
|
2016-03-10 18:44:09 +01:00
|
|
|
if (!wait_event_type)
|
2006-08-19 03:36:34 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2016-03-10 18:44:09 +01:00
|
|
|
PG_RETURN_TEXT_P(cstring_to_text(wait_event_type));
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_backend_wait_event(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
int32 beid = PG_GETARG_INT32(0);
|
|
|
|
PgBackendStatus *beentry;
|
|
|
|
PGPROC *proc;
|
2016-04-21 20:02:15 +02:00
|
|
|
const char *wait_event = NULL;
|
2016-03-10 18:44:09 +01:00
|
|
|
|
|
|
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
|
|
|
wait_event = "<backend information not available>";
|
|
|
|
else if (!has_privs_of_role(GetUserId(), beentry->st_userid))
|
|
|
|
wait_event = "<insufficient privilege>";
|
2016-04-21 20:02:15 +02:00
|
|
|
else if ((proc = BackendPidGetProc(beentry->st_procpid)) != NULL)
|
2016-03-10 18:44:09 +01:00
|
|
|
wait_event = pgstat_get_wait_event(proc->wait_event_info);
|
|
|
|
|
|
|
|
if (!wait_event)
|
|
|
|
PG_RETURN_NULL();
|
2006-08-19 03:36:34 +02:00
|
|
|
|
2016-03-10 18:44:09 +01:00
|
|
|
PG_RETURN_TEXT_P(cstring_to_text(wait_event));
|
2006-08-19 03:36:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-20 04:34:57 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2005-06-30 00:51:57 +02:00
|
|
|
int32 beid = PG_GETARG_INT32(0);
|
2003-08-04 02:43:34 +02:00
|
|
|
TimestampTz result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgBackendStatus *beentry;
|
2003-03-20 04:34:57 +01:00
|
|
|
|
2003-04-04 05:03:54 +02:00
|
|
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
2003-03-20 04:34:57 +01:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2015-03-19 20:02:33 +01:00
|
|
|
if (!has_privs_of_role(GetUserId(), beentry->st_userid))
|
2003-03-20 04:34:57 +01:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2006-06-19 03:51:22 +02:00
|
|
|
result = beentry->st_activity_start_timestamp;
|
2003-03-20 04:34:57 +01:00
|
|
|
|
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* No time recorded for start of current query -- this is the case if the
|
|
|
|
* user hasn't enabled query-level stats collection.
|
2003-03-20 04:34:57 +01:00
|
|
|
*/
|
2005-06-30 00:51:57 +02:00
|
|
|
if (result == 0)
|
2003-03-20 04:34:57 +01:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2003-04-04 05:03:54 +02:00
|
|
|
PG_RETURN_TIMESTAMPTZ(result);
|
2003-03-20 04:34:57 +01:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:06:48 +01:00
|
|
|
|
|
|
|
Datum
|
2007-09-11 05:28:05 +02:00
|
|
|
pg_stat_get_backend_xact_start(PG_FUNCTION_ARGS)
|
2006-12-06 19:06:48 +01:00
|
|
|
{
|
|
|
|
int32 beid = PG_GETARG_INT32(0);
|
|
|
|
TimestampTz result;
|
|
|
|
PgBackendStatus *beentry;
|
|
|
|
|
|
|
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2015-03-19 20:02:33 +01:00
|
|
|
if (!has_privs_of_role(GetUserId(), beentry->st_userid))
|
2006-12-06 19:06:48 +01:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2007-09-11 05:28:05 +02:00
|
|
|
result = beentry->st_xact_start_timestamp;
|
2006-12-06 19:06:48 +01:00
|
|
|
|
|
|
|
if (result == 0) /* not in a transaction */
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
|
|
|
PG_RETURN_TIMESTAMPTZ(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-09 13:31:34 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_backend_start(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2005-10-15 04:49:52 +02:00
|
|
|
int32 beid = PG_GETARG_INT32(0);
|
2005-05-09 13:31:34 +02:00
|
|
|
TimestampTz result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgBackendStatus *beentry;
|
2005-05-09 13:31:34 +02:00
|
|
|
|
|
|
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2015-03-19 20:02:33 +01:00
|
|
|
if (!has_privs_of_role(GetUserId(), beentry->st_userid))
|
2005-05-09 13:31:34 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2006-06-19 03:51:22 +02:00
|
|
|
result = beentry->st_proc_start_timestamp;
|
2005-05-09 13:31:34 +02:00
|
|
|
|
2005-06-30 00:51:57 +02:00
|
|
|
if (result == 0) /* probably can't happen? */
|
2005-05-09 13:31:34 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
|
|
|
PG_RETURN_TIMESTAMPTZ(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
int32 beid = PG_GETARG_INT32(0);
|
|
|
|
PgBackendStatus *beentry;
|
2006-05-19 17:15:37 +02:00
|
|
|
SockAddr zero_clientaddr;
|
2005-05-09 13:31:34 +02:00
|
|
|
char remote_host[NI_MAXHOST];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2015-03-19 20:02:33 +01:00
|
|
|
if (!has_privs_of_role(GetUserId(), beentry->st_userid))
|
2005-05-09 13:31:34 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2006-05-19 17:15:37 +02:00
|
|
|
/* A zeroed client addr means we don't know */
|
|
|
|
memset(&zero_clientaddr, 0, sizeof(zero_clientaddr));
|
2006-06-19 03:51:22 +02:00
|
|
|
if (memcmp(&(beentry->st_clientaddr), &zero_clientaddr,
|
2013-12-27 22:26:24 +01:00
|
|
|
sizeof(zero_clientaddr)) == 0)
|
2006-05-19 17:15:37 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2006-06-19 03:51:22 +02:00
|
|
|
switch (beentry->st_clientaddr.addr.ss_family)
|
2005-05-09 13:31:34 +02:00
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
case AF_INET6:
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
}
|
|
|
|
|
|
|
|
remote_host[0] = '\0';
|
2006-06-19 03:51:22 +02:00
|
|
|
ret = pg_getnameinfo_all(&beentry->st_clientaddr.addr,
|
|
|
|
beentry->st_clientaddr.salen,
|
2005-10-17 18:24:20 +02:00
|
|
|
remote_host, sizeof(remote_host),
|
|
|
|
NULL, 0,
|
|
|
|
NI_NUMERICHOST | NI_NUMERICSERV);
|
2011-08-09 17:28:35 +02:00
|
|
|
if (ret != 0)
|
2005-05-09 13:31:34 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2007-05-18 01:31:49 +02:00
|
|
|
clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family, remote_host);
|
|
|
|
|
2005-05-09 13:31:34 +02:00
|
|
|
PG_RETURN_INET_P(DirectFunctionCall1(inet_in,
|
|
|
|
CStringGetDatum(remote_host)));
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
int32 beid = PG_GETARG_INT32(0);
|
|
|
|
PgBackendStatus *beentry;
|
2006-05-19 17:15:37 +02:00
|
|
|
SockAddr zero_clientaddr;
|
2005-05-09 13:31:34 +02:00
|
|
|
char remote_port[NI_MAXSERV];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2015-03-19 20:02:33 +01:00
|
|
|
if (!has_privs_of_role(GetUserId(), beentry->st_userid))
|
2005-05-09 13:31:34 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2006-05-19 17:15:37 +02:00
|
|
|
/* A zeroed client addr means we don't know */
|
|
|
|
memset(&zero_clientaddr, 0, sizeof(zero_clientaddr));
|
2006-06-19 03:51:22 +02:00
|
|
|
if (memcmp(&(beentry->st_clientaddr), &zero_clientaddr,
|
2013-12-27 22:26:24 +01:00
|
|
|
sizeof(zero_clientaddr)) == 0)
|
2006-05-19 17:15:37 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2006-06-19 03:51:22 +02:00
|
|
|
switch (beentry->st_clientaddr.addr.ss_family)
|
2005-05-09 13:31:34 +02:00
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
case AF_INET6:
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case AF_UNIX:
|
|
|
|
PG_RETURN_INT32(-1);
|
|
|
|
default:
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
}
|
|
|
|
|
|
|
|
remote_port[0] = '\0';
|
2006-06-19 03:51:22 +02:00
|
|
|
ret = pg_getnameinfo_all(&beentry->st_clientaddr.addr,
|
|
|
|
beentry->st_clientaddr.salen,
|
2005-10-17 18:24:20 +02:00
|
|
|
NULL, 0,
|
|
|
|
remote_port, sizeof(remote_port),
|
|
|
|
NI_NUMERICHOST | NI_NUMERICSERV);
|
2011-08-09 17:28:35 +02:00
|
|
|
if (ret != 0)
|
2005-05-09 13:31:34 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2006-06-19 03:51:22 +02:00
|
|
|
PG_RETURN_DATUM(DirectFunctionCall1(int4in,
|
|
|
|
CStringGetDatum(remote_port)));
|
2005-05-09 13:31:34 +02:00
|
|
|
}
|
|
|
|
|
2003-03-20 04:34:57 +01:00
|
|
|
|
2001-06-22 21:18:36 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_db_numbackends(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int32 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
int tot_backends = pgstat_fetch_stat_numbackends();
|
|
|
|
int beid;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
2006-06-19 03:51:22 +02:00
|
|
|
result = 0;
|
|
|
|
for (beid = 1; beid <= tot_backends; beid++)
|
|
|
|
{
|
|
|
|
PgBackendStatus *beentry = pgstat_fetch_stat_beentry(beid);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
2006-06-19 03:51:22 +02:00
|
|
|
if (beentry && beentry->st_databaseid == dbid)
|
|
|
|
result++;
|
|
|
|
}
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT32(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatDBEntry *dbentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (dbentry->n_xact_commit);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatDBEntry *dbentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (dbentry->n_xact_rollback);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatDBEntry *dbentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (dbentry->n_blocks_fetched);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_blocks_hit(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2006-06-19 03:51:22 +02:00
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
int64 result;
|
2006-06-19 03:51:22 +02:00
|
|
|
PgStat_StatDBEntry *dbentry;
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2001-10-25 07:50:21 +02:00
|
|
|
result = (int64) (dbentry->n_blocks_hit);
|
2001-06-22 21:18:36 +02:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
2007-02-08 00:11:30 +01:00
|
|
|
|
|
|
|
|
2007-03-16 18:57:36 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_get_db_tuples_returned(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_tuples_returned);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_tuples_fetched(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_tuples_fetched);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_tuples_inserted(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_tuples_inserted);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_tuples_updated(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_tuples_updated);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_tuples_deleted(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_tuples_deleted);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
2011-02-10 15:09:35 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_get_db_stat_reset_time(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
TimestampTz result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = dbentry->stat_reset_timestamp;
|
|
|
|
|
|
|
|
if (result == 0)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
else
|
|
|
|
PG_RETURN_TIMESTAMPTZ(result);
|
|
|
|
}
|
|
|
|
|
2012-01-26 14:41:19 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_get_db_temp_files(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
2012-01-26 14:41:19 +01:00
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = dbentry->n_temp_files;
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_temp_bytes(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
2012-01-26 14:41:19 +01:00
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = dbentry->n_temp_bytes;
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
2011-01-03 12:46:03 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_get_db_conflict_tablespace(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_conflict_tablespace);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_conflict_lock(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_conflict_lock);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_conflict_snapshot(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_conflict_snapshot);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_conflict_bufferpin(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_conflict_bufferpin);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_conflict_startup_deadlock(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_conflict_startup_deadlock);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_db_conflict_all(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (
|
2011-04-10 17:42:00 +02:00
|
|
|
dbentry->n_conflict_tablespace +
|
|
|
|
dbentry->n_conflict_lock +
|
|
|
|
dbentry->n_conflict_snapshot +
|
|
|
|
dbentry->n_conflict_bufferpin +
|
|
|
|
dbentry->n_conflict_startup_deadlock);
|
2011-01-03 12:46:03 +01:00
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
2012-01-26 15:58:19 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_get_db_deadlocks(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_deadlocks);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
2019-03-09 19:45:17 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_get_db_checksum_failures(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (dbentry->n_checksum_failures);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
2012-04-05 17:37:31 +02:00
|
|
|
Datum
|
2012-04-30 00:13:33 +02:00
|
|
|
pg_stat_get_db_blk_read_time(PG_FUNCTION_ARGS)
|
2012-04-05 17:37:31 +02:00
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
2012-04-30 20:02:47 +02:00
|
|
|
double result;
|
2012-04-05 17:37:31 +02:00
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
2012-04-30 20:02:47 +02:00
|
|
|
/* convert counter from microsec to millisec for display */
|
2012-04-05 17:37:31 +02:00
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2012-04-30 20:02:47 +02:00
|
|
|
result = ((double) dbentry->n_block_read_time) / 1000.0;
|
2012-04-05 17:37:31 +02:00
|
|
|
|
2012-04-30 20:02:47 +02:00
|
|
|
PG_RETURN_FLOAT8(result);
|
2012-04-05 17:37:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
2012-04-30 00:13:33 +02:00
|
|
|
pg_stat_get_db_blk_write_time(PG_FUNCTION_ARGS)
|
2012-04-05 17:37:31 +02:00
|
|
|
{
|
|
|
|
Oid dbid = PG_GETARG_OID(0);
|
2012-04-30 20:02:47 +02:00
|
|
|
double result;
|
2012-04-05 17:37:31 +02:00
|
|
|
PgStat_StatDBEntry *dbentry;
|
|
|
|
|
2012-04-30 20:02:47 +02:00
|
|
|
/* convert counter from microsec to millisec for display */
|
2012-04-05 17:37:31 +02:00
|
|
|
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
2012-04-30 20:02:47 +02:00
|
|
|
result = ((double) dbentry->n_block_write_time) / 1000.0;
|
2012-04-05 17:37:31 +02:00
|
|
|
|
2012-04-30 20:02:47 +02:00
|
|
|
PG_RETURN_FLOAT8(result);
|
2012-04-05 17:37:31 +02:00
|
|
|
}
|
|
|
|
|
2007-03-30 20:34:56 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_bgwriter_timed_checkpoints(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
PG_RETURN_INT64(pgstat_fetch_global()->timed_checkpoints);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_bgwriter_requested_checkpoints(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
PG_RETURN_INT64(pgstat_fetch_global()->requested_checkpoints);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_bgwriter_buf_written_checkpoints(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
PG_RETURN_INT64(pgstat_fetch_global()->buf_written_checkpoints);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
2007-06-28 02:02:40 +02:00
|
|
|
pg_stat_get_bgwriter_buf_written_clean(PG_FUNCTION_ARGS)
|
2007-03-30 20:34:56 +02:00
|
|
|
{
|
2007-06-28 02:02:40 +02:00
|
|
|
PG_RETURN_INT64(pgstat_fetch_global()->buf_written_clean);
|
2007-03-30 20:34:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
2007-06-28 02:02:40 +02:00
|
|
|
pg_stat_get_bgwriter_maxwritten_clean(PG_FUNCTION_ARGS)
|
2007-03-30 20:34:56 +02:00
|
|
|
{
|
2007-06-28 02:02:40 +02:00
|
|
|
PG_RETURN_INT64(pgstat_fetch_global()->maxwritten_clean);
|
2007-03-30 20:34:56 +02:00
|
|
|
}
|
|
|
|
|
2012-04-05 20:03:21 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_checkpoint_write_time(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2012-04-30 20:02:47 +02:00
|
|
|
/* time is already in msec, just convert to double for presentation */
|
|
|
|
PG_RETURN_FLOAT8((double) pgstat_fetch_global()->checkpoint_write_time);
|
2012-04-05 20:03:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_checkpoint_sync_time(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2012-04-30 20:02:47 +02:00
|
|
|
/* time is already in msec, just convert to double for presentation */
|
|
|
|
PG_RETURN_FLOAT8((double) pgstat_fetch_global()->checkpoint_sync_time);
|
2012-04-05 20:03:21 +02:00
|
|
|
}
|
|
|
|
|
2011-02-10 15:09:35 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_get_bgwriter_stat_reset_time(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
PG_RETURN_TIMESTAMPTZ(pgstat_fetch_global()->stat_reset_timestamp);
|
|
|
|
}
|
|
|
|
|
2007-09-25 22:03:38 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_buf_written_backend(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
PG_RETURN_INT64(pgstat_fetch_global()->buf_written_backend);
|
|
|
|
}
|
|
|
|
|
2010-11-15 18:42:59 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_get_buf_fsync_backend(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
PG_RETURN_INT64(pgstat_fetch_global()->buf_fsync_backend);
|
|
|
|
}
|
|
|
|
|
2007-09-25 22:03:38 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_buf_alloc(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
PG_RETURN_INT64(pgstat_fetch_global()->buf_alloc);
|
|
|
|
}
|
|
|
|
|
2010-08-08 18:27:06 +02:00
|
|
|
Datum
|
|
|
|
pg_stat_get_xact_numscans(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_TableStatus *tabentry;
|
|
|
|
|
|
|
|
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->t_counts.t_numscans);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_xact_tuples_returned(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_TableStatus *tabentry;
|
|
|
|
|
|
|
|
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->t_counts.t_tuples_returned);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_xact_tuples_fetched(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_TableStatus *tabentry;
|
|
|
|
|
|
|
|
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->t_counts.t_tuples_fetched);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_xact_tuples_inserted(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_TableStatus *tabentry;
|
|
|
|
PgStat_TableXactStatus *trans;
|
|
|
|
|
|
|
|
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = tabentry->t_counts.t_tuples_inserted;
|
|
|
|
/* live subtransactions' counts aren't in t_tuples_inserted yet */
|
|
|
|
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
|
|
|
|
result += trans->tuples_inserted;
|
|
|
|
}
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_xact_tuples_updated(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_TableStatus *tabentry;
|
|
|
|
PgStat_TableXactStatus *trans;
|
|
|
|
|
|
|
|
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = tabentry->t_counts.t_tuples_updated;
|
|
|
|
/* live subtransactions' counts aren't in t_tuples_updated yet */
|
|
|
|
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
|
|
|
|
result += trans->tuples_updated;
|
|
|
|
}
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_xact_tuples_deleted(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_TableStatus *tabentry;
|
|
|
|
PgStat_TableXactStatus *trans;
|
|
|
|
|
|
|
|
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = tabentry->t_counts.t_tuples_deleted;
|
|
|
|
/* live subtransactions' counts aren't in t_tuples_deleted yet */
|
|
|
|
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
|
|
|
|
result += trans->tuples_deleted;
|
|
|
|
}
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_xact_tuples_hot_updated(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_TableStatus *tabentry;
|
|
|
|
|
|
|
|
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->t_counts.t_tuples_hot_updated);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_xact_blocks_fetched(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_TableStatus *tabentry;
|
|
|
|
|
|
|
|
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->t_counts.t_blocks_fetched);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_xact_blocks_hit(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid relid = PG_GETARG_OID(0);
|
|
|
|
int64 result;
|
|
|
|
PgStat_TableStatus *tabentry;
|
|
|
|
|
|
|
|
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
|
|
result = 0;
|
|
|
|
else
|
|
|
|
result = (int64) (tabentry->t_counts.t_blocks_hit);
|
|
|
|
|
|
|
|
PG_RETURN_INT64(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_xact_function_calls(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid funcid = PG_GETARG_OID(0);
|
|
|
|
PgStat_BackendFunctionEntry *funcentry;
|
|
|
|
|
|
|
|
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
PG_RETURN_INT64(funcentry->f_counts.f_numcalls);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
2012-04-30 20:02:47 +02:00
|
|
|
pg_stat_get_xact_function_total_time(PG_FUNCTION_ARGS)
|
2010-08-08 18:27:06 +02:00
|
|
|
{
|
|
|
|
Oid funcid = PG_GETARG_OID(0);
|
|
|
|
PgStat_BackendFunctionEntry *funcentry;
|
|
|
|
|
|
|
|
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
2012-04-30 20:02:47 +02:00
|
|
|
PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_counts.f_total_time));
|
2010-08-08 18:27:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_xact_function_self_time(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid funcid = PG_GETARG_OID(0);
|
|
|
|
PgStat_BackendFunctionEntry *funcentry;
|
|
|
|
|
|
|
|
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
|
|
|
|
PG_RETURN_NULL();
|
2012-04-30 20:02:47 +02:00
|
|
|
PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_counts.f_self_time));
|
2010-08-08 18:27:06 +02:00
|
|
|
}
|
|
|
|
|
2007-03-16 18:57:36 +01:00
|
|
|
|
2015-02-20 03:36:50 +01:00
|
|
|
/* Get the timestamp of the current statistics snapshot */
|
|
|
|
Datum
|
|
|
|
pg_stat_get_snapshot_timestamp(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
PG_RETURN_TIMESTAMPTZ(pgstat_fetch_global()->stats_timestamp);
|
|
|
|
}
|
|
|
|
|
2007-02-08 00:11:30 +01:00
|
|
|
/* Discard the active statistics snapshot */
|
|
|
|
Datum
|
|
|
|
pg_stat_clear_snapshot(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
pgstat_clear_snapshot();
|
|
|
|
|
|
|
|
PG_RETURN_VOID();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Reset all counters for the current database */
|
|
|
|
Datum
|
|
|
|
pg_stat_reset(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
pgstat_reset_counters();
|
|
|
|
|
|
|
|
PG_RETURN_VOID();
|
|
|
|
}
|
2010-01-19 15:11:32 +01:00
|
|
|
|
|
|
|
/* Reset some shared cluster-wide counters */
|
|
|
|
Datum
|
|
|
|
pg_stat_reset_shared(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2011-07-03 13:15:58 +02:00
|
|
|
char *target = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
|
|
|
|
|
|
|
pgstat_reset_shared_counters(target);
|
2010-01-19 15:11:32 +01:00
|
|
|
|
|
|
|
PG_RETURN_VOID();
|
|
|
|
}
|
2010-01-28 15:25:41 +01:00
|
|
|
|
2014-10-20 16:23:40 +02:00
|
|
|
/* Reset a single counter in the current database */
|
2010-01-28 15:25:41 +01:00
|
|
|
Datum
|
|
|
|
pg_stat_reset_single_table_counters(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2010-02-26 03:01:40 +01:00
|
|
|
Oid taboid = PG_GETARG_OID(0);
|
2010-01-28 15:25:41 +01:00
|
|
|
|
|
|
|
pgstat_reset_single_counter(taboid, RESET_TABLE);
|
|
|
|
|
|
|
|
PG_RETURN_VOID();
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_reset_single_function_counters(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2010-02-26 03:01:40 +01:00
|
|
|
Oid funcoid = PG_GETARG_OID(0);
|
2010-01-28 15:25:41 +01:00
|
|
|
|
|
|
|
pgstat_reset_single_counter(funcoid, RESET_FUNCTION);
|
|
|
|
|
|
|
|
PG_RETURN_VOID();
|
|
|
|
}
|
2014-01-28 18:58:22 +01:00
|
|
|
|
|
|
|
Datum
|
|
|
|
pg_stat_get_archiver(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
TupleDesc tupdesc;
|
|
|
|
Datum values[7];
|
|
|
|
bool nulls[7];
|
|
|
|
PgStat_ArchiverStats *archiver_stats;
|
|
|
|
|
|
|
|
/* Initialise values and NULL flags arrays */
|
|
|
|
MemSet(values, 0, sizeof(values));
|
|
|
|
MemSet(nulls, 0, sizeof(nulls));
|
|
|
|
|
|
|
|
/* Initialise attributes information in the tuple descriptor */
|
Remove WITH OIDS support, change oid catalog column visibility.
Previously tables declared WITH OIDS, including a significant fraction
of the catalog tables, stored the oid column not as a normal column,
but as part of the tuple header.
This special column was not shown by default, which was somewhat odd,
as it's often (consider e.g. pg_class.oid) one of the more important
parts of a row. Neither pg_dump nor COPY included the contents of the
oid column by default.
The fact that the oid column was not an ordinary column necessitated a
significant amount of special case code to support oid columns. That
already was painful for the existing, but upcoming work aiming to make
table storage pluggable, would have required expanding and duplicating
that "specialness" significantly.
WITH OIDS has been deprecated since 2005 (commit ff02d0a05280e0).
Remove it.
Removing includes:
- CREATE TABLE and ALTER TABLE syntax for declaring the table to be
WITH OIDS has been removed (WITH (oids[ = true]) will error out)
- pg_dump does not support dumping tables declared WITH OIDS and will
issue a warning when dumping one (and ignore the oid column).
- restoring an pg_dump archive with pg_restore will warn when
restoring a table with oid contents (and ignore the oid column)
- COPY will refuse to load binary dump that includes oids.
- pg_upgrade will error out when encountering tables declared WITH
OIDS, they have to be altered to remove the oid column first.
- Functionality to access the oid of the last inserted row (like
plpgsql's RESULT_OID, spi's SPI_lastoid, ...) has been removed.
The syntax for declaring a table WITHOUT OIDS (or WITH (oids = false)
for CREATE TABLE) is still supported. While that requires a bit of
support code, it seems unnecessary to break applications / dumps that
do not use oids, and are explicit about not using them.
The biggest user of WITH OID columns was postgres' catalog. This
commit changes all 'magic' oid columns to be columns that are normally
declared and stored. To reduce unnecessary query breakage all the
newly added columns are still named 'oid', even if a table's column
naming scheme would indicate 'reloid' or such. This obviously
requires adapting a lot code, mostly replacing oid access via
HeapTupleGetOid() with access to the underlying Form_pg_*->oid column.
The bootstrap process now assigns oids for all oid columns in
genbki.pl that do not have an explicit value (starting at the largest
oid previously used), only oids assigned later by oids will be above
FirstBootstrapObjectId. As the oid column now is a normal column the
special bootstrap syntax for oids has been removed.
Oids are not automatically assigned during insertion anymore, all
backend code explicitly assigns oids with GetNewOidWithIndex(). For
the rare case that insertions into the catalog via SQL are called for
the new pg_nextoid() function can be used (which only works on catalog
tables).
The fact that oid columns on system tables are now normal columns
means that they will be included in the set of columns expanded
by * (i.e. SELECT * FROM pg_class will now include the table's oid,
previously it did not). It'd not technically be hard to hide oid
column by default, but that'd mean confusing behavior would either
have to be carried forward forever, or it'd cause breakage down the
line.
While it's not unlikely that further adjustments are needed, the
scope/invasiveness of the patch makes it worthwhile to get merge this
now. It's painful to maintain externally, too complicated to commit
after the code code freeze, and a dependency of a number of other
patches.
Catversion bump, for obvious reasons.
Author: Andres Freund, with contributions by John Naylor
Discussion: https://postgr.es/m/20180930034810.ywp2c7awz7opzcfr@alap3.anarazel.de
2018-11-21 00:36:57 +01:00
|
|
|
tupdesc = CreateTemplateTupleDesc(7);
|
2014-01-28 18:58:22 +01:00
|
|
|
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "archived_count",
|
|
|
|
INT8OID, -1, 0);
|
|
|
|
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "last_archived_wal",
|
|
|
|
TEXTOID, -1, 0);
|
|
|
|
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "last_archived_time",
|
|
|
|
TIMESTAMPTZOID, -1, 0);
|
|
|
|
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "failed_count",
|
|
|
|
INT8OID, -1, 0);
|
|
|
|
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "last_failed_wal",
|
|
|
|
TEXTOID, -1, 0);
|
|
|
|
TupleDescInitEntry(tupdesc, (AttrNumber) 6, "last_failed_time",
|
|
|
|
TIMESTAMPTZOID, -1, 0);
|
|
|
|
TupleDescInitEntry(tupdesc, (AttrNumber) 7, "stats_reset",
|
|
|
|
TIMESTAMPTZOID, -1, 0);
|
|
|
|
|
|
|
|
BlessTupleDesc(tupdesc);
|
|
|
|
|
|
|
|
/* Get statistics about the archiver process */
|
|
|
|
archiver_stats = pgstat_fetch_stat_archiver();
|
|
|
|
|
|
|
|
/* Fill values and NULLs */
|
|
|
|
values[0] = Int64GetDatum(archiver_stats->archived_count);
|
2014-02-04 02:59:39 +01:00
|
|
|
if (*(archiver_stats->last_archived_wal) == '\0')
|
2014-01-28 18:58:22 +01:00
|
|
|
nulls[1] = true;
|
|
|
|
else
|
|
|
|
values[1] = CStringGetTextDatum(archiver_stats->last_archived_wal);
|
|
|
|
|
|
|
|
if (archiver_stats->last_archived_timestamp == 0)
|
|
|
|
nulls[2] = true;
|
|
|
|
else
|
|
|
|
values[2] = TimestampTzGetDatum(archiver_stats->last_archived_timestamp);
|
|
|
|
|
|
|
|
values[3] = Int64GetDatum(archiver_stats->failed_count);
|
2014-02-04 02:59:39 +01:00
|
|
|
if (*(archiver_stats->last_failed_wal) == '\0')
|
2014-01-28 18:58:22 +01:00
|
|
|
nulls[4] = true;
|
|
|
|
else
|
|
|
|
values[4] = CStringGetTextDatum(archiver_stats->last_failed_wal);
|
|
|
|
|
|
|
|
if (archiver_stats->last_failed_timestamp == 0)
|
|
|
|
nulls[5] = true;
|
|
|
|
else
|
|
|
|
values[5] = TimestampTzGetDatum(archiver_stats->last_failed_timestamp);
|
|
|
|
|
|
|
|
if (archiver_stats->stat_reset_timestamp == 0)
|
|
|
|
nulls[6] = true;
|
|
|
|
else
|
|
|
|
values[6] = TimestampTzGetDatum(archiver_stats->stat_reset_timestamp);
|
|
|
|
|
|
|
|
/* Returns the record as Datum */
|
|
|
|
PG_RETURN_DATUM(HeapTupleGetDatum(
|
Phase 3 of pgindent updates.
Don't move parenthesized lines to the left, even if that means they
flow past the right margin.
By default, BSD indent lines up statement continuation lines that are
within parentheses so that they start just to the right of the preceding
left parenthesis. However, traditionally, if that resulted in the
continuation line extending to the right of the desired right margin,
then indent would push it left just far enough to not overrun the margin,
if it could do so without making the continuation line start to the left of
the current statement indent. That makes for a weird mix of indentations
unless one has been completely rigid about never violating the 80-column
limit.
This behavior has been pretty universally panned by Postgres developers.
Hence, disable it with indent's new -lpl switch, so that parenthesized
lines are always lined up with the preceding left paren.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
2017-06-21 21:35:54 +02:00
|
|
|
heap_form_tuple(tupdesc, values, nulls)));
|
2014-01-28 18:58:22 +01:00
|
|
|
}
|