Example #1
0
  public void addSpecificRoutine(Database database, Routine routine) {

    int signature = routine.getParameterSignature();
    Type[] types = routine.getParameterTypes();

    for (int i = 0; i < this.routines.length; i++) {
      if (routines[i].parameterTypes.length == types.length) {
        if (routineType == SchemaObject.PROCEDURE) {
          throw Error.error(ErrorCode.X_42605);
        }

        if (routines[i].isAggregate() != routine.isAggregate()) {
          throw Error.error(ErrorCode.X_42605);
        }

        boolean match = true;

        for (int j = 0; j < types.length; j++) {
          if (!routines[i].parameterTypes[j].equals(types[j])) {
            match = false;

            break;
          }
        }

        if (match) {
          throw Error.error(ErrorCode.X_42605);
        }
      }
    }

    if (routine.getSpecificName() == null) {
      HsqlName specificName = database.nameManager.newSpecificRoutineName(name);

      routine.setSpecificName(specificName);
    } else {
      routine.getSpecificName().parent = name;
      routine.getSpecificName().schema = name.schema;
    }

    routine.setName(name);

    routine.routineSchema = this;
    routines = (Routine[]) ArrayUtil.resizeArray(routines, routines.length + 1);
    routines[routines.length - 1] = routine;
  }