Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
46772d32
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
46772d32
编写于
6月 02, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into fix/mnode
上级
ecaea669
3eb1d488
变更
126
展开全部
隐藏空白更改
内联
并排
Showing
126 changed file
with
4678 addition
and
2267 deletion
+4678
-2267
docs-cn/14-reference/02-rest-api/02-rest-api.mdx
docs-cn/14-reference/02-rest-api/02-rest-api.mdx
+1
-1
examples/c/tmq.c
examples/c/tmq.c
+1
-0
include/client/taos.h
include/client/taos.h
+3
-2
include/common/taosdef.h
include/common/taosdef.h
+1
-0
include/common/tdatablock.h
include/common/tdatablock.h
+3
-48
include/common/tdataformat.h
include/common/tdataformat.h
+16
-23
include/common/tglobal.h
include/common/tglobal.h
+2
-1
include/common/tmsg.h
include/common/tmsg.h
+36
-26
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
include/common/ttypes.h
include/common/ttypes.h
+46
-41
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+1
-1
include/libs/executor/executor.h
include/libs/executor/executor.h
+0
-12
include/libs/function/function.h
include/libs/function/function.h
+1
-76
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+3
-0
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+3
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+37
-15
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-1
include/libs/parser/parser.h
include/libs/parser/parser.h
+1
-0
include/libs/planner/planner.h
include/libs/planner/planner.h
+1
-1
include/libs/qcom/query.h
include/libs/qcom/query.h
+8
-1
include/libs/scheduler/scheduler.h
include/libs/scheduler/scheduler.h
+1
-1
include/libs/wal/wal.h
include/libs/wal/wal.h
+1
-0
include/util/taoserror.h
include/util/taoserror.h
+1
-0
include/util/tdef.h
include/util/tdef.h
+1
-1
include/util/tlist.h
include/util/tlist.h
+1
-1
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+4
-1
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+3
-0
source/client/src/clientHb.c
source/client/src/clientHb.c
+1
-1
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+100
-75
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+23
-0
source/client/src/clientSml.c
source/client/src/clientSml.c
+37
-1
source/client/src/tmq.c
source/client/src/tmq.c
+13
-1
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+20
-20
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+45
-1
source/common/src/systable.c
source/common/src/systable.c
+2
-0
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+128
-13
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+284
-435
source/common/src/tglobal.c
source/common/src/tglobal.c
+6
-2
source/common/src/tmsg.c
source/common/src/tmsg.c
+86
-0
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+34
-10
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+18
-23
source/dnode/mnode/impl/inc/mndTopic.h
source/dnode/mnode/impl/inc/mndTopic.h
+2
-0
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+1
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+11
-1
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+3
-9
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+121
-69
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+2
-6
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+62
-36
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+1
-2
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+12
-8
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+2
-0
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-1
source/dnode/vnode/src/meta/metaEntry.c
source/dnode/vnode/src/meta/metaEntry.c
+2
-0
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+20
-12
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+61
-37
source/dnode/vnode/src/sma/sma.c
source/dnode/vnode/src/sma/sma.c
+8
-0
source/dnode/vnode/src/sma/smaEnv.c
source/dnode/vnode/src/sma/smaEnv.c
+1
-1
source/dnode/vnode/src/sma/smaTimeRange.c
source/dnode/vnode/src/sma/smaTimeRange.c
+6
-6
source/dnode/vnode/src/sma/smaTimeRange2.c
source/dnode/vnode/src/sma/smaTimeRange2.c
+1084
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+14
-6
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+26
-28
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+12
-0
source/dnode/vnode/src/tsdb/tsdbCommit2.c
source/dnode/vnode/src/tsdb/tsdbCommit2.c
+0
-28
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
+93
-273
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+21
-4
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+20
-7
source/dnode/vnode/test/tsdbSmaTest.cpp
source/dnode/vnode/test/tsdbSmaTest.cpp
+7
-7
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+1
-1
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+33
-24
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+12
-12
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+1
-1
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+2
-11
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+3
-2
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+2
-40
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+45
-156
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+7
-5
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+3
-3
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+324
-222
source/libs/function/inc/builtins.h
source/libs/function/inc/builtins.h
+14
-12
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+4
-0
source/libs/function/inc/taggfunction.h
source/libs/function/inc/taggfunction.h
+0
-7
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+51
-40
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+290
-44
source/libs/function/src/functionMgt.c
source/libs/function/src/functionMgt.c
+78
-0
source/libs/function/src/taggfunction.c
source/libs/function/src/taggfunction.c
+2
-1
source/libs/function/src/texpr.c
source/libs/function/src/texpr.c
+0
-14
source/libs/index/src/indexFilter.c
source/libs/index/src/indexFilter.c
+50
-29
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+12
-2
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+199
-5
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+8
-0
source/libs/parser/inc/parInt.h
source/libs/parser/inc/parInt.h
+1
-0
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+43
-3
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+59
-26
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+2
-2
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+27
-2
source/libs/parser/test/mockCatalogService.h
source/libs/parser/test/mockCatalogService.h
+1
-0
source/libs/planner/inc/planInt.h
source/libs/planner/inc/planInt.h
+1
-0
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+58
-57
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+76
-9
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+351
-89
source/libs/planner/src/planUtil.c
source/libs/planner/src/planUtil.c
+51
-0
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+12
-9
source/libs/planner/test/planIntervalTest.cpp
source/libs/planner/test/planIntervalTest.cpp
+7
-1
source/libs/planner/test/planOtherTest.cpp
source/libs/planner/test/planOtherTest.cpp
+6
-0
source/libs/qcom/src/queryUtil.c
source/libs/qcom/src/queryUtil.c
+27
-0
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+5
-5
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+7
-7
source/libs/scheduler/inc/schedulerInt.h
source/libs/scheduler/inc/schedulerInt.h
+1
-1
source/libs/scheduler/src/schJob.c
source/libs/scheduler/src/schJob.c
+8
-11
source/libs/scheduler/src/schRemote.c
source/libs/scheduler/src/schRemote.c
+7
-3
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+0
-1
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+8
-0
source/util/src/terror.c
source/util/src/terror.c
+1
-0
source/util/src/tlist.c
source/util/src/tlist.c
+1
-1
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+4
-1
tests/script/tsim/catalog/alterInCurrent.sim
tests/script/tsim/catalog/alterInCurrent.sim
+70
-0
tests/script/tsim/mnode/basic4.sim
tests/script/tsim/mnode/basic4.sim
+1
-1
tests/script/tsim/stable/column_drop.sim
tests/script/tsim/stable/column_drop.sim
+3
-2
tests/script/tsim/stream/basic0.sim
tests/script/tsim/stream/basic0.sim
+2
-1
tests/system-test/1-insert/influxdb_line_taosc_insert.py
tests/system-test/1-insert/influxdb_line_taosc_insert.py
+2
-2
tests/system-test/1-insert/opentsdb_json_taosc_insert.py
tests/system-test/1-insert/opentsdb_json_taosc_insert.py
+5
-5
tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py
...system-test/1-insert/opentsdb_telnet_line_taosc_insert.py
+3
-3
tests/system-test/2-query/mavg.py
tests/system-test/2-query/mavg.py
+12
-9
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+2
-1
tests/test/c/sdbDump.c
tests/test/c/sdbDump.c
+1
-0
tests/test/c/tmqSim.c
tests/test/c/tmqSim.c
+104
-8
未找到文件。
docs-cn/14-reference/02-rest-api/02-rest-api.mdx
浏览文件 @
46772d32
...
@@ -16,7 +16,7 @@ RESTful 接口不依赖于任何 TDengine 的库,因此客户端不需要安
...
@@ -16,7 +16,7 @@ RESTful 接口不依赖于任何 TDengine 的库,因此客户端不需要安
在已经安装 TDengine 服务器端的情况下,可以按照如下方式进行验证。
在已经安装 TDengine 服务器端的情况下,可以按照如下方式进行验证。
下面以 Ubuntu 环境中使用 curl 工具(确认已经安装)来验证 RESTful 接口的正常。
下面以 Ubuntu 环境中使用 curl 工具(确认已经安装)来验证 RESTful 接口的正常
,验证前请确认 taosAdapter 服务已开启,在 Linux 系统上此服务默认由 systemd 管理,使用命令 `systemctl start taosadapter` 启动
。
下面示例是列出所有的数据库,请把 h1.taosdata.com 和 6041(缺省值)替换为实际运行的 TDengine 服务 FQDN 和端口号:
下面示例是列出所有的数据库,请把 h1.taosdata.com 和 6041(缺省值)替换为实际运行的 TDengine 服务 FQDN 和端口号:
...
...
examples/c/tmq.c
浏览文件 @
46772d32
...
@@ -24,6 +24,7 @@ static void msg_process(TAOS_RES* msg) {
...
@@ -24,6 +24,7 @@ static void msg_process(TAOS_RES* msg) {
char
buf
[
1024
];
char
buf
[
1024
];
/*memset(buf, 0, 1024);*/
/*memset(buf, 0, 1024);*/
printf
(
"topic: %s
\n
"
,
tmq_get_topic_name
(
msg
));
printf
(
"topic: %s
\n
"
,
tmq_get_topic_name
(
msg
));
printf
(
"db: %s
\n
"
,
tmq_get_db_name
(
msg
));
printf
(
"vg: %d
\n
"
,
tmq_get_vgroup_id
(
msg
));
printf
(
"vg: %d
\n
"
,
tmq_get_vgroup_id
(
msg
));
while
(
1
)
{
while
(
1
)
{
TAOS_ROW
row
=
taos_fetch_row
(
msg
);
TAOS_ROW
row
=
taos_fetch_row
(
msg
);
...
...
include/client/taos.h
浏览文件 @
46772d32
...
@@ -144,8 +144,8 @@ DLL_EXPORT int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *nam
...
@@ -144,8 +144,8 @@ DLL_EXPORT int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *nam
DLL_EXPORT
int
taos_stmt_set_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
);
DLL_EXPORT
int
taos_stmt_set_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
);
DLL_EXPORT
int
taos_stmt_set_tags
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
tags
);
DLL_EXPORT
int
taos_stmt_set_tags
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
tags
);
DLL_EXPORT
int
taos_stmt_set_sub_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
);
DLL_EXPORT
int
taos_stmt_set_sub_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
);
DLL_EXPORT
int
taos_stmt_get_tag_fields
(
TAOS_STMT
*
stmt
,
int
*
fieldNum
,
TAOS_FIELD_E
**
fields
);
DLL_EXPORT
int
taos_stmt_get_tag_fields
(
TAOS_STMT
*
stmt
,
int
*
fieldNum
,
TAOS_FIELD_E
**
fields
);
DLL_EXPORT
int
taos_stmt_get_col_fields
(
TAOS_STMT
*
stmt
,
int
*
fieldNum
,
TAOS_FIELD_E
**
fields
);
DLL_EXPORT
int
taos_stmt_get_col_fields
(
TAOS_STMT
*
stmt
,
int
*
fieldNum
,
TAOS_FIELD_E
**
fields
);
DLL_EXPORT
int
taos_stmt_is_insert
(
TAOS_STMT
*
stmt
,
int
*
insert
);
DLL_EXPORT
int
taos_stmt_is_insert
(
TAOS_STMT
*
stmt
,
int
*
insert
);
DLL_EXPORT
int
taos_stmt_num_params
(
TAOS_STMT
*
stmt
,
int
*
nums
);
DLL_EXPORT
int
taos_stmt_num_params
(
TAOS_STMT
*
stmt
,
int
*
nums
);
...
@@ -269,6 +269,7 @@ DLL_EXPORT void tmq_conf_set_auto_commit_cb(tmq_conf_t *conf, tmq_comm
...
@@ -269,6 +269,7 @@ DLL_EXPORT void tmq_conf_set_auto_commit_cb(tmq_conf_t *conf, tmq_comm
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
DLL_EXPORT
const
char
*
tmq_get_topic_name
(
TAOS_RES
*
res
);
DLL_EXPORT
const
char
*
tmq_get_topic_name
(
TAOS_RES
*
res
);
DLL_EXPORT
const
char
*
tmq_get_db_name
(
TAOS_RES
*
res
);
DLL_EXPORT
int32_t
tmq_get_vgroup_id
(
TAOS_RES
*
res
);
DLL_EXPORT
int32_t
tmq_get_vgroup_id
(
TAOS_RES
*
res
);
DLL_EXPORT
const
char
*
tmq_get_table_name
(
TAOS_RES
*
res
);
DLL_EXPORT
const
char
*
tmq_get_table_name
(
TAOS_RES
*
res
);
...
...
include/common/taosdef.h
浏览文件 @
46772d32
...
@@ -97,6 +97,7 @@ extern char *qtypeStr[];
...
@@ -97,6 +97,7 @@ extern char *qtypeStr[];
#undef TD_DEBUG_PRINT_ROW
#undef TD_DEBUG_PRINT_ROW
#undef TD_DEBUG_PRINT_TSDB_LOAD_DCOLS
#undef TD_DEBUG_PRINT_TSDB_LOAD_DCOLS
#undef TD_DEBUG_PRINT_TAG
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/common/tdatablock.h
浏览文件 @
46772d32
...
@@ -227,6 +227,9 @@ int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n);
...
@@ -227,6 +227,9 @@ int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n);
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
,
bool
copyData
);
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
,
bool
copyData
);
void
blockCompressEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
int8_t
needCompress
);
const
char
*
blockCompressDecode
(
SSDataBlock
*
pBlock
,
int32_t
numOfCols
,
int32_t
numOfRows
,
const
char
*
pData
);
void
blockDebugShowData
(
const
SArray
*
dataBlocks
);
void
blockDebugShowData
(
const
SArray
*
dataBlocks
);
int32_t
buildSubmitReqFromDataBlock
(
SSubmitReq
**
pReq
,
const
SArray
*
pDataBlocks
,
STSchema
*
pTSchema
,
int32_t
vgId
,
int32_t
buildSubmitReqFromDataBlock
(
SSubmitReq
**
pReq
,
const
SArray
*
pDataBlocks
,
STSchema
*
pTSchema
,
int32_t
vgId
,
...
@@ -246,54 +249,6 @@ static FORCE_INLINE int32_t blockCompressColData(SColumnInfoData* pColRes, int32
...
@@ -246,54 +249,6 @@ static FORCE_INLINE int32_t blockCompressColData(SColumnInfoData* pColRes, int32
colSize
+
COMP_OVERFLOW_BYTES
,
compressed
,
NULL
,
0
);
colSize
+
COMP_OVERFLOW_BYTES
,
compressed
,
NULL
,
0
);
}
}
static
FORCE_INLINE
void
blockCompressEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
int8_t
needCompress
)
{
int32_t
*
actualLen
=
(
int32_t
*
)
data
;
data
+=
sizeof
(
int32_t
);
uint64_t
*
groupId
=
(
uint64_t
*
)
data
;
data
+=
sizeof
(
uint64_t
);
int32_t
*
colSizes
=
(
int32_t
*
)
data
;
data
+=
numOfCols
*
sizeof
(
int32_t
);
*
dataLen
=
(
numOfCols
*
sizeof
(
int32_t
)
+
sizeof
(
uint64_t
)
+
sizeof
(
int32_t
));
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
for
(
int32_t
col
=
0
;
col
<
numOfCols
;
++
col
)
{
SColumnInfoData
*
pColRes
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
col
);
// copy the null bitmap
if
(
IS_VAR_DATA_TYPE
(
pColRes
->
info
.
type
))
{
size_t
metaSize
=
numOfRows
*
sizeof
(
int32_t
);
memcpy
(
data
,
pColRes
->
varmeta
.
offset
,
metaSize
);
data
+=
metaSize
;
(
*
dataLen
)
+=
metaSize
;
}
else
{
int32_t
len
=
BitmapLen
(
numOfRows
);
memcpy
(
data
,
pColRes
->
nullbitmap
,
len
);
data
+=
len
;
(
*
dataLen
)
+=
len
;
}
if
(
needCompress
)
{
colSizes
[
col
]
=
blockCompressColData
(
pColRes
,
numOfRows
,
data
,
needCompress
);
data
+=
colSizes
[
col
];
(
*
dataLen
)
+=
colSizes
[
col
];
}
else
{
colSizes
[
col
]
=
colDataGetLength
(
pColRes
,
numOfRows
);
(
*
dataLen
)
+=
colSizes
[
col
];
memmove
(
data
,
pColRes
->
pData
,
colSizes
[
col
]);
data
+=
colSizes
[
col
];
}
colSizes
[
col
]
=
htonl
(
colSizes
[
col
]);
}
*
actualLen
=
*
dataLen
;
*
groupId
=
pBlock
->
info
.
groupId
;
}
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/common/tdataformat.h
浏览文件 @
46772d32
...
@@ -46,6 +46,7 @@ void tTSchemaDestroy(STSchema *pTSchema);
...
@@ -46,6 +46,7 @@ void tTSchemaDestroy(STSchema *pTSchema);
#define COL_VAL_NULL(CID) ((SColVal){.cid = (CID), .isNull = 1})
#define COL_VAL_NULL(CID) ((SColVal){.cid = (CID), .isNull = 1})
#define COL_VAL_VALUE(CID, V) ((SColVal){.cid = (CID), .value = (V)})
#define COL_VAL_VALUE(CID, V) ((SColVal){.cid = (CID), .value = (V)})
int32_t
tTSRowNew
(
STSRowBuilder
*
pBuilder
,
SArray
*
pArray
,
STSchema
*
pTSchema
,
STSRow2
**
ppRow
);
int32_t
tTSRowClone
(
const
STSRow2
*
pRow
,
STSRow2
**
ppRow
);
int32_t
tTSRowClone
(
const
STSRow2
*
pRow
,
STSRow2
**
ppRow
);
void
tTSRowFree
(
STSRow2
*
pRow
);
void
tTSRowFree
(
STSRow2
*
pRow
);
void
tTSRowGet
(
STSRow2
*
pRow
,
STSchema
*
pTSchema
,
int32_t
iCol
,
SColVal
*
pColVal
);
void
tTSRowGet
(
STSRow2
*
pRow
,
STSchema
*
pTSchema
,
int32_t
iCol
,
SColVal
*
pColVal
);
...
@@ -54,23 +55,24 @@ int32_t tPutTSRow(uint8_t *p, STSRow2 *pRow);
...
@@ -54,23 +55,24 @@ int32_t tPutTSRow(uint8_t *p, STSRow2 *pRow);
int32_t
tGetTSRow
(
uint8_t
*
p
,
STSRow2
*
pRow
);
int32_t
tGetTSRow
(
uint8_t
*
p
,
STSRow2
*
pRow
);
// STSRowBuilder
// STSRowBuilder
#
if 0
#
define tsRowBuilderInit() ((STSRowBuilder){0})
int32_t tTSRowBuilderInit(STSRowBuilder *pBuilder, int32_t sver, int32_t nCols, SSchema *pSchema);
#define tsRowBuilderClear(B) \
void tTSRowBuilderClear(STSRowBuilder *pBuilder);
do { \
void tTSRowBuilderReset(STSRowBuilder *pBuilder);
if ((B)->pBuf) { \
int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, uint8_t *pData, uint32_t nData);
taosMemoryFree((B)->pBuf); \
int32_t tTSRowBuilderGetRow(STSRowBuilder *pBuilder, const STSRow2 **ppRow);
} \
#endif
} while (0)
// STag
// STag
int32_t
tTagNew
(
SArray
*
pArray
,
int32_t
version
,
int8_t
isJson
,
STag
**
ppTag
);
int32_t
tTagNew
(
SArray
*
pArray
,
int32_t
version
,
int8_t
isJson
,
STag
**
ppTag
);
void
tTagFree
(
STag
*
pTag
);
void
tTagFree
(
STag
*
pTag
);
bool
tTagGet
(
const
STag
*
pTag
,
STagVal
*
pTagVal
);
bool
tTagGet
(
const
STag
*
pTag
,
STagVal
*
pTagVal
);
char
*
tTagValToData
(
const
STagVal
*
pTagVal
,
bool
isJson
);
char
*
tTagValToData
(
const
STagVal
*
pTagVal
,
bool
isJson
);
int32_t
tEncodeTag
(
SEncoder
*
pEncoder
,
const
STag
*
pTag
);
int32_t
tEncodeTag
(
SEncoder
*
pEncoder
,
const
STag
*
pTag
);
int32_t
tDecodeTag
(
SDecoder
*
pDecoder
,
STag
**
ppTag
);
int32_t
tDecodeTag
(
SDecoder
*
pDecoder
,
STag
**
ppTag
);
int32_t
tTagToValArray
(
const
STag
*
pTag
,
SArray
**
ppArray
);
int32_t
tTagToValArray
(
const
STag
*
pTag
,
SArray
**
ppArray
);
void
debugPrintSTag
(
STag
*
pTag
,
const
char
*
tag
,
int32_t
ln
);
void
debugPrintSTag
(
STag
*
pTag
,
const
char
*
tag
,
int32_t
ln
);
// TODO: remove
void
debugCheckTags
(
STag
*
pTag
);
// TODO: remove
// STRUCT =================
// STRUCT =================
struct
STColumn
{
struct
STColumn
{
...
@@ -105,17 +107,9 @@ struct STSRow2 {
...
@@ -105,17 +107,9 @@ struct STSRow2 {
};
};
struct
STSRowBuilder
{
struct
STSRowBuilder
{
STSchema
*
pTSchema
;
STSRow2
tsRow
;
int32_t
szBitMap1
;
int32_t
szBuf
;
int32_t
szBitMap2
;
uint8_t
*
pBuf
;
int32_t
szKVBuf
;
uint8_t
*
pKVBuf
;
int32_t
szTPBuf
;
uint8_t
*
pTPBuf
;
int32_t
iCol
;
int32_t
vlenKV
;
int32_t
vlenTP
;
STSRow2
row
;
};
};
struct
SValue
{
struct
SValue
{
...
@@ -153,7 +147,7 @@ struct STagVal {
...
@@ -153,7 +147,7 @@ struct STagVal {
};
};
int8_t
type
;
int8_t
type
;
union
{
union
{
int64_t
i64
;
int64_t
i64
;
struct
{
struct
{
uint32_t
nData
;
uint32_t
nData
;
uint8_t
*
pData
;
uint8_t
*
pData
;
...
@@ -161,7 +155,7 @@ struct STagVal {
...
@@ -161,7 +155,7 @@ struct STagVal {
};
};
};
};
#define TD_TAG_JSON ((int8_t)0x40)
// distinguish JSON string and JSON value with the highest bit
#define TD_TAG_JSON ((int8_t)0x40) // distinguish JSON string and JSON value with the highest bit
#define TD_TAG_LARGE ((int8_t)0x20)
#define TD_TAG_LARGE ((int8_t)0x20)
struct
STag
{
struct
STag
{
int8_t
flags
;
int8_t
flags
;
...
@@ -421,4 +415,3 @@ int32_t tdMergeDataCols(SDataCols *target, SDataCols *source, int32_t rowsToM
...
@@ -421,4 +415,3 @@ int32_t tdMergeDataCols(SDataCols *target, SDataCols *source, int32_t rowsToM
#endif
#endif
#endif
/*_TD_COMMON_DATA_FORMAT_H_*/
#endif
/*_TD_COMMON_DATA_FORMAT_H_*/
include/common/tglobal.h
浏览文件 @
46772d32
...
@@ -45,6 +45,8 @@ extern bool tsEnableSlaveQuery;
...
@@ -45,6 +45,8 @@ extern bool tsEnableSlaveQuery;
extern
bool
tsPrintAuth
;
extern
bool
tsPrintAuth
;
extern
int64_t
tsTickPerMin
[
3
];
extern
int64_t
tsTickPerMin
[
3
];
extern
int32_t
tsCountAlwaysReturnValue
;
// multi-process
// multi-process
extern
int32_t
tsMultiProcess
;
extern
int32_t
tsMultiProcess
;
extern
int32_t
tsMnodeShmSize
;
extern
int32_t
tsMnodeShmSize
;
...
@@ -102,7 +104,6 @@ extern int32_t tsMaxStreamComputDelay;
...
@@ -102,7 +104,6 @@ extern int32_t tsMaxStreamComputDelay;
extern
int32_t
tsStreamCompStartDelay
;
extern
int32_t
tsStreamCompStartDelay
;
extern
int32_t
tsRetryStreamCompDelay
;
extern
int32_t
tsRetryStreamCompDelay
;
extern
float
tsStreamComputDelayRatio
;
// the delayed computing ration of the whole time window
extern
float
tsStreamComputDelayRatio
;
// the delayed computing ration of the whole time window
extern
int32_t
tsProjectExecInterval
;
extern
int64_t
tsMaxRetentWindow
;
extern
int64_t
tsMaxRetentWindow
;
// build info
// build info
...
...
include/common/tmsg.h
浏览文件 @
46772d32
...
@@ -571,13 +571,6 @@ int32_t tSerializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pR
...
@@ -571,13 +571,6 @@ int32_t tSerializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pR
int32_t
tDeserializeSGetUserAuthRsp
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthRsp
*
pRsp
);
int32_t
tDeserializeSGetUserAuthRsp
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthRsp
*
pRsp
);
void
tFreeSGetUserAuthRsp
(
SGetUserAuthRsp
*
pRsp
);
void
tFreeSGetUserAuthRsp
(
SGetUserAuthRsp
*
pRsp
);
typedef
struct
{
int16_t
colId
;
// column id
int16_t
colIndex
;
// column index in colList if it is a normal column or index in tagColList if a tag
int16_t
flag
;
// denote if it is a tag or a normal column
char
name
[
TSDB_DB_FNAME_LEN
];
}
SColIndex
;
typedef
struct
{
typedef
struct
{
int16_t
lowerRelOptr
;
int16_t
lowerRelOptr
;
int16_t
upperRelOptr
;
int16_t
upperRelOptr
;
...
@@ -779,6 +772,7 @@ typedef struct {
...
@@ -779,6 +772,7 @@ typedef struct {
int8_t
cacheLastRow
;
int8_t
cacheLastRow
;
int32_t
numOfRetensions
;
int32_t
numOfRetensions
;
SArray
*
pRetensions
;
SArray
*
pRetensions
;
int8_t
schemaless
;
}
SDbCfgRsp
;
}
SDbCfgRsp
;
int32_t
tSerializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
const
SDbCfgRsp
*
pRsp
);
int32_t
tSerializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
const
SDbCfgRsp
*
pRsp
);
...
@@ -1127,6 +1121,14 @@ typedef struct {
...
@@ -1127,6 +1121,14 @@ typedef struct {
SSchema
*
pSchemas
;
SSchema
*
pSchemas
;
}
STableMetaRsp
;
}
STableMetaRsp
;
typedef
struct
{
STableMetaRsp
*
pMeta
;
}
SMAlterStbRsp
;
int32_t
tEncodeSMAlterStbRsp
(
SEncoder
*
pEncoder
,
const
SMAlterStbRsp
*
pRsp
);
int32_t
tDecodeSMAlterStbRsp
(
SDecoder
*
pDecoder
,
SMAlterStbRsp
*
pRsp
);
void
tFreeSMAlterStbRsp
(
SMAlterStbRsp
*
pRsp
);
int32_t
tSerializeSTableMetaRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaRsp
*
pRsp
);
int32_t
tSerializeSTableMetaRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaRsp
*
pRsp
);
int32_t
tDeserializeSTableMetaRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaRsp
*
pRsp
);
int32_t
tDeserializeSTableMetaRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaRsp
*
pRsp
);
void
tFreeSTableMetaRsp
(
STableMetaRsp
*
pRsp
);
void
tFreeSTableMetaRsp
(
STableMetaRsp
*
pRsp
);
...
@@ -1880,7 +1882,8 @@ int32_t tEncodeSVAlterTbReq(SEncoder* pEncoder, const SVAlterTbReq* pReq);
...
@@ -1880,7 +1882,8 @@ int32_t tEncodeSVAlterTbReq(SEncoder* pEncoder, const SVAlterTbReq* pReq);
int32_t
tDecodeSVAlterTbReq
(
SDecoder
*
pDecoder
,
SVAlterTbReq
*
pReq
);
int32_t
tDecodeSVAlterTbReq
(
SDecoder
*
pDecoder
,
SVAlterTbReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int32_t
code
;
int32_t
code
;
STableMetaRsp
*
pMeta
;
}
SVAlterTbRsp
;
}
SVAlterTbRsp
;
int32_t
tEncodeSVAlterTbRsp
(
SEncoder
*
pEncoder
,
const
SVAlterTbRsp
*
pRsp
);
int32_t
tEncodeSVAlterTbRsp
(
SEncoder
*
pEncoder
,
const
SVAlterTbRsp
*
pRsp
);
...
@@ -2203,10 +2206,8 @@ typedef struct {
...
@@ -2203,10 +2206,8 @@ typedef struct {
int64_t
newConsumerId
;
int64_t
newConsumerId
;
char
subKey
[
TSDB_SUBSCRIBE_KEY_LEN
];
char
subKey
[
TSDB_SUBSCRIBE_KEY_LEN
];
int8_t
subType
;
int8_t
subType
;
// int8_t withTbName;
char
*
qmsg
;
// int8_t withSchema;
int64_t
suid
;
// int8_t withTag;
char
*
qmsg
;
}
SMqRebVgReq
;
}
SMqRebVgReq
;
static
FORCE_INLINE
int32_t
tEncodeSMqRebVgReq
(
void
**
buf
,
const
SMqRebVgReq
*
pReq
)
{
static
FORCE_INLINE
int32_t
tEncodeSMqRebVgReq
(
void
**
buf
,
const
SMqRebVgReq
*
pReq
)
{
...
@@ -2217,11 +2218,10 @@ static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pR
...
@@ -2217,11 +2218,10 @@ static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pR
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
newConsumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
newConsumerId
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
subKey
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
subKey
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
subType
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
subType
);
// tlen += taosEncodeFixedI8(buf, pReq->withTbName);
// tlen += taosEncodeFixedI8(buf, pReq->withSchema);
// tlen += taosEncodeFixedI8(buf, pReq->withTag);
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
tlen
+=
taosEncodeString
(
buf
,
pReq
->
qmsg
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
qmsg
);
}
else
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
suid
);
}
}
return
tlen
;
return
tlen
;
}
}
...
@@ -2233,11 +2233,10 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq)
...
@@ -2233,11 +2233,10 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq)
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
newConsumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
newConsumerId
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
subKey
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
subKey
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
subType
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
subType
);
// buf = taosDecodeFixedI8(buf, &pReq->withTbName);
// buf = taosDecodeFixedI8(buf, &pReq->withSchema);
// buf = taosDecodeFixedI8(buf, &pReq->withTag);
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
buf
=
taosDecodeString
(
buf
,
&
pReq
->
qmsg
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
qmsg
);
}
else
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
suid
);
}
}
return
(
void
*
)
buf
;
return
(
void
*
)
buf
;
}
}
...
@@ -2348,19 +2347,19 @@ typedef struct {
...
@@ -2348,19 +2347,19 @@ typedef struct {
STSma
*
tSma
;
STSma
*
tSma
;
}
STSmaWrapper
;
}
STSmaWrapper
;
static
FORCE_INLINE
void
t
d
DestroyTSma
(
STSma
*
pSma
)
{
static
FORCE_INLINE
void
tDestroyTSma
(
STSma
*
pSma
)
{
if
(
pSma
)
{
if
(
pSma
)
{
taosMemoryFreeClear
(
pSma
->
expr
);
taosMemoryFreeClear
(
pSma
->
expr
);
taosMemoryFreeClear
(
pSma
->
tagsFilter
);
taosMemoryFreeClear
(
pSma
->
tagsFilter
);
}
}
}
}
static
FORCE_INLINE
void
t
d
DestroyTSmaWrapper
(
STSmaWrapper
*
pSW
,
bool
deepCopy
)
{
static
FORCE_INLINE
void
tDestroyTSmaWrapper
(
STSmaWrapper
*
pSW
,
bool
deepCopy
)
{
if
(
pSW
)
{
if
(
pSW
)
{
if
(
pSW
->
tSma
)
{
if
(
pSW
->
tSma
)
{
if
(
deepCopy
)
{
if
(
deepCopy
)
{
for
(
uint32_t
i
=
0
;
i
<
pSW
->
number
;
++
i
)
{
for
(
uint32_t
i
=
0
;
i
<
pSW
->
number
;
++
i
)
{
t
d
DestroyTSma
(
pSW
->
tSma
+
i
);
tDestroyTSma
(
pSW
->
tSma
+
i
);
}
}
}
}
taosMemoryFreeClear
(
pSW
->
tSma
);
taosMemoryFreeClear
(
pSW
->
tSma
);
...
@@ -2368,8 +2367,8 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW, bool deepCopy)
...
@@ -2368,8 +2367,8 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW, bool deepCopy)
}
}
}
}
static
FORCE_INLINE
void
*
t
d
FreeTSmaWrapper
(
STSmaWrapper
*
pSW
,
bool
deepCopy
)
{
static
FORCE_INLINE
void
*
tFreeTSmaWrapper
(
STSmaWrapper
*
pSW
,
bool
deepCopy
)
{
t
d
DestroyTSmaWrapper
(
pSW
,
deepCopy
);
tDestroyTSmaWrapper
(
pSW
,
deepCopy
);
taosMemoryFreeClear
(
pSW
);
taosMemoryFreeClear
(
pSW
);
return
NULL
;
return
NULL
;
}
}
...
@@ -2396,6 +2395,17 @@ static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq) {
...
@@ -2396,6 +2395,17 @@ static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq) {
return
0
;
return
0
;
}
}
typedef
struct
{
int64_t
tsmaIndexUid
;
STimeWindow
queryWindow
;
}
SVGetTsmaExpWndsReq
;
typedef
struct
{
int64_t
tsmaIndexUid
;
int32_t
numExpWnds
;
TSKEY
*
expWndsStartTs
;
}
SVGetTsmaExpWndsRsp
;
typedef
struct
{
typedef
struct
{
int
idx
;
int
idx
;
}
SMCreateFullTextReq
;
}
SMCreateFullTextReq
;
...
@@ -2471,7 +2481,7 @@ static FORCE_INLINE void* tDecodeSMqSubVgEp(void* buf, SMqSubVgEp* pVgEp) {
...
@@ -2471,7 +2481,7 @@ static FORCE_INLINE void* tDecodeSMqSubVgEp(void* buf, SMqSubVgEp* pVgEp) {
typedef
struct
{
typedef
struct
{
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
int8_t
isSchemaAdaptive
;
char
db
[
TSDB_DB_FNAME_LEN
]
;
SArray
*
vgs
;
// SArray<SMqSubVgEp>
SArray
*
vgs
;
// SArray<SMqSubVgEp>
SSchemaWrapper
schema
;
SSchemaWrapper
schema
;
}
SMqSubTopicEp
;
}
SMqSubTopicEp
;
...
@@ -2479,7 +2489,7 @@ typedef struct {
...
@@ -2479,7 +2489,7 @@ typedef struct {
static
FORCE_INLINE
int32_t
tEncodeSMqSubTopicEp
(
void
**
buf
,
const
SMqSubTopicEp
*
pTopicEp
)
{
static
FORCE_INLINE
int32_t
tEncodeSMqSubTopicEp
(
void
**
buf
,
const
SMqSubTopicEp
*
pTopicEp
)
{
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeString
(
buf
,
pTopicEp
->
topic
);
tlen
+=
taosEncodeString
(
buf
,
pTopicEp
->
topic
);
tlen
+=
taosEncode
FixedI8
(
buf
,
pTopicEp
->
isSchemaAdaptive
);
tlen
+=
taosEncode
String
(
buf
,
pTopicEp
->
db
);
int32_t
sz
=
taosArrayGetSize
(
pTopicEp
->
vgs
);
int32_t
sz
=
taosArrayGetSize
(
pTopicEp
->
vgs
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
...
@@ -2492,7 +2502,7 @@ static FORCE_INLINE int32_t tEncodeSMqSubTopicEp(void** buf, const SMqSubTopicEp
...
@@ -2492,7 +2502,7 @@ static FORCE_INLINE int32_t tEncodeSMqSubTopicEp(void** buf, const SMqSubTopicEp
static
FORCE_INLINE
void
*
tDecodeSMqSubTopicEp
(
void
*
buf
,
SMqSubTopicEp
*
pTopicEp
)
{
static
FORCE_INLINE
void
*
tDecodeSMqSubTopicEp
(
void
*
buf
,
SMqSubTopicEp
*
pTopicEp
)
{
buf
=
taosDecodeStringTo
(
buf
,
pTopicEp
->
topic
);
buf
=
taosDecodeStringTo
(
buf
,
pTopicEp
->
topic
);
buf
=
taosDecode
FixedI8
(
buf
,
&
pTopicEp
->
isSchemaAdaptive
);
buf
=
taosDecode
StringTo
(
buf
,
pTopicEp
->
db
);
int32_t
sz
;
int32_t
sz
;
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pTopicEp
->
vgs
=
taosArrayInit
(
sz
,
sizeof
(
SMqSubVgEp
));
pTopicEp
->
vgs
=
taosArrayInit
(
sz
,
sizeof
(
SMqSubVgEp
));
...
...
include/common/tmsgdef.h
浏览文件 @
46772d32
...
@@ -201,6 +201,7 @@ enum {
...
@@ -201,6 +201,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_CANCEL_SMA
,
"vnode-cancel-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CANCEL_SMA
,
"vnode-cancel-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_SMA
,
"vnode-drop-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_SMA
,
"vnode-drop-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBMIT_RSMA
,
"vnode-submit-rsma"
,
SSubmitReq
,
SSubmitRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBMIT_RSMA
,
"vnode-submit-rsma"
,
SSubmitReq
,
SSubmitRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_GET_TSMA_EXP_WNDS
,
"vnode-get-tsma-expired-windows"
,
SVGetTsmaExpWndsReq
,
SVGetTsmaExpWndsRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SYNC_TIMEOUT
,
"vnode-sync-timeout"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SYNC_TIMEOUT
,
"vnode-sync-timeout"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SYNC_PING
,
"vnode-sync-ping"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SYNC_PING
,
"vnode-sync-ping"
,
NULL
,
NULL
)
...
...
include/common/ttypes.h
浏览文件 @
46772d32
...
@@ -30,7 +30,7 @@ typedef uint64_t TDRowVerT;
...
@@ -30,7 +30,7 @@ typedef uint64_t TDRowVerT;
typedef
int16_t
col_id_t
;
typedef
int16_t
col_id_t
;
typedef
int8_t
col_type_t
;
typedef
int8_t
col_type_t
;
typedef
int32_t
col_bytes_t
;
typedef
int32_t
col_bytes_t
;
typedef
int32_t
schema_ver_t
;
typedef
int32_t
schema_ver_t
;
typedef
int32_t
func_id_t
;
typedef
int32_t
func_id_t
;
#pragma pack(push, 1)
#pragma pack(push, 1)
...
@@ -49,8 +49,9 @@ typedef struct {
...
@@ -49,8 +49,9 @@ typedef struct {
#define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v))
#define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v))
#define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE))
#define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE))
#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len))
#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len))
#define IS_VAR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON))
#define IS_VAR_DATA_TYPE(t) \
#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR))
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON))
#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR))
#define varDataNetLen(v) (htons(((VarDataLenT *)(v))[0]))
#define varDataNetLen(v) (htons(((VarDataLenT *)(v))[0]))
#define varDataNetTLen(v) (sizeof(VarDataLenT) + varDataNetLen(v))
#define varDataNetTLen(v) (sizeof(VarDataLenT) + varDataNetLen(v))
...
@@ -142,52 +143,56 @@ typedef struct {
...
@@ -142,52 +143,56 @@ typedef struct {
} \
} \
} while (0)
} while (0)
#define NUM_TO_STRING(_inputType, _input, _outputBytes, _output) \
#define NUM_TO_STRING(_inputType, _input, _outputBytes, _output)
\
do { \
do {
\
switch (_inputType) { \
switch (_inputType) {
\
case TSDB_DATA_TYPE_TINYINT: \
case TSDB_DATA_TYPE_TINYINT:
\
snprintf(_output, (int32_t)(_outputBytes), "%d", *(int8_t *)(_input)); \
snprintf(_output, (int32_t)(_outputBytes), "%d", *(int8_t *)(_input));
\
break; \
break;
\
case TSDB_DATA_TYPE_UTINYINT: \
case TSDB_DATA_TYPE_UTINYINT:
\
snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint8_t *)(_input)); \
snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint8_t *)(_input));
\
break; \
break;
\
case TSDB_DATA_TYPE_SMALLINT: \
case TSDB_DATA_TYPE_SMALLINT:
\
snprintf(_output, (int32_t)(_outputBytes), "%d", *(int16_t *)(_input)); \
snprintf(_output, (int32_t)(_outputBytes), "%d", *(int16_t *)(_input));
\
break; \
break;
\
case TSDB_DATA_TYPE_USMALLINT: \
case TSDB_DATA_TYPE_USMALLINT:
\
snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint16_t *)(_input)); \
snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint16_t *)(_input));
\
break; \
break;
\
case TSDB_DATA_TYPE_TIMESTAMP: \
case TSDB_DATA_TYPE_TIMESTAMP:
\
case TSDB_DATA_TYPE_BIGINT: \
case TSDB_DATA_TYPE_BIGINT:
\
snprintf(_output, (int32_t)(_outputBytes), "%" PRId64, *(int64_t *)(_input));
\
snprintf(_output, (int32_t)(_outputBytes), "%" PRId64, *(int64_t *)(_input)); \
break; \
break;
\
case TSDB_DATA_TYPE_UBIGINT: \
case TSDB_DATA_TYPE_UBIGINT:
\
snprintf(_output, (int32_t)(_outputBytes), "%" PRIu64, *(uint64_t *)(_input));
\
snprintf(_output, (int32_t)(_outputBytes), "%" PRIu64, *(uint64_t *)(_input)); \
break; \
break;
\
case TSDB_DATA_TYPE_FLOAT: \
case TSDB_DATA_TYPE_FLOAT:
\
snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input)); \
snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input));
\
break; \
break;
\
case TSDB_DATA_TYPE_DOUBLE: \
case TSDB_DATA_TYPE_DOUBLE:
\
snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input)); \
snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input));
\
break; \
break;
\
case TSDB_DATA_TYPE_UINT: \
case TSDB_DATA_TYPE_UINT:
\
snprintf(_output, (int32_t)(_outputBytes), "%u", *(uint32_t *)(_input)); \
snprintf(_output, (int32_t)(_outputBytes), "%u", *(uint32_t *)(_input));
\
break; \
break;
\
default: \
default:
\
snprintf(_output, (int32_t)(_outputBytes), "%d", *(int32_t *)(_input)); \
snprintf(_output, (int32_t)(_outputBytes), "%d", *(int32_t *)(_input));
\
break; \
break;
\
} \
}
\
} while (0)
} while (0)
//TODO: use varchar(0) to represent NULL type
//TODO: use varchar(0) to represent NULL type
#define IS_VAR_NULL_TYPE(_t, _b) ((_t) == TSDB_DATA_TYPE_VARCHAR && (_b) == 0)
#define IS_NULL_TYPE(_t) ((_t) == TSDB_DATA_TYPE_NULL)
#define IS_NULL_TYPE(_t) ((_t) == TSDB_DATA_TYPE_NULL)
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
#define IS_INTEGER_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)))
#define IS_INTEGER_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)))
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
#define IS_MATHABLE_TYPE(_t) (IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
#define IS_MATHABLE_TYPE(_t) \
(IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
#define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX)
#define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX)
#define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX)
#define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX)
...
@@ -244,7 +249,7 @@ typedef struct tDataTypeDescriptor {
...
@@ -244,7 +249,7 @@ typedef struct tDataTypeDescriptor {
int16_t
type
;
int16_t
type
;
int16_t
nameLen
;
int16_t
nameLen
;
int32_t
bytes
;
int32_t
bytes
;
char
*
name
;
char
*
name
;
int64_t
minValue
;
int64_t
minValue
;
int64_t
maxValue
;
int64_t
maxValue
;
int32_t
(
*
compFunc
)(
const
char
*
const
input
,
int32_t
inputSize
,
const
int32_t
nelements
,
char
*
const
output
,
int32_t
(
*
compFunc
)(
const
char
*
const
input
,
int32_t
inputSize
,
const
int32_t
nelements
,
char
*
const
output
,
...
@@ -277,4 +282,4 @@ void *getDataMax(int32_t type);
...
@@ -277,4 +282,4 @@ void *getDataMax(int32_t type);
}
}
#endif
#endif
#endif
/*_TD_COMMON_TTYPE_H_*/
#endif
/*_TD_COMMON_TTYPE_H_*/
include/libs/catalog/catalog.h
浏览文件 @
46772d32
...
@@ -183,7 +183,7 @@ int32_t catalogGetTableMeta(SCatalog* pCatalog, void * pTransporter, const SEpSe
...
@@ -183,7 +183,7 @@ int32_t catalogGetTableMeta(SCatalog* pCatalog, void * pTransporter, const SEpSe
*/
*/
int32_t
catalogGetSTableMeta
(
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
);
int32_t
catalogGetSTableMeta
(
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
);
int32_t
catalogUpdate
S
TableMeta
(
SCatalog
*
pCatalog
,
STableMetaRsp
*
rspMsg
);
int32_t
catalogUpdateTableMeta
(
SCatalog
*
pCatalog
,
STableMetaRsp
*
rspMsg
);
/**
/**
...
...
include/libs/executor/executor.h
浏览文件 @
46772d32
...
@@ -156,18 +156,6 @@ int64_t qGetQueriedTableUid(qTaskInfo_t tinfo);
...
@@ -156,18 +156,6 @@ int64_t qGetQueriedTableUid(qTaskInfo_t tinfo);
*/
*/
int32_t
qGetQualifiedTableIdList
(
void
*
pTableList
,
const
char
*
tagCond
,
int32_t
tagCondLen
,
SArray
*
pTableIdList
);
int32_t
qGetQualifiedTableIdList
(
void
*
pTableList
,
const
char
*
tagCond
,
int32_t
tagCondLen
,
SArray
*
pTableIdList
);
/**
* Create the table group according to the group by tags info
* @param pTableIdList
* @param skey
* @param groupInfo
* @param groupByIndex
* @param numOfIndex
* @return
*/
// int32_t qCreateTableGroupByGroupExpr(SArray* pTableIdList, TSKEY skey, STableGroupInfo groupInfo, SColIndex*
// groupByIndex, int32_t numOfIndex);
/**
/**
* Update the table id list of a given query.
* Update the table id list of a given query.
* @param uid child table uid
* @param uid child table uid
...
...
include/libs/function/function.h
浏览文件 @
46772d32
...
@@ -61,56 +61,9 @@ typedef struct SFileBlockInfo {
...
@@ -61,56 +61,9 @@ typedef struct SFileBlockInfo {
#define TSDB_BLOCK_DIST_STEP_ROWS 8
#define TSDB_BLOCK_DIST_STEP_ROWS 8
#define MAX_INTERVAL_TIME_WINDOW 1000000 // maximum allowed time windows in final results
#define MAX_INTERVAL_TIME_WINDOW 1000000 // maximum allowed time windows in final results
#define FUNCTION_TYPE_SCALAR 1
#define FUNCTION_TYPE_AGG 2
#define TOP_BOTTOM_QUERY_LIMIT 100
#define TOP_BOTTOM_QUERY_LIMIT 100
#define FUNCTIONS_NAME_MAX_LENGTH 16
#define FUNCTIONS_NAME_MAX_LENGTH 16
#define FUNCTION_INVALID_ID -1
#define FUNCTION_COUNT 0
#define FUNCTION_SUM 1
#define FUNCTION_AVG 2
#define FUNCTION_MIN 3
#define FUNCTION_MAX 4
#define FUNCTION_STDDEV 5
#define FUNCTION_PERCT 6
#define FUNCTION_APERCT 7
#define FUNCTION_FIRST 8
#define FUNCTION_LAST 9
#define FUNCTION_LAST_ROW 10
#define FUNCTION_TOP 11
#define FUNCTION_BOTTOM 12
#define FUNCTION_SPREAD 13
#define FUNCTION_TWA 14
#define FUNCTION_LEASTSQR 15
#define FUNCTION_TS 16
#define FUNCTION_TS_DUMMY 17
#define FUNCTION_TAG_DUMMY 18
#define FUNCTION_TS_COMP 19
#define FUNCTION_TAG 20
#define FUNCTION_PRJ 21
#define FUNCTION_TAGPRJ 22
#define FUNCTION_ARITHM 23
#define FUNCTION_DIFF 24
#define FUNCTION_FIRST_DST 25
#define FUNCTION_LAST_DST 26
#define FUNCTION_STDDEV_DST 27
#define FUNCTION_INTERP 28
#define FUNCTION_RATE 29
#define FUNCTION_IRATE 30
#define FUNCTION_TID_TAG 31
#define FUNCTION_DERIVATIVE 32
#define FUNCTION_BLKINFO 33
#define FUNCTION_COV 38
typedef
struct
SResultRowEntryInfo
{
typedef
struct
SResultRowEntryInfo
{
bool
initialized
:
1
;
// output buffer has been initialized
bool
initialized
:
1
;
// output buffer has been initialized
bool
complete
:
1
;
// query has completed
bool
complete
:
1
;
// query has completed
...
@@ -180,10 +133,9 @@ typedef struct SqlFunctionCtx {
...
@@ -180,10 +133,9 @@ typedef struct SqlFunctionCtx {
char
*
pOutput
;
// final result output buffer, point to sdata->data
char
*
pOutput
;
// final result output buffer, point to sdata->data
int32_t
numOfParams
;
int32_t
numOfParams
;
SFunctParam
*
param
;
// input parameter, e.g., top(k, 20), the number of results for top query is kept in param
SFunctParam
*
param
;
// input parameter, e.g., top(k, 20), the number of results for top query is kept in param
int64_t
*
ptsList
;
// corresponding timestamp array list
int64_t
*
ptsList
;
// corresponding timestamp array list
, todo remove it
SColumnInfoData
*
pTsOutput
;
// corresponding output buffer for timestamp of each result, e.g., top/bottom*/
SColumnInfoData
*
pTsOutput
;
// corresponding output buffer for timestamp of each result, e.g., top/bottom*/
int32_t
offset
;
int32_t
offset
;
SVariant
tag
;
struct
SResultRowEntryInfo
*
resultInfo
;
struct
SResultRowEntryInfo
*
resultInfo
;
SSubsidiaryResInfo
subsidiaries
;
SSubsidiaryResInfo
subsidiaries
;
SPoint1
start
;
SPoint1
start
;
...
@@ -210,9 +162,6 @@ enum {
...
@@ -210,9 +162,6 @@ enum {
typedef
struct
tExprNode
{
typedef
struct
tExprNode
{
int32_t
nodeType
;
int32_t
nodeType
;
union
{
union
{
SSchema
*
pSchema
;
// column node
struct
SVariant
*
pVal
;
// value node
struct
{
// function node
struct
{
// function node
char
functionName
[
FUNCTIONS_NAME_MAX_LENGTH
];
// todo refactor
char
functionName
[
FUNCTIONS_NAME_MAX_LENGTH
];
// todo refactor
int32_t
functionId
;
int32_t
functionId
;
...
@@ -255,47 +204,23 @@ struct SScalarParam {
...
@@ -255,47 +204,23 @@ struct SScalarParam {
int32_t
getResultDataInfo
(
int32_t
dataType
,
int32_t
dataBytes
,
int32_t
functionId
,
int32_t
param
,
SResultDataInfo
*
pInfo
,
int16_t
extLength
,
int32_t
getResultDataInfo
(
int32_t
dataType
,
int32_t
dataBytes
,
int32_t
functionId
,
int32_t
param
,
SResultDataInfo
*
pInfo
,
int16_t
extLength
,
bool
isSuperTable
);
bool
isSuperTable
);
bool
qIsValidUdf
(
SArray
*
pUdfInfo
,
const
char
*
name
,
int32_t
len
,
int32_t
*
functionId
);
void
resetResultRowEntryResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
num
);
void
resetResultRowEntryResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
num
);
void
cleanupResultRowEntry
(
struct
SResultRowEntryInfo
*
pCell
);
void
cleanupResultRowEntry
(
struct
SResultRowEntryInfo
*
pCell
);
int32_t
getNumOfResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
num
,
SSDataBlock
*
pResBlock
);
int32_t
getNumOfResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
num
,
SSDataBlock
*
pResBlock
);
bool
isRowEntryCompleted
(
struct
SResultRowEntryInfo
*
pEntry
);
bool
isRowEntryCompleted
(
struct
SResultRowEntryInfo
*
pEntry
);
bool
isRowEntryInitialized
(
struct
SResultRowEntryInfo
*
pEntry
);
bool
isRowEntryInitialized
(
struct
SResultRowEntryInfo
*
pEntry
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// fill api
struct
SFillInfo
;
struct
SFillColInfo
;
typedef
struct
SPoint
{
typedef
struct
SPoint
{
int64_t
key
;
int64_t
key
;
void
*
val
;
void
*
val
;
}
SPoint
;
}
SPoint
;
//void taosFillSetStartInfo(struct SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey);
//void taosResetFillInfo(struct SFillInfo* pFillInfo, TSKEY startTimestamp);
//void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struct SSDataBlock* pInput);
//struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const SValueNode* val);
//bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
//
//struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
// SInterval* pInterval, int32_t fillType,
// struct SFillColInfo* pCol, const char* id);
//
//void* taosDestroyFillInfo(struct SFillInfo *pFillInfo);
//int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, void** output, int32_t capacity);
//int64_t getFillInfoStart(struct SFillInfo *pFillInfo);
int32_t
taosGetLinearInterpolationVal
(
SPoint
*
point
,
int32_t
outputType
,
SPoint
*
point1
,
SPoint
*
point2
,
int32_t
inputType
);
int32_t
taosGetLinearInterpolationVal
(
SPoint
*
point
,
int32_t
outputType
,
SPoint
*
point1
,
SPoint
*
point2
,
int32_t
inputType
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// udf api
// udf api
struct
SUdfInfo
;
struct
SUdfInfo
;
void
qAddUdfInfo
(
uint64_t
id
,
struct
SUdfInfo
*
pUdfInfo
);
void
qRemoveUdfInfo
(
uint64_t
id
,
struct
SUdfInfo
*
pUdfInfo
);
/**
/**
* create udfd proxy, called once in process that call doSetupUdf/callUdfxxx/doTeardownUdf
* create udfd proxy, called once in process that call doSetupUdf/callUdfxxx/doTeardownUdf
* @return error code
* @return error code
...
...
include/libs/function/functionMgt.h
浏览文件 @
46772d32
...
@@ -156,6 +156,9 @@ bool fmIsDynamicScanOptimizedFunc(int32_t funcId);
...
@@ -156,6 +156,9 @@ bool fmIsDynamicScanOptimizedFunc(int32_t funcId);
bool
fmIsMultiResFunc
(
int32_t
funcId
);
bool
fmIsMultiResFunc
(
int32_t
funcId
);
bool
fmIsRepeatScanFunc
(
int32_t
funcId
);
bool
fmIsRepeatScanFunc
(
int32_t
funcId
);
bool
fmIsUserDefinedFunc
(
int32_t
funcId
);
bool
fmIsUserDefinedFunc
(
int32_t
funcId
);
bool
fmIsDistExecFunc
(
int32_t
funcId
);
int32_t
fmGetDistMethod
(
const
SFunctionNode
*
pFunc
,
SFunctionNode
**
pPartialFunc
,
SFunctionNode
**
pMergeFunc
);
typedef
enum
EFuncDataRequired
{
typedef
enum
EFuncDataRequired
{
FUNC_DATA_REQUIRED_DATA_LOAD
=
1
,
FUNC_DATA_REQUIRED_DATA_LOAD
=
1
,
...
...
include/libs/nodes/nodes.h
浏览文件 @
46772d32
...
@@ -189,6 +189,7 @@ typedef enum ENodeType {
...
@@ -189,6 +189,7 @@ typedef enum ENodeType {
QUERY_NODE_LOGIC_PLAN_PROJECT
,
QUERY_NODE_LOGIC_PLAN_PROJECT
,
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
,
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
,
QUERY_NODE_LOGIC_PLAN_EXCHANGE
,
QUERY_NODE_LOGIC_PLAN_EXCHANGE
,
QUERY_NODE_LOGIC_PLAN_MERGE
,
QUERY_NODE_LOGIC_PLAN_WINDOW
,
QUERY_NODE_LOGIC_PLAN_WINDOW
,
QUERY_NODE_LOGIC_PLAN_FILL
,
QUERY_NODE_LOGIC_PLAN_FILL
,
QUERY_NODE_LOGIC_PLAN_SORT
,
QUERY_NODE_LOGIC_PLAN_SORT
,
...
@@ -206,10 +207,12 @@ typedef enum ENodeType {
...
@@ -206,10 +207,12 @@ typedef enum ENodeType {
QUERY_NODE_PHYSICAL_PLAN_JOIN
,
QUERY_NODE_PHYSICAL_PLAN_JOIN
,
QUERY_NODE_PHYSICAL_PLAN_AGG
,
QUERY_NODE_PHYSICAL_PLAN_AGG
,
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
,
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
,
QUERY_NODE_PHYSICAL_PLAN_MERGE
,
QUERY_NODE_PHYSICAL_PLAN_SORT
,
QUERY_NODE_PHYSICAL_PLAN_SORT
,
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_FILL
,
QUERY_NODE_PHYSICAL_PLAN_FILL
,
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
,
...
...
include/libs/nodes/plannodes.h
浏览文件 @
46772d32
...
@@ -95,26 +95,39 @@ typedef struct SVnodeModifLogicNode {
...
@@ -95,26 +95,39 @@ typedef struct SVnodeModifLogicNode {
typedef
struct
SExchangeLogicNode
{
typedef
struct
SExchangeLogicNode
{
SLogicNode
node
;
SLogicNode
node
;
int32_t
srcGroupId
;
int32_t
srcGroupId
;
uint8_t
precision
;
}
SExchangeLogicNode
;
}
SExchangeLogicNode
;
typedef
struct
SMergeLogicNode
{
SLogicNode
node
;
SNodeList
*
pMergeKeys
;
int32_t
numOfChannels
;
int32_t
srcGroupId
;
}
SMergeLogicNode
;
typedef
enum
EWindowType
{
WINDOW_TYPE_INTERVAL
=
1
,
WINDOW_TYPE_SESSION
,
WINDOW_TYPE_STATE
}
EWindowType
;
typedef
enum
EWindowType
{
WINDOW_TYPE_INTERVAL
=
1
,
WINDOW_TYPE_SESSION
,
WINDOW_TYPE_STATE
}
EWindowType
;
typedef
enum
EStreamIntervalAlgorithm
{
STREAM_INTERVAL_ALGO_FINAL
=
1
,
STREAM_INTERVAL_ALGO_SEMI
,
STREAM_INTERVAL_ALGO_SINGLE
}
EStreamIntervalAlgorithm
;
typedef
struct
SWindowLogicNode
{
typedef
struct
SWindowLogicNode
{
SLogicNode
node
;
SLogicNode
node
;
EWindowType
winType
;
EWindowType
winType
;
SNodeList
*
pFuncs
;
SNodeList
*
pFuncs
;
int64_t
interval
;
int64_t
interval
;
int64_t
offset
;
int64_t
offset
;
int64_t
sliding
;
int64_t
sliding
;
int8_t
intervalUnit
;
int8_t
intervalUnit
;
int8_t
slidingUnit
;
int8_t
slidingUnit
;
int64_t
sessionGap
;
int64_t
sessionGap
;
SNode
*
pTspk
;
SNode
*
pTspk
;
SNode
*
pStateExpr
;
SNode
*
pStateExpr
;
int8_t
triggerType
;
int8_t
triggerType
;
int64_t
watermark
;
int64_t
watermark
;
double
filesFactor
;
double
filesFactor
;
EStreamIntervalAlgorithm
stmInterAlgo
;
}
SWindowLogicNode
;
}
SWindowLogicNode
;
typedef
struct
SFillLogicNode
{
typedef
struct
SFillLogicNode
{
...
@@ -268,6 +281,13 @@ typedef struct SExchangePhysiNode {
...
@@ -268,6 +281,13 @@ typedef struct SExchangePhysiNode {
SNodeList
*
pSrcEndPoints
;
// element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
SNodeList
*
pSrcEndPoints
;
// element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
}
SExchangePhysiNode
;
}
SExchangePhysiNode
;
typedef
struct
SMergePhysiNode
{
SPhysiNode
node
;
SNodeList
*
pMergeKeys
;
int32_t
numOfChannels
;
int32_t
srcGroupId
;
}
SMergePhysiNode
;
typedef
struct
SWinodwPhysiNode
{
typedef
struct
SWinodwPhysiNode
{
SPhysiNode
node
;
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of parameter expression of function
SNodeList
*
pExprs
;
// these are expression list of parameter expression of function
...
@@ -288,6 +308,8 @@ typedef struct SIntervalPhysiNode {
...
@@ -288,6 +308,8 @@ typedef struct SIntervalPhysiNode {
}
SIntervalPhysiNode
;
}
SIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SStreamIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SStreamIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SStreamFinalIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SStreamSemiIntervalPhysiNode
;
typedef
struct
SFillPhysiNode
{
typedef
struct
SFillPhysiNode
{
SPhysiNode
node
;
SPhysiNode
node
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
46772d32
...
@@ -331,8 +331,8 @@ typedef struct SQuery {
...
@@ -331,8 +331,8 @@ typedef struct SQuery {
int8_t
precision
;
int8_t
precision
;
SCmdMsgInfo
*
pCmdMsg
;
SCmdMsgInfo
*
pCmdMsg
;
int32_t
msgType
;
int32_t
msgType
;
SArray
*
pDbList
;
SArray
*
pTableList
;
SArray
*
pTableList
;
SArray
*
pDbList
;
bool
showRewrite
;
bool
showRewrite
;
int32_t
placeholderNum
;
int32_t
placeholderNum
;
SArray
*
pPlaceholderValues
;
SArray
*
pPlaceholderValues
;
...
...
include/libs/parser/parser.h
浏览文件 @
46772d32
...
@@ -49,6 +49,7 @@ typedef struct SParseContext {
...
@@ -49,6 +49,7 @@ typedef struct SParseContext {
const
char
*
pUser
;
const
char
*
pUser
;
bool
isSuperUser
;
bool
isSuperUser
;
bool
async
;
bool
async
;
int8_t
schemalessType
;
}
SParseContext
;
}
SParseContext
;
int32_t
qParseSql
(
SParseContext
*
pCxt
,
SQuery
**
pQuery
);
int32_t
qParseSql
(
SParseContext
*
pCxt
,
SQuery
**
pQuery
);
...
...
include/libs/planner/planner.h
浏览文件 @
46772d32
...
@@ -36,7 +36,7 @@ typedef struct SPlanContext {
...
@@ -36,7 +36,7 @@ typedef struct SPlanContext {
int64_t
watermark
;
int64_t
watermark
;
char
*
pMsg
;
char
*
pMsg
;
int32_t
msgLen
;
int32_t
msgLen
;
double
filesFactor
;
double
filesFactor
;
}
SPlanContext
;
}
SPlanContext
;
// Create the physical plan for the query, according to the AST.
// Create the physical plan for the query, according to the AST.
...
...
include/libs/qcom/query.h
浏览文件 @
46772d32
...
@@ -56,6 +56,11 @@ typedef struct STableComInfo {
...
@@ -56,6 +56,11 @@ typedef struct STableComInfo {
int32_t
rowSize
;
// row size of the schema
int32_t
rowSize
;
// row size of the schema
}
STableComInfo
;
}
STableComInfo
;
typedef
struct
SQueryExecRes
{
int32_t
msgType
;
void
*
res
;
}
SQueryExecRes
;
typedef
struct
SIndexMeta
{
typedef
struct
SIndexMeta
{
#ifdef WINDOWS
#ifdef WINDOWS
size_t
avoidCompilationErrors
;
size_t
avoidCompilationErrors
;
...
@@ -192,6 +197,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp* msg, bool isSuperTable, STabl
...
@@ -192,6 +197,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp* msg, bool isSuperTable, STabl
char
*
jobTaskStatusStr
(
int32_t
status
);
char
*
jobTaskStatusStr
(
int32_t
status
);
SSchema
createSchema
(
int8_t
type
,
int32_t
bytes
,
col_id_t
colId
,
const
char
*
name
);
SSchema
createSchema
(
int8_t
type
,
int32_t
bytes
,
col_id_t
colId
,
const
char
*
name
);
void
destroyQueryExecRes
(
SQueryExecRes
*
pRes
);
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
,
void
*
(
*
mallocFp
)(
int32_t
));
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
,
void
*
(
*
mallocFp
)(
int32_t
));
extern
int32_t
(
*
queryProcessMsgRsp
[
TDMT_MAX
])(
void
*
output
,
char
*
msg
,
int32_t
msgSize
);
extern
int32_t
(
*
queryProcessMsgRsp
[
TDMT_MAX
])(
void
*
output
,
char
*
msg
,
int32_t
msgSize
);
...
@@ -204,7 +210,8 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
...
@@ -204,7 +210,8 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
#define NEED_CLIENT_RM_TBLMETA_ERROR(_code) \
#define NEED_CLIENT_RM_TBLMETA_ERROR(_code) \
((_code) == TSDB_CODE_PAR_TABLE_NOT_EXIST || (_code) == TSDB_CODE_VND_TB_NOT_EXIST || \
((_code) == TSDB_CODE_PAR_TABLE_NOT_EXIST || (_code) == TSDB_CODE_VND_TB_NOT_EXIST || \
(_code) == TSDB_CODE_PAR_INVALID_COLUMNS_NUM || (_code) == TSDB_CODE_PAR_INVALID_COLUMN || \
(_code) == TSDB_CODE_PAR_INVALID_COLUMNS_NUM || (_code) == TSDB_CODE_PAR_INVALID_COLUMN || \
(_code) == TSDB_CODE_PAR_TAGS_NOT_MATCHED || (_code == TSDB_CODE_PAR_VALUE_TOO_LONG))
(_code) == TSDB_CODE_PAR_TAGS_NOT_MATCHED || (_code == TSDB_CODE_PAR_VALUE_TOO_LONG) || \
(_code == TSDB_CODE_PAR_INVALID_DROP_COL))
#define NEED_CLIENT_REFRESH_VG_ERROR(_code) \
#define NEED_CLIENT_REFRESH_VG_ERROR(_code) \
((_code) == TSDB_CODE_VND_HASH_MISMATCH || (_code) == TSDB_CODE_VND_INVALID_VGROUP_ID)
((_code) == TSDB_CODE_VND_HASH_MISMATCH || (_code) == TSDB_CODE_VND_INVALID_VGROUP_ID)
#define NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code) ((_code) == TSDB_CODE_TDB_TABLE_RECREATED)
#define NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code) ((_code) == TSDB_CODE_TDB_TABLE_RECREATED)
...
...
include/libs/scheduler/scheduler.h
浏览文件 @
46772d32
...
@@ -56,7 +56,7 @@ typedef struct SQueryProfileSummary {
...
@@ -56,7 +56,7 @@ typedef struct SQueryProfileSummary {
typedef
struct
SQueryResult
{
typedef
struct
SQueryResult
{
int32_t
code
;
int32_t
code
;
uint64_t
numOfRows
;
uint64_t
numOfRows
;
void
*
res
;
SQueryExecRes
res
;
}
SQueryResult
;
}
SQueryResult
;
typedef
struct
STaskInfo
{
typedef
struct
STaskInfo
{
...
...
include/libs/wal/wal.h
浏览文件 @
46772d32
...
@@ -184,6 +184,7 @@ int32_t walRollback(SWal *, int64_t ver);
...
@@ -184,6 +184,7 @@ int32_t walRollback(SWal *, int64_t ver);
// notify that previous logs can be pruned safely
// notify that previous logs can be pruned safely
int32_t
walBeginSnapshot
(
SWal
*
,
int64_t
ver
);
int32_t
walBeginSnapshot
(
SWal
*
,
int64_t
ver
);
int32_t
walEndSnapshot
(
SWal
*
);
int32_t
walEndSnapshot
(
SWal
*
);
void
walRestoreFromSnapshot
(
SWal
*
,
int64_t
ver
);
// int32_t walDataCorrupted(SWal*);
// int32_t walDataCorrupted(SWal*);
// read
// read
...
...
include/util/taoserror.h
浏览文件 @
46772d32
...
@@ -675,6 +675,7 @@ int32_t* taosGetErrno();
...
@@ -675,6 +675,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_SML_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x3000)
#define TSDB_CODE_SML_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x3000)
#define TSDB_CODE_SML_INVALID_PRECISION_TYPE TAOS_DEF_ERROR_CODE(0, 0x3001)
#define TSDB_CODE_SML_INVALID_PRECISION_TYPE TAOS_DEF_ERROR_CODE(0, 0x3001)
#define TSDB_CODE_SML_INVALID_DATA TAOS_DEF_ERROR_CODE(0, 0x3002)
#define TSDB_CODE_SML_INVALID_DATA TAOS_DEF_ERROR_CODE(0, 0x3002)
#define TSDB_CODE_SML_INVALID_DB_CONF TAOS_DEF_ERROR_CODE(0, 0x3003)
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/util/tdef.h
浏览文件 @
46772d32
...
@@ -209,7 +209,7 @@ typedef enum ELogicConditionType {
...
@@ -209,7 +209,7 @@ typedef enum ELogicConditionType {
#define TSDB_INDEX_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_INDEX_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_INDEX_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_INDEX_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TYPE_STR_MAX_LEN 32
#define TSDB_TYPE_STR_MAX_LEN 32
#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TOPIC_FNAME_LEN
TSDB_TABLE_FNAME_LEN
#define TSDB_TOPIC_FNAME_LEN
(TSDB_ACCT_ID_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_STREAM_FNAME_LEN TSDB_TABLE_FNAME_LEN
#define TSDB_STREAM_FNAME_LEN TSDB_TABLE_FNAME_LEN
#define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CGROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2)
#define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CGROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2)
#define TSDB_PARTITION_KEY_LEN (TSDB_SUBSCRIBE_KEY_LEN + 20)
#define TSDB_PARTITION_KEY_LEN (TSDB_SUBSCRIBE_KEY_LEN + 20)
...
...
include/util/tlist.h
浏览文件 @
46772d32
...
@@ -229,7 +229,7 @@ int32_t tdListAppend(SList *list, void *data);
...
@@ -229,7 +229,7 @@ int32_t tdListAppend(SList *list, void *data);
SListNode
*
tdListPopHead
(
SList
*
list
);
SListNode
*
tdListPopHead
(
SList
*
list
);
SListNode
*
tdListPopTail
(
SList
*
list
);
SListNode
*
tdListPopTail
(
SList
*
list
);
SListNode
*
tdListGetHead
(
SList
*
list
);
SListNode
*
tdListGetHead
(
SList
*
list
);
SListNode
*
t
s
ListGetTail
(
SList
*
list
);
SListNode
*
t
d
ListGetTail
(
SList
*
list
);
SListNode
*
tdListPopNode
(
SList
*
list
,
SListNode
*
node
);
SListNode
*
tdListPopNode
(
SList
*
list
,
SListNode
*
node
);
void
tdListMove
(
SList
*
src
,
SList
*
dst
);
void
tdListMove
(
SList
*
src
,
SList
*
dst
);
void
tdListDiscard
(
SList
*
list
);
void
tdListDiscard
(
SList
*
list
);
...
...
source/client/inc/clientInt.h
浏览文件 @
46772d32
...
@@ -151,6 +151,7 @@ typedef struct STscObj {
...
@@ -151,6 +151,7 @@ typedef struct STscObj {
int32_t
numOfReqs
;
// number of sqlObj bound to this connection
int32_t
numOfReqs
;
// number of sqlObj bound to this connection
SAppInstInfo
*
pAppInfo
;
SAppInstInfo
*
pAppInfo
;
SHashObj
*
pRequests
;
SHashObj
*
pRequests
;
int8_t
schemalessType
;
}
STscObj
;
}
STscObj
;
typedef
struct
SResultColumn
{
typedef
struct
SResultColumn
{
...
@@ -162,6 +163,7 @@ typedef struct SResultColumn {
...
@@ -162,6 +163,7 @@ typedef struct SResultColumn {
}
SResultColumn
;
}
SResultColumn
;
typedef
struct
SReqResultInfo
{
typedef
struct
SReqResultInfo
{
SQueryExecRes
execRes
;
const
char
*
pRspMsg
;
const
char
*
pRspMsg
;
const
char
*
pData
;
const
char
*
pData
;
TAOS_FIELD
*
fields
;
// todo, column names are not needed.
TAOS_FIELD
*
fields
;
// todo, column names are not needed.
...
@@ -191,6 +193,7 @@ typedef struct SRequestSendRecvBody {
...
@@ -191,6 +193,7 @@ typedef struct SRequestSendRecvBody {
typedef
struct
{
typedef
struct
{
int8_t
resType
;
int8_t
resType
;
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int32_t
vgId
;
int32_t
vgId
;
SSchemaWrapper
schema
;
SSchemaWrapper
schema
;
int32_t
resIter
;
int32_t
resIter
;
...
@@ -318,7 +321,7 @@ void hbMgrInitMqHbRspHandle();
...
@@ -318,7 +321,7 @@ void hbMgrInitMqHbRspHandle();
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
,
void
**
res
);
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
,
void
**
res
);
int32_t
getQueryPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SArray
**
pNodeList
);
int32_t
getQueryPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SArray
**
pNodeList
);
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
,
void
**
res
);
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
);
int32_t
refreshMeta
(
STscObj
*
pTscObj
,
SRequestObj
*
pRequest
);
int32_t
refreshMeta
(
STscObj
*
pTscObj
,
SRequestObj
*
pRequest
);
int32_t
updateQnodeList
(
SAppInstInfo
*
pInfo
,
SArray
*
pNodeList
);
int32_t
updateQnodeList
(
SAppInstInfo
*
pInfo
,
SArray
*
pNodeList
);
...
...
source/client/src/clientEnv.c
浏览文件 @
46772d32
...
@@ -161,6 +161,7 @@ void *createTscObj(const char *user, const char *auth, const char *db, int32_t c
...
@@ -161,6 +161,7 @@ void *createTscObj(const char *user, const char *auth, const char *db, int32_t c
taosThreadMutexInit
(
&
pObj
->
mutex
,
NULL
);
taosThreadMutexInit
(
&
pObj
->
mutex
,
NULL
);
pObj
->
id
=
taosAddRef
(
clientConnRefPool
,
pObj
);
pObj
->
id
=
taosAddRef
(
clientConnRefPool
,
pObj
);
pObj
->
schemalessType
=
0
;
tscDebug
(
"connObj created, 0x%"
PRIx64
,
pObj
->
id
);
tscDebug
(
"connObj created, 0x%"
PRIx64
,
pObj
->
id
);
return
pObj
;
return
pObj
;
...
@@ -234,6 +235,8 @@ static void doDestroyRequest(void *p) {
...
@@ -234,6 +235,8 @@ static void doDestroyRequest(void *p) {
taosArrayDestroy
(
pRequest
->
tableList
);
taosArrayDestroy
(
pRequest
->
tableList
);
taosArrayDestroy
(
pRequest
->
dbList
);
taosArrayDestroy
(
pRequest
->
dbList
);
destroyQueryExecRes
(
&
pRequest
->
body
.
resInfo
.
execRes
);
deregisterRequest
(
pRequest
);
deregisterRequest
(
pRequest
);
taosMemoryFreeClear
(
pRequest
);
taosMemoryFreeClear
(
pRequest
);
}
}
...
...
source/client/src/clientHb.c
浏览文件 @
46772d32
...
@@ -120,7 +120,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
...
@@ -120,7 +120,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
return
TSDB_CODE_TSC_INVALID_VALUE
;
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
}
catalogUpdate
S
TableMeta
(
pCatalog
,
rsp
);
catalogUpdateTableMeta
(
pCatalog
,
rsp
);
}
}
}
}
...
...
source/client/src/clientImpl.c
浏览文件 @
46772d32
...
@@ -176,6 +176,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC
...
@@ -176,6 +176,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC
.
pTransporter
=
pTscObj
->
pAppInfo
->
pTransporter
,
.
pTransporter
=
pTscObj
->
pAppInfo
->
pTransporter
,
.
pStmtCb
=
pStmtCb
,
.
pStmtCb
=
pStmtCb
,
.
pUser
=
pTscObj
->
user
,
.
pUser
=
pTscObj
->
user
,
.
schemalessType
=
pTscObj
->
schemalessType
,
.
isSuperUser
=
(
0
==
strcmp
(
pTscObj
->
user
,
TSDB_DEFAULT_USER
))};
.
isSuperUser
=
(
0
==
strcmp
(
pTscObj
->
user
,
TSDB_DEFAULT_USER
))};
cxt
.
mgmtEpSet
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
cxt
.
mgmtEpSet
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
...
@@ -340,22 +341,23 @@ void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) {
...
@@ -340,22 +341,23 @@ void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) {
pResInfo
->
precision
=
precision
;
pResInfo
->
precision
=
precision
;
}
}
int32_t
scheduleAsyncQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
,
void
**
pRes
)
{
int32_t
scheduleAsyncQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
)
{
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
tsem_init
(
&
schdRspSem
,
0
,
0
);
tsem_init
(
&
schdRspSem
,
0
,
0
);
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
};
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
};
int32_t
code
=
schedulerAsyncExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
int32_t
code
=
schedulerAsyncExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
pRequest
->
metric
.
start
,
schdExecCallback
,
&
res
);
pRequest
->
metric
.
start
,
schdExecCallback
,
&
res
);
while
(
true
)
{
pRequest
->
body
.
resInfo
.
execRes
=
res
.
res
;
while
(
true
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
schedulerFreeJob
(
pRequest
->
body
.
queryJob
);
schedulerFreeJob
(
pRequest
->
body
.
queryJob
);
}
}
*
pRes
=
res
.
res
;
pRequest
->
code
=
code
;
pRequest
->
code
=
code
;
terrno
=
code
;
terrno
=
code
;
return
pRequest
->
code
;
return
pRequest
->
code
;
...
@@ -378,26 +380,25 @@ int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNod
...
@@ -378,26 +380,25 @@ int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNod
}
}
}
}
*
pRes
=
res
.
res
;
pRequest
->
code
=
res
.
code
;
pRequest
->
code
=
res
.
code
;
terrno
=
res
.
code
;
terrno
=
res
.
code
;
return
pRequest
->
code
;
return
pRequest
->
code
;
}
}
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
,
void
**
pRes
)
{
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
)
{
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
};
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
};
int32_t
code
=
schedulerExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
int32_t
code
=
schedulerExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
pRequest
->
metric
.
start
,
&
res
);
pRequest
->
metric
.
start
,
&
res
);
pRequest
->
body
.
resInfo
.
execRes
=
res
.
res
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
schedulerFreeJob
(
pRequest
->
body
.
queryJob
);
schedulerFreeJob
(
pRequest
->
body
.
queryJob
);
}
}
*
pRes
=
res
.
res
;
pRequest
->
code
=
code
;
pRequest
->
code
=
code
;
terrno
=
code
;
terrno
=
code
;
return
pRequest
->
code
;
return
pRequest
->
code
;
...
@@ -411,8 +412,6 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
...
@@ -411,8 +412,6 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
}
}
}
}
*
pRes
=
res
.
res
;
pRequest
->
code
=
res
.
code
;
pRequest
->
code
=
res
.
code
;
terrno
=
res
.
code
;
terrno
=
res
.
code
;
return
pRequest
->
code
;
return
pRequest
->
code
;
...
@@ -422,80 +421,109 @@ int32_t getQueryPlan(SRequestObj* pRequest, SQuery* pQuery, SArray** pNodeList)
...
@@ -422,80 +421,109 @@ int32_t getQueryPlan(SRequestObj* pRequest, SQuery* pQuery, SArray** pNodeList)
return
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
pNodeList
);
return
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
pNodeList
);
}
}
int32_t
validateSversion
(
SRequestObj
*
pRequest
,
void
*
res
)
{
int32_t
handleSubmitExecRes
(
SRequestObj
*
pRequest
,
void
*
res
,
SCatalog
*
pCatalog
,
SEpSet
*
epset
)
{
SArray
*
pArray
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
SArray
*
pArray
=
NULL
;
if
(
TDMT_VND_SUBMIT
==
pRequest
->
type
)
{
SSubmitRsp
*
pRsp
=
(
SSubmitRsp
*
)
res
;
SSubmitRsp
*
pRsp
=
(
SSubmitRsp
*
)
res
;
if
(
pRsp
->
nBlocks
<=
0
)
{
if
(
pRsp
->
nBlocks
<=
0
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
pArray
=
taosArrayInit
(
pRsp
->
nBlocks
,
sizeof
(
STbSVersion
));
pArray
=
taosArrayInit
(
pRsp
->
nBlocks
,
sizeof
(
STbSVersion
));
if
(
NULL
==
pArray
)
{
if
(
NULL
==
pArray
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
pRsp
->
nBlocks
;
++
i
)
{
SSubmitBlkRsp
*
blk
=
pRsp
->
pBlocks
+
i
;
if
(
NULL
==
blk
->
tblFName
||
0
==
blk
->
tblFName
[
0
])
{
continue
;
}
}
STbSVersion
tbSver
=
{.
tbFName
=
blk
->
tblFName
,
.
sver
=
blk
->
sver
};
taosArrayPush
(
pArray
,
&
tbSver
);
}
for
(
int32_t
i
=
0
;
i
<
pRsp
->
nBlocks
;
++
i
)
{
code
=
catalogChkTbMetaVersion
(
pCatalog
,
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
epset
,
pArray
);
SSubmitBlkRsp
*
blk
=
pRsp
->
pBlocks
+
i
;
if
(
NULL
==
blk
->
tblFName
||
0
==
blk
->
tblFName
[
0
])
{
continue
;
}
STbSVersion
tbSver
=
{.
tbFName
=
blk
->
tblFName
,
.
sver
=
blk
->
sver
};
_return:
taosArrayPush
(
pArray
,
&
tbSver
);
}
}
else
if
(
TDMT_VND_QUERY
==
pRequest
->
type
)
{
SArray
*
pTbArray
=
(
SArray
*
)
res
;
int32_t
tbNum
=
taosArrayGetSize
(
pTbArray
);
if
(
tbNum
<=
0
)
{
return
TSDB_CODE_SUCCESS
;
}
pArray
=
taosArrayInit
(
tbNum
,
sizeof
(
STbSVersion
));
taosArrayDestroy
(
pArray
);
if
(
NULL
==
pArray
)
{
return
code
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
}
return
TSDB_CODE_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
tbNum
;
++
i
)
{
int32_t
handleQueryExecRes
(
SRequestObj
*
pRequest
,
void
*
res
,
SCatalog
*
pCatalog
,
SEpSet
*
epset
)
{
STbVerInfo
*
tbInfo
=
taosArrayGet
(
pTbArray
,
i
);
int32_t
code
=
0
;
STbSVersion
tbSver
=
{.
tbFName
=
tbInfo
->
tbFName
,
.
sver
=
tbInfo
->
sversion
,
.
tver
=
tbInfo
->
tversion
};
SArray
*
pArray
=
NULL
;
taosArrayPush
(
pArray
,
&
tbSver
);
SArray
*
pTbArray
=
(
SArray
*
)
res
;
}
int32_t
tbNum
=
taosArrayGetSize
(
pTbArray
);
if
(
tbNum
<=
0
)
{
return
TSDB_CODE_SUCCESS
;
}
pArray
=
taosArrayInit
(
tbNum
,
sizeof
(
STbSVersion
));
if
(
NULL
==
pArray
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
tbNum
;
++
i
)
{
STbVerInfo
*
tbInfo
=
taosArrayGet
(
pTbArray
,
i
);
STbSVersion
tbSver
=
{.
tbFName
=
tbInfo
->
tbFName
,
.
sver
=
tbInfo
->
sversion
,
.
tver
=
tbInfo
->
tversion
};
taosArrayPush
(
pArray
,
&
tbSver
);
}
}
SCatalog
*
pCatalog
=
NULL
;
code
=
catalogChkTbMetaVersion
(
pCatalog
,
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
epset
,
pArray
);
CHECK_CODE_GOTO
(
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
),
_return
);
SEpSet
epset
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
);
code
=
catalogChkTbMetaVersion
(
pCatalog
,
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
&
epset
,
pArray
);
_return:
_return:
taosArrayDestroy
(
pArray
);
taosArrayDestroy
(
pArray
);
return
code
;
}
return
code
;
int32_t
handleAlterTbExecRes
(
void
*
res
,
SCatalog
*
pCatalog
)
{
return
catalogUpdateTableMeta
(
pCatalog
,
(
STableMetaRsp
*
)
res
);
}
}
void
freeRequestRes
(
SRequestObj
*
pRequest
,
void
*
res
)
{
int32_t
handleExecRes
(
SRequestObj
*
pRequest
)
{
if
(
NULL
==
pRequest
||
NULL
==
res
)
{
if
(
NULL
==
pRequest
->
body
.
resInfo
.
execRes
.
res
)
{
return
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
TDMT_VND_SUBMIT
==
pRequest
->
type
)
{
int32_t
code
=
0
;
tFreeSSubmitRsp
((
SSubmitRsp
*
)
res
);
SCatalog
*
pCatalog
=
NULL
;
}
else
if
(
TDMT_VND_QUERY
==
pRequest
->
type
)
{
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
taosArrayDestroy
((
SArray
*
)
res
);
if
(
code
)
{
return
code
;
}
}
SEpSet
epset
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
);
SQueryExecRes
*
pRes
=
&
pRequest
->
body
.
resInfo
.
execRes
;
switch
(
pRes
->
msgType
)
{
case
TDMT_VND_ALTER_TABLE
:
case
TDMT_MND_ALTER_STB
:
{
code
=
handleAlterTbExecRes
(
pRes
->
res
,
pCatalog
);
break
;
}
case
TDMT_VND_SUBMIT
:
{
code
=
handleSubmitExecRes
(
pRequest
,
pRes
->
res
,
pCatalog
,
&
epset
);
break
;
}
case
TDMT_VND_QUERY
:
{
code
=
handleQueryExecRes
(
pRequest
,
pRes
->
res
,
pCatalog
,
&
epset
);
break
;
}
default:
tscError
(
"invalid exec result for request type %d"
,
pRequest
->
type
);
return
TSDB_CODE_APP_ERROR
;
}
return
code
;
}
}
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
,
void
**
res
)
{
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
,
void
**
res
)
{
void
*
pRes
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
switch
(
pQuery
->
execMode
)
{
switch
(
pQuery
->
execMode
)
{
case
QUERY_EXEC_MODE_LOCAL
:
case
QUERY_EXEC_MODE_LOCAL
:
...
@@ -508,10 +536,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
...
@@ -508,10 +536,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
SArray
*
pNodeList
=
NULL
;
SArray
*
pNodeList
=
NULL
;
code
=
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
&
pNodeList
);
code
=
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
&
pNodeList
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
scheduleQuery
(
pRequest
,
pRequest
->
body
.
pDag
,
pNodeList
,
&
pRes
);
code
=
scheduleQuery
(
pRequest
,
pRequest
->
body
.
pDag
,
pNodeList
);
if
(
NULL
!=
pRes
)
{
code
=
validateSversion
(
pRequest
,
pRes
);
}
}
}
taosArrayDestroy
(
pNodeList
);
taosArrayDestroy
(
pNodeList
);
break
;
break
;
...
@@ -528,15 +553,15 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
...
@@ -528,15 +553,15 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
qDestroyQuery
(
pQuery
);
qDestroyQuery
(
pQuery
);
}
}
handleExecRes
(
pRequest
);
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
code
)
{
pRequest
->
code
=
terrno
;
pRequest
->
code
=
terrno
;
}
}
if
(
res
)
{
if
(
res
)
{
*
res
=
pRes
;
*
res
=
pRequest
->
body
.
resInfo
.
execRes
.
res
;
}
else
{
pRequest
->
body
.
resInfo
.
execRes
.
res
=
NULL
;
freeRequestRes
(
pRequest
,
pRes
);
pRes
=
NULL
;
}
}
return
pRequest
;
return
pRequest
;
...
@@ -898,7 +923,7 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
...
@@ -898,7 +923,7 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
int32_t
bytes
=
pResultInfo
->
fields
[
i
].
bytes
;
int32_t
bytes
=
pResultInfo
->
fields
[
i
].
bytes
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
if
(
IS_VAR_DATA_TYPE
(
type
))
{
if
(
pCol
->
offset
[
pResultInfo
->
current
]
!=
-
1
)
{
if
(
!
IS_VAR_NULL_TYPE
(
type
,
bytes
)
&&
pCol
->
offset
[
pResultInfo
->
current
]
!=
-
1
)
{
char
*
pStart
=
pResultInfo
->
pCol
[
i
].
offset
[
pResultInfo
->
current
]
+
pResultInfo
->
pCol
[
i
].
pData
;
char
*
pStart
=
pResultInfo
->
pCol
[
i
].
offset
[
pResultInfo
->
current
]
+
pResultInfo
->
pCol
[
i
].
pData
;
pResultInfo
->
length
[
i
]
=
varDataLen
(
pStart
);
pResultInfo
->
length
[
i
]
=
varDataLen
(
pStart
);
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
46772d32
...
@@ -223,10 +223,33 @@ int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -223,10 +223,33 @@ int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
return
code
;
return
code
;
}
}
int32_t
processAlterStbRsp
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
SRequestObj
*
pRequest
=
param
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
setErrno
(
pRequest
,
code
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
return
code
;
}
SMAlterStbRsp
alterRsp
=
{
0
};
SDecoder
coder
=
{
0
};
tDecoderInit
(
&
coder
,
pMsg
->
pData
,
pMsg
->
len
);
tDecodeSMAlterStbRsp
(
&
coder
,
&
alterRsp
);
tDecoderClear
(
&
coder
);
pRequest
->
body
.
resInfo
.
execRes
.
msgType
=
TDMT_MND_ALTER_STB
;
pRequest
->
body
.
resInfo
.
execRes
.
res
=
alterRsp
.
pMeta
;
tsem_post
(
&
pRequest
->
body
.
rspSem
);
return
code
;
}
void
initMsgHandleFp
()
{
void
initMsgHandleFp
()
{
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_CONNECT
)]
=
processConnectRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_CONNECT
)]
=
processConnectRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_CREATE_DB
)]
=
processCreateDbRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_CREATE_DB
)]
=
processCreateDbRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_USE_DB
)]
=
processUseDbRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_USE_DB
)]
=
processUseDbRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_CREATE_STB
)]
=
processCreateTableRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_CREATE_STB
)]
=
processCreateTableRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_DROP_DB
)]
=
processDropDbRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_DROP_DB
)]
=
processDropDbRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_ALTER_STB
)]
=
processAlterStbRsp
;
}
}
source/client/src/clientSml.c
浏览文件 @
46772d32
...
@@ -1124,7 +1124,7 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char* sql, SSmlTable
...
@@ -1124,7 +1124,7 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char* sql, SSmlTable
}
}
static
int32_t
smlParseCols
(
const
char
*
data
,
int32_t
len
,
SArray
*
cols
,
char
*
childTableName
,
bool
isTag
,
SHashObj
*
dumplicateKey
,
SSmlMsgBuf
*
msg
){
static
int32_t
smlParseCols
(
const
char
*
data
,
int32_t
len
,
SArray
*
cols
,
char
*
childTableName
,
bool
isTag
,
SHashObj
*
dumplicateKey
,
SSmlMsgBuf
*
msg
){
if
(
isTag
&&
len
==
0
){
if
(
len
==
0
){
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2318,6 +2318,28 @@ cleanup:
...
@@ -2318,6 +2318,28 @@ cleanup:
return
code
;
return
code
;
}
}
static
int32_t
isSchemalessDb
(
SSmlHandle
*
info
){
SName
name
;
tNameSetDbName
(
&
name
,
info
->
taos
->
acctId
,
info
->
taos
->
db
,
strlen
(
info
->
taos
->
db
));
char
dbFname
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
dbFname
);
SDbCfgInfo
pInfo
=
{
0
};
SEpSet
ep
=
getEpSet_s
(
&
info
->
taos
->
pAppInfo
->
mgmtEp
);
int32_t
code
=
catalogGetDBCfg
(
info
->
pCatalog
,
info
->
taos
->
pAppInfo
->
pTransporter
,
&
ep
,
dbFname
,
&
pInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
info
->
pRequest
->
code
=
code
;
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"catalogGetDBCfg error, code:"
,
tstrerror
(
code
));
return
code
;
}
if
(
!
pInfo
.
schemaless
){
info
->
pRequest
->
code
=
TSDB_CODE_SML_INVALID_DB_CONF
;
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"can not insert into schemaless db:"
,
dbFname
);
return
TSDB_CODE_SML_INVALID_DB_CONF
;
}
return
TSDB_CODE_SUCCESS
;
}
/**
/**
* taos_schemaless_insert() parse and insert data points into database according to
* taos_schemaless_insert() parse and insert data points into database according to
* different protocol.
* different protocol.
...
@@ -2351,6 +2373,19 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
...
@@ -2351,6 +2373,19 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
return
(
TAOS_RES
*
)
request
;
return
(
TAOS_RES
*
)
request
;
}
}
info
->
taos
->
schemalessType
=
1
;
if
(
request
->
pDb
==
NULL
){
request
->
code
=
TSDB_CODE_PAR_DB_NOT_SPECIFIED
;
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"Database not specified"
,
NULL
);
goto
end
;
}
if
(
isSchemalessDb
(
info
)
!=
TSDB_CODE_SUCCESS
){
request
->
code
=
TSDB_CODE_SML_INVALID_DB_CONF
;
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"Cannot write data to a non schemaless database"
,
NULL
);
goto
end
;
}
if
(
!
lines
)
{
if
(
!
lines
)
{
request
->
code
=
TSDB_CODE_SML_INVALID_DATA
;
request
->
code
=
TSDB_CODE_SML_INVALID_DATA
;
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"lines is null"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"lines is null"
,
NULL
);
...
@@ -2372,6 +2407,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
...
@@ -2372,6 +2407,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
info
->
pRequest
->
code
=
smlProcess
(
info
,
lines
,
numLines
);
info
->
pRequest
->
code
=
smlProcess
(
info
,
lines
,
numLines
);
end:
end:
uDebug
(
"result:%s"
,
info
->
msgBuf
.
buf
);
smlDestroyInfo
(
info
);
smlDestroyInfo
(
info
);
return
(
TAOS_RES
*
)
request
;
return
(
TAOS_RES
*
)
request
;
}
}
...
...
source/client/src/tmq.c
浏览文件 @
46772d32
...
@@ -143,6 +143,7 @@ typedef struct {
...
@@ -143,6 +143,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
// subscribe info
// subscribe info
char
*
topicName
;
char
*
topicName
;
char
db
[
TSDB_DB_FNAME_LEN
];
SArray
*
vgs
;
// SArray<SMqClientVg>
SArray
*
vgs
;
// SArray<SMqClientVg>
...
@@ -1039,6 +1040,7 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
...
@@ -1039,6 +1040,7 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
topic
.
schema
=
pTopicEp
->
schema
;
topic
.
schema
=
pTopicEp
->
schema
;
taosHashClear
(
pHash
);
taosHashClear
(
pHash
);
topic
.
topicName
=
strdup
(
pTopicEp
->
topic
);
topic
.
topicName
=
strdup
(
pTopicEp
->
topic
);
tstrncpy
(
topic
.
db
,
pTopicEp
->
db
,
TSDB_DB_FNAME_LEN
);
tscDebug
(
"consumer %ld update topic: %s"
,
tmq
->
consumerId
,
topic
.
topicName
);
tscDebug
(
"consumer %ld update topic: %s"
,
tmq
->
consumerId
,
topic
.
topicName
);
int32_t
topicNumCur
=
taosArrayGetSize
(
tmq
->
clientTopics
);
int32_t
topicNumCur
=
taosArrayGetSize
(
tmq
->
clientTopics
);
...
@@ -1283,7 +1285,8 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t timeout, SMqClientTopic*
...
@@ -1283,7 +1285,8 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t timeout, SMqClientTopic*
SMqRspObj
*
tmqBuildRspFromWrapper
(
SMqPollRspWrapper
*
pWrapper
)
{
SMqRspObj
*
tmqBuildRspFromWrapper
(
SMqPollRspWrapper
*
pWrapper
)
{
SMqRspObj
*
pRspObj
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqRspObj
));
SMqRspObj
*
pRspObj
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqRspObj
));
pRspObj
->
resType
=
RES_TYPE__TMQ
;
pRspObj
->
resType
=
RES_TYPE__TMQ
;
strncpy
(
pRspObj
->
topic
,
pWrapper
->
topicHandle
->
topicName
,
TSDB_TOPIC_FNAME_LEN
);
tstrncpy
(
pRspObj
->
topic
,
pWrapper
->
topicHandle
->
topicName
,
TSDB_TOPIC_FNAME_LEN
);
tstrncpy
(
pRspObj
->
db
,
pWrapper
->
topicHandle
->
db
,
TSDB_DB_FNAME_LEN
);
pRspObj
->
vgId
=
pWrapper
->
vgHandle
->
vgId
;
pRspObj
->
vgId
=
pWrapper
->
vgHandle
->
vgId
;
pRspObj
->
resIter
=
-
1
;
pRspObj
->
resIter
=
-
1
;
memcpy
(
&
pRspObj
->
rsp
,
&
pWrapper
->
msg
,
sizeof
(
SMqDataBlkRsp
));
memcpy
(
&
pRspObj
->
rsp
,
&
pWrapper
->
msg
,
sizeof
(
SMqDataBlkRsp
));
...
@@ -1506,6 +1509,15 @@ const char* tmq_get_topic_name(TAOS_RES* res) {
...
@@ -1506,6 +1509,15 @@ const char* tmq_get_topic_name(TAOS_RES* res) {
}
}
}
}
const
char
*
tmq_get_db_name
(
TAOS_RES
*
res
)
{
if
(
TD_RES_TMQ
(
res
))
{
SMqRspObj
*
pRspObj
=
(
SMqRspObj
*
)
res
;
return
strchr
(
pRspObj
->
db
,
'.'
)
+
1
;
}
else
{
return
NULL
;
}
}
int32_t
tmq_get_vgroup_id
(
TAOS_RES
*
res
)
{
int32_t
tmq_get_vgroup_id
(
TAOS_RES
*
res
)
{
if
(
TD_RES_TMQ
(
res
))
{
if
(
TD_RES_TMQ
(
res
))
{
SMqRspObj
*
pRspObj
=
(
SMqRspObj
*
)
res
;
SMqRspObj
*
pRspObj
=
(
SMqRspObj
*
)
res
;
...
...
source/client/test/clientTests.cpp
浏览文件 @
46772d32
...
@@ -567,6 +567,7 @@ TEST(testCase, insert_test) {
...
@@ -567,6 +567,7 @@ TEST(testCase, insert_test) {
taos_free_result(pRes);
taos_free_result(pRes);
taos_close(pConn);
taos_close(pConn);
}
}
#endif
TEST
(
testCase
,
projection_query_tables
)
{
TEST
(
testCase
,
projection_query_tables
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
@@ -625,23 +626,23 @@ TEST(testCase, projection_query_tables) {
...
@@ -625,23 +626,23 @@ TEST(testCase, projection_query_tables) {
printf
(
"start to insert next table
\n
"
);
printf
(
"start to insert next table
\n
"
);
for(int32_t i = 0; i < 1000000; i += 20) {
//
for(int32_t i = 0; i < 1000000; i += 20) {
char sql[1024] = {0};
//
char sql[1024] = {0};
sprintf(sql,
//
sprintf(sql,
"insert into tu2 values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
//
"insert into tu2 values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
//
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
//
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)",
//
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)",
i, i, i + 1, i + 1, i + 2, i + 2, i + 3, i + 3, i + 4, i + 4, i + 5, i + 5, i + 6, i + 6, i + 7, i + 7,
//
i, i, i + 1, i + 1, i + 2, i + 2, i + 3, i + 3, i + 4, i + 4, i + 5, i + 5, i + 6, i + 6, i + 7, i + 7,
i + 8, i + 8, i + 9, i + 9, i + 10, i + 10, i + 11, i + 11, i + 12, i + 12, i + 13, i + 13, i + 14, i + 14,
//
i + 8, i + 8, i + 9, i + 9, i + 10, i + 10, i + 11, i + 11, i + 12, i + 12, i + 13, i + 13, i + 14, i + 14,
i + 15, i + 15, i + 16, i + 16, i + 17, i + 17, i + 18, i + 18, i + 19, i + 19);
//
i + 15, i + 15, i + 16, i + 16, i + 17, i + 17, i + 18, i + 18, i + 19, i + 19);
TAOS_RES* p = taos_query(pConn, sql);
//
TAOS_RES* p = taos_query(pConn, sql);
if (taos_errno(p) != 0) {
//
if (taos_errno(p) != 0) {
printf("failed to insert data, reason:%s\n", taos_errstr(p));
//
printf("failed to insert data, reason:%s\n", taos_errstr(p));
}
//
}
//
taos_free_result(p);
//
taos_free_result(p);
}
//
}
// pRes = taos_query(pConn, "select * from tu");
// pRes = taos_query(pConn, "select * from tu");
// if (taos_errno(pRes) != 0) {
// if (taos_errno(pRes) != 0) {
...
@@ -663,7 +664,7 @@ TEST(testCase, projection_query_tables) {
...
@@ -663,7 +664,7 @@ TEST(testCase, projection_query_tables) {
// taos_free_result(pRes);
// taos_free_result(pRes);
taos_close
(
pConn
);
taos_close
(
pConn
);
}
}
#if 0
TEST(testCase, projection_query_stables) {
TEST(testCase, projection_query_stables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
ASSERT_NE(pConn, nullptr);
ASSERT_NE(pConn, nullptr);
...
@@ -692,8 +693,6 @@ TEST(testCase, projection_query_stables) {
...
@@ -692,8 +693,6 @@ TEST(testCase, projection_query_stables) {
taos_close(pConn);
taos_close(pConn);
}
}
#endif
TEST(testCase, agg_query_tables) {
TEST(testCase, agg_query_tables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
ASSERT_NE(pConn, nullptr);
ASSERT_NE(pConn, nullptr);
...
@@ -734,5 +733,6 @@ TEST(testCase, agg_query_tables) {
...
@@ -734,5 +733,6 @@ TEST(testCase, agg_query_tables) {
taos_free_result(pRes);
taos_free_result(pRes);
taos_close(pConn);
taos_close(pConn);
}
}
#endif
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
source/client/test/smlTest.cpp
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/common/src/systable.c
浏览文件 @
46772d32
...
@@ -91,6 +91,8 @@ static const SSysDbTableSchema userDBSchema[] = {
...
@@ -91,6 +91,8 @@ static const SSysDbTableSchema userDBSchema[] = {
{.
name
=
"precision"
,
.
bytes
=
2
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"precision"
,
.
bytes
=
2
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"single_stable"
,
.
bytes
=
1
,
.
type
=
TSDB_DATA_TYPE_TINYINT
},
{.
name
=
"single_stable"
,
.
bytes
=
1
,
.
type
=
TSDB_DATA_TYPE_TINYINT
},
{.
name
=
"status"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"status"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"schemaless"
,
.
bytes
=
1
,
.
type
=
TSDB_DATA_TYPE_TINYINT
},
// {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update
// {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update
};
};
...
...
source/common/src/tdatablock.c
浏览文件 @
46772d32
...
@@ -355,14 +355,19 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex)
...
@@ -355,14 +355,19 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex)
return
-
1
;
return
-
1
;
}
}
int32_t
index
=
(
tsColumnIndex
==
-
1
)
?
0
:
tsColumnIndex
;
int32_t
index
=
(
tsColumnIndex
==
-
1
)
?
0
:
tsColumnIndex
;
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
index
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
index
);
if
(
pColInfoData
->
info
.
type
!=
TSDB_DATA_TYPE_TIMESTAMP
)
{
if
(
pColInfoData
->
info
.
type
!=
TSDB_DATA_TYPE_TIMESTAMP
)
{
return
0
;
return
0
;
}
}
pDataBlock
->
info
.
window
.
skey
=
*
(
TSKEY
*
)
colDataGetData
(
pColInfoData
,
0
);
TSKEY
skey
=
*
(
TSKEY
*
)
colDataGetData
(
pColInfoData
,
0
);
pDataBlock
->
info
.
window
.
ekey
=
*
(
TSKEY
*
)
colDataGetData
(
pColInfoData
,
(
pDataBlock
->
info
.
rows
-
1
));
TSKEY
ekey
=
*
(
TSKEY
*
)
colDataGetData
(
pColInfoData
,
(
pDataBlock
->
info
.
rows
-
1
));
pDataBlock
->
info
.
window
.
skey
=
TMIN
(
skey
,
ekey
);
pDataBlock
->
info
.
window
.
ekey
=
TMAX
(
skey
,
ekey
);
return
0
;
return
0
;
}
}
...
@@ -1273,25 +1278,39 @@ static void doShiftBitmap(char* nullBitmap, size_t n, size_t total) {
...
@@ -1273,25 +1278,39 @@ static void doShiftBitmap(char* nullBitmap, size_t n, size_t total) {
memmove
(
nullBitmap
,
nullBitmap
+
n
/
8
,
newLen
);
memmove
(
nullBitmap
,
nullBitmap
+
n
/
8
,
newLen
);
}
else
{
}
else
{
int32_t
tail
=
n
%
8
;
int32_t
tail
=
n
%
8
;
int32_t
i
=
0
;
int32_t
i
=
0
;
uint8_t
*
p
=
(
uint8_t
*
)
nullBitmap
;
uint8_t
*
p
=
(
uint8_t
*
)
nullBitmap
;
while
(
i
<
len
)
{
uint8_t
v
=
p
[
i
];
p
[
i
]
=
0
;
if
(
n
<
8
)
{
p
[
i
]
=
(
v
<<
tail
);
while
(
i
<
len
)
{
uint8_t
v
=
p
[
i
];
// source bitmap value
p
[
i
]
=
(
v
<<
tail
);
if
(
i
<
len
-
1
)
{
uint8_t
next
=
p
[
i
+
1
];
p
[
i
]
|=
(
next
>>
(
8
-
tail
));
}
if
(
i
<
len
-
1
)
{
i
+=
1
;
uint8_t
next
=
p
[
i
+
1
];
p
[
i
]
|=
(
next
>>
(
8
-
tail
));
}
}
}
else
if
(
n
>
8
)
{
int32_t
gap
=
len
-
newLen
;
while
(
i
<
newLen
)
{
uint8_t
v
=
p
[
i
+
gap
];
p
[
i
]
=
(
v
<<
tail
);
if
(
i
<
newLen
-
1
)
{
uint8_t
next
=
p
[
i
+
gap
+
1
];
p
[
i
]
|=
(
next
>>
(
8
-
tail
));
}
i
+=
1
;
i
+=
1
;
}
}
}
}
}
}
}
static
void
colDataTrimFirstNRows
(
SColumnInfoData
*
pColInfoData
,
size_t
n
,
size_t
total
)
{
static
void
colDataTrimFirstNRows
(
SColumnInfoData
*
pColInfoData
,
size_t
n
,
size_t
total
)
{
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
memmove
(
pColInfoData
->
varmeta
.
offset
,
&
pColInfoData
->
varmeta
.
offset
[
n
],
(
total
-
n
)
*
sizeof
(
int32_t
));
memmove
(
pColInfoData
->
varmeta
.
offset
,
&
pColInfoData
->
varmeta
.
offset
[
n
],
(
total
-
n
)
*
sizeof
(
int32_t
));
...
@@ -1803,3 +1822,99 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
...
@@ -1803,3 +1822,99 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
taosArrayDestroy
(
tagArray
);
taosArrayDestroy
(
tagArray
);
return
ret
;
return
ret
;
}
}
void
blockCompressEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
int8_t
needCompress
)
{
int32_t
*
actualLen
=
(
int32_t
*
)
data
;
data
+=
sizeof
(
int32_t
);
uint64_t
*
groupId
=
(
uint64_t
*
)
data
;
data
+=
sizeof
(
uint64_t
);
int32_t
*
colSizes
=
(
int32_t
*
)
data
;
data
+=
numOfCols
*
sizeof
(
int32_t
);
*
dataLen
=
(
numOfCols
*
sizeof
(
int32_t
)
+
sizeof
(
uint64_t
)
+
sizeof
(
int32_t
));
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
for
(
int32_t
col
=
0
;
col
<
numOfCols
;
++
col
)
{
SColumnInfoData
*
pColRes
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
col
);
// copy the null bitmap
if
(
IS_VAR_DATA_TYPE
(
pColRes
->
info
.
type
))
{
size_t
metaSize
=
numOfRows
*
sizeof
(
int32_t
);
memcpy
(
data
,
pColRes
->
varmeta
.
offset
,
metaSize
);
data
+=
metaSize
;
(
*
dataLen
)
+=
metaSize
;
}
else
{
int32_t
len
=
BitmapLen
(
numOfRows
);
memcpy
(
data
,
pColRes
->
nullbitmap
,
len
);
data
+=
len
;
(
*
dataLen
)
+=
len
;
}
if
(
needCompress
)
{
colSizes
[
col
]
=
blockCompressColData
(
pColRes
,
numOfRows
,
data
,
needCompress
);
data
+=
colSizes
[
col
];
(
*
dataLen
)
+=
colSizes
[
col
];
}
else
{
colSizes
[
col
]
=
colDataGetLength
(
pColRes
,
numOfRows
);
(
*
dataLen
)
+=
colSizes
[
col
];
memmove
(
data
,
pColRes
->
pData
,
colSizes
[
col
]);
data
+=
colSizes
[
col
];
}
colSizes
[
col
]
=
htonl
(
colSizes
[
col
]);
}
*
actualLen
=
*
dataLen
;
*
groupId
=
pBlock
->
info
.
groupId
;
}
const
char
*
blockCompressDecode
(
SSDataBlock
*
pBlock
,
int32_t
numOfCols
,
int32_t
numOfRows
,
const
char
*
pData
)
{
blockDataEnsureCapacity
(
pBlock
,
numOfRows
);
const
char
*
pStart
=
pData
;
int32_t
dataLen
=
*
(
int32_t
*
)
pStart
;
pStart
+=
sizeof
(
int32_t
);
pBlock
->
info
.
groupId
=
*
(
uint64_t
*
)
pStart
;
pStart
+=
sizeof
(
uint64_t
);
int32_t
*
colLen
=
(
int32_t
*
)
pStart
;
pStart
+=
sizeof
(
int32_t
)
*
numOfCols
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
colLen
[
i
]
=
htonl
(
colLen
[
i
]);
ASSERT
(
colLen
[
i
]
>=
0
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
pColInfoData
->
varmeta
.
length
=
colLen
[
i
];
pColInfoData
->
varmeta
.
allocLen
=
colLen
[
i
];
memcpy
(
pColInfoData
->
varmeta
.
offset
,
pStart
,
sizeof
(
int32_t
)
*
numOfRows
);
pStart
+=
sizeof
(
int32_t
)
*
numOfRows
;
if
(
colLen
[
i
]
>
0
)
{
taosMemoryFreeClear
(
pColInfoData
->
pData
);
pColInfoData
->
pData
=
taosMemoryMalloc
(
colLen
[
i
]);
}
}
else
{
memcpy
(
pColInfoData
->
nullbitmap
,
pStart
,
BitmapLen
(
numOfRows
));
pStart
+=
BitmapLen
(
numOfRows
);
}
if
(
colLen
[
i
]
>
0
)
{
memcpy
(
pColInfoData
->
pData
,
pStart
,
colLen
[
i
]);
}
// TODO
// setting this flag to true temporarily so aggregate function on stable will
// examine NULL value for non-primary key column
pColInfoData
->
hasNull
=
true
;
pStart
+=
colLen
[
i
];
}
ASSERT
(
pStart
-
pData
==
dataLen
);
return
pStart
;
}
\ No newline at end of file
source/common/src/tdataformat.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/common/src/tglobal.c
浏览文件 @
46772d32
...
@@ -109,8 +109,11 @@ int32_t tsCompressColData = -1;
...
@@ -109,8 +109,11 @@ int32_t tsCompressColData = -1;
*/
*/
int32_t
tsCompatibleModel
=
1
;
int32_t
tsCompatibleModel
=
1
;
// count/hyperloglog function always return values in case of all NULL data or Empty data set.
int32_t
tsCountAlwaysReturnValue
=
1
;
// 10 ms for sliding time, the value will changed in case of time precision changed
// 10 ms for sliding time, the value will changed in case of time precision changed
int32_t
tsMinSlidingTime
=
10
;
int32_t
tsMinSlidingTime
=
10
;
// the maxinum number of distict query result
// the maxinum number of distict query result
int32_t
tsMaxNumOfDistinctResults
=
1000
*
10000
;
int32_t
tsMaxNumOfDistinctResults
=
1000
*
10000
;
...
@@ -130,7 +133,6 @@ int32_t tsRetryStreamCompDelay = 10 * 1000;
...
@@ -130,7 +133,6 @@ int32_t tsRetryStreamCompDelay = 10 * 1000;
// The delayed computing ration. 10% of the whole computing time window by default.
// The delayed computing ration. 10% of the whole computing time window by default.
float
tsStreamComputDelayRatio
=
0
.
1
f
;
float
tsStreamComputDelayRatio
=
0
.
1
f
;
int32_t
tsProjectExecInterval
=
10000
;
// every 10sec, the projection will be executed once
int64_t
tsMaxRetentWindow
=
24
*
3600L
;
// maximum time window tolerance
int64_t
tsMaxRetentWindow
=
24
*
3600L
;
// maximum time window tolerance
// the maximum allowed query buffer size during query processing for each data node.
// the maximum allowed query buffer size during query processing for each data node.
...
@@ -374,6 +376,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
...
@@ -374,6 +376,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
if
(
cfgAddInt32
(
pCfg
,
"minSlidingTime"
,
tsMinSlidingTime
,
10
,
1000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"minSlidingTime"
,
tsMinSlidingTime
,
10
,
1000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"minIntervalTime"
,
tsMinIntervalTime
,
1
,
1000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"minIntervalTime"
,
tsMinIntervalTime
,
1
,
1000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxNumOfDistinctRes"
,
tsMaxNumOfDistinctResults
,
10
*
10000
,
10000
*
10000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxNumOfDistinctRes"
,
tsMaxNumOfDistinctResults
,
10
*
10000
,
10000
*
10000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"countAlwaysReturnValue"
,
tsCountAlwaysReturnValue
,
0
,
1
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxStreamCompDelay"
,
tsMaxStreamComputDelay
,
10
,
1000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxStreamCompDelay"
,
tsMaxStreamComputDelay
,
10
,
1000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxFirstStreamCompDelay"
,
tsStreamCompStartDelay
,
1000
,
1000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxFirstStreamCompDelay"
,
tsStreamCompStartDelay
,
1000
,
1000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"retryStreamCompDelay"
,
tsRetryStreamCompDelay
,
10
,
1000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"retryStreamCompDelay"
,
tsRetryStreamCompDelay
,
10
,
1000000000
,
0
)
!=
0
)
return
-
1
;
...
@@ -567,6 +570,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
...
@@ -567,6 +570,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
tsMinSlidingTime
=
cfgGetItem
(
pCfg
,
"minSlidingTime"
)
->
i32
;
tsMinSlidingTime
=
cfgGetItem
(
pCfg
,
"minSlidingTime"
)
->
i32
;
tsMinIntervalTime
=
cfgGetItem
(
pCfg
,
"minIntervalTime"
)
->
i32
;
tsMinIntervalTime
=
cfgGetItem
(
pCfg
,
"minIntervalTime"
)
->
i32
;
tsMaxNumOfDistinctResults
=
cfgGetItem
(
pCfg
,
"maxNumOfDistinctRes"
)
->
i32
;
tsMaxNumOfDistinctResults
=
cfgGetItem
(
pCfg
,
"maxNumOfDistinctRes"
)
->
i32
;
tsCountAlwaysReturnValue
=
cfgGetItem
(
pCfg
,
"countAlwaysReturnValue"
)
->
i32
;
tsMaxStreamComputDelay
=
cfgGetItem
(
pCfg
,
"maxStreamCompDelay"
)
->
i32
;
tsMaxStreamComputDelay
=
cfgGetItem
(
pCfg
,
"maxStreamCompDelay"
)
->
i32
;
tsStreamCompStartDelay
=
cfgGetItem
(
pCfg
,
"maxFirstStreamCompDelay"
)
->
i32
;
tsStreamCompStartDelay
=
cfgGetItem
(
pCfg
,
"maxFirstStreamCompDelay"
)
->
i32
;
tsRetryStreamCompDelay
=
cfgGetItem
(
pCfg
,
"retryStreamCompDelay"
)
->
i32
;
tsRetryStreamCompDelay
=
cfgGetItem
(
pCfg
,
"retryStreamCompDelay"
)
->
i32
;
...
...
source/common/src/tmsg.c
浏览文件 @
46772d32
...
@@ -693,6 +693,7 @@ void tFreeSMAltertbReq(SMAlterStbReq *pReq) {
...
@@ -693,6 +693,7 @@ void tFreeSMAltertbReq(SMAlterStbReq *pReq) {
pReq
->
pFields
=
NULL
;
pReq
->
pFields
=
NULL
;
}
}
int32_t
tSerializeSEpSet
(
void
*
buf
,
int32_t
bufLen
,
const
SEpSet
*
pEpset
)
{
int32_t
tSerializeSEpSet
(
void
*
buf
,
int32_t
bufLen
,
const
SEpSet
*
pEpset
)
{
SEncoder
encoder
=
{
0
};
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
...
@@ -2277,6 +2278,7 @@ int32_t tSerializeSDbCfgRsp(void *buf, int32_t bufLen, const SDbCfgRsp *pRsp) {
...
@@ -2277,6 +2278,7 @@ int32_t tSerializeSDbCfgRsp(void *buf, int32_t bufLen, const SDbCfgRsp *pRsp) {
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
freqUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
freqUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
keepUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
keepUnit
)
<
0
)
return
-
1
;
}
}
if
(
tEncodeI8
(
&
encoder
,
pRsp
->
schemaless
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -2325,6 +2327,7 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) {
...
@@ -2325,6 +2327,7 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) {
return
-
1
;
return
-
1
;
}
}
}
}
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
schemaless
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
@@ -4347,13 +4350,96 @@ int32_t tDecodeSVAlterTbReq(SDecoder *pDecoder, SVAlterTbReq *pReq) {
...
@@ -4347,13 +4350,96 @@ int32_t tDecodeSVAlterTbReq(SDecoder *pDecoder, SVAlterTbReq *pReq) {
int32_t
tEncodeSVAlterTbRsp
(
SEncoder
*
pEncoder
,
const
SVAlterTbRsp
*
pRsp
)
{
int32_t
tEncodeSVAlterTbRsp
(
SEncoder
*
pEncoder
,
const
SVAlterTbRsp
*
pRsp
)
{
if
(
tStartEncode
(
pEncoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
pEncoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
code
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
code
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
pMeta
?
1
:
0
)
<
0
)
return
-
1
;
if
(
pRsp
->
pMeta
)
{
if
(
tEncodeSTableMetaRsp
(
pEncoder
,
pRsp
->
pMeta
)
<
0
)
return
-
1
;
}
tEndEncode
(
pEncoder
);
tEndEncode
(
pEncoder
);
return
0
;
return
0
;
}
}
int32_t
tDecodeSVAlterTbRsp
(
SDecoder
*
pDecoder
,
SVAlterTbRsp
*
pRsp
)
{
int32_t
tDecodeSVAlterTbRsp
(
SDecoder
*
pDecoder
,
SVAlterTbRsp
*
pRsp
)
{
int32_t
meta
=
0
;
if
(
tStartDecode
(
pDecoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
pDecoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pRsp
->
code
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pRsp
->
code
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
meta
)
<
0
)
return
-
1
;
if
(
meta
)
{
pRsp
->
pMeta
=
taosMemoryCalloc
(
1
,
sizeof
(
STableMetaRsp
));
if
(
NULL
==
pRsp
->
pMeta
)
return
-
1
;
if
(
tDecodeSTableMetaRsp
(
pDecoder
,
pRsp
->
pMeta
)
<
0
)
return
-
1
;
}
tEndDecode
(
pDecoder
);
return
0
;
}
int32_t
tDeserializeSVAlterTbRsp
(
void
*
buf
,
int32_t
bufLen
,
SVAlterTbRsp
*
pRsp
)
{
int32_t
meta
=
0
;
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
code
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
meta
)
<
0
)
return
-
1
;
if
(
meta
)
{
pRsp
->
pMeta
=
taosMemoryCalloc
(
1
,
sizeof
(
STableMetaRsp
));
if
(
NULL
==
pRsp
->
pMeta
)
return
-
1
;
if
(
tDecodeSTableMetaRsp
(
&
decoder
,
pRsp
->
pMeta
)
<
0
)
return
-
1
;
}
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
int32_t
tEncodeSMAlterStbRsp
(
SEncoder
*
pEncoder
,
const
SMAlterStbRsp
*
pRsp
)
{
if
(
tStartEncode
(
pEncoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
pMeta
->
pSchemas
?
1
:
0
)
<
0
)
return
-
1
;
if
(
pRsp
->
pMeta
->
pSchemas
)
{
if
(
tEncodeSTableMetaRsp
(
pEncoder
,
pRsp
->
pMeta
)
<
0
)
return
-
1
;
}
tEndEncode
(
pEncoder
);
return
0
;
}
int32_t
tDecodeSMAlterStbRsp
(
SDecoder
*
pDecoder
,
SMAlterStbRsp
*
pRsp
)
{
int32_t
meta
=
0
;
if
(
tStartDecode
(
pDecoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
meta
)
<
0
)
return
-
1
;
if
(
meta
)
{
pRsp
->
pMeta
=
taosMemoryCalloc
(
1
,
sizeof
(
STableMetaRsp
));
if
(
NULL
==
pRsp
->
pMeta
)
return
-
1
;
if
(
tDecodeSTableMetaRsp
(
pDecoder
,
pRsp
->
pMeta
)
<
0
)
return
-
1
;
}
tEndDecode
(
pDecoder
);
tEndDecode
(
pDecoder
);
return
0
;
return
0
;
}
}
int32_t
tDeserializeSMAlterStbRsp
(
void
*
buf
,
int32_t
bufLen
,
SMAlterStbRsp
*
pRsp
)
{
int32_t
meta
=
0
;
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
meta
)
<
0
)
return
-
1
;
if
(
meta
)
{
pRsp
->
pMeta
=
taosMemoryCalloc
(
1
,
sizeof
(
STableMetaRsp
));
if
(
NULL
==
pRsp
->
pMeta
)
return
-
1
;
if
(
tDecodeSTableMetaRsp
(
&
decoder
,
pRsp
->
pMeta
)
<
0
)
return
-
1
;
}
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
void
tFreeSMAlterStbRsp
(
SMAlterStbRsp
*
pRsp
)
{
if
(
NULL
==
pRsp
)
{
return
;
}
if
(
pRsp
->
pMeta
)
{
taosMemoryFree
(
pRsp
->
pMeta
->
pSchemas
);
taosMemoryFree
(
pRsp
->
pMeta
);
}
}
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
46772d32
...
@@ -180,6 +180,24 @@ static void vmGenerateWrapperCfg(SVnodeMgmt *pMgmt, SCreateVnodeReq *pCreate, SW
...
@@ -180,6 +180,24 @@ static void vmGenerateWrapperCfg(SVnodeMgmt *pMgmt, SCreateVnodeReq *pCreate, SW
snprintf
(
pCfg
->
path
,
sizeof
(
pCfg
->
path
),
"%s%svnode%d"
,
pMgmt
->
path
,
TD_DIRSEP
,
pCreate
->
vgId
);
snprintf
(
pCfg
->
path
,
sizeof
(
pCfg
->
path
),
"%s%svnode%d"
,
pMgmt
->
path
,
TD_DIRSEP
,
pCreate
->
vgId
);
}
}
static
int32_t
vmTsmaAdjustDays
(
SVnodeCfg
*
pCfg
,
SCreateVnodeReq
*
pReq
)
{
if
(
pReq
->
isTsma
)
{
SMsgHead
*
smaMsg
=
pReq
->
pTsma
;
uint32_t
contLen
=
(
uint32_t
)(
htonl
(
smaMsg
->
contLen
)
-
sizeof
(
SMsgHead
));
return
smaGetTSmaDays
(
pCfg
,
POINTER_SHIFT
(
smaMsg
,
sizeof
(
SMsgHead
)),
contLen
,
&
pCfg
->
tsdbCfg
.
days
);
}
return
0
;
}
static
int32_t
vmTsmaProcessCreate
(
SVnode
*
pVnode
,
SCreateVnodeReq
*
pReq
)
{
if
(
pReq
->
isTsma
)
{
SMsgHead
*
smaMsg
=
pReq
->
pTsma
;
uint32_t
contLen
=
(
uint32_t
)(
htonl
(
smaMsg
->
contLen
)
-
sizeof
(
SMsgHead
));
return
vnodeProcessCreateTSma
(
pVnode
,
POINTER_SHIFT
(
smaMsg
,
sizeof
(
SMsgHead
)),
contLen
);
}
return
0
;
}
int32_t
vmProcessCreateVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
vmProcessCreateVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
SCreateVnodeReq
createReq
=
{
0
};
SCreateVnodeReq
createReq
=
{
0
};
SVnodeCfg
vnodeCfg
=
{
0
};
SVnodeCfg
vnodeCfg
=
{
0
};
...
@@ -195,6 +213,13 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -195,6 +213,13 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
dDebug
(
"vgId:%d, start to create vnode, tsma:%d standby:%d"
,
createReq
.
vgId
,
createReq
.
isTsma
,
dDebug
(
"vgId:%d, start to create vnode, tsma:%d standby:%d"
,
createReq
.
vgId
,
createReq
.
isTsma
,
createReq
.
standby
);
createReq
.
standby
);
vmGenerateVnodeCfg
(
&
createReq
,
&
vnodeCfg
);
vmGenerateVnodeCfg
(
&
createReq
,
&
vnodeCfg
);
if
(
vmTsmaAdjustDays
(
&
vnodeCfg
,
&
createReq
)
<
0
)
{
dError
(
"vgId:%d, failed to adjust tsma days since %s"
,
createReq
.
vgId
,
terrstr
());
code
=
terrno
;
goto
_OVER
;
}
vmGenerateWrapperCfg
(
pMgmt
,
&
createReq
,
&
wrapperCfg
);
vmGenerateWrapperCfg
(
pMgmt
,
&
createReq
,
&
wrapperCfg
);
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
createReq
.
vgId
);
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
createReq
.
vgId
);
...
@@ -203,14 +228,16 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -203,14 +228,16 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
tFreeSCreateVnodeReq
(
&
createReq
);
tFreeSCreateVnodeReq
(
&
createReq
);
vmReleaseVnode
(
pMgmt
,
pVnode
);
vmReleaseVnode
(
pMgmt
,
pVnode
);
terrno
=
TSDB_CODE_NODE_ALREADY_DEPLOYED
;
terrno
=
TSDB_CODE_NODE_ALREADY_DEPLOYED
;
return
-
1
;
code
=
terrno
;
goto
_OVER
;
}
}
snprintf
(
path
,
TSDB_FILENAME_LEN
,
"vnode%svnode%d"
,
TD_DIRSEP
,
vnodeCfg
.
vgId
);
snprintf
(
path
,
TSDB_FILENAME_LEN
,
"vnode%svnode%d"
,
TD_DIRSEP
,
vnodeCfg
.
vgId
);
if
(
vnodeCreate
(
path
,
&
vnodeCfg
,
pMgmt
->
pTfs
)
<
0
)
{
if
(
vnodeCreate
(
path
,
&
vnodeCfg
,
pMgmt
->
pTfs
)
<
0
)
{
tFreeSCreateVnodeReq
(
&
createReq
);
tFreeSCreateVnodeReq
(
&
createReq
);
dError
(
"vgId:%d, failed to create vnode since %s"
,
createReq
.
vgId
,
terrstr
());
dError
(
"vgId:%d, failed to create vnode since %s"
,
createReq
.
vgId
,
terrstr
());
return
-
1
;
code
=
terrno
;
goto
_OVER
;
}
}
SVnode
*
pImpl
=
vnodeOpen
(
path
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
SVnode
*
pImpl
=
vnodeOpen
(
path
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
...
@@ -227,14 +254,11 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -227,14 +254,11 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
goto
_OVER
;
goto
_OVER
;
}
}
if
(
createReq
.
isTsma
)
{
code
=
vmTsmaProcessCreate
(
pImpl
,
&
createReq
);
SMsgHead
*
smaMsg
=
createReq
.
pTsma
;
if
(
code
!=
0
)
{
uint32_t
contLen
=
(
uint32_t
)(
htonl
(
smaMsg
->
contLen
)
-
sizeof
(
SMsgHead
));
dError
(
"vgId:%d, failed to create tsma since %s"
,
createReq
.
vgId
,
terrstr
());
if
(
vnodeProcessCreateTSma
(
pImpl
,
POINTER_SHIFT
(
smaMsg
,
sizeof
(
SMsgHead
)),
contLen
)
<
0
)
{
code
=
terrno
;
dError
(
"vgId:%d, failed to create tsma since %s"
,
createReq
.
vgId
,
terrstr
());
goto
_OVER
;
code
=
terrno
;
goto
_OVER
;
};
}
}
code
=
vnodeStart
(
pImpl
);
code
=
vnodeStart
(
pImpl
);
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
46772d32
...
@@ -168,7 +168,7 @@ typedef struct {
...
@@ -168,7 +168,7 @@ typedef struct {
int64_t
createdTime
;
int64_t
createdTime
;
int64_t
updateTime
;
int64_t
updateTime
;
SDnodeObj
*
pDnode
;
SDnodeObj
*
pDnode
;
SQnodeLoad
load
;
SQnodeLoad
load
;
}
SQnodeObj
;
}
SQnodeObj
;
typedef
struct
{
typedef
struct
{
...
@@ -255,6 +255,7 @@ typedef struct {
...
@@ -255,6 +255,7 @@ typedef struct {
int8_t
hashMethod
;
// default is 1
int8_t
hashMethod
;
// default is 1
int32_t
numOfRetensions
;
int32_t
numOfRetensions
;
SArray
*
pRetensions
;
SArray
*
pRetensions
;
int8_t
schemaless
;
}
SDbCfg
;
}
SDbCfg
;
typedef
struct
{
typedef
struct
{
...
@@ -403,26 +404,22 @@ int32_t tEncodeSMqOffsetObj(void** buf, const SMqOffsetObj* pOffset);
...
@@ -403,26 +404,22 @@ int32_t tEncodeSMqOffsetObj(void** buf, const SMqOffsetObj* pOffset);
void
*
tDecodeSMqOffsetObj
(
void
*
buf
,
SMqOffsetObj
*
pOffset
);
void
*
tDecodeSMqOffsetObj
(
void
*
buf
,
SMqOffsetObj
*
pOffset
);
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
createTime
;
int64_t
createTime
;
int64_t
updateTime
;
int64_t
updateTime
;
int64_t
uid
;
int64_t
uid
;
int64_t
dbUid
;
int64_t
dbUid
;
int32_t
version
;
int32_t
version
;
int8_t
subType
;
// column, db or stable
int8_t
subType
;
// column, db or stable
// int8_t withTbName;
// int8_t withSchema;
// int8_t withTag;
SRWLatch
lock
;
SRWLatch
lock
;
int32_t
consumerCnt
;
int32_t
sqlLen
;
int32_t
sqlLen
;
int32_t
astLen
;
int32_t
astLen
;
char
*
sql
;
char
*
sql
;
char
*
ast
;
char
*
ast
;
char
*
physicalPlan
;
char
*
physicalPlan
;
SSchemaWrapper
schema
;
SSchemaWrapper
schema
;
// int32_t refConsumerCnt
;
int64_t
stbUid
;
}
SMqTopicObj
;
}
SMqTopicObj
;
typedef
struct
{
typedef
struct
{
...
@@ -476,14 +473,12 @@ int32_t tEncodeSMqConsumerEp(void** buf, const SMqConsumerEp* pEp);
...
@@ -476,14 +473,12 @@ int32_t tEncodeSMqConsumerEp(void** buf, const SMqConsumerEp* pEp);
void
*
tDecodeSMqConsumerEp
(
const
void
*
buf
,
SMqConsumerEp
*
pEp
);
void
*
tDecodeSMqConsumerEp
(
const
void
*
buf
,
SMqConsumerEp
*
pEp
);
typedef
struct
{
typedef
struct
{
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
];
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
];
SRWLatch
lock
;
SRWLatch
lock
;
int64_t
dbUid
;
int64_t
dbUid
;
int32_t
vgNum
;
int32_t
vgNum
;
int8_t
subType
;
int8_t
subType
;
// int8_t withTbName;
int64_t
stbUid
;
// int8_t withSchema;
// int8_t withTag;
SHashObj
*
consumerHash
;
// consumerId -> SMqConsumerEp
SHashObj
*
consumerHash
;
// consumerId -> SMqConsumerEp
SArray
*
unassignedVgs
;
// SArray<SMqVgEp*>
SArray
*
unassignedVgs
;
// SArray<SMqVgEp*>
}
SMqSubscribeObj
;
}
SMqSubscribeObj
;
...
@@ -535,7 +530,7 @@ typedef struct {
...
@@ -535,7 +530,7 @@ typedef struct {
}
SMqRebOutputObj
;
}
SMqRebOutputObj
;
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_
TOPIC
_FNAME_LEN
];
char
name
[
TSDB_
STREAM
_FNAME_LEN
];
char
sourceDb
[
TSDB_DB_FNAME_LEN
];
char
sourceDb
[
TSDB_DB_FNAME_LEN
];
char
targetDb
[
TSDB_DB_FNAME_LEN
];
char
targetDb
[
TSDB_DB_FNAME_LEN
];
char
targetSTbName
[
TSDB_TABLE_FNAME_LEN
];
char
targetSTbName
[
TSDB_TABLE_FNAME_LEN
];
...
...
source/dnode/mnode/impl/inc/mndTopic.h
浏览文件 @
46772d32
...
@@ -37,6 +37,8 @@ const char *mndTopicGetShowName(const char topic[TSDB_TOPIC_FNAME_LEN]);
...
@@ -37,6 +37,8 @@ const char *mndTopicGetShowName(const char topic[TSDB_TOPIC_FNAME_LEN]);
int32_t
mndSetTopicCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqTopicObj
*
pTopic
);
int32_t
mndSetTopicCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqTopicObj
*
pTopic
);
bool
mndCheckColAndTagModifiable
(
SMnode
*
pMnode
,
int64_t
suid
,
const
SArray
*
colIds
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
46772d32
...
@@ -306,6 +306,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
...
@@ -306,6 +306,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
topic
);
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
topic
);
ASSERT
(
pTopic
);
ASSERT
(
pTopic
);
taosRLockLatch
(
&
pTopic
->
lock
);
taosRLockLatch
(
&
pTopic
->
lock
);
tstrncpy
(
topicEp
.
db
,
pTopic
->
db
,
TSDB_DB_FNAME_LEN
);
topicEp
.
schema
.
nCols
=
pTopic
->
schema
.
nCols
;
topicEp
.
schema
.
nCols
=
pTopic
->
schema
.
nCols
;
if
(
topicEp
.
schema
.
nCols
)
{
if
(
topicEp
.
schema
.
nCols
)
{
topicEp
.
schema
.
pSchema
=
taosMemoryCalloc
(
topicEp
.
schema
.
nCols
,
sizeof
(
SSchema
));
topicEp
.
schema
.
pSchema
=
taosMemoryCalloc
(
topicEp
.
schema
.
nCols
,
sizeof
(
SSchema
));
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
46772d32
...
@@ -115,6 +115,7 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
...
@@ -115,6 +115,7 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
SDB_SET_INT8
(
pRaw
,
dataPos
,
pRetension
->
freqUnit
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pRetension
->
freqUnit
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pRetension
->
keepUnit
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pRetension
->
keepUnit
,
_OVER
)
}
}
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
schemaless
,
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
DB_RESERVE_SIZE
,
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
DB_RESERVE_SIZE
,
_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
_OVER
)
...
@@ -192,6 +193,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
...
@@ -192,6 +193,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
}
}
}
}
}
}
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
schemaless
,
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
DB_RESERVE_SIZE
,
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
DB_RESERVE_SIZE
,
_OVER
)
taosInitRWLatch
(
&
pDb
->
lock
);
taosInitRWLatch
(
&
pDb
->
lock
);
...
@@ -380,6 +382,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
...
@@ -380,6 +382,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
if
(
pCfg
->
replications
<
TSDB_MIN_DB_REPLICA
||
pCfg
->
replications
>
TSDB_MAX_DB_REPLICA
)
return
-
1
;
if
(
pCfg
->
replications
<
TSDB_MIN_DB_REPLICA
||
pCfg
->
replications
>
TSDB_MAX_DB_REPLICA
)
return
-
1
;
if
(
pCfg
->
replications
!=
1
&&
pCfg
->
replications
!=
3
)
return
-
1
;
if
(
pCfg
->
replications
!=
1
&&
pCfg
->
replications
!=
3
)
return
-
1
;
if
(
pCfg
->
strict
<
TSDB_DB_STRICT_OFF
||
pCfg
->
strict
>
TSDB_DB_STRICT_ON
)
return
-
1
;
if
(
pCfg
->
strict
<
TSDB_DB_STRICT_OFF
||
pCfg
->
strict
>
TSDB_DB_STRICT_ON
)
return
-
1
;
if
(
pCfg
->
schemaless
<
TSDB_DB_SCHEMALESS_OFF
||
pCfg
->
schemaless
>
TSDB_DB_SCHEMALESS_ON
)
return
-
1
;
if
(
pCfg
->
cacheLastRow
<
TSDB_MIN_DB_CACHE_LAST_ROW
||
pCfg
->
cacheLastRow
>
TSDB_MAX_DB_CACHE_LAST_ROW
)
return
-
1
;
if
(
pCfg
->
cacheLastRow
<
TSDB_MIN_DB_CACHE_LAST_ROW
||
pCfg
->
cacheLastRow
>
TSDB_MAX_DB_CACHE_LAST_ROW
)
return
-
1
;
if
(
pCfg
->
hashMethod
!=
1
)
return
-
1
;
if
(
pCfg
->
hashMethod
!=
1
)
return
-
1
;
if
(
pCfg
->
replications
>
mndGetDnodeSize
(
pMnode
))
{
if
(
pCfg
->
replications
>
mndGetDnodeSize
(
pMnode
))
{
...
@@ -411,6 +414,8 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
...
@@ -411,6 +414,8 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
if
(
pCfg
->
strict
<
0
)
pCfg
->
strict
=
TSDB_DEFAULT_DB_STRICT
;
if
(
pCfg
->
strict
<
0
)
pCfg
->
strict
=
TSDB_DEFAULT_DB_STRICT
;
if
(
pCfg
->
cacheLastRow
<
0
)
pCfg
->
cacheLastRow
=
TSDB_DEFAULT_CACHE_LAST_ROW
;
if
(
pCfg
->
cacheLastRow
<
0
)
pCfg
->
cacheLastRow
=
TSDB_DEFAULT_CACHE_LAST_ROW
;
if
(
pCfg
->
numOfRetensions
<
0
)
pCfg
->
numOfRetensions
=
0
;
if
(
pCfg
->
numOfRetensions
<
0
)
pCfg
->
numOfRetensions
=
0
;
if
(
pCfg
->
schemaless
<
0
)
pCfg
->
schemaless
=
TSDB_DB_SCHEMALESS_OFF
;
}
}
static
int32_t
mndSetCreateDbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroups
)
{
static
int32_t
mndSetCreateDbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroups
)
{
...
@@ -521,6 +526,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
...
@@ -521,6 +526,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
.
strict
=
pCreate
->
strict
,
.
strict
=
pCreate
->
strict
,
.
cacheLastRow
=
pCreate
->
cacheLastRow
,
.
cacheLastRow
=
pCreate
->
cacheLastRow
,
.
hashMethod
=
1
,
.
hashMethod
=
1
,
.
schemaless
=
pCreate
->
schemaless
,
};
};
dbObj
.
cfg
.
numOfRetensions
=
pCreate
->
numOfRetensions
;
dbObj
.
cfg
.
numOfRetensions
=
pCreate
->
numOfRetensions
;
...
@@ -899,6 +905,7 @@ static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq) {
...
@@ -899,6 +905,7 @@ static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq) {
cfgRsp
.
cacheLastRow
=
pDb
->
cfg
.
cacheLastRow
;
cfgRsp
.
cacheLastRow
=
pDb
->
cfg
.
cacheLastRow
;
cfgRsp
.
numOfRetensions
=
pDb
->
cfg
.
numOfRetensions
;
cfgRsp
.
numOfRetensions
=
pDb
->
cfg
.
numOfRetensions
;
cfgRsp
.
pRetensions
=
pDb
->
cfg
.
pRetensions
;
cfgRsp
.
pRetensions
=
pDb
->
cfg
.
pRetensions
;
cfgRsp
.
schemaless
=
pDb
->
cfg
.
schemaless
;
int32_t
contLen
=
tSerializeSDbCfgRsp
(
NULL
,
0
,
&
cfgRsp
);
int32_t
contLen
=
tSerializeSDbCfgRsp
(
NULL
,
0
,
&
cfgRsp
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
...
@@ -1542,8 +1549,11 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
...
@@ -1542,8 +1549,11 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
rows
,
(
const
char
*
)
&
pDb
->
cfg
.
numOfStables
,
false
);
colDataAppend
(
pColInfo
,
rows
,
(
const
char
*
)
&
pDb
->
cfg
.
numOfStables
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
rows
,
(
const
char
*
)
statusB
,
false
);
colDataAppend
(
pColInfo
,
rows
,
(
const
char
*
)
statusB
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
colDataAppend
(
pColInfo
,
rows
,
(
const
char
*
)
&
pDb
->
cfg
.
schemaless
,
false
);
}
}
}
}
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
46772d32
...
@@ -395,10 +395,8 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
...
@@ -395,10 +395,8 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
taosInitRWLatch
(
&
pSubNew
->
lock
);
taosInitRWLatch
(
&
pSubNew
->
lock
);
pSubNew
->
dbUid
=
pSub
->
dbUid
;
pSubNew
->
dbUid
=
pSub
->
dbUid
;
pSubNew
->
stbUid
=
pSub
->
stbUid
;
pSubNew
->
subType
=
pSub
->
subType
;
pSubNew
->
subType
=
pSub
->
subType
;
/*pSubNew->withTbName = pSub->withTbName;*/
/*pSubNew->withSchema = pSub->withSchema;*/
/*pSubNew->withTag = pSub->withTag;*/
pSubNew
->
vgNum
=
pSub
->
vgNum
;
pSubNew
->
vgNum
=
pSub
->
vgNum
;
pSubNew
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
pSubNew
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
...
@@ -431,9 +429,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
...
@@ -431,9 +429,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
tlen
+=
taosEncodeFixedI64
(
buf
,
pSub
->
dbUid
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pSub
->
dbUid
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSub
->
vgNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSub
->
vgNum
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
subType
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
subType
);
/*tlen += taosEncodeFixedI8(buf, pSub->withTbName);*/
tlen
+=
taosEncodeFixedI64
(
buf
,
pSub
->
stbUid
);
/*tlen += taosEncodeFixedI8(buf, pSub->withSchema);*/
/*tlen += taosEncodeFixedI8(buf, pSub->withTag);*/
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
sz
=
taosHashGetSize
(
pSub
->
consumerHash
);
int32_t
sz
=
taosHashGetSize
(
pSub
->
consumerHash
);
...
@@ -458,9 +454,7 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
...
@@ -458,9 +454,7 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
buf
=
taosDecodeFixedI64
(
buf
,
&
pSub
->
dbUid
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pSub
->
dbUid
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSub
->
vgNum
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSub
->
vgNum
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
subType
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
subType
);
/*buf = taosDecodeFixedI8(buf, &pSub->withTbName);*/
buf
=
taosDecodeFixedI64
(
buf
,
&
pSub
->
stbUid
);
/*buf = taosDecodeFixedI8(buf, &pSub->withSchema);*/
/*buf = taosDecodeFixedI8(buf, &pSub->withTag);*/
int32_t
sz
;
int32_t
sz
;
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
46772d32
...
@@ -1207,13 +1207,125 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
...
@@ -1207,13 +1207,125 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
return
0
;
return
0
;
}
}
static
int32_t
mndBuildStbSchemaImp
(
SDbObj
*
pDb
,
SStbObj
*
pStb
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
)
{
taosRLockLatch
(
&
pStb
->
lock
);
int32_t
totalCols
=
pStb
->
numOfColumns
+
pStb
->
numOfTags
;
pRsp
->
pSchemas
=
taosMemoryCalloc
(
totalCols
,
sizeof
(
SSchema
));
if
(
pRsp
->
pSchemas
==
NULL
)
{
taosRUnLockLatch
(
&
pStb
->
lock
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
strcpy
(
pRsp
->
dbFName
,
pStb
->
db
);
strcpy
(
pRsp
->
tbName
,
tbName
);
strcpy
(
pRsp
->
stbName
,
tbName
);
pRsp
->
dbId
=
pDb
->
uid
;
pRsp
->
numOfTags
=
pStb
->
numOfTags
;
pRsp
->
numOfColumns
=
pStb
->
numOfColumns
;
pRsp
->
precision
=
pDb
->
cfg
.
precision
;
pRsp
->
tableType
=
TSDB_SUPER_TABLE
;
pRsp
->
sversion
=
pStb
->
colVer
;
pRsp
->
tversion
=
pStb
->
tagVer
;
pRsp
->
suid
=
pStb
->
uid
;
pRsp
->
tuid
=
pStb
->
uid
;
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pRsp
->
pSchemas
[
i
];
SSchema
*
pSrcSchema
=
&
pStb
->
pColumns
[
i
];
memcpy
(
pSchema
->
name
,
pSrcSchema
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
type
=
pSrcSchema
->
type
;
pSchema
->
colId
=
pSrcSchema
->
colId
;
pSchema
->
bytes
=
pSrcSchema
->
bytes
;
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pRsp
->
pSchemas
[
i
+
pStb
->
numOfColumns
];
SSchema
*
pSrcSchema
=
&
pStb
->
pTags
[
i
];
memcpy
(
pSchema
->
name
,
pSrcSchema
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
type
=
pSrcSchema
->
type
;
pSchema
->
colId
=
pSrcSchema
->
colId
;
pSchema
->
bytes
=
pSrcSchema
->
bytes
;
}
taosRUnLockLatch
(
&
pStb
->
lock
);
return
0
;
}
static
int32_t
mndBuildStbSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
)
{
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
dbFName
,
tbName
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
dbFName
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
return
-
1
;
}
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
tbFName
);
if
(
pStb
==
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
terrno
=
TSDB_CODE_MND_INVALID_STB
;
return
-
1
;
}
int32_t
code
=
mndBuildStbSchemaImp
(
pDb
,
pStb
,
tbName
,
pRsp
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseStb
(
pMnode
,
pStb
);
return
code
;
}
static
int32_t
mndBuildSMAlterStbRsp
(
SDbObj
*
pDb
,
const
SMAlterStbReq
*
pAlter
,
SStbObj
*
pObj
,
void
**
pCont
,
int32_t
*
pLen
)
{
int
ret
;
SEncoder
ec
=
{
0
};
uint32_t
contLen
=
0
;
SMAlterStbRsp
alterRsp
=
{
0
};
SName
name
=
{
0
};
tNameFromString
(
&
name
,
pAlter
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
alterRsp
.
pMeta
=
taosMemoryCalloc
(
1
,
sizeof
(
STableMetaRsp
));
if
(
NULL
==
alterRsp
.
pMeta
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
ret
=
mndBuildStbSchemaImp
(
pDb
,
pObj
,
name
.
tname
,
alterRsp
.
pMeta
);
if
(
ret
)
{
tFreeSMAlterStbRsp
(
&
alterRsp
);
return
ret
;
}
tEncodeSize
(
tEncodeSMAlterStbRsp
,
&
alterRsp
,
contLen
,
ret
);
if
(
ret
)
{
tFreeSMAlterStbRsp
(
&
alterRsp
);
return
ret
;
}
void
*
cont
=
taosMemoryMalloc
(
contLen
);
tEncoderInit
(
&
ec
,
cont
,
contLen
);
tEncodeSMAlterStbRsp
(
&
ec
,
&
alterRsp
);
tEncoderClear
(
&
ec
);
tFreeSMAlterStbRsp
(
&
alterRsp
);
*
pCont
=
cont
;
*
pLen
=
contLen
;
return
0
;
}
static
int32_t
mndAlterStb
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
const
SMAlterStbReq
*
pAlter
,
SDbObj
*
pDb
,
SStbObj
*
pOld
)
{
static
int32_t
mndAlterStb
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
const
SMAlterStbReq
*
pAlter
,
SDbObj
*
pDb
,
SStbObj
*
pOld
)
{
bool
needRsp
=
true
;
SStbObj
stbObj
=
{
0
};
SStbObj
stbObj
=
{
0
};
taosRLockLatch
(
&
pOld
->
lock
);
taosRLockLatch
(
&
pOld
->
lock
);
memcpy
(
&
stbObj
,
pOld
,
sizeof
(
SStbObj
));
memcpy
(
&
stbObj
,
pOld
,
sizeof
(
SStbObj
));
stbObj
.
pColumns
=
NULL
;
stbObj
.
pColumns
=
NULL
;
stbObj
.
pTags
=
NULL
;
stbObj
.
pTags
=
NULL
;
stbObj
.
updateTime
=
taosGetTimestampMs
();
stbObj
.
updateTime
=
taosGetTimestampMs
();
stbObj
.
lock
=
0
;
taosRUnLockLatch
(
&
pOld
->
lock
);
taosRUnLockLatch
(
&
pOld
->
lock
);
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
...
@@ -1247,9 +1359,11 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
...
@@ -1247,9 +1359,11 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
code
=
mndAlterStbColumnBytes
(
pOld
,
&
stbObj
,
pField0
);
code
=
mndAlterStbColumnBytes
(
pOld
,
&
stbObj
,
pField0
);
break
;
break
;
case
TSDB_ALTER_TABLE_UPDATE_OPTIONS
:
case
TSDB_ALTER_TABLE_UPDATE_OPTIONS
:
needRsp
=
false
;
code
=
mndUpdateStbCommentAndTTL
(
pOld
,
&
stbObj
,
pAlter
->
comment
,
pAlter
->
commentLen
,
pAlter
->
ttl
);
code
=
mndUpdateStbCommentAndTTL
(
pOld
,
&
stbObj
,
pAlter
->
comment
,
pAlter
->
commentLen
,
pAlter
->
ttl
);
break
;
break
;
default:
default:
needRsp
=
false
;
terrno
=
TSDB_CODE_OPS_NOT_SUPPORT
;
terrno
=
TSDB_CODE_OPS_NOT_SUPPORT
;
break
;
break
;
}
}
...
@@ -1263,6 +1377,13 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
...
@@ -1263,6 +1377,13 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
mDebug
(
"trans:%d, used to alter stb:%s"
,
pTrans
->
id
,
pAlter
->
name
);
mDebug
(
"trans:%d, used to alter stb:%s"
,
pTrans
->
id
,
pAlter
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
);
if
(
needRsp
)
{
void
*
pCont
=
NULL
;
int32_t
contLen
=
0
;
if
(
mndBuildSMAlterStbRsp
(
pDb
,
pAlter
,
&
stbObj
,
&
pCont
,
&
contLen
))
goto
_OVER
;
mndTransSetRpcRsp
(
pTrans
,
pCont
,
contLen
);
}
if
(
mndSetAlterStbRedoLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbRedoLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbCommitLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbCommitLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbRedoActions
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbRedoActions
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
_OVER
;
...
@@ -1483,75 +1604,6 @@ static int32_t mndProcessVDropStbRsp(SRpcMsg *pRsp) {
...
@@ -1483,75 +1604,6 @@ static int32_t mndProcessVDropStbRsp(SRpcMsg *pRsp) {
return
0
;
return
0
;
}
}
static
int32_t
mndBuildStbSchemaImp
(
SDbObj
*
pDb
,
SStbObj
*
pStb
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
)
{
taosRLockLatch
(
&
pStb
->
lock
);
int32_t
totalCols
=
pStb
->
numOfColumns
+
pStb
->
numOfTags
;
pRsp
->
pSchemas
=
taosMemoryCalloc
(
totalCols
,
sizeof
(
SSchema
));
if
(
pRsp
->
pSchemas
==
NULL
)
{
taosRUnLockLatch
(
&
pStb
->
lock
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
strcpy
(
pRsp
->
dbFName
,
pStb
->
db
);
strcpy
(
pRsp
->
tbName
,
tbName
);
strcpy
(
pRsp
->
stbName
,
tbName
);
pRsp
->
dbId
=
pDb
->
uid
;
pRsp
->
numOfTags
=
pStb
->
numOfTags
;
pRsp
->
numOfColumns
=
pStb
->
numOfColumns
;
pRsp
->
precision
=
pDb
->
cfg
.
precision
;
pRsp
->
tableType
=
TSDB_SUPER_TABLE
;
pRsp
->
sversion
=
pStb
->
colVer
;
pRsp
->
tversion
=
pStb
->
tagVer
;
pRsp
->
suid
=
pStb
->
uid
;
pRsp
->
tuid
=
pStb
->
uid
;
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pRsp
->
pSchemas
[
i
];
SSchema
*
pSrcSchema
=
&
pStb
->
pColumns
[
i
];
memcpy
(
pSchema
->
name
,
pSrcSchema
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
type
=
pSrcSchema
->
type
;
pSchema
->
colId
=
pSrcSchema
->
colId
;
pSchema
->
bytes
=
pSrcSchema
->
bytes
;
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pRsp
->
pSchemas
[
i
+
pStb
->
numOfColumns
];
SSchema
*
pSrcSchema
=
&
pStb
->
pTags
[
i
];
memcpy
(
pSchema
->
name
,
pSrcSchema
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
type
=
pSrcSchema
->
type
;
pSchema
->
colId
=
pSrcSchema
->
colId
;
pSchema
->
bytes
=
pSrcSchema
->
bytes
;
}
taosRUnLockLatch
(
&
pStb
->
lock
);
return
0
;
}
static
int32_t
mndBuildStbSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
)
{
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
dbFName
,
tbName
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
dbFName
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
return
-
1
;
}
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
tbFName
);
if
(
pStb
==
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
terrno
=
TSDB_CODE_MND_INVALID_STB
;
return
-
1
;
}
int32_t
code
=
mndBuildStbSchemaImp
(
pDb
,
pStb
,
tbName
,
pRsp
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseStb
(
pMnode
,
pStb
);
return
code
;
}
static
int32_t
mndProcessTableMetaReq
(
SRpcMsg
*
pReq
)
{
static
int32_t
mndProcessTableMetaReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
46772d32
...
@@ -93,10 +93,8 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic,
...
@@ -93,10 +93,8 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic,
return
NULL
;
return
NULL
;
}
}
pSub
->
dbUid
=
pTopic
->
dbUid
;
pSub
->
dbUid
=
pTopic
->
dbUid
;
pSub
->
stbUid
=
pTopic
->
stbUid
;
pSub
->
subType
=
pTopic
->
subType
;
pSub
->
subType
=
pTopic
->
subType
;
/*pSub->withTbName = pTopic->withTbName;*/
/*pSub->withSchema = pTopic->withSchema;*/
/*pSub->withTag = pTopic->withTag;*/
ASSERT
(
pSub
->
unassignedVgs
->
size
==
0
);
ASSERT
(
pSub
->
unassignedVgs
->
size
==
0
);
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
0
);
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
0
);
...
@@ -121,9 +119,7 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscri
...
@@ -121,9 +119,7 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscri
req
.
vgId
=
pRebVg
->
pVgEp
->
vgId
;
req
.
vgId
=
pRebVg
->
pVgEp
->
vgId
;
req
.
qmsg
=
pRebVg
->
pVgEp
->
qmsg
;
req
.
qmsg
=
pRebVg
->
pVgEp
->
qmsg
;
req
.
subType
=
pSub
->
subType
;
req
.
subType
=
pSub
->
subType
;
/*req.withTbName = pSub->withTbName;*/
req
.
suid
=
pSub
->
stbUid
;
/*req.withSchema = pSub->withSchema;*/
/*req.withTag = pSub->withTag;*/
strncpy
(
req
.
subKey
,
pSub
->
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
strncpy
(
req
.
subKey
,
pSub
->
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
int32_t
tlen
=
sizeof
(
SMsgHead
)
+
tEncodeSMqRebVgReq
(
NULL
,
&
req
);
int32_t
tlen
=
sizeof
(
SMsgHead
)
+
tEncodeSMqRebVgReq
(
NULL
,
&
req
);
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
46772d32
...
@@ -70,6 +70,56 @@ const char *mndTopicGetShowName(const char topic[TSDB_TOPIC_FNAME_LEN]) {
...
@@ -70,6 +70,56 @@ const char *mndTopicGetShowName(const char topic[TSDB_TOPIC_FNAME_LEN]) {
return
strchr
(
topic
,
'.'
)
+
1
;
return
strchr
(
topic
,
'.'
)
+
1
;
}
}
bool
mndCheckColAndTagModifiable
(
SMnode
*
pMnode
,
int64_t
suid
,
const
SArray
*
colAndTagIds
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
bool
found
=
false
;
while
(
1
)
{
SMqTopicObj
*
pTopic
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_TOPIC
,
pIter
,
(
void
**
)
&
pTopic
);
if
(
pIter
==
NULL
)
break
;
if
(
pTopic
->
subType
!=
TOPIC_SUB_TYPE__COLUMN
)
{
sdbRelease
(
pSdb
,
pTopic
);
continue
;
}
SNode
*
pAst
=
NULL
;
if
(
nodesStringToNode
(
pTopic
->
ast
,
&
pAst
)
!=
0
)
{
ASSERT
(
0
);
return
false
;
}
SHashObj
*
pColHash
=
NULL
;
SNodeList
*
pNodeList
;
nodesCollectColumns
((
SSelectStmt
*
)
pAst
,
SQL_CLAUSE_FROM
,
NULL
,
COLLECT_COL_TYPE_ALL
,
&
pNodeList
);
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pNodeList
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
pCol
->
tableId
!=
suid
)
goto
NEXT
;
if
(
pColHash
==
NULL
)
{
pColHash
=
taosHashInit
(
0
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_SMALLINT
),
false
,
HASH_NO_LOCK
);
}
if
(
pCol
->
colId
>
0
)
{
taosHashPut
(
pColHash
,
&
pCol
->
colId
,
sizeof
(
int16_t
),
NULL
,
0
);
}
}
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
colAndTagIds
);
i
++
)
{
int16_t
*
pColId
=
taosArrayGet
(
colAndTagIds
,
i
);
if
(
taosHashGet
(
pColHash
,
pColId
,
sizeof
(
int16_t
))
!=
NULL
)
{
found
=
true
;
goto
NEXT
;
}
}
NEXT:
sdbRelease
(
pSdb
,
pTopic
);
nodesDestroyNode
(
pAst
);
if
(
found
)
return
false
;
}
return
true
;
}
SSdbRaw
*
mndTopicActionEncode
(
SMqTopicObj
*
pTopic
)
{
SSdbRaw
*
mndTopicActionEncode
(
SMqTopicObj
*
pTopic
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -96,11 +146,8 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
...
@@ -96,11 +146,8 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
dbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
dbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
subType
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
subType
,
TOPIC_ENCODE_OVER
);
/*SDB_SET_INT8(pRaw, dataPos, pTopic->withTbName, TOPIC_ENCODE_OVER);*/
/*SDB_SET_INT8(pRaw, dataPos, pTopic->withSchema, TOPIC_ENCODE_OVER);*/
/*SDB_SET_INT8(pRaw, dataPos, pTopic->withTag, TOPIC_ENCODE_OVER);*/
SDB_SET_INT
32
(
pRaw
,
dataPos
,
pTopic
->
consumerCnt
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT
64
(
pRaw
,
dataPos
,
pTopic
->
stbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
astLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
astLen
,
TOPIC_ENCODE_OVER
);
...
@@ -122,8 +169,6 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
...
@@ -122,8 +169,6 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
SDB_SET_BINARY
(
pRaw
,
dataPos
,
swBuf
,
schemaLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
swBuf
,
schemaLen
,
TOPIC_ENCODE_OVER
);
}
}
/*SDB_SET_INT32(pRaw, dataPos, pTopic->refConsumerCnt, TOPIC_ENCODE_OVER);*/
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_ENCODE_OVER
);
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_ENCODE_OVER
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
TOPIC_ENCODE_OVER
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
TOPIC_ENCODE_OVER
);
...
@@ -168,12 +213,8 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
...
@@ -168,12 +213,8 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
subType
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
subType
,
TOPIC_DECODE_OVER
);
/*SDB_GET_INT8(pRaw, dataPos, &pTopic->withTbName, TOPIC_DECODE_OVER);*/
/*SDB_GET_INT8(pRaw, dataPos, &pTopic->withSchema, TOPIC_DECODE_OVER);*/
/*SDB_GET_INT8(pRaw, dataPos, &pTopic->withTag, TOPIC_DECODE_OVER);*/
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
consumerCnt
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
stbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
pTopic
->
sql
=
taosMemoryCalloc
(
pTopic
->
sqlLen
,
sizeof
(
char
));
pTopic
->
sql
=
taosMemoryCalloc
(
pTopic
->
sqlLen
,
sizeof
(
char
));
if
(
pTopic
->
sql
==
NULL
)
{
if
(
pTopic
->
sql
==
NULL
)
{
...
@@ -222,8 +263,6 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
...
@@ -222,8 +263,6 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
pTopic
->
schema
.
pSchema
=
NULL
;
pTopic
->
schema
.
pSchema
=
NULL
;
}
}
/*SDB_GET_INT32(pRaw, dataPos, &pTopic->refConsumerCnt, TOPIC_DECODE_OVER);*/
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_DECODE_OVER
);
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_DECODE_OVER
);
terrno
=
TSDB_CODE_SUCCESS
;
terrno
=
TSDB_CODE_SUCCESS
;
...
@@ -254,8 +293,6 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pOldTopic, SMqTopic
...
@@ -254,8 +293,6 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pOldTopic, SMqTopic
atomic_exchange_64
(
&
pOldTopic
->
updateTime
,
pNewTopic
->
updateTime
);
atomic_exchange_64
(
&
pOldTopic
->
updateTime
,
pNewTopic
->
updateTime
);
atomic_exchange_32
(
&
pOldTopic
->
version
,
pNewTopic
->
version
);
atomic_exchange_32
(
&
pOldTopic
->
version
,
pNewTopic
->
version
);
/*atomic_store_32(&pOldTopic->refConsumerCnt, pNewTopic->refConsumerCnt);*/
/*taosWLockLatch(&pOldTopic->lock);*/
/*taosWLockLatch(&pOldTopic->lock);*/
// TODO handle update
// TODO handle update
...
@@ -278,18 +315,6 @@ void mndReleaseTopic(SMnode *pMnode, SMqTopicObj *pTopic) {
...
@@ -278,18 +315,6 @@ void mndReleaseTopic(SMnode *pMnode, SMqTopicObj *pTopic) {
sdbRelease
(
pSdb
,
pTopic
);
sdbRelease
(
pSdb
,
pTopic
);
}
}
#if 0
static SDbObj *mndAcquireDbByTopic(SMnode *pMnode, char *topicName) {
SName name = {0};
tNameFromString(&name, topicName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
char db[TSDB_TOPIC_FNAME_LEN] = {0};
tNameGetFullDbName(&name, db);
return mndAcquireDb(pMnode, db);
}
#endif
static
SDDropTopicReq
*
mndBuildDropTopicMsg
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SMqTopicObj
*
pTopic
)
{
static
SDDropTopicReq
*
mndBuildDropTopicMsg
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SMqTopicObj
*
pTopic
)
{
int32_t
contLen
=
sizeof
(
SDDropTopicReq
);
int32_t
contLen
=
sizeof
(
SDDropTopicReq
);
...
@@ -341,8 +366,6 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
...
@@ -341,8 +366,6 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
if
(
pCreate
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pCreate
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
topicObj
.
ast
=
strdup
(
pCreate
->
ast
);
topicObj
.
ast
=
strdup
(
pCreate
->
ast
);
topicObj
.
astLen
=
strlen
(
pCreate
->
ast
)
+
1
;
topicObj
.
astLen
=
strlen
(
pCreate
->
ast
)
+
1
;
/*topicObj.withTbName = pCreate->withTbName;*/
/*topicObj.withSchema = pCreate->withSchema;*/
SNode
*
pAst
=
NULL
;
SNode
*
pAst
=
NULL
;
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
!=
0
)
{
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
!=
0
)
{
...
@@ -375,13 +398,16 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
...
@@ -375,13 +398,16 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
taosMemoryFree
(
topicObj
.
sql
);
taosMemoryFree
(
topicObj
.
sql
);
return
-
1
;
return
-
1
;
}
}
/*} else if (pCreate->subType == TOPIC_SUB_TYPE__DB) {*/
}
else
if
(
pCreate
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
/*topicObj.ast = NULL;*/
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
pCreate
->
subStbName
);
/*topicObj.astLen = 0;*/
topicObj
.
stbUid
=
pStb
->
uid
;
/*topicObj.physicalPlan = NULL;*/
}
/*topicObj.withTbName = 1;*/
/*} else if (pCreate->subType == TOPIC_SUB_TYPE__DB) {*/
/*topicObj.withSchema = 1;*/
/*topicObj.ast = NULL;*/
}
/*topicObj.astLen = 0;*/
/*topicObj.physicalPlan = NULL;*/
/*topicObj.withTbName = 1;*/
/*topicObj.withSchema = 1;*/
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_NOTHING
,
pReq
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_NOTHING
,
pReq
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
...
...
source/dnode/vnode/CMakeLists.txt
浏览文件 @
46772d32
...
@@ -32,11 +32,10 @@ target_sources(
...
@@ -32,11 +32,10 @@ target_sources(
"src/sma/smaEnv.c"
"src/sma/smaEnv.c"
"src/sma/smaOpen.c"
"src/sma/smaOpen.c"
"src/sma/smaRollup.c"
"src/sma/smaRollup.c"
"src/sma/smaTimeRange.c"
"src/sma/smaTimeRange
2
.c"
# tsdb
# tsdb
"src/tsdb/tsdbCommit.c"
"src/tsdb/tsdbCommit.c"
"src/tsdb/tsdbCommit2.c"
"src/tsdb/tsdbFile.c"
"src/tsdb/tsdbFile.c"
"src/tsdb/tsdbFS.c"
"src/tsdb/tsdbFS.c"
"src/tsdb/tsdbOpen.c"
"src/tsdb/tsdbOpen.c"
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
46772d32
...
@@ -85,7 +85,7 @@ typedef struct SMetaFltParam {
...
@@ -85,7 +85,7 @@ typedef struct SMetaFltParam {
tb_uid_t
suid
;
tb_uid_t
suid
;
int16_t
cid
;
int16_t
cid
;
int16_t
type
;
int16_t
type
;
char
*
val
;
char
*
val
;
bool
reverse
;
bool
reverse
;
int
(
*
filterFunc
)(
void
*
a
,
void
*
b
,
int16_t
type
);
int
(
*
filterFunc
)(
void
*
a
,
void
*
b
,
int16_t
type
);
...
@@ -119,7 +119,8 @@ tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STab
...
@@ -119,7 +119,8 @@ tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STab
int32_t
tsdbGetFileBlocksDistInfo
(
tsdbReaderT
*
pReader
,
STableBlockDistInfo
*
pTableBlockInfo
);
int32_t
tsdbGetFileBlocksDistInfo
(
tsdbReaderT
*
pReader
,
STableBlockDistInfo
*
pTableBlockInfo
);
bool
isTsdbCacheLastRow
(
tsdbReaderT
*
pReader
);
bool
isTsdbCacheLastRow
(
tsdbReaderT
*
pReader
);
int32_t
tsdbGetAllTableList
(
SMeta
*
pMeta
,
uint64_t
uid
,
SArray
*
list
);
int32_t
tsdbGetAllTableList
(
SMeta
*
pMeta
,
uint64_t
uid
,
SArray
*
list
);
void
*
tsdbGetIdx
(
SMeta
*
pMeta
);
int32_t
tsdbGetCtbIdList
(
SMeta
*
pMeta
,
int64_t
suid
,
SArray
*
list
);
void
*
tsdbGetIdx
(
SMeta
*
pMeta
);
int64_t
tsdbGetNumOfRowsInMemTable
(
tsdbReaderT
*
pHandle
);
int64_t
tsdbGetNumOfRowsInMemTable
(
tsdbReaderT
*
pHandle
);
bool
tsdbNextDataBlock
(
tsdbReaderT
pTsdbReadHandle
);
bool
tsdbNextDataBlock
(
tsdbReaderT
pTsdbReadHandle
);
...
@@ -146,6 +147,9 @@ bool tqNextDataBlockFilterOut(STqReadHandle *pHandle, SHashObj *filterOutUids
...
@@ -146,6 +147,9 @@ bool tqNextDataBlockFilterOut(STqReadHandle *pHandle, SHashObj *filterOutUids
int32_t
tqRetrieveDataBlock
(
SArray
**
ppCols
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
uint64_t
*
pUid
,
int32_t
tqRetrieveDataBlock
(
SArray
**
ppCols
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
uint64_t
*
pUid
,
int32_t
*
pNumOfRows
,
int16_t
*
pNumOfCols
);
int32_t
*
pNumOfRows
,
int16_t
*
pNumOfCols
);
// sma
int32_t
smaGetTSmaDays
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
);
// need to reposition
// need to reposition
// structs
// structs
...
@@ -192,7 +196,7 @@ struct SMetaEntry {
...
@@ -192,7 +196,7 @@ struct SMetaEntry {
int64_t
version
;
int64_t
version
;
int8_t
type
;
int8_t
type
;
tb_uid_t
uid
;
tb_uid_t
uid
;
char
*
name
;
char
*
name
;
union
{
union
{
struct
{
struct
{
SSchemaWrapper
schemaRow
;
SSchemaWrapper
schemaRow
;
...
@@ -220,17 +224,17 @@ struct SMetaEntry {
...
@@ -220,17 +224,17 @@ struct SMetaEntry {
struct
SMetaReader
{
struct
SMetaReader
{
int32_t
flags
;
int32_t
flags
;
SMeta
*
pMeta
;
SMeta
*
pMeta
;
SDecoder
coder
;
SDecoder
coder
;
SMetaEntry
me
;
SMetaEntry
me
;
void
*
pBuf
;
void
*
pBuf
;
int32_t
szBuf
;
int32_t
szBuf
;
};
};
struct
SMTbCursor
{
struct
SMTbCursor
{
TBC
*
pDbc
;
TBC
*
pDbc
;
void
*
pKey
;
void
*
pKey
;
void
*
pVal
;
void
*
pVal
;
int32_t
kLen
;
int32_t
kLen
;
int32_t
vLen
;
int32_t
vLen
;
SMetaReader
mr
;
SMetaReader
mr
;
...
...
source/dnode/vnode/src/inc/sma.h
浏览文件 @
46772d32
...
@@ -223,6 +223,8 @@ int32_t tdUpdateExpiredWindowImpl(SSma *pSma, const SSubmitReq *pMsg, int64_t ve
...
@@ -223,6 +223,8 @@ int32_t tdUpdateExpiredWindowImpl(SSma *pSma, const SSubmitReq *pMsg, int64_t ve
// TODO: This is the basic params, and should wrap the params to a queryHandle.
// TODO: This is the basic params, and should wrap the params to a queryHandle.
int32_t
tdGetTSmaDataImpl
(
SSma
*
pSma
,
char
*
pData
,
int64_t
indexUid
,
TSKEY
querySKey
,
int32_t
nMaxResult
);
int32_t
tdGetTSmaDataImpl
(
SSma
*
pSma
,
char
*
pData
,
int64_t
indexUid
,
TSKEY
querySKey
,
int32_t
nMaxResult
);
int32_t
tdGetTSmaDaysImpl
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
46772d32
...
@@ -87,7 +87,7 @@ int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* p
...
@@ -87,7 +87,7 @@ int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* p
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
);
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
);
int
metaCreateTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateTbReq
*
pReq
);
int
metaCreateTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateTbReq
*
pReq
);
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
);
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
);
int
metaAlterTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pReq
);
int
metaAlterTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pReq
,
STableMetaRsp
*
pMetaRsp
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
int
metaGetTableEntryByName
(
SMetaReader
*
pReader
,
const
char
*
name
);
int
metaGetTableEntryByName
(
SMetaReader
*
pReader
,
const
char
*
name
);
...
...
source/dnode/vnode/src/meta/metaEntry.c
浏览文件 @
46772d32
...
@@ -30,6 +30,7 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
...
@@ -30,6 +30,7 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
debugCheckTags
((
STag
*
)
pME
->
ctbEntry
.
pTags
);
// TODO: remove after debug
if
(
tEncodeTag
(
pCoder
,
(
const
STag
*
)
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
if
(
tEncodeTag
(
pCoder
,
(
const
STag
*
)
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
tEncodeI64
(
pCoder
,
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
...
@@ -62,6 +63,7 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
...
@@ -62,6 +63,7 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
if
(
tDecodeTag
(
pCoder
,
(
STag
**
)
&
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
// (TODO)
if
(
tDecodeTag
(
pCoder
,
(
STag
**
)
&
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
// (TODO)
debugCheckTags
((
STag
*
)
pME
->
ctbEntry
.
pTags
);
// TODO: remove after debug
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
46772d32
...
@@ -464,7 +464,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid, bool deepCopy) {
...
@@ -464,7 +464,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid, bool deepCopy) {
_err:
_err:
metaReaderClear
(
&
mr
);
metaReaderClear
(
&
mr
);
taosArrayDestroy
(
pSmaIds
);
taosArrayDestroy
(
pSmaIds
);
t
d
FreeTSmaWrapper
(
pSW
,
deepCopy
);
tFreeTSmaWrapper
(
pSW
,
deepCopy
);
return
NULL
;
return
NULL
;
}
}
...
@@ -576,15 +576,15 @@ SArray *metaGetSmaTbUids(SMeta *pMeta) {
...
@@ -576,15 +576,15 @@ SArray *metaGetSmaTbUids(SMeta *pMeta) {
const
void
*
metaGetTableTagVal
(
SMetaEntry
*
pEntry
,
int16_t
type
,
STagVal
*
val
)
{
const
void
*
metaGetTableTagVal
(
SMetaEntry
*
pEntry
,
int16_t
type
,
STagVal
*
val
)
{
ASSERT
(
pEntry
->
type
==
TSDB_CHILD_TABLE
);
ASSERT
(
pEntry
->
type
==
TSDB_CHILD_TABLE
);
STag
*
tag
=
(
STag
*
)
pEntry
->
ctbEntry
.
pTags
;
STag
*
tag
=
(
STag
*
)
pEntry
->
ctbEntry
.
pTags
;
if
(
type
==
TSDB_DATA_TYPE_JSON
){
if
(
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
tag
->
nTag
==
0
)
{
if
(
tag
->
nTag
==
0
)
{
return
NULL
;
return
NULL
;
}
}
return
tag
;
return
tag
;
}
}
bool
find
=
tTagGet
(
tag
,
val
);
bool
find
=
tTagGet
(
tag
,
val
);
if
(
!
find
)
{
if
(
!
find
)
{
return
NULL
;
return
NULL
;
}
}
return
val
;
return
val
;
...
@@ -605,8 +605,6 @@ typedef struct {
...
@@ -605,8 +605,6 @@ typedef struct {
int32_t
metaFilteTableIds
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
pUids
)
{
int32_t
metaFilteTableIds
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
pUids
)
{
SIdxCursor
*
pCursor
=
NULL
;
SIdxCursor
*
pCursor
=
NULL
;
char
*
tagData
=
param
->
val
;
int32_t
ret
=
0
,
valid
=
0
;
int32_t
ret
=
0
,
valid
=
0
;
pCursor
=
(
SIdxCursor
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SIdxCursor
));
pCursor
=
(
SIdxCursor
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SIdxCursor
));
pCursor
->
pMeta
=
pMeta
;
pCursor
->
pMeta
=
pMeta
;
...
@@ -623,12 +621,16 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
...
@@ -623,12 +621,16 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
int32_t
nKey
=
0
;
int32_t
nKey
=
0
;
int32_t
nTagData
=
0
;
int32_t
nTagData
=
0
;
if
(
IS_VAR_DATA_TYPE
(
param
->
type
)){
void
*
tagData
=
NULL
;
nTagData
=
strlen
(
param
->
val
);
}
else
{
if
(
IS_VAR_DATA_TYPE
(
param
->
type
))
{
tagData
=
varDataVal
(
param
->
val
);
nTagData
=
varDataLen
(
param
->
val
);
}
else
{
tagData
=
param
->
val
;
nTagData
=
tDataTypes
[
param
->
type
].
bytes
;
nTagData
=
tDataTypes
[
param
->
type
].
bytes
;
}
}
ret
=
metaCreateTagIdxKey
(
pCursor
->
suid
,
pCursor
->
cid
,
param
->
val
,
nTagData
,
pCursor
->
type
,
ret
=
metaCreateTagIdxKey
(
pCursor
->
suid
,
pCursor
->
cid
,
tagData
,
nTagData
,
pCursor
->
type
,
param
->
reverse
?
INT64_MAX
:
INT64_MIN
,
&
pKey
,
&
nKey
);
param
->
reverse
?
INT64_MAX
:
INT64_MIN
,
&
pKey
,
&
nKey
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
goto
END
;
goto
END
;
...
@@ -637,6 +639,7 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
...
@@ -637,6 +639,7 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
if
(
tdbTbcMoveTo
(
pCursor
->
pCur
,
pKey
,
nKey
,
&
cmp
)
<
0
)
{
if
(
tdbTbcMoveTo
(
pCursor
->
pCur
,
pKey
,
nKey
,
&
cmp
)
<
0
)
{
goto
END
;
goto
END
;
}
}
void
*
entryKey
=
NULL
,
*
entryVal
=
NULL
;
void
*
entryKey
=
NULL
,
*
entryVal
=
NULL
;
int32_t
nEntryKey
,
nEntryVal
;
int32_t
nEntryKey
,
nEntryVal
;
while
(
1
)
{
while
(
1
)
{
...
@@ -649,7 +652,12 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
...
@@ -649,7 +652,12 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
int32_t
cmp
=
(
*
param
->
filterFunc
)(
p
->
data
,
pKey
->
data
,
pKey
->
type
);
int32_t
cmp
=
(
*
param
->
filterFunc
)(
p
->
data
,
pKey
->
data
,
pKey
->
type
);
if
(
cmp
==
0
)
{
if
(
cmp
==
0
)
{
// match
// match
tb_uid_t
tuid
=
*
(
tb_uid_t
*
)(
p
->
data
+
tDataTypes
[
pCursor
->
type
].
bytes
);
tb_uid_t
tuid
=
0
;
if
(
IS_VAR_DATA_TYPE
(
pKey
->
type
))
{
tuid
=
*
(
tb_uid_t
*
)(
p
->
data
+
varDataTLen
(
p
->
data
));
}
else
{
tuid
=
*
(
tb_uid_t
*
)(
p
->
data
+
tDataTypes
[
pCursor
->
type
].
bytes
);
}
taosArrayPush
(
pUids
,
&
tuid
);
taosArrayPush
(
pUids
,
&
tuid
);
}
else
if
(
cmp
==
1
)
{
}
else
if
(
cmp
==
1
)
{
// not match but should continue to iter
// not match but should continue to iter
...
@@ -670,4 +678,4 @@ END:
...
@@ -670,4 +678,4 @@ END:
taosMemoryFree
(
pCursor
);
taosMemoryFree
(
pCursor
);
return
ret
;
return
ret
;
}
}
\ No newline at end of file
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
46772d32
...
@@ -25,15 +25,33 @@ static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME);
...
@@ -25,15 +25,33 @@ static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME);
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
);
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
);
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
);
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
);
static
int
metaUpdateMetaRsp
(
tb_uid_t
uid
,
char
*
tbName
,
SSchemaWrapper
*
pSchema
,
STableMetaRsp
*
pMetaRsp
)
{
pMetaRsp
->
pSchemas
=
taosMemoryMalloc
(
pSchema
->
nCols
*
sizeof
(
SSchema
));
if
(
NULL
==
pMetaRsp
->
pSchemas
)
{
terrno
=
TSDB_CODE_VND_OUT_OF_MEMORY
;
return
-
1
;
}
strcpy
(
pMetaRsp
->
tbName
,
tbName
);
pMetaRsp
->
numOfColumns
=
pSchema
->
nCols
;
pMetaRsp
->
tableType
=
TSDB_NORMAL_TABLE
;
pMetaRsp
->
sversion
=
pSchema
->
version
;
pMetaRsp
->
tuid
=
uid
;
memcpy
(
pMetaRsp
->
pSchemas
,
pSchema
->
pSchema
,
pSchema
->
nCols
*
sizeof
(
SSchema
));
return
0
;
}
int
metaCreateSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
int
metaCreateSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
SMetaEntry
me
=
{
0
};
SMetaEntry
me
=
{
0
};
int
kLen
=
0
;
int
kLen
=
0
;
int
vLen
=
0
;
int
vLen
=
0
;
const
void
*
pKey
=
NULL
;
const
void
*
pKey
=
NULL
;
const
void
*
pVal
=
NULL
;
const
void
*
pVal
=
NULL
;
void
*
pBuf
=
NULL
;
void
*
pBuf
=
NULL
;
int32_t
szBuf
=
0
;
int32_t
szBuf
=
0
;
void
*
p
=
NULL
;
void
*
p
=
NULL
;
SMetaReader
mr
=
{
0
};
SMetaReader
mr
=
{
0
};
// validate req
// validate req
...
@@ -87,7 +105,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
...
@@ -87,7 +105,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
}
}
// drop all child tables
// drop all child tables
TBC
*
pCtbIdxc
=
NULL
;
TBC
*
pCtbIdxc
=
NULL
;
SArray
*
pArray
=
taosArrayInit
(
8
,
sizeof
(
tb_uid_t
));
SArray
*
pArray
=
taosArrayInit
(
8
,
sizeof
(
tb_uid_t
));
tdbTbcOpen
(
pMeta
->
pCtbIdx
,
&
pCtbIdxc
,
&
pMeta
->
txn
);
tdbTbcOpen
(
pMeta
->
pCtbIdx
,
&
pCtbIdxc
,
&
pMeta
->
txn
);
...
@@ -142,8 +160,8 @@ _exit:
...
@@ -142,8 +160,8 @@ _exit:
int
metaAlterSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
int
metaAlterSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
SMetaEntry
oStbEntry
=
{
0
};
SMetaEntry
oStbEntry
=
{
0
};
SMetaEntry
nStbEntry
=
{
0
};
SMetaEntry
nStbEntry
=
{
0
};
TBC
*
pUidIdxc
=
NULL
;
TBC
*
pUidIdxc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
const
void
*
pData
;
const
void
*
pData
;
int
nData
;
int
nData
;
int64_t
oversion
;
int64_t
oversion
;
...
@@ -262,7 +280,7 @@ _err:
...
@@ -262,7 +280,7 @@ _err:
}
}
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
)
{
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
)
{
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int
nData
=
0
;
int
rc
=
0
;
int
rc
=
0
;
tb_uid_t
uid
;
tb_uid_t
uid
;
...
@@ -288,7 +306,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
...
@@ -288,7 +306,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
}
}
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
)
{
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
)
{
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int
nData
=
0
;
int
rc
=
0
;
int
rc
=
0
;
int64_t
version
;
int64_t
version
;
...
@@ -323,15 +341,16 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
...
@@ -323,15 +341,16 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
return
0
;
return
0
;
}
}
static
int
metaAlterTableColumn
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
)
{
void
*
pVal
=
NULL
;
static
int
metaAlterTableColumn
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
,
STableMetaRsp
*
pMetaRsp
)
{
void
*
pVal
=
NULL
;
int
nVal
=
0
;
int
nVal
=
0
;
const
void
*
pData
=
NULL
;
const
void
*
pData
=
NULL
;
int
nData
=
0
;
int
nData
=
0
;
int
ret
=
0
;
int
ret
=
0
;
tb_uid_t
uid
;
tb_uid_t
uid
;
int64_t
oversion
;
int64_t
oversion
;
SSchema
*
pColumn
=
NULL
;
SSchema
*
pColumn
=
NULL
;
SMetaEntry
entry
=
{
0
};
SMetaEntry
entry
=
{
0
};
SSchemaWrapper
*
pSchema
;
SSchemaWrapper
*
pSchema
;
int
c
;
int
c
;
...
@@ -463,6 +482,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
...
@@ -463,6 +482,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
metaULock
(
pMeta
);
metaULock
(
pMeta
);
metaUpdateMetaRsp
(
uid
,
pAlterTbReq
->
tbName
,
pSchema
,
pMetaRsp
);
if
(
pNewSchema
)
taosMemoryFree
(
pNewSchema
);
if
(
pNewSchema
)
taosMemoryFree
(
pNewSchema
);
tDecoderClear
(
&
dc
);
tDecoderClear
(
&
dc
);
tdbTbcClose
(
pTbDbc
);
tdbTbcClose
(
pTbDbc
);
...
@@ -479,7 +500,7 @@ _err:
...
@@ -479,7 +500,7 @@ _err:
static
int
metaUpdateTableTagVal
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
)
{
static
int
metaUpdateTableTagVal
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
)
{
SMetaEntry
ctbEntry
=
{
0
};
SMetaEntry
ctbEntry
=
{
0
};
SMetaEntry
stbEntry
=
{
0
};
SMetaEntry
stbEntry
=
{
0
};
void
*
pVal
=
NULL
;
void
*
pVal
=
NULL
;
int
nVal
=
0
;
int
nVal
=
0
;
int
ret
;
int
ret
;
int
c
;
int
c
;
...
@@ -510,7 +531,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
...
@@ -510,7 +531,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
oversion
=
*
(
int64_t
*
)
pData
;
oversion
=
*
(
int64_t
*
)
pData
;
// search table.db
// search table.db
TBC
*
pTbDbc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
SDecoder
dc1
=
{
0
};
SDecoder
dc1
=
{
0
};
SDecoder
dc2
=
{
0
};
SDecoder
dc2
=
{
0
};
...
@@ -534,7 +555,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
...
@@ -534,7 +555,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
metaDecodeEntry
(
&
dc2
,
&
stbEntry
);
metaDecodeEntry
(
&
dc2
,
&
stbEntry
);
SSchemaWrapper
*
pTagSchema
=
&
stbEntry
.
stbEntry
.
schemaTag
;
SSchemaWrapper
*
pTagSchema
=
&
stbEntry
.
stbEntry
.
schemaTag
;
SSchema
*
pColumn
=
NULL
;
SSchema
*
pColumn
=
NULL
;
int32_t
iCol
=
0
;
int32_t
iCol
=
0
;
for
(;;)
{
for
(;;)
{
pColumn
=
NULL
;
pColumn
=
NULL
;
...
@@ -564,8 +585,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
...
@@ -564,8 +585,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
memcpy
((
void
*
)
ctbEntry
.
ctbEntry
.
pTags
,
pAlterTbReq
->
pTagVal
,
pAlterTbReq
->
nTagVal
);
memcpy
((
void
*
)
ctbEntry
.
ctbEntry
.
pTags
,
pAlterTbReq
->
pTagVal
,
pAlterTbReq
->
nTagVal
);
}
else
{
}
else
{
const
STag
*
pOldTag
=
(
const
STag
*
)
ctbEntry
.
ctbEntry
.
pTags
;
const
STag
*
pOldTag
=
(
const
STag
*
)
ctbEntry
.
ctbEntry
.
pTags
;
STag
*
pNewTag
=
NULL
;
STag
*
pNewTag
=
NULL
;
SArray
*
pTagArray
=
taosArrayInit
(
pTagSchema
->
nCols
,
sizeof
(
STagVal
));
SArray
*
pTagArray
=
taosArrayInit
(
pTagSchema
->
nCols
,
sizeof
(
STagVal
));
if
(
!
pTagArray
)
{
if
(
!
pTagArray
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
...
@@ -584,7 +605,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
...
@@ -584,7 +605,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
}
}
taosArrayPush
(
pTagArray
,
&
val
);
taosArrayPush
(
pTagArray
,
&
val
);
}
else
{
}
else
{
STagVal
val
=
{
0
};
STagVal
val
=
{
.
cid
=
pCol
->
colId
};
if
(
tTagGet
(
pOldTag
,
&
val
))
{
if
(
tTagGet
(
pOldTag
,
&
val
))
{
taosArrayPush
(
pTagArray
,
&
val
);
taosArrayPush
(
pTagArray
,
&
val
);
}
}
...
@@ -629,13 +650,13 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
...
@@ -629,13 +650,13 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
return
0
;
return
0
;
}
}
int
metaAlterTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pReq
)
{
int
metaAlterTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pReq
,
STableMetaRsp
*
pMetaRsp
)
{
switch
(
pReq
->
action
)
{
switch
(
pReq
->
action
)
{
case
TSDB_ALTER_TABLE_ADD_COLUMN
:
case
TSDB_ALTER_TABLE_ADD_COLUMN
:
case
TSDB_ALTER_TABLE_DROP_COLUMN
:
case
TSDB_ALTER_TABLE_DROP_COLUMN
:
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
:
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
:
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
:
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
:
return
metaAlterTableColumn
(
pMeta
,
version
,
pReq
);
return
metaAlterTableColumn
(
pMeta
,
version
,
pReq
,
pMetaRsp
);
case
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
:
case
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
:
return
metaUpdateTableTagVal
(
pMeta
,
version
,
pReq
);
return
metaUpdateTableTagVal
(
pMeta
,
version
,
pReq
);
case
TSDB_ALTER_TABLE_UPDATE_OPTIONS
:
case
TSDB_ALTER_TABLE_UPDATE_OPTIONS
:
...
@@ -649,8 +670,8 @@ int metaAlterTable(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq) {
...
@@ -649,8 +670,8 @@ int metaAlterTable(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq) {
static
int
metaSaveToTbDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
static
int
metaSaveToTbDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
STbDbKey
tbDbKey
;
STbDbKey
tbDbKey
;
void
*
pKey
=
NULL
;
void
*
pKey
=
NULL
;
void
*
pVal
=
NULL
;
void
*
pVal
=
NULL
;
int
kLen
=
0
;
int
kLen
=
0
;
int
vLen
=
0
;
int
vLen
=
0
;
SEncoder
coder
=
{
0
};
SEncoder
coder
=
{
0
};
...
@@ -733,16 +754,11 @@ static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
...
@@ -733,16 +754,11 @@ static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
int
metaCreateTagIdxKey
(
tb_uid_t
suid
,
int32_t
cid
,
const
void
*
pTagData
,
int32_t
nTagData
,
int8_t
type
,
tb_uid_t
uid
,
int
metaCreateTagIdxKey
(
tb_uid_t
suid
,
int32_t
cid
,
const
void
*
pTagData
,
int32_t
nTagData
,
int8_t
type
,
tb_uid_t
uid
,
STagIdxKey
**
ppTagIdxKey
,
int32_t
*
nTagIdxKey
)
{
STagIdxKey
**
ppTagIdxKey
,
int32_t
*
nTagIdxKey
)
{
// int32_t nTagData = 0;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
*
nTagIdxKey
=
sizeof
(
STagIdxKey
)
+
nTagData
+
VARSTR_HEADER_SIZE
+
sizeof
(
tb_uid_t
);
// if (pTagData) {
}
else
{
// if (IS_VAR_DATA_TYPE(type)) {
*
nTagIdxKey
=
sizeof
(
STagIdxKey
)
+
nTagData
+
sizeof
(
tb_uid_t
);
// nTagData = varDataTLen(pTagData);
}
// } else {
// nTagData = tDataTypes[type].bytes;
// }
// }
*
nTagIdxKey
=
sizeof
(
STagIdxKey
)
+
nTagData
+
sizeof
(
tb_uid_t
);
*
ppTagIdxKey
=
(
STagIdxKey
*
)
taosMemoryMalloc
(
*
nTagIdxKey
);
*
ppTagIdxKey
=
(
STagIdxKey
*
)
taosMemoryMalloc
(
*
nTagIdxKey
);
if
(
*
ppTagIdxKey
==
NULL
)
{
if
(
*
ppTagIdxKey
==
NULL
)
{
...
@@ -754,8 +770,16 @@ int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int32_
...
@@ -754,8 +770,16 @@ int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int32_
(
*
ppTagIdxKey
)
->
cid
=
cid
;
(
*
ppTagIdxKey
)
->
cid
=
cid
;
(
*
ppTagIdxKey
)
->
isNull
=
(
pTagData
==
NULL
)
?
1
:
0
;
(
*
ppTagIdxKey
)
->
isNull
=
(
pTagData
==
NULL
)
?
1
:
0
;
(
*
ppTagIdxKey
)
->
type
=
type
;
(
*
ppTagIdxKey
)
->
type
=
type
;
if
(
nTagData
)
memcpy
((
*
ppTagIdxKey
)
->
data
,
pTagData
,
nTagData
);
*
(
tb_uid_t
*
)((
*
ppTagIdxKey
)
->
data
+
nTagData
)
=
uid
;
// refactor
if
(
IS_VAR_DATA_TYPE
(
type
))
{
memcpy
((
*
ppTagIdxKey
)
->
data
,
(
uint16_t
*
)
&
nTagData
,
VARSTR_HEADER_SIZE
);
memcpy
((
*
ppTagIdxKey
)
->
data
+
VARSTR_HEADER_SIZE
,
pTagData
,
nTagData
);
*
(
tb_uid_t
*
)((
*
ppTagIdxKey
)
->
data
+
VARSTR_HEADER_SIZE
+
nTagData
)
=
uid
;
}
else
{
memcpy
((
*
ppTagIdxKey
)
->
data
,
pTagData
,
nTagData
);
*
(
tb_uid_t
*
)((
*
ppTagIdxKey
)
->
data
+
nTagData
)
=
uid
;
}
return
0
;
return
0
;
}
}
...
@@ -765,14 +789,14 @@ static void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey) {
...
@@ -765,14 +789,14 @@ static void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey) {
}
}
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
)
{
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
)
{
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int
nData
=
0
;
STbDbKey
tbDbKey
=
{
0
};
STbDbKey
tbDbKey
=
{
0
};
SMetaEntry
stbEntry
=
{
0
};
SMetaEntry
stbEntry
=
{
0
};
STagIdxKey
*
pTagIdxKey
=
NULL
;
STagIdxKey
*
pTagIdxKey
=
NULL
;
int32_t
nTagIdxKey
;
int32_t
nTagIdxKey
;
const
SSchema
*
pTagColumn
;
// = &stbEntry.stbEntry.schema.pSchema[0];
const
SSchema
*
pTagColumn
;
// = &stbEntry.stbEntry.schema.pSchema[0];
const
void
*
pTagData
=
NULL
;
//
const
void
*
pTagData
=
NULL
;
//
int32_t
nTagData
=
0
;
int32_t
nTagData
=
0
;
SDecoder
dc
=
{
0
};
SDecoder
dc
=
{
0
};
...
@@ -829,7 +853,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
...
@@ -829,7 +853,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
static
int
metaSaveToSkmDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
static
int
metaSaveToSkmDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SEncoder
coder
=
{
0
};
SEncoder
coder
=
{
0
};
void
*
pVal
=
NULL
;
void
*
pVal
=
NULL
;
int
vLen
=
0
;
int
vLen
=
0
;
int
rcode
=
0
;
int
rcode
=
0
;
SSkmDbKey
skmDbKey
=
{
0
};
SSkmDbKey
skmDbKey
=
{
0
};
...
...
source/dnode/vnode/src/sma/sma.c
浏览文件 @
46772d32
...
@@ -51,3 +51,11 @@ int32_t tdGetTSmaData(SSma* pSma, char* pData, int64_t indexUid, TSKEY querySKey
...
@@ -51,3 +51,11 @@ int32_t tdGetTSmaData(SSma* pSma, char* pData, int64_t indexUid, TSKEY querySKey
}
}
return
code
;
return
code
;
}
}
int32_t
smaGetTSmaDays
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tdGetTSmaDaysImpl
(
pCfg
,
pCont
,
contLen
,
days
))
<
0
)
{
smaWarn
(
"vgId:%d get tSma days failed since %s"
,
pCfg
->
vgId
,
tstrerror
(
terrno
));
}
return
code
;
}
source/dnode/vnode/src/sma/smaEnv.c
浏览文件 @
46772d32
...
@@ -278,7 +278,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType) {
...
@@ -278,7 +278,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType) {
void
*
tdFreeSmaStatItem
(
SSmaStatItem
*
pSmaStatItem
)
{
void
*
tdFreeSmaStatItem
(
SSmaStatItem
*
pSmaStatItem
)
{
if
(
pSmaStatItem
)
{
if
(
pSmaStatItem
)
{
t
d
DestroyTSma
(
pSmaStatItem
->
pTSma
);
tDestroyTSma
(
pSmaStatItem
->
pTSma
);
taosMemoryFreeClear
(
pSmaStatItem
->
pTSma
);
taosMemoryFreeClear
(
pSmaStatItem
->
pTSma
);
taosHashCleanup
(
pSmaStatItem
->
expiredWindows
);
taosHashCleanup
(
pSmaStatItem
->
expiredWindows
);
taosMemoryFreeClear
(
pSmaStatItem
);
taosMemoryFreeClear
(
pSmaStatItem
);
...
...
source/dnode/vnode/src/sma/smaTimeRange.c
浏览文件 @
46772d32
...
@@ -828,7 +828,7 @@ int32_t tdDropTSma(SSma *pSma, char *pMsg) {
...
@@ -828,7 +828,7 @@ int32_t tdDropTSma(SSma *pSma, char *pMsg) {
// TODO: send msg to stream computing to drop tSma
// TODO: send msg to stream computing to drop tSma
// if ((send msg to stream computing) < 0) {
// if ((send msg to stream computing) < 0) {
// t
d
DestroyTSma(&vCreateSmaReq);
// tDestroyTSma(&vCreateSmaReq);
// return -1;
// return -1;
// }
// }
//
//
...
@@ -982,25 +982,25 @@ int32_t tdUpdateExpiredWindowImpl(SSma *pSma, const SSubmitReq *pMsg, int64_t ve
...
@@ -982,25 +982,25 @@ int32_t tdUpdateExpiredWindowImpl(SSma *pSma, const SSubmitReq *pMsg, int64_t ve
SSubmitBlkIter
blkIter
=
{
0
};
SSubmitBlkIter
blkIter
=
{
0
};
if
(
tInitSubmitBlkIter
(
&
msgIter
,
pBlock
,
&
blkIter
)
<
0
)
{
if
(
tInitSubmitBlkIter
(
&
msgIter
,
pBlock
,
&
blkIter
)
<
0
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
,
false
);
pSW
=
tFreeTSmaWrapper
(
pSW
,
false
);
break
;
break
;
}
}
while
(
true
)
{
while
(
true
)
{
STSRow
*
row
=
tGetSubmitBlkNext
(
&
blkIter
);
STSRow
*
row
=
tGetSubmitBlkNext
(
&
blkIter
);
if
(
!
row
)
{
if
(
!
row
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
,
false
);
pSW
=
tFreeTSmaWrapper
(
pSW
,
false
);
break
;
break
;
}
}
if
(
!
pSW
||
(
pTSma
&&
(
pTSma
->
tableUid
!=
msgIter
.
suid
)))
{
if
(
!
pSW
||
(
pTSma
&&
(
pTSma
->
tableUid
!=
msgIter
.
suid
)))
{
if
(
pSW
)
{
if
(
pSW
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
,
false
);
pSW
=
tFreeTSmaWrapper
(
pSW
,
false
);
}
}
if
(
!
(
pSW
=
metaGetSmaInfoByTable
(
SMA_META
(
pSma
),
msgIter
.
suid
,
false
)))
{
if
(
!
(
pSW
=
metaGetSmaInfoByTable
(
SMA_META
(
pSma
),
msgIter
.
suid
,
false
)))
{
break
;
break
;
}
}
if
((
pSW
->
number
)
<=
0
||
!
pSW
->
tSma
)
{
if
((
pSW
->
number
)
<=
0
||
!
pSW
->
tSma
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
,
false
);
pSW
=
tFreeTSmaWrapper
(
pSW
,
false
);
break
;
break
;
}
}
...
@@ -1020,7 +1020,7 @@ int32_t tdUpdateExpiredWindowImpl(SSma *pSma, const SSubmitReq *pMsg, int64_t ve
...
@@ -1020,7 +1020,7 @@ int32_t tdUpdateExpiredWindowImpl(SSma *pSma, const SSubmitReq *pMsg, int64_t ve
if
(
lastWinSKey
!=
winSKey
)
{
if
(
lastWinSKey
!=
winSKey
)
{
lastWinSKey
=
winSKey
;
lastWinSKey
=
winSKey
;
if
(
tdSetExpiredWindow
(
pSma
,
pItemsHash
,
pTSma
->
indexUid
,
winSKey
,
version
)
<
0
)
{
if
(
tdSetExpiredWindow
(
pSma
,
pItemsHash
,
pTSma
->
indexUid
,
winSKey
,
version
)
<
0
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
,
false
);
pSW
=
tFreeTSmaWrapper
(
pSW
,
false
);
tdUnRefSmaStat
(
pSma
,
pStat
);
tdUnRefSmaStat
(
pSma
,
pStat
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
...
source/dnode/vnode/src/sma/smaTimeRange2.c
0 → 100644
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tq/tq.c
浏览文件 @
46772d32
...
@@ -260,18 +260,14 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -260,18 +260,14 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
pHandle
->
epoch
=
-
1
;
pHandle
->
epoch
=
-
1
;
pHandle
->
execHandle
.
subType
=
req
.
subType
;
pHandle
->
execHandle
.
subType
=
req
.
subType
;
/*pExec->withTbName = req.withTbName;*/
/*pExec->withSchema = req.withSchema;*/
/*pExec->withTag = req.withTag;*/
pHandle
->
execHandle
.
exec
.
execCol
.
qmsg
=
req
.
qmsg
;
req
.
qmsg
=
NULL
;
pHandle
->
pWalReader
=
walOpenReadHandle
(
pTq
->
pVnode
->
pWal
);
pHandle
->
pWalReader
=
walOpenReadHandle
(
pTq
->
pVnode
->
pWal
);
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
pHandle
->
execHandle
.
pExecReader
[
i
]
=
tqInitSubmitMsgScanner
(
pTq
->
pVnode
->
pMeta
);
pHandle
->
execHandle
.
pExecReader
[
i
]
=
tqInitSubmitMsgScanner
(
pTq
->
pVnode
->
pMeta
);
}
}
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
pHandle
->
execHandle
.
exec
.
execCol
.
qmsg
=
req
.
qmsg
;
req
.
qmsg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
SReadHandle
handle
=
{
SReadHandle
handle
=
{
.
reader
=
pHandle
->
execHandle
.
pExecReader
[
i
],
.
reader
=
pHandle
->
execHandle
.
pExecReader
[
i
],
...
@@ -286,6 +282,18 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -286,6 +282,18 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
pHandle
->
execHandle
.
exec
.
execDb
.
pFilterOutTbUid
=
pHandle
->
execHandle
.
exec
.
execDb
.
pFilterOutTbUid
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
}
else
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
}
else
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
pHandle
->
execHandle
.
exec
.
execTb
.
suid
=
req
.
suid
;
SArray
*
tbUidList
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
tsdbGetCtbIdList
(
pTq
->
pVnode
->
pMeta
,
req
.
suid
,
tbUidList
);
tqDebug
(
"vg %d, tq try get suid: %ld"
,
pTq
->
pVnode
->
config
.
vgId
,
req
.
suid
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
int64_t
tbUid
=
*
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
tqDebug
(
"vg %d, idx %d, uid: %ld"
,
pTq
->
pVnode
->
config
.
vgId
,
i
,
tbUid
);
}
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
tqReadHandleSetTbUidList
(
pHandle
->
execHandle
.
pExecReader
[
i
],
tbUidList
);
}
taosArrayDestroy
(
tbUidList
);
}
}
taosHashPut
(
pTq
->
handles
,
req
.
subKey
,
strlen
(
req
.
subKey
),
pHandle
,
sizeof
(
STqHandle
));
taosHashPut
(
pTq
->
handles
,
req
.
subKey
,
strlen
(
req
.
subKey
),
pHandle
,
sizeof
(
STqHandle
));
}
else
{
}
else
{
...
...
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
46772d32
...
@@ -20,6 +20,28 @@ void tqTmrRspFunc(void* param, void* tmrId) {
...
@@ -20,6 +20,28 @@ void tqTmrRspFunc(void* param, void* tmrId) {
atomic_store_8
(
&
pHandle
->
pushHandle
.
tmrStopped
,
1
);
atomic_store_8
(
&
pHandle
->
pushHandle
.
tmrStopped
,
1
);
}
}
static
int32_t
tqLoopExecFromQueue
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
SStreamDataSubmit
**
ppSubmit
,
SMqDataBlkRsp
*
pRsp
)
{
SStreamDataSubmit
*
pSubmit
=
*
ppSubmit
;
while
(
pSubmit
!=
NULL
)
{
ASSERT
(
pSubmit
->
ver
==
pHandle
->
pushHandle
.
processedVer
+
1
);
if
(
tqDataExec
(
pTq
,
&
pHandle
->
execHandle
,
pSubmit
->
data
,
pRsp
,
0
)
<
0
)
{
/*ASSERT(0);*/
}
// update processed
atomic_store_64
(
&
pHandle
->
pushHandle
.
processedVer
,
pSubmit
->
ver
);
streamQSetSuccess
(
&
pHandle
->
pushHandle
.
inputQ
);
streamDataSubmitRefDec
(
pSubmit
);
if
(
pRsp
->
blockNum
>
0
)
{
*
ppSubmit
=
pSubmit
;
return
0
;
}
else
{
pSubmit
=
streamQNextItem
(
&
pHandle
->
pushHandle
.
inputQ
);
}
}
*
ppSubmit
=
pSubmit
;
return
-
1
;
}
int32_t
tqExecFromInputQ
(
STQ
*
pTq
,
STqHandle
*
pHandle
)
{
int32_t
tqExecFromInputQ
(
STQ
*
pTq
,
STqHandle
*
pHandle
)
{
SMqDataBlkRsp
rsp
=
{
0
};
SMqDataBlkRsp
rsp
=
{
0
};
// 1. guard and set status executing
// 1. guard and set status executing
...
@@ -42,38 +64,14 @@ int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) {
...
@@ -42,38 +64,14 @@ int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) {
}
}
// 3. exec, after each success, update processed ver
// 3. exec, after each success, update processed ver
// first run
// first run
while
(
pSubmit
!=
NULL
)
{
if
(
tqLoopExecFromQueue
(
pTq
,
pHandle
,
&
pSubmit
,
&
rsp
)
==
0
)
{
ASSERT
(
pSubmit
->
ver
==
pHandle
->
pushHandle
.
processedVer
+
1
);
goto
SEND_RSP
;
if
(
tqDataExec
(
pTq
,
&
pHandle
->
execHandle
,
pSubmit
->
data
,
&
rsp
,
0
)
<
0
)
{
/*ASSERT(0);*/
}
// update processed
atomic_store_64
(
&
pHandle
->
pushHandle
.
processedVer
,
pSubmit
->
ver
);
streamQSetSuccess
(
&
pHandle
->
pushHandle
.
inputQ
);
streamDataSubmitRefDec
(
pSubmit
);
if
(
rsp
.
blockNum
>
0
)
{
goto
SEND_RSP
;
}
else
{
pSubmit
=
streamQNextItem
(
&
pHandle
->
pushHandle
.
inputQ
);
}
}
}
// set exec status closing
// set exec status closing
atomic_store_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_STATUS__CLOSING
);
atomic_store_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_STATUS__CLOSING
);
// second run
// second run
while
(
pSubmit
!=
NULL
)
{
if
(
tqLoopExecFromQueue
(
pTq
,
pHandle
,
&
pSubmit
,
&
rsp
)
==
0
)
{
ASSERT
(
pSubmit
->
ver
==
pHandle
->
pushHandle
.
processedVer
+
1
);
goto
SEND_RSP
;
if
(
tqDataExec
(
pTq
,
&
pHandle
->
execHandle
,
pSubmit
->
data
,
&
rsp
,
0
)
<
0
)
{
/*ASSERT(0);*/
}
// update processed
atomic_store_64
(
&
pHandle
->
pushHandle
.
processedVer
,
pSubmit
->
ver
);
streamQSetSuccess
(
&
pHandle
->
pushHandle
.
inputQ
);
streamDataSubmitRefDec
(
pSubmit
);
if
(
rsp
.
blockNum
>
0
)
{
goto
SEND_RSP
;
}
else
{
pSubmit
=
streamQNextItem
(
&
pHandle
->
pushHandle
.
inputQ
);
}
}
}
// set exec status idle
// set exec status idle
atomic_store_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_STATUS__IDLE
);
atomic_store_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_STATUS__IDLE
);
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
46772d32
...
@@ -88,6 +88,18 @@ static void tsdbLoadAndMergeFromCache(STsdb *pTsdb, SDataCols *pDataCols, int *i
...
@@ -88,6 +88,18 @@ static void tsdbLoadAndMergeFromCache(STsdb *pTsdb, SDataCols *pDataCols, int *i
SDataCols
*
pTarget
,
TSKEY
maxKey
,
int
maxRows
,
int8_t
update
);
SDataCols
*
pTarget
,
TSKEY
maxKey
,
int
maxRows
,
int8_t
update
);
int
tsdbWriteBlockIdx
(
SDFile
*
pHeadf
,
SArray
*
pIdxA
,
void
**
ppBuf
);
int
tsdbWriteBlockIdx
(
SDFile
*
pHeadf
,
SArray
*
pIdxA
,
void
**
ppBuf
);
int
tsdbBegin
(
STsdb
*
pTsdb
)
{
if
(
!
pTsdb
)
return
0
;
STsdbMemTable
*
pMem
;
if
(
tsdbMemTableCreate
(
pTsdb
,
&
pTsdb
->
mem
)
<
0
)
{
return
-
1
;
}
return
0
;
}
int
tsdbApplyRtnOnFSet
(
STsdb
*
pRepo
,
SDFileSet
*
pSet
,
SRtn
*
pRtn
)
{
int
tsdbApplyRtnOnFSet
(
STsdb
*
pRepo
,
SDFileSet
*
pSet
,
SRtn
*
pRtn
)
{
SDiskID
did
;
SDiskID
did
;
SDFileSet
nSet
=
{
0
};
SDFileSet
nSet
=
{
0
};
...
...
source/dnode/vnode/src/tsdb/tsdbCommit2.c
已删除
100644 → 0
浏览文件 @
ecaea669
/*
* 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/>.
*/
#include "tsdb.h"
int
tsdbBegin
(
STsdb
*
pTsdb
)
{
if
(
!
pTsdb
)
return
0
;
STsdbMemTable
*
pMem
;
if
(
tsdbMemTableCreate
(
pTsdb
,
&
pTsdb
->
mem
)
<
0
)
{
return
-
1
;
}
return
0
;
}
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
46772d32
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "vnode.h"
#include "tsdb.h"
#include "tsdb.h"
#include "vnode.h"
#define EXTRA_BYTES 2
#define EXTRA_BYTES 2
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
...
@@ -327,8 +327,8 @@ static void setQueryTimewindow(STsdbReadHandle* pTsdbReadHandle, SQueryTableData
...
@@ -327,8 +327,8 @@ static void setQueryTimewindow(STsdbReadHandle* pTsdbReadHandle, SQueryTableData
if
(
updateTs
)
{
if
(
updateTs
)
{
tsdbDebug
(
"%p update the query time window, old:%"
PRId64
" - %"
PRId64
", new:%"
PRId64
" - %"
PRId64
", %s"
,
tsdbDebug
(
"%p update the query time window, old:%"
PRId64
" - %"
PRId64
", new:%"
PRId64
" - %"
PRId64
", %s"
,
pTsdbReadHandle
,
pCond
->
twindows
[
tWinIdx
].
skey
,
pCond
->
twindows
[
tWinIdx
].
ekey
,
pTsdbReadHandle
->
window
.
skey
,
pTsdbReadHandle
,
pCond
->
twindows
[
tWinIdx
].
skey
,
pCond
->
twindows
[
tWinIdx
].
ekey
,
pTsdbReadHandle
->
window
.
ekey
,
pTsdbReadHandle
->
idStr
);
pTsdbReadHandle
->
window
.
skey
,
pTsdbReadHandle
->
window
.
ekey
,
pTsdbReadHandle
->
idStr
);
}
}
}
}
...
@@ -586,7 +586,8 @@ void tsdbResetReadHandle(tsdbReaderT queryHandle, SQueryTableDataCond* pCond, in
...
@@ -586,7 +586,8 @@ void tsdbResetReadHandle(tsdbReaderT queryHandle, SQueryTableDataCond* pCond, in
resetCheckInfo
(
pTsdbReadHandle
);
resetCheckInfo
(
pTsdbReadHandle
);
}
}
void
tsdbResetQueryHandleForNewTable
(
tsdbReaderT
queryHandle
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
int32_t
tWinIdx
)
{
void
tsdbResetQueryHandleForNewTable
(
tsdbReaderT
queryHandle
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
int32_t
tWinIdx
)
{
STsdbReadHandle
*
pTsdbReadHandle
=
queryHandle
;
STsdbReadHandle
*
pTsdbReadHandle
=
queryHandle
;
pTsdbReadHandle
->
order
=
pCond
->
order
;
pTsdbReadHandle
->
order
=
pCond
->
order
;
...
@@ -2845,6 +2846,22 @@ int32_t tsdbGetAllTableList(SMeta* pMeta, uint64_t uid, SArray* list) {
...
@@ -2845,6 +2846,22 @@ int32_t tsdbGetAllTableList(SMeta* pMeta, uint64_t uid, SArray* list) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
tsdbGetCtbIdList
(
SMeta
*
pMeta
,
int64_t
suid
,
SArray
*
list
)
{
SMCtbCursor
*
pCur
=
metaOpenCtbCursor
(
pMeta
,
suid
);
while
(
1
)
{
tb_uid_t
id
=
metaCtbCursorNext
(
pCur
);
if
(
id
==
0
)
{
break
;
}
taosArrayPush
(
list
,
&
id
);
}
metaCloseCtbCursor
(
pCur
);
return
TSDB_CODE_SUCCESS
;
}
static
void
destroyHelper
(
void
*
param
)
{
static
void
destroyHelper
(
void
*
param
)
{
if
(
param
==
NULL
)
{
if
(
param
==
NULL
)
{
return
;
return
;
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
46772d32
...
@@ -252,6 +252,13 @@ void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
...
@@ -252,6 +252,13 @@ void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
tdProcessTSmaInsert
(((
SVnode
*
)
pVnode
)
->
pSma
,
smaId
,
(
const
char
*
)
data
);
tdProcessTSmaInsert
(((
SVnode
*
)
pVnode
)
->
pSma
,
smaId
,
(
const
char
*
)
data
);
}
}
void
vnodeUpdateMetaRsp
(
SVnode
*
pVnode
,
STableMetaRsp
*
pMetaRsp
)
{
strcpy
(
pMetaRsp
->
dbFName
,
pVnode
->
config
.
dbname
);
pMetaRsp
->
dbId
=
pVnode
->
config
.
dbId
;
pMetaRsp
->
vgId
=
TD_VID
(
pVnode
);
pMetaRsp
->
precision
=
pVnode
->
config
.
tsdbCfg
.
precision
;
}
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
int32_t
ret
=
TAOS_SYNC_PROPOSE_OTHER_ERROR
;
int32_t
ret
=
TAOS_SYNC_PROPOSE_OTHER_ERROR
;
...
@@ -521,12 +528,13 @@ _exit:
...
@@ -521,12 +528,13 @@ _exit:
}
}
static
int
vnodeProcessAlterTbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
)
{
static
int
vnodeProcessAlterTbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
)
{
SVAlterTbReq
vAlterTbReq
=
{
0
};
SVAlterTbReq
vAlterTbReq
=
{
0
};
SVAlterTbRsp
vAlterTbRsp
=
{
0
};
SVAlterTbRsp
vAlterTbRsp
=
{
0
};
SDecoder
dc
=
{
0
};
SDecoder
dc
=
{
0
};
int
rcode
=
0
;
int
rcode
=
0
;
int
ret
;
int
ret
;
SEncoder
ec
=
{
0
};
SEncoder
ec
=
{
0
};
STableMetaRsp
vMetaRsp
=
{
0
};
pRsp
->
msgType
=
TDMT_VND_ALTER_TABLE_RSP
;
pRsp
->
msgType
=
TDMT_VND_ALTER_TABLE_RSP
;
pRsp
->
pCont
=
NULL
;
pRsp
->
pCont
=
NULL
;
...
@@ -544,7 +552,7 @@ static int vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, i
...
@@ -544,7 +552,7 @@ static int vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, i
}
}
// process
// process
if
(
metaAlterTable
(
pVnode
->
pMeta
,
version
,
&
vAlterTbReq
)
<
0
)
{
if
(
metaAlterTable
(
pVnode
->
pMeta
,
version
,
&
vAlterTbReq
,
&
vMetaRsp
)
<
0
)
{
vAlterTbRsp
.
code
=
TSDB_CODE_INVALID_MSG
;
vAlterTbRsp
.
code
=
TSDB_CODE_INVALID_MSG
;
tDecoderClear
(
&
dc
);
tDecoderClear
(
&
dc
);
rcode
=
-
1
;
rcode
=
-
1
;
...
@@ -552,6 +560,11 @@ static int vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, i
...
@@ -552,6 +560,11 @@ static int vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, i
}
}
tDecoderClear
(
&
dc
);
tDecoderClear
(
&
dc
);
if
(
NULL
!=
vMetaRsp
.
pSchemas
)
{
vnodeUpdateMetaRsp
(
pVnode
,
&
vMetaRsp
);
vAlterTbRsp
.
pMeta
=
&
vMetaRsp
;
}
_exit:
_exit:
tEncodeSize
(
tEncodeSVAlterTbRsp
,
&
vAlterTbRsp
,
pRsp
->
contLen
,
ret
);
tEncodeSize
(
tEncodeSVAlterTbRsp
,
&
vAlterTbRsp
,
pRsp
->
contLen
,
ret
);
pRsp
->
pCont
=
rpcMallocCont
(
pRsp
->
contLen
);
pRsp
->
pCont
=
rpcMallocCont
(
pRsp
->
contLen
);
...
...
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/catalog/inc/catalogInt.h
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/catalog/src/catalog.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/catalog/src/ctgCache.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/executor/inc/executil.h
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/executor/inc/executorimpl.h
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/executor/src/executil.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/executor/src/executorimpl.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/executor/src/groupoperator.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/executor/src/scanoperator.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/executor/src/timewindowoperator.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/function/inc/builtins.h
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/function/inc/builtinsimpl.h
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/function/inc/taggfunction.h
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/function/src/builtins.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/function/src/builtinsimpl.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/function/src/functionMgt.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/function/src/taggfunction.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/function/src/texpr.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/index/src/indexFilter.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/parser/inc/parInt.h
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/parser/src/parInsert.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/parser/src/parTranslater.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalogService.h
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/planner/inc/planInt.h
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/planner/src/planLogicCreater.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/planner/src/planSpliter.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/planner/src/planUtil.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/planner/src/planner.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/planner/test/planIntervalTest.cpp
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/planner/test/planOtherTest.cpp
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/qcom/src/queryUtil.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/qcom/src/querymsg.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/scalar/src/sclfunc.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/scheduler/inc/schedulerInt.h
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/scheduler/src/schJob.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/scheduler/src/schRemote.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/transport/src/transCli.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/libs/wal/src/walWrite.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/util/src/terror.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
source/util/src/tlist.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/script/jenkins/basic.txt
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/script/tsim/catalog/alterInCurrent.sim
0 → 100644
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/script/tsim/mnode/basic4.sim
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/script/tsim/stable/column_drop.sim
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/script/tsim/stream/basic0.sim
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/system-test/1-insert/influxdb_line_taosc_insert.py
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/system-test/1-insert/opentsdb_json_taosc_insert.py
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/system-test/2-query/mavg.py
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/system-test/fulltest.sh
100644 → 100755
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/test/c/sdbDump.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
tests/test/c/tmqSim.c
浏览文件 @
46772d32
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录