use of org.jkiss.dbeaver.model.sql.SQLQuery in project dbeaver by serge-rider.
the class SQLEditor method extractScriptQueries.
private List<SQLQuery> extractScriptQueries(int startOffset, int length) {
List<SQLQuery> queryList = new ArrayList<>();
IDocument document = getDocument();
if (document == null) {
return queryList;
}
this.startScriptEvaluation();
try {
for (int queryOffset = startOffset; ; ) {
SQLQuery query = parseQuery(document, queryOffset, startOffset + length, queryOffset, true);
if (query == null) {
break;
}
queryList.add(query);
queryOffset = query.getOffset() + query.getLength() + 1;
}
} finally {
this.endScriptEvaluation();
}
if (getActivePreferenceStore().getBoolean(ModelPreferences.SQL_PARAMETERS_ENABLED)) {
// Parse parameters
for (SQLQuery query : queryList) {
query.setParameters(parseParameters(getDocument(), query));
}
}
return queryList;
}
use of org.jkiss.dbeaver.model.sql.SQLQuery in project dbeaver by serge-rider.
the class ExplainPlanViewer method loadQueryPlan.
public boolean loadQueryPlan(DBCQueryPlanner planner, Viewer viewer) {
if (planner instanceof DBCQueryPlannerSerializable) {
FileDialog fd = new FileDialog(viewer.getControl().getShell(), SWT.OPEN | SWT.SINGLE);
fd.setText(UIMessages.save_execution_plan);
fd.setFilterPath(curFolder);
fd.setFilterExtensions(SQLPlanSaveProvider.EXT);
String selected = fd.open();
if (selected != null) {
curFolder = fd.getFilterPath();
try (Reader r = new FileReader(selected)) {
lastPlan = ((DBCQueryPlannerSerializable) planner).deserialize(r);
lastQuery = new SQLQuery(contextProvider.getExecutionContext().getDataSource(), lastPlan.getQueryString());
lastQueryId = lastPlan.getQueryString();
refresh();
return true;
} catch (IOException | InvocationTargetException e) {
DBWorkbench.getPlatformUI().showError("Load plan", "Error loading plan ", GeneralUtils.getRootCause(e));
}
}
}
return false;
}
Aggregations