in backend/src/main/java/org/apache/iotdb/admin/service/impl/IotDBServiceImpl.java [2492:2547]
public List<SqlResultVO> queryAll(Connection connection, List<String> sqls, Long timestamp)
throws BaseException {
SessionPool sessionPool = getSessionPool(connection);
List<SqlResultVO> results;
String id_plus_timestamp;
try {
results = new ArrayList<>();
Integer id = connection.getId();
id_plus_timestamp = id + ":" + timestamp;
QUERY_STOP.put(id_plus_timestamp, true);
for (String sql : sqls) {
if (StringUtils.isBlank(sql)) {
continue;
}
String judge = sql.toLowerCase();
if (judge.startsWith("show")
|| judge.startsWith("count")
|| judge.startsWith("list")
|| judge.startsWith("select")) {
SqlResultVO sqlResultVO = executeQuery(sessionPool, sql, id_plus_timestamp);
results.add(sqlResultVO);
continue;
}
try {
if (QUERY_STOP.get(id_plus_timestamp)) {
long start = System.currentTimeMillis();
sessionPool.executeNonQueryStatement(sql);
long end = System.currentTimeMillis();
long time = end - start;
String queryTime = time + "ms";
SqlResultVO sqlResultVO = new SqlResultVO();
sqlResultVO.setQueryTime(queryTime);
sqlResultVO.setLine(0L);
results.add(sqlResultVO);
}
} catch (StatementExecutionException e) {
logger.error(e.getMessage());
throw new BaseException(
ErrorCode.SQL_EP,
ErrorCode.SQL_EP_MSG
+ ":["
+ sql
+ "]statement execution error, error message:["
+ e.getMessage()
+ "]");
} catch (IoTDBConnectionException e) {
logger.error(e.getMessage());
throw new BaseException(ErrorCode.GET_SESSION_FAIL, ErrorCode.GET_SESSION_FAIL_MSG);
}
}
} finally {
closeSessionPool(sessionPool);
}
QUERY_STOP.remove(id_plus_timestamp);
return results;
}