Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add isBackgroundWorker, databaseId and roleId to pg_wait_sampling_current view#95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
DmitryNFomin wants to merge1 commit intopostgrespro:master
base:master
Choose a base branch
Loading
fromDmitryNFomin:collect_more_backend_info
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletionscollector.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,6 +175,9 @@ probe_waits(History *observations, HTAB *profile_hash,
item.queryId = 0;

item.ts = ts;
item.isRegularBackend = !(proc->isBackgroundWorker);
item.databaseId = proc->databaseId;
item.roleId = proc->roleId;

/* Write to the history if needed */
if (write_history)
Expand Down
73 changes: 73 additions & 0 deletionspg_wait_sampling--1.1--1.2.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
/* contrib/pg_wait_sampling/pg_wait_sampling--1.0--1.1.sql */

DROP FUNCTION pg_wait_sampling_get_current (
pid int4,
OUT pid int4,
OUT event_type text,
OUT event text
) CASCADE;

DROP FUNCTION pg_wait_sampling_get_history (
OUT pid int4,
OUT ts timestamptz,
OUT event_type text,
OUT event text
) CASCADE;

DROP FUNCTION pg_wait_sampling_get_profile (
OUT pid int4,
OUT event_type text,
OUT event text,
OUT count bigint
) CASCADE;

CREATE FUNCTION pg_wait_sampling_get_current (
pid int4,
OUT pid int4,
OUT event_type text,
OUT event text,
OUT queryid int8,
OUT isregularbackend boolean,
OUT databaseid oid,
OUT roleid oid
)
RETURNS SETOF record
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE CALLED ON NULL INPUT;

CREATE VIEW pg_wait_sampling_current AS
SELECT * FROM pg_wait_sampling_get_current(NULL::integer);

GRANT SELECT ON pg_wait_sampling_current TO PUBLIC;

CREATE FUNCTION pg_wait_sampling_get_history (
OUT pid int4,
OUT ts timestamptz,
OUT event_type text,
OUT event text,
OUT queryid int8
)
RETURNS SETOF record
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE STRICT;

CREATE VIEW pg_wait_sampling_history AS
SELECT * FROM pg_wait_sampling_get_history();

GRANT SELECT ON pg_wait_sampling_history TO PUBLIC;

CREATE FUNCTION pg_wait_sampling_get_profile (
OUT pid int4,
OUT event_type text,
OUT event text,
OUT queryid int8,
OUT count int8
)
RETURNS SETOF record
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE STRICT;

CREATE VIEW pg_wait_sampling_profile AS
SELECT * FROM pg_wait_sampling_get_profile();

GRANT SELECT ON pg_wait_sampling_profile TO PUBLIC;
66 changes: 66 additions & 0 deletionspg_wait_sampling--1.2.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
/* contrib/pg_wait_sampling/setup.sql */

-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION pg_wait_sampling" to load this file. \quit

CREATE FUNCTION pg_wait_sampling_get_current (
pid int4,
OUT pid int4,
OUT event_type text,
OUT event text,
OUT queryid int8,
OUT isregularbackend boolean,
OUT databaseid oid,
OUT roleid oid
)
RETURNS SETOF record
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE CALLED ON NULL INPUT;

CREATE VIEW pg_wait_sampling_current AS
SELECT * FROM pg_wait_sampling_get_current(NULL::integer);

GRANT SELECT ON pg_wait_sampling_current TO PUBLIC;

CREATE FUNCTION pg_wait_sampling_get_history (
OUT pid int4,
OUT ts timestamptz,
OUT event_type text,
OUT event text,
OUT queryid int8,
OUT isregularbackend boolean,
OUT databaseid oid,
OUT roleid oid
)
RETURNS SETOF record
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE STRICT;

CREATE VIEW pg_wait_sampling_history AS
SELECT * FROM pg_wait_sampling_get_history();

GRANT SELECT ON pg_wait_sampling_history TO PUBLIC;

CREATE FUNCTION pg_wait_sampling_get_profile (
OUT pid int4,
OUT event_type text,
OUT event text,
OUT queryid int8,
OUT count int8
)
RETURNS SETOF record
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE STRICT;

CREATE VIEW pg_wait_sampling_profile AS
SELECT * FROM pg_wait_sampling_get_profile();

GRANT SELECT ON pg_wait_sampling_profile TO PUBLIC;

CREATE FUNCTION pg_wait_sampling_reset_profile()
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE STRICT;

-- Don't want this to be available to non-superusers.
REVOKE ALL ON FUNCTION pg_wait_sampling_reset_profile() FROM PUBLIC;
37 changes: 31 additions & 6 deletionspg_wait_sampling.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -514,7 +514,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
params->ts = GetCurrentTimestamp();

funcctx->user_fctx = params;
tupdesc = CreateTemplateTupleDesc(4);
tupdesc = CreateTemplateTupleDesc(7);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "pid",
INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "type",
Expand All@@ -523,6 +523,12 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "queryid",
INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "isregularbackend",
BOOLOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 6, "databaseid",
OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 7, "roleid",
OIDOID, -1, 0);

