commit
6a2b38faca
|
@ -138,3 +138,24 @@ tags
|
|||
*CMakeCache*
|
||||
*CMakeFiles*
|
||||
.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,13 +160,59 @@ ELSE ()
|
|||
CHECK_C_COMPILER_FLAG("-msse4.2" COMPILER_SUPPORT_SSE42)
|
||||
ENDIF()
|
||||
|
||||
IF (TD_ARM_64 OR TD_ARM_32)
|
||||
SET(COMPILER_SUPPORT_FMA false)
|
||||
SET(COMPILER_SUPPORT_AVX false)
|
||||
SET(COMPILER_SUPPORT_AVX2 false)
|
||||
SET(COMPILER_SUPPORT_AVX512F false)
|
||||
SET(COMPILER_SUPPORT_AVX512BMI false)
|
||||
SET(COMPILER_SUPPORT_AVX512VL false)
|
||||
ELSE()
|
||||
CHECK_C_COMPILER_FLAG("-mfma" COMPILER_SUPPORT_FMA)
|
||||
CHECK_C_COMPILER_FLAG("-mavx" COMPILER_SUPPORT_AVX)
|
||||
CHECK_C_COMPILER_FLAG("-mavx2" COMPILER_SUPPORT_AVX2)
|
||||
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)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
|
||||
|
@ -177,15 +223,17 @@ ELSE ()
|
|||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
|
||||
ENDIF()
|
||||
MESSAGE(STATUS "FMA instructions is ACTIVATED")
|
||||
ENDIF()
|
||||
IF (COMPILER_SUPPORT_AVX)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
||||
MESSAGE(STATUS "AVX instructions is ACTIVATED")
|
||||
ENDIF()
|
||||
IF (COMPILER_SUPPORT_AVX2)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
|
||||
ENDIF()
|
||||
MESSAGE(STATUS "SIMD instructions (FMA/AVX/AVX2) is ACTIVATED")
|
||||
MESSAGE(STATUS "AVX2 instructions is ACTIVATED")
|
||||
ENDIF()
|
||||
|
||||
IF ("${SIMD_AVX512_SUPPORT}" MATCHES "true")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# stub
|
||||
ExternalProject_Add(stub
|
||||
GIT_REPOSITORY https://github.com/coolxv/cpp-stub.git
|
||||
GIT_TAG 5e903b8e
|
||||
GIT_TAG 3137465194014d66a8402941e80d2bccc6346f51
|
||||
GIT_SUBMODULES "src"
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/cpp-stub"
|
||||
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. 新增数据源
|
||||
|
||||
在数据写入页面中点击左上角的 **+新增数据源** 按钮进入新增数据源页面,如下图所示:
|
||||
在数据写入页面中点击右上角的 **+新增数据源** 按钮进入新增数据源页面,如下图所示:
|
||||
|
||||

|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ d4,2017-07-14T10:40:00.006+08:00,-2.740636,10,-0.893545,7,California.LosAngles
|
|||
|
||||
- `plugins_home`:外部数据源连接器所在目录。
|
||||
- `data_dir`:数据文件存放目录。
|
||||
- `instanceId`:当前 explorer 服务的实例 ID,如果同一台机器上启动了多个 explorer 实例,必须保证各个实例的实例 ID 互不相同。
|
||||
- `instanceId`:当前 taosX 服务的实例 ID,如果同一台机器上启动了多个 taosX 实例,必须保证各个实例的实例 ID 互不相同。
|
||||
- `logs_home`:日志文件存放目录,`taosX` 日志文件的前缀为 `taosx.log`,外部数据源有自己的日志文件名前缀。已弃用,请使用 `log.path` 代替。
|
||||
- `log_level`:日志等级,可选级别包括 `error`、`warn`、`info`、`debug`、`trace`,默认值为 `info`。已弃用,请使用 `log.level` 代替。
|
||||
- `log_keep_days`:日志的最大存储天数,`taosX` 日志将按天划分为不同的文件。已弃用,请使用 `log.keepDays` 代替。
|
||||
|
|
|
@ -11,6 +11,7 @@ sidebar_label: taosX-Agent
|
|||
|
||||
- `endpoint`: 必填,`taosX` 的 GRPC 服务地址。
|
||||
- `token`: 必填,在 `Explorer` 上创建 `Agent` 时,产生的 Token。
|
||||
- `instanceId`:当前 taosx-agent 服务的实例 ID,如果同一台机器上启动了多个 taosx-agent 实例,必须保证各个实例的实例 ID 互不相同。
|
||||
- `compression`: 非必填,可配置为 `ture` 或 `false`, 默认为 `false`。配置为`true`, 则开启 `Agent` 和 `taosX` 通信数据压缩。
|
||||
- `log_level`: 非必填,日志级别,默认为 `info`, 同 `taosX` 一样,支持 `error`,`warn`,`info`,`debug`,`trace` 五级。已弃用,请使用 `log.level` 代替。
|
||||
- `log_keep_days`:非必填,日志保存天数,默认为 `30` 天。已弃用,请使用 `log.keepDays` 代替。
|
||||
|
@ -37,7 +38,7 @@ sidebar_label: taosX-Agent
|
|||
# server instance id
|
||||
#
|
||||
# The instanceId of each instance is unique on the host
|
||||
# instanceId = 64
|
||||
# instanceId = 48
|
||||
|
||||
# enable communication data compression between Agent and taosX
|
||||
#
|
||||
|
|
|
@ -132,7 +132,7 @@ cors = true
|
|||
- `cluster`:TDengine 集群的 taosAdapter 地址。
|
||||
- `cluster_native`:TDengine 集群的原生连接地址,默认关闭。
|
||||
- `x_api`:taosX 的 gRPC 地址。
|
||||
- `grpc`:taosX 代理向 taosX 建立连接的 gRPC 地址.
|
||||
- `grpc`:taosX 代理向 taosX 建立连接的 gRPC 地址。
|
||||
- `cors`:CORS 配置开关,默认为 `false`。当为 `true` 时,允许跨域访问。
|
||||
- `ssl.certificate`:SSL 证书(如果同时设置了 certificate 与 certificate_key 两个参数,则启用 HTTPS 服务,否则不启用)。
|
||||
- `ssl.certificate_key`:SSL 证书密钥。
|
||||
|
|
|
@ -99,7 +99,7 @@ PARTITION 子句中,为 tbname 定义了一个别名 tname, 在PARTITION 子
|
|||
|
||||
## 流式计算读取历史数据
|
||||
|
||||
正常情况下,流式计算不会处理创建前已经写入源表中的数据,若要处理已经写入的数据,可以在创建流时设置 fill_history 1 选项,这样创建的流式计算会自动处理创建前、创建中、创建后写入的数据。例如:
|
||||
正常情况下,流式计算不会处理创建前已经写入源表中的数据,若要处理已经写入的数据,可以在创建流时设置 fill_history 1 选项,这样创建的流式计算会自动处理创建前、创建中、创建后写入的数据。流计算处理历史数据的最大窗口数是2000万,超过限制会报错。例如:
|
||||
|
||||
```sql
|
||||
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.7【兼容软件】支持对工业软件 KingSCADA、Kepware 等的兼容性适配,通常情况下,选择默认值 General 即可
|
||||
|
||||
5. 点【测试连接】测试连接情况,如果成功,提示"成功连接到URL"
|
||||
|
||||
6. 点【确定】,即可保存配置并退出
|
||||
|
@ -90,12 +92,449 @@ TDengine ODBC 支持两种连接 TDengine 数据库方式:Websocket 连接与
|
|||
|
||||
4.6 【密码】仅供第5步测试连接使用,选填,数据库用户密码,如果不填,TDengine 默认 taosdata
|
||||
|
||||
4.7【兼容软件】支持对工业软件 KingSCADA、Kepware 等的兼容性适配,通常情况下,选择默认值 General 即可
|
||||
|
||||
5. 点【测试连接】测试连接情况,如果成功,提示"连接成功"
|
||||
|
||||
6. 点【确定】,即可保存配置并退出
|
||||
|
||||
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)
|
||||
|
|
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 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_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 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);
|
||||
|
@ -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 const char *tmq_err2str(int32_t code);
|
||||
|
||||
/* ------------------------------ TAOSX -----------------------------------*/
|
||||
/* ------------------------------ TAOSX INTERFACE -----------------------------------*/
|
||||
typedef struct tmq_raw_data {
|
||||
void *raw;
|
||||
uint32_t raw_len;
|
||||
|
|
|
@ -89,32 +89,6 @@ typedef struct {
|
|||
int32_t exprIdx;
|
||||
} 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) {
|
||||
STupleKey* pTuple1 = (STupleKey*)pKey1;
|
||||
STupleKey* pTuple2 = (STupleKey*)pKey2;
|
||||
|
|
|
@ -277,7 +277,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** pReq, const SSDataBlock* pData
|
|||
|
||||
bool alreadyAddGroupId(char* ctbName, int64_t groupId);
|
||||
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 buildCtbNameByGroupIdImpl(const char* stbName, uint64_t groupId, char* pBuf);
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ extern int64_t tsMinDiskFreeSize;
|
|||
// udf
|
||||
extern bool tsStartUdfd;
|
||||
extern char tsUdfdResFuncs[];
|
||||
extern char tsUdfdLdLibPath[];
|
||||
extern char tsUdfdLdLibPath[512];
|
||||
|
||||
// schemaless
|
||||
extern char tsSmlChildTableName[];
|
||||
|
|
|
@ -1684,6 +1684,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
int32_t openVnodes;
|
||||
int32_t dropVnodes;
|
||||
int32_t totalVnodes;
|
||||
int32_t masterNum;
|
||||
int64_t numOfSelectReqs;
|
||||
|
@ -4048,9 +4049,10 @@ void tDeleteMqMetaRsp(SMqMetaRsp* pRsp);
|
|||
#define MQ_DATA_RSP_VERSION 100
|
||||
|
||||
typedef struct {
|
||||
struct {
|
||||
SMqRspHead head;
|
||||
STqOffsetVal reqOffset;
|
||||
STqOffsetVal rspOffset;
|
||||
STqOffsetVal reqOffset;
|
||||
int32_t blockNum;
|
||||
int8_t withTbName;
|
||||
int8_t withSchema;
|
||||
|
@ -4058,27 +4060,28 @@ typedef struct {
|
|||
SArray* blockData;
|
||||
SArray* blockTbName;
|
||||
SArray* blockSchema;
|
||||
} SMqDataRspCommon;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
SMqDataRspCommon common;
|
||||
union{
|
||||
struct{
|
||||
int64_t sleepTime;
|
||||
} SMqDataRsp;
|
||||
|
||||
int32_t tEncodeMqDataRsp(SEncoder* pEncoder, const void* pRsp);
|
||||
int32_t tDecodeMqDataRsp(SDecoder* pDecoder, void* pRsp);
|
||||
void tDeleteMqDataRsp(void* pRsp);
|
||||
|
||||
typedef struct {
|
||||
SMqDataRspCommon common;
|
||||
};
|
||||
struct{
|
||||
int32_t createTableNum;
|
||||
SArray* createTableLen;
|
||||
SArray* createTableReq;
|
||||
} STaosxRsp;
|
||||
};
|
||||
};
|
||||
|
||||
int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const void* pRsp);
|
||||
int32_t tDecodeSTaosxRsp(SDecoder* pDecoder, void* pRsp);
|
||||
void tDeleteSTaosxRsp(void* pRsp);
|
||||
} SMqDataRsp;
|
||||
|
||||
int32_t tEncodeMqDataRsp(SEncoder *pEncoder, const SMqDataRsp *pObj);
|
||||
int32_t tDecodeMqDataRsp(SDecoder* pDecoder, SMqDataRsp* pRsp);
|
||||
void tDeleteMqDataRsp(SMqDataRsp* pRsp);
|
||||
|
||||
int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const SMqDataRsp* pRsp);
|
||||
int32_t tDecodeSTaosxRsp(SDecoder* pDecoder, SMqDataRsp* pRsp);
|
||||
void tDeleteSTaosxRsp(SMqDataRsp* pRsp);
|
||||
|
||||
typedef struct SMqBatchMetaRsp {
|
||||
SMqRspHead head; // not serialize
|
||||
|
@ -4163,6 +4166,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
SArray* topicPrivileges; // SArray<STopicPrivilege>
|
||||
int32_t debugFlag;
|
||||
} SMqHbRsp;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -64,7 +64,7 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
|
|||
: 1000000000;
|
||||
time_t t = taosTime(NULL);
|
||||
struct tm tm;
|
||||
(void) taosLocalTime(&t, &tm, NULL);
|
||||
(void) taosLocalTime(&t, &tm, NULL, 0);
|
||||
tm.tm_hour = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_sec = 0;
|
||||
|
|
|
@ -23,6 +23,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
// 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 {
|
||||
uint32_t nType;
|
||||
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 qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t groupId, SRetrieveTableRsp **pRsp);
|
||||
void qExplainFreeCtx(SExplainCtx *pCtx);
|
||||
int32_t formatDurationOrKeep(char* buffer, int32_t timeInMinutes);
|
||||
int32_t formatDurationOrKeep(char* buffer, int64_t bufSize, int32_t timeInMinutes);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,7 @@ extern "C" {
|
|||
#include "tcommon.h"
|
||||
#include "tsimplehash.h"
|
||||
#include "tvariant.h"
|
||||
#include "functionResInfo.h"
|
||||
|
||||
struct SqlFunctionCtx;
|
||||
struct SResultRowEntryInfo;
|
||||
|
@ -85,14 +86,7 @@ enum {
|
|||
PRE_SCAN = 0x2u, // pre-scan belongs to the main scan and occurs before main scan
|
||||
};
|
||||
|
||||
typedef struct SPoint1 {
|
||||
int64_t key;
|
||||
union {
|
||||
double val;
|
||||
char *ptr;
|
||||
};
|
||||
} SPoint1;
|
||||
|
||||
struct SPoint1;
|
||||
struct SqlFunctionCtx;
|
||||
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_STATE,
|
||||
WINDOW_TYPE_EVENT,
|
||||
WINDOW_TYPE_COUNT
|
||||
WINDOW_TYPE_COUNT,
|
||||
} EWindowType;
|
||||
|
||||
typedef enum EWindowAlgorithm {
|
||||
|
|
|
@ -190,7 +190,6 @@ typedef struct SFunctionNode {
|
|||
bool hasOriginalFunc;
|
||||
int32_t originalFuncId;
|
||||
ETrimType trimType;
|
||||
bool hasSMA;
|
||||
bool dual; // whether select stmt without from stmt, true for without.
|
||||
} 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);
|
||||
|
||||
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);
|
||||
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
|
||||
void getColumnTypeFromMeta(STableMeta* pMeta, char* pName, ETableColumnType* pType);
|
||||
|
@ -410,25 +410,25 @@ void* getTaskPoolWorkerCb();
|
|||
#define qFatal(...) \
|
||||
do { \
|
||||
if (qDebugFlag & DEBUG_FATAL) { \
|
||||
taosPrintLog("QRY FATAL ", DEBUG_FATAL, qDebugFlag, __VA_ARGS__); \
|
||||
taosPrintLog("QRY FATAL ", DEBUG_FATAL, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#define qError(...) \
|
||||
do { \
|
||||
if (qDebugFlag & DEBUG_ERROR) { \
|
||||
taosPrintLog("QRY ERROR ", DEBUG_ERROR, qDebugFlag, __VA_ARGS__); \
|
||||
taosPrintLog("QRY ERROR ", DEBUG_ERROR, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#define qWarn(...) \
|
||||
do { \
|
||||
if (qDebugFlag & DEBUG_WARN) { \
|
||||
taosPrintLog("QRY WARN ", DEBUG_WARN, qDebugFlag, __VA_ARGS__); \
|
||||
taosPrintLog("QRY WARN ", DEBUG_WARN, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#define qInfo(...) \
|
||||
do { \
|
||||
if (qDebugFlag & DEBUG_INFO) { \
|
||||
taosPrintLog("QRY ", DEBUG_INFO, qDebugFlag, __VA_ARGS__); \
|
||||
taosPrintLog("QRY ", DEBUG_INFO, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#define qDebug(...) \
|
||||
|
|
|
@ -47,7 +47,7 @@ extern "C" {
|
|||
#define SYNC_HEARTBEAT_SLOW_MS 1500
|
||||
#define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500
|
||||
#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
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ typedef struct {
|
|||
int32_t rollPeriod; // secs
|
||||
int64_t retentionSize;
|
||||
int64_t segSize;
|
||||
int64_t committed;
|
||||
EWalType level; // wal level
|
||||
int32_t encryptAlgorithm;
|
||||
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
||||
|
|
|
@ -247,9 +247,12 @@ void syslog(int unused, const char *format, ...);
|
|||
#define TD_DIRSEP_CHAR '/'
|
||||
#endif
|
||||
|
||||
#define TD_FQDN_LEN 128
|
||||
#define TD_LOCALE_LEN 64
|
||||
#define TD_CHARSET_LEN 64
|
||||
#define TD_TIMEZONE_LEN 96
|
||||
#define TD_TIME_STR_LEN 128
|
||||
#define TD_IP_LEN 64
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -85,7 +85,6 @@ typedef int32_t SOCKET;
|
|||
#else
|
||||
#define TAOS_EPOLL_WAIT_TIME 500
|
||||
typedef int32_t SOCKET;
|
||||
typedef SOCKET EpollFd;
|
||||
#define EpollClose(pollFd) taosCloseSocket(pollFd)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -62,12 +62,14 @@ typedef enum { M2C = 0, C2M } ConvType;
|
|||
#define tstrncpy(dst, src, size) \
|
||||
do { \
|
||||
(void)strncpy((dst), (src), (size)); \
|
||||
(dst)[(size)-1] = 0; \
|
||||
(dst)[(size) - 1] = 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_STRNCPY(_dst, _src, _size) ((void)strncpy(_dst, _src, _size))
|
||||
#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);
|
||||
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 tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||
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 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 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);
|
||||
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);
|
||||
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);
|
||||
time_t taosTime(time_t *t);
|
||||
time_t taosMktime(struct tm *timep);
|
||||
|
|
|
@ -476,7 +476,6 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_DNODE_INVALID_MONITOR_PARAS TAOS_DEF_ERROR_CODE(0, 0x0429)
|
||||
#define TSDB_CODE_MNODE_STOPPED TAOS_DEF_ERROR_CODE(0, 0x042A)
|
||||
|
||||
|
||||
// mnode-sma
|
||||
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
|
||||
#define TSDB_CODE_MND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0481)
|
||||
|
|
|
@ -152,11 +152,15 @@ int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int
|
|||
// for internal usage
|
||||
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);
|
||||
void tsDecompressFloatImplAvx512(const char *const input, const int32_t nelements, char *const output);
|
||||
void tsDecompressFloatImplAvx2(const char *const input, const int32_t nelements, char *const output);
|
||||
int32_t tsDecompressFloatImpAvx2(const char *input, int32_t nelements, char *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 tsDecompressTimestampAvx2(const char *const input, const int32_t nelements, char *const output, bool bigEndian);
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
* 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);
|
||||
typedef int32_t (*__data_compress_l1_fn_t)(const char *const input, const int32_t nelements, char *const output,
|
||||
const char type);
|
||||
typedef int32_t (*__data_decompress_l1_fn_t)(const char *const input, const int32_t nelements, char *const output,
|
||||
const char type);
|
||||
typedef int32_t (*__data_decompress_l1_fn_t)(const char *const input, int32_t ninput, const int32_t nelements,
|
||||
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,
|
||||
int32_t outputSize, const char type, int8_t level);
|
||||
|
|
|
@ -284,7 +284,7 @@ typedef enum ELogicConditionType {
|
|||
|
||||
#define TSDB_CLUSTER_ID_LEN 40
|
||||
#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_IPv4ADDR_LEN 16
|
||||
#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_VALUE_LEN 300
|
||||
#define MONITOR_METRIC_NAME_LEN 100
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#define TDIGEST_H
|
||||
|
||||
#include "os.h"
|
||||
#include "libs/function/functionResInfo.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338327950288 /* pi */
|
||||
|
@ -37,32 +38,6 @@
|
|||
#define TDIGEST_SIZE(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);
|
||||
int32_t tdigestAdd(TDigest *t, double x, int64_t w);
|
||||
int32_t tdigestMerge(TDigest *t1, TDigest *t2);
|
||||
|
|
|
@ -69,6 +69,8 @@ extern int32_t tdbDebugFlag;
|
|||
extern int32_t sndDebugFlag;
|
||||
extern int32_t simDebugFlag;
|
||||
|
||||
extern int32_t tqClientDebug;
|
||||
|
||||
int32_t taosInitLog(const char *logName, int32_t maxFiles, bool tsc);
|
||||
void taosCloseLog();
|
||||
void taosResetLog();
|
||||
|
|
|
@ -48,3 +48,6 @@ int64_t tGenIdPI64(void);
|
|||
* @return
|
||||
*/
|
||||
int64_t tGenQid64(int8_t dnodeId);
|
||||
|
||||
int32_t taosGetSystemUUIDU32(uint32_t *uuid);
|
||||
int32_t taosGetSystemUUIDU64(uint64_t *uuid);
|
||||
|
|
|
@ -226,30 +226,16 @@ typedef struct {
|
|||
SSchemaWrapper schema;
|
||||
int32_t resIter;
|
||||
SReqResultInfo resInfo;
|
||||
} SMqRspObjCommon;
|
||||
|
||||
typedef struct {
|
||||
SMqRspObjCommon common;
|
||||
SMqDataRsp rsp;
|
||||
} SMqRspObj;
|
||||
|
||||
typedef struct {
|
||||
int8_t resType;
|
||||
char topic[TSDB_TOPIC_FNAME_LEN];
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int32_t vgId;
|
||||
union{
|
||||
struct{
|
||||
SMqRspHead head;
|
||||
STqOffsetVal rspOffset;
|
||||
};
|
||||
SMqDataRsp dataRsp;
|
||||
SMqMetaRsp metaRsp;
|
||||
} SMqMetaRspObj;
|
||||
|
||||
typedef struct {
|
||||
SMqRspObjCommon common;
|
||||
STaosxRsp rsp;
|
||||
} SMqTaosxRspObj;
|
||||
|
||||
typedef struct {
|
||||
SMqRspObjCommon common;
|
||||
SMqBatchMetaRsp rsp;
|
||||
} SMqBatchMetaRspObj;
|
||||
SMqBatchMetaRsp batchMetaRsp;
|
||||
};
|
||||
} SMqRspObj;
|
||||
|
||||
typedef struct SReqRelInfo {
|
||||
uint64_t userRefId;
|
||||
|
@ -332,7 +318,7 @@ int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols);
|
|||
|
||||
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
||||
SMqRspObj* msg = (SMqRspObj*)res;
|
||||
return (SReqResultInfo*)&msg->common.resInfo;
|
||||
return (SReqResultInfo*)&msg->resInfo;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
if (i != 0) {
|
||||
(void)strcat(buf, ",");
|
||||
(void)strncat(buf, ",", size - 1 - len);
|
||||
len += 1;
|
||||
}
|
||||
int ret = snprintf(buf + len, size - len, "%s", db);
|
||||
int ret = tsnprintf(buf + len, size - len, "%s", db);
|
||||
if (ret < 0) {
|
||||
tscError("snprintf failed, buf:%s, ret:%d", buf, ret);
|
||||
break;
|
||||
|
@ -1094,18 +1094,14 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
* @return
|
||||
*/
|
||||
uint64_t generateRequestId() {
|
||||
static uint64_t hashId = 0;
|
||||
static uint32_t requestSerialId = 0;
|
||||
static uint32_t hashId = 0;
|
||||
static int32_t requestSerialId = 0;
|
||||
|
||||
if (hashId == 0) {
|
||||
char uid[64] = {0};
|
||||
int32_t code = taosGetSystemUUID(uid, tListLen(uid));
|
||||
int32_t code = taosGetSystemUUIDU32(&hashId);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tscError("Failed to get the system uid to generated request id, reason:%s. use ip address instead",
|
||||
tstrerror(TAOS_SYSTEM_ERROR(errno)));
|
||||
|
||||
} else {
|
||||
hashId = MurmurHash3_32(uid, strlen(uid));
|
||||
tstrerror(code));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1117,7 +1113,7 @@ uint64_t generateRequestId() {
|
|||
uint32_t val = atomic_add_fetch_32(&requestSerialId, 1);
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
|
@ -1132,27 +1128,27 @@ static setConfRet taos_set_config_imp(const char *config){
|
|||
static bool setConfFlag = false;
|
||||
if (setConfFlag) {
|
||||
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;
|
||||
}
|
||||
taosInitGlobalCfg();
|
||||
cJSON *root = cJSON_Parse(config);
|
||||
if (root == NULL){
|
||||
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;
|
||||
}
|
||||
|
||||
int size = cJSON_GetArraySize(root);
|
||||
if(!cJSON_IsObject(root) || size == 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
if(size >= 1000) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1160,7 +1156,7 @@ static setConfRet taos_set_config_imp(const char *config){
|
|||
cJSON *item = cJSON_GetArrayItem(root, i);
|
||||
if(!item) {
|
||||
ret.retCode = SET_CONF_RET_ERR_INNER;
|
||||
strcpy(ret.retMsg, "inner error");
|
||||
tstrncpy(ret.retMsg, "inner error", RET_MSG_LENGTH);
|
||||
return ret;
|
||||
}
|
||||
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) {
|
||||
SGetUserAuthRsp *rsp = taosArrayGet(batchRsp.pArray, i);
|
||||
if (NULL == rsp) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
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) {
|
||||
SDbHbRsp *rsp = taosArrayGet(batchRsp.pArray, i);
|
||||
if (NULL == rsp) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
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) {
|
||||
STableMetaRsp *rsp = taosArrayGet(hbRsp.pMetaRsp, i);
|
||||
if (NULL == rsp) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
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) {
|
||||
STableIndexRsp *rsp = taosArrayGet(hbRsp.pIndexRsp, i);
|
||||
if (NULL == rsp) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
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) {
|
||||
SViewMetaRsp *rsp = taosArrayGetP(hbRsp.pViewRsp, i);
|
||||
if (NULL == rsp) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
if (rsp->numOfCols < 0) {
|
||||
|
@ -772,7 +772,7 @@ static int32_t hbGetUserAuthInfo(SClientHbKey *connKey, SHbParam *param, SClient
|
|||
SUserAuthVersion *qUserAuth =
|
||||
(SUserAuthVersion *)taosMemoryRealloc(pKv->value, (userNum + 1) * sizeof(SUserAuthVersion));
|
||||
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
|
||||
pKv->value = qUserAuth;
|
||||
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) {
|
||||
STbVerInfo* tbInfo = taosArrayGet(pTbArray, i);
|
||||
if (NULL == tbInfo) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
char ipStr[TSDB_EP_LEN] = {0};
|
||||
char dbStr[TSDB_DB_NAME_LEN] = {0};
|
||||
char userStr[TSDB_USER_LEN] = {0};
|
||||
char passStr[TSDB_PASSWORD_LEN] = {0};
|
||||
|
||||
(void)strncpy(ipStr, ip, TMIN(TSDB_EP_LEN - 1, ipLen));
|
||||
(void)strncpy(userStr, user, TMIN(TSDB_USER_LEN - 1, userLen));
|
||||
(void)strncpy(passStr, pass, TMIN(TSDB_PASSWORD_LEN - 1, passLen));
|
||||
(void)strncpy(dbStr, db, TMIN(TSDB_DB_NAME_LEN - 1, dbLen));
|
||||
return taos_connect(ipStr, userStr, passStr, dbStr, port);
|
||||
}
|
||||
//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) {
|
||||
// char ipStr[TSDB_EP_LEN] = {0};
|
||||
// char dbStr[TSDB_DB_NAME_LEN] = {0};
|
||||
// char userStr[TSDB_USER_LEN] = {0};
|
||||
// char passStr[TSDB_PASSWORD_LEN] = {0};
|
||||
//
|
||||
// tstrncpy(ipStr, ip, TMIN(TSDB_EP_LEN - 1, ipLen));
|
||||
// tstrncpy(userStr, user, TMIN(TSDB_USER_LEN - 1, userLen));
|
||||
// tstrncpy(passStr, pass, TMIN(TSDB_PASSWORD_LEN - 1, passLen));
|
||||
// tstrncpy(dbStr, db, TMIN(TSDB_DB_NAME_LEN - 1, dbLen));
|
||||
// return taos_connect(ipStr, userStr, passStr, dbStr, port);
|
||||
//}
|
||||
|
||||
void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
|
||||
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 dst[TSDB_MAX_JSON_TAG_LEN] = {0};
|
||||
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)));
|
||||
} else if (tTagIsJson(data)) {
|
||||
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) = '\"';
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_DOUBLE) {
|
||||
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)));
|
||||
} 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)));
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
(void)sprintf(dbFName, "%d.%.*s", acctId, dbLen, dbName);
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
(void)snprintf(dbFName, TSDB_DB_FNAME_LEN, "%d.%.*s", acctId, dbLen, dbName);
|
||||
|
||||
STablesReq* pDb = taosHashGet(pHash, dbFName, strlen(dbFName));
|
||||
if (pDb) {
|
||||
|
@ -2672,7 +2672,7 @@ int32_t appendTbToReq(SHashObj* pHash, int32_t pos1, int32_t len1, int32_t pos2,
|
|||
if (NULL == db.pTables) {
|
||||
return terrno;
|
||||
}
|
||||
(void)strcpy(db.dbFName, dbFName);
|
||||
tstrncpy(db.dbFName, dbFName, TSDB_DB_FNAME_LEN);
|
||||
if (NULL == taosArrayPush(db.pTables, &name)) {
|
||||
return terrno;
|
||||
}
|
||||
|
|
|
@ -1083,14 +1083,14 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_stmtErrorMsgIm
|
|||
TAOS *tscon = (TAOS *)con;
|
||||
if (tscon == NULL) {
|
||||
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);
|
||||
}
|
||||
|
||||
TAOS_STMT *pStmt = (TAOS_STMT *)stmt;
|
||||
if (pStmt == NULL) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -373,25 +373,22 @@ void taos_free_result(TAOS_RES *res) {
|
|||
SRequestObj *pRequest = (SRequestObj *)res;
|
||||
tscDebug("0x%" PRIx64 " taos_free_result start to free query", pRequest->requestId);
|
||||
destroyRequest(pRequest);
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
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) {
|
||||
|
@ -454,7 +451,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
} else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
SMqRspObj *msg = ((SMqRspObj *)res);
|
||||
SReqResultInfo *pResultInfo = NULL;
|
||||
if (msg->common.resIter == -1) {
|
||||
if (msg->resIter == -1) {
|
||||
if (tmqGetNextResInfo(res, true, &pResultInfo) != 0) {
|
||||
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) {
|
||||
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;
|
||||
for (int i = 0; i < num_fields; ++i) {
|
||||
if (i > 0) {
|
||||
if (i > 0 && len < size - 1) {
|
||||
str[len++] = ' ';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
switch (fields[i].type) {
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float fv = 0;
|
||||
fv = GET_FLOAT_VAL(row[i]);
|
||||
len += sprintf(str + len, "%f", fv);
|
||||
len += snprintf(str + len, size - len, "%f", fv);
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
double dv = 0;
|
||||
dv = GET_DOUBLE_VAL(row[i]);
|
||||
len += sprintf(str + len, "%lf", dv);
|
||||
len += snprintf(str + len, size - len, "%lf", dv);
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_VARBINARY: {
|
||||
void *data = NULL;
|
||||
uint32_t size = 0;
|
||||
uint32_t tmp = 0;
|
||||
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;
|
||||
}
|
||||
(void)memcpy(str + len, data, size);
|
||||
len += size;
|
||||
uint32_t copyLen = TMIN(size - len - 1, tmp);
|
||||
(void)memcpy(str + len, data, copyLen);
|
||||
len += copyLen;
|
||||
taosMemoryFree(data);
|
||||
} break;
|
||||
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);
|
||||
len += charLen;
|
||||
uint32_t copyLen = TMIN(size - len - 1, charLen);
|
||||
(void)memcpy(str + len, row[i], copyLen);
|
||||
len += copyLen;
|
||||
} break;
|
||||
|
||||
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;
|
||||
|
||||
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:
|
||||
break;
|
||||
}
|
||||
|
||||
if (len >= size - 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (len < size){
|
||||
str[len] = 0;
|
||||
}
|
||||
|
||||
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;
|
||||
TSC_ERR_JRET(TSDB_CODE_INVALID_PARA);
|
||||
} else {
|
||||
(void)strcpy(database, pTscObj->db);
|
||||
tstrncpy(database, pTscObj->db, len);
|
||||
code = 0;
|
||||
}
|
||||
_return:
|
||||
|
|
|
@ -21,7 +21,7 @@ char tmpSlowLogPath[PATH_MAX] = {0};
|
|||
TdThread monitorThread;
|
||||
|
||||
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) {
|
||||
tscError("failed to get tmp path ret:%d", ret);
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
|
@ -183,7 +183,7 @@ FAILED:
|
|||
|
||||
static void generateClusterReport(taos_collector_registry_t* registry, void* pTransporter, SEpSet* epSet) {
|
||||
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);
|
||||
if (NULL == pCont) {
|
||||
tscError("generateClusterReport failed, get null content.");
|
||||
|
@ -401,7 +401,7 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
|
|||
return;
|
||||
}
|
||||
pClient->lastCheckTime = taosGetMonoTimestampMs();
|
||||
(void)strcpy(pClient->path, path);
|
||||
tstrncpy(pClient->path, path, PATH_MAX);
|
||||
pClient->offset = 0;
|
||||
pClient->pFile = pFile;
|
||||
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;
|
||||
}
|
||||
char* buf = pCont;
|
||||
(void)strcat(buf++, "[");
|
||||
(void)strncat(buf++, "[", totalSize - 1);
|
||||
int64_t readSize = taosReadFile(pFile, buf, totalSize - 4); // 4 reserved for []
|
||||
if (readSize <= 0) {
|
||||
if (readSize < 0) {
|
||||
|
|
|
@ -458,15 +458,17 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
|||
cJSON* tvalue = NULL;
|
||||
if (IS_VAR_DATA_TYPE(pTagVal->type)) {
|
||||
char* buf = NULL;
|
||||
int64_t bufSize = 0;
|
||||
if (pTagVal->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||
buf = taosMemoryCalloc(pTagVal->nData * 2 + 2 + 3, 1);
|
||||
bufSize = pTagVal->nData * 2 + 2 + 3;
|
||||
} else {
|
||||
buf = taosMemoryCalloc(pTagVal->nData + 3, 1);
|
||||
bufSize = pTagVal->nData + 3;
|
||||
}
|
||||
buf = taosMemoryCalloc(bufSize, 1);
|
||||
|
||||
RAW_NULL_CHECK(buf);
|
||||
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);
|
||||
goto end;
|
||||
}
|
||||
|
@ -548,7 +550,7 @@ end:
|
|||
tDecoderClear(&decoder);
|
||||
}
|
||||
|
||||
static void processAutoCreateTable(STaosxRsp* rsp, char** string) {
|
||||
static void processAutoCreateTable(SMqDataRsp* rsp, char** string) {
|
||||
SDecoder* decoder = NULL;
|
||||
SVCreateTbReq* pCreateReq = NULL;
|
||||
int32_t code = 0;
|
||||
|
@ -736,13 +738,15 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
goto end;
|
||||
}
|
||||
} else {
|
||||
int64_t bufSize = 0;
|
||||
if (vAlterTbReq.tagType == TSDB_DATA_TYPE_VARBINARY) {
|
||||
buf = taosMemoryCalloc(vAlterTbReq.nTagVal * 2 + 2 + 3, 1);
|
||||
bufSize = vAlterTbReq.nTagVal * 2 + 2 + 3;
|
||||
} else {
|
||||
buf = taosMemoryCalloc(vAlterTbReq.nTagVal + 3, 1);
|
||||
bufSize = vAlterTbReq.nTagVal + 3;
|
||||
}
|
||||
buf = taosMemoryCalloc(bufSize, 1);
|
||||
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) {
|
||||
taosMemoryFree(buf);
|
||||
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++) {
|
||||
SSchema* pSchema = req.schemaRow.pSchema + i;
|
||||
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) {
|
||||
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++) {
|
||||
SSchema* pSchema = req.schemaTag.pSchema + i;
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -1240,7 +1244,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
if (pTableBatch == NULL) {
|
||||
SVgroupCreateTableBatch tBatch = {0};
|
||||
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));
|
||||
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);
|
||||
pRequest->syncQuery = true;
|
||||
rspObj.common.resIter = -1;
|
||||
rspObj.common.resType = RES_TYPE__TMQ;
|
||||
rspObj.resIter = -1;
|
||||
rspObj.resType = RES_TYPE__TMQ;
|
||||
|
||||
int8_t dataVersion = *(int8_t*)data;
|
||||
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);
|
||||
}
|
||||
tDecoderInit(&decoder, data, dataLen);
|
||||
code = tDecodeMqDataRsp(&decoder, &rspObj.rsp);
|
||||
code = tDecodeMqDataRsp(&decoder, &rspObj.dataRsp);
|
||||
if (code != 0) {
|
||||
SET_ERROR_MSG("decode mq data rsp failed");
|
||||
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));
|
||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
RAW_NULL_CHECK(pVgHash);
|
||||
while (++rspObj.common.resIter < rspObj.rsp.common.blockNum) {
|
||||
void* pRetrieve = taosArrayGetP(rspObj.rsp.common.blockData, rspObj.common.resIter);
|
||||
while (++rspObj.resIter < rspObj.dataRsp.blockNum) {
|
||||
void* pRetrieve = taosArrayGetP(rspObj.dataRsp.blockData, rspObj.resIter);
|
||||
RAW_NULL_CHECK(pRetrieve);
|
||||
if (!rspObj.rsp.common.withSchema) {
|
||||
if (!rspObj.dataRsp.withSchema) {
|
||||
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);
|
||||
|
||||
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
||||
(void)strcpy(pName.dbname, pRequest->pDb);
|
||||
(void)strcpy(pName.tname, tbName);
|
||||
tstrncpy(pName.dbname, pRequest->pDb, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pName.tname, tbName, TSDB_TABLE_NAME_LEN);
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.common.blockSchema, rspObj.common.resIter);
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.dataRsp.blockSchema, rspObj.resIter);
|
||||
RAW_NULL_CHECK(pSW);
|
||||
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
||||
RAW_NULL_CHECK(fields);
|
||||
|
@ -1805,7 +1809,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
|
||||
end:
|
||||
uDebug(LOG_ID_TAG " write raw data return, msg:%s", LOG_ID_VALUE, tstrerror(code));
|
||||
tDeleteMqDataRsp(&rspObj.rsp);
|
||||
tDeleteMqDataRsp(&rspObj.dataRsp);
|
||||
tDecoderClear(&decoder);
|
||||
qDestroyQuery(pQuery);
|
||||
destroyRequest(pRequest);
|
||||
|
@ -1814,7 +1818,7 @@ end:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildCreateTbMap(STaosxRsp* rsp, SHashObj* pHashObj) {
|
||||
static int32_t buildCreateTbMap(SMqDataRsp* rsp, SHashObj* pHashObj) {
|
||||
// find schema data info
|
||||
int32_t code = 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;
|
||||
SHashObj* pVgHash = NULL;
|
||||
SQuery* pQuery = NULL;
|
||||
SMqTaosxRspObj rspObj = {0};
|
||||
SMqRspObj rspObj = {0};
|
||||
SDecoder decoder = {0};
|
||||
STableMeta* pTableMeta = 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);
|
||||
pRequest->syncQuery = true;
|
||||
rspObj.common.resIter = -1;
|
||||
rspObj.common.resType = RES_TYPE__TMQ_METADATA;
|
||||
rspObj.resIter = -1;
|
||||
rspObj.resType = RES_TYPE__TMQ_METADATA;
|
||||
|
||||
int8_t dataVersion = *(int8_t*)data;
|
||||
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);
|
||||
code = tDecodeSTaosxRsp(&decoder, &rspObj.rsp);
|
||||
code = tDecodeSTaosxRsp(&decoder, &rspObj.dataRsp);
|
||||
if (code != 0) {
|
||||
SET_ERROR_MSG("decode mq taosx data rsp failed");
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
|
@ -1905,34 +1909,34 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
RAW_NULL_CHECK(pVgHash);
|
||||
pCreateTbHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
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);
|
||||
while (++rspObj.common.resIter < rspObj.rsp.common.blockNum) {
|
||||
void* pRetrieve = taosArrayGetP(rspObj.rsp.common.blockData, rspObj.common.resIter);
|
||||
uDebug(LOG_ID_TAG " write raw metadata block num:%d", LOG_ID_VALUE, rspObj.dataRsp.blockNum);
|
||||
while (++rspObj.resIter < rspObj.dataRsp.blockNum) {
|
||||
void* pRetrieve = taosArrayGetP(rspObj.dataRsp.blockData, rspObj.resIter);
|
||||
RAW_NULL_CHECK(pRetrieve);
|
||||
if (!rspObj.rsp.common.withSchema) {
|
||||
if (!rspObj.dataRsp.withSchema) {
|
||||
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) {
|
||||
SET_ERROR_MSG("block tbname is null");
|
||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
|
||||
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}};
|
||||
(void)strcpy(pName.dbname, pRequest->pDb);
|
||||
(void)strcpy(pName.tname, tbName);
|
||||
tstrncpy(pName.dbname, pRequest->pDb, TSDB_DB_NAME_LEN);
|
||||
tstrncpy(pName.tname, tbName, TSDB_TABLE_NAME_LEN);
|
||||
|
||||
// find schema data info
|
||||
SVCreateTbReq* pCreateReqDst = (SVCreateTbReq*)taosHashGet(pCreateTbHash, tbName, strlen(tbName));
|
||||
SVgroupInfo vg = {0};
|
||||
RAW_RETURN_CHECK(catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg));
|
||||
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));
|
||||
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.common.blockSchema, rspObj.common.resIter);
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.dataRsp.blockSchema, rspObj.resIter);
|
||||
RAW_NULL_CHECK(pSW);
|
||||
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
||||
if (fields == NULL) {
|
||||
|
@ -1991,7 +1995,7 @@ end:
|
|||
pIter = taosHashIterate(pCreateTbHash, pIter);
|
||||
}
|
||||
taosHashCleanup(pCreateTbHash);
|
||||
tDeleteSTaosxRsp(&rspObj.rsp);
|
||||
tDeleteSTaosxRsp(&rspObj.dataRsp);
|
||||
tDecoderClear(&decoder);
|
||||
qDestroyQuery(pQuery);
|
||||
destroyRequest(pRequest);
|
||||
|
@ -2072,31 +2076,28 @@ char* tmq_get_json_meta(TAOS_RES* res) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char* string = NULL;
|
||||
SMqRspObj* rspObj = (SMqRspObj*)res;
|
||||
if (TD_RES_TMQ_METADATA(res)) {
|
||||
SMqTaosxRspObj* pMetaDataRspObj = (SMqTaosxRspObj*)res;
|
||||
char* string = NULL;
|
||||
processAutoCreateTable(&pMetaDataRspObj->rsp, &string);
|
||||
return string;
|
||||
processAutoCreateTable(&rspObj->dataRsp, &string);
|
||||
} else if (TD_RES_TMQ_BATCH_META(res)) {
|
||||
SMqBatchMetaRspObj* pBatchMetaRspObj = (SMqBatchMetaRspObj*)res;
|
||||
char* string = NULL;
|
||||
processBatchMetaToJson(&pBatchMetaRspObj->rsp, &string);
|
||||
return string;
|
||||
processBatchMetaToJson(&rspObj->batchMetaRsp, &string);
|
||||
} else if (TD_RES_TMQ_META(res)) {
|
||||
cJSON* pJson = NULL;
|
||||
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);
|
||||
return string;
|
||||
}
|
||||
|
||||
void tmq_free_json_meta(char* jsonMeta) { taosMemoryFreeClear(jsonMeta); }
|
||||
|
||||
static int32_t getOffSetLen(const void* rsp) {
|
||||
const SMqDataRspCommon* pRsp = rsp;
|
||||
static int32_t getOffSetLen(const SMqDataRsp* pRsp) {
|
||||
SEncoder coder = {0};
|
||||
tEncoderInit(&coder, NULL, 0);
|
||||
if (tEncodeSTqOffsetVal(&coder, &pRsp->reqOffset) < 0) return -1;
|
||||
|
@ -2106,9 +2107,8 @@ static int32_t getOffSetLen(const void* rsp) {
|
|||
return pos;
|
||||
}
|
||||
|
||||
typedef int32_t __encode_func__(SEncoder* pEncoder, const void* pRsp);
|
||||
|
||||
static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, void* rspObj, tmq_raw_data* raw) {
|
||||
typedef int32_t __encode_func__(SEncoder* pEncoder, const SMqDataRsp* pRsp);
|
||||
static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, SMqDataRsp* rspObj, tmq_raw_data* raw) {
|
||||
int32_t len = 0;
|
||||
int32_t code = 0;
|
||||
SEncoder encoder = {0};
|
||||
|
@ -2157,15 +2157,14 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) {
|
|||
if (!raw || !res) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
SMqRspObj* rspObj = ((SMqRspObj*)res);
|
||||
if (TD_RES_TMQ_META(res)) {
|
||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||
raw->raw = pMetaRspObj->metaRsp.metaRsp;
|
||||
raw->raw_len = pMetaRspObj->metaRsp.metaRspLen;
|
||||
raw->raw_type = pMetaRspObj->metaRsp.resMsgType;
|
||||
raw->raw = rspObj->metaRsp.metaRsp;
|
||||
raw->raw_len = rspObj->metaRsp.metaRspLen;
|
||||
raw->raw_type = rspObj->metaRsp.resMsgType;
|
||||
uDebug("tmq get raw type meta:%p", raw);
|
||||
} else if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj* rspObj = ((SMqRspObj*)res);
|
||||
int32_t code = encodeMqDataRsp(tEncodeMqDataRsp, &rspObj->rsp, raw);
|
||||
int32_t code = encodeMqDataRsp(tEncodeMqDataRsp, &rspObj->dataRsp, raw);
|
||||
if (code != 0) {
|
||||
uError("tmq get raw type error:%d", terrno);
|
||||
return code;
|
||||
|
@ -2173,9 +2172,7 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) {
|
|||
raw->raw_type = RES_TYPE__TMQ;
|
||||
uDebug("tmq get raw type data:%p", raw);
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
SMqTaosxRspObj* rspObj = ((SMqTaosxRspObj*)res);
|
||||
|
||||
int32_t code = encodeMqDataRsp(tEncodeSTaosxRsp, &rspObj->rsp, raw);
|
||||
int32_t code = encodeMqDataRsp(tEncodeSTaosxRsp, &rspObj->dataRsp, raw);
|
||||
if (code != 0) {
|
||||
uError("tmq get raw type error:%d", terrno);
|
||||
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;
|
||||
uDebug("tmq get raw type metadata:%p", raw);
|
||||
} else if (TD_RES_TMQ_BATCH_META(res)) {
|
||||
SMqBatchMetaRspObj* pBtMetaRspObj = (SMqBatchMetaRspObj*)res;
|
||||
raw->raw = pBtMetaRspObj->rsp.pMetaBuff;
|
||||
raw->raw_len = pBtMetaRspObj->rsp.metaBuffLen;
|
||||
raw->raw_type = RES_TYPE__TMQ_BATCH_META;
|
||||
raw->raw = rspObj->batchMetaRsp.pMetaBuff;
|
||||
raw->raw_len = rspObj->batchMetaRsp.metaBuffLen;
|
||||
raw->raw_type = rspObj->resType;
|
||||
uDebug("tmq get raw batch meta:%p", raw);
|
||||
} else {
|
||||
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);
|
||||
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);
|
||||
if (left > 2 && msg2) {
|
||||
|
@ -393,7 +393,7 @@ int32_t smlProcessChildTable(SSmlHandle *info, SSmlLineInfo *elements) {
|
|||
tinfo->tags = taosArrayDup(info->preLineTagKV, NULL);
|
||||
if (tinfo->tags == NULL) {
|
||||
smlDestroyTableInfo(&tinfo);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
for (size_t i = 0; i < taosArrayGetSize(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) {
|
||||
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) {
|
||||
(void)strcat(childTableName, tsSmlAutoChildTableNameDelimiter);
|
||||
(void)strncat(childTableName, tsSmlAutoChildTableNameDelimiter, TSDB_TABLE_NAME_LEN - 1 - strlen(childTableName));
|
||||
}
|
||||
}
|
||||
if (tsSmlDot2Underline) {
|
||||
|
@ -539,8 +539,7 @@ static int32_t smlParseTableName(SArray *tags, char *childTableName, char *tbnam
|
|||
// handle child table name
|
||||
if (childTableNameLen == tag->keyLen && strncmp(tag->key, tbnameKey, tag->keyLen) == 0) {
|
||||
(void)memset(childTableName, 0, TSDB_TABLE_NAME_LEN);
|
||||
(void)strncpy(childTableName, tag->value,
|
||||
(tag->length < TSDB_TABLE_NAME_LEN ? tag->length : TSDB_TABLE_NAME_LEN));
|
||||
tstrncpy(childTableName, tag->value, TMIN(TSDB_TABLE_NAME_LEN, tag->length + 1));
|
||||
if (tsSmlDot2Underline) {
|
||||
smlStrReplace(childTableName, strlen(childTableName));
|
||||
}
|
||||
|
@ -562,7 +561,7 @@ int32_t smlSetCTableName(SSmlTableInfo *oneTable, char *tbnameKey) {
|
|||
if (strlen(oneTable->childTableName) == 0) {
|
||||
SArray *dst = taosArrayDup(oneTable->tags, NULL);
|
||||
if (dst == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if (oneTable->sTableNameLen >= TSDB_TABLE_NAME_LEN) {
|
||||
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++) {
|
||||
SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, i);
|
||||
if (kv == NULL) {
|
||||
code = TSDB_CODE_SML_INVALID_DATA;
|
||||
code = terrno;
|
||||
goto END;
|
||||
}
|
||||
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) {
|
||||
SField *pField = taosArrayGet(pColumns, i);
|
||||
if (pField == NULL) {
|
||||
code = TSDB_CODE_SML_INVALID_DATA;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
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)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.tbUid = autoCreateTbl ? 0 : pTableMeta->uid;
|
||||
|
@ -983,7 +983,7 @@ int stmtSetDbName(TAOS_STMT* stmt, const char* dbName) {
|
|||
taosMemoryFreeClear(pStmt->exec.pRequest->pDb);
|
||||
pStmt->exec.pRequest->pDb = taosStrdup(dbName);
|
||||
if (pStmt->exec.pRequest->pDb == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1018,13 +1018,13 @@ int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
|
|||
STMT_ERR_RET(stmtGetFromCache(pStmt));
|
||||
|
||||
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;
|
||||
|
||||
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||
}
|
||||
} 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->exec.pRequest->requestId++;
|
||||
pStmt->bInfo.needParse = false;
|
||||
|
@ -1172,7 +1172,7 @@ int32_t stmtAppendTablePostHandle(STscStmt* pStmt, SStmtQNode* param) {
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -1313,7 +1313,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
|||
// param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
|
||||
|
||||
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();
|
||||
|
|
|
@ -187,7 +187,7 @@ static int32_t stmtUpdateBindInfo(TAOS_STMT2* stmt, STableMeta* pTableMeta, void
|
|||
}
|
||||
|
||||
(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.tbUid = autoCreateTbl ? 0 : pTableMeta->uid;
|
||||
|
@ -850,7 +850,7 @@ static int stmtSetDbName2(TAOS_STMT2* stmt, const char* dbName) {
|
|||
taosMemoryFreeClear(pStmt->exec.pRequest->pDb);
|
||||
pStmt->exec.pRequest->pDb = taosStrdup(dbName);
|
||||
if (pStmt->exec.pRequest->pDb == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -961,13 +961,13 @@ int stmtSetTbName2(TAOS_STMT2* stmt, const char* tbName) {
|
|||
STMT_ERR_RET(stmtGetFromCache(pStmt));
|
||||
|
||||
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;
|
||||
|
||||
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||
}
|
||||
} 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->exec.pRequest->requestId++;
|
||||
pStmt->bInfo.needParse = false;
|
||||
|
@ -1113,7 +1113,7 @@ static int32_t stmtAppendTablePostHandle(STscStmt2* pStmt, SStmtQNode* param) {
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -1367,7 +1367,7 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
|||
// param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
|
||||
|
||||
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();
|
||||
|
@ -1419,9 +1419,9 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
|||
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
STMT_ERR_RET(stmtAppendTablePostHandle(pStmt, param));
|
||||
}
|
||||
|
||||
} else {
|
||||
STMT_ERR_RET(stmtAddBatch2(pStmt));
|
||||
}
|
||||
|
||||
pStmt->stat.bindDataUs4 += taosGetTimestampUs() - startUs4;
|
||||
|
||||
|
@ -1625,6 +1625,10 @@ int stmtExec2(TAOS_STMT2* stmt, int* affected_rows) {
|
|||
return pStmt->errCode;
|
||||
}
|
||||
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
STMT_ERR_RET(stmtAddBatch2(pStmt));
|
||||
}
|
||||
|
||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
|
||||
|
||||
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);
|
||||
if (error) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -753,7 +753,7 @@ upload:
|
|||
if (!manager.etags[i]) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(EIO), &lino, _exit);
|
||||
}
|
||||
n = snprintf(buf, sizeof(buf),
|
||||
n = tsnprintf(buf, sizeof(buf),
|
||||
"<Part><PartNumber>%d</PartNumber>"
|
||||
"<ETag>%s</ETag></Part>",
|
||||
i + 1, manager.etags[i]);
|
||||
|
@ -919,7 +919,7 @@ upload:
|
|||
char buf[256];
|
||||
int n;
|
||||
for (int i = 0; i < cp.part_num; ++i) {
|
||||
n = snprintf(buf, sizeof(buf),
|
||||
n = tsnprintf(buf, sizeof(buf),
|
||||
"<Part><PartNumber>%d</PartNumber>"
|
||||
"<ETag>%s</ETag></Part>",
|
||||
// i + 1, manager.etags[i]);
|
||||
|
|
|
@ -94,7 +94,7 @@ static int32_t generateConfigFile(char* confDir) {
|
|||
#endif
|
||||
);
|
||||
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);
|
||||
(void)taosCloseFile(&pFile);
|
||||
code = terrno;
|
||||
|
|
|
@ -398,6 +398,7 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = {
|
|||
{.name = "finished", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema tsmaSchema[] = {
|
||||
{.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},
|
||||
|
|
|
@ -2446,9 +2446,11 @@ _error:
|
|||
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;
|
||||
int32_t ms = 0;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||
tt = (time_t)(val / 1000000000);
|
||||
ms = val % 1000000000;
|
||||
|
@ -2460,14 +2462,6 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
|||
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) {
|
||||
tt--;
|
||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||
|
@ -2479,28 +2473,44 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
|||
}
|
||||
}
|
||||
struct tm ptm = {0};
|
||||
if (taosLocalTime(&tt, &ptm, buf) == NULL) {
|
||||
return buf;
|
||||
if (taosLocalTime(&tt, &ptm, buf, cap) == NULL) {
|
||||
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) {
|
||||
sprintf(buf + pos, ".%09d", ms);
|
||||
nwritten = snprintf(buf + pos, cap - pos, ".%09d", ms);
|
||||
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||
sprintf(buf + pos, ".%06d", ms);
|
||||
nwritten = snprintf(buf + pos, cap - pos, ".%06d", ms);
|
||||
} 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
|
||||
int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf, const char* taskIdStr) {
|
||||
int32_t lino = 0;
|
||||
int32_t size = 2048 * 1024;
|
||||
int32_t code = 0;
|
||||
char* dumpBuf = NULL;
|
||||
char pBuf[128] = {0};
|
||||
char pBuf[TD_TIME_STR_LEN] = {0};
|
||||
int32_t rows = pDataBlock->info.rows;
|
||||
int32_t len = 0;
|
||||
|
||||
|
@ -2510,7 +2520,7 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
}
|
||||
|
||||
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
|
||||
"|version:%" PRIu64 "|cal start:%" PRIu64 "|cal end:%" PRIu64 "|tbl:%s\n",
|
||||
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++) {
|
||||
len += snprintf(dumpBuf + len, size - len, "%s|", flag);
|
||||
len += tsnprintf(dumpBuf + len, size - len, "%s|", flag);
|
||||
if (len >= size - 1) {
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -2530,11 +2540,12 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||
if (pColInfoData == NULL) {
|
||||
code = terrno;
|
||||
lino = __LINE__;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
|
@ -2543,52 +2554,55 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
switch (pColInfoData->info.type) {
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
memset(pBuf, 0, sizeof(pBuf));
|
||||
(void)formatTimestamp(pBuf, *(uint64_t*)var, pColInfoData->info.precision);
|
||||
len += snprintf(dumpBuf + len, size - len, " %25s |", pBuf);
|
||||
code = formatTimestamp(pBuf, sizeof(pBuf), *(uint64_t*)var, pColInfoData->info.precision);
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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));
|
||||
dataSize = TMIN(dataSize, 50);
|
||||
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;
|
||||
} break;
|
||||
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);
|
||||
if (code < 0) {
|
||||
uError("func %s failed to convert to ucs charset since %s", __func__, tstrerror(code));
|
||||
lino = __LINE__;
|
||||
goto _exit;
|
||||
} else { // reset the length value
|
||||
code = TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
||||
if (len >= size - 1) goto _exit;
|
||||
} 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;
|
||||
}
|
||||
len += snprintf(dumpBuf + len, size - len, "%s |end\n", flag);
|
||||
len += tsnprintf(dumpBuf + len, size - len, "%s |end\n", flag);
|
||||
|
||||
_exit:
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
*pDataBuf = dumpBuf;
|
||||
dumpBuf = NULL;
|
||||
} 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) {
|
||||
taosMemoryFree(dumpBuf);
|
||||
}
|
||||
|
@ -2860,27 +2874,98 @@ _end:
|
|||
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`.
|
||||
// If the name length exceeds TSDB_TABLE_NAME_LEN, first convert <stbName>_<groupId> to an MD5 value and then
|
||||
// concatenate. If the length is still too long, convert <ctbName> to an MD5 value as well.
|
||||
int32_t buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId, size_t cap) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
char tmp[TSDB_TABLE_NAME_LEN] = {0};
|
||||
if (stbName == NULL){
|
||||
snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%"PRIu64, groupId);
|
||||
}else{
|
||||
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;
|
||||
for(; i >= 0; i--){
|
||||
if (stbName[i] == '.'){
|
||||
for (; i >= 0; i--) {
|
||||
if (stbName[i] == '.') {
|
||||
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;
|
||||
suffix = taosMemoryMalloc(suffixCap);
|
||||
TSDB_CHECK_NULL(suffix, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
suffixLen = snprintf(suffix, suffixCap, "%s_%" PRIu64, stbName + i + 1, groupId);
|
||||
if (suffixLen >= suffixCap) {
|
||||
code = TSDB_CODE_INTERNAL_ERROR;
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctbName[TSDB_TABLE_NAME_LEN - strlen(tmp) - 1] = 0; // put stbname + groupId to the end
|
||||
(void)strcat(ctbName, tmp);
|
||||
for(int i = 0; i < strlen(ctbName); i++){
|
||||
if(ctbName[i] == '.'){
|
||||
ctbName[i] = '_';
|
||||
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.
|
||||
|
|
|
@ -362,7 +362,7 @@ static int32_t taosSplitS3Cfg(SConfig *pCfg, const char *name, char gVarible[TSD
|
|||
|
||||
char *strDup = NULL;
|
||||
if ((strDup = taosStrdup(pItem->str))== NULL){
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
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, "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, "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, "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));
|
||||
|
@ -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(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, "AVX512Enable", tsAVX512Enable, 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");
|
||||
tsSIMDEnable = (bool)pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "AVX512Enable");
|
||||
tsAVX512Enable = (bool)pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tagFilterCache");
|
||||
tsTagFilterCache = (bool)pItem->bval;
|
||||
|
||||
|
@ -1958,7 +1957,7 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, const char *name) {
|
|||
{"smaDebugFlag", &smaDebugFlag}, {"idxDebugFlag", &idxDebugFlag}, {"tdbDebugFlag", &tdbDebugFlag},
|
||||
{"tmrDebugFlag", &tmrDebugFlag}, {"uDebugFlag", &uDebugFlag}, {"smaDebugFlag", &smaDebugFlag},
|
||||
{"rpcDebugFlag", &rpcDebugFlag}, {"qDebugFlag", &qDebugFlag}, {"metaDebugFlag", &metaDebugFlag},
|
||||
{"stDebugFlag", &stDebugFlag}, {"sndDebugFlag", &sndDebugFlag},
|
||||
{"stDebugFlag", &stDebugFlag}, {"sndDebugFlag", &sndDebugFlag}, {"tqClientDebug", &tqClientDebug},
|
||||
};
|
||||
|
||||
static OptionNameAndVar options[] = {{"audit", &tsEnableAudit},
|
||||
|
|
|
@ -284,7 +284,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
|||
|
||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
||||
if (pColInfo == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
code = terrno;
|
||||
TAOS_CHECK_GOTO(code, NULL, _exit);
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
|||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
||||
if (pColInfo == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
code = terrno;
|
||||
TAOS_CHECK_GOTO(code, NULL, _exit);
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
|||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
||||
if (pColInfo == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
code = terrno;
|
||||
TAOS_CHECK_GOTO(code, 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)) {
|
||||
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pRsp->ipWhiteVer));
|
||||
}
|
||||
|
||||
tEndDecode(&decoder);
|
||||
_exit:
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -8163,6 +8164,7 @@ int32_t tSerializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) {
|
|||
TAOS_CHECK_EXIT(tEncodeI8(&encoder, privilege->noPrivilege));
|
||||
}
|
||||
|
||||
if (tEncodeI32(&encoder, pRsp->debugFlag) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
_exit:
|
||||
|
@ -8196,6 +8198,10 @@ int32_t tDeserializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) {
|
|||
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &data->noPrivilege));
|
||||
}
|
||||
}
|
||||
|
||||
if (!tDecodeIsEnd(&decoder)) {
|
||||
if (tDecodeI32(&decoder, &pRsp->debugFlag) < 0) return -1;
|
||||
}
|
||||
tEndDecode(&decoder);
|
||||
|
||||
_exit:
|
||||
|
@ -10681,7 +10687,7 @@ int32_t tDecodeMqMetaRsp(SDecoder *pDecoder, SMqMetaRsp *pRsp) {
|
|||
|
||||
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 lino;
|
||||
|
||||
|
@ -10711,19 +10717,20 @@ _exit:
|
|||
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(tEncodeI64(pEncoder, ((SMqDataRsp *)pRsp)->sleepTime));
|
||||
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pRsp->sleepTime));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tDecodeMqDataRspCommon(SDecoder *pDecoder, SMqDataRspCommon *pRsp) {
|
||||
int32_t tDecodeMqDataRspCommon(SDecoder *pDecoder, SMqDataRsp *pRsp) {
|
||||
int32_t code = 0;
|
||||
int32_t lino;
|
||||
|
||||
TAOS_CHECK_EXIT(tDecodeSTqOffsetVal(pDecoder, &pRsp->reqOffset));
|
||||
TAOS_CHECK_EXIT(tDecodeSTqOffsetVal(pDecoder, &pRsp->rspOffset));
|
||||
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &pRsp->blockNum));
|
||||
|
||||
if (pRsp->blockNum != 0) {
|
||||
if ((pRsp->blockData = taosArrayInit(pRsp->blockNum, sizeof(void *))) == NULL) {
|
||||
TAOS_CHECK_EXIT(terrno);
|
||||
|
@ -10787,17 +10794,16 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tDecodeMqDataRsp(SDecoder *pDecoder, void *pRsp) {
|
||||
int32_t tDecodeMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) {
|
||||
TAOS_CHECK_RETURN(tDecodeMqDataRspCommon(pDecoder, pRsp));
|
||||
if (!tDecodeIsEnd(pDecoder)) {
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &((SMqDataRsp *)pRsp)->sleepTime));
|
||||
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pRsp->sleepTime));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tDeleteMqDataRspCommon(void *rsp) {
|
||||
SMqDataRspCommon *pRsp = rsp;
|
||||
static void tDeleteMqDataRspCommon(SMqDataRsp *pRsp) {
|
||||
taosArrayDestroy(pRsp->blockDataLen);
|
||||
pRsp->blockDataLen = NULL;
|
||||
taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree);
|
||||
|
@ -10810,15 +10816,13 @@ static void tDeleteMqDataRspCommon(void *rsp) {
|
|||
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 lino;
|
||||
|
||||
TAOS_CHECK_EXIT(tEncodeMqDataRspCommon(pEncoder, rsp));
|
||||
|
||||
const STaosxRsp *pRsp = (const STaosxRsp *)rsp;
|
||||
TAOS_CHECK_EXIT(tEncodeMqDataRspCommon(pEncoder, pRsp));
|
||||
TAOS_CHECK_EXIT(tEncodeI32(pEncoder, pRsp->createTableNum));
|
||||
if (pRsp->createTableNum) {
|
||||
for (int32_t i = 0; i < pRsp->createTableNum; i++) {
|
||||
|
@ -10831,13 +10835,11 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, void *rsp) {
|
||||
int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) {
|
||||
int32_t code = 0;
|
||||
int32_t lino;
|
||||
|
||||
TAOS_CHECK_EXIT(tDecodeMqDataRspCommon(pDecoder, rsp));
|
||||
|
||||
STaosxRsp *pRsp = (STaosxRsp *)rsp;
|
||||
TAOS_CHECK_EXIT(tDecodeMqDataRspCommon(pDecoder, pRsp));
|
||||
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &pRsp->createTableNum));
|
||||
if (pRsp->createTableNum) {
|
||||
if ((pRsp->createTableLen = taosArrayInit(pRsp->createTableNum, sizeof(int32_t))) == NULL) {
|
||||
|
@ -10864,10 +10866,9 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
void tDeleteSTaosxRsp(void *rsp) {
|
||||
tDeleteMqDataRspCommon(rsp);
|
||||
void tDeleteSTaosxRsp(SMqDataRsp *pRsp) {
|
||||
tDeleteMqDataRspCommon(pRsp);
|
||||
|
||||
STaosxRsp *pRsp = (STaosxRsp *)rsp;
|
||||
taosArrayDestroy(pRsp->createTableLen);
|
||||
pRsp->createTableLen = NULL;
|
||||
taosArrayDestroyP(pRsp->createTableReq, (FDelete)taosMemoryFree);
|
||||
|
|
|
@ -33,7 +33,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
|
|||
}
|
||||
struct tm tm;
|
||||
time_t t = (time_t)start;
|
||||
taosLocalTime(&t, &tm);
|
||||
taosLocalTime(&t, &tm, NULL, 0);
|
||||
tm.tm_sec = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_hour = 0;
|
||||
|
@ -103,7 +103,7 @@ int32_t tNameExtractFullName(const SName* name, char* dst) {
|
|||
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);
|
||||
if (tnameLen > 0) {
|
||||
|
|
|
@ -693,7 +693,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
|||
|
||||
struct tm tm;
|
||||
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;
|
||||
tm.tm_year = 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;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if (unit == 'y') {
|
||||
|
@ -782,7 +782,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
|
|||
start /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
|
||||
struct tm tm;
|
||||
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_min = 0;
|
||||
tm.tm_hour = 0;
|
||||
|
@ -911,13 +911,13 @@ int64_t taosTimeGetIntervalEnd(int64_t intervalStart, const SInterval* pInterval
|
|||
// 2020-07-03 17:48:42
|
||||
// and the parameter can also be a variable.
|
||||
const char* fmtts(int64_t ts) {
|
||||
static char buf[96] = {0};
|
||||
static char buf[TD_TIME_STR_LEN] = {0};
|
||||
size_t pos = 0;
|
||||
struct tm tm;
|
||||
|
||||
if (ts > -62135625943 && ts < 32503651200) {
|
||||
time_t t = (time_t)ts;
|
||||
if (taosLocalTime(&t, &tm, buf) == NULL) {
|
||||
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
|
||||
return buf;
|
||||
}
|
||||
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) {
|
||||
time_t t = (time_t)(ts / 1000);
|
||||
if (taosLocalTime(&t, &tm, buf) == NULL) {
|
||||
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
|
||||
return buf;
|
||||
}
|
||||
if (pos > 0) {
|
||||
|
@ -939,7 +939,7 @@ const char* fmtts(int64_t ts) {
|
|||
|
||||
{
|
||||
time_t t = (time_t)(ts / 1000000);
|
||||
if (taosLocalTime(&t, &tm, buf) == NULL) {
|
||||
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
|
||||
return buf;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
if (NULL == taosLocalTime(", &ptm, buf)) {
|
||||
if (NULL == taosLocalTime(", &ptm, buf, bufLen)) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
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);
|
||||
|
||||
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) {
|
||||
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];
|
||||
if (NULL == taosLocalTime(&t, &tm->tm, NULL)) {
|
||||
if (NULL == taosLocalTime(&t, &tm->tm, NULL, 0)) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -480,7 +480,7 @@ TEST(testCase, StreamAllNormTest) {
|
|||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(NULL, ctbName, groupId);
|
||||
buildCtbNameAddGroupId(NULL, ctbName, groupId, sizeof(ctbName));
|
||||
|
||||
ASSERT_STREQ("_12345", ctbName);
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ TEST(testCase, StreamWithStbName) {
|
|||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName));
|
||||
|
||||
ASSERT_STREQ("_stb_12345", ctbName);
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ TEST(testCase, StreamWithoutDotInStbName) {
|
|||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName));
|
||||
|
||||
ASSERT_STREQ("_table_12345", ctbName);
|
||||
}
|
||||
|
@ -510,11 +510,59 @@ TEST(testCase, StreamWithoutDotInStbName2) {
|
|||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(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
|
||||
TEST(testCase, NoneTest) {
|
||||
const static int nCols = 14;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "dmMgmt.h"
|
||||
#include "mnode.h"
|
||||
#include "osFile.h"
|
||||
#include "tconfig.h"
|
||||
#include "tglobal.h"
|
||||
#include "version.h"
|
||||
|
@ -181,6 +182,7 @@ static void dmSetSignalHandle() {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
extern bool generateNewMeta;
|
||||
|
||||
extern bool generateNewMeta;
|
||||
|
||||
|
@ -284,9 +286,9 @@ static void dmPrintArgs(int32_t argc, char const *argv[]) {
|
|||
taosGetCwd(path, sizeof(path));
|
||||
|
||||
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) {
|
||||
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);
|
||||
|
@ -419,6 +421,9 @@ int mainWindows(int argc, char **argv) {
|
|||
return code;
|
||||
}
|
||||
int ret = dmUpdateEncryptKey(global.encryptKey, toLogFile);
|
||||
if (taosCloseFile(&pFile) != 0) {
|
||||
encryptError("failed to close file:%p", pFile);
|
||||
}
|
||||
taosCloseLog();
|
||||
taosCleanupArgs();
|
||||
return ret;
|
||||
|
|
|
@ -39,6 +39,7 @@ static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
|
|||
(void)taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
||||
}
|
||||
}
|
||||
|
||||
static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) {
|
||||
int32_t code = 0;
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||
const STraceId *trace = &pRsp->info.traceId;
|
||||
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;
|
||||
SStatusReq req = {0};
|
||||
|
||||
dDebug("send status req to mnode, statusSeq:%d, begin to mgnt lock", pMgmt->statusSeq);
|
||||
(void)taosThreadRwlockRdlock(&pMgmt->pData->lock);
|
||||
req.sver = tsVersion;
|
||||
req.dnodeVer = pMgmt->pData->dnodeVer;
|
||||
|
@ -159,14 +162,17 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
|||
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
||||
(void)taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
||||
|
||||
dDebug("send status req to mnode, statusSeq:%d, begin to get vnode loads", pMgmt->statusSeq);
|
||||
SMonVloadInfo vinfo = {0};
|
||||
(*pMgmt->getVnodeLoadsFp)(&vinfo);
|
||||
req.pVloads = vinfo.pVloads;
|
||||
|
||||
dDebug("send status req to mnode, statusSeq:%d, begin to get mnode loads", pMgmt->statusSeq);
|
||||
SMonMloadInfo minfo = {0};
|
||||
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
||||
req.mload = minfo.load;
|
||||
|
||||
dDebug("send status req to mnode, statusSeq:%d, begin to get qnode loads", pMgmt->statusSeq);
|
||||
(*pMgmt->getQnodeLoadsFp)(&req.qload);
|
||||
|
||||
pMgmt->statusSeq++;
|
||||
|
@ -204,6 +210,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
|||
int8_t epUpdated = 0;
|
||||
(void)dmGetMnodeEpSet(pMgmt->pData, &epSet);
|
||||
|
||||
dDebug("send status req to mnode, statusSeq:%d, begin to send rpc msg", pMgmt->statusSeq);
|
||||
code =
|
||||
rpcSendRecvWithTimeout(pMgmt->msgCb.statusRpc, &epSet, &rpcMsg, &rpcRsp, &epUpdated, tsStatusInterval * 5 * 1000);
|
||||
if (code != 0) {
|
||||
|
|
|
@ -77,7 +77,7 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
|||
}
|
||||
|
||||
if ((code = udfStartUdfd(pMgmt->pData->dnodeId)) != 0) {
|
||||
dError("failed to start udfd");
|
||||
dError("failed to start udfd since %s", tstrerror(code));
|
||||
}
|
||||
|
||||
pOutput->pMgmt = pMgmt;
|
||||
|
|
|
@ -77,6 +77,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
int32_t vnodeNum;
|
||||
int32_t opened;
|
||||
int32_t dropped;
|
||||
int32_t failed;
|
||||
bool updateVnodesList;
|
||||
int32_t threadIndex;
|
||||
|
|
|
@ -311,6 +311,8 @@ static void *vmOpenVnodeInThread(void *param) {
|
|||
snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, pCfg->vgId);
|
||||
vnodeDestroy(pCfg->vgId, path, pMgmt->pTfs, 0);
|
||||
pThread->updateVnodesList = true;
|
||||
pThread->dropped++;
|
||||
(void)atomic_add_fetch_32(&pMgmt->state.dropVnodes, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -352,8 +354,8 @@ static void *vmOpenVnodeInThread(void *param) {
|
|||
(void)atomic_add_fetch_32(&pMgmt->state.openVnodes, 1);
|
||||
}
|
||||
|
||||
dInfo("thread:%d, numOfVnodes:%d, opened:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened,
|
||||
pThread->failed);
|
||||
dInfo("thread:%d, numOfVnodes:%d, opened:%d dropped:%d failed:%d", pThread->threadIndex, pThread->vnodeNum,
|
||||
pThread->opened, pThread->dropped, pThread->failed);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -427,7 +429,7 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
|
|||
taosMemoryFree(threads);
|
||||
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);
|
||||
terrno = TSDB_CODE_VND_INIT_FAILED;
|
||||
return -1;
|
||||
|
@ -774,6 +776,7 @@ static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) {
|
|||
}
|
||||
|
||||
pMgmt->state.openVnodes = 0;
|
||||
pMgmt->state.dropVnodes = 0;
|
||||
dInfo("restore %d vnodes with %d threads", numOfVnodes, threadNum);
|
||||
|
||||
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);
|
||||
pWrapper->path = taosStrdup(path);
|
||||
if (pWrapper->path == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ static bool dmIsForbiddenIp(int8_t forbidden, char *user, uint32_t clientIp) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||
SDnodeTrans *pTrans = &pDnode->trans;
|
||||
int32_t code = -1;
|
||||
|
@ -150,10 +151,9 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
dmSetMnodeEpSet(&pDnode->data, pEpSet);
|
||||
}
|
||||
break;
|
||||
case TDMT_MND_RETRIEVE_IP_WHITE_RSP: {
|
||||
case TDMT_MND_RETRIEVE_IP_WHITE_RSP:
|
||||
dmUpdateRpcIpWhite(&pDnode->data, pTrans->serverRpc, pRpc);
|
||||
return;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -461,12 +461,12 @@ void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
|||
|
||||
void dmEpSetToStr(char *buf, int32_t len, SEpSet *epSet) {
|
||||
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++) {
|
||||
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 ? ", " : ""));
|
||||
}
|
||||
n += snprintf(buf + n, len - n, "%s", "}");
|
||||
n += tsnprintf(buf + n, len - n, "%s", "}");
|
||||
}
|
||||
|
||||
static FORCE_INLINE void dmSwapEps(SEp *epLhs, SEp *epRhs) {
|
||||
|
|
|
@ -14,6 +14,7 @@ IF (TD_ENTERPRISE)
|
|||
ELSEIF(${BUILD_WITH_COS})
|
||||
add_definitions(-DUSE_COS)
|
||||
ENDIF()
|
||||
|
||||
ENDIF ()
|
||||
|
||||
add_library(mnode STATIC ${MNODE_SRC})
|
||||
|
|
|
@ -445,7 +445,7 @@ static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) {
|
|||
|
||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, dnodeId);
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
|
@ -453,7 +453,10 @@ static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) {
|
|||
int64_t mndTerm = mndGetTerm(pMnode);
|
||||
|
||||
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);
|
||||
|
|
|
@ -241,7 +241,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
|
|||
clusterObj.createdTime = taosGetTimestampMs();
|
||||
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) {
|
||||
(void)strcpy(clusterObj.name, "tdengine3.0");
|
||||
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;
|
||||
|
||||
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);
|
||||
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);
|
||||
|
|
|
@ -167,7 +167,7 @@ static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbRs
|
|||
}
|
||||
STopicPrivilege *data = taosArrayReserve(rsp->topicPrivileges, 1);
|
||||
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 ||
|
||||
grantCheckExpire(TSDB_GRANT_SUBSCRIPTION) < 0) {
|
||||
data->noPrivilege = 1;
|
||||
|
@ -244,6 +244,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
storeOffsetRows(pMnode, &req, pConsumer);
|
||||
rsp.debugFlag = tqClientDebug;
|
||||
code = buildMqHbRsp(pMsg, &rsp);
|
||||
|
||||
END:
|
||||
|
@ -277,7 +278,7 @@ static int32_t addEpSetInfo(SMnode *pMnode, SMqConsumerObj *pConsumer, int32_t e
|
|||
taosRLockLatch(&pSub->lock);
|
||||
|
||||
SMqSubTopicEp topicEp = {0};
|
||||
(void)strcpy(topicEp.topic, topic);
|
||||
tstrncpy(topicEp.topic, topic, TSDB_TOPIC_FNAME_LEN);
|
||||
|
||||
// 2.1 fetch topic schema
|
||||
SMqTopicObj *pTopic = NULL;
|
||||
|
@ -587,8 +588,8 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
|||
|
||||
SCMSubscribeReq subscribe = {0};
|
||||
MND_TMQ_RETURN_CHECK(tDeserializeSCMSubscribeReq(msgStr, &subscribe, pMsg->contLen));
|
||||
bool ubSubscribe = (taosArrayGetSize(subscribe.topicNames) == 0);
|
||||
if(ubSubscribe){
|
||||
bool unSubscribe = (taosArrayGetSize(subscribe.topicNames) == 0);
|
||||
if(unSubscribe){
|
||||
SMqConsumerObj *pConsumerTmp = NULL;
|
||||
MND_TMQ_RETURN_CHECK(mndAcquireConsumer(pMnode, subscribe.consumerId, &pConsumerTmp));
|
||||
if (taosArrayGetSize(pConsumerTmp->assignedTopics) == 0){
|
||||
|
@ -599,7 +600,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
|||
}
|
||||
MND_TMQ_RETURN_CHECK(checkAndSortTopic(pMnode, subscribe.topicNames));
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY,
|
||||
(ubSubscribe ? TRN_CONFLICT_NOTHING :TRN_CONFLICT_DB_INSIDE),
|
||||
(unSubscribe ? TRN_CONFLICT_NOTHING :TRN_CONFLICT_DB_INSIDE),
|
||||
pMsg, "subscribe");
|
||||
MND_TMQ_NULL_CHECK(pTrans);
|
||||
|
||||
|
@ -909,7 +910,7 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
|||
|
||||
// consumer id
|
||||
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)));
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
|
||||
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);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -2377,9 +2377,9 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
|||
char keep1Str[128] = {0};
|
||||
char keep2Str[128] = {0};
|
||||
|
||||
int32_t lenKeep0 = formatDurationOrKeep(keep0Str, pDb->cfg.daysToKeep0);
|
||||
int32_t lenKeep1 = formatDurationOrKeep(keep1Str, pDb->cfg.daysToKeep1);
|
||||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, pDb->cfg.daysToKeep2);
|
||||
int32_t lenKeep0 = formatDurationOrKeep(keep0Str, sizeof(keep0Str), pDb->cfg.daysToKeep0);
|
||||
int32_t lenKeep1 = formatDurationOrKeep(keep1Str, sizeof(keep1Str), pDb->cfg.daysToKeep1);
|
||||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, sizeof(keep2Str), 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);
|
||||
|
|
|
@ -693,7 +693,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
int64_t clusterid = mndGetClusterId(pMnode);
|
||||
if (statusReq.clusterId != 0 && statusReq.clusterId != clusterid) {
|
||||
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);
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -740,7 +740,6 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
bool enableWhiteListChanged = statusReq.clusterCfg.enableWhiteList != (tsEnableWhiteList ? 1 : 0);
|
||||
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged ||
|
||||
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged || enableWhiteListChanged;
|
||||
|
||||
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,
|
||||
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;
|
||||
pMnode->path = taosStrdup(path);
|
||||
if (pMnode->path == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
|
@ -515,6 +515,7 @@ static int32_t mndInitWal(SMnode *pMnode) {
|
|||
.fsyncPeriod = 0,
|
||||
.rollPeriod = -1,
|
||||
.segSize = -1,
|
||||
.committed = -1,
|
||||
.retentionPeriod = 0,
|
||||
.retentionSize = 0,
|
||||
.level = TAOS_WAL_FSYNC,
|
||||
|
@ -574,6 +575,8 @@ static int32_t mndOpenSdb(SMnode *pMnode) {
|
|||
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);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
|
|||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
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);
|
||||
if (startTime == 0) startTime = taosGetTimestampMs();
|
||||
|
||||
|
|
|
@ -1231,7 +1231,7 @@ static int32_t mndGetSma(SMnode *pMnode, SUserIndexReq *indexReq, SUserIndexRsp
|
|||
SNode *node = NULL;
|
||||
FOREACH(node, pList) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -2221,10 +2221,10 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
int32_t len = 0;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
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));
|
||||
} 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);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -2235,7 +2235,7 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
// create sql
|
||||
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));
|
||||
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
}
|
||||
|
@ -2350,7 +2350,7 @@ int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STa
|
|||
nodesDestroyNode(pNode);
|
||||
}
|
||||
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) {
|
||||
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);
|
||||
if (code != TSDB_CODE_SUCCESS || !hasEpset) {
|
||||
mError("failed to extract epset during create update epset, code:%s", tstrerror(code));
|
||||
taosMemoryFree(pBuf);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -187,12 +187,12 @@ static void mndSplitSubscribeKey(const char *key, char *topic, char *cgroup, boo
|
|||
(void)memcpy(cgroup, key, i);
|
||||
cgroup[i] = 0;
|
||||
if (fullName) {
|
||||
(void)strcpy(topic, &key[i + 1]);
|
||||
tstrncpy(topic, &key[i + 1], TSDB_TOPIC_FNAME_LEN);
|
||||
} else {
|
||||
while (key[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
|
||||
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)));
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -1398,7 +1398,8 @@ static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t cons
|
|||
// vg id
|
||||
char buf[TSDB_OFFSET_LEN * 2 + VARSTR_HEADER_SIZE] = {0};
|
||||
(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)));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
MND_TMQ_NULL_CHECK(pColInfo);
|
||||
|
|
|
@ -637,7 +637,7 @@ void mndSyncStop(SMnode *pMnode) {
|
|||
|
||||
(void)taosThreadMutexLock(&pMgmt->lock);
|
||||
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->transSec = 0;
|
||||
pMgmt->errCode = TSDB_CODE_APP_IS_STOPPING;
|
||||
|
|
|
@ -589,6 +589,7 @@ STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId) {
|
|||
|
||||
void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
if (pTrans != NULL) mInfo("vgId:1, trans:%d, release transaction", pTrans->id);
|
||||
sdbRelease(pSdb, pTrans);
|
||||
}
|
||||
|
||||
|
@ -1131,10 +1132,11 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
if (!sendRsp) {
|
||||
return;
|
||||
} else {
|
||||
mInfo("trans:%d, send rsp, stage:%s failedTimes:%d code:0x%x", pTrans->id, mndTransStr(pTrans->stage),
|
||||
pTrans->failedTimes, code);
|
||||
mInfo("vgId:1, trans:%d, start to send rsp, stage:%s failedTimes:%d code:0x%x", pTrans->id,
|
||||
mndTransStr(pTrans->stage), pTrans->failedTimes, code);
|
||||
}
|
||||
|
||||
mInfo("vgId:1, trans:%d, start to lock rpc array", pTrans->id);
|
||||
taosWLockLatch(&pTrans->lockRpcArray);
|
||||
int32_t size = taosArrayGetSize(pTrans->pRpcArray);
|
||||
if (size <= 0) {
|
||||
|
@ -1155,8 +1157,8 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
if (i != 0 && code == 0) {
|
||||
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),
|
||||
pInfo->ahandle);
|
||||
mInfo("vgId:1, trans:%d, client:%d start to send rsp, code:0x%x stage:%s app:%p", pTrans->id, i, code,
|
||||
mndTransStr(pTrans->stage), pInfo->ahandle);
|
||||
|
||||
SRpcMsg rspMsg = {.code = code, .info = *pInfo};
|
||||
|
||||
|
@ -1199,6 +1201,9 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -1247,8 +1252,9 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
|
|||
pAction->errCode = pRsp->code;
|
||||
pTrans->lastErrorNo = pRsp->code;
|
||||
|
||||
mInfo("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId,
|
||||
mndTransStr(pAction->stage), action, pRsp->code, pAction->acceptableCode, pAction->retryCode);
|
||||
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, tstrerror(pRsp->code), pAction->acceptableCode,
|
||||
tstrerror(pAction->acceptableCode), pAction->retryCode, tstrerror(pAction->retryCode));
|
||||
} else {
|
||||
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);
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1464,8 +1470,8 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
|
|||
static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans, bool 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) {
|
||||
mError("trans:%d, failed to execute redoActions since:%s, code:0x%x, topHalf:%d", pTrans->id, terrstr(), terrno,
|
||||
topHalf);
|
||||
mError("trans:%d, failed to execute redoActions since:%s, code:0x%x, topHalf(TransContext):%d", pTrans->id,
|
||||
terrstr(), terrno, topHalf);
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
@ -1481,7 +1488,8 @@ static int32_t mndTransExecuteUndoActions(SMnode *pMnode, STrans *pTrans, bool t
|
|||
static int32_t mndTransExecuteCommitActions(SMnode *pMnode, STrans *pTrans, bool 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) {
|
||||
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;
|
||||
}
|
||||
|
@ -1495,11 +1503,15 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
|||
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) {
|
||||
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);
|
||||
if (code == 0) {
|
||||
if (pAction->msgSent) {
|
||||
|
@ -1531,8 +1543,8 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
|||
if (mndCannotExecuteTransAction(pMnode, topHalf)) {
|
||||
pTrans->lastErrorNo = code;
|
||||
pTrans->code = code;
|
||||
mInfo("trans:%d, %s:%d, topHalf:%d, not execute next action, code:%s", pTrans->id, mndTransStr(pAction->stage),
|
||||
action, topHalf, tstrerror(code));
|
||||
mInfo("trans:%d, %s:%d, topHalf(TransContext):%d, not execute next action, code:%s", pTrans->id,
|
||||
mndTransStr(pAction->stage), action, topHalf, tstrerror(code));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1556,7 +1568,8 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
|||
break;
|
||||
} else if (code == pAction->retryCode || code == TSDB_CODE_SYN_PROPOSE_NOT_READY ||
|
||||
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;
|
||||
taosMsleep(300);
|
||||
action--;
|
||||
|
@ -1565,8 +1578,8 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
|||
terrno = code;
|
||||
pTrans->lastErrorNo = code;
|
||||
pTrans->code = code;
|
||||
mInfo("trans:%d, %s:%d receive code:0x%x and wait another schedule, failedTimes:%d", pTrans->id,
|
||||
mndTransStr(pAction->stage), pAction->id, code, pTrans->failedTimes);
|
||||
mInfo("trans:%d, %s:%d receive code:0x%x(%s) and wait another schedule, failedTimes:%d", pTrans->id,
|
||||
mndTransStr(pAction->stage), pAction->id, code, tstrerror(code), pTrans->failedTimes);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1637,12 +1650,13 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans, bool
|
|||
pTrans->code = code;
|
||||
bool continueExec = true;
|
||||
if (code != 0 && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
||||
taosMsleep(100);
|
||||
continueExec = true;
|
||||
} else {
|
||||
continueExec = false;
|
||||
}
|
||||
mInfo("trans:%d, cannot execute redo action stage, topHalf:%d, continueExec:%d, code:%s", pTrans->id, topHalf,
|
||||
continueExec, tstrerror(code));
|
||||
mInfo("trans:%d, cannot execute redo action stage, topHalf(TransContext):%d, continueExec:%d, code:%s", pTrans->id,
|
||||
topHalf, continueExec, tstrerror(code));
|
||||
|
||||
return continueExec;
|
||||
}
|
||||
|
@ -1674,7 +1688,9 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans, bool
|
|||
}
|
||||
|
||||
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;
|
||||
} else {
|
||||
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) {
|
||||
pTrans->stage = TRN_STAGE_UNDO_ACTION;
|
||||
mInfo("trans:%d, stage from rollback to undoAction", pTrans->id);
|
||||
continueExec = true;
|
||||
} else {
|
||||
pTrans->failedTimes++;
|
||||
|
@ -1822,7 +1837,7 @@ void mndTransExecuteImp(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
|||
bool continueExec = true;
|
||||
|
||||
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);
|
||||
pTrans->lastExecTime = taosGetTimestampMs();
|
||||
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 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));
|
||||
SEpSet epset = pTrans->lastEpset;
|
||||
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);
|
||||
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);
|
||||
|
|
|
@ -594,7 +594,7 @@ int32_t mndFetchAllIpWhite(SMnode *pMnode, SHashObj **ppIpWhiteTab) {
|
|||
if (name == NULL) {
|
||||
sdbRelease(pSdb, pUser);
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _OVER);
|
||||
}
|
||||
if (taosArrayPush(pUserNames, &name) == NULL) {
|
||||
taosMemoryFree(name);
|
||||
|
@ -617,7 +617,7 @@ int32_t mndFetchAllIpWhite(SMnode *pMnode, SHashObj **ppIpWhiteTab) {
|
|||
if (found == false) {
|
||||
char *name = taosStrdup(TSDB_DEFAULT_USER);
|
||||
if (name == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _OVER);
|
||||
}
|
||||
if (taosArrayPush(pUserNames, &name) == NULL) {
|
||||
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) {
|
||||
#if 1
|
||||
mTrace("mnode apply info changed from index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " to index:%" PRId64
|
||||
mInfo("vgId:1, mnode apply info changed from index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " to index:%" PRId64
|
||||
" term:%" PRId64 " config:%" PRId64,
|
||||
pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig, index, term, config);
|
||||
#endif
|
||||
|
||||
pSdb->applyIndex = index;
|
||||
pSdb->applyTerm = term;
|
||||
pSdb->applyConfig = config;
|
||||
|
|
|
@ -173,6 +173,8 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
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)) {
|
||||
return terrno;
|
||||
}
|
||||
|
@ -554,6 +556,9 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) {
|
|||
}
|
||||
if (code != 0) {
|
||||
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);
|
||||
return code;
|
||||
|
|
|
@ -42,6 +42,7 @@ void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow, bool callFunc) {
|
|||
// remove attached object such as trans
|
||||
SdbDeleteFp deleteFp = pSdb->deleteFps[pRow->type];
|
||||
if (deleteFp != NULL) {
|
||||
mInfo("vgId:1, deleteFp:%p, type:%s", deleteFp, sdbTableName(pRow->type));
|
||||
(void)(*deleteFp)(pSdb, pRow->pObj, callFunc);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,14 +112,14 @@ int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle);
|
|||
void tqDestroyTqHandle(void* data);
|
||||
|
||||
// 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 tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, uint64_t reqId);
|
||||
|
||||
// tqExec
|
||||
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded);
|
||||
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOfCols, int8_t precision);
|
||||
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const void* pRsp,
|
||||
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, SMqDataRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded);
|
||||
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 SMqDataRsp* pRsp,
|
||||
int32_t type, int32_t vgId);
|
||||
void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId);
|
||||
|
||||
|
@ -148,9 +148,9 @@ int32_t tqOffsetRestoreFromFile(STQ* pTq, char* name);
|
|||
// tq util
|
||||
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 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 tqInitDataRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset);
|
||||
int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset);
|
||||
void tqUpdateNodeStage(STQ* pTq, bool isLeader);
|
||||
int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
||||
SSubmitTbData* pTableData, int64_t earlyTs, const char* id);
|
||||
|
|
|
@ -342,6 +342,7 @@ typedef struct {
|
|||
rocksdb_writeoptions_t *writeoptions;
|
||||
rocksdb_readoptions_t *readoptions;
|
||||
rocksdb_writebatch_t *writebatch;
|
||||
TdThreadMutex writeBatchMutex;
|
||||
STSchema *pTSchema;
|
||||
} SRocksCache;
|
||||
|
||||
|
|
|
@ -166,14 +166,14 @@ void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) {
|
|||
}
|
||||
|
||||
SMqDataRsp dataRsp = {0};
|
||||
code = tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
||||
code = tqInitDataRsp(&dataRsp, req.reqOffset);
|
||||
if (code != 0) {
|
||||
tqError("tqInitDataRsp failed, code:%d", code);
|
||||
return;
|
||||
}
|
||||
dataRsp.common.blockNum = 0;
|
||||
dataRsp.blockNum = 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,
|
||||
req.reqId);
|
||||
|
||||
|
@ -184,18 +184,18 @@ void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) {
|
|||
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) {
|
||||
int64_t sver = 0, ever = 0;
|
||||
walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
||||
|
||||
char buf1[TSDB_OFFSET_LEN] = {0};
|
||||
char buf2[TSDB_OFFSET_LEN] = {0};
|
||||
(void)tFormatOffset(buf1, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->reqOffset);
|
||||
(void)tFormatOffset(buf2, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->rspOffset);
|
||||
(void)tFormatOffset(buf1, TSDB_OFFSET_LEN, &(pRsp->reqOffset));
|
||||
(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,
|
||||
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);
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
taosRUnLockLatch(&pTq->lock);
|
||||
|
||||
SMqDataRsp dataRsp = {0};
|
||||
code = tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
||||
code = tqInitDataRsp(&dataRsp, req.reqOffset);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
|
@ -529,10 +529,10 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
goto END;
|
||||
}
|
||||
|
||||
dataRsp.common.rspOffset.type = TMQ_OFFSET__LOG;
|
||||
dataRsp.rspOffset.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) {
|
||||
STqOffset* pOffset = NULL;
|
||||
code = tqMetaGetOffset(pTq, req.subKey, &pOffset);
|
||||
|
@ -543,17 +543,17 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
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,
|
||||
req.subKey, dataRsp.common.rspOffset.version);
|
||||
req.subKey, dataRsp.rspOffset.version);
|
||||
} else {
|
||||
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) {
|
||||
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,
|
||||
dataRsp.common.rspOffset.version);
|
||||
dataRsp.rspOffset.version);
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
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){
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosMemoryFree(fname);
|
||||
|
|
|
@ -562,9 +562,18 @@ int32_t tqMaskBlock(SSchemaWrapper* pDst, SSDataBlock* pBlock, const SSchemaWrap
|
|||
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) {
|
||||
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);
|
||||
|
@ -678,10 +687,10 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
|||
vgId, suid, uid, sversion, pReader->pSchemaWrapper->version);
|
||||
return TSDB_CODE_TQ_INTERNAL_ERROR;
|
||||
}
|
||||
if (blockDataGetNumOfCols(pBlock) == 0) {
|
||||
code = buildResSDataBlock(pReader->pResBlock, pReader->pSchemaWrapper, pReader->pColIdList);
|
||||
code = buildResSDataBlock(pReader, pReader->pSchemaWrapper, pReader->pColIdList);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
}
|
||||
pBlock = pReader->pResBlock;
|
||||
*pRes = pBlock;
|
||||
}
|
||||
|
||||
int32_t numOfRows = 0;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#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);
|
||||
void* buf = taosMemoryCalloc(1, dataStrLen);
|
||||
if (buf == NULL) {
|
||||
|
@ -34,11 +34,11 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOf
|
|||
return terrno;
|
||||
}
|
||||
actualLen += sizeof(SRetrieveTableRspForTmq);
|
||||
if (taosArrayPush(((SMqDataRspCommon*)pRsp)->blockDataLen, &actualLen) == NULL){
|
||||
if (taosArrayPush(pRsp->blockDataLen, &actualLen) == NULL){
|
||||
taosMemoryFree(buf);
|
||||
return terrno;
|
||||
}
|
||||
if (taosArrayPush(((SMqDataRspCommon*)pRsp)->blockData, &buf) == NULL) {
|
||||
if (taosArrayPush(pRsp->blockData, &buf) == NULL) {
|
||||
taosMemoryFree(buf);
|
||||
return terrno;
|
||||
}
|
||||
|
@ -46,18 +46,18 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOf
|
|||
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);
|
||||
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 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};
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
pRsp->common.blockNum++;
|
||||
pRsp->blockNum++;
|
||||
if (pDataBlock == NULL) {
|
||||
blockDataDestroy(pHandle->block);
|
||||
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);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
pRsp->common.blockNum++;
|
||||
pRsp->blockNum++;
|
||||
totalRows += pDataBlock->info.rows;
|
||||
if (totalRows >= tmqRowSize || (taosGetTimestampMs() - st > 1000)) {
|
||||
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",
|
||||
pHandle->consumerId, vgId, pRsp->common.blockNum, totalRows);
|
||||
code = qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
||||
pHandle->consumerId, vgId, pRsp->blockNum, totalRows);
|
||||
code = qStreamExtractOffset(task, &pRsp->rspOffset);
|
||||
END:
|
||||
if (code != 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
qTaskInfo_t task = pExec->task;
|
||||
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);
|
||||
|
||||
if (pDataBlock != NULL && pDataBlock->info.rows > 0) {
|
||||
if (pRsp->common.withTbName) {
|
||||
if (pRsp->withTbName) {
|
||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
int64_t uid = pExec->pTqReader->lastBlkUid;
|
||||
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);
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pRsp->common.withSchema) {
|
||||
if (pRsp->withSchema) {
|
||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
if (tqAddBlockSchemaToRsp(pExec, pRsp) != 0){
|
||||
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 {
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tqAddBlockDataToRsp(pDataBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pDataBlock->pDataBlock),
|
||||
if (tqAddBlockDataToRsp(pDataBlock, pRsp, taosArrayGetSize(pDataBlock->pDataBlock),
|
||||
pTq->pVnode->config.tsdbCfg.precision) != 0) {
|
||||
tqError("vgId:%d, failed to add block to rsp msg", pTq->pVnode->config.vgId);
|
||||
continue;
|
||||
}
|
||||
pRsp->common.blockNum++;
|
||||
pRsp->blockNum++;
|
||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
continue;
|
||||
} 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),
|
||||
pHandle->snapshotVer + 1);
|
||||
code = qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
||||
code = qStreamExtractOffset(task, &pRsp->rspOffset);
|
||||
break;
|
||||
}
|
||||
|
||||
if (pRsp->common.blockNum > 0) {
|
||||
if (pRsp->blockNum > 0) {
|
||||
tqDebug("tmqsnap task exec exited, get data");
|
||||
code = qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
||||
code = qStreamExtractOffset(task, &pRsp->rspOffset);
|
||||
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;
|
||||
STqExecHandle* pExec = &pHandle->execHandle;
|
||||
STqReader* pReader = pExec->pTqReader;
|
||||
|
@ -323,7 +324,7 @@ static void tqProcessSubData(STQ* pTq, STqHandle* pHandle, STaosxRsp* pRsp, int3
|
|||
if ((pSubmitTbDataRet->flags & sourceExcluded) != 0) {
|
||||
goto END;
|
||||
}
|
||||
if (pRsp->common.withTbName) {
|
||||
if (pRsp->withTbName) {
|
||||
int64_t uid = pExec->pTqReader->lastBlkUid;
|
||||
code = tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks));
|
||||
if (code != 0) {
|
||||
|
@ -381,7 +382,7 @@ static void tqProcessSubData(STQ* pTq, STqHandle* pHandle, STaosxRsp* pRsp, int3
|
|||
if (pBlock == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (tqAddBlockDataToRsp(pBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlock->pDataBlock),
|
||||
if (tqAddBlockDataToRsp(pBlock, pRsp, taosArrayGetSize(pBlock->pDataBlock),
|
||||
pTq->pVnode->config.tsdbCfg.precision) != 0){
|
||||
tqError("vgId:%d, failed to add block to rsp msg", pTq->pVnode->config.vgId);
|
||||
continue;
|
||||
|
@ -389,11 +390,11 @@ static void tqProcessSubData(STQ* pTq, STqHandle* pHandle, STaosxRsp* pRsp, int3
|
|||
*totalRows += pBlock->info.rows;
|
||||
blockDataFreeRes(pBlock);
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
pRsp->common.blockNum++;
|
||||
pRsp->blockNum++;
|
||||
}
|
||||
|
||||
taosArrayDestroy(pBlocks);
|
||||
|
@ -405,7 +406,7 @@ END:
|
|||
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) {
|
||||
STqExecHandle* pExec = &pHandle->execHandle;
|
||||
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) {
|
||||
name = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN);
|
||||
size_t cap = TMAX(TSDB_TABLE_NAME_LEN, varDataLen(varTbName) + 1);
|
||||
name = taosMemoryMalloc(cap);
|
||||
if (name == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
memcpy(name, varDataVal(varTbName), varDataLen(varTbName));
|
||||
name[varDataLen(varTbName)] = '\0';
|
||||
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) {
|
||||
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);
|
||||
|
||||
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);
|
||||
if (p == NULL) {
|
||||
return terrno;
|
||||
|
@ -235,8 +240,11 @@ int32_t setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock*
|
|||
return terrno;
|
||||
}
|
||||
|
||||
strcpy(pCreateTableReq->name, pDataBlock->info.parTbName);
|
||||
buildCtbNameAddGroupId(stbFullName, pCreateTableReq->name, gid);
|
||||
tstrncpy(pCreateTableReq->name, pDataBlock->info.parTbName, TSDB_TABLE_NAME_LEN);
|
||||
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);
|
||||
} else {
|
||||
pCreateTableReq->name = taosStrdup(pDataBlock->info.parTbName);
|
||||
|
@ -852,9 +860,12 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
|||
!alreadyAddGroupId(dstTableName, groupId) && groupId != 0) {
|
||||
tqDebug("s-task:%s append groupId:%" PRId64 " for generated dstTable:%s", id, groupId, dstTableName);
|
||||
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) {
|
||||
buildCtbNameAddGroupId(stbFullName, dstTableName, groupId);
|
||||
code = buildCtbNameAddGroupId(stbFullName, dstTableName, groupId, sizeof(pDataBlock->info.parTbName));
|
||||
}
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
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->blockDataLen = taosArrayInit(0, sizeof(int32_t));
|
||||
|
||||
|
@ -40,7 +40,7 @@ void tqUpdateNodeStage(STQ* pTq, bool 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->rspOffset, &pOffset);
|
||||
|
||||
|
@ -116,12 +116,12 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
|||
SMqDataRsp dataRsp = {0};
|
||||
tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer + 1);
|
||||
|
||||
code = tqInitDataRsp(&dataRsp.common, *pOffsetVal);
|
||||
code = tqInitDataRsp(&dataRsp, *pOffsetVal);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
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);
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
|
||||
|
@ -145,24 +145,27 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
terrno = 0;
|
||||
|
||||
SMqDataRsp dataRsp = {0};
|
||||
|
||||
int code = tqInitDataRsp(&dataRsp.common, *pOffset);
|
||||
int code = tqInitDataRsp(&dataRsp, *pOffset);
|
||||
if (code != 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
code = qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId);
|
||||
if (code != 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
code = tqScanData(pTq, pHandle, &dataRsp, pOffset, pRequest);
|
||||
if (code != 0 && terrno != TSDB_CODE_WAL_LOG_NOT_EXIST) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
// 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
|
||||
taosWLockLatch(&pTq->lock);
|
||||
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);
|
||||
taosWUnLockLatch(&pTq->lock);
|
||||
goto end;
|
||||
|
@ -170,16 +173,16 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
taosWUnLockLatch(&pTq->lock);
|
||||
}
|
||||
|
||||
tOffsetCopy(&dataRsp.common.reqOffset,
|
||||
pOffset); // reqOffset represents the current date offset, may be changed if wal not exists
|
||||
// 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);
|
||||
|
||||
end : {
|
||||
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
|
||||
" 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);
|
||||
return code;
|
||||
}
|
||||
|
@ -208,11 +211,11 @@ static void tDeleteCommon(void* parm) {}
|
|||
static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
|
||||
SRpcMsg* pMsg, STqOffsetVal* offset) {
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
STaosxRsp taosxRsp = {0};
|
||||
SMqDataRsp taosxRsp = {0};
|
||||
SMqBatchMetaRsp btMetaRsp = {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) {
|
||||
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
|
||||
",ts:%" PRId64,
|
||||
pRequest->consumerId, pHandle->subKey, vgId, taosxRsp.common.blockNum, taosxRsp.common.rspOffset.type,
|
||||
taosxRsp.common.rspOffset.uid, taosxRsp.common.rspOffset.ts);
|
||||
if (taosxRsp.common.blockNum > 0) {
|
||||
pRequest->consumerId, pHandle->subKey, vgId, taosxRsp.blockNum, taosxRsp.rspOffset.type,
|
||||
taosxRsp.rspOffset.uid, taosxRsp.rspOffset.ts);
|
||||
if (taosxRsp.blockNum > 0) {
|
||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, &taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||
goto END;
|
||||
} else {
|
||||
tOffsetCopy(offset, &taosxRsp.common.rspOffset);
|
||||
tOffsetCopy(offset, &taosxRsp.rspOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +267,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
}
|
||||
goto END;
|
||||
}
|
||||
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer);
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
||||
code = tqSendDataRsp(
|
||||
pHandle, pMsg, pRequest, &taosxRsp,
|
||||
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
|
||||
if (pHead->msgType != TDMT_VND_SUBMIT) {
|
||||
if (totalRows > 0) {
|
||||
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer);
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
||||
code = tqSendDataRsp(
|
||||
pHandle, pMsg, pRequest, &taosxRsp,
|
||||
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)) {
|
||||
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer + 1);
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer + 1);
|
||||
code = tqSendDataRsp(
|
||||
pHandle, pMsg, pRequest, &taosxRsp,
|
||||
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;
|
||||
}
|
||||
|
||||
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 len = 0;
|
||||
int32_t code = 0;
|
||||
|
|
|
@ -22,6 +22,12 @@
|
|||
|
||||
#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) {
|
||||
int32_t code = 0, lino = 0;
|
||||
int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
|
||||
|
@ -215,6 +221,8 @@ static int32_t tsdbOpenRocksCache(STsdb *pTsdb) {
|
|||
|
||||
rocksdb_writebatch_t *writebatch = rocksdb_writebatch_create();
|
||||
|
||||
TAOS_CHECK_GOTO(taosThreadMutexInit(&pTsdb->rCache.writeBatchMutex, NULL), &lino, _err6) ;
|
||||
|
||||
pTsdb->rCache.writebatch = writebatch;
|
||||
pTsdb->rCache.my_comparator = cmp;
|
||||
pTsdb->rCache.options = options;
|
||||
|
@ -226,6 +234,8 @@ static int32_t tsdbOpenRocksCache(STsdb *pTsdb) {
|
|||
|
||||
TAOS_RETURN(code);
|
||||
|
||||
_err6:
|
||||
rocksdb_writebatch_destroy(writebatch);
|
||||
_err5:
|
||||
rocksdb_close(pTsdb->rCache.db);
|
||||
_err4:
|
||||
|
@ -244,6 +254,7 @@ _err:
|
|||
|
||||
static void tsdbCloseRocksCache(STsdb *pTsdb) {
|
||||
rocksdb_close(pTsdb->rCache.db);
|
||||
(void)taosThreadMutexDestroy(&pTsdb->rCache.writeBatchMutex);
|
||||
rocksdb_flushoptions_destroy(pTsdb->rCache.flushoptions);
|
||||
rocksdb_writebatch_destroy(pTsdb->rCache.writebatch);
|
||||
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 (tsdbCacheFlushDirty(key, klen, pLastCol, ud) != 0) {
|
||||
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;
|
||||
code = tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||
if (code == TSDB_CODE_INVALID_PARA) {
|
||||
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||
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) {
|
||||
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;
|
||||
code = tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||
if (code == TSDB_CODE_INVALID_PARA) {
|
||||
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||
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) {
|
||||
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++) {
|
||||
LRUHandle *h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[i], klen);
|
||||
if (h) {
|
||||
if (taosLRUCacheRelease(pTsdb->lruCache, h, true)) {
|
||||
tsdbInfo("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__);
|
||||
}
|
||||
tsdbLRUCacheRelease(pTsdb->lruCache, h, true);
|
||||
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);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST);
|
||||
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));
|
||||
(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);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
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);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
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));
|
||||
(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);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
STSchema *pTSchema = NULL;
|
||||
|
@ -924,11 +925,8 @@ int32_t tsdbCacheDropSubTables(STsdb *pTsdb, SArray *uids, tb_uid_t suid) {
|
|||
|
||||
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
||||
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));
|
||||
(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);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 1);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
// rocksMayWrite(pTsdb, true, false, false);
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
|
@ -974,18 +968,14 @@ int32_t tsdbCacheDropNTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, bool h
|
|||
|
||||
code = tsdbCacheCommitNoLock(pTsdb);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
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);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 1);
|
||||
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));
|
||||
(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);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
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);
|
||||
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));
|
||||
(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;
|
||||
(void)taosThreadMutexLock(&pTsdb->rCache.writeBatchMutex);
|
||||
rocksdb_writebatch_put(wb, (char *)pLastKey, ROCKS_KEY_LEN, rocks_value, vlen);
|
||||
(void)taosThreadMutexUnlock(&pTsdb->rCache.writeBatchMutex);
|
||||
|
||||
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)) {
|
||||
tsdbInfo("vgId:%d, %s release lru cache failed at line %d", TD_VID(pTsdb->pVnode), __func__, __LINE__);
|
||||
}
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
TAOS_CHECK_EXIT(code);
|
||||
} else {
|
||||
if (!remainCols) {
|
||||
|
@ -1237,9 +1219,13 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
|
|||
|
||||
SLastCol *pLastCol = NULL;
|
||||
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||
if (code == TSDB_CODE_INVALID_PARA) {
|
||||
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||
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) {
|
||||
|
@ -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);
|
||||
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));
|
||||
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
|
||||
code = tsdbCacheUpdate(pTsdb, suid, uid, ctxArray);
|
||||
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));
|
||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -1491,9 +1475,8 @@ int32_t tsdbCacheColFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SBlo
|
|||
// 3. do update
|
||||
code = tsdbCacheUpdate(pTsdb, suid, uid, ctxArray);
|
||||
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));
|
||||
TAOS_CHECK_GOTO(code, &lino, _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);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||
if (code == TSDB_CODE_INVALID_PARA) {
|
||||
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||
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;
|
||||
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;
|
||||
if (h && pLastCol->cacheStatus != TSDB_LAST_CACHE_NO_CACHE) {
|
||||
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) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
} else {
|
||||
|
@ -1800,38 +1791,39 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
|||
|
||||
if (taosArrayPush(pLastArray, &noneCol) == NULL) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (!remainCols) {
|
||||
if ((remainCols = taosArrayInit(numKeys, sizeof(SIdxKey))) == NULL) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
if (!ignoreFromRocks) {
|
||||
if ((ignoreFromRocks = taosArrayInit(numKeys, sizeof(bool))) == NULL) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
if (taosArrayPush(remainCols, &(SIdxKey){i, key}) == NULL) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
bool ignoreRocks = pLastCol ? (pLastCol->cacheStatus == TSDB_LAST_CACHE_NO_CACHE) : false;
|
||||
if (taosArrayPush(ignoreFromRocks, &ignoreRocks) == NULL) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (h) {
|
||||
code = taosLRUCacheRelease(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;
|
||||
}
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1846,6 +1838,7 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
|||
SLastCol lastCol = *pLastCol;
|
||||
code = tsdbCacheReallocSLastCol(&lastCol, NULL);
|
||||
if (code) {
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
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
|
||||
++i;
|
||||
}
|
||||
|
||||
if (h) {
|
||||
code = taosLRUCacheRelease(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;
|
||||
}
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1900,10 +1888,8 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
|
|||
|
||||
code = tsdbCacheCommit(pTsdb);
|
||||
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));
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
(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};
|
||||
code = tsdbCachePutToLRU(pTsdb, &lastKey, &noneCol, 1);
|
||||
}
|
||||
if (taosLRUCacheRelease(pTsdb->lruCache, h, false) != TSDB_CODE_SUCCESS) {
|
||||
tsdbError("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__);
|
||||
}
|
||||
tsdbLRUCacheRelease(pTsdb->lruCache, h, false);
|
||||
TAOS_CHECK_EXIT(code);
|
||||
} else {
|
||||
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) {
|
||||
SLastCol *pLastCol = NULL;
|
||||
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||
if (code == TSDB_CODE_INVALID_PARA) {
|
||||
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||
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);
|
||||
SLastKey *pLastKey = &idxKey->key;
|
||||
|
@ -3483,11 +3471,7 @@ _err:
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
void tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h) {
|
||||
if (taosLRUCacheRelease(pCache, h, false)) {
|
||||
tsdbError("%s release lru cache failed at line %d.", __func__, __LINE__);
|
||||
}
|
||||
}
|
||||
void tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h) { tsdbLRUCacheRelease(pCache, h, false); }
|
||||
|
||||
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) {
|
||||
taosLRUCacheSetCapacity(pVnode->pTsdb->lruCache, capacity);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "functionMgt.h"
|
||||
#include "functionResInfo.h"
|
||||
#include "taoserror.h"
|
||||
#include "tarray.h"
|
||||
#include "tcommon.h"
|
||||
|
|
|
@ -602,14 +602,14 @@ int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fs
|
|||
SSttLvl *lvl;
|
||||
code = tsdbSttLvlInitRef(pTsdb, lvl1, &lvl);
|
||||
if (code) {
|
||||
taosMemoryFree(lvl);
|
||||
tsdbSttLvlClear(&lvl);
|
||||
tsdbTFileSetClear(fset);
|
||||
return code;
|
||||
}
|
||||
|
||||
code = TARRAY2_APPEND(fset[0]->lvlArr, lvl);
|
||||
if (code) {
|
||||
taosMemoryFree(lvl);
|
||||
tsdbSttLvlClear(&lvl);
|
||||
tsdbTFileSetClear(fset);
|
||||
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]);
|
||||
if (pReader->status.pPrimaryTsCol == NULL) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
code = terrno;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
|
@ -855,6 +855,7 @@ static int32_t loadFileBlockBrinInfo(STsdbReader* pReader, SArray* pIndexList, S
|
|||
STableBlockScanInfo** p = taosArrayGetLast(pTableScanInfoList);
|
||||
if (p == NULL) {
|
||||
clearBrinBlockIter(&iter);
|
||||
tsdbError("invalid param, empty in tablescanInfoList, %s", pReader->idStr);
|
||||
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
|
||||
// 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.
|
||||
// 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 (!pReader->status.suspendInvoked && !pReader->status.loadFromFile) {
|
||||
tsem_wait(&pReader->resumeAfterSuspend);
|
||||
|
|
|
@ -45,6 +45,7 @@ const SVnodeCfg vnodeCfgDefault = {.vgId = -1,
|
|||
.retentionPeriod = -1,
|
||||
.rollPeriod = 0,
|
||||
.segSize = 0,
|
||||
.committed = 0,
|
||||
.retentionSize = -1,
|
||||
.level = TAOS_WAL_WRITE,
|
||||
.clearFiles = 0,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue