public void readLobResults(
      SessionInterface session, DataInputStream inputStream, RowInputBinary in)
      throws IOException, HsqlException {

    Result currentResult = this;
    boolean hasLob = false;

    setSession(session);

    while (true) {
      int addedResultMode = inputStream.readByte();

      if (addedResultMode == ResultConstants.LARGE_OBJECT_OP) {
        ResultLob resultLob = ResultLob.newLob(inputStream, false);

        if (session instanceof Session) {
          ((Session) session).allocateResultLob(resultLob, inputStream);
        } else {
          currentResult.addLobResult(resultLob);
        }

        hasLob = true;

        continue;
      } else if (addedResultMode == ResultConstants.NONE) {
        break;
      } else {
        throw Error.runtimeError(ErrorCode.U_S0500, "Result");
      }
    }

    if (hasLob) {
      ((Session) session).registerResultLobs(currentResult);
    }
  }
  public static Result newResult(Session session, int mode, DataInput dataInput, RowInputBinary in)
      throws IOException, HsqlException {

    try {
      if (mode == ResultConstants.LARGE_OBJECT_OP) {
        return ResultLob.newLob(dataInput, false);
      }

      Result result = newResult(session, dataInput, in, mode);

      return result;
    } catch (IOException e) {
      throw Error.error(ErrorCode.X_08000);
    }
  }