From 401e13ca650e06f2ee9c2220d0c7b7dcbbcf6dd6 Mon Sep 17 00:00:00 2001 From: Murtuza Zabuawala Date: Mon, 28 Aug 2017 16:13:33 +0530 Subject: [PATCH] Fixed issue where 'backend_type' column is exist for database server version greater than 10. Issue is regression of RM #2597. --- web/pgadmin/dashboard/static/js/dashboard.js | 21 ++++++++++++------- .../dashboard/sql/10_plus/activity.sql | 19 +++++++++++++++++ .../dashboard/sql/9.6_plus/activity.sql | 3 +-- 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 web/pgadmin/dashboard/templates/dashboard/sql/10_plus/activity.sql diff --git a/web/pgadmin/dashboard/static/js/dashboard.js b/web/pgadmin/dashboard/static/js/dashboard.js index 5c7542195..0e709ecb8 100644 --- a/web/pgadmin/dashboard/static/js/dashboard.js +++ b/web/pgadmin/dashboard/static/js/dashboard.js @@ -132,7 +132,7 @@ function(url_for, gettext, r, $, _, pgAdmin, Backbone, Backgrid, Flotr, type: 'text', editable: true, disabled: true, group: gettext('Details'), visible: function(m) { - return m.get('version') >= 100000; + return this.version >= 100000; } },{ id: 'query_start', label: gettext('Query started at'), @@ -644,14 +644,17 @@ function(url_for, gettext, r, $, _, pgAdmin, Backbone, Backgrid, Flotr, }]); } - var newActiveQueryDetailsModel = new ActiveQueryDetailsModel( - {'version': version} - ); + var newActiveQueryDetailsModel = new ActiveQueryDetailsModel(); var subNodeFieldsModel = Backform.generateViewSchema( null, newActiveQueryDetailsModel, 'create', null, null, true ); + // Add version to each field + _.each(subNodeFieldsModel[0].fields, function(obj) { + obj['version'] = version; + }); + // Add cancel active query button server_activity_columns.unshift({ name: "pg-backform-expand", label: "", @@ -978,14 +981,18 @@ function(url_for, gettext, r, $, _, pgAdmin, Backbone, Backgrid, Flotr, }]); } - var newActiveQueryDetailsModel = new ActiveQueryDetailsModel( - {'version': version} - ); + var newActiveQueryDetailsModel = new ActiveQueryDetailsModel(); var subNodeFieldsModel = Backform.generateViewSchema( null, newActiveQueryDetailsModel, 'create', null, null, true ); + // Add version to each field + _.each(subNodeFieldsModel[0].fields, function(obj) { + obj['version'] = version; + }); + + // Add cancel active query button database_activity_columns.unshift({ name: "pg-backform-expand", label: "", diff --git a/web/pgadmin/dashboard/templates/dashboard/sql/10_plus/activity.sql b/web/pgadmin/dashboard/templates/dashboard/sql/10_plus/activity.sql new file mode 100644 index 000000000..9b067a8df --- /dev/null +++ b/web/pgadmin/dashboard/templates/dashboard/sql/10_plus/activity.sql @@ -0,0 +1,19 @@ +SELECT + pid, + datname, + usename, + application_name, + client_addr, + to_char(backend_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS backend_start, + state, + wait_event_type || ': ' || wait_event AS wait_event, + pg_blocking_pids(pid) AS blocking_pids, + query, + to_char(state_change, 'YYYY-MM-DD HH24:MI:SS TZ') AS state_change, + to_char(query_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS query_start, + backend_type +FROM + pg_stat_activity +{% if did %}WHERE + datname = (SELECT datname FROM pg_database WHERE oid = {{ did }}){% endif %} +ORDER BY pid diff --git a/web/pgadmin/dashboard/templates/dashboard/sql/9.6_plus/activity.sql b/web/pgadmin/dashboard/templates/dashboard/sql/9.6_plus/activity.sql index 9b067a8df..f1f4061b0 100644 --- a/web/pgadmin/dashboard/templates/dashboard/sql/9.6_plus/activity.sql +++ b/web/pgadmin/dashboard/templates/dashboard/sql/9.6_plus/activity.sql @@ -10,8 +10,7 @@ SELECT pg_blocking_pids(pid) AS blocking_pids, query, to_char(state_change, 'YYYY-MM-DD HH24:MI:SS TZ') AS state_change, - to_char(query_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS query_start, - backend_type + to_char(query_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS query_start FROM pg_stat_activity {% if did %}WHERE