"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/execute/SQLQueryJob.java" between
dbeaver-6.1.5.tar.gz and dbeaver-6.2.0.tar.gz

About: DBeaver is a multi-platform database tool (for developers and database administrators) that supports all popular databases. Java sources.

SQLQueryJob.java  (dbeaver-6.1.5):SQLQueryJob.java  (dbeaver-6.2.0)
skipping to change at line 114 skipping to change at line 114
private Throwable lastError = null; private Throwable lastError = null;
private DBCStatistics statistics; private DBCStatistics statistics;
private int fetchResultSetNumber; private int fetchResultSetNumber;
private int resultSetNumber; private int resultSetNumber;
private SQLQuery lastGoodQuery; private SQLQuery lastGoodQuery;
private boolean skipConfirmation; private boolean skipConfirmation;
private int fetchSize; private int fetchSize;
private long readFlags; private long readFlags;
private boolean ignoreParameters;
public SQLQueryJob( public SQLQueryJob(
@NotNull IWorkbenchPartSite partSite, @NotNull IWorkbenchPartSite partSite,
@NotNull String name, @NotNull String name,
@NotNull DBCExecutionContext executionContext, @NotNull DBCExecutionContext executionContext,
@Nullable DBSDataContainer dataContainer, @Nullable DBSDataContainer dataContainer,
@NotNull List<SQLScriptElement> queries, @NotNull List<SQLScriptElement> queries,
@NotNull SQLScriptContext scriptContext, @NotNull SQLScriptContext scriptContext,
@Nullable SQLResultsConsumer resultsConsumer, @Nullable SQLResultsConsumer resultsConsumer,
@Nullable SQLQueryListener listener) @Nullable SQLQueryListener listener)
skipping to change at line 404 skipping to change at line 405
listener.onStartQuery(session, sqlQuery); listener.onStartQuery(session, sqlQuery);
} catch (Exception e) { } catch (Exception e) {
log.error(e); log.error(e);
} }
startQueryAlerted = true; startQueryAlerted = true;
} }
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
SQLQuery execStatement = sqlQuery; SQLQuery execStatement = sqlQuery;
long execStartTime = startTime;
DBExecUtils.tryExecuteRecover(session, session.getDataSource(), para m -> { DBExecUtils.tryExecuteRecover(session, session.getDataSource(), para m -> {
try { try {
statistics.setStatementsCount(0);
statistics.setExecuteTime(0);
statistics.setFetchTime(0);
statistics.setRowsUpdated(0);
long execStartTime = System.currentTimeMillis();
executeStatement(session, execStatement, execStartTime, curR esult); executeStatement(session, execStatement, execStartTime, curR esult);
} catch (Throwable e) { } catch (Throwable e) {
throw new InvocationTargetException(e); throw new InvocationTargetException(e);
} }
}); });
} }
catch (Throwable ex) { catch (Throwable ex) {
if (!(ex instanceof DBException)) { if (!(ex instanceof DBException)) {
log.error("Unexpected error while processing SQL", ex); log.error("Unexpected error while processing SQL", ex);
} }
skipping to change at line 452 skipping to change at line 457
private void executeStatement(@NotNull DBCSession session, SQLQuery sqlQuery , long startTime, SQLQueryResult curResult) throws DBCException { private void executeStatement(@NotNull DBCSession session, SQLQuery sqlQuery , long startTime, SQLQueryResult curResult) throws DBCException {
DBCExecutionSource source = new AbstractExecutionSource(dataContainer, s ession.getExecutionContext(), partSite.getPart(), sqlQuery); DBCExecutionSource source = new AbstractExecutionSource(dataContainer, s ession.getExecutionContext(), partSite.getPart(), sqlQuery);
final DBCStatement dbcStatement = DBUtils.makeStatement( final DBCStatement dbcStatement = DBUtils.makeStatement(
source, source,
session, session,
DBCStatementType.SCRIPT, DBCStatementType.SCRIPT,
sqlQuery, sqlQuery,
rsOffset, rsOffset,
rsMaxRows); rsMaxRows);
if (fetchSize > 0) { DBExecUtils.setStatementFetchSize(dbcStatement, rsOffset, rsMaxRows, fet
dbcStatement.setResultsFetchSize(fetchSize); chSize);
}
curStatement = dbcStatement; curStatement = dbcStatement;
int statementTimeout = getDataSourceContainer().getPreferenceStore().get Int(SQLPreferenceConstants.STATEMENT_TIMEOUT); int statementTimeout = getDataSourceContainer().getPreferenceStore().get Int(SQLPreferenceConstants.STATEMENT_TIMEOUT);
if (statementTimeout > 0) { if (statementTimeout > 0) {
try { try {
dbcStatement.setStatementTimeout(statementTimeout); dbcStatement.setStatementTimeout(statementTimeout);
} catch (Throwable e) { } catch (Throwable e) {
log.debug("Can't set statement timeout:" + e.getMessage()); log.debug("Can't set statement timeout:" + e.getMessage());
} }
} }
// Execute statement // Execute statement
try { try {
session.getProgressMonitor().subTask("Execute query"); session.getProgressMonitor().subTask("Execute query");
boolean hasResultSet = dbcStatement.executeStatement();
statistics.addExecuteTime(System.currentTimeMillis() - startTime); statistics.addExecuteTime(System.currentTimeMillis() - startTime);
statistics.addStatementsCount(); statistics.addStatementsCount();
boolean hasResultSet = dbcStatement.executeStatement();
curResult.setHasResultSet(hasResultSet); curResult.setHasResultSet(hasResultSet);
long updateCount = -1; long updateCount = -1;
while (true) { while (true) {
// Fetch data only if we have to fetch all results or if it is r s requested // Fetch data only if we have to fetch all results or if it is r s requested
if (fetchResultSetNumber < 0 || fetchResultSetNumber == resultSe tNumber) { if (fetchResultSetNumber < 0 || fetchResultSetNumber == resultSe tNumber) {
if (hasResultSet && fetchResultSets) { if (hasResultSet && fetchResultSets) {
DBCResultSet resultSet = dbcStatement.openResultSet(); DBCResultSet resultSet = dbcStatement.openResultSet();
if (resultSet == null) { if (resultSet == null) {
// Kind of bug in the driver. It says it has results et but returns null // Kind of bug in the driver. It says it has results et but returns null
skipping to change at line 616 skipping to change at line 621
fakeResultSet.addRow(updateCount, query.getText(), new Date()); fakeResultSet.addRow(updateCount, query.getText(), new Date());
} else { } else {
fakeResultSet.addColumn("Result", DBPDataKind.NUMERIC); fakeResultSet.addColumn("Result", DBPDataKind.NUMERIC);
} }
executeResult.setResultSetName("Result"); executeResult.setResultSetName("Result");
} }
fetchQueryData(session, fakeResultSet, resultInfo, executeResult, dataRe ceiver, false); fetchQueryData(session, fakeResultSet, resultInfo, executeResult, dataRe ceiver, false);
} }
public boolean prepareStatementParameters(SQLQuery sqlStatement) { public boolean prepareStatementParameters(SQLQuery sqlStatement) {
if (ignoreParameters) {
return true;
}
// Bind parameters // Bind parameters
List<SQLQueryParameter> parameters = sqlStatement.getParameters(); List<SQLQueryParameter> parameters = sqlStatement.getParameters();
if (CommonUtils.isEmpty(parameters)) { if (CommonUtils.isEmpty(parameters)) {
return true; return true;
} }
if ((readFlags & DBSDataContainer.FLAG_FETCH_SEGMENT) == 0) { if ((readFlags & DBSDataContainer.FLAG_FETCH_SEGMENT) == 0) {
// Resolve parameters (only if it is the first fetch) // Resolve parameters (only if it is the first fetch)
if (!fillStatementParameters(parameters)) { if (!fillStatementParameters(parameters)) {
return false; return false;
} }
} }
if (ignoreParameters) {
return true;
}
// Set values for all parameters // Set values for all parameters
// Replace parameter tokens with parameter values // Replace parameter tokens with parameter values
String query = sqlStatement.getText(); String query = sqlStatement.getText();
for (int i = parameters.size(); i > 0; i--) { for (int i = parameters.size(); i > 0; i--) {
SQLQueryParameter parameter = parameters.get(i - 1); SQLQueryParameter parameter = parameters.get(i - 1);
String paramValue = parameter.getValue(); String paramValue = parameter.getValue();
if (paramValue == null || paramValue.isEmpty()) { if (paramValue == null || paramValue.isEmpty()) {
paramValue = SQLConstants.NULL_VALUE; paramValue = SQLConstants.NULL_VALUE;
} }
query = query.substring(0, parameter.getTokenOffset()) + paramValue + query.substring(parameter.getTokenOffset() + parameter.getTokenLength()); query = query.substring(0, parameter.getTokenOffset()) + paramValue + query.substring(parameter.getTokenOffset() + parameter.getTokenLength());
skipping to change at line 667 skipping to change at line 679
boolean allSet = true; boolean allSet = true;
for (SQLQueryParameter param : parameters) { for (SQLQueryParameter param : parameters) {
if (!param.isVariableSet()) { if (!param.isVariableSet()) {
allSet = false; allSet = false;
} }
} }
if (allSet) { if (allSet) {
return true; return true;
} }
boolean okPressed = new UIConfirmation() { int paramsResult = UITask.run(() -> {
@Override SQLQueryParameterBindDialog dialog = new SQLQueryParameterBindDialog
public Boolean runTask() { (
SQLQueryParameterBindDialog dialog = new SQLQueryParameterBindDi partSite.getShell(),
alog( parameters);
partSite.getShell(), return dialog.open();
parameters); });
return (dialog.open() == IDialogConstants.OK_ID);
}
}.execute();
if (okPressed) { if (paramsResult == IDialogConstants.OK_ID) {
// Save values back to script context // Save values back to script context
for (SQLQueryParameter param : parameters) { for (SQLQueryParameter param : parameters) {
if (param.isNamed() && scriptContext.hasVariable(param.getVarNam e())) { if (param.isNamed() && scriptContext.hasVariable(param.getVarNam e())) {
String strValue = param.getValue(); String strValue = param.getValue();
scriptContext.setVariable(param.getVarName(), strValue); scriptContext.setVariable(param.getVarName(), strValue);
} }
} }
return true;
} else if (paramsResult == IDialogConstants.IGNORE_ID) {
ignoreParameters = true;
return true;
} }
return okPressed; return false;
} }
private boolean fetchQueryData(DBCSession session, DBCResultSet resultSet, S QLQueryResult result, SQLQueryResult.ExecuteResult executeResult, DBDDataReceive r dataReceiver, boolean updateStatistics) private boolean fetchQueryData(DBCSession session, DBCResultSet resultSet, S QLQueryResult result, SQLQueryResult.ExecuteResult executeResult, DBDDataReceive r dataReceiver, boolean updateStatistics)
throws DBCException throws DBCException
{ {
if (dataReceiver == null) { if (dataReceiver == null) {
// No data pump - skip fetching stage // No data pump - skip fetching stage
return false; return false;
} }
if (resultSet == null) { if (resultSet == null) {
 End of changes. 12 change blocks. 
17 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)