docs: static Integer convertToInt(Object a, int type) {
  
          int value;
  
          if (a instanceof Integer) {
              if (type == Types.SQL_INTEGER) {
                  return (Integer) a;
              }
  
              value = ((Integer) a).intValue();
          } else if (a instanceof Long) {
              long temp = ((Long) a).longValue();
  
              if (Integer.MAX_VALUE < temp || temp < Integer.MIN_VALUE) {
                  throw Error.error(ErrorCode.X_22003);
              }
  
              value = (int) temp;
          } else if (a instanceof BigDecimal) {
              BigDecimal bd = ((BigDecimal) a);
  
              if (bd.compareTo(MAX_INT) > 0 || bd.compareTo(MIN_INT) < 0) {
                  throw Error.error(ErrorCode.X_22003);
              }
  
              value = bd.intValue();
          } else if (a instanceof Double || a instanceof Float) {
              double d = ((Number) a).doubleValue();
  
              if (Double.isInfinite(d) || Double.isNaN(d)
                      || d >= (double) Integer.MAX_VALUE + 1
                      || d <= (double) Integer.MIN_VALUE - 1) {
                  throw Error.error(ErrorCode.X_22003);
              }
  
              value = (int) d;
          } else {
              throw Error.error(ErrorCode.X_42561);
          }
  
          if (type == Types.TINYINT) {
              if (Byte.MAX_VALUE < value || value < Byte.MIN_VALUE) {
                  throw Error.error(ErrorCode.X_22003);
              }
          } else if (type == Types.SQL_SMALLINT) {
              if (Short.MAX_VALUE < value || value < Short.MIN_VALUE) {
                  throw Error.error(ErrorCode.X_22003);
              }
          }
  
          return ValuePool.getInt(value);
      }