Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
dc98029b
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看板
提交
dc98029b
编写于
1月 08, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feature/tkv
上级
eb7151f7
2942658d
变更
47
隐藏空白更改
内联
并排
Showing
47 changed file
with
1080 addition
and
682 deletion
+1080
-682
include/common/tmsg.h
include/common/tmsg.h
+2
-2
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+7
-7
include/libs/parser/parsenodes.h
include/libs/parser/parsenodes.h
+1
-2
include/libs/parser/parser.h
include/libs/parser/parser.h
+12
-4
include/libs/planner/planner.h
include/libs/planner/planner.h
+12
-5
include/libs/qcom/query.h
include/libs/qcom/query.h
+1
-1
include/libs/scheduler/scheduler.h
include/libs/scheduler/scheduler.h
+10
-0
include/util/taoserror.h
include/util/taoserror.h
+12
-16
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+2
-1
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+4
-4
source/client/src/clientMain.c
source/client/src/clientMain.c
+3
-2
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+53
-28
source/dnode/mgmt/impl/src/dndBnode.c
source/dnode/mgmt/impl/src/dndBnode.c
+2
-2
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+60
-26
source/dnode/mgmt/impl/src/dndQnode.c
source/dnode/mgmt/impl/src/dndQnode.c
+2
-2
source/dnode/mgmt/impl/src/dndSnode.c
source/dnode/mgmt/impl/src/dndSnode.c
+2
-2
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+4
-0
source/dnode/mgmt/impl/test/bnode/dbnode.cpp
source/dnode/mgmt/impl/test/bnode/dbnode.cpp
+2
-2
source/dnode/mgmt/impl/test/mnode/dmnode.cpp
source/dnode/mgmt/impl/test/mnode/dmnode.cpp
+58
-52
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
+2
-2
source/dnode/mgmt/impl/test/snode/dsnode.cpp
source/dnode/mgmt/impl/test/snode/dsnode.cpp
+2
-2
source/dnode/mgmt/impl/test/sut/src/sut.cpp
source/dnode/mgmt/impl/test/sut/src/sut.cpp
+1
-1
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+89
-117
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+4
-4
source/dnode/mnode/impl/test/mnode/mnode.cpp
source/dnode/mnode/impl/test/mnode/mnode.cpp
+152
-163
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+3
-4
source/libs/executor/CMakeLists.txt
source/libs/executor/CMakeLists.txt
+1
-1
source/libs/executor/inc/dataSinkInt.h
source/libs/executor/inc/dataSinkInt.h
+45
-0
source/libs/executor/inc/dataSinkMgt.h
source/libs/executor/inc/dataSinkMgt.h
+104
-0
source/libs/executor/src/dataDispatcher.c
source/libs/executor/src/dataDispatcher.c
+140
-0
source/libs/executor/src/dataSinkMgt.c
source/libs/executor/src/dataSinkMgt.c
+56
-0
source/libs/parser/inc/parserInt.h
source/libs/parser/inc/parserInt.h
+15
-7
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+30
-106
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+17
-6
source/libs/parser/src/insertParser.c
source/libs/parser/src/insertParser.c
+2
-3
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+17
-13
source/libs/parser/test/parserTests.cpp
source/libs/parser/test/parserTests.cpp
+55
-13
source/libs/parser/test/plannerTest.cpp
source/libs/parser/test/plannerTest.cpp
+5
-2
source/libs/parser/test/tokenizerTest.cpp
source/libs/parser/test/tokenizerTest.cpp
+5
-1
source/libs/planner/inc/plannerInt.h
source/libs/planner/inc/plannerInt.h
+2
-2
source/libs/planner/src/logicPlan.c
source/libs/planner/src/logicPlan.c
+48
-47
source/libs/planner/src/physicalPlan.c
source/libs/planner/src/physicalPlan.c
+5
-2
source/libs/planner/src/physicalPlanJson.c
source/libs/planner/src/physicalPlanJson.c
+5
-3
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+7
-0
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+14
-15
source/util/src/terror.c
source/util/src/terror.c
+4
-8
tests/script/general/table/basic1.sim
tests/script/general/table/basic1.sim
+1
-2
未找到文件。
include/common/tmsg.h
浏览文件 @
dc98029b
...
@@ -935,13 +935,13 @@ typedef struct {
...
@@ -935,13 +935,13 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
}
SMCreateMnode
Msg
,
SMDropMnodeMsg
,
SDDropMnodeMsg
;
}
SMCreateMnode
Req
,
SMDropMnodeReq
,
SDDropMnodeReq
;
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
int8_t
replica
;
int8_t
replica
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
SReplica
replicas
[
TSDB_MAX_REPLICA
];
}
SDCreateMnode
Msg
,
SDAlterMnodeMsg
;
}
SDCreateMnode
Req
,
SDAlterMnodeReq
;
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
...
...
include/libs/catalog/catalog.h
浏览文件 @
dc98029b
...
@@ -87,14 +87,14 @@ int32_t catalogGetDBVgroupVersion(struct SCatalog* pCatalog, const char* dbName,
...
@@ -87,14 +87,14 @@ int32_t catalogGetDBVgroupVersion(struct SCatalog* pCatalog, const char* dbName,
/**
/**
* Get a DB's all vgroup info.
* Get a DB's all vgroup info.
* @param pCatalog (input, got with catalogGetHandle)
* @param pCatalog (input, got with catalogGetHandle)
* @param p
Rpc
(input, rpc object)
* @param p
Transporter
(input, rpc object)
* @param pMgmtEps (input, mnode EPs)
* @param pMgmtEps (input, mnode EPs)
* @param pDBName (input, full db name)
* @param pDBName (input, full db name)
* @param forceUpdate (input, force update db vgroup info from mnode)
* @param forceUpdate (input, force update db vgroup info from mnode)
* @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller)
* @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller)
* @return error code
* @return error code
*/
*/
int32_t
catalogGetDBVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
p
Rpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
bool
forceUpdate
,
SArray
**
pVgroupList
);
int32_t
catalogGetDBVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
p
Transporter
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
bool
forceUpdate
,
SArray
**
pVgroupList
);
int32_t
catalogUpdateDBVgroup
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
*
dbInfo
);
int32_t
catalogUpdateDBVgroup
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
*
dbInfo
);
...
@@ -149,13 +149,13 @@ int32_t catalogGetSTableMeta(struct SCatalog* pCatalog, void * pTransporter, con
...
@@ -149,13 +149,13 @@ int32_t catalogGetSTableMeta(struct SCatalog* pCatalog, void * pTransporter, con
/**
/**
* Get a table's actual vgroup, for stable it's all possible vgroup list.
* Get a table's actual vgroup, for stable it's all possible vgroup list.
* @param pCatalog (input, got with catalogGetHandle)
* @param pCatalog (input, got with catalogGetHandle)
* @param p
Rpc
(input, rpc object)
* @param p
Transporter
(input, rpc object)
* @param pMgmtEps (input, mnode EPs)
* @param pMgmtEps (input, mnode EPs)
* @param pTableName (input, table name, NOT including db name)
* @param pTableName (input, table name, NOT including db name)
* @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller)
* @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller)
* @return error code
* @return error code
*/
*/
int32_t
catalogGetTableDistVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
p
Rpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SArray
**
pVgroupList
);
int32_t
catalogGetTableDistVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
p
Transporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SArray
**
pVgroupList
);
/**
/**
* Get a table's vgroup from its name's hash value.
* Get a table's vgroup from its name's hash value.
...
@@ -172,16 +172,16 @@ int32_t catalogGetTableHashVgroup(struct SCatalog* pCatalog, void * pTransporter
...
@@ -172,16 +172,16 @@ int32_t catalogGetTableHashVgroup(struct SCatalog* pCatalog, void * pTransporter
/**
/**
* Get all meta data required in pReq.
* Get all meta data required in pReq.
* @param pCatalog (input, got with catalogGetHandle)
* @param pCatalog (input, got with catalogGetHandle)
* @param p
Rpc
(input, rpc object)
* @param p
Transporter
(input, rpc object)
* @param pMgmtEps (input, mnode EPs)
* @param pMgmtEps (input, mnode EPs)
* @param pReq (input, reqest info)
* @param pReq (input, reqest info)
* @param pRsp (output, response data)
* @param pRsp (output, response data)
* @return error code
* @return error code
*/
*/
int32_t
catalogGetAllMeta
(
struct
SCatalog
*
pCatalog
,
void
*
p
Rpc
,
const
SEpSet
*
pMgmtEps
,
const
SCatalogReq
*
pReq
,
SMetaData
*
pRsp
);
int32_t
catalogGetAllMeta
(
struct
SCatalog
*
pCatalog
,
void
*
p
Transporter
,
const
SEpSet
*
pMgmtEps
,
const
SCatalogReq
*
pReq
,
SMetaData
*
pRsp
);
int32_t
catalogGetQnodeList
(
struct
SCatalog
*
pCatalog
,
void
*
p
Rpc
,
const
SEpSet
*
pMgmtEps
,
SArray
*
pQnodeList
);
int32_t
catalogGetQnodeList
(
struct
SCatalog
*
pCatalog
,
void
*
p
Transporter
,
const
SEpSet
*
pMgmtEps
,
SArray
*
pQnodeList
);
int32_t
catalogGetExpiredSTables
(
struct
SCatalog
*
pCatalog
,
SSTableMetaVersion
**
stables
,
uint32_t
*
num
);
int32_t
catalogGetExpiredSTables
(
struct
SCatalog
*
pCatalog
,
SSTableMetaVersion
**
stables
,
uint32_t
*
num
);
...
...
include/libs/parser/parsenodes.h
浏览文件 @
dc98029b
...
@@ -135,9 +135,8 @@ typedef struct SQueryStmtInfo {
...
@@ -135,9 +135,8 @@ typedef struct SQueryStmtInfo {
SArray
*
pUdfInfo
;
SArray
*
pUdfInfo
;
struct
SQueryStmtInfo
*
sibling
;
// sibling
struct
SQueryStmtInfo
*
sibling
;
// sibling
struct
SQueryStmtInfo
*
pDownstream
;
SMultiFunctionsDesc
info
;
SMultiFunctionsDesc
info
;
SArray
*
p
Up
stream
;
// SArray<struct SQueryStmtInfo>
SArray
*
p
Down
stream
;
// SArray<struct SQueryStmtInfo>
int32_t
havingFieldNum
;
int32_t
havingFieldNum
;
int32_t
exprListLevelIndex
;
int32_t
exprListLevelIndex
;
}
SQueryStmtInfo
;
}
SQueryStmtInfo
;
...
...
include/libs/parser/parser.h
浏览文件 @
dc98029b
...
@@ -24,7 +24,6 @@ extern "C" {
...
@@ -24,7 +24,6 @@ extern "C" {
typedef
struct
SParseContext
{
typedef
struct
SParseContext
{
SParseBasicCtx
ctx
;
SParseBasicCtx
ctx
;
int8_t
schemaAttached
;
// denote if submit block is built with table schema or not
const
char
*
pSql
;
// sql string
const
char
*
pSql
;
// sql string
size_t
sqlLen
;
// length of the sql string
size_t
sqlLen
;
// length of the sql string
char
*
pMsg
;
// extended error message if exists to help identifying the problem in sql statement.
char
*
pMsg
;
// extended error message if exists to help identifying the problem in sql statement.
...
@@ -41,8 +40,17 @@ typedef struct SParseContext {
...
@@ -41,8 +40,17 @@ typedef struct SParseContext {
*/
*/
int32_t
qParseQuerySql
(
SParseContext
*
pContext
,
SQueryNode
**
pQuery
);
int32_t
qParseQuerySql
(
SParseContext
*
pContext
,
SQueryNode
**
pQuery
);
bool
qIsDdlQuery
(
const
SQueryNode
*
pQuery
);
/**
* Return true if it is a ddl/dcl sql statement
* @param pQuery
* @return
*/
bool
qIsDdlQuery
(
const
SQueryNode
*
pQueryNode
);
/**
* Destroy logic query plan
* @param pQueryNode
*/
void
qDestroyQuery
(
SQueryNode
*
pQueryNode
);
void
qDestroyQuery
(
SQueryNode
*
pQueryNode
);
/**
/**
...
@@ -62,8 +70,8 @@ void columnListDestroy(SArray* pColumnList);
...
@@ -62,8 +70,8 @@ void columnListDestroy(SArray* pColumnList);
void
dropAllExprInfo
(
SArray
**
pExprInfo
,
int32_t
numOfLevel
);
void
dropAllExprInfo
(
SArray
**
pExprInfo
,
int32_t
numOfLevel
);
typedef
struct
SSourceParam
{
typedef
struct
SSourceParam
{
SArray
*
pExprNodeList
;
//Array<struct tExprNode*>
SArray
*
pExprNodeList
;
//Array<struct tExprNode*>
SArray
*
pColumnList
;
//Array<struct SColumn>
SArray
*
pColumnList
;
//Array<struct SColumn>
int32_t
num
;
int32_t
num
;
}
SSourceParam
;
}
SSourceParam
;
...
...
include/libs/planner/planner.h
浏览文件 @
dc98029b
...
@@ -50,8 +50,10 @@ struct SQueryStmtInfo;
...
@@ -50,8 +50,10 @@ struct SQueryStmtInfo;
typedef
SSchema
SSlotSchema
;
typedef
SSchema
SSlotSchema
;
typedef
struct
SDataBlockSchema
{
typedef
struct
SDataBlockSchema
{
SSlotSchema
*
pSchema
;
SSlotSchema
*
pSchema
;
int32_t
numOfCols
;
// number of columns
int32_t
numOfCols
;
// number of columns
int32_t
resultRowSize
;
int16_t
precision
;
}
SDataBlockSchema
;
}
SDataBlockSchema
;
typedef
struct
SQueryNodeBasicInfo
{
typedef
struct
SQueryNodeBasicInfo
{
...
@@ -61,6 +63,7 @@ typedef struct SQueryNodeBasicInfo {
...
@@ -61,6 +63,7 @@ typedef struct SQueryNodeBasicInfo {
typedef
struct
SDataSink
{
typedef
struct
SDataSink
{
SQueryNodeBasicInfo
info
;
SQueryNodeBasicInfo
info
;
SDataBlockSchema
schema
;
}
SDataSink
;
}
SDataSink
;
typedef
struct
SDataDispatcher
{
typedef
struct
SDataDispatcher
{
...
@@ -139,9 +142,13 @@ typedef struct SQueryDag {
...
@@ -139,9 +142,13 @@ typedef struct SQueryDag {
struct
SQueryNode
;
struct
SQueryNode
;
/**
/**
* Create the physical plan for the query, according to the AST.
* Create the physical plan for the query, according to the AST.
*/
* @param pQueryInfo
* @param pDag
* @param requestId
* @return
*/
int32_t
qCreateQueryDag
(
const
struct
SQueryNode
*
pQueryInfo
,
struct
SQueryDag
**
pDag
,
uint64_t
requestId
);
int32_t
qCreateQueryDag
(
const
struct
SQueryNode
*
pQueryInfo
,
struct
SQueryDag
**
pDag
,
uint64_t
requestId
);
// Set datasource of this subplan, multiple calls may be made to a subplan.
// Set datasource of this subplan, multiple calls may be made to a subplan.
...
...
include/libs/qcom/query.h
浏览文件 @
dc98029b
...
@@ -87,7 +87,7 @@ typedef struct SUseDbOutput {
...
@@ -87,7 +87,7 @@ typedef struct SUseDbOutput {
SDBVgroupInfo
dbVgroup
;
SDBVgroupInfo
dbVgroup
;
}
SUseDbOutput
;
}
SUseDbOutput
;
typedef
enum
{
enum
{
META_TYPE_NON_TABLE
=
1
,
META_TYPE_NON_TABLE
=
1
,
META_TYPE_CTABLE
,
META_TYPE_CTABLE
,
META_TYPE_TABLE
,
META_TYPE_TABLE
,
...
...
include/libs/scheduler/scheduler.h
浏览文件 @
dc98029b
...
@@ -75,6 +75,12 @@ int32_t scheduleExecJob(void *transport, SArray *nodeList, SQueryDag* pDag, void
...
@@ -75,6 +75,12 @@ int32_t scheduleExecJob(void *transport, SArray *nodeList, SQueryDag* pDag, void
*/
*/
int32_t
scheduleAsyncExecJob
(
void
*
transport
,
SArray
*
nodeList
,
SQueryDag
*
pDag
,
void
**
pJob
);
int32_t
scheduleAsyncExecJob
(
void
*
transport
,
SArray
*
nodeList
,
SQueryDag
*
pDag
,
void
**
pJob
);
/**
* Fetch query result from the remote query executor
* @param pJob
* @param data
* @return
*/
int32_t
scheduleFetchRows
(
void
*
pJob
,
void
**
data
);
int32_t
scheduleFetchRows
(
void
*
pJob
,
void
**
data
);
...
@@ -85,6 +91,10 @@ int32_t scheduleFetchRows(void *pJob, void **data);
...
@@ -85,6 +91,10 @@ int32_t scheduleFetchRows(void *pJob, void **data);
*/
*/
int32_t
scheduleCancelJob
(
void
*
pJob
);
int32_t
scheduleCancelJob
(
void
*
pJob
);
/**
* Free the query job
* @param pJob
*/
void
scheduleFreeJob
(
void
*
pJob
);
void
scheduleFreeJob
(
void
*
pJob
);
void
schedulerDestroy
(
void
);
void
schedulerDestroy
(
void
);
...
...
include/util/taoserror.h
浏览文件 @
dc98029b
...
@@ -259,28 +259,24 @@ int32_t* taosGetErrno();
...
@@ -259,28 +259,24 @@ int32_t* taosGetErrno();
#define TSDB_CODE_DND_DNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0411)
#define TSDB_CODE_DND_DNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0411)
#define TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0420)
#define TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0420)
#define TSDB_CODE_DND_MNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0421)
#define TSDB_CODE_DND_MNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0421)
#define TSDB_CODE_DND_MNODE_ID_INVALID TAOS_DEF_ERROR_CODE(0, 0x0422)
#define TSDB_CODE_DND_MNODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0422)
#define TSDB_CODE_DND_MNODE_ID_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0423)
#define TSDB_CODE_DND_MNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0423)
#define TSDB_CODE_DND_MNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0424)
#define TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0424)
#define TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0425)
#define TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0430)
#define TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0430)
#define TSDB_CODE_DND_QNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0431)
#define TSDB_CODE_DND_QNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0431)
#define TSDB_CODE_DND_QNODE_ID_INVALID TAOS_DEF_ERROR_CODE(0, 0x0432)
#define TSDB_CODE_DND_QNODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0432)
#define TSDB_CODE_DND_QNODE_ID_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0433)
#define TSDB_CODE_DND_QNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0433)
#define TSDB_CODE_DND_QNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0434)
#define TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0434)
#define TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0435)
#define TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0440)
#define TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0440)
#define TSDB_CODE_DND_SNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0441)
#define TSDB_CODE_DND_SNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0441)
#define TSDB_CODE_DND_SNODE_ID_INVALID TAOS_DEF_ERROR_CODE(0, 0x0442)
#define TSDB_CODE_DND_SNODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0442)
#define TSDB_CODE_DND_SNODE_ID_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0443)
#define TSDB_CODE_DND_SNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0443)
#define TSDB_CODE_DND_SNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0444)
#define TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0444)
#define TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0445)
#define TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0450)
#define TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0450)
#define TSDB_CODE_DND_BNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0451)
#define TSDB_CODE_DND_BNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0451)
#define TSDB_CODE_DND_BNODE_ID_INVALID TAOS_DEF_ERROR_CODE(0, 0x0452)
#define TSDB_CODE_DND_BNODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0452)
#define TSDB_CODE_DND_BNODE_ID_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0453)
#define TSDB_CODE_DND_BNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0453)
#define TSDB_CODE_DND_BNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0454)
#define TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0454)
#define TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0455)
#define TSDB_CODE_DND_VNODE_TOO_MANY_VNODES TAOS_DEF_ERROR_CODE(0, 0x0460)
#define TSDB_CODE_DND_VNODE_TOO_MANY_VNODES TAOS_DEF_ERROR_CODE(0, 0x0460)
#define TSDB_CODE_DND_VNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0461)
#define TSDB_CODE_DND_VNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0461)
#define TSDB_CODE_DND_VNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0462)
#define TSDB_CODE_DND_VNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0462)
...
...
source/client/inc/clientInt.h
浏览文件 @
dc98029b
...
@@ -62,6 +62,7 @@ typedef struct SAppInstInfo {
...
@@ -62,6 +62,7 @@ typedef struct SAppInstInfo {
SList
*
pConnList
;
// STscObj linked list
SList
*
pConnList
;
// STscObj linked list
int64_t
clusterId
;
int64_t
clusterId
;
void
*
pTransporter
;
void
*
pTransporter
;
SHeartBeatInfo
hb
;
}
SAppInstInfo
;
}
SAppInstInfo
;
typedef
struct
SAppInfo
{
typedef
struct
SAppInfo
{
...
@@ -70,7 +71,7 @@ typedef struct SAppInfo {
...
@@ -70,7 +71,7 @@ typedef struct SAppInfo {
char
*
ep
;
char
*
ep
;
int32_t
pid
;
int32_t
pid
;
int32_t
numOfThreads
;
int32_t
numOfThreads
;
SHeartBeatInfo
hb
;
SHashObj
*
pInstMap
;
SHashObj
*
pInstMap
;
}
SAppInfo
;
}
SAppInfo
;
...
...
source/client/src/clientImpl.c
浏览文件 @
dc98029b
...
@@ -291,10 +291,10 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
...
@@ -291,10 +291,10 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
nPrintTsc
(
"%s"
,
sql
)
nPrintTsc
(
"%s"
,
sql
)
SRequestObj
*
pRequest
=
NULL
;
SRequestObj
*
pRequest
=
NULL
;
SQueryNode
*
pQuery
=
NULL
;
SQueryNode
*
pQuery
=
NULL
;
SQueryDag
*
pDag
=
NULL
;
SQueryDag
*
pDag
=
NULL
;
void
*
pJob
=
NULL
;
void
*
pJob
=
NULL
;
terrno
=
TSDB_CODE_SUCCESS
;
terrno
=
TSDB_CODE_SUCCESS
;
CHECK_CODE_GOTO
(
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
),
_return
);
CHECK_CODE_GOTO
(
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
),
_return
);
...
...
source/client/src/clientMain.c
浏览文件 @
dc98029b
#include "os.h"
#include "os.h"
#include "tref.h"
#include "trpc.h"
#include "clientInt.h"
#include "clientInt.h"
#include "clientLog.h"
#include "clientLog.h"
#include "query.h"
#include "query.h"
#include "tmsg.h"
#include "tmsg.h"
#include "tglobal.h"
#include "tglobal.h"
#include "tref.h"
#include "catalog.h"
#include "trpc.h"
#define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_RELEASED 0
#define TSC_VAR_RELEASED 0
...
...
source/client/test/clientTests.cpp
浏览文件 @
dc98029b
...
@@ -485,6 +485,22 @@ TEST(testCase, drop_stable_Test) {
...
@@ -485,6 +485,22 @@ TEST(testCase, drop_stable_Test) {
taos_close
(
pConn
);
taos_close
(
pConn
);
}
}
TEST
(
testCase
,
generated_request_id_test
)
{
SHashObj
*
phash
=
taosHashInit
(
10000
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_ENTRY_LOCK
);
for
(
int32_t
i
=
0
;
i
<
50000
;
++
i
)
{
uint64_t
v
=
generateRequestId
();
void
*
result
=
taosHashGet
(
phash
,
&
v
,
sizeof
(
v
));
if
(
result
!=
nullptr
)
{
printf
(
"0x%lx, index:%d
\n
"
,
v
,
i
);
}
assert
(
result
==
nullptr
);
taosHashPut
(
phash
,
&
v
,
sizeof
(
v
),
NULL
,
0
);
}
taosHashCleanup
(
phash
);
}
// TEST(testCase, create_topic_Test) {
// TEST(testCase, create_topic_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
// assert(pConn != NULL);
...
@@ -518,46 +534,55 @@ TEST(testCase, drop_stable_Test) {
...
@@ -518,46 +534,55 @@ TEST(testCase, drop_stable_Test) {
// tmq_create_topic(pConn, "test_topic_1", sql, strlen(sql));
// tmq_create_topic(pConn, "test_topic_1", sql, strlen(sql));
// taos_close(pConn);
// taos_close(pConn);
//}
//}
TEST
(
testCase
,
generated_request_id_test
)
{
//TEST(testCase, insert_test) {
SHashObj
*
phash
=
taosHashInit
(
10000
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_ENTRY_LOCK
);
for
(
int32_t
i
=
0
;
i
<
50000
;
++
i
)
{
uint64_t
v
=
generateRequestId
();
void
*
result
=
taosHashGet
(
phash
,
&
v
,
sizeof
(
v
));
if
(
result
!=
nullptr
)
{
printf
(
"0x%lx, index:%d
\n
"
,
v
,
i
);
}
assert
(
result
==
nullptr
);
taosHashPut
(
phash
,
&
v
,
sizeof
(
v
),
NULL
,
0
);
}
taosHashCleanup
(
phash
);
}
// TEST(testCase, projection_query_tables) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// ASSERT_EQ(pConn, nullptr);
// ASSERT_EQ(pConn, nullptr);
//
//
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// taos_free_result(pRes);
// taos_free_result(pRes);
//
//
// pRes = taos_query(pConn, "
select * from t_2
");
// pRes = taos_query(pConn, "
insert into t_2 values(now, 1)
");
// if (taos_errno(pRes) != 0) {
// if (taos_errno(pRes) != 0) {
// printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes));
// printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes));
// taos_free_result(pRes);
// taos_free_result(pRes);
// ASSERT_TRUE(false);
// ASSERT_TRUE(false);
// }
// }
//
//
// TAOS_ROW pRow = NULL;
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
// int32_t numOfFields = taos_num_fields(pRes);
//
// char str[512] = {0};
// while((pRow = taos_fetch_row(pRes)) != NULL) {
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
// printf("%s\n", str);
// }
//
// taos_free_result(pRes);
// taos_free_result(pRes);
// taos_close(pConn);
// taos_close(pConn);
//}
//}
//#endif
TEST
(
testCase
,
projection_query_tables
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use test1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to use db, reason:%s"
,
taos_errstr
(
pRes
));
taos_free_result
(
pRes
);
return
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"select * from tm0"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create multiple tables, reason:%s
\n
"
,
taos_errstr
(
pRes
));
taos_free_result
(
pRes
);
ASSERT_TRUE
(
false
);
}
TAOS_ROW
pRow
=
NULL
;
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int32_t
code
=
taos_print_row
(
str
,
pRow
,
pFields
,
numOfFields
);
printf
(
"%s
\n
"
,
str
);
}
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
source/dnode/mgmt/impl/src/dndBnode.c
浏览文件 @
dc98029b
...
@@ -268,7 +268,7 @@ int32_t dndProcessCreateBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
...
@@ -268,7 +268,7 @@ int32_t dndProcessCreateBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_BNODE_I
D_INVALID
;
terrno
=
TSDB_CODE_DND_BNODE_I
NVALID_OPTION
;
dError
(
"failed to create bnode since %s"
,
terrstr
());
dError
(
"failed to create bnode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
else
{
}
else
{
...
@@ -281,7 +281,7 @@ int32_t dndProcessDropBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
...
@@ -281,7 +281,7 @@ int32_t dndProcessDropBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_BNODE_I
D_INVALID
;
terrno
=
TSDB_CODE_DND_BNODE_I
NVALID_OPTION
;
dError
(
"failed to drop bnode since %s"
,
terrstr
());
dError
(
"failed to drop bnode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
else
{
}
else
{
...
...
source/dnode/mgmt/impl/src/dndMnode.c
浏览文件 @
dc98029b
...
@@ -305,25 +305,24 @@ static void dndBuildMnodeOpenOption(SDnode *pDnode, SMnodeOpt *pOption) {
...
@@ -305,25 +305,24 @@ static void dndBuildMnodeOpenOption(SDnode *pDnode, SMnodeOpt *pOption) {
memcpy
(
&
pOption
->
replicas
,
pMgmt
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
memcpy
(
&
pOption
->
replicas
,
pMgmt
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
}
}
static
int32_t
dndBuildMnodeOptionFromReq
(
SDnode
*
pDnode
,
SMnodeOpt
*
pOption
,
SDCreateMnode
Msg
*
pReq
)
{
static
int32_t
dndBuildMnodeOptionFromReq
(
SDnode
*
pDnode
,
SMnodeOpt
*
pOption
,
SDCreateMnode
Req
*
pCreate
)
{
dndInitMnodeOption
(
pDnode
,
pOption
);
dndInitMnodeOption
(
pDnode
,
pOption
);
pOption
->
dnodeId
=
dndGetDnodeId
(
pDnode
);
pOption
->
dnodeId
=
dndGetDnodeId
(
pDnode
);
pOption
->
clusterId
=
dndGetClusterId
(
pDnode
);
pOption
->
clusterId
=
dndGetClusterId
(
pDnode
);
pOption
->
replica
=
p
Req
->
replica
;
pOption
->
replica
=
p
Create
->
replica
;
pOption
->
selfIndex
=
-
1
;
pOption
->
selfIndex
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
p
Req
->
replica
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
p
Create
->
replica
;
++
i
)
{
SReplica
*
pReplica
=
&
pOption
->
replicas
[
i
];
SReplica
*
pReplica
=
&
pOption
->
replicas
[
i
];
pReplica
->
id
=
p
Req
->
replicas
[
i
].
id
;
pReplica
->
id
=
p
Create
->
replicas
[
i
].
id
;
pReplica
->
port
=
p
Req
->
replicas
[
i
].
port
;
pReplica
->
port
=
p
Create
->
replicas
[
i
].
port
;
memcpy
(
pReplica
->
fqdn
,
p
Req
->
replicas
[
i
].
fqdn
,
TSDB_FQDN_LEN
);
memcpy
(
pReplica
->
fqdn
,
p
Create
->
replicas
[
i
].
fqdn
,
TSDB_FQDN_LEN
);
if
(
pReplica
->
id
==
pOption
->
dnodeId
)
{
if
(
pReplica
->
id
==
pOption
->
dnodeId
)
{
pOption
->
selfIndex
=
i
;
pOption
->
selfIndex
=
i
;
}
}
}
}
if
(
pOption
->
selfIndex
==
-
1
)
{
if
(
pOption
->
selfIndex
==
-
1
)
{
terrno
=
TSDB_CODE_DND_MNODE_ID_NOT_FOUND
;
dError
(
"failed to build mnode options since %s"
,
terrstr
());
dError
(
"failed to build mnode options since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
@@ -423,8 +422,8 @@ static int32_t dndDropMnode(SDnode *pDnode) {
...
@@ -423,8 +422,8 @@ static int32_t dndDropMnode(SDnode *pDnode) {
return
0
;
return
0
;
}
}
static
SDCreateMnode
Msg
*
dndParseCreateMnodeReq
(
SRpcMsg
*
pReq
)
{
static
SDCreateMnode
Req
*
dndParseCreateMnodeReq
(
SRpcMsg
*
pReq
)
{
SDCreateMnode
Msg
*
pCreate
=
pReq
->
pCont
;
SDCreateMnode
Req
*
pCreate
=
pReq
->
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
for
(
int32_t
i
=
0
;
i
<
pCreate
->
replica
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCreate
->
replica
;
++
i
)
{
pCreate
->
replicas
[
i
].
id
=
htonl
(
pCreate
->
replicas
[
i
].
id
);
pCreate
->
replicas
[
i
].
id
=
htonl
(
pCreate
->
replicas
[
i
].
id
);
...
@@ -435,51 +434,85 @@ static SDCreateMnodeMsg *dndParseCreateMnodeReq(SRpcMsg *pReq) {
...
@@ -435,51 +434,85 @@ static SDCreateMnodeMsg *dndParseCreateMnodeReq(SRpcMsg *pReq) {
}
}
int32_t
dndProcessCreateMnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
int32_t
dndProcessCreateMnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
SDCreateMnode
Msg
*
pCreate
=
dndParseCreateMnodeReq
(
pReq
);
SDCreateMnode
Req
*
pCreate
=
dndParseCreateMnodeReq
(
pReq
);
if
(
pCreate
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
if
(
pCreate
->
replica
<=
1
||
pCreate
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_MNODE_ID_INVALID
;
terrno
=
TSDB_CODE_DND_MNODE_INVALID_OPTION
;
dError
(
"failed to create mnode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
else
{
}
SMnodeOpt
option
=
{
0
};
if
(
dndBuildMnodeOptionFromReq
(
pDnode
,
&
option
,
pCreate
)
!=
0
)
{
return
-
1
;
}
return
dndOpenMnode
(
pDnode
,
&
option
);
SMnodeOpt
option
=
{
0
};
if
(
dndBuildMnodeOptionFromReq
(
pDnode
,
&
option
,
pCreate
)
!=
0
)
{
terrno
=
TSDB_CODE_DND_MNODE_INVALID_OPTION
;
dError
(
"failed to create mnode since %s"
,
terrstr
());
return
-
1
;
}
}
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
if
(
pMnode
!=
NULL
)
{
dndReleaseMnode
(
pDnode
,
pMnode
);
terrno
=
TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED
;
dError
(
"failed to create mnode since %s"
,
terrstr
());
return
-
1
;
}
dDebug
(
"start to create mnode"
);
return
dndOpenMnode
(
pDnode
,
&
option
);
}
}
int32_t
dndProcessAlterMnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
int32_t
dndProcessAlterMnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
SDAlterMnode
Msg
*
pAlter
=
dndParseCreateMnodeReq
(
pReq
);
SDAlterMnode
Req
*
pAlter
=
dndParseCreateMnodeReq
(
pReq
);
if
(
pAlter
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
if
(
pAlter
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_MNODE_ID_INVALID
;
terrno
=
TSDB_CODE_DND_MNODE_INVALID_OPTION
;
dError
(
"failed to alter mnode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
SMnodeOpt
option
=
{
0
};
SMnodeOpt
option
=
{
0
};
if
(
dndBuildMnodeOptionFromReq
(
pDnode
,
&
option
,
pAlter
)
!=
0
)
{
if
(
dndBuildMnodeOptionFromReq
(
pDnode
,
&
option
,
pAlter
)
!=
0
)
{
terrno
=
TSDB_CODE_DND_MNODE_INVALID_OPTION
;
dError
(
"failed to alter mnode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
if
(
dndAlterMnode
(
pDnode
,
&
option
)
!=
0
)
{
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
if
(
pMnode
==
NULL
)
{
terrno
=
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
;
dError
(
"failed to alter mnode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
return
dndWriteMnodeFile
(
pDnode
);
dDebug
(
"start to alter mnode"
);
int32_t
code
=
dndAlterMnode
(
pDnode
,
&
option
);
dndReleaseMnode
(
pDnode
,
pMnode
);
return
code
;
}
}
int32_t
dndProcessDropMnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
int32_t
dndProcessDropMnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
SDDropMnode
Msg
*
pDrop
=
pReq
->
pCont
;
SDDropMnode
Req
*
pDrop
=
pReq
->
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
if
(
pDrop
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
if
(
pDrop
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_MNODE_ID_INVALID
;
terrno
=
TSDB_CODE_DND_MNODE_INVALID_OPTION
;
dError
(
"failed to drop mnode since %s"
,
terrstr
());
return
-
1
;
}
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
if
(
pMnode
==
NULL
)
{
terrno
=
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
;
dError
(
"failed to drop mnode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
else
{
return
dndDropMnode
(
pDnode
);
}
}
dDebug
(
"start to drop mnode"
);
int32_t
code
=
dndDropMnode
(
pDnode
);
dndReleaseMnode
(
pDnode
,
pMnode
);
return
code
;
}
}
static
void
dndProcessMnodeQueue
(
SDnode
*
pDnode
,
SMnodeMsg
*
pMsg
)
{
static
void
dndProcessMnodeQueue
(
SDnode
*
pDnode
,
SMnodeMsg
*
pMsg
)
{
...
@@ -506,6 +539,7 @@ static void dndWriteMnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpc
...
@@ -506,6 +539,7 @@ static void dndWriteMnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpc
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
else
{
}
else
{
code
=
dndWriteMsgToWorker
(
pWorker
,
pMsg
,
0
);
code
=
dndWriteMsgToWorker
(
pWorker
,
pMsg
,
0
);
if
(
code
!=
0
)
code
=
terrno
;
}
}
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
...
source/dnode/mgmt/impl/src/dndQnode.c
浏览文件 @
dc98029b
...
@@ -274,7 +274,7 @@ int32_t dndProcessCreateQnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
...
@@ -274,7 +274,7 @@ int32_t dndProcessCreateQnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_QNODE_I
D_INVALID
;
terrno
=
TSDB_CODE_DND_QNODE_I
NVALID_OPTION
;
dError
(
"failed to create qnode since %s"
,
terrstr
());
dError
(
"failed to create qnode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
else
{
}
else
{
...
@@ -287,7 +287,7 @@ int32_t dndProcessDropQnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
...
@@ -287,7 +287,7 @@ int32_t dndProcessDropQnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_QNODE_I
D_INVALID
;
terrno
=
TSDB_CODE_DND_QNODE_I
NVALID_OPTION
;
dError
(
"failed to drop qnode since %s"
,
terrstr
());
dError
(
"failed to drop qnode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
else
{
}
else
{
...
...
source/dnode/mgmt/impl/src/dndSnode.c
浏览文件 @
dc98029b
...
@@ -268,7 +268,7 @@ int32_t dndProcessCreateSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
...
@@ -268,7 +268,7 @@ int32_t dndProcessCreateSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_SNODE_I
D_INVALID
;
terrno
=
TSDB_CODE_DND_SNODE_I
NVALID_OPTION
;
dError
(
"failed to create snode since %s"
,
terrstr
());
dError
(
"failed to create snode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
else
{
}
else
{
...
@@ -281,7 +281,7 @@ int32_t dndProcessDropSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
...
@@ -281,7 +281,7 @@ int32_t dndProcessDropSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_SNODE_I
D_INVALID
;
terrno
=
TSDB_CODE_DND_SNODE_I
NVALID_OPTION
;
dError
(
"failed to drop snode since %s"
,
terrstr
());
dError
(
"failed to drop snode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
else
{
}
else
{
...
...
source/dnode/mgmt/impl/src/dndVnodes.c
浏览文件 @
dc98029b
...
@@ -197,6 +197,10 @@ static void dndCloseVnode(SDnode *pDnode, SVnodeObj *pVnode) {
...
@@ -197,6 +197,10 @@ static void dndCloseVnode(SDnode *pDnode, SVnodeObj *pVnode) {
dndFreeVnodeWriteQueue
(
pDnode
,
pVnode
);
dndFreeVnodeWriteQueue
(
pDnode
,
pVnode
);
dndFreeVnodeApplyQueue
(
pDnode
,
pVnode
);
dndFreeVnodeApplyQueue
(
pDnode
,
pVnode
);
dndFreeVnodeSyncQueue
(
pDnode
,
pVnode
);
dndFreeVnodeSyncQueue
(
pDnode
,
pVnode
);
vnodeClose
(
pVnode
->
pImpl
);
pVnode
->
pImpl
=
NULL
;
free
(
pVnode
->
path
);
free
(
pVnode
->
path
);
free
(
pVnode
->
db
);
free
(
pVnode
->
db
);
free
(
pVnode
);
free
(
pVnode
);
...
...
source/dnode/mgmt/impl/test/bnode/dbnode.cpp
浏览文件 @
dc98029b
...
@@ -34,7 +34,7 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
...
@@ -34,7 +34,7 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_BNODE_I
D_INVALID
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_BNODE_I
NVALID_OPTION
);
}
}
{
{
...
@@ -82,7 +82,7 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
...
@@ -82,7 +82,7 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_BNODE_I
D_INVALID
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_BNODE_I
NVALID_OPTION
);
}
}
{
{
...
...
source/dnode/mgmt/impl/test/mnode/
q
mnode.cpp
→
source/dnode/mgmt/impl/test/mnode/
d
mnode.cpp
浏览文件 @
dc98029b
...
@@ -16,26 +16,29 @@ class DndTestMnode : public ::testing::Test {
...
@@ -16,26 +16,29 @@ class DndTestMnode : public ::testing::Test {
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/dnode_test_mnode"
,
9113
);
}
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/dnode_test_mnode"
,
9113
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
static
Testbase
test
;
public:
public:
void
SetUp
()
override
{}
void
SetUp
()
override
{}
void
TearDown
()
override
{}
void
TearDown
()
override
{}
};
};
Testbase
DndTestMnode
::
test
;
Testbase
DndTestMnode
::
test
;
#if 0
TEST_F
(
DndTestMnode
,
01
_Create_Mnode
)
{
TEST_F
(
DndTestMnode
,
01
_Create_Mnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SDCreateMnodeReq
);
int32_t
contLen
=
sizeof
(
SDCreateMnodeReq
);
SDCreateMnodeReq
*
pReq
=
(
SDCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateMnodeReq
*
pReq
=
(
SDCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
replica
=
1
;
pReq
->
replicas
[
0
].
id
=
htonl
(
1
);
pReq
->
replicas
[
0
].
port
=
htonl
(
9113
);
strcpy
(
pReq
->
replicas
[
0
].
fqdn
,
"localhost"
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_MNODE_I
D_INVALID
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_MNODE_I
NVALID_OPTION
);
}
}
{
{
...
@@ -43,30 +46,28 @@ TEST_F(DndTestMnode, 01_Create_Mnode) {
...
@@ -43,30 +46,28 @@ TEST_F(DndTestMnode, 01_Create_Mnode) {
SDCreateMnodeReq
*
pReq
=
(
SDCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateMnodeReq
*
pReq
=
(
SDCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
replica
=
1
;
pReq
->
replicas
[
0
].
id
=
htonl
(
2
);
pReq
->
replicas
[
0
].
port
=
htonl
(
9113
);
strcpy
(
pReq
->
replicas
[
0
].
fqdn
,
"localhost"
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ(pRsp->code, 0);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_MNODE_INVALID_OPTION
);
}
{
int32_t contLen = sizeof(SDCreateMnodeReq);
SDCreateMnodeReq* pReq = (SDCreateMnodeReq*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(1);
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_MNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED);
}
}
test.Restart();
{
{
int32_t
contLen
=
sizeof
(
SDCreateMnodeReq
);
int32_t
contLen
=
sizeof
(
SDCreateMnodeReq
);
SDCreateMnodeReq
*
pReq
=
(
SDCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateMnodeReq
*
pReq
=
(
SDCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
replica
=
2
;
pReq
->
replicas
[
0
].
id
=
htonl
(
1
);
pReq
->
replicas
[
0
].
port
=
htonl
(
9113
);
strcpy
(
pReq
->
replicas
[
0
].
fqdn
,
"localhost"
);
pReq
->
replicas
[
1
].
id
=
htonl
(
1
);
pReq
->
replicas
[
1
].
port
=
htonl
(
9114
);
strcpy
(
pReq
->
replicas
[
1
].
fqdn
,
"localhost"
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -75,50 +76,49 @@ TEST_F(DndTestMnode, 01_Create_Mnode) {
...
@@ -75,50 +76,49 @@ TEST_F(DndTestMnode, 01_Create_Mnode) {
}
}
TEST_F
(
DndTestMnode
,
02
_Alter_Mnode
)
{
TEST_F
(
DndTestMnode
,
02
_Alter_Mnode
)
{
{
{
int32_t contLen = sizeof(SD
Create
MnodeReq);
int32_t
contLen
=
sizeof
(
SD
Alter
MnodeReq
);
SD
CreateMnodeReq* pReq = (SDCreate
MnodeReq*)rpcMallocCont(contLen);
SD
AlterMnodeReq
*
pReq
=
(
SDAlter
MnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
replica
=
1
;
pReq
->
replicas
[
0
].
id
=
htonl
(
1
);
pReq
->
replicas
[
0
].
port
=
htonl
(
9113
);
strcpy
(
pReq
->
replicas
[
0
].
fqdn
,
"localhost"
);
SRpcMsg* pRsp = test.SendReq(TDMT_DND_
CREATE
_MNODE, pReq, contLen);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_
ALTER
_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_MNODE_I
D_INVALID
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_MNODE_I
NVALID_OPTION
);
}
}
{
{
int32_t contLen = sizeof(SD
Create
MnodeReq);
int32_t
contLen
=
sizeof
(
SD
Alter
MnodeReq
);
SD
CreateMnodeReq* pReq = (SDCreate
MnodeReq*)rpcMallocCont(contLen);
SD
AlterMnodeReq
*
pReq
=
(
SDAlter
MnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
replica
=
1
;
pReq
->
replicas
[
0
].
id
=
htonl
(
2
);
pReq
->
replicas
[
0
].
port
=
htonl
(
9113
);
strcpy
(
pReq
->
replicas
[
0
].
fqdn
,
"localhost"
);
SRpcMsg* pRsp = test.SendReq(TDMT_DND_
CREATE
_MNODE, pReq, contLen);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_
ALTER
_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ(pRsp->code,
0
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_MNODE_INVALID_OPTION
);
}
}
{
{
int32_t contLen = sizeof(SD
Create
MnodeReq);
int32_t
contLen
=
sizeof
(
SD
Alter
MnodeReq
);
SD
CreateMnodeReq* pReq = (SDCreate
MnodeReq*)rpcMallocCont(contLen);
SD
AlterMnodeReq
*
pReq
=
(
SDAlter
MnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
replica
=
1
;
pReq
->
replicas
[
0
].
id
=
htonl
(
1
);
pReq
->
replicas
[
0
].
port
=
htonl
(
9113
);
strcpy
(
pReq
->
replicas
[
0
].
fqdn
,
"localhost"
);
SRpcMsg* pRsp = test.SendReq(TDMT_DND_
CREATE
_MNODE, pReq, contLen);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_
ALTER
_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
test.Restart();
{
int32_t contLen = sizeof(SDCreateMnodeReq);
SDCreateMnodeReq* pReq = (SDCreateMnodeReq*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(1);
SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_MNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED);
}
}
}
}
...
@@ -131,7 +131,7 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) {
...
@@ -131,7 +131,7 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_DROP_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_DROP_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ(pRsp->code, TSDB_CODE_DND_MNODE_I
D_INVALID
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_MNODE_I
NVALID_OPTION
);
}
}
{
{
...
@@ -156,28 +156,34 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) {
...
@@ -156,28 +156,34 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) {
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
);
}
}
test.Restart();
{
{
int32_t contLen = sizeof(SD
Drop
MnodeReq);
int32_t
contLen
=
sizeof
(
SD
Alter
MnodeReq
);
SD
DropMnodeReq* pReq = (SDDrop
MnodeReq*)rpcMallocCont(contLen);
SD
AlterMnodeReq
*
pReq
=
(
SDAlter
MnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
replica
=
1
;
pReq
->
replicas
[
0
].
id
=
htonl
(
1
);
pReq
->
replicas
[
0
].
port
=
htonl
(
9113
);
strcpy
(
pReq
->
replicas
[
0
].
fqdn
,
"localhost"
);
SRpcMsg* pRsp = test.SendReq(TDMT_DND_
DROP
_MNODE, pReq, contLen);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_
ALTER
_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
);
}
}
{
{
int32_t
contLen
=
sizeof
(
SDCreateMnodeReq
);
int32_t
contLen
=
sizeof
(
SDCreateMnodeReq
);
SDCreateMnodeReq
*
pReq
=
(
SDCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateMnodeReq
*
pReq
=
(
SDCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
replica
=
2
;
pReq
->
replicas
[
0
].
id
=
htonl
(
1
);
pReq
->
replicas
[
0
].
port
=
htonl
(
9113
);
strcpy
(
pReq
->
replicas
[
0
].
fqdn
,
"localhost"
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
}
}
#endif
\ No newline at end of file
\ No newline at end of file
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
浏览文件 @
dc98029b
...
@@ -34,7 +34,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
...
@@ -34,7 +34,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_QNODE_I
D_INVALID
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_QNODE_I
NVALID_OPTION
);
}
}
{
{
...
@@ -82,7 +82,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) {
...
@@ -82,7 +82,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_QNODE_I
D_INVALID
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_QNODE_I
NVALID_OPTION
);
}
}
{
{
...
...
source/dnode/mgmt/impl/test/snode/dsnode.cpp
浏览文件 @
dc98029b
...
@@ -34,7 +34,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
...
@@ -34,7 +34,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_SNODE_I
D_INVALID
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_SNODE_I
NVALID_OPTION
);
}
}
{
{
...
@@ -82,7 +82,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
...
@@ -82,7 +82,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_SNODE_I
D_INVALID
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_SNODE_I
NVALID_OPTION
);
}
}
{
{
...
...
source/dnode/mgmt/impl/test/sut/src/sut.cpp
浏览文件 @
dc98029b
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#include "sut.h"
#include "sut.h"
void
Testbase
::
InitLog
(
const
char
*
path
)
{
void
Testbase
::
InitLog
(
const
char
*
path
)
{
dDebugFlag
=
0
;
dDebugFlag
=
143
;
vDebugFlag
=
0
;
vDebugFlag
=
0
;
mDebugFlag
=
143
;
mDebugFlag
=
143
;
cDebugFlag
=
0
;
cDebugFlag
=
0
;
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
dc98029b
...
@@ -27,14 +27,14 @@ static SSdbRaw *mndMnodeActionEncode(SMnodeObj *pObj);
...
@@ -27,14 +27,14 @@ static SSdbRaw *mndMnodeActionEncode(SMnodeObj *pObj);
static
SSdbRow
*
mndMnodeActionDecode
(
SSdbRaw
*
pRaw
);
static
SSdbRow
*
mndMnodeActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndMnodeActionInsert
(
SSdb
*
pSdb
,
SMnodeObj
*
pObj
);
static
int32_t
mndMnodeActionInsert
(
SSdb
*
pSdb
,
SMnodeObj
*
pObj
);
static
int32_t
mndMnodeActionDelete
(
SSdb
*
pSdb
,
SMnodeObj
*
pObj
);
static
int32_t
mndMnodeActionDelete
(
SSdb
*
pSdb
,
SMnodeObj
*
pObj
);
static
int32_t
mndMnodeActionUpdate
(
SSdb
*
pSdb
,
SMnodeObj
*
pOld
Mnode
,
SMnodeObj
*
pNewMnode
);
static
int32_t
mndMnodeActionUpdate
(
SSdb
*
pSdb
,
SMnodeObj
*
pOld
,
SMnodeObj
*
pNew
);
static
int32_t
mndProcessCreateMnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateMnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessDropMnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropMnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessCreateMnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateMnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndProcessAlterMnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessAlterMnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndProcessDropMnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropMnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndGetMnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndGetMnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveMnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveMnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextMnode
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextMnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitMnode
(
SMnode
*
pMnode
)
{
int32_t
mndInitMnode
(
SMnode
*
pMnode
)
{
...
@@ -65,7 +65,7 @@ void mndCleanupMnode(SMnode *pMnode) {}
...
@@ -65,7 +65,7 @@ void mndCleanupMnode(SMnode *pMnode) {}
static
SMnodeObj
*
mndAcquireMnode
(
SMnode
*
pMnode
,
int32_t
mnodeId
)
{
static
SMnodeObj
*
mndAcquireMnode
(
SMnode
*
pMnode
,
int32_t
mnodeId
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SMnodeObj
*
pObj
=
sdbAcquire
(
pSdb
,
SDB_MNODE
,
&
mnodeId
);
SMnodeObj
*
pObj
=
sdbAcquire
(
pSdb
,
SDB_MNODE
,
&
mnodeId
);
if
(
pObj
==
NULL
)
{
if
(
pObj
==
NULL
&&
terrno
==
TSDB_CODE_SDB_OBJ_NOT_THERE
)
{
terrno
=
TSDB_CODE_MND_MNODE_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_MNODE_NOT_EXIST
;
}
}
return
pObj
;
return
pObj
;
...
@@ -207,9 +207,9 @@ static int32_t mndMnodeActionDelete(SSdb *pSdb, SMnodeObj *pObj) {
...
@@ -207,9 +207,9 @@ static int32_t mndMnodeActionDelete(SSdb *pSdb, SMnodeObj *pObj) {
return
0
;
return
0
;
}
}
static
int32_t
mndMnodeActionUpdate
(
SSdb
*
pSdb
,
SMnodeObj
*
pOld
Mnode
,
SMnodeObj
*
pNewMnode
)
{
static
int32_t
mndMnodeActionUpdate
(
SSdb
*
pSdb
,
SMnodeObj
*
pOld
,
SMnodeObj
*
pNew
)
{
mTrace
(
"mnode:%d, perform update action, old_row:%p new_row:%p"
,
pOld
Mnode
->
id
,
pOldMnode
,
pNewMnode
);
mTrace
(
"mnode:%d, perform update action, old_row:%p new_row:%p"
,
pOld
->
id
,
pOld
,
pNew
);
pOld
Mnode
->
updateTime
=
pNewMnode
->
updateTime
;
pOld
->
updateTime
=
pNew
->
updateTime
;
return
0
;
return
0
;
}
}
...
@@ -277,13 +277,13 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
...
@@ -277,13 +277,13 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
numOfReplicas
=
0
;
int32_t
numOfReplicas
=
0
;
SDCreateMnode
Msg
createMsg
=
{
0
};
SDCreateMnode
Req
createReq
=
{
0
};
while
(
1
)
{
while
(
1
)
{
SMnodeObj
*
pMObj
=
NULL
;
SMnodeObj
*
pMObj
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pMObj
);
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pMObj
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
SReplica
*
pReplica
=
&
create
Msg
.
replicas
[
numOfReplicas
];
SReplica
*
pReplica
=
&
create
Req
.
replicas
[
numOfReplicas
];
pReplica
->
id
=
htonl
(
pMObj
->
id
);
pReplica
->
id
=
htonl
(
pMObj
->
id
);
pReplica
->
port
=
htons
(
pMObj
->
pDnode
->
port
);
pReplica
->
port
=
htons
(
pMObj
->
pDnode
->
port
);
memcpy
(
pReplica
->
fqdn
,
pMObj
->
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
memcpy
(
pReplica
->
fqdn
,
pMObj
->
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
...
@@ -292,13 +292,13 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
...
@@ -292,13 +292,13 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
sdbRelease
(
pSdb
,
pMObj
);
sdbRelease
(
pSdb
,
pMObj
);
}
}
SReplica
*
pReplica
=
&
create
Msg
.
replicas
[
numOfReplicas
];
SReplica
*
pReplica
=
&
create
Req
.
replicas
[
numOfReplicas
];
pReplica
->
id
=
htonl
(
pDnode
->
id
);
pReplica
->
id
=
htonl
(
pDnode
->
id
);
pReplica
->
port
=
htons
(
pDnode
->
port
);
pReplica
->
port
=
htons
(
pDnode
->
port
);
memcpy
(
pReplica
->
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
memcpy
(
pReplica
->
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
numOfReplicas
++
;
numOfReplicas
++
;
create
Msg
.
replica
=
numOfReplicas
;
create
Req
.
replica
=
numOfReplicas
;
while
(
1
)
{
while
(
1
)
{
SMnodeObj
*
pMObj
=
NULL
;
SMnodeObj
*
pMObj
=
NULL
;
...
@@ -307,22 +307,23 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
...
@@ -307,22 +307,23 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
SDAlterMnode
Msg
*
pMsg
=
malloc
(
sizeof
(
SDAlterMnodeMsg
));
SDAlterMnode
Req
*
pReq
=
malloc
(
sizeof
(
SDAlterMnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pMObj
);
sdbRelease
(
pSdb
,
pMObj
);
return
-
1
;
return
-
1
;
}
}
memcpy
(
p
Msg
,
&
createMsg
,
sizeof
(
SDAlterMnodeMsg
));
memcpy
(
p
Req
,
&
createReq
,
sizeof
(
SDAlterMnodeReq
));
p
Msg
->
dnodeId
=
htonl
(
pMObj
->
id
);
p
Req
->
dnodeId
=
htonl
(
pMObj
->
id
);
action
.
epSet
=
mndGetDnodeEpset
(
pMObj
->
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pMObj
->
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDAlterMnode
Msg
);
action
.
contLen
=
sizeof
(
SDAlterMnode
Req
);
action
.
msgType
=
TDMT_DND_ALTER_MNODE
;
action
.
msgType
=
TDMT_DND_ALTER_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pMObj
);
sdbRelease
(
pSdb
,
pMObj
);
return
-
1
;
return
-
1
;
...
@@ -335,17 +336,18 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
...
@@ -335,17 +336,18 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
SDCreateMnode
Msg
*
pMsg
=
malloc
(
sizeof
(
SDCreateMnodeMsg
));
SDCreateMnode
Req
*
pReq
=
malloc
(
sizeof
(
SDCreateMnodeReq
));
if
(
p
Msg
==
NULL
)
return
-
1
;
if
(
p
Req
==
NULL
)
return
-
1
;
memcpy
(
p
Msg
,
&
createMsg
,
sizeof
(
SDAlterMnodeMsg
));
memcpy
(
p
Req
,
&
createReq
,
sizeof
(
SDAlterMnodeReq
));
p
Msg
->
dnodeId
=
htonl
(
pObj
->
id
);
p
Req
->
dnodeId
=
htonl
(
pObj
->
id
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDCreateMnode
Msg
);
action
.
contLen
=
sizeof
(
SDCreateMnode
Req
);
action
.
msgType
=
TDMT_DND_CREATE_MNODE
;
action
.
msgType
=
TDMT_DND_CREATE_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -353,39 +355,23 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
...
@@ -353,39 +355,23 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
return
0
;
return
0
;
}
}
static
int32_t
mndCreateMnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SDnodeObj
*
pDnode
,
SMCreateMnodeMsg
*
pCreate
)
{
static
int32_t
mndCreateMnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pReq
,
SDnodeObj
*
pDnode
,
SMCreateMnodeReq
*
pCreate
)
{
int32_t
code
=
-
1
;
SMnodeObj
mnodeObj
=
{
0
};
SMnodeObj
mnodeObj
=
{
0
};
mnodeObj
.
id
=
pDnode
->
id
;
mnodeObj
.
id
=
pDnode
->
id
;
mnodeObj
.
createdTime
=
taosGetTimestampMs
();
mnodeObj
.
createdTime
=
taosGetTimestampMs
();
mnodeObj
.
updateTime
=
mnodeObj
.
createdTime
;
mnodeObj
.
updateTime
=
mnodeObj
.
createdTime
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
pMsg
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_MNODE_OVER
;
if
(
pTrans
==
NULL
)
{
mError
(
"mnode:%d, failed to create since %s"
,
pCreate
->
dnodeId
,
terrstr
());
goto
CREATE_MNODE_OVER
;
}
mDebug
(
"trans:%d, used to create mnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
if
(
mndSetCreateMnodeRedoLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
{
mDebug
(
"trans:%d, used to create mnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
mError
(
"trans:%d, failed to set redo log since %s"
,
pTrans
->
id
,
terrstr
());
if
(
mndSetCreateMnodeRedoLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
CREATE_MNODE_OVER
;
goto
CREATE_MNODE_OVER
;
if
(
mndSetCreateMnodeCommitLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
CREATE_MNODE_OVER
;
}
if
(
mndSetCreateMnodeRedoActions
(
pMnode
,
pTrans
,
pDnode
,
&
mnodeObj
)
!=
0
)
goto
CREATE_MNODE_OVER
;
if
(
mndSetCreateMnodeCommitLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set commit log since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_MNODE_OVER
;
}
if
(
mndSetCreateMnodeRedoActions
(
pMnode
,
pTrans
,
pDnode
,
&
mnodeObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo actions since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_MNODE_OVER
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
CREATE_MNODE_OVER
;
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_MNODE_OVER
;
}
code
=
0
;
code
=
0
;
...
@@ -394,9 +380,9 @@ CREATE_MNODE_OVER:
...
@@ -394,9 +380,9 @@ CREATE_MNODE_OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndProcessCreateMnodeReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessCreateMnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMCreateMnode
Msg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SMCreateMnode
Req
*
pCreate
=
pReq
->
rpcMsg
.
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
...
@@ -408,6 +394,9 @@ static int32_t mndProcessCreateMnodeReq(SMnodeMsg *pMsg) {
...
@@ -408,6 +394,9 @@ static int32_t mndProcessCreateMnodeReq(SMnodeMsg *pMsg) {
mError
(
"mnode:%d, mnode already exist"
,
pObj
->
id
);
mError
(
"mnode:%d, mnode already exist"
,
pObj
->
id
);
terrno
=
TSDB_CODE_MND_MNODE_ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_MNODE_ALREADY_EXIST
;
return
-
1
;
return
-
1
;
}
else
if
(
terrno
!=
TSDB_CODE_MND_MNODE_NOT_EXIST
)
{
mError
(
"qnode:%d, failed to create mnode since %s"
,
pCreate
->
dnodeId
,
terrstr
());
return
-
1
;
}
}
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pCreate
->
dnodeId
);
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pCreate
->
dnodeId
);
...
@@ -417,7 +406,7 @@ static int32_t mndProcessCreateMnodeReq(SMnodeMsg *pMsg) {
...
@@ -417,7 +406,7 @@ static int32_t mndProcessCreateMnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndCreateMnode
(
pMnode
,
p
Msg
,
pDnode
,
pCreate
);
int32_t
code
=
mndCreateMnode
(
pMnode
,
p
Req
,
pDnode
,
pCreate
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -449,14 +438,14 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
...
@@ -449,14 +438,14 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
numOfReplicas
=
0
;
int32_t
numOfReplicas
=
0
;
SDAlterMnode
Msg
alterMsg
=
{
0
};
SDAlterMnode
Req
alterReq
=
{
0
};
while
(
1
)
{
while
(
1
)
{
SMnodeObj
*
pMObj
=
NULL
;
SMnodeObj
*
pMObj
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pMObj
);
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pMObj
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
if
(
pMObj
->
id
!=
pObj
->
id
)
{
if
(
pMObj
->
id
!=
pObj
->
id
)
{
SReplica
*
pReplica
=
&
alter
Msg
.
replicas
[
numOfReplicas
];
SReplica
*
pReplica
=
&
alter
Req
.
replicas
[
numOfReplicas
];
pReplica
->
id
=
htonl
(
pMObj
->
id
);
pReplica
->
id
=
htonl
(
pMObj
->
id
);
pReplica
->
port
=
htons
(
pMObj
->
pDnode
->
port
);
pReplica
->
port
=
htons
(
pMObj
->
pDnode
->
port
);
memcpy
(
pReplica
->
fqdn
,
pMObj
->
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
memcpy
(
pReplica
->
fqdn
,
pMObj
->
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
...
@@ -466,7 +455,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
...
@@ -466,7 +455,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
sdbRelease
(
pSdb
,
pMObj
);
sdbRelease
(
pSdb
,
pMObj
);
}
}
alter
Msg
.
replica
=
numOfReplicas
;
alter
Req
.
replica
=
numOfReplicas
;
while
(
1
)
{
while
(
1
)
{
SMnodeObj
*
pMObj
=
NULL
;
SMnodeObj
*
pMObj
=
NULL
;
...
@@ -475,22 +464,23 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
...
@@ -475,22 +464,23 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
if
(
pMObj
->
id
!=
pObj
->
id
)
{
if
(
pMObj
->
id
!=
pObj
->
id
)
{
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
SDAlterMnode
Msg
*
pMsg
=
malloc
(
sizeof
(
SDAlterMnodeMsg
));
SDAlterMnode
Req
*
pReq
=
malloc
(
sizeof
(
SDAlterMnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pMObj
);
sdbRelease
(
pSdb
,
pMObj
);
return
-
1
;
return
-
1
;
}
}
memcpy
(
p
Msg
,
&
alterMsg
,
sizeof
(
SDAlterMnodeMsg
));
memcpy
(
p
Req
,
&
alterReq
,
sizeof
(
SDAlterMnodeReq
));
p
Msg
->
dnodeId
=
htonl
(
pMObj
->
id
);
p
Req
->
dnodeId
=
htonl
(
pMObj
->
id
);
action
.
epSet
=
mndGetDnodeEpset
(
pMObj
->
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pMObj
->
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDAlterMnode
Msg
);
action
.
contLen
=
sizeof
(
SDAlterMnode
Req
);
action
.
msgType
=
TDMT_DND_ALTER_MNODE
;
action
.
msgType
=
TDMT_DND_ALTER_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pMObj
);
sdbRelease
(
pSdb
,
pMObj
);
return
-
1
;
return
-
1
;
...
@@ -504,19 +494,20 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
...
@@ -504,19 +494,20 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
SDDropMnode
Msg
*
pMsg
=
malloc
(
sizeof
(
SDDropMnodeMsg
));
SDDropMnode
Req
*
pReq
=
malloc
(
sizeof
(
SDDropMnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
p
Msg
->
dnodeId
=
htonl
(
pObj
->
id
);
p
Req
->
dnodeId
=
htonl
(
pObj
->
id
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropMnode
Msg
);
action
.
contLen
=
sizeof
(
SDDropMnode
Req
);
action
.
msgType
=
TDMT_DND_DROP_MNODE
;
action
.
msgType
=
TDMT_DND_DROP_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -524,35 +515,18 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
...
@@ -524,35 +515,18 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
return
0
;
return
0
;
}
}
static
int32_t
mndDropMnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SMnodeObj
*
pObj
)
{
static
int32_t
mndDropMnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SMnodeObj
*
pObj
)
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
pMsg
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"mnode:%d, failed to drop since %s"
,
pObj
->
id
,
terrstr
());
goto
DROP_MNODE_OVER
;
}
mDebug
(
"trans:%d, used to drop mnode:%d"
,
pTrans
->
id
,
pObj
->
id
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_MNODE_OVER
;
if
(
mndSetDropMnodeRedoLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
{
mDebug
(
"trans:%d, used to drop mnode:%d"
,
pTrans
->
id
,
pObj
->
id
);
mError
(
"trans:%d, failed to set redo log since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_MNODE_OVER
;
}
if
(
mndSetDropMnodeCommitLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set commit log since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_MNODE_OVER
;
}
if
(
mndSetDropMnodeRedoActions
(
pMnode
,
pTrans
,
pObj
->
pDnode
,
pObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo actions since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_MNODE_OVER
;
}
if
(
mnd
TransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
if
(
mnd
SetDropMnodeRedoLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
DROP_MNODE_OVER
;
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
())
;
if
(
mndSetDropMnodeCommitLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
DROP_MNODE_OVER
;
goto
DROP_MNODE_OVER
;
if
(
mndSetDropMnodeRedoActions
(
pMnode
,
pTrans
,
pObj
->
pDnode
,
pObj
)
!=
0
)
goto
DROP_MNODE_OVER
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
DROP_MNODE_OVER
;
code
=
0
;
code
=
0
;
...
@@ -561,9 +535,9 @@ DROP_MNODE_OVER:
...
@@ -561,9 +535,9 @@ DROP_MNODE_OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndProcessDropMnodeReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessDropMnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMDropMnode
Msg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
SMDropMnode
Req
*
pDrop
=
pReq
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"mnode:%d, start to drop"
,
pDrop
->
dnodeId
);
mDebug
(
"mnode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
@@ -577,12 +551,10 @@ static int32_t mndProcessDropMnodeReq(SMnodeMsg *pMsg) {
...
@@ -577,12 +551,10 @@ static int32_t mndProcessDropMnodeReq(SMnodeMsg *pMsg) {
SMnodeObj
*
pObj
=
mndAcquireMnode
(
pMnode
,
pDrop
->
dnodeId
);
SMnodeObj
*
pObj
=
mndAcquireMnode
(
pMnode
,
pDrop
->
dnodeId
);
if
(
pObj
==
NULL
)
{
if
(
pObj
==
NULL
)
{
mError
(
"mnode:%d, not exist"
,
pDrop
->
dnodeId
);
mError
(
"mnode:%d, not exist"
,
pDrop
->
dnodeId
);
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndDropMnode
(
pMnode
,
pMsg
,
pObj
);
int32_t
code
=
mndDropMnode
(
pMnode
,
pReq
,
pObj
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"mnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
mError
(
"mnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -592,23 +564,23 @@ static int32_t mndProcessDropMnodeReq(SMnodeMsg *pMsg) {
...
@@ -592,23 +564,23 @@ static int32_t mndProcessDropMnodeReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
static
int32_t
mndProcessCreateMnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessCreateMnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Msg
);
mndTransProcessRsp
(
p
Rsp
);
return
0
;
return
0
;
}
}
static
int32_t
mndProcessAlterMnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessAlterMnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Msg
);
mndTransProcessRsp
(
p
Rsp
);
return
0
;
return
0
;
}
}
static
int32_t
mndProcessDropMnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessDropMnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Msg
);
mndTransProcessRsp
(
p
Rsp
);
return
0
;
return
0
;
}
}
static
int32_t
mndGetMnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
static
int32_t
mndGetMnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
...
@@ -660,8 +632,8 @@ static int32_t mndGetMnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
...
@@ -660,8 +632,8 @@ static int32_t mndGetMnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveMnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveMnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
dc98029b
...
@@ -86,10 +86,6 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
...
@@ -86,10 +86,6 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
mndTransPullup
(
pMnode
);
mndTransPullup
(
pMnode
);
if
(
walBeginSnapshot
(
pWal
,
sdbVer
)
<
0
)
{
goto
WAL_RESTORE_OVER
;
}
if
(
sdbVer
!=
lastSdbVer
)
{
if
(
sdbVer
!=
lastSdbVer
)
{
mInfo
(
"sdb restored from %"
PRId64
" to %"
PRId64
", write file"
,
lastSdbVer
,
sdbVer
);
mInfo
(
"sdb restored from %"
PRId64
" to %"
PRId64
", write file"
,
lastSdbVer
,
sdbVer
);
if
(
sdbWriteFile
(
pSdb
)
!=
0
)
{
if
(
sdbWriteFile
(
pSdb
)
!=
0
)
{
...
@@ -97,6 +93,10 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
...
@@ -97,6 +93,10 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
}
}
}
}
if
(
walBeginSnapshot
(
pWal
,
sdbVer
)
<
0
)
{
goto
WAL_RESTORE_OVER
;
}
if
(
walEndSnapshot
(
pWal
)
<
0
)
{
if
(
walEndSnapshot
(
pWal
)
<
0
)
{
goto
WAL_RESTORE_OVER
;
goto
WAL_RESTORE_OVER
;
}
}
...
...
source/dnode/mnode/impl/test/mnode/mnode.cpp
浏览文件 @
dc98029b
...
@@ -18,37 +18,25 @@ class MndTestMnode : public ::testing::Test {
...
@@ -18,37 +18,25 @@ class MndTestMnode : public ::testing::Test {
public:
public:
static
void
SetUpTestSuite
()
{
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_mnode1"
,
90
31
);
test
.
Init
(
"/tmp/mnode_test_mnode1"
,
90
28
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:90
31
"
;
const
char
*
firstEp
=
"localhost:90
28
"
;
server2
.
Start
(
"/tmp/mnode_test_mnode2"
,
fqdn
,
9032
,
firstEp
);
server2
.
Start
(
"/tmp/mnode_test_mnode2"
,
fqdn
,
9029
,
firstEp
);
server3
.
Start
(
"/tmp/mnode_test_mnode3"
,
fqdn
,
9033
,
firstEp
);
server4
.
Start
(
"/tmp/mnode_test_mnode4"
,
fqdn
,
9034
,
firstEp
);
server5
.
Start
(
"/tmp/mnode_test_mnode5"
,
fqdn
,
9035
,
firstEp
);
taosMsleep
(
300
);
taosMsleep
(
300
);
}
}
static
void
TearDownTestSuite
()
{
static
void
TearDownTestSuite
()
{
server2
.
Stop
();
server2
.
Stop
();
server3
.
Stop
();
server4
.
Stop
();
server5
.
Stop
();
test
.
Cleanup
();
test
.
Cleanup
();
}
}
static
Testbase
test
;
static
Testbase
test
;
static
TestServer
server2
;
static
TestServer
server2
;
static
TestServer
server3
;
static
TestServer
server4
;
static
TestServer
server5
;
};
};
Testbase
MndTestMnode
::
test
;
Testbase
MndTestMnode
::
test
;
TestServer
MndTestMnode
::
server2
;
TestServer
MndTestMnode
::
server2
;
TestServer
MndTestMnode
::
server3
;
TestServer
MndTestMnode
::
server4
;
TestServer
MndTestMnode
::
server5
;
TEST_F
(
MndTestMnode
,
01
_ShowDnode
)
{
TEST_F
(
MndTestMnode
,
01
_ShowDnode
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_MNODE
,
""
);
...
@@ -64,7 +52,7 @@ TEST_F(MndTestMnode, 01_ShowDnode) {
...
@@ -64,7 +52,7 @@ TEST_F(MndTestMnode, 01_ShowDnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
31
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
28
"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckBinary
(
"master"
,
12
);
CheckInt64
(
0
);
CheckInt64
(
0
);
CheckTimestamp
();
CheckTimestamp
();
...
@@ -72,9 +60,9 @@ TEST_F(MndTestMnode, 01_ShowDnode) {
...
@@ -72,9 +60,9 @@ TEST_F(MndTestMnode, 01_ShowDnode) {
TEST_F
(
MndTestMnode
,
02
_Create_Mnode_Invalid_Id
)
{
TEST_F
(
MndTestMnode
,
02
_Create_Mnode_Invalid_Id
)
{
{
{
int32_t
contLen
=
sizeof
(
SMCreateMnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateMnode
Req
);
SMCreateMnode
Msg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateMnode
Req
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
...
@@ -85,9 +73,9 @@ TEST_F(MndTestMnode, 02_Create_Mnode_Invalid_Id) {
...
@@ -85,9 +73,9 @@ TEST_F(MndTestMnode, 02_Create_Mnode_Invalid_Id) {
TEST_F
(
MndTestMnode
,
03
_Create_Mnode_Invalid_Id
)
{
TEST_F
(
MndTestMnode
,
03
_Create_Mnode_Invalid_Id
)
{
{
{
int32_t
contLen
=
sizeof
(
SMCreateMnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateMnode
Req
);
SMCreateMnode
Msg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateMnode
Req
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
...
@@ -103,7 +91,7 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
...
@@ -103,7 +91,7 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
32
);
pReq
->
port
=
htonl
(
90
29
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -117,9 +105,9 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
...
@@ -117,9 +105,9 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
{
{
// create mnode
// create mnode
int32_t
contLen
=
sizeof
(
SMCreateMnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateMnode
Req
);
SMCreateMnode
Msg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateMnode
Req
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
...
@@ -132,8 +120,8 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
...
@@ -132,8 +120,8 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckInt16
(
2
);
CheckInt16
(
2
);
CheckBinary
(
"localhost:90
31
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
28
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
32
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
29
"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckBinary
(
"master"
,
12
);
CheckBinary
(
"slave"
,
12
);
CheckBinary
(
"slave"
,
12
);
CheckInt64
(
0
);
CheckInt64
(
0
);
...
@@ -144,9 +132,9 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
...
@@ -144,9 +132,9 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
{
{
// drop mnode
// drop mnode
int32_t
contLen
=
sizeof
(
SMDropMnode
Msg
);
int32_t
contLen
=
sizeof
(
SMDropMnode
Req
);
SMDropMnode
Msg
*
pReq
=
(
SMDropMnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMDropMnode
Req
*
pReq
=
(
SMDropMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
...
@@ -158,144 +146,145 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
...
@@ -158,144 +146,145 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
31
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
28
"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckBinary
(
"master"
,
12
);
CheckInt64
(
0
);
CheckInt64
(
0
);
CheckTimestamp
();
CheckTimestamp
();
}
}
{
// drop mnode
int32_t
contLen
=
sizeof
(
SMDropMnodeReq
);
SMDropMnodeReq
*
pReq
=
(
SMDropMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_MNODE_NOT_EXIST
);
}
}
TEST_F
(
MndTestMnode
,
03
_Create_Mnode_Rollback
)
{
{
// send message first, then dnode2 crash, result is returned, and rollback is started
int32_t
contLen
=
sizeof
(
SMCreateMnodeReq
);
SMCreateMnodeReq
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
{
// continue send message, mnode is creating
int32_t
contLen
=
sizeof
(
SMCreateMnodeReq
);
SMCreateMnodeReq
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
{
// continue send message, mnode is creating
int32_t
contLen
=
sizeof
(
SMDropMnodeReq
);
SMDropMnodeReq
*
pReq
=
(
SMDropMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
{
// server start, wait until the rollback finished
server2
.
DoStart
();
taosMsleep
(
1000
);
int32_t
retry
=
0
;
int32_t
retryMax
=
20
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateMnodeReq
);
SMCreateMnodeReq
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
pRsp
->
code
==
TSDB_CODE_MND_MNODE_ALREADY_EXIST
)
break
;
taosMsleep
(
1000
);
}
ASSERT_NE
(
retry
,
retryMax
);
}
}
}
// {
// int32_t contLen = sizeof(SDropDnodeReq);
TEST_F
(
MndTestMnode
,
04
_Drop_Mnode_Rollback
)
{
{
// SDropDnodeReq* pReq = (SDropDnodeReq*)rpcMallocCont(contLen);
// send message first, then dnode2 crash, result is returned, and rollback is started
// pReq->dnodeId = htonl(2);
int32_t
contLen
=
sizeof
(
SMDropMnodeReq
);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
SMDropMnodeReq
*
pReq
=
(
SMDropMnodeReq
*
)
rpcMallocCont
(
contLen
);
// ASSERT_NE(pRsp, nullptr);
pReq
->
dnodeId
=
htonl
(
2
);
// ASSERT_EQ(pRsp->code, 0);
// }
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
ASSERT_NE
(
pRsp
,
nullptr
);
// CHECK_META("show dnodes", 7);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
// test.SendShowRetrieveReq();
}
// EXPECT_EQ(test.GetShowRows(), 1);
{
// CheckInt16(1);
// continue send message, mnode is dropping
// CheckBinary("localhost:9031", TSDB_EP_LEN);
int32_t
contLen
=
sizeof
(
SMCreateMnodeReq
);
// CheckInt16(0);
// CheckInt16(1);
SMCreateMnodeReq
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
// CheckBinary("ready", 10);
pReq
->
dnodeId
=
htonl
(
2
);
// CheckTimestamp();
// CheckBinary("", 24);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
// {
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
// int32_t contLen = sizeof(SCreateDnodeReq);
}
// SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
{
// strcpy(pReq->ep, "localhost:9033");
// continue send message, mnode is dropping
int32_t
contLen
=
sizeof
(
SMDropMnodeReq
);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
SMDropMnodeReq
*
pReq
=
(
SMDropMnodeReq
*
)
rpcMallocCont
(
contLen
);
// ASSERT_EQ(pRsp->code, 0);
pReq
->
dnodeId
=
htonl
(
2
);
// }
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
// {
ASSERT_NE
(
pRsp
,
nullptr
);
// int32_t contLen = sizeof(SCreateDnodeReq);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
// SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9034");
{
// server start, wait until the rollback finished
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
server2
.
DoStart
();
// ASSERT_NE(pRsp, nullptr);
taosMsleep
(
1000
);
// ASSERT_EQ(pRsp->code, 0);
// }
int32_t
retry
=
0
;
int32_t
retryMax
=
20
;
// {
// int32_t contLen = sizeof(SCreateDnodeReq);
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateMnodeReq
);
// SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9035");
SMCreateMnodeReq
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
// ASSERT_EQ(pRsp->code, 0);
ASSERT_NE
(
pRsp
,
nullptr
);
// }
if
(
pRsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
// taosMsleep(1300);
}
// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
ASSERT_NE
(
retry
,
retryMax
);
// test.SendShowRetrieveReq();
}
// EXPECT_EQ(test.GetShowRows(), 4);
}
\ No newline at end of file
// CheckInt16(1);
// CheckInt16(3);
// CheckInt16(4);
// CheckInt16(5);
// CheckBinary("localhost:9031", TSDB_EP_LEN);
// CheckBinary("localhost:9033", TSDB_EP_LEN);
// CheckBinary("localhost:9034", TSDB_EP_LEN);
// CheckBinary("localhost:9035", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// // restart
// uInfo("stop all server");
// test.Restart();
// server2.Restart();
// server3.Restart();
// server4.Restart();
// server5.Restart();
// taosMsleep(1300);
// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieveReq();
// EXPECT_EQ(test.GetShowRows(), 4);
// CheckInt16(1);
// CheckInt16(3);
// CheckInt16(4);
// CheckInt16(5);
// CheckBinary("localhost:9031", TSDB_EP_LEN);
// CheckBinary("localhost:9033", TSDB_EP_LEN);
// CheckBinary("localhost:9034", TSDB_EP_LEN);
// CheckBinary("localhost:9035", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// }
source/libs/catalog/src/catalog.c
浏览文件 @
dc98029b
...
@@ -1288,8 +1288,8 @@ _return:
...
@@ -1288,8 +1288,8 @@ _return:
}
}
int32_t
catalogGetAllMeta
(
struct
SCatalog
*
pCatalog
,
void
*
p
Rpc
,
const
SEpSet
*
pMgmtEps
,
const
SCatalogReq
*
pReq
,
SMetaData
*
pRsp
)
{
int32_t
catalogGetAllMeta
(
struct
SCatalog
*
pCatalog
,
void
*
p
Transporter
,
const
SEpSet
*
pMgmtEps
,
const
SCatalogReq
*
pReq
,
SMetaData
*
pRsp
)
{
if
(
NULL
==
pCatalog
||
NULL
==
p
Rpc
||
NULL
==
pMgmtEps
||
NULL
==
pReq
||
NULL
==
pRsp
)
{
if
(
NULL
==
pCatalog
||
NULL
==
p
Transporter
||
NULL
==
pMgmtEps
||
NULL
==
pReq
||
NULL
==
pRsp
)
{
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
...
@@ -1312,7 +1312,7 @@ int32_t catalogGetAllMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* p
...
@@ -1312,7 +1312,7 @@ int32_t catalogGetAllMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* p
SName
*
name
=
taosArrayGet
(
pReq
->
pTableName
,
i
);
SName
*
name
=
taosArrayGet
(
pReq
->
pTableName
,
i
);
STableMeta
*
pTableMeta
=
NULL
;
STableMeta
*
pTableMeta
=
NULL
;
CTG_ERR_JRET
(
ctgGetTableMeta
(
pCatalog
,
p
Rpc
,
pMgmtEps
,
name
,
false
,
&
pTableMeta
,
-
1
));
CTG_ERR_JRET
(
ctgGetTableMeta
(
pCatalog
,
p
Transporter
,
pMgmtEps
,
name
,
false
,
&
pTableMeta
,
-
1
));
if
(
NULL
==
taosArrayPush
(
pRsp
->
pTableMeta
,
&
pTableMeta
))
{
if
(
NULL
==
taosArrayPush
(
pRsp
->
pTableMeta
,
&
pTableMeta
))
{
ctgError
(
"taosArrayPush failed, idx:%d"
,
i
);
ctgError
(
"taosArrayPush failed, idx:%d"
,
i
);
...
@@ -1325,7 +1325,6 @@ int32_t catalogGetAllMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* p
...
@@ -1325,7 +1325,6 @@ int32_t catalogGetAllMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* p
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_return:
_return:
if
(
pRsp
->
pTableMeta
)
{
if
(
pRsp
->
pTableMeta
)
{
int32_t
aSize
=
taosArrayGetSize
(
pRsp
->
pTableMeta
);
int32_t
aSize
=
taosArrayGetSize
(
pRsp
->
pTableMeta
);
for
(
int32_t
i
=
0
;
i
<
aSize
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
aSize
;
++
i
)
{
...
...
source/libs/executor/CMakeLists.txt
浏览文件 @
dc98029b
...
@@ -8,5 +8,5 @@ target_include_directories(
...
@@ -8,5 +8,5 @@ target_include_directories(
target_link_libraries
(
target_link_libraries
(
executor
executor
PRIVATE os util common function parser
PRIVATE os util common function parser
planner qcom
)
)
\ No newline at end of file
source/libs/executor/inc/dataSinkInt.h
0 → 100644
浏览文件 @
dc98029b
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _DATA_SINK_INT_H
#define _DATA_SINK_INT_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "common.h"
#include "dataSinkMgt.h"
struct
SDataSink
;
struct
SDataSinkHandle
;
typedef
int32_t
(
*
FPutDataBlock
)(
struct
SDataSinkHandle
*
pHandle
,
const
SDataResult
*
pRes
);
typedef
int32_t
(
*
FGetDataBlock
)(
struct
SDataSinkHandle
*
pHandle
,
char
*
pData
,
int32_t
*
pLen
);
typedef
int32_t
(
*
FDestroyDataSinker
)(
struct
SDataSinkHandle
*
pHandle
);
typedef
struct
SDataSinkHandle
{
FPutDataBlock
fPut
;
FGetDataBlock
fGet
;
FDestroyDataSinker
fDestroy
;
}
SDataSinkHandle
;
int32_t
createDataDispatcher
(
const
struct
SDataSink
*
pDataSink
,
DataSinkHandle
*
pHandle
);
#ifdef __cplusplus
}
#endif
#endif
/*_DATA_SINK_INT_H*/
source/libs/executor/inc/dataSinkMgt.h
0 → 100644
浏览文件 @
dc98029b
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _DATA_SINK_MGT_H
#define _DATA_SINK_MGT_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "os.h"
#include "executorimpl.h"
#define DS_CAPACITY_ENOUGH 1
#define DS_CAPACITY_FULL 2
#define DS_NEED_SCHEDULE 3
struct
SDataSink
;
struct
SSDataBlock
;
typedef
struct
SDataSinkMgtCfg
{
uint32_t
maxDataBlockNum
;
uint32_t
maxDataBlockNumPerQuery
;
}
SDataSinkMgtCfg
;
int32_t
dsDataSinkMgtInit
(
SDataSinkMgtCfg
*
cfg
);
typedef
void
*
DataSinkHandle
;
typedef
struct
SDataResult
{
SQueryCostInfo
profile
;
const
SSDataBlock
*
pData
;
SHashObj
*
pTableRetrieveTsMap
;
}
SDataResult
;
/**
* Create a subplan's datasinker handle for all later operations.
* @param pDataSink
* @param pHandle output
* @return error code
*/
int32_t
dsCreateDataSinker
(
const
struct
SDataSink
*
pDataSink
,
DataSinkHandle
*
pHandle
);
/**
* Put the result set returned by the executor into datasinker.
* @param handle
* @param pRes
* @return error code
*/
int32_t
dsPutDataBlock
(
DataSinkHandle
handle
,
const
SDataResult
*
pRes
);
/**
* Get the length of the data returned by the next call to dsGetDataBlock.
* @param handle
* @return data length
*/
int32_t
dsGetDataLength
(
DataSinkHandle
handle
);
/**
* Get data, the caller needs to allocate data memory.
* @param handle
* @param pData output
* @param pLen output
* @return error code
*/
int32_t
dsGetDataBlock
(
DataSinkHandle
handle
,
char
*
pData
,
int32_t
*
pLen
);
/**
* Get the datasinker state, after each dsPutDataBlock and dsGetDataBlock call.
* @param handle
* @return datasinker status
*/
int32_t
dsGetStatus
(
DataSinkHandle
handle
);
/**
* After dsGetStatus returns DS_NEED_SCHEDULE, the caller need to put this into the work queue.
* @param ahandle
* @param pItem
*/
void
dsScheduleProcess
(
void
*
ahandle
,
void
*
pItem
);
/**
* Destroy the datasinker handle.
* @param handle
*/
void
dsDestroyDataSinker
(
DataSinkHandle
handle
);
#ifdef __cplusplus
}
#endif
#endif
/*_DATA_SINK_MGT_H*/
source/libs/executor/src/dataDispatcher.c
0 → 100644
浏览文件 @
dc98029b
/*
* 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 "dataSinkInt.h"
#include "dataSinkMgt.h"
#include "planner.h"
#include "tcompression.h"
#include "tglobal.h"
#include "tqueue.h"
#define GET_BUF_DATA(buf) (buf)->pData + (buf)->pos
#define GET_BUF_REMAIN(buf) (buf)->remain
typedef
struct
SBuf
{
int32_t
size
;
int32_t
pos
;
int32_t
remain
;
char
*
pData
;
}
SBuf
;
typedef
struct
SDataDispatchHandle
{
SDataSinkHandle
sink
;
SDataBlockSchema
schema
;
STaosQueue
*
pDataBlocks
;
SBuf
buf
;
}
SDataDispatchHandle
;
static
bool
needCompress
(
const
SSDataBlock
*
pData
,
const
SDataBlockSchema
*
pSchema
)
{
if
(
tsCompressColData
<
0
||
0
==
pData
->
info
.
rows
)
{
return
false
;
}
for
(
int32_t
col
=
0
;
col
<
pSchema
->
numOfCols
;
++
col
)
{
SColumnInfoData
*
pColRes
=
taosArrayGet
(
pData
->
pDataBlock
,
col
);
int32_t
colSize
=
pColRes
->
info
.
bytes
*
pData
->
info
.
rows
;
if
(
NEEDTO_COMPRESS_QUERY
(
colSize
))
{
return
true
;
}
}
return
false
;
}
static
int32_t
compressQueryColData
(
SColumnInfoData
*
pColRes
,
int32_t
numOfRows
,
char
*
data
,
int8_t
compressed
)
{
int32_t
colSize
=
pColRes
->
info
.
bytes
*
numOfRows
;
return
(
*
(
tDataTypes
[
pColRes
->
info
.
type
].
compFunc
))(
pColRes
->
pData
,
colSize
,
numOfRows
,
data
,
colSize
+
COMP_OVERFLOW_BYTES
,
compressed
,
NULL
,
0
);
}
static
void
doCopyQueryResultToMsg
(
const
SDataResult
*
pRes
,
const
SDataBlockSchema
*
pSchema
,
char
*
data
,
int8_t
compressed
,
int32_t
*
compLen
)
{
int32_t
*
compSizes
=
(
int32_t
*
)
data
;
if
(
compressed
)
{
data
+=
pSchema
->
numOfCols
*
sizeof
(
int32_t
);
}
for
(
int32_t
col
=
0
;
col
<
pSchema
->
numOfCols
;
++
col
)
{
SColumnInfoData
*
pColRes
=
taosArrayGet
(
pRes
->
pData
->
pDataBlock
,
col
);
if
(
compressed
)
{
compSizes
[
col
]
=
compressQueryColData
(
pColRes
,
pRes
->
pData
->
info
.
rows
,
data
,
compressed
);
data
+=
compSizes
[
col
];
*
compLen
+=
compSizes
[
col
];
compSizes
[
col
]
=
htonl
(
compSizes
[
col
]);
}
else
{
memmove
(
data
,
pColRes
->
pData
,
pColRes
->
info
.
bytes
*
pRes
->
pData
->
info
.
rows
);
data
+=
pColRes
->
info
.
bytes
*
pRes
->
pData
->
info
.
rows
;
}
}
int32_t
numOfTables
=
(
int32_t
)
taosHashGetSize
(
pRes
->
pTableRetrieveTsMap
);
*
(
int32_t
*
)
data
=
htonl
(
numOfTables
);
data
+=
sizeof
(
int32_t
);
STableIdInfo
*
item
=
taosHashIterate
(
pRes
->
pTableRetrieveTsMap
,
NULL
);
while
(
item
)
{
STableIdInfo
*
pDst
=
(
STableIdInfo
*
)
data
;
pDst
->
uid
=
htobe64
(
item
->
uid
);
pDst
->
key
=
htobe64
(
item
->
key
);
data
+=
sizeof
(
STableIdInfo
);
item
=
taosHashIterate
(
pRes
->
pTableRetrieveTsMap
,
item
);
}
}
static
void
toRetrieveResult
(
SDataDispatchHandle
*
pHandle
,
const
SDataResult
*
pRes
,
char
*
pData
,
int32_t
*
pContLen
)
{
SRetrieveTableRsp
*
pRsp
=
(
SRetrieveTableRsp
*
)
pData
;
pRsp
->
useconds
=
htobe64
(
pRes
->
profile
.
elapsedTime
);
pRsp
->
precision
=
htons
(
pHandle
->
schema
.
precision
);
pRsp
->
compressed
=
(
int8_t
)
needCompress
(
pRes
->
pData
,
&
(
pHandle
->
schema
));
pRsp
->
numOfRows
=
htonl
(
pRes
->
pData
->
info
.
rows
);
*
pContLen
=
sizeof
(
int32_t
)
+
sizeof
(
STableIdInfo
)
*
taosHashGetSize
(
pRes
->
pTableRetrieveTsMap
)
+
sizeof
(
SRetrieveTableRsp
);
doCopyQueryResultToMsg
(
pRes
,
&
pHandle
->
schema
,
pRsp
->
data
,
pRsp
->
compressed
,
&
pRsp
->
compLen
);
*
pContLen
+=
(
pRsp
->
compressed
?
pRsp
->
compLen
:
pHandle
->
schema
.
resultRowSize
*
pRes
->
pData
->
info
.
rows
);
pRsp
->
compLen
=
htonl
(
pRsp
->
compLen
);
// todo completed
}
static
int32_t
putDataBlock
(
SDataSinkHandle
*
pHandle
,
const
SDataResult
*
pRes
)
{
SDataDispatchHandle
*
pDispatcher
=
(
SDataDispatchHandle
*
)
pHandle
;
int32_t
useSize
=
0
;
toRetrieveResult
(
pDispatcher
,
pRes
,
GET_BUF_DATA
(
&
pDispatcher
->
buf
),
&
useSize
);
}
static
int32_t
getDataBlock
(
SDataSinkHandle
*
pHandle
,
char
*
pData
,
int32_t
*
pLen
)
{
}
static
int32_t
destroyDataSinker
(
SDataSinkHandle
*
pHandle
)
{
}
int32_t
createDataDispatcher
(
const
SDataSink
*
pDataSink
,
DataSinkHandle
*
pHandle
)
{
SDataDispatchHandle
*
dispatcher
=
calloc
(
1
,
sizeof
(
SDataDispatchHandle
));
if
(
NULL
==
dispatcher
)
{
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
}
dispatcher
->
sink
.
fPut
=
putDataBlock
;
dispatcher
->
sink
.
fGet
=
getDataBlock
;
dispatcher
->
sink
.
fDestroy
=
destroyDataSinker
;
dispatcher
->
pDataBlocks
=
taosOpenQueue
();
if
(
NULL
==
dispatcher
->
pDataBlocks
)
{
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
}
*
pHandle
=
dispatcher
;
return
TSDB_CODE_SUCCESS
;
}
source/libs/executor/src/dataSinkMgt.c
0 → 100644
浏览文件 @
dc98029b
/*
* 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 "dataSinkMgt.h"
#include "dataSinkInt.h"
#include "planner.h"
int32_t
dsDataSinkMgtInit
(
SDataSinkMgtCfg
*
cfg
)
{
// todo
}
int32_t
dsCreateDataSinker
(
const
struct
SDataSink
*
pDataSink
,
DataSinkHandle
*
pHandle
)
{
if
(
DSINK_Dispatch
==
pDataSink
->
info
.
type
)
{
return
createDataDispatcher
(
pDataSink
,
pHandle
);
}
return
TSDB_CODE_FAILED
;
}
int32_t
dsPutDataBlock
(
DataSinkHandle
handle
,
const
SDataResult
*
pRes
)
{
SDataSinkHandle
*
pHandleImpl
=
(
SDataSinkHandle
*
)
handle
;
return
pHandleImpl
->
fPut
(
pHandleImpl
,
pRes
);
}
int32_t
dsGetDataLength
(
DataSinkHandle
handle
)
{
// todo
}
int32_t
dsGetDataBlock
(
DataSinkHandle
handle
,
char
*
pData
,
int32_t
*
pLen
)
{
SDataSinkHandle
*
pHandleImpl
=
(
SDataSinkHandle
*
)
handle
;
return
pHandleImpl
->
fGet
(
pHandleImpl
,
pData
,
pLen
);
}
int32_t
dsGetStatus
(
DataSinkHandle
handle
)
{
// todo
}
void
dsScheduleProcess
(
void
*
ahandle
,
void
*
pItem
)
{
// todo
}
void
dsDestroyDataSinker
(
DataSinkHandle
handle
)
{
SDataSinkHandle
*
pHandleImpl
=
(
SDataSinkHandle
*
)
handle
;
pHandleImpl
->
fDestroy
(
pHandleImpl
);
}
source/libs/parser/inc/parserInt.h
浏览文件 @
dc98029b
...
@@ -44,14 +44,14 @@ void clearAllTableMetaInfo(SQueryStmtInfo* pQueryInfo, bool removeMeta, uint64_t
...
@@ -44,14 +44,14 @@ void clearAllTableMetaInfo(SQueryStmtInfo* pQueryInfo, bool removeMeta, uint64_t
/**
/**
* Validate the sql info, according to the corresponding metadata info from catalog.
* Validate the sql info, according to the corresponding metadata info from catalog.
* @param pC
atalog
* @param pC
tx
* @param p
Sql
Info
* @param pInfo
* @param pQueryInfo
a bounded AST with essential meta data from local buffer or mgmt node
* @param pQueryInfo
* @param
id
* @param
msgBuf
* @param msg
* @param msg
BufLen
* @return
* @return
*/
*/
int32_t
qParserValidateSqlNode
(
struct
SCatalog
*
pCatalog
,
SSqlInfo
*
pSqlInfo
,
SQueryStmtInfo
*
pQueryInfo
,
int64_t
id
,
char
*
msg
,
int32_t
msg
Len
);
int32_t
qParserValidateSqlNode
(
SParseBasicCtx
*
pCtx
,
SSqlInfo
*
pInfo
,
SQueryStmtInfo
*
pQueryInfo
,
char
*
msgBuf
,
int32_t
msgBuf
Len
);
/**
/**
* validate the ddl ast, and convert the ast to the corresponding message format
* validate the ddl ast, and convert the ast to the corresponding message format
...
@@ -62,6 +62,14 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pSqlInfo, SQ
...
@@ -62,6 +62,14 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pSqlInfo, SQ
*/
*/
SDclStmtInfo
*
qParserValidateDclSqlNode
(
SSqlInfo
*
pInfo
,
SParseBasicCtx
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
);
SDclStmtInfo
*
qParserValidateDclSqlNode
(
SSqlInfo
*
pInfo
,
SParseBasicCtx
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
);
/**
*
* @param pInfo
* @param pCtx
* @param msgBuf
* @param msgBufLen
* @return
*/
SVnodeModifOpStmtInfo
*
qParserValidateCreateTbSqlNode
(
SSqlInfo
*
pInfo
,
SParseBasicCtx
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
);
SVnodeModifOpStmtInfo
*
qParserValidateCreateTbSqlNode
(
SSqlInfo
*
pInfo
,
SParseBasicCtx
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
);
/**
/**
...
@@ -90,7 +98,7 @@ int32_t checkForInvalidExpr(SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf);
...
@@ -90,7 +98,7 @@ int32_t checkForInvalidExpr(SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf);
* @param msgBufLen
* @param msgBufLen
* @return
* @return
*/
*/
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
SCatalogReq
*
pMetaInfo
,
char
*
msg
,
int32_t
msgBufLen
);
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
SCatalogReq
*
pMetaInfo
,
SParseBasicCtx
*
pCtx
,
char
*
msg
,
int32_t
msgBufLen
);
/**
/**
* Destroy the meta data request structure.
* Destroy the meta data request structure.
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
dc98029b
...
@@ -213,7 +213,7 @@ SQueryStmtInfo *createQueryInfo() {
...
@@ -213,7 +213,7 @@ SQueryStmtInfo *createQueryInfo() {
pQueryInfo
->
slimit
.
limit
=
-
1
;
pQueryInfo
->
slimit
.
limit
=
-
1
;
pQueryInfo
->
slimit
.
offset
=
0
;
pQueryInfo
->
slimit
.
offset
=
0
;
pQueryInfo
->
p
Upstream
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pQueryInfo
->
p
Downstream
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pQueryInfo
->
window
=
TSWINDOW_INITIALIZER
;
pQueryInfo
->
window
=
TSWINDOW_INITIALIZER
;
pQueryInfo
->
exprList
=
calloc
(
10
,
POINTER_BYTES
);
pQueryInfo
->
exprList
=
calloc
(
10
,
POINTER_BYTES
);
...
@@ -247,8 +247,8 @@ static void destroyQueryInfoImpl(SQueryStmtInfo* pQueryInfo) {
...
@@ -247,8 +247,8 @@ static void destroyQueryInfoImpl(SQueryStmtInfo* pQueryInfo) {
tfree
(
pQueryInfo
->
fillVal
);
tfree
(
pQueryInfo
->
fillVal
);
tfree
(
pQueryInfo
->
buf
);
tfree
(
pQueryInfo
->
buf
);
taosArrayDestroy
(
pQueryInfo
->
p
Up
stream
);
taosArrayDestroy
(
pQueryInfo
->
p
Down
stream
);
pQueryInfo
->
p
Up
stream
=
NULL
;
pQueryInfo
->
p
Down
stream
=
NULL
;
pQueryInfo
->
bufLen
=
0
;
pQueryInfo
->
bufLen
=
0
;
}
}
...
@@ -256,9 +256,9 @@ void destroyQueryInfo(SQueryStmtInfo* pQueryInfo) {
...
@@ -256,9 +256,9 @@ void destroyQueryInfo(SQueryStmtInfo* pQueryInfo) {
while
(
pQueryInfo
!=
NULL
)
{
while
(
pQueryInfo
!=
NULL
)
{
SQueryStmtInfo
*
p
=
pQueryInfo
->
sibling
;
SQueryStmtInfo
*
p
=
pQueryInfo
->
sibling
;
size_t
numOfUpstream
=
taosArrayGetSize
(
pQueryInfo
->
p
Up
stream
);
size_t
numOfUpstream
=
taosArrayGetSize
(
pQueryInfo
->
p
Down
stream
);
for
(
int32_t
i
=
0
;
i
<
numOfUpstream
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfUpstream
;
++
i
)
{
SQueryStmtInfo
*
pUpQueryInfo
=
taosArrayGetP
(
pQueryInfo
->
p
Up
stream
,
i
);
SQueryStmtInfo
*
pUpQueryInfo
=
taosArrayGetP
(
pQueryInfo
->
p
Down
stream
,
i
);
destroyQueryInfoImpl
(
pUpQueryInfo
);
destroyQueryInfoImpl
(
pUpQueryInfo
);
clearAllTableMetaInfo
(
pUpQueryInfo
,
false
,
0
);
clearAllTableMetaInfo
(
pUpQueryInfo
,
false
,
0
);
tfree
(
pUpQueryInfo
);
tfree
(
pUpQueryInfo
);
...
@@ -288,7 +288,6 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SQueryStmtI
...
@@ -288,7 +288,6 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SQueryStmtI
}
}
pSub
->
pUdfInfo
=
pUdfInfo
;
pSub
->
pUdfInfo
=
pUdfInfo
;
pSub
->
pDownstream
=
pQueryInfo
;
int32_t
code
=
validateSqlNode
(
p
,
pSub
,
pMsgBuf
);
int32_t
code
=
validateSqlNode
(
p
,
pSub
,
pMsgBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -311,7 +310,7 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SQueryStmtI
...
@@ -311,7 +310,7 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SQueryStmtI
tstrncpy
(
pTableMetaInfo1
->
aliasName
,
subInfo
->
aliasName
.
z
,
subInfo
->
aliasName
.
n
+
1
);
tstrncpy
(
pTableMetaInfo1
->
aliasName
,
subInfo
->
aliasName
.
z
,
subInfo
->
aliasName
.
n
+
1
);
}
}
taosArrayPush
(
pQueryInfo
->
p
Up
stream
,
&
pSub
);
taosArrayPush
(
pQueryInfo
->
p
Down
stream
,
&
pSub
);
// NOTE: order mix up in subquery not support yet.
// NOTE: order mix up in subquery not support yet.
pQueryInfo
->
order
=
pSub
->
order
;
pQueryInfo
->
order
=
pSub
->
order
;
...
@@ -600,7 +599,7 @@ int32_t checkForUnsupportedQuery(SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf) {
...
@@ -600,7 +599,7 @@ int32_t checkForUnsupportedQuery(SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf) {
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
}
if
(
f
==
FUNCTION_BLKINFO
&&
taosArrayGetSize
(
pQueryInfo
->
p
Up
stream
)
>
0
)
{
if
(
f
==
FUNCTION_BLKINFO
&&
taosArrayGetSize
(
pQueryInfo
->
p
Down
stream
)
>
0
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
}
...
@@ -1584,7 +1583,6 @@ int32_t validateSqlNode(SSqlNode* pSqlNode, SQueryStmtInfo* pQueryInfo, SMsgBuf*
...
@@ -1584,7 +1583,6 @@ int32_t validateSqlNode(SSqlNode* pSqlNode, SQueryStmtInfo* pQueryInfo, SMsgBuf*
}
}
pushDownAggFuncExprInfo
(
pQueryInfo
);
pushDownAggFuncExprInfo
(
pQueryInfo
);
// addColumnNodeFromLowerLevel(pQueryInfo);
for
(
int32_t
i
=
0
;
i
<
1
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
1
;
++
i
)
{
SArray
*
functionList
=
extractFunctionList
(
pQueryInfo
->
exprList
[
i
]);
SArray
*
functionList
=
extractFunctionList
(
pQueryInfo
->
exprList
[
i
]);
...
@@ -3630,12 +3628,12 @@ int32_t evaluateSqlNode(SSqlNode* pNode, int32_t tsPrecision, SMsgBuf* pMsgBuf)
...
@@ -3630,12 +3628,12 @@ int32_t evaluateSqlNode(SSqlNode* pNode, int32_t tsPrecision, SMsgBuf* pMsgBuf)
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
qParserValidateSqlNode
(
struct
SCatalog
*
pCatalog
,
SSqlInfo
*
pInfo
,
SQueryStmtInfo
*
pQueryInfo
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
int32_t
qParserValidateSqlNode
(
SParseBasicCtx
*
pCtx
,
SSqlInfo
*
pInfo
,
SQueryStmtInfo
*
pQueryInfo
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
assert
(
pC
atalog
!=
NULL
&&
pInfo
!=
NULL
);
assert
(
pC
tx
!=
NULL
&&
pInfo
!=
NULL
);
int32_t
code
=
0
;
int32_t
code
=
0
;
SMsgBuf
m
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SMsgBuf
m
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SMsgBuf
*
pMsgBuf
=
&
m
;
SMsgBuf
*
pMsgBuf
=
&
m
;
switch
(
pInfo
->
type
)
{
switch
(
pInfo
->
type
)
{
#if 0
#if 0
...
@@ -3682,22 +3680,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
...
@@ -3682,22 +3680,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
break;
break;
}
}
case TSDB_SQL_USE_DB: {
const char* msg = "invalid db name";
SToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
return buildInvalidOperationMsg(pMsgBuf, msg);
}
int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), pToken);
if (ret != TSDB_CODE_SUCCESS) {
return buildInvalidOperationMsg(pMsgBuf, msg);
}
break;
}
case TSDB_SQL_RESET_CACHE: {
case TSDB_SQL_RESET_CACHE: {
return TSDB_CODE_SUCCESS;
return TSDB_CODE_SUCCESS;
}
}
...
@@ -3712,55 +3694,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
...
@@ -3712,55 +3694,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
break;
break;
}
}
case TSDB_SQL_CREATE_DNODE: {
const char* msg = "invalid host name (ip address)";
if (taosArrayGetSize(pInfo->pMiscInfo->a) > 1) {
return buildInvalidOperationMsg(pMsgBuf, msg);
}
SToken* id = taosArrayGet(pInfo->pMiscInfo->a, 0);
if (id->type == TK_STRING) {
id->n = strdequote(id->z);
}
break;
}
case TSDB_SQL_CREATE_ACCT:
case TSDB_SQL_ALTER_ACCT: {
const char* msg1 = "invalid state option, available options[no, r, w, all]";
const char* msg2 = "invalid user/account name";
const char* msg3 = "name too long";
SToken* pName = &pInfo->pMiscInfo->user.user;
SToken* pPwd = &pInfo->pMiscInfo->user.passwd;
if (handlePassword(pCmd, pPwd) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
if (pName->n >= TSDB_USER_LEN) {
return buildInvalidOperationMsg(pMsgBuf, msg3);
}
if (tscValidateName(pName) != TSDB_CODE_SUCCESS) {
return buildInvalidOperationMsg(pMsgBuf, msg2);
}
SCreateAcctInfo* pAcctOpt = &pInfo->pMiscInfo->acctOpt;
if (pAcctOpt->stat.n > 0) {
if (pAcctOpt->stat.z[0] == 'r' && pAcctOpt->stat.n == 1) {
} else if (pAcctOpt->stat.z[0] == 'w' && pAcctOpt->stat.n == 1) {
} else if (strncmp(pAcctOpt->stat.z, "all", 3) == 0 && pAcctOpt->stat.n == 3) {
} else if (strncmp(pAcctOpt->stat.z, "no", 2) == 0 && pAcctOpt->stat.n == 2) {
} else {
return buildInvalidOperationMsg(pMsgBuf, msg1);
}
}
break;
}
case TSDB_SQL_DESCRIBE_TABLE: {
case TSDB_SQL_DESCRIBE_TABLE: {
const char* msg1 = "invalid table name";
const char* msg1 = "invalid table name";
...
@@ -3865,29 +3798,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
...
@@ -3865,29 +3798,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
return TSDB_CODE_SUCCESS;
return TSDB_CODE_SUCCESS;
}
}
case TSDB_SQL_CREATE_TABLE: {
SCreateTableSql* pCreateTable = pInfo->pCreateTableInfo;
if (pCreateTable->type == TSQL_CREATE_TABLE || pCreateTable->type == TSQL_CREATE_STABLE) {
if ((code = doCheckForCreateTable(pSql, 0, pInfo)) != TSDB_CODE_SUCCESS) {
return code;
}
} else if (pCreateTable->type == TSQL_CREATE_TABLE_FROM_STABLE) {
assert(pCmd->numOfCols == 0);
if ((code = doCheckForCreateFromStable(pSql, pInfo)) != TSDB_CODE_SUCCESS) {
return code;
}
} else if (pCreateTable->type == TSQL_CREATE_STREAM) {
if ((code = doCheckForStream(pSql, pInfo)) != TSDB_CODE_SUCCESS) {
return code;
}
}
break;
}
case TSDB_SQL_SELECT: {
case TSDB_SQL_SELECT: {
const char * msg1 = "no nested query supported in union clause";
const char * msg1 = "no nested query supported in union clause";
code = loadAllTableMeta(pSql, pInfo);
code = loadAllTableMeta(pSql, pInfo);
...
@@ -3981,27 +3891,41 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
...
@@ -3981,27 +3891,41 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
}
}
break;
break;
}
}
#endif
default:
default:
return buildInvalidOperationMsg(pMsgBuf, "not support sql expression");
return buildInvalidOperationMsg(pMsgBuf, "not support sql expression");
}
}
#endif
}
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
SMetaData
data
=
{
0
};
SMetaData
data
=
{
0
};
// TODO: check if the qnode info has been cached already
// TODO: check if the qnode info has been cached already
req
.
qNodeRequired
=
true
;
req
.
qNodeRequired
=
true
;
code
=
qParserExtractRequestedMetaInfo
(
pInfo
,
&
req
,
msgBuf
,
msgBufLen
);
code
=
qParserExtractRequestedMetaInfo
(
pInfo
,
&
req
,
pCtx
,
msgBuf
,
msgBufLen
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
// load the meta data from catalog
// load the meta data from catalog
code
=
catalogGetAllMeta
(
pCatalog
,
NULL
,
NULL
,
&
req
,
&
data
);
// code = catalogGetAllMeta(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, &req, &data);
STableMeta
*
pmt
=
NULL
;
SName
*
name
=
taosArrayGet
(
req
.
pTableName
,
0
);
code
=
catalogGetTableMeta
(
pCtx
->
pCatalog
,
pCtx
->
pTransporter
,
&
pCtx
->
mgmtEpSet
,
name
,
&
pmt
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
data
.
pTableMeta
=
taosArrayInit
(
1
,
POINTER_BYTES
);
taosArrayPush
(
data
.
pTableMeta
,
&
pmt
);
pQueryInfo
->
pTableMetaInfo
=
calloc
(
1
,
POINTER_BYTES
);
pQueryInfo
->
pTableMetaInfo
[
0
]
=
calloc
(
1
,
sizeof
(
STableMetaInfo
));
pQueryInfo
->
pTableMetaInfo
[
0
]
->
pTableMeta
=
pmt
;
pQueryInfo
->
pTableMetaInfo
[
0
]
->
name
=
*
name
;
pQueryInfo
->
numOfTables
=
1
;
// evaluate the sqlnode
// evaluate the sqlnode
STableMeta
*
pTableMeta
=
(
STableMeta
*
)
taosArrayGetP
(
data
.
pTableMeta
,
0
);
STableMeta
*
pTableMeta
=
(
STableMeta
*
)
taosArrayGetP
(
data
.
pTableMeta
,
0
);
assert
(
pTableMeta
!=
NULL
);
assert
(
pTableMeta
!=
NULL
);
...
...
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
dc98029b
#include <astGenerator.h>
#include "tmsg.h"
#include <tmsg.h>
#include "tglobal.h"
#include "astToMsg.h"
#include "parserInt.h"
#include "parserInt.h"
#include "ttime.h"
#include "astToMsg.h"
#include "astGenerator.h"
#include "parserUtil.h"
#include "parserUtil.h"
#include "queryInfoUtil.h"
#include "queryInfoUtil.h"
#include "tglobal.h"
#include "tmsg.h"
#include "ttime.h"
/* is contained in pFieldList or not */
/* is contained in pFieldList or not */
static
bool
has
(
SArray
*
pFieldList
,
int32_t
startIndex
,
const
char
*
name
)
{
static
bool
has
(
SArray
*
pFieldList
,
int32_t
startIndex
,
const
char
*
name
)
{
...
@@ -195,6 +194,18 @@ static int32_t doCheckDbOptions(SCreateDbMsg* pCreate, SMsgBuf* pMsgBuf) {
...
@@ -195,6 +194,18 @@ static int32_t doCheckDbOptions(SCreateDbMsg* pCreate, SMsgBuf* pMsgBuf) {
TSDB_MIN_VNODES_PER_DB
,
TSDB_MAX_VNODES_PER_DB
);
TSDB_MIN_VNODES_PER_DB
,
TSDB_MAX_VNODES_PER_DB
);
}
}
val
=
htonl
(
pCreate
->
maxRows
);
if
(
val
<
TSDB_MIN_MAX_ROW_FBLOCK
||
val
>
TSDB_MAX_MAX_ROW_FBLOCK
)
{
snprintf
(
msg
,
tListLen
(
msg
),
"invalid number of max rows in file block for DB:%d valid range: [%d, %d]"
,
val
,
TSDB_MIN_MAX_ROW_FBLOCK
,
TSDB_MAX_MAX_ROW_FBLOCK
);
}
val
=
htonl
(
pCreate
->
minRows
);
if
(
val
<
TSDB_MIN_MIN_ROW_FBLOCK
||
val
>
TSDB_MAX_MIN_ROW_FBLOCK
)
{
snprintf
(
msg
,
tListLen
(
msg
),
"invalid number of min rows in file block for DB:%d valid range: [%d, %d]"
,
val
,
TSDB_MIN_MIN_ROW_FBLOCK
,
TSDB_MAX_MIN_ROW_FBLOCK
);
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/parser/src/insertParser.c
浏览文件 @
dc98029b
...
@@ -624,12 +624,11 @@ int32_t parseInsertSql(SParseContext* pContext, SVnodeModifOpStmtInfo** pInfo) {
...
@@ -624,12 +624,11 @@ int32_t parseInsertSql(SParseContext* pContext, SVnodeModifOpStmtInfo** pInfo) {
if
(
NULL
==
context
.
pVgroupsHashObj
||
NULL
==
context
.
pTableBlockHashObj
||
NULL
==
context
.
pOutput
)
{
if
(
NULL
==
context
.
pVgroupsHashObj
||
NULL
==
context
.
pTableBlockHashObj
||
NULL
==
context
.
pOutput
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_
FAILED
;
return
TSDB_CODE_
TSC_OUT_OF_MEMORY
;
}
}
*
pInfo
=
context
.
pOutput
;
*
pInfo
=
context
.
pOutput
;
context
.
pOutput
->
nodeType
=
TSDB_SQL_INSERT
;
context
.
pOutput
->
nodeType
=
TSDB_SQL_INSERT
;
context
.
pOutput
->
schemaAttache
=
pContext
->
schemaAttached
;
context
.
pOutput
->
payloadType
=
PAYLOAD_TYPE_KV
;
context
.
pOutput
->
payloadType
=
PAYLOAD_TYPE_KV
;
int32_t
code
=
skipInsertInto
(
&
context
);
int32_t
code
=
skipInsertInto
(
&
context
);
...
@@ -638,5 +637,5 @@ int32_t parseInsertSql(SParseContext* pContext, SVnodeModifOpStmtInfo** pInfo) {
...
@@ -638,5 +637,5 @@ int32_t parseInsertSql(SParseContext* pContext, SVnodeModifOpStmtInfo** pInfo) {
}
}
destroyInsertParseContext
(
&
context
);
destroyInsertParseContext
(
&
context
);
terrno
=
code
;
terrno
=
code
;
return
(
TSDB_CODE_SUCCESS
==
code
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_FAILED
)
;
return
code
;
}
}
source/libs/parser/src/parser.c
浏览文件 @
dc98029b
...
@@ -31,8 +31,8 @@ bool isInsertSql(const char* pStr, size_t length) {
...
@@ -31,8 +31,8 @@ bool isInsertSql(const char* pStr, size_t length) {
}
while
(
1
);
}
while
(
1
);
}
}
bool
qIsDdlQuery
(
const
SQueryNode
*
pQuery
)
{
bool
qIsDdlQuery
(
const
SQueryNode
*
pQuery
Node
)
{
return
TSDB_SQL_INSERT
!=
pQuery
->
type
&&
TSDB_SQL_SELECT
!=
pQuery
->
type
&&
TSDB_SQL_CREATE_TABLE
!=
pQuery
->
type
;
return
TSDB_SQL_INSERT
!=
pQuery
Node
->
type
&&
TSDB_SQL_SELECT
!=
pQueryNode
->
type
&&
TSDB_SQL_CREATE_TABLE
!=
pQueryNode
->
type
;
}
}
int32_t
parseQuerySql
(
SParseContext
*
pCxt
,
SQueryNode
**
pQuery
)
{
int32_t
parseQuerySql
(
SParseContext
*
pCxt
,
SQueryNode
**
pQuery
)
{
...
@@ -61,13 +61,13 @@ int32_t parseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
...
@@ -61,13 +61,13 @@ int32_t parseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
pDcl
->
nodeType
=
info
.
type
;
pDcl
->
nodeType
=
info
.
type
;
}
}
}
else
{
}
else
{
SQueryStmtInfo
*
pQueryInfo
=
c
alloc
(
1
,
sizeof
(
SQueryStmtInfo
)
);
SQueryStmtInfo
*
pQueryInfo
=
c
reateQueryInfo
(
);
if
(
pQueryInfo
==
NULL
)
{
if
(
pQueryInfo
==
NULL
)
{
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
// set correct error code.
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
// set correct error code.
return
terrno
;
return
terrno
;
}
}
int32_t
code
=
qParserValidateSqlNode
(
pCxt
->
ctx
.
pCatalog
,
&
info
,
pQueryInfo
,
pCxt
->
ctx
.
requestId
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
int32_t
code
=
qParserValidateSqlNode
(
&
pCxt
->
ctx
,
&
info
,
pQueryInfo
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
*
pQuery
=
(
SQueryNode
*
)
pQueryInfo
;
*
pQuery
=
(
SQueryNode
*
)
pQueryInfo
;
}
}
...
@@ -89,7 +89,7 @@ int32_t qParserConvertSql(const char* pStr, size_t length, char** pConvertSql) {
...
@@ -89,7 +89,7 @@ int32_t qParserConvertSql(const char* pStr, size_t length, char** pConvertSql) {
return
0
;
return
0
;
}
}
static
int32_t
getTableNameFromSqlNode
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
SMsgBuf
*
pMsgBuf
);
static
int32_t
getTableNameFromSqlNode
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
S
ParseBasicCtx
*
pCtx
,
S
MsgBuf
*
pMsgBuf
);
static
int32_t
tnameComparFn
(
const
void
*
p1
,
const
void
*
p2
)
{
static
int32_t
tnameComparFn
(
const
void
*
p1
,
const
void
*
p2
)
{
SName
*
pn1
=
(
SName
*
)
p1
;
SName
*
pn1
=
(
SName
*
)
p1
;
...
@@ -113,7 +113,7 @@ static int32_t tnameComparFn(const void* p1, const void* p2) {
...
@@ -113,7 +113,7 @@ static int32_t tnameComparFn(const void* p1, const void* p2) {
}
}
}
}
static
int32_t
getTableNameFromSubquery
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
SMsgBuf
*
pMsgBuf
)
{
static
int32_t
getTableNameFromSubquery
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
S
ParseBasicCtx
*
pCtx
,
S
MsgBuf
*
pMsgBuf
)
{
int32_t
numOfSub
=
(
int32_t
)
taosArrayGetSize
(
pSqlNode
->
from
->
list
);
int32_t
numOfSub
=
(
int32_t
)
taosArrayGetSize
(
pSqlNode
->
from
->
list
);
for
(
int32_t
j
=
0
;
j
<
numOfSub
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfSub
;
++
j
)
{
...
@@ -123,12 +123,12 @@ static int32_t getTableNameFromSubquery(SSqlNode* pSqlNode, SArray* tableNameLis
...
@@ -123,12 +123,12 @@ static int32_t getTableNameFromSubquery(SSqlNode* pSqlNode, SArray* tableNameLis
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SSqlNode
*
p
=
taosArrayGetP
(
sub
->
pSubquery
->
node
,
i
);
SSqlNode
*
p
=
taosArrayGetP
(
sub
->
pSubquery
->
node
,
i
);
if
(
p
->
from
->
type
==
SQL_FROM_NODE_TABLES
)
{
if
(
p
->
from
->
type
==
SQL_FROM_NODE_TABLES
)
{
int32_t
code
=
getTableNameFromSqlNode
(
p
,
tableNameList
,
pMsgBuf
);
int32_t
code
=
getTableNameFromSqlNode
(
p
,
tableNameList
,
p
Ctx
,
p
MsgBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
}
else
{
}
else
{
getTableNameFromSubquery
(
p
,
tableNameList
,
pMsgBuf
);
getTableNameFromSubquery
(
p
,
tableNameList
,
p
Ctx
,
p
MsgBuf
);
}
}
}
}
}
}
...
@@ -136,7 +136,7 @@ static int32_t getTableNameFromSubquery(SSqlNode* pSqlNode, SArray* tableNameLis
...
@@ -136,7 +136,7 @@ static int32_t getTableNameFromSubquery(SSqlNode* pSqlNode, SArray* tableNameLis
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
getTableNameFromSqlNode
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
SMsgBuf
*
pMsgBuf
)
{
int32_t
getTableNameFromSqlNode
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
S
ParseBasicCtx
*
pParseCtx
,
S
MsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"invalid table name"
;
const
char
*
msg1
=
"invalid table name"
;
int32_t
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pSqlNode
->
from
->
list
);
int32_t
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pSqlNode
->
from
->
list
);
...
@@ -155,7 +155,11 @@ int32_t getTableNameFromSqlNode(SSqlNode* pSqlNode, SArray* tableNameList, SMsgB
...
@@ -155,7 +155,11 @@ int32_t getTableNameFromSqlNode(SSqlNode* pSqlNode, SArray* tableNameList, SMsgB
}
}
SName
name
=
{
0
};
SName
name
=
{
0
};
strndequote
(
name
.
tname
,
t
->
z
,
t
->
n
);
int32_t
code
=
createSName
(
&
name
,
t
,
pParseCtx
,
pMsgBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
taosArrayPush
(
tableNameList
,
&
name
);
taosArrayPush
(
tableNameList
,
&
name
);
}
}
...
@@ -166,7 +170,7 @@ static void freePtrElem(void* p) {
...
@@ -166,7 +170,7 @@ static void freePtrElem(void* p) {
tfree
(
*
(
char
**
)
p
);
tfree
(
*
(
char
**
)
p
);
}
}
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
SCatalogReq
*
pMetaInfo
,
char
*
msg
,
int32_t
msgBufLen
)
{
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
SCatalogReq
*
pMetaInfo
,
SParseBasicCtx
*
pCtx
,
char
*
msg
,
int32_t
msgBufLen
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SMsgBuf
msgBuf
=
{.
buf
=
msg
,
.
len
=
msgBufLen
};
SMsgBuf
msgBuf
=
{.
buf
=
msg
,
.
len
=
msgBufLen
};
...
@@ -182,12 +186,12 @@ int32_t qParserExtractRequestedMetaInfo(const SSqlInfo* pSqlInfo, SCatalogReq* p
...
@@ -182,12 +186,12 @@ int32_t qParserExtractRequestedMetaInfo(const SSqlInfo* pSqlInfo, SCatalogReq* p
// load the table meta in the FROM clause
// load the table meta in the FROM clause
if
(
pSqlNode
->
from
->
type
==
SQL_FROM_NODE_TABLES
)
{
if
(
pSqlNode
->
from
->
type
==
SQL_FROM_NODE_TABLES
)
{
code
=
getTableNameFromSqlNode
(
pSqlNode
,
pMetaInfo
->
pTableName
,
&
msgBuf
);
code
=
getTableNameFromSqlNode
(
pSqlNode
,
pMetaInfo
->
pTableName
,
pCtx
,
&
msgBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
}
else
{
}
else
{
code
=
getTableNameFromSubquery
(
pSqlNode
,
pMetaInfo
->
pTableName
,
&
msgBuf
);
code
=
getTableNameFromSubquery
(
pSqlNode
,
pMetaInfo
->
pTableName
,
pCtx
,
&
msgBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
...
source/libs/parser/test/parserTests.cpp
浏览文件 @
dc98029b
...
@@ -77,12 +77,15 @@ void sqlCheck(const char* sql, bool valid) {
...
@@ -77,12 +77,15 @@ void sqlCheck(const char* sql, bool valid) {
buf
.
len
=
128
;
buf
.
len
=
128
;
buf
.
buf
=
msg
;
buf
.
buf
=
msg
;
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
SSqlNode
*
pNode
=
(
SSqlNode
*
)
taosArrayGetP
(((
SArray
*
)
info1
.
sub
.
node
),
0
);
SSqlNode
*
pNode
=
(
SSqlNode
*
)
taosArrayGetP
(((
SArray
*
)
info1
.
sub
.
node
),
0
);
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -119,7 +122,11 @@ TEST(testCase, validateAST_test) {
...
@@ -119,7 +122,11 @@ TEST(testCase, validateAST_test) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -177,7 +184,11 @@ TEST(testCase, function_Test) {
...
@@ -177,7 +184,11 @@ TEST(testCase, function_Test) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -223,7 +234,11 @@ TEST(testCase, function_Test2) {
...
@@ -223,7 +234,11 @@ TEST(testCase, function_Test2) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -269,7 +284,11 @@ TEST(testCase, function_Test3) {
...
@@ -269,7 +284,11 @@ TEST(testCase, function_Test3) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -314,7 +333,11 @@ TEST(testCase, function_Test4) {
...
@@ -314,7 +333,11 @@ TEST(testCase, function_Test4) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -362,7 +385,11 @@ TEST(testCase, function_Test5) {
...
@@ -362,7 +385,11 @@ TEST(testCase, function_Test5) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -447,7 +474,11 @@ TEST(testCase, function_Test6) {
...
@@ -447,7 +474,11 @@ TEST(testCase, function_Test6) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -525,7 +556,11 @@ TEST(testCase, function_Test6) {
...
@@ -525,7 +556,11 @@ TEST(testCase, function_Test6) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -587,7 +622,11 @@ TEST(testCase, function_Test6) {
...
@@ -587,7 +622,11 @@ TEST(testCase, function_Test6) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -636,7 +675,7 @@ TEST(testCase, function_Test6) {
...
@@ -636,7 +675,7 @@ TEST(testCase, function_Test6) {
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -666,7 +705,10 @@ TEST(testCase, function_Test6) {
...
@@ -666,7 +705,10 @@ TEST(testCase, function_Test6) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -688,7 +730,7 @@ TEST(testCase, function_Test6) {
...
@@ -688,7 +730,7 @@ TEST(testCase, function_Test6) {
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
source/libs/parser/test/plannerTest.cpp
浏览文件 @
dc98029b
...
@@ -81,7 +81,8 @@ void generateLogicplan(const char* sql) {
...
@@ -81,7 +81,8 @@ void generateLogicplan(const char* sql) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
@@ -121,7 +122,9 @@ TEST(testCase, planner_test) {
...
@@ -121,7 +122,9 @@ TEST(testCase, planner_test) {
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
source/libs/parser/test/tokenizerTest.cpp
浏览文件 @
dc98029b
...
@@ -710,7 +710,11 @@ TEST(testCase, extractMeta_test) {
...
@@ -710,7 +710,11 @@ TEST(testCase, extractMeta_test) {
char
msg
[
128
]
=
{
0
};
char
msg
[
128
]
=
{
0
};
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
SParseBasicCtx
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
source/libs/planner/inc/plannerInt.h
浏览文件 @
dc98029b
...
@@ -53,8 +53,8 @@ typedef struct SQueryDistPlanNodeInfo {
...
@@ -53,8 +53,8 @@ typedef struct SQueryDistPlanNodeInfo {
typedef
struct
SQueryTableInfo
{
typedef
struct
SQueryTableInfo
{
char
*
tableName
;
// to be deleted
char
*
tableName
;
// to be deleted
uint64_t
uid
;
// to be deleted
uint64_t
uid
;
// to be deleted
STableMetaInfo
*
pMeta
;
STableMetaInfo
*
pMeta
;
STimeWindow
window
;
STimeWindow
window
;
}
SQueryTableInfo
;
}
SQueryTableInfo
;
typedef
struct
SQueryPlanNode
{
typedef
struct
SQueryPlanNode
{
...
...
source/libs/planner/src/logicPlan.c
浏览文件 @
dc98029b
...
@@ -64,10 +64,11 @@ static int32_t createModificationOpPlan(const SQueryNode* pNode, SQueryPlanNode*
...
@@ -64,10 +64,11 @@ static int32_t createModificationOpPlan(const SQueryNode* pNode, SQueryPlanNode*
}
}
int32_t
createSelectPlan
(
const
SQueryStmtInfo
*
pSelect
,
SQueryPlanNode
**
pQueryPlan
)
{
int32_t
createSelectPlan
(
const
SQueryStmtInfo
*
pSelect
,
SQueryPlanNode
**
pQueryPlan
)
{
SArray
*
upstream
=
createQueryPlanImpl
(
pSelect
);
SArray
*
pDownstream
=
createQueryPlanImpl
(
pSelect
);
assert
(
taosArrayGetSize
(
upstream
)
==
1
);
assert
(
taosArrayGetSize
(
pDownstream
)
==
1
);
*
pQueryPlan
=
taosArrayGetP
(
upstream
,
0
);
taosArrayDestroy
(
upstream
);
*
pQueryPlan
=
taosArrayGetP
(
pDownstream
,
0
);
taosArrayDestroy
(
pDownstream
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -100,23 +101,21 @@ void destroyQueryPlan(SQueryPlanNode* pQueryNode) {
...
@@ -100,23 +101,21 @@ void destroyQueryPlan(SQueryPlanNode* pQueryNode) {
//======================================================================================================================
//======================================================================================================================
static
SQueryPlanNode
*
createQueryNode
(
int32_t
type
,
const
char
*
name
,
SQueryPlanNode
**
p
rev
,
int32_t
numOfPrev
,
static
SQueryPlanNode
*
createQueryNode
(
int32_t
type
,
const
char
*
name
,
SQueryPlanNode
**
p
ChildrenNode
,
int32_t
numOfChildren
,
SExprInfo
**
pExpr
,
int32_t
numOfOutput
,
const
void
*
pExtInfo
)
{
SExprInfo
**
pExpr
,
int32_t
numOfOutput
,
const
void
*
pExtInfo
)
{
SQueryPlanNode
*
pNode
=
calloc
(
1
,
sizeof
(
SQueryPlanNode
));
SQueryPlanNode
*
pNode
=
calloc
(
1
,
sizeof
(
SQueryPlanNode
));
pNode
->
info
.
type
=
type
;
pNode
->
info
.
type
=
type
;
pNode
->
info
.
name
=
strdup
(
name
);
pNode
->
info
.
name
=
strdup
(
name
);
pNode
->
numOfExpr
=
numOfOutput
;
pNode
->
numOfExpr
=
numOfOutput
;
pNode
->
pExpr
=
taosArrayInit
(
numOfOutput
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
pNode
->
pExpr
=
taosArrayInit
(
numOfOutput
,
POINTER_BYTES
);
taosArrayPush
(
pNode
->
pExpr
,
&
pExpr
[
i
]
);
taosArrayAddBatch
(
pNode
->
pExpr
,
pExpr
,
numOfOutput
);
}
assert
(
pNode
->
numOfExpr
==
numOfOutput
);
pNode
->
pChildren
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pNode
->
pChildren
=
taosArrayInit
(
4
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
numOf
Prev
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOf
Children
;
++
i
)
{
taosArrayPush
(
pNode
->
pChildren
,
&
p
rev
[
i
]);
taosArrayPush
(
pNode
->
pChildren
,
&
p
ChildrenNode
[
i
]);
}
}
switch
(
type
)
{
switch
(
type
)
{
...
@@ -184,8 +183,7 @@ static SQueryPlanNode* createQueryNode(int32_t type, const char* name, SQueryPla
...
@@ -184,8 +183,7 @@ static SQueryPlanNode* createQueryNode(int32_t type, const char* name, SQueryPla
return
pNode
;
return
pNode
;
}
}
static
SQueryPlanNode
*
doAddTableColumnNode
(
const
SQueryStmtInfo
*
pQueryInfo
,
STableMetaInfo
*
pTableMetaInfo
,
SQueryTableInfo
*
info
,
static
SQueryPlanNode
*
doAddTableColumnNode
(
const
SQueryStmtInfo
*
pQueryInfo
,
SQueryTableInfo
*
info
,
SArray
*
pExprs
,
SArray
*
tableCols
)
{
SArray
*
pExprs
,
SArray
*
tableCols
)
{
if
(
pQueryInfo
->
info
.
onlyTagQuery
)
{
if
(
pQueryInfo
->
info
.
onlyTagQuery
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pExprs
);
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pExprs
);
SQueryPlanNode
*
pNode
=
createQueryNode
(
QNODE_TAGSCAN
,
"TableTagScan"
,
NULL
,
0
,
pExprs
->
pData
,
num
,
info
);
SQueryPlanNode
*
pNode
=
createQueryNode
(
QNODE_TAGSCAN
,
"TableTagScan"
,
NULL
,
0
,
pExprs
->
pData
,
num
,
info
);
...
@@ -193,16 +191,12 @@ static SQueryPlanNode* doAddTableColumnNode(const SQueryStmtInfo* pQueryInfo, ST
...
@@ -193,16 +191,12 @@ static SQueryPlanNode* doAddTableColumnNode(const SQueryStmtInfo* pQueryInfo, ST
if
(
pQueryInfo
->
info
.
distinct
)
{
if
(
pQueryInfo
->
info
.
distinct
)
{
pNode
=
createQueryNode
(
QNODE_DISTINCT
,
"Distinct"
,
&
pNode
,
1
,
pExprs
->
pData
,
num
,
NULL
);
pNode
=
createQueryNode
(
QNODE_DISTINCT
,
"Distinct"
,
&
pNode
,
1
,
pExprs
->
pData
,
num
,
NULL
);
}
}
return
pNode
;
return
pNode
;
}
}
SQueryPlanNode
*
pNode
=
createQueryNode
(
QNODE_TABLESCAN
,
"TableScan"
,
NULL
,
0
,
NULL
,
0
,
info
);
SQueryPlanNode
*
pNode
=
createQueryNode
(
QNODE_TABLESCAN
,
"TableScan"
,
NULL
,
0
,
NULL
,
0
,
info
);
if
(
pQueryInfo
->
info
.
projectionQuery
)
{
if
(
!
pQueryInfo
->
info
.
projectionQuery
)
{
int32_t
numOfOutput
=
(
int32_t
)
taosArrayGetSize
(
pExprs
);
pNode
=
createQueryNode
(
QNODE_PROJECT
,
"Projection"
,
&
pNode
,
1
,
pExprs
->
pData
,
numOfOutput
,
NULL
);
}
else
{
STableMetaInfo
*
pTableMetaInfo1
=
getMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo1
=
getMetaInfo
(
pQueryInfo
,
0
);
// table source column projection, generate the projection expr
// table source column projection, generate the projection expr
...
@@ -262,7 +256,11 @@ static SQueryPlanNode* doCreateQueryPlanForSingleTableImpl(const SQueryStmtInfo*
...
@@ -262,7 +256,11 @@ static SQueryPlanNode* doCreateQueryPlanForSingleTableImpl(const SQueryStmtInfo*
pNode
=
createQueryNode
(
QNODE_AGGREGATE
,
"Aggregate"
,
&
pNode
,
1
,
p
->
pData
,
num
,
NULL
);
pNode
=
createQueryNode
(
QNODE_AGGREGATE
,
"Aggregate"
,
&
pNode
,
1
,
p
->
pData
,
num
,
NULL
);
}
}
}
else
{
}
else
{
pNode
=
createQueryNode
(
QNODE_PROJECT
,
"Projection"
,
&
pNode
,
1
,
p
->
pData
,
num
,
NULL
);
// here we can push down the projection to tablescan operator.
pNode
->
numOfExpr
=
num
;
pNode
->
pExpr
=
taosArrayInit
(
num
,
POINTER_BYTES
);
taosArrayAddAll
(
pNode
->
pExpr
,
p
);
// pNode = createQueryNode(QNODE_PROJECT, "Projection", &pNode, 1, p->pData, num, NULL);
}
}
}
}
...
@@ -299,9 +297,11 @@ static SQueryPlanNode* doCreateQueryPlanForSingleTable(const SQueryStmtInfo* pQu
...
@@ -299,9 +297,11 @@ static SQueryPlanNode* doCreateQueryPlanForSingleTable(const SQueryStmtInfo* pQu
tstrncpy
(
name
,
pTableMetaInfo
->
name
.
tname
,
TSDB_TABLE_FNAME_LEN
);
tstrncpy
(
name
,
pTableMetaInfo
->
name
.
tname
,
TSDB_TABLE_FNAME_LEN
);
SQueryTableInfo
info
=
{.
tableName
=
strdup
(
name
),
.
uid
=
pTableMetaInfo
->
pTableMeta
->
uid
,};
SQueryTableInfo
info
=
{.
tableName
=
strdup
(
name
),
.
uid
=
pTableMetaInfo
->
pTableMeta
->
uid
,};
info
.
window
=
pQueryInfo
->
window
;
info
.
pMeta
=
pTableMetaInfo
;
// handle the only tag query
// handle the only tag query
SQueryPlanNode
*
pNode
=
doAddTableColumnNode
(
pQueryInfo
,
pTableMetaInfo
,
&
info
,
pExprs
,
tableCols
);
SQueryPlanNode
*
pNode
=
doAddTableColumnNode
(
pQueryInfo
,
&
info
,
pExprs
,
tableCols
);
if
(
pQueryInfo
->
info
.
onlyTagQuery
)
{
if
(
pQueryInfo
->
info
.
onlyTagQuery
)
{
tfree
(
info
.
tableName
);
tfree
(
info
.
tableName
);
return
pNode
;
return
pNode
;
...
@@ -326,23 +326,23 @@ static bool isAllAggExpr(SArray* pList) {
...
@@ -326,23 +326,23 @@ static bool isAllAggExpr(SArray* pList) {
}
}
SArray
*
createQueryPlanImpl
(
const
SQueryStmtInfo
*
pQueryInfo
)
{
SArray
*
createQueryPlanImpl
(
const
SQueryStmtInfo
*
pQueryInfo
)
{
SArray
*
up
stream
=
NULL
;
SArray
*
pDown
stream
=
NULL
;
if
(
pQueryInfo
->
p
Upstream
!=
NULL
&&
taosArrayGetSize
(
pQueryInfo
->
pUp
stream
)
>
0
)
{
// subquery in the from clause
if
(
pQueryInfo
->
p
Downstream
!=
NULL
&&
taosArrayGetSize
(
pQueryInfo
->
pDown
stream
)
>
0
)
{
// subquery in the from clause
up
stream
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pDown
stream
=
taosArrayInit
(
4
,
POINTER_BYTES
);
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
p
Up
stream
);
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
p
Down
stream
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SQueryStmtInfo
*
pq
=
taosArrayGet
(
pQueryInfo
->
p
Up
stream
,
i
);
SQueryStmtInfo
*
pq
=
taosArrayGet
(
pQueryInfo
->
p
Down
stream
,
i
);
SArray
*
p
=
createQueryPlanImpl
(
pq
);
SArray
*
p
=
createQueryPlanImpl
(
pq
);
taosArrayAddBatch
(
up
stream
,
p
->
pData
,
(
int32_t
)
taosArrayGetSize
(
p
));
taosArrayAddBatch
(
pDown
stream
,
p
->
pData
,
(
int32_t
)
taosArrayGetSize
(
p
));
}
}
}
}
if
(
pQueryInfo
->
numOfTables
>
1
)
{
// it is a join query
if
(
pQueryInfo
->
numOfTables
>
1
)
{
// it is a join query
// 1. separate the select clause according to table
// 1. separate the select clause according to table
taosArrayDestroy
(
up
stream
);
taosArrayDestroy
(
pDown
stream
);
up
stream
=
taosArrayInit
(
5
,
POINTER_BYTES
);
pDown
stream
=
taosArrayInit
(
5
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
STableMetaInfo
*
pTableMetaInfo
=
pQueryInfo
->
pTableMetaInfo
[
i
];
STableMetaInfo
*
pTableMetaInfo
=
pQueryInfo
->
pTableMetaInfo
[
i
];
...
@@ -365,30 +365,30 @@ SArray* createQueryPlanImpl(const SQueryStmtInfo* pQueryInfo) {
...
@@ -365,30 +365,30 @@ SArray* createQueryPlanImpl(const SQueryStmtInfo* pQueryInfo) {
columnListCopy
(
tableColumnList
,
pQueryInfo
->
colList
,
uid
);
columnListCopy
(
tableColumnList
,
pQueryInfo
->
colList
,
uid
);
// 4. add the projection query node
// 4. add the projection query node
SQueryPlanNode
*
pNode
=
doAddTableColumnNode
(
pQueryInfo
,
pTableMetaInfo
,
&
info
,
exprList
,
tableColumnList
);
SQueryPlanNode
*
pNode
=
doAddTableColumnNode
(
pQueryInfo
,
&
info
,
exprList
,
tableColumnList
);
columnListDestroy
(
tableColumnList
);
columnListDestroy
(
tableColumnList
);
// dropAllExprInfo(exprList);
// dropAllExprInfo(exprList);
taosArrayPush
(
up
stream
,
&
pNode
);
taosArrayPush
(
pDown
stream
,
&
pNode
);
}
}
// 3. add the join node here
// 3. add the join node here
SQueryTableInfo
info
=
{
0
};
SQueryTableInfo
info
=
{
0
};
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pQueryInfo
->
exprList
[
0
]);
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pQueryInfo
->
exprList
[
0
]);
SQueryPlanNode
*
pNode
=
createQueryNode
(
QNODE_JOIN
,
"Join"
,
up
stream
->
pData
,
pQueryInfo
->
numOfTables
,
SQueryPlanNode
*
pNode
=
createQueryNode
(
QNODE_JOIN
,
"Join"
,
pDown
stream
->
pData
,
pQueryInfo
->
numOfTables
,
pQueryInfo
->
exprList
[
0
]
->
pData
,
num
,
NULL
);
pQueryInfo
->
exprList
[
0
]
->
pData
,
num
,
NULL
);
// 4. add the aggregation or projection execution node
// 4. add the aggregation or projection execution node
pNode
=
doCreateQueryPlanForSingleTableImpl
(
pQueryInfo
,
pNode
,
&
info
);
pNode
=
doCreateQueryPlanForSingleTableImpl
(
pQueryInfo
,
pNode
,
&
info
);
up
stream
=
taosArrayInit
(
5
,
POINTER_BYTES
);
pDown
stream
=
taosArrayInit
(
5
,
POINTER_BYTES
);
taosArrayPush
(
up
stream
,
&
pNode
);
taosArrayPush
(
pDown
stream
,
&
pNode
);
}
else
{
// only one table, normal query process
}
else
{
// only one table, normal query process
STableMetaInfo
*
pTableMetaInfo
=
pQueryInfo
->
pTableMetaInfo
[
0
];
STableMetaInfo
*
pTableMetaInfo
=
pQueryInfo
->
pTableMetaInfo
[
0
];
SQueryPlanNode
*
pNode
=
doCreateQueryPlanForSingleTable
(
pQueryInfo
,
pTableMetaInfo
,
pQueryInfo
->
exprList
[
0
],
pQueryInfo
->
colList
);
SQueryPlanNode
*
pNode
=
doCreateQueryPlanForSingleTable
(
pQueryInfo
,
pTableMetaInfo
,
pQueryInfo
->
exprList
[
0
],
pQueryInfo
->
colList
);
up
stream
=
taosArrayInit
(
5
,
POINTER_BYTES
);
pDown
stream
=
taosArrayInit
(
5
,
POINTER_BYTES
);
taosArrayPush
(
up
stream
,
&
pNode
);
taosArrayPush
(
pDown
stream
,
&
pNode
);
}
}
return
up
stream
;
return
pDown
stream
;
}
}
static
void
doDestroyQueryNode
(
SQueryPlanNode
*
pQueryNode
)
{
static
void
doDestroyQueryNode
(
SQueryPlanNode
*
pQueryNode
)
{
...
@@ -434,22 +434,23 @@ static int32_t doPrintPlan(char* buf, SQueryPlanNode* pQueryNode, int32_t level,
...
@@ -434,22 +434,23 @@ static int32_t doPrintPlan(char* buf, SQueryPlanNode* pQueryNode, int32_t level,
switch
(
pQueryNode
->
info
.
type
)
{
switch
(
pQueryNode
->
info
.
type
)
{
case
QNODE_TABLESCAN
:
{
case
QNODE_TABLESCAN
:
{
SQueryTableInfo
*
pInfo
=
(
SQueryTableInfo
*
)
pQueryNode
->
pExtInfo
;
SQueryTableInfo
*
pInfo
=
(
SQueryTableInfo
*
)
pQueryNode
->
pExtInfo
;
len1
=
sprintf
(
buf
+
len
,
"%s #%"
PRIu64
") time_range: %"
PRId64
" - %"
PRId64
,
pInfo
->
tableName
,
pInfo
->
uid
,
len1
=
sprintf
(
buf
+
len
,
"%s #%"
PRIu64
,
pInfo
->
tableName
,
pInfo
->
uid
);
pInfo
->
window
.
skey
,
pInfo
->
window
.
ekey
);
assert
(
len1
>
0
);
assert
(
len1
>
0
);
len
+=
len1
;
len
+=
len1
;
for
(
int32_t
i
=
0
;
i
<
pQueryNode
->
numOfExpr
;
++
i
)
{
len1
=
sprintf
(
buf
+
len
,
" , cols:"
);
SColumn
*
pCol
=
taosArrayGetP
(
pQueryNode
->
pExpr
,
i
);
assert
(
len1
>
0
);
len1
=
sprintf
(
buf
+
len
,
" [%s #%d] "
,
pCol
->
name
,
pCol
->
info
.
colId
);
len
+=
len1
;
assert
(
len1
>
0
);
len
+=
len1
;
}
len1
=
sprintf
(
buf
+
len
,
"
\n
"
);
len
=
printExprInfo
(
buf
,
pQueryNode
,
len
);
len1
=
sprintf
(
buf
+
len
,
")"
);
assert
(
len1
>
0
);
assert
(
len1
>
0
);
// todo print filter info
len1
=
sprintf
(
buf
+
len
,
") filters:(nil)"
);
len
+=
len1
;
len1
=
sprintf
(
buf
+
len
,
" time_range: %"
PRId64
" - %"
PRId64
"
\n
"
,
pInfo
->
window
.
skey
,
pInfo
->
window
.
ekey
);
len
+=
len1
;
len
+=
len1
;
break
;
break
;
}
}
...
...
source/libs/planner/src/physicalPlan.c
浏览文件 @
dc98029b
...
@@ -187,7 +187,8 @@ static SSubplan* initSubplan(SPlanContext* pCxt, int32_t type) {
...
@@ -187,7 +187,8 @@ static SSubplan* initSubplan(SPlanContext* pCxt, int32_t type) {
SSubplan
*
subplan
=
validPointer
(
calloc
(
1
,
sizeof
(
SSubplan
)));
SSubplan
*
subplan
=
validPointer
(
calloc
(
1
,
sizeof
(
SSubplan
)));
subplan
->
id
=
pCxt
->
nextId
;
subplan
->
id
=
pCxt
->
nextId
;
++
(
pCxt
->
nextId
.
subplanId
);
++
(
pCxt
->
nextId
.
subplanId
);
subplan
->
type
=
type
;
subplan
->
type
=
type
;
subplan
->
level
=
0
;
subplan
->
level
=
0
;
if
(
NULL
!=
pCxt
->
pCurrentSubplan
)
{
if
(
NULL
!=
pCxt
->
pCurrentSubplan
)
{
subplan
->
level
=
pCxt
->
pCurrentSubplan
->
level
+
1
;
subplan
->
level
=
pCxt
->
pCurrentSubplan
->
level
+
1
;
...
@@ -275,6 +276,8 @@ static SPhyNode* createPhyNode(SPlanContext* pCxt, SQueryPlanNode* pPlanNode) {
...
@@ -275,6 +276,8 @@ static SPhyNode* createPhyNode(SPlanContext* pCxt, SQueryPlanNode* pPlanNode) {
case
QNODE_TABLESCAN
:
case
QNODE_TABLESCAN
:
node
=
createTableScanNode
(
pCxt
,
pPlanNode
);
node
=
createTableScanNode
(
pCxt
,
pPlanNode
);
break
;
break
;
case
QNODE_PROJECT
:
// node = create
case
QNODE_MODIFY
:
case
QNODE_MODIFY
:
// Insert is not an operator in a physical plan.
// Insert is not an operator in a physical plan.
break
;
break
;
...
@@ -335,7 +338,7 @@ int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryD
...
@@ -335,7 +338,7 @@ int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryD
.
pCatalog
=
pCatalog
,
.
pCatalog
=
pCatalog
,
.
pDag
=
validPointer
(
calloc
(
1
,
sizeof
(
SQueryDag
))),
.
pDag
=
validPointer
(
calloc
(
1
,
sizeof
(
SQueryDag
))),
.
pCurrentSubplan
=
NULL
,
.
pCurrentSubplan
=
NULL
,
.
nextId
=
{
0
}
// todo queryid
.
nextId
=
{
.
queryId
=
requestId
},
};
};
*
pDag
=
context
.
pDag
;
*
pDag
=
context
.
pDag
;
...
...
source/libs/planner/src/physicalPlanJson.c
浏览文件 @
dc98029b
...
@@ -230,9 +230,11 @@ static bool columnInfoToJson(const void* obj, cJSON* jCol) {
...
@@ -230,9 +230,11 @@ static bool columnInfoToJson(const void* obj, cJSON* jCol) {
if
(
res
)
{
if
(
res
)
{
res
=
cJSON_AddNumberToObject
(
jCol
,
jkColumnInfoBytes
,
col
->
bytes
);
res
=
cJSON_AddNumberToObject
(
jCol
,
jkColumnInfoBytes
,
col
->
bytes
);
}
}
if
(
res
)
{
res
=
addRawArray
(
jCol
,
jkColumnInfoFilterList
,
columnFilterInfoToJson
,
col
->
flist
.
filterInfo
,
sizeof
(
SColumnFilterInfo
),
col
->
flist
.
numOfFilters
);
if
(
res
)
{
// TODO: temporarily disable it
// res = addRawArray(jCol, jkColumnInfoFilterList, columnFilterInfoToJson, col->flist.filterInfo, sizeof(SColumnFilterInfo), col->flist.numOfFilters);
}
}
return
res
;
return
res
;
}
}
...
@@ -794,7 +796,6 @@ static cJSON* subplanToJson(const SSubplan* subplan) {
...
@@ -794,7 +796,6 @@ static cJSON* subplanToJson(const SSubplan* subplan) {
}
}
// The 'type', 'level', 'execEpSet', 'pChildren' and 'pParents' fields do not need to be serialized.
// The 'type', 'level', 'execEpSet', 'pChildren' and 'pParents' fields do not need to be serialized.
bool
res
=
addObject
(
jSubplan
,
jkSubplanId
,
subplanIdToJson
,
&
subplan
->
id
);
bool
res
=
addObject
(
jSubplan
,
jkSubplanId
,
subplanIdToJson
,
&
subplan
->
id
);
if
(
res
)
{
if
(
res
)
{
res
=
addObject
(
jSubplan
,
jkSubplanNode
,
phyNodeToJson
,
subplan
->
pNode
);
res
=
addObject
(
jSubplan
,
jkSubplanNode
,
phyNodeToJson
,
subplan
->
pNode
);
...
@@ -807,6 +808,7 @@ static cJSON* subplanToJson(const SSubplan* subplan) {
...
@@ -807,6 +808,7 @@ static cJSON* subplanToJson(const SSubplan* subplan) {
cJSON_Delete
(
jSubplan
);
cJSON_Delete
(
jSubplan
);
return
NULL
;
return
NULL
;
}
}
return
jSubplan
;
return
jSubplan
;
}
}
...
...
source/libs/planner/src/planner.c
浏览文件 @
dc98029b
...
@@ -64,6 +64,13 @@ int32_t qCreateQueryDag(const struct SQueryNode* pNode, struct SQueryDag** pDag,
...
@@ -64,6 +64,13 @@ int32_t qCreateQueryDag(const struct SQueryNode* pNode, struct SQueryDag** pDag,
return
code
;
return
code
;
}
}
//
if
(
logicPlan
->
info
.
type
!=
QNODE_MODIFY
)
{
// char* str = NULL;
// queryPlanToString(logicPlan, &str);
// printf("%s\n", str);
}
code
=
optimizeQueryPlan
(
logicPlan
);
code
=
optimizeQueryPlan
(
logicPlan
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
destroyQueryPlan
(
logicPlan
);
destroyQueryPlan
(
logicPlan
);
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
dc98029b
...
@@ -88,7 +88,6 @@ int32_t schBuildTaskRalation(SSchJob *job, SHashObj *planToTask) {
...
@@ -88,7 +88,6 @@ int32_t schBuildTaskRalation(SSchJob *job, SHashObj *planToTask) {
SCH_ERR_RET
(
TSDB_CODE_SCH_INTERNAL_ERROR
);
SCH_ERR_RET
(
TSDB_CODE_SCH_INTERNAL_ERROR
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -248,19 +247,20 @@ int32_t schSetTaskCandidateAddrs(SSchJob *job, SSchTask *task) {
...
@@ -248,19 +247,20 @@ int32_t schSetTaskCandidateAddrs(SSchJob *job, SSchTask *task) {
}
}
int32_t
addNum
=
0
;
int32_t
addNum
=
0
;
int32_t
nodeNum
=
taosArrayGetSize
(
job
->
nodeList
);
if
(
job
->
nodeList
)
{
for
(
int32_t
i
=
0
;
i
<
nodeNum
&&
addNum
<
SCH_MAX_CONDIDATE_EP_NUM
;
++
i
)
{
int32_t
nodeNum
=
(
int32_t
)
taosArrayGetSize
(
job
->
nodeList
);
SQueryNodeAddr
*
naddr
=
taosArrayGet
(
job
->
nodeList
,
i
);
for
(
int32_t
i
=
0
;
i
<
nodeNum
&&
addNum
<
SCH_MAX_CONDIDATE_EP_NUM
;
++
i
)
{
SQueryNodeAddr
*
naddr
=
taosArrayGet
(
job
->
nodeList
,
i
);
if
(
NULL
==
taosArrayPush
(
task
->
candidateAddrs
,
&
task
->
plan
->
execNode
))
{
qError
(
"taosArrayPush failed"
);
if
(
NULL
==
taosArrayPush
(
task
->
candidateAddrs
,
&
task
->
plan
->
execNode
))
{
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
qError
(
"taosArrayPush failed"
);
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
++
addNum
;
}
}
++
addNum
;
}
}
/*
/*
for (int32_t i = 0; i < job->dataSrcEps.numOfEps && addNum < SCH_MAX_CONDIDATE_EP_NUM; ++i) {
for (int32_t i = 0; i < job->dataSrcEps.numOfEps && addNum < SCH_MAX_CONDIDATE_EP_NUM; ++i) {
strncpy(epSet->fqdn[epSet->numOfEps], job->dataSrcEps.fqdn[i], sizeof(job->dataSrcEps.fqdn[i]));
strncpy(epSet->fqdn[epSet->numOfEps], job->dataSrcEps.fqdn[i], sizeof(job->dataSrcEps.fqdn[i]));
...
@@ -279,8 +279,7 @@ int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask) {
...
@@ -279,8 +279,7 @@ int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask) {
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
qDebug
(
"add one task, taskId:0x%"
PRIx64
", numOfTasks:%d, reqId:0x%"
PRIx64
,
pTask
->
taskId
,
taosHashGetSize
(
pJob
->
execTasks
),
qDebug
(
"add one task, taskId:0x%"
PRIx64
", numOfTasks:%d, reqId:0x%"
PRIx64
,
pTask
->
taskId
,
taosHashGetSize
(
pJob
->
execTasks
),
pJob
->
queryId
);
pJob
->
queryId
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -997,7 +996,7 @@ int32_t scheduleExecJob(void *transport, SArray *nodeList, SQueryDag* pDag, void
...
@@ -997,7 +996,7 @@ int32_t scheduleExecJob(void *transport, SArray *nodeList, SQueryDag* pDag, void
}
}
int32_t
scheduleAsyncExecJob
(
void
*
transport
,
SArray
*
nodeList
,
SQueryDag
*
pDag
,
void
**
pJob
)
{
int32_t
scheduleAsyncExecJob
(
void
*
transport
,
SArray
*
nodeList
,
SQueryDag
*
pDag
,
void
**
pJob
)
{
if
(
NULL
==
transport
||
NULL
==
nodeList
||
NULL
==
pDag
||
NULL
==
pDag
->
pSubplans
||
NULL
==
pJob
)
{
if
(
NULL
==
transport
||
/*NULL == nodeList || */
NULL
==
pDag
||
NULL
==
pDag
->
pSubplans
||
NULL
==
pJob
)
{
SCH_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
SCH_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
}
...
...
source/util/src/terror.c
浏览文件 @
dc98029b
...
@@ -259,26 +259,22 @@ TAOS_DEFINE_ERROR(TSDB_CODE_DND_DNODE_READ_FILE_ERROR, "Read dnode.json error
...
@@ -259,26 +259,22 @@ TAOS_DEFINE_ERROR(TSDB_CODE_DND_DNODE_READ_FILE_ERROR, "Read dnode.json error
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_DNODE_WRITE_FILE_ERROR
,
"Write dnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_DNODE_WRITE_FILE_ERROR
,
"Write dnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED
,
"Mnode already deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED
,
"Mnode already deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
,
"Mnode not deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
,
"Mnode not deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MNODE_ID_INVALID
,
"Mnode Id invalid"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MNODE_INVALID_OPTION
,
"Mnode option invalid"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MNODE_ID_NOT_FOUND
,
"Mnode Id not found"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MNODE_READ_FILE_ERROR
,
"Read mnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MNODE_READ_FILE_ERROR
,
"Read mnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR
,
"Write mnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR
,
"Write mnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
,
"Qnode already deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
,
"Qnode already deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
,
"Qnode not deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
,
"Qnode not deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_QNODE_ID_INVALID
,
"Qnode Id invalid"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_QNODE_INVALID_OPTION
,
"Qnode option invalid"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_QNODE_ID_NOT_FOUND
,
"Qnode Id not found"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_QNODE_READ_FILE_ERROR
,
"Read qnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_QNODE_READ_FILE_ERROR
,
"Read qnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR
,
"Write qnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR
,
"Write qnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
,
"Snode already deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
,
"Snode already deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
,
"Snode not deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
,
"Snode not deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_SNODE_ID_INVALID
,
"Snode Id invalid"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_SNODE_INVALID_OPTION
,
"Snode option invalid"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_SNODE_ID_NOT_FOUND
,
"Snode Id not found"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_SNODE_READ_FILE_ERROR
,
"Read snode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_SNODE_READ_FILE_ERROR
,
"Read snode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR
,
"Write snode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR
,
"Write snode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
,
"Bnode already deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
,
"Bnode already deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
,
"Bnode not deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
,
"Bnode not deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_BNODE_ID_INVALID
,
"Bnode Id invalid"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_BNODE_INVALID_OPTION
,
"Bnode option invalid"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_BNODE_ID_NOT_FOUND
,
"Bnode Id not found"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_BNODE_READ_FILE_ERROR
,
"Read bnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_BNODE_READ_FILE_ERROR
,
"Read bnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR
,
"Write bnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR
,
"Write bnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_VNODE_TOO_MANY_VNODES
,
"Too many vnode directories"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_VNODE_TOO_MANY_VNODES
,
"Too many vnode directories"
)
...
...
tests/script/general/table/basic1.sim
浏览文件 @
dc98029b
...
@@ -62,13 +62,12 @@ print $data00 $data01 $data02
...
@@ -62,13 +62,12 @@ print $data00 $data01 $data02
print $data10 $data11 $data22
print $data10 $data11 $data22
print $data20 $data11 $data22
print $data20 $data11 $data22
return
print =============== insert data
print =============== insert data
sql insert into c1 values(now+1s, 1)
sql insert into c1 values(now+1s, 1)
sql insert into c1 values(now+2s, 2)
sql insert into c1 values(now+2s, 2)
sql insert into c1 values(now+3s, 3)
sql insert into c1 values(now+3s, 3)
return
print =============== query data
print =============== query data
sql select * from c1
sql select * from c1
if $rows != 3 then
if $rows != 3 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录