public Result execute(Session session) { Result result; if (targetTable != null && session.isReadOnly() && !targetTable.isTemp()) { HsqlException e = Error.error(ErrorCode.X_25006); return Result.newErrorResult(e); } if (isExplain) { return getExplainResult(session); } try { if (subqueries.length > 0) { materializeSubQueries(session); } result = getResult(session); } catch (Throwable t) { result = Result.newErrorResult(t, null); result.getException().setStatementType(group, type); } session.sessionContext.clearStructures(this); return result; }
boolean setWaitedSessionsTPL(Session session, Statement cs) { session.tempSet.clear(); if (cs == null || session.abortTransaction) { return true; } HsqlName[] nameList = cs.getTableNamesForWrite(); for (int i = 0; i < nameList.length; i++) { HsqlName name = nameList[i]; if (name.schema == SqlInvariants.SYSTEM_SCHEMA_HSQLNAME) { continue; } Session holder = (Session) tableWriteLocks.get(name); if (holder != null && holder != session) { session.tempSet.add(holder); } Iterator it = tableReadLocks.get(name); while (it.hasNext()) { holder = (Session) it.next(); if (holder != session) { session.tempSet.add(holder); } } } nameList = cs.getTableNamesForRead(); if (session.isReadOnly()) { nameList = catalogNameList; } for (int i = 0; i < nameList.length; i++) { HsqlName name = nameList[i]; if (name.schema == SqlInvariants.SYSTEM_SCHEMA_HSQLNAME) { continue; } Session holder = (Session) tableWriteLocks.get(name); if (holder != null && holder != session) { session.tempSet.add(holder); } } for (int i = 0; i < session.waitingSessions.size(); i++) { Session current = (Session) session.waitingSessions.get(i); if (session.tempSet.contains(current)) { session.tempSet.clear(); return false; } } return true; }