Support EXPLAIN on Greenplum. Fixes #3097

- Extract SQLEditor.execute and SQLEditor._poll into their own files and add test around them
 - Extract SQLEditor backend functions that start executing query to their own files and add tests around it
 - Move the Explain SQL from the front-end and now pass the Explain plan parameters as a JSON object in the start query call.
 - Extract the compile_template_name into a function that can be used by the different places that try to select the version of the template and the server type
This commit is contained in:
Joao Pedro De Almeida Pereira
2018-02-09 11:54:42 +00:00
committed by Dave Page
parent e60a84c44f
commit e16a952753
30 changed files with 3673 additions and 582 deletions
@@ -0,0 +1,17 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2018, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
import os
def compile_template_name(template_prefix, template_file_name, server_type, version):
if server_type == 'gpdb':
version_path = '#{0}#{1}#'.format(server_type, version)
else:
version_path = '#{0}#'.format(version)
return os.path.join(template_prefix, version_path, template_file_name)
@@ -0,0 +1,34 @@
#######################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2018, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
from pgadmin.utils.compile_template_name import compile_template_name
from pgadmin.utils.route import BaseTestGenerator
class StartRunningQueryTest(BaseTestGenerator):
"""
Check that the apply_explain_plan_weapper_if_needed method works as intended
"""
scenarios = [
('When server is Postgres and version is 10, it returns the path to the postgres template', dict(
server_type='pg',
version=100000,
expected_return_value='some/prefix/#100000#/some_file.sql'
)),
('When server is GreenPlum and version is 5, it returns the path to the GreenPlum template', dict(
server_type='gpdb',
version=80323,
expected_return_value='some/prefix/#gpdb#80323#/some_file.sql'
)),
]
def runTest(self):
result = compile_template_name('some/prefix', 'some_file.sql', self.server_type, self.version)
self.assertEquals(result, self.expected_return_value)
@@ -6,7 +6,6 @@
# This software is released under the PostgreSQL Licence
#
##########################################################################
from flask.templating import DispatchingJinjaLoader
from jinja2 import TemplateNotFound
@@ -54,6 +53,7 @@ class VersionedTemplateLoader(DispatchingJinjaLoader):
template_path = path_start + '/' + \
server_version['name'] + '/' + file_name
try:
return super(VersionedTemplateLoader, self).get_source(
environment, template_path