@Override
  public void close() throws IoTDBConnectionException {
    if (!Objects.equals(session.getSqlDialect(), sessionPool.sqlDialect)) {
      try {
        session.executeNonQueryStatement("set sql_dialect=" + sessionPool.sqlDialect);
      } catch (StatementExecutionException e) {
        LOGGER.warn(
            "Failed to change back sql_dialect by executing: set sql_dialect={}",
            sessionPool.sqlDialect,
            e);
        session.close();
        session = null;
        return;
      }
    }

    if (closed.compareAndSet(false, true)) {
      if (!Objects.equals(session.getDatabase(), sessionPool.database)
          && sessionPool.database != null) {
        try {
          session.executeNonQueryStatement("use " + sessionPool.database);
        } catch (StatementExecutionException e) {
          LOGGER.warn(
              "Failed to change back database by executing: use {}", sessionPool.database, e);
          session.close();
          session = null;
          return;
        }
      }

      sessionPool.putBack(session);
      session = null;
    }
  }
NOTICE: TableSessionWrapper is specific to the table model.

<p>used for SessionPool.getSession need to do some other things like calling
cleanSessionAndMayThrowConnectionException in SessionPool while encountering connection exception
only need to putBack to SessionPool while closing.
iotdb-client/session/src/main/java/org/apache/iotdb/session/pool/TableSessionWrapper.java