PG-552: Remove unnecessary columns from PostgreSQL 11 and 12 views.

There was a typo while checking the PostgreSQL version in the SQL file. This commit
will fix the typo, and only the necessary columns will be visible in the view.
pull/313/head
Ibrar Ahmed 2022-11-15 17:10:42 +00:00
parent db5a6aa30e
commit 40afdce2eb
3 changed files with 22 additions and 20 deletions

View File

@ -195,7 +195,6 @@ CREATE VIEW pg_stat_monitor AS SELECT
datname, datname,
'0.0.0.0'::inet + client_ip AS client_ip, '0.0.0.0'::inet + client_ip AS client_ip,
queryid, queryid,
toplevel,
top_queryid, top_queryid,
query, query,
comments, comments,
@ -210,11 +209,11 @@ CREATE VIEW pg_stat_monitor AS SELECT
sqlcode, sqlcode,
message, message,
calls, calls,
total_exec_time, total_exec_time AS total_time,
min_exec_time, min_exec_time AS min_time,
max_exec_time, max_exec_time AS max_time,
mean_exec_time, mean_exec_time AS mean_time,
stddev_exec_time, stddev_exec_time AS stddev_time,
rows_retrieved, rows_retrieved,
shared_blks_hit, shared_blks_hit,
shared_blks_read, shared_blks_read,
@ -373,13 +372,13 @@ $$
DECLARE ver integer; DECLARE ver integer;
BEGIN BEGIN
SELECT current_setting('server_version_num') INTO ver; SELECT current_setting('server_version_num') INTO ver;
IF (ver >= 14000) THEN IF (ver >= 140000) THEN
return pgsm_create_14_view(); return pgsm_create_14_view();
END IF; END IF;
IF (ver >= 13000) THEN IF (ver >= 130000) THEN
return pgsm_create_13_view(); return pgsm_create_13_view();
END IF; END IF;
IF (ver >= 11000) THEN IF (ver >= 110000) THEN
return pgsm_create_11_view(); return pgsm_create_11_view();
END IF; END IF;
RETURN 0; RETURN 0;

View File

@ -116,8 +116,9 @@ CREATE FUNCTION pg_stat_monitor_internal(
OUT planid text, OUT planid text,
OUT query text, OUT query text,
OUT query_plan text, OUT query_plan text,
OUT state_code int8,
OUT top_queryid text, OUT top_queryid text,
OUT top_query text, OUT top_query text,
OUT application_name text, OUT application_name text,
OUT relations text, -- 11 OUT relations text, -- 11
@ -181,7 +182,6 @@ CREATE VIEW pg_stat_monitor AS SELECT
datname, datname,
'0.0.0.0'::inet + client_ip AS client_ip, '0.0.0.0'::inet + client_ip AS client_ip,
queryid, queryid,
toplevel,
top_queryid, top_queryid,
query, query,
comments, comments,
@ -197,10 +197,10 @@ CREATE VIEW pg_stat_monitor AS SELECT
message, message,
calls, calls,
total_exec_time, total_exec_time,
min_exec_time, min_time,
max_exec_time, max_time,
mean_exec_time, mean_time,
stddev_exec_time, stddev_time,
rows_retrieved, rows_retrieved,
shared_blks_hit, shared_blks_hit,
shared_blks_read, shared_blks_read,
@ -352,13 +352,13 @@ $$
DECLARE ver integer; DECLARE ver integer;
BEGIN BEGIN
SELECT current_setting('server_version_num') INTO ver; SELECT current_setting('server_version_num') INTO ver;
IF (ver >= 14000) THEN IF (ver >= 140000) THEN
return pgsm_create_14_view(); return pgsm_create_14_view();
END IF; END IF;
IF (ver >= 13000) THEN IF (ver >= 130000) THEN
return pgsm_create_13_view(); return pgsm_create_13_view();
END IF; END IF;
IF (ver >= 11000) THEN IF (ver >= 110000) THEN
return pgsm_create_11_view(); return pgsm_create_11_view();
END IF; END IF;
RETURN 0; RETURN 0;

View File

@ -1627,7 +1627,7 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
elog(ERROR, "pg_stat_monitor: return type must be a row type"); elog(ERROR, "pg_stat_monitor: return type must be a row type");
if (tupdesc->natts != 50) if (tupdesc->natts != 51)
elog(ERROR, "pg_stat_monitor: incorrect number of output arguments, required %d", tupdesc->natts); elog(ERROR, "pg_stat_monitor: incorrect number of output arguments, required %d", tupdesc->natts);
tupstore = tuplestore_begin_heap(true, false, work_mem); tupstore = tuplestore_begin_heap(true, false, work_mem);
@ -1772,7 +1772,10 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
values[i++] = CStringGetTextDatum("<insufficient privilege>"); values[i++] = CStringGetTextDatum("<insufficient privilege>");
} }
/* parentid at column number 8 */ /* state at column number 8 */
values[i++] = Int64GetDatumFast(tmp.state);
/* parentid at column number 9 */
if (tmp.info.parentid != UINT64CONST(0)) if (tmp.info.parentid != UINT64CONST(0))
{ {
snprintf(parentid_txt, 32, "%08lX", tmp.info.parentid); snprintf(parentid_txt, 32, "%08lX", tmp.info.parentid);