コード例 #1
0
  public void resolveRangeTable(
      Session session,
      RangeVariable[] rangeVariables,
      int rangeCount,
      RangeVariable[] outerRanges) {

    Table table = rangeTable;
    SubQuery subQuery = table.getSubQuery();

    if (subQuery != null && !subQuery.isResolved()) {
      if (subQuery.dataExpression != null) {
        HsqlList unresolved =
            subQuery.dataExpression.resolveColumnReferences(
                session, RangeVariable.emptyArray, null);

        if (unresolved != null) {
          unresolved =
              subQuery.dataExpression.resolveColumnReferences(
                  session, rangeVariables, rangeCount, null, true);
        }

        if (unresolved != null) {
          unresolved = subQuery.dataExpression.resolveColumnReferences(session, outerRanges, null);
        }

        if (unresolved != null) {
          throw Error.error(ErrorCode.X_42501, ((Expression) unresolved.get(0)).getSQL());
        }

        subQuery.dataExpression.resolveTypes(session, null);
        setRangeTableVariables();
      }

      if (subQuery.queryExpression != null) {
        subQuery.queryExpression.resolveReferences(session, outerRanges);

        HsqlList list = subQuery.queryExpression.getUnresolvedExpressions();

        // todo resolve against i ranges
        HsqlList unresolved =
            Expression.resolveColumnSet(session, rangeVariables, rangeCount, list, null);

        if (unresolved != null) {
          throw Error.error(ErrorCode.X_42501, ((Expression) unresolved.get(0)).getSQL());
        }

        subQuery.queryExpression.resolveTypes(session);
        subQuery.prepareTable(session);
        subQuery.setCorrelated();
        setRangeTableVariables();
      }
    }
  }
コード例 #2
0
  static void checkColumnsResolved(HsqlList set) {

    if (set != null && !set.isEmpty()) {
      StringBuffer sb = new StringBuffer();
      Expression e = (Expression) set.get(0);

      if (e instanceof ExpressionColumn) {
        ExpressionColumn c = (ExpressionColumn) e;

        if (c.schema != null) {
          sb.append(c.schema + '.');
        }

        if (c.tableName != null) {
          sb.append(c.tableName + '.');
        }

        throw Error.error(ErrorCode.X_42501, sb.toString() + c.getColumnName());
      } else {
        OrderedHashSet newSet = new OrderedHashSet();

        e.collectAllExpressions(
            newSet, Expression.columnExpressionSet, Expression.emptyExpressionSet);

        // throw with column name
        checkColumnsResolved(newSet);

        // throw anyway if not found
        throw Error.error(ErrorCode.X_42501);
      }
    }
  }