code: public static Long executeAutoCount(Dialect dialect, Executor executor, MappedStatement countMs,
                                          Object parameter, BoundSql boundSql,
                                          RowBounds rowBounds, ResultHandler resultHandler) throws SQLException {
          Map<String, Object> additionalParameters = getAdditionalParameter(boundSql);
          //创建 count 查询的缓存 key
          CacheKey countKey = executor.createCacheKey(countMs, parameter, RowBounds.DEFAULT, boundSql);
          //调用方言获取 count sql
          String countSql = dialect.getCountSql(countMs, boundSql, parameter, rowBounds, countKey);
          //countKey.update(countSql);
          BoundSql countBoundSql = new BoundSql(countMs.getConfiguration(), countSql, boundSql.getParameterMappings(), parameter);
          //当使用动态 SQL 时，可能会产生临时的参数，这些参数需要手动设置到新的 BoundSql 中
          for (String key : additionalParameters.keySet()) {
              countBoundSql.setAdditionalParameter(key, additionalParameters.get(key));
          }
          //执行 count 查询
          Object countResultList = executor.query(countMs, parameter, RowBounds.DEFAULT, resultHandler, countKey, countBoundSql);
          Long count = (Long) ((List) countResultList).get(0);
          return count;
      }
docs: 执行自动生成的 count 查询
  
  @param dialect
  @param executor
  @param countMs
  @param parameter
  @param boundSql
  @param rowBounds
  @param resultHandler
  @return
  @throws SQLException