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;
  }
 /**
  * Changes index name. Used by 'alter index rename to'. Argument isquoted is true if the name was
  * quoted in the DDL.
  */
 void setName(String name, boolean isquoted) throws HsqlException {
   indexName.rename(name, isquoted);
 }
Exemple #3
0
  public Routine getSpecificRoutine(Type[] types) {

    int matchIndex = -1;

    outerLoop:
    for (int i = 0; i < this.routines.length; i++) {
      int matchCount = 0;

      if (routines[i].isAggregate()) {
        if (types.length == 1) {
          if (types[0] == null) {
            return routines[i];
          }

          int typeDifference = types[0].precedenceDegree(routines[i].parameterTypes[0]);

          if (typeDifference < -NumberType.DOUBLE_WIDTH) {
            if (matchIndex == -1) {
              continue;
            }

            int oldDiff = types[0].precedenceDegree(routines[matchIndex].parameterTypes[0]);
            int newDiff = types[0].precedenceDegree(routines[i].parameterTypes[0]);

            if (oldDiff == newDiff) {
              continue outerLoop;
            }

            if (newDiff < oldDiff) {
              matchIndex = i;
            }

            continue outerLoop;
          } else if (typeDifference == 0) {
            return routines[i];
          } else {
            matchIndex = i;

            continue outerLoop;
          }
        }

        // treat routine as non-aggregate
      }

      if (routines[i].parameterTypes.length != types.length) {
        continue;
      }

      if (types.length == 0) {
        return this.routines[i];
      }

      for (int j = 0; j < types.length; j++) {
        int typeDifference;

        // parameters
        if (types[j] == null) {
          continue;
        }

        typeDifference = types[j].precedenceDegree(routines[i].parameterTypes[j]);

        if (typeDifference < -NumberType.DOUBLE_WIDTH) {

          // accept numeric type narrowing
          continue outerLoop;
        } else if (typeDifference == 0) {
          if (matchCount == j) {
            matchCount = j + 1;
          }
        }
      }

      if (matchCount == types.length) {
        return routines[i];
      }

      if (matchIndex == -1) {
        matchIndex = i;

        continue;
      }

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

        int oldDiff = types[j].precedenceDegree(routines[matchIndex].parameterTypes[j]);
        int newDiff = types[j].precedenceDegree(routines[i].parameterTypes[j]);

        if (oldDiff == newDiff) {
          continue;
        }

        if (newDiff < oldDiff) {
          matchIndex = i;
        }

        continue outerLoop;
      }
    }

    if (matchIndex < 0) {
      StringBuffer sb = new StringBuffer();

      sb.append(name.getSchemaQualifiedStatementName());
      sb.append(Tokens.T_OPENBRACKET);

      for (int i = 0; i < types.length; i++) {
        if (i != 0) {
          sb.append(Tokens.T_COMMA);
        }

        sb.append(types[i].getNameString());
      }

      sb.append(Tokens.T_CLOSEBRACKET);

      throw Error.error(ErrorCode.X_42609, sb.toString());
    }

    return routines[matchIndex];
  }