Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
055e0516
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
055e0516
编写于
4月 21, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feature/vnode_refact1
上级
1fe0daaf
103af37e
变更
64
展开全部
隐藏空白更改
内联
并排
Showing
64 changed file
with
2128 addition
and
2197 deletion
+2128
-2197
include/client/taos.h
include/client/taos.h
+1
-0
include/common/taosdef.h
include/common/taosdef.h
+0
-7
include/common/tmsg.h
include/common/tmsg.h
+49
-11
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+2
-0
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+8
-1
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+3
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+0
-1
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+5
-3
include/libs/planner/planner.h
include/libs/planner/planner.h
+1
-0
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+0
-1
source/client/inc/clientStmt.h
source/client/inc/clientStmt.h
+1
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+31
-24
source/client/src/clientMain.c
source/client/src/clientMain.c
+4
-0
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+2
-1
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+1
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+129
-77
source/dnode/mgmt/implement/src/dmTransport.c
source/dnode/mgmt/implement/src/dmTransport.c
+4
-4
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+23
-313
source/dnode/mnode/impl/inc/mndScheduler.h
source/dnode/mnode/impl/inc/mndScheduler.h
+2
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+2
-0
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+18
-67
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+27
-18
source/dnode/mnode/impl/src/mndInfoSchema.c
source/dnode/mnode/impl/src/mndInfoSchema.c
+1
-1
source/dnode/mnode/impl/src/mndOffset.c
source/dnode/mnode/impl/src/mndOffset.c
+3
-3
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+49
-42
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+48
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+1
-0
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+18
-568
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+44
-42
source/dnode/mnode/impl/test/func/func.cpp
source/dnode/mnode/impl/test/func/func.cpp
+2
-2
source/dnode/mnode/impl/test/profile/profile.cpp
source/dnode/mnode/impl/test/profile/profile.cpp
+13
-0
source/dnode/mnode/impl/test/show/show.cpp
source/dnode/mnode/impl/test/show/show.cpp
+7
-1
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+1
-2
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+1
-0
source/dnode/vnode/src/meta/metaTDBImpl.c
source/dnode/vnode/src/meta/metaTDBImpl.c
+65
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+0
-121
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+21
-26
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+3
-0
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
+23
-17
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+22
-15
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+67
-0
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+143
-129
source/libs/function/src/functionMgt.c
source/libs/function/src/functionMgt.c
+20
-8
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+2
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+93
-8
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+2
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+532
-526
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+166
-8
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+2
-0
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+2
-2
source/libs/planner/src/planScaleOut.c
source/libs/planner/src/planScaleOut.c
+6
-7
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+177
-17
source/libs/planner/test/planSetOpTest.cpp
source/libs/planner/test/planSetOpTest.cpp
+35
-0
source/libs/planner/test/planTestMain.cpp
source/libs/planner/test/planTestMain.cpp
+0
-0
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+19
-2
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+49
-0
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+2
-1
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+12
-11
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+3
-22
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+33
-15
tests/script/runAllSimCases.sh
tests/script/runAllSimCases.sh
+1
-1
tests/system-test/2-query/cast.py
tests/system-test/2-query/cast.py
+121
-70
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+5
-1
未找到文件。
include/client/taos.h
浏览文件 @
055e0516
...
@@ -146,6 +146,7 @@ DLL_EXPORT TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt);
...
@@ -146,6 +146,7 @@ DLL_EXPORT TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt);
DLL_EXPORT
int
taos_stmt_close
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_close
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
char
*
taos_stmt_errstr
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
char
*
taos_stmt_errstr
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_affected_rows
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_affected_rows
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_affected_rows_once
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sql
);
DLL_EXPORT
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sql
);
DLL_EXPORT
TAOS_RES
*
taos_query_l
(
TAOS
*
taos
,
const
char
*
sql
,
int
sqlLen
);
DLL_EXPORT
TAOS_RES
*
taos_query_l
(
TAOS
*
taos
,
const
char
*
sql
,
int
sqlLen
);
...
...
include/common/taosdef.h
浏览文件 @
055e0516
...
@@ -78,13 +78,6 @@ typedef enum {
...
@@ -78,13 +78,6 @@ typedef enum {
TSDB_SMA_TYPE_ROLLUP
=
2
,
// Rollup SMA
TSDB_SMA_TYPE_ROLLUP
=
2
,
// Rollup SMA
}
ETsdbSmaType
;
}
ETsdbSmaType
;
typedef
enum
{
TSDB_BSMA_TYPE_NONE
=
0
,
// no block-wise SMA
TSDB_BSMA_TYPE_I
=
1
,
// sum/min/max(default)
}
ETsdbBSmaType
;
#define TSDB_BSMA_TYPE_LATEST TSDB_BSMA_TYPE_I
extern
char
*
qtypeStr
[];
extern
char
*
qtypeStr
[];
#define TSDB_PORT_HTTP 11
#define TSDB_PORT_HTTP 11
...
...
include/common/tmsg.h
浏览文件 @
055e0516
...
@@ -331,6 +331,8 @@ typedef struct {
...
@@ -331,6 +331,8 @@ typedef struct {
int32_t
pid
;
int32_t
pid
;
char
app
[
TSDB_APP_NAME_LEN
];
char
app
[
TSDB_APP_NAME_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
char
user
[
TSDB_USER_LEN
];
char
passwd
[
TSDB_PASSWORD_LEN
];
int64_t
startTime
;
int64_t
startTime
;
}
SConnectReq
;
}
SConnectReq
;
...
@@ -482,7 +484,7 @@ typedef struct {
...
@@ -482,7 +484,7 @@ typedef struct {
char
intervalUnit
;
char
intervalUnit
;
char
slidingUnit
;
char
slidingUnit
;
char
char
offsetUnit
;
// TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration.
offsetUnit
;
// TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration.
int8_t
precision
;
int8_t
precision
;
int64_t
interval
;
int64_t
interval
;
int64_t
sliding
;
int64_t
sliding
;
...
@@ -680,6 +682,7 @@ int32_t tDeserializeSDropFuncReq(void* buf, int32_t bufLen, SDropFuncReq* pReq);
...
@@ -680,6 +682,7 @@ int32_t tDeserializeSDropFuncReq(void* buf, int32_t bufLen, SDropFuncReq* pReq);
typedef
struct
{
typedef
struct
{
int32_t
numOfFuncs
;
int32_t
numOfFuncs
;
bool
ignoreCodeComment
;
SArray
*
pFuncNames
;
SArray
*
pFuncNames
;
}
SRetrieveFuncReq
;
}
SRetrieveFuncReq
;
...
@@ -708,6 +711,7 @@ typedef struct {
...
@@ -708,6 +711,7 @@ typedef struct {
int32_t
tSerializeSRetrieveFuncRsp
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncRsp
*
pRsp
);
int32_t
tSerializeSRetrieveFuncRsp
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncRsp
*
pRsp
);
int32_t
tDeserializeSRetrieveFuncRsp
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncRsp
*
pRsp
);
int32_t
tDeserializeSRetrieveFuncRsp
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncRsp
*
pRsp
);
void
tFreeSFuncInfo
(
SFuncInfo
*
pInfo
);
void
tFreeSRetrieveFuncRsp
(
SRetrieveFuncRsp
*
pRsp
);
void
tFreeSRetrieveFuncRsp
(
SRetrieveFuncRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
...
@@ -1273,11 +1277,16 @@ typedef struct {
...
@@ -1273,11 +1277,16 @@ typedef struct {
}
SMVCreateStreamRsp
,
SMSCreateStreamRsp
;
}
SMVCreateStreamRsp
,
SMSCreateStreamRsp
;
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
name
[
TSDB_TOPIC_FNAME_LEN
];
int8_t
igExists
;
int8_t
igExists
;
char
*
sql
;
int8_t
withTbName
;
char
*
ast
;
int8_t
withSchema
;
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
int8_t
withTag
;
int8_t
withTagSchema
;
char
*
sql
;
char
*
ast
;
int64_t
subDbUid
;
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
}
SCMCreateTopicReq
;
}
SCMCreateTopicReq
;
int32_t
tSerializeSCMCreateTopicReq
(
void
*
buf
,
int32_t
bufLen
,
const
SCMCreateTopicReq
*
pReq
);
int32_t
tSerializeSCMCreateTopicReq
(
void
*
buf
,
int32_t
bufLen
,
const
SCMCreateTopicReq
*
pReq
);
...
@@ -1471,8 +1480,12 @@ typedef struct {
...
@@ -1471,8 +1480,12 @@ typedef struct {
typedef
struct
{
typedef
struct
{
float
xFilesFactor
;
float
xFilesFactor
;
int32_t
delay
;
int32_t
delay
;
int8_t
nFuncIds
;
int32_t
qmsg1Len
;
int32_t
qmsg2Len
;
func_id_t
*
pFuncIds
;
func_id_t
*
pFuncIds
;
char
*
qmsg1
;
// not null: pAst1:qmsg1:SRetention1 => trigger aggr task1
char
*
qmsg2
;
// not null: pAst2:qmsg2:SRetention2 => trigger aggr task2
int8_t
nFuncIds
;
}
SRSmaParam
;
}
SRSmaParam
;
int
tEncodeSRSmaParam
(
SCoder
*
pCoder
,
const
SRSmaParam
*
pRSmaParam
);
int
tEncodeSRSmaParam
(
SCoder
*
pCoder
,
const
SRSmaParam
*
pRSmaParam
);
...
@@ -1940,12 +1953,22 @@ static FORCE_INLINE void* taosDecodeSMqMsg(void* buf, SMqHbMsg* pMsg) {
...
@@ -1940,12 +1953,22 @@ static FORCE_INLINE void* taosDecodeSMqMsg(void* buf, SMqHbMsg* pMsg) {
return
buf
;
return
buf
;
}
}
enum
{
TOPIC_SUB_TYPE__DB
=
1
,
TOPIC_SUB_TYPE__TABLE
,
};
typedef
struct
{
typedef
struct
{
int64_t
leftForVer
;
int64_t
leftForVer
;
int32_t
vgId
;
int32_t
vgId
;
int64_t
oldConsumerId
;
int64_t
oldConsumerId
;
int64_t
newConsumerId
;
int64_t
newConsumerId
;
char
subKey
[
TSDB_SUBSCRIBE_KEY_LEN
];
char
subKey
[
TSDB_SUBSCRIBE_KEY_LEN
];
int8_t
subType
;
int8_t
withTbName
;
int8_t
withSchema
;
int8_t
withTag
;
int8_t
withTagSchema
;
char
*
qmsg
;
char
*
qmsg
;
}
SMqRebVgReq
;
}
SMqRebVgReq
;
...
@@ -1956,7 +1979,14 @@ static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pR
...
@@ -1956,7 +1979,14 @@ static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pR
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
oldConsumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
oldConsumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
newConsumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
newConsumerId
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
subKey
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
subKey
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
qmsg
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
subType
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
withTbName
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
withSchema
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
withTag
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
withTagSchema
);
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
tlen
+=
taosEncodeString
(
buf
,
pReq
->
qmsg
);
}
return
tlen
;
return
tlen
;
}
}
...
@@ -1966,7 +1996,14 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq)
...
@@ -1966,7 +1996,14 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq)
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
oldConsumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
oldConsumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
newConsumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
newConsumerId
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
subKey
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
subKey
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
qmsg
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
subType
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
withTbName
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
withSchema
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
withTag
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
withTagSchema
);
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
buf
=
taosDecodeString
(
buf
,
&
pReq
->
qmsg
);
}
return
(
void
*
)
buf
;
return
(
void
*
)
buf
;
}
}
...
@@ -2306,9 +2343,10 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
...
@@ -2306,9 +2343,10 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
}
}
}
}
static
FORCE_INLINE
void
tdFreeTSmaWrapper
(
STSmaWrapper
*
pSW
)
{
static
FORCE_INLINE
void
*
tdFreeTSmaWrapper
(
STSmaWrapper
*
pSW
)
{
tdDestroyTSmaWrapper
(
pSW
);
tdDestroyTSmaWrapper
(
pSW
);
taosMemoryFreeClear
(
pSW
);
taosMemoryFree
(
pSW
);
return
NULL
;
}
}
static
FORCE_INLINE
int32_t
tEncodeTSma
(
void
**
buf
,
const
STSma
*
pSma
)
{
static
FORCE_INLINE
int32_t
tEncodeTSma
(
void
**
buf
,
const
STSma
*
pSma
)
{
...
...
include/libs/catalog/catalog.h
浏览文件 @
055e0516
...
@@ -224,6 +224,8 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
...
@@ -224,6 +224,8 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
int32_t
catalogGetIndexInfo
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
indexName
,
SIndexInfo
*
pInfo
);
int32_t
catalogGetIndexInfo
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
indexName
,
SIndexInfo
*
pInfo
);
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
funcName
,
SFuncInfo
**
pInfo
);
/**
/**
* Destroy catalog and relase all resources
* Destroy catalog and relase all resources
...
...
include/libs/function/functionMgt.h
浏览文件 @
055e0516
...
@@ -119,12 +119,19 @@ typedef enum EFunctionType {
...
@@ -119,12 +119,19 @@ typedef enum EFunctionType {
struct
SqlFunctionCtx
;
struct
SqlFunctionCtx
;
struct
SResultRowEntryInfo
;
struct
SResultRowEntryInfo
;
struct
STimeWindow
;
struct
STimeWindow
;
struct
SCatalog
;
typedef
struct
SFmGetFuncInfoParam
{
struct
SCatalog
*
pCtg
;
void
*
pRpc
;
const
SEpSet
*
pMgmtEps
;
}
SFmGetFuncInfoParam
;
int32_t
fmFuncMgtInit
();
int32_t
fmFuncMgtInit
();
void
fmFuncMgtDestroy
();
void
fmFuncMgtDestroy
();
int32_t
fmGetFuncInfo
(
const
char
*
pFuncName
,
int32_t
*
pFuncId
,
int32_t
*
pFuncType
);
int32_t
fmGetFuncInfo
(
SFmGetFuncInfoParam
*
pParam
,
const
char
*
pFuncName
,
int32_t
*
pFuncId
,
int32_t
*
pFuncType
);
int32_t
fmGetFuncResultType
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
);
int32_t
fmGetFuncResultType
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
);
...
...
include/libs/nodes/nodes.h
浏览文件 @
055e0516
...
@@ -48,6 +48,9 @@ extern "C" {
...
@@ -48,6 +48,9 @@ extern "C" {
(NULL == cell1 ? (node1 = NULL, false) : (node1 = cell1->pNode, true)), (NULL == cell2 ? (node2 = NULL, false) : (node2 = cell2->pNode, true)), (node1 != NULL && node2 != NULL); \
(NULL == cell1 ? (node1 = NULL, false) : (node1 = cell1->pNode, true)), (NULL == cell2 ? (node2 = NULL, false) : (node2 = cell2->pNode, true)), (node1 != NULL && node2 != NULL); \
cell1 = cell1->pNext, cell2 = cell2->pNext)
cell1 = cell1->pNext, cell2 = cell2->pNext)
#define REPLACE_LIST1_NODE(newNode) cell1->pNode = (SNode*)(newNode)
#define REPLACE_LIST2_NODE(newNode) cell2->pNode = (SNode*)(newNode)
#define FOREACH_FOR_REWRITE(node, list) \
#define FOREACH_FOR_REWRITE(node, list) \
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
...
...
include/libs/nodes/plannodes.h
浏览文件 @
055e0516
...
@@ -155,7 +155,6 @@ typedef struct SLogicSubplan {
...
@@ -155,7 +155,6 @@ typedef struct SLogicSubplan {
typedef
struct
SQueryLogicPlan
{
typedef
struct
SQueryLogicPlan
{
ENodeType
type
;
ENodeType
type
;
int32_t
totalLevel
;
SNodeList
*
pTopSubplans
;
SNodeList
*
pTopSubplans
;
}
SQueryLogicPlan
;
}
SQueryLogicPlan
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
055e0516
...
@@ -229,10 +229,10 @@ typedef struct SFillNode {
...
@@ -229,10 +229,10 @@ typedef struct SFillNode {
typedef
struct
SSelectStmt
{
typedef
struct
SSelectStmt
{
ENodeType
type
;
// QUERY_NODE_SELECT_STMT
ENodeType
type
;
// QUERY_NODE_SELECT_STMT
bool
isDistinct
;
bool
isDistinct
;
SNodeList
*
pProjectionList
;
// SNode
SNodeList
*
pProjectionList
;
SNode
*
pFromTable
;
SNode
*
pFromTable
;
SNode
*
pWhere
;
SNode
*
pWhere
;
SNodeList
*
pPartitionByList
;
// SNode
SNodeList
*
pPartitionByList
;
SNode
*
pWindow
;
SNode
*
pWindow
;
SNodeList
*
pGroupByList
;
// SGroupingSetNode
SNodeList
*
pGroupByList
;
// SGroupingSetNode
SNode
*
pHaving
;
SNode
*
pHaving
;
...
@@ -245,12 +245,14 @@ typedef struct SSelectStmt {
...
@@ -245,12 +245,14 @@ typedef struct SSelectStmt {
}
SSelectStmt
;
}
SSelectStmt
;
typedef
enum
ESetOperatorType
{
typedef
enum
ESetOperatorType
{
SET_OP_TYPE_UNION_ALL
=
1
SET_OP_TYPE_UNION_ALL
=
1
,
SET_OP_TYPE_UNION
}
ESetOperatorType
;
}
ESetOperatorType
;
typedef
struct
SSetOperator
{
typedef
struct
SSetOperator
{
ENodeType
type
;
// QUERY_NODE_SET_OPERATOR
ENodeType
type
;
// QUERY_NODE_SET_OPERATOR
ESetOperatorType
opType
;
ESetOperatorType
opType
;
SNodeList
*
pProjectionList
;
SNode
*
pLeft
;
SNode
*
pLeft
;
SNode
*
pRight
;
SNode
*
pRight
;
SNodeList
*
pOrderByList
;
// SOrderByExprNode
SNodeList
*
pOrderByList
;
// SOrderByExprNode
...
...
include/libs/planner/planner.h
浏览文件 @
055e0516
...
@@ -30,6 +30,7 @@ typedef struct SPlanContext {
...
@@ -30,6 +30,7 @@ typedef struct SPlanContext {
SNode
*
pAstRoot
;
SNode
*
pAstRoot
;
bool
topicQuery
;
bool
topicQuery
;
bool
streamQuery
;
bool
streamQuery
;
bool
rSmaQuery
;
bool
showRewrite
;
bool
showRewrite
;
int8_t
triggerType
;
int8_t
triggerType
;
int64_t
watermark
;
int64_t
watermark
;
...
...
include/util/taoserror.h
浏览文件 @
055e0516
...
@@ -614,6 +614,7 @@ int32_t* taosGetErrno();
...
@@ -614,6 +614,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x2631)
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x2631)
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2632)
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2632)
#define TSDB_CODE_PAR_ONLY_ONE_JSON_TAG TAOS_DEF_ERROR_CODE(0, 0x2633)
#define TSDB_CODE_PAR_ONLY_ONE_JSON_TAG TAOS_DEF_ERROR_CODE(0, 0x2633)
#define TSDB_CODE_PAR_INCORRECT_NUM_OF_COL TAOS_DEF_ERROR_CODE(0, 0x2634)
//planner
//planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
...
...
source/client/inc/clientInt.h
浏览文件 @
055e0516
...
@@ -306,7 +306,6 @@ void hbMgrInitMqHbRspHandle();
...
@@ -306,7 +306,6 @@ void hbMgrInitMqHbRspHandle();
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
);
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/client/inc/clientStmt.h
浏览文件 @
055e0516
...
@@ -60,6 +60,7 @@ typedef struct SStmtBindInfo {
...
@@ -60,6 +60,7 @@ typedef struct SStmtBindInfo {
}
SStmtBindInfo
;
}
SStmtBindInfo
;
typedef
struct
SStmtExecInfo
{
typedef
struct
SStmtExecInfo
{
int32_t
affectedRows
;
SRequestObj
*
pRequest
;
SRequestObj
*
pRequest
;
SHashObj
*
pVgHash
;
SHashObj
*
pVgHash
;
SHashObj
*
pBlockHash
;
SHashObj
*
pBlockHash
;
...
...
source/client/src/clientImpl.c
浏览文件 @
055e0516
...
@@ -146,7 +146,8 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj*
...
@@ -146,7 +146,8 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj*
(
*
pRequest
)
->
sqlstr
[
sqlLen
]
=
0
;
(
*
pRequest
)
->
sqlstr
[
sqlLen
]
=
0
;
(
*
pRequest
)
->
sqlLen
=
sqlLen
;
(
*
pRequest
)
->
sqlLen
=
sqlLen
;
if
(
taosHashPut
(
pTscObj
->
pRequests
,
&
(
*
pRequest
)
->
self
,
sizeof
((
*
pRequest
)
->
self
),
&
(
*
pRequest
)
->
self
,
sizeof
((
*
pRequest
)
->
self
)))
{
if
(
taosHashPut
(
pTscObj
->
pRequests
,
&
(
*
pRequest
)
->
self
,
sizeof
((
*
pRequest
)
->
self
),
&
(
*
pRequest
)
->
self
,
sizeof
((
*
pRequest
)
->
self
)))
{
destroyRequest
(
*
pRequest
);
destroyRequest
(
*
pRequest
);
*
pRequest
=
NULL
;
*
pRequest
=
NULL
;
tscError
(
"put request to request hash failed"
);
tscError
(
"put request to request hash failed"
);
...
@@ -263,7 +264,8 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
...
@@ -263,7 +264,8 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
}
}
void
setResPrecision
(
SReqResultInfo
*
pResInfo
,
int32_t
precision
)
{
void
setResPrecision
(
SReqResultInfo
*
pResInfo
,
int32_t
precision
)
{
if
(
precision
!=
TSDB_TIME_PRECISION_MILLI
&&
precision
!=
TSDB_TIME_PRECISION_MICRO
&&
precision
!=
TSDB_TIME_PRECISION_NANO
)
{
if
(
precision
!=
TSDB_TIME_PRECISION_MILLI
&&
precision
!=
TSDB_TIME_PRECISION_MICRO
&&
precision
!=
TSDB_TIME_PRECISION_NANO
)
{
return
;
return
;
}
}
...
@@ -275,7 +277,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
...
@@ -275,7 +277,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
,
.
msgSize
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
msg
=
pRequest
->
msgBuf
};
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
,
.
msgSize
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
msg
=
pRequest
->
msgBuf
};
int32_t
code
=
schedulerExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
int32_t
code
=
schedulerExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
pRequest
->
metric
.
start
,
&
res
);
pRequest
->
metric
.
start
,
&
res
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
schedulerFreeJob
(
pRequest
->
body
.
queryJob
);
schedulerFreeJob
(
pRequest
->
body
.
queryJob
);
...
@@ -300,7 +302,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
...
@@ -300,7 +302,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
}
}
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
)
{
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
)
{
SArray
*
pNodeList
=
taosArrayInit
(
4
,
sizeof
(
struct
SQueryNodeAddr
));
SArray
*
pNodeList
=
taosArrayInit
(
4
,
sizeof
(
struct
SQueryNodeAddr
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
switch
(
pQuery
->
execMode
)
{
switch
(
pQuery
->
execMode
)
{
...
@@ -328,7 +330,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
...
@@ -328,7 +330,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
if
(
!
keepQuery
)
{
if
(
!
keepQuery
)
{
qDestroyQuery
(
pQuery
);
qDestroyQuery
(
pQuery
);
}
}
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
code
)
{
pRequest
->
code
=
terrno
;
pRequest
->
code
=
terrno
;
}
}
...
@@ -336,7 +338,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
...
@@ -336,7 +338,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
return
pRequest
;
return
pRequest
;
}
}
SRequestObj
*
launchQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
)
{
SRequestObj
*
launchQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
)
{
SRequestObj
*
pRequest
=
NULL
;
SRequestObj
*
pRequest
=
NULL
;
SQuery
*
pQuery
=
NULL
;
SQuery
*
pQuery
=
NULL
;
...
@@ -522,6 +523,8 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest, int8_t connType) {
...
@@ -522,6 +523,8 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest, int8_t connType) {
connectReq
.
pid
=
htonl
(
appInfo
.
pid
);
connectReq
.
pid
=
htonl
(
appInfo
.
pid
);
connectReq
.
startTime
=
htobe64
(
appInfo
.
startTime
);
connectReq
.
startTime
=
htobe64
(
appInfo
.
startTime
);
tstrncpy
(
connectReq
.
app
,
appInfo
.
appName
,
sizeof
(
connectReq
.
app
));
tstrncpy
(
connectReq
.
app
,
appInfo
.
appName
,
sizeof
(
connectReq
.
app
));
tstrncpy
(
connectReq
.
user
,
pObj
->
user
,
sizeof
(
connectReq
.
user
));
tstrncpy
(
connectReq
.
passwd
,
pObj
->
pass
,
sizeof
(
connectReq
.
passwd
));
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
...
@@ -726,7 +729,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
...
@@ -726,7 +729,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
int32_t
len
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
pStart
),
varDataLen
(
pStart
),
varDataVal
(
p
));
int32_t
len
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
pStart
),
varDataLen
(
pStart
),
varDataVal
(
p
));
ASSERT
(
len
<=
bytes
);
ASSERT
(
len
<=
bytes
);
ASSERT
((
p
+
len
)
<
(
pResultInfo
->
convertBuf
[
i
]
+
colLength
[
i
]));
ASSERT
((
p
+
len
)
<
(
pResultInfo
->
convertBuf
[
i
]
+
colLength
[
i
]));
varDataSetLen
(
p
,
len
);
varDataSetLen
(
p
,
len
);
pCol
->
offset
[
j
]
=
(
p
-
pResultInfo
->
convertBuf
[
i
]);
pCol
->
offset
[
j
]
=
(
p
-
pResultInfo
->
convertBuf
[
i
]);
p
+=
(
len
+
VARSTR_HEADER_SIZE
);
p
+=
(
len
+
VARSTR_HEADER_SIZE
);
...
@@ -744,51 +747,55 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
...
@@ -744,51 +747,55 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
}
}
pResultInfo
->
convertBuf
[
i
]
=
p
;
pResultInfo
->
convertBuf
[
i
]
=
p
;
int32_t
len
=
0
;
int32_t
len
=
0
;
SResultColumn
*
pCol
=
&
pResultInfo
->
pCol
[
i
];
SResultColumn
*
pCol
=
&
pResultInfo
->
pCol
[
i
];
for
(
int32_t
j
=
0
;
j
<
numOfRows
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfRows
;
++
j
)
{
if
(
pCol
->
offset
[
j
]
!=
-
1
)
{
if
(
pCol
->
offset
[
j
]
!=
-
1
)
{
char
*
pStart
=
pCol
->
offset
[
j
]
+
pCol
->
pData
;
char
*
pStart
=
pCol
->
offset
[
j
]
+
pCol
->
pData
;
int32_t
jsonInnerType
=
*
pStart
;
int32_t
jsonInnerType
=
*
pStart
;
char
*
jsonInnerData
=
pStart
+
CHAR_BYTES
;
char
*
jsonInnerData
=
pStart
+
CHAR_BYTES
;
char
dst
[
TSDB_MAX_JSON_TAG_LEN
]
=
{
0
};
char
dst
[
TSDB_MAX_JSON_TAG_LEN
]
=
{
0
};
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NULL
)
{
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NULL
)
{
sprintf
(
varDataVal
(
dst
),
"%s"
,
TSDB_DATA_NULL_STR_L
);
sprintf
(
varDataVal
(
dst
),
"%s"
,
TSDB_DATA_NULL_STR_L
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_JSON
){
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
length
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
jsonInnerData
),
varDataLen
(
jsonInnerData
),
varDataVal
(
dst
));
int32_t
length
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
jsonInnerData
),
varDataLen
(
jsonInnerData
),
varDataVal
(
dst
));
if
(
length
<=
0
)
{
if
(
length
<=
0
)
{
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
varDataVal
(
jsonInnerData
));
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
varDataVal
(
jsonInnerData
));
length
=
0
;
length
=
0
;
}
}
varDataSetLen
(
dst
,
length
);
varDataSetLen
(
dst
,
length
);
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NCHAR
)
{
// value -> "value"
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NCHAR
)
{
// value -> "value"
*
(
char
*
)
varDataVal
(
dst
)
=
'\"'
;
*
(
char
*
)
varDataVal
(
dst
)
=
'\"'
;
int32_t
length
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
jsonInnerData
),
varDataLen
(
jsonInnerData
),
varDataVal
(
dst
)
+
CHAR_BYTES
);
int32_t
length
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
jsonInnerData
),
varDataLen
(
jsonInnerData
),
varDataVal
(
dst
)
+
CHAR_BYTES
);
if
(
length
<=
0
)
{
if
(
length
<=
0
)
{
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
varDataVal
(
jsonInnerData
));
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
varDataVal
(
jsonInnerData
));
length
=
0
;
length
=
0
;
}
}
varDataSetLen
(
dst
,
length
+
CHAR_BYTES
*
2
);
varDataSetLen
(
dst
,
length
+
CHAR_BYTES
*
2
);
*
(
char
*
)(
varDataVal
(
dst
),
length
+
CHAR_BYTES
)
=
'\"'
;
*
(
char
*
)(
varDataVal
(
dst
),
length
+
CHAR_BYTES
)
=
'\"'
;
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_DOUBLE
)
{
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
jsonVd
=
*
(
double
*
)(
jsonInnerData
);
double
jsonVd
=
*
(
double
*
)(
jsonInnerData
);
sprintf
(
varDataVal
(
dst
),
"%.9lf"
,
jsonVd
);
sprintf
(
varDataVal
(
dst
),
"%.9lf"
,
jsonVd
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_BIGINT
)
{
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_BIGINT
)
{
int64_t
jsonVd
=
*
(
int64_t
*
)(
jsonInnerData
);
int64_t
jsonVd
=
*
(
int64_t
*
)(
jsonInnerData
);
sprintf
(
varDataVal
(
dst
),
"%"
PRId64
,
jsonVd
);
sprintf
(
varDataVal
(
dst
),
"%"
PRId64
,
jsonVd
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_BOOL
)
{
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_BOOL
)
{
sprintf
(
varDataVal
(
dst
),
"%s"
,
(
*
((
char
*
)
jsonInnerData
)
==
1
)
?
"true"
:
"false"
);
sprintf
(
varDataVal
(
dst
),
"%s"
,
(
*
((
char
*
)
jsonInnerData
)
==
1
)
?
"true"
:
"false"
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
if
(
len
+
varDataTLen
(
dst
)
>
colLength
[
i
])
{
if
(
len
+
varDataTLen
(
dst
)
>
colLength
[
i
])
{
p
=
taosMemoryRealloc
(
pResultInfo
->
convertBuf
[
i
],
len
+
varDataTLen
(
dst
));
p
=
taosMemoryRealloc
(
pResultInfo
->
convertBuf
[
i
],
len
+
varDataTLen
(
dst
));
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
source/client/src/clientMain.c
浏览文件 @
055e0516
...
@@ -622,6 +622,10 @@ int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) {
...
@@ -622,6 +622,10 @@ int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) {
return
stmtSetTbName
(
stmt
,
name
);
return
stmtSetTbName
(
stmt
,
name
);
}
}
int
taos_stmt_set_sub_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
)
{
return
taos_stmt_set_tbname
(
stmt
,
name
);
}
int
taos_stmt_bind_param
(
TAOS_STMT
*
stmt
,
TAOS_BIND_v2
*
bind
)
{
int
taos_stmt_bind_param
(
TAOS_STMT
*
stmt
,
TAOS_BIND_v2
*
bind
)
{
if
(
stmt
==
NULL
||
bind
==
NULL
)
{
if
(
stmt
==
NULL
||
bind
==
NULL
)
{
tscError
(
"NULL parameter for %s"
,
__FUNCTION__
);
tscError
(
"NULL parameter for %s"
,
__FUNCTION__
);
...
...
source/client/src/clientStmt.c
浏览文件 @
055e0516
...
@@ -486,7 +486,8 @@ int stmtExec(TAOS_STMT *stmt) {
...
@@ -486,7 +486,8 @@ int stmtExec(TAOS_STMT *stmt) {
STMT_ERR_JRET
(
pStmt
->
exec
.
pRequest
->
code
);
STMT_ERR_JRET
(
pStmt
->
exec
.
pRequest
->
code
);
pStmt
->
affectedRows
+=
taos_affected_rows
(
pStmt
->
exec
.
pRequest
);
pStmt
->
exec
.
affectedRows
=
taos_affected_rows
(
pStmt
->
exec
.
pRequest
);
pStmt
->
affectedRows
+=
pStmt
->
exec
.
affectedRows
;
_return:
_return:
...
...
source/common/src/tdataformat.c
浏览文件 @
055e0516
...
@@ -110,7 +110,7 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) {
...
@@ -110,7 +110,7 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) {
for
(
int
i
=
0
;
i
<
numOfCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numOfCols
;
i
++
)
{
col_type_t
type
=
0
;
col_type_t
type
=
0
;
int8_t
sma
=
TSDB_BSMA_TYPE_NONE
;
int8_t
sma
=
0
;
col_id_t
colId
=
0
;
col_id_t
colId
=
0
;
col_bytes_t
bytes
=
0
;
col_bytes_t
bytes
=
0
;
buf
=
taosDecodeFixedI8
(
buf
,
&
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
type
);
...
...
source/common/src/tmsg.c
浏览文件 @
055e0516
...
@@ -482,34 +482,44 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -482,34 +482,44 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
// tlen += taosEncodeFixedU8(buf, pReq->info);
// tlen += taosEncodeFixedU8(buf, pReq->info);
switch
(
pReq
->
type
)
{
switch
(
pReq
->
type
)
{
// case TD_SUPER_TABLE:
case
TD_SUPER_TABLE
:
// tlen += taosEncodeFixedI64(buf, pReq->stbCfg.suid);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
stbCfg
.
suid
);
// tlen += taosEncodeFixedI16(buf, pReq->stbCfg.nCols);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
nCols
);
// for (col_id_t i = 0; i < pReq->stbCfg.nCols; ++i) {
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
nBSmaCols
);
// tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pSchema[i].type);
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nCols
;
++
i
)
{
// tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pSchema[i].flags);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
type
);
// tlen += taosEncodeFixedI16(buf, pReq->stbCfg.pSchema[i].colId);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
flags
);
// tlen += taosEncodeFixedI32(buf, pReq->stbCfg.pSchema[i].bytes);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
colId
);
// tlen += taosEncodeString(buf, pReq->stbCfg.pSchema[i].name);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
bytes
);
// }
tlen
+=
taosEncodeString
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
name
);
// tlen += taosEncodeFixedI16(buf, pReq->stbCfg.nTagCols);
}
// for (col_id_t i = 0; i < pReq->stbCfg.nTagCols; ++i) {
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
nTagCols
);
// tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pTagSchema[i].type);
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nTagCols
;
++
i
)
{
// tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pTagSchema[i].flags);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
type
);
// tlen += taosEncodeFixedI16(buf, pReq->stbCfg.pTagSchema[i].colId);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
flags
);
// tlen += taosEncodeFixedI32(buf, pReq->stbCfg.pTagSchema[i].bytes);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
colId
);
// tlen += taosEncodeString(buf, pReq->stbCfg.pTagSchema[i].name);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
// }
tlen
+=
taosEncodeString
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
// if (pReq->rollup && pReq->stbCfg.pRSmaParam) {
}
// SRSmaParam *param = pReq->stbCfg.pRSmaParam;
if
(
pReq
->
rollup
&&
pReq
->
stbCfg
.
pRSmaParam
)
{
// tlen += taosEncodeBinary(buf, (const void *)¶m->xFilesFactor, sizeof(param->xFilesFactor));
SRSmaParam
*
param
=
pReq
->
stbCfg
.
pRSmaParam
;
// tlen += taosEncodeFixedI32(buf, param->delay);
tlen
+=
taosEncodeBinary
(
buf
,
(
const
void
*
)
&
param
->
xFilesFactor
,
sizeof
(
param
->
xFilesFactor
));
// tlen += taosEncodeFixedI8(buf, param->nFuncIds);
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
delay
);
// for (int8_t i = 0; i < param->nFuncIds; ++i) {
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
nFuncIds
);
// tlen += taosEncodeFixedI32(buf, param->pFuncIds[i]);
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
// }
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
pFuncIds
[
i
]);
// }
}
// break;
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
qmsg1Len
);
if
(
param
->
qmsg1Len
>
0
)
{
tlen
+=
taosEncodeString
(
buf
,
param
->
qmsg1
);
}
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
qmsg2Len
);
if
(
param
->
qmsg2Len
>
0
)
{
tlen
+=
taosEncodeString
(
buf
,
param
->
qmsg2
);
}
}
break
;
case
TD_CHILD_TABLE
:
case
TD_CHILD_TABLE
:
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
ctbCfg
.
suid
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
ctbCfg
.
suid
);
tlen
+=
tdEncodeKVRow
(
buf
,
pReq
->
ctbCfg
.
pTag
);
tlen
+=
tdEncodeKVRow
(
buf
,
pReq
->
ctbCfg
.
pTag
);
...
@@ -539,44 +549,52 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -539,44 +549,52 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
// buf = taosDecodeFixedU8(buf, &(pReq->info));
// buf = taosDecodeFixedU8(buf, &(pReq->info));
switch
(
pReq
->
type
)
{
switch
(
pReq
->
type
)
{
// case TD_SUPER_TABLE:
case
TD_SUPER_TABLE
:
// buf = taosDecodeFixedI64(buf, &(pReq->stbCfg.suid));
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pReq
->
stbCfg
.
suid
));
// buf = taosDecodeFixedI16(buf, &(pReq->stbCfg.nCols));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
stbCfg
.
nCols
));
// pReq->stbCfg.pSchema = (SSchema *)taosMemoryMalloc(pReq->stbCfg.nCols * sizeof(SSchema));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
stbCfg
.
nBSmaCols
));
// for (col_id_t i = 0; i < pReq->stbCfg.nCols; ++i) {
pReq
->
stbCfg
.
pSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
stbCfg
.
nCols
*
sizeof
(
SSchema
));
// buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pSchema[i].type));
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nCols
;
++
i
)
{
// buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pSchema[i].flags));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
type
));
// buf = taosDecodeFixedI16(buf, &(pReq->stbCfg.pSchema[i].colId));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
flags
));
// buf = taosDecodeFixedI32(buf, &(pReq->stbCfg.pSchema[i].bytes));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
colId
));
// buf = taosDecodeStringTo(buf, pReq->stbCfg.pSchema[i].name);
buf
=
taosDecodeFixedI32
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
bytes
));
// }
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
name
);
// buf = taosDecodeFixedI16(buf, &pReq->stbCfg.nTagCols);
}
// pReq->stbCfg.pTagSchema = (SSchema *)taosMemoryMalloc(pReq->stbCfg.nTagCols * sizeof(SSchema));
buf
=
taosDecodeFixedI16
(
buf
,
&
pReq
->
stbCfg
.
nTagCols
);
// for (col_id_t i = 0; i < pReq->stbCfg.nTagCols; ++i) {
pReq
->
stbCfg
.
pTagSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
stbCfg
.
nTagCols
*
sizeof
(
SSchema
));
// buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].type));
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nTagCols
;
++
i
)
{
// buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].flags));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pTagSchema
[
i
].
type
));
// buf = taosDecodeFixedI16(buf, &pReq->stbCfg.pTagSchema[i].colId);
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pTagSchema
[
i
].
flags
));
// buf = taosDecodeFixedI32(buf, &pReq->stbCfg.pTagSchema[i].bytes);
buf
=
taosDecodeFixedI16
(
buf
,
&
pReq
->
stbCfg
.
pTagSchema
[
i
].
colId
);
// buf = taosDecodeStringTo(buf, pReq->stbCfg.pTagSchema[i].name);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
// }
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
// if (pReq->rollup) {
}
// pReq->stbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam));
if
(
pReq
->
rollup
)
{
// SRSmaParam *param = pReq->stbCfg.pRSmaParam;
pReq
->
stbCfg
.
pRSmaParam
=
(
SRSmaParam
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SRSmaParam
));
// buf = taosDecodeBinaryTo(buf, (void *)¶m->xFilesFactor, sizeof(param->xFilesFactor));
SRSmaParam
*
param
=
pReq
->
stbCfg
.
pRSmaParam
;
// buf = taosDecodeFixedI32(buf, ¶m->delay);
buf
=
taosDecodeBinaryTo
(
buf
,
(
void
*
)
&
param
->
xFilesFactor
,
sizeof
(
param
->
xFilesFactor
));
// buf = taosDecodeFixedI8(buf, ¶m->nFuncIds);
buf
=
taosDecodeFixedI32
(
buf
,
&
param
->
delay
);
// if (param->nFuncIds > 0) {
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
// param->pFuncIds = (func_id_t *)taosMemoryMalloc(param->nFuncIds * sizeof(func_id_t));
if
(
param
->
nFuncIds
>
0
)
{
// for (int8_t i = 0; i < param->nFuncIds; ++i) {
param
->
pFuncIds
=
(
func_id_t
*
)
taosMemoryCalloc
(
param
->
nFuncIds
,
sizeof
(
func_id_t
));
// buf = taosDecodeFixedI32(buf, param->pFuncIds + i);
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
// }
buf
=
taosDecodeFixedI32
(
buf
,
param
->
pFuncIds
+
i
);
// } else {
}
// param->pFuncIds = NULL;
}
// }
buf
=
taosDecodeFixedI32
(
buf
,
&
param
->
qmsg1Len
);
// } else {
if
(
param
->
qmsg1Len
>
0
)
{
// pReq->stbCfg.pRSmaParam = NULL;
buf
=
taosDecodeString
(
buf
,
&
param
->
qmsg1
);
// }
}
// break;
buf
=
taosDecodeFixedI32
(
buf
,
&
param
->
qmsg2Len
);
if
(
param
->
qmsg2Len
>
0
)
{
buf
=
taosDecodeString
(
buf
,
&
param
->
qmsg2
);
}
}
else
{
pReq
->
stbCfg
.
pRSmaParam
=
NULL
;
}
break
;
case
TD_CHILD_TABLE
:
case
TD_CHILD_TABLE
:
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
ctbCfg
.
suid
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
ctbCfg
.
suid
);
buf
=
tdDecodeKVRow
(
buf
,
&
pReq
->
ctbCfg
.
pTag
);
buf
=
tdDecodeKVRow
(
buf
,
&
pReq
->
ctbCfg
.
pTag
);
...
@@ -1670,6 +1688,7 @@ int32_t tSerializeSRetrieveFuncReq(void *buf, int32_t bufLen, SRetrieveFuncReq *
...
@@ -1670,6 +1688,7 @@ int32_t tSerializeSRetrieveFuncReq(void *buf, int32_t bufLen, SRetrieveFuncReq *
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfFuncs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfFuncs
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
ignoreCodeComment
)
<
0
)
return
-
1
;
if
(
pReq
->
numOfFuncs
!=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pFuncNames
))
return
-
1
;
if
(
pReq
->
numOfFuncs
!=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pFuncNames
))
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfFuncs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfFuncs
;
++
i
)
{
...
@@ -1690,6 +1709,7 @@ int32_t tDeserializeSRetrieveFuncReq(void *buf, int32_t bufLen, SRetrieveFuncReq
...
@@ -1690,6 +1709,7 @@ int32_t tDeserializeSRetrieveFuncReq(void *buf, int32_t bufLen, SRetrieveFuncReq
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfFuncs
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfFuncs
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
(
int8_t
*
)
&
pReq
->
ignoreCodeComment
)
<
0
)
return
-
1
;
pReq
->
pFuncNames
=
taosArrayInit
(
pReq
->
numOfFuncs
,
TSDB_FUNC_NAME_LEN
);
pReq
->
pFuncNames
=
taosArrayInit
(
pReq
->
numOfFuncs
,
TSDB_FUNC_NAME_LEN
);
if
(
pReq
->
pFuncNames
==
NULL
)
return
-
1
;
if
(
pReq
->
pFuncNames
==
NULL
)
return
-
1
;
...
@@ -1727,8 +1747,12 @@ int32_t tSerializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp *
...
@@ -1727,8 +1747,12 @@ int32_t tSerializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp *
if
(
tEncodeI64
(
&
encoder
,
pInfo
->
signature
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pInfo
->
signature
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
codeSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
codeSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
commentSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
commentSize
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pInfo
->
pCode
)
<
0
)
return
-
1
;
if
(
pInfo
->
codeSize
)
{
if
(
tEncodeCStr
(
&
encoder
,
pInfo
->
pComment
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pInfo
->
pCode
)
<
0
)
return
-
1
;
}
if
(
pInfo
->
commentSize
)
{
if
(
tEncodeCStr
(
&
encoder
,
pInfo
->
pComment
)
<
0
)
return
-
1
;
}
}
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
...
@@ -1759,15 +1783,23 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
...
@@ -1759,15 +1783,23 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
if
(
tDecodeI64
(
&
decoder
,
&
fInfo
.
signature
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
fInfo
.
signature
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
codeSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
codeSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
commentSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
commentSize
)
<
0
)
return
-
1
;
fInfo
.
pCode
=
taosMemoryCalloc
(
1
,
fInfo
.
codeSize
);
if
(
fInfo
.
codeSize
)
{
fInfo
.
pComment
=
taosMemoryCalloc
(
1
,
fInfo
.
commentSize
);
fInfo
.
pCode
=
taosMemoryCalloc
(
1
,
fInfo
.
codeSize
);
if
(
fInfo
.
pCode
==
NULL
||
fInfo
.
pComment
==
NULL
)
{
if
(
fInfo
.
pCode
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
if
(
tDecodeCStrTo
(
&
decoder
,
fInfo
.
pCode
)
<
0
)
return
-
1
;
}
if
(
fInfo
.
commentSize
)
{
fInfo
.
pComment
=
taosMemoryCalloc
(
1
,
fInfo
.
commentSize
);
if
(
fInfo
.
pComment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
tDecodeCStrTo
(
&
decoder
,
fInfo
.
pComment
)
<
0
)
return
-
1
;
}
}
if
(
tDecodeCStrTo
(
&
decoder
,
fInfo
.
pCode
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
fInfo
.
pComment
)
<
0
)
return
-
1
;
taosArrayPush
(
pRsp
->
pFuncInfos
,
&
fInfo
);
taosArrayPush
(
pRsp
->
pFuncInfos
,
&
fInfo
);
}
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
...
@@ -1776,12 +1808,20 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
...
@@ -1776,12 +1808,20 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
return
0
;
return
0
;
}
}
void
tFreeSFuncInfo
(
SFuncInfo
*
pInfo
)
{
if
(
NULL
==
pInfo
)
{
return
;
}
taosMemoryFree
(
pInfo
->
pCode
);
taosMemoryFree
(
pInfo
->
pComment
);
}
void
tFreeSRetrieveFuncRsp
(
SRetrieveFuncRsp
*
pRsp
)
{
void
tFreeSRetrieveFuncRsp
(
SRetrieveFuncRsp
*
pRsp
)
{
int32_t
size
=
taosArrayGetSize
(
pRsp
->
pFuncInfos
);
int32_t
size
=
taosArrayGetSize
(
pRsp
->
pFuncInfos
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SFuncInfo
*
pInfo
=
taosArrayGet
(
pRsp
->
pFuncInfos
,
i
);
SFuncInfo
*
pInfo
=
taosArrayGet
(
pRsp
->
pFuncInfos
,
i
);
taosMemoryFree
(
pInfo
->
pCode
);
tFreeSFuncInfo
(
pInfo
);
taosMemoryFree
(
pInfo
->
pComment
);
}
}
taosArrayDestroy
(
pRsp
->
pFuncInfos
);
taosArrayDestroy
(
pRsp
->
pFuncInfos
);
}
}
...
@@ -2720,6 +2760,10 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
...
@@ -2720,6 +2760,10 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTbName
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withSchema
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTag
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTagSchema
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
sqlLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
sqlLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
astLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
astLen
)
<
0
)
return
-
1
;
if
(
sqlLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
if
(
sqlLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
...
@@ -2742,6 +2786,10 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
...
@@ -2742,6 +2786,10 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTbName
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withSchema
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTag
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTagSchema
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
sqlLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
sqlLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
astLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
astLen
)
<
0
)
return
-
1
;
...
@@ -2802,6 +2850,8 @@ int32_t tSerializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
...
@@ -2802,6 +2850,8 @@ int32_t tSerializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
if
(
tEncodeI32
(
&
encoder
,
pReq
->
pid
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
pid
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
app
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
app
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
passwd
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
startTime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
startTime
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
...
@@ -2819,6 +2869,8 @@ int32_t tDeserializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
...
@@ -2819,6 +2869,8 @@ int32_t tDeserializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
pid
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
pid
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
app
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
app
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
passwd
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
startTime
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
startTime
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
...
...
source/dnode/mgmt/implement/src/dmTransport.c
浏览文件 @
055e0516
...
@@ -119,10 +119,10 @@ _OVER:
...
@@ -119,10 +119,10 @@ _OVER:
}
}
static
void
dmProcessMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
static
void
dmProcessMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
tmsg_t
msgType
=
pMsg
->
msgType
;
tmsg_t
msgType
=
pMsg
->
msgType
;
bool
isReq
=
msgType
&
1u
;
bool
isReq
=
msgType
&
1u
;
SMsgHandle
*
pHandle
=
&
pTrans
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
SMsgHandle
*
pHandle
=
&
pTrans
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
SMgmtWrapper
*
pWrapper
=
pHandle
->
pNdWrapper
;
SMgmtWrapper
*
pWrapper
=
pHandle
->
pNdWrapper
;
if
(
msgType
==
TDMT_DND_SERVER_STATUS
)
{
if
(
msgType
==
TDMT_DND_SERVER_STATUS
)
{
...
@@ -443,7 +443,7 @@ static inline int32_t dmRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *s
...
@@ -443,7 +443,7 @@ static inline int32_t dmRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *s
SAuthReq
authReq
=
{
0
};
SAuthReq
authReq
=
{
0
};
tstrncpy
(
authReq
.
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
authReq
.
user
,
user
,
TSDB_USER_LEN
);
int32_t
contLen
=
tSerializeSAuthReq
(
NULL
,
0
,
&
authReq
);
int32_t
contLen
=
tSerializeSAuthReq
(
NULL
,
0
,
&
authReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAuthReq
(
pReq
,
contLen
,
&
authReq
);
tSerializeSAuthReq
(
pReq
,
contLen
,
&
authReq
);
SRpcMsg
rpcMsg
=
{.
pCont
=
pReq
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_MND_AUTH
,
.
ahandle
=
(
void
*
)
9528
};
SRpcMsg
rpcMsg
=
{.
pCont
=
pReq
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_MND_AUTH
,
.
ahandle
=
(
void
*
)
9528
};
...
@@ -523,4 +523,4 @@ SMsgCb dmGetMsgcb(SMgmtWrapper *pWrapper) {
...
@@ -523,4 +523,4 @@ SMsgCb dmGetMsgcb(SMgmtWrapper *pWrapper) {
.
pWrapper
=
pWrapper
,
.
pWrapper
=
pWrapper
,
};
};
return
msgCb
;
return
msgCb
;
}
}
\ No newline at end of file
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
055e0516
...
@@ -418,82 +418,6 @@ typedef struct {
...
@@ -418,82 +418,6 @@ typedef struct {
char
payload
[];
char
payload
[];
}
SSysTableRetrieveObj
;
}
SSysTableRetrieveObj
;
typedef
struct
{
int32_t
vgId
;
// -1 for unassigned
int32_t
status
;
int32_t
epoch
;
SEpSet
epSet
;
int64_t
oldConsumerId
;
int64_t
consumerId
;
// -1 for unassigned
char
*
qmsg
;
}
SMqConsumerEp
;
static
FORCE_INLINE
int32_t
tEncodeSMqConsumerEp
(
void
**
buf
,
const
SMqConsumerEp
*
pConsumerEp
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pConsumerEp
->
vgId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pConsumerEp
->
status
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pConsumerEp
->
epoch
);
tlen
+=
taosEncodeSEpSet
(
buf
,
&
pConsumerEp
->
epSet
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pConsumerEp
->
oldConsumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pConsumerEp
->
consumerId
);
tlen
+=
taosEncodeString
(
buf
,
pConsumerEp
->
qmsg
);
return
tlen
;
}
static
FORCE_INLINE
void
*
tDecodeSMqConsumerEp
(
void
**
buf
,
SMqConsumerEp
*
pConsumerEp
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pConsumerEp
->
vgId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pConsumerEp
->
status
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pConsumerEp
->
epoch
);
buf
=
taosDecodeSEpSet
(
buf
,
&
pConsumerEp
->
epSet
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pConsumerEp
->
oldConsumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pConsumerEp
->
consumerId
);
buf
=
taosDecodeString
(
buf
,
&
pConsumerEp
->
qmsg
);
return
buf
;
}
static
FORCE_INLINE
void
tDeleteSMqConsumerEp
(
SMqConsumerEp
*
pConsumerEp
)
{
if
(
pConsumerEp
)
{
taosMemoryFreeClear
(
pConsumerEp
->
qmsg
);
}
}
typedef
struct
{
int64_t
consumerId
;
SArray
*
vgInfo
;
// SArray<SMqConsumerEp>
}
SMqSubConsumer
;
static
FORCE_INLINE
int32_t
tEncodeSMqSubConsumer
(
void
**
buf
,
const
SMqSubConsumer
*
pConsumer
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pConsumer
->
consumerId
);
int32_t
sz
=
taosArrayGetSize
(
pConsumer
->
vgInfo
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMqConsumerEp
*
pCEp
=
taosArrayGet
(
pConsumer
->
vgInfo
,
i
);
tlen
+=
tEncodeSMqConsumerEp
(
buf
,
pCEp
);
}
return
tlen
;
}
static
FORCE_INLINE
void
*
tDecodeSMqSubConsumer
(
void
**
buf
,
SMqSubConsumer
*
pConsumer
)
{
int32_t
sz
;
buf
=
taosDecodeFixedI64
(
buf
,
&
pConsumer
->
consumerId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pConsumer
->
vgInfo
=
taosArrayInit
(
sz
,
sizeof
(
SMqConsumerEp
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMqConsumerEp
consumerEp
;
buf
=
tDecodeSMqConsumerEp
(
buf
,
&
consumerEp
);
taosArrayPush
(
pConsumer
->
vgInfo
,
&
consumerEp
);
}
return
buf
;
}
static
FORCE_INLINE
void
tDeleteSMqSubConsumer
(
SMqSubConsumer
*
pSubConsumer
)
{
if
(
pSubConsumer
->
vgInfo
)
{
taosArrayDestroyEx
(
pSubConsumer
->
vgInfo
,
(
void
(
*
)(
void
*
))
tDeleteSMqConsumerEp
);
pSubConsumer
->
vgInfo
=
NULL
;
}
}
typedef
struct
{
typedef
struct
{
char
key
[
TSDB_PARTITION_KEY_LEN
];
char
key
[
TSDB_PARTITION_KEY_LEN
];
int64_t
offset
;
int64_t
offset
;
...
@@ -512,147 +436,21 @@ static FORCE_INLINE void* tDecodeSMqOffsetObj(void* buf, SMqOffsetObj* pOffset)
...
@@ -512,147 +436,21 @@ static FORCE_INLINE void* tDecodeSMqOffsetObj(void* buf, SMqOffsetObj* pOffset)
return
buf
;
return
buf
;
}
}
#if 0
typedef struct {
char key[TSDB_SUBSCRIBE_KEY_LEN];
int32_t status;
int32_t vgNum;
SArray* consumers; // SArray<SMqSubConsumer>
SArray* lostConsumers; // SArray<SMqSubConsumer>
SArray* unassignedVg; // SArray<SMqConsumerEp>
} SMqSubscribeObj;
static FORCE_INLINE SMqSubscribeObj* tNewSubscribeObj() {
SMqSubscribeObj* pSub = taosMemoryCalloc(1, sizeof(SMqSubscribeObj));
if (pSub == NULL) {
return NULL;
}
pSub->consumers = taosArrayInit(0, sizeof(SMqSubConsumer));
if (pSub->consumers == NULL) {
goto _err;
}
pSub->lostConsumers = taosArrayInit(0, sizeof(SMqSubConsumer));
if (pSub->lostConsumers == NULL) {
goto _err;
}
pSub->unassignedVg = taosArrayInit(0, sizeof(SMqConsumerEp));
if (pSub->unassignedVg == NULL) {
goto _err;
}
pSub->key[0] = 0;
pSub->vgNum = 0;
pSub->status = 0;
return pSub;
_err:
taosMemoryFreeClear(pSub->consumers);
taosMemoryFreeClear(pSub->lostConsumers);
taosMemoryFreeClear(pSub->unassignedVg);
taosMemoryFreeClear(pSub);
return NULL;
}
static FORCE_INLINE int32_t tEncodeSubscribeObj(void** buf, const SMqSubscribeObj* pSub) {
int32_t tlen = 0;
tlen += taosEncodeString(buf, pSub->key);
tlen += taosEncodeFixedI32(buf, pSub->vgNum);
tlen += taosEncodeFixedI32(buf, pSub->status);
int32_t sz;
sz = taosArrayGetSize(pSub->consumers);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
SMqSubConsumer* pSubConsumer = taosArrayGet(pSub->consumers, i);
tlen += tEncodeSMqSubConsumer(buf, pSubConsumer);
}
sz = taosArrayGetSize(pSub->lostConsumers);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
SMqSubConsumer* pSubConsumer = taosArrayGet(pSub->lostConsumers, i);
tlen += tEncodeSMqSubConsumer(buf, pSubConsumer);
}
sz = taosArrayGetSize(pSub->unassignedVg);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
SMqConsumerEp* pCEp = taosArrayGet(pSub->unassignedVg, i);
tlen += tEncodeSMqConsumerEp(buf, pCEp);
}
return tlen;
}
static FORCE_INLINE void* tDecodeSubscribeObj(void* buf, SMqSubscribeObj* pSub) {
buf = taosDecodeStringTo(buf, pSub->key);
buf = taosDecodeFixedI32(buf, &pSub->vgNum);
buf = taosDecodeFixedI32(buf, &pSub->status);
int32_t sz;
buf = taosDecodeFixedI32(buf, &sz);
pSub->consumers = taosArrayInit(sz, sizeof(SMqSubConsumer));
if (pSub->consumers == NULL) {
return NULL;
}
for (int32_t i = 0; i < sz; i++) {
SMqSubConsumer subConsumer = {0};
buf = tDecodeSMqSubConsumer(buf, &subConsumer);
taosArrayPush(pSub->consumers, &subConsumer);
}
buf = taosDecodeFixedI32(buf, &sz);
pSub->lostConsumers = taosArrayInit(sz, sizeof(SMqSubConsumer));
if (pSub->lostConsumers == NULL) {
return NULL;
}
for (int32_t i = 0; i < sz; i++) {
SMqSubConsumer subConsumer = {0};
buf = tDecodeSMqSubConsumer(buf, &subConsumer);
taosArrayPush(pSub->lostConsumers, &subConsumer);
}
buf = taosDecodeFixedI32(buf, &sz);
pSub->unassignedVg = taosArrayInit(sz, sizeof(SMqConsumerEp));
if (pSub->unassignedVg == NULL) {
return NULL;
}
for (int32_t i = 0; i < sz; i++) {
SMqConsumerEp consumerEp = {0};
buf = tDecodeSMqConsumerEp(buf, &consumerEp);
taosArrayPush(pSub->unassignedVg, &consumerEp);
}
return buf;
}
static FORCE_INLINE void tDeleteSMqSubscribeObj(SMqSubscribeObj* pSub) {
if (pSub->consumers) {
// taosArrayDestroyEx(pSub->consumers, (void (*)(void*))tDeleteSMqSubConsumer);
// taosArrayDestroy(pSub->consumers);
pSub->consumers = NULL;
}
if (pSub->unassignedVg) {
// taosArrayDestroyEx(pSub->unassignedVg, (void (*)(void*))tDeleteSMqConsumerEp);
// taosArrayDestroy(pSub->unassignedVg);
pSub->unassignedVg = NULL;
}
}
#endif
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
createTime
;
int64_t
createTime
;
int64_t
updateTime
;
int64_t
updateTime
;
int64_t
uid
;
int64_t
uid
;
// TODO: use subDbUid
int64_t
dbUid
;
int64_t
dbUid
;
int64_t
subDbUid
;
int32_t
version
;
int32_t
version
;
int8_t
subType
;
// db or table
int8_t
withTbName
;
int8_t
withSchema
;
int8_t
withTag
;
int8_t
withTagSchema
;
SRWLatch
lock
;
SRWLatch
lock
;
int32_t
sqlLen
;
int32_t
sqlLen
;
int32_t
astLen
;
int32_t
astLen
;
...
@@ -662,79 +460,6 @@ typedef struct {
...
@@ -662,79 +460,6 @@ typedef struct {
SSchemaWrapper
schema
;
SSchemaWrapper
schema
;
}
SMqTopicObj
;
}
SMqTopicObj
;
#if 0
typedef struct {
int64_t consumerId;
int64_t connId;
SRWLatch lock;
char cgroup[TSDB_CGROUP_LEN];
SArray* currentTopics; // SArray<char*>
SArray* recentRemovedTopics; // SArray<char*>
int32_t epoch;
// stat
int64_t pollCnt;
// status
int32_t status;
// heartbeat from the consumer reset hbStatus to 0
// each checkConsumerAlive msg add hbStatus by 1
// if checkConsumerAlive > CONSUMER_REBALANCE_CNT, mask to lost
int32_t hbStatus;
} SMqConsumerObj;
static FORCE_INLINE int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer) {
int32_t sz;
int32_t tlen = 0;
tlen += taosEncodeFixedI64(buf, pConsumer->consumerId);
tlen += taosEncodeFixedI64(buf, pConsumer->connId);
tlen += taosEncodeFixedI32(buf, pConsumer->epoch);
tlen += taosEncodeFixedI64(buf, pConsumer->pollCnt);
tlen += taosEncodeFixedI32(buf, pConsumer->status);
tlen += taosEncodeString(buf, pConsumer->cgroup);
sz = taosArrayGetSize(pConsumer->currentTopics);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
char* topic = taosArrayGetP(pConsumer->currentTopics, i);
tlen += taosEncodeString(buf, topic);
}
sz = taosArrayGetSize(pConsumer->recentRemovedTopics);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
char* topic = taosArrayGetP(pConsumer->recentRemovedTopics, i);
tlen += taosEncodeString(buf, topic);
}
return tlen;
}
static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pConsumer) {
int32_t sz;
buf = taosDecodeFixedI64(buf, &pConsumer->consumerId);
buf = taosDecodeFixedI64(buf, &pConsumer->connId);
buf = taosDecodeFixedI32(buf, &pConsumer->epoch);
buf = taosDecodeFixedI64(buf, &pConsumer->pollCnt);
buf = taosDecodeFixedI32(buf, &pConsumer->status);
buf = taosDecodeStringTo(buf, pConsumer->cgroup);
buf = taosDecodeFixedI32(buf, &sz);
pConsumer->currentTopics = taosArrayInit(sz, sizeof(void*));
for (int32_t i = 0; i < sz; i++) {
char* topic;
buf = taosDecodeString(buf, &topic);
taosArrayPush(pConsumer->currentTopics, &topic);
}
buf = taosDecodeFixedI32(buf, &sz);
pConsumer->recentRemovedTopics = taosArrayInit(sz, sizeof(void*));
for (int32_t i = 0; i < sz; i++) {
char* topic;
buf = taosDecodeString(buf, &topic);
taosArrayPush(pConsumer->recentRemovedTopics, &topic);
}
return buf;
}
#endif
enum
{
enum
{
CONSUMER_UPDATE__TOUCH
=
1
,
CONSUMER_UPDATE__TOUCH
=
1
,
CONSUMER_UPDATE__ADD
,
CONSUMER_UPDATE__ADD
,
...
@@ -753,12 +478,9 @@ typedef struct {
...
@@ -753,12 +478,9 @@ typedef struct {
int32_t
hbStatus
;
int32_t
hbStatus
;
// lock is used for topics update
// lock is used for topics update
SRWLatch
lock
;
SRWLatch
lock
;
SArray
*
currentTopics
;
// SArray<char*>
SArray
*
currentTopics
;
// SArray<char*>
#if 0
SArray
*
rebNewTopics
;
// SArray<char*>
SArray* waitingRebTopics; // SArray<char*>
SArray
*
rebRemovedTopics
;
// SArray<char*>
#endif
SArray
*
rebNewTopics
;
// SArray<char*>
SArray
*
rebRemovedTopics
;
// SArray<char*>
}
SMqConsumerObj
;
}
SMqConsumerObj
;
SMqConsumerObj
*
tNewSMqConsumerObj
(
int64_t
consumerId
,
char
cgroup
[
TSDB_CGROUP_LEN
]);
SMqConsumerObj
*
tNewSMqConsumerObj
(
int64_t
consumerId
,
char
cgroup
[
TSDB_CGROUP_LEN
]);
...
@@ -769,8 +491,7 @@ void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer
...
@@ -769,8 +491,7 @@ void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
int32_t
vgId
;
char
*
qmsg
;
char
*
qmsg
;
// char topic[TSDB_TOPIC_FNAME_LEN];
SEpSet
epSet
;
SEpSet
epSet
;
}
SMqVgEp
;
}
SMqVgEp
;
SMqVgEp
*
tCloneSMqVgEp
(
const
SMqVgEp
*
pVgEp
);
SMqVgEp
*
tCloneSMqVgEp
(
const
SMqVgEp
*
pVgEp
);
...
@@ -792,7 +513,14 @@ typedef struct {
...
@@ -792,7 +513,14 @@ typedef struct {
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
];
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
];
SRWLatch
lock
;
SRWLatch
lock
;
int32_t
vgNum
;
int32_t
vgNum
;
int8_t
subType
;
int8_t
withTbName
;
int8_t
withSchema
;
int8_t
withTag
;
int8_t
withTagSchema
;
SHashObj
*
consumerHash
;
// consumerId -> SMqConsumerEpInSub
SHashObj
*
consumerHash
;
// consumerId -> SMqConsumerEpInSub
// TODO put -1 into unassignVgs
// SArray* unassignedVgs;
}
SMqSubscribeObj
;
}
SMqSubscribeObj
;
SMqSubscribeObj
*
tNewSubscribeObj
(
const
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
]);
SMqSubscribeObj
*
tNewSubscribeObj
(
const
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
]);
...
@@ -821,18 +549,6 @@ void tDeleteSMqSubActionLogObj(SMqSubActionLogObj* pLog);
...
@@ -821,18 +549,6 @@ void tDeleteSMqSubActionLogObj(SMqSubActionLogObj* pLog);
int32_t
tEncodeSMqSubActionLogObj
(
void
**
buf
,
const
SMqSubActionLogObj
*
pLog
);
int32_t
tEncodeSMqSubActionLogObj
(
void
**
buf
,
const
SMqSubActionLogObj
*
pLog
);
void
*
tDecodeSMqSubActionLogObj
(
const
void
*
buf
,
SMqSubActionLogObj
*
pLog
);
void
*
tDecodeSMqSubActionLogObj
(
const
void
*
buf
,
SMqSubActionLogObj
*
pLog
);
typedef
struct
{
int64_t
consumerId
;
char
cgroup
[
TSDB_CGROUP_LEN
];
SRWLatch
lock
;
SArray
*
vgs
;
// SArray<SMqVgEp*>
}
SMqConsumerEpObj
;
SMqConsumerEpObj
*
tCloneSMqConsumerEpObj
(
const
SMqConsumerEpObj
*
pConsumerEp
);
void
tDeleteSMqConsumerEpObj
(
SMqConsumerEpObj
*
pConsumerEp
);
int32_t
tEncodeSMqConsumerEpObj
(
void
**
buf
,
const
SMqConsumerEpObj
*
pConsumerEp
);
void
*
tDecodeSMqConsumerEpObj
(
const
void
*
buf
,
SMqConsumerEpObj
*
pConsumerEp
);
typedef
struct
{
typedef
struct
{
const
SMqSubscribeObj
*
pOldSub
;
const
SMqSubscribeObj
*
pOldSub
;
const
SMqTopicObj
*
pTopic
;
const
SMqTopicObj
*
pTopic
;
...
@@ -845,12 +561,6 @@ typedef struct {
...
@@ -845,12 +561,6 @@ typedef struct {
SMqVgEp
*
pVgEp
;
SMqVgEp
*
pVgEp
;
}
SMqRebOutputVg
;
}
SMqRebOutputVg
;
#if 0
typedef struct {
int64_t consumerId;
} SMqRebOutputConsumer;
#endif
typedef
struct
{
typedef
struct
{
SArray
*
rebVgs
;
// SArray<SMqRebOutputVg>
SArray
*
rebVgs
;
// SArray<SMqRebOutputVg>
SArray
*
newConsumers
;
// SArray<int64_t>
SArray
*
newConsumers
;
// SArray<int64_t>
...
...
source/dnode/mnode/impl/inc/mndScheduler.h
浏览文件 @
055e0516
...
@@ -29,6 +29,8 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
...
@@ -29,6 +29,8 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
int32_t
mndScheduleStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndScheduleStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndConvertRSmaTask
(
const
char
*
ast
,
int8_t
triggerType
,
int64_t
watermark
,
char
**
pStr
,
int32_t
*
pLen
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
055e0516
...
@@ -851,6 +851,8 @@ static int32_t mndProcessGetDbCfgReq(SNodeMsg *pReq) {
...
@@ -851,6 +851,8 @@ static int32_t mndProcessGetDbCfgReq(SNodeMsg *pReq) {
cfgRsp
.
cacheLastRow
=
pDb
->
cfg
.
cacheLastRow
;
cfgRsp
.
cacheLastRow
=
pDb
->
cfg
.
cacheLastRow
;
cfgRsp
.
streamMode
=
pDb
->
cfg
.
streamMode
;
cfgRsp
.
streamMode
=
pDb
->
cfg
.
streamMode
;
cfgRsp
.
singleSTable
=
pDb
->
cfg
.
singleSTable
;
cfgRsp
.
singleSTable
=
pDb
->
cfg
.
singleSTable
;
cfgRsp
.
numOfRetensions
=
pDb
->
cfg
.
numOfRetensions
;
cfgRsp
.
pRetensions
=
pDb
->
cfg
.
pRetensions
;
int32_t
contLen
=
tSerializeSDbCfgRsp
(
NULL
,
0
,
&
cfgRsp
);
int32_t
contLen
=
tSerializeSDbCfgRsp
(
NULL
,
0
,
&
cfgRsp
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
055e0516
...
@@ -32,9 +32,6 @@ SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_L
...
@@ -32,9 +32,6 @@ SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_L
taosInitRWLatch
(
&
pConsumer
->
lock
);
taosInitRWLatch
(
&
pConsumer
->
lock
);
pConsumer
->
currentTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
pConsumer
->
currentTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
#if 0
pConsumer->waitingRebTopics = NULL;
#endif
pConsumer
->
rebNewTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
pConsumer
->
rebNewTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
pConsumer
->
rebRemovedTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
pConsumer
->
rebRemovedTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
...
@@ -53,11 +50,6 @@ void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) {
...
@@ -53,11 +50,6 @@ void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) {
if
(
pConsumer
->
currentTopics
)
{
if
(
pConsumer
->
currentTopics
)
{
taosArrayDestroyP
(
pConsumer
->
currentTopics
,
(
FDelete
)
taosMemoryFree
);
taosArrayDestroyP
(
pConsumer
->
currentTopics
,
(
FDelete
)
taosMemoryFree
);
}
}
#if 0
if (pConsumer->waitingRebTopics) {
taosArrayDestroyP(pConsumer->waitingRebTopics, taosMemoryFree);
}
#endif
if
(
pConsumer
->
rebNewTopics
)
{
if
(
pConsumer
->
rebNewTopics
)
{
taosArrayDestroyP
(
pConsumer
->
rebNewTopics
,
(
FDelete
)
taosMemoryFree
);
taosArrayDestroyP
(
pConsumer
->
rebNewTopics
,
(
FDelete
)
taosMemoryFree
);
}
}
...
@@ -87,20 +79,6 @@ int32_t tEncodeSMqConsumerObj(void **buf, const SMqConsumerObj *pConsumer) {
...
@@ -87,20 +79,6 @@ int32_t tEncodeSMqConsumerObj(void **buf, const SMqConsumerObj *pConsumer) {
tlen
+=
taosEncodeFixedI32
(
buf
,
0
);
tlen
+=
taosEncodeFixedI32
(
buf
,
0
);
}
}
#if 0
// waiting reb topics
if (pConsumer->waitingRebTopics) {
sz = taosArrayGetSize(pConsumer->waitingRebTopics);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
char *topic = taosArrayGetP(pConsumer->waitingRebTopics, i);
tlen += taosEncodeString(buf, topic);
}
} else {
tlen += taosEncodeFixedI32(buf, 0);
}
#endif
// reb new topics
// reb new topics
if
(
pConsumer
->
rebNewTopics
)
{
if
(
pConsumer
->
rebNewTopics
)
{
sz
=
taosArrayGetSize
(
pConsumer
->
rebNewTopics
);
sz
=
taosArrayGetSize
(
pConsumer
->
rebNewTopics
);
...
@@ -145,17 +123,6 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer) {
...
@@ -145,17 +123,6 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer) {
taosArrayPush
(
pConsumer
->
currentTopics
,
&
topic
);
taosArrayPush
(
pConsumer
->
currentTopics
,
&
topic
);
}
}
#if 0
// waiting reb topics
buf = taosDecodeFixedI32(buf, &sz);
pConsumer->waitingRebTopics = taosArrayInit(sz, sizeof(void *));
for (int32_t i = 0; i < sz; i++) {
char *topic;
buf = taosDecodeString(buf, &topic);
taosArrayPush(pConsumer->waitingRebTopics, &topic);
}
#endif
// reb new topics
// reb new topics
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pConsumer
->
rebNewTopics
=
taosArrayInit
(
sz
,
sizeof
(
void
*
));
pConsumer
->
rebNewTopics
=
taosArrayInit
(
sz
,
sizeof
(
void
*
));
...
@@ -182,7 +149,6 @@ SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) {
...
@@ -182,7 +149,6 @@ SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) {
if
(
pVgEpNew
==
NULL
)
return
NULL
;
if
(
pVgEpNew
==
NULL
)
return
NULL
;
pVgEpNew
->
vgId
=
pVgEp
->
vgId
;
pVgEpNew
->
vgId
=
pVgEp
->
vgId
;
pVgEpNew
->
qmsg
=
strdup
(
pVgEp
->
qmsg
);
pVgEpNew
->
qmsg
=
strdup
(
pVgEp
->
qmsg
);
/*memcpy(pVgEpNew->topic, pVgEp->topic, TSDB_TOPIC_FNAME_LEN);*/
pVgEpNew
->
epSet
=
pVgEp
->
epSet
;
pVgEpNew
->
epSet
=
pVgEp
->
epSet
;
return
pVgEpNew
;
return
pVgEpNew
;
}
}
...
@@ -193,7 +159,6 @@ int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
...
@@ -193,7 +159,6 @@ int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pVgEp
->
vgId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pVgEp
->
vgId
);
tlen
+=
taosEncodeString
(
buf
,
pVgEp
->
qmsg
);
tlen
+=
taosEncodeString
(
buf
,
pVgEp
->
qmsg
);
/*tlen += taosEncodeString(buf, pVgEp->topic);*/
tlen
+=
taosEncodeSEpSet
(
buf
,
&
pVgEp
->
epSet
);
tlen
+=
taosEncodeSEpSet
(
buf
,
&
pVgEp
->
epSet
);
return
tlen
;
return
tlen
;
}
}
...
@@ -201,40 +166,10 @@ int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
...
@@ -201,40 +166,10 @@ int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
void
*
tDecodeSMqVgEp
(
const
void
*
buf
,
SMqVgEp
*
pVgEp
)
{
void
*
tDecodeSMqVgEp
(
const
void
*
buf
,
SMqVgEp
*
pVgEp
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pVgEp
->
vgId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pVgEp
->
vgId
);
buf
=
taosDecodeString
(
buf
,
&
pVgEp
->
qmsg
);
buf
=
taosDecodeString
(
buf
,
&
pVgEp
->
qmsg
);
/*buf = taosDecodeStringTo(buf, pVgEp->topic);*/
buf
=
taosDecodeSEpSet
(
buf
,
&
pVgEp
->
epSet
);
buf
=
taosDecodeSEpSet
(
buf
,
&
pVgEp
->
epSet
);
return
(
void
*
)
buf
;
return
(
void
*
)
buf
;
}
}
SMqConsumerEpObj
*
tCloneSMqConsumerEpObj
(
const
SMqConsumerEpObj
*
pConsumerEp
)
{
SMqConsumerEpObj
*
pConsumerEpNew
=
taosMemoryMalloc
(
sizeof
(
SMqConsumerEpObj
));
if
(
pConsumerEpNew
==
NULL
)
return
NULL
;
pConsumerEpNew
->
consumerId
=
pConsumerEp
->
consumerId
;
memcpy
(
pConsumerEpNew
->
cgroup
,
pConsumerEp
->
cgroup
,
TSDB_CGROUP_LEN
);
taosInitRWLatch
(
&
pConsumerEpNew
->
lock
);
pConsumerEpNew
->
vgs
=
taosArrayDeepCopy
(
pConsumerEpNew
->
vgs
,
(
FCopy
)
tCloneSMqVgEp
);
return
pConsumerEpNew
;
}
void
tDeleteSMqConsumerEpObj
(
SMqConsumerEpObj
*
pConsumerEp
)
{
taosArrayDestroyEx
(
pConsumerEp
->
vgs
,
(
FDelete
)
tDeleteSMqVgEp
);
}
int32_t
tEncodeSMqConsumerEpObj
(
void
**
buf
,
const
SMqConsumerEpObj
*
pConsumerEp
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pConsumerEp
->
consumerId
);
tlen
+=
taosEncodeString
(
buf
,
pConsumerEp
->
cgroup
);
tlen
+=
taosEncodeArray
(
buf
,
pConsumerEp
->
vgs
,
(
FEncode
)
tEncodeSMqVgEp
);
return
tlen
;
}
void
*
tDecodeSMqConsumerEpObj
(
const
void
*
buf
,
SMqConsumerEpObj
*
pConsumerEp
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pConsumerEp
->
consumerId
);
buf
=
taosDecodeStringTo
(
buf
,
pConsumerEp
->
cgroup
);
buf
=
taosDecodeArray
(
buf
,
&
pConsumerEp
->
vgs
,
(
FDecode
)
tDecodeSMqVgEp
,
sizeof
(
SMqSubVgEp
));
return
(
void
*
)
buf
;
}
SMqConsumerEpInSub
*
tCloneSMqConsumerEpInSub
(
const
SMqConsumerEpInSub
*
pEpInSub
)
{
SMqConsumerEpInSub
*
tCloneSMqConsumerEpInSub
(
const
SMqConsumerEpInSub
*
pEpInSub
)
{
SMqConsumerEpInSub
*
pEpInSubNew
=
taosMemoryMalloc
(
sizeof
(
SMqConsumerEpInSub
));
SMqConsumerEpInSub
*
pEpInSubNew
=
taosMemoryMalloc
(
sizeof
(
SMqConsumerEpInSub
));
if
(
pEpInSubNew
==
NULL
)
return
NULL
;
if
(
pEpInSubNew
==
NULL
)
return
NULL
;
...
@@ -276,7 +211,7 @@ void *tDecodeSMqConsumerEpInSub(const void *buf, SMqConsumerEpInSub *pEpInSub) {
...
@@ -276,7 +211,7 @@ void *tDecodeSMqConsumerEpInSub(const void *buf, SMqConsumerEpInSub *pEpInSub) {
}
}
SMqSubscribeObj
*
tNewSubscribeObj
(
const
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
])
{
SMqSubscribeObj
*
tNewSubscribeObj
(
const
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
])
{
SMqSubscribeObj
*
pSubNew
=
taosMemory
Malloc
(
sizeof
(
SMqSubscribeObj
));
SMqSubscribeObj
*
pSubNew
=
taosMemory
Calloc
(
1
,
sizeof
(
SMqSubscribeObj
));
if
(
pSubNew
==
NULL
)
return
NULL
;
if
(
pSubNew
==
NULL
)
return
NULL
;
memcpy
(
pSubNew
->
key
,
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
memcpy
(
pSubNew
->
key
,
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
taosInitRWLatch
(
&
pSubNew
->
lock
);
taosInitRWLatch
(
&
pSubNew
->
lock
);
...
@@ -297,8 +232,14 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
...
@@ -297,8 +232,14 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
if
(
pSubNew
==
NULL
)
return
NULL
;
if
(
pSubNew
==
NULL
)
return
NULL
;
memcpy
(
pSubNew
->
key
,
pSub
->
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
memcpy
(
pSubNew
->
key
,
pSub
->
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
taosInitRWLatch
(
&
pSubNew
->
lock
);
taosInitRWLatch
(
&
pSubNew
->
lock
);
pSubNew
->
subType
=
pSub
->
subType
;
pSubNew
->
withTbName
=
pSub
->
withTbName
;
pSubNew
->
withSchema
=
pSub
->
withSchema
;
pSubNew
->
withTag
=
pSub
->
withTag
;
pSubNew
->
withTagSchema
=
pSub
->
withTagSchema
;
pSubNew
->
vgNum
=
pSub
->
vgNum
;
pSubNew
->
vgNum
=
pSub
->
vgNum
;
/*pSubNew->consumerEps = taosArrayDeepCopy(pSub->consumerEps, (FCopy)tCloneSMqConsumerEpInSub);*/
pSubNew
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
pSubNew
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
/*taosHashSetFreeFp(pSubNew->consumerHash, taosArrayDestroy);*/
/*taosHashSetFreeFp(pSubNew->consumerHash, taosArrayDestroy);*/
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
...
@@ -325,6 +266,11 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
...
@@ -325,6 +266,11 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeString
(
buf
,
pSub
->
key
);
tlen
+=
taosEncodeString
(
buf
,
pSub
->
key
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSub
->
vgNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSub
->
vgNum
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
subType
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
withTbName
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
withSchema
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
withTag
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
withTagSchema
);
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
sz
=
taosHashGetSize
(
pSub
->
consumerHash
);
int32_t
sz
=
taosHashGetSize
(
pSub
->
consumerHash
);
...
@@ -347,6 +293,11 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
...
@@ -347,6 +293,11 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
//
//
buf
=
taosDecodeStringTo
(
buf
,
pSub
->
key
);
buf
=
taosDecodeStringTo
(
buf
,
pSub
->
key
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSub
->
vgNum
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSub
->
vgNum
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
subType
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
withTbName
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
withSchema
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
withTag
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
withTagSchema
);
int32_t
sz
;
int32_t
sz
;
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
055e0516
...
@@ -427,7 +427,6 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) {
...
@@ -427,7 +427,6 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) {
SFuncObj
*
pFunc
=
mndAcquireFunc
(
pMnode
,
funcName
);
SFuncObj
*
pFunc
=
mndAcquireFunc
(
pMnode
,
funcName
);
if
(
pFunc
==
NULL
)
{
if
(
pFunc
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC
;
goto
RETRIEVE_FUNC_OVER
;
goto
RETRIEVE_FUNC_OVER
;
}
}
...
@@ -439,21 +438,26 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) {
...
@@ -439,21 +438,26 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) {
funcInfo
.
outputLen
=
pFunc
->
outputLen
;
funcInfo
.
outputLen
=
pFunc
->
outputLen
;
funcInfo
.
bufSize
=
pFunc
->
bufSize
;
funcInfo
.
bufSize
=
pFunc
->
bufSize
;
funcInfo
.
signature
=
pFunc
->
signature
;
funcInfo
.
signature
=
pFunc
->
signature
;
funcInfo
.
commentSize
=
pFunc
->
commentSize
;
if
(
retrieveReq
.
ignoreCodeComment
)
{
funcInfo
.
codeSize
=
pFunc
->
codeSize
;
funcInfo
.
commentSize
=
0
;
funcInfo
.
pCode
=
taosMemoryCalloc
(
1
,
funcInfo
.
codeSize
);
funcInfo
.
codeSize
=
0
;
if
(
funcInfo
.
pCode
==
NULL
)
{
}
else
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
funcInfo
.
commentSize
=
pFunc
->
commentSize
;
goto
RETRIEVE_FUNC_OVER
;
funcInfo
.
codeSize
=
pFunc
->
codeSize
;
}
funcInfo
.
pCode
=
taosMemoryCalloc
(
1
,
funcInfo
.
codeSize
);
memcpy
(
funcInfo
.
pCode
,
pFunc
->
pCode
,
pFunc
->
codeSize
);
if
(
funcInfo
.
pCode
==
NULL
)
{
if
(
funcInfo
.
commentSize
>
0
)
{
funcInfo
.
pComment
=
taosMemoryCalloc
(
1
,
funcInfo
.
commentSize
);
if
(
funcInfo
.
pComment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
RETRIEVE_FUNC_OVER
;
goto
RETRIEVE_FUNC_OVER
;
}
}
memcpy
(
funcInfo
.
pComment
,
pFunc
->
pComment
,
pFunc
->
commentSize
);
memcpy
(
funcInfo
.
pCode
,
pFunc
->
pCode
,
pFunc
->
codeSize
);
if
(
funcInfo
.
commentSize
>
0
)
{
funcInfo
.
pComment
=
taosMemoryCalloc
(
1
,
funcInfo
.
commentSize
);
if
(
funcInfo
.
pComment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
RETRIEVE_FUNC_OVER
;
}
memcpy
(
funcInfo
.
pComment
,
pFunc
->
pComment
,
pFunc
->
commentSize
);
}
}
}
taosArrayPush
(
retrieveRsp
.
pFuncInfos
,
&
funcInfo
);
taosArrayPush
(
retrieveRsp
.
pFuncInfos
,
&
funcInfo
);
mndReleaseFunc
(
pMnode
,
pFunc
);
mndReleaseFunc
(
pMnode
,
pFunc
);
...
@@ -518,11 +522,16 @@ static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
...
@@ -518,11 +522,16 @@ static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b1
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b1
,
false
);
char
*
b2
=
taosMemoryCalloc
(
1
,
pShow
->
bytes
[
cols
]);
if
(
pFunc
->
pComment
)
{
STR_WITH_MAXSIZE_TO_VARSTR
(
b2
,
pFunc
->
pComment
,
pShow
->
bytes
[
cols
]);
char
*
b2
=
taosMemoryCalloc
(
1
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
b2
,
pFunc
->
pComment
,
pShow
->
bytes
[
cols
]);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b2
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b2
,
false
);
}
else
{
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
NULL
,
true
);
}
int32_t
isAgg
=
(
pFunc
->
funcType
==
TSDB_FUNC_TYPE_AGGREGATE
)
?
1
:
0
;
int32_t
isAgg
=
(
pFunc
->
funcType
==
TSDB_FUNC_TYPE_AGGREGATE
)
?
1
:
0
;
...
@@ -556,4 +565,4 @@ static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
...
@@ -556,4 +565,4 @@ static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
static
void
mndCancelGetNextFunc
(
SMnode
*
pMnode
,
void
*
pIter
)
{
static
void
mndCancelGetNextFunc
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
}
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndInfoSchema.c
浏览文件 @
055e0516
...
@@ -98,7 +98,7 @@ static const SInfosTableSchema userFuncSchema[] = {
...
@@ -98,7 +98,7 @@ static const SInfosTableSchema userFuncSchema[] = {
{.
name
=
"name"
,
.
bytes
=
TSDB_FUNC_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"name"
,
.
bytes
=
TSDB_FUNC_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"comment"
,
.
bytes
=
PATH_MAX
-
1
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"comment"
,
.
bytes
=
PATH_MAX
-
1
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"aggregate"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"aggregate"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"
comment
"
,
.
bytes
=
TSDB_TYPE_STR_MAX_LEN
-
1
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"
output_type
"
,
.
bytes
=
TSDB_TYPE_STR_MAX_LEN
-
1
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"code_len"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"code_len"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"bufsize"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"bufsize"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
...
...
source/dnode/mnode/impl/src/mndOffset.c
浏览文件 @
055e0516
...
@@ -133,9 +133,9 @@ OFFSET_DECODE_OVER:
...
@@ -133,9 +133,9 @@ OFFSET_DECODE_OVER:
int32_t
mndCreateOffsets
(
STrans
*
pTrans
,
const
char
*
cgroup
,
const
char
*
topicName
,
const
SArray
*
vgs
)
{
int32_t
mndCreateOffsets
(
STrans
*
pTrans
,
const
char
*
cgroup
,
const
char
*
topicName
,
const
SArray
*
vgs
)
{
int32_t
sz
=
taosArrayGetSize
(
vgs
);
int32_t
sz
=
taosArrayGetSize
(
vgs
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMqConsumerEp
*
pConsumerEp
=
taosArrayGet
(
vgs
,
i
);
int32_t
vgId
=
*
(
int32_t
*
)
taosArrayGet
(
vgs
,
i
);
SMqOffsetObj
offsetObj
;
SMqOffsetObj
offsetObj
;
if
(
mndMakePartitionKey
(
offsetObj
.
key
,
cgroup
,
topicName
,
pConsumerEp
->
vgId
)
<
0
)
{
if
(
mndMakePartitionKey
(
offsetObj
.
key
,
cgroup
,
topicName
,
vgId
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
offsetObj
.
offset
=
-
1
;
offsetObj
.
offset
=
-
1
;
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
055e0516
...
@@ -24,20 +24,20 @@
...
@@ -24,20 +24,20 @@
#include "version.h"
#include "version.h"
typedef
struct
{
typedef
struct
{
uint32_t
id
;
uint32_t
id
;
int8_t
connType
;
int8_t
connType
;
char
user
[
TSDB_USER_LEN
];
char
user
[
TSDB_USER_LEN
];
char
app
[
TSDB_APP_NAME_LEN
];
// app name that invokes taosc
char
app
[
TSDB_APP_NAME_LEN
];
// app name that invokes taosc
int64_t
appStartTimeMs
;
// app start time
int64_t
appStartTimeMs
;
// app start time
int32_t
pid
;
// pid of app that invokes taosc
int32_t
pid
;
// pid of app that invokes taosc
uint32_t
ip
;
uint32_t
ip
;
uint16_t
port
;
uint16_t
port
;
int8_t
killed
;
int8_t
killed
;
int64_t
loginTimeMs
;
int64_t
loginTimeMs
;
int64_t
lastAccessTimeMs
;
int64_t
lastAccessTimeMs
;
uint64_t
killId
;
uint64_t
killId
;
int32_t
numOfQueries
;
int32_t
numOfQueries
;
SArray
*
pQueries
;
//
SArray<SQueryDesc>
SArray
*
pQueries
;
//
SArray<SQueryDesc>
}
SConnObj
;
}
SConnObj
;
static
SConnObj
*
mndCreateConn
(
SMnode
*
pMnode
,
const
char
*
user
,
int8_t
connType
,
uint32_t
ip
,
uint16_t
port
,
static
SConnObj
*
mndCreateConn
(
SMnode
*
pMnode
,
const
char
*
user
,
int8_t
connType
,
uint32_t
ip
,
uint16_t
port
,
...
@@ -45,7 +45,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
...
@@ -45,7 +45,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
static
void
mndFreeConn
(
SConnObj
*
pConn
);
static
void
mndFreeConn
(
SConnObj
*
pConn
);
static
SConnObj
*
mndAcquireConn
(
SMnode
*
pMnode
,
uint32_t
connId
);
static
SConnObj
*
mndAcquireConn
(
SMnode
*
pMnode
,
uint32_t
connId
);
static
void
mndReleaseConn
(
SMnode
*
pMnode
,
SConnObj
*
pConn
);
static
void
mndReleaseConn
(
SMnode
*
pMnode
,
SConnObj
*
pConn
);
static
void
*
mndGetNextConn
(
SMnode
*
pMnode
,
SCacheIter
*
pIter
);
static
void
*
mndGetNextConn
(
SMnode
*
pMnode
,
SCacheIter
*
pIter
);
static
void
mndCancelGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndProcessHeartBeatReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessHeartBeatReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessConnectReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessConnectReq
(
SNodeMsg
*
pReq
);
...
@@ -71,9 +71,9 @@ int32_t mndInitProfile(SMnode *pMnode) {
...
@@ -71,9 +71,9 @@ int32_t mndInitProfile(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_QUERY
,
mndProcessKillQueryReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_QUERY
,
mndProcessKillQueryReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_CONN
,
mndProcessKillConnReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_CONN
,
mndProcessKillConnReq
);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndCancelGetNextConn
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndCancelGetNextConn
);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndRetrieveQueries);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndRetrieveQueries);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_QUERIES
,
mndCancelGetNextQuery
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_QUERIES
,
mndCancelGetNextQuery
);
return
0
;
return
0
;
...
@@ -91,7 +91,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
...
@@ -91,7 +91,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
int32_t
pid
,
const
char
*
app
,
int64_t
startTime
)
{
int32_t
pid
,
const
char
*
app
,
int64_t
startTime
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
char
connStr
[
255
]
=
{
0
};
char
connStr
[
255
]
=
{
0
};
int32_t
len
=
snprintf
(
connStr
,
sizeof
(
connStr
),
"%s%d%d%d%s"
,
user
,
ip
,
port
,
pid
,
app
);
int32_t
len
=
snprintf
(
connStr
,
sizeof
(
connStr
),
"%s%d%d%d%s"
,
user
,
ip
,
port
,
pid
,
app
);
int32_t
connId
=
mndGenerateUid
(
connStr
,
len
);
int32_t
connId
=
mndGenerateUid
(
connStr
,
len
);
if
(
startTime
==
0
)
startTime
=
taosGetTimestampMs
();
if
(
startTime
==
0
)
startTime
=
taosGetTimestampMs
();
...
@@ -174,10 +174,10 @@ static void mndCancelGetNextConn(SMnode *pMnode, void *pIter) {
...
@@ -174,10 +174,10 @@ static void mndCancelGetNextConn(SMnode *pMnode, void *pIter) {
}
}
static
int32_t
mndProcessConnectReq
(
SNodeMsg
*
pReq
)
{
static
int32_t
mndProcessConnectReq
(
SNodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SUserObj
*
pUser
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SConnObj
*
pConn
=
NULL
;
SConnObj
*
pConn
=
NULL
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SConnectReq
connReq
=
{
0
};
SConnectReq
connReq
=
{
0
};
char
ip
[
30
]
=
{
0
};
char
ip
[
30
]
=
{
0
};
...
@@ -194,6 +194,11 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) {
...
@@ -194,6 +194,11 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) {
mError
(
"user:%s, failed to login while acquire user since %s"
,
pReq
->
user
,
terrstr
());
mError
(
"user:%s, failed to login while acquire user since %s"
,
pReq
->
user
,
terrstr
());
goto
CONN_OVER
;
goto
CONN_OVER
;
}
}
if
(
0
!=
strncmp
(
connReq
.
passwd
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
-
1
))
{
mError
(
"user:%s, failed to auth while acquire user
\n
%s
\r\n
%s"
,
pReq
->
user
,
connReq
.
passwd
,
pUser
->
pass
);
code
=
TSDB_CODE_RPC_AUTH_FAILURE
;
goto
CONN_OVER
;
}
if
(
connReq
.
db
[
0
])
{
if
(
connReq
.
db
[
0
])
{
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
...
@@ -253,8 +258,8 @@ static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) {
...
@@ -253,8 +258,8 @@ static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) {
pConn
->
pQueries
=
pBasic
->
queryDesc
;
pConn
->
pQueries
=
pBasic
->
queryDesc
;
pBasic
->
queryDesc
=
NULL
;
pBasic
->
queryDesc
=
NULL
;
pConn
->
numOfQueries
=
pBasic
->
queryDesc
?
taosArrayGetSize
(
pBasic
->
queryDesc
)
:
0
;
pConn
->
numOfQueries
=
pBasic
->
queryDesc
?
taosArrayGetSize
(
pBasic
->
queryDesc
)
:
0
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -324,9 +329,10 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
...
@@ -324,9 +329,10 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
return
NULL
;
return
NULL
;
}
}
static
int32_t
mndProcessQueryHeartBeat
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
,
SClientHbReq
*
pHbReq
,
SClientHbBatchRsp
*
pBatchRsp
)
{
static
int32_t
mndProcessQueryHeartBeat
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
,
SClientHbReq
*
pHbReq
,
SClientHbBatchRsp
*
pBatchRsp
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SClientHbRsp
hbRsp
=
{.
connKey
=
pHbReq
->
connKey
,
.
status
=
0
,
.
info
=
NULL
,
.
query
=
NULL
};
SClientHbRsp
hbRsp
=
{.
connKey
=
pHbReq
->
connKey
,
.
status
=
0
,
.
info
=
NULL
,
.
query
=
NULL
};
if
(
pHbReq
->
query
)
{
if
(
pHbReq
->
query
)
{
SQueryHbReqBasic
*
pBasic
=
pHbReq
->
query
;
SQueryHbReqBasic
*
pBasic
=
pHbReq
->
query
;
...
@@ -335,8 +341,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -335,8 +341,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
rpcGetConnInfo
(
pMsg
->
handle
,
&
connInfo
);
rpcGetConnInfo
(
pMsg
->
handle
,
&
connInfo
);
SConnObj
*
pConn
=
mndAcquireConn
(
pMnode
,
pBasic
->
connId
);
SConnObj
*
pConn
=
mndAcquireConn
(
pMnode
,
pBasic
->
connId
);
if
(
pConn
==
NULL
)
{
if
(
pConn
==
NULL
)
{
pConn
=
mndCreateConn
(
pMnode
,
connInfo
.
user
,
CONN_TYPE__QUERY
,
connInfo
.
clientIp
,
connInfo
.
clientPort
,
pBasic
->
pid
,
pBasic
->
app
,
0
);
pConn
=
mndCreateConn
(
pMnode
,
connInfo
.
user
,
CONN_TYPE__QUERY
,
connInfo
.
clientIp
,
connInfo
.
clientPort
,
pBasic
->
pid
,
pBasic
->
app
,
0
);
if
(
pConn
==
NULL
)
{
if
(
pConn
==
NULL
)
{
mError
(
"user:%s, conn:%u is freed and failed to create new since %s"
,
connInfo
.
user
,
pBasic
->
connId
,
terrstr
());
mError
(
"user:%s, conn:%u is freed and failed to create new since %s"
,
connInfo
.
user
,
pBasic
->
connId
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -345,7 +352,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -345,7 +352,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
}
}
}
else
if
(
pConn
->
killed
)
{
}
else
if
(
pConn
->
killed
)
{
mError
(
"user:%s, conn:%u is already killed"
,
connInfo
.
user
,
pConn
->
id
);
mError
(
"user:%s, conn:%u is already killed"
,
connInfo
.
user
,
pConn
->
id
);
mndReleaseConn
(
pMnode
,
pConn
);
mndReleaseConn
(
pMnode
,
pConn
);
terrno
=
TSDB_CODE_MND_INVALID_CONNECTION
;
terrno
=
TSDB_CODE_MND_INVALID_CONNECTION
;
return
-
1
;
return
-
1
;
}
}
...
@@ -369,8 +376,8 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -369,8 +376,8 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
}
}
rspBasic
->
connId
=
pConn
->
id
;
rspBasic
->
connId
=
pConn
->
id
;
rspBasic
->
totalDnodes
=
1
;
//
TODO
rspBasic
->
totalDnodes
=
1
;
//
TODO
rspBasic
->
onlineDnodes
=
1
;
//
TODO
rspBasic
->
onlineDnodes
=
1
;
//
TODO
mndGetMnodeEpSet
(
pMnode
,
&
rspBasic
->
epSet
);
mndGetMnodeEpSet
(
pMnode
,
&
rspBasic
->
epSet
);
mndReleaseConn
(
pMnode
,
pConn
);
mndReleaseConn
(
pMnode
,
pConn
);
...
@@ -379,7 +386,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -379,7 +386,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
int32_t
kvNum
=
taosHashGetSize
(
pHbReq
->
info
);
int32_t
kvNum
=
taosHashGetSize
(
pHbReq
->
info
);
if
(
NULL
==
pHbReq
->
info
||
kvNum
<=
0
)
{
if
(
NULL
==
pHbReq
->
info
||
kvNum
<=
0
)
{
taosArrayPush
(
pBatchRsp
->
rsps
,
&
hbRsp
);
taosArrayPush
(
pBatchRsp
->
rsps
,
&
hbRsp
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -396,7 +403,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -396,7 +403,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
switch
(
kv
->
key
)
{
switch
(
kv
->
key
)
{
case
HEARTBEAT_KEY_DBINFO
:
{
case
HEARTBEAT_KEY_DBINFO
:
{
void
*
rspMsg
=
NULL
;
void
*
rspMsg
=
NULL
;
int32_t
rspLen
=
0
;
int32_t
rspLen
=
0
;
mndValidateDbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SDbVgVersion
),
&
rspMsg
,
&
rspLen
);
mndValidateDbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SDbVgVersion
),
&
rspMsg
,
&
rspLen
);
if
(
rspMsg
&&
rspLen
>
0
)
{
if
(
rspMsg
&&
rspLen
>
0
)
{
...
@@ -406,7 +413,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -406,7 +413,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
break
;
break
;
}
}
case
HEARTBEAT_KEY_STBINFO
:
{
case
HEARTBEAT_KEY_STBINFO
:
{
void
*
rspMsg
=
NULL
;
void
*
rspMsg
=
NULL
;
int32_t
rspLen
=
0
;
int32_t
rspLen
=
0
;
mndValidateStbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SSTableMetaVersion
),
&
rspMsg
,
&
rspLen
);
mndValidateStbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SSTableMetaVersion
),
&
rspMsg
,
&
rspLen
);
if
(
rspMsg
&&
rspLen
>
0
)
{
if
(
rspMsg
&&
rspLen
>
0
)
{
...
@@ -457,7 +464,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
...
@@ -457,7 +464,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
taosArrayDestroyEx
(
batchReq
.
reqs
,
tFreeClientHbReq
);
taosArrayDestroyEx
(
batchReq
.
reqs
,
tFreeClientHbReq
);
int32_t
tlen
=
tSerializeSClientHbBatchRsp
(
NULL
,
0
,
&
batchRsp
);
int32_t
tlen
=
tSerializeSClientHbBatchRsp
(
NULL
,
0
,
&
batchRsp
);
void
*
buf
=
rpcMallocCont
(
tlen
);
void
*
buf
=
rpcMallocCont
(
tlen
);
tSerializeSClientHbBatchRsp
(
buf
,
tlen
,
&
batchRsp
);
tSerializeSClientHbBatchRsp
(
buf
,
tlen
,
&
batchRsp
);
int32_t
rspNum
=
(
int32_t
)
taosArrayGetSize
(
batchRsp
.
rsps
);
int32_t
rspNum
=
(
int32_t
)
taosArrayGetSize
(
batchRsp
.
rsps
);
...
@@ -479,7 +486,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
...
@@ -479,7 +486,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
}
}
static
int32_t
mndProcessKillQueryReq
(
SNodeMsg
*
pReq
)
{
static
int32_t
mndProcessKillQueryReq
(
SNodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
...
@@ -513,7 +520,7 @@ static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) {
...
@@ -513,7 +520,7 @@ static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) {
}
}
static
int32_t
mndProcessKillConnReq
(
SNodeMsg
*
pReq
)
{
static
int32_t
mndProcessKillConnReq
(
SNodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
...
@@ -545,11 +552,11 @@ static int32_t mndProcessKillConnReq(SNodeMsg *pReq) {
...
@@ -545,11 +552,11 @@ static int32_t mndProcessKillConnReq(SNodeMsg *pReq) {
}
}
static
int32_t
mndRetrieveConns
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveConns
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
SConnObj
*
pConn
=
NULL
;
SConnObj
*
pConn
=
NULL
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
*
pWrite
;
char
ipStr
[
TSDB_IPv4ADDR_LEN
+
6
];
char
ipStr
[
TSDB_IPv4ADDR_LEN
+
6
];
if
(
pShow
->
pIter
==
NULL
)
{
if
(
pShow
->
pIter
==
NULL
)
{
...
@@ -604,8 +611,8 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int
...
@@ -604,8 +611,8 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int
}
}
static
int32_t
mndRetrieveQueries
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveQueries
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
#if 0
#if 0
SConnObj *pConn = NULL;
SConnObj *pConn = NULL;
int32_t cols = 0;
int32_t cols = 0;
...
@@ -703,7 +710,7 @@ static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, i
...
@@ -703,7 +710,7 @@ static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, i
}
}
pShow->numOfRows += numOfRows;
pShow->numOfRows += numOfRows;
#endif
#endif
return
numOfRows
;
return
numOfRows
;
}
}
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
055e0516
...
@@ -34,6 +34,54 @@
...
@@ -34,6 +34,54 @@
extern
bool
tsStreamSchedV
;
extern
bool
tsStreamSchedV
;
int32_t
mndConvertRSmaTask
(
const
char
*
ast
,
int8_t
triggerType
,
int64_t
watermark
,
char
**
pStr
,
int32_t
*
pLen
)
{
SNode
*
pAst
=
NULL
;
SQueryPlan
*
pPlan
=
NULL
;
terrno
=
TSDB_CODE_SUCCESS
;
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
SPlanContext
cxt
=
{
.
pAstRoot
=
pAst
,
.
topicQuery
=
false
,
.
streamQuery
=
true
,
.
rSmaQuery
=
true
,
.
triggerType
=
triggerType
,
.
watermark
=
watermark
,
};
if
(
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
)
<
0
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
int32_t
levelNum
=
LIST_LENGTH
(
pPlan
->
pSubplans
);
if
(
levelNum
!=
1
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
SNodeListNode
*
inner
=
nodesListGetNode
(
pPlan
->
pSubplans
,
0
);
int32_t
opNum
=
LIST_LENGTH
(
inner
->
pNodeList
);
if
(
opNum
!=
1
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
SSubplan
*
plan
=
nodesListGetNode
(
inner
->
pNodeList
,
0
);
if
(
qSubPlanToString
(
plan
,
pStr
,
pLen
)
<
0
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
END:
if
(
pAst
)
nodesDestroyNode
(
pAst
);
if
(
pPlan
)
nodesDestroyNode
(
pPlan
);
return
terrno
;
}
int32_t
mndPersistTaskDeployReq
(
STrans
*
pTrans
,
SStreamTask
*
pTask
,
const
SEpSet
*
pEpSet
,
tmsg_t
type
,
int32_t
nodeId
)
{
int32_t
mndPersistTaskDeployReq
(
STrans
*
pTrans
,
SStreamTask
*
pTask
,
const
SEpSet
*
pEpSet
,
tmsg_t
type
,
int32_t
nodeId
)
{
SCoder
encoder
;
SCoder
encoder
;
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_ENCODER
);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
055e0516
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include "mndInfoSchema.h"
#include "mndInfoSchema.h"
#include "mndMnode.h"
#include "mndMnode.h"
#include "mndPerfSchema.h"
#include "mndPerfSchema.h"
#include "mndScheduler.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndUser.h"
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
055e0516
此差异已折叠。
点击以展开。
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
055e0516
...
@@ -76,7 +76,13 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
...
@@ -76,7 +76,13 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
updateTime
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
updateTime
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
uid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
uid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
dbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
dbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
subDbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
subType
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
withTbName
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
withSchema
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
withTag
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
withTagSchema
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
astLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
astLen
,
TOPIC_ENCODE_OVER
);
...
@@ -134,7 +140,13 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
...
@@ -134,7 +140,13 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
updateTime
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
updateTime
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
uid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
uid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
subDbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
subType
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
withTbName
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
withSchema
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
withTag
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
withTagSchema
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
pTopic
->
sql
=
taosMemoryCalloc
(
pTopic
->
sqlLen
,
sizeof
(
char
));
pTopic
->
sql
=
taosMemoryCalloc
(
pTopic
->
sqlLen
,
sizeof
(
char
));
...
@@ -254,33 +266,13 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
...
@@ -254,33 +266,13 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
terrno
=
TSDB_CODE_MND_INVALID_TOPIC_OPTION
;
terrno
=
TSDB_CODE_MND_INVALID_TOPIC_OPTION
;
return
-
1
;
return
-
1
;
}
}
return
0
;
}
#if 0
static int32_t mndGetPlanString(const SCMCreateTopicReq *pCreate, char **pStr) {
if (NULL == pCreate->ast) {
return TSDB_CODE_SUCCESS;
}
SNode *pAst = NULL;
int32_t code = nodesStringToNode(pCreate->ast, &pAst);
SQueryPlan *pPlan = NULL;
if
((
pCreate
->
ast
==
NULL
||
pCreate
->
ast
[
0
]
==
0
)
&&
pCreate
->
subscribeDbName
[
0
]
==
0
)
{
if (TSDB_CODE_SUCCESS == code) {
terrno
=
TSDB_CODE_MND_INVALID_TOPIC_OPTION
;
SPlanContext cxt = {.pAstRoot = pAst, .topicQuery = true};
return
-
1
;
code = qCreateQueryPlan(&cxt, &pPlan, NULL);
}
if (TSDB_CODE_SUCCESS == code) {
code = nodesNodeToString(pPlan, false, pStr, NULL);
}
}
nodesDestroyNode(pAst);
return
0
;
nodesDestroyNode(pPlan);
terrno = code;
return code;
}
}
#endif
static
int32_t
mndCreateTopic
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SCMCreateTopicReq
*
pCreate
,
SDbObj
*
pDb
)
{
static
int32_t
mndCreateTopic
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SCMCreateTopicReq
*
pCreate
,
SDbObj
*
pDb
)
{
mDebug
(
"topic:%s to create"
,
pCreate
->
name
);
mDebug
(
"topic:%s to create"
,
pCreate
->
name
);
...
@@ -297,28 +289,38 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
...
@@ -297,28 +289,38 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
topicObj
.
ast
=
strdup
(
pCreate
->
ast
);
topicObj
.
ast
=
strdup
(
pCreate
->
ast
);
topicObj
.
astLen
=
strlen
(
pCreate
->
ast
)
+
1
;
topicObj
.
astLen
=
strlen
(
pCreate
->
ast
)
+
1
;
SNode
*
pAst
=
NULL
;
if
(
pCreate
->
ast
&&
pCreate
->
ast
[
0
])
{
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
!=
0
)
{
topicObj
.
subType
=
TOPIC_SUB_TYPE__TABLE
;
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
topicObj
.
withTbName
=
0
;
return
-
1
;
topicObj
.
withSchema
=
0
;
}
SQueryPlan
*
pPlan
=
NULL
;
SNode
*
pAst
=
NULL
;
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
SPlanContext
cxt
=
{.
pAstRoot
=
pAst
,
.
topicQuery
=
true
};
SQueryPlan
*
pPlan
=
NULL
;
if
(
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
if
(
qExtractResultSchema
(
pAst
,
&
topicObj
.
schema
.
nCols
,
&
topicObj
.
schema
.
pSchema
)
!=
0
)
{
SPlanContext
cxt
=
{.
pAstRoot
=
pAst
,
.
topicQuery
=
true
};
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
if
(
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
)
!=
0
)
{
return
-
1
;
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
}
return
-
1
;
}
if
(
nodesNodeToString
(
pPlan
,
false
,
&
topicObj
.
physicalPlan
,
NULL
)
!=
0
)
{
if
(
qExtractResultSchema
(
pAst
,
&
topicObj
.
schema
.
nCols
,
&
topicObj
.
schema
.
pSchema
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
}
if
(
nodesNodeToString
(
pPlan
,
false
,
&
topicObj
.
physicalPlan
,
NULL
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
}
else
{
topicObj
.
subType
=
TOPIC_SUB_TYPE__DB
;
topicObj
.
withTbName
=
1
;
topicObj
.
withSchema
=
1
;
}
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_TOPIC
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_TOPIC
,
&
pReq
->
rpcMsg
);
...
...
source/dnode/mnode/impl/test/func/func.cpp
浏览文件 @
055e0516
...
@@ -240,7 +240,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -240,7 +240,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_
INVALID_FUNC
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_
FUNC_NOT_EXIST
);
}
}
{
{
...
@@ -371,7 +371,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -371,7 +371,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_
INVALID_FUNC
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_
FUNC_NOT_EXIST
);
}
}
}
}
...
...
source/dnode/mnode/impl/test/profile/profile.cpp
浏览文件 @
055e0516
...
@@ -30,8 +30,15 @@ int32_t MndTestProfile::connId;
...
@@ -30,8 +30,15 @@ int32_t MndTestProfile::connId;
TEST_F
(
MndTestProfile
,
01
_ConnectMsg
)
{
TEST_F
(
MndTestProfile
,
01
_ConnectMsg
)
{
SConnectReq
connectReq
=
{
0
};
SConnectReq
connectReq
=
{
0
};
connectReq
.
pid
=
1234
;
connectReq
.
pid
=
1234
;
char
passwd
[]
=
"taosdata"
;
char
secretEncrypt
[
TSDB_PASSWORD_LEN
]
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
passwd
,
strlen
(
passwd
),
secretEncrypt
);
strcpy
(
connectReq
.
app
,
"mnode_test_profile"
);
strcpy
(
connectReq
.
app
,
"mnode_test_profile"
);
strcpy
(
connectReq
.
db
,
""
);
strcpy
(
connectReq
.
db
,
""
);
strcpy
(
connectReq
.
user
,
"root"
);
strcpy
(
connectReq
.
passwd
,
secretEncrypt
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
@@ -58,10 +65,16 @@ TEST_F(MndTestProfile, 01_ConnectMsg) {
...
@@ -58,10 +65,16 @@ TEST_F(MndTestProfile, 01_ConnectMsg) {
}
}
TEST_F
(
MndTestProfile
,
02
_ConnectMsg_InvalidDB
)
{
TEST_F
(
MndTestProfile
,
02
_ConnectMsg_InvalidDB
)
{
char
passwd
[]
=
"taosdata"
;
char
secretEncrypt
[
TSDB_PASSWORD_LEN
]
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
passwd
,
strlen
(
passwd
),
secretEncrypt
);
SConnectReq
connectReq
=
{
0
};
SConnectReq
connectReq
=
{
0
};
connectReq
.
pid
=
1234
;
connectReq
.
pid
=
1234
;
strcpy
(
connectReq
.
app
,
"mnode_test_profile"
);
strcpy
(
connectReq
.
app
,
"mnode_test_profile"
);
strcpy
(
connectReq
.
db
,
"invalid_db"
);
strcpy
(
connectReq
.
db
,
"invalid_db"
);
strcpy
(
connectReq
.
user
,
"root"
);
strcpy
(
connectReq
.
passwd
,
secretEncrypt
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
...
source/dnode/mnode/impl/test/show/show.cpp
浏览文件 @
055e0516
...
@@ -54,10 +54,16 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
...
@@ -54,10 +54,16 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
}
}
TEST_F
(
MndTestShow
,
03
_ShowMsg_Conn
)
{
TEST_F
(
MndTestShow
,
03
_ShowMsg_Conn
)
{
char
passwd
[]
=
"taosdata"
;
char
secretEncrypt
[
TSDB_PASSWORD_LEN
]
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
passwd
,
strlen
(
passwd
),
secretEncrypt
);
SConnectReq
connectReq
=
{
0
};
SConnectReq
connectReq
=
{
0
};
connectReq
.
pid
=
1234
;
connectReq
.
pid
=
1234
;
strcpy
(
connectReq
.
app
,
"mnode_test_show"
);
strcpy
(
connectReq
.
app
,
"mnode_test_show"
);
strcpy
(
connectReq
.
db
,
""
);
strcpy
(
connectReq
.
db
,
""
);
strcpy
(
connectReq
.
user
,
"root"
);
strcpy
(
connectReq
.
passwd
,
secretEncrypt
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
@@ -74,4 +80,4 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
...
@@ -74,4 +80,4 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
TEST_F
(
MndTestShow
,
04
_ShowMsg_Cluster
)
{
TEST_F
(
MndTestShow
,
04
_ShowMsg_Cluster
)
{
test
.
SendShowReq
(
TSDB_MGMT_TABLE_CLUSTER
,
"cluster"
,
""
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_CLUSTER
,
"cluster"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
}
\ No newline at end of file
source/dnode/vnode/inc/vnode.h
浏览文件 @
055e0516
...
@@ -109,8 +109,7 @@ int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList
...
@@ -109,8 +109,7 @@ int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList
int
tqReadHandleAddTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
);
int
tqReadHandleAddTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
);
int32_t
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
int32_t
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
);
int32_t
tqRetrieveDataBlock
(
SArray
**
ppCols
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
int32_t
*
pNumOfRows
);
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
);
// need to reposition
// need to reposition
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
055e0516
...
@@ -404,6 +404,7 @@ struct SReadH {
...
@@ -404,6 +404,7 @@ struct SReadH {
#define TSDB_READ_REPO_ID(rh) REPO_ID(TSDB_READ_REPO(rh))
#define TSDB_READ_REPO_ID(rh) REPO_ID(TSDB_READ_REPO(rh))
#define TSDB_READ_FSET(rh) (&((rh)->rSet))
#define TSDB_READ_FSET(rh) (&((rh)->rSet))
#define TSDB_READ_TABLE(rh) ((rh)->pTable)
#define TSDB_READ_TABLE(rh) ((rh)->pTable)
#define TSDB_READ_TABLE_UID(rh) ((rh)->pTable->uid)
#define TSDB_READ_HEAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_HEAD)
#define TSDB_READ_HEAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_HEAD)
#define TSDB_READ_DATA_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_DATA)
#define TSDB_READ_DATA_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_DATA)
#define TSDB_READ_LAST_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_LAST)
#define TSDB_READ_LAST_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_LAST)
...
...
source/dnode/vnode/src/meta/metaTDBImpl.c
浏览文件 @
055e0516
...
@@ -426,6 +426,71 @@ struct SMSmaCursor {
...
@@ -426,6 +426,71 @@ struct SMSmaCursor {
int
vLen
;
int
vLen
;
};
};
STSmaWrapper
*
metaGetSmaInfoByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
// TODO
// ASSERT(0);
// return NULL;
#ifdef META_TDB_SMA_TEST
STSmaWrapper
*
pSW
=
NULL
;
SMSmaCursor
*
pCur
=
metaOpenSmaCursor
(
pMeta
,
uid
);
if
(
pCur
==
NULL
)
{
return
NULL
;
}
void
*
pBuf
=
NULL
;
SSmaIdxKey
*
pSmaIdxKey
=
NULL
;
while
(
true
)
{
// TODO: lock during iterate?
if
(
tdbDbNext
(
pCur
->
pCur
,
&
pCur
->
pKey
,
&
pCur
->
kLen
,
NULL
,
&
pCur
->
vLen
)
==
0
)
{
pSmaIdxKey
=
pCur
->
pKey
;
ASSERT
(
pSmaIdxKey
!=
NULL
);
void
*
pSmaVal
=
metaGetSmaInfoByIndex
(
pMeta
,
pSmaIdxKey
->
smaUid
,
false
);
if
(
pSmaVal
==
NULL
)
{
tsdbWarn
(
"no tsma exists for indexUid: %"
PRIi64
,
pSmaIdxKey
->
smaUid
);
continue
;
}
if
((
pSW
==
NULL
)
&&
((
pSW
=
taosMemoryCalloc
(
1
,
sizeof
(
*
pSW
)))
==
NULL
))
{
TDB_FREE
(
pSmaVal
);
metaCloseSmaCursor
(
pCur
);
return
NULL
;
}
++
pSW
->
number
;
STSma
*
tptr
=
(
STSma
*
)
taosMemoryRealloc
(
pSW
->
tSma
,
pSW
->
number
*
sizeof
(
STSma
));
if
(
tptr
==
NULL
)
{
TDB_FREE
(
pSmaVal
);
metaCloseSmaCursor
(
pCur
);
tdDestroyTSmaWrapper
(
pSW
);
taosMemoryFreeClear
(
pSW
);
return
NULL
;
}
pSW
->
tSma
=
tptr
;
pBuf
=
pSmaVal
;
if
(
tDecodeTSma
(
pBuf
,
pSW
->
tSma
+
pSW
->
number
-
1
)
==
NULL
)
{
TDB_FREE
(
pSmaVal
);
metaCloseSmaCursor
(
pCur
);
tdDestroyTSmaWrapper
(
pSW
);
taosMemoryFreeClear
(
pSW
);
return
NULL
;
}
TDB_FREE
(
pSmaVal
);
continue
;
}
break
;
}
metaCloseSmaCursor
(
pCur
);
return
pSW
;
#endif
}
int
metaRemoveSmaFromDb
(
SMeta
*
pMeta
,
int64_t
indexUid
)
{
int
metaRemoveSmaFromDb
(
SMeta
*
pMeta
,
int64_t
indexUid
)
{
// TODO
// TODO
ASSERT
(
0
);
ASSERT
(
0
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
055e0516
...
@@ -618,127 +618,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -618,127 +618,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
}
}
}
}
#if 0
int32_t tqProcessRebReq(STQ* pTq, char* msg) {
SMqMVRebReq req = {0};
terrno = TSDB_CODE_SUCCESS;
tDecodeSMqMVRebReq(msg, &req);
vDebug("vg %d set from consumer %ld to consumer %ld", req.vgId, req.oldConsumerId, req.newConsumerId);
STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, req.oldConsumerId);
ASSERT(pConsumer);
ASSERT(pConsumer->consumerId == req.oldConsumerId);
int32_t numOfTopics = taosArrayGetSize(pConsumer->topics);
if (numOfTopics == 1) {
STqTopic* pTopic = taosArrayGet(pConsumer->topics, 0);
ASSERT(strcmp(pTopic->topicName, req.topic) == 0);
STqConsumer* pNewConsumer = tqHandleGet(pTq->tqMeta, req.newConsumerId);
if (pNewConsumer == NULL) {
pConsumer->consumerId = req.newConsumerId;
tqHandleMovePut(pTq->tqMeta, req.newConsumerId, pConsumer);
tqHandleCommit(pTq->tqMeta, req.newConsumerId);
tqHandlePurge(pTq->tqMeta, req.oldConsumerId);
return 0;
} else {
taosArrayPush(pNewConsumer->topics, pTopic);
}
} else {
for (int32_t i = 0; i < numOfTopics; i++) {
STqTopic* pTopic = taosArrayGet(pConsumer->topics, i);
if (strcmp(pTopic->topicName, req.topic) == 0) {
STqConsumer* pNewConsumer = tqHandleGet(pTq->tqMeta, req.newConsumerId);
if (pNewConsumer == NULL) {
pNewConsumer = taosMemoryCalloc(1, sizeof(STqConsumer));
if (pNewConsumer == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return -1;
}
strcpy(pNewConsumer->cgroup, pConsumer->cgroup);
pNewConsumer->topics = taosArrayInit(0, sizeof(STqTopic));
pNewConsumer->consumerId = req.newConsumerId;
pNewConsumer->epoch = 0;
taosArrayPush(pNewConsumer->topics, pTopic);
tqHandleMovePut(pTq->tqMeta, req.newConsumerId, pConsumer);
tqHandleCommit(pTq->tqMeta, req.newConsumerId);
return 0;
}
ASSERT(pNewConsumer->consumerId == req.newConsumerId);
taosArrayPush(pNewConsumer->topics, pTopic);
break;
}
}
//
}
return 0;
}
int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
SMqSetCVgReq req = {0};
tDecodeSMqSetCVgReq(msg, &req);
bool create = false;
vDebug("vg %d set to consumer %ld", req.vgId, req.consumerId);
STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, req.consumerId);
if (pConsumer == NULL) {
pConsumer = taosMemoryCalloc(1, sizeof(STqConsumer));
if (pConsumer == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return -1;
}
strcpy(pConsumer->cgroup, req.cgroup);
pConsumer->topics = taosArrayInit(0, sizeof(STqTopic));
pConsumer->consumerId = req.consumerId;
pConsumer->epoch = 0;
create = true;
}
STqTopic* pTopic = taosMemoryCalloc(1, sizeof(STqTopic));
if (pTopic == NULL) {
taosArrayDestroy(pConsumer->topics);
taosMemoryFree(pConsumer);
return -1;
}
strcpy(pTopic->topicName, req.topicName);
pTopic->sql = req.sql;
pTopic->physicalPlan = req.physicalPlan;
pTopic->qmsg = req.qmsg;
/*pTopic->committedOffset = -1;*/
/*pTopic->currentOffset = -1;*/
pTopic->buffer.firstOffset = -1;
pTopic->buffer.lastOffset = -1;
pTopic->pReadhandle = walOpenReadHandle(pTq->pWal);
if (pTopic->pReadhandle == NULL) {
ASSERT(false);
}
for (int i = 0; i < TQ_BUFFER_SIZE; i++) {
pTopic->buffer.output[i].status = 0;
STqReadHandle* pReadHandle = tqInitSubmitMsgScanner(pTq->pVnodeMeta);
SReadHandle handle = {
.reader = pReadHandle,
.meta = pTq->pVnodeMeta,
};
pTopic->buffer.output[i].pReadHandle = pReadHandle;
pTopic->buffer.output[i].task = qCreateStreamExecTaskInfo(req.qmsg, &handle);
ASSERT(pTopic->buffer.output[i].task);
}
vDebug("set topic %s to consumer %ld on vg %d", pTopic->topicName, req.consumerId, TD_VID(pTq->pVnode));
taosArrayPush(pConsumer->topics, pTopic);
if (create) {
tqHandleMovePut(pTq->tqMeta, req.consumerId, pConsumer);
tqHandleCommit(pTq->tqMeta, req.consumerId);
}
terrno = TSDB_CODE_SUCCESS;
return 0;
}
int32_t tqProcessCancelConnReq(STQ* pTq, char* msg) {
terrno = TSDB_CODE_SUCCESS;
return 0;
}
#endif
int32_t
tqExpandTask
(
STQ
*
pTq
,
SStreamTask
*
pTask
,
int32_t
parallel
)
{
int32_t
tqExpandTask
(
STQ
*
pTq
,
SStreamTask
*
pTask
,
int32_t
parallel
)
{
if
(
pTask
->
execType
==
TASK_EXEC__NONE
)
return
0
;
if
(
pTask
->
execType
==
TASK_EXEC__NONE
)
return
0
;
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
055e0516
...
@@ -82,16 +82,7 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
...
@@ -82,16 +82,7 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
return
false
;
return
false
;
}
}
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
)
{
int32_t
tqRetrieveDataBlock
(
SArray
**
ppCols
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
int32_t
*
pNumOfRows
)
{
// currently only rows are used
pBlockInfo
->
numOfCols
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
pBlockInfo
->
rows
=
pHandle
->
pBlock
->
numOfRows
;
// pBlockInfo->uid = pHandle->pBlock->uid; // the uid can not be assigned to pBlockData.
return
0
;
}
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
)
{
/*int32_t sversion = pHandle->pBlock->sversion;*/
/*int32_t sversion = pHandle->pBlock->sversion;*/
// TODO set to real sversion
// TODO set to real sversion
int32_t
sversion
=
0
;
int32_t
sversion
=
0
;
...
@@ -112,7 +103,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -112,7 +103,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
STSchema
*
pTschema
=
pHandle
->
pSchema
;
STSchema
*
pTschema
=
pHandle
->
pSchema
;
SSchemaWrapper
*
pSchemaWrapper
=
pHandle
->
pSchemaWrapper
;
SSchemaWrapper
*
pSchemaWrapper
=
pHandle
->
pSchemaWrapper
;
int32_t
n
umOfRows
=
pHandle
->
pBlock
->
numOfRows
;
*
pN
umOfRows
=
pHandle
->
pBlock
->
numOfRows
;
/*int32_t numOfCols = pHandle->pSchema->numOfCols;*/
/*int32_t numOfCols = pHandle->pSchema->numOfCols;*/
int32_t
colNumNeed
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
int32_t
colNumNeed
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
...
@@ -120,10 +111,11 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -120,10 +111,11 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
colNumNeed
=
pSchemaWrapper
->
nCols
;
colNumNeed
=
pSchemaWrapper
->
nCols
;
}
}
SArray
*
pArray
=
taosArrayInit
(
colNumNeed
,
sizeof
(
SColumnInfoData
));
*
ppCols
=
taosArrayInit
(
colNumNeed
,
sizeof
(
SColumnInfoData
));
if
(
pArray
==
NULL
)
{
if
(
*
ppCols
==
NULL
)
{
return
NULL
;
return
-
1
;
}
}
int32_t
colMeta
=
0
;
int32_t
colMeta
=
0
;
int32_t
colNeed
=
0
;
int32_t
colNeed
=
0
;
while
(
colMeta
<
pSchemaWrapper
->
nCols
&&
colNeed
<
colNumNeed
)
{
while
(
colMeta
<
pSchemaWrapper
->
nCols
&&
colNeed
<
colNumNeed
)
{
...
@@ -136,21 +128,24 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -136,21 +128,24 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
colNeed
++
;
colNeed
++
;
}
else
{
}
else
{
SColumnInfoData
colInfo
=
{
0
};
SColumnInfoData
colInfo
=
{
0
};
/*int sz = numOfRows * pColSchema->bytes;*/
colInfo
.
info
.
bytes
=
pColSchema
->
bytes
;
colInfo
.
info
.
bytes
=
pColSchema
->
bytes
;
colInfo
.
info
.
colId
=
pColSchema
->
colId
;
colInfo
.
info
.
colId
=
pColSchema
->
colId
;
colInfo
.
info
.
type
=
pColSchema
->
type
;
colInfo
.
info
.
type
=
pColSchema
->
type
;
if
(
colInfoDataEnsureCapacity
(
&
colInfo
,
0
,
numOfRows
)
<
0
)
{
if
(
colInfoDataEnsureCapacity
(
&
colInfo
,
0
,
*
pNumOfRows
)
<
0
)
{
taosArrayDestroyEx
(
pArray
,
(
void
(
*
)(
void
*
))
tDeleteSSDataBlock
);
goto
FAIL
;
return
NULL
;
}
}
taosArrayPush
(
pArray
,
&
colInfo
);
taosArrayPush
(
*
ppCols
,
&
colInfo
);
colMeta
++
;
colMeta
++
;
colNeed
++
;
colNeed
++
;
}
}
}
}
int32_t
colActual
=
taosArrayGetSize
(
*
ppCols
);
// TODO in stream shuffle case, fetch groupId
*
pGroupId
=
0
;
STSRowIter
iter
=
{
0
};
STSRowIter
iter
=
{
0
};
tdSTSRowIterInit
(
&
iter
,
pTschema
);
tdSTSRowIterInit
(
&
iter
,
pTschema
);
STSRow
*
row
;
STSRow
*
row
;
...
@@ -159,22 +154,22 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -159,22 +154,22 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
while
((
row
=
tGetSubmitBlkNext
(
&
pHandle
->
blkIter
))
!=
NULL
)
{
while
((
row
=
tGetSubmitBlkNext
(
&
pHandle
->
blkIter
))
!=
NULL
)
{
tdSTSRowIterReset
(
&
iter
,
row
);
tdSTSRowIterReset
(
&
iter
,
row
);
// get all wanted col of that block
// get all wanted col of that block
int32_t
colTot
=
taosArrayGetSize
(
pArray
);
for
(
int32_t
i
=
0
;
i
<
colActual
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
colTot
;
i
++
)
{
SColumnInfoData
*
pColData
=
taosArrayGet
(
*
ppCols
,
i
);
SColumnInfoData
*
pColData
=
taosArrayGet
(
pArray
,
i
);
SCellVal
sVal
=
{
0
};
SCellVal
sVal
=
{
0
};
if
(
!
tdSTSRowIterNext
(
&
iter
,
pColData
->
info
.
colId
,
pColData
->
info
.
type
,
&
sVal
))
{
if
(
!
tdSTSRowIterNext
(
&
iter
,
pColData
->
info
.
colId
,
pColData
->
info
.
type
,
&
sVal
))
{
break
;
break
;
}
}
/*if (colDataAppend(pColData, curRow, sVal.val, false) < 0) {*/
if
(
colDataAppend
(
pColData
,
curRow
,
sVal
.
val
,
sVal
.
valType
==
TD_VTYPE_NULL
)
<
0
)
{
if
(
colDataAppend
(
pColData
,
curRow
,
sVal
.
val
,
sVal
.
valType
==
TD_VTYPE_NULL
)
<
0
)
{
taosArrayDestroyEx
(
pArray
,
(
void
(
*
)(
void
*
))
tDeleteSSDataBlock
);
goto
FAIL
;
return
NULL
;
}
}
}
}
curRow
++
;
curRow
++
;
}
}
return
pArray
;
return
0
;
FAIL:
taosArrayDestroy
(
*
ppCols
);
return
-
1
;
}
}
void
tqReadHandleSetColIdList
(
STqReadHandle
*
pReadHandle
,
SArray
*
pColIdList
)
{
pReadHandle
->
pColIdList
=
pColIdList
;
}
void
tqReadHandleSetColIdList
(
STqReadHandle
*
pReadHandle
,
SArray
*
pColIdList
)
{
pReadHandle
->
pColIdList
=
pColIdList
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
055e0516
...
@@ -3260,6 +3260,9 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDat
...
@@ -3260,6 +3260,9 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDat
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
tsdbDebug
(
"vgId:%d succeed to load block statis part for uid %"
PRIu64
,
REPO_ID
(
pHandle
->
pTsdb
),
TSDB_READ_TABLE_UID
(
&
pHandle
->
rhelper
));
int16_t
*
colIds
=
pHandle
->
defaultLoadColumn
->
pData
;
int16_t
*
colIds
=
pHandle
->
defaultLoadColumn
->
pData
;
size_t
numOfCols
=
QH_GET_NUM_OF_COLS
(
pHandle
);
size_t
numOfCols
=
QH_GET_NUM_OF_COLS
(
pHandle
);
...
...
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
浏览文件 @
055e0516
...
@@ -322,15 +322,18 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) {
...
@@ -322,15 +322,18 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) {
ASSERT
(
pBlock
->
numOfSubBlocks
<=
1
);
ASSERT
(
pBlock
->
numOfSubBlocks
<=
1
);
if
(
!
pBlock
->
aggrStat
)
{
if
(
!
pBlock
->
aggrStat
)
{
tsdbDebug
(
"vgId:%d no need to load block statis part for uid %"
PRIu64
" since not exist"
,
REPO_ID
(
pReadh
->
pRepo
),
TSDB_READ_TABLE_UID
(
pReadh
));
return
TSDB_STATIS_NONE
;
return
TSDB_STATIS_NONE
;
}
}
SDFile
*
pDFileAggr
=
pBlock
->
last
?
TSDB_READ_SMAL_FILE
(
pReadh
)
:
TSDB_READ_SMAD_FILE
(
pReadh
);
SDFile
*
pDFileAggr
=
pBlock
->
last
?
TSDB_READ_SMAL_FILE
(
pReadh
)
:
TSDB_READ_SMAD_FILE
(
pReadh
);
if
(
tsdbSeekDFile
(
pDFileAggr
,
pBlock
->
aggrOffset
,
SEEK_SET
)
<
0
)
{
if
(
tsdbSeekDFile
(
pDFileAggr
,
pBlock
->
aggrOffset
,
SEEK_SET
)
<
0
)
{
tsdbError
(
"vgId:%d failed to load block aggr part while seek file %s to offset %"
PRIu64
" since %s"
,
tsdbError
(
"vgId:%d failed to load block statis part for uid %"
PRIu64
" while seek file %s to offset %"
PRIu64
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
uint64_t
)
pBlock
->
aggrOffset
,
" since %s"
,
tstrerror
(
terrno
));
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_READ_TABLE_UID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
uint64_t
)
pBlock
->
aggrOffset
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
}
}
...
@@ -339,25 +342,28 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) {
...
@@ -339,25 +342,28 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) {
int64_t
nreadAggr
=
tsdbReadDFile
(
pDFileAggr
,
(
void
*
)(
pReadh
->
pAggrBlkData
),
sizeAggr
);
int64_t
nreadAggr
=
tsdbReadDFile
(
pDFileAggr
,
(
void
*
)(
pReadh
->
pAggrBlkData
),
sizeAggr
);
if
(
nreadAggr
<
0
)
{
if
(
nreadAggr
<
0
)
{
tsdbError
(
"vgId:%d failed to load block aggr part while read file %s since %s, offset:%"
PRIu64
" len :%"
PRIzu
,
tsdbError
(
"vgId:%d failed to load block statis part for uid %"
PRIu64
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
tstrerror
(
terrno
),
" while read file %s since %s, offset:%"
PRIu64
" len :%"
PRIzu
,
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_READ_TABLE_UID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
tstrerror
(
terrno
),
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
return
-
1
;
return
-
1
;
}
}
if
(
nreadAggr
<
sizeAggr
)
{
if
(
nreadAggr
<
sizeAggr
)
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block
aggr part in file %s is corrupted, offset:%"
PRIu64
" expected bytes:%"
PRIzu
tsdbError
(
"vgId:%d block
statis part for uid %"
PRIu64
" in file %s is corrupted, offset:%"
PRIu64
" read bytes: %"
PRId64
,
"
expected bytes:%"
PRIzu
"
read bytes: %"
PRId64
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_
FILE_FULL_NAME
(
pDFileAggr
),
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_
READ_TABLE_UID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
)
,
nreadAggr
);
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
,
nreadAggr
);
return
-
1
;
return
-
1
;
}
}
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pReadh
->
pAggrBlkData
),
(
uint32_t
)
sizeAggr
))
{
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pReadh
->
pAggrBlkData
),
(
uint32_t
)
sizeAggr
))
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block aggr part in file %s is corrupted since wrong checksum, offset:%"
PRIu64
" len :%"
PRIzu
,
tsdbError
(
"vgId:%d block statis part for uid %"
PRIu64
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
"in file %s is corrupted since wrong checksum, offset:%"
PRIu64
" len :%"
PRIzu
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_READ_TABLE_UID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
...
@@ -367,7 +373,7 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
...
@@ -367,7 +373,7 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
ASSERT
(
pBlock
->
numOfSubBlocks
<=
1
);
ASSERT
(
pBlock
->
numOfSubBlocks
<=
1
);
SDFile
*
pDFile
=
(
pBlock
->
last
)
?
TSDB_READ_LAST_FILE
(
pReadh
)
:
TSDB_READ_DATA_FILE
(
pReadh
);
SDFile
*
pDFile
=
(
pBlock
->
last
)
?
TSDB_READ_LAST_FILE
(
pReadh
)
:
TSDB_READ_DATA_FILE
(
pReadh
);
if
(
tsdbSeekDFile
(
pDFile
,
pBlock
->
offset
,
SEEK_SET
)
<
0
)
{
if
(
tsdbSeekDFile
(
pDFile
,
pBlock
->
offset
,
SEEK_SET
)
<
0
)
{
tsdbError
(
"vgId:%d failed to load block
statis
part while seek file %s to offset %"
PRId64
" since %s"
,
tsdbError
(
"vgId:%d failed to load block
head
part while seek file %s to offset %"
PRId64
" since %s"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
tstrerror
(
terrno
));
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
}
}
...
@@ -377,14 +383,14 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
...
@@ -377,14 +383,14 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
int64_t
nread
=
tsdbReadDFile
(
pDFile
,
(
void
*
)(
pReadh
->
pBlkData
),
size
);
int64_t
nread
=
tsdbReadDFile
(
pDFile
,
(
void
*
)(
pReadh
->
pBlkData
),
size
);
if
(
nread
<
0
)
{
if
(
nread
<
0
)
{
tsdbError
(
"vgId:%d failed to load block
statis
part while read file %s since %s, offset:%"
PRId64
" len :%"
PRIzu
,
tsdbError
(
"vgId:%d failed to load block
head
part while read file %s since %s, offset:%"
PRId64
" len :%"
PRIzu
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tstrerror
(
terrno
),
(
int64_t
)
pBlock
->
offset
,
size
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tstrerror
(
terrno
),
(
int64_t
)
pBlock
->
offset
,
size
);
return
-
1
;
return
-
1
;
}
}
if
(
nread
<
size
)
{
if
(
nread
<
size
)
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block
statis
part in file %s is corrupted, offset:%"
PRId64
" expected bytes:%"
PRIzu
tsdbError
(
"vgId:%d block
head
part in file %s is corrupted, offset:%"
PRId64
" expected bytes:%"
PRIzu
" read bytes: %"
PRId64
,
" read bytes: %"
PRId64
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
size
,
nread
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
size
,
nread
);
return
-
1
;
return
-
1
;
...
@@ -392,7 +398,7 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
...
@@ -392,7 +398,7 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pReadh
->
pBlkData
),
(
uint32_t
)
size
))
{
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pReadh
->
pBlkData
),
(
uint32_t
)
size
))
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block
statis
part in file %s is corrupted since wrong checksum, offset:%"
PRId64
" len :%"
PRIzu
,
tsdbError
(
"vgId:%d block
head
part in file %s is corrupted since wrong checksum, offset:%"
PRId64
" len :%"
PRIzu
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
size
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
size
);
return
-
1
;
return
-
1
;
}
}
...
@@ -546,7 +552,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
...
@@ -546,7 +552,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
int32_t
tsize
=
(
int32_t
)
tsdbBlockStatisSize
(
pBlock
->
numOfCols
,
(
uint32_t
)
pBlock
->
blkVer
);
int32_t
tsize
=
(
int32_t
)
tsdbBlockStatisSize
(
pBlock
->
numOfCols
,
(
uint32_t
)
pBlock
->
blkVer
);
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
TSDB_READ_BUF
(
pReadh
),
tsize
))
{
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
TSDB_READ_BUF
(
pReadh
),
tsize
))
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block
statis
part in file %s is corrupted since wrong checksum, offset:%"
PRId64
" len :%d"
,
tsdbError
(
"vgId:%d block
head
part in file %s is corrupted since wrong checksum, offset:%"
PRId64
" len :%d"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
tsize
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
tsize
);
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
055e0516
...
@@ -643,6 +643,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
...
@@ -643,6 +643,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
SSubmitMsgIter
msgIter
=
{
0
};
SSubmitMsgIter
msgIter
=
{
0
};
SSubmitBlk
*
pBlock
=
NULL
;
SSubmitBlk
*
pBlock
=
NULL
;
SInterval
interval
=
{
0
};
SInterval
interval
=
{
0
};
TSKEY
lastWinSKey
=
INT64_MIN
;
if
(
tInitSubmitMsgIter
(
pMsg
,
&
msgIter
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tInitSubmitMsgIter
(
pMsg
,
&
msgIter
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
...
@@ -657,7 +658,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
...
@@ -657,7 +658,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
SSubmitBlkIter
blkIter
=
{
0
};
SSubmitBlkIter
blkIter
=
{
0
};
if
(
tInitSubmitBlkIter
(
pBlock
,
&
blkIter
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tInitSubmitBlkIter
(
pBlock
,
&
blkIter
)
!=
TSDB_CODE_SUCCESS
)
{
tdFreeTSmaWrapper
(
pSW
);
pSW
=
tdFreeTSmaWrapper
(
pSW
);
break
;
break
;
}
}
...
@@ -667,31 +668,37 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
...
@@ -667,31 +668,37 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
tdFreeTSmaWrapper
(
pSW
);
tdFreeTSmaWrapper
(
pSW
);
break
;
break
;
}
}
if
(
pSW
==
NULL
)
{
if
(
!
pSW
||
(
pTSma
->
tableUid
!=
pBlock
->
suid
))
{
if
(
pSW
)
{
pSW
=
tdFreeTSmaWrapper
(
pSW
);
}
if
((
pSW
=
metaGetSmaInfoByTable
(
REPO_META
(
pTsdb
),
pBlock
->
suid
))
==
NULL
)
{
if
((
pSW
=
metaGetSmaInfoByTable
(
REPO_META
(
pTsdb
),
pBlock
->
suid
))
==
NULL
)
{
break
;
break
;
}
}
if
((
pSW
->
number
)
<=
0
||
(
pSW
->
tSma
==
NULL
))
{
if
((
pSW
->
number
)
<=
0
||
(
pSW
->
tSma
==
NULL
))
{
tdFreeTSmaWrapper
(
pSW
);
pSW
=
tdFreeTSmaWrapper
(
pSW
);
break
;
break
;
}
}
pTSma
=
pSW
->
tSma
;
pTSma
=
pSW
->
tSma
;
}
interval
.
interval
=
pTSma
->
interval
;
interval
.
interval
=
pTSma
->
interval
;
interval
.
intervalUnit
=
pTSma
->
intervalUnit
;
interval
.
intervalUnit
=
pTSma
->
intervalUnit
;
interval
.
offset
=
pTSma
->
offset
;
interval
.
offset
=
pTSma
->
offset
;
interval
.
precision
=
REPO_CFG
(
pTsdb
)
->
precision
;
interval
.
precision
=
REPO_CFG
(
pTsdb
)
->
precision
;
interval
.
sliding
=
pTSma
->
sliding
;
interval
.
sliding
=
pTSma
->
sliding
;
interval
.
slidingUnit
=
pTSma
->
slidingUnit
;
interval
.
slidingUnit
=
pTSma
->
slidingUnit
;
}
TSKEY
winSKey
=
taosTimeTruncate
(
TD_ROW_KEY
(
row
),
&
interval
,
interval
.
precision
);
TSKEY
winSKey
=
taosTimeTruncate
(
TD_ROW_KEY
(
row
),
&
interval
,
interval
.
precision
);
tsdbSetExpiredWindow
(
pTsdb
,
pItemsHash
,
pTSma
->
indexUid
,
winSKey
,
version
);
if
(
lastWinSKey
!=
winSKey
)
{
lastWinSKey
=
winSKey
;
// TODO: release only when suid changes.
tsdbSetExpiredWindow
(
pTsdb
,
pItemsHash
,
pTSma
->
indexUid
,
winSKey
,
version
);
tdDestroyTSmaWrapper
(
pSW
);
}
else
{
taosMemoryFreeClear
(
pSW
);
tsdbDebug
(
"vgId:%d smaIndex %"
PRIi64
", put skey %"
PRIi64
" to expire window ignore as duplicated"
,
REPO_ID
(
pTsdb
),
pTSma
->
indexUid
,
winSKey
);
}
}
}
}
}
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
055e0516
...
@@ -643,6 +643,49 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmt
...
@@ -643,6 +643,49 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmt
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgGetUdfInfoFromMnode
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
funcName
,
SFuncInfo
**
out
)
{
char
*
msg
=
NULL
;
int32_t
msgLen
=
0
;
ctgDebug
(
"try to get udf info from mnode, funcName:%s"
,
funcName
);
int32_t
code
=
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_RETRIEVE_FUNC
)]((
void
*
)
funcName
,
&
msg
,
0
,
&
msgLen
);
if
(
code
)
{
ctgError
(
"Build get udf msg failed, code:%x, db:%s"
,
code
,
funcName
);
CTG_ERR_RET
(
code
);
}
SRpcMsg
rpcMsg
=
{
.
msgType
=
TDMT_MND_RETRIEVE_FUNC
,
.
pCont
=
msg
,
.
contLen
=
msgLen
,
};
SRpcMsg
rpcRsp
=
{
0
};
rpcSendRecv
(
pRpc
,
(
SEpSet
*
)
pMgmtEps
,
&
rpcMsg
,
&
rpcRsp
);
if
(
TSDB_CODE_SUCCESS
!=
rpcRsp
.
code
)
{
if
(
TSDB_CODE_MND_FUNC_NOT_EXIST
==
rpcRsp
.
code
)
{
ctgDebug
(
"funcName %s not exist in mnode"
,
funcName
);
taosMemoryFreeClear
(
*
out
);
CTG_RET
(
TSDB_CODE_SUCCESS
);
}
ctgError
(
"error rsp for get udf, error:%s, funcName:%s"
,
tstrerror
(
rpcRsp
.
code
),
funcName
);
CTG_ERR_RET
(
rpcRsp
.
code
);
}
code
=
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_RETRIEVE_FUNC
)](
*
out
,
rpcRsp
.
pCont
,
rpcRsp
.
contLen
);
if
(
code
)
{
ctgError
(
"Process get udf rsp failed, code:%x, funcName:%s"
,
code
,
funcName
);
CTG_ERR_RET
(
code
);
}
ctgDebug
(
"Got udf from mnode, funcName:%s"
,
funcName
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgIsTableMetaExistInCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tbName
,
int32_t
*
exist
)
{
int32_t
ctgIsTableMetaExistInCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tbName
,
int32_t
*
exist
)
{
if
(
NULL
==
pCtg
->
dbCache
)
{
if
(
NULL
==
pCtg
->
dbCache
)
{
...
@@ -2811,6 +2854,30 @@ int32_t catalogGetIndexInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps,
...
@@ -2811,6 +2854,30 @@ int32_t catalogGetIndexInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps,
CTG_API_LEAVE
(
ctgGetIndexInfoFromMnode
(
pCtg
,
pRpc
,
pMgmtEps
,
indexName
,
pInfo
));
CTG_API_LEAVE
(
ctgGetIndexInfoFromMnode
(
pCtg
,
pRpc
,
pMgmtEps
,
indexName
,
pInfo
));
}
}
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
funcName
,
SFuncInfo
**
pInfo
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pRpc
||
NULL
==
pMgmtEps
||
NULL
==
funcName
||
NULL
==
pInfo
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
int32_t
code
=
0
;
*
pInfo
=
taosMemoryMalloc
(
sizeof
(
SFuncInfo
));
if
(
NULL
==
*
pInfo
)
{
CTG_API_LEAVE
(
TSDB_CODE_OUT_OF_MEMORY
);
}
CTG_ERR_JRET
(
ctgGetUdfInfoFromMnode
(
pCtg
,
pRpc
,
pMgmtEps
,
funcName
,
pInfo
));
_return:
if
(
code
)
{
taosMemoryFreeClear
(
*
pInfo
);
}
CTG_API_LEAVE
(
code
);
}
void
catalogDestroy
(
void
)
{
void
catalogDestroy
(
void
)
{
qInfo
(
"start to destroy catalog"
);
qInfo
(
"start to destroy catalog"
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
055e0516
此差异已折叠。
点击以展开。
source/libs/function/src/functionMgt.c
浏览文件 @
055e0516
...
@@ -29,6 +29,7 @@ typedef struct SFuncMgtService {
...
@@ -29,6 +29,7 @@ typedef struct SFuncMgtService {
typedef
struct
SUdfInfo
{
typedef
struct
SUdfInfo
{
SDataType
outputDt
;
SDataType
outputDt
;
int8_t
funcType
;
}
SUdfInfo
;
}
SUdfInfo
;
static
SFuncMgtService
gFunMgtService
;
static
SFuncMgtService
gFunMgtService
;
...
@@ -52,30 +53,41 @@ static void doInitFunctionTable() {
...
@@ -52,30 +53,41 @@ static void doInitFunctionTable() {
gFunMgtService
.
pUdfTable
=
NULL
;
gFunMgtService
.
pUdfTable
=
NULL
;
}
}
static
int8_t
getUdfType
(
int32_t
funcId
)
{
SUdfInfo
*
pUdf
=
taosArrayGet
(
gFunMgtService
.
pUdfTable
,
funcId
-
FUNC_UDF_ID_START_OFFSET_VAL
-
1
);
return
pUdf
->
funcType
;
}
static
bool
isSpecificClassifyFunc
(
int32_t
funcId
,
uint64_t
classification
)
{
static
bool
isSpecificClassifyFunc
(
int32_t
funcId
,
uint64_t
classification
)
{
if
(
fmIsUserDefinedFunc
(
funcId
))
{
return
getUdfType
(
funcId
);
}
if
(
funcId
<
0
||
funcId
>=
funcMgtBuiltinsNum
)
{
if
(
funcId
<
0
||
funcId
>=
funcMgtBuiltinsNum
)
{
return
false
;
return
false
;
}
}
return
FUNC_MGT_TEST_MASK
(
funcMgtBuiltins
[
funcId
].
classification
,
classification
);
return
FUNC_MGT_TEST_MASK
(
funcMgtBuiltins
[
funcId
].
classification
,
classification
);
}
}
static
int32_t
getUdfId
(
const
char
*
pFuncName
)
{
static
int32_t
getUdfId
(
SFmGetFuncInfoParam
*
pParam
,
const
char
*
pFuncName
)
{
// todo: udf by call catalog
SFuncInfo
*
pInfo
=
NULL
;
if
(
1
)
{
int32_t
code
=
catalogGetUdfInfo
(
pParam
->
pCtg
,
pParam
->
pRpc
,
pParam
->
pMgmtEps
,
pFuncName
,
&
pInfo
);
if
(
TSDB_CODE_SUCCESS
!=
code
||
NULL
==
pInfo
)
{
return
-
1
;
return
-
1
;
}
}
if
(
NULL
==
gFunMgtService
.
pUdfTable
)
{
if
(
NULL
==
gFunMgtService
.
pUdfTable
)
{
gFunMgtService
.
pUdfTable
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
sizeof
(
SUdfInfo
));
gFunMgtService
.
pUdfTable
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
sizeof
(
SUdfInfo
));
}
}
SUdfInfo
info
=
{
0
};
//todo
SUdfInfo
info
=
{
.
outputDt
.
type
=
pInfo
->
outputType
,
.
outputDt
.
bytes
=
pInfo
->
outputLen
,
.
funcType
=
pInfo
->
funcType
};
taosArrayPush
(
gFunMgtService
.
pUdfTable
,
&
info
);
taosArrayPush
(
gFunMgtService
.
pUdfTable
,
&
info
);
tFreeSFuncInfo
(
pInfo
);
taosMemoryFree
(
pInfo
);
return
taosArrayGetSize
(
gFunMgtService
.
pUdfTable
)
+
FUNC_UDF_ID_START_OFFSET_VAL
;
return
taosArrayGetSize
(
gFunMgtService
.
pUdfTable
)
+
FUNC_UDF_ID_START_OFFSET_VAL
;
}
}
static
int32_t
getFuncId
(
const
char
*
pFuncName
)
{
static
int32_t
getFuncId
(
SFmGetFuncInfoParam
*
pParam
,
const
char
*
pFuncName
)
{
void
*
pVal
=
taosHashGet
(
gFunMgtService
.
pFuncNameHashTable
,
pFuncName
,
strlen
(
pFuncName
));
void
*
pVal
=
taosHashGet
(
gFunMgtService
.
pFuncNameHashTable
,
pFuncName
,
strlen
(
pFuncName
));
if
(
NULL
==
pVal
)
{
if
(
NULL
==
pVal
)
{
return
getUdfId
(
pFuncName
);
return
getUdfId
(
p
Param
,
p
FuncName
);
}
}
return
*
(
int32_t
*
)
pVal
;
return
*
(
int32_t
*
)
pVal
;
}
}
...
@@ -91,8 +103,8 @@ int32_t fmFuncMgtInit() {
...
@@ -91,8 +103,8 @@ int32_t fmFuncMgtInit() {
return
initFunctionCode
;
return
initFunctionCode
;
}
}
int32_t
fmGetFuncInfo
(
const
char
*
pFuncName
,
int32_t
*
pFuncId
,
int32_t
*
pFuncType
)
{
int32_t
fmGetFuncInfo
(
SFmGetFuncInfoParam
*
pParam
,
const
char
*
pFuncName
,
int32_t
*
pFuncId
,
int32_t
*
pFuncType
)
{
*
pFuncId
=
getFuncId
(
pFuncName
);
*
pFuncId
=
getFuncId
(
p
Param
,
p
FuncName
);
if
(
*
pFuncId
<
0
)
{
if
(
*
pFuncId
<
0
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
...
source/libs/parser/inc/sql.y
浏览文件 @
055e0516
...
@@ -837,6 +837,8 @@ query_expression(A) ::=
...
@@ -837,6 +837,8 @@ query_expression(A) ::=
query_expression_body(A) ::= query_primary(B). { A = B; }
query_expression_body(A) ::= query_primary(B). { A = B; }
query_expression_body(A) ::=
query_expression_body(A) ::=
query_expression_body(B) UNION ALL query_expression_body(D). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, B, D); }
query_expression_body(B) UNION ALL query_expression_body(D). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, B, D); }
query_expression_body(A) ::=
query_expression_body(B) UNION query_expression_body(D). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION, B, D); }
query_primary(A) ::= query_specification(B). { A = B; }
query_primary(A) ::= query_specification(B). { A = B; }
//query_primary(A) ::=
//query_primary(A) ::=
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
055e0516
...
@@ -230,6 +230,21 @@ static int32_t initTranslateContext(SParseContext* pParseCxt, STranslateContext*
...
@@ -230,6 +230,21 @@ static int32_t initTranslateContext(SParseContext* pParseCxt, STranslateContext*
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
resetTranslateNamespace
(
STranslateContext
*
pCxt
)
{
if
(
NULL
!=
pCxt
->
pNsLevel
)
{
size_t
size
=
taosArrayGetSize
(
pCxt
->
pNsLevel
);
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
taosArrayDestroy
(
taosArrayGetP
(
pCxt
->
pNsLevel
,
i
));
}
taosArrayDestroy
(
pCxt
->
pNsLevel
);
}
pCxt
->
pNsLevel
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
POINTER_BYTES
);
if
(
NULL
==
pCxt
->
pNsLevel
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
return
TSDB_CODE_SUCCESS
;
}
static
void
destroyTranslateContext
(
STranslateContext
*
pCxt
)
{
static
void
destroyTranslateContext
(
STranslateContext
*
pCxt
)
{
if
(
NULL
!=
pCxt
->
pNsLevel
)
{
if
(
NULL
!=
pCxt
->
pNsLevel
)
{
size_t
size
=
taosArrayGetSize
(
pCxt
->
pNsLevel
);
size_t
size
=
taosArrayGetSize
(
pCxt
->
pNsLevel
);
...
@@ -261,9 +276,11 @@ static bool belongTable(const char* currentDb, const SColumnNode* pCol, const ST
...
@@ -261,9 +276,11 @@ static bool belongTable(const char* currentDb, const SColumnNode* pCol, const ST
return
(
0
==
cmp
);
return
(
0
==
cmp
);
}
}
static
SNodeList
*
getProjectList
(
SNode
*
pNode
)
{
static
SNodeList
*
getProjectList
(
const
SNode
*
pNode
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pNode
))
{
return
((
SSelectStmt
*
)
pNode
)
->
pProjectionList
;
return
((
SSelectStmt
*
)
pNode
)
->
pProjectionList
;
}
else
if
(
QUERY_NODE_SET_OPERATOR
==
nodeType
(
pNode
))
{
return
((
SSetOperator
*
)
pNode
)
->
pProjectionList
;
}
}
return
NULL
;
return
NULL
;
}
}
...
@@ -568,7 +585,8 @@ static EDealRes haveAggFunction(SNode* pNode, void* pContext) {
...
@@ -568,7 +585,8 @@ static EDealRes haveAggFunction(SNode* pNode, void* pContext) {
}
}
static
EDealRes
translateFunction
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pFunc
)
{
static
EDealRes
translateFunction
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pFunc
)
{
if
(
TSDB_CODE_SUCCESS
!=
fmGetFuncInfo
(
pFunc
->
functionName
,
&
pFunc
->
funcId
,
&
pFunc
->
funcType
))
{
SFmGetFuncInfoParam
param
=
{
.
pCtg
=
pCxt
->
pParseCxt
->
pCatalog
,
.
pRpc
=
pCxt
->
pParseCxt
->
pTransporter
,
.
pMgmtEps
=
&
pCxt
->
pParseCxt
->
mgmtEpSet
};
if
(
TSDB_CODE_SUCCESS
!=
fmGetFuncInfo
(
&
param
,
pFunc
->
functionName
,
&
pFunc
->
funcId
,
&
pFunc
->
funcType
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_FUNTION
,
pFunc
->
functionName
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_FUNTION
,
pFunc
->
functionName
);
}
}
pCxt
->
errCode
=
fmGetFuncResultType
(
pFunc
,
pCxt
->
msgBuf
.
buf
,
pCxt
->
msgBuf
.
len
);
pCxt
->
errCode
=
fmGetFuncResultType
(
pFunc
,
pCxt
->
msgBuf
.
buf
,
pCxt
->
msgBuf
.
len
);
...
@@ -1353,13 +1371,77 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -1353,13 +1371,77 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
return
code
;
return
code
;
}
}
static
SNode
*
createSetOperProject
(
SNode
*
pNode
)
{
SColumnNode
*
pCol
=
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
return
NULL
;
}
pCol
->
node
.
resType
=
((
SExprNode
*
)
pNode
)
->
resType
;
strcpy
(
pCol
->
colName
,
((
SExprNode
*
)
pNode
)
->
aliasName
);
strcpy
(
pCol
->
node
.
aliasName
,
pCol
->
colName
);
return
(
SNode
*
)
pCol
;
}
static
bool
dataTypeEqual
(
const
SDataType
*
l
,
const
SDataType
*
r
)
{
return
(
l
->
type
==
r
->
type
&&
l
->
bytes
==
l
->
bytes
&&
l
->
precision
==
r
->
precision
&&
l
->
scale
==
l
->
scale
);
}
static
int32_t
createCastFunc
(
STranslateContext
*
pCxt
,
SNode
*
pExpr
,
SDataType
dt
,
SNode
**
pCast
)
{
SFunctionNode
*
pFunc
=
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pFunc
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
strcpy
(
pFunc
->
functionName
,
"cast"
);
pFunc
->
node
.
resType
=
dt
;
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeAppend
(
&
pFunc
->
pParameterList
,
pExpr
))
{
nodesDestroyNode
(
pFunc
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
DEAL_RES_ERROR
==
translateFunction
(
pCxt
,
pFunc
))
{
nodesClearList
(
pFunc
->
pParameterList
);
pFunc
->
pParameterList
=
NULL
;
nodesDestroyNode
(
pFunc
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)
pExpr
)
->
aliasName
);
}
*
pCast
=
(
SNode
*
)
pFunc
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateSetOperatorImpl
(
STranslateContext
*
pCxt
,
SSetOperator
*
pSetOperator
)
{
static
int32_t
translateSetOperatorImpl
(
STranslateContext
*
pCxt
,
SSetOperator
*
pSetOperator
)
{
// todo
SNodeList
*
pLeftProjections
=
getProjectList
(
pSetOperator
->
pLeft
);
SNodeList
*
pRightProjections
=
getProjectList
(
pSetOperator
->
pRight
);
if
(
LIST_LENGTH
(
pLeftProjections
)
!=
LIST_LENGTH
(
pRightProjections
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INCORRECT_NUM_OF_COL
);
}
SNode
*
pLeft
=
NULL
;
SNode
*
pRight
=
NULL
;
FORBOTH
(
pLeft
,
pLeftProjections
,
pRight
,
pRightProjections
)
{
SExprNode
*
pLeftExpr
=
(
SExprNode
*
)
pLeft
;
SExprNode
*
pRightExpr
=
(
SExprNode
*
)
pRight
;
if
(
!
dataTypeEqual
(
&
pLeftExpr
->
resType
,
&
pRightExpr
->
resType
))
{
SNode
*
pRightFunc
=
NULL
;
int32_t
code
=
createCastFunc
(
pCxt
,
pRight
,
pLeftExpr
->
resType
,
&
pRightFunc
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
REPLACE_LIST2_NODE
(
pRightFunc
);
pRightExpr
=
(
SExprNode
*
)
pRightFunc
;
}
strcpy
(
pRightExpr
->
aliasName
,
pLeftExpr
->
aliasName
);
pRightExpr
->
aliasName
[
strlen
(
pLeftExpr
->
aliasName
)]
=
'\0'
;
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pSetOperator
->
pProjectionList
,
createSetOperProject
(
pLeft
)))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
translateSetOperator
(
STranslateContext
*
pCxt
,
SSetOperator
*
pSetOperator
)
{
static
int32_t
translateSetOperator
(
STranslateContext
*
pCxt
,
SSetOperator
*
pSetOperator
)
{
int32_t
code
=
translateQuery
(
pCxt
,
pSetOperator
->
pLeft
);
int32_t
code
=
translateQuery
(
pCxt
,
pSetOperator
->
pLeft
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
resetTranslateNamespace
(
pCxt
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateQuery
(
pCxt
,
pSetOperator
->
pRight
);
code
=
translateQuery
(
pCxt
,
pSetOperator
->
pRight
);
}
}
...
@@ -1837,7 +1919,8 @@ static int32_t checkTableRollupOption(STranslateContext* pCxt, SNodeList* pFuncs
...
@@ -1837,7 +1919,8 @@ static int32_t checkTableRollupOption(STranslateContext* pCxt, SNodeList* pFuncs
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
);
}
}
SFunctionNode
*
pFunc
=
nodesListGetNode
(
pFuncs
,
0
);
SFunctionNode
*
pFunc
=
nodesListGetNode
(
pFuncs
,
0
);
if
(
TSDB_CODE_SUCCESS
!=
fmGetFuncInfo
(
pFunc
->
functionName
,
&
pFunc
->
funcId
,
&
pFunc
->
funcType
))
{
SFmGetFuncInfoParam
param
=
{
.
pCtg
=
pCxt
->
pParseCxt
->
pCatalog
,
.
pRpc
=
pCxt
->
pParseCxt
->
pTransporter
,
.
pMgmtEps
=
&
pCxt
->
pParseCxt
->
mgmtEpSet
};
if
(
TSDB_CODE_SUCCESS
!=
fmGetFuncInfo
(
&
param
,
pFunc
->
functionName
,
&
pFunc
->
funcId
,
&
pFunc
->
funcType
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_FUNTION
,
pFunc
->
functionName
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_FUNTION
,
pFunc
->
functionName
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -2794,8 +2877,8 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
...
@@ -2794,8 +2877,8 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
return
code
;
return
code
;
}
}
static
int32_t
extract
SelectResultSchema
(
const
SSelectStmt
*
pSelect
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
static
int32_t
extract
QueryResultSchema
(
const
SNodeList
*
pProjections
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
*
numOfCols
=
LIST_LENGTH
(
p
Select
->
pProjectionList
);
*
numOfCols
=
LIST_LENGTH
(
p
Projections
);
*
pSchema
=
taosMemoryCalloc
((
*
numOfCols
),
sizeof
(
SSchema
));
*
pSchema
=
taosMemoryCalloc
((
*
numOfCols
),
sizeof
(
SSchema
));
if
(
NULL
==
(
*
pSchema
))
{
if
(
NULL
==
(
*
pSchema
))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -2803,7 +2886,7 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu
...
@@ -2803,7 +2886,7 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu
SNode
*
pNode
;
SNode
*
pNode
;
int32_t
index
=
0
;
int32_t
index
=
0
;
FOREACH
(
pNode
,
p
Select
->
pProjectionList
)
{
FOREACH
(
pNode
,
p
Projections
)
{
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
(
*
pSchema
)[
index
].
type
=
pExpr
->
resType
.
type
;
(
*
pSchema
)[
index
].
type
=
pExpr
->
resType
.
type
;
(
*
pSchema
)[
index
].
bytes
=
pExpr
->
resType
.
bytes
;
(
*
pSchema
)[
index
].
bytes
=
pExpr
->
resType
.
bytes
;
...
@@ -2862,7 +2945,8 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS
...
@@ -2862,7 +2945,8 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS
switch
(
nodeType
(
pRoot
))
{
switch
(
nodeType
(
pRoot
))
{
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
return
extractSelectResultSchema
((
SSelectStmt
*
)
pRoot
,
numOfCols
,
pSchema
);
case
QUERY_NODE_SET_OPERATOR
:
return
extractQueryResultSchema
(
getProjectList
(
pRoot
),
numOfCols
,
pSchema
);
case
QUERY_NODE_EXPLAIN_STMT
:
case
QUERY_NODE_EXPLAIN_STMT
:
return
extractExplainResultSchema
(
numOfCols
,
pSchema
);
return
extractExplainResultSchema
(
numOfCols
,
pSchema
);
case
QUERY_NODE_DESCRIBE_STMT
:
case
QUERY_NODE_DESCRIBE_STMT
:
...
@@ -3487,6 +3571,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -3487,6 +3571,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
static
int32_t
setQuery
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
static
int32_t
setQuery
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
switch
(
nodeType
(
pQuery
->
pRoot
))
{
switch
(
nodeType
(
pQuery
->
pRoot
))
{
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SET_OPERATOR
:
case
QUERY_NODE_EXPLAIN_STMT
:
case
QUERY_NODE_EXPLAIN_STMT
:
pQuery
->
execMode
=
QUERY_EXEC_MODE_SCHEDULE
;
pQuery
->
execMode
=
QUERY_EXEC_MODE_SCHEDULE
;
pQuery
->
haveResultSet
=
true
;
pQuery
->
haveResultSet
=
true
;
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
055e0516
...
@@ -118,6 +118,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -118,6 +118,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"sliding value can not less than 1% of interval value"
;
return
"sliding value can not less than 1% of interval value"
;
case
TSDB_CODE_PAR_ONLY_ONE_JSON_TAG
:
case
TSDB_CODE_PAR_ONLY_ONE_JSON_TAG
:
return
"Only one tag if there is a json tag"
;
return
"Only one tag if there is a json tag"
;
case
TSDB_CODE_PAR_INCORRECT_NUM_OF_COL
:
return
"Query block has incorrect number of result columns"
;
case
TSDB_CODE_OUT_OF_MEMORY
:
case
TSDB_CODE_OUT_OF_MEMORY
:
return
"Out of memory"
;
return
"Out of memory"
;
default:
default:
...
...
source/libs/parser/src/sql.c
浏览文件 @
055e0516
此差异已折叠。
点击以展开。
source/libs/planner/src/planLogicCreater.c
浏览文件 @
055e0516
...
@@ -22,6 +22,7 @@ typedef struct SLogicPlanContext {
...
@@ -22,6 +22,7 @@ typedef struct SLogicPlanContext {
}
SLogicPlanContext
;
}
SLogicPlanContext
;
typedef
int32_t
(
*
FCreateLogicNode
)(
SLogicPlanContext
*
,
SSelectStmt
*
,
SLogicNode
**
);
typedef
int32_t
(
*
FCreateLogicNode
)(
SLogicPlanContext
*
,
SSelectStmt
*
,
SLogicNode
**
);
typedef
int32_t
(
*
FCreateSetOpLogicNode
)(
SLogicPlanContext
*
,
SSetOperator
*
,
SLogicNode
**
);
static
int32_t
doCreateLogicNodeByTable
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SNode
*
pTable
,
SLogicNode
**
pLogicNode
);
static
int32_t
doCreateLogicNodeByTable
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SNode
*
pTable
,
SLogicNode
**
pLogicNode
);
static
int32_t
createQueryLogicNode
(
SLogicPlanContext
*
pCxt
,
SNode
*
pStmt
,
SLogicNode
**
pLogicNode
);
static
int32_t
createQueryLogicNode
(
SLogicPlanContext
*
pCxt
,
SNode
*
pStmt
,
SLogicNode
**
pLogicNode
);
...
@@ -84,13 +85,19 @@ static EDealRes doNameExpr(SNode* pNode, void* pContext) {
...
@@ -84,13 +85,19 @@ static EDealRes doNameExpr(SNode* pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
static
int32_t
rewriteExpr
(
SNodeList
*
pExprs
,
SSelectStmt
*
pSelect
,
ESqlClause
clause
)
{
static
int32_t
rewriteExpr
ForSelect
(
SNodeList
*
pExprs
,
SSelectStmt
*
pSelect
,
ESqlClause
clause
)
{
nodesWalkExprs
(
pExprs
,
doNameExpr
,
NULL
);
nodesWalkExprs
(
pExprs
,
doNameExpr
,
NULL
);
SRewriteExprCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
pExprs
=
pExprs
};
SRewriteExprCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
pExprs
=
pExprs
};
nodesRewriteSelectStmt
(
pSelect
,
clause
,
doRewriteExpr
,
&
cxt
);
nodesRewriteSelectStmt
(
pSelect
,
clause
,
doRewriteExpr
,
&
cxt
);
return
cxt
.
errCode
;
return
cxt
.
errCode
;
}
}
static
int32_t
rewriteExprs
(
SNodeList
*
pExprs
,
SNodeList
*
pTarget
)
{
SRewriteExprCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
pExprs
=
pExprs
};
nodesRewriteExprs
(
pTarget
,
doRewriteExpr
,
&
cxt
);
return
cxt
.
errCode
;
}
static
int32_t
pushLogicNode
(
SLogicPlanContext
*
pCxt
,
SLogicNode
**
pOldRoot
,
SLogicNode
*
pNewRoot
)
{
static
int32_t
pushLogicNode
(
SLogicPlanContext
*
pCxt
,
SLogicNode
**
pOldRoot
,
SLogicNode
*
pNewRoot
)
{
if
(
NULL
==
pNewRoot
->
pChildren
)
{
if
(
NULL
==
pNewRoot
->
pChildren
)
{
pNewRoot
->
pChildren
=
nodesMakeList
();
pNewRoot
->
pChildren
=
nodesMakeList
();
...
@@ -343,7 +350,9 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr)
...
@@ -343,7 +350,9 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr)
}
}
pCol
->
node
.
resType
=
pExpr
->
resType
;
pCol
->
node
.
resType
=
pExpr
->
resType
;
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
strcpy
(
pCol
->
tableAlias
,
pStmtName
);
if
(
NULL
!=
pStmtName
)
{
strcpy
(
pCol
->
tableAlias
,
pStmtName
);
}
return
pCol
;
return
pCol
;
}
}
...
@@ -430,10 +439,10 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
...
@@ -430,10 +439,10 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
// rewrite the expression in subsequent clauses
// rewrite the expression in subsequent clauses
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExpr
(
pAgg
->
pGroupKeys
,
pSelect
,
SQL_CLAUSE_GROUP_BY
);
code
=
rewriteExpr
ForSelect
(
pAgg
->
pGroupKeys
,
pSelect
,
SQL_CLAUSE_GROUP_BY
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExpr
(
pAgg
->
pAggFuncs
,
pSelect
,
SQL_CLAUSE_GROUP_BY
);
code
=
rewriteExpr
ForSelect
(
pAgg
->
pAggFuncs
,
pSelect
,
SQL_CLAUSE_GROUP_BY
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pSelect
->
pHaving
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pSelect
->
pHaving
)
{
...
@@ -469,7 +478,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
...
@@ -469,7 +478,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExpr
(
pWindow
->
pFuncs
,
pSelect
,
SQL_CLAUSE_WINDOW
);
code
=
rewriteExpr
ForSelect
(
pWindow
->
pFuncs
,
pSelect
,
SQL_CLAUSE_WINDOW
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -720,7 +729,7 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
...
@@ -720,7 +729,7 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
// rewrite the expression in subsequent clauses
// rewrite the expression in subsequent clauses
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExpr
(
pAgg
->
pGroupKeys
,
pSelect
,
SQL_CLAUSE_DISTINCT
);
code
=
rewriteExpr
ForSelect
(
pAgg
->
pGroupKeys
,
pSelect
,
SQL_CLAUSE_DISTINCT
);
}
}
// set the output
// set the output
...
@@ -768,11 +777,160 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
...
@@ -768,11 +777,160 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
return
code
;
return
code
;
}
}
static
int32_t
createSetOpChildLogicNode
(
SLogicPlanContext
*
pCxt
,
SSetOperator
*
pSetOperator
,
FCreateSetOpLogicNode
func
,
SLogicNode
**
pRoot
)
{
SLogicNode
*
pNode
=
NULL
;
int32_t
code
=
func
(
pCxt
,
pSetOperator
,
&
pNode
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pNode
)
{
code
=
pushLogicNode
(
pCxt
,
pRoot
,
pNode
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
(
pNode
);
}
return
code
;
}
static
int32_t
createSetOpSortLogicNode
(
SLogicPlanContext
*
pCxt
,
SSetOperator
*
pSetOperator
,
SLogicNode
**
pLogicNode
)
{
if
(
NULL
==
pSetOperator
->
pOrderByList
)
{
return
TSDB_CODE_SUCCESS
;
}
SSortLogicNode
*
pSort
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_SORT
);
if
(
NULL
==
pSort
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
pSort
->
node
.
pTargets
=
nodesCloneList
(
pSetOperator
->
pProjectionList
);
if
(
NULL
==
pSort
->
node
.
pTargets
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pSort
->
pSortKeys
=
nodesCloneList
(
pSetOperator
->
pOrderByList
);
if
(
NULL
==
pSort
->
pSortKeys
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pSort
;
}
else
{
nodesDestroyNode
(
pSort
);
}
return
code
;
}
static
int32_t
createSetOpProjectLogicNode
(
SLogicPlanContext
*
pCxt
,
SSetOperator
*
pSetOperator
,
SLogicNode
**
pLogicNode
)
{
SProjectLogicNode
*
pProject
=
(
SProjectLogicNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_PROJECT
);
if
(
NULL
==
pProject
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
NULL
!=
pSetOperator
->
pLimit
)
{
pProject
->
limit
=
((
SLimitNode
*
)
pSetOperator
->
pLimit
)
->
limit
;
pProject
->
offset
=
((
SLimitNode
*
)
pSetOperator
->
pLimit
)
->
offset
;
}
else
{
pProject
->
limit
=
-
1
;
pProject
->
offset
=
-
1
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
pProject
->
pProjections
=
nodesCloneList
(
pSetOperator
->
pProjectionList
);
if
(
NULL
==
pProject
->
pProjections
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByProjections
(
pCxt
,
NULL
,
pSetOperator
->
pProjectionList
,
&
pProject
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pProject
;
}
else
{
nodesDestroyNode
(
pProject
);
}
return
code
;
}
static
int32_t
createSetOpAggLogicNode
(
SLogicPlanContext
*
pCxt
,
SSetOperator
*
pSetOperator
,
SLogicNode
**
pLogicNode
)
{
SAggLogicNode
*
pAgg
=
(
SAggLogicNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_AGG
);
if
(
NULL
==
pAgg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
pAgg
->
pGroupKeys
=
nodesCloneList
(
pSetOperator
->
pProjectionList
);
if
(
NULL
==
pAgg
->
pGroupKeys
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
// rewrite the expression in subsequent clauses
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExprs
(
pAgg
->
pGroupKeys
,
pSetOperator
->
pOrderByList
);
}
// set the output
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExps
(
pCxt
,
pAgg
->
pGroupKeys
,
&
pAgg
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pAgg
;
}
else
{
nodesDestroyNode
(
pAgg
);
}
return
code
;
}
static
int32_t
createSetOpLogicNode
(
SLogicPlanContext
*
pCxt
,
SSetOperator
*
pSetOperator
,
SLogicNode
**
pLogicNode
)
{
SLogicNode
*
pSetOp
=
NULL
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
pSetOperator
->
opType
)
{
case
SET_OP_TYPE_UNION_ALL
:
code
=
createSetOpProjectLogicNode
(
pCxt
,
pSetOperator
,
&
pSetOp
);
break
;
case
SET_OP_TYPE_UNION
:
code
=
createSetOpAggLogicNode
(
pCxt
,
pSetOperator
,
&
pSetOp
);
break
;
default:
code
=
-
1
;
break
;
}
SLogicNode
*
pLeft
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createQueryLogicNode
(
pCxt
,
pSetOperator
->
pLeft
,
&
pLeft
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeStrictAppend
(
&
pSetOp
->
pChildren
,
(
SNode
*
)
pLeft
);
}
SLogicNode
*
pRight
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createQueryLogicNode
(
pCxt
,
pSetOperator
->
pRight
,
&
pRight
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListStrictAppend
(
pSetOp
->
pChildren
,
(
SNode
*
)
pRight
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pSetOp
;
}
else
{
nodesDestroyNode
(
pSetOp
);
}
return
code
;
}
static
int32_t
createSetOperatorLogicNode
(
SLogicPlanContext
*
pCxt
,
SSetOperator
*
pSetOperator
,
SLogicNode
**
pLogicNode
)
{
static
int32_t
createSetOperatorLogicNode
(
SLogicPlanContext
*
pCxt
,
SSetOperator
*
pSetOperator
,
SLogicNode
**
pLogicNode
)
{
SLogicNode
*
pRoot
=
NULL
;
SLogicNode
*
pRoot
=
NULL
;
int32_t
code
=
create
QueryLogicNode
(
pCxt
,
pSetOperator
->
pLeft
,
&
pRoot
);
int32_t
code
=
create
SetOpLogicNode
(
pCxt
,
pSetOperator
,
&
pRoot
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
create
QueryLogicNode
(
pCxt
,
pSetOperator
->
pRight
,
&
pRoot
);
code
=
create
SetOpChildLogicNode
(
pCxt
,
pSetOperator
,
createSetOpSortLogicNode
,
&
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
055e0516
...
@@ -228,6 +228,8 @@ static int32_t cpdMergeConds(SNode** pDst, SNodeList** pSrc) {
...
@@ -228,6 +228,8 @@ static int32_t cpdMergeConds(SNode** pDst, SNodeList** pSrc) {
if
(
NULL
==
pLogicCond
)
{
if
(
NULL
==
pLogicCond
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pLogicCond
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
pLogicCond
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
pLogicCond
->
condType
=
LOGIC_COND_TYPE_AND
;
pLogicCond
->
condType
=
LOGIC_COND_TYPE_AND
;
pLogicCond
->
pParameterList
=
*
pSrc
;
pLogicCond
->
pParameterList
=
*
pSrc
;
*
pDst
=
(
SNode
*
)
pLogicCond
;
*
pDst
=
(
SNode
*
)
pLogicCond
;
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
055e0516
...
@@ -38,7 +38,7 @@ typedef struct SPhysiPlanContext {
...
@@ -38,7 +38,7 @@ typedef struct SPhysiPlanContext {
static
int32_t
getSlotKey
(
SNode
*
pNode
,
const
char
*
pStmtName
,
char
*
pKey
)
{
static
int32_t
getSlotKey
(
SNode
*
pNode
,
const
char
*
pStmtName
,
char
*
pKey
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
NULL
!=
pStmtName
)
{
if
(
NULL
!=
pStmtName
&&
'\0'
!=
pStmtName
[
0
]
)
{
return
sprintf
(
pKey
,
"%s.%s"
,
pStmtName
,
pCol
->
node
.
aliasName
);
return
sprintf
(
pKey
,
"%s.%s"
,
pStmtName
,
pCol
->
node
.
aliasName
);
}
}
if
(
'\0'
==
pCol
->
tableAlias
[
0
])
{
if
(
'\0'
==
pCol
->
tableAlias
[
0
])
{
...
@@ -47,7 +47,7 @@ static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char* pKey) {
...
@@ -47,7 +47,7 @@ static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char* pKey) {
return
sprintf
(
pKey
,
"%s.%s"
,
pCol
->
tableAlias
,
pCol
->
colName
);
return
sprintf
(
pKey
,
"%s.%s"
,
pCol
->
tableAlias
,
pCol
->
colName
);
}
}
if
(
NULL
!=
pStmtName
)
{
if
(
NULL
!=
pStmtName
&&
'\0'
!=
pStmtName
[
0
]
)
{
return
sprintf
(
pKey
,
"%s.%s"
,
pStmtName
,
((
SExprNode
*
)
pNode
)
->
aliasName
);
return
sprintf
(
pKey
,
"%s.%s"
,
pStmtName
,
((
SExprNode
*
)
pNode
)
->
aliasName
);
}
}
return
sprintf
(
pKey
,
"%s"
,
((
SExprNode
*
)
pNode
)
->
aliasName
);
return
sprintf
(
pKey
,
"%s"
,
((
SExprNode
*
)
pNode
)
->
aliasName
);
...
...
source/libs/planner/src/planScaleOut.c
浏览文件 @
055e0516
...
@@ -129,7 +129,7 @@ static int32_t pushHierarchicalPlan(SNodeList* pParentsGroup, SNodeList* pCurren
...
@@ -129,7 +129,7 @@ static int32_t pushHierarchicalPlan(SNodeList* pParentsGroup, SNodeList* pCurren
return
code
;
return
code
;
}
}
static
int32_t
doScaleOut
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
int32_t
*
pL
evel
,
SNodeList
*
pParentsGroup
)
{
static
int32_t
doScaleOut
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
int32_t
l
evel
,
SNodeList
*
pParentsGroup
)
{
SNodeList
*
pCurrentGroup
=
nodesMakeList
();
SNodeList
*
pCurrentGroup
=
nodesMakeList
();
if
(
NULL
==
pCurrentGroup
)
{
if
(
NULL
==
pCurrentGroup
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -138,13 +138,13 @@ static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32
...
@@ -138,13 +138,13 @@ static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
pSubplan
->
subplanType
)
{
switch
(
pSubplan
->
subplanType
)
{
case
SUBPLAN_TYPE_MERGE
:
case
SUBPLAN_TYPE_MERGE
:
code
=
scaleOutForMerge
(
pCxt
,
pSubplan
,
*
pL
evel
,
pCurrentGroup
);
code
=
scaleOutForMerge
(
pCxt
,
pSubplan
,
l
evel
,
pCurrentGroup
);
break
;
break
;
case
SUBPLAN_TYPE_SCAN
:
case
SUBPLAN_TYPE_SCAN
:
code
=
scaleOutForScan
(
pCxt
,
pSubplan
,
*
pL
evel
,
pCurrentGroup
);
code
=
scaleOutForScan
(
pCxt
,
pSubplan
,
l
evel
,
pCurrentGroup
);
break
;
break
;
case
SUBPLAN_TYPE_MODIFY
:
case
SUBPLAN_TYPE_MODIFY
:
code
=
scaleOutForModify
(
pCxt
,
pSubplan
,
*
pL
evel
,
pCurrentGroup
);
code
=
scaleOutForModify
(
pCxt
,
pSubplan
,
l
evel
,
pCurrentGroup
);
break
;
break
;
default:
default:
break
;
break
;
...
@@ -152,13 +152,12 @@ static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32
...
@@ -152,13 +152,12 @@ static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
pushHierarchicalPlan
(
pParentsGroup
,
pCurrentGroup
);
code
=
pushHierarchicalPlan
(
pParentsGroup
,
pCurrentGroup
);
++
(
*
pLevel
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SNode
*
pChild
;
SNode
*
pChild
;
FOREACH
(
pChild
,
pSubplan
->
pChildren
)
{
FOREACH
(
pChild
,
pSubplan
->
pChildren
)
{
code
=
doScaleOut
(
pCxt
,
(
SLogicSubplan
*
)
pChild
,
pLevel
,
pCurrentGroup
);
code
=
doScaleOut
(
pCxt
,
(
SLogicSubplan
*
)
pChild
,
level
+
1
,
pCurrentGroup
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
break
;
}
}
...
@@ -194,7 +193,7 @@ int32_t scaleOutLogicPlan(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SQue
...
@@ -194,7 +193,7 @@ int32_t scaleOutLogicPlan(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SQue
}
}
SScaleOutContext
cxt
=
{
.
pPlanCxt
=
pCxt
,
.
subplanId
=
1
};
SScaleOutContext
cxt
=
{
.
pPlanCxt
=
pCxt
,
.
subplanId
=
1
};
int32_t
code
=
doScaleOut
(
&
cxt
,
pLogicSubplan
,
&
(
pPlan
->
totalLevel
)
,
pPlan
->
pTopSubplans
);
int32_t
code
=
doScaleOut
(
&
cxt
,
pLogicSubplan
,
0
,
pPlan
->
pTopSubplans
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicPlan
=
pPlan
;
*
pLogicPlan
=
pPlan
;
}
else
{
}
else
{
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
055e0516
...
@@ -45,7 +45,17 @@ typedef struct SCtjInfo {
...
@@ -45,7 +45,17 @@ typedef struct SCtjInfo {
SLogicSubplan
*
pSubplan
;
SLogicSubplan
*
pSubplan
;
}
SCtjInfo
;
}
SCtjInfo
;
typedef
bool
(
*
FSplFindSplitNode
)(
SLogicSubplan
*
pSubplan
,
SStsInfo
*
pInfo
);
typedef
struct
SUaInfo
{
SProjectLogicNode
*
pProject
;
SLogicSubplan
*
pSubplan
;
}
SUaInfo
;
typedef
struct
SUnInfo
{
SAggLogicNode
*
pAgg
;
SLogicSubplan
*
pSubplan
;
}
SUnInfo
;
typedef
bool
(
*
FSplFindSplitNode
)(
SLogicSubplan
*
pSubplan
,
void
*
pInfo
);
static
SLogicSubplan
*
splCreateScanSubplan
(
SSplitContext
*
pCxt
,
SScanLogicNode
*
pScan
,
int32_t
flag
)
{
static
SLogicSubplan
*
splCreateScanSubplan
(
SSplitContext
*
pCxt
,
SScanLogicNode
*
pScan
,
int32_t
flag
)
{
SLogicSubplan
*
pSubplan
=
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
SLogicSubplan
*
pSubplan
=
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
...
@@ -132,16 +142,10 @@ static bool stsFindSplitNode(SLogicSubplan* pSubplan, SStsInfo* pInfo) {
...
@@ -132,16 +142,10 @@ static bool stsFindSplitNode(SLogicSubplan* pSubplan, SStsInfo* pInfo) {
static
int32_t
stsSplit
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
static
int32_t
stsSplit
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
SStsInfo
info
=
{
0
};
SStsInfo
info
=
{
0
};
if
(
!
splMatch
(
pCxt
,
pSubplan
,
SPLIT_FLAG_STS
,
stsFindSplitNode
,
&
info
))
{
if
(
!
splMatch
(
pCxt
,
pSubplan
,
SPLIT_FLAG_STS
,
(
FSplFindSplitNode
)
stsFindSplitNode
,
&
info
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
NULL
==
info
.
pSubplan
->
pChildren
)
{
int32_t
code
=
nodesListMakeStrictAppend
(
&
info
.
pSubplan
->
pChildren
,
splCreateScanSubplan
(
pCxt
,
info
.
pScan
,
SPLIT_FLAG_STS
));
info
.
pSubplan
->
pChildren
=
nodesMakeList
();
if
(
NULL
==
info
.
pSubplan
->
pChildren
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
int32_t
code
=
nodesListStrictAppend
(
info
.
pSubplan
->
pChildren
,
splCreateScanSubplan
(
pCxt
,
info
.
pScan
,
SPLIT_FLAG_STS
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
splCreateExchangeNode
(
pCxt
,
info
.
pSubplan
,
info
.
pScan
,
SUBPLAN_TYPE_MERGE
);
code
=
splCreateExchangeNode
(
pCxt
,
info
.
pSubplan
,
info
.
pScan
,
SUBPLAN_TYPE_MERGE
);
}
}
...
@@ -173,7 +177,7 @@ static SLogicNode* ctjMatchByNode(SLogicNode* pNode) {
...
@@ -173,7 +177,7 @@ static SLogicNode* ctjMatchByNode(SLogicNode* pNode) {
return
NULL
;
return
NULL
;
}
}
static
bool
ctjFindSplitNode
(
SLogicSubplan
*
pSubplan
,
S
Sts
Info
*
pInfo
)
{
static
bool
ctjFindSplitNode
(
SLogicSubplan
*
pSubplan
,
S
Ctj
Info
*
pInfo
)
{
SLogicNode
*
pSplitNode
=
ctjMatchByNode
(
pSubplan
->
pNode
);
SLogicNode
*
pSplitNode
=
ctjMatchByNode
(
pSubplan
->
pNode
);
if
(
NULL
!=
pSplitNode
)
{
if
(
NULL
!=
pSplitNode
)
{
pInfo
->
pScan
=
(
SScanLogicNode
*
)
pSplitNode
;
pInfo
->
pScan
=
(
SScanLogicNode
*
)
pSplitNode
;
...
@@ -184,18 +188,172 @@ static bool ctjFindSplitNode(SLogicSubplan* pSubplan, SStsInfo* pInfo) {
...
@@ -184,18 +188,172 @@ static bool ctjFindSplitNode(SLogicSubplan* pSubplan, SStsInfo* pInfo) {
static
int32_t
ctjSplit
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
static
int32_t
ctjSplit
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
SCtjInfo
info
=
{
0
};
SCtjInfo
info
=
{
0
};
if
(
!
splMatch
(
pCxt
,
pSubplan
,
SPLIT_FLAG_CTJ
,
ctjFindSplitNode
,
&
info
))
{
if
(
!
splMatch
(
pCxt
,
pSubplan
,
SPLIT_FLAG_CTJ
,
(
FSplFindSplitNode
)
ctjFindSplitNode
,
&
info
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
NULL
==
info
.
pSubplan
->
pChildren
)
{
int32_t
code
=
nodesListMakeStrictAppend
(
&
info
.
pSubplan
->
pChildren
,
splCreateScanSubplan
(
pCxt
,
info
.
pScan
,
SPLIT_FLAG_CTJ
));
info
.
pSubplan
->
pChildren
=
nodesMakeList
();
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
NULL
==
info
.
pSubplan
->
pChildren
)
{
code
=
splCreateExchangeNode
(
pCxt
,
info
.
pSubplan
,
info
.
pScan
,
info
.
pSubplan
->
subplanType
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
++
(
pCxt
->
groupId
);
pCxt
->
split
=
true
;
return
code
;
}
static
SLogicNode
*
uaMatchByNode
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_PROJECT
==
nodeType
(
pNode
)
&&
LIST_LENGTH
(
pNode
->
pChildren
)
>
1
)
{
return
pNode
;
}
SNode
*
pChild
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
SLogicNode
*
pSplitNode
=
uaMatchByNode
((
SLogicNode
*
)
pChild
);
if
(
NULL
!=
pSplitNode
)
{
return
pSplitNode
;
}
}
return
NULL
;
}
static
bool
uaFindSplitNode
(
SLogicSubplan
*
pSubplan
,
SUaInfo
*
pInfo
)
{
SLogicNode
*
pSplitNode
=
uaMatchByNode
(
pSubplan
->
pNode
);
if
(
NULL
!=
pSplitNode
)
{
pInfo
->
pProject
=
(
SProjectLogicNode
*
)
pSplitNode
;
pInfo
->
pSubplan
=
pSubplan
;
}
return
NULL
!=
pSplitNode
;
}
static
SLogicSubplan
*
uaCreateSubplan
(
SSplitContext
*
pCxt
,
SLogicNode
*
pNode
)
{
SLogicSubplan
*
pSubplan
=
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
if
(
NULL
==
pSubplan
)
{
return
NULL
;
}
pSubplan
->
id
.
groupId
=
pCxt
->
groupId
;
pSubplan
->
subplanType
=
SUBPLAN_TYPE_SCAN
;
pSubplan
->
pNode
=
pNode
;
return
pSubplan
;
}
static
int32_t
uaCreateExchangeNode
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
SProjectLogicNode
*
pProject
)
{
SExchangeLogicNode
*
pExchange
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_EXCHANGE
);
if
(
NULL
==
pExchange
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pExchange
->
srcGroupId
=
pCxt
->
groupId
;
// pExchange->precision = pScan->pMeta->tableInfo.precision;
pExchange
->
node
.
pTargets
=
nodesCloneList
(
pProject
->
node
.
pTargets
);
if
(
NULL
==
pExchange
->
node
.
pTargets
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
if
(
NULL
==
pProject
->
node
.
pParent
)
{
pSubplan
->
pNode
=
(
SLogicNode
*
)
pExchange
;
nodesDestroyNode
(
pProject
);
return
TSDB_CODE_SUCCESS
;
}
SNode
*
pNode
;
FOREACH
(
pNode
,
pProject
->
node
.
pParent
->
pChildren
)
{
if
(
nodesEqualNode
(
pNode
,
pProject
))
{
REPLACE_NODE
(
pExchange
);
nodesDestroyNode
(
pNode
);
return
TSDB_CODE_SUCCESS
;
}
}
nodesDestroyNode
(
pExchange
);
return
TSDB_CODE_FAILED
;
}
static
int32_t
uaSplit
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
SUaInfo
info
=
{
0
};
if
(
!
splMatch
(
pCxt
,
pSubplan
,
0
,
(
FSplFindSplitNode
)
uaFindSplitNode
,
&
info
))
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNode
*
pChild
=
NULL
;
FOREACH
(
pChild
,
info
.
pProject
->
node
.
pChildren
)
{
code
=
nodesListMakeStrictAppend
(
&
info
.
pSubplan
->
pChildren
,
uaCreateSubplan
(
pCxt
,
(
SLogicNode
*
)
pChild
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
REPLACE_NODE
(
NULL
);
}
else
{
break
;
}
}
}
}
int32_t
code
=
nodesListStrictAppend
(
info
.
pSubplan
->
pChildren
,
splCreateScanSubplan
(
pCxt
,
info
.
pScan
,
SPLIT_FLAG_CTJ
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
splCreateExchangeNode
(
pCxt
,
info
.
pSubplan
,
info
.
pScan
,
info
.
pSubplan
->
subplanType
);
nodesClearList
(
info
.
pProject
->
node
.
pChildren
);
info
.
pProject
->
node
.
pChildren
=
NULL
;
code
=
uaCreateExchangeNode
(
pCxt
,
info
.
pSubplan
,
info
.
pProject
);
}
++
(
pCxt
->
groupId
);
pCxt
->
split
=
true
;
return
code
;
}
static
SLogicNode
*
unMatchByNode
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_AGG
==
nodeType
(
pNode
)
&&
LIST_LENGTH
(
pNode
->
pChildren
)
>
1
)
{
return
pNode
;
}
SNode
*
pChild
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
SLogicNode
*
pSplitNode
=
uaMatchByNode
((
SLogicNode
*
)
pChild
);
if
(
NULL
!=
pSplitNode
)
{
return
pSplitNode
;
}
}
return
NULL
;
}
static
int32_t
unCreateExchangeNode
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
SAggLogicNode
*
pAgg
)
{
SExchangeLogicNode
*
pExchange
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_EXCHANGE
);
if
(
NULL
==
pExchange
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pExchange
->
srcGroupId
=
pCxt
->
groupId
;
// pExchange->precision = pScan->pMeta->tableInfo.precision;
pExchange
->
node
.
pTargets
=
nodesCloneList
(
pAgg
->
node
.
pTargets
);
if
(
NULL
==
pExchange
->
node
.
pTargets
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
return
nodesListMakeAppend
(
&
pAgg
->
node
.
pChildren
,
pExchange
);
}
static
bool
unFindSplitNode
(
SLogicSubplan
*
pSubplan
,
SUnInfo
*
pInfo
)
{
SLogicNode
*
pSplitNode
=
unMatchByNode
(
pSubplan
->
pNode
);
if
(
NULL
!=
pSplitNode
)
{
pInfo
->
pAgg
=
(
SAggLogicNode
*
)
pSplitNode
;
pInfo
->
pSubplan
=
pSubplan
;
}
return
NULL
!=
pSplitNode
;
}
static
int32_t
unSplit
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
SUnInfo
info
=
{
0
};
if
(
!
splMatch
(
pCxt
,
pSubplan
,
0
,
(
FSplFindSplitNode
)
unFindSplitNode
,
&
info
))
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNode
*
pChild
=
NULL
;
FOREACH
(
pChild
,
info
.
pAgg
->
node
.
pChildren
)
{
code
=
nodesListMakeStrictAppend
(
&
info
.
pSubplan
->
pChildren
,
uaCreateSubplan
(
pCxt
,
(
SLogicNode
*
)
pChild
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
REPLACE_NODE
(
NULL
);
}
else
{
break
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
nodesClearList
(
info
.
pAgg
->
node
.
pChildren
);
info
.
pAgg
->
node
.
pChildren
=
NULL
;
code
=
unCreateExchangeNode
(
pCxt
,
info
.
pSubplan
,
info
.
pAgg
);
}
}
++
(
pCxt
->
groupId
);
++
(
pCxt
->
groupId
);
pCxt
->
split
=
true
;
pCxt
->
split
=
true
;
...
@@ -205,6 +363,8 @@ static int32_t ctjSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
...
@@ -205,6 +363,8 @@ static int32_t ctjSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
static
const
SSplitRule
splitRuleSet
[]
=
{
static
const
SSplitRule
splitRuleSet
[]
=
{
{
.
pName
=
"SuperTableScan"
,
.
splitFunc
=
stsSplit
},
{
.
pName
=
"SuperTableScan"
,
.
splitFunc
=
stsSplit
},
{
.
pName
=
"ChildTableJoin"
,
.
splitFunc
=
ctjSplit
},
{
.
pName
=
"ChildTableJoin"
,
.
splitFunc
=
ctjSplit
},
{
.
pName
=
"UnionAll"
,
.
splitFunc
=
uaSplit
},
{
.
pName
=
"Union"
,
.
splitFunc
=
unSplit
}
};
};
static
const
int32_t
splitRuleNum
=
(
sizeof
(
splitRuleSet
)
/
sizeof
(
SSplitRule
));
static
const
int32_t
splitRuleNum
=
(
sizeof
(
splitRuleSet
)
/
sizeof
(
SSplitRule
));
...
...
source/libs/planner/test/planSetOpTest.cpp
0 → 100644
浏览文件 @
055e0516
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "planTestUtil.h"
#include "planner.h"
using
namespace
std
;
class
PlanSetOpTest
:
public
PlannerTestBase
{
};
TEST_F
(
PlanSetOpTest
,
unionAll
)
{
useDb
(
"root"
,
"test"
);
run
(
"select c1, c2 from t1 where c1 > 10 union all select c1, c2 from t1 where c1 > 20"
);
}
TEST_F
(
PlanSetOpTest
,
union
)
{
useDb
(
"root"
,
"test"
);
run
(
"select c1, c2 from t1 where c1 > 10 union select c1, c2 from t1 where c1 > 20"
);
}
source/libs/planner/test/plan
ner
TestMain.cpp
→
source/libs/planner/test/planTestMain.cpp
浏览文件 @
055e0516
文件已移动
source/libs/planner/test/planTestUtil.cpp
浏览文件 @
055e0516
...
@@ -62,7 +62,11 @@ public:
...
@@ -62,7 +62,11 @@ public:
doScaleOutLogicPlan
(
&
cxt
,
pLogicSubplan
,
&
pLogicPlan
);
doScaleOutLogicPlan
(
&
cxt
,
pLogicSubplan
,
&
pLogicPlan
);
SQueryPlan
*
pPlan
=
nullptr
;
SQueryPlan
*
pPlan
=
nullptr
;
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
,
NULL
);
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
);
if
(
g_isDump
)
{
dump
();
}
}
catch
(...)
{
}
catch
(...)
{
dump
();
dump
();
throw
;
throw
;
...
@@ -87,6 +91,7 @@ private:
...
@@ -87,6 +91,7 @@ private:
string
splitLogicPlan_
;
string
splitLogicPlan_
;
string
scaledLogicPlan_
;
string
scaledLogicPlan_
;
string
physiPlan_
;
string
physiPlan_
;
vector
<
string
>
physiSubplans_
;
};
};
void
reset
()
{
void
reset
()
{
...
@@ -115,6 +120,10 @@ private:
...
@@ -115,6 +120,10 @@ private:
cout
<<
res_
.
scaledLogicPlan_
<<
endl
;
cout
<<
res_
.
scaledLogicPlan_
<<
endl
;
cout
<<
"physical plan : "
<<
endl
;
cout
<<
"physical plan : "
<<
endl
;
cout
<<
res_
.
physiPlan_
<<
endl
;
cout
<<
res_
.
physiPlan_
<<
endl
;
cout
<<
"physical subplan : "
<<
endl
;
for
(
const
auto
&
subplan
:
res_
.
physiSubplans_
)
{
cout
<<
subplan
<<
endl
;
}
}
}
void
doParseSql
(
const
string
&
sql
,
SQuery
**
pQuery
)
{
void
doParseSql
(
const
string
&
sql
,
SQuery
**
pQuery
)
{
...
@@ -153,9 +162,17 @@ private:
...
@@ -153,9 +162,17 @@ private:
res_
.
scaledLogicPlan_
=
toString
((
SNode
*
)(
*
pLogicPlan
));
res_
.
scaledLogicPlan_
=
toString
((
SNode
*
)(
*
pLogicPlan
));
}
}
void
doCreatePhysiPlan
(
SPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
void
doCreatePhysiPlan
(
SPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
)
{
SArray
*
pExecNodeList
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
sizeof
(
SQueryNodeAddr
));
DO_WITH_THROW
(
createPhysiPlan
,
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
DO_WITH_THROW
(
createPhysiPlan
,
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
res_
.
physiPlan_
=
toString
((
SNode
*
)(
*
pPlan
));
res_
.
physiPlan_
=
toString
((
SNode
*
)(
*
pPlan
));
SNode
*
pNode
;
FOREACH
(
pNode
,
(
*
pPlan
)
->
pSubplans
)
{
SNode
*
pSubplan
;
FOREACH
(
pSubplan
,
((
SNodeListNode
*
)
pNode
)
->
pNodeList
)
{
res_
.
physiSubplans_
.
push_back
(
toString
(
pSubplan
));
}
}
}
}
void
setPlanContext
(
SQuery
*
pQuery
,
SPlanContext
*
pCxt
)
{
void
setPlanContext
(
SQuery
*
pQuery
,
SPlanContext
*
pCxt
)
{
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
055e0516
...
@@ -157,6 +157,28 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t
...
@@ -157,6 +157,28 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
queryBuildRetrieveFuncMsg
(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
)
{
if
(
NULL
==
msg
||
NULL
==
msgLen
)
{
return
TSDB_CODE_TSC_INVALID_INPUT
;
}
SRetrieveFuncReq
funcReq
=
{
0
};
funcReq
.
numOfFuncs
=
1
;
funcReq
.
ignoreCodeComment
=
true
;
funcReq
.
pFuncNames
=
taosArrayInit
(
1
,
strlen
(
input
)
+
1
);
taosArrayPush
(
funcReq
.
pFuncNames
,
input
);
int32_t
bufLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
funcReq
);
void
*
pBuf
=
rpcMallocCont
(
bufLen
);
tSerializeSRetrieveFuncReq
(
pBuf
,
bufLen
,
&
funcReq
);
taosArrayDestroy
(
funcReq
.
pFuncNames
);
*
msg
=
pBuf
;
*
msgLen
=
bufLen
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
queryProcessUseDBRsp
(
void
*
output
,
char
*
msg
,
int32_t
msgSize
)
{
int32_t
queryProcessUseDBRsp
(
void
*
output
,
char
*
msg
,
int32_t
msgSize
)
{
SUseDbOutput
*
pOut
=
output
;
SUseDbOutput
*
pOut
=
output
;
...
@@ -379,6 +401,31 @@ int32_t queryProcessGetIndexRsp(void *output, char *msg, int32_t msgSize) {
...
@@ -379,6 +401,31 @@ int32_t queryProcessGetIndexRsp(void *output, char *msg, int32_t msgSize) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
queryProcessRetrieveFuncRsp
(
void
*
output
,
char
*
msg
,
int32_t
msgSize
)
{
SRetrieveFuncRsp
out
=
{
0
};
if
(
NULL
==
output
||
NULL
==
msg
||
msgSize
<=
0
)
{
return
TSDB_CODE_TSC_INVALID_INPUT
;
}
if
(
tDeserializeSRetrieveFuncRsp
(
msg
,
msgSize
,
&
out
)
!=
0
)
{
qError
(
"tDeserializeSRetrieveFuncRsp failed, msgSize:%d"
,
msgSize
);
return
TSDB_CODE_INVALID_MSG
;
}
if
(
1
!=
out
.
numOfFuncs
)
{
qError
(
"invalid func num returned, numOfFuncs:%d"
,
out
.
numOfFuncs
);
return
TSDB_CODE_INVALID_MSG
;
}
SFuncInfo
*
funcInfo
=
taosArrayGet
(
out
.
pFuncInfos
,
0
);
memcpy
(
output
,
funcInfo
,
sizeof
(
*
funcInfo
));
taosArrayDestroy
(
out
.
pFuncInfos
);
return
TSDB_CODE_SUCCESS
;
}
void
initQueryModuleMsgHandle
()
{
void
initQueryModuleMsgHandle
()
{
queryBuildMsg
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)]
=
queryBuildTableMetaReqMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)]
=
queryBuildTableMetaReqMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_TABLE_META
)]
=
queryBuildTableMetaReqMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_TABLE_META
)]
=
queryBuildTableMetaReqMsg
;
...
@@ -386,6 +433,7 @@ void initQueryModuleMsgHandle() {
...
@@ -386,6 +433,7 @@ void initQueryModuleMsgHandle() {
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_QNODE_LIST
)]
=
queryBuildQnodeListMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_QNODE_LIST
)]
=
queryBuildQnodeListMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_GET_DB_CFG
)]
=
queryBuildGetDBCfgMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_GET_DB_CFG
)]
=
queryBuildGetDBCfgMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_GET_INDEX
)]
=
queryBuildGetIndexMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_GET_INDEX
)]
=
queryBuildGetIndexMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_RETRIEVE_FUNC
)]
=
queryBuildRetrieveFuncMsg
;
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)]
=
queryProcessTableMetaRsp
;
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)]
=
queryProcessTableMetaRsp
;
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_TABLE_META
)]
=
queryProcessTableMetaRsp
;
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_TABLE_META
)]
=
queryProcessTableMetaRsp
;
...
@@ -393,6 +441,7 @@ void initQueryModuleMsgHandle() {
...
@@ -393,6 +441,7 @@ void initQueryModuleMsgHandle() {
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_QNODE_LIST
)]
=
queryProcessQnodeListRsp
;
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_QNODE_LIST
)]
=
queryProcessQnodeListRsp
;
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_GET_DB_CFG
)]
=
queryProcessGetDbCfgRsp
;
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_GET_DB_CFG
)]
=
queryProcessGetDbCfgRsp
;
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_GET_INDEX
)]
=
queryProcessGetIndexRsp
;
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_GET_INDEX
)]
=
queryProcessGetIndexRsp
;
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_RETRIEVE_FUNC
)]
=
queryProcessRetrieveFuncRsp
;
}
}
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
source/libs/scalar/src/sclfunc.c
浏览文件 @
055e0516
...
@@ -716,7 +716,8 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
...
@@ -716,7 +716,8 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
int32_t
len
=
sprintf
(
varDataVal
(
output
),
"%.*s"
,
(
int32_t
)(
outputLen
-
VARSTR_HEADER_SIZE
),
*
(
int8_t
*
)
input
?
"true"
:
"false"
);
int32_t
len
=
sprintf
(
varDataVal
(
output
),
"%.*s"
,
(
int32_t
)(
outputLen
-
VARSTR_HEADER_SIZE
),
*
(
int8_t
*
)
input
?
"true"
:
"false"
);
varDataSetLen
(
output
,
len
);
varDataSetLen
(
output
,
len
);
}
else
if
(
inputType
==
TSDB_DATA_TYPE_BINARY
)
{
}
else
if
(
inputType
==
TSDB_DATA_TYPE_BINARY
)
{
int32_t
len
=
sprintf
(
varDataVal
(
output
),
"%.*s"
,
(
int32_t
)(
outputLen
-
VARSTR_HEADER_SIZE
),
varDataVal
(
input
));
int32_t
len
=
MIN
(
varDataLen
(
input
),
outputLen
-
VARSTR_HEADER_SIZE
);
len
=
sprintf
(
varDataVal
(
output
),
"%.*s"
,
len
,
varDataVal
(
input
));
varDataSetLen
(
output
,
len
);
varDataSetLen
(
output
,
len
);
}
else
if
(
inputType
==
TSDB_DATA_TYPE_NCHAR
)
{
}
else
if
(
inputType
==
TSDB_DATA_TYPE_NCHAR
)
{
//not support
//not support
...
...
source/libs/transport/inc/transComm.h
浏览文件 @
055e0516
...
@@ -158,6 +158,7 @@ typedef struct {
...
@@ -158,6 +158,7 @@ typedef struct {
char
secured
:
2
;
char
secured
:
2
;
char
spi
:
2
;
char
spi
:
2
;
char
user
[
TSDB_UNI_LEN
];
uint64_t
ahandle
;
// ahandle assigned by client
uint64_t
ahandle
;
// ahandle assigned by client
uint32_t
code
;
// del later
uint32_t
code
;
// del later
uint32_t
msgType
;
uint32_t
msgType
;
...
@@ -186,23 +187,23 @@ typedef enum { Normal, Quit, Release, Register } STransMsgType;
...
@@ -186,23 +187,23 @@ typedef enum { Normal, Quit, Release, Register } STransMsgType;
typedef
enum
{
ConnNormal
,
ConnAcquire
,
ConnRelease
,
ConnBroken
,
ConnInPool
}
ConnStatus
;
typedef
enum
{
ConnNormal
,
ConnAcquire
,
ConnRelease
,
ConnBroken
,
ConnInPool
}
ConnStatus
;
#define container_of(ptr, type, member) ((type*)((char*)(ptr)-offsetof(type, member)))
#define container_of(ptr, type, member) ((type*)((char*)(ptr)-offsetof(type, member)))
#define RPC_RESERVE_SIZE (sizeof(STranConnCtx))
#define RPC_RESERVE_SIZE
(sizeof(STranConnCtx))
#define RPC_MSG_OVERHEAD (sizeof(SRpcHead) + sizeof(SRpcDigest))
#define RPC_MSG_OVERHEAD
(sizeof(SRpcHead) + sizeof(SRpcDigest))
#define rpcHeadFromCont(cont) ((SRpcHead*)((char*)cont - sizeof(SRpcHead)))
#define rpcHeadFromCont(cont)
((SRpcHead*)((char*)cont - sizeof(SRpcHead)))
#define rpcContFromHead(msg) (msg + sizeof(SRpcHead))
#define rpcContFromHead(msg)
(msg + sizeof(SRpcHead))
#define rpcMsgLenFromCont(contLen) (contLen + sizeof(SRpcHead))
#define rpcMsgLenFromCont(contLen) (contLen + sizeof(SRpcHead))
#define rpcContLenFromMsg(msgLen) (msgLen - sizeof(SRpcHead))
#define rpcContLenFromMsg(msgLen)
(msgLen - sizeof(SRpcHead))
#define rpcIsReq(type) (type & 1U)
#define rpcIsReq(type)
(type & 1U)
#define TRANS_RESERVE_SIZE (sizeof(STranConnCtx))
#define TRANS_RESERVE_SIZE (sizeof(STranConnCtx))
#define TRANS_MSG_OVERHEAD (sizeof(STransMsgHead))
#define TRANS_MSG_OVERHEAD
(sizeof(STransMsgHead))
#define transHeadFromCont(cont) ((STransMsgHead*)((char*)cont - sizeof(STransMsgHead)))
#define transHeadFromCont(cont)
((STransMsgHead*)((char*)cont - sizeof(STransMsgHead)))
#define transContFromHead(msg) (msg + sizeof(STransMsgHead))
#define transContFromHead(msg)
(msg + sizeof(STransMsgHead))
#define transMsgLenFromCont(contLen) (contLen + sizeof(STransMsgHead))
#define transMsgLenFromCont(contLen) (contLen + sizeof(STransMsgHead))
#define transContLenFromMsg(msgLen) (msgLen - sizeof(STransMsgHead));
#define transContLenFromMsg(msgLen)
(msgLen - sizeof(STransMsgHead));
#define transIsReq(type) (type & 1U)
#define transIsReq(type)
(type & 1U)
int
rpcAuthenticateMsg
(
void
*
pMsg
,
int
msgLen
,
void
*
pAuth
,
void
*
pKey
);
int
rpcAuthenticateMsg
(
void
*
pMsg
,
int
msgLen
,
void
*
pAuth
,
void
*
pKey
);
void
rpcBuildAuthHead
(
void
*
pMsg
,
int
msgLen
,
void
*
pAuth
,
void
*
pKey
);
void
rpcBuildAuthHead
(
void
*
pMsg
,
int
msgLen
,
void
*
pAuth
,
void
*
pKey
);
...
...
source/libs/transport/src/transCli.c
浏览文件 @
055e0516
...
@@ -614,35 +614,16 @@ void cliSend(SCliConn* pConn) {
...
@@ -614,35 +614,16 @@ void cliSend(SCliConn* pConn) {
pMsg
->
pCont
=
(
void
*
)
rpcMallocCont
(
0
);
pMsg
->
pCont
=
(
void
*
)
rpcMallocCont
(
0
);
pMsg
->
contLen
=
0
;
pMsg
->
contLen
=
0
;
}
}
STransMsgHead
*
pHead
=
transHeadFromCont
(
pMsg
->
pCont
);
pHead
->
ahandle
=
pCtx
!=
NULL
?
(
uint64_t
)
pCtx
->
ahandle
:
0
;
int
msgLen
=
transMsgLenFromCont
(
pMsg
->
contLen
);
int
msgLen
=
transMsgLenFromCont
(
pMsg
->
contLen
);
if
(
!
pConn
->
secured
)
{
STransMsgHead
*
pHead
=
transHeadFromCont
(
pMsg
->
pCont
);
char
*
buf
=
taosMemoryCalloc
(
1
,
msgLen
+
sizeof
(
STransUserMsg
));
pHead
->
ahandle
=
pCtx
!=
NULL
?
(
uint64_t
)
pCtx
->
ahandle
:
0
;
memcpy
(
buf
,
(
char
*
)
pHead
,
msgLen
);
STransUserMsg
*
uMsg
=
(
STransUserMsg
*
)(
buf
+
msgLen
);
memcpy
(
uMsg
->
user
,
pTransInst
->
user
,
tListLen
(
uMsg
->
user
));
memcpy
(
uMsg
->
secret
,
pTransInst
->
secret
,
tListLen
(
uMsg
->
secret
));
// to avoid mem leak
destroyUserdata
(
pMsg
);
pMsg
->
pCont
=
(
char
*
)
buf
+
sizeof
(
STransMsgHead
);
pMsg
->
contLen
=
msgLen
+
sizeof
(
STransUserMsg
)
-
sizeof
(
STransMsgHead
);
pHead
=
(
STransMsgHead
*
)
buf
;
pHead
->
secured
=
1
;
msgLen
+=
sizeof
(
STransUserMsg
);
}
pHead
->
noResp
=
REQUEST_NO_RESP
(
pMsg
)
?
1
:
0
;
pHead
->
noResp
=
REQUEST_NO_RESP
(
pMsg
)
?
1
:
0
;
pHead
->
persist
=
REQUEST_PERSIS_HANDLE
(
pMsg
)
?
1
:
0
;
pHead
->
persist
=
REQUEST_PERSIS_HANDLE
(
pMsg
)
?
1
:
0
;
pHead
->
msgType
=
pMsg
->
msgType
;
pHead
->
msgType
=
pMsg
->
msgType
;
pHead
->
msgLen
=
(
int32_t
)
htonl
((
uint32_t
)
msgLen
);
pHead
->
msgLen
=
(
int32_t
)
htonl
((
uint32_t
)
msgLen
);
pHead
->
release
=
REQUEST_RELEASE_HANDLE
(
pCliMsg
)
?
1
:
0
;
pHead
->
release
=
REQUEST_RELEASE_HANDLE
(
pCliMsg
)
?
1
:
0
;
memcpy
(
pHead
->
user
,
pTransInst
->
user
,
strlen
(
pTransInst
->
user
));
uv_buf_t
wb
=
uv_buf_init
((
char
*
)
pHead
,
msgLen
);
uv_buf_t
wb
=
uv_buf_init
((
char
*
)
pHead
,
msgLen
);
tDebug
(
"%s cli conn %p %s is send to %s:%d, local info %s:%d"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
tDebug
(
"%s cli conn %p %s is send to %s:%d, local info %s:%d"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
...
...
source/libs/transport/src/transSrv.c
浏览文件 @
055e0516
...
@@ -46,7 +46,6 @@ typedef struct SSrvConn {
...
@@ -46,7 +46,6 @@ typedef struct SSrvConn {
struct
sockaddr_in
addr
;
struct
sockaddr_in
addr
;
struct
sockaddr_in
locaddr
;
struct
sockaddr_in
locaddr
;
char
secured
;
int
spi
;
int
spi
;
char
info
[
64
];
char
info
[
64
];
char
user
[
TSDB_UNI_LEN
];
// user ID for the link
char
user
[
TSDB_UNI_LEN
];
// user ID for the link
...
@@ -104,6 +103,13 @@ static void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf)
...
@@ -104,6 +103,13 @@ static void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf)
static
void
uvWorkerAsyncCb
(
uv_async_t
*
handle
);
static
void
uvWorkerAsyncCb
(
uv_async_t
*
handle
);
static
void
uvAcceptAsyncCb
(
uv_async_t
*
handle
);
static
void
uvAcceptAsyncCb
(
uv_async_t
*
handle
);
static
void
uvShutDownCb
(
uv_shutdown_t
*
req
,
int
status
);
static
void
uvShutDownCb
(
uv_shutdown_t
*
req
,
int
status
);
/*
* time-consuming task throwed into BG work thread
*/
static
void
uvWorkDoTask
(
uv_work_t
*
req
);
static
void
uvWorkAfterTask
(
uv_work_t
*
req
,
int
status
);
static
void
uvWalkCb
(
uv_handle_t
*
handle
,
void
*
arg
);
static
void
uvWalkCb
(
uv_handle_t
*
handle
,
void
*
arg
);
static
void
uvFreeCb
(
uv_handle_t
*
handle
);
static
void
uvFreeCb
(
uv_handle_t
*
handle
);
...
@@ -181,16 +187,16 @@ static void uvHandleReq(SSrvConn* pConn) {
...
@@ -181,16 +187,16 @@ static void uvHandleReq(SSrvConn* pConn) {
uint32_t
msgLen
=
pBuf
->
len
;
uint32_t
msgLen
=
pBuf
->
len
;
STransMsgHead
*
pHead
=
(
STransMsgHead
*
)
msg
;
STransMsgHead
*
pHead
=
(
STransMsgHead
*
)
msg
;
if
(
pHead
->
secured
==
1
)
{
STransUserMsg
*
uMsg
=
(
STransUserMsg
*
)((
char
*
)
msg
+
msgLen
-
sizeof
(
STransUserMsg
));
memcpy
(
pConn
->
user
,
uMsg
->
user
,
tListLen
(
uMsg
->
user
));
memcpy
(
pConn
->
secret
,
uMsg
->
secret
,
tListLen
(
uMsg
->
secret
));
}
pHead
->
code
=
htonl
(
pHead
->
code
);
pHead
->
code
=
htonl
(
pHead
->
code
);
pHead
->
msgLen
=
htonl
(
pHead
->
msgLen
);
pHead
->
msgLen
=
htonl
(
pHead
->
msgLen
);
if
(
pHead
->
secured
==
1
)
{
memcpy
(
pConn
->
user
,
pHead
->
user
,
strlen
(
pHead
->
user
));
pHead
->
msgLen
-=
sizeof
(
STransUserMsg
);
}
// TODO(dengyihao): time-consuming task throwed into BG Thread
// uv_work_t* wreq = taosMemoryMalloc(sizeof(uv_work_t));
// wreq->data = pConn;
// uv_read_stop((uv_stream_t*)pConn->pTcp);
// transRefSrvHandle(pConn);
// uv_queue_work(((SWorkThrdObj*)pConn->hostThrd)->loop, wreq, uvWorkDoTask, uvWorkAfterTask);
CONN_SHOULD_RELEASE
(
pConn
,
pHead
);
CONN_SHOULD_RELEASE
(
pConn
,
pHead
);
...
@@ -344,12 +350,6 @@ static void uvPrepareSendData(SSrvMsg* smsg, uv_buf_t* wb) {
...
@@ -344,12 +350,6 @@ static void uvPrepareSendData(SSrvMsg* smsg, uv_buf_t* wb) {
STransMsgHead
*
pHead
=
transHeadFromCont
(
pMsg
->
pCont
);
STransMsgHead
*
pHead
=
transHeadFromCont
(
pMsg
->
pCont
);
pHead
->
ahandle
=
(
uint64_t
)
pMsg
->
ahandle
;
pHead
->
ahandle
=
(
uint64_t
)
pMsg
->
ahandle
;
// pHead->secured = pMsg->code == 0 ? 1 : 0; //
if
(
!
pConn
->
secured
)
{
pConn
->
secured
=
pMsg
->
code
==
0
?
1
:
0
;
}
pHead
->
secured
=
pConn
->
secured
;
if
(
pConn
->
status
==
ConnNormal
)
{
if
(
pConn
->
status
==
ConnNormal
)
{
pHead
->
msgType
=
pConn
->
inType
+
1
;
pHead
->
msgType
=
pConn
->
inType
+
1
;
}
else
{
}
else
{
...
@@ -464,6 +464,24 @@ static void uvShutDownCb(uv_shutdown_t* req, int status) {
...
@@ -464,6 +464,24 @@ static void uvShutDownCb(uv_shutdown_t* req, int status) {
taosMemoryFree
(
req
);
taosMemoryFree
(
req
);
}
}
static
void
uvWorkDoTask
(
uv_work_t
*
req
)
{
// doing time-consumeing task
// only auth conn currently, add more func later
tTrace
(
"server conn %p start to be processed in BG Thread"
,
req
->
data
);
return
;
}
static
void
uvWorkAfterTask
(
uv_work_t
*
req
,
int
status
)
{
if
(
status
!=
0
)
{
tTrace
(
"server conn %p failed to processed "
,
req
->
data
);
}
// Done time-consumeing task
// add more func later
// this func called in main loop
tTrace
(
"server conn %p already processed "
,
req
->
data
);
taosMemoryFree
(
req
);
}
void
uvOnAcceptCb
(
uv_stream_t
*
stream
,
int
status
)
{
void
uvOnAcceptCb
(
uv_stream_t
*
stream
,
int
status
)
{
if
(
status
==
-
1
)
{
if
(
status
==
-
1
)
{
return
;
return
;
...
...
tests/script/runAllSimCases.sh
浏览文件 @
055e0516
!
/bin/bash
#
!/bin/bash
##################################################
##################################################
#
#
...
...
tests/system-test/2-query/cast.py
浏览文件 @
055e0516
import
taos
import
taos
import
sys
import
sys
import
datetime
import
datetime
import
inspect
from
util.log
import
*
from
util.log
import
*
from
util.sql
import
*
from
util.sql
import
*
...
@@ -70,16 +71,6 @@ class TDTestCase:
...
@@ -70,16 +71,6 @@ class TDTestCase:
tdSql
.
query
(
"select c1 from t1"
)
tdSql
.
query
(
"select c1 from t1"
)
data_t1_c1
=
[
tdSql
.
getData
(
i
,
0
)
for
i
in
range
(
tdSql
.
queryRows
)]
data_t1_c1
=
[
tdSql
.
getData
(
i
,
0
)
for
i
in
range
(
tdSql
.
queryRows
)]
# tdLog.printNoPrefix("==========step1: cast int to int, expect no changes")
# tdSql.query("select cast(c1 as int) as b from ct4")
# for i in range(len(data_ct4)):
# tdSql.checkData( i, 0, data_ct4[i])
# tdSql.query("select cast(c1 as int) as b from t1")
# for i in range(len(data_t1)):
# tdSql.checkData( i, 0, data_t1[i])
tdLog
.
printNoPrefix
(
"==========step2: cast int to bigint, expect no changes"
)
tdLog
.
printNoPrefix
(
"==========step2: cast int to bigint, expect no changes"
)
tdSql
.
query
(
"select cast(c1 as bigint) as b from ct4"
)
tdSql
.
query
(
"select cast(c1 as bigint) as b from ct4"
)
...
@@ -89,24 +80,6 @@ class TDTestCase:
...
@@ -89,24 +80,6 @@ class TDTestCase:
for
i
in
range
(
len
(
data_t1_c1
)):
for
i
in
range
(
len
(
data_t1_c1
)):
tdSql
.
checkData
(
i
,
0
,
data_t1_c1
[
i
])
tdSql
.
checkData
(
i
,
0
,
data_t1_c1
[
i
])
# tdLog.printNoPrefix("==========step3: cast int to float, expect no changes")
# tdSql.query("select cast(c1 as float) as b from ct4")
# for i in range(len(data_ct4)):
# tdSql.checkData( i, 0, data_ct4[i])
# tdSql.query("select cast(c1 as float) as b from t1")
# for i in range(len(data_t1)):
# tdSql.checkData( i, 0, data_t1[i])
# tdLog.printNoPrefix("==========step4: cast int to double, expect no changes")
# tdSql.query("select cast(c1 as double) as b from ct4")
# for i in range(len(data_ct4)):
# tdSql.checkData( i, 0, data_ct4[i])
# tdSql.query("select cast(c1 as double) as b from t1")
# for i in range(len(data_t1)):
# tdSql.checkData( i, 0, data_t1[i])
tdLog
.
printNoPrefix
(
"==========step5: cast int to binary, expect changes to str(int) "
)
tdLog
.
printNoPrefix
(
"==========step5: cast int to binary, expect changes to str(int) "
)
tdSql
.
query
(
"select cast(c1 as binary(32)) as b from ct4"
)
tdSql
.
query
(
"select cast(c1 as binary(32)) as b from ct4"
)
...
@@ -195,10 +168,13 @@ class TDTestCase:
...
@@ -195,10 +168,13 @@ class TDTestCase:
date_data
=
date_init_stamp
.
replace
(
tzinfo
=
utc_zone
).
astimezone
(
utc_8
).
strftime
(
"%Y-%m-%d %H:%M:%S.%f"
)
date_data
=
date_init_stamp
.
replace
(
tzinfo
=
utc_zone
).
astimezone
(
utc_8
).
strftime
(
"%Y-%m-%d %H:%M:%S.%f"
)
tdSql
.
checkData
(
i
,
0
,
date_data
)
tdSql
.
checkData
(
i
,
0
,
date_data
)
tdSql
.
query
(
"select cast(c2 as timestamp) as b from t1"
)
tdSql
.
query
(
"select cast(c2 as timestamp) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c2
)):
for
i
in
range
(
len
(
data_t1_c2
)):
if
data_t1_c2
[
i
]
is
None
:
if
data_t1_c2
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
tdSql
.
checkData
(
i
,
0
,
None
)
elif
i
==
10
:
continue
else
:
else
:
utc_zone
=
datetime
.
timezone
.
utc
utc_zone
=
datetime
.
timezone
.
utc
utc_8
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
))
utc_8
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
))
...
@@ -329,29 +305,26 @@ class TDTestCase:
...
@@ -329,29 +305,26 @@ class TDTestCase:
tdSql
.
query
(
"select cast(c5 as bigint) as b from ct4"
)
tdSql
.
query
(
"select cast(c5 as bigint) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c5
)):
for
i
in
range
(
len
(
data_ct4_c5
)):
tdSql
.
checkData
(
i
,
0
,
data_ct4_c5
[
i
]
)
if
data_ct4_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
int
(
data_ct4_c5
[
i
])
)
tdSql
.
checkData
(
i
,
0
,
None
)
if
data_ct4_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
int
(
data_ct4_c5
[
i
])
)
tdSql
.
query
(
"select cast(c5 as bigint) as b from t1"
)
tdSql
.
query
(
"select cast(c5 as bigint) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c5
)):
for
i
in
range
(
len
(
data_t1_c5
)):
tdSql
.
checkData
(
i
,
0
,
data_t1_c5
[
i
]
)
if
data_t1_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
int
(
data_t1_c5
[
i
])
)
tdSql
.
checkData
(
i
,
0
,
None
)
if
data_t1_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
int
(
data_t1_c5
[
i
])
)
tdLog
.
printNoPrefix
(
"==========step21: cast float to binary, expect changes to str(int) "
)
tdLog
.
printNoPrefix
(
"==========step21: cast float to binary, expect changes to str(int) "
)
tdSql
.
query
(
"select cast(c5 as binary(32)) as b from ct4"
)
tdSql
.
query
(
"select cast(c5 as binary(32)) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c5
)):
for
i
in
range
(
len
(
data_ct4_c5
)):
# tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, str(round(data_ct4_c5[i], 6)) )
tdSql
.
checkData
(
i
,
0
,
str
(
data_ct4_c5
[
i
])
)
if
data_ct4_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_ct4_c5
[
i
]:.
6
f
}
'
)
tdSql
.
checkData
(
i
,
0
,
str
(
data_ct4_c5
[
i
])
)
if
data_ct4_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_ct4_c5
[
i
]:.
6
f
}
'
)
tdSql
.
query
(
"select cast(c5 as binary(32)) as b from t1"
)
tdSql
.
query
(
"select cast(c5 as binary(32)) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c5
)):
for
i
in
range
(
len
(
data_t1_c5
)):
# tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, str(round(data_t1_c5[i], 6)) )
tdSql
.
checkData
(
i
,
0
,
str
(
data_t1_c5
[
i
])
)
if
data_t1_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_t1_c5
[
i
]:.
6
f
}
'
)
tdSql
.
checkData
(
i
,
0
,
str
(
data_t1_c5
[
i
])
)
if
data_t1_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_t1_c5
[
i
]:.
6
f
}
'
)
# tdSql.checkData( i, 0, str(data_t1_c5[i]) )
tdLog
.
printNoPrefix
(
"==========step22: cast float to nchar, expect changes to str(int) "
)
tdLog
.
printNoPrefix
(
"==========step22: cast float to nchar, expect changes to str(int) "
)
tdSql
.
query
(
"select cast(c5 as nchar(32)) as b from ct4"
)
tdSql
.
query
(
"select cast(c5 as nchar(32)) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c5
)):
for
i
in
range
(
len
(
data_ct4_c5
)):
tdSql
.
checkData
(
i
,
0
,
str
(
data_ct4_c5
[
i
])
)
if
data_ct4_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_ct4_c5
[
i
]:.
6
f
}
'
)
tdSql
.
checkData
(
i
,
0
,
None
)
if
data_ct4_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_ct4_c5
[
i
]:.
6
f
}
'
)
tdSql
.
query
(
"select cast(c5 as nchar(32)) as b from t1"
)
tdSql
.
query
(
"select cast(c5 as nchar(32)) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c5
)):
for
i
in
range
(
len
(
data_t1_c5
)):
tdSql
.
checkData
(
i
,
0
,
str
(
data_t1_c5
[
i
])
)
if
data_t1_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_t1_c5
[
i
]:.
6
f
}
'
)
tdSql
.
checkData
(
i
,
0
,
None
)
if
data_t1_c5
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_t1_c5
[
i
]:.
6
f
}
'
)
tdLog
.
printNoPrefix
(
"==========step23: cast float to timestamp, expect changes to timestamp "
)
tdLog
.
printNoPrefix
(
"==========step23: cast float to timestamp, expect changes to timestamp "
)
tdSql
.
query
(
"select cast(c5 as timestamp) as b from ct4"
)
tdSql
.
query
(
"select cast(c5 as timestamp) as b from ct4"
)
...
@@ -383,7 +356,7 @@ class TDTestCase:
...
@@ -383,7 +356,7 @@ class TDTestCase:
tdSql
.
query
(
"select cast(c6 as bigint) as b from ct4"
)
tdSql
.
query
(
"select cast(c6 as bigint) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c6
)):
for
i
in
range
(
len
(
data_ct4_c6
)):
tdSql
.
checkData
(
i
,
0
,
data_ct4_c6
[
i
]
)
if
data_ct4_c6
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
int
(
data_ct4_c6
[
i
])
)
tdSql
.
checkData
(
i
,
0
,
None
)
if
data_ct4_c6
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
int
(
data_ct4_c6
[
i
])
)
tdSql
.
query
(
"select cast(c6 as bigint) as b from t1"
)
tdSql
.
query
(
"select cast(c6 as bigint) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c6
)):
for
i
in
range
(
len
(
data_t1_c6
)):
if
data_t1_c6
[
i
]
is
None
:
if
data_t1_c6
[
i
]
is
None
:
...
@@ -396,18 +369,18 @@ class TDTestCase:
...
@@ -396,18 +369,18 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"==========step25: cast double to binary, expect changes to str(int) "
)
tdLog
.
printNoPrefix
(
"==========step25: cast double to binary, expect changes to str(int) "
)
tdSql
.
query
(
"select cast(c6 as binary(32)) as b from ct4"
)
tdSql
.
query
(
"select cast(c6 as binary(32)) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c6
)):
for
i
in
range
(
len
(
data_ct4_c6
)):
tdSql
.
checkData
(
i
,
0
,
str
(
data_ct4_c6
[
i
])
)
if
data_ct4_c6
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_ct4_c6
[
i
]:.
6
f
}
'
)
tdSql
.
checkData
(
i
,
0
,
None
)
if
data_ct4_c6
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_ct4_c6
[
i
]:.
6
f
}
'
)
tdSql
.
query
(
"select cast(c6 as binary(32)) as b from t1"
)
tdSql
.
query
(
"select cast(c6 as binary(32)) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c6
)):
for
i
in
range
(
len
(
data_t1_c6
)):
tdSql
.
checkData
(
i
,
0
,
str
(
data_t1_c6
[
i
])
)
if
data_t1_c6
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_t1_c6
[
i
]:.
6
f
}
'
)
tdSql
.
checkData
(
i
,
0
,
None
)
if
data_t1_c6
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_t1_c6
[
i
]:.
6
f
}
'
)
tdLog
.
printNoPrefix
(
"==========step26: cast double to nchar, expect changes to str(int) "
)
tdLog
.
printNoPrefix
(
"==========step26: cast double to nchar, expect changes to str(int) "
)
tdSql
.
query
(
"select cast(c6 as nchar(32)) as b from ct4"
)
tdSql
.
query
(
"select cast(c6 as nchar(32)) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c6
)):
for
i
in
range
(
len
(
data_ct4_c6
)):
tdSql
.
checkData
(
i
,
0
,
str
(
data_ct4_c6
[
i
])
)
if
data_ct4_c6
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_ct4_c6
[
i
]:.
6
f
}
'
)
tdSql
.
checkData
(
i
,
0
,
None
)
if
data_ct4_c6
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_ct4_c6
[
i
]:.
6
f
}
'
)
tdSql
.
query
(
"select cast(c6 as nchar(32)) as b from t1"
)
tdSql
.
query
(
"select cast(c6 as nchar(32)) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c6
)):
for
i
in
range
(
len
(
data_t1_c6
)):
tdSql
.
checkData
(
i
,
0
,
str
(
data_t1_c6
[
i
])
)
if
data_t1_c6
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_t1_c6
[
i
]:.
6
f
}
'
)
tdSql
.
checkData
(
i
,
0
,
None
)
if
data_t1_c6
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
f
'
{
data_t1_c6
[
i
]:.
6
f
}
'
)
tdLog
.
printNoPrefix
(
"==========step27: cast double to timestamp, expect changes to timestamp "
)
tdLog
.
printNoPrefix
(
"==========step27: cast double to timestamp, expect changes to timestamp "
)
tdSql
.
query
(
"select cast(c6 as timestamp) as b from ct4"
)
tdSql
.
query
(
"select cast(c6 as timestamp) as b from ct4"
)
...
@@ -420,16 +393,19 @@ class TDTestCase:
...
@@ -420,16 +393,19 @@ class TDTestCase:
date_init_stamp
=
datetime
.
datetime
.
utcfromtimestamp
(
int
(
data_ct4_c6
[
i
]
/
1000
))
date_init_stamp
=
datetime
.
datetime
.
utcfromtimestamp
(
int
(
data_ct4_c6
[
i
]
/
1000
))
date_data
=
date_init_stamp
.
replace
(
tzinfo
=
utc_zone
).
astimezone
(
utc_8
).
strftime
(
"%Y-%m-%d %H:%M:%S.%f"
)
date_data
=
date_init_stamp
.
replace
(
tzinfo
=
utc_zone
).
astimezone
(
utc_8
).
strftime
(
"%Y-%m-%d %H:%M:%S.%f"
)
tdSql
.
checkData
(
i
,
0
,
date_data
)
tdSql
.
checkData
(
i
,
0
,
date_data
)
# tdSql.query("select cast(c6 as timestamp) as b from t1")
# for i in range(len(data_t1_c6)):
tdSql
.
query
(
"select cast(c6 as timestamp) as b from t1"
)
# if data_t1_c6[i] is None:
for
i
in
range
(
len
(
data_t1_c6
)):
# tdSql.checkData( i, 0 , None )
if
data_t1_c6
[
i
]
is
None
:
# else:
tdSql
.
checkData
(
i
,
0
,
None
)
# utc_zone = datetime.timezone.utc
elif
i
==
10
:
# utc_8 = datetime.timezone(datetime.timedelta(hours=8))
continue
# date_init_stamp = datetime.datetime.utcfromtimestamp(int(data_t1_c6[i]/1000))
else
:
# date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
utc_zone
=
datetime
.
timezone
.
utc
# tdSql.checkData( i, 0, date_data)
utc_8
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
))
date_init_stamp
=
datetime
.
datetime
.
utcfromtimestamp
(
int
(
data_t1_c6
[
i
]
/
1000
))
date_data
=
date_init_stamp
.
replace
(
tzinfo
=
utc_zone
).
astimezone
(
utc_8
).
strftime
(
"%Y-%m-%d %H:%M:%S.%f"
)
tdSql
.
checkData
(
i
,
0
,
date_data
)
tdLog
.
printNoPrefix
(
"==========step28: cast bool to bigint, expect no changes"
)
tdLog
.
printNoPrefix
(
"==========step28: cast bool to bigint, expect no changes"
)
tdSql
.
query
(
"select c7 from ct4"
)
tdSql
.
query
(
"select c7 from ct4"
)
...
@@ -491,26 +467,51 @@ class TDTestCase:
...
@@ -491,26 +467,51 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"==========step32: cast binary to binary, expect no changes "
)
tdLog
.
printNoPrefix
(
"==========step32: cast binary to binary, expect no changes "
)
tdSql
.
query
(
"select cast(c8 as binary(32)) as b from ct4"
)
tdSql
.
query
(
"select cast(c8 as binary(32)) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c8
)):
for
i
in
range
(
len
(
data_ct4_c8
)):
tdSql
.
checkData
(
i
,
0
,
data_ct4_c8
[
i
]
)
tdSql
.
checkData
(
i
,
0
,
None
)
if
data_ct4_c8
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
data_ct4_c8
[
i
])
tdSql
.
query
(
"select cast(c8 as binary(32)) as b from t1"
)
tdSql
.
query
(
"select cast(c8 as binary(32)) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c8
)):
for
i
in
range
(
len
(
data_t1_c8
)):
tdSql
.
checkData
(
i
,
0
,
data_t1_c8
[
i
]
)
tdSql
.
checkData
(
i
,
0
,
None
)
if
data_t1_c8
[
i
]
is
None
else
tdSql
.
checkData
(
i
,
0
,
data_t1_c8
[
i
]
)
tdLog
.
printNoPrefix
(
"==========step33: cast binary to binary, expect truncate "
)
tdLog
.
printNoPrefix
(
"==========step33: cast binary to binary, expect truncate "
)
tdSql
.
query
(
"select cast(c8 as binary(2)) as b from ct4"
)
tdSql
.
query
(
"select cast(c8 as binary(2)) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c8
)):
for
i
in
range
(
len
(
data_ct4_c8
)):
tdSql
.
checkData
(
i
,
0
,
data_ct4_c8
[
i
][:
2
]
)
if
data_ct4_c8
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
elif
tdSql
.
getData
(
i
,
0
)
==
data_ct4_c8
[
i
][:
2
]:
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
== expect:
{
data_ct4_c8
[
i
][:
2
]
}
"
)
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
tdSql
.
sql
}
row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
!= expect:
{
data_ct4_c8
[
i
][:
2
]
}
"
)
tdSql
.
query
(
"select cast(c8 as binary(2)) as b from t1"
)
tdSql
.
query
(
"select cast(c8 as binary(2)) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c8
)):
for
i
in
range
(
len
(
data_t1_c8
)):
tdSql
.
checkData
(
i
,
0
,
data_t1_c8
[
i
][:
2
]
)
if
data_t1_c8
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
elif
tdSql
.
getData
(
i
,
0
)
==
data_t1_c8
[
i
][:
2
]:
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
== expect:
{
data_t1_c8
[
i
][:
2
]
}
"
)
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
tdSql
.
sql
}
row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
!= expect:
{
data_t1_c8
[
i
][:
2
]
}
"
)
tdLog
.
printNoPrefix
(
"==========step34: cast binary to nchar, expect changes to str(int) "
)
tdLog
.
printNoPrefix
(
"==========step34: cast binary to nchar, expect changes to str(int) "
)
tdSql
.
query
(
"select cast(c8 as nchar(32)) as b from ct4"
)
tdSql
.
query
(
"select cast(c8 as nchar(32)) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c8
)):
for
i
in
range
(
len
(
data_ct4_c8
)):
tdSql
.
checkData
(
i
,
0
,
data_ct4_c8
[
i
]
)
if
data_ct4_c8
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
elif
tdSql
.
getData
(
i
,
0
)
==
data_ct4_c8
[
i
]:
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
== expect:
{
data_ct4_c8
[
i
]
}
"
)
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
tdSql
.
sql
}
row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
!= expect:
{
data_ct4_c8
[
i
]
}
"
)
tdSql
.
query
(
"select cast(c8 as nchar(32)) as b from t1"
)
tdSql
.
query
(
"select cast(c8 as nchar(32)) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c8
)):
for
i
in
range
(
len
(
data_t1_c8
)):
tdSql
.
checkData
(
i
,
0
,
data_t1_c8
[
i
]
)
if
data_t1_c8
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
elif
tdSql
.
getData
(
i
,
0
)
==
data_t1_c8
[
i
]:
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
== expect:
{
data_t1_c8
[
i
]
}
"
)
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
tdSql
.
sql
}
row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
!= expect:
{
data_t1_c8
[
i
]
}
"
)
tdSql
.
query
(
"select c9 from ct4"
)
tdSql
.
query
(
"select c9 from ct4"
)
...
@@ -522,31 +523,84 @@ class TDTestCase:
...
@@ -522,31 +523,84 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"==========step35: cast nchar to nchar, expect no changes "
)
tdLog
.
printNoPrefix
(
"==========step35: cast nchar to nchar, expect no changes "
)
tdSql
.
query
(
"select cast(c9 as nchar(32)) as b from ct4"
)
tdSql
.
query
(
"select cast(c9 as nchar(32)) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c9
)):
for
i
in
range
(
len
(
data_ct4_c9
)):
tdSql
.
checkData
(
i
,
0
,
data_ct4_c9
[
i
])
if
data_ct4_c9
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
elif
tdSql
.
getData
(
i
,
0
)
==
data_ct4_c9
[
i
]:
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
== expect:
{
data_ct4_c9
[
i
]
}
"
)
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
tdSql
.
sql
}
row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
!= expect:
{
data_ct4_c9
[
i
]
}
"
)
tdSql
.
query
(
"select cast(c9 as nchar(32)) as b from t1"
)
tdSql
.
query
(
"select cast(c9 as nchar(32)) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c9
)):
for
i
in
range
(
len
(
data_t1_c9
)):
tdSql
.
checkData
(
i
,
0
,
data_t1_c9
[
i
]
)
tdSql
.
checkData
(
i
,
0
,
data_t1_c9
[
i
]
)
if
data_t1_c9
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
elif
tdSql
.
getData
(
i
,
0
)
==
data_t1_c9
[
i
]:
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
== expect:
{
data_t1_c9
[
i
]
}
"
)
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
tdSql
.
sql
}
row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
!= expect:
{
data_t1_c9
[
i
]
}
"
)
tdLog
.
printNoPrefix
(
"==========step36: cast nchar to nchar, expect truncate "
)
tdLog
.
printNoPrefix
(
"==========step36: cast nchar to nchar, expect truncate "
)
tdSql
.
query
(
"select cast(c9 as nchar(2)) as b from ct4"
)
tdSql
.
query
(
"select cast(c9 as nchar(2)) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c9
)):
for
i
in
range
(
len
(
data_ct4_c9
)):
tdSql
.
checkData
(
i
,
0
,
data_ct4_c9
[
i
][:
2
]
)
if
data_ct4_c9
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
elif
tdSql
.
getData
(
i
,
0
)
==
data_ct4_c9
[
i
][:
2
]:
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
== expect:
{
data_ct4_c9
[
i
][:
2
]
}
"
)
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
tdSql
.
sql
}
row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
!= expect:
{
data_ct4_c9
[
i
][:
2
]
}
"
)
tdSql
.
query
(
"select cast(c9 as nchar(2)) as b from t1"
)
tdSql
.
query
(
"select cast(c9 as nchar(2)) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c9
)):
for
i
in
range
(
len
(
data_t1_c9
)):
tdSql
.
checkData
(
i
,
0
,
data_t1_c9
[
i
][:
2
]
)
if
data_t1_c9
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
elif
tdSql
.
getData
(
i
,
0
)
==
data_t1_c9
[
i
][:
2
]:
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
== expect:
{
data_t1_c9
[
i
][:
2
]
}
"
)
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
tdSql
.
sql
}
row:
{
i
}
col:0 data:
{
tdSql
.
queryResult
[
i
][
0
]
}
!= expect:
{
data_t1_c9
[
i
][:
2
]
}
"
)
tdSql
.
query
(
"select c
9
from ct4"
)
tdSql
.
query
(
"select c
10
from ct4"
)
data_ct4_c10
=
[
tdSql
.
getData
(
i
,
0
)
for
i
in
range
(
tdSql
.
queryRows
)]
data_ct4_c10
=
[
tdSql
.
getData
(
i
,
0
)
for
i
in
range
(
tdSql
.
queryRows
)]
tdSql
.
query
(
"select c
9
from t1"
)
tdSql
.
query
(
"select c
10
from t1"
)
data_t1_c10
=
[
tdSql
.
getData
(
i
,
0
)
for
i
in
range
(
tdSql
.
queryRows
)]
data_t1_c10
=
[
tdSql
.
getData
(
i
,
0
)
for
i
in
range
(
tdSql
.
queryRows
)]
tdLog
.
printNoPrefix
(
"==========step37: cast timestamp to nchar, expect no changes "
)
tdLog
.
printNoPrefix
(
"==========step37: cast timestamp to nchar, expect no changes "
)
tdSql
.
query
(
"select cast(c
9
as nchar(32)) as b from ct4"
)
tdSql
.
query
(
"select cast(c
10
as nchar(32)) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c10
)):
for
i
in
range
(
len
(
data_ct4_c10
)):
tdSql
.
checkData
(
i
,
0
,
data_ct4_c10
[
i
])
if
data_ct4_c10
[
i
]
is
None
:
tdSql
.
query
(
"select cast(c9 as nchar(32)) as b from t1"
)
tdSql
.
checkData
(
i
,
0
,
None
)
else
:
time2str
=
str
(
int
(
datetime
.
datetime
.
timestamp
(
data_ct4_c10
[
i
])
*
1000
))
tdSql
.
checkData
(
i
,
0
,
time2str
)
tdSql
.
query
(
"select cast(c10 as nchar(32)) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c10
)):
for
i
in
range
(
len
(
data_t1_c10
)):
tdSql
.
checkData
(
i
,
0
,
data_t1_c10
[
i
]
)
if
data_t1_c10
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
elif
i
==
10
:
continue
else
:
time2str
=
str
(
int
(
datetime
.
datetime
.
timestamp
(
data_t1_c10
[
i
])
*
1000
))
tdSql
.
checkData
(
i
,
0
,
time2str
)
tdLog
.
printNoPrefix
(
"==========step38: cast timestamp to binary, expect no changes "
)
tdSql
.
query
(
"select cast(c10 as binary(32)) as b from ct4"
)
for
i
in
range
(
len
(
data_ct4_c10
)):
if
data_ct4_c10
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
else
:
time2str
=
str
(
int
(
datetime
.
datetime
.
timestamp
(
data_ct4_c10
[
i
])
*
1000
))
tdSql
.
checkData
(
i
,
0
,
time2str
)
tdSql
.
query
(
"select cast(c10 as binary(32)) as b from t1"
)
for
i
in
range
(
len
(
data_t1_c10
)):
if
data_t1_c10
[
i
]
is
None
:
tdSql
.
checkData
(
i
,
0
,
None
)
elif
i
==
10
:
continue
else
:
time2str
=
str
(
int
(
datetime
.
datetime
.
timestamp
(
data_t1_c10
[
i
])
*
1000
))
tdSql
.
checkData
(
i
,
0
,
time2str
)
tdSql
.
error
(
"select cast(c1 as int) as b from ct4"
)
tdSql
.
error
(
"select cast(c1 as int) as b from ct4"
)
...
@@ -567,12 +621,9 @@ class TDTestCase:
...
@@ -567,12 +621,9 @@ class TDTestCase:
tdSql
.
error
(
"select cast(c7 as double) as b from ct4"
)
tdSql
.
error
(
"select cast(c7 as double) as b from ct4"
)
tdSql
.
error
(
"select cast(c8 as tinyint unsigned) as b from ct4"
)
tdSql
.
error
(
"select cast(c8 as tinyint unsigned) as b from ct4"
)
tdSql
.
query
(
"select cast(c8 as timestamp ) as b from ct4"
)
tdSql
.
error
(
"select cast(c8 as timestamp ) as b from ct4"
)
tdSql
.
query
(
"select cast(c9 as timestamp ) as b from ct4"
)
tdSql
.
error
(
"select cast(c9 as timestamp ) as b from ct4"
)
tdSql
.
error
(
"select cast(c9 as binary(64) ) as b from ct4"
)
tdSql
.
error
(
"select cast(c9 as binary(64) ) as b from ct4"
)
tdSql
.
error
(
"select cast(c10 as binary(64) ) as b from ct4"
)
tdSql
.
error
(
"select cast(c10 as nchar(64) ) as b from ct4"
)
def
stop
(
self
):
def
stop
(
self
):
...
...
tests/system-test/fulltest.sh
浏览文件 @
055e0516
python3 ./test.py
-f
2-query/between.py
#!/bin/bash
set
-e
#python3 ./test.py -f 2-query/between.py
python3 ./test.py
-f
2-query/distinct.py
python3 ./test.py
-f
2-query/distinct.py
python3 ./test.py
-f
2-query/varchar.py
python3 ./test.py
-f
2-query/varchar.py
python3 ./test.py
-f
2-query/cast.py
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录