sb.append("\n");
  public static ArrayValue pg_copy_to(Env env,                                      @NotNull Postgres conn,                                      String tableName,                                      @Optional("") String delimiter,                                      @Optional("") String nullAs)  {    try {      // XXX: This should be replaced when @Optional("\t") is fixed.      if (delimiter.equals("")) {        delimiter = "\t";      }      // XXX: This should be replaced when @Optional("\n") is fixed.      if (nullAs.equals("")) {        nullAs = "\n";      }      PostgresResult result = pg_query(env, conn, "SELECT * FROM " + tableName);      ArrayValueImpl newArray = new ArrayValueImpl();      Object value;      int curr = 0;      while ((value = result.fetchArray(env, PGSQL_NUM)) != null) {        ArrayValueImpl arr = (ArrayValueImpl) value;        int count = arr.size();        StringBuilderValue sb = new StringBuilderValue();        LongValue currValue = LongValue.create(curr);        for (int i=0; i<count; i++) {          if (sb.length() > 0)            sb.append(delimiter);          Value v = newArray.get(currValue);          Value fieldValue = arr.get(LongValue.create(i));          if (fieldValue instanceof NullValue) {            sb.append(nullAs);          } else {            sb.append(fieldValue.toString());          }        }        newArray.put(currValue, sb);        curr++;      }      return newArray;    } catch (Exception ex) {      log.log(Level.FINE, ex.toString(), ex);      return null;    }  }