コード例 #1
0
    public void run() {

      try {
        for (int i = sessionList.size() - 1; i >= 0; i--) {
          Session session = (Session) sessionList.get(i);

          if (session.isClosed()) {
            synchronized (this) {
              sessionList.remove(i);
            }

            continue;
          }

          boolean result = session.timeoutManager.checkTimeout();
          /*
                              if (result) {
                                  synchronized (this) {
                                      sessionList.remove(i);
                                  }
                              }
          */
        }
      } catch (Throwable e) {

        // ignore exceptions
        // may be InterruptedException or IOException
      }
    }
コード例 #2
0
  private Result getExplainResult(Session session) {

    Result result = Result.newSingleColumnStringResult("OPERATION", describe(session));
    OrderedHashSet set = getReferences();

    result.navigator.add(new Object[] {"Object References"});

    for (int i = 0; i < set.size(); i++) {
      HsqlName name = (HsqlName) set.get(i);

      result.navigator.add(new Object[] {name.getSchemaQualifiedStatementName()});
    }

    result.navigator.add(new Object[] {"Read Locks"});

    for (int i = 0; i < readTableNames.length; i++) {
      HsqlName name = readTableNames[i];

      result.navigator.add(new Object[] {name.getSchemaQualifiedStatementName()});
    }

    result.navigator.add(new Object[] {"WriteLocks"});

    for (int i = 0; i < writeTableNames.length; i++) {
      HsqlName name = writeTableNames[i];

      result.navigator.add(new Object[] {name.getSchemaQualifiedStatementName()});
    }

    return result;
  }
コード例 #3
0
  SubQuery[] getSubqueries(Session session) {

    OrderedHashSet subQueries = null;

    for (int i = 0; i < targetRangeVariables.length; i++) {
      if (targetRangeVariables[i] == null) {
        continue;
      }

      OrderedHashSet set = targetRangeVariables[i].getSubqueries();

      subQueries = OrderedHashSet.addAll(subQueries, set);
    }

    for (int i = 0; i < updateExpressions.length; i++) {
      subQueries = updateExpressions[i].collectAllSubqueries(subQueries);
    }

    if (insertExpression != null) {
      subQueries = insertExpression.collectAllSubqueries(subQueries);
    }

    if (condition != null) {
      subQueries = condition.collectAllSubqueries(subQueries);
    }

    if (queryExpression != null) {
      OrderedHashSet set = queryExpression.getSubqueries();

      subQueries = OrderedHashSet.addAll(subQueries, set);
    }

    if (subQueries == null || subQueries.size() == 0) {
      return SubQuery.emptySubqueryArray;
    }

    SubQuery[] subQueryArray = new SubQuery[subQueries.size()];

    subQueries.toArray(subQueryArray);
    ArraySort.sort(subQueryArray, 0, subQueryArray.length, subQueryArray[0]);

    for (int i = 0; i < subQueryArray.length; i++) {
      subQueryArray[i].prepareTable(session);
    }

    return subQueryArray;
  }
コード例 #4
0
  void setDatabseObjects(Session session, CompileContext compileContext) {

    parameters = compileContext.getParameters();

    setParameters();
    setParameterMetaData();

    subqueries = getSubqueries(session);
    rangeIteratorCount = compileContext.getRangeVarCount();
    rangeVariables = compileContext.getRangeVariables();
    sequences = compileContext.getSequences();
    routines = compileContext.getRoutines();

    OrderedHashSet set = new OrderedHashSet();

    collectTableNamesForWrite(set);

    if (set.size() > 0) {
      writeTableNames = new HsqlName[set.size()];

      set.toArray(writeTableNames);
      set.clear();
    }

    collectTableNamesForRead(set);
    set.removeAll(writeTableNames);

    if (set.size() > 0) {
      readTableNames = new HsqlName[set.size()];

      set.toArray(readTableNames);
    }

    references = compileContext.getSchemaObjectNames();

    if (targetTable != null) {
      references.add(targetTable.getName());
    }
  }
コード例 #5
0
ファイル: Constraint.java プロジェクト: davoodinator/StarMade
 public OrderedHashSet getReferences() {
   switch (this.constType) {
     case 3:
       OrderedHashSet localOrderedHashSet1 = new OrderedHashSet();
       this.check.collectObjectNames(localOrderedHashSet1);
       for (int i = localOrderedHashSet1.size() - 1; i >= 0; i--) {
         HsqlNameManager.HsqlName localHsqlName =
             (HsqlNameManager.HsqlName) localOrderedHashSet1.get(i);
         if ((localHsqlName.type == 9) || (localHsqlName.type == 3))
           localOrderedHashSet1.remove(i);
       }
       return localOrderedHashSet1;
     case 0:
       OrderedHashSet localOrderedHashSet2 = new OrderedHashSet();
       localOrderedHashSet2.add(this.core.uniqueName);
       return localOrderedHashSet2;
   }
   return new OrderedHashSet();
 }
コード例 #6
0
  void moveConditionsToInner(Session session, RangeVariable[] ranges) {

    Expression[] colExpr;
    int exclude;
    HsqlArrayList conditionsList;
    Expression condition = null;

    if (whereConditions.length > 1) {
      return;
    }

    if (joinConditions.length > 1) {
      return;
    }

    for (int i = 0; i < ranges.length; i++) {
      if (ranges[i].isLeftJoin || ranges[i].isRightJoin) {
        return;
      }
    }

    exclude = ArrayUtil.find(ranges, this);
    conditionsList = new HsqlArrayList();

    addConditionsToList(conditionsList, joinConditions[0].indexCond);

    if (joinConditions[0].indexCond != null
        && joinConditions[0].indexCond[0] != joinConditions[0].indexEndCond[0]) {
      addConditionsToList(conditionsList, joinConditions[0].indexEndCond);
    }

    addConditionsToList(conditionsList, whereConditions[0].indexCond);
    addConditionsToList(conditionsList, whereConditions[0].indexEndCond);
    RangeVariableResolver.decomposeAndConditions(
        session, joinConditions[0].nonIndexCondition, conditionsList);
    RangeVariableResolver.decomposeAndConditions(
        session, whereConditions[0].nonIndexCondition, conditionsList);

    for (int i = conditionsList.size() - 1; i >= 0; i--) {
      Expression e = (Expression) conditionsList.get(i);

      if (e == null || e.isTrue() || e.hasReference(ranges, exclude)) {
        conditionsList.remove(i);

        continue;
      }
    }

    if (conditionsList.size() == 0) {
      if (rangeTable.isView()) {
        ((TableDerived) rangeTable).resetToView();
      }

      return;
    }

    QueryExpression queryExpression = rangeTable.getQueryExpression();

    colExpr = ((QuerySpecification) queryExpression).exprColumns;

    for (int i = 0; i < conditionsList.size(); i++) {
      Expression e = (Expression) conditionsList.get(i);
      OrderedHashSet set = e.collectRangeVariables(null);

      e = e.duplicate();
      e = e.replaceColumnReferences(this, colExpr);

      if (e.collectAllSubqueries(null) != null) {
        return;
      }

      if (set != null) {
        for (int j = 0; j < set.size(); j++) {
          RangeVariable range = (RangeVariable) set.get(j);

          if (this != range && range.rangeType == RangeVariable.TABLE_RANGE) {
            queryExpression.setCorrelated();
          }
        }
      }

      condition = ExpressionLogical.andExpressions(condition, e);
    }

    queryExpression.addExtraConditions(condition);
  }