Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6a889ae8
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看板
提交
6a889ae8
编写于
4月 27, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'main' of
https://github.com/taosdata/TDengine
into fix/TS-3222
上级
224d87b1
6436351a
变更
58
展开全部
隐藏空白更改
内联
并排
Showing
58 changed file
with
2273 addition
and
885 deletion
+2273
-885
cmake/taosadapter_CMakeLists.txt.in
cmake/taosadapter_CMakeLists.txt.in
+1
-1
include/common/systable.h
include/common/systable.h
+1
-1
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+6
-2
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+2
-0
include/libs/qcom/query.h
include/libs/qcom/query.h
+2
-2
packaging/deb/DEBIAN/preinst
packaging/deb/DEBIAN/preinst
+37
-0
packaging/deb/DEBIAN/prerm
packaging/deb/DEBIAN/prerm
+1
-0
packaging/deb/makedeb.sh
packaging/deb/makedeb.sh
+26
-0
packaging/rpm/makerpm.sh
packaging/rpm/makerpm.sh
+23
-1
packaging/rpm/tdengine.spec
packaging/rpm/tdengine.spec
+19
-2
packaging/tools/post.sh
packaging/tools/post.sh
+28
-11
packaging/tools/preun.sh
packaging/tools/preun.sh
+16
-1
source/client/src/clientMain.c
source/client/src/clientMain.c
+19
-17
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+1
-5
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+23
-20
source/common/src/tmsg.c
source/common/src/tmsg.c
+5
-4
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+10
-2
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+1
-5
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+2
-0
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+0
-1
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+29
-11
source/dnode/vnode/src/tq/tqScan.c
source/dnode/vnode/src/tq/tqScan.c
+0
-2
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+7
-5
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
+10
-1
source/dnode/vnode/src/tsdb/tsdbDataIter.c
source/dnode/vnode/src/tsdb/tsdbDataIter.c
+39
-22
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+3
-2
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
+34
-73
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+329
-297
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+15
-11
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+118
-229
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+19
-0
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+58
-1
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+269
-9
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+27
-2
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+96
-40
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+2
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+8
-2
source/libs/parser/src/parAuthenticator.c
source/libs/parser/src/parAuthenticator.c
+3
-3
source/libs/parser/src/parInsertSql.c
source/libs/parser/src/parInsertSql.c
+100
-14
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+10
-3
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+1
-1
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+1
-1
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+14
-12
source/os/src/osFile.c
source/os/src/osFile.c
+3
-2
source/util/src/tlog.c
source/util/src/tlog.c
+1
-3
source/util/src/tsimplehash.c
source/util/src/tsimplehash.c
+0
-4
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+4
-0
tests/script/tsim/user/privilege_table.sim
tests/script/tsim/user/privilege_table.sim
+302
-0
tests/script/win-test-file
tests/script/win-test-file
+1
-0
tests/system-test/0-others/multilevel.py
tests/system-test/0-others/multilevel.py
+263
-0
tests/system-test/1-insert/alter_replica.py
tests/system-test/1-insert/alter_replica.py
+114
-0
tests/system-test/1-insert/delete_systable.py
tests/system-test/1-insert/delete_systable.py
+111
-0
tests/system-test/6-cluster/clusterCommonCreate.py
tests/system-test/6-cluster/clusterCommonCreate.py
+20
-20
tests/system-test/7-tmq/subscribeDb3.py
tests/system-test/7-tmq/subscribeDb3.py
+24
-22
tests/system-test/7-tmq/tmqCommon.py
tests/system-test/7-tmq/tmqCommon.py
+11
-13
tests/system-test/7-tmq/tmqConsumerGroup.py
tests/system-test/7-tmq/tmqConsumerGroup.py
+1
-1
tests/system-test/7-tmq/tmqDnodeRestart1.py
tests/system-test/7-tmq/tmqDnodeRestart1.py
+2
-2
未找到文件。
cmake/taosadapter_CMakeLists.txt.in
浏览文件 @
6a889ae8
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# taosadapter
# taosadapter
ExternalProject_Add(taosadapter
ExternalProject_Add(taosadapter
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
GIT_TAG
e02ddb2
GIT_TAG
ae8d51c
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
BINARY_DIR ""
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
#BUILD_IN_SOURCE TRUE
...
...
include/common/systable.h
浏览文件 @
6a889ae8
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
* You should have received a copy of the GNU Affero General Public License
* 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/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef TDENGINE_SYSTABLE_H
#ifndef TDENGINE_SYSTABLE_H
#define TDENGINE_SYSTABLE_H
#define TDENGINE_SYSTABLE_H
...
...
include/common/tmsg.h
浏览文件 @
6a889ae8
...
@@ -689,6 +689,7 @@ typedef struct {
...
@@ -689,6 +689,7 @@ typedef struct {
int32_t
tSerializeSAlterUserReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterUserReq
*
pReq
);
int32_t
tSerializeSAlterUserReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterUserReq
*
pReq
);
int32_t
tDeserializeSAlterUserReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterUserReq
*
pReq
);
int32_t
tDeserializeSAlterUserReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterUserReq
*
pReq
);
void
tFreeSAlterUserReq
(
SAlterUserReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
char
user
[
TSDB_USER_LEN
];
...
...
include/libs/catalog/catalog.h
浏览文件 @
6a889ae8
...
@@ -82,6 +82,7 @@ typedef struct SCatalogReq {
...
@@ -82,6 +82,7 @@ typedef struct SCatalogReq {
SArray
*
pUser
;
// element is SUserAuthInfo
SArray
*
pUser
;
// element is SUserAuthInfo
SArray
*
pTableIndex
;
// element is SNAME
SArray
*
pTableIndex
;
// element is SNAME
SArray
*
pTableCfg
;
// element is SNAME
SArray
*
pTableCfg
;
// element is SNAME
SArray
*
pTableTag
;
// element is SNAME
bool
qNodeRequired
;
// valid qnode
bool
qNodeRequired
;
// valid qnode
bool
dNodeRequired
;
// valid dnode
bool
dNodeRequired
;
// valid dnode
bool
svrVerRequired
;
bool
svrVerRequired
;
...
@@ -105,6 +106,7 @@ typedef struct SMetaData {
...
@@ -105,6 +106,7 @@ typedef struct SMetaData {
SArray
*
pUser
;
// pRes = SUserAuthRes*
SArray
*
pUser
;
// pRes = SUserAuthRes*
SArray
*
pQnodeList
;
// pRes = SArray<SQueryNodeLoad>*
SArray
*
pQnodeList
;
// pRes = SArray<SQueryNodeLoad>*
SArray
*
pTableCfg
;
// pRes = STableCfg*
SArray
*
pTableCfg
;
// pRes = STableCfg*
SArray
*
pTableTag
;
// pRes = SArray<STagVal>*
SArray
*
pDnodeList
;
// pRes = SArray<SEpSet>*
SArray
*
pDnodeList
;
// pRes = SArray<SEpSet>*
SMetaRes
*
pSvrVer
;
// pRes = char*
SMetaRes
*
pSvrVer
;
// pRes = char*
}
SMetaData
;
}
SMetaData
;
...
@@ -122,8 +124,8 @@ typedef struct SSTableVersion {
...
@@ -122,8 +124,8 @@ typedef struct SSTableVersion {
char
stbName
[
TSDB_TABLE_NAME_LEN
];
char
stbName
[
TSDB_TABLE_NAME_LEN
];
uint64_t
dbId
;
uint64_t
dbId
;
uint64_t
suid
;
uint64_t
suid
;
int
16
_t
sversion
;
int
32
_t
sversion
;
int
16
_t
tversion
;
int
32
_t
tversion
;
int32_t
smaVer
;
int32_t
smaVer
;
}
SSTableVersion
;
}
SSTableVersion
;
...
@@ -312,6 +314,8 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
...
@@ -312,6 +314,8 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
int32_t
catalogGetTableIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
);
int32_t
catalogGetTableIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
);
int32_t
catalogGetTableTag
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
);
int32_t
catalogRefreshGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
);
int32_t
catalogRefreshGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
);
int32_t
catalogUpdateTableIndex
(
SCatalog
*
pCtg
,
STableIndexRsp
*
pRsp
);
int32_t
catalogUpdateTableIndex
(
SCatalog
*
pCtg
,
STableIndexRsp
*
pRsp
);
...
...
include/libs/nodes/querynodes.h
浏览文件 @
6a889ae8
...
@@ -379,6 +379,8 @@ typedef struct SVnodeModifyOpStmt {
...
@@ -379,6 +379,8 @@ typedef struct SVnodeModifyOpStmt {
SName
usingTableName
;
SName
usingTableName
;
const
char
*
pBoundCols
;
const
char
*
pBoundCols
;
struct
STableMeta
*
pTableMeta
;
struct
STableMeta
*
pTableMeta
;
SNode
*
pTagCond
;
SArray
*
pTableTag
;
SHashObj
*
pVgroupsHashObj
;
SHashObj
*
pVgroupsHashObj
;
SHashObj
*
pTableBlockHashObj
;
// SHashObj<tuid, STableDataCxt*>
SHashObj
*
pTableBlockHashObj
;
// SHashObj<tuid, STableDataCxt*>
SHashObj
*
pSubTableHashObj
;
SHashObj
*
pSubTableHashObj
;
...
...
include/libs/qcom/query.h
浏览文件 @
6a889ae8
...
@@ -116,8 +116,8 @@ typedef struct STableMeta {
...
@@ -116,8 +116,8 @@ typedef struct STableMeta {
// if the table is TSDB_CHILD_TABLE, the following information is acquired from the corresponding super table meta
// if the table is TSDB_CHILD_TABLE, the following information is acquired from the corresponding super table meta
// info
// info
int
16
_t
sversion
;
int
32
_t
sversion
;
int
16
_t
tversion
;
int
32
_t
tversion
;
STableComInfo
tableInfo
;
STableComInfo
tableInfo
;
SSchema
schema
[];
SSchema
schema
[];
}
STableMeta
;
}
STableMeta
;
...
...
packaging/deb/DEBIAN/preinst
浏览文件 @
6a889ae8
...
@@ -26,6 +26,38 @@ if pidof taosd &> /dev/null; then
...
@@ -26,6 +26,38 @@ if pidof taosd &> /dev/null; then
sleep
1
sleep
1
fi
fi
# Stop adapter service if running
if
pidof taosadapter &> /dev/null
;
then
if
pidof systemd &> /dev/null
;
then
${
csudo
}
systemctl stop taosadapter
||
:
elif
$(
which service &> /dev/null
)
;
then
${
csudo
}
service taosadapter stop
||
:
else
pid
=
$(
ps
-ef
|
grep
"taosadapter"
|
grep
-v
"grep"
|
awk
'{print $2}'
)
if
[
-n
"
$pid
"
]
;
then
${
csudo
}
kill
-9
$pid
||
:
fi
fi
echo
"Stop taosadapter service success!"
sleep
1
fi
# Stop keeper service if running
if
pidof taoskeeper &> /dev/null
;
then
if
pidof systemd &> /dev/null
;
then
${
csudo
}
systemctl stop taoskeeper
||
:
elif
$(
which service &> /dev/null
)
;
then
${
csudo
}
service taoskeeper stop
||
:
else
pid
=
$(
ps
-ef
|
grep
"taoskeeper"
|
grep
-v
"grep"
|
awk
'{print $2}'
)
if
[
-n
"
$pid
"
]
;
then
${
csudo
}
kill
-9
$pid
||
:
fi
fi
echo
"Stop taoskeeper service success!"
sleep
1
fi
# if taos.cfg already softlink, remove it
# if taos.cfg already softlink, remove it
cfg_install_dir
=
"/etc/taos"
cfg_install_dir
=
"/etc/taos"
install_main_dir
=
"/usr/local/taos"
install_main_dir
=
"/usr/local/taos"
...
@@ -41,6 +73,11 @@ if [ -f "${install_main_dir}/taosadapter.service" ]; then
...
@@ -41,6 +73,11 @@ if [ -f "${install_main_dir}/taosadapter.service" ]; then
${
csudo
}
rm
-f
${
install_main_dir
}
/cfg/taosadapter.service
||
:
${
csudo
}
rm
-f
${
install_main_dir
}
/cfg/taosadapter.service
||
:
fi
fi
if
[
-f
"
${
install_main_dir
}
/taoskeeper.toml"
]
;
then
${
csudo
}
rm
-f
${
install_main_dir
}
/cfg/taoskeeper.toml
||
:
fi
# there can not libtaos.so*, otherwise ln -s error
# there can not libtaos.so*, otherwise ln -s error
${
csudo
}
rm
-f
${
install_main_dir
}
/driver/libtaos.
*
||
:
${
csudo
}
rm
-f
${
install_main_dir
}
/driver/libtaos.
*
||
:
[
-f
${
install_main_dir
}
/driver/libtaosws.so
]
&&
${
csudo
}
rm
-f
${
install_main_dir
}
/driver/libtaosws.so
||
:
[
-f
${
install_main_dir
}
/driver/libtaosws.so
]
&&
${
csudo
}
rm
-f
${
install_main_dir
}
/driver/libtaosws.so
||
:
packaging/deb/DEBIAN/prerm
浏览文件 @
6a889ae8
...
@@ -32,6 +32,7 @@ else
...
@@ -32,6 +32,7 @@ else
${
csudo
}
rm
-f
${
bin_link_dir
}
/udfd
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/udfd
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosadapter
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosadapter
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosdemo
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosdemo
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taoskeeper
||
:
${
csudo
}
rm
-f
${
cfg_link_dir
}
/
*
||
:
${
csudo
}
rm
-f
${
cfg_link_dir
}
/
*
||
:
${
csudo
}
rm
-f
${
inc_link_dir
}
/taos.h
||
:
${
csudo
}
rm
-f
${
inc_link_dir
}
/taos.h
||
:
${
csudo
}
rm
-f
${
inc_link_dir
}
/taosdef.h
||
:
${
csudo
}
rm
-f
${
inc_link_dir
}
/taosdef.h
||
:
...
...
packaging/deb/makedeb.sh
浏览文件 @
6a889ae8
...
@@ -44,8 +44,31 @@ mkdir -p ${pkg_dir}${install_home_path}/include
...
@@ -44,8 +44,31 @@ mkdir -p ${pkg_dir}${install_home_path}/include
#mkdir -p ${pkg_dir}${install_home_path}/init.d
#mkdir -p ${pkg_dir}${install_home_path}/init.d
mkdir
-p
${
pkg_dir
}${
install_home_path
}
/script
mkdir
-p
${
pkg_dir
}${
install_home_path
}
/script
# download taoskeeper and build
if
[
"
$cpuType
"
=
"x64"
]
||
[
"
$cpuType
"
=
"x86_64"
]
||
[
"
$cpuType
"
=
"amd64"
]
;
then
arch
=
amd64
elif
[
"
$cpuType
"
=
"x32"
]
||
[
"
$cpuType
"
=
"i386"
]
||
[
"
$cpuType
"
=
"i686"
]
;
then
arch
=
386
elif
[
"
$cpuType
"
=
"arm"
]
||
[
"
$cpuType
"
=
"aarch32"
]
;
then
arch
=
arm
elif
[
"
$cpuType
"
=
"arm64"
]
||
[
"
$cpuType
"
=
"aarch64"
]
;
then
arch
=
arm64
else
arch
=
$cpuType
fi
echo
"
${
top_dir
}
/../enterprise/packaging/build_taoskeeper.sh -r
${
arch
}
-e taoskeeper"
echo
"
$top_dir
=
${
top_dir
}
"
taoskeeper_binary
=
`
${
top_dir
}
/../enterprise/packaging/build_taoskeeper.sh
-r
$arch
-e
taoskeeper
`
echo
"taoskeeper_binary:
${
taoskeeper_binary
}
"
# copy config files
cp
$(
dirname
${
taoskeeper_binary
}
)
/config/taoskeeper.toml
${
pkg_dir
}${
install_home_path
}
/cfg
cp
$(
dirname
${
taoskeeper_binary
}
)
/taoskeeper.service
${
pkg_dir
}${
install_home_path
}
/cfg
cp
${
compile_dir
}
/../packaging/cfg/taos.cfg
${
pkg_dir
}${
install_home_path
}
/cfg
cp
${
compile_dir
}
/../packaging/cfg/taos.cfg
${
pkg_dir
}${
install_home_path
}
/cfg
cp
${
compile_dir
}
/../packaging/cfg/taosd.service
${
pkg_dir
}${
install_home_path
}
/cfg
cp
${
compile_dir
}
/../packaging/cfg/taosd.service
${
pkg_dir
}${
install_home_path
}
/cfg
if
[
-f
"
${
compile_dir
}
/test/cfg/taosadapter.toml"
]
;
then
if
[
-f
"
${
compile_dir
}
/test/cfg/taosadapter.toml"
]
;
then
cp
${
compile_dir
}
/test/cfg/taosadapter.toml
${
pkg_dir
}${
install_home_path
}
/cfg
||
:
cp
${
compile_dir
}
/test/cfg/taosadapter.toml
${
pkg_dir
}${
install_home_path
}
/cfg
||
:
fi
fi
...
@@ -53,6 +76,7 @@ if [ -f "${compile_dir}/test/cfg/taosadapter.service" ]; then
...
@@ -53,6 +76,7 @@ if [ -f "${compile_dir}/test/cfg/taosadapter.service" ]; then
cp
${
compile_dir
}
/test/cfg/taosadapter.service
${
pkg_dir
}${
install_home_path
}
/cfg
||
:
cp
${
compile_dir
}
/test/cfg/taosadapter.service
${
pkg_dir
}${
install_home_path
}
/cfg
||
:
fi
fi
cp
${
taoskeeper_binary
}
${
pkg_dir
}${
install_home_path
}
/bin
#cp ${compile_dir}/../packaging/deb/taosd ${pkg_dir}${install_home_path}/init.d
#cp ${compile_dir}/../packaging/deb/taosd ${pkg_dir}${install_home_path}/init.d
cp
${
compile_dir
}
/../packaging/tools/post.sh
${
pkg_dir
}${
install_home_path
}
/script
cp
${
compile_dir
}
/../packaging/tools/post.sh
${
pkg_dir
}${
install_home_path
}
/script
cp
${
compile_dir
}
/../packaging/tools/preun.sh
${
pkg_dir
}${
install_home_path
}
/script
cp
${
compile_dir
}
/../packaging/tools/preun.sh
${
pkg_dir
}${
install_home_path
}
/script
...
@@ -143,6 +167,7 @@ else
...
@@ -143,6 +167,7 @@ else
exit
1
exit
1
fi
fi
rm
-rf
${
pkg_dir
}
/build-taoskeeper
# make deb package
# make deb package
dpkg
-b
${
pkg_dir
}
$debname
dpkg
-b
${
pkg_dir
}
$debname
echo
"make deb package success!"
echo
"make deb package success!"
...
@@ -150,4 +175,5 @@ echo "make deb package success!"
...
@@ -150,4 +175,5 @@ echo "make deb package success!"
cp
${
pkg_dir
}
/
*
.deb
${
output_dir
}
cp
${
pkg_dir
}
/
*
.deb
${
output_dir
}
# clean temp dir
# clean temp dir
rm
-rf
${
pkg_dir
}
rm
-rf
${
pkg_dir
}
packaging/rpm/makerpm.sh
浏览文件 @
6a889ae8
...
@@ -35,14 +35,16 @@ function cp_rpm_package() {
...
@@ -35,14 +35,16 @@ function cp_rpm_package() {
local
cur_dir
local
cur_dir
cd
$1
cd
$1
cur_dir
=
$(
pwd
)
cur_dir
=
$(
pwd
)
echo
"cp_rpm_package cd:
${
cur_dir
}
"
for
dirlist
in
"
$(
ls
${
cur_dir
}
)
"
;
do
for
dirlist
in
"
$(
ls
${
cur_dir
}
)
"
;
do
if
test
-d
${
dirlist
}
;
then
if
test
-d
${
dirlist
}
;
then
cd
${
dirlist
}
cd
${
dirlist
}
echo
'cp_rpm_package ${cur_dir}/${dirlist}'
cp_rpm_package
${
cur_dir
}
/
${
dirlist
}
cp_rpm_package
${
cur_dir
}
/
${
dirlist
}
cd
..
cd
..
fi
fi
if
test
-e
${
dirlist
}
;
then
if
test
-e
${
dirlist
}
;
then
echo
"
${
cur_dir
}
/
${
dirlist
}
${
output_dir
}
/TDengine-
${
tdengine_ver
}
.rpm"
cp
${
cur_dir
}
/
${
dirlist
}
${
output_dir
}
/TDengine-
${
tdengine_ver
}
.rpm
cp
${
cur_dir
}
/
${
dirlist
}
${
output_dir
}
/TDengine-
${
tdengine_ver
}
.rpm
fi
fi
done
done
...
@@ -54,6 +56,25 @@ fi
...
@@ -54,6 +56,25 @@ fi
${
csudo
}
mkdir
-p
${
pkg_dir
}
${
csudo
}
mkdir
-p
${
pkg_dir
}
cd
${
pkg_dir
}
cd
${
pkg_dir
}
# download taoskeeper and build
if
[
"
$cpuType
"
=
"x64"
]
||
[
"
$cpuType
"
=
"x86_64"
]
||
[
"
$cpuType
"
=
"amd64"
]
;
then
arch
=
amd64
elif
[
"
$cpuType
"
=
"x32"
]
||
[
"
$cpuType
"
=
"i386"
]
||
[
"
$cpuType
"
=
"i686"
]
;
then
arch
=
386
elif
[
"
$cpuType
"
=
"arm"
]
||
[
"
$cpuType
"
=
"aarch32"
]
;
then
arch
=
arm
elif
[
"
$cpuType
"
=
"arm64"
]
||
[
"
$cpuType
"
=
"aarch64"
]
;
then
arch
=
arm64
else
arch
=
$cpuType
fi
cd
${
top_dir
}
echo
"
${
top_dir
}
/../enterprise/packaging/build_taoskeeper.sh -r
${
arch
}
-e taoskeeper"
taoskeeper_binary
=
`
${
top_dir
}
/../enterprise/packaging/build_taoskeeper.sh
-r
$arch
-e
taoskeeper
`
echo
"taoskeeper_binary:
${
taoskeeper_binary
}
"
cd
${
package_dir
}
${
csudo
}
mkdir
-p
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
${
csudo
}
mkdir
-p
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
${
csudo
}
rpmbuild
--define
=
"_version
${
tdengine_ver
}
"
--define
=
"_topdir
${
pkg_dir
}
"
--define
=
"_compiledir
${
compile_dir
}
"
-bb
${
spec_file
}
${
csudo
}
rpmbuild
--define
=
"_version
${
tdengine_ver
}
"
--define
=
"_topdir
${
pkg_dir
}
"
--define
=
"_compiledir
${
compile_dir
}
"
-bb
${
spec_file
}
...
@@ -85,3 +106,4 @@ mv ${output_dir}/TDengine-${tdengine_ver}.rpm ${output_dir}/${rpmname}
...
@@ -85,3 +106,4 @@ mv ${output_dir}/TDengine-${tdengine_ver}.rpm ${output_dir}/${rpmname}
cd
..
cd
..
${
csudo
}
rm
-rf
${
pkg_dir
}
${
csudo
}
rm
-rf
${
pkg_dir
}
rm
-rf
${
top_dir
}
/build-taoskeeper
\ No newline at end of file
packaging/rpm/tdengine.spec
浏览文件 @
6a889ae8
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
%define cfg_install_dir /etc/taos
%define cfg_install_dir /etc/taos
%define __strip /bin/true
%define __strip /bin/true
%global __python /usr/bin/python3
%global __python /usr/bin/python3
%global _build_id_links none
Name: tdengine
Name: tdengine
Version: %{_version}
Version: %{_version}
...
@@ -62,6 +63,15 @@ fi
...
@@ -62,6 +63,15 @@ fi
if [ -f %{_compiledir}/test/cfg/taosadapter.service ]; then
if [ -f %{_compiledir}/test/cfg/taosadapter.service ]; then
cp %{_compiledir}/test/cfg/taosadapter.service %{buildroot}%{homepath}/cfg
cp %{_compiledir}/test/cfg/taosadapter.service %{buildroot}%{homepath}/cfg
fi
fi
if [ -f %{_compiledir}/../build-taoskeeper/config/taoskeeper.toml ]; then
cp %{_compiledir}/../build-taoskeeper/config/taoskeeper.toml %{buildroot}%{homepath}/cfg ||:
fi
if [ -f %{_compiledir}/../build-taoskeeper/taoskeeper.service ]; then
cp %{_compiledir}/../build-taoskeeper/taoskeeper.service %{buildroot}%{homepath}/cfg ||:
fi
#cp %{_compiledir}/../packaging/rpm/taosd %{buildroot}%{homepath}/init.d
#cp %{_compiledir}/../packaging/rpm/taosd %{buildroot}%{homepath}/init.d
cp %{_compiledir}/../packaging/tools/post.sh %{buildroot}%{homepath}/script
cp %{_compiledir}/../packaging/tools/post.sh %{buildroot}%{homepath}/script
cp %{_compiledir}/../packaging/tools/preun.sh %{buildroot}%{homepath}/script
cp %{_compiledir}/../packaging/tools/preun.sh %{buildroot}%{homepath}/script
...
@@ -73,8 +83,12 @@ cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin
...
@@ -73,8 +83,12 @@ cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/udfd %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/udfd %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taosBenchmark %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taosBenchmark %{buildroot}%{homepath}/bin
if [ -f %{_compiledir}/../build-taoskeeper/taoskeeper ]; then
cp %{_compiledir}/../build-taoskeeper/taoskeeper %{buildroot}%{homepath}/bin
fi
if [ -f %{_compiledir}/build/bin/taosadapter ]; then
if [ -f %{_compiledir}/build/bin/taosadapter ]; then
cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin
||:
cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin
fi
fi
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
[ -f %{_compiledir}/build/lib/${wslibfile} ] && cp %{_compiledir}/build/lib/${wslibfile} %{buildroot}%{homepath}/driver ||:
[ -f %{_compiledir}/build/lib/${wslibfile} ] && cp %{_compiledir}/build/lib/${wslibfile} %{buildroot}%{homepath}/driver ||:
...
@@ -119,7 +133,9 @@ if [ -f %{_compiledir}/build/bin/jemalloc-config ]; then
...
@@ -119,7 +133,9 @@ if [ -f %{_compiledir}/build/bin/jemalloc-config ]; then
cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{homepath}/jemalloc/lib/pkgconfig
cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{homepath}/jemalloc/lib/pkgconfig
fi
fi
fi
fi
ls -al %{buildroot}%{homepath}/bin
tree -L 5
echo "==============================copying files done"
#Scripts executed before installation
#Scripts executed before installation
%pre
%pre
if [ -f /var/lib/taos/dnode/dnodeCfg.json ]; then
if [ -f /var/lib/taos/dnode/dnodeCfg.json ]; then
...
@@ -196,6 +212,7 @@ if [ $1 -eq 0 ];then
...
@@ -196,6 +212,7 @@ if [ $1 -eq 0 ];then
${csudo}rm -f ${bin_link_dir}/taosd || :
${csudo}rm -f ${bin_link_dir}/taosd || :
${csudo}rm -f ${bin_link_dir}/udfd || :
${csudo}rm -f ${bin_link_dir}/udfd || :
${csudo}rm -f ${bin_link_dir}/taosadapter || :
${csudo}rm -f ${bin_link_dir}/taosadapter || :
${csudo}rm -f ${bin_link_dir}/taoskeeper || :
${csudo}rm -f ${cfg_link_dir}/* || :
${csudo}rm -f ${cfg_link_dir}/* || :
${csudo}rm -f ${inc_link_dir}/taos.h || :
${csudo}rm -f ${inc_link_dir}/taos.h || :
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
...
...
packaging/tools/post.sh
浏览文件 @
6a889ae8
...
@@ -436,7 +436,7 @@ function local_fqdn_check() {
...
@@ -436,7 +436,7 @@ function local_fqdn_check() {
function
install_taosadapter_config
()
{
function
install_taosadapter_config
()
{
if
[
!
-f
"
${
cfg_install_dir
}
/taosadapter.toml"
]
;
then
if
[
!
-f
"
${
cfg_install_dir
}
/taosadapter.toml"
]
;
then
[
!
-d
%
{
cfg_install_dir
}
]
&&
[
!
-d
$
{
cfg_install_dir
}
]
&&
${
csudo
}${
csudo
}
mkdir
-p
${
cfg_install_dir
}
${
csudo
}${
csudo
}
mkdir
-p
${
cfg_install_dir
}
[
-f
${
cfg_dir
}
/taosadapter.toml
]
&&
${
csudo
}
cp
${
cfg_dir
}
/taosadapter.toml
${
cfg_install_dir
}
[
-f
${
cfg_dir
}
/taosadapter.toml
]
&&
${
csudo
}
cp
${
cfg_dir
}
/taosadapter.toml
${
cfg_install_dir
}
[
-f
${
cfg_install_dir
}
/taosadapter.toml
]
&&
[
-f
${
cfg_install_dir
}
/taosadapter.toml
]
&&
...
@@ -451,19 +451,26 @@ function install_taosadapter_config() {
...
@@ -451,19 +451,26 @@ function install_taosadapter_config() {
}
}
function
install_taoskeeper_config
()
{
function
install_taoskeeper_config
()
{
if
[
!
-f
"
${
cfg_install_dir
}
/keeper.toml"
]
;
then
# if new environment without taoskeeper
[
!
-d
%
{
cfg_install_dir
}
]
&&
if
[[
!
-f
"
${
cfg_install_dir
}
/keeper.toml"
]]
&&
[[
!
-f
"
${
cfg_install_dir
}
/taoskeeper.toml"
]]
;
then
${
csudo
}${
csudo
}
mkdir
-p
${
cfg_install_dir
}
[
!
-d
${
cfg_install_dir
}
]
&&
${
csudo
}${
csudo
}
mkdir
-p
${
cfg_install_dir
}
[
-f
${
cfg_dir
}
/keeper.toml
]
&&
${
csudo
}
cp
${
cfg_dir
}
/keeper.toml
${
cfg_install_dir
}
[
-f
${
cfg_dir
}
/taoskeeper.toml
]
&&
${
csudo
}
cp
${
cfg_dir
}
/taoskeeper.toml
${
cfg_install_dir
}
[
-f
${
cfg_install_dir
}
/keeper.toml
]
&&
[
-f
${
cfg_install_dir
}
/taoskeeper.toml
]
&&
${
csudo
}
chmod
644
${
cfg_install_dir
}
/keeper.toml
${
csudo
}
chmod
644
${
cfg_install_dir
}
/taoskeeper.toml
fi
# if old machine with taoskeeper.toml file
if
[
-f
${
cfg_install_dir
}
/taoskeeper.toml
]
;
then
${
csudo
}
mv
${
cfg_dir
}
/taoskeeper.toml
${
cfg_dir
}
/taoskeeper.toml.new
fi
fi
[
-f
${
cfg_dir
}
/keeper.toml
]
&&
if
[
-f
${
cfg_install_dir
}
/keeper.toml
]
;
then
${
csudo
}
mv
${
cfg_dir
}
/keeper.toml
${
cfg_dir
}
/keeper.toml.new
echo
"The file keeper.toml will be renamed to taoskeeper.toml"
${
csudo
}
mv
${
cfg_install_dir
}
/keeper.toml
${
cfg_install_dir
}
/taoskeeper.toml
${
csudo
}
mv
${
cfg_dir
}
/taoskeeper.toml
${
cfg_dir
}
/taoskeeper.toml.new
fi
[
-f
${
cfg_install_dir
}
/keeper.toml
]
&&
[
-f
${
cfg_install_dir
}
/
taos
keeper.toml
]
&&
${
csudo
}
ln
-s
${
cfg_install_dir
}
/keeper.toml
${
cfg_dir
}
${
csudo
}
ln
-s
${
cfg_install_dir
}
/
taos
keeper.toml
${
cfg_dir
}
}
}
function
install_config
()
{
function
install_config
()
{
...
@@ -655,6 +662,15 @@ function install_taosadapter_service() {
...
@@ -655,6 +662,15 @@ function install_taosadapter_service() {
fi
fi
}
}
function
install_taoskeeper_service
()
{
if
((
${
service_mod
}
==
0
))
;
then
[
-f
${
script_dir
}
/../cfg/taoskeeper.service
]
&&
\
${
csudo
}
cp
${
script_dir
}
/../cfg/taoskeeper.service
\
${
service_config_dir
}
/
||
:
${
csudo
}
systemctl daemon-reload
fi
}
function
install_service
()
{
function
install_service
()
{
log_print
"start install service"
log_print
"start install service"
if
[
"
$osType
"
!=
"Darwin"
]
;
then
if
[
"
$osType
"
!=
"Darwin"
]
;
then
...
@@ -732,6 +748,7 @@ function install_TDengine() {
...
@@ -732,6 +748,7 @@ function install_TDengine() {
install_taosadapter_config
install_taosadapter_config
install_taoskeeper_config
install_taoskeeper_config
install_taosadapter_service
install_taosadapter_service
install_taoskeeper_service
install_service
install_service
install_app
install_app
...
...
packaging/tools/preun.sh
浏览文件 @
6a889ae8
...
@@ -17,7 +17,7 @@ cfg_link_dir="/usr/local/taos/cfg"
...
@@ -17,7 +17,7 @@ cfg_link_dir="/usr/local/taos/cfg"
service_config_dir
=
"/etc/systemd/system"
service_config_dir
=
"/etc/systemd/system"
taos_service_name
=
"taosd"
taos_service_name
=
"taosd"
taoskeeper_service_name
=
"taoskeeper"
csudo
=
""
csudo
=
""
if
command
-v
sudo
>
/dev/null
;
then
if
command
-v
sudo
>
/dev/null
;
then
csudo
=
"sudo "
csudo
=
"sudo "
...
@@ -57,6 +57,13 @@ function kill_taosd() {
...
@@ -57,6 +57,13 @@ function kill_taosd() {
fi
fi
}
}
function
kill_taoskeeper
()
{
pid
=
$(
ps
-ef
|
grep
"taoskeeper"
|
grep
-v
"grep"
|
awk
'{print $2}'
)
if
[
-n
"
$pid
"
]
;
then
${
csudo
}
kill
-9
$pid
||
:
fi
}
function
clean_service_on_systemd
()
{
function
clean_service_on_systemd
()
{
taosadapter_service_config
=
"
${
service_config_dir
}
/taosadapter.service"
taosadapter_service_config
=
"
${
service_config_dir
}
/taosadapter.service"
if
systemctl is-active
--quiet
taosadapter
;
then
if
systemctl is-active
--quiet
taosadapter
;
then
...
@@ -76,6 +83,12 @@ function clean_service_on_systemd() {
...
@@ -76,6 +83,12 @@ function clean_service_on_systemd() {
[
-f
${
taosadapter_service_config
}
]
&&
${
csudo
}
rm
-f
${
taosadapter_service_config
}
[
-f
${
taosadapter_service_config
}
]
&&
${
csudo
}
rm
-f
${
taosadapter_service_config
}
taoskeeper_service_config
=
"
${
service_config_dir
}
/
${
taoskeeper_service_name
}
.service"
if
systemctl is-active
--quiet
${
taoskeeper_service_name
}
;
then
echo
"TDengine taoskeeper is running, stopping it..."
${
csudo
}
systemctl stop
${
taoskeeper_service_name
}
&> /dev/null
||
echo
&> /dev/null
fi
[
-f
${
taoskeeper_service_config
}
]
&&
${
csudo
}
rm
-f
${
taoskeeper_service_config
}
}
}
function
clean_service_on_sysvinit
()
{
function
clean_service_on_sysvinit
()
{
...
@@ -111,6 +124,7 @@ function clean_service() {
...
@@ -111,6 +124,7 @@ function clean_service() {
# must manual stop taosd
# must manual stop taosd
kill_taosadapter
kill_taosadapter
kill_taosd
kill_taosd
kill_taoskeeper
fi
fi
}
}
...
@@ -124,6 +138,7 @@ ${csudo}rm -f ${bin_link_dir}/taosadapter || :
...
@@ -124,6 +138,7 @@ ${csudo}rm -f ${bin_link_dir}/taosadapter || :
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosBenchmark
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosBenchmark
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosdemo
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosdemo
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/set_core
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/set_core
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taoskeeper
||
:
${
csudo
}
rm
-f
${
cfg_link_dir
}
/
*
.new
||
:
${
csudo
}
rm
-f
${
cfg_link_dir
}
/
*
.new
||
:
${
csudo
}
rm
-f
${
inc_link_dir
}
/taos.h
||
:
${
csudo
}
rm
-f
${
inc_link_dir
}
/taos.h
||
:
${
csudo
}
rm
-f
${
inc_link_dir
}
/taosdef.h
||
:
${
csudo
}
rm
-f
${
inc_link_dir
}
/taosdef.h
||
:
...
...
source/client/src/clientMain.c
浏览文件 @
6a889ae8
...
@@ -108,7 +108,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
...
@@ -108,7 +108,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
if
(
pass
==
NULL
)
{
if
(
pass
==
NULL
)
{
pass
=
TSDB_DEFAULT_PASS
;
pass
=
TSDB_DEFAULT_PASS
;
}
}
STscObj
*
pObj
=
taos_connect_internal
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
CONN_TYPE__QUERY
);
STscObj
*
pObj
=
taos_connect_internal
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
CONN_TYPE__QUERY
);
if
(
pObj
)
{
if
(
pObj
)
{
int64_t
*
rid
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
));
int64_t
*
rid
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
));
...
@@ -359,11 +359,11 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
...
@@ -359,11 +359,11 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
case
TSDB_DATA_TYPE_NCHAR
:
{
case
TSDB_DATA_TYPE_NCHAR
:
{
int32_t
charLen
=
varDataLen
((
char
*
)
row
[
i
]
-
VARSTR_HEADER_SIZE
);
int32_t
charLen
=
varDataLen
((
char
*
)
row
[
i
]
-
VARSTR_HEADER_SIZE
);
if
(
fields
[
i
].
type
==
TSDB_DATA_TYPE_BINARY
)
{
if
(
fields
[
i
].
type
==
TSDB_DATA_TYPE_BINARY
)
{
if
(
ASSERT
(
charLen
<=
fields
[
i
].
bytes
&&
charLen
>=
0
))
{
if
(
ASSERT
(
charLen
<=
fields
[
i
].
bytes
&&
charLen
>=
0
))
{
tscError
(
"taos_print_row error binary. charLen:%d, fields[i].bytes:%d"
,
charLen
,
fields
[
i
].
bytes
);
tscError
(
"taos_print_row error binary. charLen:%d, fields[i].bytes:%d"
,
charLen
,
fields
[
i
].
bytes
);
}
}
}
else
{
}
else
{
if
(
ASSERT
(
charLen
<=
fields
[
i
].
bytes
*
TSDB_NCHAR_SIZE
&&
charLen
>=
0
))
{
if
(
ASSERT
(
charLen
<=
fields
[
i
].
bytes
*
TSDB_NCHAR_SIZE
&&
charLen
>=
0
))
{
tscError
(
"taos_print_row error. charLen:%d, fields[i].bytes:%d"
,
charLen
,
fields
[
i
].
bytes
);
tscError
(
"taos_print_row error. charLen:%d, fields[i].bytes:%d"
,
charLen
,
fields
[
i
].
bytes
);
}
}
}
}
...
@@ -705,16 +705,16 @@ int taos_get_current_db(TAOS *taos, char *database, int len, int *required) {
...
@@ -705,16 +705,16 @@ int taos_get_current_db(TAOS *taos, char *database, int len, int *required) {
int
code
=
TSDB_CODE_SUCCESS
;
int
code
=
TSDB_CODE_SUCCESS
;
taosThreadMutexLock
(
&
pTscObj
->
mutex
);
taosThreadMutexLock
(
&
pTscObj
->
mutex
);
if
(
database
==
NULL
||
len
<=
0
)
{
if
(
database
==
NULL
||
len
<=
0
)
{
if
(
required
!=
NULL
)
*
required
=
strlen
(
pTscObj
->
db
)
+
1
;
if
(
required
!=
NULL
)
*
required
=
strlen
(
pTscObj
->
db
)
+
1
;
terrno
=
TSDB_CODE_INVALID_PARA
;
terrno
=
TSDB_CODE_INVALID_PARA
;
code
=
-
1
;
code
=
-
1
;
}
else
if
(
len
<
strlen
(
pTscObj
->
db
)
+
1
)
{
}
else
if
(
len
<
strlen
(
pTscObj
->
db
)
+
1
)
{
tstrncpy
(
database
,
pTscObj
->
db
,
len
);
tstrncpy
(
database
,
pTscObj
->
db
,
len
);
if
(
required
)
*
required
=
strlen
(
pTscObj
->
db
)
+
1
;
if
(
required
)
*
required
=
strlen
(
pTscObj
->
db
)
+
1
;
terrno
=
TSDB_CODE_INVALID_PARA
;
terrno
=
TSDB_CODE_INVALID_PARA
;
code
=
-
1
;
code
=
-
1
;
}
else
{
}
else
{
strcpy
(
database
,
pTscObj
->
db
);
strcpy
(
database
,
pTscObj
->
db
);
code
=
0
;
code
=
0
;
}
}
...
@@ -741,6 +741,7 @@ static void destoryCatalogReq(SCatalogReq *pCatalogReq) {
...
@@ -741,6 +741,7 @@ static void destoryCatalogReq(SCatalogReq *pCatalogReq) {
taosArrayDestroy
(
pCatalogReq
->
pUser
);
taosArrayDestroy
(
pCatalogReq
->
pUser
);
taosArrayDestroy
(
pCatalogReq
->
pTableIndex
);
taosArrayDestroy
(
pCatalogReq
->
pTableIndex
);
taosArrayDestroy
(
pCatalogReq
->
pTableCfg
);
taosArrayDestroy
(
pCatalogReq
->
pTableCfg
);
taosArrayDestroy
(
pCatalogReq
->
pTableTag
);
taosMemoryFree
(
pCatalogReq
);
taosMemoryFree
(
pCatalogReq
);
}
}
...
@@ -975,8 +976,10 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
...
@@ -975,8 +976,10 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pRequest
->
stmtType
=
pRequest
->
pQuery
->
pRoot
->
type
;
pRequest
->
stmtType
=
pRequest
->
pQuery
->
pRoot
->
type
;
phaseAsyncQuery
(
pWrapper
);
code
=
phaseAsyncQuery
(
pWrapper
);
}
else
{
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
tscError
(
"0x%"
PRIx64
" error happens, code:%d - %s, reqId:0x%"
PRIx64
,
pRequest
->
self
,
code
,
tstrerror
(
code
),
tscError
(
"0x%"
PRIx64
" error happens, code:%d - %s, reqId:0x%"
PRIx64
,
pRequest
->
self
,
code
,
tstrerror
(
code
),
pRequest
->
requestId
);
pRequest
->
requestId
);
destorySqlCallbackWrapper
(
pWrapper
);
destorySqlCallbackWrapper
(
pWrapper
);
...
@@ -1042,11 +1045,11 @@ static void fetchCallback(void *pResult, void *param, int32_t code) {
...
@@ -1042,11 +1045,11 @@ static void fetchCallback(void *pResult, void *param, int32_t code) {
}
}
void
taos_fetch_rows_a
(
TAOS_RES
*
res
,
__taos_async_fn_t
fp
,
void
*
param
)
{
void
taos_fetch_rows_a
(
TAOS_RES
*
res
,
__taos_async_fn_t
fp
,
void
*
param
)
{
if
(
ASSERT
(
res
!=
NULL
&&
fp
!=
NULL
))
{
if
(
ASSERT
(
res
!=
NULL
&&
fp
!=
NULL
))
{
tscError
(
"taos_fetch_rows_a invalid paras"
);
tscError
(
"taos_fetch_rows_a invalid paras"
);
return
;
return
;
}
}
if
(
ASSERT
(
TD_RES_QUERY
(
res
)))
{
if
(
ASSERT
(
TD_RES_QUERY
(
res
)))
{
tscError
(
"taos_fetch_rows_a res is NULL"
);
tscError
(
"taos_fetch_rows_a res is NULL"
);
return
;
return
;
}
}
...
@@ -1092,11 +1095,11 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
...
@@ -1092,11 +1095,11 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
}
}
void
taos_fetch_raw_block_a
(
TAOS_RES
*
res
,
__taos_async_fn_t
fp
,
void
*
param
)
{
void
taos_fetch_raw_block_a
(
TAOS_RES
*
res
,
__taos_async_fn_t
fp
,
void
*
param
)
{
if
(
ASSERT
(
res
!=
NULL
&&
fp
!=
NULL
))
{
if
(
ASSERT
(
res
!=
NULL
&&
fp
!=
NULL
))
{
tscError
(
"taos_fetch_rows_a invalid paras"
);
tscError
(
"taos_fetch_rows_a invalid paras"
);
return
;
return
;
}
}
if
(
ASSERT
(
TD_RES_QUERY
(
res
)))
{
if
(
ASSERT
(
TD_RES_QUERY
(
res
)))
{
tscError
(
"taos_fetch_rows_a res is NULL"
);
tscError
(
"taos_fetch_rows_a res is NULL"
);
return
;
return
;
}
}
...
@@ -1111,11 +1114,11 @@ void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
...
@@ -1111,11 +1114,11 @@ void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
}
}
const
void
*
taos_get_raw_block
(
TAOS_RES
*
res
)
{
const
void
*
taos_get_raw_block
(
TAOS_RES
*
res
)
{
if
(
ASSERT
(
res
!=
NULL
))
{
if
(
ASSERT
(
res
!=
NULL
))
{
tscError
(
"taos_fetch_rows_a invalid paras"
);
tscError
(
"taos_fetch_rows_a invalid paras"
);
return
NULL
;
return
NULL
;
}
}
if
(
ASSERT
(
TD_RES_QUERY
(
res
)))
{
if
(
ASSERT
(
TD_RES_QUERY
(
res
)))
{
tscError
(
"taos_fetch_rows_a res is NULL"
);
tscError
(
"taos_fetch_rows_a res is NULL"
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1273,7 +1276,6 @@ _return:
...
@@ -1273,7 +1276,6 @@ _return:
return
code
;
return
code
;
}
}
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
)
{
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
)
{
if
(
NULL
==
taos
)
{
if
(
NULL
==
taos
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
...
...
source/client/src/clientTmq.c
浏览文件 @
6a889ae8
...
@@ -1664,11 +1664,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p
...
@@ -1664,11 +1664,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p
return
handleErrorBeforePoll
(
pVg
,
pTmq
);
return
handleErrorBeforePoll
(
pVg
,
pTmq
);
}
}
sendInfo
->
msgInfo
=
(
SDataBuf
){
sendInfo
->
msgInfo
=
(
SDataBuf
){
.
pData
=
msg
,
.
len
=
msgSize
,
.
handle
=
NULL
};
.
pData
=
msg
,
.
len
=
msgSize
,
.
handle
=
NULL
,
};
sendInfo
->
requestId
=
req
.
reqId
;
sendInfo
->
requestId
=
req
.
reqId
;
sendInfo
->
requestObjRefId
=
0
;
sendInfo
->
requestObjRefId
=
0
;
...
...
source/client/test/clientTests.cpp
浏览文件 @
6a889ae8
...
@@ -165,7 +165,7 @@ void* queryThread(void* arg) {
...
@@ -165,7 +165,7 @@ void* queryThread(void* arg) {
int32_t
numOfThreads
=
1
;
int32_t
numOfThreads
=
1
;
void
tmq_commit_cb_print
(
tmq_t
*
pTmq
,
int32_t
code
,
void
*
param
)
{
void
tmq_commit_cb_print
(
tmq_t
*
pTmq
,
int32_t
code
,
void
*
param
)
{
printf
(
"auto commit success, code:%d
\n\n\n
\n
"
,
code
);
// printf("auto commit success, code:%d
\n", code);
}
}
void
*
doConsumeData
(
void
*
param
)
{
void
*
doConsumeData
(
void
*
param
)
{
...
@@ -1053,19 +1053,24 @@ TEST(clientCase, sub_db_test) {
...
@@ -1053,19 +1053,24 @@ TEST(clientCase, sub_db_test) {
}
}
TEST
(
clientCase
,
sub_tb_test
)
{
TEST
(
clientCase
,
sub_tb_test
)
{
taos_options
(
TSDB_OPTION_CONFIGDIR
,
"
~/first/cfg
"
);
taos_options
(
TSDB_OPTION_CONFIGDIR
,
"
/home/tests/dir/cfg/
"
);
TAOS
*
pConn
=
taos_connect
(
"
localhost
"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
pConn
=
taos_connect
(
"
vm116
"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
ASSERT_NE
(
pConn
,
nullptr
);
tmq_conf_t
*
conf
=
tmq_conf_new
();
tmq_conf_t
*
conf
=
tmq_conf_new
();
int32_t
ts
=
taosGetTimestampMs
()
%
INT32_MAX
;
char
consumerGroupid
[
128
]
=
{
0
};
sprintf
(
consumerGroupid
,
"group_id_%d"
,
ts
);
tmq_conf_set
(
conf
,
"enable.auto.commit"
,
"true"
);
tmq_conf_set
(
conf
,
"enable.auto.commit"
,
"true"
);
tmq_conf_set
(
conf
,
"auto.commit.interval.ms"
,
"
1
000"
);
tmq_conf_set
(
conf
,
"auto.commit.interval.ms"
,
"
2
000"
);
tmq_conf_set
(
conf
,
"group.id"
,
"cgrpName45"
);
tmq_conf_set
(
conf
,
"group.id"
,
consumerGroupid
);
tmq_conf_set
(
conf
,
"td.connect.user"
,
"root"
);
tmq_conf_set
(
conf
,
"td.connect.user"
,
"root"
);
tmq_conf_set
(
conf
,
"td.connect.pass"
,
"taosdata"
);
tmq_conf_set
(
conf
,
"td.connect.pass"
,
"taosdata"
);
tmq_conf_set
(
conf
,
"auto.offset.reset"
,
"earliest"
);
tmq_conf_set
(
conf
,
"auto.offset.reset"
,
"earliest"
);
tmq_conf_set
(
conf
,
"experimental.snapshot.enable"
,
"
tru
e"
);
tmq_conf_set
(
conf
,
"experimental.snapshot.enable"
,
"
fals
e"
);
tmq_conf_set
(
conf
,
"msg.with.table.name"
,
"true"
);
tmq_conf_set
(
conf
,
"msg.with.table.name"
,
"true"
);
tmq_conf_set_auto_commit_cb
(
conf
,
tmq_commit_cb_print
,
NULL
);
tmq_conf_set_auto_commit_cb
(
conf
,
tmq_commit_cb_print
,
NULL
);
...
@@ -1074,7 +1079,7 @@ TEST(clientCase, sub_tb_test) {
...
@@ -1074,7 +1079,7 @@ TEST(clientCase, sub_tb_test) {
// 创建订阅 topics 列表
// 创建订阅 topics 列表
tmq_list_t
*
topicList
=
tmq_list_new
();
tmq_list_t
*
topicList
=
tmq_list_new
();
tmq_list_append
(
topicList
,
"topic_t
2
"
);
tmq_list_append
(
topicList
,
"topic_t
1
"
);
// 启动订阅
// 启动订阅
tmq_subscribe
(
tmq
,
topicList
);
tmq_subscribe
(
tmq
,
topicList
);
...
@@ -1093,15 +1098,15 @@ TEST(clientCase, sub_tb_test) {
...
@@ -1093,15 +1098,15 @@ TEST(clientCase, sub_tb_test) {
while
(
1
)
{
while
(
1
)
{
TAOS_RES
*
pRes
=
tmq_consumer_poll
(
tmq
,
timeout
);
TAOS_RES
*
pRes
=
tmq_consumer_poll
(
tmq
,
timeout
);
if
(
pRes
)
{
if
(
pRes
)
{
char
buf
[
1
024
];
char
buf
[
1
28
];
const
char
*
topicName
=
tmq_get_topic_name
(
pRes
);
const
char
*
topicName
=
tmq_get_topic_name
(
pRes
);
const
char
*
dbName
=
tmq_get_db_name
(
pRes
);
//
const char* dbName = tmq_get_db_name(pRes);
int32_t
vgroupId
=
tmq_get_vgroup_id
(
pRes
);
//
int32_t vgroupId = tmq_get_vgroup_id(pRes);
//
printf
(
"topic: %s
\n
"
,
topicName
);
//
printf("topic: %s\n", topicName);
printf
(
"db: %s
\n
"
,
dbName
);
//
printf("db: %s\n", dbName);
printf
(
"vgroup id: %d
\n
"
,
vgroupId
);
//
printf("vgroup id: %d\n", vgroupId);
while
(
1
)
{
while
(
1
)
{
TAOS_ROW
row
=
taos_fetch_row
(
pRes
);
TAOS_ROW
row
=
taos_fetch_row
(
pRes
);
...
@@ -1111,16 +1116,14 @@ TEST(clientCase, sub_tb_test) {
...
@@ -1111,16 +1116,14 @@ TEST(clientCase, sub_tb_test) {
fields
=
taos_fetch_fields
(
pRes
);
fields
=
taos_fetch_fields
(
pRes
);
numOfFields
=
taos_field_count
(
pRes
);
numOfFields
=
taos_field_count
(
pRes
);
precision
=
taos_result_precision
(
pRes
);
taos_print_row
(
buf
,
row
,
fields
,
numOfFields
);
totalRows
+=
1
;
totalRows
+=
1
;
printf
(
"precision: %d, row content: %s
\n
"
,
precision
,
buf
);
if
(
totalRows
%
100000
==
0
)
{
taos_print_row
(
buf
,
row
,
fields
,
numOfFields
);
printf
(
"row content: %s
\n
"
,
buf
);
}
}
}
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
// if ((++count) > 1) {
// break;
// }
}
else
{
}
else
{
break
;
break
;
}
}
...
...
source/common/src/tmsg.c
浏览文件 @
6a889ae8
...
@@ -1409,6 +1409,8 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq
...
@@ -1409,6 +1409,8 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq
return
0
;
return
0
;
}
}
void
tFreeSAlterUserReq
(
SAlterUserReq
*
pReq
)
{
taosMemoryFreeClear
(
pReq
->
tagCond
);
}
int32_t
tSerializeSGetUserAuthReq
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthReq
*
pReq
)
{
int32_t
tSerializeSGetUserAuthReq
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
...
@@ -1635,6 +1637,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
...
@@ -1635,6 +1637,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
int32_t
ref
=
0
;
int32_t
ref
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
ref
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
ref
)
<
0
)
return
-
1
;
taosHashPut
(
pRsp
->
useDbs
,
key
,
strlen
(
key
),
&
ref
,
sizeof
(
ref
));
taosHashPut
(
pRsp
->
useDbs
,
key
,
strlen
(
key
),
&
ref
,
sizeof
(
ref
));
taosMemoryFree
(
key
);
}
}
}
}
...
@@ -1831,7 +1834,6 @@ int32_t tSerializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pReq
...
@@ -1831,7 +1834,6 @@ int32_t tSerializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pReq
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pComment
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pComment
)
<
0
)
return
-
1
;
}
}
if
(
tEncodeI8
(
&
encoder
,
pReq
->
orReplace
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
orReplace
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
...
@@ -1876,7 +1878,6 @@ int32_t tDeserializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pR
...
@@ -1876,7 +1878,6 @@ int32_t tDeserializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pR
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pComment
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pComment
)
<
0
)
return
-
1
;
}
}
if
(
!
tDecodeIsEnd
(
&
decoder
))
{
if
(
!
tDecodeIsEnd
(
&
decoder
))
{
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
orReplace
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
orReplace
)
<
0
)
return
-
1
;
}
else
{
}
else
{
...
@@ -2053,12 +2054,12 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
...
@@ -2053,12 +2054,12 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
if
(
pRsp
->
pFuncExtraInfos
==
NULL
)
return
-
1
;
if
(
pRsp
->
pFuncExtraInfos
==
NULL
)
return
-
1
;
if
(
tDecodeIsEnd
(
&
decoder
))
{
if
(
tDecodeIsEnd
(
&
decoder
))
{
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfFuncs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfFuncs
;
++
i
)
{
SFuncExtraInfo
extraInfo
=
{
0
};
SFuncExtraInfo
extraInfo
=
{
0
};
taosArrayPush
(
pRsp
->
pFuncExtraInfos
,
&
extraInfo
);
taosArrayPush
(
pRsp
->
pFuncExtraInfos
,
&
extraInfo
);
}
}
}
else
{
}
else
{
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfFuncs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfFuncs
;
++
i
)
{
SFuncExtraInfo
extraInfo
=
{
0
};
SFuncExtraInfo
extraInfo
=
{
0
};
if
(
tDecodeI32
(
&
decoder
,
&
extraInfo
.
funcVersion
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
extraInfo
.
funcVersion
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
extraInfo
.
funcCreatedTime
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
extraInfo
.
funcCreatedTime
)
<
0
)
return
-
1
;
taosArrayPush
(
pRsp
->
pFuncExtraInfos
,
&
extraInfo
);
taosArrayPush
(
pRsp
->
pFuncExtraInfos
,
&
extraInfo
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
6a889ae8
...
@@ -113,8 +113,16 @@ static void vmProcessFetchQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
...
@@ -113,8 +113,16 @@ static void vmProcessFetchQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
int32_t
code
=
vnodeProcessFetchMsg
(
pVnode
->
pImpl
,
pMsg
,
pInfo
);
int32_t
code
=
vnodeProcessFetchMsg
(
pVnode
->
pImpl
,
pMsg
,
pInfo
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
if
(
terrno
!=
0
)
code
=
terrno
;
if
(
terrno
!=
0
)
{
dGError
(
"vnodeProcessFetchMsg vgId:%d, msg:%p failed to fetch since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
code
=
terrno
;
}
if
(
code
==
TSDB_CODE_WAL_LOG_NOT_EXIST
)
{
dGDebug
(
"vnodeProcessFetchMsg vgId:%d, msg:%p failed to fetch since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
}
else
{
dGError
(
"vnodeProcessFetchMsg vgId:%d, msg:%p failed to fetch since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
}
vmSendRsp
(
pMsg
,
code
);
vmSendRsp
(
pMsg
,
code
);
}
}
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
6a889ae8
...
@@ -124,11 +124,7 @@ static void mndCalMqRebalance(SMnode *pMnode) {
...
@@ -124,11 +124,7 @@ static void mndCalMqRebalance(SMnode *pMnode) {
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
if
(
pReq
!=
NULL
)
{
if
(
pReq
!=
NULL
)
{
SRpcMsg
rpcMsg
=
{
SRpcMsg
rpcMsg
=
{
.
msgType
=
TDMT_MND_TMQ_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
.
msgType
=
TDMT_MND_TMQ_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
,
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
}
}
}
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
6a889ae8
...
@@ -390,6 +390,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
...
@@ -390,6 +390,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
ref
,
_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
ref
,
_OVER
);
taosHashPut
(
pUser
->
useDbs
,
key
,
keyLen
,
&
ref
,
sizeof
(
ref
));
taosHashPut
(
pUser
->
useDbs
,
key
,
keyLen
,
&
ref
,
sizeof
(
ref
));
taosMemoryFree
(
key
);
}
}
}
}
...
@@ -956,6 +957,7 @@ _OVER:
...
@@ -956,6 +957,7 @@ _OVER:
mError
(
"user:%s, failed to alter since %s"
,
alterReq
.
user
,
terrstr
());
mError
(
"user:%s, failed to alter since %s"
,
alterReq
.
user
,
terrstr
());
}
}
tFreeSAlterUserReq
(
&
alterReq
);
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
mndUserFreeObj
(
&
newUser
);
mndUserFreeObj
(
&
newUser
);
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
6a889ae8
...
@@ -162,7 +162,6 @@ int32_t metaTbCursorPrev(SMTbCursor *pTbCur, ETableType jumpTableType);
...
@@ -162,7 +162,6 @@ int32_t metaTbCursorPrev(SMTbCursor *pTbCur, ETableType jumpTableType);
#endif
#endif
// tsdb
// tsdb
// typedef struct STsdb STsdb;
typedef
struct
STsdbReader
STsdbReader
;
typedef
struct
STsdbReader
STsdbReader
;
#define TSDB_DEFAULT_STT_FILE 8
#define TSDB_DEFAULT_STT_FILE 8
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
6a889ae8
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#ifndef _TD_VNODE_TSDB_H_
#ifndef _TD_VNODE_TSDB_H_
#define _TD_VNODE_TSDB_H_
#define _TD_VNODE_TSDB_H_
#include "tsimplehash.h"
#include "vnodeInt.h"
#include "vnodeInt.h"
#ifdef __cplusplus
#ifdef __cplusplus
...
@@ -122,14 +123,14 @@ int32_t tsdbRowCmprFn(const void *p1, const void *p2);
...
@@ -122,14 +123,14 @@ int32_t tsdbRowCmprFn(const void *p1, const void *p2);
int32_t
tsdbRowIterOpen
(
STSDBRowIter
*
pIter
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
int32_t
tsdbRowIterOpen
(
STSDBRowIter
*
pIter
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
void
tsdbRowClose
(
STSDBRowIter
*
pIter
);
void
tsdbRowClose
(
STSDBRowIter
*
pIter
);
SColVal
*
tsdbRowIterNext
(
STSDBRowIter
*
pIter
);
SColVal
*
tsdbRowIterNext
(
STSDBRowIter
*
pIter
);
// SRowMerger
// SRowMerger
int32_t
tsdbRowMergerInit
(
SRowMerger
*
pMerger
,
STSchema
*
p
ResTSchema
,
TSDBROW
*
pRow
,
STSchema
*
pT
Schema
);
int32_t
tsdbRowMergerInit
(
SRowMerger
*
pMerger
,
STSchema
*
pSchema
);
int32_t
tsdbRowMergerAdd
(
SRowMerger
*
pMerger
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
int32_t
tsdbRowMergerAdd
(
SRowMerger
*
pMerger
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
// int32_t tsdbRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema);
void
tsdbRowMergerClear
(
SRowMerger
*
pMerger
);
// int32_t tsdbRowMerge(SRowMerger *pMerger, TSDBROW *pRow);
int32_t
tsdbRowMergerGetRow
(
SRowMerger
*
pMerger
,
SRow
**
ppRow
);
int32_t
tsdbRowMergerGetRow
(
SRowMerger
*
pMerger
,
SRow
**
ppRow
);
void
tsdbRowMergerClear
(
SRowMerger
*
pMerger
);
void
tsdbRowMergerCleanup
(
SRowMerger
*
pMerger
);
// TABLEID
// TABLEID
int32_t
tTABLEIDCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
int32_t
tTABLEIDCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
// TSDBKEY
// TSDBKEY
...
@@ -224,7 +225,7 @@ int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward,
...
@@ -224,7 +225,7 @@ int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward,
void
*
tsdbTbDataIterDestroy
(
STbDataIter
*
pIter
);
void
*
tsdbTbDataIterDestroy
(
STbDataIter
*
pIter
);
void
tsdbTbDataIterOpen
(
STbData
*
pTbData
,
TSDBKEY
*
pFrom
,
int8_t
backward
,
STbDataIter
*
pIter
);
void
tsdbTbDataIterOpen
(
STbData
*
pTbData
,
TSDBKEY
*
pFrom
,
int8_t
backward
,
STbDataIter
*
pIter
);
bool
tsdbTbDataIterNext
(
STbDataIter
*
pIter
);
bool
tsdbTbDataIterNext
(
STbDataIter
*
pIter
);
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
SHashObj
*
pTableMap
,
int64_t
*
rowsNum
);
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
S
S
HashObj
*
pTableMap
,
int64_t
*
rowsNum
);
// STbData
// STbData
int32_t
tsdbGetNRowsInTbData
(
STbData
*
pTbData
);
int32_t
tsdbGetNRowsInTbData
(
STbData
*
pTbData
);
...
@@ -322,8 +323,9 @@ int32_t tGnrtDiskData(SDiskDataBuilder *pBuilder, const SDiskData **ppDiskData,
...
@@ -322,8 +323,9 @@ int32_t tGnrtDiskData(SDiskDataBuilder *pBuilder, const SDiskData **ppDiskData,
#define TSDB_STT_FILE_DATA_ITER 2
#define TSDB_STT_FILE_DATA_ITER 2
#define TSDB_TOMB_FILE_DATA_ITER 3
#define TSDB_TOMB_FILE_DATA_ITER 3
#define TSDB_FILTER_FLAG_BY_VERSION 0x1
#define TSDB_FILTER_FLAG_BY_VERSION 0x1
#define TSDB_FILTER_FLAG_BY_TABLEID 0x2
#define TSDB_FILTER_FLAG_BY_TABLEID 0x2
#define TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE 0x4
#define TSDB_RBTN_TO_DATA_ITER(pNode) ((STsdbDataIter2 *)(((char *)pNode) - offsetof(STsdbDataIter2, rbtn)))
#define TSDB_RBTN_TO_DATA_ITER(pNode) ((STsdbDataIter2 *)(((char *)pNode) - offsetof(STsdbDataIter2, rbtn)))
/* open */
/* open */
...
@@ -705,7 +707,6 @@ typedef struct SSttBlockLoadInfo {
...
@@ -705,7 +707,6 @@ typedef struct SSttBlockLoadInfo {
typedef
struct
SMergeTree
{
typedef
struct
SMergeTree
{
int8_t
backward
;
int8_t
backward
;
SRBTree
rbt
;
SRBTree
rbt
;
SArray
*
pIterList
;
SLDataIter
*
pIter
;
SLDataIter
*
pIter
;
bool
destroyLoadInfo
;
bool
destroyLoadInfo
;
SSttBlockLoadInfo
*
pLoadInfo
;
SSttBlockLoadInfo
*
pLoadInfo
;
...
@@ -751,13 +752,29 @@ struct SDiskDataBuilder {
...
@@ -751,13 +752,29 @@ struct SDiskDataBuilder {
SBlkInfo
bi
;
SBlkInfo
bi
;
};
};
typedef
struct
SLDataIter
{
SRBTreeNode
node
;
SSttBlk
*
pSttBlk
;
SDataFReader
*
pReader
;
int32_t
iStt
;
int8_t
backward
;
int32_t
iSttBlk
;
int32_t
iRow
;
SRowInfo
rInfo
;
uint64_t
uid
;
STimeWindow
timeWindow
;
SVersionRange
verRange
;
SSttBlockLoadInfo
*
pBlockLoadInfo
;
bool
ignoreEarlierTs
;
}
SLDataIter
;
#define tMergeTreeGetRow(_t) (&((_t)->pIter->rInfo.row))
int32_t
tMergeTreeOpen
(
SMergeTree
*
pMTree
,
int8_t
backward
,
SDataFReader
*
pFReader
,
uint64_t
suid
,
uint64_t
uid
,
int32_t
tMergeTreeOpen
(
SMergeTree
*
pMTree
,
int8_t
backward
,
SDataFReader
*
pFReader
,
uint64_t
suid
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
bool
destroyLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
);
bool
destroyLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
,
SLDataIter
*
pLDataIter
);
void
tMergeTreeAddIter
(
SMergeTree
*
pMTree
,
SLDataIter
*
pIter
);
void
tMergeTreeAddIter
(
SMergeTree
*
pMTree
,
SLDataIter
*
pIter
);
bool
tMergeTreeNext
(
SMergeTree
*
pMTree
);
bool
tMergeTreeNext
(
SMergeTree
*
pMTree
);
bool
tMergeTreeIgnoreEarlierTs
(
SMergeTree
*
pMTree
);
bool
tMergeTreeIgnoreEarlierTs
(
SMergeTree
*
pMTree
);
TSDBROW
tMergeTreeGetRow
(
SMergeTree
*
pMTree
);
void
tMergeTreeClose
(
SMergeTree
*
pMTree
);
void
tMergeTreeClose
(
SMergeTree
*
pMTree
);
SSttBlockLoadInfo
*
tCreateLastBlockLoadInfo
(
STSchema
*
pSchema
,
int16_t
*
colList
,
int32_t
numOfCols
,
int32_t
numOfStt
);
SSttBlockLoadInfo
*
tCreateLastBlockLoadInfo
(
STSchema
*
pSchema
,
int16_t
*
colList
,
int32_t
numOfCols
,
int32_t
numOfStt
);
...
@@ -782,6 +799,7 @@ typedef struct SCacheRowsReader {
...
@@ -782,6 +799,7 @@ typedef struct SCacheRowsReader {
STableKeyInfo
*
pTableList
;
// table id list
STableKeyInfo
*
pTableList
;
// table id list
int32_t
numOfTables
;
int32_t
numOfTables
;
SSttBlockLoadInfo
*
pLoadInfo
;
SSttBlockLoadInfo
*
pLoadInfo
;
SLDataIter
*
pDataIter
;
STsdbReadSnap
*
pReadSnap
;
STsdbReadSnap
*
pReadSnap
;
SDataFReader
*
pDataFReader
;
SDataFReader
*
pDataFReader
;
SDataFReader
*
pDataFReaderLast
;
SDataFReader
*
pDataFReaderLast
;
...
...
source/dnode/vnode/src/tq/tqScan.c
浏览文件 @
6a889ae8
...
@@ -74,7 +74,6 @@ int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffs
...
@@ -74,7 +74,6 @@ int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffs
qTaskInfo_t
task
=
pExec
->
task
;
qTaskInfo_t
task
=
pExec
->
task
;
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqError
(
"prepare scan failed, return"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -119,7 +118,6 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
...
@@ -119,7 +118,6 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
qTaskInfo_t
task
=
pExec
->
task
;
qTaskInfo_t
task
=
pExec
->
task
;
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqDebug
(
"tqScanTaosx prepare scan failed, return"
);
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
6a889ae8
...
@@ -598,6 +598,7 @@ typedef struct {
...
@@ -598,6 +598,7 @@ typedef struct {
SMergeTree
mergeTree
;
SMergeTree
mergeTree
;
SMergeTree
*
pMergeTree
;
SMergeTree
*
pMergeTree
;
SSttBlockLoadInfo
*
pLoadInfo
;
SSttBlockLoadInfo
*
pLoadInfo
;
SLDataIter
*
pDataIter
;
int64_t
lastTs
;
int64_t
lastTs
;
}
SFSLastNextRowIter
;
}
SFSLastNextRowIter
;
...
@@ -645,7 +646,7 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow, bool *pIgnoreEa
...
@@ -645,7 +646,7 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow, bool *pIgnoreEa
}
}
tMergeTreeOpen
(
&
state
->
mergeTree
,
1
,
*
state
->
pDataFReader
,
state
->
suid
,
state
->
uid
,
tMergeTreeOpen
(
&
state
->
mergeTree
,
1
,
*
state
->
pDataFReader
,
state
->
suid
,
state
->
uid
,
&
(
STimeWindow
){.
skey
=
state
->
lastTs
,
.
ekey
=
TSKEY_MAX
},
&
(
STimeWindow
){.
skey
=
state
->
lastTs
,
.
ekey
=
TSKEY_MAX
},
&
(
SVersionRange
){.
minVer
=
0
,
.
maxVer
=
UINT64_MAX
},
state
->
pLoadInfo
,
false
,
NULL
,
true
);
&
(
SVersionRange
){.
minVer
=
0
,
.
maxVer
=
UINT64_MAX
},
state
->
pLoadInfo
,
false
,
NULL
,
true
,
state
->
pDataIter
);
state
->
pMergeTree
=
&
state
->
mergeTree
;
state
->
pMergeTree
=
&
state
->
mergeTree
;
state
->
state
=
SFSLASTNEXTROW_BLOCKROW
;
state
->
state
=
SFSLASTNEXTROW_BLOCKROW
;
}
}
...
@@ -667,7 +668,7 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow, bool *pIgnoreEa
...
@@ -667,7 +668,7 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow, bool *pIgnoreEa
state
->
state
=
SFSLASTNEXTROW_FILESET
;
state
->
state
=
SFSLASTNEXTROW_FILESET
;
goto
_next_fileset
;
goto
_next_fileset
;
}
}
state
->
row
=
tMergeTreeGetRow
(
&
state
->
mergeTree
);
state
->
row
=
*
tMergeTreeGetRow
(
&
state
->
mergeTree
);
*
ppRow
=
&
state
->
row
;
*
ppRow
=
&
state
->
row
;
if
(
TSDBROW_TS
(
&
state
->
row
)
<=
state
->
lastTs
)
{
if
(
TSDBROW_TS
(
&
state
->
row
)
<=
state
->
lastTs
)
{
...
@@ -1211,7 +1212,7 @@ typedef struct {
...
@@ -1211,7 +1212,7 @@ typedef struct {
}
CacheNextRowIter
;
}
CacheNextRowIter
;
static
int32_t
nextRowIterOpen
(
CacheNextRowIter
*
pIter
,
tb_uid_t
uid
,
STsdb
*
pTsdb
,
STSchema
*
pTSchema
,
tb_uid_t
suid
,
static
int32_t
nextRowIterOpen
(
CacheNextRowIter
*
pIter
,
tb_uid_t
uid
,
STsdb
*
pTsdb
,
STSchema
*
pTSchema
,
tb_uid_t
suid
,
SSttBlockLoadInfo
*
pLoadInfo
,
STsdbReadSnap
*
pReadSnap
,
SDataFReader
**
pDataFReader
,
SSttBlockLoadInfo
*
pLoadInfo
,
S
LDataIter
*
pLDataIter
,
S
TsdbReadSnap
*
pReadSnap
,
SDataFReader
**
pDataFReader
,
SDataFReader
**
pDataFReaderLast
,
int64_t
lastTs
)
{
SDataFReader
**
pDataFReaderLast
,
int64_t
lastTs
)
{
int
code
=
0
;
int
code
=
0
;
...
@@ -1274,6 +1275,7 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
...
@@ -1274,6 +1275,7 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
pIter
->
fsLastState
.
pLoadInfo
=
pLoadInfo
;
pIter
->
fsLastState
.
pLoadInfo
=
pLoadInfo
;
pIter
->
fsLastState
.
pDataFReader
=
pDataFReaderLast
;
pIter
->
fsLastState
.
pDataFReader
=
pDataFReaderLast
;
pIter
->
fsLastState
.
lastTs
=
lastTs
;
pIter
->
fsLastState
.
lastTs
=
lastTs
;
pIter
->
fsLastState
.
pDataIter
=
pLDataIter
;
pIter
->
fsState
.
state
=
SFSNEXTROW_FS
;
pIter
->
fsState
.
state
=
SFSNEXTROW_FS
;
pIter
->
fsState
.
pTsdb
=
pTsdb
;
pIter
->
fsState
.
pTsdb
=
pTsdb
;
...
@@ -1465,7 +1467,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo
...
@@ -1465,7 +1467,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo
TSKEY
lastRowTs
=
TSKEY_MAX
;
TSKEY
lastRowTs
=
TSKEY_MAX
;
CacheNextRowIter
iter
=
{
0
};
CacheNextRowIter
iter
=
{
0
};
nextRowIterOpen
(
&
iter
,
uid
,
pTsdb
,
pTSchema
,
pr
->
suid
,
pr
->
pLoadInfo
,
pr
->
pReadSnap
,
&
pr
->
pDataFReader
,
nextRowIterOpen
(
&
iter
,
uid
,
pTsdb
,
pTSchema
,
pr
->
suid
,
pr
->
pLoadInfo
,
pr
->
p
DataIter
,
pr
->
p
ReadSnap
,
&
pr
->
pDataFReader
,
&
pr
->
pDataFReaderLast
,
pr
->
lastTs
);
&
pr
->
pDataFReaderLast
,
pr
->
lastTs
);
do
{
do
{
...
@@ -1622,7 +1624,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCach
...
@@ -1622,7 +1624,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCach
TSKEY
lastRowTs
=
TSKEY_MAX
;
TSKEY
lastRowTs
=
TSKEY_MAX
;
CacheNextRowIter
iter
=
{
0
};
CacheNextRowIter
iter
=
{
0
};
nextRowIterOpen
(
&
iter
,
uid
,
pTsdb
,
pTSchema
,
pr
->
suid
,
pr
->
pLoadInfo
,
pr
->
pReadSnap
,
&
pr
->
pDataFReader
,
nextRowIterOpen
(
&
iter
,
uid
,
pTsdb
,
pTSchema
,
pr
->
suid
,
pr
->
pLoadInfo
,
pr
->
p
DataIter
,
pr
->
p
ReadSnap
,
&
pr
->
pDataFReader
,
&
pr
->
pDataFReaderLast
,
pr
->
lastTs
);
&
pr
->
pDataFReaderLast
,
pr
->
lastTs
);
do
{
do
{
...
...
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
浏览文件 @
6a889ae8
...
@@ -187,13 +187,21 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
...
@@ -187,13 +187,21 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
}
}
}
}
int32_t
numOfStt
=
((
SVnode
*
)
pVnode
)
->
config
.
sttTrigger
;
SVnodeCfg
*
pCfg
=
&
((
SVnode
*
)
pVnode
)
->
config
;
int32_t
numOfStt
=
pCfg
->
sttTrigger
;
p
->
pLoadInfo
=
tCreateLastBlockLoadInfo
(
p
->
pSchema
,
NULL
,
0
,
numOfStt
);
p
->
pLoadInfo
=
tCreateLastBlockLoadInfo
(
p
->
pSchema
,
NULL
,
0
,
numOfStt
);
if
(
p
->
pLoadInfo
==
NULL
)
{
if
(
p
->
pLoadInfo
==
NULL
)
{
tsdbCacherowsReaderClose
(
p
);
tsdbCacherowsReaderClose
(
p
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
p
->
pDataIter
=
taosMemoryCalloc
(
pCfg
->
sttTrigger
,
sizeof
(
SLDataIter
));
if
(
p
->
pDataIter
==
NULL
)
{
tsdbCacherowsReaderClose
(
p
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
p
->
idstr
=
taosStrdup
(
idstr
);
p
->
idstr
=
taosStrdup
(
idstr
);
taosThreadMutexInit
(
&
p
->
readerMutex
,
NULL
);
taosThreadMutexInit
(
&
p
->
readerMutex
,
NULL
);
...
@@ -215,6 +223,7 @@ void* tsdbCacherowsReaderClose(void* pReader) {
...
@@ -215,6 +223,7 @@ void* tsdbCacherowsReaderClose(void* pReader) {
taosMemoryFree
(
p
->
pSchema
);
taosMemoryFree
(
p
->
pSchema
);
}
}
taosMemoryFreeClear
(
p
->
pDataIter
);
taosMemoryFree
(
p
->
pCurrSchema
);
taosMemoryFree
(
p
->
pCurrSchema
);
destroyLastBlockLoadInfo
(
p
->
pLoadInfo
);
destroyLastBlockLoadInfo
(
p
->
pLoadInfo
);
...
...
source/dnode/vnode/src/tsdb/tsdbDataIter.c
浏览文件 @
6a889ae8
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
*/
*/
#include "tsdb.h"
#include "tsdb.h"
#include "vnodeInt.h"
// STsdbDataIter2
// STsdbDataIter2
/* open */
/* open */
...
@@ -202,13 +203,6 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
...
@@ -202,13 +203,6 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
for
(;;)
{
for
(;;)
{
while
(
pIter
->
dIter
.
iRow
<
pIter
->
dIter
.
bData
.
nRow
)
{
while
(
pIter
->
dIter
.
iRow
<
pIter
->
dIter
.
bData
.
nRow
)
{
if
(
pFilterInfo
)
{
if
(
pFilterInfo
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_TABLEID
)
{
if
(
pFilterInfo
->
tbid
.
uid
==
pIter
->
dIter
.
bData
.
uid
)
{
pIter
->
dIter
.
iRow
=
pIter
->
dIter
.
bData
.
nRow
;
continue
;
}
}
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pIter
->
dIter
.
bData
.
aVersion
[
pIter
->
dIter
.
iRow
]
<
pFilterInfo
->
sver
||
if
(
pIter
->
dIter
.
bData
.
aVersion
[
pIter
->
dIter
.
iRow
]
<
pFilterInfo
->
sver
||
pIter
->
dIter
.
bData
.
aVersion
[
pIter
->
dIter
.
iRow
]
>
pFilterInfo
->
ever
)
{
pIter
->
dIter
.
bData
.
aVersion
[
pIter
->
dIter
.
iRow
]
>
pFilterInfo
->
ever
)
{
...
@@ -232,13 +226,6 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
...
@@ -232,13 +226,6 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
// filter
// filter
if
(
pFilterInfo
)
{
if
(
pFilterInfo
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_TABLEID
)
{
if
(
tTABLEIDCmprFn
(
&
pFilterInfo
->
tbid
,
&
pIter
->
rowInfo
)
==
0
)
{
pIter
->
dIter
.
iDataBlk
=
pIter
->
dIter
.
mDataBlk
.
nItem
;
continue
;
}
}
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
sver
>
dataBlk
.
maxVer
||
pFilterInfo
->
ever
<
dataBlk
.
minVer
)
{
if
(
pFilterInfo
->
sver
>
dataBlk
.
maxVer
||
pFilterInfo
->
ever
<
dataBlk
.
minVer
)
{
pIter
->
dIter
.
iDataBlk
++
;
pIter
->
dIter
.
iDataBlk
++
;
...
@@ -262,13 +249,23 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
...
@@ -262,13 +249,23 @@ static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
if
(
pIter
->
dIter
.
iBlockIdx
<
taosArrayGetSize
(
pIter
->
dIter
.
aBlockIdx
))
{
if
(
pIter
->
dIter
.
iBlockIdx
<
taosArrayGetSize
(
pIter
->
dIter
.
aBlockIdx
))
{
SBlockIdx
*
pBlockIdx
=
taosArrayGet
(
pIter
->
dIter
.
aBlockIdx
,
pIter
->
dIter
.
iBlockIdx
);
SBlockIdx
*
pBlockIdx
=
taosArrayGet
(
pIter
->
dIter
.
aBlockIdx
,
pIter
->
dIter
.
iBlockIdx
);
if
(
pFilterInfo
&&
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_TABLEID
))
{
if
(
pFilterInfo
)
{
int32_t
c
=
tTABLEIDCmprFn
(
pBlockIdx
,
&
pFilterInfo
->
tbid
);
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_TABLEID
)
{
if
(
c
==
0
)
{
int32_t
c
=
tTABLEIDCmprFn
(
pBlockIdx
,
&
pFilterInfo
->
tbid
);
pIter
->
dIter
.
iBlockIdx
++
;
if
(
c
==
0
)
{
continue
;
pIter
->
dIter
.
iBlockIdx
++
;
}
else
if
(
c
<
0
)
{
continue
;
ASSERT
(
0
);
}
else
if
(
c
<
0
)
{
ASSERT
(
0
);
}
}
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE
)
{
SMetaInfo
info
;
if
(
metaGetInfo
(
pIter
->
dIter
.
pReader
->
pTsdb
->
pVnode
->
pMeta
,
pBlockIdx
->
uid
,
&
info
,
NULL
))
{
pIter
->
dIter
.
iBlockIdx
++
;
continue
;
}
}
}
}
}
...
@@ -304,14 +301,24 @@ static int32_t tsdbSttFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* p
...
@@ -304,14 +301,24 @@ static int32_t tsdbSttFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* p
for
(;;)
{
for
(;;)
{
while
(
pIter
->
sIter
.
iRow
<
pIter
->
sIter
.
bData
.
nRow
)
{
while
(
pIter
->
sIter
.
iRow
<
pIter
->
sIter
.
bData
.
nRow
)
{
if
(
pFilterInfo
)
{
if
(
pFilterInfo
)
{
int64_t
uid
=
pIter
->
sIter
.
bData
.
uid
?
pIter
->
sIter
.
bData
.
uid
:
pIter
->
sIter
.
bData
.
aUid
[
pIter
->
sIter
.
iRow
];
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_TABLEID
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_TABLEID
)
{
int64_t
uid
=
pIter
->
sIter
.
bData
.
uid
?
pIter
->
sIter
.
bData
.
uid
:
pIter
->
sIter
.
bData
.
aUid
[
pIter
->
sIter
.
iRow
];
if
(
pFilterInfo
->
tbid
.
uid
==
uid
)
{
if
(
pFilterInfo
->
tbid
.
uid
==
uid
)
{
pIter
->
sIter
.
iRow
++
;
pIter
->
sIter
.
iRow
++
;
continue
;
continue
;
}
}
}
}
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE
)
{
if
(
pIter
->
rowInfo
.
uid
!=
uid
)
{
SMetaInfo
info
;
if
(
metaGetInfo
(
pIter
->
sIter
.
pReader
->
pTsdb
->
pVnode
->
pMeta
,
uid
,
&
info
,
NULL
))
{
pIter
->
sIter
.
iRow
++
;
continue
;
}
}
}
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_BY_VERSION
)
{
if
(
pFilterInfo
->
sver
>
pIter
->
sIter
.
bData
.
aVersion
[
pIter
->
sIter
.
iRow
]
||
if
(
pFilterInfo
->
sver
>
pIter
->
sIter
.
bData
.
aVersion
[
pIter
->
sIter
.
iRow
]
||
pFilterInfo
->
ever
<
pIter
->
sIter
.
bData
.
aVersion
[
pIter
->
sIter
.
iRow
])
{
pFilterInfo
->
ever
<
pIter
->
sIter
.
bData
.
aVersion
[
pIter
->
sIter
.
iRow
])
{
...
@@ -395,6 +402,16 @@ static int32_t tsdbTombFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
...
@@ -395,6 +402,16 @@ static int32_t tsdbTombFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
if
(
pIter
->
tIter
.
iDelIdx
<
taosArrayGetSize
(
pIter
->
tIter
.
aDelIdx
))
{
if
(
pIter
->
tIter
.
iDelIdx
<
taosArrayGetSize
(
pIter
->
tIter
.
aDelIdx
))
{
SDelIdx
*
pDelIdx
=
taosArrayGet
(
pIter
->
tIter
.
aDelIdx
,
pIter
->
tIter
.
iDelIdx
);
SDelIdx
*
pDelIdx
=
taosArrayGet
(
pIter
->
tIter
.
aDelIdx
,
pIter
->
tIter
.
iDelIdx
);
if
(
pFilterInfo
)
{
if
(
pFilterInfo
->
flag
&
TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE
)
{
SMetaInfo
info
;
if
(
metaGetInfo
(
pIter
->
dIter
.
pReader
->
pTsdb
->
pVnode
->
pMeta
,
pDelIdx
->
uid
,
&
info
,
NULL
))
{
pIter
->
tIter
.
iDelIdx
++
;
continue
;
}
}
}
code
=
tsdbReadDelData
(
pIter
->
tIter
.
pReader
,
pDelIdx
,
pIter
->
tIter
.
aDelData
);
code
=
tsdbReadDelData
(
pIter
->
tIter
.
pReader
,
pDelIdx
,
pIter
->
tIter
.
aDelData
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
6a889ae8
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* 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 <util/tsimplehash.h>
#include "tsdb.h"
#include "tsdb.h"
#define MEM_MIN_HASH 1024
#define MEM_MIN_HASH 1024
...
@@ -298,12 +299,12 @@ int64_t tsdbCountTbDataRows(STbData *pTbData) {
...
@@ -298,12 +299,12 @@ int64_t tsdbCountTbDataRows(STbData *pTbData) {
return
rowsNum
;
return
rowsNum
;
}
}
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
S
HashObj
*
pTableMap
,
int64_t
*
rowsNum
)
{
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
S
SHashObj
*
pTableMap
,
int64_t
*
rowsNum
)
{
taosRLockLatch
(
&
pMemTable
->
latch
);
taosRLockLatch
(
&
pMemTable
->
latch
);
for
(
int32_t
i
=
0
;
i
<
pMemTable
->
nBucket
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pMemTable
->
nBucket
;
++
i
)
{
STbData
*
pTbData
=
pMemTable
->
aBucket
[
i
];
STbData
*
pTbData
=
pMemTable
->
aBucket
[
i
];
while
(
pTbData
)
{
while
(
pTbData
)
{
void
*
p
=
t
aos
HashGet
(
pTableMap
,
&
pTbData
->
uid
,
sizeof
(
pTbData
->
uid
));
void
*
p
=
t
Simple
HashGet
(
pTableMap
,
&
pTbData
->
uid
,
sizeof
(
pTbData
->
uid
));
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
pTbData
=
pTbData
->
next
;
pTbData
=
pTbData
->
next
;
continue
;
continue
;
...
...
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
浏览文件 @
6a889ae8
...
@@ -16,22 +16,6 @@
...
@@ -16,22 +16,6 @@
#include "tsdb.h"
#include "tsdb.h"
// SLDataIter =================================================
// SLDataIter =================================================
struct
SLDataIter
{
SRBTreeNode
node
;
SSttBlk
*
pSttBlk
;
SDataFReader
*
pReader
;
int32_t
iStt
;
int8_t
backward
;
int32_t
iSttBlk
;
int32_t
iRow
;
SRowInfo
rInfo
;
uint64_t
uid
;
STimeWindow
timeWindow
;
SVersionRange
verRange
;
SSttBlockLoadInfo
*
pBlockLoadInfo
;
bool
ignoreEarlierTs
;
};
SSttBlockLoadInfo
*
tCreateLastBlockLoadInfo
(
STSchema
*
pSchema
,
int16_t
*
colList
,
int32_t
numOfCols
,
SSttBlockLoadInfo
*
tCreateLastBlockLoadInfo
(
STSchema
*
pSchema
,
int16_t
*
colList
,
int32_t
numOfCols
,
int32_t
numOfSttTrigger
)
{
int32_t
numOfSttTrigger
)
{
SSttBlockLoadInfo
*
pLoadInfo
=
taosMemoryCalloc
(
numOfSttTrigger
,
sizeof
(
SSttBlockLoadInfo
));
SSttBlockLoadInfo
*
pLoadInfo
=
taosMemoryCalloc
(
numOfSttTrigger
,
sizeof
(
SSttBlockLoadInfo
));
...
@@ -268,25 +252,21 @@ static int32_t binarySearchForStartRowIndex(uint64_t *uidList, int32_t num, uint
...
@@ -268,25 +252,21 @@ static int32_t binarySearchForStartRowIndex(uint64_t *uidList, int32_t num, uint
}
}
}
}
int32_t
tLDataIterOpen
(
struct
SLDataIter
*
*
pIter
,
SDataFReader
*
pReader
,
int32_t
iStt
,
int8_t
backward
,
uint64_t
suid
,
int32_t
tLDataIterOpen
(
struct
SLDataIter
*
pIter
,
SDataFReader
*
pReader
,
int32_t
iStt
,
int8_t
backward
,
uint64_t
suid
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
)
{
const
char
*
idStr
,
bool
strictTimeRange
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
*
pIter
=
taosMemoryCalloc
(
1
,
sizeof
(
SLDataIter
));
pIter
->
uid
=
uid
;
if
(
*
pIter
==
NULL
)
{
pIter
->
pReader
=
pReader
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
pIter
->
iStt
=
iStt
;
goto
_exit
;
pIter
->
backward
=
backward
;
}
pIter
->
verRange
.
minVer
=
pRange
->
minVer
;
pIter
->
verRange
.
maxVer
=
pRange
->
maxVer
;
pIter
->
timeWindow
.
skey
=
pTimeWindow
->
skey
;
pIter
->
timeWindow
.
ekey
=
pTimeWindow
->
ekey
;
(
*
pIter
)
->
uid
=
uid
;
pIter
->
pBlockLoadInfo
=
pBlockLoadInfo
;
(
*
pIter
)
->
pReader
=
pReader
;
(
*
pIter
)
->
iStt
=
iStt
;
(
*
pIter
)
->
backward
=
backward
;
(
*
pIter
)
->
verRange
=
*
pRange
;
(
*
pIter
)
->
timeWindow
=
*
pTimeWindow
;
(
*
pIter
)
->
pBlockLoadInfo
=
pBlockLoadInfo
;
if
(
!
pBlockLoadInfo
->
sttBlockLoaded
)
{
if
(
!
pBlockLoadInfo
->
sttBlockLoaded
)
{
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
...
@@ -294,7 +274,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
...
@@ -294,7 +274,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
code
=
tsdbReadSttBlk
(
pReader
,
iStt
,
pBlockLoadInfo
->
aSttBlk
);
code
=
tsdbReadSttBlk
(
pReader
,
iStt
,
pBlockLoadInfo
->
aSttBlk
);
if
(
code
)
{
if
(
code
)
{
goto
_exit
;
return
code
;
}
}
// only apply to the child tables, ordinary tables will not incur this filter procedure.
// only apply to the child tables, ordinary tables will not incur this filter procedure.
...
@@ -310,7 +290,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
...
@@ -310,7 +290,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
// no qualified stt block existed
// no qualified stt block existed
taosArrayClear
(
pBlockLoadInfo
->
aSttBlk
);
taosArrayClear
(
pBlockLoadInfo
->
aSttBlk
);
(
*
pIter
)
->
iSttBlk
=
-
1
;
pIter
->
iSttBlk
=
-
1
;
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
tsdbDebug
(
"load the last file info completed, elapsed time:%.2fms, %s"
,
el
,
idStr
);
tsdbDebug
(
"load the last file info completed, elapsed time:%.2fms, %s"
,
el
,
idStr
);
return
code
;
return
code
;
...
@@ -343,31 +323,27 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
...
@@ -343,31 +323,27 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
size_t
size
=
taosArrayGetSize
(
pBlockLoadInfo
->
aSttBlk
);
size_t
size
=
taosArrayGetSize
(
pBlockLoadInfo
->
aSttBlk
);
// find the start block
// find the start block
(
*
pIter
)
->
iSttBlk
=
binarySearchForStartBlock
(
pBlockLoadInfo
->
aSttBlk
->
pData
,
size
,
uid
,
backward
);
pIter
->
iSttBlk
=
binarySearchForStartBlock
(
pBlockLoadInfo
->
aSttBlk
->
pData
,
size
,
uid
,
backward
);
if
(
(
*
pIter
)
->
iSttBlk
!=
-
1
)
{
if
(
pIter
->
iSttBlk
!=
-
1
)
{
(
*
pIter
)
->
pSttBlk
=
taosArrayGet
(
pBlockLoadInfo
->
aSttBlk
,
(
*
pIter
)
->
iSttBlk
);
pIter
->
pSttBlk
=
taosArrayGet
(
pBlockLoadInfo
->
aSttBlk
,
pIter
->
iSttBlk
);
(
*
pIter
)
->
iRow
=
((
*
pIter
)
->
backward
)
?
(
*
pIter
)
->
pSttBlk
->
nRow
:
-
1
;
pIter
->
iRow
=
(
pIter
->
backward
)
?
pIter
->
pSttBlk
->
nRow
:
-
1
;
if
((
!
backward
)
&&
((
strictTimeRange
&&
(
*
pIter
)
->
pSttBlk
->
minKey
>=
(
*
pIter
)
->
timeWindow
.
ekey
)
||
if
((
!
backward
)
&&
((
strictTimeRange
&&
pIter
->
pSttBlk
->
minKey
>=
pIter
->
timeWindow
.
ekey
)
||
(
!
strictTimeRange
&&
(
*
pIter
)
->
pSttBlk
->
minKey
>
(
*
pIter
)
->
timeWindow
.
ekey
)))
{
(
!
strictTimeRange
&&
pIter
->
pSttBlk
->
minKey
>
pIter
->
timeWindow
.
ekey
)))
{
(
*
pIter
)
->
pSttBlk
=
NULL
;
pIter
->
pSttBlk
=
NULL
;
}
}
if
(
backward
&&
((
strictTimeRange
&&
(
*
pIter
)
->
pSttBlk
->
maxKey
<=
(
*
pIter
)
->
timeWindow
.
skey
)
||
if
(
backward
&&
((
strictTimeRange
&&
pIter
->
pSttBlk
->
maxKey
<=
pIter
->
timeWindow
.
skey
)
||
(
!
strictTimeRange
&&
(
*
pIter
)
->
pSttBlk
->
maxKey
<
(
*
pIter
)
->
timeWindow
.
skey
)))
{
(
!
strictTimeRange
&&
pIter
->
pSttBlk
->
maxKey
<
pIter
->
timeWindow
.
skey
)))
{
(
*
pIter
)
->
pSttBlk
=
NULL
;
pIter
->
pSttBlk
=
NULL
;
(
*
pIter
)
->
ignoreEarlierTs
=
true
;
pIter
->
ignoreEarlierTs
=
true
;
}
}
}
}
return
code
;
return
code
;
_exit:
taosMemoryFree
(
*
pIter
);
return
code
;
}
}
void
tLDataIterClose
(
SLDataIter
*
pIter
)
{
taosMemoryFree
(
pIter
);
}
void
tLDataIterClose
(
SLDataIter
*
pIter
)
{
/*taosMemoryFree(pIter); */
}
void
tLDataIterNextBlock
(
SLDataIter
*
pIter
,
const
char
*
idStr
)
{
void
tLDataIterNextBlock
(
SLDataIter
*
pIter
,
const
char
*
idStr
)
{
int32_t
step
=
pIter
->
backward
?
-
1
:
1
;
int32_t
step
=
pIter
->
backward
?
-
1
:
1
;
...
@@ -594,43 +570,38 @@ static FORCE_INLINE int32_t tLDataIterDescCmprFn(const SRBTreeNode *p1, const SR
...
@@ -594,43 +570,38 @@ static FORCE_INLINE int32_t tLDataIterDescCmprFn(const SRBTreeNode *p1, const SR
int32_t
tMergeTreeOpen
(
SMergeTree
*
pMTree
,
int8_t
backward
,
SDataFReader
*
pFReader
,
uint64_t
suid
,
uint64_t
uid
,
int32_t
tMergeTreeOpen
(
SMergeTree
*
pMTree
,
int8_t
backward
,
SDataFReader
*
pFReader
,
uint64_t
suid
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
bool
destroyLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
)
{
bool
destroyLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
,
SLDataIter
*
pLDataIter
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
pMTree
->
backward
=
backward
;
pMTree
->
backward
=
backward
;
pMTree
->
pIter
=
NULL
;
pMTree
->
pIter
=
NULL
;
pMTree
->
pIterList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
if
(
pMTree
->
pIterList
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pMTree
->
idStr
=
idStr
;
pMTree
->
idStr
=
idStr
;
if
(
!
pMTree
->
backward
)
{
// asc
if
(
!
pMTree
->
backward
)
{
// asc
tRBTreeCreate
(
&
pMTree
->
rbt
,
tLDataIterCmprFn
);
tRBTreeCreate
(
&
pMTree
->
rbt
,
tLDataIterCmprFn
);
}
else
{
// desc
}
else
{
// desc
tRBTreeCreate
(
&
pMTree
->
rbt
,
tLDataIterDescCmprFn
);
tRBTreeCreate
(
&
pMTree
->
rbt
,
tLDataIterDescCmprFn
);
}
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
pMTree
->
pLoadInfo
=
pBlockLoadInfo
;
pMTree
->
pLoadInfo
=
pBlockLoadInfo
;
pMTree
->
destroyLoadInfo
=
destroyLoadInfo
;
pMTree
->
destroyLoadInfo
=
destroyLoadInfo
;
pMTree
->
ignoreEarlierTs
=
false
;
pMTree
->
ignoreEarlierTs
=
false
;
for
(
int32_t
i
=
0
;
i
<
pFReader
->
pSet
->
nSttF
;
++
i
)
{
// open all last file
for
(
int32_t
i
=
0
;
i
<
pFReader
->
pSet
->
nSttF
;
++
i
)
{
// open all last file
struct
SLDataIter
*
pIter
=
NULL
;
memset
(
&
pLDataIter
[
i
],
0
,
sizeof
(
SLDataIter
))
;
code
=
tLDataIterOpen
(
&
p
Iter
,
pFReader
,
i
,
pMTree
->
backward
,
suid
,
uid
,
pTimeWindow
,
pVerRange
,
code
=
tLDataIterOpen
(
&
p
LDataIter
[
i
]
,
pFReader
,
i
,
pMTree
->
backward
,
suid
,
uid
,
pTimeWindow
,
pVerRange
,
&
pMTree
->
pLoadInfo
[
i
],
pMTree
->
idStr
,
strictTimeRange
);
&
pMTree
->
pLoadInfo
[
i
],
pMTree
->
idStr
,
strictTimeRange
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_end
;
goto
_end
;
}
}
bool
hasVal
=
tLDataIterNextRow
(
pIter
,
pMTree
->
idStr
);
bool
hasVal
=
tLDataIterNextRow
(
&
pLDataIter
[
i
]
,
pMTree
->
idStr
);
if
(
hasVal
)
{
if
(
hasVal
)
{
taosArrayPush
(
pMTree
->
pIterList
,
&
pIter
);
tMergeTreeAddIter
(
pMTree
,
&
pLDataIter
[
i
]);
tMergeTreeAddIter
(
pMTree
,
pIter
);
}
else
{
}
else
{
if
(
!
pMTree
->
ignoreEarlierTs
)
{
if
(
!
pMTree
->
ignoreEarlierTs
)
{
pMTree
->
ignoreEarlierTs
=
p
Iter
->
ignoreEarlierTs
;
pMTree
->
ignoreEarlierTs
=
p
LDataIter
[
i
].
ignoreEarlierTs
;
}
}
tLDataIterClose
(
pIter
);
}
}
}
}
...
@@ -678,18 +649,8 @@ bool tMergeTreeNext(SMergeTree *pMTree) {
...
@@ -678,18 +649,8 @@ bool tMergeTreeNext(SMergeTree *pMTree) {
return
pMTree
->
pIter
!=
NULL
;
return
pMTree
->
pIter
!=
NULL
;
}
}
TSDBROW
tMergeTreeGetRow
(
SMergeTree
*
pMTree
)
{
return
pMTree
->
pIter
->
rInfo
.
row
;
}
void
tMergeTreeClose
(
SMergeTree
*
pMTree
)
{
void
tMergeTreeClose
(
SMergeTree
*
pMTree
)
{
size_t
size
=
taosArrayGetSize
(
pMTree
->
pIterList
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SLDataIter
*
pIter
=
taosArrayGetP
(
pMTree
->
pIterList
,
i
);
tLDataIterClose
(
pIter
);
}
pMTree
->
pIterList
=
taosArrayDestroy
(
pMTree
->
pIterList
);
pMTree
->
pIter
=
NULL
;
pMTree
->
pIter
=
NULL
;
if
(
pMTree
->
destroyLoadInfo
)
{
if
(
pMTree
->
destroyLoadInfo
)
{
pMTree
->
pLoadInfo
=
destroyLastBlockLoadInfo
(
pMTree
->
pLoadInfo
);
pMTree
->
pLoadInfo
=
destroyLastBlockLoadInfo
(
pMTree
->
pLoadInfo
);
pMTree
->
destroyLoadInfo
=
false
;
pMTree
->
destroyLoadInfo
=
false
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
6a889ae8
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
6a889ae8
...
@@ -70,10 +70,11 @@ static int32_t tsdbSnapReadFileDataStart(STsdbSnapReader* pReader) {
...
@@ -70,10 +70,11 @@ static int32_t tsdbSnapReadFileDataStart(STsdbSnapReader* pReader) {
if
(
pReader
->
pIter
)
{
if
(
pReader
->
pIter
)
{
// iter to next with filter info (sver, ever)
// iter to next with filter info (sver, ever)
code
=
tsdbDataIterNext2
(
pReader
->
pIter
,
code
=
tsdbDataIterNext2
(
&
(
STsdbFilterInfo
){.
flag
=
TSDB_FILTER_FLAG_BY_VERSION
,
// flag
pReader
->
pIter
,
.
sver
=
pReader
->
sver
,
&
(
STsdbFilterInfo
){.
flag
=
TSDB_FILTER_FLAG_BY_VERSION
|
TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE
,
// flag
.
ever
=
pReader
->
ever
});
.
sver
=
pReader
->
sver
,
.
ever
=
pReader
->
ever
});
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
pReader
->
pIter
->
rowInfo
.
suid
||
pReader
->
pIter
->
rowInfo
.
uid
)
{
if
(
pReader
->
pIter
->
rowInfo
.
suid
||
pReader
->
pIter
->
rowInfo
.
uid
)
{
...
@@ -94,10 +95,11 @@ static int32_t tsdbSnapReadFileDataStart(STsdbSnapReader* pReader) {
...
@@ -94,10 +95,11 @@ static int32_t tsdbSnapReadFileDataStart(STsdbSnapReader* pReader) {
if
(
pReader
->
pIter
)
{
if
(
pReader
->
pIter
)
{
// iter to valid row
// iter to valid row
code
=
tsdbDataIterNext2
(
pReader
->
pIter
,
code
=
tsdbDataIterNext2
(
&
(
STsdbFilterInfo
){.
flag
=
TSDB_FILTER_FLAG_BY_VERSION
,
// flag
pReader
->
pIter
,
.
sver
=
pReader
->
sver
,
&
(
STsdbFilterInfo
){.
flag
=
TSDB_FILTER_FLAG_BY_VERSION
|
TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE
,
// flag
.
ever
=
pReader
->
ever
});
.
sver
=
pReader
->
sver
,
.
ever
=
pReader
->
ever
});
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
pReader
->
pIter
->
rowInfo
.
suid
||
pReader
->
pIter
->
rowInfo
.
uid
)
{
if
(
pReader
->
pIter
->
rowInfo
.
suid
||
pReader
->
pIter
->
rowInfo
.
uid
)
{
...
@@ -139,7 +141,8 @@ static int32_t tsdbSnapReadNextRow(STsdbSnapReader* pReader, SRowInfo** ppRowInf
...
@@ -139,7 +141,8 @@ static int32_t tsdbSnapReadNextRow(STsdbSnapReader* pReader, SRowInfo** ppRowInf
int32_t
lino
=
0
;
int32_t
lino
=
0
;
if
(
pReader
->
pIter
)
{
if
(
pReader
->
pIter
)
{
code
=
tsdbDataIterNext2
(
pReader
->
pIter
,
&
(
STsdbFilterInfo
){.
flag
=
TSDB_FILTER_FLAG_BY_VERSION
,
// flag
code
=
tsdbDataIterNext2
(
pReader
->
pIter
,
&
(
STsdbFilterInfo
){.
flag
=
TSDB_FILTER_FLAG_BY_VERSION
|
TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE
,
// flag
.
sver
=
pReader
->
sver
,
.
sver
=
pReader
->
sver
,
.
ever
=
pReader
->
ever
});
.
ever
=
pReader
->
ever
});
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
@@ -346,8 +349,9 @@ static int32_t tsdbSnapReadNextTombData(STsdbSnapReader* pReader, SDelInfo** ppD
...
@@ -346,8 +349,9 @@ static int32_t tsdbSnapReadNextTombData(STsdbSnapReader* pReader, SDelInfo** ppD
int32_t
lino
=
0
;
int32_t
lino
=
0
;
code
=
tsdbDataIterNext2
(
code
=
tsdbDataIterNext2
(
pReader
->
pTIter
,
pReader
->
pTIter
,
&
(
STsdbFilterInfo
){.
flag
=
TSDB_FILTER_FLAG_BY_VERSION
|
TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE
,
&
(
STsdbFilterInfo
){.
flag
=
TSDB_FILTER_FLAG_BY_VERSION
,
.
sver
=
pReader
->
sver
,
.
ever
=
pReader
->
ever
});
.
sver
=
pReader
->
sver
,
.
ever
=
pReader
->
ever
});
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
ppDelInfo
)
{
if
(
ppDelInfo
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
6a889ae8
...
@@ -637,200 +637,144 @@ SColVal *tsdbRowIterNext(STSDBRowIter *pIter) {
...
@@ -637,200 +637,144 @@ SColVal *tsdbRowIterNext(STSDBRowIter *pIter) {
}
}
// SRowMerger ======================================================
// SRowMerger ======================================================
int32_t
tsdbRowMergerAdd
(
SRowMerger
*
pMerger
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
)
{
int32_t
tsdbRowMergerInit
(
SRowMerger
*
pMerger
,
STSchema
*
pResTSchema
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
TSDBKEY
key
=
TSDBROW_KEY
(
pRow
);
TSDBKEY
key
=
TSDBROW_KEY
(
pRow
);
SColVal
*
pColVal
=
&
(
SColVal
){
0
};
SColVal
*
pColVal
=
&
(
SColVal
){
0
};
STColumn
*
pTColumn
;
STColumn
*
pTColumn
;
int32_t
iCol
,
jCol
=
0
;
int32_t
iCol
,
jCol
=
1
;
if
(
NULL
==
pResTSchema
)
{
pResTSchema
=
pTSchema
;
}
pMerger
->
pTSchema
=
pResTSchema
;
pMerger
->
version
=
key
.
version
;
pMerger
->
pArray
=
taosArrayInit
(
pResTSchema
->
numOfCols
,
sizeof
(
SColVal
));
if
(
pMerger
->
pArray
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
// ts
pTColumn
=
&
pTSchema
->
columns
[
jCol
++
];
ASSERT
(
pTColumn
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
*
pColVal
=
COL_VAL_VALUE
(
pTColumn
->
colId
,
pTColumn
->
type
,
(
SValue
){.
val
=
key
.
ts
});
if
(
NULL
==
pTSchema
)
{
if
(
taosArrayPush
(
pMerger
->
pArray
,
pColVal
)
==
NULL
)
{
pTSchema
=
pMerger
->
pTSchema
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
}
// other
if
(
taosArrayGetSize
(
pMerger
->
pArray
)
==
0
)
{
for
(
iCol
=
1
;
jCol
<
pTSchema
->
numOfCols
&&
iCol
<
pResTSchema
->
numOfCols
;
++
iCol
)
{
// ts
pTColumn
=
&
pResTSchema
->
columns
[
iCol
];
jCol
=
0
;
if
(
pTSchema
->
columns
[
jCol
].
colId
<
pTColumn
->
colId
)
{
pTColumn
=
&
pTSchema
->
columns
[
jCol
++
];
++
jCol
;
--
iCol
;
continue
;
}
else
if
(
pTSchema
->
columns
[
jCol
].
colId
>
pTColumn
->
colId
)
{
taosArrayPush
(
pMerger
->
pArray
,
&
COL_VAL_NONE
(
pTColumn
->
colId
,
pTColumn
->
type
));
continue
;
}
tsdbRowGetColVal
(
pRow
,
pTSchema
,
jCol
++
,
pColVal
);
if
((
!
COL_VAL_IS_NONE
(
pColVal
))
&&
(
!
COL_VAL_IS_NULL
(
pColVal
))
&&
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
uint8_t
*
pVal
=
pColVal
->
value
.
pData
;
pColVal
->
value
.
pData
=
NULL
;
ASSERT
(
pTColumn
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
code
=
tRealloc
(
&
pColVal
->
value
.
pData
,
pColVal
->
value
.
nData
);
if
(
code
)
goto
_exit
;
if
(
pColVal
->
value
.
nData
)
{
memcpy
(
pColVal
->
value
.
pData
,
pVal
,
pColVal
->
value
.
nData
);
}
}
*
pColVal
=
COL_VAL_VALUE
(
pTColumn
->
colId
,
pTColumn
->
type
,
(
SValue
){.
val
=
key
.
ts
});
if
(
taosArrayPush
(
pMerger
->
pArray
,
pColVal
)
==
NULL
)
{
if
(
taosArrayPush
(
pMerger
->
pArray
,
pColVal
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
return
code
;
// goto _exit;
}
}
}
for
(;
iCol
<
pResTSchema
->
numOfCols
;
++
iCol
)
{
// other
pTColumn
=
&
pResTSchema
->
columns
[
iCol
];
for
(
iCol
=
1
;
jCol
<
pTSchema
->
numOfCols
&&
iCol
<
pMerger
->
pTSchema
->
numOfCols
;
++
iCol
)
{
taosArrayPush
(
pMerger
->
pArray
,
&
COL_VAL_NONE
(
pTColumn
->
colId
,
pTColumn
->
type
));
pTColumn
=
&
pMerger
->
pTSchema
->
columns
[
iCol
];
}
if
(
pTSchema
->
columns
[
jCol
].
colId
<
pTColumn
->
colId
)
{
++
jCol
;
--
iCol
;
continue
;
}
else
if
(
pTSchema
->
columns
[
jCol
].
colId
>
pTColumn
->
colId
)
{
taosArrayPush
(
pMerger
->
pArray
,
&
COL_VAL_NONE
(
pTColumn
->
colId
,
pTColumn
->
type
));
continue
;
}
_exit:
tsdbRowGetColVal
(
pRow
,
pTSchema
,
jCol
++
,
pColVal
);
return
code
;
if
((
!
COL_VAL_IS_NONE
(
pColVal
))
&&
(
!
COL_VAL_IS_NULL
(
pColVal
))
&&
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
}
uint8_t
*
pVal
=
pColVal
->
value
.
pData
;
int32_t
tsdbRowMergerAdd
(
SRowMerger
*
pMerger
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
)
{
pColVal
->
value
.
pData
=
NULL
;
int32_t
code
=
0
;
code
=
tRealloc
(
&
pColVal
->
value
.
pData
,
pColVal
->
value
.
nData
);
TSDBKEY
key
=
TSDBROW_KEY
(
pRow
);
if
(
code
)
{
SColVal
*
pColVal
=
&
(
SColVal
){
0
};
return
TSDB_CODE_OUT_OF_MEMORY
;
STColumn
*
pTColumn
;
}
int32_t
iCol
,
jCol
=
1
;
if
(
NULL
==
pTSchem
a
)
{
if
(
pColVal
->
value
.
nDat
a
)
{
pTSchema
=
pMerger
->
pTSchema
;
memcpy
(
pColVal
->
value
.
pData
,
pVal
,
pColVal
->
value
.
nData
)
;
}
}
ASSERT
(((
SColVal
*
)
pMerger
->
pArray
->
pData
)
->
value
.
val
==
key
.
ts
);
}
for
(
iCol
=
1
;
iCol
<
pMerger
->
pTSchema
->
numOfCols
&&
jCol
<
pTSchema
->
numOfCols
;
++
iCol
)
{
if
(
taosArrayPush
(
pMerger
->
pArray
,
pColVal
)
==
NULL
)
{
pTColumn
=
&
pMerger
->
pTSchema
->
columns
[
iCol
];
code
=
TSDB_CODE_OUT_OF_MEMORY
;
if
(
pTSchema
->
columns
[
jCol
].
colId
<
pTColumn
->
colId
)
{
return
code
;
++
jCol
;
}
--
iCol
;
continue
;
}
else
if
(
pTSchema
->
columns
[
jCol
].
colId
>
pTColumn
->
colId
)
{
continue
;
}
}
tsdbRowGetColVal
(
pRow
,
pTSchema
,
jCol
++
,
pColVal
);
for
(;
iCol
<
pMerger
->
pTSchema
->
numOfCols
;
++
iCol
)
{
pTColumn
=
&
pMerger
->
pTSchema
->
columns
[
iCol
];
taosArrayPush
(
pMerger
->
pArray
,
&
COL_VAL_NONE
(
pTColumn
->
colId
,
pTColumn
->
type
));
}
if
(
key
.
version
>
pMerger
->
version
)
{
pMerger
->
version
=
key
.
version
;
if
(
!
COL_VAL_IS_NONE
(
pColVal
))
{
return
0
;
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
}
else
{
SColVal
*
pTColVal
=
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
ASSERT
(((
SColVal
*
)
pMerger
->
pArray
->
pData
)
->
value
.
val
==
key
.
ts
);
if
(
!
COL_VAL_IS_NULL
(
pColVal
))
{
code
=
tRealloc
(
&
pTColVal
->
value
.
pData
,
pColVal
->
value
.
nData
);
for
(
iCol
=
1
;
iCol
<
pMerger
->
pTSchema
->
numOfCols
&&
jCol
<
pTSchema
->
numOfCols
;
++
iCol
)
{
if
(
code
)
return
code
;
pTColumn
=
&
pMerger
->
pTSchema
->
columns
[
iCol
];
if
(
pTSchema
->
columns
[
jCol
].
colId
<
pTColumn
->
colId
)
{
++
jCol
;
--
iCol
;
continue
;
}
else
if
(
pTSchema
->
columns
[
jCol
].
colId
>
pTColumn
->
colId
)
{
continue
;
}
pTColVal
->
value
.
nData
=
pColVal
->
value
.
nData
;
tsdbRowGetColVal
(
pRow
,
pTSchema
,
jCol
++
,
pColVal
);
if
(
pTColVal
->
value
.
nData
)
{
memcpy
(
pTColVal
->
value
.
pData
,
pColVal
->
value
.
pData
,
pTColVal
->
value
.
nData
);
if
(
key
.
version
>
pMerger
->
version
)
{
if
(
!
COL_VAL_IS_NONE
(
pColVal
))
{
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
SColVal
*
pTColVal
=
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
if
(
!
COL_VAL_IS_NULL
(
pColVal
))
{
code
=
tRealloc
(
&
pTColVal
->
value
.
pData
,
pColVal
->
value
.
nData
);
if
(
code
)
return
code
;
pTColVal
->
value
.
nData
=
pColVal
->
value
.
nData
;
if
(
pTColVal
->
value
.
nData
)
{
memcpy
(
pTColVal
->
value
.
pData
,
pColVal
->
value
.
pData
,
pTColVal
->
value
.
nData
);
}
pTColVal
->
flag
=
0
;
}
else
{
tFree
(
pTColVal
->
value
.
pData
);
taosArraySet
(
pMerger
->
pArray
,
iCol
,
pColVal
);
}
}
pTColVal
->
flag
=
0
;
}
else
{
}
else
{
tFree
(
pTColVal
->
value
.
pData
);
taosArraySet
(
pMerger
->
pArray
,
iCol
,
pColVal
);
taosArraySet
(
pMerger
->
pArray
,
iCol
,
pColVal
);
}
}
}
else
{
taosArraySet
(
pMerger
->
pArray
,
iCol
,
pColVal
);
}
}
}
}
else
if
(
key
.
version
<
pMerger
->
version
)
{
}
else
if
(
key
.
version
<
pMerger
->
version
)
{
SColVal
*
tColVal
=
(
SColVal
*
)
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
SColVal
*
tColVal
=
(
SColVal
*
)
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
if
(
COL_VAL_IS_NONE
(
tColVal
)
&&
!
COL_VAL_IS_NONE
(
pColVal
))
{
if
(
COL_VAL_IS_NONE
(
tColVal
)
&&
!
COL_VAL_IS_NONE
(
pColVal
))
{
if
((
!
COL_VAL_IS_NULL
(
pColVal
))
&&
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
if
((
!
COL_VAL_IS_NULL
(
pColVal
))
&&
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
code
=
tRealloc
(
&
tColVal
->
value
.
pData
,
pColVal
->
value
.
nData
);
code
=
tRealloc
(
&
tColVal
->
value
.
pData
,
pColVal
->
value
.
nData
);
if
(
code
)
return
code
;
if
(
code
)
return
code
;
tColVal
->
value
.
nData
=
pColVal
->
value
.
nData
;
tColVal
->
value
.
nData
=
pColVal
->
value
.
nData
;
if
(
pColVal
->
value
.
nData
)
{
if
(
pColVal
->
value
.
nData
)
{
memcpy
(
tColVal
->
value
.
pData
,
pColVal
->
value
.
pData
,
pColVal
->
value
.
nData
);
memcpy
(
tColVal
->
value
.
pData
,
pColVal
->
value
.
pData
,
pColVal
->
value
.
nData
);
}
tColVal
->
flag
=
0
;
}
else
{
taosArraySet
(
pMerger
->
pArray
,
iCol
,
pColVal
);
}
}
tColVal
->
flag
=
0
;
}
else
{
taosArraySet
(
pMerger
->
pArray
,
iCol
,
pColVal
);
}
}
}
else
{
ASSERT
(
0
&&
"dup versions not allowed"
);
}
}
}
else
{
ASSERT
(
0
&&
"dup versions not allowed"
);
}
}
}
pMerger
->
version
=
key
.
version
;
pMerger
->
version
=
key
.
version
;
return
code
;
return
code
;
}
}
}
/*
int32_t tsdbRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) {
int32_t code = 0;
TSDBKEY key = TSDBROW_KEY(pRow);
SColVal *pColVal = &(SColVal){0};
STColumn *pTColumn;
pMerger->pTSchema = pTSchema;
pMerger->version = key.version;
pMerger->pArray = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal));
int32_t
tsdbRowMergerInit
(
SRowMerger
*
pMerger
,
STSchema
*
pSchema
)
{
pMerger
->
pTSchema
=
pSchema
;
pMerger
->
pArray
=
taosArrayInit
(
pSchema
->
numOfCols
,
sizeof
(
SColVal
));
if
(
pMerger
->
pArray
==
NULL
)
{
if
(
pMerger
->
pArray
==
NULL
)
{
code = TSDB_CODE_OUT_OF_MEMORY;
return
TSDB_CODE_OUT_OF_MEMORY
;
goto _exit;
}
else
{
}
return
TSDB_CODE_SUCCESS
;
// ts
pTColumn = &pTSchema->columns[0];
ASSERT(pTColumn->type == TSDB_DATA_TYPE_TIMESTAMP);
*pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.val = key.ts});
if (taosArrayPush(pMerger->pArray, pColVal) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
// other
for (int16_t iCol = 1; iCol < pTSchema->numOfCols; iCol++) {
tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal);
if ((!COL_VAL_IS_NONE(pColVal)) && (!COL_VAL_IS_NULL(pColVal)) && IS_VAR_DATA_TYPE(pColVal->type)) {
uint8_t *pVal = pColVal->value.pData;
pColVal->value.pData = NULL;
code = tRealloc(&pColVal->value.pData, pColVal->value.nData);
if (code) goto _exit;
if (pColVal->value.nData) {
memcpy(pColVal->value.pData, pVal, pColVal->value.nData);
}
}
if (taosArrayPush(pMerger->pArray, pColVal) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
}
}
_exit:
return code;
}
}
*/
void
tsdbRowMergerClear
(
SRowMerger
*
pMerger
)
{
void
tsdbRowMergerClear
(
SRowMerger
*
pMerger
)
{
for
(
int32_t
iCol
=
1
;
iCol
<
pMerger
->
pTSchema
->
numOfCols
;
iCol
++
)
{
for
(
int32_t
iCol
=
1
;
iCol
<
pMerger
->
pTSchema
->
numOfCols
;
iCol
++
)
{
SColVal
*
pTColVal
=
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
SColVal
*
pTColVal
=
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
if
(
IS_VAR_DATA_TYPE
(
pTColVal
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pTColVal
->
type
))
{
...
@@ -838,74 +782,21 @@ void tsdbRowMergerClear(SRowMerger *pMerger) {
...
@@ -838,74 +782,21 @@ void tsdbRowMergerClear(SRowMerger *pMerger) {
}
}
}
}
taosArray
Destroy
(
pMerger
->
pArray
);
taosArray
Clear
(
pMerger
->
pArray
);
}
}
/*
int32_t tsdbRowMerge(SRowMerger *pMerger, TSDBROW *pRow) {
int32_t code = 0;
TSDBKEY key = TSDBROW_KEY(pRow);
SColVal *pColVal = &(SColVal){0};
ASSERT(((SColVal *)pMerger->pArray->pData)->value.val == key.ts);
for (int32_t iCol = 1; iCol < pMerger->pTSchema->numOfCols; iCol++) {
tsdbRowGetColVal(pRow, pMerger->pTSchema, iCol, pColVal);
if (key.version > pMerger->version) {
if (!COL_VAL_IS_NONE(pColVal)) {
if (IS_VAR_DATA_TYPE(pColVal->type)) {
SColVal *pTColVal = taosArrayGet(pMerger->pArray, iCol);
if (!COL_VAL_IS_NULL(pColVal)) {
code = tRealloc(&pTColVal->value.pData, pColVal->value.nData);
if (code) goto _exit;
pTColVal->value.nData = pColVal->value.nData;
if (pTColVal->value.nData) {
memcpy(pTColVal->value.pData, pColVal->value.pData, pTColVal->value.nData);
}
pTColVal->flag = 0;
} else {
tFree(pTColVal->value.pData);
pTColVal->value.pData = NULL;
taosArraySet(pMerger->pArray, iCol, pColVal);
}
} else {
taosArraySet(pMerger->pArray, iCol, pColVal);
}
}
} else if (key.version < pMerger->version) {
SColVal *tColVal = (SColVal *)taosArrayGet(pMerger->pArray, iCol);
if (COL_VAL_IS_NONE(tColVal) && !COL_VAL_IS_NONE(pColVal)) {
if (IS_VAR_DATA_TYPE(pColVal->type)) {
if (!COL_VAL_IS_NULL(pColVal)) {
code = tRealloc(&tColVal->value.pData, pColVal->value.nData);
if (code) goto _exit;
tColVal->value.nData = pColVal->value.nData;
void
tsdbRowMergerCleanup
(
SRowMerger
*
pMerger
)
{
if (tColVal->value.nData) {
int32_t
numOfCols
=
taosArrayGetSize
(
pMerger
->
pArray
);
memcpy(tColVal->value.pData, pColVal->value.pData, tColVal->value.nData);
for
(
int32_t
iCol
=
1
;
iCol
<
numOfCols
;
iCol
++
)
{
}
SColVal
*
pTColVal
=
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
tColVal->flag = 0;
if
(
IS_VAR_DATA_TYPE
(
pTColVal
->
type
))
{
} else {
tFree
(
pTColVal
->
value
.
pData
);
tFree(tColVal->value.pData);
tColVal->value.pData = NULL;
taosArraySet(pMerger->pArray, iCol, pColVal);
}
} else {
taosArraySet(pMerger->pArray, iCol, pColVal);
}
}
} else {
ASSERT(0);
}
}
}
}
pMerger->version = key.version;
taosArrayDestroy
(
pMerger
->
pArray
);
_exit:
return code;
}
}
*/
int32_t
tsdbRowMergerGetRow
(
SRowMerger
*
pMerger
,
SRow
**
ppRow
)
{
int32_t
tsdbRowMergerGetRow
(
SRowMerger
*
pMerger
,
SRow
**
ppRow
)
{
return
tRowBuild
(
pMerger
->
pArray
,
pMerger
->
pTSchema
,
ppRow
);
return
tRowBuild
(
pMerger
->
pArray
,
pMerger
->
pTSchema
,
ppRow
);
}
}
...
@@ -1160,8 +1051,6 @@ int32_t tBlockDataCreate(SBlockData *pBlockData) {
...
@@ -1160,8 +1051,6 @@ int32_t tBlockDataCreate(SBlockData *pBlockData) {
pBlockData
->
aTSKEY
=
NULL
;
pBlockData
->
aTSKEY
=
NULL
;
pBlockData
->
nColData
=
0
;
pBlockData
->
nColData
=
0
;
pBlockData
->
aColData
=
NULL
;
pBlockData
->
aColData
=
NULL
;
_exit:
return
code
;
return
code
;
}
}
...
@@ -1218,9 +1107,10 @@ int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema,
...
@@ -1218,9 +1107,10 @@ int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema,
int32_t
iColumn
=
1
;
int32_t
iColumn
=
1
;
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
iColumn
];
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
iColumn
];
for
(
int32_t
iCid
=
0
;
iCid
<
nCid
;
iCid
++
)
{
for
(
int32_t
iCid
=
0
;
iCid
<
nCid
;
iCid
++
)
{
if
(
ASSERTS
(
pTColumn
!=
NULL
,
"invalid input param"
))
{
code
=
TSDB_CODE_INVALID_PARA
;
// aCid array (from taos client catalog) contains columns that does not exist in the pTSchema. the pTSchema is newer
goto
_exit
;
if
(
pTColumn
==
NULL
)
{
continue
;
}
}
while
(
pTColumn
->
colId
<
aCid
[
iCid
])
{
while
(
pTColumn
->
colId
<
aCid
[
iCid
])
{
...
@@ -1229,9 +1119,8 @@ int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema,
...
@@ -1229,9 +1119,8 @@ int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema,
pTColumn
=
&
pTSchema
->
columns
[
iColumn
];
pTColumn
=
&
pTSchema
->
columns
[
iColumn
];
}
}
if
(
ASSERTS
(
pTColumn
->
colId
==
aCid
[
iCid
],
"invalid input param"
))
{
if
(
pTColumn
->
colId
!=
aCid
[
iCid
])
{
code
=
TSDB_CODE_INVALID_PARA
;
continue
;
goto
_exit
;
}
}
tColDataInit
(
&
pBlockData
->
aColData
[
iCid
],
pTColumn
->
colId
,
pTColumn
->
type
,
tColDataInit
(
&
pBlockData
->
aColData
[
iCid
],
pTColumn
->
colId
,
pTColumn
->
type
,
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
6a889ae8
...
@@ -58,6 +58,7 @@ typedef enum {
...
@@ -58,6 +58,7 @@ typedef enum {
CTG_CI_OTHERTABLE_META
,
CTG_CI_OTHERTABLE_META
,
CTG_CI_TBL_SMA
,
CTG_CI_TBL_SMA
,
CTG_CI_TBL_CFG
,
CTG_CI_TBL_CFG
,
CTG_CI_TBL_TAG
,
CTG_CI_INDEX_INFO
,
CTG_CI_INDEX_INFO
,
CTG_CI_USER
,
CTG_CI_USER
,
CTG_CI_UDF
,
CTG_CI_UDF
,
...
@@ -110,6 +111,7 @@ typedef enum {
...
@@ -110,6 +111,7 @@ typedef enum {
CTG_TASK_GET_SVR_VER
,
CTG_TASK_GET_SVR_VER
,
CTG_TASK_GET_TB_META_BATCH
,
CTG_TASK_GET_TB_META_BATCH
,
CTG_TASK_GET_TB_HASH_BATCH
,
CTG_TASK_GET_TB_HASH_BATCH
,
CTG_TASK_GET_TB_TAG
,
}
CTG_TASK_TYPE
;
}
CTG_TASK_TYPE
;
typedef
enum
{
typedef
enum
{
...
@@ -152,6 +154,11 @@ typedef struct SCtgTbCacheInfo {
...
@@ -152,6 +154,11 @@ typedef struct SCtgTbCacheInfo {
int32_t
tbType
;
int32_t
tbType
;
}
SCtgTbCacheInfo
;
}
SCtgTbCacheInfo
;
typedef
struct
SCtgTbMetaParam
{
SName
*
pName
;
int32_t
flag
;
}
SCtgTbMetaParam
;
typedef
struct
SCtgTbMetaCtx
{
typedef
struct
SCtgTbMetaCtx
{
SCtgTbCacheInfo
tbInfo
;
SCtgTbCacheInfo
tbInfo
;
int32_t
vgId
;
int32_t
vgId
;
...
@@ -186,6 +193,11 @@ typedef struct SCtgTbCfgCtx {
...
@@ -186,6 +193,11 @@ typedef struct SCtgTbCfgCtx {
SVgroupInfo
*
pVgInfo
;
SVgroupInfo
*
pVgInfo
;
}
SCtgTbCfgCtx
;
}
SCtgTbCfgCtx
;
typedef
struct
SCtgTbTagCtx
{
SName
*
pName
;
SVgroupInfo
*
pVgInfo
;
}
SCtgTbTagCtx
;
typedef
struct
SCtgDbVgCtx
{
typedef
struct
SCtgDbVgCtx
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
}
SCtgDbVgCtx
;
}
SCtgDbVgCtx
;
...
@@ -304,6 +316,7 @@ typedef struct SCtgJob {
...
@@ -304,6 +316,7 @@ typedef struct SCtgJob {
catalogCallback
userFp
;
catalogCallback
userFp
;
int32_t
tbMetaNum
;
int32_t
tbMetaNum
;
int32_t
tbHashNum
;
int32_t
tbHashNum
;
int32_t
tbTagNum
;
int32_t
dbVgNum
;
int32_t
dbVgNum
;
int32_t
udfNum
;
int32_t
udfNum
;
int32_t
qnodeNum
;
int32_t
qnodeNum
;
...
@@ -346,6 +359,7 @@ typedef struct SCtgSubRes {
...
@@ -346,6 +359,7 @@ typedef struct SCtgSubRes {
struct
SCtgTask
{
struct
SCtgTask
{
CTG_TASK_TYPE
type
;
CTG_TASK_TYPE
type
;
bool
subTask
;
int32_t
taskId
;
int32_t
taskId
;
SCtgJob
*
pJob
;
SCtgJob
*
pJob
;
void
*
taskCtx
;
void
*
taskCtx
;
...
@@ -623,6 +637,7 @@ typedef struct SCtgCacheItemInfo {
...
@@ -623,6 +637,7 @@ typedef struct SCtgCacheItemInfo {
#define CTG_FLAG_SYS_DB 0x8
#define CTG_FLAG_SYS_DB 0x8
#define CTG_FLAG_FORCE_UPDATE 0x10
#define CTG_FLAG_FORCE_UPDATE 0x10
#define CTG_FLAG_ONLY_CACHE 0x20
#define CTG_FLAG_ONLY_CACHE 0x20
#define CTG_FLAG_SYNC_OP 0x40
#define CTG_FLAG_SET(_flag, _v) ((_flag) |= (_v))
#define CTG_FLAG_SET(_flag, _v) ((_flag) |= (_v))
...
@@ -925,6 +940,10 @@ void ctgReleaseVgMetaToCache(SCatalog* pCtg, SCtgDBCache* dbCache, SCtgTbCach
...
@@ -925,6 +940,10 @@ void ctgReleaseVgMetaToCache(SCatalog* pCtg, SCtgDBCache* dbCache, SCtgTbCach
void
ctgReleaseTbMetaToCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
,
SCtgTbCache
*
pCache
);
void
ctgReleaseTbMetaToCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
,
SCtgTbCache
*
pCache
);
void
ctgGetGlobalCacheStat
(
SCtgCacheStat
*
pStat
);
void
ctgGetGlobalCacheStat
(
SCtgCacheStat
*
pStat
);
int32_t
ctgChkSetAuthRes
(
SCatalog
*
pCtg
,
SCtgAuthReq
*
req
,
SCtgAuthRsp
*
res
);
int32_t
ctgChkSetAuthRes
(
SCatalog
*
pCtg
,
SCtgAuthReq
*
req
,
SCtgAuthRsp
*
res
);
int32_t
ctgGetTbMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
);
int32_t
ctgGetCachedStbNameFromSuid
(
SCatalog
*
pCtg
,
char
*
dbFName
,
uint64_t
suid
,
char
**
stbName
);
int32_t
ctgGetTbTagCb
(
SCtgTask
*
pTask
);
int32_t
ctgGetUserCb
(
SCtgTask
*
pTask
);
extern
SCatalogMgmt
gCtgMgmt
;
extern
SCatalogMgmt
gCtgMgmt
;
extern
SCtgDebug
gCTGDebug
;
extern
SCtgDebug
gCTGDebug
;
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
6a889ae8
...
@@ -208,7 +208,7 @@ int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx
...
@@ -208,7 +208,7 @@ int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx
}
}
while
(
true
)
{
while
(
true
)
{
CTG_ERR_JRET
(
ctgRefreshTbMeta
(
pCtg
,
pConn
,
ctx
,
&
output
,
false
));
CTG_ERR_JRET
(
ctgRefreshTbMeta
(
pCtg
,
pConn
,
ctx
,
&
output
,
ctx
->
flag
&
CTG_FLAG_SYNC_OP
));
if
(
CTG_IS_META_TABLE
(
output
->
metaType
))
{
if
(
CTG_IS_META_TABLE
(
output
->
metaType
))
{
*
pTableMeta
=
output
->
tbMeta
;
*
pTableMeta
=
output
->
tbMeta
;
...
@@ -429,6 +429,48 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName,
...
@@ -429,6 +429,48 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName,
CTG_RET
(
TSDB_CODE_SUCCESS
);
CTG_RET
(
TSDB_CODE_SUCCESS
);
}
}
int32_t
ctgGetTbTag
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pRes
)
{
SVgroupInfo
vgroupInfo
=
{
0
};
STableCfg
*
pCfg
=
NULL
;
int32_t
code
=
0
;
CTG_ERR_RET
(
ctgGetTbHashVgroup
(
pCtg
,
pConn
,
pTableName
,
&
vgroupInfo
,
NULL
));
CTG_ERR_RET
(
ctgGetTableCfgFromVnode
(
pCtg
,
pConn
,
pTableName
,
&
vgroupInfo
,
&
pCfg
,
NULL
));
if
(
NULL
==
pCfg
->
pTags
||
pCfg
->
tagsLen
<=
0
)
{
ctgError
(
"invalid tag in tbCfg rsp, pTags:%p, len:%d"
,
pCfg
->
pTags
,
pCfg
->
tagsLen
);
CTG_ERR_JRET
(
TSDB_CODE_INVALID_MSG
);
}
SArray
*
pTagVals
=
NULL
;
STag
*
pTag
=
(
STag
*
)
pCfg
->
pTags
;
if
(
tTagIsJson
(
pTag
))
{
pTagVals
=
taosArrayInit
(
1
,
sizeof
(
STagVal
));
if
(
NULL
==
pTagVals
)
{
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
char
*
pJson
=
parseTagDatatoJson
(
pTag
);
STagVal
tagVal
;
tagVal
.
cid
=
0
;
tagVal
.
type
=
TSDB_DATA_TYPE_JSON
;
tagVal
.
pData
=
pJson
;
tagVal
.
nData
=
strlen
(
pJson
);
taosArrayPush
(
pTagVals
,
&
tagVal
);
}
else
{
CTG_ERR_JRET
(
tTagToValArray
((
const
STag
*
)
pCfg
->
pTags
,
&
pTagVals
));
}
*
pRes
=
pTagVals
;
_return:
tFreeSTableCfgRsp
((
STableCfgRsp
*
)
pCfg
);
CTG_RET
(
code
);
}
int32_t
ctgGetTbDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pVgList
)
{
int32_t
ctgGetTbDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pVgList
)
{
STableMeta
*
tbMeta
=
NULL
;
STableMeta
*
tbMeta
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -1414,6 +1456,21 @@ _return:
...
@@ -1414,6 +1456,21 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogGetTableTag
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pRes
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
int32_t
code
=
0
;
CTG_ERR_JRET
(
ctgGetTbTag
(
pCtg
,
pConn
,
(
SName
*
)
pTableName
,
pRes
));
_return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogRefreshGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
int32_t
catalogRefreshGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
6a889ae8
...
@@ -21,7 +21,8 @@
...
@@ -21,7 +21,8 @@
#include "trpc.h"
#include "trpc.h"
int32_t
ctgInitGetTbMetaTask
(
SCtgJob
*
pJob
,
int32_t
taskIdx
,
void
*
param
)
{
int32_t
ctgInitGetTbMetaTask
(
SCtgJob
*
pJob
,
int32_t
taskIdx
,
void
*
param
)
{
SName
*
name
=
(
SName
*
)
param
;
SCtgTbMetaParam
*
pParam
=
(
SCtgTbMetaParam
*
)
param
;
SName
*
name
=
pParam
->
pName
;
SCtgTask
task
=
{
0
};
SCtgTask
task
=
{
0
};
task
.
type
=
CTG_TASK_GET_TB_META
;
task
.
type
=
CTG_TASK_GET_TB_META
;
...
@@ -41,7 +42,7 @@ int32_t ctgInitGetTbMetaTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
...
@@ -41,7 +42,7 @@ int32_t ctgInitGetTbMetaTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
}
}
memcpy
(
ctx
->
pName
,
name
,
sizeof
(
*
name
));
memcpy
(
ctx
->
pName
,
name
,
sizeof
(
*
name
));
ctx
->
flag
=
CTG_FLAG_UNKNOWN_STB
;
ctx
->
flag
=
pParam
->
flag
|
CTG_FLAG_UNKNOWN_STB
;
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
...
@@ -386,6 +387,37 @@ int32_t ctgInitGetTbCfgTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
...
@@ -386,6 +387,37 @@ int32_t ctgInitGetTbCfgTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgInitGetTbTagTask
(
SCtgJob
*
pJob
,
int32_t
taskIdx
,
void
*
param
)
{
SName
*
name
=
(
SName
*
)
param
;
SCtgTask
task
=
{
0
};
task
.
type
=
CTG_TASK_GET_TB_TAG
;
task
.
taskId
=
taskIdx
;
task
.
pJob
=
pJob
;
task
.
taskCtx
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgTbTagCtx
));
if
(
NULL
==
task
.
taskCtx
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
SCtgTbTagCtx
*
ctx
=
task
.
taskCtx
;
ctx
->
pName
=
taosMemoryMalloc
(
sizeof
(
*
name
));
if
(
NULL
==
ctx
->
pName
)
{
taosMemoryFree
(
task
.
taskCtx
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
memcpy
(
ctx
->
pName
,
name
,
sizeof
(
*
name
));
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:0x%"
PRIx64
" the %dth task type %s initialized, tbName:%s"
,
pJob
->
queryId
,
taskIdx
,
ctgTaskTypeStr
(
task
.
type
),
name
->
tname
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgHandleForceUpdate
(
SCatalog
*
pCtg
,
int32_t
taskNum
,
SCtgJob
*
pJob
,
const
SCatalogReq
*
pReq
)
{
int32_t
ctgHandleForceUpdate
(
SCatalog
*
pCtg
,
int32_t
taskNum
,
SCtgJob
*
pJob
,
const
SCatalogReq
*
pReq
)
{
SHashObj
*
pDb
=
taosHashInit
(
taskNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
SHashObj
*
pDb
=
taosHashInit
(
taskNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
SHashObj
*
pTb
=
taosHashInit
(
taskNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
SHashObj
*
pTb
=
taosHashInit
(
taskNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
...
@@ -437,6 +469,15 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con
...
@@ -437,6 +469,15 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
name
,
dbFName
);
tNameGetFullDbName
(
name
,
dbFName
);
taosHashPut
(
pDb
,
dbFName
,
strlen
(
dbFName
),
dbFName
,
TSDB_DB_FNAME_LEN
);
taosHashPut
(
pDb
,
dbFName
,
strlen
(
dbFName
),
dbFName
,
TSDB_DB_FNAME_LEN
);
taosHashPut
(
pTb
,
name
,
sizeof
(
SName
),
name
,
sizeof
(
SName
));
}
for
(
int32_t
i
=
0
;
i
<
pJob
->
tbTagNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableTag
,
i
);
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
name
,
dbFName
);
taosHashPut
(
pDb
,
dbFName
,
strlen
(
dbFName
),
dbFName
,
TSDB_DB_FNAME_LEN
);
taosHashPut
(
pTb
,
name
,
sizeof
(
SName
),
name
,
sizeof
(
SName
));
}
}
char
*
dbFName
=
taosHashIterate
(
pDb
,
NULL
);
char
*
dbFName
=
taosHashIterate
(
pDb
,
NULL
);
...
@@ -505,9 +546,10 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
...
@@ -505,9 +546,10 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
int32_t
dbInfoNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pDbInfo
);
int32_t
dbInfoNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pDbInfo
);
int32_t
tbIndexNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pTableIndex
);
int32_t
tbIndexNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pTableIndex
);
int32_t
tbCfgNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pTableCfg
);
int32_t
tbCfgNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pTableCfg
);
int32_t
tbTagNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pTableTag
);
int32_t
taskNum
=
tbMetaNum
+
dbVgNum
+
udfNum
+
tbHashNum
+
qnodeNum
+
dnodeNum
+
svrVerNum
+
dbCfgNum
+
indexNum
+
int32_t
taskNum
=
tbMetaNum
+
dbVgNum
+
udfNum
+
tbHashNum
+
qnodeNum
+
dnodeNum
+
svrVerNum
+
dbCfgNum
+
indexNum
+
userNum
+
dbInfoNum
+
tbIndexNum
+
tbCfgNum
;
userNum
+
dbInfoNum
+
tbIndexNum
+
tbCfgNum
+
tbTagNum
;
*
job
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgJob
));
*
job
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgJob
));
if
(
NULL
==
*
job
)
{
if
(
NULL
==
*
job
)
{
...
@@ -537,6 +579,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
...
@@ -537,6 +579,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
pJob
->
tbIndexNum
=
tbIndexNum
;
pJob
->
tbIndexNum
=
tbIndexNum
;
pJob
->
tbCfgNum
=
tbCfgNum
;
pJob
->
tbCfgNum
=
tbCfgNum
;
pJob
->
svrVerNum
=
svrVerNum
;
pJob
->
svrVerNum
=
svrVerNum
;
pJob
->
tbTagNum
=
tbTagNum
;
#if CTG_BATCH_FETCH
#if CTG_BATCH_FETCH
pJob
->
pBatchs
=
pJob
->
pBatchs
=
...
@@ -604,6 +647,12 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
...
@@ -604,6 +647,12 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
CTG_ERR_JRET
(
ctgInitTask
(
pJob
,
CTG_TASK_GET_TB_CFG
,
name
,
NULL
));
CTG_ERR_JRET
(
ctgInitTask
(
pJob
,
CTG_TASK_GET_TB_CFG
,
name
,
NULL
));
}
}
for
(
int32_t
i
=
0
;
i
<
tbTagNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableTag
,
i
);
CTG_ERR_JRET
(
ctgInitTask
(
pJob
,
CTG_TASK_GET_TB_TAG
,
name
,
NULL
));
}
for
(
int32_t
i
=
0
;
i
<
indexNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
indexNum
;
++
i
)
{
char
*
indexName
=
taosArrayGet
(
pReq
->
pIndex
,
i
);
char
*
indexName
=
taosArrayGet
(
pReq
->
pIndex
,
i
);
CTG_ERR_JRET
(
ctgInitTask
(
pJob
,
CTG_TASK_GET_INDEX_INFO
,
indexName
,
NULL
));
CTG_ERR_JRET
(
ctgInitTask
(
pJob
,
CTG_TASK_GET_INDEX_INFO
,
indexName
,
NULL
));
...
@@ -650,6 +699,10 @@ _return:
...
@@ -650,6 +699,10 @@ _return:
}
}
int32_t
ctgDumpTbMetaRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpTbMetaRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pTableMeta
)
{
if
(
NULL
==
pJob
->
jobRes
.
pTableMeta
)
{
pJob
->
jobRes
.
pTableMeta
=
taosArrayInit
(
pJob
->
tbMetaNum
,
sizeof
(
SMetaRes
));
pJob
->
jobRes
.
pTableMeta
=
taosArrayInit
(
pJob
->
tbMetaNum
,
sizeof
(
SMetaRes
));
...
@@ -665,6 +718,10 @@ int32_t ctgDumpTbMetaRes(SCtgTask* pTask) {
...
@@ -665,6 +718,10 @@ int32_t ctgDumpTbMetaRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpTbMetasRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpTbMetasRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
pJob
->
jobRes
.
pTableMeta
=
pTask
->
res
;
pJob
->
jobRes
.
pTableMeta
=
pTask
->
res
;
...
@@ -673,6 +730,10 @@ int32_t ctgDumpTbMetasRes(SCtgTask* pTask) {
...
@@ -673,6 +730,10 @@ int32_t ctgDumpTbMetasRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpDbVgRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpDbVgRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pDbVgroup
)
{
if
(
NULL
==
pJob
->
jobRes
.
pDbVgroup
)
{
pJob
->
jobRes
.
pDbVgroup
=
taosArrayInit
(
pJob
->
dbVgNum
,
sizeof
(
SMetaRes
));
pJob
->
jobRes
.
pDbVgroup
=
taosArrayInit
(
pJob
->
dbVgNum
,
sizeof
(
SMetaRes
));
...
@@ -688,6 +749,10 @@ int32_t ctgDumpDbVgRes(SCtgTask* pTask) {
...
@@ -688,6 +749,10 @@ int32_t ctgDumpDbVgRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpTbHashRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpTbHashRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pTableHash
)
{
if
(
NULL
==
pJob
->
jobRes
.
pTableHash
)
{
pJob
->
jobRes
.
pTableHash
=
taosArrayInit
(
pJob
->
tbHashNum
,
sizeof
(
SMetaRes
));
pJob
->
jobRes
.
pTableHash
=
taosArrayInit
(
pJob
->
tbHashNum
,
sizeof
(
SMetaRes
));
...
@@ -703,6 +768,10 @@ int32_t ctgDumpTbHashRes(SCtgTask* pTask) {
...
@@ -703,6 +768,10 @@ int32_t ctgDumpTbHashRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpTbHashsRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpTbHashsRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
pJob
->
jobRes
.
pTableHash
=
pTask
->
res
;
pJob
->
jobRes
.
pTableHash
=
pTask
->
res
;
...
@@ -711,9 +780,17 @@ int32_t ctgDumpTbHashsRes(SCtgTask* pTask) {
...
@@ -711,9 +780,17 @@ int32_t ctgDumpTbHashsRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpTbIndexRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpTbIndexRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pTableIndex
)
{
if
(
NULL
==
pJob
->
jobRes
.
pTableIndex
)
{
pJob
->
jobRes
.
pTableIndex
=
taosArrayInit
(
pJob
->
tbIndexNum
,
sizeof
(
SMetaRes
));
SArray
*
pRes
=
taosArrayInit
(
pJob
->
tbIndexNum
,
sizeof
(
SMetaRes
));
if
(
atomic_val_compare_exchange_ptr
(
&
pJob
->
jobRes
.
pTableIndex
,
NULL
,
pRes
))
{
taosArrayDestroy
(
pRes
);
}
if
(
NULL
==
pJob
->
jobRes
.
pTableIndex
)
{
if
(
NULL
==
pJob
->
jobRes
.
pTableIndex
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
...
@@ -726,9 +803,17 @@ int32_t ctgDumpTbIndexRes(SCtgTask* pTask) {
...
@@ -726,9 +803,17 @@ int32_t ctgDumpTbIndexRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpTbCfgRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpTbCfgRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pTableCfg
)
{
if
(
NULL
==
pJob
->
jobRes
.
pTableCfg
)
{
pJob
->
jobRes
.
pTableCfg
=
taosArrayInit
(
pJob
->
tbCfgNum
,
sizeof
(
SMetaRes
));
SArray
*
pRes
=
taosArrayInit
(
pJob
->
tbCfgNum
,
sizeof
(
SMetaRes
));
if
(
atomic_val_compare_exchange_ptr
(
&
pJob
->
jobRes
.
pTableCfg
,
NULL
,
pRes
))
{
taosArrayDestroy
(
pRes
);
}
if
(
NULL
==
pJob
->
jobRes
.
pTableCfg
)
{
if
(
NULL
==
pJob
->
jobRes
.
pTableCfg
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
...
@@ -740,7 +825,35 @@ int32_t ctgDumpTbCfgRes(SCtgTask* pTask) {
...
@@ -740,7 +825,35 @@ int32_t ctgDumpTbCfgRes(SCtgTask* pTask) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgDumpTbTagRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pTableTag
)
{
SArray
*
pRes
=
taosArrayInit
(
pJob
->
tbTagNum
,
sizeof
(
SMetaRes
));
if
(
atomic_val_compare_exchange_ptr
(
&
pJob
->
jobRes
.
pTableTag
,
NULL
,
pRes
))
{
taosArrayDestroy
(
pRes
);
}
if
(
NULL
==
pJob
->
jobRes
.
pTableTag
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
SMetaRes
res
=
{.
code
=
pTask
->
code
,
.
pRes
=
pTask
->
res
};
taosArrayPush
(
pJob
->
jobRes
.
pTableTag
,
&
res
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgDumpIndexRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpIndexRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pIndex
)
{
if
(
NULL
==
pJob
->
jobRes
.
pIndex
)
{
pJob
->
jobRes
.
pIndex
=
taosArrayInit
(
pJob
->
indexNum
,
sizeof
(
SMetaRes
));
pJob
->
jobRes
.
pIndex
=
taosArrayInit
(
pJob
->
indexNum
,
sizeof
(
SMetaRes
));
...
@@ -756,6 +869,10 @@ int32_t ctgDumpIndexRes(SCtgTask* pTask) {
...
@@ -756,6 +869,10 @@ int32_t ctgDumpIndexRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpQnodeRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpQnodeRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pQnodeList
)
{
if
(
NULL
==
pJob
->
jobRes
.
pQnodeList
)
{
pJob
->
jobRes
.
pQnodeList
=
taosArrayInit
(
1
,
sizeof
(
SMetaRes
));
pJob
->
jobRes
.
pQnodeList
=
taosArrayInit
(
1
,
sizeof
(
SMetaRes
));
...
@@ -771,6 +888,10 @@ int32_t ctgDumpQnodeRes(SCtgTask* pTask) {
...
@@ -771,6 +888,10 @@ int32_t ctgDumpQnodeRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpDnodeRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpDnodeRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pDnodeList
)
{
if
(
NULL
==
pJob
->
jobRes
.
pDnodeList
)
{
pJob
->
jobRes
.
pDnodeList
=
taosArrayInit
(
1
,
sizeof
(
SMetaRes
));
pJob
->
jobRes
.
pDnodeList
=
taosArrayInit
(
1
,
sizeof
(
SMetaRes
));
...
@@ -786,6 +907,10 @@ int32_t ctgDumpDnodeRes(SCtgTask* pTask) {
...
@@ -786,6 +907,10 @@ int32_t ctgDumpDnodeRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpDbCfgRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpDbCfgRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pDbCfg
)
{
if
(
NULL
==
pJob
->
jobRes
.
pDbCfg
)
{
pJob
->
jobRes
.
pDbCfg
=
taosArrayInit
(
pJob
->
dbCfgNum
,
sizeof
(
SMetaRes
));
pJob
->
jobRes
.
pDbCfg
=
taosArrayInit
(
pJob
->
dbCfgNum
,
sizeof
(
SMetaRes
));
...
@@ -801,6 +926,10 @@ int32_t ctgDumpDbCfgRes(SCtgTask* pTask) {
...
@@ -801,6 +926,10 @@ int32_t ctgDumpDbCfgRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpDbInfoRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpDbInfoRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pDbInfo
)
{
if
(
NULL
==
pJob
->
jobRes
.
pDbInfo
)
{
pJob
->
jobRes
.
pDbInfo
=
taosArrayInit
(
pJob
->
dbInfoNum
,
sizeof
(
SMetaRes
));
pJob
->
jobRes
.
pDbInfo
=
taosArrayInit
(
pJob
->
dbInfoNum
,
sizeof
(
SMetaRes
));
...
@@ -816,6 +945,10 @@ int32_t ctgDumpDbInfoRes(SCtgTask* pTask) {
...
@@ -816,6 +945,10 @@ int32_t ctgDumpDbInfoRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpUdfRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpUdfRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pUdfList
)
{
if
(
NULL
==
pJob
->
jobRes
.
pUdfList
)
{
pJob
->
jobRes
.
pUdfList
=
taosArrayInit
(
pJob
->
udfNum
,
sizeof
(
SMetaRes
));
pJob
->
jobRes
.
pUdfList
=
taosArrayInit
(
pJob
->
udfNum
,
sizeof
(
SMetaRes
));
...
@@ -831,6 +964,10 @@ int32_t ctgDumpUdfRes(SCtgTask* pTask) {
...
@@ -831,6 +964,10 @@ int32_t ctgDumpUdfRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpUserRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpUserRes
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pUser
)
{
if
(
NULL
==
pJob
->
jobRes
.
pUser
)
{
pJob
->
jobRes
.
pUser
=
taosArrayInit
(
pJob
->
userNum
,
sizeof
(
SMetaRes
));
pJob
->
jobRes
.
pUser
=
taosArrayInit
(
pJob
->
userNum
,
sizeof
(
SMetaRes
));
...
@@ -846,6 +983,10 @@ int32_t ctgDumpUserRes(SCtgTask* pTask) {
...
@@ -846,6 +983,10 @@ int32_t ctgDumpUserRes(SCtgTask* pTask) {
}
}
int32_t
ctgDumpSvrVer
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpSvrVer
(
SCtgTask
*
pTask
)
{
if
(
pTask
->
subTask
)
{
return
TSDB_CODE_SUCCESS
;
}
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pSvrVer
)
{
if
(
NULL
==
pJob
->
jobRes
.
pSvrVer
)
{
pJob
->
jobRes
.
pSvrVer
=
taosMemoryCalloc
(
1
,
sizeof
(
SMetaRes
));
pJob
->
jobRes
.
pSvrVer
=
taosMemoryCalloc
(
1
,
sizeof
(
SMetaRes
));
...
@@ -1075,7 +1216,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf
...
@@ -1075,7 +1216,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf
STableMetaOutput
*
pOut
=
(
STableMetaOutput
*
)
pMsgCtx
->
out
;
STableMetaOutput
*
pOut
=
(
STableMetaOutput
*
)
pMsgCtx
->
out
;
ctgUpdateTbMetaToCache
(
pCtg
,
pOut
,
f
alse
);
ctgUpdateTbMetaToCache
(
pCtg
,
pOut
,
f
lag
&
CTG_FLAG_SYNC_OP
);
if
(
CTG_IS_META_BOTH
(
pOut
->
metaType
))
{
if
(
CTG_IS_META_BOTH
(
pOut
->
metaType
))
{
memcpy
(
pOut
->
tbMeta
,
&
pOut
->
ctbMeta
,
sizeof
(
pOut
->
ctbMeta
));
memcpy
(
pOut
->
tbMeta
,
&
pOut
->
ctbMeta
,
sizeof
(
pOut
->
ctbMeta
));
...
@@ -1473,6 +1614,49 @@ _return:
...
@@ -1473,6 +1614,49 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgHandleGetTbTagRsp
(
SCtgTaskReq
*
tReq
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
int32_t
code
=
0
;
SCtgTask
*
pTask
=
tReq
->
pTask
;
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
CTG_ERR_JRET
(
ctgProcessRspMsg
(
&
pTask
->
msgCtx
.
out
,
reqType
,
pMsg
->
pData
,
pMsg
->
len
,
rspCode
,
pTask
->
msgCtx
.
target
));
STableCfgRsp
*
pRsp
=
(
STableCfgRsp
*
)
pTask
->
msgCtx
.
out
;
if
(
NULL
==
pRsp
->
pTags
||
pRsp
->
tagsLen
<=
0
)
{
ctgError
(
"invalid tag in tbCfg rsp, pTags:%p, len:%d"
,
pRsp
->
pTags
,
pRsp
->
tagsLen
);
CTG_ERR_JRET
(
TSDB_CODE_INVALID_MSG
);
}
SArray
*
pTagVals
=
NULL
;
STag
*
pTag
=
(
STag
*
)
pRsp
->
pTags
;
if
(
tTagIsJson
(
pTag
))
{
pTagVals
=
taosArrayInit
(
1
,
sizeof
(
STagVal
));
if
(
NULL
==
pTagVals
)
{
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
char
*
pJson
=
parseTagDatatoJson
(
pTag
);
STagVal
tagVal
;
tagVal
.
cid
=
0
;
tagVal
.
type
=
TSDB_DATA_TYPE_JSON
;
tagVal
.
pData
=
pJson
;
tagVal
.
nData
=
strlen
(
pJson
);
taosArrayPush
(
pTagVals
,
&
tagVal
);
}
else
{
CTG_ERR_JRET
(
tTagToValArray
((
const
STag
*
)
pRsp
->
pTags
,
&
pTagVals
));
}
pTask
->
res
=
pTagVals
;
_return:
ctgHandleTaskEnd
(
pTask
,
code
);
CTG_RET
(
code
);
}
int32_t
ctgHandleGetDbCfgRsp
(
SCtgTaskReq
*
tReq
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
int32_t
ctgHandleGetDbCfgRsp
(
SCtgTaskReq
*
tReq
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgTask
*
pTask
=
tReq
->
pTask
;
SCtgTask
*
pTask
=
tReq
->
pTask
;
...
@@ -1905,7 +2089,10 @@ int32_t ctgLaunchGetTbCfgTask(SCtgTask* pTask) {
...
@@ -1905,7 +2089,10 @@ int32_t ctgLaunchGetTbCfgTask(SCtgTask* pTask) {
if
(
pCtx
->
tbType
<=
0
)
{
if
(
pCtx
->
tbType
<=
0
)
{
CTG_ERR_JRET
(
ctgReadTbTypeFromCache
(
pCtg
,
dbFName
,
pCtx
->
pName
->
tname
,
&
pCtx
->
tbType
));
CTG_ERR_JRET
(
ctgReadTbTypeFromCache
(
pCtg
,
dbFName
,
pCtx
->
pName
->
tname
,
&
pCtx
->
tbType
));
if
(
pCtx
->
tbType
<=
0
)
{
if
(
pCtx
->
tbType
<=
0
)
{
CTG_ERR_JRET
(
ctgLaunchSubTask
(
pTask
,
CTG_TASK_GET_TB_META
,
ctgGetTbCfgCb
,
pCtx
->
pName
));
SCtgTbMetaParam
param
;
param
.
pName
=
pCtx
->
pName
;
param
.
flag
=
0
;
CTG_ERR_JRET
(
ctgLaunchSubTask
(
pTask
,
CTG_TASK_GET_TB_META
,
ctgGetTbCfgCb
,
&
param
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
}
...
@@ -1935,6 +2122,45 @@ _return:
...
@@ -1935,6 +2122,45 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgLaunchGetTbTagTask
(
SCtgTask
*
pTask
)
{
int32_t
code
=
0
;
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
SRequestConnInfo
*
pConn
=
&
pTask
->
pJob
->
conn
;
SCtgTbTagCtx
*
pCtx
=
(
SCtgTbTagCtx
*
)
pTask
->
taskCtx
;
SArray
*
pRes
=
NULL
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
pCtx
->
pName
,
dbFName
);
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgMsgCtx
*
pMsgCtx
=
CTG_GET_TASK_MSGCTX
(
pTask
,
-
1
);
if
(
NULL
==
pMsgCtx
->
pBatchs
)
{
pMsgCtx
->
pBatchs
=
pJob
->
pBatchs
;
}
if
(
NULL
==
pCtx
->
pVgInfo
)
{
CTG_ERR_JRET
(
ctgGetTbHashVgroupFromCache
(
pCtg
,
pCtx
->
pName
,
&
pCtx
->
pVgInfo
));
if
(
NULL
==
pCtx
->
pVgInfo
)
{
CTG_ERR_JRET
(
ctgLaunchSubTask
(
pTask
,
CTG_TASK_GET_DB_VGROUP
,
ctgGetTbTagCb
,
dbFName
));
return
TSDB_CODE_SUCCESS
;
}
}
CTG_CACHE_NHIT_INC
(
CTG_CI_TBL_TAG
,
1
);
CTG_ERR_JRET
(
ctgGetTableCfgFromVnode
(
pCtg
,
pConn
,
pCtx
->
pName
,
pCtx
->
pVgInfo
,
NULL
,
pTask
));
return
TSDB_CODE_SUCCESS
;
_return:
if
(
CTG_TASK_LAUNCHED
==
pTask
->
status
)
{
ctgHandleTaskEnd
(
pTask
,
code
);
}
CTG_RET
(
code
);
}
int32_t
ctgLaunchGetQnodeTask
(
SCtgTask
*
pTask
)
{
int32_t
ctgLaunchGetQnodeTask
(
SCtgTask
*
pTask
)
{
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
SRequestConnInfo
*
pConn
=
&
pTask
->
pJob
->
conn
;
SRequestConnInfo
*
pConn
=
&
pTask
->
pJob
->
conn
;
...
@@ -2077,6 +2303,8 @@ int32_t ctgLaunchGetUserTask(SCtgTask* pTask) {
...
@@ -2077,6 +2303,8 @@ int32_t ctgLaunchGetUserTask(SCtgTask* pTask) {
if
(
inCache
)
{
if
(
inCache
)
{
pTask
->
res
=
rsp
.
pRawRes
;
pTask
->
res
=
rsp
.
pRawRes
;
ctgTaskDebug
(
"Final res got, pass:%d, pCond:%p"
,
rsp
.
pRawRes
->
pass
,
rsp
.
pRawRes
->
pCond
);
CTG_ERR_RET
(
ctgHandleTaskEnd
(
pTask
,
0
));
CTG_ERR_RET
(
ctgHandleTaskEnd
(
pTask
,
0
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2084,7 +2312,10 @@ int32_t ctgLaunchGetUserTask(SCtgTask* pTask) {
...
@@ -2084,7 +2312,10 @@ int32_t ctgLaunchGetUserTask(SCtgTask* pTask) {
taosMemoryFreeClear
(
rsp
.
pRawRes
);
taosMemoryFreeClear
(
rsp
.
pRawRes
);
if
(
rsp
.
metaNotExists
)
{
if
(
rsp
.
metaNotExists
)
{
CTG_ERR_RET
(
ctgLaunchSubTask
(
pTask
,
CTG_TASK_GET_TB_META
,
ctgGetTbCfgCb
,
&
pCtx
->
user
.
tbName
));
SCtgTbMetaParam
param
;
param
.
pName
=
&
pCtx
->
user
.
tbName
;
param
.
flag
=
CTG_FLAG_SYNC_OP
;
CTG_ERR_RET
(
ctgLaunchSubTask
(
pTask
,
CTG_TASK_GET_TB_META
,
ctgGetUserCb
,
&
param
));
}
else
{
}
else
{
CTG_ERR_RET
(
ctgGetUserDbAuthFromMnode
(
pCtg
,
pConn
,
pCtx
->
user
.
user
,
NULL
,
pTask
));
CTG_ERR_RET
(
ctgGetUserDbAuthFromMnode
(
pCtg
,
pConn
,
pCtx
->
user
.
user
,
NULL
,
pTask
));
}
}
...
@@ -2138,6 +2369,27 @@ _return:
...
@@ -2138,6 +2369,27 @@ _return:
CTG_RET
(
ctgHandleTaskEnd
(
pTask
,
pTask
->
subRes
.
code
));
CTG_RET
(
ctgHandleTaskEnd
(
pTask
,
pTask
->
subRes
.
code
));
}
}
int32_t
ctgGetTbTagCb
(
SCtgTask
*
pTask
)
{
int32_t
code
=
0
;
CTG_ERR_JRET
(
pTask
->
subRes
.
code
);
SCtgTbTagCtx
*
pCtx
=
(
SCtgTbTagCtx
*
)
pTask
->
taskCtx
;
SDBVgInfo
*
pDb
=
(
SDBVgInfo
*
)
pTask
->
subRes
.
res
;
if
(
NULL
==
pCtx
->
pVgInfo
)
{
pCtx
->
pVgInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SVgroupInfo
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pTask
->
pJob
->
pCtg
,
pDb
,
pCtx
->
pName
,
pCtx
->
pVgInfo
));
}
CTG_RET
(
ctgLaunchGetTbTagTask
(
pTask
));
_return:
CTG_RET
(
ctgHandleTaskEnd
(
pTask
,
pTask
->
subRes
.
code
));
}
int32_t
ctgGetUserCb
(
SCtgTask
*
pTask
)
{
int32_t
ctgGetUserCb
(
SCtgTask
*
pTask
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -2162,8 +2414,12 @@ int32_t ctgCompDbVgTasks(SCtgTask* pTask, void* param, bool* equal) {
...
@@ -2162,8 +2414,12 @@ int32_t ctgCompDbVgTasks(SCtgTask* pTask, void* param, bool* equal) {
int32_t
ctgCompTbMetaTasks
(
SCtgTask
*
pTask
,
void
*
param
,
bool
*
equal
)
{
int32_t
ctgCompTbMetaTasks
(
SCtgTask
*
pTask
,
void
*
param
,
bool
*
equal
)
{
SCtgTbMetaCtx
*
ctx
=
pTask
->
taskCtx
;
SCtgTbMetaCtx
*
ctx
=
pTask
->
taskCtx
;
SCtgTbMetaParam
*
pParam
=
(
SCtgTbMetaParam
*
)
param
;
*
equal
=
tNameTbNameEqual
(
ctx
->
pName
,
(
SName
*
)
param
);
*
equal
=
tNameTbNameEqual
(
ctx
->
pName
,
(
SName
*
)
pParam
->
pName
);
if
(
*
equal
)
{
ctx
->
flag
|=
pParam
->
flag
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2197,6 +2453,7 @@ SCtgAsyncFps gCtgAsyncFps[] = {
...
@@ -2197,6 +2453,7 @@ SCtgAsyncFps gCtgAsyncFps[] = {
{
ctgInitGetSvrVerTask
,
ctgLaunchGetSvrVerTask
,
ctgHandleGetSvrVerRsp
,
ctgDumpSvrVer
,
NULL
,
NULL
},
{
ctgInitGetSvrVerTask
,
ctgLaunchGetSvrVerTask
,
ctgHandleGetSvrVerRsp
,
ctgDumpSvrVer
,
NULL
,
NULL
},
{
ctgInitGetTbMetasTask
,
ctgLaunchGetTbMetasTask
,
ctgHandleGetTbMetasRsp
,
ctgDumpTbMetasRes
,
NULL
,
NULL
},
{
ctgInitGetTbMetasTask
,
ctgLaunchGetTbMetasTask
,
ctgHandleGetTbMetasRsp
,
ctgDumpTbMetasRes
,
NULL
,
NULL
},
{
ctgInitGetTbHashsTask
,
ctgLaunchGetTbHashsTask
,
ctgHandleGetTbHashsRsp
,
ctgDumpTbHashsRes
,
NULL
,
NULL
},
{
ctgInitGetTbHashsTask
,
ctgLaunchGetTbHashsTask
,
ctgHandleGetTbHashsRsp
,
ctgDumpTbHashsRes
,
NULL
,
NULL
},
{
ctgInitGetTbTagTask
,
ctgLaunchGetTbTagTask
,
ctgHandleGetTbTagRsp
,
ctgDumpTbTagRes
,
NULL
,
NULL
},
};
};
int32_t
ctgMakeAsyncRes
(
SCtgJob
*
pJob
)
{
int32_t
ctgMakeAsyncRes
(
SCtgJob
*
pJob
)
{
...
@@ -2284,6 +2541,9 @@ int32_t ctgLaunchSubTask(SCtgTask* pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp,
...
@@ -2284,6 +2541,9 @@ int32_t ctgLaunchSubTask(SCtgTask* pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp,
}
}
SCtgTask
*
pSub
=
taosArrayGet
(
pJob
->
pTasks
,
subTaskId
);
SCtgTask
*
pSub
=
taosArrayGet
(
pJob
->
pTasks
,
subTaskId
);
if
(
newTask
)
{
pSub
->
subTask
=
true
;
}
CTG_ERR_RET
(
ctgSetSubTaskCb
(
pSub
,
pTask
));
CTG_ERR_RET
(
ctgSetSubTaskCb
(
pSub
,
pTask
));
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
6a889ae8
...
@@ -703,7 +703,31 @@ _return:
...
@@ -703,7 +703,31 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgGetCachedStbNameFromSuid
(
SCatalog
*
pCtg
,
char
*
dbFName
,
uint64_t
suid
,
char
**
stbName
)
{
*
stbName
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
if
(
NULL
==
dbCache
)
{
ctgDebug
(
"db %s not in cache"
,
dbFName
);
return
TSDB_CODE_SUCCESS
;
}
char
*
stb
=
taosHashAcquire
(
dbCache
->
stbCache
,
&
suid
,
sizeof
(
suid
));
if
(
NULL
==
stb
)
{
ctgDebug
(
"stb 0x%"
PRIx64
" not in cache, dbFName:%s"
,
suid
,
dbFName
);
return
TSDB_CODE_SUCCESS
;
}
*
stbName
=
taosStrdup
(
stb
);
taosHashRelease
(
dbCache
->
stbCache
,
stb
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
SUserAuthInfo
*
pReq
,
bool
*
inCache
,
SCtgAuthRsp
*
pRes
)
{
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
SUserAuthInfo
*
pReq
,
bool
*
inCache
,
SCtgAuthRsp
*
pRes
)
{
int32_t
code
=
0
;
if
(
IS_SYS_DBNAME
(
pReq
->
tbName
.
dbname
))
{
if
(
IS_SYS_DBNAME
(
pReq
->
tbName
.
dbname
))
{
*
inCache
=
true
;
*
inCache
=
true
;
pRes
->
pRawRes
->
pass
=
true
;
pRes
->
pRawRes
->
pass
=
true
;
...
@@ -728,7 +752,7 @@ int32_t ctgChkAuthFromCache(SCatalog *pCtg, SUserAuthInfo *pReq, bool *inCache,
...
@@ -728,7 +752,7 @@ int32_t ctgChkAuthFromCache(SCatalog *pCtg, SUserAuthInfo *pReq, bool *inCache,
CTG_LOCK
(
CTG_READ
,
&
pUser
->
lock
);
CTG_LOCK
(
CTG_READ
,
&
pUser
->
lock
);
memcpy
(
&
req
.
authInfo
,
&
pUser
->
userAuth
,
sizeof
(
pUser
->
userAuth
));
memcpy
(
&
req
.
authInfo
,
&
pUser
->
userAuth
,
sizeof
(
pUser
->
userAuth
));
int32_t
code
=
ctgChkSetAuthRes
(
pCtg
,
&
req
,
pRes
);
code
=
ctgChkSetAuthRes
(
pCtg
,
&
req
,
pRes
);
CTG_UNLOCK
(
CTG_READ
,
&
pUser
->
lock
);
CTG_UNLOCK
(
CTG_READ
,
&
pUser
->
lock
);
CTG_ERR_JRET
(
code
);
CTG_ERR_JRET
(
code
);
...
@@ -742,8 +766,9 @@ _return:
...
@@ -742,8 +766,9 @@ _return:
*
inCache
=
false
;
*
inCache
=
false
;
CTG_CACHE_NHIT_INC
(
CTG_CI_USER
,
1
);
CTG_CACHE_NHIT_INC
(
CTG_CI_USER
,
1
);
ctgDebug
(
"Get user from cache failed, user:%s, metaNotExists:%d, code:%d"
,
pReq
->
user
,
pRes
->
metaNotExists
,
code
);
return
TSDB_CODE_SUCCESS
;
return
code
;
}
}
void
ctgDequeue
(
SCtgCacheOperation
**
op
)
{
void
ctgDequeue
(
SCtgCacheOperation
**
op
)
{
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
6a889ae8
...
@@ -170,6 +170,9 @@ void ctgFreeSMetaData(SMetaData* pData) {
...
@@ -170,6 +170,9 @@ void ctgFreeSMetaData(SMetaData* pData) {
taosArrayDestroy
(
pData
->
pTableCfg
);
taosArrayDestroy
(
pData
->
pTableCfg
);
pData
->
pTableCfg
=
NULL
;
pData
->
pTableCfg
=
NULL
;
taosArrayDestroy
(
pData
->
pTableTag
);
pData
->
pTableTag
=
NULL
;
taosMemoryFreeClear
(
pData
->
pSvrVer
);
taosMemoryFreeClear
(
pData
->
pSvrVer
);
}
}
...
@@ -486,6 +489,18 @@ void ctgFreeBatchHash(void* hash) {
...
@@ -486,6 +489,18 @@ void ctgFreeBatchHash(void* hash) {
taosMemoryFreeClear
(
pRes
->
pRes
);
taosMemoryFreeClear
(
pRes
->
pRes
);
}
}
void
ctgFreeJsonTagVal
(
void
*
val
)
{
if
(
NULL
==
val
)
{
return
;
}
STagVal
*
pVal
=
(
STagVal
*
)
val
;
if
(
TSDB_DATA_TYPE_JSON
==
pVal
->
type
)
{
taosMemoryFree
(
pVal
->
pData
);
}
}
void
ctgFreeTaskRes
(
CTG_TASK_TYPE
type
,
void
**
pRes
)
{
void
ctgFreeTaskRes
(
CTG_TASK_TYPE
type
,
void
**
pRes
)
{
switch
(
type
)
{
switch
(
type
)
{
case
CTG_TASK_GET_QNODE
:
case
CTG_TASK_GET_QNODE
:
...
@@ -516,16 +531,32 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void** pRes) {
...
@@ -516,16 +531,32 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void** pRes) {
}
}
break
;
break
;
}
}
case
CTG_TASK_GET_USER
:
{
if
(
*
pRes
)
{
SUserAuthRes
*
pAuth
=
(
SUserAuthRes
*
)
*
pRes
;
nodesDestroyNode
(
pAuth
->
pCond
);
taosMemoryFreeClear
(
*
pRes
);
}
break
;
}
case
CTG_TASK_GET_TB_HASH
:
case
CTG_TASK_GET_TB_HASH
:
case
CTG_TASK_GET_DB_INFO
:
case
CTG_TASK_GET_DB_INFO
:
case
CTG_TASK_GET_INDEX_INFO
:
case
CTG_TASK_GET_INDEX_INFO
:
case
CTG_TASK_GET_UDF
:
case
CTG_TASK_GET_UDF
:
case
CTG_TASK_GET_USER
:
case
CTG_TASK_GET_SVR_VER
:
case
CTG_TASK_GET_SVR_VER
:
case
CTG_TASK_GET_TB_META
:
{
case
CTG_TASK_GET_TB_META
:
{
taosMemoryFreeClear
(
*
pRes
);
taosMemoryFreeClear
(
*
pRes
);
break
;
break
;
}
}
case
CTG_TASK_GET_TB_TAG
:
{
if
(
1
==
taosArrayGetSize
(
*
pRes
))
{
taosArrayDestroyEx
(
*
pRes
,
ctgFreeJsonTagVal
);
}
else
{
taosArrayDestroy
(
*
pRes
);
}
*
pRes
=
NULL
;
break
;
}
case
CTG_TASK_GET_TB_META_BATCH
:
{
case
CTG_TASK_GET_TB_META_BATCH
:
{
SArray
*
pArray
=
(
SArray
*
)
*
pRes
;
SArray
*
pArray
=
(
SArray
*
)
*
pRes
;
int32_t
num
=
taosArrayGetSize
(
pArray
);
int32_t
num
=
taosArrayGetSize
(
pArray
);
...
@@ -679,6 +710,13 @@ void ctgFreeTaskCtx(SCtgTask* pTask) {
...
@@ -679,6 +710,13 @@ void ctgFreeTaskCtx(SCtgTask* pTask) {
taosMemoryFreeClear
(
pTask
->
taskCtx
);
taosMemoryFreeClear
(
pTask
->
taskCtx
);
break
;
break
;
}
}
case
CTG_TASK_GET_TB_TAG
:
{
SCtgTbTagCtx
*
taskCtx
=
(
SCtgTbTagCtx
*
)
pTask
->
taskCtx
;
taosMemoryFreeClear
(
taskCtx
->
pName
);
taosMemoryFreeClear
(
taskCtx
->
pVgInfo
);
taosMemoryFreeClear
(
taskCtx
);
break
;
}
case
CTG_TASK_GET_DB_VGROUP
:
case
CTG_TASK_GET_DB_VGROUP
:
case
CTG_TASK_GET_DB_CFG
:
case
CTG_TASK_GET_DB_CFG
:
case
CTG_TASK_GET_DB_INFO
:
case
CTG_TASK_GET_DB_INFO
:
...
@@ -1336,57 +1374,75 @@ int32_t ctgChkSetTbAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) {
...
@@ -1336,57 +1374,75 @@ int32_t ctgChkSetTbAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) {
STableMeta
*
pMeta
=
NULL
;
STableMeta
*
pMeta
=
NULL
;
SGetUserAuthRsp
*
pInfo
=
&
req
->
authInfo
;
SGetUserAuthRsp
*
pInfo
=
&
req
->
authInfo
;
SHashObj
*
pTbs
=
(
AUTH_TYPE_READ
==
req
->
singleType
)
?
pInfo
->
readTbs
:
pInfo
->
writeTbs
;
SHashObj
*
pTbs
=
(
AUTH_TYPE_READ
==
req
->
singleType
)
?
pInfo
->
readTbs
:
pInfo
->
writeTbs
;
char
*
stbName
=
NULL
;
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
char
tbFName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
&
req
->
pRawReq
->
tbName
,
tbFullName
);
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
*
pCond
=
taosHashGet
(
pTbs
,
tbFullName
,
strlen
(
tbFullName
));
tNameExtractFullName
(
&
req
->
pRawReq
->
tbName
,
tbFName
);
if
(
pCond
)
{
tNameGetFullDbName
(
&
req
->
pRawReq
->
tbName
,
dbFName
);
if
(
strlen
(
pCond
)
>
1
)
{
CTG_ERR_RET
(
nodesStringToNode
(
pCond
,
&
res
->
pRawRes
->
pCond
));
while
(
true
)
{
taosMemoryFreeClear
(
pMeta
);
char
*
pCond
=
taosHashGet
(
pTbs
,
tbFName
,
strlen
(
tbFName
));
if
(
pCond
)
{
if
(
strlen
(
pCond
)
>
1
)
{
CTG_ERR_JRET
(
nodesStringToNode
(
pCond
,
&
res
->
pRawRes
->
pCond
));
}
res
->
pRawRes
->
pass
=
true
;
goto
_return
;
}
}
res
->
pRawRes
->
pass
=
true
;
if
(
stbName
)
{
return
TSDB_CODE_SUCCESS
;
res
->
pRawRes
->
pass
=
false
;
}
goto
_return
;
}
res
->
pRawRes
->
pass
=
false
;
CTG_ERR_JRET
(
catalogGetCachedTableMeta
(
pCtg
,
&
req
->
pRawReq
->
tbName
,
&
pMeta
));
if
(
NULL
==
pMeta
)
{
if
(
req
->
onlyCache
)
{
res
->
metaNotExists
=
true
;
ctgDebug
(
"db %s tb %s meta not in cache for auth"
,
req
->
pRawReq
->
tbName
.
dbname
,
req
->
pRawReq
->
tbName
.
tname
);
goto
_return
;
}
// CTG_ERR_RET(catalogGetCachedTableMeta(pCtg, &req->pRawReq->tbName, &pMeta));
SCtgTbMetaCtx
ctx
=
{
0
};
// if (NULL == pMeta) {
ctx
.
pName
=
(
SName
*
)
&
req
->
pRawReq
->
tbName
;
// if (req->onlyCache) {
ctx
.
flag
=
CTG_FLAG_UNKNOWN_STB
|
CTG_FLAG_SYNC_OP
;
// res->metaNotExists = true;
// ctgDebug("db %s tb %s meta not in cache for auth", req->pRawReq->tbName.dbname, req->pRawReq->tbName.tname);
// return TSDB_CODE_SUCCESS;
// }
// CTG_ERR_RET(catalogGetTableMeta(pCtg, req->pConn, &req->pRawReq->tbName
, &pMeta));
CTG_ERR_JRET
(
ctgGetTbMeta
(
pCtg
,
req
->
pConn
,
&
ctx
,
&
pMeta
));
//
}
}
// if (TSDB_SUPER_TABLE == pMeta->tableType || TSDB_NORMAL_TABLE == pMeta->tableType) {
if
(
TSDB_SUPER_TABLE
==
pMeta
->
tableType
||
TSDB_NORMAL_TABLE
==
pMeta
->
tableType
)
{
// res->pRawRes->pass = false;
res
->
pRawRes
->
pass
=
false
;
// goto _return;
goto
_return
;
// }
}
if
(
TSDB_CHILD_TABLE
==
pMeta
->
tableType
)
{
CTG_ERR_JRET
(
ctgGetCachedStbNameFromSuid
(
pCtg
,
dbFName
,
pMeta
->
suid
,
&
stbName
));
if
(
NULL
==
stbName
)
{
if
(
req
->
onlyCache
)
{
res
->
metaNotExists
=
true
;
ctgDebug
(
"suid %"
PRIu64
" name not in cache for auth"
,
pMeta
->
suid
);
goto
_return
;
}
// if (TSDB_CHILD_TABLE == pMeta->tableType) {
continue
;
// res->pRawRes->pass = true;
}
// /*
sprintf
(
tbFName
,
"%s.%s"
,
dbFName
,
stbName
);
// char stbName[TSDB_TABLE_NAME_LEN] = {0};
continue
;
// CTG_ERR_JRET(ctgGetCachedStbNameFromSuid(pCtg, pMeta->suid, stbName));
}
// if (0 == stbName[0]) {
// if (req->onlyCache) {
// res->notExists = true;
// return TSDB_CODE_SUCCESS;
// }
// CTG_ERR_RET(catalogRefreshTableMeta(pCtg, req->pConn, &req->pRawReq->tbName, 0));
ctgError
(
"Invalid table type %d for %s"
,
pMeta
->
tableType
,
tbFName
);
// }
CTG_ERR_JRET
(
TSDB_CODE_INVALID_PARA
);
// */
}
// }
_return:
_return:
taosMemoryFree
(
pMeta
);
taosMemoryFree
(
pMeta
);
taosMemoryFree
(
stbName
);
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
...
@@ -1423,7 +1479,7 @@ int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) {
...
@@ -1423,7 +1479,7 @@ int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) {
if
(
pInfo
->
readTbs
&&
taosHashGetSize
(
pInfo
->
readTbs
)
>
0
)
{
if
(
pInfo
->
readTbs
&&
taosHashGetSize
(
pInfo
->
readTbs
)
>
0
)
{
req
->
singleType
=
AUTH_TYPE_READ
;
req
->
singleType
=
AUTH_TYPE_READ
;
CTG_ERR_RET
(
ctgChkSetTbAuthRes
(
pCtg
,
req
,
res
));
CTG_ERR_RET
(
ctgChkSetTbAuthRes
(
pCtg
,
req
,
res
));
if
(
pRes
->
pass
)
{
if
(
pRes
->
pass
||
res
->
metaNotExists
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
}
...
@@ -1439,7 +1495,7 @@ int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) {
...
@@ -1439,7 +1495,7 @@ int32_t ctgChkSetAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) {
if
(
pInfo
->
writeTbs
&&
taosHashGetSize
(
pInfo
->
writeTbs
)
>
0
)
{
if
(
pInfo
->
writeTbs
&&
taosHashGetSize
(
pInfo
->
writeTbs
)
>
0
)
{
req
->
singleType
=
AUTH_TYPE_WRITE
;
req
->
singleType
=
AUTH_TYPE_WRITE
;
CTG_ERR_RET
(
ctgChkSetTbAuthRes
(
pCtg
,
req
,
res
));
CTG_ERR_RET
(
ctgChkSetTbAuthRes
(
pCtg
,
req
,
res
));
if
(
pRes
->
pass
)
{
if
(
pRes
->
pass
||
res
->
metaNotExists
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
}
...
...
source/libs/executor/src/tsort.c
浏览文件 @
6a889ae8
...
@@ -155,7 +155,7 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) {
...
@@ -155,7 +155,7 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) {
int64_t
fetchUs
=
0
,
fetchNum
=
0
;
int64_t
fetchUs
=
0
,
fetchNum
=
0
;
tsortClearOrderdSource
(
pSortHandle
->
pOrderedSource
,
&
fetchUs
,
&
fetchNum
);
tsortClearOrderdSource
(
pSortHandle
->
pOrderedSource
,
&
fetchUs
,
&
fetchNum
);
q
Error
(
"all source fetch time: %"
PRId64
"us num:%"
PRId64
" %s"
,
fetchUs
,
fetchNum
,
pSortHandle
->
idStr
);
q
Debug
(
"all source fetch time: %"
PRId64
"us num:%"
PRId64
" %s"
,
fetchUs
,
fetchNum
,
pSortHandle
->
idStr
);
taosArrayDestroy
(
pSortHandle
->
pOrderedSource
);
taosArrayDestroy
(
pSortHandle
->
pOrderedSource
);
taosMemoryFreeClear
(
pSortHandle
);
taosMemoryFreeClear
(
pSortHandle
);
...
@@ -316,7 +316,7 @@ static int32_t sortComparInit(SMsortComparParam* pParam, SArray* pSources, int32
...
@@ -316,7 +316,7 @@ static int32_t sortComparInit(SMsortComparParam* pParam, SArray* pSources, int32
}
}
int64_t
et
=
taosGetTimestampUs
();
int64_t
et
=
taosGetTimestampUs
();
q
Error
(
"init for merge sort completed, elapsed time:%.2f ms, %s"
,
(
et
-
st
)
/
1000
.
0
,
pHandle
->
idStr
);
q
Debug
(
"init for merge sort completed, elapsed time:%.2f ms, %s"
,
(
et
-
st
)
/
1000
.
0
,
pHandle
->
idStr
);
}
}
return
code
;
return
code
;
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
6a889ae8
...
@@ -827,6 +827,8 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -827,6 +827,8 @@ void nodesDestroyNode(SNode* pNode) {
SVnodeModifyOpStmt
*
pStmt
=
(
SVnodeModifyOpStmt
*
)
pNode
;
SVnodeModifyOpStmt
*
pStmt
=
(
SVnodeModifyOpStmt
*
)
pNode
;
destroyVgDataBlockArray
(
pStmt
->
pDataBlocks
);
destroyVgDataBlockArray
(
pStmt
->
pDataBlocks
);
taosMemoryFreeClear
(
pStmt
->
pTableMeta
);
taosMemoryFreeClear
(
pStmt
->
pTableMeta
);
nodesDestroyNode
(
pStmt
->
pTagCond
);
taosArrayDestroy
(
pStmt
->
pTableTag
);
taosHashCleanup
(
pStmt
->
pVgroupsHashObj
);
taosHashCleanup
(
pStmt
->
pVgroupsHashObj
);
taosHashCleanup
(
pStmt
->
pSubTableHashObj
);
taosHashCleanup
(
pStmt
->
pSubTableHashObj
);
taosHashCleanup
(
pStmt
->
pTableNameHashObj
);
taosHashCleanup
(
pStmt
->
pTableNameHashObj
);
...
@@ -953,8 +955,12 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -953,8 +955,12 @@ void nodesDestroyNode(SNode* pNode) {
break
;
break
;
case
QUERY_NODE_SPLIT_VGROUP_STMT
:
// no pointer field
case
QUERY_NODE_SPLIT_VGROUP_STMT
:
// no pointer field
case
QUERY_NODE_SYNCDB_STMT
:
// no pointer field
case
QUERY_NODE_SYNCDB_STMT
:
// no pointer field
case
QUERY_NODE_GRANT_STMT
:
// no pointer field
break
;
case
QUERY_NODE_REVOKE_STMT
:
// no pointer field
case
QUERY_NODE_GRANT_STMT
:
nodesDestroyNode
(((
SGrantStmt
*
)
pNode
)
->
pTagCond
);
break
;
case
QUERY_NODE_REVOKE_STMT
:
nodesDestroyNode
(((
SRevokeStmt
*
)
pNode
)
->
pTagCond
);
break
;
break
;
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
...
...
source/libs/parser/src/parAuthenticator.c
浏览文件 @
6a889ae8
...
@@ -70,7 +70,7 @@ static EDealRes authSubquery(SAuthCxt* pCxt, SNode* pStmt) {
...
@@ -70,7 +70,7 @@ static EDealRes authSubquery(SAuthCxt* pCxt, SNode* pStmt) {
return
TSDB_CODE_SUCCESS
==
authQuery
(
pCxt
,
pStmt
)
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
;
return
TSDB_CODE_SUCCESS
==
authQuery
(
pCxt
,
pStmt
)
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
;
}
}
static
int32_t
mergeStableTagCond
(
SNode
**
pWhere
,
SNode
*
*
pTagCond
)
{
static
int32_t
mergeStableTagCond
(
SNode
**
pWhere
,
SNode
*
pTagCond
)
{
SLogicConditionNode
*
pLogicCond
=
(
SLogicConditionNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_CONDITION
);
SLogicConditionNode
*
pLogicCond
=
(
SLogicConditionNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_CONDITION
);
if
(
NULL
==
pLogicCond
)
{
if
(
NULL
==
pLogicCond
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -78,7 +78,7 @@ static int32_t mergeStableTagCond(SNode** pWhere, SNode** pTagCond) {
...
@@ -78,7 +78,7 @@ static int32_t mergeStableTagCond(SNode** pWhere, SNode** pTagCond) {
pLogicCond
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
pLogicCond
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
pLogicCond
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
pLogicCond
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
pLogicCond
->
condType
=
LOGIC_COND_TYPE_AND
;
pLogicCond
->
condType
=
LOGIC_COND_TYPE_AND
;
int32_t
code
=
nodesListMakeStrictAppend
(
&
pLogicCond
->
pParameterList
,
*
pTagCond
);
int32_t
code
=
nodesListMakeStrictAppend
(
&
pLogicCond
->
pParameterList
,
pTagCond
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeAppend
(
&
pLogicCond
->
pParameterList
,
*
pWhere
);
code
=
nodesListMakeAppend
(
&
pLogicCond
->
pParameterList
,
*
pWhere
);
}
}
...
@@ -106,7 +106,7 @@ static int32_t appendStableTagCond(SNode** pWhere, SNode* pTagCond) {
...
@@ -106,7 +106,7 @@ static int32_t appendStableTagCond(SNode** pWhere, SNode* pTagCond) {
return
nodesListStrictAppend
(((
SLogicConditionNode
*
)
*
pWhere
)
->
pParameterList
,
pTagCondCopy
);
return
nodesListStrictAppend
(((
SLogicConditionNode
*
)
*
pWhere
)
->
pParameterList
,
pTagCondCopy
);
}
}
return
mergeStableTagCond
(
pWhere
,
&
pTagCondCopy
);
return
mergeStableTagCond
(
pWhere
,
pTagCondCopy
);
}
}
static
EDealRes
authSelectImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
static
EDealRes
authSelectImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
...
...
source/libs/parser/src/parInsertSql.c
浏览文件 @
6a889ae8
...
@@ -53,6 +53,7 @@ typedef struct SInsertParseContext {
...
@@ -53,6 +53,7 @@ typedef struct SInsertParseContext {
bool
missCache
;
bool
missCache
;
bool
usingDuplicateTable
;
bool
usingDuplicateTable
;
bool
forceUpdate
;
bool
forceUpdate
;
bool
needTableTagVal
;
}
SInsertParseContext
;
}
SInsertParseContext
;
typedef
int32_t
(
*
_row_append_fn_t
)(
SMsgBuf
*
pMsgBuf
,
const
void
*
value
,
int32_t
len
,
void
*
param
);
typedef
int32_t
(
*
_row_append_fn_t
)(
SMsgBuf
*
pMsgBuf
,
const
void
*
value
,
int32_t
len
,
void
*
param
);
...
@@ -577,28 +578,39 @@ static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) {
...
@@ -577,28 +578,39 @@ static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) {
if
(
NULL
==
pValue
)
{
if
(
NULL
==
pValue
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pValue
->
node
.
resType
.
type
=
pVal
->
type
;
pValue
->
node
.
resType
=
((
SColumnNode
*
)
*
pNode
)
->
node
.
resType
;
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
pValue
;
switch
(
pVal
->
type
)
{
switch
(
pVal
->
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
pValue
->
datum
.
b
=
*
(
int8_t
*
)(
&
pVal
->
i64
);
pValue
->
datum
.
b
=
*
(
int8_t
*
)(
&
pVal
->
i64
);
*
(
bool
*
)
&
pValue
->
typeData
=
pValue
->
datum
.
b
;
break
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_TINYINT
:
pValue
->
datum
.
i
=
*
(
int8_t
*
)(
&
pVal
->
i64
);
pValue
->
datum
.
i
=
*
(
int8_t
*
)(
&
pVal
->
i64
);
*
(
int8_t
*
)
&
pValue
->
typeData
=
pValue
->
datum
.
i
;
break
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
pValue
->
datum
.
i
=
*
(
int16_t
*
)(
&
pVal
->
i64
);
pValue
->
datum
.
i
=
*
(
int16_t
*
)(
&
pVal
->
i64
);
*
(
int16_t
*
)
&
pValue
->
typeData
=
pValue
->
datum
.
i
;
break
;
break
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_INT
:
pValue
->
datum
.
i
=
*
(
int32_t
*
)(
&
pVal
->
i64
);
pValue
->
datum
.
i
=
*
(
int32_t
*
)(
&
pVal
->
i64
);
*
(
int32_t
*
)
&
pValue
->
typeData
=
pValue
->
datum
.
i
;
break
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
pValue
->
datum
.
i
=
pVal
->
i64
;
pValue
->
datum
.
i
=
pVal
->
i64
;
pValue
->
typeData
=
pValue
->
datum
.
i
;
break
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_FLOAT
:
pValue
->
datum
.
d
=
*
(
float
*
)(
&
pVal
->
i64
);
pValue
->
datum
.
d
=
*
(
float
*
)(
&
pVal
->
i64
);
*
(
float
*
)
&
pValue
->
typeData
=
pValue
->
datum
.
d
;
break
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_DOUBLE
:
pValue
->
datum
.
d
=
*
(
double
*
)(
&
pVal
->
i64
);
pValue
->
datum
.
d
=
*
(
double
*
)(
&
pVal
->
i64
);
*
(
double
*
)
&
pValue
->
typeData
=
pValue
->
datum
.
d
;
break
;
break
;
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
...
@@ -611,18 +623,23 @@ static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) {
...
@@ -611,18 +623,23 @@ static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) {
break
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
pValue
->
datum
.
i
=
pVal
->
i64
;
pValue
->
datum
.
i
=
pVal
->
i64
;
pValue
->
typeData
=
pValue
->
datum
.
i
;
break
;
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
pValue
->
datum
.
i
=
*
(
uint8_t
*
)(
&
pVal
->
i64
);
pValue
->
datum
.
i
=
*
(
uint8_t
*
)(
&
pVal
->
i64
);
*
(
uint8_t
*
)
&
pValue
->
typeData
=
pValue
->
datum
.
i
;
break
;
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
pValue
->
datum
.
i
=
*
(
uint16_t
*
)(
&
pVal
->
i64
);
pValue
->
datum
.
i
=
*
(
uint16_t
*
)(
&
pVal
->
i64
);
*
(
uint16_t
*
)
&
pValue
->
typeData
=
pValue
->
datum
.
i
;
break
;
break
;
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UINT
:
pValue
->
datum
.
i
=
*
(
uint32_t
*
)(
&
pVal
->
i64
);
pValue
->
datum
.
i
=
*
(
uint32_t
*
)(
&
pVal
->
i64
);
*
(
uint32_t
*
)
&
pValue
->
typeData
=
pValue
->
datum
.
i
;
break
;
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
pValue
->
datum
.
i
=
*
(
uint64_t
*
)(
&
pVal
->
i64
);
pValue
->
datum
.
i
=
*
(
uint64_t
*
)(
&
pVal
->
i64
);
*
(
uint64_t
*
)
&
pValue
->
typeData
=
pValue
->
datum
.
i
;
break
;
break
;
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_VARBINARY
:
...
@@ -667,16 +684,15 @@ static int32_t checkTagCondResult(SNode* pResult) {
...
@@ -667,16 +684,15 @@ static int32_t checkTagCondResult(SNode* pResult) {
:
TSDB_CODE_PAR_PERMISSION_DENIED
;
:
TSDB_CODE_PAR_PERMISSION_DENIED
;
}
}
int32_t
checkSubtablePrivilege
(
SArray
*
pTagVals
,
SArray
*
pTagName
,
SNode
*
pCond
)
{
static
int32_t
checkSubtablePrivilege
(
SArray
*
pTagVals
,
SArray
*
pTagName
,
SNode
**
pCond
)
{
int32_t
code
=
setTagVal
(
pTagVals
,
pTagName
,
pCond
);
int32_t
code
=
setTagVal
(
pTagVals
,
pTagName
,
*
pCond
);
SNode
*
pNew
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
scalarCalculateConstants
(
pCond
,
&
pNew
);
code
=
scalarCalculateConstants
(
*
pCond
,
pCond
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkTagCondResult
(
pNew
);
code
=
checkTagCondResult
(
*
pCond
);
}
}
nodesDestroyNode
(
pNew
);
NODES_DESTORY_NODE
(
*
pCond
);
return
code
;
return
code
;
}
}
...
@@ -716,6 +732,10 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt
...
@@ -716,6 +732,10 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt
}
}
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pStmt
->
pTagCond
)
{
code
=
checkSubtablePrivilege
(
pTagVals
,
pTagName
,
&
pStmt
->
pTagCond
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
isParseBindParam
&&
!
isJson
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
isParseBindParam
&&
!
isJson
)
{
code
=
tTagNew
(
pTagVals
,
1
,
false
,
&
pTag
);
code
=
tTagNew
(
pTagVals
,
1
,
false
,
&
pTag
);
}
}
...
@@ -843,7 +863,7 @@ static void setUserAuthInfo(SParseContext* pCxt, SName* pTbName, SUserAuthInfo*
...
@@ -843,7 +863,7 @@ static void setUserAuthInfo(SParseContext* pCxt, SName* pTbName, SUserAuthInfo*
pInfo
->
type
=
AUTH_TYPE_WRITE
;
pInfo
->
type
=
AUTH_TYPE_WRITE
;
}
}
static
int32_t
checkAuth
(
SParseContext
*
pCxt
,
SName
*
pTbName
,
bool
*
pMissCache
)
{
static
int32_t
checkAuth
(
SParseContext
*
pCxt
,
SName
*
pTbName
,
bool
*
pMissCache
,
SNode
**
pTagCond
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SUserAuthInfo
authInfo
=
{
0
};
SUserAuthInfo
authInfo
=
{
0
};
setUserAuthInfo
(
pCxt
,
pTbName
,
&
authInfo
);
setUserAuthInfo
(
pCxt
,
pTbName
,
&
authInfo
);
...
@@ -863,11 +883,28 @@ static int32_t checkAuth(SParseContext* pCxt, SName* pTbName, bool* pMissCache)
...
@@ -863,11 +883,28 @@ static int32_t checkAuth(SParseContext* pCxt, SName* pTbName, bool* pMissCache)
*
pMissCache
=
true
;
*
pMissCache
=
true
;
}
else
if
(
!
authRes
.
pass
)
{
}
else
if
(
!
authRes
.
pass
)
{
code
=
TSDB_CODE_PAR_PERMISSION_DENIED
;
code
=
TSDB_CODE_PAR_PERMISSION_DENIED
;
}
else
if
(
NULL
!=
authRes
.
pCond
)
{
*
pTagCond
=
authRes
.
pCond
;
}
}
}
}
return
code
;
return
code
;
}
}
static
int32_t
checkAuthForTable
(
SParseContext
*
pCxt
,
SName
*
pTbName
,
bool
*
pMissCache
,
bool
*
pNeedTableTagVal
)
{
SNode
*
pTagCond
=
NULL
;
int32_t
code
=
checkAuth
(
pCxt
,
pTbName
,
pMissCache
,
&
pTagCond
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pNeedTableTagVal
=
((
*
pMissCache
)
||
(
NULL
!=
pTagCond
));
*
pMissCache
=
(
NULL
!=
pTagCond
);
}
nodesDestroyNode
(
pTagCond
);
return
code
;
}
static
int32_t
checkAuthForStable
(
SParseContext
*
pCxt
,
SName
*
pTbName
,
bool
*
pMissCache
,
SNode
**
pTagCond
)
{
return
checkAuth
(
pCxt
,
pTbName
,
pMissCache
,
pTagCond
);
}
static
int32_t
getTableMeta
(
SInsertParseContext
*
pCxt
,
SName
*
pTbName
,
bool
isStb
,
STableMeta
**
pTableMeta
,
static
int32_t
getTableMeta
(
SInsertParseContext
*
pCxt
,
SName
*
pTbName
,
bool
isStb
,
STableMeta
**
pTableMeta
,
bool
*
pMissCache
)
{
bool
*
pMissCache
)
{
SParseContext
*
pComCxt
=
pCxt
->
pComCxt
;
SParseContext
*
pComCxt
=
pCxt
->
pComCxt
;
...
@@ -970,7 +1007,7 @@ static int32_t getTargetTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStm
...
@@ -970,7 +1007,7 @@ static int32_t getTargetTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStm
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
code
=
checkAuth
(
pCxt
->
pComCxt
,
&
pStmt
->
targetTableName
,
&
pCxt
->
missCache
);
int32_t
code
=
checkAuth
ForTable
(
pCxt
->
pComCxt
,
&
pStmt
->
targetTableName
,
&
pCxt
->
missCache
,
&
pCxt
->
needTableTagVal
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
pCxt
->
missCache
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
pCxt
->
missCache
)
{
code
=
getTableMetaAndVgroup
(
pCxt
,
pStmt
,
&
pCxt
->
missCache
);
code
=
getTableMetaAndVgroup
(
pCxt
,
pStmt
,
&
pCxt
->
missCache
);
}
}
...
@@ -993,7 +1030,7 @@ static int32_t getUsingTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStmt
...
@@ -993,7 +1030,7 @@ static int32_t getUsingTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStmt
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
code
=
checkAuth
(
pCxt
->
pComCxt
,
&
pStmt
->
targetTableName
,
&
pCxt
->
missCache
);
int32_t
code
=
checkAuth
ForStable
(
pCxt
->
pComCxt
,
&
pStmt
->
usingTableName
,
&
pCxt
->
missCache
,
&
pStmt
->
pTagCond
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
pCxt
->
missCache
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
pCxt
->
missCache
)
{
code
=
getTableMeta
(
pCxt
,
&
pStmt
->
usingTableName
,
true
,
&
pStmt
->
pTableMeta
,
&
pCxt
->
missCache
);
code
=
getTableMeta
(
pCxt
,
&
pStmt
->
usingTableName
,
true
,
&
pStmt
->
pTableMeta
,
&
pCxt
->
missCache
);
}
}
...
@@ -1606,6 +1643,8 @@ static int32_t parseInsertTableClauseBottom(SInsertParseContext* pCxt, SVnodeMod
...
@@ -1606,6 +1643,8 @@ static int32_t parseInsertTableClauseBottom(SInsertParseContext* pCxt, SVnodeMod
static
void
resetEnvPreTable
(
SInsertParseContext
*
pCxt
,
SVnodeModifyOpStmt
*
pStmt
)
{
static
void
resetEnvPreTable
(
SInsertParseContext
*
pCxt
,
SVnodeModifyOpStmt
*
pStmt
)
{
insDestroyBoundColInfo
(
&
pCxt
->
tags
);
insDestroyBoundColInfo
(
&
pCxt
->
tags
);
taosMemoryFreeClear
(
pStmt
->
pTableMeta
);
taosMemoryFreeClear
(
pStmt
->
pTableMeta
);
nodesDestroyNode
(
pStmt
->
pTagCond
);
taosArrayDestroy
(
pStmt
->
pTableTag
);
tdDestroySVCreateTbReq
(
pStmt
->
pCreateTblReq
);
tdDestroySVCreateTbReq
(
pStmt
->
pCreateTblReq
);
taosMemoryFreeClear
(
pStmt
->
pCreateTblReq
);
taosMemoryFreeClear
(
pStmt
->
pCreateTblReq
);
pCxt
->
missCache
=
false
;
pCxt
->
missCache
=
false
;
...
@@ -1780,14 +1819,18 @@ static int32_t createInsertQuery(SInsertParseContext* pCxt, SQuery** pOutput) {
...
@@ -1780,14 +1819,18 @@ static int32_t createInsertQuery(SInsertParseContext* pCxt, SQuery** pOutput) {
return
code
;
return
code
;
}
}
static
int32_t
checkAuthFromMetaData
(
const
SArray
*
pUsers
)
{
static
int32_t
checkAuthFromMetaData
(
const
SArray
*
pUsers
,
SNode
**
pTagCond
)
{
if
(
1
!=
taosArrayGetSize
(
pUsers
))
{
if
(
1
!=
taosArrayGetSize
(
pUsers
))
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
SMetaRes
*
pRes
=
taosArrayGet
(
pUsers
,
0
);
SMetaRes
*
pRes
=
taosArrayGet
(
pUsers
,
0
);
if
(
TSDB_CODE_SUCCESS
==
pRes
->
code
)
{
if
(
TSDB_CODE_SUCCESS
==
pRes
->
code
)
{
return
(
*
(
bool
*
)
pRes
->
pRes
)
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_PAR_PERMISSION_DENIED
;
SUserAuthRes
*
pAuth
=
pRes
->
pRes
;
if
(
NULL
!=
pAuth
->
pCond
)
{
*
pTagCond
=
nodesCloneNode
(
pAuth
->
pCond
);
}
return
pAuth
->
pass
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_PAR_PERMISSION_DENIED
;
}
}
return
pRes
->
code
;
return
pRes
->
code
;
}
}
...
@@ -1826,9 +1869,40 @@ static int32_t getTableVgroupFromMetaData(const SArray* pTables, SVnodeModifyOpS
...
@@ -1826,9 +1869,40 @@ static int32_t getTableVgroupFromMetaData(const SArray* pTables, SVnodeModifyOpS
sizeof
(
SVgroupInfo
));
sizeof
(
SVgroupInfo
));
}
}
static
int32_t
buildTagNameFromMeta
(
STableMeta
*
pMeta
,
SArray
**
pTagName
)
{
*
pTagName
=
taosArrayInit
(
pMeta
->
tableInfo
.
numOfTags
,
TSDB_COL_NAME_LEN
);
if
(
NULL
==
*
pTagName
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SSchema
*
pSchema
=
getTableTagSchema
(
pMeta
);
for
(
int32_t
i
=
0
;
i
<
pMeta
->
tableInfo
.
numOfTags
;
++
i
)
{
taosArrayPush
(
*
pTagName
,
pSchema
[
i
].
name
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
checkSubtablePrivilegeForTable
(
const
SArray
*
pTables
,
SVnodeModifyOpStmt
*
pStmt
)
{
if
(
1
!=
taosArrayGetSize
(
pTables
))
{
return
TSDB_CODE_FAILED
;
}
SMetaRes
*
pRes
=
taosArrayGet
(
pTables
,
0
);
if
(
TSDB_CODE_SUCCESS
!=
pRes
->
code
)
{
return
pRes
->
code
;
}
SArray
*
pTagName
=
NULL
;
int32_t
code
=
buildTagNameFromMeta
(
pStmt
->
pTableMeta
,
&
pTagName
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkSubtablePrivilege
((
SArray
*
)
pRes
->
pRes
,
pTagName
,
&
pStmt
->
pTagCond
);
}
taosArrayDestroy
(
pTagName
);
return
code
;
}
static
int32_t
getTableSchemaFromMetaData
(
SInsertParseContext
*
pCxt
,
const
SMetaData
*
pMetaData
,
static
int32_t
getTableSchemaFromMetaData
(
SInsertParseContext
*
pCxt
,
const
SMetaData
*
pMetaData
,
SVnodeModifyOpStmt
*
pStmt
,
bool
isStb
)
{
SVnodeModifyOpStmt
*
pStmt
,
bool
isStb
)
{
int32_t
code
=
checkAuthFromMetaData
(
pMetaData
->
pUser
);
int32_t
code
=
checkAuthFromMetaData
(
pMetaData
->
pUser
,
&
pStmt
->
pTagCond
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getTableMetaFromMetaData
(
pMetaData
->
pTableMeta
,
&
pStmt
->
pTableMeta
);
code
=
getTableMetaFromMetaData
(
pMetaData
->
pTableMeta
,
&
pStmt
->
pTableMeta
);
}
}
...
@@ -1841,6 +1915,9 @@ static int32_t getTableSchemaFromMetaData(SInsertParseContext* pCxt, const SMeta
...
@@ -1841,6 +1915,9 @@ static int32_t getTableSchemaFromMetaData(SInsertParseContext* pCxt, const SMeta
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getTableVgroupFromMetaData
(
pMetaData
->
pTableHash
,
pStmt
,
isStb
);
code
=
getTableVgroupFromMetaData
(
pMetaData
->
pTableHash
,
pStmt
,
isStb
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
isStb
&&
NULL
!=
pStmt
->
pTagCond
)
{
code
=
checkSubtablePrivilegeForTable
(
pMetaData
->
pTableTag
,
pStmt
);
}
return
code
;
return
code
;
}
}
...
@@ -1860,6 +1937,8 @@ static void clearCatalogReq(SCatalogReq* pCatalogReq) {
...
@@ -1860,6 +1937,8 @@ static void clearCatalogReq(SCatalogReq* pCatalogReq) {
pCatalogReq
->
pTableHash
=
NULL
;
pCatalogReq
->
pTableHash
=
NULL
;
taosArrayDestroy
(
pCatalogReq
->
pUser
);
taosArrayDestroy
(
pCatalogReq
->
pUser
);
pCatalogReq
->
pUser
=
NULL
;
pCatalogReq
->
pUser
=
NULL
;
taosArrayDestroy
(
pCatalogReq
->
pTableTag
);
pCatalogReq
->
pTableTag
=
NULL
;
}
}
static
int32_t
setVnodeModifOpStmt
(
SInsertParseContext
*
pCxt
,
SCatalogReq
*
pCatalogReq
,
const
SMetaData
*
pMetaData
,
static
int32_t
setVnodeModifOpStmt
(
SInsertParseContext
*
pCxt
,
SCatalogReq
*
pCatalogReq
,
const
SMetaData
*
pMetaData
,
...
@@ -2033,8 +2112,15 @@ static int32_t buildInsertUserAuthReq(const char* pUser, SName* pName, SArray**
...
@@ -2033,8 +2112,15 @@ static int32_t buildInsertUserAuthReq(const char* pUser, SName* pName, SArray**
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
buildInsertTableTagReq
(
SName
*
pName
,
SArray
**
pTables
)
{
return
buildInsertTableReq
(
pName
,
pTables
);
}
static
int32_t
buildInsertCatalogReq
(
SInsertParseContext
*
pCxt
,
SVnodeModifyOpStmt
*
pStmt
,
SCatalogReq
*
pCatalogReq
)
{
static
int32_t
buildInsertCatalogReq
(
SInsertParseContext
*
pCxt
,
SVnodeModifyOpStmt
*
pStmt
,
SCatalogReq
*
pCatalogReq
)
{
int32_t
code
=
buildInsertUserAuthReq
(
pCxt
->
pComCxt
->
pUser
,
&
pStmt
->
targetTableName
,
&
pCatalogReq
->
pUser
);
int32_t
code
=
buildInsertUserAuthReq
(
pCxt
->
pComCxt
->
pUser
,
(
0
==
pStmt
->
usingTableName
.
type
?
&
pStmt
->
targetTableName
:
&
pStmt
->
usingTableName
),
&
pCatalogReq
->
pUser
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
pCxt
->
needTableTagVal
)
{
code
=
buildInsertTableTagReq
(
&
pStmt
->
targetTableName
,
&
pCatalogReq
->
pTableTag
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
0
==
pStmt
->
usingTableName
.
type
)
{
if
(
0
==
pStmt
->
usingTableName
.
type
)
{
code
=
buildInsertDbReq
(
&
pStmt
->
targetTableName
,
&
pCatalogReq
->
pTableMeta
);
code
=
buildInsertDbReq
(
&
pStmt
->
targetTableName
,
&
pCatalogReq
->
pTableMeta
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
6a889ae8
...
@@ -1310,7 +1310,8 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
...
@@ -1310,7 +1310,8 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
}
}
static
EDealRes
haveVectorFunction
(
SNode
*
pNode
,
void
*
pContext
)
{
static
EDealRes
haveVectorFunction
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
isAggFunc
(
pNode
)
||
isIndefiniteRowsFunc
(
pNode
)
||
isWindowPseudoColumnFunc
(
pNode
)
||
isInterpPseudoColumnFunc
(
pNode
))
{
if
(
isAggFunc
(
pNode
)
||
isIndefiniteRowsFunc
(
pNode
)
||
isWindowPseudoColumnFunc
(
pNode
)
||
isInterpPseudoColumnFunc
(
pNode
))
{
*
((
bool
*
)
pContext
)
=
true
;
*
((
bool
*
)
pContext
)
=
true
;
return
DEAL_RES_END
;
return
DEAL_RES_END
;
}
}
...
@@ -2577,8 +2578,13 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
...
@@ -2577,8 +2578,13 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
if
(
TSDB_SUPER_TABLE
==
pRealTable
->
pMeta
->
tableType
)
{
if
(
TSDB_SUPER_TABLE
==
pRealTable
->
pMeta
->
tableType
)
{
pCxt
->
stableQuery
=
true
;
pCxt
->
stableQuery
=
true
;
}
}
if
(
TSDB_SYSTEM_TABLE
==
pRealTable
->
pMeta
->
tableType
&&
isSelectStmt
(
pCxt
->
pCurrStmt
))
{
if
(
TSDB_SYSTEM_TABLE
==
pRealTable
->
pMeta
->
tableType
)
{
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
isTimeLineResult
=
false
;
if
(
isSelectStmt
(
pCxt
->
pCurrStmt
))
{
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
isTimeLineResult
=
false
;
}
else
if
(
isDeleteStmt
(
pCxt
->
pCurrStmt
))
{
code
=
TSDB_CODE_TSC_INVALID_OPERATION
;
break
;
}
}
}
code
=
addNamespace
(
pCxt
,
pRealTable
);
code
=
addNamespace
(
pCxt
,
pRealTable
);
}
}
...
@@ -6642,6 +6648,7 @@ static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) {
...
@@ -6642,6 +6648,7 @@ static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_ALTER_USER
,
(
FSerializeFunc
)
tSerializeSAlterUserReq
,
&
req
);
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_ALTER_USER
,
(
FSerializeFunc
)
tSerializeSAlterUserReq
,
&
req
);
}
}
tFreeSAlterUserReq
(
&
req
);
return
code
;
return
code
;
}
}
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
6a889ae8
...
@@ -1443,7 +1443,7 @@ static int32_t createDeleteRootLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
...
@@ -1443,7 +1443,7 @@ static int32_t createDeleteRootLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
static
int32_t
createDeleteScanLogicNode
(
SLogicPlanContext
*
pCxt
,
SDeleteStmt
*
pDelete
,
SLogicNode
**
pLogicNode
)
{
static
int32_t
createDeleteScanLogicNode
(
SLogicPlanContext
*
pCxt
,
SDeleteStmt
*
pDelete
,
SLogicNode
**
pLogicNode
)
{
SScanLogicNode
*
pScan
=
NULL
;
SScanLogicNode
*
pScan
=
NULL
;
int32_t
code
=
makeScanLogicNode
(
pCxt
,
(
SRealTableNode
*
)
pDelete
->
pFromTable
,
false
,
(
SLogicNode
**
)
&
pScan
);
int32_t
code
=
makeScanLogicNode
(
pCxt
,
(
SRealTableNode
*
)
pDelete
->
pFromTable
,
false
,
(
SLogicNode
**
)
&
pScan
);
// set columns to scan
// set columns to scan
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
6a889ae8
...
@@ -407,7 +407,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta *
...
@@ -407,7 +407,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta *
pTableMeta
->
tableInfo
.
rowSize
+=
pTableMeta
->
schema
[
i
].
bytes
;
pTableMeta
->
tableInfo
.
rowSize
+=
pTableMeta
->
schema
[
i
].
bytes
;
}
}
qDebug
(
"table %s uid %"
PRIx64
" meta returned, type %d vgId:%d db %s stb %s suid %"
PRIx64
" sver %d tver %d"
PRIx64
qDebug
(
"table %s uid %"
PRIx64
" meta returned, type %d vgId:%d db %s stb %s suid %"
PRIx64
" sver %d tver %d"
" tagNum %d colNum %d precision %d rowSize %d"
,
" tagNum %d colNum %d precision %d rowSize %d"
,
msg
->
tbName
,
pTableMeta
->
uid
,
pTableMeta
->
tableType
,
pTableMeta
->
vgId
,
msg
->
dbFName
,
msg
->
stbName
,
msg
->
tbName
,
pTableMeta
->
uid
,
pTableMeta
->
tableType
,
pTableMeta
->
vgId
,
msg
->
dbFName
,
msg
->
stbName
,
pTableMeta
->
suid
,
pTableMeta
->
sversion
,
pTableMeta
->
tversion
,
pTableMeta
->
tableInfo
.
numOfTags
,
pTableMeta
->
suid
,
pTableMeta
->
sversion
,
pTableMeta
->
tversion
,
pTableMeta
->
tableInfo
.
numOfTags
,
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
6a889ae8
...
@@ -53,6 +53,7 @@ int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarPara
...
@@ -53,6 +53,7 @@ int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarPara
int32_t
code
=
colInfoDataEnsureCapacity
(
pColumnData
,
numOfRows
,
true
);
int32_t
code
=
colInfoDataEnsureCapacity
(
pColumnData
,
numOfRows
,
true
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
colDataDestroy
(
pColumnData
);
taosMemoryFree
(
pColumnData
);
taosMemoryFree
(
pColumnData
);
return
terrno
;
return
terrno
;
}
}
...
@@ -1061,17 +1062,20 @@ int32_t sclConvertOpValueNodeTs(SOperatorNode *node, SScalarCtx *ctx) {
...
@@ -1061,17 +1062,20 @@ int32_t sclConvertOpValueNodeTs(SOperatorNode *node, SScalarCtx *ctx) {
if
(
node
->
pLeft
&&
SCL_IS_VAR_VALUE_NODE
(
node
->
pLeft
))
{
if
(
node
->
pLeft
&&
SCL_IS_VAR_VALUE_NODE
(
node
->
pLeft
))
{
if
(
node
->
pRight
&&
(
TSDB_DATA_TYPE_TIMESTAMP
==
((
SExprNode
*
)
node
->
pRight
)
->
resType
.
type
))
{
if
(
node
->
pRight
&&
(
TSDB_DATA_TYPE_TIMESTAMP
==
((
SExprNode
*
)
node
->
pRight
)
->
resType
.
type
))
{
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
sclGetOpValueNodeTsPrecision
(
node
->
pLeft
,
node
->
pRight
),
(
SValueNode
*
)
node
->
pLeft
));
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
sclGetOpValueNodeTsPrecision
(
node
->
pLeft
,
node
->
pRight
),
(
SValueNode
*
)
node
->
pLeft
));
}
}
}
else
if
(
node
->
pRight
&&
SCL_IS_NOTNULL_CONST_NODE
(
node
->
pRight
))
{
}
else
if
(
node
->
pRight
&&
SCL_IS_NOTNULL_CONST_NODE
(
node
->
pRight
))
{
if
(
node
->
pLeft
&&
(
TSDB_DATA_TYPE_TIMESTAMP
==
((
SExprNode
*
)
node
->
pLeft
)
->
resType
.
type
))
{
if
(
node
->
pLeft
&&
(
TSDB_DATA_TYPE_TIMESTAMP
==
((
SExprNode
*
)
node
->
pLeft
)
->
resType
.
type
))
{
if
(
SCL_IS_VAR_VALUE_NODE
(
node
->
pRight
))
{
if
(
SCL_IS_VAR_VALUE_NODE
(
node
->
pRight
))
{
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
sclGetOpValueNodeTsPrecision
(
node
->
pLeft
,
node
->
pRight
),
(
SValueNode
*
)
node
->
pRight
));
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
sclGetOpValueNodeTsPrecision
(
node
->
pLeft
,
node
->
pRight
),
(
SValueNode
*
)
node
->
pRight
));
}
else
if
(
QUERY_NODE_NODE_LIST
==
node
->
pRight
->
type
)
{
}
else
if
(
QUERY_NODE_NODE_LIST
==
node
->
pRight
->
type
)
{
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
((
SNodeListNode
*
)
node
->
pRight
)
->
pNodeList
)
{
FOREACH
(
pNode
,
((
SNodeListNode
*
)
node
->
pRight
)
->
pNodeList
)
{
if
(
SCL_IS_VAR_VALUE_NODE
(
pNode
))
{
if
(
SCL_IS_VAR_VALUE_NODE
(
pNode
))
{
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
sclGetOpValueNodeTsPrecision
(
node
->
pLeft
,
pNode
),
(
SValueNode
*
)
pNode
));
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
sclGetOpValueNodeTsPrecision
(
node
->
pLeft
,
pNode
),
(
SValueNode
*
)
pNode
));
}
}
}
}
}
}
...
@@ -1086,8 +1090,6 @@ _return:
...
@@ -1086,8 +1090,6 @@ _return:
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
}
}
int32_t
sclConvertCaseWhenValueNodeTs
(
SCaseWhenNode
*
node
,
SScalarCtx
*
ctx
)
{
int32_t
sclConvertCaseWhenValueNodeTs
(
SCaseWhenNode
*
node
,
SScalarCtx
*
ctx
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -1096,19 +1098,20 @@ int32_t sclConvertCaseWhenValueNodeTs(SCaseWhenNode *node, SScalarCtx *ctx) {
...
@@ -1096,19 +1098,20 @@ int32_t sclConvertCaseWhenValueNodeTs(SCaseWhenNode *node, SScalarCtx *ctx) {
}
}
if
(
SCL_IS_VAR_VALUE_NODE
(
node
->
pCase
))
{
if
(
SCL_IS_VAR_VALUE_NODE
(
node
->
pCase
))
{
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
node
->
pWhenThenList
)
{
FOREACH
(
pNode
,
node
->
pWhenThenList
)
{
SExprNode
*
pExpr
=
(
SExprNode
*
)((
SWhenThenNode
*
)
pNode
)
->
pWhen
;
SExprNode
*
pExpr
=
(
SExprNode
*
)((
SWhenThenNode
*
)
pNode
)
->
pWhen
;
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
pExpr
->
resType
.
type
)
{
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
pExpr
->
resType
.
type
)
{
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
pExpr
->
resType
.
precision
,
(
SValueNode
*
)
node
->
pCase
));
SCL_ERR_JRET
(
sclConvertToTsValueNode
(
pExpr
->
resType
.
precision
,
(
SValueNode
*
)
node
->
pCase
));
break
;
break
;
}
}
}
}
}
else
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
((
SExprNode
*
)
node
->
pCase
)
->
resType
.
type
)
{
}
else
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
((
SExprNode
*
)
node
->
pCase
)
->
resType
.
type
)
{
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
node
->
pWhenThenList
)
{
FOREACH
(
pNode
,
node
->
pWhenThenList
)
{
if
(
SCL_IS_VAR_VALUE_NODE
(((
SWhenThenNode
*
)
pNode
)
->
pWhen
))
{
if
(
SCL_IS_VAR_VALUE_NODE
(((
SWhenThenNode
*
)
pNode
)
->
pWhen
))
{
SCL_ERR_JRET
(
sclConvertToTsValueNode
(((
SExprNode
*
)
node
->
pCase
)
->
resType
.
precision
,
(
SValueNode
*
)((
SWhenThenNode
*
)
pNode
)
->
pWhen
));
SCL_ERR_JRET
(
sclConvertToTsValueNode
(((
SExprNode
*
)
node
->
pCase
)
->
resType
.
precision
,
(
SValueNode
*
)((
SWhenThenNode
*
)
pNode
)
->
pWhen
));
}
}
}
}
}
}
...
@@ -1271,7 +1274,6 @@ EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) {
...
@@ -1271,7 +1274,6 @@ EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
EDealRes
sclRewriteOperator
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
EDealRes
sclRewriteOperator
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
SOperatorNode
*
node
=
(
SOperatorNode
*
)
*
pNode
;
SOperatorNode
*
node
=
(
SOperatorNode
*
)
*
pNode
;
...
...
source/os/src/osFile.c
浏览文件 @
6a889ae8
...
@@ -538,10 +538,11 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
...
@@ -538,10 +538,11 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
return
-
1
;
return
-
1
;
}
}
struct
stat
fileStat
;
#ifdef WINDOWS
#ifdef WINDOWS
int32_t
code
=
_fstat
(
pFile
->
fd
,
&
fileStat
);
struct
__stat64
fileStat
;
int32_t
code
=
_fstat64
(
pFile
->
fd
,
&
fileStat
);
#else
#else
struct
stat
fileStat
;
int32_t
code
=
fstat
(
pFile
->
fd
,
&
fileStat
);
int32_t
code
=
fstat
(
pFile
->
fd
,
&
fileStat
);
#endif
#endif
if
(
code
<
0
)
{
if
(
code
<
0
)
{
...
...
source/util/src/tlog.c
浏览文件 @
6a889ae8
...
@@ -347,7 +347,6 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
...
@@ -347,7 +347,6 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
char
name
[
LOG_FILE_NAME_LEN
+
50
]
=
"
\0
"
;
char
name
[
LOG_FILE_NAME_LEN
+
50
]
=
"
\0
"
;
int32_t
logstat0_mtime
,
logstat1_mtime
;
int32_t
logstat0_mtime
,
logstat1_mtime
;
int32_t
size
;
tsLogObj
.
maxLines
=
maxLines
;
tsLogObj
.
maxLines
=
maxLines
;
tsLogObj
.
fileNum
=
maxFileNum
;
tsLogObj
.
fileNum
=
maxFileNum
;
...
@@ -395,8 +394,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
...
@@ -395,8 +394,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
printf
(
"
\n
failed to fstat log file:%s, reason:%s
\n
"
,
fileName
,
strerror
(
errno
));
printf
(
"
\n
failed to fstat log file:%s, reason:%s
\n
"
,
fileName
,
strerror
(
errno
));
return
-
1
;
return
-
1
;
}
}
size
=
(
int32_t
)
filesize
;
tsLogObj
.
lines
=
(
int32_t
)(
filesize
/
60
);
tsLogObj
.
lines
=
size
/
60
;
taosLSeekFile
(
tsLogObj
.
logHandle
->
pFile
,
0
,
SEEK_END
);
taosLSeekFile
(
tsLogObj
.
logHandle
->
pFile
,
0
,
SEEK_END
);
...
...
source/util/src/tsimplehash.c
浏览文件 @
6a889ae8
...
@@ -361,10 +361,6 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke
...
@@ -361,10 +361,6 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
destroyItems
(
void
*
pItem
)
{
taosMemoryFree
(
*
(
void
**
)
pItem
);
}
void
tSimpleHashClear
(
SSHashObj
*
pHashObj
)
{
void
tSimpleHashClear
(
SSHashObj
*
pHashObj
)
{
if
(
!
pHashObj
||
taosHashTableEmpty
(
pHashObj
))
{
if
(
!
pHashObj
||
taosHashTableEmpty
(
pHashObj
))
{
return
;
return
;
...
...
tests/parallel_test/cases.task
浏览文件 @
6a889ae8
...
@@ -137,11 +137,13 @@
...
@@ -137,11 +137,13 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_control.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_control.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_manage.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_manage.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/fsync.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/fsync.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/multilevel.py
,,n,system-test,python3 ./test.py -f 0-others/compatibility.py
,,n,system-test,python3 ./test.py -f 0-others/compatibility.py
,,n,system-test,python3 ./test.py -f 0-others/tag_index_basic.py
,,n,system-test,python3 ./test.py -f 0-others/tag_index_basic.py
,,n,system-test,python3 ./test.py -f 0-others/udfpy_main.py
,,n,system-test,python3 ./test.py -f 0-others/udfpy_main.py
,,n,system-test,python3 ./test.py -N 3 -f 0-others/walRetention.py
,,n,system-test,python3 ./test.py -N 3 -f 0-others/walRetention.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_database.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_database.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_replica.py -N 3
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py
...
@@ -347,6 +349,7 @@
...
@@ -347,6 +349,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/tb_100w_data_order.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/tb_100w_data_order.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_childtable.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_childtable.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_normaltable.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_normaltable.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_systable.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/keep_expired.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/keep_expired.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/drop.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/drop.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/drop.py -N 3 -M 3 -i False -n 3
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/drop.py -N 3 -M 3 -i False -n 3
...
@@ -732,6 +735,7 @@
...
@@ -732,6 +735,7 @@
,,y,script,./test.sh -f tsim/user/privilege_db.sim
,,y,script,./test.sh -f tsim/user/privilege_db.sim
,,y,script,./test.sh -f tsim/user/privilege_sysinfo.sim
,,y,script,./test.sh -f tsim/user/privilege_sysinfo.sim
,,y,script,./test.sh -f tsim/user/privilege_topic.sim
,,y,script,./test.sh -f tsim/user/privilege_topic.sim
,,y,script,./test.sh -f tsim/user/privilege_table.sim
,,y,script,./test.sh -f tsim/db/alter_option.sim
,,y,script,./test.sh -f tsim/db/alter_option.sim
,,y,script,./test.sh -f tsim/db/alter_replica_31.sim
,,y,script,./test.sh -f tsim/db/alter_replica_31.sim
,,y,script,./test.sh -f tsim/db/basic1.sim
,,y,script,./test.sh -f tsim/db/basic1.sim
...
...
tests/script/tsim/user/privilege_table.sim
0 → 100644
浏览文件 @
6a889ae8
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print =============== init env
sql drop database if exists test;
sql create database test vgroups 1;
sql use test;
sql create stable st1(ts timestamp, i int) tags(id int, loc varchar(20));
sql create table st1s1 using st1 tags(1, 'beijing');
sql create table st1s2 using st1 tags(2, 'shanghai');
sql insert into st1s1 values(now, 1) st1s2 values(now, 2);
sql create stable st2(ts timestamp, i int) tags(id int, loc varchar(20));
sql create table st2s1 using st2 tags(1, 'beijing');
sql create table st2s2 using st2 tags(2, 'shanghai');
sql insert into st2s1 values(now, 1) st2s2 values(now, 2);
sql create user wxy pass 'taosdata';
print =============== case 1: database unauthorized and table unauthorized
sql close
sql connect wxy
sql reset query cache;
sql_error select * from test.st1;
sql_error insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
sql_error select * from test.st2;
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 2: database unauthorized and table read privilege
sql close
sql connect
sql grant read on test.st1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql select * from test.st1;
if $rows != 2 then
return -1
endi
sql_error insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
sql_error select * from test.st2;
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 3: database unauthorized and table read privilege with condition
sql close
sql connect
sql revoke read on test.st1 from wxy;
sql grant read on test.st1 with id = 1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql select * from test.st1;
if $rows != 1 then
return -1
endi
sql_error insert into test.st1s1 values(now, 10);
sql_error insert into test.st1s2 values(now, 20);
sql_error select * from test.st2;
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 4: database unauthorized and table write privilege
sql close
sql connect
sql revoke read on test.st1 with id = 1 from wxy;
sql grant write on test.st1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql_error select tbname, * from test.st1;
sql insert into test.st1s1 values(now, 10);
sql insert into test.st1s2 values(now, 20);
sql_error select * from test.st2;
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 5: database unauthorized and table write privilege with condition
sql close
sql connect
sql revoke write on test.st1 from wxy;
sql grant write on test.st1 with id = 1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql_error select tbname, * from test.st1;
sql insert into test.st1s1 values(now, 10);
sql insert into test.st1s3 using test.st1 tags(1, 'dachang') values(now, 100);
sql_error insert into test.st1s2 values(now, 20);
sql_error insert into test.st1s4 using test.st1 tags(3, 'dachang') values(now, 300);
sql_error select * from test.st2;
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 6: database read privilege and table unauthorized
sql close
sql connect
sql revoke write on test.st1 with id = 1 from wxy;
sql grant read on test.* to wxy;
sql close
sql connect wxy
sql reset query cache;
sql select * from test.st1;
if $rows != 6 then
return -1
endi
sql_error insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
sql select * from test.st2;
if $rows != 2 then
return -1
endi
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 7: database read privilege and table read privilege
sql close
sql connect
sql grant read on test.st1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql select * from test.st1;
if $rows != 6 then
return -1
endi
sql_error insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
sql select * from test.st2;
if $rows != 2 then
return -1
endi
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 8: database read privilege and table read privilege with condition
sql close
sql connect
sql revoke read on test.st1 from wxy;
sql grant read on test.st1 with id = 1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql select * from test.st1;
if $rows != 4 then
return -1
endi
sql_error insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
sql select * from test.st2;
if $rows != 2 then
return -1
endi
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 9: database read privilege and table write privilege
sql close
sql connect
sql revoke read on test.st1 with id = 1 from wxy;
sql grant write on test.st1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql select * from test.st1;
if $rows != 6 then
return -1
endi
sql insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
sql select * from test.st2;
if $rows != 2 then
return -1
endi
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 10: database read privilege and table write privilege with condition
sql close
sql connect
sql revoke write on test.st1 from wxy;
sql grant write on test.st1 with id = 1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql select * from test.st1;
if $rows != 8 then
return -1
endi
sql insert into test.st1s1 values(now, 10);
sql_error insert into test.st1s2 values(now, 20);
sql select * from test.st2;
if $rows != 2 then
return -1
endi
sql_error insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 11: database write privilege and table unauthorized
sql close
sql connect
sql revoke read on test.* from wxy;
sql revoke write on test.st1 with id = 1 from wxy;
sql grant write on test.* to wxy;
sql close
sql connect wxy
sql reset query cache;
sql_error select * from test.st1;
sql insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
sql_error select * from test.st2;
sql insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 12: database write privilege and table read privilege
sql close
sql connect
sql grant read on test.st1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql select * from test.st1;
if $rows != 11 then
return -1
endi
sql insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
sql_error select * from test.st2;
sql insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 13: database write privilege and table read privilege with condition
sql close
sql connect
sql revoke read on test.st1 from wxy;
sql grant read on test.st1 with id = 1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql select * from test.st1;
if $rows != 8 then
return -1
endi
sql insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
sql_error select * from test.st2;
sql insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 14: database write privilege and table write privilege
sql close
sql connect
sql revoke read on test.st1 with id = 1 from wxy;
sql grant write on test.st1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql_error select * from test.st1;
sql insert into test.st1s1 values(now, 10) test.st1s2 values(now, 20);
sql_error select * from test.st2;
sql insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
print =============== case 15: database write privilege and table write privilege with condition
sql close
sql connect
sql revoke write on test.st1 from wxy;
sql grant write on test.st1 with id = 1 to wxy;
sql close
sql connect wxy
sql reset query cache;
sql_error select * from test.st1;
sql insert into test.st1s1 values(now, 10);
sql_error insert into test.st1s2 values(now, 20);
sql_error select * from test.st2;
sql insert into test.st2s1 values(now, 10) test.st2s2 values(now, 20);
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/win-test-file
浏览文件 @
6a889ae8
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
./test.sh -f tsim/user/privilege_db.sim
./test.sh -f tsim/user/privilege_db.sim
./test.sh -f tsim/user/privilege_sysinfo.sim
./test.sh -f tsim/user/privilege_sysinfo.sim
./test.sh -f tsim/user/privilege_topic.sim
./test.sh -f tsim/user/privilege_topic.sim
./test.sh -f tsim/user/privilege_table.sim
./test.sh -f tsim/db/alter_option.sim
./test.sh -f tsim/db/alter_option.sim
rem ./test.sh -f tsim/db/alter_replica_13.sim
rem ./test.sh -f tsim/db/alter_replica_13.sim
./test.sh -f tsim/db/alter_replica_31.sim
./test.sh -f tsim/db/alter_replica_31.sim
...
...
tests/system-test/0-others/multilevel.py
0 → 100644
浏览文件 @
6a889ae8
此差异已折叠。
点击以展开。
tests/system-test/1-insert/alter_replica.py
0 → 100644
浏览文件 @
6a889ae8
import
taos
import
sys
import
time
import
socket
import
os
import
threading
import
datetime
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.dnodes
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
,
replicaVar
=
1
):
self
.
replicaVar
=
int
(
replicaVar
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
checkVgroups
(
self
,
dbName
,
vgNum
):
sleepNum
=
vgNum
*
60
flag
=
0
while
(
sleepNum
>
0
):
sql
=
f
'show
{
dbName
}
.vgroups'
tdSql
.
query
(
sql
)
flag
=
0
for
vgid
in
range
(
vgNum
)
:
v1_status
=
tdSql
.
queryResult
[
vgid
][
4
]
v2_status
=
tdSql
.
queryResult
[
vgid
][
6
]
v3_status
=
tdSql
.
queryResult
[
vgid
][
8
]
if
((
v1_status
==
'leader'
)
and
(
v2_status
==
'follower'
)
and
(
v3_status
==
'follower'
))
\
or
((
v2_status
==
'leader'
)
and
(
v1_status
==
'follower'
)
and
(
v3_status
==
'follower'
))
\
or
((
v3_status
==
'leader'
)
and
(
v2_status
==
'follower'
)
and
(
v1_status
==
'follower'
)):
continue
else
:
sleepNum
=
sleepNum
-
1
time
.
sleep
(
1
)
flag
=
1
break
if
(
0
==
flag
):
return
0
tdLog
.
debug
(
"vgroup[%d] status: %s, %s, %s"
%
(
vgid
,
v1_status
,
v2_status
,
v3_status
))
return
-
1
def
alter_replica
(
self
):
# create db and alter replica
tdLog
.
debug
(
"====alter db repica 1===="
)
vgNum
=
3
dbName
=
'db1'
sql
=
f
'create database
{
dbName
}
vgroups
{
vgNum
}
'
tdSql
.
execute
(
sql
)
sql
=
f
'alter database
{
dbName
}
replica 3'
tdSql
.
execute
(
sql
)
tdLog
.
debug
(
"start check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
res
=
self
.
checkVgroups
(
dbName
,
vgNum
)
tdLog
.
debug
(
"end check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
if
(
0
!=
res
):
tdLog
.
exit
(
f
'fail: alter database
{
dbName
}
replica 3'
)
# create db, stable, child tables, and insert data, then alter replica
tdLog
.
debug
(
"====alter db repica 2===="
)
dbName
=
'db2'
sql
=
f
'create database
{
dbName
}
vgroups
{
vgNum
}
'
tdSql
.
execute
(
sql
)
sql
=
f
'use
{
dbName
}
'
tdSql
.
execute
(
sql
)
sql
=
f
'create stable stb (ts timestamp, c int) tags (t int)'
tdSql
.
execute
(
sql
)
sql
=
f
'create table ctb using stb tags (1)'
tdSql
.
execute
(
sql
)
sql
=
f
'insert into ctb values (now, 1) (now+1s, 2) (now+2s, 3)'
tdSql
.
execute
(
sql
)
sql
=
f
'alter database
{
dbName
}
replica 3'
tdSql
.
execute
(
sql
)
tdLog
.
debug
(
"start check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
res
=
self
.
checkVgroups
(
dbName
,
vgNum
)
tdLog
.
debug
(
"end check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
if
(
0
!=
res
):
tdLog
.
exit
(
f
'fail: alter database
{
dbName
}
replica 3'
)
# firstly create db, stable, child tables, and insert data, then drop stable, and then alter replica
tdLog
.
debug
(
"====alter db repica 3===="
)
dbName
=
'db3'
sql
=
f
'create database
{
dbName
}
vgroups
{
vgNum
}
'
tdSql
.
execute
(
sql
)
sql
=
f
'use
{
dbName
}
'
tdSql
.
execute
(
sql
)
sql
=
f
'create stable stb (ts timestamp, c int) tags (t int)'
tdSql
.
execute
(
sql
)
sql
=
f
'create table ctb using stb tags (1)'
tdSql
.
execute
(
sql
)
sql
=
f
'insert into ctb values (now, 1) (now+1s, 2) (now+2s, 3)'
tdSql
.
execute
(
sql
)
sql
=
f
'drop table stb'
tdSql
.
execute
(
sql
)
sql
=
f
'alter database
{
dbName
}
replica 3'
tdSql
.
execute
(
sql
)
tdLog
.
debug
(
"start check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
res
=
self
.
checkVgroups
(
dbName
,
vgNum
)
tdLog
.
debug
(
"end check time: %s"
%
(
str
(
datetime
.
datetime
.
now
())))
if
(
0
!=
res
):
tdLog
.
exit
(
f
'fail: alter database
{
dbName
}
replica 3'
)
def
run
(
self
):
self
.
alter_replica
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tests/system-test/1-insert/delete_systable.py
0 → 100644
浏览文件 @
6a889ae8
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/clusterCommonCreate.py
浏览文件 @
6a889ae8
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeDb3.py
浏览文件 @
6a889ae8
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmqCommon.py
浏览文件 @
6a889ae8
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmqConsumerGroup.py
浏览文件 @
6a889ae8
...
@@ -100,7 +100,7 @@ class TDTestCase:
...
@@ -100,7 +100,7 @@ class TDTestCase:
tdLog
.
info
(
"wait consumer commit notify"
)
tdLog
.
info
(
"wait consumer commit notify"
)
# tmqCom.getStartCommitNotifyFromTmqsim(rows=4)
# tmqCom.getStartCommitNotifyFromTmqsim(rows=4)
tmqCom
.
getStartConsumeNotifyFromTmqsim
(
rows
=
2
)
tmqCom
.
getStartConsumeNotifyFromTmqsim
()
tdLog
.
info
(
"pkill one consume processor"
)
tdLog
.
info
(
"pkill one consume processor"
)
tmqCom
.
stopTmqSimProcess
(
'tmq_sim_new'
)
tmqCom
.
stopTmqSimProcess
(
'tmq_sim_new'
)
...
...
tests/system-test/7-tmq/tmqDnodeRestart1.py
浏览文件 @
6a889ae8
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录