funcctx->tuple_desc = BlessTupleDesc(tupdesc);

Expand All@@ -540,6 +546,9 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
item->pid = proc->pid;
item->wait_event_info = proc->wait_event_info;
item->queryId = pgws_proc_queryids[proc - ProcGlobal->allProcs];
item->isRegularBackend = !(proc->isBackgroundWorker);
item->databaseId = proc->databaseId;
item->roleId = proc->roleId;
funcctx->max_calls = 1;
}
else
Expand All@@ -562,6 +571,9 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
params->items[j].pid = proc->pid;
params->items[j].wait_event_info = proc->wait_event_info;
params->items[j].queryId = pgws_proc_queryids[i];
params->items[j].isRegularBackend = !(proc->isBackgroundWorker);
params->items[j].databaseId = proc->databaseId;
params->items[j].roleId = proc->roleId;
j++;
}
funcctx->max_calls = j;
Expand All@@ -579,8 +591,8 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
if (funcctx->call_cntr < funcctx->max_calls)
{
HeapTupletuple;
Datumvalues[4];
boolnulls[4];
Datumvalues[7];
boolnulls[7];
const char *event_type,
*event;
HistoryItem *item;
Expand All@@ -604,6 +616,9 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
nulls[2] = true;

values[3] = UInt64GetDatum(item->queryId);
values[4] = BoolGetDatum(item->isRegularBackend);
values[5] = ObjectIdGetDatum(item->databaseId);
values[6] = ObjectIdGetDatum(item->roleId);
tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);

SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(tuple));
Expand DownExpand Up@@ -858,7 +873,7 @@ pg_wait_sampling_get_history(PG_FUNCTION_ARGS)
funcctx->max_calls = history->count;

/* Make tuple descriptor */
tupdesc = CreateTemplateTupleDesc(5);
tupdesc = CreateTemplateTupleDesc(8);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "pid",
INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "sample_ts",
Expand All@@ -869,6 +884,13 @@ pg_wait_sampling_get_history(PG_FUNCTION_ARGS)
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "queryid",
INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 6, "isregularbackend",
BOOLOID, -1, 0),
TupleDescInitEntry(tupdesc, (AttrNumber) 7, "databaseid",
OIDOID, -1, 0),
TupleDescInitEntry(tupdesc, (AttrNumber) 8, "roleid",
OIDOID, -1, 0);

funcctx->tuple_desc = BlessTupleDesc(tupdesc);

MemoryContextSwitchTo(oldcontext);
Expand All@@ -883,8 +905,8 @@ pg_wait_sampling_get_history(PG_FUNCTION_ARGS)
{
HeapTupletuple;
HistoryItem *item;
Datumvalues[5];
boolnulls[5];
Datumvalues[8];
boolnulls[8];
const char *event_type,
*event;

Expand All@@ -908,6 +930,9 @@ pg_wait_sampling_get_history(PG_FUNCTION_ARGS)
nulls[3] = true;

values[4] = UInt64GetDatum(item->queryId);
values[5] = BoolGetDatum(item->isRegularBackend);
values[6] = ObjectIdGetDatum(item->databaseId);
values[7] = ObjectIdGetDatum(item->roleId);
tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);

history->index++;
Expand Down
2 changes: 1 addition & 1 deletionpg_wait_sampling.control
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
# pg_wait_sampling extension
comment = 'sampling based statistics of wait events'
default_version = '1.1'
default_version = '1.2'
module_pathname = '$libdir/pg_wait_sampling'
relocatable = true
3 changes: 3 additions & 0 deletionspg_wait_sampling.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,6 +34,9 @@ typedef struct
intpid;
uint32wait_event_info;
uint64queryId;
boolisRegularBackend;
OiddatabaseId;
OidroleId;
TimestampTz ts;
} HistoryItem;

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp