protected void readExistingData(Session session) throws IOException, HsqlException {

    for (; ; ) {
      String s = readTableInit();

      if (s == null) {
        break;
      }

      String schema = session.getSchemaName(currentSchema);
      Table t = db.schemaManager.getUserTable(session, s, schema);
      int j = 0;

      for (j = 0; ; j++) {
        if (readRow(t) == false) {
          break;
        }
      }

      int checkCount = readTableTerm();

      if (j != checkCount) {
        throw Trace.error(
            Trace.ERROR_IN_SCRIPT_FILE,
            Trace.ERROR_IN_BINARY_SCRIPT_1,
            new Object[] {s, new Integer(j), new Integer(checkCount)});
      }
    }
  }
  public HsqlList resolveColumnReferences(
      Session session,
      RangeVariable[] rangeVarArray,
      int rangeCount,
      HsqlList unresolvedSet,
      boolean acceptsSequences) {

    switch (opType) {
      case OpTypes.SEQUENCE:
        if (!acceptsSequences) {
          throw Error.error(ErrorCode.X_42598);
        }
        break;

      case OpTypes.ROWNUM:
      case OpTypes.MULTICOLUMN:
      case OpTypes.DYNAMIC_PARAM:
      case OpTypes.ASTERISK:
      case OpTypes.SIMPLE_COLUMN:
      case OpTypes.COALESCE:
      case OpTypes.DIAGNOSTICS_VARIABLE:
        break;

      case OpTypes.COLUMN:
      case OpTypes.PARAMETER:
      case OpTypes.VARIABLE:
        {
          boolean resolved = false;
          boolean tableQualified = tableName != null;

          if (rangeVariable != null) {
            return unresolvedSet;
          }

          for (int i = 0; i < rangeCount; i++) {
            RangeVariable rangeVar = rangeVarArray[i];

            if (rangeVar == null) {
              continue;
            }

            if (resolved) {
              if (session.database.sqlEnforceRefs) {
                if (resolvesDuplicateColumnReference(rangeVar)) {
                  String message = getColumnName();

                  if (alias != null) {
                    StringBuffer sb = new StringBuffer(message);

                    sb.append(' ').append(Tokens.T_AS).append(' ').append(alias.getStatementName());

                    message = sb.toString();
                  }

                  throw Error.error(ErrorCode.X_42580, message);
                }
              }
            } else {
              if (resolveColumnReference(rangeVar)) {
                if (tableQualified) {
                  return unresolvedSet;
                }

                resolved = true;

                continue;
              }
            }
          }

          if (resolved) {
            return unresolvedSet;
          }

          if (session.database.sqlSyntaxOra) {
            if (acceptsSequences && tableName != null) {
              if (Tokens.T_CURRVAL.equals(columnName)) {
                NumberSequence seq =
                    session.database.schemaManager.getSequence(
                        tableName, session.getSchemaName(schema), false);

                if (seq != null) {
                  opType = OpTypes.SEQUENCE_CURRENT;
                  dataType = seq.getDataType();
                  sequence = seq;
                  schema = null;
                  tableName = null;
                  columnName = null;
                  resolved = true;
                }
              } else if (Tokens.T_NEXTVAL.equals(columnName)) {
                NumberSequence seq =
                    session.database.schemaManager.getSequence(
                        tableName, session.getSchemaName(schema), false);

                if (seq != null) {
                  opType = OpTypes.SEQUENCE;
                  dataType = seq.getDataType();
                  sequence = seq;
                  schema = null;
                  tableName = null;
                  columnName = null;
                  resolved = true;
                }
              }
            }
          }

          if (resolved) {
            return unresolvedSet;
          }

          if (unresolvedSet == null) {
            unresolvedSet = new ArrayListIdentity();
          }

          unresolvedSet.add(this);
        }
    }

    return unresolvedSet;
  }