mirror of https://gitee.com/bigwinds/arangodb
explain bind param support, view + aardvark
This commit is contained in:
parent
bb814f1c5d
commit
068bee4c80
|
@ -170,11 +170,17 @@ controller.post("disableVersionCheck", function(req, res) {
|
||||||
*/
|
*/
|
||||||
controller.post("/query/explain", function(req, res) {
|
controller.post("/query/explain", function(req, res) {
|
||||||
|
|
||||||
var explain, query = req.body().query;
|
var explain, query = req.body().query,
|
||||||
|
bindVars = req.body().bindVars;
|
||||||
|
|
||||||
if (query.length > 0) {
|
if (query.length > 0) {
|
||||||
try {
|
try {
|
||||||
explain = require("org/arangodb/aql/explainer").explain(query, {colors: false}, false);
|
if (bindVars) {
|
||||||
|
explain = require("org/arangodb/aql/explainer").explain(query, {colors: false}, false, bindVars);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
explain = require("org/arangodb/aql/explainer").explain(query, {colors: false}, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
explain = JSON.stringify(e);
|
explain = JSON.stringify(e);
|
||||||
|
|
|
@ -102,7 +102,7 @@
|
||||||
inputEditor = ace.edit("aqlEditor"),
|
inputEditor = ace.edit("aqlEditor"),
|
||||||
varsEditor = ace.edit("varsEditor");
|
varsEditor = ace.edit("varsEditor");
|
||||||
inputEditor.setValue(this.getCustomQueryValueByName(queryName));
|
inputEditor.setValue(this.getCustomQueryValueByName(queryName));
|
||||||
varsEditor.setValue(this.getCustomQueryParameterByName(queryName));
|
varsEditor.setValue(JSON.stringify(this.getCustomQueryParameterByName(queryName)));
|
||||||
this.deselect(varsEditor);
|
this.deselect(varsEditor);
|
||||||
this.deselect(inputEditor);
|
this.deselect(inputEditor);
|
||||||
$('#querySelect').val(queryName);
|
$('#querySelect').val(queryName);
|
||||||
|
@ -541,6 +541,14 @@
|
||||||
bindVars = '{}';
|
bindVars = '{}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof bindVars === 'string') {
|
||||||
|
try {
|
||||||
|
bindVars = JSON.parse(bindVars);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log("could not parse bind parameter");
|
||||||
|
}
|
||||||
|
}
|
||||||
this.collection.add({
|
this.collection.add({
|
||||||
name: saveName,
|
name: saveName,
|
||||||
parameter: bindVars,
|
parameter: bindVars,
|
||||||
|
@ -672,6 +680,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
var bindVars = varsEditor.getValue();
|
var bindVars = varsEditor.getValue();
|
||||||
|
|
||||||
if (bindVars.length > 0) {
|
if (bindVars.length > 0) {
|
||||||
try {
|
try {
|
||||||
var params = JSON.parse(bindVars);
|
var params = JSON.parse(bindVars);
|
||||||
|
@ -681,6 +690,7 @@
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
arangoHelper.arangoError("Query error", "Could not parse bind parameters.");
|
arangoHelper.arangoError("Query error", "Could not parse bind parameters.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return JSON.stringify(data);
|
return JSON.stringify(data);
|
||||||
|
@ -859,42 +869,47 @@
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var outputEditor = ace.edit("queryOutput");
|
var outputEditor = ace.edit("queryOutput");
|
||||||
|
var queryData = this.readQueryData();
|
||||||
$('.queryExecutionTime').text('');
|
$('.queryExecutionTime').text('');
|
||||||
window.progressView.show(
|
|
||||||
"Explain is operating..."
|
|
||||||
);
|
|
||||||
this.execPending = false;
|
this.execPending = false;
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: "/_admin/aardvark/query/explain/",
|
|
||||||
data: this.readQueryData(),
|
|
||||||
contentType: "application/json",
|
|
||||||
processData: false,
|
|
||||||
success: function (data) {
|
|
||||||
outputEditor.setValue(data.msg);
|
|
||||||
self.switchTab("result-switch");
|
|
||||||
window.progressView.hide();
|
|
||||||
self.deselect(outputEditor);
|
|
||||||
$('#downloadQueryResult').hide();
|
|
||||||
if (typeof callback === "function") {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function (data) {
|
|
||||||
try {
|
|
||||||
var temp = JSON.parse(data.responseText);
|
|
||||||
arangoHelper.arangoError("Explain error", temp.errorNum);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
arangoHelper.arangoError("Explain error", "ERROR");
|
|
||||||
}
|
|
||||||
window.progressView.hide();
|
|
||||||
if (typeof callback === "function") {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
if (queryData) {
|
||||||
|
window.progressView.show(
|
||||||
|
"Explain is operating..."
|
||||||
|
);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/_admin/aardvark/query/explain/",
|
||||||
|
data: queryData,
|
||||||
|
contentType: "application/json",
|
||||||
|
processData: false,
|
||||||
|
success: function (data) {
|
||||||
|
outputEditor.setValue(data.msg);
|
||||||
|
self.switchTab("result-switch");
|
||||||
|
window.progressView.hide();
|
||||||
|
self.deselect(outputEditor);
|
||||||
|
$('#downloadQueryResult').hide();
|
||||||
|
if (typeof callback === "function") {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (data) {
|
||||||
|
window.progressView.hide();
|
||||||
|
try {
|
||||||
|
var temp = JSON.parse(data.responseText);
|
||||||
|
arangoHelper.arangoError("Explain error", temp.errorNum);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
arangoHelper.arangoError("Explain error", "ERROR");
|
||||||
|
}
|
||||||
|
window.progressView.hide();
|
||||||
|
if (typeof callback === "function") {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
var self = this;
|
var self = this;
|
||||||
$("svg#explainOutput").html();
|
$("svg#explainOutput").html();
|
||||||
|
@ -952,67 +967,70 @@
|
||||||
// clear result
|
// clear result
|
||||||
outputEditor.setValue('');
|
outputEditor.setValue('');
|
||||||
|
|
||||||
window.progressView.show(
|
var queryData = this.readQueryData();
|
||||||
"Query is operating..."
|
if (queryData) {
|
||||||
);
|
|
||||||
|
|
||||||
$('.queryExecutionTime').text('');
|
window.progressView.show(
|
||||||
self.timer.start();
|
"Query is operating..."
|
||||||
|
);
|
||||||
|
|
||||||
this.execPending = false;
|
$('.queryExecutionTime').text('');
|
||||||
$.ajax({
|
self.timer.start();
|
||||||
type: "POST",
|
|
||||||
url: "/_api/cursor",
|
|
||||||
data: this.readQueryData(),
|
|
||||||
contentType: "application/json",
|
|
||||||
processData: false,
|
|
||||||
success: function (data) {
|
|
||||||
|
|
||||||
var time = "Execution time: " + self.timer.getTimeAndReset()/1000 + " s";
|
this.execPending = false;
|
||||||
$('.queryExecutionTime').text(time);
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/_api/cursor",
|
||||||
|
data: queryData,
|
||||||
|
contentType: "application/json",
|
||||||
|
processData: false,
|
||||||
|
success: function (data) {
|
||||||
|
|
||||||
var warnings = "";
|
var time = "Execution time: " + self.timer.getTimeAndReset()/1000 + " s";
|
||||||
if (data.extra && data.extra.warnings && data.extra.warnings.length > 0) {
|
$('.queryExecutionTime').text(time);
|
||||||
warnings += "Warnings:" + "\r\n\r\n";
|
|
||||||
data.extra.warnings.forEach(function(w) {
|
var warnings = "";
|
||||||
warnings += "[" + w.code + "], '" + w.message + "'\r\n";
|
if (data.extra && data.extra.warnings && data.extra.warnings.length > 0) {
|
||||||
});
|
warnings += "Warnings:" + "\r\n\r\n";
|
||||||
|
data.extra.warnings.forEach(function(w) {
|
||||||
|
warnings += "[" + w.code + "], '" + w.message + "'\r\n";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (warnings !== "") {
|
||||||
|
warnings += "\r\n" + "Result:" + "\r\n\r\n";
|
||||||
|
}
|
||||||
|
outputEditor.setValue(warnings + JSON.stringify(data.result, undefined, 2));
|
||||||
|
self.switchTab("result-switch");
|
||||||
|
window.progressView.hide();
|
||||||
|
self.deselect(outputEditor);
|
||||||
|
$('#downloadQueryResult').show();
|
||||||
|
if (typeof callback === "function") {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (data) {
|
||||||
|
self.switchTab("result-switch");
|
||||||
|
$('#downloadQueryResult').hide();
|
||||||
|
try {
|
||||||
|
var temp = JSON.parse(data.responseText);
|
||||||
|
outputEditor.setValue('[' + temp.errorNum + '] ' + temp.errorMessage);
|
||||||
|
//arangoHelper.arangoError("Query error", temp.errorMessage);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
outputEditor.setValue('ERROR');
|
||||||
|
arangoHelper.arangoError("Query error", "ERROR");
|
||||||
|
}
|
||||||
|
window.progressView.hide();
|
||||||
|
if (typeof callback === "function") {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (warnings !== "") {
|
});
|
||||||
warnings += "\r\n" + "Result:" + "\r\n\r\n";
|
}
|
||||||
}
|
|
||||||
outputEditor.setValue(warnings + JSON.stringify(data.result, undefined, 2));
|
|
||||||
self.switchTab("result-switch");
|
|
||||||
window.progressView.hide();
|
|
||||||
self.deselect(outputEditor);
|
|
||||||
$('#downloadQueryResult').show();
|
|
||||||
if (typeof callback === "function") {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function (data) {
|
|
||||||
self.switchTab("result-switch");
|
|
||||||
$('#downloadQueryResult').hide();
|
|
||||||
try {
|
|
||||||
var temp = JSON.parse(data.responseText);
|
|
||||||
outputEditor.setValue('[' + temp.errorNum + '] ' + temp.errorMessage);
|
|
||||||
//arangoHelper.arangoError("Query error", temp.errorMessage);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
outputEditor.setValue('ERROR');
|
|
||||||
arangoHelper.arangoError("Query error", "ERROR");
|
|
||||||
}
|
|
||||||
window.progressView.hide();
|
|
||||||
if (typeof callback === "function") {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
submitQuery: function () {
|
submitQuery: function () {
|
||||||
var outputEditor = ace.edit("queryOutput");
|
var outputEditor = ace.edit("queryOutput");
|
||||||
// this.fillExplain();
|
|
||||||
this.fillResult(this.switchTab.bind(this, "result-switch"));
|
this.fillResult(this.switchTab.bind(this, "result-switch"));
|
||||||
outputEditor.resize();
|
outputEditor.resize();
|
||||||
var inputEditor = ace.edit("aqlEditor");
|
var inputEditor = ace.edit("aqlEditor");
|
||||||
|
@ -1021,14 +1039,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
explainQuery: function() {
|
explainQuery: function() {
|
||||||
|
|
||||||
this.fillExplain();
|
this.fillExplain();
|
||||||
/*
|
|
||||||
this.fillExplain(this.switchTab.bind(this, "explain-switch"));
|
|
||||||
this.execPending = true;
|
|
||||||
var inputEditor = ace.edit("aqlEditor");
|
|
||||||
this.deselect(inputEditor);
|
|
||||||
*/
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// This function changes the focus onto the tab that has been clicked
|
// This function changes the focus onto the tab that has been clicked
|
||||||
|
|
Loading…
Reference in New Issue