postgresql - How to get current query inside a transaction -


i tried current query pg_stats_activity didn't work expected.

outside transaction works:

pagetest=# select query pg_stat_activity pid = pg_backend_pid() , 1 not null;                                        query                                         ------------------------------------------------------------------------------------  select query pg_stat_activity pid = pg_backend_pid() , 1 not null; (1 row)  pagetest=# select query pg_stat_activity pid = pg_backend_pid() , 2 not null;                                        query                                         ------------------------------------------------------------------------------------  select query pg_stat_activity pid = pg_backend_pid() , 2 not null; (1 row)  pagetest=# select query pg_stat_activity pid = pg_backend_pid() , 3 not null;                                        query                                         ------------------------------------------------------------------------------------  select query pg_stat_activity pid = pg_backend_pid() , 3 not null; (1 row) 

but inside transaction wrong result:

pagetest=# begin; begin pagetest=# select query pg_stat_activity pid = pg_backend_pid() , 1 not null;                                        query                                         ------------------------------------------------------------------------------------  select query pg_stat_activity pid = pg_backend_pid() , 1 not null; (1 row)  pagetest=# select query pg_stat_activity pid = pg_backend_pid() , 2 not null;                                        query                                         ------------------------------------------------------------------------------------  select query pg_stat_activity pid = pg_backend_pid() , 1 not null; (1 row)  pagetest=# select query pg_stat_activity pid = pg_backend_pid() , 3 not null;                                        query                                         ------------------------------------------------------------------------------------  select query pg_stat_activity pid = pg_backend_pid() , 1 not null; (1 row)  pagetest=# rollback pagetest-# ; rollback 

it looks there strange visibility rules on stat collector views. there reasonable way around this?

try :

  begin;     select 1,current_query();     select 2,current_query();    rollback; 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -