mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix debugging of procedures in EPAS packages. Fixes #3457
This commit is contained in:
parent
fb1ef9ac0b
commit
b390c033cf
@ -17,3 +17,4 @@ Bug fixes
|
|||||||
*********
|
*********
|
||||||
|
|
||||||
| `Bug #3309 <https://redmine.postgresql.org/issues/3309>`_ - Fix Directory format support for backups.
|
| `Bug #3309 <https://redmine.postgresql.org/issues/3309>`_ - Fix Directory format support for backups.
|
||||||
|
| `Bug #3457 <https://redmine.postgresql.org/issues/3457>`_ - Fix debugging of procedures in EPAS packages.
|
||||||
|
@ -1240,6 +1240,8 @@ def execute_debugger_query(trans_id, query_type):
|
|||||||
update_session_debugger_transaction(trans_id, session_obj)
|
update_session_debugger_transaction(trans_id, session_obj)
|
||||||
|
|
||||||
status, result = conn.execute_async(sql)
|
status, result = conn.execute_async(sql)
|
||||||
|
if not status:
|
||||||
|
internal_server_error(errormsg=result)
|
||||||
return make_json_response(
|
return make_json_response(
|
||||||
data={'status': status, 'result': result}
|
data={'status': status, 'result': result}
|
||||||
)
|
)
|
||||||
@ -1969,6 +1971,16 @@ def poll_end_execution_result(trans_id):
|
|||||||
if statusmsg and statusmsg == 'SELECT 1':
|
if statusmsg and statusmsg == 'SELECT 1':
|
||||||
statusmsg = ''
|
statusmsg = ''
|
||||||
status, result = conn.poll()
|
status, result = conn.poll()
|
||||||
|
if not status:
|
||||||
|
status = 'ERROR'
|
||||||
|
return make_json_response(
|
||||||
|
info=gettext("Execution completed with an error."),
|
||||||
|
data={
|
||||||
|
'status': status,
|
||||||
|
'status_message': result
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
session_function_data = session['functionData'][str(trans_id)]
|
session_function_data = session['functionData'][str(trans_id)]
|
||||||
if status == ASYNC_OK and \
|
if status == ASYNC_OK and \
|
||||||
not session_function_data['is_func'] and\
|
not session_function_data['is_func'] and\
|
||||||
@ -1996,7 +2008,7 @@ def poll_end_execution_result(trans_id):
|
|||||||
if 'ERROR' in result:
|
if 'ERROR' in result:
|
||||||
status = 'ERROR'
|
status = 'ERROR'
|
||||||
return make_json_response(
|
return make_json_response(
|
||||||
info=gettext("Execution completed with error"),
|
info=gettext("Execution completed with an error."),
|
||||||
data={
|
data={
|
||||||
'status': status,
|
'status': status,
|
||||||
'status_message': result
|
'status_message': result
|
||||||
@ -2084,7 +2096,9 @@ def poll_result(trans_id):
|
|||||||
|
|
||||||
if conn.connected():
|
if conn.connected():
|
||||||
status, result = conn.poll()
|
status, result = conn.poll()
|
||||||
if status == ASYNC_OK and result is not None:
|
if not status:
|
||||||
|
status = 'ERROR'
|
||||||
|
elif status == ASYNC_OK and result is not None:
|
||||||
status = 'Success'
|
status = 'Success'
|
||||||
columns, result = convert_data_to_dict(conn, result)
|
columns, result = convert_data_to_dict(conn, result)
|
||||||
else:
|
else:
|
||||||
|
@ -2,10 +2,11 @@ define([
|
|||||||
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
|
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
|
||||||
'underscore.string', 'alertify', 'sources/pgadmin', 'pgadmin.browser',
|
'underscore.string', 'alertify', 'sources/pgadmin', 'pgadmin.browser',
|
||||||
'backbone', 'pgadmin.backgrid', 'codemirror', 'pgadmin.backform',
|
'backbone', 'pgadmin.backgrid', 'codemirror', 'pgadmin.backform',
|
||||||
'pgadmin.tools.debugger.ui', 'wcdocker', 'pgadmin.browser.frame',
|
'pgadmin.tools.debugger.ui', 'pgadmin.tools.debugger.utils',
|
||||||
|
'wcdocker', 'pgadmin.browser.frame',
|
||||||
], function(
|
], function(
|
||||||
gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
|
gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
|
||||||
CodeMirror, Backform, get_function_arguments
|
CodeMirror, Backform, get_function_arguments, debuggerUtils
|
||||||
) {
|
) {
|
||||||
var pgTools = pgAdmin.Tools = pgAdmin.Tools || {},
|
var pgTools = pgAdmin.Tools = pgAdmin.Tools || {},
|
||||||
wcDocker = window.wcDocker;
|
wcDocker = window.wcDocker;
|
||||||
@ -337,7 +338,7 @@ define([
|
|||||||
'sid': treeInfo.server._id,
|
'sid': treeInfo.server._id,
|
||||||
'did': treeInfo.database._id,
|
'did': treeInfo.database._id,
|
||||||
'scid': treeInfo.schema._id,
|
'scid': treeInfo.schema._id,
|
||||||
'func_id': treeInfo.procedure._id,
|
'func_id': debuggerUtils.getProcedureId(treeInfo),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if (d._type == 'trigger_function') {
|
} else if (d._type == 'trigger_function') {
|
||||||
@ -482,7 +483,7 @@ define([
|
|||||||
'sid': treeInfo.server._id,
|
'sid': treeInfo.server._id,
|
||||||
'did': treeInfo.database._id,
|
'did': treeInfo.database._id,
|
||||||
'scid': treeInfo.schema._id,
|
'scid': treeInfo.schema._id,
|
||||||
'func_id': treeInfo.procedure._id,
|
'func_id': debuggerUtils.getProcedureId(treeInfo),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,19 @@ function setFocusToDebuggerEditor(editor, command) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getProcedureId(treeInfoObject) {
|
||||||
|
let objectId;
|
||||||
|
if(treeInfoObject) {
|
||||||
|
if (treeInfoObject.procedure && treeInfoObject.procedure._id) {
|
||||||
|
objectId = treeInfoObject.procedure._id;
|
||||||
|
} else if (treeInfoObject.edbproc && treeInfoObject.edbproc._id) {
|
||||||
|
objectId = treeInfoObject.edbproc._id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return objectId;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
setFocusToDebuggerEditor: setFocusToDebuggerEditor,
|
setFocusToDebuggerEditor: setFocusToDebuggerEditor,
|
||||||
|
getProcedureId: getProcedureId,
|
||||||
};
|
};
|
||||||
|
@ -7,9 +7,12 @@
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
import { setFocusToDebuggerEditor } from '../../pgadmin/tools/debugger/static/js/debugger_utils';
|
import {
|
||||||
|
setFocusToDebuggerEditor,
|
||||||
|
getProcedureId,
|
||||||
|
} from '../../pgadmin/tools/debugger/static/js/debugger_utils';
|
||||||
|
|
||||||
describe('debuggerUtils', function () {
|
describe('setFocusToDebuggerEditor', function () {
|
||||||
let editor;
|
let editor;
|
||||||
editor = jasmine.createSpyObj('editor', ['focus']);
|
editor = jasmine.createSpyObj('editor', ['focus']);
|
||||||
|
|
||||||
@ -23,22 +26,60 @@ describe('debuggerUtils', function () {
|
|||||||
keyCode: 13,
|
keyCode: 13,
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('debuggerUtils', function () {
|
describe('setFocusToDebuggerEditor', function () {
|
||||||
it('returns undefined if no command is passed', function () {
|
it('returns undefined if no command is passed', function () {
|
||||||
expect(setFocusToDebuggerEditor(editor, null)).toEqual(undefined);
|
expect(setFocusToDebuggerEditor(editor, null)).toEqual(undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('debuggerUtils', function () {
|
describe('setFocusToDebuggerEditor', function () {
|
||||||
it('should call focus on editor', function () {
|
it('should call focus on editor', function () {
|
||||||
setFocusToDebuggerEditor(editor, enter_key);
|
setFocusToDebuggerEditor(editor, enter_key);
|
||||||
expect(editor.focus).toHaveBeenCalled();
|
expect(editor.focus).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('debuggerUtils', function () {
|
describe('setFocusToDebuggerEditor', function () {
|
||||||
it('should not call focus on editor and returns undefined', function () {
|
it('should not call focus on editor and returns undefined', function () {
|
||||||
expect(setFocusToDebuggerEditor(editor, tab_key)).toEqual(undefined);
|
expect(setFocusToDebuggerEditor(editor, tab_key)).toEqual(undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getProcedureId', function () {
|
||||||
|
let treeInfroProc = {
|
||||||
|
'procedure': {
|
||||||
|
'_id': 123,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let treeInfroInvalidProcId = {
|
||||||
|
'procedure': {
|
||||||
|
'_id': null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let treeInfroEdbProc = {
|
||||||
|
'edbproc': {
|
||||||
|
'_id': 321,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let fakeTreeInfro;
|
||||||
|
|
||||||
|
describe('Should return proper object id', function () {
|
||||||
|
it('returns valid procedure id', function () {
|
||||||
|
expect(getProcedureId(treeInfroProc)).toBe(123);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns valid edbproc id', function () {
|
||||||
|
expect(getProcedureId(treeInfroEdbProc)).toBe(321);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns undefined for fake tree info', function () {
|
||||||
|
expect(getProcedureId(fakeTreeInfro)).toBe(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns undefined for invalid procedure id', function () {
|
||||||
|
expect(getProcedureId(treeInfroInvalidProcId)).toBe(undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user