public OrderedHashSet getSubqueries() {

    OrderedHashSet set = null;

    if (joinCondition != null) {
      set = joinCondition.collectAllSubqueries(set);
    }

    if (rangeTable instanceof TableDerived) {
      QueryExpression queryExpression = ((TableDerived) rangeTable).getQueryExpression();

      if (queryExpression == null) {
        Expression dataExpression = ((TableDerived) rangeTable).getDataExpression();

        if (dataExpression != null) {
          if (set == null) {
            set = new OrderedHashSet();
          }

          OrderedHashSet.addAll(set, dataExpression.getSubqueries());
        }
      } else {
        OrderedHashSet temp = queryExpression.getSubqueries();

        set = OrderedHashSet.addAll(set, temp);
        set = OrderedHashSet.add(set, rangeTable);
      }
    }

    return set;
  }
  OrderedHashSet getSubqueries() {

    OrderedHashSet set = null;

    if (joinCondition != null) {
      set = joinCondition.collectAllSubqueries(set);
    }

    if (rangeTable instanceof TableDerived) {
      QueryExpression baseQueryExpression = ((TableDerived) rangeTable).getQueryExpression();

      if (((TableDerived) rangeTable).view != null) {
        if (set == null) {
          set = new OrderedHashSet();
        }

        set.addAll(((TableDerived) rangeTable).view.getSubqueries());
      } else if (baseQueryExpression == null) {
        set = OrderedHashSet.add(set, rangeTable.getSubQuery());
      } else {
        OrderedHashSet temp = baseQueryExpression.getSubqueries();

        set = OrderedHashSet.addAll(set, temp);
        set = OrderedHashSet.add(set, rangeTable.getSubQuery());
      }
    }

    return set;
  }
  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
  public OrderedHashSet getComponents() {

    OrderedHashSet set = new OrderedHashSet();

    set.addAll(routines);

    return set;
  }
Пример #5
0
  public OrderedHashSet getReferences() {

    OrderedHashSet set = new OrderedHashSet();

    for (int i = 0; i < routines.length; i++) {
      set.addAll(routines[i].getReferences());
    }

    return set;
  }
  public OrderedHashSet getUniqueColumnNameSet() {

    OrderedHashSet set = new OrderedHashSet();

    if (columnAliases != null) {
      set.addAll(columnAliases);

      return set;
    }

    for (int i = 0; i < rangeTable.columnList.size(); i++) {
      String name = rangeTable.getColumn(i).getName().name;
      boolean added = set.add(name);

      if (!added) {
        throw Error.error(ErrorCode.X_42578, name);
      }
    }

    return set;
  }