use of org.jkiss.dbeaver.model.qm.meta.QMMTransactionSavepointInfo in project dbeaver by dbeaver.
the class QMUtils method isTransactionActive.
public static boolean isTransactionActive(DBCExecutionContext executionContext) {
if (executionContext == null || application == null) {
return false;
} else {
QMMSessionInfo sessionInfo = getCurrentSession(executionContext);
if (sessionInfo != null && sessionInfo.isTransactional()) {
QMMTransactionInfo txnInfo = sessionInfo.getTransaction();
if (txnInfo != null) {
QMMTransactionSavepointInfo sp = txnInfo.getCurrentSavepoint();
QMMStatementExecuteInfo execInfo = sp.getLastExecute();
for (QMMStatementExecuteInfo exec = execInfo; exec != null && exec.getSavepoint() == sp; exec = exec.getPrevious()) {
if (exec.isTransactional()) {
return true;
}
}
}
}
}
return false;
}
use of org.jkiss.dbeaver.model.qm.meta.QMMTransactionSavepointInfo in project dbeaver by dbeaver.
the class TransactionInfoDialog method createContextFilter.
protected QMEventFilter createContextFilter(DBCExecutionContext executionContext) {
if (executionContext == null) {
return VOID_FILTER;
}
final boolean showAll = showAllCheck != null && showAllCheck.getSelection();
final boolean showPrevious = showPreviousCheck != null && showPreviousCheck.getSelection();
final QMMSessionInfo currentSession = QMUtils.getCurrentSession(executionContext);
final QMMTransactionSavepointInfo currentSP = QMUtils.getCurrentTransaction(executionContext);
QMEventFilter filter = new QMEventFilter() {
@Override
public boolean accept(QMMetaEvent event) {
QMMObject object = event.getObject();
if (object instanceof QMMStatementExecuteInfo) {
QMMStatementExecuteInfo exec = (QMMStatementExecuteInfo) object;
if (!showPrevious && exec.getSavepoint() != currentSP) {
return false;
}
if (exec.getStatement().getSession() != currentSession) {
return false;
}
DBCExecutionPurpose purpose = exec.getStatement().getPurpose();
if (purpose == DBCExecutionPurpose.META || purpose == DBCExecutionPurpose.UTIL) {
return false;
}
return (showAll || exec.isTransactional());
}
return false;
}
};
return filter;
}
use of org.jkiss.dbeaver.model.qm.meta.QMMTransactionSavepointInfo in project dbeaver by serge-rider.
the class TransactionInfoDialog method createContextFilter.
protected QMEventFilter createContextFilter(DBCExecutionContext executionContext) {
if (executionContext == null) {
return VOID_FILTER;
}
final boolean showAll = showAllCheck != null && showAllCheck.getSelection();
final boolean showPrevious = showPreviousCheck != null && showPreviousCheck.getSelection();
final QMMSessionInfo currentSession = QMUtils.getCurrentSession(executionContext);
final QMMTransactionSavepointInfo currentSP = QMUtils.getCurrentTransaction(executionContext);
QMEventFilter filter = event -> {
QMMObject object = event.getObject();
if (object instanceof QMMStatementExecuteInfo) {
QMMStatementExecuteInfo exec = (QMMStatementExecuteInfo) object;
if (!showPrevious && !CommonUtils.equalObjects(exec.getSavepoint(), currentSP)) {
return false;
}
if (!showAll && !CommonUtils.equalObjects(exec.getStatement().getSession(), currentSession)) {
return false;
}
DBCExecutionPurpose purpose = exec.getStatement().getPurpose();
if (purpose == DBCExecutionPurpose.META || purpose == DBCExecutionPurpose.UTIL) {
return false;
}
return (showAll || exec.isTransactional());
}
return false;
};
return filter;
}
use of org.jkiss.dbeaver.model.qm.meta.QMMTransactionSavepointInfo in project dbeaver by serge-rider.
the class QMUtils method getTransactionState.
@NotNull
public static QMTransactionState getTransactionState(DBCExecutionContext executionContext) {
int execCount = 0, updateCount = 0;
final boolean txnMode;
long txnStartTime = 0;
if (executionContext == null || application == null) {
txnMode = false;
} else {
QMMSessionInfo sessionInfo = getCurrentSession(executionContext);
if (sessionInfo == null || sessionInfo.isClosed()) {
txnMode = false;
} else if (sessionInfo.isTransactional()) {
QMMTransactionInfo txnInfo = sessionInfo.getTransaction();
if (txnInfo != null) {
txnMode = true;
QMMTransactionSavepointInfo sp = txnInfo.getCurrentSavepoint();
QMMStatementExecuteInfo execInfo = sp.getLastExecute();
for (QMMStatementExecuteInfo exec = execInfo; exec != null && exec.getSavepoint() == sp; exec = exec.getPrevious()) {
execCount++;
DBCExecutionPurpose purpose = exec.getStatement().getPurpose();
if (!exec.hasError() && purpose != DBCExecutionPurpose.META && purpose != DBCExecutionPurpose.UTIL) {
txnStartTime = exec.getOpenTime();
updateCount++;
}
}
} else {
// No active transaction?
txnMode = false;
}
} else {
txnMode = false;
}
}
if (txnStartTime <= 0) {
txnStartTime = System.currentTimeMillis();
}
return new QMTransactionState(execCount, updateCount, txnMode, txnStartTime);
}
use of org.jkiss.dbeaver.model.qm.meta.QMMTransactionSavepointInfo in project dbeaver by serge-rider.
the class QMUtils method isTransactionActive.
public static boolean isTransactionActive(DBCExecutionContext executionContext) {
if (executionContext == null || application == null) {
return false;
} else {
QMMSessionInfo sessionInfo = getCurrentSession(executionContext);
if (sessionInfo != null) {
QMMTransactionInfo txnInfo = sessionInfo.getTransaction();
if (txnInfo != null) {
QMMTransactionSavepointInfo sp = txnInfo.getCurrentSavepoint();
QMMStatementExecuteInfo execInfo = sp.getLastExecute();
for (QMMStatementExecuteInfo exec = execInfo; exec != null && exec.getSavepoint() == sp; exec = exec.getPrevious()) {
if (exec.isTransactional()) {
return true;
}
}
}
}
}
return false;
}
Aggregations