Merge pull request #175 from darkfronza/PG-338_fix_query_call_count

PG-338: Fix query call count
pull/178/head
Ibrar Ahmed 2022-01-24 18:45:30 +05:00 committed by GitHub
commit 363f4ab2bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 5 deletions

View File

@ -986,6 +986,7 @@ static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
WalUsage walusage_start = pgWalUsage;
#endif
INSTR_TIME_SET_CURRENT(start);
exec_nested_level++;
PG_TRY();
{
#if PG_VERSION_NUM >= 140000
@ -1024,12 +1025,12 @@ static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
dest,
completionTag);
#endif
exec_nested_level--;
}
PG_CATCH();
{
exec_nested_level--;
PG_RE_THROW();
}
PG_END_TRY();

View File

@ -42,9 +42,16 @@ SELECT query,calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
SELECT pg_stat_monitor_reset() | 1
(2 rows)
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------
ALTER SYSTEM SET pg_stat_monitor.track TO 'all';
SELECT pg_reload_conf();
pg_reload_conf
----------------
t
(1 row)
SELECT pg_sleep(1);
pg_sleep
----------
(1 row)
@ -81,6 +88,19 @@ SELECT query,calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
end $$ |
(3 rows)
ALTER SYSTEM SET pg_stat_monitor.track TO 'top';
SELECT pg_reload_conf();
pg_reload_conf
----------------
t
(1 row)
SELECT pg_sleep(1);
pg_sleep
----------
(1 row)
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------

View File

@ -12,9 +12,12 @@ SELECT a,b,c,d FROM t1, t2, t3, t4 WHERE t1.a = t2.b AND t3.c = t4.d ORDER BY a;
SELECT a,b,c,d FROM t1, t2, t3, t4 WHERE t1.a = t2.b AND t3.c = t4.d ORDER BY a;
SELECT a,b,c,d FROM t1, t2, t3, t4 WHERE t1.a = t2.b AND t3.c = t4.d ORDER BY a;
SELECT query,calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
ALTER SYSTEM SET pg_stat_monitor.track TO 'all';
SELECT pg_reload_conf();
SELECT pg_sleep(1);
SELECT pg_stat_monitor_reset();
SELECT pg_stat_monitor_reset();
do $$
declare
n integer:= 1;
@ -26,6 +29,10 @@ begin
end loop;
end $$;
SELECT query,calls FROM pg_stat_monitor ORDER BY query COLLATE "C";
ALTER SYSTEM SET pg_stat_monitor.track TO 'top';
SELECT pg_reload_conf();
SELECT pg_sleep(1);
SELECT pg_stat_monitor_reset();
DROP TABLE t1;