public inbox for [email protected]
help / color / mirror / Atom feed[pgadmin4][patch] GreenPlum function statistics through an exception
2+ messages / 2 participants
[nested] [flat]
* [pgadmin4][patch] GreenPlum function statistics through an exception
@ 2018-03-05 14:25 Joao De Almeida Pereira <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Joao De Almeida Pereira @ 2018-03-05 14:25 UTC (permalink / raw)
To: pgadmin-hackers
Hi Hackers,
You can find attached the resolution for issue 3176.
When trying to retrieve the statistics from a function in a GreenPlum
database an error is displayed, To fix this for version 5.X we decided to
remove the ability to get statistics.
Thanks
Joao
Attachments:
[text/x-patch] display-statistics-error-on-functions.diff (4.1K, 3-display-statistics-error-on-functions.diff)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js
index 7622cd0b..6e405165 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js
@@ -92,7 +92,9 @@ define('pgadmin.node.function', [
collection_type: 'coll-function',
hasSQL: true,
hasDepends: true,
- hasStatistics: true,
+ hasStatistics: (treeInformation) => {
+ return treeInformation.server.server_type !== 'gpdb';
+ },
hasScriptTypes: ['create', 'select'],
parent_type: ['schema', 'catalog'],
Init: function() {
diff --git a/web/pgadmin/misc/statistics/static/js/statistics.js b/web/pgadmin/misc/statistics/static/js/statistics.js
index 39ff7bb3..3ff88a0a 100644
--- a/web/pgadmin/misc/statistics/static/js/statistics.js
+++ b/web/pgadmin/misc/statistics/static/js/statistics.js
@@ -1,8 +1,10 @@
define('misc.statistics', [
'sources/gettext', 'underscore', 'underscore.string', 'jquery', 'backbone',
'pgadmin.browser', 'pgadmin.backgrid', 'alertify', 'sources/size_prettify',
+ 'sources/misc/statistics/statistics',
], function(
- gettext, _, S, $, Backbone, pgBrowser, Backgrid, Alertify, sizePrettify
+ gettext, _, S, $, Backbone, pgBrowser, Backgrid, Alertify, sizePrettify,
+ statisticsHelper
) {
if (pgBrowser.NodeStatistics)
@@ -208,7 +210,7 @@ define('misc.statistics', [
// Cache the current IDs for next time
$(panel[0]).data('node-prop', cache_flag);
- if (node.hasStatistics) {
+ if (statisticsHelper.nodeHasStatistics(node, item)) {
msg = '';
var timer;
// Set the url, fetch the data and update the collection
diff --git a/web/pgadmin/static/js/misc/statistics/statistics.js b/web/pgadmin/static/js/misc/statistics/statistics.js
new file mode 100644
index 00000000..2aabc75b
--- /dev/null
+++ b/web/pgadmin/static/js/misc/statistics/statistics.js
@@ -0,0 +1,15 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin 4 - PostgreSQL Tools
+//
+// Copyright (C) 2013 - 2018, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+export function nodeHasStatistics(node, item) {
+ if(typeof(node.hasStatistics) === 'function') {
+ const treeHierarchy = node.getTreeNodeHierarchy(item);
+ return node.hasStatistics(treeHierarchy);
+ }
+ return node.hasStatistics;
+}
diff --git a/web/regression/javascript/misc/statistics/statistics_spec.js b/web/regression/javascript/misc/statistics/statistics_spec.js
new file mode 100644
index 00000000..87540d10
--- /dev/null
+++ b/web/regression/javascript/misc/statistics/statistics_spec.js
@@ -0,0 +1,35 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin 4 - PostgreSQL Tools
+//
+// Copyright (C) 2013 - 2018, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+import {nodeHasStatistics} from "../../../../pgadmin/static/js/misc/statistics/statistics";
+
+describe('#nodeHasStatistics', () => {
+ describe('when node hasStatistics is not a function', () => {
+ it('return the value of hasStatistics', () => {
+ const node = {
+ hasStatistics: true,
+ };
+ expect(nodeHasStatistics(node, {})).toBe(true);
+ });
+ });
+
+ describe('when node hasStatistics is a function', () => {
+ describe('when the function returns true', () => {
+ it('returns true', () => {
+ const node = {
+ hasStatistics: () => true,
+ getTreeNodeHierarchy: jasmine.createSpy(),
+ };
+ const item = {};
+
+ expect(nodeHasStatistics(node, item)).toBe(true);
+ expect(node.getTreeNodeHierarchy).toHaveBeenCalledWith(item);
+ });
+ });
+ });
+});
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [pgadmin4][patch] GreenPlum function statistics through an exception
@ 2018-03-07 11:52 Dave Page <[email protected]>
parent: Joao De Almeida Pereira <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Dave Page @ 2018-03-07 11:52 UTC (permalink / raw)
To: Joao De Almeida Pereira <[email protected]>; +Cc: pgadmin-hackers
Thanks, applied.
On Mon, Mar 5, 2018 at 2:25 PM, Joao De Almeida Pereira <
[email protected]> wrote:
> Hi Hackers,
> You can find attached the resolution for issue 3176.
> When trying to retrieve the statistics from a function in a GreenPlum
> database an error is displayed, To fix this for version 5.X we decided to
> remove the ability to get statistics.
>
> Thanks
> Joao
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-03-07 11:52 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-05 14:25 [pgadmin4][patch] GreenPlum function statistics through an exception Joao De Almeida Pereira <[email protected]>
2018-03-07 11:52 ` Dave Page <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox