commit
6a2b38faca
|
@ -138,3 +138,24 @@ tags
|
||||||
*CMakeCache*
|
*CMakeCache*
|
||||||
*CMakeFiles*
|
*CMakeFiles*
|
||||||
.history/
|
.history/
|
||||||
|
*.txt
|
||||||
|
*.tcl
|
||||||
|
*.pc
|
||||||
|
contrib/geos
|
||||||
|
contrib/libuv
|
||||||
|
contrib/pcre2
|
||||||
|
contrib/zlib
|
||||||
|
deps_tmp_CMakeLists.txt.in
|
||||||
|
*.a
|
||||||
|
*.ctest
|
||||||
|
pcre2-config
|
||||||
|
pcre2_test.sh
|
||||||
|
pcre2_grep_test.sh
|
||||||
|
pcre2_chartables.c
|
||||||
|
geos-config
|
||||||
|
config.h
|
||||||
|
pcre2.h
|
||||||
|
zconf.h
|
||||||
|
version.h
|
||||||
|
geos_c.h
|
||||||
|
|
||||||
|
|
|
@ -160,12 +160,58 @@ ELSE ()
|
||||||
CHECK_C_COMPILER_FLAG("-msse4.2" COMPILER_SUPPORT_SSE42)
|
CHECK_C_COMPILER_FLAG("-msse4.2" COMPILER_SUPPORT_SSE42)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
CHECK_C_COMPILER_FLAG("-mfma" COMPILER_SUPPORT_FMA)
|
IF (TD_ARM_64 OR TD_ARM_32)
|
||||||
CHECK_C_COMPILER_FLAG("-mavx" COMPILER_SUPPORT_AVX)
|
SET(COMPILER_SUPPORT_FMA false)
|
||||||
CHECK_C_COMPILER_FLAG("-mavx2" COMPILER_SUPPORT_AVX2)
|
SET(COMPILER_SUPPORT_AVX false)
|
||||||
CHECK_C_COMPILER_FLAG("-mavx512f" COMPILER_SUPPORT_AVX512F)
|
SET(COMPILER_SUPPORT_AVX2 false)
|
||||||
CHECK_C_COMPILER_FLAG("-mavx512vbmi" COMPILER_SUPPORT_AVX512BMI)
|
SET(COMPILER_SUPPORT_AVX512F false)
|
||||||
CHECK_C_COMPILER_FLAG("-mavx512vl" COMPILER_SUPPORT_AVX512VL)
|
SET(COMPILER_SUPPORT_AVX512BMI false)
|
||||||
|
SET(COMPILER_SUPPORT_AVX512VL false)
|
||||||
|
ELSE()
|
||||||
|
CHECK_C_COMPILER_FLAG("-mfma" COMPILER_SUPPORT_FMA)
|
||||||
|
CHECK_C_COMPILER_FLAG("-mavx512f" COMPILER_SUPPORT_AVX512F)
|
||||||
|
CHECK_C_COMPILER_FLAG("-mavx512vbmi" COMPILER_SUPPORT_AVX512BMI)
|
||||||
|
CHECK_C_COMPILER_FLAG("-mavx512vl" COMPILER_SUPPORT_AVX512VL)
|
||||||
|
|
||||||
|
INCLUDE(CheckCSourceRuns)
|
||||||
|
SET(CMAKE_REQUIRED_FLAGS "-mavx")
|
||||||
|
check_c_source_runs("
|
||||||
|
#include <immintrin.h>
|
||||||
|
int main() {
|
||||||
|
__m256d a, b, c;
|
||||||
|
double buf[4] = {0};
|
||||||
|
a = _mm256_loadu_pd(buf);
|
||||||
|
b = _mm256_loadu_pd(buf);
|
||||||
|
c = _mm256_add_pd(a, b);
|
||||||
|
_mm256_storeu_pd(buf, c);
|
||||||
|
for (int i = 0; i < sizeof(buf) / sizeof(buf[0]); ++i) {
|
||||||
|
if (buf[i] != 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" COMPILER_SUPPORT_AVX)
|
||||||
|
|
||||||
|
SET(CMAKE_REQUIRED_FLAGS "-mavx2")
|
||||||
|
check_c_source_runs("
|
||||||
|
#include <immintrin.h>
|
||||||
|
int main() {
|
||||||
|
__m256i a, b, c;
|
||||||
|
int buf[8] = {0};
|
||||||
|
a = _mm256_loadu_si256((__m256i *)buf);
|
||||||
|
b = _mm256_loadu_si256((__m256i *)buf);
|
||||||
|
c = _mm256_and_si256(a, b);
|
||||||
|
_mm256_storeu_si256((__m256i *)buf, c);
|
||||||
|
for (int i = 0; i < sizeof(buf) / sizeof(buf[0]); ++i) {
|
||||||
|
if (buf[i] != 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" COMPILER_SUPPORT_AVX2)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF (COMPILER_SUPPORT_SSE42)
|
IF (COMPILER_SUPPORT_SSE42)
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
|
||||||
|
@ -177,15 +223,17 @@ ELSE ()
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
IF (COMPILER_SUPPORT_AVX)
|
MESSAGE(STATUS "FMA instructions is ACTIVATED")
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
|
ENDIF()
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
IF (COMPILER_SUPPORT_AVX)
|
||||||
ENDIF()
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
|
||||||
IF (COMPILER_SUPPORT_AVX2)
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
|
MESSAGE(STATUS "AVX instructions is ACTIVATED")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
|
ENDIF()
|
||||||
ENDIF()
|
IF (COMPILER_SUPPORT_AVX2)
|
||||||
MESSAGE(STATUS "SIMD instructions (FMA/AVX/AVX2) is ACTIVATED")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
|
||||||
|
MESSAGE(STATUS "AVX2 instructions is ACTIVATED")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF ("${SIMD_AVX512_SUPPORT}" MATCHES "true")
|
IF ("${SIMD_AVX512_SUPPORT}" MATCHES "true")
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# stub
|
# stub
|
||||||
ExternalProject_Add(stub
|
ExternalProject_Add(stub
|
||||||
GIT_REPOSITORY https://github.com/coolxv/cpp-stub.git
|
GIT_REPOSITORY https://github.com/coolxv/cpp-stub.git
|
||||||
GIT_TAG 5e903b8e
|
GIT_TAG 3137465194014d66a8402941e80d2bccc6346f51
|
||||||
GIT_SUBMODULES "src"
|
GIT_SUBMODULES "src"
|
||||||
SOURCE_DIR "${TD_CONTRIB_DIR}/cpp-stub"
|
SOURCE_DIR "${TD_CONTRIB_DIR}/cpp-stub"
|
||||||
BINARY_DIR "${TD_CONTRIB_DIR}/cpp-stub/src"
|
BINARY_DIR "${TD_CONTRIB_DIR}/cpp-stub/src"
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
PROJECT(TDengine)
|
||||||
|
|
||||||
|
IF (TD_LINUX)
|
||||||
|
INCLUDE_DIRECTORIES(. ${TD_SOURCE_DIR}/src/inc ${TD_SOURCE_DIR}/src/client/inc ${TD_SOURCE_DIR}/inc)
|
||||||
|
AUX_SOURCE_DIRECTORY(. SRC)
|
||||||
|
|
||||||
|
add_executable(docs_connect_example "")
|
||||||
|
add_executable(docs_create_db_demo "")
|
||||||
|
add_executable(docs_insert_data_demo "")
|
||||||
|
add_executable(docs_query_data_demo "")
|
||||||
|
add_executable(docs_with_reqid_demo "")
|
||||||
|
add_executable(docs_sml_insert_demo "")
|
||||||
|
add_executable(docs_stmt_insert_demo "")
|
||||||
|
add_executable(docs_tmq_demo "")
|
||||||
|
|
||||||
|
target_sources(docs_connect_example
|
||||||
|
PRIVATE
|
||||||
|
"connect_example.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(docs_create_db_demo
|
||||||
|
PRIVATE
|
||||||
|
"create_db_demo.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(docs_insert_data_demo
|
||||||
|
PRIVATE
|
||||||
|
"insert_data_demo.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(docs_query_data_demo
|
||||||
|
PRIVATE
|
||||||
|
"query_data_demo.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(docs_with_reqid_demo
|
||||||
|
PRIVATE
|
||||||
|
"with_reqid_demo.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(docs_sml_insert_demo
|
||||||
|
PRIVATE
|
||||||
|
"sml_insert_demo.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(docs_stmt_insert_demo
|
||||||
|
PRIVATE
|
||||||
|
"stmt_insert_demo.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(docs_tmq_demo
|
||||||
|
PRIVATE
|
||||||
|
"tmq_demo.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(docs_connect_example
|
||||||
|
taos
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(docs_create_db_demo
|
||||||
|
taos
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(docs_insert_data_demo
|
||||||
|
taos
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(docs_query_data_demo
|
||||||
|
taos
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(docs_with_reqid_demo
|
||||||
|
taos
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(docs_sml_insert_demo
|
||||||
|
taos
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(docs_stmt_insert_demo
|
||||||
|
taos
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(docs_tmq_demo
|
||||||
|
taos
|
||||||
|
pthread
|
||||||
|
)
|
||||||
|
|
||||||
|
SET_TARGET_PROPERTIES(docs_connect_example PROPERTIES OUTPUT_NAME docs_connect_example)
|
||||||
|
SET_TARGET_PROPERTIES(docs_create_db_demo PROPERTIES OUTPUT_NAME docs_create_db_demo)
|
||||||
|
SET_TARGET_PROPERTIES(docs_insert_data_demo PROPERTIES OUTPUT_NAME docs_insert_data_demo)
|
||||||
|
SET_TARGET_PROPERTIES(docs_query_data_demo PROPERTIES OUTPUT_NAME docs_query_data_demo)
|
||||||
|
SET_TARGET_PROPERTIES(docs_with_reqid_demo PROPERTIES OUTPUT_NAME docs_with_reqid_demo)
|
||||||
|
SET_TARGET_PROPERTIES(docs_sml_insert_demo PROPERTIES OUTPUT_NAME docs_sml_insert_demo)
|
||||||
|
SET_TARGET_PROPERTIES(docs_stmt_insert_demo PROPERTIES OUTPUT_NAME docs_stmt_insert_demo)
|
||||||
|
SET_TARGET_PROPERTIES(docs_tmq_demo PROPERTIES OUTPUT_NAME docs_tmq_demo)
|
||||||
|
ENDIF ()
|
||||||
|
IF (TD_DARWIN)
|
||||||
|
INCLUDE_DIRECTORIES(. ${TD_SOURCE_DIR}/src/inc ${TD_SOURCE_DIR}/src/client/inc ${TD_SOURCE_DIR}/inc)
|
||||||
|
AUX_SOURCE_DIRECTORY(. SRC)
|
||||||
|
ENDIF ()
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Makefile for building TDengine examples on TD Linux platform
|
||||||
|
|
||||||
|
INCLUDE_DIRS =
|
||||||
|
|
||||||
|
TARGETS = connect_example \
|
||||||
|
create_db_demo \
|
||||||
|
insert_data_demo \
|
||||||
|
query_data_demo \
|
||||||
|
with_reqid_demo \
|
||||||
|
sml_insert_demo \
|
||||||
|
stmt_insert_demo \
|
||||||
|
tmq_demo
|
||||||
|
|
||||||
|
SOURCES = connect_example.c \
|
||||||
|
create_db_demo.c \
|
||||||
|
insert_data_demo.c \
|
||||||
|
query_data_demo.c \
|
||||||
|
with_reqid_demo.c \
|
||||||
|
sml_insert_demo.c \
|
||||||
|
stmt_insert_demo.c \
|
||||||
|
tmq_demo.c
|
||||||
|
|
||||||
|
LIBS = -ltaos -lpthread
|
||||||
|
|
||||||
|
|
||||||
|
CFLAGS = -g
|
||||||
|
|
||||||
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
$(TARGETS):
|
||||||
|
$(CC) $(CFLAGS) -o $@ $(wildcard $(@F).c) $(LIBS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(TARGETS)
|
|
@ -13,7 +13,7 @@ MongoDB 是一个介于关系型数据库与非关系型数据库之间的产品
|
||||||
|
|
||||||
### 1. 新增数据源
|
### 1. 新增数据源
|
||||||
|
|
||||||
在数据写入页面中点击左上角的 **+新增数据源** 按钮进入新增数据源页面,如下图所示:
|
在数据写入页面中点击右上角的 **+新增数据源** 按钮进入新增数据源页面,如下图所示:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ d4,2017-07-14T10:40:00.006+08:00,-2.740636,10,-0.893545,7,California.LosAngles
|
||||||
|
|
||||||
- `plugins_home`:外部数据源连接器所在目录。
|
- `plugins_home`:外部数据源连接器所在目录。
|
||||||
- `data_dir`:数据文件存放目录。
|
- `data_dir`:数据文件存放目录。
|
||||||
- `instanceId`:当前 explorer 服务的实例 ID,如果同一台机器上启动了多个 explorer 实例,必须保证各个实例的实例 ID 互不相同。
|
- `instanceId`:当前 taosX 服务的实例 ID,如果同一台机器上启动了多个 taosX 实例,必须保证各个实例的实例 ID 互不相同。
|
||||||
- `logs_home`:日志文件存放目录,`taosX` 日志文件的前缀为 `taosx.log`,外部数据源有自己的日志文件名前缀。已弃用,请使用 `log.path` 代替。
|
- `logs_home`:日志文件存放目录,`taosX` 日志文件的前缀为 `taosx.log`,外部数据源有自己的日志文件名前缀。已弃用,请使用 `log.path` 代替。
|
||||||
- `log_level`:日志等级,可选级别包括 `error`、`warn`、`info`、`debug`、`trace`,默认值为 `info`。已弃用,请使用 `log.level` 代替。
|
- `log_level`:日志等级,可选级别包括 `error`、`warn`、`info`、`debug`、`trace`,默认值为 `info`。已弃用,请使用 `log.level` 代替。
|
||||||
- `log_keep_days`:日志的最大存储天数,`taosX` 日志将按天划分为不同的文件。已弃用,请使用 `log.keepDays` 代替。
|
- `log_keep_days`:日志的最大存储天数,`taosX` 日志将按天划分为不同的文件。已弃用,请使用 `log.keepDays` 代替。
|
||||||
|
|
|
@ -11,6 +11,7 @@ sidebar_label: taosX-Agent
|
||||||
|
|
||||||
- `endpoint`: 必填,`taosX` 的 GRPC 服务地址。
|
- `endpoint`: 必填,`taosX` 的 GRPC 服务地址。
|
||||||
- `token`: 必填,在 `Explorer` 上创建 `Agent` 时,产生的 Token。
|
- `token`: 必填,在 `Explorer` 上创建 `Agent` 时,产生的 Token。
|
||||||
|
- `instanceId`:当前 taosx-agent 服务的实例 ID,如果同一台机器上启动了多个 taosx-agent 实例,必须保证各个实例的实例 ID 互不相同。
|
||||||
- `compression`: 非必填,可配置为 `ture` 或 `false`, 默认为 `false`。配置为`true`, 则开启 `Agent` 和 `taosX` 通信数据压缩。
|
- `compression`: 非必填,可配置为 `ture` 或 `false`, 默认为 `false`。配置为`true`, 则开启 `Agent` 和 `taosX` 通信数据压缩。
|
||||||
- `log_level`: 非必填,日志级别,默认为 `info`, 同 `taosX` 一样,支持 `error`,`warn`,`info`,`debug`,`trace` 五级。已弃用,请使用 `log.level` 代替。
|
- `log_level`: 非必填,日志级别,默认为 `info`, 同 `taosX` 一样,支持 `error`,`warn`,`info`,`debug`,`trace` 五级。已弃用,请使用 `log.level` 代替。
|
||||||
- `log_keep_days`:非必填,日志保存天数,默认为 `30` 天。已弃用,请使用 `log.keepDays` 代替。
|
- `log_keep_days`:非必填,日志保存天数,默认为 `30` 天。已弃用,请使用 `log.keepDays` 代替。
|
||||||
|
@ -37,7 +38,7 @@ sidebar_label: taosX-Agent
|
||||||
# server instance id
|
# server instance id
|
||||||
#
|
#
|
||||||
# The instanceId of each instance is unique on the host
|
# The instanceId of each instance is unique on the host
|
||||||
# instanceId = 64
|
# instanceId = 48
|
||||||
|
|
||||||
# enable communication data compression between Agent and taosX
|
# enable communication data compression between Agent and taosX
|
||||||
#
|
#
|
||||||
|
|
|
@ -132,7 +132,7 @@ cors = true
|
||||||
- `cluster`:TDengine 集群的 taosAdapter 地址。
|
- `cluster`:TDengine 集群的 taosAdapter 地址。
|
||||||
- `cluster_native`:TDengine 集群的原生连接地址,默认关闭。
|
- `cluster_native`:TDengine 集群的原生连接地址,默认关闭。
|
||||||
- `x_api`:taosX 的 gRPC 地址。
|
- `x_api`:taosX 的 gRPC 地址。
|
||||||
- `grpc`:taosX 代理向 taosX 建立连接的 gRPC 地址.
|
- `grpc`:taosX 代理向 taosX 建立连接的 gRPC 地址。
|
||||||
- `cors`:CORS 配置开关,默认为 `false`。当为 `true` 时,允许跨域访问。
|
- `cors`:CORS 配置开关,默认为 `false`。当为 `true` 时,允许跨域访问。
|
||||||
- `ssl.certificate`:SSL 证书(如果同时设置了 certificate 与 certificate_key 两个参数,则启用 HTTPS 服务,否则不启用)。
|
- `ssl.certificate`:SSL 证书(如果同时设置了 certificate 与 certificate_key 两个参数,则启用 HTTPS 服务,否则不启用)。
|
||||||
- `ssl.certificate_key`:SSL 证书密钥。
|
- `ssl.certificate_key`:SSL 证书密钥。
|
||||||
|
|
|
@ -99,7 +99,7 @@ PARTITION 子句中,为 tbname 定义了一个别名 tname, 在PARTITION 子
|
||||||
|
|
||||||
## 流式计算读取历史数据
|
## 流式计算读取历史数据
|
||||||
|
|
||||||
正常情况下,流式计算不会处理创建前已经写入源表中的数据,若要处理已经写入的数据,可以在创建流时设置 fill_history 1 选项,这样创建的流式计算会自动处理创建前、创建中、创建后写入的数据。例如:
|
正常情况下,流式计算不会处理创建前已经写入源表中的数据,若要处理已经写入的数据,可以在创建流时设置 fill_history 1 选项,这样创建的流式计算会自动处理创建前、创建中、创建后写入的数据。流计算处理历史数据的最大窗口数是2000万,超过限制会报错。例如:
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
create stream if not exists s1 fill_history 1 into st1 as select count(*) from t1 interval(10s)
|
create stream if not exists s1 fill_history 1 into st1 as select count(*) from t1 interval(10s)
|
||||||
|
|
|
@ -60,6 +60,8 @@ TDengine ODBC 支持两种连接 TDengine 数据库方式:Websocket 连接与
|
||||||
|
|
||||||
4.6【密码】仅供第5步测试连接使用,选填,数据库用户密码,如果不填,TDengine 默认 taosdata
|
4.6【密码】仅供第5步测试连接使用,选填,数据库用户密码,如果不填,TDengine 默认 taosdata
|
||||||
|
|
||||||
|
4.7【兼容软件】支持对工业软件 KingSCADA、Kepware 等的兼容性适配,通常情况下,选择默认值 General 即可
|
||||||
|
|
||||||
5. 点【测试连接】测试连接情况,如果成功,提示"成功连接到URL"
|
5. 点【测试连接】测试连接情况,如果成功,提示"成功连接到URL"
|
||||||
|
|
||||||
6. 点【确定】,即可保存配置并退出
|
6. 点【确定】,即可保存配置并退出
|
||||||
|
@ -90,12 +92,449 @@ TDengine ODBC 支持两种连接 TDengine 数据库方式:Websocket 连接与
|
||||||
|
|
||||||
4.6 【密码】仅供第5步测试连接使用,选填,数据库用户密码,如果不填,TDengine 默认 taosdata
|
4.6 【密码】仅供第5步测试连接使用,选填,数据库用户密码,如果不填,TDengine 默认 taosdata
|
||||||
|
|
||||||
|
4.7【兼容软件】支持对工业软件 KingSCADA、Kepware 等的兼容性适配,通常情况下,选择默认值 General 即可
|
||||||
|
|
||||||
5. 点【测试连接】测试连接情况,如果成功,提示"连接成功"
|
5. 点【测试连接】测试连接情况,如果成功,提示"连接成功"
|
||||||
|
|
||||||
6. 点【确定】,即可保存配置并退出
|
6. 点【确定】,即可保存配置并退出
|
||||||
|
|
||||||
7. 也可以在第2步选择已经配置好的数据源名通过【配置】按钮进入配置页面,修改已有配置
|
7. 也可以在第2步选择已经配置好的数据源名通过【配置】按钮进入配置页面,修改已有配置
|
||||||
|
|
||||||
|
|
||||||
|
## 支持的平台
|
||||||
|
|
||||||
|
原生连接方式支持的平台和 TDengine Windows X64版 客户端驱动支持的平台一致。
|
||||||
|
WebSocket 连接方式除此之外还支持 Windows X64系统上运行的 32 位应用程序上使用。
|
||||||
|
|
||||||
|
|
||||||
|
## 版本历史
|
||||||
|
|
||||||
|
| taos_odbc版本 | 主要变化 | TDengine 版本 |
|
||||||
|
| :----------- | :-------------------------------------------------------------------------------------------------- | :---------------- |
|
||||||
|
| v1.1.0 | 1. 支持视图功能;<br/>2. 支持 VARBINARY/GEOMETRY 数据类型; | 3.3.3.0及更高版本 |
|
||||||
|
| v1.0.2 | 支持 CP1252 字符编码; | 3.2.3.0及更高版本 |
|
||||||
|
| v1.0.1 | 1. 支持 DSN 设置 BI 模式,在 BI 模式下 TDengine 数据库不返回系统数据库和超级表子表信息;<br/>2. 重构字符集转换模块,提升读写性能;<br/>3. ODBC 数据源配置对话框中默认修改默认连接方式为“WebSocket”;<br/>4. ODBC 数据源配置对话框增加“测试连接”控件;<br/>5. ODBC 数据源配置支持中文/英文界面; | - |
|
||||||
|
| v1.0.0.0 | 发布初始版本,支持与Tdengine数据库交互以读写数据,具体请参考“API 参考”一节 | 3.2.2.0及更高版本 |
|
||||||
|
|
||||||
|
|
||||||
|
## 数据类型映射
|
||||||
|
|
||||||
|
下表说明了 ODBC 连接器如何将服务器数据类型映射到默认的 SQL 和 C 数据类型。
|
||||||
|
|
||||||
|
| TDengine Type | SQL Type | C Type |
|
||||||
|
|--------------------|-------------------|-------------------|
|
||||||
|
| TIMESTAMP | SQL_TYPE_TIMESTAMP| SQL_C_TIMESTAMP |
|
||||||
|
| INT | SQL_INTEGER | SQL_C_SLONG |
|
||||||
|
| INT UNSIGNED | SQL_INTEGER | SQL_C_ULONG |
|
||||||
|
| BIGINT | SQL_BIGINT | SQL_C_SBIGINT |
|
||||||
|
| BIGINT UNSIGNED | SQL_BIGINT | SQL_C_UBIGINT |
|
||||||
|
| FLOAT | SQL_REAL | SQL_C_FLOAT |
|
||||||
|
| DOUBLE | SQL_REAL | SQL_C_DOUBLE |
|
||||||
|
| BINARY | SQL_BINARY | SQL_C_BINARY |
|
||||||
|
| SMALLINT | SQL_SMALLINT | SQL_C_SSHORT |
|
||||||
|
| SMALLINT UNSIGNED | SQL_SMALLINT | SQL_C_USHORT |
|
||||||
|
| TINYINT | SQL_TINYINT | SQL_C_STINYINT |
|
||||||
|
| TINYINT UNSIGNED | SQL_TINYINT | SQL_C_UTINYINT |
|
||||||
|
| BOOL | SQL_BIT | SQL_C_BIT |
|
||||||
|
| NCHAR | SQL_VARCHAR | SQL_C_CHAR |
|
||||||
|
| JSON | SQL_VARCHAR | SQL_C_CHAR |
|
||||||
|
| VARCHAR | SQL_VARCHAR | SQL_C_CHAR |
|
||||||
|
| GEOMETRY | SQL_VARBINARY | SQL_C_BINARY |
|
||||||
|
| VARBINARY | SQL_VARBINARY | SQL_C_BINARY |
|
||||||
|
|
||||||
|
|
||||||
|
## API 参考
|
||||||
|
|
||||||
|
本节按功能分类汇总了 ODBC API,关于完整的 ODBC API 参考,请访问 http://msdn.microsoft.com/en-us/library/ms714177.aspx 的ODBC程序员参考页面。
|
||||||
|
|
||||||
|
### 数据源和驱动程序管理
|
||||||
|
|
||||||
|
- API: ConfigDSN
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 配置数据源
|
||||||
|
|
||||||
|
- API: ConfigDriver
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 用于执行与特定驱动程序相关的安装和配置任务
|
||||||
|
|
||||||
|
- API: ConfigTranslator
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 用于解析DSN的配置,在DSN配置和实际数据库驱动程序配置之间进行翻译或转换
|
||||||
|
|
||||||
|
|
||||||
|
### 连接到数据源
|
||||||
|
|
||||||
|
- API: SQLAllocHandle
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 分配环境、连接、语句或描述符句柄
|
||||||
|
|
||||||
|
- API: SQLConnect
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 通过数据源名称、用户 ID 和密码连接到特定驱动程序
|
||||||
|
|
||||||
|
- API: SQLDriverConnect
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 通过连接字符串连接到特定驱动程序,支持更多连接信息
|
||||||
|
|
||||||
|
- API: SQLBrowseConnect
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 用于发现和枚举连接到数据源所需的特性和属性值。每次调用 SQLBrowseConnect 都会返回属性和属性值的连续级别
|
||||||
|
|
||||||
|
- API: SQLAllocEnv
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.x 函数 SQLAllocEnv 已替换为 SQLAllocHandle
|
||||||
|
|
||||||
|
- API: SQLAllocConnect
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.x 函数 SQLAllocConnect 已替换为 SQLAllocHandle
|
||||||
|
|
||||||
|
|
||||||
|
### 获取有关驱动程序和数据源的信息
|
||||||
|
|
||||||
|
- API: SQLDataSources
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回可用数据源的列表,由驱动程序管理器处理
|
||||||
|
|
||||||
|
- API: SQLDrivers
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回由驱动程序管理器处理的已安装驱动程序及其属性的列表
|
||||||
|
|
||||||
|
- API: SQLGetInfo
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回有关数据库环境的详细信息,如数据库产品名称、驱动程序名、数据库的SQL语法特性、连接能力等等
|
||||||
|
|
||||||
|
- API: SQLGetFunctions
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 用于查询驱动程序支持的函数
|
||||||
|
|
||||||
|
- API: SQLGetTypeInfo
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回有关支持的数据类型的信息
|
||||||
|
|
||||||
|
|
||||||
|
### 设置和检索驱动程序属性
|
||||||
|
|
||||||
|
- API: SQLSetConnectAttr
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 设置连接属性,当设置SQL_ATTR_AUTOCOMMIT属性时,用于控制自动提交模式
|
||||||
|
|
||||||
|
- API: SQLGetConnectAttr
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回连接属性的值
|
||||||
|
|
||||||
|
- API: SQLSetConnectOption
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.0 函数 SQLSetConnectOption 已替换为 SQLSetConnectAttr
|
||||||
|
|
||||||
|
- API: SQLGetConnectOption
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.0 函数 SQLSetConnectOption 已替换为 SQLGetConnectAttr
|
||||||
|
|
||||||
|
- API: SQLSetEnvAttr
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 设置控制环境的属性
|
||||||
|
|
||||||
|
- API: SQLGetEnvAttr
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回环境属性的当前设置
|
||||||
|
|
||||||
|
- API: SQLSetStmtAttr
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 设置与语句相关的属性
|
||||||
|
|
||||||
|
- API: SQLGetStmtAttr
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回语句属性的当前设置
|
||||||
|
|
||||||
|
- API: SQLSetStmtOption
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.0 函数 SQLSetStmtOption 已替换为 SQLSetStmtAttr
|
||||||
|
|
||||||
|
- API: SQLGetStmtOption
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.0 函数 SQLSetStmtOption 已替换为 SQLGetStmtAttr
|
||||||
|
|
||||||
|
|
||||||
|
### 准备SQL请求
|
||||||
|
|
||||||
|
- API: SQLAllocStmt
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.x 函数 SQLAllocStmt 已替换为 SQLAllocHandle
|
||||||
|
|
||||||
|
- API: SQLPrepare
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 用于预处理SQL语句,这通常是SQLExecute之前的一个步骤
|
||||||
|
|
||||||
|
- API: SQLBindCol
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 用于将结果集中的列绑定到应用程序缓冲区
|
||||||
|
|
||||||
|
- API: SQLBindParameter
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 用于将SQL语句的参数绑定到应用程序缓冲区
|
||||||
|
|
||||||
|
- API: SQLGetCursorName
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回与指定语句关联的游标名称
|
||||||
|
|
||||||
|
- API: SQLSetCursorName
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 设置游标名称,允许在查询中使用命名游标
|
||||||
|
|
||||||
|
- API: SQLSetScrollOptions
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 设置控制光标行为的选项
|
||||||
|
|
||||||
|
|
||||||
|
### 提交请求
|
||||||
|
|
||||||
|
- API: SQLExecute
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 用于执行之前通过 SQLPrepare 准备好的SQL语句
|
||||||
|
|
||||||
|
- API: SQLExecDirect
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 用于执行包含SQL语句的字符串
|
||||||
|
|
||||||
|
- API: SQLNativeSql
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 用于将应用程序提供的SQL语句转换为数据库驱动程序的本机SQL语法
|
||||||
|
|
||||||
|
- API: SQLDescribeParam
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 返回语句中特定参数的描述
|
||||||
|
|
||||||
|
- API: SQLNumParams
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 用于查询预编译SQL语句中的参数数量
|
||||||
|
|
||||||
|
- API: SQLParamData
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 用于从参数数据流中获取下一个参数值
|
||||||
|
|
||||||
|
- API: SQLPutData
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 当使用流输入方式时,可以用于向输出参数发送数据块
|
||||||
|
|
||||||
|
|
||||||
|
### 检索结果和关于结果的信息
|
||||||
|
|
||||||
|
- API: SQLRowCount
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回受插入或删除请求影响的行数
|
||||||
|
|
||||||
|
- API: SQLNumResultCols
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回结果集中的列数
|
||||||
|
|
||||||
|
- API: SQLDescribeCol
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 用于描述结果集中列的属性。它提供了关于列的数据类型、列名、列的最大宽度、小数位数和是否可为空等信息
|
||||||
|
|
||||||
|
- API: SQLColAttribute
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回结果集中列的描述符信息,如标题、排序规则等
|
||||||
|
|
||||||
|
- API: SQLColAttributes
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.0 函数 SQLColAttributes 已替换为 SQLColAttribute
|
||||||
|
|
||||||
|
- API: SQLGetData
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 用于从结果集中的当前行获取特定列的数据
|
||||||
|
|
||||||
|
- API: SQLMoreResults
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 多个结果集的 SQL 语句执行后(例如:一个批处理或存储过程),移动到下一个结果集
|
||||||
|
|
||||||
|
- API: SQLFetch
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 用于从结果集中提取下一行数据,并返回所有绑定列的数据
|
||||||
|
|
||||||
|
- API: SQLFetchScroll
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 用于从结果集中提取指定的数据行集,并返回所有绑定列的数据
|
||||||
|
|
||||||
|
- API: SQLExtendedFetch
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,SQLExtendedFetch 已替换为 SQLFetchScroll
|
||||||
|
|
||||||
|
- API: SQLSetPos
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 设置行集中的游标位置,并允许应用程序更新数据集中的行
|
||||||
|
|
||||||
|
- API: SQLBulkOperations
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 执行批量插入和批量书签操作,包括更新、删除和按书签提取
|
||||||
|
|
||||||
|
|
||||||
|
### 检索错误或诊断信息
|
||||||
|
|
||||||
|
- API: SQLError
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.x 函数 SQLError 已替换为 SQLGetDiagRec
|
||||||
|
|
||||||
|
- API: SQLGetDiagField
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回附加诊断信息(单条诊断结果)
|
||||||
|
|
||||||
|
- API: SQLGetDiagRec
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回附加诊断信息(多条诊断结果)
|
||||||
|
|
||||||
|
|
||||||
|
### 获取有关数据源的系统表项的信息
|
||||||
|
|
||||||
|
- API: SQLColumnPrivileges
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 用于检索指定表中列的权限信息,如哪些用户或角色拥有对特定列的读取、插入、更新或删除权限
|
||||||
|
|
||||||
|
- API: SQLColumns
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: X/Open
|
||||||
|
- **作用**: 返回指定表中的列名列表
|
||||||
|
|
||||||
|
- API: SQLForeignKeys
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 检索外键关系的详细信息
|
||||||
|
|
||||||
|
- API: SQLPrimaryKeys
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 返回构成表主键的列名列表
|
||||||
|
|
||||||
|
- API: SQLSpecialColumns
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: X/Open
|
||||||
|
- **作用**: 返回数据库中特殊列的信息,如唯一键或索引列
|
||||||
|
|
||||||
|
- API: SQLStatistics
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 返回关于表的统计信息,如行数、列数、平均行宽等
|
||||||
|
|
||||||
|
- API: SQLTablePrivileges
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 返回用户在特定表上的权限,如SELECT、INSERT、UPDATE等
|
||||||
|
|
||||||
|
- API: SQLTables
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: X/Open
|
||||||
|
- **作用**: 返回存储在数据源的当前数据库中的表信息
|
||||||
|
|
||||||
|
- API: SQLProcedures
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 返回数据库中可用的存储过程信息,包括名称和类型
|
||||||
|
|
||||||
|
- API: SQLProcedureColumns
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 返回存储过程的列信息,包括输入输出参数的详细信息
|
||||||
|
|
||||||
|
|
||||||
|
### 执行事务
|
||||||
|
|
||||||
|
- API: SQLTransact
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.x 函数 SQLTransact 已替换为 SQLEndTran
|
||||||
|
|
||||||
|
- API: SQLEndTran
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 用于提交或回滚事务,TDengine 不支持事务,因此不支持回滚操作
|
||||||
|
|
||||||
|
|
||||||
|
### 终止连接
|
||||||
|
|
||||||
|
- API: SQLDisconnect
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 断开数据库连接
|
||||||
|
|
||||||
|
- API: SQLFreeHandle
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ISO 92
|
||||||
|
- **作用**: 释放与特定环境、连接、语句或描述符句柄关联的资源
|
||||||
|
|
||||||
|
- API: SQLFreeConnect
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.0 函数 SQLFreeConnect 已替换为 SQLFreeHandle
|
||||||
|
|
||||||
|
- API: SQLFreeEnv
|
||||||
|
- **是否支持**: 不支持
|
||||||
|
- **标准**: 弃用
|
||||||
|
- **作用**: 在 ODBC 3.x 中,ODBC 2.0 函数 SQLFreeEnv 已替换为 SQLFreeHandle
|
||||||
|
|
||||||
|
- API: SQLFreeStmt
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 结束语句处理,丢弃挂起的结果,并且可以选择释放与语句句柄关联的所有资源
|
||||||
|
|
||||||
|
- API: SQLCloseCursor
|
||||||
|
- **是否支持**: 支持
|
||||||
|
- **标准**: ODBC
|
||||||
|
- **作用**: 关闭与当前语句句柄关联的游标,并释放游标所使用的所有资源
|
||||||
|
|
||||||
|
|
||||||
## 与第三方集成
|
## 与第三方集成
|
||||||
|
|
||||||
作为使用 TDengine ODBC driver 的一个示例,你可以使用 Power BI 与 TDengine 分析时序数据。更多细节请参考 [Power BI](../../../third-party/bi/powerbi)
|
作为使用 TDengine ODBC driver 的一个示例,你可以使用 Power BI 与 TDengine 分析时序数据。更多细节请参考 [Power BI](../../../third-party/bi/powerbi)
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 11 KiB |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 11 KiB |
|
@ -251,6 +251,7 @@ DLL_EXPORT int64_t taos_affected_rows64(TAOS_RES *res);
|
||||||
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
||||||
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
||||||
DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
|
DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
|
||||||
|
DLL_EXPORT int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
|
||||||
DLL_EXPORT void taos_stop_query(TAOS_RES *res);
|
DLL_EXPORT void taos_stop_query(TAOS_RES *res);
|
||||||
DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col);
|
DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col);
|
||||||
DLL_EXPORT int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows);
|
DLL_EXPORT int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows);
|
||||||
|
@ -389,7 +390,7 @@ DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res);
|
||||||
DLL_EXPORT int64_t tmq_get_vgroup_offset(TAOS_RES *res);
|
DLL_EXPORT int64_t tmq_get_vgroup_offset(TAOS_RES *res);
|
||||||
DLL_EXPORT const char *tmq_err2str(int32_t code);
|
DLL_EXPORT const char *tmq_err2str(int32_t code);
|
||||||
|
|
||||||
/* ------------------------------ TAOSX -----------------------------------*/
|
/* ------------------------------ TAOSX INTERFACE -----------------------------------*/
|
||||||
typedef struct tmq_raw_data {
|
typedef struct tmq_raw_data {
|
||||||
void *raw;
|
void *raw;
|
||||||
uint32_t raw_len;
|
uint32_t raw_len;
|
||||||
|
|
|
@ -89,32 +89,6 @@ typedef struct {
|
||||||
int32_t exprIdx;
|
int32_t exprIdx;
|
||||||
} STupleKey;
|
} STupleKey;
|
||||||
|
|
||||||
typedef struct STuplePos {
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
int32_t pageId;
|
|
||||||
int32_t offset;
|
|
||||||
};
|
|
||||||
SWinKey streamTupleKey;
|
|
||||||
};
|
|
||||||
} STuplePos;
|
|
||||||
|
|
||||||
typedef struct SFirstLastRes {
|
|
||||||
bool hasResult;
|
|
||||||
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
|
||||||
// this attribute is required
|
|
||||||
bool isNull;
|
|
||||||
int32_t bytes;
|
|
||||||
int64_t ts;
|
|
||||||
char* pkData;
|
|
||||||
int32_t pkBytes;
|
|
||||||
int8_t pkType;
|
|
||||||
STuplePos pos;
|
|
||||||
STuplePos nullTuplePos;
|
|
||||||
bool nullTupleSaved;
|
|
||||||
char buf[];
|
|
||||||
} SFirstLastRes;
|
|
||||||
|
|
||||||
static inline int STupleKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
static inline int STupleKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
||||||
STupleKey* pTuple1 = (STupleKey*)pKey1;
|
STupleKey* pTuple1 = (STupleKey*)pKey1;
|
||||||
STupleKey* pTuple2 = (STupleKey*)pKey2;
|
STupleKey* pTuple2 = (STupleKey*)pKey2;
|
||||||
|
|
|
@ -277,7 +277,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** pReq, const SSDataBlock* pData
|
||||||
|
|
||||||
bool alreadyAddGroupId(char* ctbName, int64_t groupId);
|
bool alreadyAddGroupId(char* ctbName, int64_t groupId);
|
||||||
bool isAutoTableName(char* ctbName);
|
bool isAutoTableName(char* ctbName);
|
||||||
void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId);
|
int32_t buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId, size_t cap);
|
||||||
int32_t buildCtbNameByGroupId(const char* stbName, uint64_t groupId, char** pName);
|
int32_t buildCtbNameByGroupId(const char* stbName, uint64_t groupId, char** pName);
|
||||||
int32_t buildCtbNameByGroupIdImpl(const char* stbName, uint64_t groupId, char* pBuf);
|
int32_t buildCtbNameByGroupIdImpl(const char* stbName, uint64_t groupId, char* pBuf);
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ extern int64_t tsMinDiskFreeSize;
|
||||||
// udf
|
// udf
|
||||||
extern bool tsStartUdfd;
|
extern bool tsStartUdfd;
|
||||||
extern char tsUdfdResFuncs[];
|
extern char tsUdfdResFuncs[];
|
||||||
extern char tsUdfdLdLibPath[];
|
extern char tsUdfdLdLibPath[512];
|
||||||
|
|
||||||
// schemaless
|
// schemaless
|
||||||
extern char tsSmlChildTableName[];
|
extern char tsSmlChildTableName[];
|
||||||
|
|
|
@ -1684,6 +1684,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t openVnodes;
|
int32_t openVnodes;
|
||||||
|
int32_t dropVnodes;
|
||||||
int32_t totalVnodes;
|
int32_t totalVnodes;
|
||||||
int32_t masterNum;
|
int32_t masterNum;
|
||||||
int64_t numOfSelectReqs;
|
int64_t numOfSelectReqs;
|
||||||
|
@ -2822,8 +2823,8 @@ enum {
|
||||||
TOPIC_SUB_TYPE__COLUMN,
|
TOPIC_SUB_TYPE__COLUMN,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_MAX_POLL_INTERVAL 300000
|
#define DEFAULT_MAX_POLL_INTERVAL 300000
|
||||||
#define DEFAULT_SESSION_TIMEOUT 12000
|
#define DEFAULT_SESSION_TIMEOUT 12000
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TOPIC_FNAME_LEN]; // accout.topic
|
char name[TSDB_TOPIC_FNAME_LEN]; // accout.topic
|
||||||
|
@ -4048,37 +4049,39 @@ void tDeleteMqMetaRsp(SMqMetaRsp* pRsp);
|
||||||
#define MQ_DATA_RSP_VERSION 100
|
#define MQ_DATA_RSP_VERSION 100
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMqRspHead head;
|
struct {
|
||||||
STqOffsetVal reqOffset;
|
SMqRspHead head;
|
||||||
STqOffsetVal rspOffset;
|
STqOffsetVal rspOffset;
|
||||||
int32_t blockNum;
|
STqOffsetVal reqOffset;
|
||||||
int8_t withTbName;
|
int32_t blockNum;
|
||||||
int8_t withSchema;
|
int8_t withTbName;
|
||||||
SArray* blockDataLen;
|
int8_t withSchema;
|
||||||
SArray* blockData;
|
SArray* blockDataLen;
|
||||||
SArray* blockTbName;
|
SArray* blockData;
|
||||||
SArray* blockSchema;
|
SArray* blockTbName;
|
||||||
} SMqDataRspCommon;
|
SArray* blockSchema;
|
||||||
|
};
|
||||||
|
|
||||||
|
union{
|
||||||
|
struct{
|
||||||
|
int64_t sleepTime;
|
||||||
|
};
|
||||||
|
struct{
|
||||||
|
int32_t createTableNum;
|
||||||
|
SArray* createTableLen;
|
||||||
|
SArray* createTableReq;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
SMqDataRspCommon common;
|
|
||||||
int64_t sleepTime;
|
|
||||||
} SMqDataRsp;
|
} SMqDataRsp;
|
||||||
|
|
||||||
int32_t tEncodeMqDataRsp(SEncoder* pEncoder, const void* pRsp);
|
int32_t tEncodeMqDataRsp(SEncoder *pEncoder, const SMqDataRsp *pObj);
|
||||||
int32_t tDecodeMqDataRsp(SDecoder* pDecoder, void* pRsp);
|
int32_t tDecodeMqDataRsp(SDecoder* pDecoder, SMqDataRsp* pRsp);
|
||||||
void tDeleteMqDataRsp(void* pRsp);
|
void tDeleteMqDataRsp(SMqDataRsp* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const SMqDataRsp* pRsp);
|
||||||
SMqDataRspCommon common;
|
int32_t tDecodeSTaosxRsp(SDecoder* pDecoder, SMqDataRsp* pRsp);
|
||||||
int32_t createTableNum;
|
void tDeleteSTaosxRsp(SMqDataRsp* pRsp);
|
||||||
SArray* createTableLen;
|
|
||||||
SArray* createTableReq;
|
|
||||||
} STaosxRsp;
|
|
||||||
|
|
||||||
int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const void* pRsp);
|
|
||||||
int32_t tDecodeSTaosxRsp(SDecoder* pDecoder, void* pRsp);
|
|
||||||
void tDeleteSTaosxRsp(void* pRsp);
|
|
||||||
|
|
||||||
typedef struct SMqBatchMetaRsp {
|
typedef struct SMqBatchMetaRsp {
|
||||||
SMqRspHead head; // not serialize
|
SMqRspHead head; // not serialize
|
||||||
|
@ -4163,6 +4166,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SArray* topicPrivileges; // SArray<STopicPrivilege>
|
SArray* topicPrivileges; // SArray<STopicPrivilege>
|
||||||
|
int32_t debugFlag;
|
||||||
} SMqHbRsp;
|
} SMqHbRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -64,7 +64,7 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
|
||||||
: 1000000000;
|
: 1000000000;
|
||||||
time_t t = taosTime(NULL);
|
time_t t = taosTime(NULL);
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
(void) taosLocalTime(&t, &tm, NULL);
|
(void) taosLocalTime(&t, &tm, NULL, 0);
|
||||||
tm.tm_hour = 0;
|
tm.tm_hour = 0;
|
||||||
tm.tm_min = 0;
|
tm.tm_min = 0;
|
||||||
tm.tm_sec = 0;
|
tm.tm_sec = 0;
|
||||||
|
|
|
@ -23,6 +23,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// variant, each number/string/field_id has a corresponding struct during parsing sql
|
// variant, each number/string/field_id has a corresponding struct during parsing sql
|
||||||
|
// **NOTE**: if you want to change this struct, please consider the backward compatibility of function top and bottom.
|
||||||
typedef struct SVariant {
|
typedef struct SVariant {
|
||||||
uint32_t nType;
|
uint32_t nType;
|
||||||
int32_t nLen; // only used for string, for number, it is useless
|
int32_t nLen; // only used for string, for number, it is useless
|
||||||
|
|
|
@ -29,6 +29,6 @@ int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs)
|
||||||
int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp);
|
int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp);
|
||||||
int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t groupId, SRetrieveTableRsp **pRsp);
|
int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t groupId, SRetrieveTableRsp **pRsp);
|
||||||
void qExplainFreeCtx(SExplainCtx *pCtx);
|
void qExplainFreeCtx(SExplainCtx *pCtx);
|
||||||
int32_t formatDurationOrKeep(char* buffer, int32_t timeInMinutes);
|
int32_t formatDurationOrKeep(char* buffer, int64_t bufSize, int32_t timeInMinutes);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,6 +23,7 @@ extern "C" {
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
#include "tsimplehash.h"
|
#include "tsimplehash.h"
|
||||||
#include "tvariant.h"
|
#include "tvariant.h"
|
||||||
|
#include "functionResInfo.h"
|
||||||
|
|
||||||
struct SqlFunctionCtx;
|
struct SqlFunctionCtx;
|
||||||
struct SResultRowEntryInfo;
|
struct SResultRowEntryInfo;
|
||||||
|
@ -85,14 +86,7 @@ enum {
|
||||||
PRE_SCAN = 0x2u, // pre-scan belongs to the main scan and occurs before main scan
|
PRE_SCAN = 0x2u, // pre-scan belongs to the main scan and occurs before main scan
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct SPoint1 {
|
struct SPoint1;
|
||||||
int64_t key;
|
|
||||||
union {
|
|
||||||
double val;
|
|
||||||
char *ptr;
|
|
||||||
};
|
|
||||||
} SPoint1;
|
|
||||||
|
|
||||||
struct SqlFunctionCtx;
|
struct SqlFunctionCtx;
|
||||||
struct SResultRowEntryInfo;
|
struct SResultRowEntryInfo;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TDENGINE_FUNCTIONRESINFO_H
|
||||||
|
#define TDENGINE_FUNCTIONRESINFO_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
#include "tcommon.h"
|
||||||
|
|
||||||
|
typedef struct STuplePos {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
int32_t pageId;
|
||||||
|
int32_t offset;
|
||||||
|
};
|
||||||
|
SWinKey streamTupleKey;
|
||||||
|
};
|
||||||
|
} STuplePos;
|
||||||
|
|
||||||
|
typedef struct SCentroid {
|
||||||
|
double mean;
|
||||||
|
int64_t weight;
|
||||||
|
} SCentroid;
|
||||||
|
|
||||||
|
typedef struct SPt {
|
||||||
|
double value;
|
||||||
|
int64_t weight;
|
||||||
|
} SPt;
|
||||||
|
|
||||||
|
typedef struct TDigest {
|
||||||
|
double compression;
|
||||||
|
int32_t threshold;
|
||||||
|
int64_t size;
|
||||||
|
|
||||||
|
int64_t total_weight;
|
||||||
|
double min;
|
||||||
|
double max;
|
||||||
|
|
||||||
|
int32_t num_buffered_pts;
|
||||||
|
SPt *buffered_pts;
|
||||||
|
|
||||||
|
int32_t num_centroids;
|
||||||
|
SCentroid *centroids;
|
||||||
|
} TDigest;
|
||||||
|
|
||||||
|
typedef struct SFirstLastRes {
|
||||||
|
bool hasResult;
|
||||||
|
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
||||||
|
// this attribute is required
|
||||||
|
bool isNull;
|
||||||
|
int32_t bytes;
|
||||||
|
int64_t ts;
|
||||||
|
char* pkData;
|
||||||
|
int32_t pkBytes;
|
||||||
|
int8_t pkType;
|
||||||
|
STuplePos pos;
|
||||||
|
STuplePos nullTuplePos;
|
||||||
|
bool nullTupleSaved;
|
||||||
|
char buf[];
|
||||||
|
} SFirstLastRes;
|
||||||
|
|
||||||
|
typedef struct SPoint1 {
|
||||||
|
int64_t key;
|
||||||
|
union {
|
||||||
|
double val;
|
||||||
|
char *ptr;
|
||||||
|
};
|
||||||
|
} SPoint1;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // TDENGINE_FUNCTIONRESINFO_H
|
|
@ -274,7 +274,7 @@ typedef enum EWindowType {
|
||||||
WINDOW_TYPE_SESSION,
|
WINDOW_TYPE_SESSION,
|
||||||
WINDOW_TYPE_STATE,
|
WINDOW_TYPE_STATE,
|
||||||
WINDOW_TYPE_EVENT,
|
WINDOW_TYPE_EVENT,
|
||||||
WINDOW_TYPE_COUNT
|
WINDOW_TYPE_COUNT,
|
||||||
} EWindowType;
|
} EWindowType;
|
||||||
|
|
||||||
typedef enum EWindowAlgorithm {
|
typedef enum EWindowAlgorithm {
|
||||||
|
|
|
@ -190,7 +190,6 @@ typedef struct SFunctionNode {
|
||||||
bool hasOriginalFunc;
|
bool hasOriginalFunc;
|
||||||
int32_t originalFuncId;
|
int32_t originalFuncId;
|
||||||
ETrimType trimType;
|
ETrimType trimType;
|
||||||
bool hasSMA;
|
|
||||||
bool dual; // whether select stmt without from stmt, true for without.
|
bool dual; // whether select stmt without from stmt, true for without.
|
||||||
} SFunctionNode;
|
} SFunctionNode;
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,7 @@ char* jobTaskStatusStr(int32_t status);
|
||||||
SSchema createSchema(int8_t type, int32_t bytes, col_id_t colId, const char* name);
|
SSchema createSchema(int8_t type, int32_t bytes, col_id_t colId, const char* name);
|
||||||
|
|
||||||
void destroyQueryExecRes(SExecResult* pRes);
|
void destroyQueryExecRes(SExecResult* pRes);
|
||||||
int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t* len);
|
int32_t dataConverToStr(char* str, int64_t capacity, int type, void* buf, int32_t bufSize, int32_t* len);
|
||||||
void parseTagDatatoJson(void* p, char** jsonStr);
|
void parseTagDatatoJson(void* p, char** jsonStr);
|
||||||
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
|
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
|
||||||
void getColumnTypeFromMeta(STableMeta* pMeta, char* pName, ETableColumnType* pType);
|
void getColumnTypeFromMeta(STableMeta* pMeta, char* pName, ETableColumnType* pType);
|
||||||
|
@ -407,29 +407,29 @@ void* getTaskPoolWorkerCb();
|
||||||
#define IS_AUDIT_CTB_NAME(_ctbname) \
|
#define IS_AUDIT_CTB_NAME(_ctbname) \
|
||||||
((*(_ctbname) == 't') && (0 == strncmp(_ctbname, TSDB_AUDIT_CTB_OPERATION, TSDB_AUDIT_CTB_OPERATION_LEN)))
|
((*(_ctbname) == 't') && (0 == strncmp(_ctbname, TSDB_AUDIT_CTB_OPERATION, TSDB_AUDIT_CTB_OPERATION_LEN)))
|
||||||
|
|
||||||
#define qFatal(...) \
|
#define qFatal(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_FATAL) { \
|
if (qDebugFlag & DEBUG_FATAL) { \
|
||||||
taosPrintLog("QRY FATAL ", DEBUG_FATAL, qDebugFlag, __VA_ARGS__); \
|
taosPrintLog("QRY FATAL ", DEBUG_FATAL, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define qError(...) \
|
#define qError(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_ERROR) { \
|
if (qDebugFlag & DEBUG_ERROR) { \
|
||||||
taosPrintLog("QRY ERROR ", DEBUG_ERROR, qDebugFlag, __VA_ARGS__); \
|
taosPrintLog("QRY ERROR ", DEBUG_ERROR, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define qWarn(...) \
|
#define qWarn(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_WARN) { \
|
if (qDebugFlag & DEBUG_WARN) { \
|
||||||
taosPrintLog("QRY WARN ", DEBUG_WARN, qDebugFlag, __VA_ARGS__); \
|
taosPrintLog("QRY WARN ", DEBUG_WARN, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define qInfo(...) \
|
#define qInfo(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_INFO) { \
|
if (qDebugFlag & DEBUG_INFO) { \
|
||||||
taosPrintLog("QRY ", DEBUG_INFO, qDebugFlag, __VA_ARGS__); \
|
taosPrintLog("QRY ", DEBUG_INFO, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define qDebug(...) \
|
#define qDebug(...) \
|
||||||
do { \
|
do { \
|
||||||
|
|
|
@ -47,7 +47,7 @@ extern "C" {
|
||||||
#define SYNC_HEARTBEAT_SLOW_MS 1500
|
#define SYNC_HEARTBEAT_SLOW_MS 1500
|
||||||
#define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500
|
#define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500
|
||||||
#define SYNC_SNAP_RESEND_MS 1000 * 60
|
#define SYNC_SNAP_RESEND_MS 1000 * 60
|
||||||
#define SYNC_SNAP_TIMEOUT_MS 1000 * 300
|
#define SYNC_SNAP_TIMEOUT_MS 1000 * 180
|
||||||
|
|
||||||
#define SYNC_VND_COMMIT_MIN_MS 3000
|
#define SYNC_VND_COMMIT_MIN_MS 3000
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ typedef struct {
|
||||||
int32_t rollPeriod; // secs
|
int32_t rollPeriod; // secs
|
||||||
int64_t retentionSize;
|
int64_t retentionSize;
|
||||||
int64_t segSize;
|
int64_t segSize;
|
||||||
|
int64_t committed;
|
||||||
EWalType level; // wal level
|
EWalType level; // wal level
|
||||||
int32_t encryptAlgorithm;
|
int32_t encryptAlgorithm;
|
||||||
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
||||||
|
|
|
@ -247,9 +247,12 @@ void syslog(int unused, const char *format, ...);
|
||||||
#define TD_DIRSEP_CHAR '/'
|
#define TD_DIRSEP_CHAR '/'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TD_FQDN_LEN 128
|
||||||
#define TD_LOCALE_LEN 64
|
#define TD_LOCALE_LEN 64
|
||||||
#define TD_CHARSET_LEN 64
|
#define TD_CHARSET_LEN 64
|
||||||
#define TD_TIMEZONE_LEN 96
|
#define TD_TIMEZONE_LEN 96
|
||||||
|
#define TD_TIME_STR_LEN 128
|
||||||
|
#define TD_IP_LEN 64
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,6 @@ typedef int32_t SOCKET;
|
||||||
#else
|
#else
|
||||||
#define TAOS_EPOLL_WAIT_TIME 500
|
#define TAOS_EPOLL_WAIT_TIME 500
|
||||||
typedef int32_t SOCKET;
|
typedef int32_t SOCKET;
|
||||||
typedef SOCKET EpollFd;
|
|
||||||
#define EpollClose(pollFd) taosCloseSocket(pollFd)
|
#define EpollClose(pollFd) taosCloseSocket(pollFd)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -59,15 +59,17 @@ typedef enum { M2C = 0, C2M } ConvType;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define tstrncpy(dst, src, size) \
|
#define tstrncpy(dst, src, size) \
|
||||||
do { \
|
do { \
|
||||||
(void)strncpy((dst), (src), (size)); \
|
(void)strncpy((dst), (src), (size)); \
|
||||||
(dst)[(size)-1] = 0; \
|
(dst)[(size) - 1] = 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
int64_t tsnprintf(char *dst, int64_t size, const char *format, ...);
|
||||||
#define TAOS_STRCPY(_dst, _src) ((void)strcpy(_dst, _src))
|
#define TAOS_STRCPY(_dst, _src) ((void)strcpy(_dst, _src))
|
||||||
#define TAOS_STRNCPY(_dst, _src, _size) ((void)strncpy(_dst, _src, _size))
|
#define TAOS_STRNCPY(_dst, _src, _size) ((void)strncpy(_dst, _src, _size))
|
||||||
#define TAOS_STRCAT(_dst, _src) ((void)strcat(_dst, _src))
|
#define TAOS_STRCAT(_dst, _src) ((void)strcat(_dst, _src))
|
||||||
|
#define TAOS_STRNCAT(_dst, _src, len) ((void)strncat(_dst, _src, len))
|
||||||
|
|
||||||
char *tstrdup(const char *src);
|
char *tstrdup(const char *src);
|
||||||
int32_t taosUcs4len(TdUcs4 *ucs4);
|
int32_t taosUcs4len(TdUcs4 *ucs4);
|
||||||
|
@ -86,7 +88,7 @@ bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs
|
||||||
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
||||||
int32_t tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
int32_t tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||||
bool taosValidateEncodec(const char *encodec);
|
bool taosValidateEncodec(const char *encodec);
|
||||||
int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len);
|
int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len, int32_t bufSize);
|
||||||
int32_t taosHexDecode(const char *src, char *dst, int32_t len);
|
int32_t taosHexDecode(const char *src, char *dst, int32_t len);
|
||||||
|
|
||||||
int32_t taosWcharWidth(TdWchar wchar);
|
int32_t taosWcharWidth(TdWchar wchar);
|
||||||
|
|
|
@ -52,7 +52,8 @@ int32_t taosGetCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes);
|
||||||
void taosSetDefaultCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes);
|
void taosSetDefaultCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes);
|
||||||
|
|
||||||
void taosKillSystem();
|
void taosKillSystem();
|
||||||
int32_t taosGetSystemUUID(char *uid, int32_t uidlen);
|
int32_t taosGetSystemUUIDLimit36(char *uid, int32_t uidlen);
|
||||||
|
int32_t taosGetSystemUUIDLen(char *uid, int32_t uidlen);
|
||||||
char *taosGetCmdlineByPID(int32_t pid);
|
char *taosGetCmdlineByPID(int32_t pid);
|
||||||
void taosSetCoreDump(bool enable);
|
void taosSetCoreDump(bool enable);
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ static FORCE_INLINE int64_t taosGetMonoTimestampMs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm);
|
char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm);
|
||||||
struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf);
|
struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf, int32_t bufSize);
|
||||||
struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, int dst);
|
struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, int dst);
|
||||||
time_t taosTime(time_t *t);
|
time_t taosTime(time_t *t);
|
||||||
time_t taosMktime(struct tm *timep);
|
time_t taosMktime(struct tm *timep);
|
||||||
|
|
|
@ -474,8 +474,7 @@ int32_t taosGetErrSize();
|
||||||
#define TSDB_CODE_DNODE_INVALID_TTL_CHG_ON_WR TAOS_DEF_ERROR_CODE(0, 0x0427)
|
#define TSDB_CODE_DNODE_INVALID_TTL_CHG_ON_WR TAOS_DEF_ERROR_CODE(0, 0x0427)
|
||||||
#define TSDB_CODE_DNODE_INVALID_EN_WHITELIST TAOS_DEF_ERROR_CODE(0, 0x0428)
|
#define TSDB_CODE_DNODE_INVALID_EN_WHITELIST TAOS_DEF_ERROR_CODE(0, 0x0428)
|
||||||
#define TSDB_CODE_DNODE_INVALID_MONITOR_PARAS TAOS_DEF_ERROR_CODE(0, 0x0429)
|
#define TSDB_CODE_DNODE_INVALID_MONITOR_PARAS TAOS_DEF_ERROR_CODE(0, 0x0429)
|
||||||
#define TSDB_CODE_MNODE_STOPPED TAOS_DEF_ERROR_CODE(0, 0x042A)
|
#define TSDB_CODE_MNODE_STOPPED TAOS_DEF_ERROR_CODE(0, 0x042A)
|
||||||
|
|
||||||
|
|
||||||
// mnode-sma
|
// mnode-sma
|
||||||
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
|
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
|
||||||
|
|
|
@ -152,11 +152,15 @@ int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int
|
||||||
// for internal usage
|
// for internal usage
|
||||||
int32_t getWordLength(char type);
|
int32_t getWordLength(char type);
|
||||||
|
|
||||||
|
#ifdef __AVX2__
|
||||||
int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, char *const output, const char type);
|
int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, char *const output, const char type);
|
||||||
void tsDecompressFloatImplAvx512(const char *const input, const int32_t nelements, char *const output);
|
int32_t tsDecompressFloatImpAvx2(const char *input, int32_t nelements, char *output);
|
||||||
void tsDecompressFloatImplAvx2(const char *const input, const int32_t nelements, char *const output);
|
int32_t tsDecompressDoubleImpAvx2(const char *input, int32_t nelements, char *output);
|
||||||
|
#endif
|
||||||
|
#ifdef __AVX512VL__
|
||||||
|
void tsDecompressTimestampAvx2(const char *input, int32_t nelements, char *output, bool bigEndian);
|
||||||
void tsDecompressTimestampAvx512(const char *const input, const int32_t nelements, char *const output, bool bigEndian);
|
void tsDecompressTimestampAvx512(const char *const input, const int32_t nelements, char *const output, bool bigEndian);
|
||||||
void tsDecompressTimestampAvx2(const char *const input, const int32_t nelements, char *const output, bool bigEndian);
|
#endif
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* REGULAR COMPRESSION 2
|
* REGULAR COMPRESSION 2
|
||||||
|
@ -213,8 +217,8 @@ typedef int32_t (*__data_compress_init)(char *lossyColumns, float fPrecision, do
|
||||||
uint32_t intervals, int32_t ifAdtFse, const char *compressor);
|
uint32_t intervals, int32_t ifAdtFse, const char *compressor);
|
||||||
typedef int32_t (*__data_compress_l1_fn_t)(const char *const input, const int32_t nelements, char *const output,
|
typedef int32_t (*__data_compress_l1_fn_t)(const char *const input, const int32_t nelements, char *const output,
|
||||||
const char type);
|
const char type);
|
||||||
typedef int32_t (*__data_decompress_l1_fn_t)(const char *const input, const int32_t nelements, char *const output,
|
typedef int32_t (*__data_decompress_l1_fn_t)(const char *const input, int32_t ninput, const int32_t nelements,
|
||||||
const char type);
|
char *const output, const char type);
|
||||||
|
|
||||||
typedef int32_t (*__data_compress_l2_fn_t)(const char *const input, const int32_t nelements, char *const output,
|
typedef int32_t (*__data_compress_l2_fn_t)(const char *const input, const int32_t nelements, char *const output,
|
||||||
int32_t outputSize, const char type, int8_t level);
|
int32_t outputSize, const char type, int8_t level);
|
||||||
|
@ -289,4 +293,4 @@ int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, u
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_UTIL_COMPRESSION_H_*/
|
#endif /*_TD_UTIL_COMPRESSION_H_*/
|
||||||
|
|
|
@ -284,7 +284,7 @@ typedef enum ELogicConditionType {
|
||||||
|
|
||||||
#define TSDB_CLUSTER_ID_LEN 40
|
#define TSDB_CLUSTER_ID_LEN 40
|
||||||
#define TSDB_MACHINE_ID_LEN 24
|
#define TSDB_MACHINE_ID_LEN 24
|
||||||
#define TSDB_FQDN_LEN 128
|
#define TSDB_FQDN_LEN TD_FQDN_LEN
|
||||||
#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6)
|
#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6)
|
||||||
#define TSDB_IPv4ADDR_LEN 16
|
#define TSDB_IPv4ADDR_LEN 16
|
||||||
#define TSDB_FILENAME_LEN 128
|
#define TSDB_FILENAME_LEN 128
|
||||||
|
@ -603,6 +603,7 @@ enum { RAND_ERR_MEMORY = 1, RAND_ERR_FILE = 2, RAND_ERR_NETWORK = 4 };
|
||||||
#define MONITOR_TAG_NAME_LEN 100
|
#define MONITOR_TAG_NAME_LEN 100
|
||||||
#define MONITOR_TAG_VALUE_LEN 300
|
#define MONITOR_TAG_VALUE_LEN 300
|
||||||
#define MONITOR_METRIC_NAME_LEN 100
|
#define MONITOR_METRIC_NAME_LEN 100
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#define TDIGEST_H
|
#define TDIGEST_H
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "libs/function/functionResInfo.h"
|
||||||
|
|
||||||
#ifndef M_PI
|
#ifndef M_PI
|
||||||
#define M_PI 3.14159265358979323846264338327950288 /* pi */
|
#define M_PI 3.14159265358979323846264338327950288 /* pi */
|
||||||
|
@ -37,32 +38,6 @@
|
||||||
#define TDIGEST_SIZE(compression) \
|
#define TDIGEST_SIZE(compression) \
|
||||||
(sizeof(TDigest) + sizeof(SCentroid) * GET_CENTROID(compression) + sizeof(SPt) * GET_THRESHOLD(compression))
|
(sizeof(TDigest) + sizeof(SCentroid) * GET_CENTROID(compression) + sizeof(SPt) * GET_THRESHOLD(compression))
|
||||||
|
|
||||||
typedef struct SCentroid {
|
|
||||||
double mean;
|
|
||||||
int64_t weight;
|
|
||||||
} SCentroid;
|
|
||||||
|
|
||||||
typedef struct SPt {
|
|
||||||
double value;
|
|
||||||
int64_t weight;
|
|
||||||
} SPt;
|
|
||||||
|
|
||||||
typedef struct TDigest {
|
|
||||||
double compression;
|
|
||||||
int32_t threshold;
|
|
||||||
int64_t size;
|
|
||||||
|
|
||||||
int64_t total_weight;
|
|
||||||
double min;
|
|
||||||
double max;
|
|
||||||
|
|
||||||
int32_t num_buffered_pts;
|
|
||||||
SPt *buffered_pts;
|
|
||||||
|
|
||||||
int32_t num_centroids;
|
|
||||||
SCentroid *centroids;
|
|
||||||
} TDigest;
|
|
||||||
|
|
||||||
TDigest *tdigestNewFrom(void *pBuf, int32_t compression);
|
TDigest *tdigestNewFrom(void *pBuf, int32_t compression);
|
||||||
int32_t tdigestAdd(TDigest *t, double x, int64_t w);
|
int32_t tdigestAdd(TDigest *t, double x, int64_t w);
|
||||||
int32_t tdigestMerge(TDigest *t1, TDigest *t2);
|
int32_t tdigestMerge(TDigest *t1, TDigest *t2);
|
||||||
|
|
|
@ -69,6 +69,8 @@ extern int32_t tdbDebugFlag;
|
||||||
extern int32_t sndDebugFlag;
|
extern int32_t sndDebugFlag;
|
||||||
extern int32_t simDebugFlag;
|
extern int32_t simDebugFlag;
|
||||||
|
|
||||||
|
extern int32_t tqClientDebug;
|
||||||
|
|
||||||
int32_t taosInitLog(const char *logName, int32_t maxFiles, bool tsc);
|
int32_t taosInitLog(const char *logName, int32_t maxFiles, bool tsc);
|
||||||
void taosCloseLog();
|
void taosCloseLog();
|
||||||
void taosResetLog();
|
void taosResetLog();
|
||||||
|
|
|
@ -48,3 +48,6 @@ int64_t tGenIdPI64(void);
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int64_t tGenQid64(int8_t dnodeId);
|
int64_t tGenQid64(int8_t dnodeId);
|
||||||
|
|
||||||
|
int32_t taosGetSystemUUIDU32(uint32_t *uuid);
|
||||||
|
int32_t taosGetSystemUUIDU64(uint64_t *uuid);
|
||||||
|
|
|
@ -226,31 +226,17 @@ typedef struct {
|
||||||
SSchemaWrapper schema;
|
SSchemaWrapper schema;
|
||||||
int32_t resIter;
|
int32_t resIter;
|
||||||
SReqResultInfo resInfo;
|
SReqResultInfo resInfo;
|
||||||
} SMqRspObjCommon;
|
union{
|
||||||
|
struct{
|
||||||
typedef struct {
|
SMqRspHead head;
|
||||||
SMqRspObjCommon common;
|
STqOffsetVal rspOffset;
|
||||||
SMqDataRsp rsp;
|
};
|
||||||
|
SMqDataRsp dataRsp;
|
||||||
|
SMqMetaRsp metaRsp;
|
||||||
|
SMqBatchMetaRsp batchMetaRsp;
|
||||||
|
};
|
||||||
} SMqRspObj;
|
} SMqRspObj;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int8_t resType;
|
|
||||||
char topic[TSDB_TOPIC_FNAME_LEN];
|
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
|
||||||
int32_t vgId;
|
|
||||||
SMqMetaRsp metaRsp;
|
|
||||||
} SMqMetaRspObj;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
SMqRspObjCommon common;
|
|
||||||
STaosxRsp rsp;
|
|
||||||
} SMqTaosxRspObj;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
SMqRspObjCommon common;
|
|
||||||
SMqBatchMetaRsp rsp;
|
|
||||||
} SMqBatchMetaRspObj;
|
|
||||||
|
|
||||||
typedef struct SReqRelInfo {
|
typedef struct SReqRelInfo {
|
||||||
uint64_t userRefId;
|
uint64_t userRefId;
|
||||||
uint64_t prevRefId;
|
uint64_t prevRefId;
|
||||||
|
@ -332,7 +318,7 @@ int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols);
|
||||||
|
|
||||||
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
||||||
SMqRspObj* msg = (SMqRspObj*)res;
|
SMqRspObj* msg = (SMqRspObj*)res;
|
||||||
return (SReqResultInfo*)&msg->common.resInfo;
|
return (SReqResultInfo*)&msg->resInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4, SReqResultInfo** pResInfo);
|
int32_t tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4, SReqResultInfo** pResInfo);
|
||||||
|
|
|
@ -114,10 +114,10 @@ static void concatStrings(SArray *list, char *buf, int size) {
|
||||||
db = dot + 1;
|
db = dot + 1;
|
||||||
}
|
}
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
(void)strcat(buf, ",");
|
(void)strncat(buf, ",", size - 1 - len);
|
||||||
len += 1;
|
len += 1;
|
||||||
}
|
}
|
||||||
int ret = snprintf(buf + len, size - len, "%s", db);
|
int ret = tsnprintf(buf + len, size - len, "%s", db);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tscError("snprintf failed, buf:%s, ret:%d", buf, ret);
|
tscError("snprintf failed, buf:%s, ret:%d", buf, ret);
|
||||||
break;
|
break;
|
||||||
|
@ -1094,18 +1094,14 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
uint64_t generateRequestId() {
|
uint64_t generateRequestId() {
|
||||||
static uint64_t hashId = 0;
|
static uint32_t hashId = 0;
|
||||||
static uint32_t requestSerialId = 0;
|
static int32_t requestSerialId = 0;
|
||||||
|
|
||||||
if (hashId == 0) {
|
if (hashId == 0) {
|
||||||
char uid[64] = {0};
|
int32_t code = taosGetSystemUUIDU32(&hashId);
|
||||||
int32_t code = taosGetSystemUUID(uid, tListLen(uid));
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tscError("Failed to get the system uid to generated request id, reason:%s. use ip address instead",
|
tscError("Failed to get the system uid to generated request id, reason:%s. use ip address instead",
|
||||||
tstrerror(TAOS_SYSTEM_ERROR(errno)));
|
tstrerror(code));
|
||||||
|
|
||||||
} else {
|
|
||||||
hashId = MurmurHash3_32(uid, strlen(uid));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1117,7 +1113,7 @@ uint64_t generateRequestId() {
|
||||||
uint32_t val = atomic_add_fetch_32(&requestSerialId, 1);
|
uint32_t val = atomic_add_fetch_32(&requestSerialId, 1);
|
||||||
if (val >= 0xFFFF) atomic_store_32(&requestSerialId, 0);
|
if (val >= 0xFFFF) atomic_store_32(&requestSerialId, 0);
|
||||||
|
|
||||||
id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF);
|
id = (((uint64_t)(hashId & 0x0FFF)) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF);
|
||||||
if (id) {
|
if (id) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1132,27 +1128,27 @@ static setConfRet taos_set_config_imp(const char *config){
|
||||||
static bool setConfFlag = false;
|
static bool setConfFlag = false;
|
||||||
if (setConfFlag) {
|
if (setConfFlag) {
|
||||||
ret.retCode = SET_CONF_RET_ERR_ONLY_ONCE;
|
ret.retCode = SET_CONF_RET_ERR_ONLY_ONCE;
|
||||||
strcpy(ret.retMsg, "configuration can only set once");
|
tstrncpy(ret.retMsg, "configuration can only set once", RET_MSG_LENGTH);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
taosInitGlobalCfg();
|
taosInitGlobalCfg();
|
||||||
cJSON *root = cJSON_Parse(config);
|
cJSON *root = cJSON_Parse(config);
|
||||||
if (root == NULL){
|
if (root == NULL){
|
||||||
ret.retCode = SET_CONF_RET_ERR_JSON_PARSE;
|
ret.retCode = SET_CONF_RET_ERR_JSON_PARSE;
|
||||||
strcpy(ret.retMsg, "parse json error");
|
tstrncpy(ret.retMsg, "parse json error", RET_MSG_LENGTH);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = cJSON_GetArraySize(root);
|
int size = cJSON_GetArraySize(root);
|
||||||
if(!cJSON_IsObject(root) || size == 0) {
|
if(!cJSON_IsObject(root) || size == 0) {
|
||||||
ret.retCode = SET_CONF_RET_ERR_JSON_INVALID;
|
ret.retCode = SET_CONF_RET_ERR_JSON_INVALID;
|
||||||
strcpy(ret.retMsg, "json content is invalid, must be not empty object");
|
tstrncpy(ret.retMsg, "json content is invalid, must be not empty object", RET_MSG_LENGTH);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(size >= 1000) {
|
if(size >= 1000) {
|
||||||
ret.retCode = SET_CONF_RET_ERR_TOO_LONG;
|
ret.retCode = SET_CONF_RET_ERR_TOO_LONG;
|
||||||
strcpy(ret.retMsg, "json object size is too long");
|
tstrncpy(ret.retMsg, "json object size is too long", RET_MSG_LENGTH);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1160,7 +1156,7 @@ static setConfRet taos_set_config_imp(const char *config){
|
||||||
cJSON *item = cJSON_GetArrayItem(root, i);
|
cJSON *item = cJSON_GetArrayItem(root, i);
|
||||||
if(!item) {
|
if(!item) {
|
||||||
ret.retCode = SET_CONF_RET_ERR_INNER;
|
ret.retCode = SET_CONF_RET_ERR_INNER;
|
||||||
strcpy(ret.retMsg, "inner error");
|
tstrncpy(ret.retMsg, "inner error", RET_MSG_LENGTH);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if(!taosReadConfigOption(item->string, item->valuestring, NULL, NULL, TAOS_CFG_CSTATUS_OPTION, TSDB_CFG_CTYPE_B_CLIENT)){
|
if(!taosReadConfigOption(item->string, item->valuestring, NULL, NULL, TAOS_CFG_CSTATUS_OPTION, TSDB_CFG_CTYPE_B_CLIENT)){
|
||||||
|
|
|
@ -55,7 +55,7 @@ static int32_t hbProcessUserAuthInfoRsp(void *value, int32_t valueLen, struct SC
|
||||||
for (int32_t i = 0; i < numOfBatchs; ++i) {
|
for (int32_t i = 0; i < numOfBatchs; ++i) {
|
||||||
SGetUserAuthRsp *rsp = taosArrayGet(batchRsp.pArray, i);
|
SGetUserAuthRsp *rsp = taosArrayGet(batchRsp.pArray, i);
|
||||||
if (NULL == rsp) {
|
if (NULL == rsp) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
tscDebug("hb to update user auth, user:%s, version:%d", rsp->user, rsp->version);
|
tscDebug("hb to update user auth, user:%s, version:%d", rsp->user, rsp->version);
|
||||||
|
@ -217,7 +217,7 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
||||||
for (int32_t i = 0; i < numOfBatchs; ++i) {
|
for (int32_t i = 0; i < numOfBatchs; ++i) {
|
||||||
SDbHbRsp *rsp = taosArrayGet(batchRsp.pArray, i);
|
SDbHbRsp *rsp = taosArrayGet(batchRsp.pArray, i);
|
||||||
if (NULL == rsp) {
|
if (NULL == rsp) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
if (rsp->useDbRsp) {
|
if (rsp->useDbRsp) {
|
||||||
|
@ -291,7 +291,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
|
||||||
for (int32_t i = 0; i < numOfMeta; ++i) {
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
STableMetaRsp *rsp = taosArrayGet(hbRsp.pMetaRsp, i);
|
STableMetaRsp *rsp = taosArrayGet(hbRsp.pMetaRsp, i);
|
||||||
if (NULL == rsp) {
|
if (NULL == rsp) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
if (rsp->numOfColumns < 0) {
|
if (rsp->numOfColumns < 0) {
|
||||||
|
@ -313,7 +313,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
|
||||||
for (int32_t i = 0; i < numOfIndex; ++i) {
|
for (int32_t i = 0; i < numOfIndex; ++i) {
|
||||||
STableIndexRsp *rsp = taosArrayGet(hbRsp.pIndexRsp, i);
|
STableIndexRsp *rsp = taosArrayGet(hbRsp.pIndexRsp, i);
|
||||||
if (NULL == rsp) {
|
if (NULL == rsp) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
TSC_ERR_JRET(catalogUpdateTableIndex(pCatalog, rsp));
|
TSC_ERR_JRET(catalogUpdateTableIndex(pCatalog, rsp));
|
||||||
|
@ -354,7 +354,7 @@ static int32_t hbProcessViewInfoRsp(void *value, int32_t valueLen, struct SCatal
|
||||||
for (int32_t i = 0; i < numOfMeta; ++i) {
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
SViewMetaRsp *rsp = taosArrayGetP(hbRsp.pViewRsp, i);
|
SViewMetaRsp *rsp = taosArrayGetP(hbRsp.pViewRsp, i);
|
||||||
if (NULL == rsp) {
|
if (NULL == rsp) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
if (rsp->numOfCols < 0) {
|
if (rsp->numOfCols < 0) {
|
||||||
|
@ -772,7 +772,7 @@ static int32_t hbGetUserAuthInfo(SClientHbKey *connKey, SHbParam *param, SClient
|
||||||
SUserAuthVersion *qUserAuth =
|
SUserAuthVersion *qUserAuth =
|
||||||
(SUserAuthVersion *)taosMemoryRealloc(pKv->value, (userNum + 1) * sizeof(SUserAuthVersion));
|
(SUserAuthVersion *)taosMemoryRealloc(pKv->value, (userNum + 1) * sizeof(SUserAuthVersion));
|
||||||
if (qUserAuth) {
|
if (qUserAuth) {
|
||||||
(void)strncpy((qUserAuth + userNum)->user, pTscObj->user, TSDB_USER_LEN);
|
tstrncpy((qUserAuth + userNum)->user, pTscObj->user, TSDB_USER_LEN);
|
||||||
(qUserAuth + userNum)->version = htonl(-1); // force get userAuthInfo
|
(qUserAuth + userNum)->version = htonl(-1); // force get userAuthInfo
|
||||||
pKv->value = qUserAuth;
|
pKv->value = qUserAuth;
|
||||||
pKv->valueLen += sizeof(SUserAuthVersion);
|
pKv->valueLen += sizeof(SUserAuthVersion);
|
||||||
|
|
|
@ -949,7 +949,7 @@ int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog,
|
||||||
for (int32_t i = 0; i < tbNum; ++i) {
|
for (int32_t i = 0; i < tbNum; ++i) {
|
||||||
STbVerInfo* tbInfo = taosArrayGet(pTbArray, i);
|
STbVerInfo* tbInfo = taosArrayGet(pTbArray, i);
|
||||||
if (NULL == tbInfo) {
|
if (NULL == tbInfo) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
STbSVersion tbSver = {.tbFName = tbInfo->tbFName, .sver = tbInfo->sversion, .tver = tbInfo->tversion};
|
STbSVersion tbSver = {.tbFName = tbInfo->tbFName, .sver = tbInfo->sversion, .tver = tbInfo->tversion};
|
||||||
|
@ -1921,19 +1921,19 @@ TAOS* taos_connect_auth(const char* ip, const char* user, const char* auth, cons
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, const char* pass, int passLen,
|
//TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, const char* pass, int passLen,
|
||||||
const char* db, int dbLen, uint16_t port) {
|
// const char* db, int dbLen, uint16_t port) {
|
||||||
char ipStr[TSDB_EP_LEN] = {0};
|
// char ipStr[TSDB_EP_LEN] = {0};
|
||||||
char dbStr[TSDB_DB_NAME_LEN] = {0};
|
// char dbStr[TSDB_DB_NAME_LEN] = {0};
|
||||||
char userStr[TSDB_USER_LEN] = {0};
|
// char userStr[TSDB_USER_LEN] = {0};
|
||||||
char passStr[TSDB_PASSWORD_LEN] = {0};
|
// char passStr[TSDB_PASSWORD_LEN] = {0};
|
||||||
|
//
|
||||||
(void)strncpy(ipStr, ip, TMIN(TSDB_EP_LEN - 1, ipLen));
|
// tstrncpy(ipStr, ip, TMIN(TSDB_EP_LEN - 1, ipLen));
|
||||||
(void)strncpy(userStr, user, TMIN(TSDB_USER_LEN - 1, userLen));
|
// tstrncpy(userStr, user, TMIN(TSDB_USER_LEN - 1, userLen));
|
||||||
(void)strncpy(passStr, pass, TMIN(TSDB_PASSWORD_LEN - 1, passLen));
|
// tstrncpy(passStr, pass, TMIN(TSDB_PASSWORD_LEN - 1, passLen));
|
||||||
(void)strncpy(dbStr, db, TMIN(TSDB_DB_NAME_LEN - 1, dbLen));
|
// tstrncpy(dbStr, db, TMIN(TSDB_DB_NAME_LEN - 1, dbLen));
|
||||||
return taos_connect(ipStr, userStr, passStr, dbStr, port);
|
// return taos_connect(ipStr, userStr, passStr, dbStr, port);
|
||||||
}
|
//}
|
||||||
|
|
||||||
void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
|
void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
|
||||||
for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
||||||
|
@ -2275,7 +2275,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
char* jsonInnerData = data + CHAR_BYTES;
|
char* jsonInnerData = data + CHAR_BYTES;
|
||||||
char dst[TSDB_MAX_JSON_TAG_LEN] = {0};
|
char dst[TSDB_MAX_JSON_TAG_LEN] = {0};
|
||||||
if (jsonInnerType == TSDB_DATA_TYPE_NULL) {
|
if (jsonInnerType == TSDB_DATA_TYPE_NULL) {
|
||||||
(void)sprintf(varDataVal(dst), "%s", TSDB_DATA_NULL_STR_L);
|
(void)snprintf(varDataVal(dst), TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE, "%s", TSDB_DATA_NULL_STR_L);
|
||||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||||
} else if (tTagIsJson(data)) {
|
} else if (tTagIsJson(data)) {
|
||||||
char* jsonString = NULL;
|
char* jsonString = NULL;
|
||||||
|
@ -2298,10 +2298,10 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
*(char*)POINTER_SHIFT(varDataVal(dst), length + CHAR_BYTES) = '\"';
|
*(char*)POINTER_SHIFT(varDataVal(dst), length + CHAR_BYTES) = '\"';
|
||||||
} else if (jsonInnerType == TSDB_DATA_TYPE_DOUBLE) {
|
} else if (jsonInnerType == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
double jsonVd = *(double*)(jsonInnerData);
|
double jsonVd = *(double*)(jsonInnerData);
|
||||||
(void)sprintf(varDataVal(dst), "%.9lf", jsonVd);
|
(void)snprintf(varDataVal(dst), TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE, "%.9lf", jsonVd);
|
||||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||||
} else if (jsonInnerType == TSDB_DATA_TYPE_BOOL) {
|
} else if (jsonInnerType == TSDB_DATA_TYPE_BOOL) {
|
||||||
(void)sprintf(varDataVal(dst), "%s", (*((char*)jsonInnerData) == 1) ? "true" : "false");
|
(void)snprintf(varDataVal(dst), TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE, "%s", (*((char*)jsonInnerData) == 1) ? "true" : "false");
|
||||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||||
} else {
|
} else {
|
||||||
tscError("doConvertJson error: invalid type:%d", jsonInnerType);
|
tscError("doConvertJson error: invalid type:%d", jsonInnerType);
|
||||||
|
@ -2658,8 +2658,8 @@ int32_t appendTbToReq(SHashObj* pHash, int32_t pos1, int32_t len1, int32_t pos2,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||||
(void)sprintf(dbFName, "%d.%.*s", acctId, dbLen, dbName);
|
(void)snprintf(dbFName, TSDB_DB_FNAME_LEN, "%d.%.*s", acctId, dbLen, dbName);
|
||||||
|
|
||||||
STablesReq* pDb = taosHashGet(pHash, dbFName, strlen(dbFName));
|
STablesReq* pDb = taosHashGet(pHash, dbFName, strlen(dbFName));
|
||||||
if (pDb) {
|
if (pDb) {
|
||||||
|
@ -2672,7 +2672,7 @@ int32_t appendTbToReq(SHashObj* pHash, int32_t pos1, int32_t len1, int32_t pos2,
|
||||||
if (NULL == db.pTables) {
|
if (NULL == db.pTables) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
(void)strcpy(db.dbFName, dbFName);
|
tstrncpy(db.dbFName, dbFName, TSDB_DB_FNAME_LEN);
|
||||||
if (NULL == taosArrayPush(db.pTables, &name)) {
|
if (NULL == taosArrayPush(db.pTables, &name)) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1083,14 +1083,14 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_stmtErrorMsgIm
|
||||||
TAOS *tscon = (TAOS *)con;
|
TAOS *tscon = (TAOS *)con;
|
||||||
if (tscon == NULL) {
|
if (tscon == NULL) {
|
||||||
jniError("jobj:%p, connection already closed", jobj);
|
jniError("jobj:%p, connection already closed", jobj);
|
||||||
(void)sprintf(errMsg, "jobj:%p, connection already closed", jobj);
|
(void)snprintf(errMsg, sizeof(errMsg), "jobj:%p, connection already closed", jobj);
|
||||||
return (*env)->NewStringUTF(env, errMsg);
|
return (*env)->NewStringUTF(env, errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_STMT *pStmt = (TAOS_STMT *)stmt;
|
TAOS_STMT *pStmt = (TAOS_STMT *)stmt;
|
||||||
if (pStmt == NULL) {
|
if (pStmt == NULL) {
|
||||||
jniError("jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
jniError("jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
||||||
(void)sprintf(errMsg, "jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
(void)snprintf(errMsg, sizeof(errMsg), "jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
||||||
return (*env)->NewStringUTF(env, errMsg);
|
return (*env)->NewStringUTF(env, errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -373,25 +373,22 @@ void taos_free_result(TAOS_RES *res) {
|
||||||
SRequestObj *pRequest = (SRequestObj *)res;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
tscDebug("0x%" PRIx64 " taos_free_result start to free query", pRequest->requestId);
|
tscDebug("0x%" PRIx64 " taos_free_result start to free query", pRequest->requestId);
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
return;
|
||||||
SMqTaosxRspObj *pRsp = (SMqTaosxRspObj *)res;
|
|
||||||
tDeleteSTaosxRsp(&pRsp->rsp);
|
|
||||||
doFreeReqResultInfo(&pRsp->common.resInfo);
|
|
||||||
taosMemoryFree(pRsp);
|
|
||||||
} else if (TD_RES_TMQ(res)) {
|
|
||||||
SMqRspObj *pRsp = (SMqRspObj *)res;
|
|
||||||
tDeleteMqDataRsp(&pRsp->rsp);
|
|
||||||
doFreeReqResultInfo(&pRsp->common.resInfo);
|
|
||||||
taosMemoryFree(pRsp);
|
|
||||||
} else if (TD_RES_TMQ_META(res)) {
|
|
||||||
SMqMetaRspObj *pRspObj = (SMqMetaRspObj *)res;
|
|
||||||
tDeleteMqMetaRsp(&pRspObj->metaRsp);
|
|
||||||
taosMemoryFree(pRspObj);
|
|
||||||
} else if (TD_RES_TMQ_BATCH_META(res)) {
|
|
||||||
SMqBatchMetaRspObj *pBtRspObj = (SMqBatchMetaRspObj *)res;
|
|
||||||
tDeleteMqBatchMetaRsp(&pBtRspObj->rsp);
|
|
||||||
taosMemoryFree(pBtRspObj);
|
|
||||||
}
|
}
|
||||||
|
SMqRspObj *pRsp = (SMqRspObj *)res;
|
||||||
|
if (TD_RES_TMQ(res)) {
|
||||||
|
tDeleteMqDataRsp(&pRsp->dataRsp);
|
||||||
|
doFreeReqResultInfo(&pRsp->resInfo);
|
||||||
|
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||||
|
tDeleteSTaosxRsp(&pRsp->dataRsp);
|
||||||
|
doFreeReqResultInfo(&pRsp->resInfo);
|
||||||
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
|
tDeleteMqMetaRsp(&pRsp->metaRsp);
|
||||||
|
} else if (TD_RES_TMQ_BATCH_META(res)) {
|
||||||
|
tDeleteMqBatchMetaRsp(&pRsp->batchMetaRsp);
|
||||||
|
}
|
||||||
|
taosMemoryFree(pRsp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_kill_query(TAOS *taos) {
|
void taos_kill_query(TAOS *taos) {
|
||||||
|
@ -454,7 +451,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
||||||
} else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
} else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqRspObj *msg = ((SMqRspObj *)res);
|
SMqRspObj *msg = ((SMqRspObj *)res);
|
||||||
SReqResultInfo *pResultInfo = NULL;
|
SReqResultInfo *pResultInfo = NULL;
|
||||||
if (msg->common.resIter == -1) {
|
if (msg->resIter == -1) {
|
||||||
if (tmqGetNextResInfo(res, true, &pResultInfo) != 0) {
|
if (tmqGetNextResInfo(res, true, &pResultInfo) != 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -485,71 +482,75 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
||||||
|
return taos_print_row_with_size(str, INT32_MAX, row, fields, num_fields);
|
||||||
|
}
|
||||||
|
int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields){
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
for (int i = 0; i < num_fields; ++i) {
|
for (int i = 0; i < num_fields; ++i) {
|
||||||
if (i > 0) {
|
if (i > 0 && len < size - 1) {
|
||||||
str[len++] = ' ';
|
str[len++] = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row[i] == NULL) {
|
if (row[i] == NULL) {
|
||||||
len += sprintf(str + len, "%s", TSDB_DATA_NULL_STR);
|
len += snprintf(str + len, size - len, "%s", TSDB_DATA_NULL_STR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (fields[i].type) {
|
switch (fields[i].type) {
|
||||||
case TSDB_DATA_TYPE_TINYINT:
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
len += sprintf(str + len, "%d", *((int8_t *)row[i]));
|
len += snprintf(str + len, size - len, "%d", *((int8_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_UTINYINT:
|
case TSDB_DATA_TYPE_UTINYINT:
|
||||||
len += sprintf(str + len, "%u", *((uint8_t *)row[i]));
|
len += snprintf(str + len, size - len, "%u", *((uint8_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_SMALLINT:
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
len += sprintf(str + len, "%d", *((int16_t *)row[i]));
|
len += snprintf(str + len, size - len, "%d", *((int16_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_USMALLINT:
|
case TSDB_DATA_TYPE_USMALLINT:
|
||||||
len += sprintf(str + len, "%u", *((uint16_t *)row[i]));
|
len += snprintf(str + len, size - len, "%u", *((uint16_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_INT:
|
case TSDB_DATA_TYPE_INT:
|
||||||
len += sprintf(str + len, "%d", *((int32_t *)row[i]));
|
len += snprintf(str + len, size - len, "%d", *((int32_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_UINT:
|
case TSDB_DATA_TYPE_UINT:
|
||||||
len += sprintf(str + len, "%u", *((uint32_t *)row[i]));
|
len += snprintf(str + len, size - len, "%u", *((uint32_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i]));
|
len += snprintf(str + len, size - len, "%" PRId64, *((int64_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_UBIGINT:
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
len += sprintf(str + len, "%" PRIu64, *((uint64_t *)row[i]));
|
len += snprintf(str + len, size - len, "%" PRIu64, *((uint64_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
case TSDB_DATA_TYPE_FLOAT: {
|
||||||
float fv = 0;
|
float fv = 0;
|
||||||
fv = GET_FLOAT_VAL(row[i]);
|
fv = GET_FLOAT_VAL(row[i]);
|
||||||
len += sprintf(str + len, "%f", fv);
|
len += snprintf(str + len, size - len, "%f", fv);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
double dv = 0;
|
double dv = 0;
|
||||||
dv = GET_DOUBLE_VAL(row[i]);
|
dv = GET_DOUBLE_VAL(row[i]);
|
||||||
len += sprintf(str + len, "%lf", dv);
|
len += snprintf(str + len, size - len, "%lf", dv);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_VARBINARY: {
|
case TSDB_DATA_TYPE_VARBINARY: {
|
||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
uint32_t size = 0;
|
uint32_t tmp = 0;
|
||||||
int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE);
|
int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE);
|
||||||
if (taosAscii2Hex(row[i], charLen, &data, &size) < 0) {
|
if (taosAscii2Hex(row[i], charLen, &data, &tmp) < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(void)memcpy(str + len, data, size);
|
uint32_t copyLen = TMIN(size - len - 1, tmp);
|
||||||
len += size;
|
(void)memcpy(str + len, data, copyLen);
|
||||||
|
len += copyLen;
|
||||||
taosMemoryFree(data);
|
taosMemoryFree(data);
|
||||||
} break;
|
} break;
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
|
@ -569,21 +570,28 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)memcpy(str + len, row[i], charLen);
|
uint32_t copyLen = TMIN(size - len - 1, charLen);
|
||||||
len += charLen;
|
(void)memcpy(str + len, row[i], copyLen);
|
||||||
|
len += copyLen;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i]));
|
len += snprintf(str + len, size - len, "%" PRId64, *((int64_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
len += sprintf(str + len, "%d", *((int8_t *)row[i]));
|
len += snprintf(str + len, size - len, "%d", *((int8_t *)row[i]));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (len >= size - 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (len < size){
|
||||||
|
str[len] = 0;
|
||||||
}
|
}
|
||||||
str[len] = 0;
|
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
@ -948,7 +956,7 @@ int taos_get_current_db(TAOS *taos, char *database, int len, int *required) {
|
||||||
if (required) *required = strlen(pTscObj->db) + 1;
|
if (required) *required = strlen(pTscObj->db) + 1;
|
||||||
TSC_ERR_JRET(TSDB_CODE_INVALID_PARA);
|
TSC_ERR_JRET(TSDB_CODE_INVALID_PARA);
|
||||||
} else {
|
} else {
|
||||||
(void)strcpy(database, pTscObj->db);
|
tstrncpy(database, pTscObj->db, len);
|
||||||
code = 0;
|
code = 0;
|
||||||
}
|
}
|
||||||
_return:
|
_return:
|
||||||
|
|
|
@ -21,7 +21,7 @@ char tmpSlowLogPath[PATH_MAX] = {0};
|
||||||
TdThread monitorThread;
|
TdThread monitorThread;
|
||||||
|
|
||||||
static int32_t getSlowLogTmpDir(char* tmpPath, int32_t size) {
|
static int32_t getSlowLogTmpDir(char* tmpPath, int32_t size) {
|
||||||
int ret = snprintf(tmpPath, size, "%s/tdengine_slow_log/", tsTempDir);
|
int ret = tsnprintf(tmpPath, size, "%s/tdengine_slow_log/", tsTempDir);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tscError("failed to get tmp path ret:%d", ret);
|
tscError("failed to get tmp path ret:%d", ret);
|
||||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
@ -183,7 +183,7 @@ FAILED:
|
||||||
|
|
||||||
static void generateClusterReport(taos_collector_registry_t* registry, void* pTransporter, SEpSet* epSet) {
|
static void generateClusterReport(taos_collector_registry_t* registry, void* pTransporter, SEpSet* epSet) {
|
||||||
char ts[50] = {0};
|
char ts[50] = {0};
|
||||||
(void)sprintf(ts, "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI));
|
(void)snprintf(ts, sizeof(ts), "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI));
|
||||||
char* pCont = (char*)taos_collector_registry_bridge_new(registry, ts, "%" PRId64, NULL);
|
char* pCont = (char*)taos_collector_registry_bridge_new(registry, ts, "%" PRId64, NULL);
|
||||||
if (NULL == pCont) {
|
if (NULL == pCont) {
|
||||||
tscError("generateClusterReport failed, get null content.");
|
tscError("generateClusterReport failed, get null content.");
|
||||||
|
@ -401,7 +401,7 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pClient->lastCheckTime = taosGetMonoTimestampMs();
|
pClient->lastCheckTime = taosGetMonoTimestampMs();
|
||||||
(void)strcpy(pClient->path, path);
|
tstrncpy(pClient->path, path, PATH_MAX);
|
||||||
pClient->offset = 0;
|
pClient->offset = 0;
|
||||||
pClient->pFile = pFile;
|
pClient->pFile = pFile;
|
||||||
if (taosHashPut(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES, &pClient, POINTER_BYTES) != 0) {
|
if (taosHashPut(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES, &pClient, POINTER_BYTES) != 0) {
|
||||||
|
@ -458,7 +458,7 @@ static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
char* buf = pCont;
|
char* buf = pCont;
|
||||||
(void)strcat(buf++, "[");
|
(void)strncat(buf++, "[", totalSize - 1);
|
||||||
int64_t readSize = taosReadFile(pFile, buf, totalSize - 4); // 4 reserved for []
|
int64_t readSize = taosReadFile(pFile, buf, totalSize - 4); // 4 reserved for []
|
||||||
if (readSize <= 0) {
|
if (readSize <= 0) {
|
||||||
if (readSize < 0) {
|
if (readSize < 0) {
|
||||||
|
|
|
@ -458,15 +458,17 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
||||||
cJSON* tvalue = NULL;
|
cJSON* tvalue = NULL;
|
||||||
if (IS_VAR_DATA_TYPE(pTagVal->type)) {
|
if (IS_VAR_DATA_TYPE(pTagVal->type)) {
|
||||||
char* buf = NULL;
|
char* buf = NULL;
|
||||||
|
int64_t bufSize = 0;
|
||||||
if (pTagVal->type == TSDB_DATA_TYPE_VARBINARY) {
|
if (pTagVal->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||||
buf = taosMemoryCalloc(pTagVal->nData * 2 + 2 + 3, 1);
|
bufSize = pTagVal->nData * 2 + 2 + 3;
|
||||||
} else {
|
} else {
|
||||||
buf = taosMemoryCalloc(pTagVal->nData + 3, 1);
|
bufSize = pTagVal->nData + 3;
|
||||||
}
|
}
|
||||||
|
buf = taosMemoryCalloc(bufSize, 1);
|
||||||
|
|
||||||
RAW_NULL_CHECK(buf);
|
RAW_NULL_CHECK(buf);
|
||||||
if (!buf) goto end;
|
if (!buf) goto end;
|
||||||
if (dataConverToStr(buf, pTagVal->type, pTagVal->pData, pTagVal->nData, NULL) != TSDB_CODE_SUCCESS) {
|
if (dataConverToStr(buf, bufSize, pTagVal->type, pTagVal->pData, pTagVal->nData, NULL) != TSDB_CODE_SUCCESS) {
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -548,7 +550,7 @@ end:
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void processAutoCreateTable(STaosxRsp* rsp, char** string) {
|
static void processAutoCreateTable(SMqDataRsp* rsp, char** string) {
|
||||||
SDecoder* decoder = NULL;
|
SDecoder* decoder = NULL;
|
||||||
SVCreateTbReq* pCreateReq = NULL;
|
SVCreateTbReq* pCreateReq = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -736,13 +738,15 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
int64_t bufSize = 0;
|
||||||
if (vAlterTbReq.tagType == TSDB_DATA_TYPE_VARBINARY) {
|
if (vAlterTbReq.tagType == TSDB_DATA_TYPE_VARBINARY) {
|
||||||
buf = taosMemoryCalloc(vAlterTbReq.nTagVal * 2 + 2 + 3, 1);
|
bufSize = vAlterTbReq.nTagVal * 2 + 2 + 3;
|
||||||
} else {
|
} else {
|
||||||
buf = taosMemoryCalloc(vAlterTbReq.nTagVal + 3, 1);
|
bufSize = vAlterTbReq.nTagVal + 3;
|
||||||
}
|
}
|
||||||
|
buf = taosMemoryCalloc(bufSize, 1);
|
||||||
RAW_NULL_CHECK(buf);
|
RAW_NULL_CHECK(buf);
|
||||||
if (dataConverToStr(buf, vAlterTbReq.tagType, vAlterTbReq.pTagVal, vAlterTbReq.nTagVal, NULL) !=
|
if (dataConverToStr(buf, bufSize, vAlterTbReq.tagType, vAlterTbReq.pTagVal, vAlterTbReq.nTagVal, NULL) !=
|
||||||
TSDB_CODE_SUCCESS) {
|
TSDB_CODE_SUCCESS) {
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -922,7 +926,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
for (int32_t i = 0; i < req.schemaRow.nCols; i++) {
|
for (int32_t i = 0; i < req.schemaRow.nCols; i++) {
|
||||||
SSchema* pSchema = req.schemaRow.pSchema + i;
|
SSchema* pSchema = req.schemaRow.pSchema + i;
|
||||||
SFieldWithOptions field = {.type = pSchema->type, .flags = pSchema->flags, .bytes = pSchema->bytes};
|
SFieldWithOptions field = {.type = pSchema->type, .flags = pSchema->flags, .bytes = pSchema->bytes};
|
||||||
(void)strcpy(field.name, pSchema->name);
|
tstrncpy(field.name, pSchema->name, TSDB_COL_NAME_LEN);
|
||||||
|
|
||||||
if (createDefaultCompress) {
|
if (createDefaultCompress) {
|
||||||
field.compress = createDefaultColCmprByType(pSchema->type);
|
field.compress = createDefaultColCmprByType(pSchema->type);
|
||||||
|
@ -937,7 +941,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
for (int32_t i = 0; i < req.schemaTag.nCols; i++) {
|
for (int32_t i = 0; i < req.schemaTag.nCols; i++) {
|
||||||
SSchema* pSchema = req.schemaTag.pSchema + i;
|
SSchema* pSchema = req.schemaTag.pSchema + i;
|
||||||
SField field = {.type = pSchema->type, .flags = pSchema->flags, .bytes = pSchema->bytes};
|
SField field = {.type = pSchema->type, .flags = pSchema->flags, .bytes = pSchema->bytes};
|
||||||
(void)strcpy(field.name, pSchema->name);
|
tstrncpy(field.name, pSchema->name, TSDB_COL_NAME_LEN);
|
||||||
RAW_NULL_CHECK(taosArrayPush(pReq.pTags, &field));
|
RAW_NULL_CHECK(taosArrayPush(pReq.pTags, &field));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1240,7 +1244,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
if (pTableBatch == NULL) {
|
if (pTableBatch == NULL) {
|
||||||
SVgroupCreateTableBatch tBatch = {0};
|
SVgroupCreateTableBatch tBatch = {0};
|
||||||
tBatch.info = pInfo;
|
tBatch.info = pInfo;
|
||||||
(void)strcpy(tBatch.dbName, pRequest->pDb);
|
tstrncpy(tBatch.dbName, pRequest->pDb, TSDB_DB_NAME_LEN);
|
||||||
|
|
||||||
tBatch.req.pArray = taosArrayInit(4, sizeof(struct SVCreateTbReq));
|
tBatch.req.pArray = taosArrayInit(4, sizeof(struct SVCreateTbReq));
|
||||||
RAW_NULL_CHECK(tBatch.req.pArray);
|
RAW_NULL_CHECK(tBatch.req.pArray);
|
||||||
|
@ -1721,8 +1725,8 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
|
|
||||||
uDebug(LOG_ID_TAG " write raw data, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
uDebug(LOG_ID_TAG " write raw data, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
||||||
pRequest->syncQuery = true;
|
pRequest->syncQuery = true;
|
||||||
rspObj.common.resIter = -1;
|
rspObj.resIter = -1;
|
||||||
rspObj.common.resType = RES_TYPE__TMQ;
|
rspObj.resType = RES_TYPE__TMQ;
|
||||||
|
|
||||||
int8_t dataVersion = *(int8_t*)data;
|
int8_t dataVersion = *(int8_t*)data;
|
||||||
if (dataVersion >= MQ_DATA_RSP_VERSION) {
|
if (dataVersion >= MQ_DATA_RSP_VERSION) {
|
||||||
|
@ -1730,7 +1734,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
dataLen -= sizeof(int8_t) + sizeof(int32_t);
|
dataLen -= sizeof(int8_t) + sizeof(int32_t);
|
||||||
}
|
}
|
||||||
tDecoderInit(&decoder, data, dataLen);
|
tDecoderInit(&decoder, data, dataLen);
|
||||||
code = tDecodeMqDataRsp(&decoder, &rspObj.rsp);
|
code = tDecodeMqDataRsp(&decoder, &rspObj.dataRsp);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
SET_ERROR_MSG("decode mq data rsp failed");
|
SET_ERROR_MSG("decode mq data rsp failed");
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -1754,19 +1758,19 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
RAW_RETURN_CHECK(smlInitHandle(&pQuery));
|
RAW_RETURN_CHECK(smlInitHandle(&pQuery));
|
||||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||||
RAW_NULL_CHECK(pVgHash);
|
RAW_NULL_CHECK(pVgHash);
|
||||||
while (++rspObj.common.resIter < rspObj.rsp.common.blockNum) {
|
while (++rspObj.resIter < rspObj.dataRsp.blockNum) {
|
||||||
void* pRetrieve = taosArrayGetP(rspObj.rsp.common.blockData, rspObj.common.resIter);
|
void* pRetrieve = taosArrayGetP(rspObj.dataRsp.blockData, rspObj.resIter);
|
||||||
RAW_NULL_CHECK(pRetrieve);
|
RAW_NULL_CHECK(pRetrieve);
|
||||||
if (!rspObj.rsp.common.withSchema) {
|
if (!rspObj.dataRsp.withSchema) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.common.blockTbName, rspObj.common.resIter);
|
const char* tbName = (const char*)taosArrayGetP(rspObj.dataRsp.blockTbName, rspObj.resIter);
|
||||||
RAW_NULL_CHECK(tbName);
|
RAW_NULL_CHECK(tbName);
|
||||||
|
|
||||||
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
||||||
(void)strcpy(pName.dbname, pRequest->pDb);
|
tstrncpy(pName.dbname, pRequest->pDb, TSDB_DB_NAME_LEN);
|
||||||
(void)strcpy(pName.tname, tbName);
|
tstrncpy(pName.tname, tbName, TSDB_TABLE_NAME_LEN);
|
||||||
|
|
||||||
RAW_RETURN_CHECK(catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta));
|
RAW_RETURN_CHECK(catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta));
|
||||||
|
|
||||||
|
@ -1778,7 +1782,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
RAW_RETURN_CHECK(taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)));
|
RAW_RETURN_CHECK(taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.common.blockSchema, rspObj.common.resIter);
|
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.dataRsp.blockSchema, rspObj.resIter);
|
||||||
RAW_NULL_CHECK(pSW);
|
RAW_NULL_CHECK(pSW);
|
||||||
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
||||||
RAW_NULL_CHECK(fields);
|
RAW_NULL_CHECK(fields);
|
||||||
|
@ -1805,7 +1809,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
|
|
||||||
end:
|
end:
|
||||||
uDebug(LOG_ID_TAG " write raw data return, msg:%s", LOG_ID_VALUE, tstrerror(code));
|
uDebug(LOG_ID_TAG " write raw data return, msg:%s", LOG_ID_VALUE, tstrerror(code));
|
||||||
tDeleteMqDataRsp(&rspObj.rsp);
|
tDeleteMqDataRsp(&rspObj.dataRsp);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
qDestroyQuery(pQuery);
|
qDestroyQuery(pQuery);
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
|
@ -1814,7 +1818,7 @@ end:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t buildCreateTbMap(STaosxRsp* rsp, SHashObj* pHashObj) {
|
static int32_t buildCreateTbMap(SMqDataRsp* rsp, SHashObj* pHashObj) {
|
||||||
// find schema data info
|
// find schema data info
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SVCreateTbReq pCreateReq = {0};
|
SVCreateTbReq pCreateReq = {0};
|
||||||
|
@ -1859,7 +1863,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SHashObj* pVgHash = NULL;
|
SHashObj* pVgHash = NULL;
|
||||||
SQuery* pQuery = NULL;
|
SQuery* pQuery = NULL;
|
||||||
SMqTaosxRspObj rspObj = {0};
|
SMqRspObj rspObj = {0};
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
STableMeta* pTableMeta = NULL;
|
STableMeta* pTableMeta = NULL;
|
||||||
SHashObj* pCreateTbHash = NULL;
|
SHashObj* pCreateTbHash = NULL;
|
||||||
|
@ -1869,8 +1873,8 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
|
|
||||||
uDebug(LOG_ID_TAG " write raw metadata, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
uDebug(LOG_ID_TAG " write raw metadata, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
||||||
pRequest->syncQuery = true;
|
pRequest->syncQuery = true;
|
||||||
rspObj.common.resIter = -1;
|
rspObj.resIter = -1;
|
||||||
rspObj.common.resType = RES_TYPE__TMQ_METADATA;
|
rspObj.resType = RES_TYPE__TMQ_METADATA;
|
||||||
|
|
||||||
int8_t dataVersion = *(int8_t*)data;
|
int8_t dataVersion = *(int8_t*)data;
|
||||||
if (dataVersion >= MQ_DATA_RSP_VERSION) {
|
if (dataVersion >= MQ_DATA_RSP_VERSION) {
|
||||||
|
@ -1879,7 +1883,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
}
|
}
|
||||||
|
|
||||||
tDecoderInit(&decoder, data, dataLen);
|
tDecoderInit(&decoder, data, dataLen);
|
||||||
code = tDecodeSTaosxRsp(&decoder, &rspObj.rsp);
|
code = tDecodeSTaosxRsp(&decoder, &rspObj.dataRsp);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
SET_ERROR_MSG("decode mq taosx data rsp failed");
|
SET_ERROR_MSG("decode mq taosx data rsp failed");
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -1905,34 +1909,34 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
RAW_NULL_CHECK(pVgHash);
|
RAW_NULL_CHECK(pVgHash);
|
||||||
pCreateTbHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
pCreateTbHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||||
RAW_NULL_CHECK(pCreateTbHash);
|
RAW_NULL_CHECK(pCreateTbHash);
|
||||||
RAW_RETURN_CHECK(buildCreateTbMap(&rspObj.rsp, pCreateTbHash));
|
RAW_RETURN_CHECK(buildCreateTbMap(&rspObj.dataRsp, pCreateTbHash));
|
||||||
|
|
||||||
uDebug(LOG_ID_TAG " write raw metadata block num:%d", LOG_ID_VALUE, rspObj.rsp.common.blockNum);
|
uDebug(LOG_ID_TAG " write raw metadata block num:%d", LOG_ID_VALUE, rspObj.dataRsp.blockNum);
|
||||||
while (++rspObj.common.resIter < rspObj.rsp.common.blockNum) {
|
while (++rspObj.resIter < rspObj.dataRsp.blockNum) {
|
||||||
void* pRetrieve = taosArrayGetP(rspObj.rsp.common.blockData, rspObj.common.resIter);
|
void* pRetrieve = taosArrayGetP(rspObj.dataRsp.blockData, rspObj.resIter);
|
||||||
RAW_NULL_CHECK(pRetrieve);
|
RAW_NULL_CHECK(pRetrieve);
|
||||||
if (!rspObj.rsp.common.withSchema) {
|
if (!rspObj.dataRsp.withSchema) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.common.blockTbName, rspObj.common.resIter);
|
const char* tbName = (const char*)taosArrayGetP(rspObj.dataRsp.blockTbName, rspObj.resIter);
|
||||||
if (!tbName) {
|
if (!tbName) {
|
||||||
SET_ERROR_MSG("block tbname is null");
|
SET_ERROR_MSG("block tbname is null");
|
||||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
code = terrno;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
uDebug(LOG_ID_TAG " write raw metadata block tbname:%s", LOG_ID_VALUE, tbName);
|
uDebug(LOG_ID_TAG " write raw metadata block tbname:%s", LOG_ID_VALUE, tbName);
|
||||||
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
||||||
(void)strcpy(pName.dbname, pRequest->pDb);
|
tstrncpy(pName.dbname, pRequest->pDb, TSDB_DB_NAME_LEN);
|
||||||
(void)strcpy(pName.tname, tbName);
|
tstrncpy(pName.tname, tbName, TSDB_TABLE_NAME_LEN);
|
||||||
|
|
||||||
// find schema data info
|
// find schema data info
|
||||||
SVCreateTbReq* pCreateReqDst = (SVCreateTbReq*)taosHashGet(pCreateTbHash, tbName, strlen(tbName));
|
SVCreateTbReq* pCreateReqDst = (SVCreateTbReq*)taosHashGet(pCreateTbHash, tbName, strlen(tbName));
|
||||||
SVgroupInfo vg = {0};
|
SVgroupInfo vg = {0};
|
||||||
RAW_RETURN_CHECK(catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg));
|
RAW_RETURN_CHECK(catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg));
|
||||||
if (pCreateReqDst) { // change stable name to get meta
|
if (pCreateReqDst) { // change stable name to get meta
|
||||||
(void)strcpy(pName.tname, pCreateReqDst->ctb.stbName);
|
tstrncpy(pName.tname, pCreateReqDst->ctb.stbName, TSDB_TABLE_NAME_LEN);
|
||||||
}
|
}
|
||||||
RAW_RETURN_CHECK(catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta));
|
RAW_RETURN_CHECK(catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta));
|
||||||
|
|
||||||
|
@ -1946,7 +1950,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
RAW_RETURN_CHECK(taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)));
|
RAW_RETURN_CHECK(taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.common.blockSchema, rspObj.common.resIter);
|
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.dataRsp.blockSchema, rspObj.resIter);
|
||||||
RAW_NULL_CHECK(pSW);
|
RAW_NULL_CHECK(pSW);
|
||||||
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
||||||
if (fields == NULL) {
|
if (fields == NULL) {
|
||||||
|
@ -1991,7 +1995,7 @@ end:
|
||||||
pIter = taosHashIterate(pCreateTbHash, pIter);
|
pIter = taosHashIterate(pCreateTbHash, pIter);
|
||||||
}
|
}
|
||||||
taosHashCleanup(pCreateTbHash);
|
taosHashCleanup(pCreateTbHash);
|
||||||
tDeleteSTaosxRsp(&rspObj.rsp);
|
tDeleteSTaosxRsp(&rspObj.dataRsp);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
qDestroyQuery(pQuery);
|
qDestroyQuery(pQuery);
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
|
@ -2072,31 +2076,28 @@ char* tmq_get_json_meta(TAOS_RES* res) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* string = NULL;
|
||||||
|
SMqRspObj* rspObj = (SMqRspObj*)res;
|
||||||
if (TD_RES_TMQ_METADATA(res)) {
|
if (TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqTaosxRspObj* pMetaDataRspObj = (SMqTaosxRspObj*)res;
|
processAutoCreateTable(&rspObj->dataRsp, &string);
|
||||||
char* string = NULL;
|
|
||||||
processAutoCreateTable(&pMetaDataRspObj->rsp, &string);
|
|
||||||
return string;
|
|
||||||
} else if (TD_RES_TMQ_BATCH_META(res)) {
|
} else if (TD_RES_TMQ_BATCH_META(res)) {
|
||||||
SMqBatchMetaRspObj* pBatchMetaRspObj = (SMqBatchMetaRspObj*)res;
|
processBatchMetaToJson(&rspObj->batchMetaRsp, &string);
|
||||||
char* string = NULL;
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
processBatchMetaToJson(&pBatchMetaRspObj->rsp, &string);
|
cJSON* pJson = NULL;
|
||||||
return string;
|
processSimpleMeta(&rspObj->metaRsp, &pJson);
|
||||||
|
string = cJSON_PrintUnformatted(pJson);
|
||||||
|
cJSON_Delete(pJson);
|
||||||
|
} else{
|
||||||
|
uError("tmq_get_json_meta res:%d, invalid type", *(int8_t*)res);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
|
||||||
cJSON* pJson = NULL;
|
|
||||||
processSimpleMeta(&pMetaRspObj->metaRsp, &pJson);
|
|
||||||
char* string = cJSON_PrintUnformatted(pJson);
|
|
||||||
cJSON_Delete(pJson);
|
|
||||||
uDebug("tmq_get_json_meta string:%s", string);
|
uDebug("tmq_get_json_meta string:%s", string);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmq_free_json_meta(char* jsonMeta) { taosMemoryFreeClear(jsonMeta); }
|
void tmq_free_json_meta(char* jsonMeta) { taosMemoryFreeClear(jsonMeta); }
|
||||||
|
|
||||||
static int32_t getOffSetLen(const void* rsp) {
|
static int32_t getOffSetLen(const SMqDataRsp* pRsp) {
|
||||||
const SMqDataRspCommon* pRsp = rsp;
|
|
||||||
SEncoder coder = {0};
|
SEncoder coder = {0};
|
||||||
tEncoderInit(&coder, NULL, 0);
|
tEncoderInit(&coder, NULL, 0);
|
||||||
if (tEncodeSTqOffsetVal(&coder, &pRsp->reqOffset) < 0) return -1;
|
if (tEncodeSTqOffsetVal(&coder, &pRsp->reqOffset) < 0) return -1;
|
||||||
|
@ -2106,9 +2107,8 @@ static int32_t getOffSetLen(const void* rsp) {
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef int32_t __encode_func__(SEncoder* pEncoder, const void* pRsp);
|
typedef int32_t __encode_func__(SEncoder* pEncoder, const SMqDataRsp* pRsp);
|
||||||
|
static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, SMqDataRsp* rspObj, tmq_raw_data* raw) {
|
||||||
static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, void* rspObj, tmq_raw_data* raw) {
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
|
@ -2157,15 +2157,14 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) {
|
||||||
if (!raw || !res) {
|
if (!raw || !res) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
SMqRspObj* rspObj = ((SMqRspObj*)res);
|
||||||
if (TD_RES_TMQ_META(res)) {
|
if (TD_RES_TMQ_META(res)) {
|
||||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
raw->raw = rspObj->metaRsp.metaRsp;
|
||||||
raw->raw = pMetaRspObj->metaRsp.metaRsp;
|
raw->raw_len = rspObj->metaRsp.metaRspLen;
|
||||||
raw->raw_len = pMetaRspObj->metaRsp.metaRspLen;
|
raw->raw_type = rspObj->metaRsp.resMsgType;
|
||||||
raw->raw_type = pMetaRspObj->metaRsp.resMsgType;
|
|
||||||
uDebug("tmq get raw type meta:%p", raw);
|
uDebug("tmq get raw type meta:%p", raw);
|
||||||
} else if (TD_RES_TMQ(res)) {
|
} else if (TD_RES_TMQ(res)) {
|
||||||
SMqRspObj* rspObj = ((SMqRspObj*)res);
|
int32_t code = encodeMqDataRsp(tEncodeMqDataRsp, &rspObj->dataRsp, raw);
|
||||||
int32_t code = encodeMqDataRsp(tEncodeMqDataRsp, &rspObj->rsp, raw);
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
uError("tmq get raw type error:%d", terrno);
|
uError("tmq get raw type error:%d", terrno);
|
||||||
return code;
|
return code;
|
||||||
|
@ -2173,9 +2172,7 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) {
|
||||||
raw->raw_type = RES_TYPE__TMQ;
|
raw->raw_type = RES_TYPE__TMQ;
|
||||||
uDebug("tmq get raw type data:%p", raw);
|
uDebug("tmq get raw type data:%p", raw);
|
||||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqTaosxRspObj* rspObj = ((SMqTaosxRspObj*)res);
|
int32_t code = encodeMqDataRsp(tEncodeSTaosxRsp, &rspObj->dataRsp, raw);
|
||||||
|
|
||||||
int32_t code = encodeMqDataRsp(tEncodeSTaosxRsp, &rspObj->rsp, raw);
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
uError("tmq get raw type error:%d", terrno);
|
uError("tmq get raw type error:%d", terrno);
|
||||||
return code;
|
return code;
|
||||||
|
@ -2183,10 +2180,9 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) {
|
||||||
raw->raw_type = RES_TYPE__TMQ_METADATA;
|
raw->raw_type = RES_TYPE__TMQ_METADATA;
|
||||||
uDebug("tmq get raw type metadata:%p", raw);
|
uDebug("tmq get raw type metadata:%p", raw);
|
||||||
} else if (TD_RES_TMQ_BATCH_META(res)) {
|
} else if (TD_RES_TMQ_BATCH_META(res)) {
|
||||||
SMqBatchMetaRspObj* pBtMetaRspObj = (SMqBatchMetaRspObj*)res;
|
raw->raw = rspObj->batchMetaRsp.pMetaBuff;
|
||||||
raw->raw = pBtMetaRspObj->rsp.pMetaBuff;
|
raw->raw_len = rspObj->batchMetaRsp.metaBuffLen;
|
||||||
raw->raw_len = pBtMetaRspObj->rsp.metaBuffLen;
|
raw->raw_type = rspObj->resType;
|
||||||
raw->raw_type = RES_TYPE__TMQ_BATCH_META;
|
|
||||||
uDebug("tmq get raw batch meta:%p", raw);
|
uDebug("tmq get raw batch meta:%p", raw);
|
||||||
} else {
|
} else {
|
||||||
uError("tmq get raw error type:%d", *(int8_t*)res);
|
uError("tmq get raw error type:%d", *(int8_t*)res);
|
||||||
|
|
|
@ -137,7 +137,7 @@ void smlBuildInvalidDataMsg(SSmlMsgBuf *pBuf, const char *msg1, const char *msg2
|
||||||
}
|
}
|
||||||
(void)memset(pBuf->buf, 0, pBuf->len);
|
(void)memset(pBuf->buf, 0, pBuf->len);
|
||||||
if (msg1) {
|
if (msg1) {
|
||||||
(void)strncat(pBuf->buf, msg1, pBuf->len);
|
(void)strncat(pBuf->buf, msg1, pBuf->len - 1);
|
||||||
}
|
}
|
||||||
int32_t left = pBuf->len - strlen(pBuf->buf);
|
int32_t left = pBuf->len - strlen(pBuf->buf);
|
||||||
if (left > 2 && msg2) {
|
if (left > 2 && msg2) {
|
||||||
|
@ -393,7 +393,7 @@ int32_t smlProcessChildTable(SSmlHandle *info, SSmlLineInfo *elements) {
|
||||||
tinfo->tags = taosArrayDup(info->preLineTagKV, NULL);
|
tinfo->tags = taosArrayDup(info->preLineTagKV, NULL);
|
||||||
if (tinfo->tags == NULL) {
|
if (tinfo->tags == NULL) {
|
||||||
smlDestroyTableInfo(&tinfo);
|
smlDestroyTableInfo(&tinfo);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < taosArrayGetSize(info->preLineTagKV); i++) {
|
for (size_t i = 0; i < taosArrayGetSize(info->preLineTagKV); i++) {
|
||||||
SSmlKv *kv = (SSmlKv *)taosArrayGet(info->preLineTagKV, i);
|
SSmlKv *kv = (SSmlKv *)taosArrayGet(info->preLineTagKV, i);
|
||||||
|
@ -516,9 +516,9 @@ static int32_t smlParseTableName(SArray *tags, char *childTableName, char *tbnam
|
||||||
if (tag == NULL) {
|
if (tag == NULL) {
|
||||||
return TSDB_CODE_SML_INVALID_DATA;
|
return TSDB_CODE_SML_INVALID_DATA;
|
||||||
}
|
}
|
||||||
(void)strncat(childTableName, tag->value, tag->length);
|
(void)strncat(childTableName, tag->value, TMIN(tag->length, TSDB_TABLE_NAME_LEN - 1 - strlen(childTableName)));
|
||||||
if (i != taosArrayGetSize(tags) - 1) {
|
if (i != taosArrayGetSize(tags) - 1) {
|
||||||
(void)strcat(childTableName, tsSmlAutoChildTableNameDelimiter);
|
(void)strncat(childTableName, tsSmlAutoChildTableNameDelimiter, TSDB_TABLE_NAME_LEN - 1 - strlen(childTableName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tsSmlDot2Underline) {
|
if (tsSmlDot2Underline) {
|
||||||
|
@ -539,8 +539,7 @@ static int32_t smlParseTableName(SArray *tags, char *childTableName, char *tbnam
|
||||||
// handle child table name
|
// handle child table name
|
||||||
if (childTableNameLen == tag->keyLen && strncmp(tag->key, tbnameKey, tag->keyLen) == 0) {
|
if (childTableNameLen == tag->keyLen && strncmp(tag->key, tbnameKey, tag->keyLen) == 0) {
|
||||||
(void)memset(childTableName, 0, TSDB_TABLE_NAME_LEN);
|
(void)memset(childTableName, 0, TSDB_TABLE_NAME_LEN);
|
||||||
(void)strncpy(childTableName, tag->value,
|
tstrncpy(childTableName, tag->value, TMIN(TSDB_TABLE_NAME_LEN, tag->length + 1));
|
||||||
(tag->length < TSDB_TABLE_NAME_LEN ? tag->length : TSDB_TABLE_NAME_LEN));
|
|
||||||
if (tsSmlDot2Underline) {
|
if (tsSmlDot2Underline) {
|
||||||
smlStrReplace(childTableName, strlen(childTableName));
|
smlStrReplace(childTableName, strlen(childTableName));
|
||||||
}
|
}
|
||||||
|
@ -562,7 +561,7 @@ int32_t smlSetCTableName(SSmlTableInfo *oneTable, char *tbnameKey) {
|
||||||
if (strlen(oneTable->childTableName) == 0) {
|
if (strlen(oneTable->childTableName) == 0) {
|
||||||
SArray *dst = taosArrayDup(oneTable->tags, NULL);
|
SArray *dst = taosArrayDup(oneTable->tags, NULL);
|
||||||
if (dst == NULL) {
|
if (dst == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
if (oneTable->sTableNameLen >= TSDB_TABLE_NAME_LEN) {
|
if (oneTable->sTableNameLen >= TSDB_TABLE_NAME_LEN) {
|
||||||
uError("SML:smlSetCTableName super table name is too long");
|
uError("SML:smlSetCTableName super table name is too long");
|
||||||
|
@ -958,7 +957,7 @@ static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols, bool
|
||||||
for (; i < taosArrayGetSize(cols); i++) {
|
for (; i < taosArrayGetSize(cols); i++) {
|
||||||
SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, i);
|
SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, i);
|
||||||
if (kv == NULL) {
|
if (kv == NULL) {
|
||||||
code = TSDB_CODE_SML_INVALID_DATA;
|
code = terrno;
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
if (taosHashGet(hashTmp, kv->key, kv->keyLen) == NULL) {
|
if (taosHashGet(hashTmp, kv->key, kv->keyLen) == NULL) {
|
||||||
|
@ -1054,7 +1053,7 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SArray *pColumns,
|
||||||
for (int32_t i = 0; i < pReq.numOfColumns; ++i) {
|
for (int32_t i = 0; i < pReq.numOfColumns; ++i) {
|
||||||
SField *pField = taosArrayGet(pColumns, i);
|
SField *pField = taosArrayGet(pColumns, i);
|
||||||
if (pField == NULL) {
|
if (pField == NULL) {
|
||||||
code = TSDB_CODE_SML_INVALID_DATA;
|
code = terrno;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
SFieldWithOptions fieldWithOption = {0};
|
SFieldWithOptions fieldWithOption = {0};
|
||||||
|
|
|
@ -236,7 +236,7 @@ int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName));
|
(void)memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName));
|
||||||
(void)strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1);
|
tstrncpy(pStmt->bInfo.tbFName, tbFName, TSDB_TABLE_FNAME_LEN);
|
||||||
pStmt->bInfo.tbFName[sizeof(pStmt->bInfo.tbFName) - 1] = 0;
|
pStmt->bInfo.tbFName[sizeof(pStmt->bInfo.tbFName) - 1] = 0;
|
||||||
|
|
||||||
pStmt->bInfo.tbUid = autoCreateTbl ? 0 : pTableMeta->uid;
|
pStmt->bInfo.tbUid = autoCreateTbl ? 0 : pTableMeta->uid;
|
||||||
|
@ -983,7 +983,7 @@ int stmtSetDbName(TAOS_STMT* stmt, const char* dbName) {
|
||||||
taosMemoryFreeClear(pStmt->exec.pRequest->pDb);
|
taosMemoryFreeClear(pStmt->exec.pRequest->pDb);
|
||||||
pStmt->exec.pRequest->pDb = taosStrdup(dbName);
|
pStmt->exec.pRequest->pDb = taosStrdup(dbName);
|
||||||
if (pStmt->exec.pRequest->pDb == NULL) {
|
if (pStmt->exec.pRequest->pDb == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1018,13 +1018,13 @@ int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
|
||||||
STMT_ERR_RET(stmtGetFromCache(pStmt));
|
STMT_ERR_RET(stmtGetFromCache(pStmt));
|
||||||
|
|
||||||
if (pStmt->bInfo.needParse) {
|
if (pStmt->bInfo.needParse) {
|
||||||
(void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
tstrncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName));
|
||||||
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
||||||
|
|
||||||
STMT_ERR_RET(stmtParseSql(pStmt));
|
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
tstrncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName));
|
||||||
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
||||||
pStmt->exec.pRequest->requestId++;
|
pStmt->exec.pRequest->requestId++;
|
||||||
pStmt->bInfo.needParse = false;
|
pStmt->bInfo.needParse = false;
|
||||||
|
@ -1172,7 +1172,7 @@ int32_t stmtAppendTablePostHandle(STscStmt* pStmt, SStmtQNode* param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == pStmt->sql.siInfo.firstName[0]) {
|
if (0 == pStmt->sql.siInfo.firstName[0]) {
|
||||||
(void)strcpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName);
|
tstrncpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
param->tblData.getFromHash = pStmt->sql.siInfo.tbFromHash;
|
param->tblData.getFromHash = pStmt->sql.siInfo.tbFromHash;
|
||||||
|
@ -1313,7 +1313,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
||||||
// param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
|
// param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
|
||||||
|
|
||||||
param->restoreTbCols = false;
|
param->restoreTbCols = false;
|
||||||
(void)strcpy(param->tblData.tbName, pStmt->bInfo.tbName);
|
tstrncpy(param->tblData.tbName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t startUs3 = taosGetTimestampUs();
|
int64_t startUs3 = taosGetTimestampUs();
|
||||||
|
|
|
@ -187,7 +187,7 @@ static int32_t stmtUpdateBindInfo(TAOS_STMT2* stmt, STableMeta* pTableMeta, void
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName));
|
(void)memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName));
|
||||||
(void)strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1);
|
tstrncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName));
|
||||||
pStmt->bInfo.tbFName[sizeof(pStmt->bInfo.tbFName) - 1] = 0;
|
pStmt->bInfo.tbFName[sizeof(pStmt->bInfo.tbFName) - 1] = 0;
|
||||||
|
|
||||||
pStmt->bInfo.tbUid = autoCreateTbl ? 0 : pTableMeta->uid;
|
pStmt->bInfo.tbUid = autoCreateTbl ? 0 : pTableMeta->uid;
|
||||||
|
@ -850,7 +850,7 @@ static int stmtSetDbName2(TAOS_STMT2* stmt, const char* dbName) {
|
||||||
taosMemoryFreeClear(pStmt->exec.pRequest->pDb);
|
taosMemoryFreeClear(pStmt->exec.pRequest->pDb);
|
||||||
pStmt->exec.pRequest->pDb = taosStrdup(dbName);
|
pStmt->exec.pRequest->pDb = taosStrdup(dbName);
|
||||||
if (pStmt->exec.pRequest->pDb == NULL) {
|
if (pStmt->exec.pRequest->pDb == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -961,13 +961,13 @@ int stmtSetTbName2(TAOS_STMT2* stmt, const char* tbName) {
|
||||||
STMT_ERR_RET(stmtGetFromCache(pStmt));
|
STMT_ERR_RET(stmtGetFromCache(pStmt));
|
||||||
|
|
||||||
if (pStmt->bInfo.needParse) {
|
if (pStmt->bInfo.needParse) {
|
||||||
(void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
tstrncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName));
|
||||||
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
||||||
|
|
||||||
STMT_ERR_RET(stmtParseSql(pStmt));
|
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
tstrncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName));
|
||||||
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
||||||
pStmt->exec.pRequest->requestId++;
|
pStmt->exec.pRequest->requestId++;
|
||||||
pStmt->bInfo.needParse = false;
|
pStmt->bInfo.needParse = false;
|
||||||
|
@ -1113,7 +1113,7 @@ static int32_t stmtAppendTablePostHandle(STscStmt2* pStmt, SStmtQNode* param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == pStmt->sql.siInfo.firstName[0]) {
|
if (0 == pStmt->sql.siInfo.firstName[0]) {
|
||||||
(void)strcpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName);
|
tstrncpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
param->tblData.getFromHash = pStmt->sql.siInfo.tbFromHash;
|
param->tblData.getFromHash = pStmt->sql.siInfo.tbFromHash;
|
||||||
|
@ -1367,7 +1367,7 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
||||||
// param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
|
// param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
|
||||||
|
|
||||||
param->restoreTbCols = false;
|
param->restoreTbCols = false;
|
||||||
(void)strcpy(param->tblData.tbName, pStmt->bInfo.tbName);
|
tstrncpy(param->tblData.tbName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t startUs3 = taosGetTimestampUs();
|
int64_t startUs3 = taosGetTimestampUs();
|
||||||
|
@ -1419,10 +1419,10 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
||||||
|
|
||||||
if (pStmt->sql.stbInterlaceMode) {
|
if (pStmt->sql.stbInterlaceMode) {
|
||||||
STMT_ERR_RET(stmtAppendTablePostHandle(pStmt, param));
|
STMT_ERR_RET(stmtAppendTablePostHandle(pStmt, param));
|
||||||
|
} else {
|
||||||
|
STMT_ERR_RET(stmtAddBatch2(pStmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
STMT_ERR_RET(stmtAddBatch2(pStmt));
|
|
||||||
|
|
||||||
pStmt->stat.bindDataUs4 += taosGetTimestampUs() - startUs4;
|
pStmt->stat.bindDataUs4 += taosGetTimestampUs() - startUs4;
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1625,6 +1625,10 @@ int stmtExec2(TAOS_STMT2* stmt, int* affected_rows) {
|
||||||
return pStmt->errCode;
|
return pStmt->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pStmt->sql.stbInterlaceMode) {
|
||||||
|
STMT_ERR_RET(stmtAddBatch2(pStmt));
|
||||||
|
}
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
|
||||||
|
|
||||||
if (STMT_TYPE_QUERY != pStmt->sql.type) {
|
if (STMT_TYPE_QUERY != pStmt->sql.type) {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -260,19 +260,19 @@ static void responseCompleteCallback(S3Status status, const S3ErrorDetails *erro
|
||||||
const int elen = sizeof(cbd->err_msg);
|
const int elen = sizeof(cbd->err_msg);
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error->message && elen - len > 0) {
|
if (error->message && elen - len > 0) {
|
||||||
len += snprintf(&(cbd->err_msg[len]), elen - len, " Message: %s\n", error->message);
|
len += tsnprintf(&(cbd->err_msg[len]), elen - len, " Message: %s\n", error->message);
|
||||||
}
|
}
|
||||||
if (error->resource && elen - len > 0) {
|
if (error->resource && elen - len > 0) {
|
||||||
len += snprintf(&(cbd->err_msg[len]), elen - len, " Resource: %s\n", error->resource);
|
len += tsnprintf(&(cbd->err_msg[len]), elen - len, " Resource: %s\n", error->resource);
|
||||||
}
|
}
|
||||||
if (error->furtherDetails && elen - len > 0) {
|
if (error->furtherDetails && elen - len > 0) {
|
||||||
len += snprintf(&(cbd->err_msg[len]), elen - len, " Further Details: %s\n", error->furtherDetails);
|
len += tsnprintf(&(cbd->err_msg[len]), elen - len, " Further Details: %s\n", error->furtherDetails);
|
||||||
}
|
}
|
||||||
if (error->extraDetailsCount && elen - len > 0) {
|
if (error->extraDetailsCount && elen - len > 0) {
|
||||||
len += snprintf(&(cbd->err_msg[len]), elen - len, "%s", " Extra Details:\n");
|
len += tsnprintf(&(cbd->err_msg[len]), elen - len, "%s", " Extra Details:\n");
|
||||||
for (int i = 0; i < error->extraDetailsCount; i++) {
|
for (int i = 0; i < error->extraDetailsCount; i++) {
|
||||||
if (elen - len > 0) {
|
if (elen - len > 0) {
|
||||||
len += snprintf(&(cbd->err_msg[len]), elen - len, " %s: %s\n", error->extraDetails[i].name,
|
len += tsnprintf(&(cbd->err_msg[len]), elen - len, " %s: %s\n", error->extraDetails[i].name,
|
||||||
error->extraDetails[i].value);
|
error->extraDetails[i].value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -753,7 +753,7 @@ upload:
|
||||||
if (!manager.etags[i]) {
|
if (!manager.etags[i]) {
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(EIO), &lino, _exit);
|
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(EIO), &lino, _exit);
|
||||||
}
|
}
|
||||||
n = snprintf(buf, sizeof(buf),
|
n = tsnprintf(buf, sizeof(buf),
|
||||||
"<Part><PartNumber>%d</PartNumber>"
|
"<Part><PartNumber>%d</PartNumber>"
|
||||||
"<ETag>%s</ETag></Part>",
|
"<ETag>%s</ETag></Part>",
|
||||||
i + 1, manager.etags[i]);
|
i + 1, manager.etags[i]);
|
||||||
|
@ -919,7 +919,7 @@ upload:
|
||||||
char buf[256];
|
char buf[256];
|
||||||
int n;
|
int n;
|
||||||
for (int i = 0; i < cp.part_num; ++i) {
|
for (int i = 0; i < cp.part_num; ++i) {
|
||||||
n = snprintf(buf, sizeof(buf),
|
n = tsnprintf(buf, sizeof(buf),
|
||||||
"<Part><PartNumber>%d</PartNumber>"
|
"<Part><PartNumber>%d</PartNumber>"
|
||||||
"<ETag>%s</ETag></Part>",
|
"<ETag>%s</ETag></Part>",
|
||||||
// i + 1, manager.etags[i]);
|
// i + 1, manager.etags[i]);
|
||||||
|
|
|
@ -94,7 +94,7 @@ static int32_t generateConfigFile(char* confDir) {
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
uDebug("[rsync] conf:%s", confContent);
|
uDebug("[rsync] conf:%s", confContent);
|
||||||
if (taosWriteFile(pFile, confContent, strlen(confContent)) != TSDB_CODE_SUCCESS) {
|
if (taosWriteFile(pFile, confContent, strlen(confContent)) <= 0) {
|
||||||
uError("[rsync] write conf file error," ERRNO_ERR_FORMAT, ERRNO_ERR_DATA);
|
uError("[rsync] write conf file error," ERRNO_ERR_FORMAT, ERRNO_ERR_DATA);
|
||||||
(void)taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
|
|
@ -398,6 +398,7 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = {
|
||||||
{.name = "finished", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
{.name = "finished", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||||
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema tsmaSchema[] = {
|
static const SSysDbTableSchema tsmaSchema[] = {
|
||||||
{.name = "tsma_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
{.name = "tsma_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
|
|
|
@ -2446,9 +2446,11 @@ _error:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
static int32_t formatTimestamp(char* buf, size_t cap, int64_t val, int precision) {
|
||||||
time_t tt;
|
time_t tt;
|
||||||
int32_t ms = 0;
|
int32_t ms = 0;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
tt = (time_t)(val / 1000000000);
|
tt = (time_t)(val / 1000000000);
|
||||||
ms = val % 1000000000;
|
ms = val % 1000000000;
|
||||||
|
@ -2460,14 +2462,6 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
||||||
ms = val % 1000;
|
ms = val % 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* comment out as it make testcases like select_with_tags.sim fail.
|
|
||||||
but in windows, this may cause the call to localtime crash if tt < 0,
|
|
||||||
need to find a better solution.
|
|
||||||
if (tt < 0) {
|
|
||||||
tt = 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (tt <= 0 && ms < 0) {
|
if (tt <= 0 && ms < 0) {
|
||||||
tt--;
|
tt--;
|
||||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
|
@ -2479,28 +2473,44 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct tm ptm = {0};
|
struct tm ptm = {0};
|
||||||
if (taosLocalTime(&tt, &ptm, buf) == NULL) {
|
if (taosLocalTime(&tt, &ptm, buf, cap) == NULL) {
|
||||||
return buf;
|
code = TSDB_CODE_INTERNAL_ERROR;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm);
|
size_t pos = strftime(buf, cap, "%Y-%m-%d %H:%M:%S", &ptm);
|
||||||
|
if (pos == 0) {
|
||||||
|
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
int32_t nwritten = 0;
|
||||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
sprintf(buf + pos, ".%09d", ms);
|
nwritten = snprintf(buf + pos, cap - pos, ".%09d", ms);
|
||||||
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||||
sprintf(buf + pos, ".%06d", ms);
|
nwritten = snprintf(buf + pos, cap - pos, ".%06d", ms);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf + pos, ".%03d", ms);
|
nwritten = snprintf(buf + pos, cap - pos, ".%03d", ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf;
|
if (nwritten >= cap - pos) {
|
||||||
|
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
uError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for debug
|
// for debug
|
||||||
int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf, const char* taskIdStr) {
|
int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf, const char* taskIdStr) {
|
||||||
|
int32_t lino = 0;
|
||||||
int32_t size = 2048 * 1024;
|
int32_t size = 2048 * 1024;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
char* dumpBuf = NULL;
|
char* dumpBuf = NULL;
|
||||||
char pBuf[128] = {0};
|
char pBuf[TD_TIME_STR_LEN] = {0};
|
||||||
int32_t rows = pDataBlock->info.rows;
|
int32_t rows = pDataBlock->info.rows;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
|
|
||||||
|
@ -2510,7 +2520,7 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||||
len += snprintf(dumpBuf + len, size - len,
|
len += tsnprintf(dumpBuf + len, size - len,
|
||||||
"%s===stream===%s|block type %d|child id %d|group id:%" PRIu64 "|uid:%" PRId64 "|rows:%" PRId64
|
"%s===stream===%s|block type %d|child id %d|group id:%" PRIu64 "|uid:%" PRId64 "|rows:%" PRId64
|
||||||
"|version:%" PRIu64 "|cal start:%" PRIu64 "|cal end:%" PRIu64 "|tbl:%s\n",
|
"|version:%" PRIu64 "|cal start:%" PRIu64 "|cal end:%" PRIu64 "|tbl:%s\n",
|
||||||
taskIdStr, flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId,
|
taskIdStr, flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId,
|
||||||
|
@ -2521,7 +2531,7 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t j = 0; j < rows; j++) {
|
for (int32_t j = 0; j < rows; j++) {
|
||||||
len += snprintf(dumpBuf + len, size - len, "%s|", flag);
|
len += tsnprintf(dumpBuf + len, size - len, "%s|", flag);
|
||||||
if (len >= size - 1) {
|
if (len >= size - 1) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -2530,11 +2540,12 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||||
if (pColInfoData == NULL) {
|
if (pColInfoData == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
lino = __LINE__;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colDataIsNull(pColInfoData, rows, j, NULL) || !pColInfoData->pData) {
|
if (colDataIsNull(pColInfoData, rows, j, NULL) || !pColInfoData->pData) {
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15s |", "NULL");
|
len += tsnprintf(dumpBuf + len, size - len, " %15s |", "NULL");
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2543,52 +2554,55 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
||||||
switch (pColInfoData->info.type) {
|
switch (pColInfoData->info.type) {
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
memset(pBuf, 0, sizeof(pBuf));
|
memset(pBuf, 0, sizeof(pBuf));
|
||||||
(void)formatTimestamp(pBuf, *(uint64_t*)var, pColInfoData->info.precision);
|
code = formatTimestamp(pBuf, sizeof(pBuf), *(uint64_t*)var, pColInfoData->info.precision);
|
||||||
len += snprintf(dumpBuf + len, size - len, " %25s |", pBuf);
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
TAOS_UNUSED(tsnprintf(pBuf, sizeof(pBuf), "NaN"));
|
||||||
|
}
|
||||||
|
len += tsnprintf(dumpBuf + len, size - len, " %25s |", pBuf);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_TINYINT:
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int8_t*)var);
|
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(int8_t*)var);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_UTINYINT:
|
case TSDB_DATA_TYPE_UTINYINT:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint8_t*)var);
|
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(uint8_t*)var);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_SMALLINT:
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int16_t*)var);
|
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(int16_t*)var);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_USMALLINT:
|
case TSDB_DATA_TYPE_USMALLINT:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint16_t*)var);
|
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(uint16_t*)var);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_INT:
|
case TSDB_DATA_TYPE_INT:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int32_t*)var);
|
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(int32_t*)var);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_UINT:
|
case TSDB_DATA_TYPE_UINT:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15u |", *(uint32_t*)var);
|
len += tsnprintf(dumpBuf + len, size - len, " %15u |", *(uint32_t*)var);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15" PRId64 " |", *(int64_t*)var);
|
len += tsnprintf(dumpBuf + len, size - len, " %15" PRId64 " |", *(int64_t*)var);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_UBIGINT:
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15" PRIu64 " |", *(uint64_t*)var);
|
len += tsnprintf(dumpBuf + len, size - len, " %15" PRIu64 " |", *(uint64_t*)var);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15f |", *(float*)var);
|
len += tsnprintf(dumpBuf + len, size - len, " %15f |", *(float*)var);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15f |", *(double*)var);
|
len += tsnprintf(dumpBuf + len, size - len, " %15f |", *(double*)var);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(bool*)var);
|
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(bool*)var);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
|
@ -2599,7 +2613,7 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
||||||
int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData));
|
int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData));
|
||||||
dataSize = TMIN(dataSize, 50);
|
dataSize = TMIN(dataSize, 50);
|
||||||
memcpy(pBuf, varDataVal(pData), dataSize);
|
memcpy(pBuf, varDataVal(pData), dataSize);
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
len += tsnprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
} break;
|
} break;
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
|
@ -2609,27 +2623,27 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
||||||
code = taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf);
|
code = taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
uError("func %s failed to convert to ucs charset since %s", __func__, tstrerror(code));
|
uError("func %s failed to convert to ucs charset since %s", __func__, tstrerror(code));
|
||||||
|
lino = __LINE__;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
} else { // reset the length value
|
} else { // reset the length value
|
||||||
code = TSDB_CODE_SUCCESS;
|
code = TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
len += tsnprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len += snprintf(dumpBuf + len, size - len, "%d\n", j);
|
len += tsnprintf(dumpBuf + len, size - len, "%d\n", j);
|
||||||
if (len >= size - 1) goto _exit;
|
if (len >= size - 1) goto _exit;
|
||||||
}
|
}
|
||||||
len += snprintf(dumpBuf + len, size - len, "%s |end\n", flag);
|
len += tsnprintf(dumpBuf + len, size - len, "%s |end\n", flag);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
*pDataBuf = dumpBuf;
|
*pDataBuf = dumpBuf;
|
||||||
dumpBuf = NULL;
|
dumpBuf = NULL;
|
||||||
} else {
|
} else {
|
||||||
uError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
uError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
if (dumpBuf) {
|
if (dumpBuf) {
|
||||||
taosMemoryFree(dumpBuf);
|
taosMemoryFree(dumpBuf);
|
||||||
}
|
}
|
||||||
|
@ -2860,27 +2874,98 @@ _end:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId) {
|
// Construct the child table name in the form of <ctbName>_<stbName>_<groupId> and store it in `ctbName`.
|
||||||
char tmp[TSDB_TABLE_NAME_LEN] = {0};
|
// If the name length exceeds TSDB_TABLE_NAME_LEN, first convert <stbName>_<groupId> to an MD5 value and then
|
||||||
if (stbName == NULL){
|
// concatenate. If the length is still too long, convert <ctbName> to an MD5 value as well.
|
||||||
snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%"PRIu64, groupId);
|
int32_t buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId, size_t cap) {
|
||||||
}else{
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
char tmp[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
|
char* suffix = tmp;
|
||||||
|
size_t suffixCap = sizeof(tmp);
|
||||||
|
size_t suffixLen = 0;
|
||||||
|
size_t prefixLen = 0;
|
||||||
|
T_MD5_CTX context;
|
||||||
|
|
||||||
|
if (ctbName == NULL || cap < TSDB_TABLE_NAME_LEN) {
|
||||||
|
code = TSDB_CODE_INTERNAL_ERROR;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
|
||||||
|
prefixLen = strlen(ctbName);
|
||||||
|
|
||||||
|
if (stbName == NULL) {
|
||||||
|
suffixLen = snprintf(suffix, suffixCap, "%" PRIu64, groupId);
|
||||||
|
if (suffixLen >= suffixCap) {
|
||||||
|
code = TSDB_CODE_INTERNAL_ERROR;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
int32_t i = strlen(stbName) - 1;
|
int32_t i = strlen(stbName) - 1;
|
||||||
for(; i >= 0; i--){
|
for (; i >= 0; i--) {
|
||||||
if (stbName[i] == '.'){
|
if (stbName[i] == '.') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%s_%"PRIu64, stbName + i + 1, groupId);
|
suffixLen = snprintf(suffix, suffixCap, "%s_%" PRIu64, stbName + i + 1, groupId);
|
||||||
}
|
if (suffixLen >= suffixCap) {
|
||||||
|
suffixCap = suffixLen + 1;
|
||||||
ctbName[TSDB_TABLE_NAME_LEN - strlen(tmp) - 1] = 0; // put stbname + groupId to the end
|
suffix = taosMemoryMalloc(suffixCap);
|
||||||
(void)strcat(ctbName, tmp);
|
TSDB_CHECK_NULL(suffix, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
for(int i = 0; i < strlen(ctbName); i++){
|
suffixLen = snprintf(suffix, suffixCap, "%s_%" PRIu64, stbName + i + 1, groupId);
|
||||||
if(ctbName[i] == '.'){
|
if (suffixLen >= suffixCap) {
|
||||||
ctbName[i] = '_';
|
code = TSDB_CODE_INTERNAL_ERROR;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prefixLen + suffixLen + 1 >= TSDB_TABLE_NAME_LEN) {
|
||||||
|
// If the name length exceeeds the limit, convert the suffix to MD5 value.
|
||||||
|
tMD5Init(&context);
|
||||||
|
tMD5Update(&context, (uint8_t*)suffix, suffixLen);
|
||||||
|
tMD5Final(&context);
|
||||||
|
suffixLen = snprintf(suffix, suffixCap, "%016" PRIx64 "%016" PRIx64, *(uint64_t*)context.digest,
|
||||||
|
*(uint64_t*)(context.digest + 8));
|
||||||
|
if (suffixLen >= suffixCap) {
|
||||||
|
code = TSDB_CODE_INTERNAL_ERROR;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefixLen + suffixLen + 1 >= TSDB_TABLE_NAME_LEN) {
|
||||||
|
// If the name is still too long, convert the ctbName to MD5 value.
|
||||||
|
tMD5Init(&context);
|
||||||
|
tMD5Update(&context, (uint8_t*)ctbName, prefixLen);
|
||||||
|
tMD5Final(&context);
|
||||||
|
prefixLen = snprintf(ctbName, cap, "t_%016" PRIx64 "%016" PRIx64, *(uint64_t*)context.digest,
|
||||||
|
*(uint64_t*)(context.digest + 8));
|
||||||
|
if (prefixLen >= cap) {
|
||||||
|
code = TSDB_CODE_INTERNAL_ERROR;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefixLen + suffixLen + 1 >= TSDB_TABLE_NAME_LEN) {
|
||||||
|
code = TSDB_CODE_INTERNAL_ERROR;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctbName[prefixLen] = '_';
|
||||||
|
tstrncpy(&ctbName[prefixLen + 1], suffix, cap - prefixLen - 1);
|
||||||
|
|
||||||
|
for (char* p = ctbName; *p; ++p) {
|
||||||
|
if (*p == '.') *p = '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
uError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
if (suffix != tmp) {
|
||||||
|
taosMemoryFree(suffix);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto stream subtable name starts with 't_', followed by the first segment of MD5 digest for group vals.
|
// auto stream subtable name starts with 't_', followed by the first segment of MD5 digest for group vals.
|
||||||
|
|
|
@ -362,7 +362,7 @@ static int32_t taosSplitS3Cfg(SConfig *pCfg, const char *name, char gVarible[TSD
|
||||||
|
|
||||||
char *strDup = NULL;
|
char *strDup = NULL;
|
||||||
if ((strDup = taosStrdup(pItem->str))== NULL){
|
if ((strDup = taosStrdup(pItem->str))== NULL){
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = terrno;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,6 +542,7 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "sDebugFlag", sDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "sDebugFlag", sDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "tsdbDebugFlag", tsdbDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "tsdbDebugFlag", tsdbDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "tqDebugFlag", tqDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "tqDebugFlag", tqDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "tqClientDebug", tqClientDebug, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "fsDebugFlag", fsDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "fsDebugFlag", fsDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "udfDebugFlag", udfDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "udfDebugFlag", udfDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "smaDebugFlag", smaDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "smaDebugFlag", smaDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
|
@ -644,11 +645,6 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "enableCoreFile", tsEnableCoreFile, CFG_SCOPE_BOTH, CFG_DYN_BOTH));
|
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "enableCoreFile", tsEnableCoreFile, CFG_SCOPE_BOTH, CFG_DYN_BOTH));
|
||||||
TAOS_CHECK_RETURN(cfgAddFloat(pCfg, "numOfCores", tsNumOfCores, 1, 100000, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
TAOS_CHECK_RETURN(cfgAddFloat(pCfg, "numOfCores", tsNumOfCores, 1, 100000, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "ssd42", tsSSE42Supported, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "avx", tsAVXSupported, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "avx2", tsAVX2Supported, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "fma", tsFMASupported, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "avx512", tsAVX512Supported, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "simdEnable", tsSIMDEnable, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "simdEnable", tsSIMDEnable, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "AVX512Enable", tsAVX512Enable, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "AVX512Enable", tsAVX512Enable, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "tagFilterCache", tsTagFilterCache, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "tagFilterCache", tsTagFilterCache, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||||
|
@ -1396,6 +1392,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "simdEnable");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "simdEnable");
|
||||||
tsSIMDEnable = (bool)pItem->bval;
|
tsSIMDEnable = (bool)pItem->bval;
|
||||||
|
|
||||||
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "AVX512Enable");
|
||||||
|
tsAVX512Enable = (bool)pItem->bval;
|
||||||
|
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tagFilterCache");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tagFilterCache");
|
||||||
tsTagFilterCache = (bool)pItem->bval;
|
tsTagFilterCache = (bool)pItem->bval;
|
||||||
|
|
||||||
|
@ -1958,7 +1957,7 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, const char *name) {
|
||||||
{"smaDebugFlag", &smaDebugFlag}, {"idxDebugFlag", &idxDebugFlag}, {"tdbDebugFlag", &tdbDebugFlag},
|
{"smaDebugFlag", &smaDebugFlag}, {"idxDebugFlag", &idxDebugFlag}, {"tdbDebugFlag", &tdbDebugFlag},
|
||||||
{"tmrDebugFlag", &tmrDebugFlag}, {"uDebugFlag", &uDebugFlag}, {"smaDebugFlag", &smaDebugFlag},
|
{"tmrDebugFlag", &tmrDebugFlag}, {"uDebugFlag", &uDebugFlag}, {"smaDebugFlag", &smaDebugFlag},
|
||||||
{"rpcDebugFlag", &rpcDebugFlag}, {"qDebugFlag", &qDebugFlag}, {"metaDebugFlag", &metaDebugFlag},
|
{"rpcDebugFlag", &rpcDebugFlag}, {"qDebugFlag", &qDebugFlag}, {"metaDebugFlag", &metaDebugFlag},
|
||||||
{"stDebugFlag", &stDebugFlag}, {"sndDebugFlag", &sndDebugFlag},
|
{"stDebugFlag", &stDebugFlag}, {"sndDebugFlag", &sndDebugFlag}, {"tqClientDebug", &tqClientDebug},
|
||||||
};
|
};
|
||||||
|
|
||||||
static OptionNameAndVar options[] = {{"audit", &tsEnableAudit},
|
static OptionNameAndVar options[] = {{"audit", &tsEnableAudit},
|
||||||
|
|
|
@ -284,7 +284,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
||||||
|
|
||||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
||||||
if (pColInfo == NULL) {
|
if (pColInfo == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = terrno;
|
||||||
TAOS_CHECK_GOTO(code, NULL, _exit);
|
TAOS_CHECK_GOTO(code, NULL, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
||||||
if (pColInfo == NULL) {
|
if (pColInfo == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = terrno;
|
||||||
TAOS_CHECK_GOTO(code, NULL, _exit);
|
TAOS_CHECK_GOTO(code, NULL, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
||||||
if (pColInfo == NULL) {
|
if (pColInfo == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = terrno;
|
||||||
TAOS_CHECK_GOTO(code, NULL, _exit);
|
TAOS_CHECK_GOTO(code, NULL, _exit);
|
||||||
}
|
}
|
||||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, scope, false), NULL, _exit);
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, scope, false), NULL, _exit);
|
||||||
|
|
|
@ -1703,6 +1703,7 @@ int32_t tDeserializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
|
||||||
if (!tDecodeIsEnd(&decoder)) {
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pRsp->ipWhiteVer));
|
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pRsp->ipWhiteVer));
|
||||||
}
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
_exit:
|
_exit:
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -8163,6 +8164,7 @@ int32_t tSerializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) {
|
||||||
TAOS_CHECK_EXIT(tEncodeI8(&encoder, privilege->noPrivilege));
|
TAOS_CHECK_EXIT(tEncodeI8(&encoder, privilege->noPrivilege));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tEncodeI32(&encoder, pRsp->debugFlag) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -8196,6 +8198,10 @@ int32_t tDeserializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) {
|
||||||
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &data->noPrivilege));
|
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &data->noPrivilege));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
if (tDecodeI32(&decoder, &pRsp->debugFlag) < 0) return -1;
|
||||||
|
}
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -10681,7 +10687,7 @@ int32_t tDecodeMqMetaRsp(SDecoder *pDecoder, SMqMetaRsp *pRsp) {
|
||||||
|
|
||||||
void tDeleteMqMetaRsp(SMqMetaRsp *pRsp) { taosMemoryFree(pRsp->metaRsp); }
|
void tDeleteMqMetaRsp(SMqMetaRsp *pRsp) { taosMemoryFree(pRsp->metaRsp); }
|
||||||
|
|
||||||
int32_t tEncodeMqDataRspCommon(SEncoder *pEncoder, const SMqDataRspCommon *pRsp) {
|
int32_t tEncodeMqDataRspCommon(SEncoder *pEncoder, const SMqDataRsp *pRsp) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino;
|
int32_t lino;
|
||||||
|
|
||||||
|
@ -10711,19 +10717,20 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeMqDataRsp(SEncoder *pEncoder, const void *pRsp) {
|
int32_t tEncodeMqDataRsp(SEncoder *pEncoder, const SMqDataRsp *pRsp) {
|
||||||
TAOS_CHECK_RETURN(tEncodeMqDataRspCommon(pEncoder, pRsp));
|
TAOS_CHECK_RETURN(tEncodeMqDataRspCommon(pEncoder, pRsp));
|
||||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, ((SMqDataRsp *)pRsp)->sleepTime));
|
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pRsp->sleepTime));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeMqDataRspCommon(SDecoder *pDecoder, SMqDataRspCommon *pRsp) {
|
int32_t tDecodeMqDataRspCommon(SDecoder *pDecoder, SMqDataRsp *pRsp) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino;
|
int32_t lino;
|
||||||
|
|
||||||
TAOS_CHECK_EXIT(tDecodeSTqOffsetVal(pDecoder, &pRsp->reqOffset));
|
TAOS_CHECK_EXIT(tDecodeSTqOffsetVal(pDecoder, &pRsp->reqOffset));
|
||||||
TAOS_CHECK_EXIT(tDecodeSTqOffsetVal(pDecoder, &pRsp->rspOffset));
|
TAOS_CHECK_EXIT(tDecodeSTqOffsetVal(pDecoder, &pRsp->rspOffset));
|
||||||
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &pRsp->blockNum));
|
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &pRsp->blockNum));
|
||||||
|
|
||||||
if (pRsp->blockNum != 0) {
|
if (pRsp->blockNum != 0) {
|
||||||
if ((pRsp->blockData = taosArrayInit(pRsp->blockNum, sizeof(void *))) == NULL) {
|
if ((pRsp->blockData = taosArrayInit(pRsp->blockNum, sizeof(void *))) == NULL) {
|
||||||
TAOS_CHECK_EXIT(terrno);
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
@ -10787,17 +10794,16 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeMqDataRsp(SDecoder *pDecoder, void *pRsp) {
|
int32_t tDecodeMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) {
|
||||||
TAOS_CHECK_RETURN(tDecodeMqDataRspCommon(pDecoder, pRsp));
|
TAOS_CHECK_RETURN(tDecodeMqDataRspCommon(pDecoder, pRsp));
|
||||||
if (!tDecodeIsEnd(pDecoder)) {
|
if (!tDecodeIsEnd(pDecoder)) {
|
||||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &((SMqDataRsp *)pRsp)->sleepTime));
|
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pRsp->sleepTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tDeleteMqDataRspCommon(void *rsp) {
|
static void tDeleteMqDataRspCommon(SMqDataRsp *pRsp) {
|
||||||
SMqDataRspCommon *pRsp = rsp;
|
|
||||||
taosArrayDestroy(pRsp->blockDataLen);
|
taosArrayDestroy(pRsp->blockDataLen);
|
||||||
pRsp->blockDataLen = NULL;
|
pRsp->blockDataLen = NULL;
|
||||||
taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree);
|
taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree);
|
||||||
|
@ -10810,15 +10816,13 @@ static void tDeleteMqDataRspCommon(void *rsp) {
|
||||||
tOffsetDestroy(&pRsp->rspOffset);
|
tOffsetDestroy(&pRsp->rspOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tDeleteMqDataRsp(void *rsp) { tDeleteMqDataRspCommon(rsp); }
|
void tDeleteMqDataRsp(SMqDataRsp *rsp) { tDeleteMqDataRspCommon(rsp); }
|
||||||
|
|
||||||
int32_t tEncodeSTaosxRsp(SEncoder *pEncoder, const void *rsp) {
|
int32_t tEncodeSTaosxRsp(SEncoder *pEncoder, const SMqDataRsp *pRsp) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino;
|
int32_t lino;
|
||||||
|
|
||||||
TAOS_CHECK_EXIT(tEncodeMqDataRspCommon(pEncoder, rsp));
|
TAOS_CHECK_EXIT(tEncodeMqDataRspCommon(pEncoder, pRsp));
|
||||||
|
|
||||||
const STaosxRsp *pRsp = (const STaosxRsp *)rsp;
|
|
||||||
TAOS_CHECK_EXIT(tEncodeI32(pEncoder, pRsp->createTableNum));
|
TAOS_CHECK_EXIT(tEncodeI32(pEncoder, pRsp->createTableNum));
|
||||||
if (pRsp->createTableNum) {
|
if (pRsp->createTableNum) {
|
||||||
for (int32_t i = 0; i < pRsp->createTableNum; i++) {
|
for (int32_t i = 0; i < pRsp->createTableNum; i++) {
|
||||||
|
@ -10831,13 +10835,11 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, void *rsp) {
|
int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino;
|
int32_t lino;
|
||||||
|
|
||||||
TAOS_CHECK_EXIT(tDecodeMqDataRspCommon(pDecoder, rsp));
|
TAOS_CHECK_EXIT(tDecodeMqDataRspCommon(pDecoder, pRsp));
|
||||||
|
|
||||||
STaosxRsp *pRsp = (STaosxRsp *)rsp;
|
|
||||||
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &pRsp->createTableNum));
|
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &pRsp->createTableNum));
|
||||||
if (pRsp->createTableNum) {
|
if (pRsp->createTableNum) {
|
||||||
if ((pRsp->createTableLen = taosArrayInit(pRsp->createTableNum, sizeof(int32_t))) == NULL) {
|
if ((pRsp->createTableLen = taosArrayInit(pRsp->createTableNum, sizeof(int32_t))) == NULL) {
|
||||||
|
@ -10864,10 +10866,9 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tDeleteSTaosxRsp(void *rsp) {
|
void tDeleteSTaosxRsp(SMqDataRsp *pRsp) {
|
||||||
tDeleteMqDataRspCommon(rsp);
|
tDeleteMqDataRspCommon(pRsp);
|
||||||
|
|
||||||
STaosxRsp *pRsp = (STaosxRsp *)rsp;
|
|
||||||
taosArrayDestroy(pRsp->createTableLen);
|
taosArrayDestroy(pRsp->createTableLen);
|
||||||
pRsp->createTableLen = NULL;
|
pRsp->createTableLen = NULL;
|
||||||
taosArrayDestroyP(pRsp->createTableReq, (FDelete)taosMemoryFree);
|
taosArrayDestroyP(pRsp->createTableReq, (FDelete)taosMemoryFree);
|
||||||
|
|
|
@ -33,7 +33,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
|
||||||
}
|
}
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t t = (time_t)start;
|
time_t t = (time_t)start;
|
||||||
taosLocalTime(&t, &tm);
|
taosLocalTime(&t, &tm, NULL, 0);
|
||||||
tm.tm_sec = 0;
|
tm.tm_sec = 0;
|
||||||
tm.tm_min = 0;
|
tm.tm_min = 0;
|
||||||
tm.tm_hour = 0;
|
tm.tm_hour = 0;
|
||||||
|
@ -103,7 +103,7 @@ int32_t tNameExtractFullName(const SName* name, char* dst) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = snprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname);
|
int32_t len = tsnprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname);
|
||||||
|
|
||||||
size_t tnameLen = strlen(name->tname);
|
size_t tnameLen = strlen(name->tname);
|
||||||
if (tnameLen > 0) {
|
if (tnameLen > 0) {
|
||||||
|
|
|
@ -693,7 +693,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
||||||
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||||
struct tm* ptm = taosLocalTime(&tt, &tm, NULL);
|
struct tm* ptm = taosLocalTime(&tt, &tm, NULL, 0);
|
||||||
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth;
|
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth;
|
||||||
tm.tm_year = mon / 12;
|
tm.tm_year = mon / 12;
|
||||||
tm.tm_mon = mon % 12;
|
tm.tm_mon = mon % 12;
|
||||||
|
@ -754,11 +754,11 @@ int32_t taosTimeCountIntervalForFill(int64_t skey, int64_t ekey, int64_t interva
|
||||||
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t t = (time_t)skey;
|
time_t t = (time_t)skey;
|
||||||
struct tm* ptm = taosLocalTime(&t, &tm, NULL);
|
struct tm* ptm = taosLocalTime(&t, &tm, NULL, 0);
|
||||||
int32_t smon = tm.tm_year * 12 + tm.tm_mon;
|
int32_t smon = tm.tm_year * 12 + tm.tm_mon;
|
||||||
|
|
||||||
t = (time_t)ekey;
|
t = (time_t)ekey;
|
||||||
ptm = taosLocalTime(&t, &tm, NULL);
|
ptm = taosLocalTime(&t, &tm, NULL, 0);
|
||||||
int32_t emon = tm.tm_year * 12 + tm.tm_mon;
|
int32_t emon = tm.tm_year * 12 + tm.tm_mon;
|
||||||
|
|
||||||
if (unit == 'y') {
|
if (unit == 'y') {
|
||||||
|
@ -782,7 +782,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
|
||||||
start /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
|
start /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t tt = (time_t)start;
|
time_t tt = (time_t)start;
|
||||||
struct tm* ptm = taosLocalTime(&tt, &tm, NULL);
|
struct tm* ptm = taosLocalTime(&tt, &tm, NULL, 0);
|
||||||
tm.tm_sec = 0;
|
tm.tm_sec = 0;
|
||||||
tm.tm_min = 0;
|
tm.tm_min = 0;
|
||||||
tm.tm_hour = 0;
|
tm.tm_hour = 0;
|
||||||
|
@ -911,13 +911,13 @@ int64_t taosTimeGetIntervalEnd(int64_t intervalStart, const SInterval* pInterval
|
||||||
// 2020-07-03 17:48:42
|
// 2020-07-03 17:48:42
|
||||||
// and the parameter can also be a variable.
|
// and the parameter can also be a variable.
|
||||||
const char* fmtts(int64_t ts) {
|
const char* fmtts(int64_t ts) {
|
||||||
static char buf[96] = {0};
|
static char buf[TD_TIME_STR_LEN] = {0};
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
if (ts > -62135625943 && ts < 32503651200) {
|
if (ts > -62135625943 && ts < 32503651200) {
|
||||||
time_t t = (time_t)ts;
|
time_t t = (time_t)ts;
|
||||||
if (taosLocalTime(&t, &tm, buf) == NULL) {
|
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
pos += strftime(buf + pos, sizeof(buf), "s=%Y-%m-%d %H:%M:%S", &tm);
|
pos += strftime(buf + pos, sizeof(buf), "s=%Y-%m-%d %H:%M:%S", &tm);
|
||||||
|
@ -925,7 +925,7 @@ const char* fmtts(int64_t ts) {
|
||||||
|
|
||||||
if (ts > -62135625943000 && ts < 32503651200000) {
|
if (ts > -62135625943000 && ts < 32503651200000) {
|
||||||
time_t t = (time_t)(ts / 1000);
|
time_t t = (time_t)(ts / 1000);
|
||||||
if (taosLocalTime(&t, &tm, buf) == NULL) {
|
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
|
@ -939,7 +939,7 @@ const char* fmtts(int64_t ts) {
|
||||||
|
|
||||||
{
|
{
|
||||||
time_t t = (time_t)(ts / 1000000);
|
time_t t = (time_t)(ts / 1000000);
|
||||||
if (taosLocalTime(&t, &tm, buf) == NULL) {
|
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
|
@ -993,11 +993,11 @@ int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precisio
|
||||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == taosLocalTime(", &ptm, buf)) {
|
if (NULL == taosLocalTime(", &ptm, buf, bufLen)) {
|
||||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||||
}
|
}
|
||||||
int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", &ptm);
|
int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", &ptm);
|
||||||
length += snprintf(ts + length, fractionLen, format, mod);
|
length += tsnprintf(ts + length, fractionLen, format, mod);
|
||||||
length += (int32_t)strftime(ts + length, 40 - length, "%z", &ptm);
|
length += (int32_t)strftime(ts + length, 40 - length, "%z", &ptm);
|
||||||
|
|
||||||
tstrncpy(buf, ts, bufLen);
|
tstrncpy(buf, ts, bufLen);
|
||||||
|
@ -1007,7 +1007,7 @@ int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precisio
|
||||||
int32_t taosTs2Tm(int64_t ts, int32_t precision, struct STm* tm) {
|
int32_t taosTs2Tm(int64_t ts, int32_t precision, struct STm* tm) {
|
||||||
tm->fsec = ts % TICK_PER_SECOND[precision] * (TICK_PER_SECOND[TSDB_TIME_PRECISION_NANO] / TICK_PER_SECOND[precision]);
|
tm->fsec = ts % TICK_PER_SECOND[precision] * (TICK_PER_SECOND[TSDB_TIME_PRECISION_NANO] / TICK_PER_SECOND[precision]);
|
||||||
time_t t = ts / TICK_PER_SECOND[precision];
|
time_t t = ts / TICK_PER_SECOND[precision];
|
||||||
if (NULL == taosLocalTime(&t, &tm->tm, NULL)) {
|
if (NULL == taosLocalTime(&t, &tm->tm, NULL, 0)) {
|
||||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -480,7 +480,7 @@ TEST(testCase, StreamAllNormTest) {
|
||||||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
uint64_t groupId = 12345;
|
uint64_t groupId = 12345;
|
||||||
|
|
||||||
buildCtbNameAddGroupId(NULL, ctbName, groupId);
|
buildCtbNameAddGroupId(NULL, ctbName, groupId, sizeof(ctbName));
|
||||||
|
|
||||||
ASSERT_STREQ("_12345", ctbName);
|
ASSERT_STREQ("_12345", ctbName);
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ TEST(testCase, StreamWithStbName) {
|
||||||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
uint64_t groupId = 12345;
|
uint64_t groupId = 12345;
|
||||||
|
|
||||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName));
|
||||||
|
|
||||||
ASSERT_STREQ("_stb_12345", ctbName);
|
ASSERT_STREQ("_stb_12345", ctbName);
|
||||||
}
|
}
|
||||||
|
@ -500,7 +500,7 @@ TEST(testCase, StreamWithoutDotInStbName) {
|
||||||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
uint64_t groupId = 12345;
|
uint64_t groupId = 12345;
|
||||||
|
|
||||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName));
|
||||||
|
|
||||||
ASSERT_STREQ("_table_12345", ctbName);
|
ASSERT_STREQ("_table_12345", ctbName);
|
||||||
}
|
}
|
||||||
|
@ -510,11 +510,59 @@ TEST(testCase, StreamWithoutDotInStbName2) {
|
||||||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
uint64_t groupId = 12345;
|
uint64_t groupId = 12345;
|
||||||
|
|
||||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName));
|
||||||
|
|
||||||
ASSERT_STREQ("__12345", ctbName);
|
ASSERT_STREQ("__12345", ctbName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(testCase, StreamWithLongStbName) {
|
||||||
|
char ctbName[TSDB_TABLE_NAME_LEN];
|
||||||
|
char expectName[TSDB_TABLE_NAME_LEN];
|
||||||
|
char *stbName = "a_simle_stb_name";
|
||||||
|
uint64_t groupId = UINT64_MAX;
|
||||||
|
|
||||||
|
// test basic function
|
||||||
|
strcpy(ctbName, "a_simple_ctb_name");
|
||||||
|
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName)), TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_STREQ(ctbName, "a_simple_ctb_name_a_simle_stb_name_18446744073709551615");
|
||||||
|
|
||||||
|
// test null stbName
|
||||||
|
strcpy(ctbName, "a_simple_ctb_name");
|
||||||
|
stbName = NULL;
|
||||||
|
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName)), TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_STREQ(ctbName, "a_simple_ctb_name_18446744073709551615");
|
||||||
|
|
||||||
|
// test buffer capcity check
|
||||||
|
EXPECT_EQ(buildCtbNameAddGroupId(stbName, NULL, groupId, sizeof(ctbName)), TSDB_CODE_INTERNAL_ERROR);
|
||||||
|
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName) - 1), TSDB_CODE_INTERNAL_ERROR);
|
||||||
|
|
||||||
|
// test md5 conversion of stbName with groupid
|
||||||
|
for (int32_t i = 0; i < 159; ++i) ctbName[i] = 'A';
|
||||||
|
ctbName[159] = '\0';
|
||||||
|
stbName = taosStrdup(ctbName);
|
||||||
|
snprintf(expectName, TSDB_TABLE_NAME_LEN, "%s_d85f0d87946d76eeedd7b7b78b7492a2", ctbName);
|
||||||
|
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName)), TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_STREQ(ctbName, expectName);
|
||||||
|
|
||||||
|
// test md5 conversion of all parts
|
||||||
|
for (int32_t i = 0; i < 190; ++i) ctbName[i] = 'A';
|
||||||
|
ctbName[190] = '\0';
|
||||||
|
tstrncpy(expectName, "t_d38a8b2df999bef0082ffc80a59a9cd7_d85f0d87946d76eeedd7b7b78b7492a2", TSDB_TABLE_NAME_LEN);
|
||||||
|
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName)), TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_STREQ(ctbName, expectName);
|
||||||
|
|
||||||
|
// test larger stbName
|
||||||
|
taosMemoryFree(stbName);
|
||||||
|
for (int32_t i = 0; i < 190; ++i) ctbName[i] = 'A';
|
||||||
|
ctbName[190] = '\0';
|
||||||
|
stbName = taosStrdup(ctbName);
|
||||||
|
tstrncpy(expectName, "t_d38a8b2df999bef0082ffc80a59a9cd7_9c99cc7c52073b63fb750af402d9b84b", TSDB_TABLE_NAME_LEN);
|
||||||
|
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName)), TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_STREQ(ctbName, expectName);
|
||||||
|
|
||||||
|
taosMemoryFree(stbName);
|
||||||
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
TEST(testCase, NoneTest) {
|
TEST(testCase, NoneTest) {
|
||||||
const static int nCols = 14;
|
const static int nCols = 14;
|
||||||
|
@ -570,4 +618,4 @@ for (int r = 0; r < nRows; ++r) {
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
taosMemoryFree(pTSchema);
|
taosMemoryFree(pTSchema);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
#include "osFile.h"
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
@ -181,6 +182,7 @@ static void dmSetSignalHandle() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
extern bool generateNewMeta;
|
||||||
|
|
||||||
extern bool generateNewMeta;
|
extern bool generateNewMeta;
|
||||||
|
|
||||||
|
@ -284,9 +286,9 @@ static void dmPrintArgs(int32_t argc, char const *argv[]) {
|
||||||
taosGetCwd(path, sizeof(path));
|
taosGetCwd(path, sizeof(path));
|
||||||
|
|
||||||
char args[1024] = {0};
|
char args[1024] = {0};
|
||||||
int32_t arglen = snprintf(args, sizeof(args), "%s", argv[0]);
|
int32_t arglen = tsnprintf(args, sizeof(args), "%s", argv[0]);
|
||||||
for (int32_t i = 1; i < argc; ++i) {
|
for (int32_t i = 1; i < argc; ++i) {
|
||||||
arglen = arglen + snprintf(args + arglen, sizeof(args) - arglen, " %s", argv[i]);
|
arglen = arglen + tsnprintf(args + arglen, sizeof(args) - arglen, " %s", argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("startup path:%s args:%s", path, args);
|
dInfo("startup path:%s args:%s", path, args);
|
||||||
|
@ -419,6 +421,9 @@ int mainWindows(int argc, char **argv) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
int ret = dmUpdateEncryptKey(global.encryptKey, toLogFile);
|
int ret = dmUpdateEncryptKey(global.encryptKey, toLogFile);
|
||||||
|
if (taosCloseFile(&pFile) != 0) {
|
||||||
|
encryptError("failed to close file:%p", pFile);
|
||||||
|
}
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
taosCleanupArgs();
|
taosCleanupArgs();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -39,6 +39,7 @@ static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
|
||||||
(void)taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
(void)taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) {
|
static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
dDebug("ip-white-list on dnode ver: %" PRId64 ", status ver: %" PRId64 "", pMgmt->pData->ipWhiteVer, ver);
|
dDebug("ip-white-list on dnode ver: %" PRId64 ", status ver: %" PRId64 "", pMgmt->pData->ipWhiteVer, ver);
|
||||||
|
@ -84,6 +85,7 @@ static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) {
|
||||||
dError("failed to send retrieve ip white list request since:%s", tstrerror(code));
|
dError("failed to send retrieve ip white list request since:%s", tstrerror(code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||||
const STraceId *trace = &pRsp->info.traceId;
|
const STraceId *trace = &pRsp->info.traceId;
|
||||||
dGTrace("status rsp received from mnode, statusSeq:%d code:0x%x", pMgmt->statusSeq, pRsp->code);
|
dGTrace("status rsp received from mnode, statusSeq:%d code:0x%x", pMgmt->statusSeq, pRsp->code);
|
||||||
|
@ -121,6 +123,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SStatusReq req = {0};
|
SStatusReq req = {0};
|
||||||
|
|
||||||
|
dDebug("send status req to mnode, statusSeq:%d, begin to mgnt lock", pMgmt->statusSeq);
|
||||||
(void)taosThreadRwlockRdlock(&pMgmt->pData->lock);
|
(void)taosThreadRwlockRdlock(&pMgmt->pData->lock);
|
||||||
req.sver = tsVersion;
|
req.sver = tsVersion;
|
||||||
req.dnodeVer = pMgmt->pData->dnodeVer;
|
req.dnodeVer = pMgmt->pData->dnodeVer;
|
||||||
|
@ -159,14 +162,17 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
||||||
(void)taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
(void)taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
||||||
|
|
||||||
|
dDebug("send status req to mnode, statusSeq:%d, begin to get vnode loads", pMgmt->statusSeq);
|
||||||
SMonVloadInfo vinfo = {0};
|
SMonVloadInfo vinfo = {0};
|
||||||
(*pMgmt->getVnodeLoadsFp)(&vinfo);
|
(*pMgmt->getVnodeLoadsFp)(&vinfo);
|
||||||
req.pVloads = vinfo.pVloads;
|
req.pVloads = vinfo.pVloads;
|
||||||
|
|
||||||
|
dDebug("send status req to mnode, statusSeq:%d, begin to get mnode loads", pMgmt->statusSeq);
|
||||||
SMonMloadInfo minfo = {0};
|
SMonMloadInfo minfo = {0};
|
||||||
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
||||||
req.mload = minfo.load;
|
req.mload = minfo.load;
|
||||||
|
|
||||||
|
dDebug("send status req to mnode, statusSeq:%d, begin to get qnode loads", pMgmt->statusSeq);
|
||||||
(*pMgmt->getQnodeLoadsFp)(&req.qload);
|
(*pMgmt->getQnodeLoadsFp)(&req.qload);
|
||||||
|
|
||||||
pMgmt->statusSeq++;
|
pMgmt->statusSeq++;
|
||||||
|
@ -204,6 +210,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
int8_t epUpdated = 0;
|
int8_t epUpdated = 0;
|
||||||
(void)dmGetMnodeEpSet(pMgmt->pData, &epSet);
|
(void)dmGetMnodeEpSet(pMgmt->pData, &epSet);
|
||||||
|
|
||||||
|
dDebug("send status req to mnode, statusSeq:%d, begin to send rpc msg", pMgmt->statusSeq);
|
||||||
code =
|
code =
|
||||||
rpcSendRecvWithTimeout(pMgmt->msgCb.statusRpc, &epSet, &rpcMsg, &rpcRsp, &epUpdated, tsStatusInterval * 5 * 1000);
|
rpcSendRecvWithTimeout(pMgmt->msgCb.statusRpc, &epSet, &rpcMsg, &rpcRsp, &epUpdated, tsStatusInterval * 5 * 1000);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = udfStartUdfd(pMgmt->pData->dnodeId)) != 0) {
|
if ((code = udfStartUdfd(pMgmt->pData->dnodeId)) != 0) {
|
||||||
dError("failed to start udfd");
|
dError("failed to start udfd since %s", tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
pOutput->pMgmt = pMgmt;
|
pOutput->pMgmt = pMgmt;
|
||||||
|
|
|
@ -77,6 +77,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vnodeNum;
|
int32_t vnodeNum;
|
||||||
int32_t opened;
|
int32_t opened;
|
||||||
|
int32_t dropped;
|
||||||
int32_t failed;
|
int32_t failed;
|
||||||
bool updateVnodesList;
|
bool updateVnodesList;
|
||||||
int32_t threadIndex;
|
int32_t threadIndex;
|
||||||
|
|
|
@ -311,6 +311,8 @@ static void *vmOpenVnodeInThread(void *param) {
|
||||||
snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, pCfg->vgId);
|
snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, pCfg->vgId);
|
||||||
vnodeDestroy(pCfg->vgId, path, pMgmt->pTfs, 0);
|
vnodeDestroy(pCfg->vgId, path, pMgmt->pTfs, 0);
|
||||||
pThread->updateVnodesList = true;
|
pThread->updateVnodesList = true;
|
||||||
|
pThread->dropped++;
|
||||||
|
(void)atomic_add_fetch_32(&pMgmt->state.dropVnodes, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,8 +354,8 @@ static void *vmOpenVnodeInThread(void *param) {
|
||||||
(void)atomic_add_fetch_32(&pMgmt->state.openVnodes, 1);
|
(void)atomic_add_fetch_32(&pMgmt->state.openVnodes, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("thread:%d, numOfVnodes:%d, opened:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened,
|
dInfo("thread:%d, numOfVnodes:%d, opened:%d dropped:%d failed:%d", pThread->threadIndex, pThread->vnodeNum,
|
||||||
pThread->failed);
|
pThread->opened, pThread->dropped, pThread->failed);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +429,7 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
|
||||||
taosMemoryFree(threads);
|
taosMemoryFree(threads);
|
||||||
taosMemoryFree(pCfgs);
|
taosMemoryFree(pCfgs);
|
||||||
|
|
||||||
if (pMgmt->state.openVnodes != pMgmt->state.totalVnodes) {
|
if ((pMgmt->state.openVnodes + pMgmt->state.dropVnodes) != pMgmt->state.totalVnodes) {
|
||||||
dError("there are total vnodes:%d, opened:%d", pMgmt->state.totalVnodes, pMgmt->state.openVnodes);
|
dError("there are total vnodes:%d, opened:%d", pMgmt->state.totalVnodes, pMgmt->state.openVnodes);
|
||||||
terrno = TSDB_CODE_VND_INIT_FAILED;
|
terrno = TSDB_CODE_VND_INIT_FAILED;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -774,6 +776,7 @@ static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pMgmt->state.openVnodes = 0;
|
pMgmt->state.openVnodes = 0;
|
||||||
|
pMgmt->state.dropVnodes = 0;
|
||||||
dInfo("restore %d vnodes with %d threads", numOfVnodes, threadNum);
|
dInfo("restore %d vnodes with %d threads", numOfVnodes, threadNum);
|
||||||
|
|
||||||
for (int32_t t = 0; t < threadNum; ++t) {
|
for (int32_t t = 0; t < threadNum; ++t) {
|
||||||
|
|
|
@ -65,7 +65,7 @@ int32_t dmInitDnode(SDnode *pDnode) {
|
||||||
snprintf(path, sizeof(path), "%s%s%s", tsDataDir, TD_DIRSEP, pWrapper->name);
|
snprintf(path, sizeof(path), "%s%s%s", tsDataDir, TD_DIRSEP, pWrapper->name);
|
||||||
pWrapper->path = taosStrdup(path);
|
pWrapper->path = taosStrdup(path);
|
||||||
if (pWrapper->path == NULL) {
|
if (pWrapper->path == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ static bool dmIsForbiddenIp(int8_t forbidden, char *user, uint32_t clientIp) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -150,10 +151,9 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
dmSetMnodeEpSet(&pDnode->data, pEpSet);
|
dmSetMnodeEpSet(&pDnode->data, pEpSet);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TDMT_MND_RETRIEVE_IP_WHITE_RSP: {
|
case TDMT_MND_RETRIEVE_IP_WHITE_RSP:
|
||||||
dmUpdateRpcIpWhite(&pDnode->data, pTrans->serverRpc, pRpc);
|
dmUpdateRpcIpWhite(&pDnode->data, pTrans->serverRpc, pRpc);
|
||||||
return;
|
return;
|
||||||
} break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -461,12 +461,12 @@ void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
||||||
|
|
||||||
void dmEpSetToStr(char *buf, int32_t len, SEpSet *epSet) {
|
void dmEpSetToStr(char *buf, int32_t len, SEpSet *epSet) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
n += snprintf(buf + n, len - n, "%s", "{");
|
n += tsnprintf(buf + n, len - n, "%s", "{");
|
||||||
for (int i = 0; i < epSet->numOfEps; i++) {
|
for (int i = 0; i < epSet->numOfEps; i++) {
|
||||||
n += snprintf(buf + n, len - n, "%s:%d%s", epSet->eps[i].fqdn, epSet->eps[i].port,
|
n += tsnprintf(buf + n, len - n, "%s:%d%s", epSet->eps[i].fqdn, epSet->eps[i].port,
|
||||||
(i + 1 < epSet->numOfEps ? ", " : ""));
|
(i + 1 < epSet->numOfEps ? ", " : ""));
|
||||||
}
|
}
|
||||||
n += snprintf(buf + n, len - n, "%s", "}");
|
n += tsnprintf(buf + n, len - n, "%s", "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void dmSwapEps(SEp *epLhs, SEp *epRhs) {
|
static FORCE_INLINE void dmSwapEps(SEp *epLhs, SEp *epRhs) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ IF (TD_ENTERPRISE)
|
||||||
ELSEIF(${BUILD_WITH_COS})
|
ELSEIF(${BUILD_WITH_COS})
|
||||||
add_definitions(-DUSE_COS)
|
add_definitions(-DUSE_COS)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
add_library(mnode STATIC ${MNODE_SRC})
|
add_library(mnode STATIC ${MNODE_SRC})
|
||||||
|
|
|
@ -445,7 +445,7 @@ static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) {
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, dnodeId);
|
SDnodeObj *pDnode = mndAcquireDnode(pMnode, dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
mError("dnodeId:%d, timer failed to send arb-hb request, failed find dnode", dnodeId);
|
mError("dnodeId:%d, timer failed to acquire dnode", dnodeId);
|
||||||
taosArrayDestroy(hbMembers);
|
taosArrayDestroy(hbMembers);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -453,7 +453,10 @@ static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) {
|
||||||
int64_t mndTerm = mndGetTerm(pMnode);
|
int64_t mndTerm = mndGetTerm(pMnode);
|
||||||
|
|
||||||
if (mndIsDnodeOnline(pDnode, nowMs)) {
|
if (mndIsDnodeOnline(pDnode, nowMs)) {
|
||||||
TAOS_CHECK_RETURN(mndSendArbHeartBeatReq(pDnode, arbToken, mndTerm, hbMembers));
|
int32_t sendCode = mndSendArbHeartBeatReq(pDnode, arbToken, mndTerm, hbMembers);
|
||||||
|
if (TSDB_CODE_SUCCESS != sendCode) {
|
||||||
|
mError("dnodeId:%d, timer failed to send arb-hb request", dnodeId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
|
|
@ -241,7 +241,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
|
||||||
clusterObj.createdTime = taosGetTimestampMs();
|
clusterObj.createdTime = taosGetTimestampMs();
|
||||||
clusterObj.updateTime = clusterObj.createdTime;
|
clusterObj.updateTime = clusterObj.createdTime;
|
||||||
|
|
||||||
int32_t code = taosGetSystemUUID(clusterObj.name, TSDB_CLUSTER_ID_LEN);
|
int32_t code = taosGetSystemUUIDLen(clusterObj.name, TSDB_CLUSTER_ID_LEN);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
(void)strcpy(clusterObj.name, "tdengine3.0");
|
(void)strcpy(clusterObj.name, "tdengine3.0");
|
||||||
mError("failed to get name from system, set to default val %s", clusterObj.name);
|
mError("failed to get name from system, set to default val %s", clusterObj.name);
|
||||||
|
|
|
@ -640,10 +640,10 @@ void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact) {
|
||||||
rpcMsg.pCont = pHead;
|
rpcMsg.pCont = pHead;
|
||||||
|
|
||||||
char detail[1024] = {0};
|
char detail[1024] = {0};
|
||||||
int32_t len = snprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d",
|
int32_t len = tsnprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d",
|
||||||
TMSG_INFO(TDMT_VND_QUERY_COMPACT_PROGRESS), epSet.numOfEps, epSet.inUse);
|
TMSG_INFO(TDMT_VND_QUERY_COMPACT_PROGRESS), epSet.numOfEps, epSet.inUse);
|
||||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||||
len += snprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
len += tsnprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("compact:%d, send update progress msg to %s", pDetail->compactId, detail);
|
mDebug("compact:%d, send update progress msg to %s", pDetail->compactId, detail);
|
||||||
|
|
|
@ -167,7 +167,7 @@ static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbRs
|
||||||
}
|
}
|
||||||
STopicPrivilege *data = taosArrayReserve(rsp->topicPrivileges, 1);
|
STopicPrivilege *data = taosArrayReserve(rsp->topicPrivileges, 1);
|
||||||
MND_TMQ_NULL_CHECK(data);
|
MND_TMQ_NULL_CHECK(data);
|
||||||
(void)strcpy(data->topic, topic);
|
tstrncpy(data->topic, topic, TSDB_TOPIC_FNAME_LEN);
|
||||||
if (mndCheckTopicPrivilege(pMnode, user, MND_OPER_SUBSCRIBE, pTopic) != 0 ||
|
if (mndCheckTopicPrivilege(pMnode, user, MND_OPER_SUBSCRIBE, pTopic) != 0 ||
|
||||||
grantCheckExpire(TSDB_GRANT_SUBSCRIPTION) < 0) {
|
grantCheckExpire(TSDB_GRANT_SUBSCRIPTION) < 0) {
|
||||||
data->noPrivilege = 1;
|
data->noPrivilege = 1;
|
||||||
|
@ -244,6 +244,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
storeOffsetRows(pMnode, &req, pConsumer);
|
storeOffsetRows(pMnode, &req, pConsumer);
|
||||||
|
rsp.debugFlag = tqClientDebug;
|
||||||
code = buildMqHbRsp(pMsg, &rsp);
|
code = buildMqHbRsp(pMsg, &rsp);
|
||||||
|
|
||||||
END:
|
END:
|
||||||
|
@ -277,7 +278,7 @@ static int32_t addEpSetInfo(SMnode *pMnode, SMqConsumerObj *pConsumer, int32_t e
|
||||||
taosRLockLatch(&pSub->lock);
|
taosRLockLatch(&pSub->lock);
|
||||||
|
|
||||||
SMqSubTopicEp topicEp = {0};
|
SMqSubTopicEp topicEp = {0};
|
||||||
(void)strcpy(topicEp.topic, topic);
|
tstrncpy(topicEp.topic, topic, TSDB_TOPIC_FNAME_LEN);
|
||||||
|
|
||||||
// 2.1 fetch topic schema
|
// 2.1 fetch topic schema
|
||||||
SMqTopicObj *pTopic = NULL;
|
SMqTopicObj *pTopic = NULL;
|
||||||
|
@ -587,8 +588,8 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
||||||
|
|
||||||
SCMSubscribeReq subscribe = {0};
|
SCMSubscribeReq subscribe = {0};
|
||||||
MND_TMQ_RETURN_CHECK(tDeserializeSCMSubscribeReq(msgStr, &subscribe, pMsg->contLen));
|
MND_TMQ_RETURN_CHECK(tDeserializeSCMSubscribeReq(msgStr, &subscribe, pMsg->contLen));
|
||||||
bool ubSubscribe = (taosArrayGetSize(subscribe.topicNames) == 0);
|
bool unSubscribe = (taosArrayGetSize(subscribe.topicNames) == 0);
|
||||||
if(ubSubscribe){
|
if(unSubscribe){
|
||||||
SMqConsumerObj *pConsumerTmp = NULL;
|
SMqConsumerObj *pConsumerTmp = NULL;
|
||||||
MND_TMQ_RETURN_CHECK(mndAcquireConsumer(pMnode, subscribe.consumerId, &pConsumerTmp));
|
MND_TMQ_RETURN_CHECK(mndAcquireConsumer(pMnode, subscribe.consumerId, &pConsumerTmp));
|
||||||
if (taosArrayGetSize(pConsumerTmp->assignedTopics) == 0){
|
if (taosArrayGetSize(pConsumerTmp->assignedTopics) == 0){
|
||||||
|
@ -599,7 +600,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
MND_TMQ_RETURN_CHECK(checkAndSortTopic(pMnode, subscribe.topicNames));
|
MND_TMQ_RETURN_CHECK(checkAndSortTopic(pMnode, subscribe.topicNames));
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY,
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY,
|
||||||
(ubSubscribe ? TRN_CONFLICT_NOTHING :TRN_CONFLICT_DB_INSIDE),
|
(unSubscribe ? TRN_CONFLICT_NOTHING :TRN_CONFLICT_DB_INSIDE),
|
||||||
pMsg, "subscribe");
|
pMsg, "subscribe");
|
||||||
MND_TMQ_NULL_CHECK(pTrans);
|
MND_TMQ_NULL_CHECK(pTrans);
|
||||||
|
|
||||||
|
@ -909,7 +910,7 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
||||||
|
|
||||||
// consumer id
|
// consumer id
|
||||||
char consumerIdHex[TSDB_CONSUMER_ID_LEN + VARSTR_HEADER_SIZE] = {0};
|
char consumerIdHex[TSDB_CONSUMER_ID_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
(void)sprintf(varDataVal(consumerIdHex), "0x%" PRIx64, pConsumer->consumerId);
|
(void)snprintf(varDataVal(consumerIdHex), TSDB_CONSUMER_ID_LEN, "0x%" PRIx64, pConsumer->consumerId);
|
||||||
varDataSetLen(consumerIdHex, strlen(varDataVal(consumerIdHex)));
|
varDataSetLen(consumerIdHex, strlen(varDataVal(consumerIdHex)));
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
@ -992,7 +993,7 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
||||||
|
|
||||||
parasStr = taosMemoryCalloc(1, pShow->pMeta->pSchemas[cols].bytes);
|
parasStr = taosMemoryCalloc(1, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
MND_TMQ_NULL_CHECK(parasStr);
|
MND_TMQ_NULL_CHECK(parasStr);
|
||||||
(void)sprintf(varDataVal(parasStr), "tbname:%d,commit:%d,interval:%dms,reset:%s", pConsumer->withTbName,
|
(void)snprintf(varDataVal(parasStr), pShow->pMeta->pSchemas[cols].bytes - VARSTR_HEADER_SIZE, "tbname:%d,commit:%d,interval:%dms,reset:%s", pConsumer->withTbName,
|
||||||
pConsumer->autoCommit, pConsumer->autoCommitInterval, buf);
|
pConsumer->autoCommit, pConsumer->autoCommitInterval, buf);
|
||||||
varDataSetLen(parasStr, strlen(varDataVal(parasStr)));
|
varDataSetLen(parasStr, strlen(varDataVal(parasStr)));
|
||||||
|
|
||||||
|
|
|
@ -2366,7 +2366,7 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
||||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, rows, (const char *)strictVstr, false), &lino, _OVER);
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, rows, (const char *)strictVstr, false), &lino, _OVER);
|
||||||
|
|
||||||
char durationVstr[128] = {0};
|
char durationVstr[128] = {0};
|
||||||
int32_t len = formatDurationOrKeep(&durationVstr[VARSTR_HEADER_SIZE], pDb->cfg.daysPerFile);
|
int32_t len = formatDurationOrKeep(&durationVstr[VARSTR_HEADER_SIZE], sizeof(durationVstr) - VARSTR_HEADER_SIZE, pDb->cfg.daysPerFile);
|
||||||
|
|
||||||
varDataSetLen(durationVstr, len);
|
varDataSetLen(durationVstr, len);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
@ -2377,9 +2377,9 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
||||||
char keep1Str[128] = {0};
|
char keep1Str[128] = {0};
|
||||||
char keep2Str[128] = {0};
|
char keep2Str[128] = {0};
|
||||||
|
|
||||||
int32_t lenKeep0 = formatDurationOrKeep(keep0Str, pDb->cfg.daysToKeep0);
|
int32_t lenKeep0 = formatDurationOrKeep(keep0Str, sizeof(keep0Str), pDb->cfg.daysToKeep0);
|
||||||
int32_t lenKeep1 = formatDurationOrKeep(keep1Str, pDb->cfg.daysToKeep1);
|
int32_t lenKeep1 = formatDurationOrKeep(keep1Str, sizeof(keep1Str), pDb->cfg.daysToKeep1);
|
||||||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, pDb->cfg.daysToKeep2);
|
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, sizeof(keep2Str), pDb->cfg.daysToKeep2);
|
||||||
|
|
||||||
if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) {
|
if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) {
|
||||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep1Str, keep2Str, keep0Str);
|
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep1Str, keep2Str, keep0Str);
|
||||||
|
|
|
@ -693,7 +693,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
int64_t clusterid = mndGetClusterId(pMnode);
|
int64_t clusterid = mndGetClusterId(pMnode);
|
||||||
if (statusReq.clusterId != 0 && statusReq.clusterId != clusterid) {
|
if (statusReq.clusterId != 0 && statusReq.clusterId != clusterid) {
|
||||||
code = TSDB_CODE_MND_DNODE_DIFF_CLUSTER;
|
code = TSDB_CODE_MND_DNODE_DIFF_CLUSTER;
|
||||||
mWarn("dnode:%d, %s, its clusterid:%" PRId64 " differ from current cluster:%" PRId64 ", code:0x%x",
|
mWarn("dnode:%d, %s, its clusterid:%" PRId64 " differ from current clusterid:%" PRId64 ", code:0x%x",
|
||||||
statusReq.dnodeId, statusReq.dnodeEp, statusReq.clusterId, clusterid, code);
|
statusReq.dnodeId, statusReq.dnodeEp, statusReq.clusterId, clusterid, code);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -740,7 +740,6 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
bool enableWhiteListChanged = statusReq.clusterCfg.enableWhiteList != (tsEnableWhiteList ? 1 : 0);
|
bool enableWhiteListChanged = statusReq.clusterCfg.enableWhiteList != (tsEnableWhiteList ? 1 : 0);
|
||||||
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged ||
|
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged ||
|
||||||
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged || enableWhiteListChanged;
|
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged || enableWhiteListChanged;
|
||||||
|
|
||||||
const STraceId *trace = &pReq->info.traceId;
|
const STraceId *trace = &pReq->info.traceId;
|
||||||
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||||
pDnode->accessTimes, needCheck, online, reboot, dnodeChanged, statusReq.statusSeq);
|
pDnode->accessTimes, needCheck, online, reboot, dnodeChanged, statusReq.statusSeq);
|
||||||
|
|
|
@ -495,7 +495,7 @@ static int32_t mndCreateDir(SMnode *pMnode, const char *path) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
pMnode->path = taosStrdup(path);
|
pMnode->path = taosStrdup(path);
|
||||||
if (pMnode->path == NULL) {
|
if (pMnode->path == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = terrno;
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,6 +515,7 @@ static int32_t mndInitWal(SMnode *pMnode) {
|
||||||
.fsyncPeriod = 0,
|
.fsyncPeriod = 0,
|
||||||
.rollPeriod = -1,
|
.rollPeriod = -1,
|
||||||
.segSize = -1,
|
.segSize = -1,
|
||||||
|
.committed = -1,
|
||||||
.retentionPeriod = 0,
|
.retentionPeriod = 0,
|
||||||
.retentionSize = 0,
|
.retentionSize = 0,
|
||||||
.level = TAOS_WAL_FSYNC,
|
.level = TAOS_WAL_FSYNC,
|
||||||
|
@ -574,6 +575,8 @@ static int32_t mndOpenSdb(SMnode *pMnode) {
|
||||||
code = sdbReadFile(pMnode->pSdb);
|
code = sdbReadFile(pMnode->pSdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mInfo("vgId:1, mnode sdb is opened, with applied index:%" PRId64, pMnode->pSdb->commitIndex);
|
||||||
|
|
||||||
atomic_store_64(&pMnode->applied, pMnode->pSdb->commitIndex);
|
atomic_store_64(&pMnode->applied, pMnode->pSdb->commitIndex);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
|
||||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||||
|
|
||||||
char connStr[255] = {0};
|
char connStr[255] = {0};
|
||||||
int32_t len = snprintf(connStr, sizeof(connStr), "%s%d%d%d%s", user, ip, port, pid, app);
|
int32_t len = tsnprintf(connStr, sizeof(connStr), "%s%d%d%d%s", user, ip, port, pid, app);
|
||||||
uint32_t connId = mndGenerateUid(connStr, len);
|
uint32_t connId = mndGenerateUid(connStr, len);
|
||||||
if (startTime == 0) startTime = taosGetTimestampMs();
|
if (startTime == 0) startTime = taosGetTimestampMs();
|
||||||
|
|
||||||
|
|
|
@ -1231,7 +1231,7 @@ static int32_t mndGetSma(SMnode *pMnode, SUserIndexReq *indexReq, SUserIndexRsp
|
||||||
SNode *node = NULL;
|
SNode *node = NULL;
|
||||||
FOREACH(node, pList) {
|
FOREACH(node, pList) {
|
||||||
SFunctionNode *pFunc = (SFunctionNode *)node;
|
SFunctionNode *pFunc = (SFunctionNode *)node;
|
||||||
extOffset += snprintf(rsp->indexExts + extOffset, sizeof(rsp->indexExts) - extOffset - 1, "%s%s",
|
extOffset += tsnprintf(rsp->indexExts + extOffset, sizeof(rsp->indexExts) - extOffset - 1, "%s%s",
|
||||||
(extOffset ? "," : ""), pFunc->functionName);
|
(extOffset ? "," : ""), pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2221,10 +2221,10 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (!IS_CALENDAR_TIME_DURATION(pSma->intervalUnit)) {
|
if (!IS_CALENDAR_TIME_DURATION(pSma->intervalUnit)) {
|
||||||
len = snprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval,
|
len = tsnprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval,
|
||||||
getPrecisionUnit(pSrcDb->cfg.precision));
|
getPrecisionUnit(pSrcDb->cfg.precision));
|
||||||
} else {
|
} else {
|
||||||
len = snprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval, pSma->intervalUnit);
|
len = tsnprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval, pSma->intervalUnit);
|
||||||
}
|
}
|
||||||
varDataSetLen(interval, len);
|
varDataSetLen(interval, len);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
@ -2235,7 +2235,7 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
// create sql
|
// create sql
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
len = snprintf(buf + VARSTR_HEADER_SIZE, TSDB_MAX_SAVED_SQL_LEN, "%s", pSma->sql);
|
len = tsnprintf(buf + VARSTR_HEADER_SIZE, TSDB_MAX_SAVED_SQL_LEN, "%s", pSma->sql);
|
||||||
varDataSetLen(buf, TMIN(len, TSDB_MAX_SAVED_SQL_LEN));
|
varDataSetLen(buf, TMIN(len, TSDB_MAX_SAVED_SQL_LEN));
|
||||||
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||||
}
|
}
|
||||||
|
@ -2350,7 +2350,7 @@ int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STa
|
||||||
nodesDestroyNode(pNode);
|
nodesDestroyNode(pNode);
|
||||||
}
|
}
|
||||||
pInfo->ast = taosStrdup(pSma->ast);
|
pInfo->ast = taosStrdup(pSma->ast);
|
||||||
if (!pInfo->ast) code = TSDB_CODE_OUT_OF_MEMORY;
|
if (!pInfo->ast) code = terrno;
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS && pDestStb->numOfTags > 0) {
|
if (code == TSDB_CODE_SUCCESS && pDestStb->numOfTags > 0) {
|
||||||
pInfo->pTags = taosArrayInit(pDestStb->numOfTags, sizeof(SSchema));
|
pInfo->pTags = taosArrayInit(pDestStb->numOfTags, sizeof(SSchema));
|
||||||
|
|
|
@ -231,6 +231,7 @@ static int32_t doSetUpdateTaskAction(SMnode *pMnode, STrans *pTrans, SStreamTask
|
||||||
code = extractNodeEpset(pMnode, &epset, &hasEpset, pTask->id.taskId, pTask->info.nodeId);
|
code = extractNodeEpset(pMnode, &epset, &hasEpset, pTask->id.taskId, pTask->info.nodeId);
|
||||||
if (code != TSDB_CODE_SUCCESS || !hasEpset) {
|
if (code != TSDB_CODE_SUCCESS || !hasEpset) {
|
||||||
mError("failed to extract epset during create update epset, code:%s", tstrerror(code));
|
mError("failed to extract epset during create update epset, code:%s", tstrerror(code));
|
||||||
|
taosMemoryFree(pBuf);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,12 +187,12 @@ static void mndSplitSubscribeKey(const char *key, char *topic, char *cgroup, boo
|
||||||
(void)memcpy(cgroup, key, i);
|
(void)memcpy(cgroup, key, i);
|
||||||
cgroup[i] = 0;
|
cgroup[i] = 0;
|
||||||
if (fullName) {
|
if (fullName) {
|
||||||
(void)strcpy(topic, &key[i + 1]);
|
tstrncpy(topic, &key[i + 1], TSDB_TOPIC_FNAME_LEN);
|
||||||
} else {
|
} else {
|
||||||
while (key[i] != '.') {
|
while (key[i] != '.') {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
(void)strcpy(topic, &key[i + 1]);
|
tstrncpy(topic, &key[i + 1], TSDB_CGROUP_LEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1361,7 +1361,7 @@ static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t cons
|
||||||
|
|
||||||
// consumer id
|
// consumer id
|
||||||
char consumerIdHex[TSDB_CONSUMER_ID_LEN] = {0};
|
char consumerIdHex[TSDB_CONSUMER_ID_LEN] = {0};
|
||||||
(void)sprintf(varDataVal(consumerIdHex), "0x%" PRIx64, consumerId);
|
(void)snprintf(varDataVal(consumerIdHex), TSDB_CONSUMER_ID_LEN - VARSTR_HEADER_SIZE, "0x%" PRIx64, consumerId);
|
||||||
varDataSetLen(consumerIdHex, strlen(varDataVal(consumerIdHex)));
|
varDataSetLen(consumerIdHex, strlen(varDataVal(consumerIdHex)));
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
@ -1398,7 +1398,8 @@ static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t cons
|
||||||
// vg id
|
// vg id
|
||||||
char buf[TSDB_OFFSET_LEN * 2 + VARSTR_HEADER_SIZE] = {0};
|
char buf[TSDB_OFFSET_LEN * 2 + VARSTR_HEADER_SIZE] = {0};
|
||||||
(void)tFormatOffset(varDataVal(buf), TSDB_OFFSET_LEN, &data->offset);
|
(void)tFormatOffset(varDataVal(buf), TSDB_OFFSET_LEN, &data->offset);
|
||||||
(void)sprintf(varDataVal(buf) + strlen(varDataVal(buf)), "/%" PRId64, data->ever);
|
(void)snprintf(varDataVal(buf) + strlen(varDataVal(buf)),
|
||||||
|
sizeof(buf) - VARSTR_HEADER_SIZE - strlen(varDataVal(buf)), "/%" PRId64, data->ever);
|
||||||
varDataSetLen(buf, strlen(varDataVal(buf)));
|
varDataSetLen(buf, strlen(varDataVal(buf)));
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
MND_TMQ_NULL_CHECK(pColInfo);
|
MND_TMQ_NULL_CHECK(pColInfo);
|
||||||
|
|
|
@ -637,7 +637,7 @@ void mndSyncStop(SMnode *pMnode) {
|
||||||
|
|
||||||
(void)taosThreadMutexLock(&pMgmt->lock);
|
(void)taosThreadMutexLock(&pMgmt->lock);
|
||||||
if (pMgmt->transId != 0) {
|
if (pMgmt->transId != 0) {
|
||||||
mInfo("vgId:1, is stopped and post sem, trans:%d", pMgmt->transId);
|
mInfo("vgId:1, trans:%d, is stopped and post sem", pMgmt->transId);
|
||||||
pMgmt->transId = 0;
|
pMgmt->transId = 0;
|
||||||
pMgmt->transSec = 0;
|
pMgmt->transSec = 0;
|
||||||
pMgmt->errCode = TSDB_CODE_APP_IS_STOPPING;
|
pMgmt->errCode = TSDB_CODE_APP_IS_STOPPING;
|
||||||
|
|
|
@ -589,6 +589,7 @@ STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId) {
|
||||||
|
|
||||||
void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) {
|
void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
if (pTrans != NULL) mInfo("vgId:1, trans:%d, release transaction", pTrans->id);
|
||||||
sdbRelease(pSdb, pTrans);
|
sdbRelease(pSdb, pTrans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1131,10 +1132,11 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
||||||
if (!sendRsp) {
|
if (!sendRsp) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
mInfo("trans:%d, send rsp, stage:%s failedTimes:%d code:0x%x", pTrans->id, mndTransStr(pTrans->stage),
|
mInfo("vgId:1, trans:%d, start to send rsp, stage:%s failedTimes:%d code:0x%x", pTrans->id,
|
||||||
pTrans->failedTimes, code);
|
mndTransStr(pTrans->stage), pTrans->failedTimes, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mInfo("vgId:1, trans:%d, start to lock rpc array", pTrans->id);
|
||||||
taosWLockLatch(&pTrans->lockRpcArray);
|
taosWLockLatch(&pTrans->lockRpcArray);
|
||||||
int32_t size = taosArrayGetSize(pTrans->pRpcArray);
|
int32_t size = taosArrayGetSize(pTrans->pRpcArray);
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
|
@ -1155,8 +1157,8 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
||||||
if (i != 0 && code == 0) {
|
if (i != 0 && code == 0) {
|
||||||
code = TSDB_CODE_MNODE_NOT_FOUND;
|
code = TSDB_CODE_MNODE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
mInfo("trans:%d, client:%d send rsp, code:0x%x stage:%s app:%p", pTrans->id, i, code, mndTransStr(pTrans->stage),
|
mInfo("vgId:1, trans:%d, client:%d start to send rsp, code:0x%x stage:%s app:%p", pTrans->id, i, code,
|
||||||
pInfo->ahandle);
|
mndTransStr(pTrans->stage), pInfo->ahandle);
|
||||||
|
|
||||||
SRpcMsg rspMsg = {.code = code, .info = *pInfo};
|
SRpcMsg rspMsg = {.code = code, .info = *pInfo};
|
||||||
|
|
||||||
|
@ -1199,6 +1201,9 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tmsgSendRsp(&rspMsg);
|
tmsgSendRsp(&rspMsg);
|
||||||
|
|
||||||
|
mInfo("vgId:1, trans:%d, client:%d send rsp finished, code:0x%x stage:%s app:%p", pTrans->id, i, code,
|
||||||
|
mndTransStr(pTrans->stage), pInfo->ahandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosArrayClear(pTrans->pRpcArray);
|
taosArrayClear(pTrans->pRpcArray);
|
||||||
|
@ -1247,8 +1252,9 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
|
||||||
pAction->errCode = pRsp->code;
|
pAction->errCode = pRsp->code;
|
||||||
pTrans->lastErrorNo = pRsp->code;
|
pTrans->lastErrorNo = pRsp->code;
|
||||||
|
|
||||||
mInfo("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId,
|
mInfo("trans:%d, %s:%d response is received, received code:0x%x(%s), accept:0x%x(%s) retry:0x%x(%s)", transId,
|
||||||
mndTransStr(pAction->stage), action, pRsp->code, pAction->acceptableCode, pAction->retryCode);
|
mndTransStr(pAction->stage), action, pRsp->code, tstrerror(pRsp->code), pAction->acceptableCode,
|
||||||
|
tstrerror(pAction->acceptableCode), pAction->retryCode, tstrerror(pAction->retryCode));
|
||||||
} else {
|
} else {
|
||||||
mInfo("trans:%d, invalid action, index:%d, code:0x%x", transId, action, pRsp->code);
|
mInfo("trans:%d, invalid action, index:%d, code:0x%x", transId, action, pRsp->code);
|
||||||
}
|
}
|
||||||
|
@ -1338,10 +1344,10 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
|
||||||
memcpy(rpcMsg.pCont, pAction->pCont, pAction->contLen);
|
memcpy(rpcMsg.pCont, pAction->pCont, pAction->contLen);
|
||||||
|
|
||||||
char detail[1024] = {0};
|
char detail[1024] = {0};
|
||||||
int32_t len = snprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d", TMSG_INFO(pAction->msgType),
|
int32_t len = tsnprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d", TMSG_INFO(pAction->msgType),
|
||||||
pAction->epSet.numOfEps, pAction->epSet.inUse);
|
pAction->epSet.numOfEps, pAction->epSet.inUse);
|
||||||
for (int32_t i = 0; i < pAction->epSet.numOfEps; ++i) {
|
for (int32_t i = 0; i < pAction->epSet.numOfEps; ++i) {
|
||||||
len += snprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, pAction->epSet.eps[i].fqdn,
|
len += tsnprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, pAction->epSet.eps[i].fqdn,
|
||||||
pAction->epSet.eps[i].port);
|
pAction->epSet.eps[i].port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1464,8 +1470,8 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
|
||||||
static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->redoActions, topHalf);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->redoActions, topHalf);
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
||||||
mError("trans:%d, failed to execute redoActions since:%s, code:0x%x, topHalf:%d", pTrans->id, terrstr(), terrno,
|
mError("trans:%d, failed to execute redoActions since:%s, code:0x%x, topHalf(TransContext):%d", pTrans->id,
|
||||||
topHalf);
|
terrstr(), terrno, topHalf);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1473,7 +1479,8 @@ static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans, bool t
|
||||||
static int32_t mndTransExecuteUndoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static int32_t mndTransExecuteUndoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->undoActions, topHalf);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->undoActions, topHalf);
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
||||||
mError("trans:%d, failed to execute undoActions since %s. topHalf:%d", pTrans->id, terrstr(), topHalf);
|
mError("trans:%d, failed to execute undoActions since %s. topHalf(TransContext):%d", pTrans->id, terrstr(),
|
||||||
|
topHalf);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1481,7 +1488,8 @@ static int32_t mndTransExecuteUndoActions(SMnode *pMnode, STrans *pTrans, bool t
|
||||||
static int32_t mndTransExecuteCommitActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static int32_t mndTransExecuteCommitActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->commitActions, topHalf);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->commitActions, topHalf);
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
||||||
mError("trans:%d, failed to execute commitActions since %s. topHalf:%d", pTrans->id, terrstr(), topHalf);
|
mError("trans:%d, failed to execute commitActions since %s. topHalf(TransContext):%d", pTrans->id, terrstr(),
|
||||||
|
topHalf);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1495,11 +1503,15 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("trans:%d, execute %d actions serial, current redoAction:%d", pTrans->id, numOfActions, pTrans->actionPos);
|
mInfo("trans:%d, execute %d actions serial, begin at action:%d, stage:%s", pTrans->id, numOfActions,
|
||||||
|
pTrans->actionPos, mndTransStr(pTrans->stage));
|
||||||
|
|
||||||
for (int32_t action = pTrans->actionPos; action < numOfActions; ++action) {
|
for (int32_t action = pTrans->actionPos; action < numOfActions; ++action) {
|
||||||
STransAction *pAction = taosArrayGet(pActions, action);
|
STransAction *pAction = taosArrayGet(pActions, action);
|
||||||
|
|
||||||
|
mInfo("trans:%d, current action:%d, stage:%s, actionType(0:log,1:msg):%d", pTrans->id, pTrans->actionPos,
|
||||||
|
mndTransStr(pAction->stage), pAction->actionType);
|
||||||
|
|
||||||
code = mndTransExecSingleAction(pMnode, pTrans, pAction, topHalf);
|
code = mndTransExecSingleAction(pMnode, pTrans, pAction, topHalf);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
if (pAction->msgSent) {
|
if (pAction->msgSent) {
|
||||||
|
@ -1531,8 +1543,8 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
||||||
if (mndCannotExecuteTransAction(pMnode, topHalf)) {
|
if (mndCannotExecuteTransAction(pMnode, topHalf)) {
|
||||||
pTrans->lastErrorNo = code;
|
pTrans->lastErrorNo = code;
|
||||||
pTrans->code = code;
|
pTrans->code = code;
|
||||||
mInfo("trans:%d, %s:%d, topHalf:%d, not execute next action, code:%s", pTrans->id, mndTransStr(pAction->stage),
|
mInfo("trans:%d, %s:%d, topHalf(TransContext):%d, not execute next action, code:%s", pTrans->id,
|
||||||
action, topHalf, tstrerror(code));
|
mndTransStr(pAction->stage), action, topHalf, tstrerror(code));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1556,7 +1568,8 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
||||||
break;
|
break;
|
||||||
} else if (code == pAction->retryCode || code == TSDB_CODE_SYN_PROPOSE_NOT_READY ||
|
} else if (code == pAction->retryCode || code == TSDB_CODE_SYN_PROPOSE_NOT_READY ||
|
||||||
code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_SYN_NOT_LEADER) {
|
code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
mInfo("trans:%d, %s:%d receive code:0x%x and retry", pTrans->id, mndTransStr(pAction->stage), pAction->id, code);
|
mInfo("trans:%d, %s:%d receive code:0x%x(%s) and retry", pTrans->id, mndTransStr(pAction->stage), pAction->id,
|
||||||
|
code, tstrerror(code));
|
||||||
pTrans->lastErrorNo = code;
|
pTrans->lastErrorNo = code;
|
||||||
taosMsleep(300);
|
taosMsleep(300);
|
||||||
action--;
|
action--;
|
||||||
|
@ -1565,8 +1578,8 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
||||||
terrno = code;
|
terrno = code;
|
||||||
pTrans->lastErrorNo = code;
|
pTrans->lastErrorNo = code;
|
||||||
pTrans->code = code;
|
pTrans->code = code;
|
||||||
mInfo("trans:%d, %s:%d receive code:0x%x and wait another schedule, failedTimes:%d", pTrans->id,
|
mInfo("trans:%d, %s:%d receive code:0x%x(%s) and wait another schedule, failedTimes:%d", pTrans->id,
|
||||||
mndTransStr(pAction->stage), pAction->id, code, pTrans->failedTimes);
|
mndTransStr(pAction->stage), pAction->id, code, tstrerror(code), pTrans->failedTimes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1637,12 +1650,13 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans, bool
|
||||||
pTrans->code = code;
|
pTrans->code = code;
|
||||||
bool continueExec = true;
|
bool continueExec = true;
|
||||||
if (code != 0 && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
if (code != 0 && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
||||||
|
taosMsleep(100);
|
||||||
continueExec = true;
|
continueExec = true;
|
||||||
} else {
|
} else {
|
||||||
continueExec = false;
|
continueExec = false;
|
||||||
}
|
}
|
||||||
mInfo("trans:%d, cannot execute redo action stage, topHalf:%d, continueExec:%d, code:%s", pTrans->id, topHalf,
|
mInfo("trans:%d, cannot execute redo action stage, topHalf(TransContext):%d, continueExec:%d, code:%s", pTrans->id,
|
||||||
continueExec, tstrerror(code));
|
topHalf, continueExec, tstrerror(code));
|
||||||
|
|
||||||
return continueExec;
|
return continueExec;
|
||||||
}
|
}
|
||||||
|
@ -1674,7 +1688,9 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
pTrans->stage = TRN_STAGE_ROLLBACK;
|
pTrans->stage = TRN_STAGE_ROLLBACK;
|
||||||
mError("trans:%d, stage from redoAction to rollback since %s", pTrans->id, terrstr());
|
pTrans->actionPos = 0;
|
||||||
|
mError("trans:%d, stage from redoAction to rollback since %s, and set actionPos to %d", pTrans->id, terrstr(),
|
||||||
|
pTrans->actionPos);
|
||||||
continueExec = true;
|
continueExec = true;
|
||||||
} else {
|
} else {
|
||||||
mError("trans:%d, stage keep on redoAction since %s, failedTimes:%d", pTrans->id, terrstr(), pTrans->failedTimes);
|
mError("trans:%d, stage keep on redoAction since %s, failedTimes:%d", pTrans->id, terrstr(), pTrans->failedTimes);
|
||||||
|
@ -1767,7 +1783,6 @@ static bool mndTransPerformRollbackStage(SMnode *pMnode, STrans *pTrans, bool to
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
pTrans->stage = TRN_STAGE_UNDO_ACTION;
|
pTrans->stage = TRN_STAGE_UNDO_ACTION;
|
||||||
mInfo("trans:%d, stage from rollback to undoAction", pTrans->id);
|
|
||||||
continueExec = true;
|
continueExec = true;
|
||||||
} else {
|
} else {
|
||||||
pTrans->failedTimes++;
|
pTrans->failedTimes++;
|
||||||
|
@ -1822,7 +1837,7 @@ void mndTransExecuteImp(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
bool continueExec = true;
|
bool continueExec = true;
|
||||||
|
|
||||||
while (continueExec) {
|
while (continueExec) {
|
||||||
mInfo("trans:%d, continue to execute, stage:%s createTime:%" PRId64 " topHalf:%d", pTrans->id,
|
mInfo("trans:%d, continue to execute, stage:%s createTime:%" PRId64 " topHalf(TransContext):%d", pTrans->id,
|
||||||
mndTransStr(pTrans->stage), pTrans->createdTime, topHalf);
|
mndTransStr(pTrans->stage), pTrans->createdTime, topHalf);
|
||||||
pTrans->lastExecTime = taosGetTimestampMs();
|
pTrans->lastExecTime = taosGetTimestampMs();
|
||||||
switch (pTrans->stage) {
|
switch (pTrans->stage) {
|
||||||
|
@ -2017,14 +2032,14 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
|
|
||||||
char lastInfo[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0};
|
char lastInfo[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
char detail[TSDB_TRANS_ERROR_LEN + 1] = {0};
|
char detail[TSDB_TRANS_ERROR_LEN + 1] = {0};
|
||||||
int32_t len = snprintf(detail, sizeof(detail), "action:%d code:0x%x(%s) ", pTrans->lastAction,
|
int32_t len = tsnprintf(detail, sizeof(detail), "action:%d code:0x%x(%s) ", pTrans->lastAction,
|
||||||
pTrans->lastErrorNo & 0xFFFF, tstrerror(pTrans->lastErrorNo));
|
pTrans->lastErrorNo & 0xFFFF, tstrerror(pTrans->lastErrorNo));
|
||||||
SEpSet epset = pTrans->lastEpset;
|
SEpSet epset = pTrans->lastEpset;
|
||||||
if (epset.numOfEps > 0) {
|
if (epset.numOfEps > 0) {
|
||||||
len += snprintf(detail + len, sizeof(detail) - len, "msgType:%s numOfEps:%d inUse:%d ",
|
len += tsnprintf(detail + len, sizeof(detail) - len, "msgType:%s numOfEps:%d inUse:%d ",
|
||||||
TMSG_INFO(pTrans->lastMsgType), epset.numOfEps, epset.inUse);
|
TMSG_INFO(pTrans->lastMsgType), epset.numOfEps, epset.inUse);
|
||||||
for (int32_t i = 0; i < pTrans->lastEpset.numOfEps; ++i) {
|
for (int32_t i = 0; i < pTrans->lastEpset.numOfEps; ++i) {
|
||||||
len += snprintf(detail + len, sizeof(detail) - len, "ep:%d-%s:%u ", i, epset.eps[i].fqdn, epset.eps[i].port);
|
len += tsnprintf(detail + len, sizeof(detail) - len, "ep:%d-%s:%u ", i, epset.eps[i].fqdn, epset.eps[i].port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(lastInfo, detail, pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(lastInfo, detail, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
|
|
@ -594,7 +594,7 @@ int32_t mndFetchAllIpWhite(SMnode *pMnode, SHashObj **ppIpWhiteTab) {
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
sdbRelease(pSdb, pUser);
|
sdbRelease(pSdb, pUser);
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
TAOS_CHECK_GOTO(terrno, &lino, _OVER);
|
||||||
}
|
}
|
||||||
if (taosArrayPush(pUserNames, &name) == NULL) {
|
if (taosArrayPush(pUserNames, &name) == NULL) {
|
||||||
taosMemoryFree(name);
|
taosMemoryFree(name);
|
||||||
|
@ -617,7 +617,7 @@ int32_t mndFetchAllIpWhite(SMnode *pMnode, SHashObj **ppIpWhiteTab) {
|
||||||
if (found == false) {
|
if (found == false) {
|
||||||
char *name = taosStrdup(TSDB_DEFAULT_USER);
|
char *name = taosStrdup(TSDB_DEFAULT_USER);
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
TAOS_CHECK_GOTO(terrno, &lino, _OVER);
|
||||||
}
|
}
|
||||||
if (taosArrayPush(pUserNames, &name) == NULL) {
|
if (taosArrayPush(pUserNames, &name) == NULL) {
|
||||||
taosMemoryFree(name);
|
taosMemoryFree(name);
|
||||||
|
|
|
@ -168,11 +168,10 @@ static int32_t sdbCreateDir(SSdb *pSdb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdbSetApplyInfo(SSdb *pSdb, int64_t index, int64_t term, int64_t config) {
|
void sdbSetApplyInfo(SSdb *pSdb, int64_t index, int64_t term, int64_t config) {
|
||||||
#if 1
|
mInfo("vgId:1, mnode apply info changed from index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " to index:%" PRId64
|
||||||
mTrace("mnode apply info changed from index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " to index:%" PRId64
|
" term:%" PRId64 " config:%" PRId64,
|
||||||
" term:%" PRId64 " config:%" PRId64,
|
pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig, index, term, config);
|
||||||
pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig, index, term, config);
|
|
||||||
#endif
|
|
||||||
pSdb->applyIndex = index;
|
pSdb->applyIndex = index;
|
||||||
pSdb->applyTerm = term;
|
pSdb->applyTerm = term;
|
||||||
pSdb->applyConfig = config;
|
pSdb->applyConfig = config;
|
||||||
|
|
|
@ -173,6 +173,8 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mInfo("vgId:1, write sdb file with sdb applyIndex:%" PRId64 " term:%" PRId64 " config:%" PRId64, pSdb->applyIndex,
|
||||||
|
pSdb->applyTerm, pSdb->applyConfig);
|
||||||
if (taosWriteFile(pFile, &pSdb->applyIndex, sizeof(int64_t)) != sizeof(int64_t)) {
|
if (taosWriteFile(pFile, &pSdb->applyIndex, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -554,6 +556,9 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) {
|
||||||
}
|
}
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("failed to write sdb file since %s", tstrerror(code));
|
mError("failed to write sdb file since %s", tstrerror(code));
|
||||||
|
} else {
|
||||||
|
mInfo("write sdb file success, apply index:%" PRId64 " term:%" PRId64 " config:%" PRId64, pSdb->applyIndex,
|
||||||
|
pSdb->applyTerm, pSdb->applyConfig);
|
||||||
}
|
}
|
||||||
(void)taosThreadMutexUnlock(&pSdb->filelock);
|
(void)taosThreadMutexUnlock(&pSdb->filelock);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -42,6 +42,7 @@ void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow, bool callFunc) {
|
||||||
// remove attached object such as trans
|
// remove attached object such as trans
|
||||||
SdbDeleteFp deleteFp = pSdb->deleteFps[pRow->type];
|
SdbDeleteFp deleteFp = pSdb->deleteFps[pRow->type];
|
||||||
if (deleteFp != NULL) {
|
if (deleteFp != NULL) {
|
||||||
|
mInfo("vgId:1, deleteFp:%p, type:%s", deleteFp, sdbTableName(pRow->type));
|
||||||
(void)(*deleteFp)(pSdb, pRow->pObj, callFunc);
|
(void)(*deleteFp)(pSdb, pRow->pObj, callFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,14 +112,14 @@ int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle);
|
||||||
void tqDestroyTqHandle(void* data);
|
void tqDestroyTqHandle(void* data);
|
||||||
|
|
||||||
// tqRead
|
// tqRead
|
||||||
int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatchMetaRsp* pBatchMetaRsp, STqOffsetVal* offset);
|
int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, SMqBatchMetaRsp* pBatchMetaRsp, STqOffsetVal* offset);
|
||||||
int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset, const SMqPollReq* pRequest);
|
int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset, const SMqPollReq* pRequest);
|
||||||
int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, uint64_t reqId);
|
int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, uint64_t reqId);
|
||||||
|
|
||||||
// tqExec
|
// tqExec
|
||||||
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded);
|
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, SMqDataRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded);
|
||||||
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOfCols, int8_t precision);
|
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision);
|
||||||
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const void* pRsp,
|
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp,
|
||||||
int32_t type, int32_t vgId);
|
int32_t type, int32_t vgId);
|
||||||
void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId);
|
void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId);
|
||||||
|
|
||||||
|
@ -148,9 +148,9 @@ int32_t tqOffsetRestoreFromFile(STQ* pTq, char* name);
|
||||||
// tq util
|
// tq util
|
||||||
int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type);
|
int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type);
|
||||||
int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg);
|
int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg);
|
||||||
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const void* pRsp, int32_t epoch, int64_t consumerId,
|
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp* pRsp, int32_t epoch, int64_t consumerId,
|
||||||
int32_t type, int64_t sver, int64_t ever);
|
int32_t type, int64_t sver, int64_t ever);
|
||||||
int32_t tqInitDataRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset);
|
int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset);
|
||||||
void tqUpdateNodeStage(STQ* pTq, bool isLeader);
|
void tqUpdateNodeStage(STQ* pTq, bool isLeader);
|
||||||
int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
||||||
SSubmitTbData* pTableData, int64_t earlyTs, const char* id);
|
SSubmitTbData* pTableData, int64_t earlyTs, const char* id);
|
||||||
|
|
|
@ -342,6 +342,7 @@ typedef struct {
|
||||||
rocksdb_writeoptions_t *writeoptions;
|
rocksdb_writeoptions_t *writeoptions;
|
||||||
rocksdb_readoptions_t *readoptions;
|
rocksdb_readoptions_t *readoptions;
|
||||||
rocksdb_writebatch_t *writebatch;
|
rocksdb_writebatch_t *writebatch;
|
||||||
|
TdThreadMutex writeBatchMutex;
|
||||||
STSchema *pTSchema;
|
STSchema *pTSchema;
|
||||||
} SRocksCache;
|
} SRocksCache;
|
||||||
|
|
||||||
|
|
|
@ -166,14 +166,14 @@ void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
code = tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
code = tqInitDataRsp(&dataRsp, req.reqOffset);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tqError("tqInitDataRsp failed, code:%d", code);
|
tqError("tqInitDataRsp failed, code:%d", code);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dataRsp.common.blockNum = 0;
|
dataRsp.blockNum = 0;
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
(void)tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.common.reqOffset);
|
(void)tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.reqOffset);
|
||||||
tqInfo("tqPushEmptyDataRsp to consumer:0x%" PRIx64 " vgId:%d, offset:%s,QID:0x%" PRIx64, req.consumerId, vgId, buf,
|
tqInfo("tqPushEmptyDataRsp to consumer:0x%" PRIx64 " vgId:%d, offset:%s,QID:0x%" PRIx64, req.consumerId, vgId, buf,
|
||||||
req.reqId);
|
req.reqId);
|
||||||
|
|
||||||
|
@ -184,18 +184,18 @@ void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) {
|
||||||
tDeleteMqDataRsp(&dataRsp);
|
tDeleteMqDataRsp(&dataRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const void* pRsp, int32_t type,
|
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp, int32_t type,
|
||||||
int32_t vgId) {
|
int32_t vgId) {
|
||||||
int64_t sver = 0, ever = 0;
|
int64_t sver = 0, ever = 0;
|
||||||
walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
||||||
|
|
||||||
char buf1[TSDB_OFFSET_LEN] = {0};
|
char buf1[TSDB_OFFSET_LEN] = {0};
|
||||||
char buf2[TSDB_OFFSET_LEN] = {0};
|
char buf2[TSDB_OFFSET_LEN] = {0};
|
||||||
(void)tFormatOffset(buf1, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->reqOffset);
|
(void)tFormatOffset(buf1, TSDB_OFFSET_LEN, &(pRsp->reqOffset));
|
||||||
(void)tFormatOffset(buf2, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->rspOffset);
|
(void)tFormatOffset(buf2, TSDB_OFFSET_LEN, &(pRsp->rspOffset));
|
||||||
|
|
||||||
tqDebug("tmq poll vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s,QID:0x%" PRIx64,
|
tqDebug("tmq poll vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s,QID:0x%" PRIx64,
|
||||||
vgId, pReq->consumerId, pReq->epoch, ((SMqDataRspCommon*)pRsp)->blockNum, buf1, buf2, pReq->reqId);
|
vgId, pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2, pReq->reqId);
|
||||||
|
|
||||||
return tqDoSendDataRsp(&pMsg->info, pRsp, pReq->epoch, pReq->consumerId, type, sver, ever);
|
return tqDoSendDataRsp(&pMsg->info, pRsp, pReq->epoch, pReq->consumerId, type, sver, ever);
|
||||||
}
|
}
|
||||||
|
@ -518,7 +518,7 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
taosRUnLockLatch(&pTq->lock);
|
taosRUnLockLatch(&pTq->lock);
|
||||||
|
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
code = tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
code = tqInitDataRsp(&dataRsp, req.reqOffset);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -529,10 +529,10 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataRsp.common.rspOffset.type = TMQ_OFFSET__LOG;
|
dataRsp.rspOffset.type = TMQ_OFFSET__LOG;
|
||||||
|
|
||||||
if (reqOffset.type == TMQ_OFFSET__LOG) {
|
if (reqOffset.type == TMQ_OFFSET__LOG) {
|
||||||
dataRsp.common.rspOffset.version = reqOffset.version;
|
dataRsp.rspOffset.version = reqOffset.version;
|
||||||
} else if (reqOffset.type < 0) {
|
} else if (reqOffset.type < 0) {
|
||||||
STqOffset* pOffset = NULL;
|
STqOffset* pOffset = NULL;
|
||||||
code = tqMetaGetOffset(pTq, req.subKey, &pOffset);
|
code = tqMetaGetOffset(pTq, req.subKey, &pOffset);
|
||||||
|
@ -543,17 +543,17 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataRsp.common.rspOffset.version = pOffset->val.version;
|
dataRsp.rspOffset.version = pOffset->val.version;
|
||||||
tqInfo("consumer:0x%" PRIx64 " vgId:%d subkey:%s get assignment from store:%" PRId64, consumerId, vgId,
|
tqInfo("consumer:0x%" PRIx64 " vgId:%d subkey:%s get assignment from store:%" PRId64, consumerId, vgId,
|
||||||
req.subKey, dataRsp.common.rspOffset.version);
|
req.subKey, dataRsp.rspOffset.version);
|
||||||
} else {
|
} else {
|
||||||
if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEST) {
|
if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEST) {
|
||||||
dataRsp.common.rspOffset.version = sver; // not consume yet, set the earliest position
|
dataRsp.rspOffset.version = sver; // not consume yet, set the earliest position
|
||||||
} else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
|
} else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
|
||||||
dataRsp.common.rspOffset.version = ever;
|
dataRsp.rspOffset.version = ever;
|
||||||
}
|
}
|
||||||
tqInfo("consumer:0x%" PRIx64 " vgId:%d subkey:%s get assignment from init:%" PRId64, consumerId, vgId, req.subKey,
|
tqInfo("consumer:0x%" PRIx64 " vgId:%d subkey:%s get assignment from init:%" PRId64, consumerId, vgId, req.subKey,
|
||||||
dataRsp.common.rspOffset.version);
|
dataRsp.rspOffset.version);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s invalid offset type:%d", consumerId, vgId, req.subKey,
|
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s invalid offset type:%d", consumerId, vgId, req.subKey,
|
||||||
|
|
|
@ -22,7 +22,7 @@ int32_t tqBuildFName(char** data, const char* path, char* name) {
|
||||||
if(fname == NULL) {
|
if(fname == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
int32_t code = snprintf(fname, len, "%s%s%s", path, TD_DIRSEP, name);
|
int32_t code = tsnprintf(fname, len, "%s%s%s", path, TD_DIRSEP, name);
|
||||||
if (code < 0){
|
if (code < 0){
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
taosMemoryFree(fname);
|
taosMemoryFree(fname);
|
||||||
|
|
|
@ -562,9 +562,18 @@ int32_t tqMaskBlock(SSchemaWrapper* pDst, SSDataBlock* pBlock, const SSchemaWrap
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t buildResSDataBlock(SSDataBlock* pBlock, SSchemaWrapper* pSchema, const SArray* pColIdList) {
|
static int32_t buildResSDataBlock(STqReader* pReader, SSchemaWrapper* pSchema, const SArray* pColIdList) {
|
||||||
|
SSDataBlock* pBlock = pReader->pResBlock;
|
||||||
if (blockDataGetNumOfCols(pBlock) > 0) {
|
if (blockDataGetNumOfCols(pBlock) > 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
blockDataDestroy(pBlock);
|
||||||
|
int32_t code = createDataBlock(&pReader->pResBlock);
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
pBlock = pReader->pResBlock;
|
||||||
|
|
||||||
|
pBlock->info.id.uid = pReader->cachedSchemaUid;
|
||||||
|
pBlock->info.version = pReader->msg.ver;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfCols = taosArrayGetSize(pColIdList);
|
int32_t numOfCols = taosArrayGetSize(pColIdList);
|
||||||
|
@ -678,10 +687,10 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
||||||
vgId, suid, uid, sversion, pReader->pSchemaWrapper->version);
|
vgId, suid, uid, sversion, pReader->pSchemaWrapper->version);
|
||||||
return TSDB_CODE_TQ_INTERNAL_ERROR;
|
return TSDB_CODE_TQ_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
if (blockDataGetNumOfCols(pBlock) == 0) {
|
code = buildResSDataBlock(pReader, pReader->pSchemaWrapper, pReader->pColIdList);
|
||||||
code = buildResSDataBlock(pReader->pResBlock, pReader->pSchemaWrapper, pReader->pColIdList);
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
TSDB_CHECK_CODE(code, line, END);
|
pBlock = pReader->pResBlock;
|
||||||
}
|
*pRes = pBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "tq.h"
|
#include "tq.h"
|
||||||
|
|
||||||
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOfCols, int8_t precision) {
|
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision) {
|
||||||
int32_t dataStrLen = sizeof(SRetrieveTableRspForTmq) + blockGetEncodeSize(pBlock);
|
int32_t dataStrLen = sizeof(SRetrieveTableRspForTmq) + blockGetEncodeSize(pBlock);
|
||||||
void* buf = taosMemoryCalloc(1, dataStrLen);
|
void* buf = taosMemoryCalloc(1, dataStrLen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
|
@ -34,11 +34,11 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOf
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
actualLen += sizeof(SRetrieveTableRspForTmq);
|
actualLen += sizeof(SRetrieveTableRspForTmq);
|
||||||
if (taosArrayPush(((SMqDataRspCommon*)pRsp)->blockDataLen, &actualLen) == NULL){
|
if (taosArrayPush(pRsp->blockDataLen, &actualLen) == NULL){
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
if (taosArrayPush(((SMqDataRspCommon*)pRsp)->blockData, &buf) == NULL) {
|
if (taosArrayPush(pRsp->blockData, &buf) == NULL) {
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -46,18 +46,18 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOf
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, void* pRsp) {
|
static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, SMqDataRsp* pRsp) {
|
||||||
SSchemaWrapper* pSW = tCloneSSchemaWrapper(pExec->pTqReader->pSchemaWrapper);
|
SSchemaWrapper* pSW = tCloneSSchemaWrapper(pExec->pTqReader->pSchemaWrapper);
|
||||||
if (pSW == NULL) {
|
if (pSW == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
if (taosArrayPush(((SMqDataRspCommon*)pRsp)->blockSchema, &pSW) == NULL) {
|
if (taosArrayPush(pRsp->blockSchema, &pSW) == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, void* pRsp, int32_t n) {
|
static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp, int32_t n) {
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
metaReaderDoInit(&mr, pTq->pVnode->pMeta, META_READER_LOCK);
|
metaReaderDoInit(&mr, pTq->pVnode->pMeta, META_READER_LOCK);
|
||||||
|
|
||||||
|
@ -73,7 +73,8 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, void* pRsp, int32_t
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
if(taosArrayPush(((SMqDataRspCommon*)pRsp)->blockTbName, &tbName) == NULL){
|
if(taosArrayPush(pRsp->blockTbName, &tbName) == NULL){
|
||||||
|
tqError("failed to push tbName to blockTbName:%s", tbName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +144,7 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
code = tqAddBlockDataToRsp(pHandle->block, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision);
|
code = tqAddBlockDataToRsp(pHandle->block, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision);
|
||||||
TSDB_CHECK_CODE(code, line, END);
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
|
|
||||||
pRsp->common.blockNum++;
|
pRsp->blockNum++;
|
||||||
if (pDataBlock == NULL) {
|
if (pDataBlock == NULL) {
|
||||||
blockDataDestroy(pHandle->block);
|
blockDataDestroy(pHandle->block);
|
||||||
pHandle->block = NULL;
|
pHandle->block = NULL;
|
||||||
|
@ -167,7 +168,7 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
code = tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision);
|
code = tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision);
|
||||||
TSDB_CHECK_CODE(code, line, END);
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
|
|
||||||
pRsp->common.blockNum++;
|
pRsp->blockNum++;
|
||||||
totalRows += pDataBlock->info.rows;
|
totalRows += pDataBlock->info.rows;
|
||||||
if (totalRows >= tmqRowSize || (taosGetTimestampMs() - st > 1000)) {
|
if (totalRows >= tmqRowSize || (taosGetTimestampMs() - st > 1000)) {
|
||||||
break;
|
break;
|
||||||
|
@ -176,8 +177,8 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDebug("consumer:0x%" PRIx64 " vgId:%d tmq task executed finished, total blocks:%d, totalRows:%d",
|
tqDebug("consumer:0x%" PRIx64 " vgId:%d tmq task executed finished, total blocks:%d, totalRows:%d",
|
||||||
pHandle->consumerId, vgId, pRsp->common.blockNum, totalRows);
|
pHandle->consumerId, vgId, pRsp->blockNum, totalRows);
|
||||||
code = qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
code = qStreamExtractOffset(task, &pRsp->rspOffset);
|
||||||
END:
|
END:
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tqError("consumer:0x%" PRIx64 " vgId:%d tmq task executed error, line:%d code:%d", pHandle->consumerId, vgId, line,
|
tqError("consumer:0x%" PRIx64 " vgId:%d tmq task executed error, line:%d code:%d", pHandle->consumerId, vgId, line,
|
||||||
|
@ -186,7 +187,7 @@ END:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatchMetaRsp* pBatchMetaRsp, STqOffsetVal* pOffset) {
|
int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, SMqBatchMetaRsp* pBatchMetaRsp, STqOffsetVal* pOffset) {
|
||||||
const STqExecHandle* pExec = &pHandle->execHandle;
|
const STqExecHandle* pExec = &pHandle->execHandle;
|
||||||
qTaskInfo_t task = pExec->task;
|
qTaskInfo_t task = pExec->task;
|
||||||
int code = qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType);
|
int code = qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType);
|
||||||
|
@ -208,7 +209,7 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
||||||
tqDebug("tmqsnap task execute end, get %p", pDataBlock);
|
tqDebug("tmqsnap task execute end, get %p", pDataBlock);
|
||||||
|
|
||||||
if (pDataBlock != NULL && pDataBlock->info.rows > 0) {
|
if (pDataBlock != NULL && pDataBlock->info.rows > 0) {
|
||||||
if (pRsp->common.withTbName) {
|
if (pRsp->withTbName) {
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
int64_t uid = pExec->pTqReader->lastBlkUid;
|
int64_t uid = pExec->pTqReader->lastBlkUid;
|
||||||
if (tqAddTbNameToRsp(pTq, uid, pRsp, 1) < 0) {
|
if (tqAddTbNameToRsp(pTq, uid, pRsp, 1) < 0) {
|
||||||
|
@ -221,13 +222,13 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
||||||
tqError("vgId:%d, failed to add tbname to rsp msg, null", pTq->pVnode->config.vgId);
|
tqError("vgId:%d, failed to add tbname to rsp msg, null", pTq->pVnode->config.vgId);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
if (taosArrayPush(pRsp->common.blockTbName, &tbName) == NULL){
|
if (taosArrayPush(pRsp->blockTbName, &tbName) == NULL){
|
||||||
tqError("vgId:%d, failed to add tbname to rsp msg", pTq->pVnode->config.vgId);
|
tqError("vgId:%d, failed to add tbname to rsp msg", pTq->pVnode->config.vgId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pRsp->common.withSchema) {
|
if (pRsp->withSchema) {
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
if (tqAddBlockSchemaToRsp(pExec, pRsp) != 0){
|
if (tqAddBlockSchemaToRsp(pExec, pRsp) != 0){
|
||||||
tqError("vgId:%d, failed to add schema to rsp msg", pTq->pVnode->config.vgId);
|
tqError("vgId:%d, failed to add schema to rsp msg", pTq->pVnode->config.vgId);
|
||||||
|
@ -235,19 +236,19 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SSchemaWrapper* pSW = tCloneSSchemaWrapper(qExtractSchemaFromTask(task));
|
SSchemaWrapper* pSW = tCloneSSchemaWrapper(qExtractSchemaFromTask(task));
|
||||||
if(taosArrayPush(pRsp->common.blockSchema, &pSW) == NULL){
|
if(taosArrayPush(pRsp->blockSchema, &pSW) == NULL){
|
||||||
tqError("vgId:%d, failed to add schema to rsp msg", pTq->pVnode->config.vgId);
|
tqError("vgId:%d, failed to add schema to rsp msg", pTq->pVnode->config.vgId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tqAddBlockDataToRsp(pDataBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pDataBlock->pDataBlock),
|
if (tqAddBlockDataToRsp(pDataBlock, pRsp, taosArrayGetSize(pDataBlock->pDataBlock),
|
||||||
pTq->pVnode->config.tsdbCfg.precision) != 0) {
|
pTq->pVnode->config.tsdbCfg.precision) != 0) {
|
||||||
tqError("vgId:%d, failed to add block to rsp msg", pTq->pVnode->config.vgId);
|
tqError("vgId:%d, failed to add block to rsp msg", pTq->pVnode->config.vgId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pRsp->common.blockNum++;
|
pRsp->blockNum++;
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -281,13 +282,13 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
||||||
|
|
||||||
tqDebug("tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode),
|
tqDebug("tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode),
|
||||||
pHandle->snapshotVer + 1);
|
pHandle->snapshotVer + 1);
|
||||||
code = qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
code = qStreamExtractOffset(task, &pRsp->rspOffset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRsp->common.blockNum > 0) {
|
if (pRsp->blockNum > 0) {
|
||||||
tqDebug("tmqsnap task exec exited, get data");
|
tqDebug("tmqsnap task exec exited, get data");
|
||||||
code = qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
code = qStreamExtractOffset(task, &pRsp->rspOffset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +297,7 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void tqProcessSubData(STQ* pTq, STqHandle* pHandle, STaosxRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded){
|
static void tqProcessSubData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded){
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
STqExecHandle* pExec = &pHandle->execHandle;
|
STqExecHandle* pExec = &pHandle->execHandle;
|
||||||
STqReader* pReader = pExec->pTqReader;
|
STqReader* pReader = pExec->pTqReader;
|
||||||
|
@ -323,7 +324,7 @@ static void tqProcessSubData(STQ* pTq, STqHandle* pHandle, STaosxRsp* pRsp, int3
|
||||||
if ((pSubmitTbDataRet->flags & sourceExcluded) != 0) {
|
if ((pSubmitTbDataRet->flags & sourceExcluded) != 0) {
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
if (pRsp->common.withTbName) {
|
if (pRsp->withTbName) {
|
||||||
int64_t uid = pExec->pTqReader->lastBlkUid;
|
int64_t uid = pExec->pTqReader->lastBlkUid;
|
||||||
code = tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks));
|
code = tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks));
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
@ -381,7 +382,7 @@ static void tqProcessSubData(STQ* pTq, STqHandle* pHandle, STaosxRsp* pRsp, int3
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (tqAddBlockDataToRsp(pBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlock->pDataBlock),
|
if (tqAddBlockDataToRsp(pBlock, pRsp, taosArrayGetSize(pBlock->pDataBlock),
|
||||||
pTq->pVnode->config.tsdbCfg.precision) != 0){
|
pTq->pVnode->config.tsdbCfg.precision) != 0){
|
||||||
tqError("vgId:%d, failed to add block to rsp msg", pTq->pVnode->config.vgId);
|
tqError("vgId:%d, failed to add block to rsp msg", pTq->pVnode->config.vgId);
|
||||||
continue;
|
continue;
|
||||||
|
@ -389,11 +390,11 @@ static void tqProcessSubData(STQ* pTq, STqHandle* pHandle, STaosxRsp* pRsp, int3
|
||||||
*totalRows += pBlock->info.rows;
|
*totalRows += pBlock->info.rows;
|
||||||
blockDataFreeRes(pBlock);
|
blockDataFreeRes(pBlock);
|
||||||
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
||||||
if (taosArrayPush(pRsp->common.blockSchema, &pSW) == NULL){
|
if (taosArrayPush(pRsp->blockSchema, &pSW) == NULL){
|
||||||
tqError("vgId:%d, failed to add schema to rsp msg", pTq->pVnode->config.vgId);
|
tqError("vgId:%d, failed to add schema to rsp msg", pTq->pVnode->config.vgId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pRsp->common.blockNum++;
|
pRsp->blockNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pBlocks);
|
taosArrayDestroy(pBlocks);
|
||||||
|
@ -405,7 +406,7 @@ END:
|
||||||
taosArrayDestroyP(pSchemas, (FDelete)tDeleteSchemaWrapper);
|
taosArrayDestroyP(pSchemas, (FDelete)tDeleteSchemaWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows,
|
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, SMqDataRsp* pRsp, int32_t* totalRows,
|
||||||
int8_t sourceExcluded) {
|
int8_t sourceExcluded) {
|
||||||
STqExecHandle* pExec = &pHandle->execHandle;
|
STqExecHandle* pExec = &pHandle->execHandle;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
|
@ -73,14 +73,19 @@ int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* p
|
||||||
}
|
}
|
||||||
|
|
||||||
if (varTbName != NULL && varTbName != (void*)-1) {
|
if (varTbName != NULL && varTbName != (void*)-1) {
|
||||||
name = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN);
|
size_t cap = TMAX(TSDB_TABLE_NAME_LEN, varDataLen(varTbName) + 1);
|
||||||
|
name = taosMemoryMalloc(cap);
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(name, varDataVal(varTbName), varDataLen(varTbName));
|
memcpy(name, varDataVal(varTbName), varDataLen(varTbName));
|
||||||
|
name[varDataLen(varTbName)] = '\0';
|
||||||
if (newSubTableRule && !isAutoTableName(name) && !alreadyAddGroupId(name, groupId) && groupId != 0 && stbFullName) {
|
if (newSubTableRule && !isAutoTableName(name) && !alreadyAddGroupId(name, groupId) && groupId != 0 && stbFullName) {
|
||||||
buildCtbNameAddGroupId(stbFullName, name, groupId);
|
int32_t code = buildCtbNameAddGroupId(stbFullName, name, groupId, cap);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (stbFullName) {
|
} else if (stbFullName) {
|
||||||
int32_t code = buildCtbNameByGroupId(stbFullName, groupId, &name);
|
int32_t code = buildCtbNameByGroupId(stbFullName, groupId, &name);
|
||||||
|
@ -107,7 +112,7 @@ int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* p
|
||||||
groupId, name, skey, ekey);
|
groupId, name, skey, ekey);
|
||||||
|
|
||||||
SSingleDeleteReq req = {.startTs = skey, .endTs = ekey};
|
SSingleDeleteReq req = {.startTs = skey, .endTs = ekey};
|
||||||
strncpy(req.tbname, name, TSDB_TABLE_NAME_LEN - 1);
|
tstrncpy(req.tbname, name, TSDB_TABLE_NAME_LEN);
|
||||||
void* p = taosArrayPush(deleteReq->deleteReqs, &req);
|
void* p = taosArrayPush(deleteReq->deleteReqs, &req);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -235,8 +240,11 @@ int32_t setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock*
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(pCreateTableReq->name, pDataBlock->info.parTbName);
|
tstrncpy(pCreateTableReq->name, pDataBlock->info.parTbName, TSDB_TABLE_NAME_LEN);
|
||||||
buildCtbNameAddGroupId(stbFullName, pCreateTableReq->name, gid);
|
int32_t code = buildCtbNameAddGroupId(stbFullName, pCreateTableReq->name, gid, TSDB_TABLE_NAME_LEN);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
// tqDebug("gen name from:%s", pDataBlock->info.parTbName);
|
// tqDebug("gen name from:%s", pDataBlock->info.parTbName);
|
||||||
} else {
|
} else {
|
||||||
pCreateTableReq->name = taosStrdup(pDataBlock->info.parTbName);
|
pCreateTableReq->name = taosStrdup(pDataBlock->info.parTbName);
|
||||||
|
@ -852,9 +860,12 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
||||||
!alreadyAddGroupId(dstTableName, groupId) && groupId != 0) {
|
!alreadyAddGroupId(dstTableName, groupId) && groupId != 0) {
|
||||||
tqDebug("s-task:%s append groupId:%" PRId64 " for generated dstTable:%s", id, groupId, dstTableName);
|
tqDebug("s-task:%s append groupId:%" PRId64 " for generated dstTable:%s", id, groupId, dstTableName);
|
||||||
if (pTask->ver == SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
|
if (pTask->ver == SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
|
||||||
buildCtbNameAddGroupId(NULL, dstTableName, groupId);
|
code = buildCtbNameAddGroupId(NULL, dstTableName, groupId, sizeof(pDataBlock->info.parTbName));
|
||||||
} else if (pTask->ver > SSTREAM_TASK_SUBTABLE_CHANGED_VER && stbFullName) {
|
} else if (pTask->ver > SSTREAM_TASK_SUBTABLE_CHANGED_VER && stbFullName) {
|
||||||
buildCtbNameAddGroupId(stbFullName, dstTableName, groupId);
|
code = buildCtbNameAddGroupId(stbFullName, dstTableName, groupId, sizeof(pDataBlock->info.parTbName));
|
||||||
|
}
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1250,4 +1261,4 @@ int32_t doBuildAndSendDeleteMsg(SVnode* pVnode, char* stbFullName, SSDataBlock*
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ static int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const
|
||||||
static int32_t tqSendBatchMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq,
|
static int32_t tqSendBatchMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq,
|
||||||
const SMqBatchMetaRsp* pRsp, int32_t vgId);
|
const SMqBatchMetaRsp* pRsp, int32_t vgId);
|
||||||
|
|
||||||
int32_t tqInitDataRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset) {
|
int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset) {
|
||||||
pRsp->blockData = taosArrayInit(0, sizeof(void*));
|
pRsp->blockData = taosArrayInit(0, sizeof(void*));
|
||||||
pRsp->blockDataLen = taosArrayInit(0, sizeof(int32_t));
|
pRsp->blockDataLen = taosArrayInit(0, sizeof(int32_t));
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ void tqUpdateNodeStage(STQ* pTq, bool isLeader) {
|
||||||
streamMetaUpdateStageRole(pTq->pStreamMeta, state.term, isLeader);
|
streamMetaUpdateStageRole(pTq->pStreamMeta, state.term, isLeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tqInitTaosxRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset) {
|
static int32_t tqInitTaosxRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset) {
|
||||||
tOffsetCopy(&pRsp->reqOffset, &pOffset);
|
tOffsetCopy(&pRsp->reqOffset, &pOffset);
|
||||||
tOffsetCopy(&pRsp->rspOffset, &pOffset);
|
tOffsetCopy(&pRsp->rspOffset, &pOffset);
|
||||||
|
|
||||||
|
@ -116,12 +116,12 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer + 1);
|
tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer + 1);
|
||||||
|
|
||||||
code = tqInitDataRsp(&dataRsp.common, *pOffsetVal);
|
code = tqInitDataRsp(&dataRsp, *pOffsetVal);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, (latest) offset reset to %" PRId64, consumerId,
|
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, (latest) offset reset to %" PRId64, consumerId,
|
||||||
pHandle->subKey, vgId, dataRsp.common.rspOffset.version);
|
pHandle->subKey, vgId, dataRsp.rspOffset.version);
|
||||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
tDeleteMqDataRsp(&dataRsp);
|
tDeleteMqDataRsp(&dataRsp);
|
||||||
|
|
||||||
|
@ -145,24 +145,27 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
|
int code = tqInitDataRsp(&dataRsp, *pOffset);
|
||||||
int code = tqInitDataRsp(&dataRsp.common, *pOffset);
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId);
|
code = qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId);
|
||||||
|
if (code != 0) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
code = tqScanData(pTq, pHandle, &dataRsp, pOffset, pRequest);
|
code = tqScanData(pTq, pHandle, &dataRsp, pOffset, pRequest);
|
||||||
if (code != 0 && terrno != TSDB_CODE_WAL_LOG_NOT_EXIST) {
|
if (code != 0 && terrno != TSDB_CODE_WAL_LOG_NOT_EXIST) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// till now, all data has been transferred to consumer, new data needs to push client once arrived.
|
// till now, all data has been transferred to consumer, new data needs to push client once arrived.
|
||||||
if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST && dataRsp.common.blockNum == 0) {
|
if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST && dataRsp.blockNum == 0) {
|
||||||
// lock
|
// lock
|
||||||
taosWLockLatch(&pTq->lock);
|
taosWLockLatch(&pTq->lock);
|
||||||
int64_t ver = walGetCommittedVer(pTq->pVnode->pWal);
|
int64_t ver = walGetCommittedVer(pTq->pVnode->pWal);
|
||||||
if (dataRsp.common.rspOffset.version > ver) { // check if there are data again to avoid lost data
|
if (dataRsp.rspOffset.version > ver) { // check if there are data again to avoid lost data
|
||||||
code = tqRegisterPushHandle(pTq, pHandle, pMsg);
|
code = tqRegisterPushHandle(pTq, pHandle, pMsg);
|
||||||
taosWUnLockLatch(&pTq->lock);
|
taosWUnLockLatch(&pTq->lock);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -170,16 +173,16 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
taosWUnLockLatch(&pTq->lock);
|
taosWUnLockLatch(&pTq->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
tOffsetCopy(&dataRsp.common.reqOffset,
|
// reqOffset represents the current date offset, may be changed if wal not exists
|
||||||
pOffset); // reqOffset represents the current date offset, may be changed if wal not exists
|
tOffsetCopy(&dataRsp.reqOffset, pOffset);
|
||||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
|
|
||||||
end : {
|
end : {
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.common.rspOffset);
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.rspOffset);
|
||||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s,QID:0x%" PRIx64
|
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s,QID:0x%" PRIx64
|
||||||
" code:%d",
|
" code:%d",
|
||||||
consumerId, pHandle->subKey, vgId, dataRsp.common.blockNum, buf, pRequest->reqId, code);
|
consumerId, pHandle->subKey, vgId, dataRsp.blockNum, buf, pRequest->reqId, code);
|
||||||
tDeleteMqDataRsp(&dataRsp);
|
tDeleteMqDataRsp(&dataRsp);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -208,11 +211,11 @@ static void tDeleteCommon(void* parm) {}
|
||||||
static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
|
static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
|
||||||
SRpcMsg* pMsg, STqOffsetVal* offset) {
|
SRpcMsg* pMsg, STqOffsetVal* offset) {
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
STaosxRsp taosxRsp = {0};
|
SMqDataRsp taosxRsp = {0};
|
||||||
SMqBatchMetaRsp btMetaRsp = {0};
|
SMqBatchMetaRsp btMetaRsp = {0};
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
TQ_ERR_GO_TO_END(tqInitTaosxRsp(&taosxRsp.common, *offset));
|
TQ_ERR_GO_TO_END(tqInitTaosxRsp(&taosxRsp, *offset));
|
||||||
if (offset->type != TMQ_OFFSET__LOG) {
|
if (offset->type != TMQ_OFFSET__LOG) {
|
||||||
TQ_ERR_GO_TO_END(tqScanTaosx(pTq, pHandle, &taosxRsp, &btMetaRsp, offset));
|
TQ_ERR_GO_TO_END(tqScanTaosx(pTq, pHandle, &taosxRsp, &btMetaRsp, offset));
|
||||||
|
|
||||||
|
@ -227,13 +230,13 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
|
|
||||||
tqDebug("taosx poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%" PRId64
|
tqDebug("taosx poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%" PRId64
|
||||||
",ts:%" PRId64,
|
",ts:%" PRId64,
|
||||||
pRequest->consumerId, pHandle->subKey, vgId, taosxRsp.common.blockNum, taosxRsp.common.rspOffset.type,
|
pRequest->consumerId, pHandle->subKey, vgId, taosxRsp.blockNum, taosxRsp.rspOffset.type,
|
||||||
taosxRsp.common.rspOffset.uid, taosxRsp.common.rspOffset.ts);
|
taosxRsp.rspOffset.uid, taosxRsp.rspOffset.ts);
|
||||||
if (taosxRsp.common.blockNum > 0) {
|
if (taosxRsp.blockNum > 0) {
|
||||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, &taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
code = tqSendDataRsp(pHandle, pMsg, pRequest, &taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
goto END;
|
goto END;
|
||||||
} else {
|
} else {
|
||||||
tOffsetCopy(offset, &taosxRsp.common.rspOffset);
|
tOffsetCopy(offset, &taosxRsp.rspOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +267,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
}
|
}
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer);
|
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
||||||
code = tqSendDataRsp(
|
code = tqSendDataRsp(
|
||||||
pHandle, pMsg, pRequest, &taosxRsp,
|
pHandle, pMsg, pRequest, &taosxRsp,
|
||||||
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
|
@ -278,7 +281,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
// process meta
|
// process meta
|
||||||
if (pHead->msgType != TDMT_VND_SUBMIT) {
|
if (pHead->msgType != TDMT_VND_SUBMIT) {
|
||||||
if (totalRows > 0) {
|
if (totalRows > 0) {
|
||||||
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer);
|
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
||||||
code = tqSendDataRsp(
|
code = tqSendDataRsp(
|
||||||
pHandle, pMsg, pRequest, &taosxRsp,
|
pHandle, pMsg, pRequest, &taosxRsp,
|
||||||
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
|
@ -387,7 +390,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalRows >= tmqRowSize || (taosGetTimestampMs() - st > 1000)) {
|
if (totalRows >= tmqRowSize || (taosGetTimestampMs() - st > 1000)) {
|
||||||
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer + 1);
|
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer + 1);
|
||||||
code = tqSendDataRsp(
|
code = tqSendDataRsp(
|
||||||
pHandle, pMsg, pRequest, &taosxRsp,
|
pHandle, pMsg, pRequest, &taosxRsp,
|
||||||
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
|
@ -522,7 +525,7 @@ int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPoll
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const void* pRsp, int32_t epoch, int64_t consumerId,
|
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp* pRsp, int32_t epoch, int64_t consumerId,
|
||||||
int32_t type, int64_t sver, int64_t ever) {
|
int32_t type, int64_t sver, int64_t ever) {
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
|
@ -22,6 +22,12 @@
|
||||||
|
|
||||||
#define ROCKS_BATCH_SIZE (4096)
|
#define ROCKS_BATCH_SIZE (4096)
|
||||||
|
|
||||||
|
void tsdbLRUCacheRelease(SLRUCache *cache, LRUHandle *handle, bool eraseIfLastRef) {
|
||||||
|
if (!taosLRUCacheRelease(cache, handle, eraseIfLastRef)) {
|
||||||
|
tsdbTrace(" release lru cache failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t tsdbOpenBCache(STsdb *pTsdb) {
|
static int32_t tsdbOpenBCache(STsdb *pTsdb) {
|
||||||
int32_t code = 0, lino = 0;
|
int32_t code = 0, lino = 0;
|
||||||
int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
|
int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
|
||||||
|
@ -215,6 +221,8 @@ static int32_t tsdbOpenRocksCache(STsdb *pTsdb) {
|
||||||
|
|
||||||
rocksdb_writebatch_t *writebatch = rocksdb_writebatch_create();
|
rocksdb_writebatch_t *writebatch = rocksdb_writebatch_create();
|
||||||
|
|
||||||
|
TAOS_CHECK_GOTO(taosThreadMutexInit(&pTsdb->rCache.writeBatchMutex, NULL), &lino, _err6) ;
|
||||||
|
|
||||||
pTsdb->rCache.writebatch = writebatch;
|
pTsdb->rCache.writebatch = writebatch;
|
||||||
pTsdb->rCache.my_comparator = cmp;
|
pTsdb->rCache.my_comparator = cmp;
|
||||||
pTsdb->rCache.options = options;
|
pTsdb->rCache.options = options;
|
||||||
|
@ -226,6 +234,8 @@ static int32_t tsdbOpenRocksCache(STsdb *pTsdb) {
|
||||||
|
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
|
|
||||||
|
_err6:
|
||||||
|
rocksdb_writebatch_destroy(writebatch);
|
||||||
_err5:
|
_err5:
|
||||||
rocksdb_close(pTsdb->rCache.db);
|
rocksdb_close(pTsdb->rCache.db);
|
||||||
_err4:
|
_err4:
|
||||||
|
@ -244,6 +254,7 @@ _err:
|
||||||
|
|
||||||
static void tsdbCloseRocksCache(STsdb *pTsdb) {
|
static void tsdbCloseRocksCache(STsdb *pTsdb) {
|
||||||
rocksdb_close(pTsdb->rCache.db);
|
rocksdb_close(pTsdb->rCache.db);
|
||||||
|
(void)taosThreadMutexDestroy(&pTsdb->rCache.writeBatchMutex);
|
||||||
rocksdb_flushoptions_destroy(pTsdb->rCache.flushoptions);
|
rocksdb_flushoptions_destroy(pTsdb->rCache.flushoptions);
|
||||||
rocksdb_writebatch_destroy(pTsdb->rCache.writebatch);
|
rocksdb_writebatch_destroy(pTsdb->rCache.writebatch);
|
||||||
rocksdb_readoptions_destroy(pTsdb->rCache.readoptions);
|
rocksdb_readoptions_destroy(pTsdb->rCache.readoptions);
|
||||||
|
@ -579,7 +590,7 @@ static void tsdbCacheDeleter(const void *key, size_t klen, void *value, void *ud
|
||||||
if (pLastCol->dirty) {
|
if (pLastCol->dirty) {
|
||||||
if (tsdbCacheFlushDirty(key, klen, pLastCol, ud) != 0) {
|
if (tsdbCacheFlushDirty(key, klen, pLastCol, ud) != 0) {
|
||||||
STsdb *pTsdb = (STsdb *)ud;
|
STsdb *pTsdb = (STsdb *)ud;
|
||||||
tsdbError("tsdb/cache: vgId:%d, flush cache %s failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__);
|
tsdbTrace("tsdb/cache: vgId:%d, flush cache %s failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,9 +724,13 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid,
|
||||||
{
|
{
|
||||||
SLastCol *pLastCol = NULL;
|
SLastCol *pLastCol = NULL;
|
||||||
code = tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol);
|
code = tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_INVALID_PARA) {
|
||||||
tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
|
} else if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
|
tstrerror(code));
|
||||||
|
goto _exit;
|
||||||
}
|
}
|
||||||
if (NULL != pLastCol) {
|
if (NULL != pLastCol) {
|
||||||
rocksdb_writebatch_delete(wb, keys_list[0], klen);
|
rocksdb_writebatch_delete(wb, keys_list[0], klen);
|
||||||
|
@ -724,9 +739,13 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid,
|
||||||
|
|
||||||
pLastCol = NULL;
|
pLastCol = NULL;
|
||||||
code = tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol);
|
code = tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_INVALID_PARA) {
|
||||||
tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
|
} else if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
|
tstrerror(code));
|
||||||
|
goto _exit;
|
||||||
}
|
}
|
||||||
if (NULL != pLastCol) {
|
if (NULL != pLastCol) {
|
||||||
rocksdb_writebatch_delete(wb, keys_list[1], klen);
|
rocksdb_writebatch_delete(wb, keys_list[1], klen);
|
||||||
|
@ -739,9 +758,7 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid,
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
LRUHandle *h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[i], klen);
|
LRUHandle *h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[i], klen);
|
||||||
if (h) {
|
if (h) {
|
||||||
if (taosLRUCacheRelease(pTsdb->lruCache, h, true)) {
|
tsdbLRUCacheRelease(pTsdb->lruCache, h, true);
|
||||||
tsdbInfo("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__);
|
|
||||||
}
|
|
||||||
taosLRUCacheErase(pTsdb->lruCache, keys_list[i], klen);
|
taosLRUCacheErase(pTsdb->lruCache, keys_list[i], klen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -770,17 +787,13 @@ int32_t tsdbCacheNewTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWrap
|
||||||
|
|
||||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST_ROW);
|
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST_ROW);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST);
|
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -798,17 +811,13 @@ int32_t tsdbCacheNewTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWrap
|
||||||
|
|
||||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST_ROW);
|
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST_ROW);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST);
|
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -827,10 +836,8 @@ int32_t tsdbCacheDropTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWra
|
||||||
|
|
||||||
code = tsdbCacheCommitNoLock(pTsdb);
|
code = tsdbCacheCommitNoLock(pTsdb);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSchemaRow != NULL) {
|
if (pSchemaRow != NULL) {
|
||||||
|
@ -845,10 +852,8 @@ int32_t tsdbCacheDropTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWra
|
||||||
|
|
||||||
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -871,10 +876,8 @@ int32_t tsdbCacheDropTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWra
|
||||||
|
|
||||||
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -895,10 +898,8 @@ int32_t tsdbCacheDropSubTables(STsdb *pTsdb, SArray *uids, tb_uid_t suid) {
|
||||||
|
|
||||||
code = tsdbCacheCommitNoLock(pTsdb);
|
code = tsdbCacheCommitNoLock(pTsdb);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STSchema *pTSchema = NULL;
|
STSchema *pTSchema = NULL;
|
||||||
|
@ -924,11 +925,8 @@ int32_t tsdbCacheDropSubTables(STsdb *pTsdb, SArray *uids, tb_uid_t suid) {
|
||||||
|
|
||||||
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
taosMemoryFree(pTSchema);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -949,17 +947,13 @@ int32_t tsdbCacheNewNTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, int8_t
|
||||||
|
|
||||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 0);
|
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 1);
|
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
// rocksMayWrite(pTsdb, true, false, false);
|
// rocksMayWrite(pTsdb, true, false, false);
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||||
|
@ -974,18 +968,14 @@ int32_t tsdbCacheDropNTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, bool h
|
||||||
|
|
||||||
code = tsdbCacheCommitNoLock(pTsdb);
|
code = tsdbCacheCommitNoLock(pTsdb);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rocksMayWrite(pTsdb, false);
|
rocksMayWrite(pTsdb, false);
|
||||||
|
@ -1005,17 +995,13 @@ int32_t tsdbCacheNewSTableColumn(STsdb *pTsdb, SArray *uids, int16_t cid, int8_t
|
||||||
|
|
||||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 0);
|
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 1);
|
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,10 +1017,8 @@ int32_t tsdbCacheDropSTableColumn(STsdb *pTsdb, SArray *uids, int16_t cid, bool
|
||||||
|
|
||||||
code = tsdbCacheCommitNoLock(pTsdb);
|
code = tsdbCacheCommitNoLock(pTsdb);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < TARRAY_SIZE(uids); ++i) {
|
for (int i = 0; i < TARRAY_SIZE(uids); ++i) {
|
||||||
|
@ -1042,10 +1026,8 @@ int32_t tsdbCacheDropSTableColumn(STsdb *pTsdb, SArray *uids, int16_t cid, bool
|
||||||
|
|
||||||
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1100,7 +1082,9 @@ static int32_t tsdbCachePutToRocksdb(STsdb *pTsdb, SLastKey *pLastKey, SLastCol
|
||||||
}
|
}
|
||||||
|
|
||||||
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
|
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
|
||||||
|
(void)taosThreadMutexLock(&pTsdb->rCache.writeBatchMutex);
|
||||||
rocksdb_writebatch_put(wb, (char *)pLastKey, ROCKS_KEY_LEN, rocks_value, vlen);
|
rocksdb_writebatch_put(wb, (char *)pLastKey, ROCKS_KEY_LEN, rocks_value, vlen);
|
||||||
|
(void)taosThreadMutexUnlock(&pTsdb->rCache.writeBatchMutex);
|
||||||
|
|
||||||
taosMemoryFree(rocks_value);
|
taosMemoryFree(rocks_value);
|
||||||
|
|
||||||
|
@ -1174,9 +1158,7 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!taosLRUCacheRelease(pCache, h, false)) {
|
tsdbLRUCacheRelease(pCache, h, false);
|
||||||
tsdbInfo("vgId:%d, %s release lru cache failed at line %d", TD_VID(pTsdb->pVnode), __func__, __LINE__);
|
|
||||||
}
|
|
||||||
TAOS_CHECK_EXIT(code);
|
TAOS_CHECK_EXIT(code);
|
||||||
} else {
|
} else {
|
||||||
if (!remainCols) {
|
if (!remainCols) {
|
||||||
|
@ -1237,9 +1219,13 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
|
||||||
|
|
||||||
SLastCol *pLastCol = NULL;
|
SLastCol *pLastCol = NULL;
|
||||||
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_INVALID_PARA) {
|
||||||
tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
|
} else if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
|
tstrerror(code));
|
||||||
|
goto _exit;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -1391,9 +1377,8 @@ int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int6
|
||||||
}
|
}
|
||||||
code = tSimpleHashIterateRemove(iColHash, &iCol, sizeof(iCol), &pIte, &iter);
|
code = tSimpleHashIterateRemove(iColHash, &iCol, sizeof(iCol), &pIte, &iter);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s tSimpleHashIterateRemove failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__,
|
tsdbTrace("vgId:%d, %s tSimpleHashIterateRemove failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__,
|
||||||
__LINE__, tstrerror(code));
|
__LINE__, tstrerror(code));
|
||||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1402,9 +1387,8 @@ int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int6
|
||||||
// 3. do update
|
// 3. do update
|
||||||
code = tsdbCacheUpdate(pTsdb, suid, uid, ctxArray);
|
code = tsdbCacheUpdate(pTsdb, suid, uid, ctxArray);
|
||||||
if (code < TSDB_CODE_SUCCESS) {
|
if (code < TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s tsdbCacheUpdate failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s tsdbCacheUpdate failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -1491,9 +1475,8 @@ int32_t tsdbCacheColFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SBlo
|
||||||
// 3. do update
|
// 3. do update
|
||||||
code = tsdbCacheUpdate(pTsdb, suid, uid, ctxArray);
|
code = tsdbCacheUpdate(pTsdb, suid, uid, ctxArray);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s tsdbCacheUpdate failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s tsdbCacheUpdate failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -1709,9 +1692,13 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_INVALID_PARA) {
|
||||||
tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
|
} else if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
|
tstrerror(code));
|
||||||
|
goto _exit;
|
||||||
}
|
}
|
||||||
SLastCol *pToFree = pLastCol;
|
SLastCol *pToFree = pLastCol;
|
||||||
SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j];
|
SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j];
|
||||||
|
@ -1787,10 +1774,14 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
||||||
SLastCol *pLastCol = h ? (SLastCol *)taosLRUCacheValue(pCache, h) : NULL;
|
SLastCol *pLastCol = h ? (SLastCol *)taosLRUCacheValue(pCache, h) : NULL;
|
||||||
if (h && pLastCol->cacheStatus != TSDB_LAST_CACHE_NO_CACHE) {
|
if (h && pLastCol->cacheStatus != TSDB_LAST_CACHE_NO_CACHE) {
|
||||||
SLastCol lastCol = *pLastCol;
|
SLastCol lastCol = *pLastCol;
|
||||||
TAOS_CHECK_GOTO(tsdbCacheReallocSLastCol(&lastCol, NULL), NULL, _exit);
|
if (TSDB_CODE_SUCCESS != (code = tsdbCacheReallocSLastCol(&lastCol, NULL))) {
|
||||||
|
tsdbLRUCacheRelease(pCache, h, false);
|
||||||
|
TAOS_CHECK_GOTO(code, NULL, _exit);
|
||||||
|
}
|
||||||
|
|
||||||
if (taosArrayPush(pLastArray, &lastCol) == NULL) {
|
if (taosArrayPush(pLastArray, &lastCol) == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
tsdbLRUCacheRelease(pCache, h, false);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1800,38 +1791,39 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
||||||
|
|
||||||
if (taosArrayPush(pLastArray, &noneCol) == NULL) {
|
if (taosArrayPush(pLastArray, &noneCol) == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
tsdbLRUCacheRelease(pCache, h, false);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!remainCols) {
|
if (!remainCols) {
|
||||||
if ((remainCols = taosArrayInit(numKeys, sizeof(SIdxKey))) == NULL) {
|
if ((remainCols = taosArrayInit(numKeys, sizeof(SIdxKey))) == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
tsdbLRUCacheRelease(pCache, h, false);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ignoreFromRocks) {
|
if (!ignoreFromRocks) {
|
||||||
if ((ignoreFromRocks = taosArrayInit(numKeys, sizeof(bool))) == NULL) {
|
if ((ignoreFromRocks = taosArrayInit(numKeys, sizeof(bool))) == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
tsdbLRUCacheRelease(pCache, h, false);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (taosArrayPush(remainCols, &(SIdxKey){i, key}) == NULL) {
|
if (taosArrayPush(remainCols, &(SIdxKey){i, key}) == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
tsdbLRUCacheRelease(pCache, h, false);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
bool ignoreRocks = pLastCol ? (pLastCol->cacheStatus == TSDB_LAST_CACHE_NO_CACHE) : false;
|
bool ignoreRocks = pLastCol ? (pLastCol->cacheStatus == TSDB_LAST_CACHE_NO_CACHE) : false;
|
||||||
if (taosArrayPush(ignoreFromRocks, &ignoreRocks) == NULL) {
|
if (taosArrayPush(ignoreFromRocks, &ignoreRocks) == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
tsdbLRUCacheRelease(pCache, h, false);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h) {
|
if (h) {
|
||||||
code = taosLRUCacheRelease(pCache, h, false);
|
tsdbLRUCacheRelease(pCache, h, false);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tsdbError("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__);
|
|
||||||
goto _exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1846,6 +1838,7 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
||||||
SLastCol lastCol = *pLastCol;
|
SLastCol lastCol = *pLastCol;
|
||||||
code = tsdbCacheReallocSLastCol(&lastCol, NULL);
|
code = tsdbCacheReallocSLastCol(&lastCol, NULL);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
tsdbLRUCacheRelease(pCache, h, false);
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
@ -1858,13 +1851,8 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
||||||
// no cache or cache is invalid
|
// no cache or cache is invalid
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h) {
|
if (h) {
|
||||||
code = taosLRUCacheRelease(pCache, h, false);
|
tsdbLRUCacheRelease(pCache, h, false);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tsdbError("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__);
|
|
||||||
goto _exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1900,10 +1888,8 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
|
||||||
|
|
||||||
code = tsdbCacheCommit(pTsdb);
|
code = tsdbCacheCommit(pTsdb);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d, %s commit failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s commit failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)taosThreadMutexLock(&pTsdb->lruMutex);
|
(void)taosThreadMutexLock(&pTsdb->lruMutex);
|
||||||
|
@ -1922,9 +1908,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
|
||||||
.cacheStatus = TSDB_LAST_CACHE_NO_CACHE};
|
.cacheStatus = TSDB_LAST_CACHE_NO_CACHE};
|
||||||
code = tsdbCachePutToLRU(pTsdb, &lastKey, &noneCol, 1);
|
code = tsdbCachePutToLRU(pTsdb, &lastKey, &noneCol, 1);
|
||||||
}
|
}
|
||||||
if (taosLRUCacheRelease(pTsdb->lruCache, h, false) != TSDB_CODE_SUCCESS) {
|
tsdbLRUCacheRelease(pTsdb->lruCache, h, false);
|
||||||
tsdbError("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__);
|
|
||||||
}
|
|
||||||
TAOS_CHECK_EXIT(code);
|
TAOS_CHECK_EXIT(code);
|
||||||
} else {
|
} else {
|
||||||
if (!remainCols) {
|
if (!remainCols) {
|
||||||
|
@ -1976,9 +1960,13 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
|
||||||
for (int i = 0; i < numKeys; ++i) {
|
for (int i = 0; i < numKeys; ++i) {
|
||||||
SLastCol *pLastCol = NULL;
|
SLastCol *pLastCol = NULL;
|
||||||
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_INVALID_PARA) {
|
||||||
tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
|
} else if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
|
tstrerror(code));
|
||||||
|
goto _exit;
|
||||||
}
|
}
|
||||||
SIdxKey *idxKey = taosArrayGet(remainCols, i);
|
SIdxKey *idxKey = taosArrayGet(remainCols, i);
|
||||||
SLastKey *pLastKey = &idxKey->key;
|
SLastKey *pLastKey = &idxKey->key;
|
||||||
|
@ -3483,11 +3471,7 @@ _err:
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h) {
|
void tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h) { tsdbLRUCacheRelease(pCache, h, false); }
|
||||||
if (taosLRUCacheRelease(pCache, h, false)) {
|
|
||||||
tsdbError("%s release lru cache failed at line %d.", __func__, __LINE__);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) {
|
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) {
|
||||||
taosLRUCacheSetCapacity(pVnode->pTsdb->lruCache, capacity);
|
taosLRUCacheSetCapacity(pVnode->pTsdb->lruCache, capacity);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
#include "functionResInfo.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
|
|
|
@ -602,14 +602,14 @@ int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fs
|
||||||
SSttLvl *lvl;
|
SSttLvl *lvl;
|
||||||
code = tsdbSttLvlInitRef(pTsdb, lvl1, &lvl);
|
code = tsdbSttLvlInitRef(pTsdb, lvl1, &lvl);
|
||||||
if (code) {
|
if (code) {
|
||||||
taosMemoryFree(lvl);
|
tsdbSttLvlClear(&lvl);
|
||||||
tsdbTFileSetClear(fset);
|
tsdbTFileSetClear(fset);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = TARRAY2_APPEND(fset[0]->lvlArr, lvl);
|
code = TARRAY2_APPEND(fset[0]->lvlArr, lvl);
|
||||||
if (code) {
|
if (code) {
|
||||||
taosMemoryFree(lvl);
|
tsdbSttLvlClear(&lvl);
|
||||||
tsdbTFileSetClear(fset);
|
tsdbTFileSetClear(fset);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -596,7 +596,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, void
|
||||||
|
|
||||||
pReader->status.pPrimaryTsCol = taosArrayGet(pReader->resBlockInfo.pResBlock->pDataBlock, pSup->slotId[0]);
|
pReader->status.pPrimaryTsCol = taosArrayGet(pReader->resBlockInfo.pResBlock->pDataBlock, pSup->slotId[0]);
|
||||||
if (pReader->status.pPrimaryTsCol == NULL) {
|
if (pReader->status.pPrimaryTsCol == NULL) {
|
||||||
code = TSDB_CODE_INVALID_PARA;
|
code = terrno;
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,6 +855,7 @@ static int32_t loadFileBlockBrinInfo(STsdbReader* pReader, SArray* pIndexList, S
|
||||||
STableBlockScanInfo** p = taosArrayGetLast(pTableScanInfoList);
|
STableBlockScanInfo** p = taosArrayGetLast(pTableScanInfoList);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
clearBrinBlockIter(&iter);
|
clearBrinBlockIter(&iter);
|
||||||
|
tsdbError("invalid param, empty in tablescanInfoList, %s", pReader->idStr);
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5256,7 +5257,7 @@ int32_t tsdbNextDataBlock2(STsdbReader* pReader, bool* hasNext) {
|
||||||
// NOTE: the following codes is used to perform test for suspend/resume for tsdbReader when it blocks the commit
|
// NOTE: the following codes is used to perform test for suspend/resume for tsdbReader when it blocks the commit
|
||||||
// the data should be ingested in round-robin and all the child tables should be createted before ingesting data
|
// the data should be ingested in round-robin and all the child tables should be createted before ingesting data
|
||||||
// the version range of query will be used to identify the correctness of suspend/resume functions.
|
// the version range of query will be used to identify the correctness of suspend/resume functions.
|
||||||
// this function will blocked before loading the SECOND block from vnode-buffer, and restart itself from sst-files
|
// this function will be blocked before loading the SECOND block from vnode-buffer, and restart itself from sst-files
|
||||||
#if SUSPEND_RESUME_TEST
|
#if SUSPEND_RESUME_TEST
|
||||||
if (!pReader->status.suspendInvoked && !pReader->status.loadFromFile) {
|
if (!pReader->status.suspendInvoked && !pReader->status.loadFromFile) {
|
||||||
tsem_wait(&pReader->resumeAfterSuspend);
|
tsem_wait(&pReader->resumeAfterSuspend);
|
||||||
|
|
|
@ -45,6 +45,7 @@ const SVnodeCfg vnodeCfgDefault = {.vgId = -1,
|
||||||
.retentionPeriod = -1,
|
.retentionPeriod = -1,
|
||||||
.rollPeriod = 0,
|
.rollPeriod = 0,
|
||||||
.segSize = 0,
|
.segSize = 0,
|
||||||
|
.committed = 0,
|
||||||
.retentionSize = -1,
|
.retentionSize = -1,
|
||||||
.level = TAOS_WAL_WRITE,
|
.level = TAOS_WAL_WRITE,
|
||||||
.clearFiles = 0,
|
.clearFiles = 0,
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue