Fix comments with fileds numbers
parent
9d8b072421
commit
f5059a8138
|
@ -15,7 +15,7 @@ CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
OUT datname text,
|
OUT datname text,
|
||||||
OUT client_ip int8,
|
OUT client_ip int8,
|
||||||
|
|
||||||
OUT queryid int8, -- 4
|
OUT queryid int8, -- 6
|
||||||
OUT planid int8,
|
OUT planid int8,
|
||||||
OUT query text,
|
OUT query text,
|
||||||
OUT query_plan text,
|
OUT query_plan text,
|
||||||
|
@ -24,32 +24,32 @@ CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
OUT top_query text,
|
OUT top_query text,
|
||||||
OUT application_name text,
|
OUT application_name text,
|
||||||
|
|
||||||
OUT relations text, -- 11
|
OUT relations text, -- 14
|
||||||
OUT cmd_type int,
|
OUT cmd_type int,
|
||||||
OUT elevel int,
|
OUT elevel int,
|
||||||
OUT sqlcode TEXT,
|
OUT sqlcode TEXT,
|
||||||
OUT message text,
|
OUT message text,
|
||||||
OUT bucket_start_time timestamptz,
|
OUT bucket_start_time timestamptz,
|
||||||
|
|
||||||
OUT calls int8, -- 16
|
OUT calls int8, -- 20
|
||||||
|
|
||||||
OUT total_exec_time float8,
|
OUT total_exec_time float8, -- 21
|
||||||
OUT min_exec_time float8,
|
OUT min_exec_time float8,
|
||||||
OUT max_exec_time float8,
|
OUT max_exec_time float8,
|
||||||
OUT mean_exec_time float8,
|
OUT mean_exec_time float8,
|
||||||
OUT stddev_exec_time float8,
|
OUT stddev_exec_time float8,
|
||||||
|
|
||||||
OUT rows int8,
|
OUT rows int8, -- 26
|
||||||
|
|
||||||
OUT plans int8, -- 23
|
OUT plans int8, -- 27
|
||||||
|
|
||||||
OUT total_plan_time float8,
|
OUT total_plan_time float8, -- 28
|
||||||
OUT min_plan_time float8,
|
OUT min_plan_time float8,
|
||||||
OUT max_plan_time float8,
|
OUT max_plan_time float8,
|
||||||
OUT mean_plan_time float8,
|
OUT mean_plan_time float8,
|
||||||
OUT stddev_plan_time float8,
|
OUT stddev_plan_time float8,
|
||||||
|
|
||||||
OUT shared_blks_hit int8, -- 29
|
OUT shared_blks_hit int8, -- 33
|
||||||
OUT shared_blks_read int8,
|
OUT shared_blks_read int8,
|
||||||
OUT shared_blks_dirtied int8,
|
OUT shared_blks_dirtied int8,
|
||||||
OUT shared_blks_written int8,
|
OUT shared_blks_written int8,
|
||||||
|
@ -62,10 +62,10 @@ CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
OUT shared_blk_read_time float8,
|
OUT shared_blk_read_time float8,
|
||||||
OUT shared_blk_write_time float8,
|
OUT shared_blk_write_time float8,
|
||||||
|
|
||||||
OUT temp_blk_read_time float8,
|
OUT temp_blk_read_time float8, -- 45
|
||||||
OUT temp_blk_write_time float8,
|
OUT temp_blk_write_time float8,
|
||||||
|
|
||||||
OUT resp_calls text, -- 41
|
OUT resp_calls text, -- 47
|
||||||
OUT cpu_user_time float8,
|
OUT cpu_user_time float8,
|
||||||
OUT cpu_sys_time float8,
|
OUT cpu_sys_time float8,
|
||||||
OUT wal_records int8,
|
OUT wal_records int8,
|
||||||
|
@ -73,7 +73,7 @@ CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
OUT wal_bytes numeric,
|
OUT wal_bytes numeric,
|
||||||
OUT comments TEXT,
|
OUT comments TEXT,
|
||||||
|
|
||||||
OUT jit_functions int8,
|
OUT jit_functions int8, -- 54
|
||||||
OUT jit_generation_time float8,
|
OUT jit_generation_time float8,
|
||||||
OUT jit_inlining_count int8,
|
OUT jit_inlining_count int8,
|
||||||
OUT jit_inlining_time float8,
|
OUT jit_inlining_time float8,
|
||||||
|
@ -82,7 +82,7 @@ CREATE FUNCTION pg_stat_monitor_internal(
|
||||||
OUT jit_emission_count int8,
|
OUT jit_emission_count int8,
|
||||||
OUT jit_emission_time float8,
|
OUT jit_emission_time float8,
|
||||||
|
|
||||||
OUT toplevel BOOLEAN,
|
OUT toplevel BOOLEAN, --62
|
||||||
OUT bucket_done BOOLEAN
|
OUT bucket_done BOOLEAN
|
||||||
)
|
)
|
||||||
RETURNS SETOF record
|
RETURNS SETOF record
|
||||||
|
|
|
@ -2191,17 +2191,17 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
/* userid at column number 1 */
|
/* userid at column number 1 */
|
||||||
values[i++] = ObjectIdGetDatum(userid);
|
values[i++] = ObjectIdGetDatum(userid);
|
||||||
|
|
||||||
/* userid at column number 1 */
|
/* username at column number 2 */
|
||||||
values[i++] = CStringGetTextDatum(entry->username);
|
values[i++] = CStringGetTextDatum(entry->username);
|
||||||
|
|
||||||
/* dbid at column number 2 */
|
/* dbid at column number 3 */
|
||||||
values[i++] = ObjectIdGetDatum(dbid);
|
values[i++] = ObjectIdGetDatum(dbid);
|
||||||
|
|
||||||
/* userid at column number 1 */
|
/* datname at column number 4 */
|
||||||
values[i++] = CStringGetTextDatum(entry->datname);
|
values[i++] = CStringGetTextDatum(entry->datname);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ip address at column number 3, Superusers or members of
|
* ip address at column number 5, Superusers or members of
|
||||||
* pg_read_all_stats members are allowed
|
* pg_read_all_stats members are allowed
|
||||||
*/
|
*/
|
||||||
if (is_allowed_role || userid == GetUserId())
|
if (is_allowed_role || userid == GetUserId())
|
||||||
|
@ -2209,10 +2209,10 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
else
|
else
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
|
|
||||||
/* queryid at column number 4 */
|
/* queryid at column number 6 */
|
||||||
values[i++] = UInt64GetDatum(queryid);
|
values[i++] = UInt64GetDatum(queryid);
|
||||||
|
|
||||||
/* planid at column number 5 */
|
/* planid at column number 7 */
|
||||||
if (planid)
|
if (planid)
|
||||||
{
|
{
|
||||||
values[i++] = UInt64GetDatum(planid);
|
values[i++] = UInt64GetDatum(planid);
|
||||||
|
@ -2227,12 +2227,12 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
{
|
{
|
||||||
char *enc;
|
char *enc;
|
||||||
|
|
||||||
/* query at column number 6 */
|
/* query at column number 8 */
|
||||||
enc = pg_any_to_server(query_txt, strlen(query_txt), GetDatabaseEncoding());
|
enc = pg_any_to_server(query_txt, strlen(query_txt), GetDatabaseEncoding());
|
||||||
values[i++] = CStringGetTextDatum(enc);
|
values[i++] = CStringGetTextDatum(enc);
|
||||||
if (enc != query_txt)
|
if (enc != query_txt)
|
||||||
pfree(enc);
|
pfree(enc);
|
||||||
/* plan at column number 7 */
|
/* plan at column number 9 */
|
||||||
if (planid && tmp.planinfo.plan_text[0])
|
if (planid && tmp.planinfo.plan_text[0])
|
||||||
values[i++] = CStringGetTextDatum(tmp.planinfo.plan_text);
|
values[i++] = CStringGetTextDatum(tmp.planinfo.plan_text);
|
||||||
else
|
else
|
||||||
|
@ -2240,25 +2240,26 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* query at column number 6 */
|
/* query at column number 8 */
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
/* plan at column number 7 */
|
/* plan at column number 9 */
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* query text at column number 6 */
|
/* query text and plan at column number 8 and 9 */
|
||||||
values[i++] = CStringGetTextDatum("<insufficient privilege>");
|
values[i++] = CStringGetTextDatum("<insufficient privilege>");
|
||||||
values[i++] = CStringGetTextDatum("<insufficient privilege>");
|
values[i++] = CStringGetTextDatum("<insufficient privilege>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* pgsm_query_id at column number 10 */
|
||||||
if (pgsm_query_id)
|
if (pgsm_query_id)
|
||||||
values[i++] = UInt64GetDatum(pgsm_query_id);
|
values[i++] = UInt64GetDatum(pgsm_query_id);
|
||||||
else
|
else
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
|
|
||||||
/* parentid at column number 9 */
|
/* parentid at column number 11 */
|
||||||
if (tmp.info.parentid != UINT64CONST(0))
|
if (tmp.info.parentid != UINT64CONST(0))
|
||||||
{
|
{
|
||||||
values[i++] = UInt64GetDatum(tmp.info.parentid);
|
values[i++] = UInt64GetDatum(tmp.info.parentid);
|
||||||
|
@ -2270,13 +2271,13 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* application_name at column number 10 */
|
/* application_name at column number 15 */
|
||||||
if (strlen(tmp.info.application_name) > 0)
|
if (strlen(tmp.info.application_name) > 0)
|
||||||
values[i++] = CStringGetTextDatum(tmp.info.application_name);
|
values[i++] = CStringGetTextDatum(tmp.info.application_name);
|
||||||
else
|
else
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
|
|
||||||
/* relations at column number 10 */
|
/* relations at column number 14 */
|
||||||
if (tmp.info.num_relations > 0)
|
if (tmp.info.num_relations > 0)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
@ -2305,28 +2306,28 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
else
|
else
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
|
|
||||||
/* cmd_type at column number 11 */
|
/* cmd_type at column number 15 */
|
||||||
if (tmp.info.cmd_type == CMD_NOTHING)
|
if (tmp.info.cmd_type == CMD_NOTHING)
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
else
|
else
|
||||||
values[i++] = Int64GetDatumFast((int64) tmp.info.cmd_type);
|
values[i++] = Int64GetDatumFast((int64) tmp.info.cmd_type);
|
||||||
|
|
||||||
/* elevel at column number 12 */
|
/* elevel at column number 16 */
|
||||||
values[i++] = Int64GetDatumFast(tmp.error.elevel);
|
values[i++] = Int64GetDatumFast(tmp.error.elevel);
|
||||||
|
|
||||||
/* sqlcode at column number 13 */
|
/* sqlcode at column number 17 */
|
||||||
if (strlen(tmp.error.sqlcode) == 0)
|
if (strlen(tmp.error.sqlcode) == 0)
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
else
|
else
|
||||||
values[i++] = CStringGetTextDatum(tmp.error.sqlcode);
|
values[i++] = CStringGetTextDatum(tmp.error.sqlcode);
|
||||||
|
|
||||||
/* message at column number 14 */
|
/* message at column number 18 */
|
||||||
if (strlen(tmp.error.message) == 0)
|
if (strlen(tmp.error.message) == 0)
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
else
|
else
|
||||||
values[i++] = CStringGetTextDatum(tmp.error.message);
|
values[i++] = CStringGetTextDatum(tmp.error.message);
|
||||||
|
|
||||||
/* bucket_start_time at column number 15 */
|
/* bucket_start_time at column number 19 */
|
||||||
values[i++] = TimestampTzGetDatum(pgsm->bucket_start_time[entry->key.bucket_id]);
|
values[i++] = TimestampTzGetDatum(pgsm->bucket_start_time[entry->key.bucket_id]);
|
||||||
|
|
||||||
if (tmp.calls.calls == 0)
|
if (tmp.calls.calls == 0)
|
||||||
|
@ -2336,29 +2337,29 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
tmp.resp_calls[0]++;
|
tmp.resp_calls[0]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calls at column number 16 */
|
/* calls at column number 20 */
|
||||||
values[i++] = Int64GetDatumFast(tmp.calls.calls);
|
values[i++] = Int64GetDatumFast(tmp.calls.calls);
|
||||||
|
|
||||||
/* total_time at column number 17 */
|
/* total_time at column number 21 */
|
||||||
values[i++] = Float8GetDatumFast(tmp.time.total_time);
|
values[i++] = Float8GetDatumFast(tmp.time.total_time);
|
||||||
|
|
||||||
/* min_time at column number 18 */
|
/* min_time at column number 22 */
|
||||||
values[i++] = Float8GetDatumFast(tmp.time.min_time);
|
values[i++] = Float8GetDatumFast(tmp.time.min_time);
|
||||||
|
|
||||||
/* max_time at column number 19 */
|
/* max_time at column number 23 */
|
||||||
values[i++] = Float8GetDatumFast(tmp.time.max_time);
|
values[i++] = Float8GetDatumFast(tmp.time.max_time);
|
||||||
|
|
||||||
/* mean_time at column number 20 */
|
/* mean_time at column number 24 */
|
||||||
values[i++] = Float8GetDatumFast(tmp.time.mean_time);
|
values[i++] = Float8GetDatumFast(tmp.time.mean_time);
|
||||||
if (tmp.calls.calls > 1)
|
if (tmp.calls.calls > 1)
|
||||||
stddev = sqrt(tmp.time.sum_var_time / tmp.calls.calls);
|
stddev = sqrt(tmp.time.sum_var_time / tmp.calls.calls);
|
||||||
else
|
else
|
||||||
stddev = 0.0;
|
stddev = 0.0;
|
||||||
|
|
||||||
/* calls at column number 21 */
|
/* stddev_exec_time at column number 25 */
|
||||||
values[i++] = Float8GetDatumFast(stddev);
|
values[i++] = Float8GetDatumFast(stddev);
|
||||||
|
|
||||||
/* calls at column number 22 */
|
/* rows at column number 26 */
|
||||||
values[i++] = Int64GetDatumFast(tmp.calls.rows);
|
values[i++] = Int64GetDatumFast(tmp.calls.rows);
|
||||||
|
|
||||||
if (tmp.calls.calls == 0)
|
if (tmp.calls.calls == 0)
|
||||||
|
@ -2368,29 +2369,29 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
tmp.resp_calls[0]++;
|
tmp.resp_calls[0]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calls at column number 23 */
|
/* plans at column number 27 */
|
||||||
values[i++] = Int64GetDatumFast(tmp.plancalls.calls);
|
values[i++] = Int64GetDatumFast(tmp.plancalls.calls);
|
||||||
|
|
||||||
/* total_time at column number 24 */
|
/* total_plan_time at column number 28 */
|
||||||
values[i++] = Float8GetDatumFast(tmp.plantime.total_time);
|
values[i++] = Float8GetDatumFast(tmp.plantime.total_time);
|
||||||
|
|
||||||
/* min_time at column number 25 */
|
/* min_plan_time at column number 29 */
|
||||||
values[i++] = Float8GetDatumFast(tmp.plantime.min_time);
|
values[i++] = Float8GetDatumFast(tmp.plantime.min_time);
|
||||||
|
|
||||||
/* max_time at column number 26 */
|
/* max_plan_time at column number 30 */
|
||||||
values[i++] = Float8GetDatumFast(tmp.plantime.max_time);
|
values[i++] = Float8GetDatumFast(tmp.plantime.max_time);
|
||||||
|
|
||||||
/* mean_time at column number 27 */
|
/* mean_plan_time at column number 31 */
|
||||||
values[i++] = Float8GetDatumFast(tmp.plantime.mean_time);
|
values[i++] = Float8GetDatumFast(tmp.plantime.mean_time);
|
||||||
if (tmp.plancalls.calls > 1)
|
if (tmp.plancalls.calls > 1)
|
||||||
stddev = sqrt(tmp.plantime.sum_var_time / tmp.plancalls.calls);
|
stddev = sqrt(tmp.plantime.sum_var_time / tmp.plancalls.calls);
|
||||||
else
|
else
|
||||||
stddev = 0.0;
|
stddev = 0.0;
|
||||||
|
|
||||||
/* calls at column number 28 */
|
/* stddev_plan_time at column number 32 */
|
||||||
values[i++] = Float8GetDatumFast(stddev);
|
values[i++] = Float8GetDatumFast(stddev);
|
||||||
|
|
||||||
/* blocks are from column number 29 - 40 */
|
/* blocks are from column number 33 - 46 */
|
||||||
values[i++] = Int64GetDatumFast(tmp.blocks.shared_blks_hit);
|
values[i++] = Int64GetDatumFast(tmp.blocks.shared_blks_hit);
|
||||||
values[i++] = Int64GetDatumFast(tmp.blocks.shared_blks_read);
|
values[i++] = Int64GetDatumFast(tmp.blocks.shared_blks_read);
|
||||||
values[i++] = Int64GetDatumFast(tmp.blocks.shared_blks_dirtied);
|
values[i++] = Int64GetDatumFast(tmp.blocks.shared_blks_dirtied);
|
||||||
|
@ -2406,22 +2407,22 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
values[i++] = Float8GetDatumFast(tmp.blocks.temp_blk_read_time);
|
values[i++] = Float8GetDatumFast(tmp.blocks.temp_blk_read_time);
|
||||||
values[i++] = Float8GetDatumFast(tmp.blocks.temp_blk_write_time);
|
values[i++] = Float8GetDatumFast(tmp.blocks.temp_blk_write_time);
|
||||||
|
|
||||||
/* resp_calls at column number 41 */
|
/* resp_calls at column number 47 */
|
||||||
values[i++] = IntArrayGetTextDatum(tmp.resp_calls, hist_bucket_count_total);
|
values[i++] = IntArrayGetTextDatum(tmp.resp_calls, hist_bucket_count_total);
|
||||||
|
|
||||||
/* utime at column number 42 */
|
/* cpu_user_time at column number 48 */
|
||||||
values[i++] = Float8GetDatumFast(tmp.sysinfo.utime);
|
values[i++] = Float8GetDatumFast(tmp.sysinfo.utime);
|
||||||
|
|
||||||
/* stime at column number 43 */
|
/* cpu_sys_time at column number 49 */
|
||||||
values[i++] = Float8GetDatumFast(tmp.sysinfo.stime);
|
values[i++] = Float8GetDatumFast(tmp.sysinfo.stime);
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
Datum wal_bytes;
|
Datum wal_bytes;
|
||||||
|
|
||||||
/* wal_records at column number 44 */
|
/* wal_records at column number 50 */
|
||||||
values[i++] = Int64GetDatumFast(tmp.walusage.wal_records);
|
values[i++] = Int64GetDatumFast(tmp.walusage.wal_records);
|
||||||
|
|
||||||
/* wal_fpi at column number 45 */
|
/* wal_fpi at column number 51 */
|
||||||
values[i++] = Int64GetDatumFast(tmp.walusage.wal_fpi);
|
values[i++] = Int64GetDatumFast(tmp.walusage.wal_fpi);
|
||||||
|
|
||||||
snprintf(buf, sizeof buf, UINT64_FORMAT, tmp.walusage.wal_bytes);
|
snprintf(buf, sizeof buf, UINT64_FORMAT, tmp.walusage.wal_bytes);
|
||||||
|
@ -2431,15 +2432,16 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
CStringGetDatum(buf),
|
CStringGetDatum(buf),
|
||||||
ObjectIdGetDatum(0),
|
ObjectIdGetDatum(0),
|
||||||
Int32GetDatum(-1));
|
Int32GetDatum(-1));
|
||||||
/* wal_bytes at column number 46 */
|
/* wal_bytes at column number 52 */
|
||||||
values[i++] = wal_bytes;
|
values[i++] = wal_bytes;
|
||||||
|
|
||||||
/* application_name at column number 47 */
|
/* application_name at column number 53 */
|
||||||
if (strlen(tmp.info.comments) > 0)
|
if (strlen(tmp.info.comments) > 0)
|
||||||
values[i++] = CStringGetTextDatum(tmp.info.comments);
|
values[i++] = CStringGetTextDatum(tmp.info.comments);
|
||||||
else
|
else
|
||||||
nulls[i++] = true;
|
nulls[i++] = true;
|
||||||
|
|
||||||
|
/* blocks are from column number 54 - 61 */
|
||||||
values[i++] = Int64GetDatumFast(tmp.jitinfo.jit_functions);
|
values[i++] = Int64GetDatumFast(tmp.jitinfo.jit_functions);
|
||||||
values[i++] = Float8GetDatumFast(tmp.jitinfo.jit_generation_time);
|
values[i++] = Float8GetDatumFast(tmp.jitinfo.jit_generation_time);
|
||||||
values[i++] = Int64GetDatumFast(tmp.jitinfo.jit_inlining_count);
|
values[i++] = Int64GetDatumFast(tmp.jitinfo.jit_inlining_count);
|
||||||
|
@ -2449,7 +2451,10 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
values[i++] = Int64GetDatumFast(tmp.jitinfo.jit_emission_count);
|
values[i++] = Int64GetDatumFast(tmp.jitinfo.jit_emission_count);
|
||||||
values[i++] = Float8GetDatumFast(tmp.jitinfo.jit_emission_time);
|
values[i++] = Float8GetDatumFast(tmp.jitinfo.jit_emission_time);
|
||||||
}
|
}
|
||||||
|
/* toplevel at column number 62 */
|
||||||
values[i++] = BoolGetDatum(toplevel);
|
values[i++] = BoolGetDatum(toplevel);
|
||||||
|
|
||||||
|
/* bucket_done at column number 63 */
|
||||||
values[i++] = BoolGetDatum(pg_atomic_read_u64(&pgsm->current_wbucket) != bucketid);
|
values[i++] = BoolGetDatum(pg_atomic_read_u64(&pgsm->current_wbucket) != bucketid);
|
||||||
|
|
||||||
/* clean up and return the tuplestore */
|
/* clean up and return the tuplestore */
|
||||||
|
|
Loading…
Reference in New Issue