Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
98ce2f57
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看板
提交
98ce2f57
编写于
4月 22, 2022
作者:
C
cpwu
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into cpwu/3.0
上级
bb815260
30647172
变更
62
展开全部
隐藏空白更改
内联
并排
Showing
62 changed file
with
3730 addition
and
5007 deletion
+3730
-5007
include/common/tglobal.h
include/common/tglobal.h
+3
-0
include/common/tmsg.h
include/common/tmsg.h
+1
-3
include/common/ttokendef.h
include/common/ttokendef.h
+90
-88
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+8
-0
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+1
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+2
-2
include/libs/planner/planner.h
include/libs/planner/planner.h
+2
-0
include/util/taoserror.h
include/util/taoserror.h
+4
-0
include/util/tdef.h
include/util/tdef.h
+0
-1
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+15
-12
source/common/src/tglobal.c
source/common/src/tglobal.c
+5
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+3
-2
source/common/src/ttime.c
source/common/src/ttime.c
+1
-1
source/dnode/mgmt/implement/src/dmHandle.c
source/dnode/mgmt/implement/src/dmHandle.c
+26
-23
source/dnode/mgmt/interface/inc/dmDef.h
source/dnode/mgmt/interface/inc/dmDef.h
+2
-1
source/dnode/mnode/impl/src/mndInfoSchema.c
source/dnode/mnode/impl/src/mndInfoSchema.c
+0
-10
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+0
-2
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+2
-2
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+1
-1
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+2
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+2
-0
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+3
-2
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+11
-5
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+22
-10
source/libs/parser/src/parCalcConst.c
source/libs/parser/src/parCalcConst.c
+68
-25
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+1
-1
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+2
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+84
-56
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+15
-7
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2457
-2200
source/libs/planner/inc/planInt.h
source/libs/planner/inc/planInt.h
+4
-0
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+2
-2
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+9
-1
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+6
-8
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+1
-2
source/util/src/tjson.c
source/util/src/tjson.c
+2
-2
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+1
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+6
-15
tests/script/sh/checkValgrind.sh
tests/script/sh/checkValgrind.sh
+2
-1
tests/script/tsim/db/alter_option.sim
tests/script/tsim/db/alter_option.sim
+2
-2
tests/script/tsim/tmq/basic.sim
tests/script/tsim/tmq/basic.sim
+0
-86
tests/script/tsim/tmq/basic1.sim
tests/script/tsim/tmq/basic1.sim
+49
-23
tests/script/tsim/tmq/basic2.sim
tests/script/tsim/tmq/basic2.sim
+219
-0
tests/script/tsim/tmq/basic3.sim
tests/script/tsim/tmq/basic3.sim
+278
-0
tests/script/tsim/tmq/basic4.sim
tests/script/tsim/tmq/basic4.sim
+216
-0
tests/script/tsim/tmq/insertDataV1.sim
tests/script/tsim/tmq/insertDataV1.sim
+0
-44
tests/script/tsim/tmq/insertDataV4.sim
tests/script/tsim/tmq/insertDataV4.sim
+0
-44
tests/script/tsim/tmq/insertFixedDataV2.sim
tests/script/tsim/tmq/insertFixedDataV2.sim
+0
-51
tests/script/tsim/tmq/insertFixedDataV4.sim
tests/script/tsim/tmq/insertFixedDataV4.sim
+0
-51
tests/script/tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim
tests/script/tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim
+0
-269
tests/script/tsim/tmq/main2Con1Cgrp1TopicFrStb.sim
tests/script/tsim/tmq/main2Con1Cgrp1TopicFrStb.sim
+0
-244
tests/script/tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim
tests/script/tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim
+0
-239
tests/script/tsim/tmq/main2Con1Cgrp2TopicFrStb.sim
tests/script/tsim/tmq/main2Con1Cgrp2TopicFrStb.sim
+0
-244
tests/script/tsim/tmq/mainConsumerInMultiTopic.sim
tests/script/tsim/tmq/mainConsumerInMultiTopic.sim
+0
-217
tests/script/tsim/tmq/mainConsumerInOneTopic.sim
tests/script/tsim/tmq/mainConsumerInOneTopic.sim
+0
-246
tests/script/tsim/tmq/multiTopic.sim
tests/script/tsim/tmq/multiTopic.sim
+0
-228
tests/script/tsim/tmq/oneTopic.sim
tests/script/tsim/tmq/oneTopic.sim
+0
-268
tests/script/tsim/tmq/overlapTopic2Con1Cgrp.sim
tests/script/tsim/tmq/overlapTopic2Con1Cgrp.sim
+0
-255
tests/script/tsim/tmq/prepareBasicEnv-1vgrp.sim
tests/script/tsim/tmq/prepareBasicEnv-1vgrp.sim
+2
-2
tests/script/tsim/tmq/prepareBasicEnv-4vgrp.sim
tests/script/tsim/tmq/prepareBasicEnv-4vgrp.sim
+88
-0
tests/script/tsim/valgrind/checkError.sim
tests/script/tsim/valgrind/checkError.sim
+2
-2
tests/test/c/tmqSim.c
tests/test/c/tmqSim.c
+8
-5
未找到文件。
include/common/tglobal.h
浏览文件 @
98ce2f57
...
@@ -94,6 +94,9 @@ extern bool tsRetrieveBlockingModel; // retrieve threads will be blocked
...
@@ -94,6 +94,9 @@ extern bool tsRetrieveBlockingModel; // retrieve threads will be blocked
extern
bool
tsKeepOriginalColumnName
;
extern
bool
tsKeepOriginalColumnName
;
extern
bool
tsDeadLockKillQuery
;
extern
bool
tsDeadLockKillQuery
;
// query client
extern
int32_t
tsQueryPolicy
;
// client
// client
extern
int32_t
tsMaxWildCardsLen
;
extern
int32_t
tsMaxWildCardsLen
;
extern
int32_t
tsMaxRegexStringLen
;
extern
int32_t
tsMaxRegexStringLen
;
...
...
include/common/tmsg.h
浏览文件 @
98ce2f57
...
@@ -1283,15 +1283,13 @@ typedef struct {
...
@@ -1283,15 +1283,13 @@ typedef struct {
}
SMVCreateStreamRsp
,
SMSCreateStreamRsp
;
}
SMVCreateStreamRsp
,
SMSCreateStreamRsp
;
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
name
[
TSDB_TOPIC_FNAME_LEN
];
// accout.topic
int8_t
igExists
;
int8_t
igExists
;
int8_t
withTbName
;
int8_t
withTbName
;
int8_t
withSchema
;
int8_t
withSchema
;
int8_t
withTag
;
int8_t
withTag
;
int8_t
withTagSchema
;
char
*
sql
;
char
*
sql
;
char
*
ast
;
char
*
ast
;
int64_t
subDbUid
;
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
}
SCMCreateTopicReq
;
}
SCMCreateTopicReq
;
...
...
include/common/ttokendef.h
浏览文件 @
98ce2f57
...
@@ -156,87 +156,96 @@
...
@@ -156,87 +156,96 @@
#define TK_INTERVAL 138
#define TK_INTERVAL 138
#define TK_TOPIC 139
#define TK_TOPIC 139
#define TK_AS 140
#define TK_AS 140
#define TK_DESC 141
#define TK_WITH 141
#define TK_DESCRIBE 142
#define TK_SCHEMA 142
#define TK_RESET 143
#define TK_DESC 143
#define TK_QUERY 144
#define TK_DESCRIBE 144
#define TK_EXPLAIN 145
#define TK_RESET 145
#define TK_ANALYZE 146
#define TK_QUERY 146
#define TK_VERBOSE 147
#define TK_EXPLAIN 147
#define TK_NK_BOOL 148
#define TK_ANALYZE 148
#define TK_RATIO 149
#define TK_VERBOSE 149
#define TK_COMPACT 150
#define TK_NK_BOOL 150
#define TK_VNODES 151
#define TK_RATIO 151
#define TK_IN 152
#define TK_COMPACT 152
#define TK_OUTPUTTYPE 153
#define TK_VNODES 153
#define TK_AGGREGATE 154
#define TK_IN 154
#define TK_BUFSIZE 155
#define TK_OUTPUTTYPE 155
#define TK_STREAM 156
#define TK_AGGREGATE 156
#define TK_INTO 157
#define TK_BUFSIZE 157
#define TK_TRIGGER 158
#define TK_STREAM 158
#define TK_AT_ONCE 159
#define TK_INTO 159
#define TK_WINDOW_CLOSE 160
#define TK_TRIGGER 160
#define TK_WATERMARK 161
#define TK_AT_ONCE 161
#define TK_KILL 162
#define TK_WINDOW_CLOSE 162
#define TK_CONNECTION 163
#define TK_WATERMARK 163
#define TK_MERGE 164
#define TK_KILL 164
#define TK_VGROUP 165
#define TK_CONNECTION 165
#define TK_REDISTRIBUTE 166
#define TK_MERGE 166
#define TK_SPLIT 167
#define TK_VGROUP 167
#define TK_SYNCDB 168
#define TK_REDISTRIBUTE 168
#define TK_NULL 169
#define TK_SPLIT 169
#define TK_NK_QUESTION 170
#define TK_SYNCDB 170
#define TK_NK_ARROW 171
#define TK_NULL 171
#define TK_ROWTS 172
#define TK_NK_QUESTION 172
#define TK_TBNAME 173
#define TK_NK_ARROW 173
#define TK_QSTARTTS 174
#define TK_ROWTS 174
#define TK_QENDTS 175
#define TK_TBNAME 175
#define TK_WSTARTTS 176
#define TK_QSTARTTS 176
#define TK_WENDTS 177
#define TK_QENDTS 177
#define TK_WDURATION 178
#define TK_WSTARTTS 178
#define TK_CAST 179
#define TK_WENDTS 179
#define TK_NOW 180
#define TK_WDURATION 180
#define TK_TODAY 181
#define TK_CAST 181
#define TK_TIMEZONE 182
#define TK_NOW 182
#define TK_COUNT 183
#define TK_TODAY 183
#define TK_FIRST 184
#define TK_TIMEZONE 184
#define TK_LAST 185
#define TK_COUNT 185
#define TK_LAST_ROW 186
#define TK_FIRST 186
#define TK_BETWEEN 187
#define TK_LAST 187
#define TK_IS 188
#define TK_LAST_ROW 188
#define TK_NK_LT 189
#define TK_BETWEEN 189
#define TK_NK_GT 190
#define TK_IS 190
#define TK_NK_LE 191
#define TK_NK_LT 191
#define TK_NK_GE 192
#define TK_NK_GT 192
#define TK_NK_NE 193
#define TK_NK_LE 193
#define TK_MATCH 194
#define TK_NK_GE 194
#define TK_NMATCH 195
#define TK_NK_NE 195
#define TK_CONTAINS 196
#define TK_MATCH 196
#define TK_JOIN 197
#define TK_NMATCH 197
#define TK_INNER 198
#define TK_CONTAINS 198
#define TK_SELECT 199
#define TK_JOIN 199
#define TK_DISTINCT 200
#define TK_INNER 200
#define TK_WHERE 201
#define TK_SELECT 201
#define TK_PARTITION 202
#define TK_DISTINCT 202
#define TK_BY 203
#define TK_WHERE 203
#define TK_SESSION 204
#define TK_PARTITION 204
#define TK_STATE_WINDOW 205
#define TK_BY 205
#define TK_SLIDING 206
#define TK_SESSION 206
#define TK_FILL 207
#define TK_STATE_WINDOW 207
#define TK_VALUE 208
#define TK_SLIDING 208
#define TK_NONE 209
#define TK_FILL 209
#define TK_PREV 210
#define TK_VALUE 210
#define TK_LINEAR 211
#define TK_NONE 211
#define TK_NEXT 212
#define TK_PREV 212
#define TK_GROUP 213
#define TK_LINEAR 213
#define TK_HAVING 214
#define TK_NEXT 214
#define TK_ORDER 215
#define TK_GROUP 215
#define TK_SLIMIT 216
#define TK_HAVING 216
#define TK_SOFFSET 217
#define TK_ORDER 217
#define TK_LIMIT 218
#define TK_SLIMIT 218
#define TK_OFFSET 219
#define TK_SOFFSET 219
#define TK_ASC 220
#define TK_LIMIT 220
#define TK_NULLS 221
#define TK_OFFSET 221
#define TK_ASC 222
#define TK_NULLS 223
#define TK_ID 224
#define TK_NK_BITNOT 225
#define TK_INSERT 226
#define TK_VALUES 227
#define TK_IMPORT 228
#define TK_NK_SEMI 229
#define TK_FILE 230
#define TK_NK_SPACE 300
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
#define TK_NK_COMMENT 301
...
@@ -244,13 +253,6 @@
...
@@ -244,13 +253,6 @@
#define TK_NK_HEX 303 // hex number 0x123
#define TK_NK_HEX 303 // hex number 0x123
#define TK_NK_OCT 304 // oct number
#define TK_NK_OCT 304 // oct number
#define TK_NK_BIN 305 // bin format data 0b111
#define TK_NK_BIN 305 // bin format data 0b111
#define TK_NK_FILE 306
#define TK_NK_BITNOT 501
#define TK_INSERT 502
#define TK_VALUES 507
#define TK_IMPORT 509
#define TK_NK_SEMI 508
#define TK_NK_NIL 65535
#define TK_NK_NIL 65535
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
98ce2f57
...
@@ -241,12 +241,20 @@ typedef struct SDropComponentNodeStmt {
...
@@ -241,12 +241,20 @@ typedef struct SDropComponentNodeStmt {
int32_t
dnodeId
;
int32_t
dnodeId
;
}
SDropComponentNodeStmt
;
}
SDropComponentNodeStmt
;
typedef
struct
STopicOptions
{
ENodeType
type
;
bool
withTable
;
bool
withSchema
;
bool
withTag
;
}
STopicOptions
;
typedef
struct
SCreateTopicStmt
{
typedef
struct
SCreateTopicStmt
{
ENodeType
type
;
ENodeType
type
;
char
topicName
[
TSDB_TABLE_NAME_LEN
];
char
topicName
[
TSDB_TABLE_NAME_LEN
];
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
bool
ignoreExists
;
bool
ignoreExists
;
SNode
*
pQuery
;
SNode
*
pQuery
;
STopicOptions
*
pOptions
;
}
SCreateTopicStmt
;
}
SCreateTopicStmt
;
typedef
struct
SDropTopicStmt
{
typedef
struct
SDropTopicStmt
{
...
...
include/libs/nodes/nodes.h
浏览文件 @
98ce2f57
...
@@ -84,6 +84,7 @@ typedef enum ENodeType {
...
@@ -84,6 +84,7 @@ typedef enum ENodeType {
QUERY_NODE_INDEX_OPTIONS
,
QUERY_NODE_INDEX_OPTIONS
,
QUERY_NODE_EXPLAIN_OPTIONS
,
QUERY_NODE_EXPLAIN_OPTIONS
,
QUERY_NODE_STREAM_OPTIONS
,
QUERY_NODE_STREAM_OPTIONS
,
QUERY_NODE_TOPIC_OPTIONS
,
// Statement nodes are used in parser and planner module.
// Statement nodes are used in parser and planner module.
QUERY_NODE_SET_OPERATOR
,
QUERY_NODE_SET_OPERATOR
,
...
...
include/libs/nodes/querynodes.h
浏览文件 @
98ce2f57
...
@@ -237,8 +237,8 @@ typedef struct SSelectStmt {
...
@@ -237,8 +237,8 @@ typedef struct SSelectStmt {
SNodeList
*
pGroupByList
;
// SGroupingSetNode
SNodeList
*
pGroupByList
;
// SGroupingSetNode
SNode
*
pHaving
;
SNode
*
pHaving
;
SNodeList
*
pOrderByList
;
// SOrderByExprNode
SNodeList
*
pOrderByList
;
// SOrderByExprNode
SNode
*
pLimit
;
S
Limit
Node
*
pLimit
;
SNode
*
pSlimit
;
S
Limit
Node
*
pSlimit
;
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
uint8_t
precision
;
uint8_t
precision
;
bool
isEmptyResult
;
bool
isEmptyResult
;
...
...
include/libs/planner/planner.h
浏览文件 @
98ce2f57
...
@@ -35,6 +35,8 @@ typedef struct SPlanContext {
...
@@ -35,6 +35,8 @@ typedef struct SPlanContext {
int8_t
triggerType
;
int8_t
triggerType
;
int64_t
watermark
;
int64_t
watermark
;
bool
isStmtQuery
;
bool
isStmtQuery
;
void
*
pTransporter
;
struct
SCatalog
*
pCatalog
;
}
SPlanContext
;
}
SPlanContext
;
// Create the physical plan for the query, according to the AST.
// Create the physical plan for the query, according to the AST.
...
...
include/util/taoserror.h
浏览文件 @
98ce2f57
...
@@ -615,6 +615,10 @@ int32_t* taosGetErrno();
...
@@ -615,6 +615,10 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2632)
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2632)
#define TSDB_CODE_PAR_ONLY_ONE_JSON_TAG TAOS_DEF_ERROR_CODE(0, 0x2633)
#define TSDB_CODE_PAR_ONLY_ONE_JSON_TAG TAOS_DEF_ERROR_CODE(0, 0x2633)
#define TSDB_CODE_PAR_INCORRECT_NUM_OF_COL TAOS_DEF_ERROR_CODE(0, 0x2634)
#define TSDB_CODE_PAR_INCORRECT_NUM_OF_COL TAOS_DEF_ERROR_CODE(0, 0x2634)
#define TSDB_CODE_PAR_INCORRECT_TIMESTAMP_VAL TAOS_DEF_ERROR_CODE(0, 0x2635)
#define TSDB_CODE_PAR_INVALID_DAYS_VALUE TAOS_DEF_ERROR_CODE(0, 0x2636)
#define TSDB_CODE_PAR_OFFSET_LESS_ZERO TAOS_DEF_ERROR_CODE(0, 0x2637)
#define TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY TAOS_DEF_ERROR_CODE(0, 0x2638)
//planner
//planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
...
...
include/util/tdef.h
浏览文件 @
98ce2f57
...
@@ -118,7 +118,6 @@ extern const int32_t TYPE_BYTES[15];
...
@@ -118,7 +118,6 @@ extern const int32_t TYPE_BYTES[15];
#define TSDB_INS_TABLE_USER_USERS "user_users"
#define TSDB_INS_TABLE_USER_USERS "user_users"
#define TSDB_INS_TABLE_LICENCES "grants"
#define TSDB_INS_TABLE_LICENCES "grants"
#define TSDB_INS_TABLE_VGROUPS "vgroups"
#define TSDB_INS_TABLE_VGROUPS "vgroups"
#define TSDB_INS_TABLE_TOPICS "topics"
#define TSDB_INS_TABLE_CONSUMERS "consumers"
#define TSDB_INS_TABLE_CONSUMERS "consumers"
#define TSDB_INS_TABLE_SUBSCRIBES "subscribes"
#define TSDB_INS_TABLE_SUBSCRIBES "subscribes"
#define TSDB_INS_TABLE_TRANS "trans"
#define TSDB_INS_TABLE_TRANS "trans"
...
...
source/client/src/clientImpl.c
浏览文件 @
98ce2f57
...
@@ -226,14 +226,17 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
...
@@ -226,14 +226,17 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
int32_t
getPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SQueryPlan
**
pPlan
,
SArray
*
pNodeList
)
{
int32_t
getPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SQueryPlan
**
pPlan
,
SArray
*
pNodeList
)
{
pRequest
->
type
=
pQuery
->
msgType
;
pRequest
->
type
=
pQuery
->
msgType
;
SPlanContext
cxt
=
{.
queryId
=
pRequest
->
requestId
,
SPlanContext
cxt
=
{
.
acctId
=
pRequest
->
pTscObj
->
acctId
,
.
queryId
=
pRequest
->
requestId
,
.
mgmtEpSet
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
),
.
acctId
=
pRequest
->
pTscObj
->
acctId
,
.
pAstRoot
=
pQuery
->
pRoot
,
.
mgmtEpSet
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
),
.
showRewrite
=
pQuery
->
showRewrite
};
.
pAstRoot
=
pQuery
->
pRoot
,
int32_t
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
.
showRewrite
=
pQuery
->
showRewrite
,
if
(
code
!=
0
)
{
.
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
return
code
;
};
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
cxt
.
pCatalog
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
}
}
return
code
;
return
code
;
}
}
...
@@ -302,8 +305,6 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
...
@@ -302,8 +305,6 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
}
}
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
)
{
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
)
{
SArray
*
pNodeList
=
taosArrayInit
(
4
,
sizeof
(
struct
SQueryNodeAddr
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
switch
(
pQuery
->
execMode
)
{
switch
(
pQuery
->
execMode
)
{
case
QUERY_EXEC_MODE_LOCAL
:
case
QUERY_EXEC_MODE_LOCAL
:
...
@@ -312,12 +313,15 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
...
@@ -312,12 +313,15 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
case
QUERY_EXEC_MODE_RPC
:
case
QUERY_EXEC_MODE_RPC
:
code
=
execDdlQuery
(
pRequest
,
pQuery
);
code
=
execDdlQuery
(
pRequest
,
pQuery
);
break
;
break
;
case
QUERY_EXEC_MODE_SCHEDULE
:
case
QUERY_EXEC_MODE_SCHEDULE
:
{
SArray
*
pNodeList
=
taosArrayInit
(
4
,
sizeof
(
struct
SQueryNodeAddr
));
code
=
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
pNodeList
);
code
=
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
pNodeList
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
scheduleQuery
(
pRequest
,
pRequest
->
body
.
pDag
,
pNodeList
);
code
=
scheduleQuery
(
pRequest
,
pRequest
->
body
.
pDag
,
pNodeList
);
}
}
taosArrayDestroy
(
pNodeList
);
break
;
break
;
}
case
QUERY_EXEC_MODE_EMPTY_RESULT
:
case
QUERY_EXEC_MODE_EMPTY_RESULT
:
pRequest
->
type
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
pRequest
->
type
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
break
;
break
;
...
@@ -326,7 +330,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
...
@@ -326,7 +330,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
}
}
}
}
taosArrayDestroy
(
pNodeList
);
if
(
!
keepQuery
)
{
if
(
!
keepQuery
)
{
qDestroyQuery
(
pQuery
);
qDestroyQuery
(
pQuery
);
}
}
...
...
source/common/src/tglobal.c
浏览文件 @
98ce2f57
...
@@ -80,6 +80,9 @@ int32_t tsTelemInterval = 86400;
...
@@ -80,6 +80,9 @@ int32_t tsTelemInterval = 86400;
char
tsTelemServer
[
TSDB_FQDN_LEN
]
=
"telemetry.taosdata.com"
;
char
tsTelemServer
[
TSDB_FQDN_LEN
]
=
"telemetry.taosdata.com"
;
uint16_t
tsTelemPort
=
80
;
uint16_t
tsTelemPort
=
80
;
// query
int32_t
tsQueryPolicy
=
1
;
/*
/*
* denote if the server needs to compress response message at the application layer to client, including query rsp,
* denote if the server needs to compress response message at the application layer to client, including query rsp,
* metricmeta rsp, and multi-meter query rsp message body. The client compress the submit message to server.
* metricmeta rsp, and multi-meter query rsp message body. The client compress the submit message to server.
...
@@ -322,6 +325,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
...
@@ -322,6 +325,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
return
-
1
;
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"keepColumnName"
,
tsKeepOriginalColumnName
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"keepColumnName"
,
tsKeepOriginalColumnName
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxBinaryDisplayWidth"
,
tsMaxBinaryDisplayWidth
,
1
,
65536
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxBinaryDisplayWidth"
,
tsMaxBinaryDisplayWidth
,
1
,
65536
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"queryPolicy"
,
tsQueryPolicy
,
1
,
3
,
1
)
!=
0
)
return
-
1
;
tsNumOfTaskQueueThreads
=
tsNumOfCores
/
4
;
tsNumOfTaskQueueThreads
=
tsNumOfCores
/
4
;
tsNumOfTaskQueueThreads
=
TRANGE
(
tsNumOfTaskQueueThreads
,
1
,
2
);
tsNumOfTaskQueueThreads
=
TRANGE
(
tsNumOfTaskQueueThreads
,
1
,
2
);
...
@@ -515,6 +519,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
...
@@ -515,6 +519,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
tsKeepOriginalColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
tsKeepOriginalColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
tsMaxBinaryDisplayWidth
=
cfgGetItem
(
pCfg
,
"maxBinaryDisplayWidth"
)
->
i32
;
tsMaxBinaryDisplayWidth
=
cfgGetItem
(
pCfg
,
"maxBinaryDisplayWidth"
)
->
i32
;
tsNumOfTaskQueueThreads
=
cfgGetItem
(
pCfg
,
"numOfTaskQueueThreads"
)
->
i32
;
tsNumOfTaskQueueThreads
=
cfgGetItem
(
pCfg
,
"numOfTaskQueueThreads"
)
->
i32
;
tsQueryPolicy
=
cfgGetItem
(
pCfg
,
"queryPolicy"
)
->
i32
;
return
0
;
return
0
;
}
}
...
...
source/common/src/tmsg.c
浏览文件 @
98ce2f57
...
@@ -2734,11 +2734,11 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
...
@@ -2734,11 +2734,11 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTbName
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTbName
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withSchema
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withSchema
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTag
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTag
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTagSchema
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
sqlLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
sqlLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
astLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
astLen
)
<
0
)
return
-
1
;
if
(
sqlLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
if
(
sqlLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
if
(
astLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
ast
)
<
0
)
return
-
1
;
if
(
astLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
ast
)
<
0
)
return
-
1
;
if
(
0
==
astLen
&&
tEncodeCStr
(
&
encoder
,
pReq
->
subscribeDbName
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
...
@@ -2760,7 +2760,6 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
...
@@ -2760,7 +2760,6 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTbName
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTbName
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withSchema
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withSchema
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTag
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTag
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTagSchema
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
sqlLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
sqlLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
astLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
astLen
)
<
0
)
return
-
1
;
...
@@ -2774,6 +2773,8 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
...
@@ -2774,6 +2773,8 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
pReq
->
ast
=
taosMemoryCalloc
(
1
,
astLen
+
1
);
pReq
->
ast
=
taosMemoryCalloc
(
1
,
astLen
+
1
);
if
(
pReq
->
ast
==
NULL
)
return
-
1
;
if
(
pReq
->
ast
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
ast
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
ast
)
<
0
)
return
-
1
;
}
else
{
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
subscribeDbName
)
<
0
)
return
-
1
;
}
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
...
...
source/common/src/ttime.c
浏览文件 @
98ce2f57
...
@@ -412,7 +412,7 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char
...
@@ -412,7 +412,7 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char
int32_t
convertStringToTimestamp
(
int16_t
type
,
char
*
inputData
,
int64_t
timePrec
,
int64_t
*
timeVal
)
{
int32_t
convertStringToTimestamp
(
int16_t
type
,
char
*
inputData
,
int64_t
timePrec
,
int64_t
*
timeVal
)
{
int32_t
charLen
=
varDataLen
(
inputData
);
int32_t
charLen
=
varDataLen
(
inputData
);
char
*
newColData
;
char
*
newColData
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_VARBINARY
)
{
newColData
=
taosMemoryCalloc
(
1
,
charLen
+
1
);
newColData
=
taosMemoryCalloc
(
1
,
charLen
+
1
);
memcpy
(
newColData
,
varDataVal
(
inputData
),
charLen
);
memcpy
(
newColData
,
varDataVal
(
inputData
),
charLen
);
bool
ret
=
taosParseTime
(
newColData
,
timeVal
,
charLen
,
(
int32_t
)
timePrec
,
tsDaylight
);
bool
ret
=
taosParseTime
(
newColData
,
timeVal
,
charLen
,
(
int32_t
)
timePrec
,
tsDaylight
);
...
...
source/dnode/mgmt/implement/src/dmHandle.c
浏览文件 @
98ce2f57
...
@@ -220,13 +220,11 @@ static int32_t dmSpawnUdfd(SDnode *pDnode);
...
@@ -220,13 +220,11 @@ static int32_t dmSpawnUdfd(SDnode *pDnode);
void
dmUdfdExit
(
uv_process_t
*
process
,
int64_t
exitStatus
,
int
termSignal
)
{
void
dmUdfdExit
(
uv_process_t
*
process
,
int64_t
exitStatus
,
int
termSignal
)
{
dInfo
(
"udfd process exited with status %"
PRId64
", signal %d"
,
exitStatus
,
termSignal
);
dInfo
(
"udfd process exited with status %"
PRId64
", signal %d"
,
exitStatus
,
termSignal
);
uv_close
((
uv_handle_t
*
)
process
,
NULL
);
SDnode
*
pDnode
=
process
->
data
;
SDnode
*
pDnode
=
process
->
data
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
if
(
exitStatus
==
0
&&
termSignal
==
0
||
atomic_load_32
(
&
pDnode
->
udfdData
.
stopCalled
))
{
if
(
atomic_load_8
(
&
pData
->
stopping
)
!=
0
)
{
dInfo
(
"udfd process exit due to SIGINT or dnode-mgmt called stop"
);
dDebug
(
"udfd process exit due to stopping"
);
}
else
{
}
else
{
uv_close
((
uv_handle_t
*
)
&
pData
->
ctrlPipe
,
NULL
);
dInfo
(
"udfd process restart"
);
dmSpawnUdfd
(
pDnode
);
dmSpawnUdfd
(
pDnode
);
}
}
}
}
...
@@ -248,6 +246,7 @@ static int32_t dmSpawnUdfd(SDnode *pDnode) {
...
@@ -248,6 +246,7 @@ static int32_t dmSpawnUdfd(SDnode *pDnode) {
options
.
file
=
path
;
options
.
file
=
path
;
options
.
exit_cb
=
dmUdfdExit
;
options
.
exit_cb
=
dmUdfdExit
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
uv_pipe_init
(
&
pData
->
loop
,
&
pData
->
ctrlPipe
,
1
);
uv_pipe_init
(
&
pData
->
loop
,
&
pData
->
ctrlPipe
,
1
);
...
@@ -260,6 +259,8 @@ static int32_t dmSpawnUdfd(SDnode *pDnode) {
...
@@ -260,6 +259,8 @@ static int32_t dmSpawnUdfd(SDnode *pDnode) {
options
.
stdio_count
=
3
;
options
.
stdio_count
=
3
;
options
.
stdio
=
child_stdio
;
options
.
stdio
=
child_stdio
;
options
.
flags
=
UV_PROCESS_DETACHED
;
char
dnodeIdEnvItem
[
32
]
=
{
0
};
char
dnodeIdEnvItem
[
32
]
=
{
0
};
char
thrdPoolSizeEnvItem
[
32
]
=
{
0
};
char
thrdPoolSizeEnvItem
[
32
]
=
{
0
};
snprintf
(
dnodeIdEnvItem
,
32
,
"%s=%d"
,
"DNODE_ID"
,
pDnode
->
data
.
dnodeId
);
snprintf
(
dnodeIdEnvItem
,
32
,
"%s=%d"
,
"DNODE_ID"
,
pDnode
->
data
.
dnodeId
);
...
@@ -284,24 +285,31 @@ static void dmUdfdCloseWalkCb(uv_handle_t* handle, void* arg) {
...
@@ -284,24 +285,31 @@ static void dmUdfdCloseWalkCb(uv_handle_t* handle, void* arg) {
}
}
}
}
void
dmWatchUdfd
(
void
*
args
)
{
static
void
dmUdfdStopAsyncCb
(
uv_async_t
*
async
)
{
SDnode
*
pDnode
=
async
->
data
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
uv_stop
(
&
pData
->
loop
);
}
static
void
dmWatchUdfd
(
void
*
args
)
{
SDnode
*
pDnode
=
args
;
SDnode
*
pDnode
=
args
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
uv_loop_init
(
&
pData
->
loop
);
uv_loop_init
(
&
pData
->
loop
);
uv_async_init
(
&
pData
->
loop
,
&
pData
->
stopAsync
,
dmUdfdStopAsyncCb
);
pData
->
stopAsync
.
data
=
pDnode
;
int32_t
err
=
dmSpawnUdfd
(
pDnode
);
int32_t
err
=
dmSpawnUdfd
(
pDnode
);
atomic_store_32
(
&
pData
->
spawnErr
,
err
);
atomic_store_32
(
&
pData
->
spawnErr
,
err
);
uv_barrier_wait
(
&
pData
->
barrier
);
uv_barrier_wait
(
&
pData
->
barrier
);
uv_run
(
&
pData
->
loop
,
UV_RUN_DEFAULT
);
uv_run
(
&
pData
->
loop
,
UV_RUN_DEFAULT
);
err
=
uv_loop_close
(
&
pData
->
loop
);
uv_loop_close
(
&
pData
->
loop
);
while
(
err
==
UV_EBUSY
)
{
uv_walk
(
&
pData
->
loop
,
dmUdfdCloseWalkCb
,
NULL
);
uv_walk
(
&
pData
->
loop
,
dmUdfdCloseWalkCb
,
NULL
);
uv_run
(
&
pData
->
loop
,
UV_RUN_DEFAULT
);
uv_run
(
&
pData
->
loop
,
UV_RUN_DEFAULT
);
err
=
uv_loop_close
(
&
pData
->
loop
);
uv_loop_close
(
&
pData
->
loop
);
}
return
;
return
;
}
}
int32_t
dmStartUdfd
(
SDnode
*
pDnode
)
{
static
int32_t
dmStartUdfd
(
SDnode
*
pDnode
)
{
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
if
(
pData
->
startCalled
)
{
if
(
pData
->
startCalled
)
{
dInfo
(
"dnode-mgmt start udfd already called"
);
dInfo
(
"dnode-mgmt start udfd already called"
);
...
@@ -309,30 +317,25 @@ int32_t dmStartUdfd(SDnode *pDnode) {
...
@@ -309,30 +317,25 @@ int32_t dmStartUdfd(SDnode *pDnode) {
}
}
pData
->
startCalled
=
true
;
pData
->
startCalled
=
true
;
uv_barrier_init
(
&
pData
->
barrier
,
2
);
uv_barrier_init
(
&
pData
->
barrier
,
2
);
pData
->
stopping
=
0
;
uv_thread_create
(
&
pData
->
thread
,
dmWatchUdfd
,
pDnode
);
uv_thread_create
(
&
pData
->
thread
,
dmWatchUdfd
,
pDnode
);
uv_barrier_wait
(
&
pData
->
barrier
);
uv_barrier_wait
(
&
pData
->
barrier
);
pData
->
needCleanUp
=
true
;
pData
->
needCleanUp
=
true
;
return
pData
->
spawnErr
;
return
pData
->
spawnErr
;
}
}
int32_t
dmStopUdfd
(
SDnode
*
pDnode
)
{
static
int32_t
dmStopUdfd
(
SDnode
*
pDnode
)
{
dInfo
(
"dnode-mgmt to stop udfd. need cleanup: %d, spawn err: %d"
,
dInfo
(
"dnode-mgmt to stop udfd. need cleanup: %d, spawn err: %d"
,
pDnode
->
udfdData
.
needCleanUp
,
pDnode
->
udfdData
.
spawnErr
);
pDnode
->
udfdData
.
needCleanUp
,
pDnode
->
udfdData
.
spawnErr
);
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
if
(
!
pData
->
needCleanUp
)
{
if
(
!
pData
->
needCleanUp
||
atomic_load_32
(
&
pData
->
stopCalled
)
)
{
return
0
;
return
0
;
}
}
atomic_store_
8
(
&
pData
->
stopping
,
1
);
atomic_store_
32
(
&
pData
->
stopCalled
,
1
);
pData
->
needCleanUp
=
false
;
uv_barrier_destroy
(
&
pData
->
barrier
);
uv_barrier_destroy
(
&
pData
->
barrier
);
if
(
pData
->
spawnErr
==
0
)
{
uv_async_send
(
&
pData
->
stopAsync
);
uv_process_kill
(
&
pData
->
process
,
SIGINT
);
}
uv_stop
(
&
pData
->
loop
);
uv_thread_join
(
&
pData
->
thread
);
uv_thread_join
(
&
pData
->
thread
);
atomic_store_8
(
&
pData
->
stopping
,
0
);
return
0
;
return
0
;
}
}
...
...
source/dnode/mgmt/interface/inc/dmDef.h
浏览文件 @
98ce2f57
...
@@ -151,8 +151,9 @@ typedef struct SUdfdData {
...
@@ -151,8 +151,9 @@ typedef struct SUdfdData {
uv_barrier_t
barrier
;
uv_barrier_t
barrier
;
uv_process_t
process
;
uv_process_t
process
;
int
spawnErr
;
int
spawnErr
;
int8_t
stopping
;
uv_pipe_t
ctrlPipe
;
uv_pipe_t
ctrlPipe
;
uv_async_t
stopAsync
;
int32_t
stopCalled
;
}
SUdfdData
;
}
SUdfdData
;
typedef
struct
SDnode
{
typedef
struct
SDnode
{
...
...
source/dnode/mnode/impl/src/mndInfoSchema.c
浏览文件 @
98ce2f57
...
@@ -199,15 +199,6 @@ static const SInfosTableSchema vgroupsSchema[] = {
...
@@ -199,15 +199,6 @@ static const SInfosTableSchema vgroupsSchema[] = {
{.
name
=
"file_size"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"file_size"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
};
};
// TODO put into perf schema
static
const
SInfosTableSchema
topicSchema
[]
=
{
{.
name
=
"topic_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"sql"
,
.
bytes
=
1024
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"row_len"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
};
static
const
SInfosTableSchema
consumerSchema
[]
=
{
static
const
SInfosTableSchema
consumerSchema
[]
=
{
{.
name
=
"client_id"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"client_id"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"group_id"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"group_id"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
@@ -291,7 +282,6 @@ static const SInfosTableMeta infosMeta[] = {
...
@@ -291,7 +282,6 @@ static const SInfosTableMeta infosMeta[] = {
{
TSDB_INS_TABLE_USER_USERS
,
userUsersSchema
,
tListLen
(
userUsersSchema
)},
{
TSDB_INS_TABLE_USER_USERS
,
userUsersSchema
,
tListLen
(
userUsersSchema
)},
{
TSDB_INS_TABLE_LICENCES
,
grantsSchema
,
tListLen
(
grantsSchema
)},
{
TSDB_INS_TABLE_LICENCES
,
grantsSchema
,
tListLen
(
grantsSchema
)},
{
TSDB_INS_TABLE_VGROUPS
,
vgroupsSchema
,
tListLen
(
vgroupsSchema
)},
{
TSDB_INS_TABLE_VGROUPS
,
vgroupsSchema
,
tListLen
(
vgroupsSchema
)},
{
TSDB_INS_TABLE_TOPICS
,
topicSchema
,
tListLen
(
topicSchema
)},
{
TSDB_INS_TABLE_CONSUMERS
,
consumerSchema
,
tListLen
(
consumerSchema
)},
{
TSDB_INS_TABLE_CONSUMERS
,
consumerSchema
,
tListLen
(
consumerSchema
)},
{
TSDB_INS_TABLE_SUBSCRIBES
,
subscribeSchema
,
tListLen
(
subscribeSchema
)},
{
TSDB_INS_TABLE_SUBSCRIBES
,
subscribeSchema
,
tListLen
(
subscribeSchema
)},
{
TSDB_INS_TABLE_TRANS
,
transSchema
,
tListLen
(
transSchema
)},
{
TSDB_INS_TABLE_TRANS
,
transSchema
,
tListLen
(
transSchema
)},
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
98ce2f57
...
@@ -84,8 +84,6 @@ static int32_t convertToRetrieveType(char* name, int32_t len) {
...
@@ -84,8 +84,6 @@ static int32_t convertToRetrieveType(char* name, int32_t len) {
type
=
TSDB_MGMT_TABLE_GRANTS
;
type
=
TSDB_MGMT_TABLE_GRANTS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_VGROUPS
,
len
)
==
0
)
{
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_VGROUPS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_VGROUP
;
type
=
TSDB_MGMT_TABLE_VGROUP
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TOPICS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_TOPICS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CONSUMERS
,
len
)
==
0
)
{
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CONSUMERS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_CONSUMERS
;
type
=
TSDB_MGMT_TABLE_CONSUMERS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_SUBSCRIBES
,
len
)
==
0
)
{
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_SUBSCRIBES
,
len
)
==
0
)
{
...
...
source/libs/function/src/builtins.c
浏览文件 @
98ce2f57
...
@@ -339,7 +339,7 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
...
@@ -339,7 +339,7 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
int32_t
para2Bytes
=
pFunc
->
node
.
resType
.
bytes
;
int32_t
para2Bytes
=
pFunc
->
node
.
resType
.
bytes
;
if
(
para2Bytes
<=
0
)
{
//non-positive value or overflow
if
(
para2Bytes
<=
0
||
para2Bytes
>
1000
)
{
//cast dst var type length limits to 1000
return
invaildFuncParaValueErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaValueErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -420,7 +420,7 @@ static int32_t translateToJson(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
...
@@ -420,7 +420,7 @@ static int32_t translateToJson(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_
JSON
].
bytes
,
.
type
=
TSDB_DATA_TYPE_JSON
};
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_
BINARY
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BINARY
};
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/function/src/udfd.c
浏览文件 @
98ce2f57
...
@@ -586,7 +586,7 @@ static int32_t udfdRun() {
...
@@ -586,7 +586,7 @@ static int32_t udfdRun() {
udfdCloseClientRpc
();
udfdCloseClientRpc
();
uv_mutex_destroy
(
&
global
.
udfsMutex
);
uv_mutex_destroy
(
&
global
.
udfsMutex
);
taosHashCleanup
(
global
.
udfsHash
);
taosHashCleanup
(
global
.
udfsHash
);
return
code
;
return
0
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
98ce2f57
...
@@ -2465,10 +2465,10 @@ static int32_t jsonToSelectStmt(const SJson* pJson, void* pObj) {
...
@@ -2465,10 +2465,10 @@ static int32_t jsonToSelectStmt(const SJson* pJson, void* pObj) {
code
=
jsonToNodeList
(
pJson
,
jkSelectStmtOrderBy
,
&
pNode
->
pOrderByList
);
code
=
jsonToNodeList
(
pJson
,
jkSelectStmtOrderBy
,
&
pNode
->
pOrderByList
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkSelectStmtLimit
,
&
pNode
->
pLimit
);
code
=
jsonToNodeObject
(
pJson
,
jkSelectStmtLimit
,
(
SNode
**
)
&
pNode
->
pLimit
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkSelectStmtSlimit
,
&
pNode
->
pSlimit
);
code
=
jsonToNodeObject
(
pJson
,
jkSelectStmtSlimit
,
(
SNode
**
)
&
pNode
->
pSlimit
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetStringValue
(
pJson
,
jkSelectStmtStmtName
,
pNode
->
stmtName
);
code
=
tjsonGetStringValue
(
pJson
,
jkSelectStmtStmtName
,
pNode
->
stmtName
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
98ce2f57
...
@@ -86,6 +86,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -86,6 +86,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SExplainOptions
));
return
makeNode
(
type
,
sizeof
(
SExplainOptions
));
case
QUERY_NODE_STREAM_OPTIONS
:
case
QUERY_NODE_STREAM_OPTIONS
:
return
makeNode
(
type
,
sizeof
(
SStreamOptions
));
return
makeNode
(
type
,
sizeof
(
SStreamOptions
));
case
QUERY_NODE_TOPIC_OPTIONS
:
return
makeNode
(
type
,
sizeof
(
STopicOptions
));
case
QUERY_NODE_SET_OPERATOR
:
case
QUERY_NODE_SET_OPERATOR
:
return
makeNode
(
type
,
sizeof
(
SSetOperator
));
return
makeNode
(
type
,
sizeof
(
SSetOperator
));
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
98ce2f57
...
@@ -128,7 +128,7 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, STo
...
@@ -128,7 +128,7 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, STo
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
setTableAlterOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
);
SNode
*
setTableAlterOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
);
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
);
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
);
SDataType
createDataType
(
uint8_t
type
);
SDataType
createDataType
(
uint8_t
type
);
SDataType
createVarLenDataType
(
uint8_t
type
,
const
SToken
*
pLen
);
SDataType
createVarLenDataType
(
uint8_t
type
,
const
SToken
*
pLen
);
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNodeList
*
pTags
,
SNode
*
pOptions
);
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNodeList
*
pTags
,
SNode
*
pOptions
);
...
@@ -157,7 +157,8 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
...
@@ -157,7 +157,8 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pIndexName
,
SToken
*
pTableName
);
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pIndexName
,
SToken
*
pTableName
);
SNode
*
createCreateComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createCreateComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createDropComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createDropComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createCreateTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
,
const
SToken
*
pSubscribeDbName
);
SNode
*
createTopicOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createCreateTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
,
const
SToken
*
pSubscribeDbName
,
SNode
*
pOptions
);
SNode
*
createDropTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pTopicName
);
SNode
*
createDropTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pTopicName
);
SNode
*
createAlterLocalStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createAlterLocalStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createDefaultExplainOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createDefaultExplainOptions
(
SAstCreateContext
*
pCxt
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
98ce2f57
...
@@ -35,14 +35,11 @@
...
@@ -35,14 +35,11 @@
%left OR.
%left OR.
%left AND.
%left AND.
//%right NOT.
%left UNION ALL MINUS EXCEPT INTERSECT.
%left UNION ALL MINUS EXCEPT INTERSECT.
%left NK_BITAND NK_BITOR NK_LSHIFT NK_RSHIFT.
%left NK_BITAND NK_BITOR NK_LSHIFT NK_RSHIFT.
%left NK_PLUS NK_MINUS.
%left NK_PLUS NK_MINUS.
//%left DIVIDE TIMES.
%left NK_STAR NK_SLASH NK_REM.
%left NK_STAR NK_SLASH NK_REM.
%left NK_CONCAT.
%left NK_CONCAT.
//%right NK_BITNOT.
/************************************************ create/alter account *****************************************/
/************************************************ create/alter account *****************************************/
cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options. { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options. { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
...
@@ -387,10 +384,17 @@ func_list(A) ::= func_list(B) NK_COMMA func(C).
...
@@ -387,10 +384,17 @@ func_list(A) ::= func_list(B) NK_COMMA func(C).
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
/************************************************ create/drop topic ***************************************************/
/************************************************ create/drop topic ***************************************************/
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, C, NULL); }
cmd ::= CREATE TOPIC not_exists_opt(A)
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C); }
topic_name(B) topic_options(D) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, C, NULL, D); }
cmd ::= CREATE TOPIC not_exists_opt(A)
topic_name(B) topic_options(D) AS db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C, D); }
cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); }
cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); }
topic_options(A) ::= . { A = createTopicOptions(pCxt); }
topic_options(A) ::= topic_options(B) WITH TABLE. { ((STopicOptions*)B)->withTable = true; A = B; }
topic_options(A) ::= topic_options(B) WITH SCHEMA. { ((STopicOptions*)B)->withSchema = true; A = B; }
topic_options(A) ::= topic_options(B) WITH TAG. { ((STopicOptions*)B)->withTag = true; A = B; }
/************************************************ desc/describe *******************************************************/
/************************************************ desc/describe *******************************************************/
cmd ::= DESC full_table_name(A). { pCxt->pRootNode = createDescribeStmt(pCxt, A); }
cmd ::= DESC full_table_name(A). { pCxt->pRootNode = createDescribeStmt(pCxt, A); }
cmd ::= DESCRIBE full_table_name(A). { pCxt->pRootNode = createDescribeStmt(pCxt, A); }
cmd ::= DESCRIBE full_table_name(A). { pCxt->pRootNode = createDescribeStmt(pCxt, A); }
...
@@ -887,3 +891,5 @@ ordering_specification_opt(A) ::= DESC.
...
@@ -887,3 +891,5 @@ ordering_specification_opt(A) ::= DESC.
null_ordering_opt(A) ::= . { A = NULL_ORDER_DEFAULT; }
null_ordering_opt(A) ::= . { A = NULL_ORDER_DEFAULT; }
null_ordering_opt(A) ::= NULLS FIRST. { A = NULL_ORDER_FIRST; }
null_ordering_opt(A) ::= NULLS FIRST. { A = NULL_ORDER_FIRST; }
null_ordering_opt(A) ::= NULLS LAST. { A = NULL_ORDER_LAST; }
null_ordering_opt(A) ::= NULLS LAST. { A = NULL_ORDER_LAST; }
%fallback ID NK_BITNOT INSERT VALUES IMPORT NK_SEMI FILE.
source/libs/parser/src/parAstCreater.c
浏览文件 @
98ce2f57
...
@@ -146,44 +146,42 @@ static bool checkDbName(SAstCreateContext* pCxt, SToken* pDbName, bool query) {
...
@@ -146,44 +146,42 @@ static bool checkDbName(SAstCreateContext* pCxt, SToken* pDbName, bool query) {
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
}
}
}
else
{
}
else
{
trimEscape
(
pDbName
);
if
(
pDbName
->
n
>=
TSDB_DB_NAME_LEN
)
{
if
(
pDbName
->
n
>=
TSDB_DB_NAME_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pDbName
->
z
);
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pDbName
->
z
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
}
}
}
}
if
(
pCxt
->
valid
)
{
trimEscape
(
pDbName
);
}
return
pCxt
->
valid
;
return
pCxt
->
valid
;
}
}
static
bool
checkTableName
(
SAstCreateContext
*
pCxt
,
SToken
*
pTableName
)
{
static
bool
checkTableName
(
SAstCreateContext
*
pCxt
,
SToken
*
pTableName
)
{
trimEscape
(
pTableName
);
if
(
NULL
!=
pTableName
&&
pTableName
->
n
>=
TSDB_TABLE_NAME_LEN
)
{
if
(
NULL
!=
pTableName
&&
pTableName
->
n
>=
TSDB_TABLE_NAME_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pTableName
->
z
);
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pTableName
->
z
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
false
;
return
false
;
}
}
trimEscape
(
pTableName
);
return
true
;
return
true
;
}
}
static
bool
checkColumnName
(
SAstCreateContext
*
pCxt
,
SToken
*
pColumnName
)
{
static
bool
checkColumnName
(
SAstCreateContext
*
pCxt
,
SToken
*
pColumnName
)
{
trimEscape
(
pColumnName
);
if
(
NULL
!=
pColumnName
&&
pColumnName
->
n
>=
TSDB_COL_NAME_LEN
)
{
if
(
NULL
!=
pColumnName
&&
pColumnName
->
n
>=
TSDB_COL_NAME_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pColumnName
->
z
);
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pColumnName
->
z
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
false
;
return
false
;
}
}
trimEscape
(
pColumnName
);
return
true
;
return
true
;
}
}
static
bool
checkIndexName
(
SAstCreateContext
*
pCxt
,
SToken
*
pIndexName
)
{
static
bool
checkIndexName
(
SAstCreateContext
*
pCxt
,
SToken
*
pIndexName
)
{
trimEscape
(
pIndexName
);
if
(
NULL
!=
pIndexName
&&
pIndexName
->
n
>=
TSDB_INDEX_NAME_LEN
)
{
if
(
NULL
!=
pIndexName
&&
pIndexName
->
n
>=
TSDB_INDEX_NAME_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pIndexName
->
z
);
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pIndexName
->
z
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
false
;
return
false
;
}
}
trimEscape
(
pIndexName
);
return
true
;
return
true
;
}
}
...
@@ -609,14 +607,14 @@ SNode* addOrderByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pOrder
...
@@ -609,14 +607,14 @@ SNode* addOrderByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pOrder
SNode
*
addSlimitClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pSlimit
)
{
SNode
*
addSlimitClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pSlimit
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
((
SSelectStmt
*
)
pStmt
)
->
pSlimit
=
pSlimit
;
((
SSelectStmt
*
)
pStmt
)
->
pSlimit
=
(
SLimitNode
*
)
pSlimit
;
}
}
return
pStmt
;
return
pStmt
;
}
}
SNode
*
addLimitClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pLimit
)
{
SNode
*
addLimitClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pLimit
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
((
SSelectStmt
*
)
pStmt
)
->
pLimit
=
pLimit
;
((
SSelectStmt
*
)
pStmt
)
->
pLimit
=
(
SLimitNode
*
)
pLimit
;
}
}
return
pStmt
;
return
pStmt
;
}
}
...
@@ -771,7 +769,10 @@ SNode* setTableAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOptio
...
@@ -771,7 +769,10 @@ SNode* setTableAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOptio
return
pOptions
;
return
pOptions
;
}
}
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
)
{
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
)
{
if
(
!
checkColumnName
(
pCxt
,
pColName
))
{
return
NULL
;
}
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN_DEF
);
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN_DEF
);
CHECK_OUT_OF_MEM
(
pCol
);
CHECK_OUT_OF_MEM
(
pCol
);
strncpy
(
pCol
->
colName
,
pColName
->
z
,
pColName
->
n
);
strncpy
(
pCol
->
colName
,
pColName
->
z
,
pColName
->
n
);
...
@@ -1101,7 +1102,17 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons
...
@@ -1101,7 +1102,17 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
SNode
*
createCreateTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
,
const
SToken
*
pSubscribeDbName
)
{
SNode
*
createTopicOptions
(
SAstCreateContext
*
pCxt
)
{
STopicOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_TOPIC_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
withTable
=
false
;
pOptions
->
withSchema
=
false
;
pOptions
->
withTag
=
false
;
return
(
SNode
*
)
pOptions
;
}
SNode
*
createCreateTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
,
const
SToken
*
pSubscribeDbName
,
SNode
*
pOptions
)
{
SCreateTopicStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_CREATE_TOPIC_STMT
);
SCreateTopicStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_CREATE_TOPIC_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
CHECK_OUT_OF_MEM
(
pStmt
);
strncpy
(
pStmt
->
topicName
,
pTopicName
->
z
,
pTopicName
->
n
);
strncpy
(
pStmt
->
topicName
,
pTopicName
->
z
,
pTopicName
->
n
);
...
@@ -1110,6 +1121,7 @@ SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const S
...
@@ -1110,6 +1121,7 @@ SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const S
if
(
NULL
!=
pSubscribeDbName
)
{
if
(
NULL
!=
pSubscribeDbName
)
{
strncpy
(
pStmt
->
subscribeDbName
,
pSubscribeDbName
->
z
,
pSubscribeDbName
->
n
);
strncpy
(
pStmt
->
subscribeDbName
,
pSubscribeDbName
->
z
,
pSubscribeDbName
->
n
);
}
}
pStmt
->
pOptions
=
(
STopicOptions
*
)
pOptions
;
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
...
...
source/libs/parser/src/parCalcConst.c
浏览文件 @
98ce2f57
...
@@ -16,12 +16,15 @@
...
@@ -16,12 +16,15 @@
#include "functionMgt.h"
#include "functionMgt.h"
#include "parInt.h"
#include "parInt.h"
#include "scalar.h"
#include "scalar.h"
#include "ttime.h"
typedef
struct
SCalcConstContext
{
typedef
struct
SCalcConstContext
{
SParseContext
*
pParseCxt
;
SMsgBuf
msgBuf
;
int32_t
code
;
int32_t
code
;
}
SCalcConstContext
;
}
SCalcConstContext
;
static
int32_t
calcConstQuery
(
SNode
*
pStmt
);
static
int32_t
calcConstQuery
(
S
CalcConstContext
*
pCxt
,
S
Node
*
pStmt
);
static
EDealRes
doCalcConst
(
SNode
**
pNode
,
SCalcConstContext
*
pCxt
)
{
static
EDealRes
doCalcConst
(
SNode
**
pNode
,
SCalcConstContext
*
pCxt
)
{
SNode
*
pNew
=
NULL
;
SNode
*
pNew
=
NULL
;
...
@@ -35,10 +38,45 @@ static EDealRes doCalcConst(SNode** pNode, SCalcConstContext* pCxt) {
...
@@ -35,10 +38,45 @@ static EDealRes doCalcConst(SNode** pNode, SCalcConstContext* pCxt) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
static
bool
isTimestampCol
(
SNode
*
pNode
)
{
if
(
NULL
==
pNode
)
{
return
false
;
}
return
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
)
&&
TSDB_DATA_TYPE_TIMESTAMP
==
((
SExprNode
*
)
pNode
)
->
resType
.
type
);
}
static
EDealRes
stringToTimestamp
(
SCalcConstContext
*
pCxt
,
uint8_t
precision
,
SValueNode
*
pVal
)
{
switch
(
pVal
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
{
int64_t
val
=
0
;
if
(
TSDB_CODE_SUCCESS
!=
convertStringToTimestamp
(
pVal
->
node
.
resType
.
type
,
pVal
->
datum
.
p
,
precision
,
&
val
))
{
pCxt
->
code
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INCORRECT_TIMESTAMP_VAL
,
varDataVal
(
pVal
->
datum
.
p
));
return
DEAL_RES_ERROR
;
}
pVal
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
pVal
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_TIMESTAMP
].
bytes
;
taosMemoryFreeClear
(
pVal
->
datum
.
p
);
pVal
->
datum
.
i
=
val
;
break
;
}
default:
break
;
}
return
DEAL_RES_CONTINUE
;
}
static
EDealRes
calcConstOperator
(
SOperatorNode
**
pNode
,
void
*
pContext
)
{
static
EDealRes
calcConstOperator
(
SOperatorNode
**
pNode
,
void
*
pContext
)
{
SCalcConstContext
*
pCxt
=
pContext
;
SOperatorNode
*
pOp
=
*
pNode
;
SOperatorNode
*
pOp
=
*
pNode
;
if
(
QUERY_NODE_VALUE
==
nodeType
(
pOp
->
pLeft
)
&&
(
NULL
==
pOp
->
pRight
||
QUERY_NODE_VALUE
==
nodeType
(
pOp
->
pRight
)))
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pOp
->
pLeft
)
&&
(
NULL
==
pOp
->
pRight
||
QUERY_NODE_VALUE
==
nodeType
(
pOp
->
pRight
)))
{
return
doCalcConst
((
SNode
**
)
pNode
,
(
SCalcConstContext
*
)
pContext
);
return
doCalcConst
((
SNode
**
)
pNode
,
pCxt
);
}
if
(
isTimestampCol
(
pOp
->
pLeft
)
&&
(
NULL
==
pOp
->
pRight
||
QUERY_NODE_VALUE
==
nodeType
(
pOp
->
pRight
)))
{
return
stringToTimestamp
(
pCxt
,
((
SColumnNode
*
)
pOp
->
pLeft
)
->
node
.
resType
.
precision
,
(
SValueNode
*
)
pOp
->
pRight
);
}
else
if
(
isTimestampCol
(
pOp
->
pRight
)
&&
QUERY_NODE_VALUE
==
nodeType
(
pOp
->
pLeft
))
{
return
stringToTimestamp
(
pCxt
,
((
SColumnNode
*
)
pOp
->
pRight
)
->
node
.
resType
.
precision
,
(
SValueNode
*
)
pOp
->
pLeft
);
}
}
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
...
@@ -71,7 +109,7 @@ static EDealRes calcConstLogicCond(SLogicConditionNode** pNode, void* pContext)
...
@@ -71,7 +109,7 @@ static EDealRes calcConstLogicCond(SLogicConditionNode** pNode, void* pContext)
static
EDealRes
calcConstSubquery
(
STempTableNode
**
pNode
,
void
*
pContext
)
{
static
EDealRes
calcConstSubquery
(
STempTableNode
**
pNode
,
void
*
pContext
)
{
SCalcConstContext
*
pCxt
=
pContext
;
SCalcConstContext
*
pCxt
=
pContext
;
pCxt
->
code
=
calcConstQuery
((
*
pNode
)
->
pSubquery
);
pCxt
->
code
=
calcConstQuery
(
pCxt
,
(
*
pNode
)
->
pSubquery
);
return
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
);
return
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
);
}
}
...
@@ -185,39 +223,38 @@ static int32_t calcConstCondition(SCalcConstContext* pCxt, SSelectStmt* pSelect,
...
@@ -185,39 +223,38 @@ static int32_t calcConstCondition(SCalcConstContext* pCxt, SSelectStmt* pSelect,
return
pCxt
->
code
;
return
pCxt
->
code
;
}
}
static
int32_t
calcConstSelect
(
SSelectStmt
*
pSelect
)
{
static
int32_t
calcConstSelect
(
SCalcConstContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
SCalcConstContext
cxt
=
{
.
code
=
TSDB_CODE_SUCCESS
};
nodesRewriteExprsPostOrder
(
pSelect
->
pProjectionList
,
calcConst
,
pCxt
);
nodesRewriteExprsPostOrder
(
pSelect
->
pProjectionList
,
calcConst
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
pCxt
->
code
=
calcConstFromTable
(
pCxt
,
pSelect
);
cxt
.
code
=
calcConstFromTable
(
&
cxt
,
pSelect
);
}
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
cxt
.
code
=
calcConstCondition
(
&
c
xt
,
pSelect
,
&
pSelect
->
pWhere
);
pCxt
->
code
=
calcConstCondition
(
pC
xt
,
pSelect
,
&
pSelect
->
pWhere
);
}
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
nodesRewriteExprsPostOrder
(
pSelect
->
pPartitionByList
,
calcConst
,
&
c
xt
);
nodesRewriteExprsPostOrder
(
pSelect
->
pPartitionByList
,
calcConst
,
pC
xt
);
}
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
nodesRewriteExprPostOrder
(
&
pSelect
->
pWindow
,
calcConst
,
&
c
xt
);
nodesRewriteExprPostOrder
(
&
pSelect
->
pWindow
,
calcConst
,
pC
xt
);
}
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
nodesRewriteExprsPostOrder
(
pSelect
->
pGroupByList
,
calcConst
,
&
c
xt
);
nodesRewriteExprsPostOrder
(
pSelect
->
pGroupByList
,
calcConst
,
pC
xt
);
}
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
cxt
.
code
=
calcConstCondition
(
&
c
xt
,
pSelect
,
&
pSelect
->
pHaving
);
pCxt
->
code
=
calcConstCondition
(
pC
xt
,
pSelect
,
&
pSelect
->
pHaving
);
}
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
nodesRewriteExprsPostOrder
(
pSelect
->
pOrderByList
,
calcConst
,
&
c
xt
);
nodesRewriteExprsPostOrder
(
pSelect
->
pOrderByList
,
calcConst
,
pC
xt
);
}
}
return
cxt
.
code
;
return
pCxt
->
code
;
}
}
static
int32_t
calcConstQuery
(
SNode
*
pStmt
)
{
static
int32_t
calcConstQuery
(
S
CalcConstContext
*
pCxt
,
S
Node
*
pStmt
)
{
switch
(
nodeType
(
pStmt
))
{
switch
(
nodeType
(
pStmt
))
{
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
return
calcConstSelect
((
SSelectStmt
*
)
pStmt
);
return
calcConstSelect
(
pCxt
,
(
SSelectStmt
*
)
pStmt
);
case
QUERY_NODE_EXPLAIN_STMT
:
case
QUERY_NODE_EXPLAIN_STMT
:
return
calcConstQuery
(((
SExplainStmt
*
)
pStmt
)
->
pQuery
);
return
calcConstQuery
(
pCxt
,
((
SExplainStmt
*
)
pStmt
)
->
pQuery
);
default:
default:
break
;
break
;
}
}
...
@@ -237,7 +274,13 @@ static bool isEmptyResultQuery(SNode* pStmt) {
...
@@ -237,7 +274,13 @@ static bool isEmptyResultQuery(SNode* pStmt) {
}
}
int32_t
calculateConstant
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
)
{
int32_t
calculateConstant
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
)
{
int32_t
code
=
calcConstQuery
(
pQuery
->
pRoot
);
SCalcConstContext
cxt
=
{
.
pParseCxt
=
pParseCxt
,
.
msgBuf
.
buf
=
pParseCxt
->
pMsg
,
.
msgBuf
.
len
=
pParseCxt
->
msgLen
,
.
code
=
TSDB_CODE_SUCCESS
};
int32_t
code
=
calcConstQuery
(
&
cxt
,
pQuery
->
pRoot
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pQuery
->
execMode
=
isEmptyResultQuery
(
pQuery
->
pRoot
)
?
QUERY_EXEC_MODE_EMPTY_RESULT
:
pQuery
->
execMode
;
pQuery
->
execMode
=
isEmptyResultQuery
(
pQuery
->
pRoot
)
?
QUERY_EXEC_MODE_EMPTY_RESULT
:
pQuery
->
execMode
;
}
}
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
98ce2f57
...
@@ -1116,7 +1116,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
...
@@ -1116,7 +1116,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
}
}
// FILE csv_file_path
// FILE csv_file_path
if
(
TK_
NK_
FILE
==
sToken
.
type
)
{
if
(
TK_FILE
==
sToken
.
type
)
{
// pSql -> csv_file_path
// pSql -> csv_file_path
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
if
(
0
==
sToken
.
n
||
(
TK_NK_STRING
!=
sToken
.
type
&&
TK_NK_ID
!=
sToken
.
type
))
{
if
(
0
==
sToken
.
n
||
(
TK_NK_STRING
!=
sToken
.
type
&&
TK_NK_ID
!=
sToken
.
type
))
{
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
98ce2f57
...
@@ -148,6 +148,7 @@ static SKeyword keywordTable[] = {
...
@@ -148,6 +148,7 @@ static SKeyword keywordTable[] = {
{
"RESET"
,
TK_RESET
},
{
"RESET"
,
TK_RESET
},
{
"RETENTIONS"
,
TK_RETENTIONS
},
{
"RETENTIONS"
,
TK_RETENTIONS
},
{
"ROLLUP"
,
TK_ROLLUP
},
{
"ROLLUP"
,
TK_ROLLUP
},
{
"SCHEMA"
,
TK_SCHEMA
},
{
"SCORES"
,
TK_SCORES
},
{
"SCORES"
,
TK_SCORES
},
{
"SELECT"
,
TK_SELECT
},
{
"SELECT"
,
TK_SELECT
},
{
"SESSION"
,
TK_SESSION
},
{
"SESSION"
,
TK_SESSION
},
...
@@ -202,6 +203,7 @@ static SKeyword keywordTable[] = {
...
@@ -202,6 +203,7 @@ static SKeyword keywordTable[] = {
{
"WATERMARK"
,
TK_WATERMARK
},
{
"WATERMARK"
,
TK_WATERMARK
},
{
"WHERE"
,
TK_WHERE
},
{
"WHERE"
,
TK_WHERE
},
{
"WINDOW_CLOSE"
,
TK_WINDOW_CLOSE
},
{
"WINDOW_CLOSE"
,
TK_WINDOW_CLOSE
},
{
"WITH"
,
TK_WITH
},
{
"_QENDTS"
,
TK_QENDTS
},
{
"_QENDTS"
,
TK_QENDTS
},
{
"_QSTARTTS"
,
TK_QSTARTTS
},
{
"_QSTARTTS"
,
TK_QSTARTTS
},
{
"_ROWTS"
,
TK_ROWTS
},
{
"_ROWTS"
,
TK_ROWTS
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
98ce2f57
...
@@ -119,10 +119,8 @@ static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STa
...
@@ -119,10 +119,8 @@ static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STa
}
}
static
int32_t
getTableMeta
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
STableMeta
**
pMeta
)
{
static
int32_t
getTableMeta
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
STableMeta
**
pMeta
)
{
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
name
;
strcpy
(
name
.
dbname
,
pDbName
);
return
getTableMetaImpl
(
pCxt
,
toName
(
pCxt
->
pParseCxt
->
acctId
,
pDbName
,
pTableName
,
&
name
),
pMeta
);
strcpy
(
name
.
tname
,
pTableName
);
return
getTableMetaImpl
(
pCxt
,
&
name
,
pMeta
);
}
}
static
int32_t
getTableDistVgInfo
(
STranslateContext
*
pCxt
,
const
SName
*
pName
,
SArray
**
pVgInfo
)
{
static
int32_t
getTableDistVgInfo
(
STranslateContext
*
pCxt
,
const
SName
*
pName
,
SArray
**
pVgInfo
)
{
...
@@ -181,10 +179,8 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam
...
@@ -181,10 +179,8 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam
static
int32_t
getTableHashVgroup
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
static
int32_t
getTableHashVgroup
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
SVgroupInfo
*
pInfo
)
{
SVgroupInfo
*
pInfo
)
{
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
name
;
strcpy
(
name
.
dbname
,
pDbName
);
return
getTableHashVgroupImpl
(
pCxt
,
toName
(
pCxt
->
pParseCxt
->
acctId
,
pDbName
,
pTableName
,
&
name
),
pInfo
);
strcpy
(
name
.
tname
,
pTableName
);
return
getTableHashVgroupImpl
(
pCxt
,
&
name
,
pInfo
);
}
}
static
int32_t
getDBVgVersion
(
STranslateContext
*
pCxt
,
const
char
*
pDbFName
,
int32_t
*
pVersion
,
int64_t
*
pDbId
,
static
int32_t
getDBVgVersion
(
STranslateContext
*
pCxt
,
const
char
*
pDbFName
,
int32_t
*
pVersion
,
int64_t
*
pDbId
,
...
@@ -938,7 +934,7 @@ static int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STabl
...
@@ -938,7 +934,7 @@ static int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STabl
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
}
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pTableAlias
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pTableAlias
);
}
}
static
int32_t
createTableAllCols
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
,
SNodeList
**
pOutput
)
{
static
int32_t
createTableAllCols
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
,
SNodeList
**
pOutput
)
{
...
@@ -1346,6 +1342,18 @@ static int32_t translateFrom(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -1346,6 +1342,18 @@ static int32_t translateFrom(STranslateContext* pCxt, SSelectStmt* pSelect) {
return
code
;
return
code
;
}
}
static
int32_t
checkLimit
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
if
((
NULL
!=
pSelect
->
pLimit
&&
pSelect
->
pLimit
->
offset
<
0
)
||
(
NULL
!=
pSelect
->
pSlimit
&&
pSelect
->
pSlimit
->
offset
<
0
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_OFFSET_LESS_ZERO
);
}
if
(
NULL
!=
pSelect
->
pSlimit
&&
NULL
==
pSelect
->
pPartitionByList
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateSelect
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
static
int32_t
translateSelect
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
pCxt
->
pCurrStmt
=
pSelect
;
pCxt
->
pCurrStmt
=
pSelect
;
int32_t
code
=
translateFrom
(
pCxt
,
pSelect
);
int32_t
code
=
translateFrom
(
pCxt
,
pSelect
);
...
@@ -1373,6 +1381,9 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -1373,6 +1381,9 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkAggColCoexist
(
pCxt
,
pSelect
);
code
=
checkAggColCoexist
(
pCxt
,
pSelect
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkLimit
(
pCxt
,
pSelect
);
}
return
code
;
return
code
;
}
}
...
@@ -1537,11 +1548,11 @@ static int32_t checkRangeOption(STranslateContext* pCxt, const char* pName, SVal
...
@@ -1537,11 +1548,11 @@ static int32_t checkRangeOption(STranslateContext* pCxt, const char* pName, SVal
}
}
if
(
pVal
->
isDuration
&&
if
(
pVal
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pVal
->
unit
&&
TIME_UNIT_HOUR
!=
pVal
->
unit
&&
TIME_UNIT_DAY
!=
pVal
->
unit
))
{
(
TIME_UNIT_MINUTE
!=
pVal
->
unit
&&
TIME_UNIT_HOUR
!=
pVal
->
unit
&&
TIME_UNIT_DAY
!=
pVal
->
unit
))
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_OPTION_UNIT
,
pName
,
pVal
->
unit
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_OPTION_UNIT
,
pName
,
pVal
->
unit
);
}
}
int64_t
val
=
getBigintFromValueNode
(
pVal
);
int64_t
val
=
getBigintFromValueNode
(
pVal
);
if
(
val
<
minVal
||
val
>
maxVal
)
{
if
(
val
<
minVal
||
val
>
maxVal
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_RANGE_OPTION
,
pName
,
val
,
minVal
,
maxVal
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_RANGE_OPTION
,
pName
,
val
,
minVal
,
maxVal
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1567,7 +1578,7 @@ static int32_t checkDbPrecisionOption(STranslateContext* pCxt, SValueNode* pVal)
...
@@ -1567,7 +1578,7 @@ static int32_t checkDbPrecisionOption(STranslateContext* pCxt, SValueNode* pVal)
}
else
if
(
0
==
strcmp
(
pRrecision
,
TSDB_TIME_PRECISION_NANO_STR
))
{
}
else
if
(
0
==
strcmp
(
pRrecision
,
TSDB_TIME_PRECISION_NANO_STR
))
{
convertValueFromStrToInt
(
pVal
,
TSDB_TIME_PRECISION_NANO
);
convertValueFromStrToInt
(
pVal
,
TSDB_TIME_PRECISION_NANO
);
}
else
{
}
else
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_STR_OPTION
,
"precision"
,
pVal
->
datum
.
p
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STR_OPTION
,
"precision"
,
pVal
->
datum
.
p
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1580,7 +1591,7 @@ static int32_t checkDbEnumOption(STranslateContext* pCxt, const char* pName, SVa
...
@@ -1580,7 +1591,7 @@ static int32_t checkDbEnumOption(STranslateContext* pCxt, const char* pName, SVa
}
}
int64_t
val
=
pVal
->
datum
.
i
;
int64_t
val
=
pVal
->
datum
.
i
;
if
(
val
!=
v1
&&
val
!=
v2
)
{
if
(
val
!=
v1
&&
val
!=
v2
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_ENUM_OPTION
,
pName
,
val
,
v1
,
v2
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ENUM_OPTION
,
pName
,
val
,
v1
,
v2
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1593,7 +1604,7 @@ static int32_t checkTtlOption(STranslateContext* pCxt, SValueNode* pVal) {
...
@@ -1593,7 +1604,7 @@ static int32_t checkTtlOption(STranslateContext* pCxt, SValueNode* pVal) {
}
}
int64_t
val
=
pVal
->
datum
.
i
;
int64_t
val
=
pVal
->
datum
.
i
;
if
(
val
<
TSDB_MIN_DB_TTL
)
{
if
(
val
<
TSDB_MIN_DB_TTL
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_TTL_OPTION
,
val
,
TSDB_MIN_DB_TTL
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TTL_OPTION
,
val
,
TSDB_MIN_DB_TTL
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1606,7 +1617,7 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
...
@@ -1606,7 +1617,7 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
int32_t
numOfKeep
=
LIST_LENGTH
(
pKeep
);
int32_t
numOfKeep
=
LIST_LENGTH
(
pKeep
);
if
(
numOfKeep
>
3
||
numOfKeep
<
1
)
{
if
(
numOfKeep
>
3
||
numOfKeep
<
1
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_NUM
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_KEEP_NUM
);
}
}
SNode
*
pNode
=
NULL
;
SNode
*
pNode
=
NULL
;
...
@@ -1637,7 +1648,7 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
...
@@ -1637,7 +1648,7 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
(
TIME_UNIT_MINUTE
!=
pKeep1
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep1
->
unit
&&
TIME_UNIT_DAY
!=
pKeep1
->
unit
))
||
(
TIME_UNIT_MINUTE
!=
pKeep1
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep1
->
unit
&&
TIME_UNIT_DAY
!=
pKeep1
->
unit
))
||
(
pKeep2
->
isDuration
&&
(
pKeep2
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pKeep2
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep2
->
unit
&&
TIME_UNIT_DAY
!=
pKeep2
->
unit
)))
{
(
TIME_UNIT_MINUTE
!=
pKeep2
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep2
->
unit
&&
TIME_UNIT_DAY
!=
pKeep2
->
unit
)))
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_UNIT
,
pKeep0
->
unit
,
pKeep1
->
unit
,
pKeep2
->
unit
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_KEEP_UNIT
,
pKeep0
->
unit
,
pKeep1
->
unit
,
pKeep2
->
unit
);
}
}
int32_t
daysToKeep0
=
getBigintFromValueNode
(
pKeep0
);
int32_t
daysToKeep0
=
getBigintFromValueNode
(
pKeep0
);
...
@@ -1645,12 +1656,12 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
...
@@ -1645,12 +1656,12 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
int32_t
daysToKeep2
=
getBigintFromValueNode
(
pKeep2
);
int32_t
daysToKeep2
=
getBigintFromValueNode
(
pKeep2
);
if
(
daysToKeep0
<
TSDB_MIN_KEEP
||
daysToKeep1
<
TSDB_MIN_KEEP
||
daysToKeep2
<
TSDB_MIN_KEEP
||
if
(
daysToKeep0
<
TSDB_MIN_KEEP
||
daysToKeep1
<
TSDB_MIN_KEEP
||
daysToKeep2
<
TSDB_MIN_KEEP
||
daysToKeep0
>
TSDB_MAX_KEEP
||
daysToKeep1
>
TSDB_MAX_KEEP
||
daysToKeep2
>
TSDB_MAX_KEEP
)
{
daysToKeep0
>
TSDB_MAX_KEEP
||
daysToKeep1
>
TSDB_MAX_KEEP
||
daysToKeep2
>
TSDB_MAX_KEEP
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_VALUE
,
daysToKeep0
,
daysToKeep1
,
daysToKeep2
,
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_KEEP_VALUE
,
daysToKeep0
,
daysToKeep1
,
daysToKeep2
,
TSDB_MIN_KEEP
,
TSDB_MAX_KEEP
);
TSDB_MIN_KEEP
,
TSDB_MAX_KEEP
);
}
}
if
(
!
((
daysToKeep0
<=
daysToKeep1
)
&&
(
daysToKeep1
<=
daysToKeep2
)))
{
if
(
!
((
daysToKeep0
<=
daysToKeep1
)
&&
(
daysToKeep1
<=
daysToKeep2
)))
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_ORDER
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_KEEP_ORDER
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1662,7 +1673,7 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
...
@@ -1662,7 +1673,7 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
}
}
if
(
LIST_LENGTH
(
pRetentions
)
>
3
)
{
if
(
LIST_LENGTH
(
pRetentions
)
>
3
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION
);
}
}
SNode
*
pNode
=
NULL
;
SNode
*
pNode
=
NULL
;
...
@@ -1678,7 +1689,28 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
...
@@ -1678,7 +1689,28 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
checkDatabaseOptions
(
STranslateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
)
{
static
int32_t
checkOptionsDependency
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
SDatabaseOptions
*
pOptions
,
bool
alter
)
{
if
(
NULL
==
pOptions
->
pDaysPerFile
&&
NULL
==
pOptions
->
pKeep
)
{
return
TSDB_CODE_SUCCESS
;
}
int64_t
daysPerFile
=
GET_OPTION_VAL
(
pOptions
->
pDaysPerFile
,
alter
?
-
1
:
TSDB_DEFAULT_DAYS_PER_FILE
);
int64_t
daysToKeep0
=
GET_OPTION_VAL
(
nodesListGetNode
(
pOptions
->
pKeep
,
0
),
alter
?
-
1
:
TSDB_DEFAULT_KEEP
);
if
(
alter
&&
(
-
1
==
daysPerFile
||
-
1
==
daysToKeep0
))
{
SDbCfgInfo
dbCfg
;
int32_t
code
=
getDBCfg
(
pCxt
,
pDbName
,
&
dbCfg
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
daysPerFile
=
(
-
1
==
daysPerFile
?
dbCfg
.
daysPerFile
:
daysPerFile
);
daysToKeep0
=
(
-
1
==
daysPerFile
?
dbCfg
.
daysToKeep0
:
daysToKeep0
);
}
if
(
daysPerFile
>
daysToKeep0
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_DAYS_VALUE
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
checkDatabaseOptions
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
SDatabaseOptions
*
pOptions
,
bool
alter
)
{
int32_t
code
=
int32_t
code
=
checkRangeOption
(
pCxt
,
"totalBlocks"
,
pOptions
->
pNumOfBlocks
,
TSDB_MIN_TOTAL_BLOCKS
,
TSDB_MAX_TOTAL_BLOCKS
);
checkRangeOption
(
pCxt
,
"totalBlocks"
,
pOptions
->
pNumOfBlocks
,
TSDB_MIN_TOTAL_BLOCKS
,
TSDB_MAX_TOTAL_BLOCKS
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -1739,11 +1771,14 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
...
@@ -1739,11 +1771,14 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkDbEnumOption
(
pCxt
,
"strict"
,
pOptions
->
pStrict
,
TSDB_DB_STRICT_OFF
,
TSDB_DB_STRICT_ON
);
code
=
checkDbEnumOption
(
pCxt
,
"strict"
,
pOptions
->
pStrict
,
TSDB_DB_STRICT_OFF
,
TSDB_DB_STRICT_ON
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkOptionsDependency
(
pCxt
,
pDbName
,
pOptions
,
alter
);
}
return
code
;
return
code
;
}
}
static
int32_t
checkCreateDatabase
(
STranslateContext
*
pCxt
,
SCreateDatabaseStmt
*
pStmt
)
{
static
int32_t
checkCreateDatabase
(
STranslateContext
*
pCxt
,
SCreateDatabaseStmt
*
pStmt
)
{
return
checkDatabaseOptions
(
pCxt
,
pStmt
->
pOptions
);
return
checkDatabaseOptions
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
pOptions
,
false
);
}
}
typedef
int32_t
(
*
FSerializeFunc
)(
void
*
pBuf
,
int32_t
bufLen
,
void
*
pReq
);
typedef
int32_t
(
*
FSerializeFunc
)(
void
*
pBuf
,
int32_t
bufLen
,
void
*
pReq
);
...
@@ -1807,7 +1842,7 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
...
@@ -1807,7 +1842,7 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
}
}
static
int32_t
translateAlterDatabase
(
STranslateContext
*
pCxt
,
SAlterDatabaseStmt
*
pStmt
)
{
static
int32_t
translateAlterDatabase
(
STranslateContext
*
pCxt
,
SAlterDatabaseStmt
*
pStmt
)
{
int32_t
code
=
checkDatabaseOptions
(
pCxt
,
pStmt
->
pOptions
);
int32_t
code
=
checkDatabaseOptions
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
pOptions
,
true
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
return
code
;
}
}
...
@@ -1868,7 +1903,7 @@ static int32_t checkTableCommentOption(STranslateContext* pCxt, SValueNode* pVal
...
@@ -1868,7 +1903,7 @@ static int32_t checkTableCommentOption(STranslateContext* pCxt, SValueNode* pVal
return
pCxt
->
errCode
;
return
pCxt
->
errCode
;
}
}
if
(
pVal
->
node
.
resType
.
bytes
>=
TSDB_STB_COMMENT_LEN
)
{
if
(
pVal
->
node
.
resType
.
bytes
>=
TSDB_STB_COMMENT_LEN
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_COMMENT_OPTION
,
TSDB_STB_COMMENT_LEN
-
1
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_COMMENT_OPTION
,
TSDB_STB_COMMENT_LEN
-
1
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1880,7 +1915,7 @@ static int32_t checTableFactorOption(STranslateContext* pCxt, SValueNode* pVal)
...
@@ -1880,7 +1915,7 @@ static int32_t checTableFactorOption(STranslateContext* pCxt, SValueNode* pVal)
return
pCxt
->
errCode
;
return
pCxt
->
errCode
;
}
}
if
(
pVal
->
datum
.
d
<
TSDB_MIN_DB_FILE_FACTOR
||
pVal
->
datum
.
d
>
TSDB_MAX_DB_FILE_FACTOR
)
{
if
(
pVal
->
datum
.
d
<
TSDB_MIN_DB_FILE_FACTOR
||
pVal
->
datum
.
d
>
TSDB_MAX_DB_FILE_FACTOR
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_F_RANGE_OPTION
,
"file_factor"
,
pVal
->
datum
.
d
,
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_F_RANGE_OPTION
,
"file_factor"
,
pVal
->
datum
.
d
,
TSDB_MIN_DB_FILE_FACTOR
,
TSDB_MAX_DB_FILE_FACTOR
);
TSDB_MIN_DB_FILE_FACTOR
,
TSDB_MAX_DB_FILE_FACTOR
);
}
}
}
}
...
@@ -1921,12 +1956,12 @@ static int32_t checkTableRollupOption(STranslateContext* pCxt, SNodeList* pFuncs
...
@@ -1921,12 +1956,12 @@ static int32_t checkTableRollupOption(STranslateContext* pCxt, SNodeList* pFuncs
}
}
if
(
1
!=
LIST_LENGTH
(
pFuncs
))
{
if
(
1
!=
LIST_LENGTH
(
pFuncs
))
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
);
}
}
SFunctionNode
*
pFunc
=
nodesListGetNode
(
pFuncs
,
0
);
SFunctionNode
*
pFunc
=
nodesListGetNode
(
pFuncs
,
0
);
SFmGetFuncInfoParam
param
=
{
.
pCtg
=
pCxt
->
pParseCxt
->
pCatalog
,
.
pRpc
=
pCxt
->
pParseCxt
->
pTransporter
,
.
pMgmtEps
=
&
pCxt
->
pParseCxt
->
mgmtEpSet
};
SFmGetFuncInfoParam
param
=
{
.
pCtg
=
pCxt
->
pParseCxt
->
pCatalog
,
.
pRpc
=
pCxt
->
pParseCxt
->
pTransporter
,
.
pMgmtEps
=
&
pCxt
->
pParseCxt
->
mgmtEpSet
};
if
(
TSDB_CODE_SUCCESS
!=
fmGetFuncInfo
(
&
param
,
pFunc
->
functionName
,
&
pFunc
->
funcId
,
&
pFunc
->
funcType
))
{
if
(
TSDB_CODE_SUCCESS
!=
fmGetFuncInfo
(
&
param
,
pFunc
->
functionName
,
&
pFunc
->
funcId
,
&
pFunc
->
funcType
))
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_FUNTION
,
pFunc
->
functionName
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_FUNTION
,
pFunc
->
functionName
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2200,10 +2235,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
...
@@ -2200,10 +2235,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
pReq
->
numOfSmas
=
LIST_LENGTH
(
pStmt
->
pOptions
->
pSma
);
pReq
->
numOfSmas
=
LIST_LENGTH
(
pStmt
->
pOptions
->
pSma
);
}
}
SName
tableName
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
tableName
;
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
pReq
->
name
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
tNameExtractFullName
(
&
tableName
,
pReq
->
name
);
return
buildRollupAst
(
pCxt
,
pStmt
,
pReq
);
return
buildRollupAst
(
pCxt
,
pStmt
,
pReq
);
}
}
...
@@ -2253,10 +2286,8 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt
...
@@ -2253,10 +2286,8 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt
}
}
static
int32_t
translateDropSuperTable
(
STranslateContext
*
pCxt
,
SDropSuperTableStmt
*
pStmt
)
{
static
int32_t
translateDropSuperTable
(
STranslateContext
*
pCxt
,
SDropSuperTableStmt
*
pStmt
)
{
SName
tableName
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
tableName
;
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
return
doTranslateDropSuperTable
(
pCxt
,
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
pStmt
->
ignoreNotExists
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
return
doTranslateDropSuperTable
(
pCxt
,
&
tableName
,
pStmt
->
ignoreNotExists
);
}
}
static
int32_t
setAlterTableField
(
SAlterTableStmt
*
pStmt
,
SMAltertbReq
*
pAlterReq
)
{
static
int32_t
setAlterTableField
(
SAlterTableStmt
*
pStmt
,
SMAltertbReq
*
pAlterReq
)
{
...
@@ -2296,10 +2327,8 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterRe
...
@@ -2296,10 +2327,8 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterRe
static
int32_t
translateAlterTable
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
static
int32_t
translateAlterTable
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
SMAltertbReq
alterReq
=
{
0
};
SMAltertbReq
alterReq
=
{
0
};
SName
tableName
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
tableName
;
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
alterReq
.
name
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
tNameExtractFullName
(
&
tableName
,
alterReq
.
name
);
alterReq
.
alterType
=
pStmt
->
alterType
;
alterReq
.
alterType
=
pStmt
->
alterType
;
alterReq
.
numOfFields
=
1
;
alterReq
.
numOfFields
=
1
;
if
(
TSDB_ALTER_TABLE_UPDATE_OPTIONS
==
pStmt
->
alterType
)
{
if
(
TSDB_ALTER_TABLE_UPDATE_OPTIONS
==
pStmt
->
alterType
)
{
...
@@ -2389,8 +2418,6 @@ static int32_t nodeTypeToShowType(ENodeType nt) {
...
@@ -2389,8 +2418,6 @@ static int32_t nodeTypeToShowType(ENodeType nt) {
return
TSDB_MGMT_TABLE_GRANTS
;
return
TSDB_MGMT_TABLE_GRANTS
;
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
return
TSDB_MGMT_TABLE_QUERIES
;
return
TSDB_MGMT_TABLE_QUERIES
;
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
0
;
// todo
case
QUERY_NODE_SHOW_VARIABLE_STMT
:
case
QUERY_NODE_SHOW_VARIABLE_STMT
:
return
0
;
// todo
return
0
;
// todo
default:
default:
...
@@ -2452,10 +2479,8 @@ static int32_t getSmaIndexAst(STranslateContext* pCxt, SCreateIndexStmt* pStmt,
...
@@ -2452,10 +2479,8 @@ static int32_t getSmaIndexAst(STranslateContext* pCxt, SCreateIndexStmt* pStmt,
}
}
static
int32_t
buildCreateSmaReq
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
SMCreateSmaReq
*
pReq
)
{
static
int32_t
buildCreateSmaReq
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
SMCreateSmaReq
*
pReq
)
{
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
name
;
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
pStmt
->
indexName
,
&
name
),
pReq
->
name
);
strcpy
(
name
.
tname
,
pStmt
->
indexName
);
tNameExtractFullName
(
&
name
,
pReq
->
name
);
strcpy
(
name
.
tname
,
pStmt
->
tableName
);
strcpy
(
name
.
tname
,
pStmt
->
tableName
);
name
.
tname
[
strlen
(
pStmt
->
tableName
)]
=
'\0'
;
name
.
tname
[
strlen
(
pStmt
->
tableName
)]
=
'\0'
;
tNameExtractFullName
(
&
name
,
pReq
->
stb
);
tNameExtractFullName
(
&
name
,
pReq
->
stb
);
...
@@ -2610,11 +2635,14 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
...
@@ -2610,11 +2635,14 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
}
;
SName
name
;
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
// tNameSetDbName(&name, pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, strlen(pCxt->pParseCxt->db)
);
strcpy
(
name
.
tname
,
pStmt
->
topicN
ame
);
// tNameGetFullDbName(&name, createReq.n
ame);
tNameExtractFullName
(
&
name
,
createReq
.
name
);
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
pStmt
->
topicName
,
&
name
)
,
createReq
.
name
);
createReq
.
igExists
=
pStmt
->
ignoreExists
;
createReq
.
igExists
=
pStmt
->
ignoreExists
;
createReq
.
withTbName
=
pStmt
->
pOptions
->
withTable
;
createReq
.
withSchema
=
pStmt
->
pOptions
->
withSchema
;
createReq
.
withTag
=
pStmt
->
pOptions
->
withTag
;
int32_t
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_CREATE_TOPIC
,
(
FSerializeFunc
)
tSerializeSCMCreateTopicReq
,
&
createReq
);
int32_t
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_CREATE_TOPIC
,
(
FSerializeFunc
)
tSerializeSCMCreateTopicReq
,
&
createReq
);
tFreeSCMCreateTopicReq
(
&
createReq
);
tFreeSCMCreateTopicReq
(
&
createReq
);
...
@@ -2624,10 +2652,8 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
...
@@ -2624,10 +2652,8 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
static
int32_t
translateDropTopic
(
STranslateContext
*
pCxt
,
SDropTopicStmt
*
pStmt
)
{
static
int32_t
translateDropTopic
(
STranslateContext
*
pCxt
,
SDropTopicStmt
*
pStmt
)
{
SMDropTopicReq
dropReq
=
{
0
};
SMDropTopicReq
dropReq
=
{
0
};
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
name
;
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
pStmt
->
topicName
,
&
name
),
dropReq
.
name
);
strcpy
(
name
.
tname
,
pStmt
->
topicName
);
tNameExtractFullName
(
&
name
,
dropReq
.
name
);
dropReq
.
igNotExists
=
pStmt
->
ignoreNotExists
;
dropReq
.
igNotExists
=
pStmt
->
ignoreNotExists
;
return
buildCmdMsg
(
pCxt
,
TDMT_MND_DROP_TOPIC
,
(
FSerializeFunc
)
tSerializeSMDropTopicReq
,
&
dropReq
);
return
buildCmdMsg
(
pCxt
,
TDMT_MND_DROP_TOPIC
,
(
FSerializeFunc
)
tSerializeSMDropTopicReq
,
&
dropReq
);
...
@@ -2666,10 +2692,8 @@ static int32_t translateCreateStream(STranslateContext* pCxt, SCreateStreamStmt*
...
@@ -2666,10 +2692,8 @@ static int32_t translateCreateStream(STranslateContext* pCxt, SCreateStreamStmt*
createReq
.
igExists
=
pStmt
->
ignoreExists
;
createReq
.
igExists
=
pStmt
->
ignoreExists
;
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
name
;
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
pStmt
->
streamName
,
&
name
),
createReq
.
name
);
strcpy
(
name
.
tname
,
pStmt
->
streamName
);
tNameExtractFullName
(
&
name
,
createReq
.
name
);
if
(
'\0'
!=
pStmt
->
targetTabName
[
0
])
{
if
(
'\0'
!=
pStmt
->
targetTabName
[
0
])
{
strcpy
(
name
.
dbname
,
pStmt
->
targetDbName
);
strcpy
(
name
.
dbname
,
pStmt
->
targetDbName
);
...
@@ -2984,6 +3008,7 @@ static const char* getSysDbName(ENodeType type) {
...
@@ -2984,6 +3008,7 @@ static const char* getSysDbName(ENodeType type) {
return
TSDB_INFORMATION_SCHEMA_DB
;
return
TSDB_INFORMATION_SCHEMA_DB
;
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
TSDB_PERFORMANCE_SCHEMA_DB
;
return
TSDB_PERFORMANCE_SCHEMA_DB
;
default:
default:
break
;
break
;
...
@@ -3029,6 +3054,8 @@ static const char* getSysTableName(ENodeType type) {
...
@@ -3029,6 +3054,8 @@ static const char* getSysTableName(ENodeType type) {
return
TSDB_PERFS_TABLE_CONNECTIONS
;
return
TSDB_PERFS_TABLE_CONNECTIONS
;
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
return
TSDB_PERFS_TABLE_QUERIES
;
return
TSDB_PERFS_TABLE_QUERIES
;
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
TSDB_PERFS_TABLE_TOPICS
;
default:
default:
break
;
break
;
}
}
...
@@ -3550,6 +3577,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -3550,6 +3577,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_CLUSTER_STMT
:
case
QUERY_NODE_SHOW_CLUSTER_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
code
=
rewriteShow
(
pCxt
,
pQuery
);
code
=
rewriteShow
(
pCxt
,
pQuery
);
break
;
break
;
case
QUERY_NODE_CREATE_TABLE_STMT
:
case
QUERY_NODE_CREATE_TABLE_STMT
:
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
98ce2f57
...
@@ -23,15 +23,15 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -23,15 +23,15 @@ static char* getSyntaxErrFormat(int32_t errCode) {
case
TSDB_CODE_PAR_INCOMPLETE_SQL
:
case
TSDB_CODE_PAR_INCOMPLETE_SQL
:
return
"Incomplete SQL statement"
;
return
"Incomplete SQL statement"
;
case
TSDB_CODE_PAR_INVALID_COLUMN
:
case
TSDB_CODE_PAR_INVALID_COLUMN
:
return
"Invalid column name
: %s"
;
return
"Invalid column name: %s"
;
case
TSDB_CODE_PAR_TABLE_NOT_EXIST
:
case
TSDB_CODE_PAR_TABLE_NOT_EXIST
:
return
"Table does not exist
: %s"
;
return
"Table does not exist: %s"
;
case
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
:
case
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
:
return
"Column ambiguously defined
: %s"
;
return
"Column ambiguously defined: %s"
;
case
TSDB_CODE_PAR_WRONG_VALUE_TYPE
:
case
TSDB_CODE_PAR_WRONG_VALUE_TYPE
:
return
"Invalid value type
: %s"
;
return
"Invalid value type: %s"
;
case
TSDB_CODE_PAR_INVALID_FUNTION
:
case
TSDB_CODE_PAR_INVALID_FUNTION
:
return
"Invalid function name
: %s"
;
return
"Invalid function name: %s"
;
case
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
:
case
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
:
return
"There mustn't be aggregation"
;
return
"There mustn't be aggregation"
;
case
TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
:
case
TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
:
...
@@ -45,7 +45,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -45,7 +45,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
case
TSDB_CODE_PAR_TAGS_NOT_MATCHED
:
case
TSDB_CODE_PAR_TAGS_NOT_MATCHED
:
return
"Tags number not matched"
;
return
"Tags number not matched"
;
case
TSDB_CODE_PAR_INVALID_TAG_NAME
:
case
TSDB_CODE_PAR_INVALID_TAG_NAME
:
return
"Invalid tag name
: %s"
;
return
"Invalid tag name: %s"
;
case
TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG
:
case
TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG
:
return
"Name or password too long"
;
return
"Name or password too long"
;
case
TSDB_CODE_PAR_PASSWD_EMPTY
:
case
TSDB_CODE_PAR_PASSWD_EMPTY
:
...
@@ -61,7 +61,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -61,7 +61,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
case
TSDB_CODE_PAR_DB_NOT_SPECIFIED
:
case
TSDB_CODE_PAR_DB_NOT_SPECIFIED
:
return
"Database not specified"
;
return
"Database not specified"
;
case
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
:
case
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
:
return
"Invalid identifier name
: %s"
;
return
"Invalid identifier name: %s"
;
case
TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR
:
case
TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR
:
return
"Corresponding super table not in this db"
;
return
"Corresponding super table not in this db"
;
case
TSDB_CODE_PAR_INVALID_RANGE_OPTION
:
case
TSDB_CODE_PAR_INVALID_RANGE_OPTION
:
...
@@ -120,6 +120,14 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -120,6 +120,14 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"Only one tag if there is a json tag"
;
return
"Only one tag if there is a json tag"
;
case
TSDB_CODE_PAR_INCORRECT_NUM_OF_COL
:
case
TSDB_CODE_PAR_INCORRECT_NUM_OF_COL
:
return
"Query block has incorrect number of result columns"
;
return
"Query block has incorrect number of result columns"
;
case
TSDB_CODE_PAR_INCORRECT_TIMESTAMP_VAL
:
return
"Incorrect TIMESTAMP value: %s"
;
case
TSDB_CODE_PAR_INVALID_DAYS_VALUE
:
return
"Invalid days value, should be keep2 >= keep1 >= keep0 >= days"
;
case
TSDB_CODE_PAR_OFFSET_LESS_ZERO
:
return
"soffset/offset can not be less than 0"
;
case
TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY
:
return
"slimit/soffset only available for PARTITION BY query"
;
case
TSDB_CODE_OUT_OF_MEMORY
:
case
TSDB_CODE_OUT_OF_MEMORY
:
return
"Out of memory"
;
return
"Out of memory"
;
default:
default:
...
...
source/libs/parser/src/sql.c
浏览文件 @
98ce2f57
此差异已折叠。
点击以展开。
source/libs/planner/inc/planInt.h
浏览文件 @
98ce2f57
...
@@ -22,6 +22,10 @@ extern "C" {
...
@@ -22,6 +22,10 @@ extern "C" {
#include "planner.h"
#include "planner.h"
#define QUERY_POLICY_VNODE 1
#define QUERY_POLICY_HYBRID 2
#define QUERY_POLICY_QNODE 3
#define planFatal(param, ...) qFatal("PLAN: " param, __VA_ARGS__)
#define planFatal(param, ...) qFatal("PLAN: " param, __VA_ARGS__)
#define planError(param, ...) qError("PLAN: " param, __VA_ARGS__)
#define planError(param, ...) qError("PLAN: " param, __VA_ARGS__)
#define planWarn(param, ...) qWarn("PLAN: " param, __VA_ARGS__)
#define planWarn(param, ...) qWarn("PLAN: " param, __VA_ARGS__)
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
98ce2f57
...
@@ -639,8 +639,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
...
@@ -639,8 +639,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
}
}
if
(
NULL
!=
pSelect
->
pLimit
)
{
if
(
NULL
!=
pSelect
->
pLimit
)
{
pProject
->
limit
=
((
SLimitNode
*
)
pSelect
->
pLimit
)
->
limit
;
pProject
->
limit
=
pSelect
->
pLimit
->
limit
;
pProject
->
offset
=
((
SLimitNode
*
)
pSelect
->
pLimit
)
->
offset
;
pProject
->
offset
=
pSelect
->
pLimit
->
offset
;
}
else
{
}
else
{
pProject
->
limit
=
-
1
;
pProject
->
limit
=
-
1
;
pProject
->
offset
=
-
1
;
pProject
->
offset
=
-
1
;
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
98ce2f57
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#include "planInt.h"
#include "planInt.h"
#include "functionMgt.h"
#include "functionMgt.h"
#include "tglobal.h"
#include "catalog.h"
typedef
struct
SSlotIdInfo
{
typedef
struct
SSlotIdInfo
{
int16_t
slotId
;
int16_t
slotId
;
...
@@ -1233,7 +1235,13 @@ int32_t createPhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryP
...
@@ -1233,7 +1235,13 @@ int32_t createPhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryP
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
int32_t
code
=
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
pPlan
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
tsQueryPolicy
>
QUERY_POLICY_VNODE
)
{
code
=
catalogGetQnodeList
(
pCxt
->
pCatalog
,
pCxt
->
pTransporter
,
&
pCxt
->
mgmtEpSet
,
pExecNodeList
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
pPlan
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
setExplainInfo
(
pCxt
,
*
pPlan
);
setExplainInfo
(
pCxt
,
*
pPlan
);
}
}
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
98ce2f57
...
@@ -644,9 +644,9 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
...
@@ -644,9 +644,9 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
}
}
int32_t
castFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int32_t
castFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int16_t
inputType
=
pInput
[
0
].
columnData
->
info
.
type
;
int16_t
inputType
=
GET_PARAM_TYPE
(
&
pInput
[
0
])
;
int16_t
outputType
=
pOutput
[
0
].
columnData
->
info
.
type
;
int16_t
outputType
=
GET_PARAM_TYPE
(
&
pOutput
[
0
])
;
int64_t
outputLen
=
pOutput
[
0
].
columnData
->
info
.
bytes
;
int64_t
outputLen
=
GET_PARAM_BYTES
(
&
pOutput
[
0
])
;
if
(
IS_VAR_DATA_TYPE
(
outputType
))
{
if
(
IS_VAR_DATA_TYPE
(
outputType
))
{
int32_t
factor
=
(
TSDB_DATA_TYPE_NCHAR
==
outputType
)
?
TSDB_NCHAR_SIZE
:
1
;
int32_t
factor
=
(
TSDB_DATA_TYPE_NCHAR
==
outputType
)
?
TSDB_NCHAR_SIZE
:
1
;
...
@@ -884,13 +884,13 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
...
@@ -884,13 +884,13 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
char
*
input
=
pInput
[
0
].
columnData
->
pData
+
pInput
[
0
].
columnData
->
varmeta
.
offset
[
0
];
char
tmp
[
TSDB_MAX_JSON_TAG_LEN
]
=
{
0
};
char
*
tmp
=
taosMemoryCalloc
(
pInput
[
0
].
columnData
->
info
.
bytes
+
1
,
1
);
for
(
int32_t
i
=
0
;
i
<
pInput
[
0
].
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInput
[
0
].
numOfRows
;
++
i
)
{
if
(
colDataIsNull_s
(
pInput
[
0
].
columnData
,
i
))
{
if
(
colDataIsNull_s
(
pInput
[
0
].
columnData
,
i
))
{
colDataAppendNULL
(
pOutput
->
columnData
,
i
);
colDataAppendNULL
(
pOutput
->
columnData
,
i
);
continue
;
continue
;
}
}
char
*
input
=
pInput
[
0
].
columnData
->
pData
+
pInput
[
0
].
columnData
->
varmeta
.
offset
[
i
];
if
(
type
==
TSDB_DATA_TYPE_NCHAR
){
if
(
type
==
TSDB_DATA_TYPE_NCHAR
){
if
(
varDataTLen
(
input
)
>
TSDB_MAX_JSON_TAG_LEN
){
if
(
varDataTLen
(
input
)
>
TSDB_MAX_JSON_TAG_LEN
){
...
@@ -909,7 +909,7 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
...
@@ -909,7 +909,7 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
continue
;
continue
;
}
}
memcpy
(
tmp
,
varDataVal
(
input
),
varDataLen
(
input
));
memcpy
(
tmp
,
varDataVal
(
input
),
varDataLen
(
input
));
tmp
[
varData
T
Len
(
input
)]
=
0
;
tmp
[
varDataLen
(
input
)]
=
0
;
}
}
if
(
!
tjsonValidateJson
(
tmp
)){
if
(
!
tjsonValidateJson
(
tmp
)){
...
@@ -918,9 +918,7 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
...
@@ -918,9 +918,7 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
}
}
colDataAppend
(
pOutput
->
columnData
,
i
,
input
,
false
);
colDataAppend
(
pOutput
->
columnData
,
i
,
input
,
false
);
input
+=
varDataTLen
(
input
);
}
}
taosMemoryFree
(
tmp
);
pOutput
->
numOfRows
=
pInput
->
numOfRows
;
pOutput
->
numOfRows
=
pInput
->
numOfRows
;
...
...
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
98ce2f57
...
@@ -159,10 +159,9 @@ void scltMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, in
...
@@ -159,10 +159,9 @@ void scltMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, in
idata
.
info
.
colId
=
3
;
idata
.
info
.
colId
=
3
;
int32_t
size
=
idata
.
info
.
bytes
*
rowNum
;
int32_t
size
=
idata
.
info
.
bytes
*
rowNum
;
idata
.
pData
=
(
char
*
)
taosMemoryCalloc
(
1
,
size
);
idata
.
pData
=
(
char
*
)
taosMemoryCalloc
(
1
,
size
);
colInfoDataEnsureCapacity
(
&
idata
,
0
,
rowNum
);
taosArrayPush
(
res
->
pDataBlock
,
&
idata
);
taosArrayPush
(
res
->
pDataBlock
,
&
idata
);
blockDataEnsureCapacity
(
res
,
rowNum
);
SColumnInfoData
*
pColumn
=
(
SColumnInfoData
*
)
taosArrayGetLast
(
res
->
pDataBlock
);
SColumnInfoData
*
pColumn
=
(
SColumnInfoData
*
)
taosArrayGetLast
(
res
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
colDataAppend
(
pColumn
,
i
,
(
const
char
*
)
value
,
false
);
colDataAppend
(
pColumn
,
i
,
(
const
char
*
)
value
,
false
);
...
...
source/util/src/tjson.c
浏览文件 @
98ce2f57
...
@@ -300,8 +300,8 @@ bool tjsonValidateJson(const char *jIn) {
...
@@ -300,8 +300,8 @@ bool tjsonValidateJson(const char *jIn) {
char
*
jsonKey
=
item
->
string
;
char
*
jsonKey
=
item
->
string
;
if
(
!
jsonKey
)
return
false
;
if
(
!
jsonKey
)
return
false
;
for
(
size_t
j
=
0
;
j
<
strlen
(
jsonKey
);
++
i
)
{
for
(
size_t
j
=
0
;
j
<
strlen
(
jsonKey
);
++
j
)
{
if
(
isprint
(
jsonKey
[
i
])
==
0
)
return
false
;
if
(
isprint
(
jsonKey
[
j
])
==
0
)
return
false
;
}
}
if
(
item
->
type
==
cJSON_Object
||
item
->
type
==
cJSON_Array
)
{
if
(
item
->
type
==
cJSON_Object
||
item
->
type
==
cJSON_Array
)
{
...
...
tests/pytest/util/sql.py
浏览文件 @
98ce2f57
...
@@ -60,6 +60,7 @@ class TDSql:
...
@@ -60,6 +60,7 @@ class TDSql:
self
.
cursor
.
execute
(
s
)
self
.
cursor
.
execute
(
s
)
s
=
'use db'
s
=
'use db'
self
.
cursor
.
execute
(
s
)
self
.
cursor
.
execute
(
s
)
time
.
sleep
(
2
)
def
error
(
self
,
sql
):
def
error
(
self
,
sql
):
expectErrNotOccured
=
True
expectErrNotOccured
=
True
...
...
tests/script/jenkins/basic.txt
浏览文件 @
98ce2f57
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
# ---- db
# ---- db
./test.sh -f tsim/db/create_all_options.sim
./test.sh -f tsim/db/create_all_options.sim
./test.sh -f tsim/db/alter_option.sim
#
./test.sh -f tsim/db/alter_option.sim
./test.sh -f tsim/db/basic1.sim
./test.sh -f tsim/db/basic1.sim
./test.sh -f tsim/db/basic2.sim
./test.sh -f tsim/db/basic2.sim
./test.sh -f tsim/db/basic3.sim
./test.sh -f tsim/db/basic3.sim
...
@@ -54,19 +54,10 @@
...
@@ -54,19 +54,10 @@
./test.sh -f tsim/table/basic1.sim
./test.sh -f tsim/table/basic1.sim
# ---- tmq
# ---- tmq
./test.sh -f tsim/tmq/basic.sim
./test.sh -f tsim/tmq/basic1.sim
#./test.sh -f tsim/tmq/basic1.sim
./test.sh -f tsim/tmq/basic2.sim
#./test.sh -f tsim/tmq/oneTopic.sim
./test.sh -f tsim/tmq/basic3.sim
#./test.sh -f tsim/tmq/multiTopic.sim
./test.sh -f tsim/tmq/basic4.sim
#./test.sh -f tsim/tmq/mainConsumerInMultiTopic.sim
#./test.sh -f tsim/tmq/mainConsumerInOneTopic.sim
#fail ./test.sh -f tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim
#fail ./test.sh -f tsim/tmq/main2Con1Cgrp1TopicFrStb.sim
#./test.sh -f tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim
#./test.sh -f tsim/tmq/main2Con1Cgrp2TopicFrStb.sim
# --- stable
# --- stable
./test.sh -f tsim/stable/disk.sim
./test.sh -f tsim/stable/disk.sim
...
@@ -85,7 +76,7 @@
...
@@ -85,7 +76,7 @@
./test.sh -f tsim/insert/backquote.sim -m
./test.sh -f tsim/insert/backquote.sim -m
./test.sh -f tsim/parser/fourArithmetic-basic.sim -m
./test.sh -f tsim/parser/fourArithmetic-basic.sim -m
./test.sh -f tsim/query/interval-offset.sim -m
./test.sh -f tsim/query/interval-offset.sim -m
./test.sh -f tsim/tmq/basic.sim -m
#
./test.sh -f tsim/tmq/basic.sim -m
./test.sh -f tsim/stable/vnode3.sim -m
./test.sh -f tsim/stable/vnode3.sim -m
./test.sh -f tsim/qnode/basic1.sim -m
./test.sh -f tsim/qnode/basic1.sim -m
./test.sh -f tsim/mnode/basic1.sim -m
./test.sh -f tsim/mnode/basic1.sim -m
...
...
tests/script/sh/checkValgrind.sh
浏览文件 @
98ce2f57
...
@@ -34,5 +34,6 @@ LOG_DIR=$TAOS_DIR/sim/$NODE_NAME/log
...
@@ -34,5 +34,6 @@ LOG_DIR=$TAOS_DIR/sim/$NODE_NAME/log
#echo ---- $LOG_DIR
#echo ---- $LOG_DIR
errors
=
`
grep
"ERROR SUMMARY:"
${
LOG_DIR
}
/valgrind-taosd-
*
.log |
cut
-d
' '
-f
2,3,4,5 |
tr
-d
"
\n
"
`
#errors=`grep "ERROR SUMMARY:" ${LOG_DIR}/valgrind-taosd-*.log | cut -d ' ' -f 2,3,4,5 | tr -d "\n"`
errors
=
`
cat
${
LOG_DIR
}
/valgrind-taosd-
*
.log |
grep
"ERROR SUMMARY:"
|
awk
'{print $4}'
|
awk
'{sum+=$1}END{print sum}'
`
echo
$errors
echo
$errors
tests/script/tsim/db/alter_option.sim
浏览文件 @
98ce2f57
...
@@ -183,10 +183,10 @@ sql_error alter database db days 0
...
@@ -183,10 +183,10 @@ sql_error alter database db days 0
sql_error alter database db days 14400 # set over than keep
sql_error alter database db days 14400 # set over than keep
print ============== modify keep
print ============== modify keep
sql alter database db keep
2
000
sql alter database db keep
3456
000
sql show databases
sql show databases
print keep $data7_db
print keep $data7_db
if $data7_db !=
2000,2000,2
000 then
if $data7_db !=
3456000,3456000,3456
000 then
return -1
return -1
endi
endi
...
...
tests/script/tsim/tmq/basic.sim
已删除
100644 → 0
浏览文件 @
bb815260
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wal -v 1
system sh/exec.sh -n dnode1 -s start
sleep 500
sql connect
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 100
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
#root@trd02 /data2/dnode $ tmq_demo --help
#Used to tmq_demo
# -c Configuration directory, default is
# -d The name of the database to be created, default is tmqdb
# -s The name of the super table to be created, default is stb
# -f The file of result, default is ./tmqResult.txt
# -w The path of vnode of wal, default is /data2/dnode/data/vnodes/vnode2/wal
# -t numOfThreads, default is 1
# -n numOfTables, default is 1
# -v numOfVgroups, default is 1
# -a runMode, default is 0
# -l numOfColumn, default is 1
# -q ratio, default is 1.000000
# -b batchNumOfRow, default is 1
# -r totalRowsOfPerTbl, default is 10000
# -m startTimestamp, default is 1640966400000 [2022-01-01 00:00:00]
# -g showMsgFlag, default is 0
#
system_content echo -n \$BUILD_DIR
$tmq_demo = $system_content . /build/bin/tmq_demo
system_content echo -n \$SIM_DIR
$tsim_cfg = $system_content . /tsim/cfg
$sim_wal = $system_content . /dnode1/data/vnode/vnode4/wal
print cmd===> system_content $tmq_demo -sim 1 -b 100 -c $tsim_cfg -w $sim_wal
system_content $tmq_demo -sim 1 -b 100 -c $tsim_cfg -w $sim_wal
print cmd result----> $system_content
if $system_content != @{consume success: 100}@ then
return -1
endi
sql show databases
print ===> $rows $data00 $data01 $data02 $data03
if $rows != 3 then
return -1
endi
if $data20 != tmqdb then
return -1
endi
sql use tmqdb
sql show tables
print ===> $rows $data00 $data01 $data02 $data03
if $rows != 1 then
return -1
endi
if $data00 != stb0 then
return -1
endi
sql select count(*) from stb0
print ===> $rows $data00 $data01 $data02 $data03
if $rows != 1 then
return -1
endi
if $data00 != 10000 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/basic1.sim
浏览文件 @
98ce2f57
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
# vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
#basic1.sim: vgroups=1, one topic for one consumer, firstly insert data, then start consume. Include six topics
# vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
#basic2.sim: vgroups=1, multi topics for one consumer, firstly insert data, then start consume. Include six topics
# vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
#basic3.sim: vgroups=4, one topic for one consumer, firstly insert data, then start consume. Include six topics
# vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
#basic4.sim: vgroups=4, multi topics for one consumer, firstly insert data, then start consume. Include six topics
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
#
run tsim/tmq/prepareBasicEnv.sim
run tsim/tmq/prepareBasicEnv
-1vgrp
.sim
#---- global parameters start ----#
#---- global parameters start ----#
$dbName = db
$dbName = db
...
@@ -20,11 +21,11 @@ $ntbPrefix = ntb
...
@@ -20,11 +21,11 @@ $ntbPrefix = ntb
$stbNum = 1
$stbNum = 1
$ctbNum = 10
$ctbNum = 10
$ntbNum = 10
$ntbNum = 10
$rowsPerCtb = 10
0
$rowsPerCtb = 10
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#---- global parameters end ----#
#---- global parameters end ----#
$pullDelay =
3
$pullDelay =
5
$ifcheckdata = 1
$ifcheckdata = 1
$showMsg = 1
$showMsg = 1
$showRow = 0
$showRow = 0
...
@@ -55,9 +56,33 @@ sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb0
...
@@ -55,9 +56,33 @@ sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb0
$keyList = ' . group.id:cgrp1
$keyList = ' . group.id:cgrp1
$keyList = $keyList . '
$keyList = $keyList . '
$cdb_index = 0
#=============================== start consume =============================#
print ================ test consume from stb
print ================ test consume from stb
$loop_cnt = 0
$loop_cnt = 0
loop_consume_diff_topic_from_stb:
loop_consume_diff_topic_from_stb:
#######################################################################################
# clear consume info and consume result
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
$cdb_index = $cdb_index + 1
$cdbName = cdb . $cdb_index
sql create database $cdbName vgroups 1
sleep 500
sql use $cdbName
print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
sql show tables
if $rows != 2 then
return -1
endi
#######################################################################################
if $loop_cnt == 0 then
if $loop_cnt == 0 then
print == scenario 1: topic_stb_column
print == scenario 1: topic_stb_column
$topicList = ' . topic_stb_column
$topicList = ' . topic_stb_column
...
@@ -76,13 +101,12 @@ endi
...
@@ -76,13 +101,12 @@ endi
$consumerId = 0
$consumerId = 0
$totalMsgOfStb = $ctbNum * $rowsPerCtb
$totalMsgOfStb = $ctbNum * $rowsPerCtb
#$expectmsgcnt = $totalMsgOfStb + 1
$expectmsgcnt = $totalMsgOfStb
$expectmsgcnt = 110
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $
c
dbName -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $
c
dbName -s start
print == check consume result
print == check consume result
wait_consumer_end_from_stb:
wait_consumer_end_from_stb:
...
@@ -106,11 +130,16 @@ $loop_cnt = $loop_cnt + 1
...
@@ -106,11 +130,16 @@ $loop_cnt = $loop_cnt + 1
goto loop_consume_diff_topic_from_stb
goto loop_consume_diff_topic_from_stb
loop_consume_diff_topic_from_stb_end:
loop_consume_diff_topic_from_stb_end:
print ================ test consume from ctb
$loop_cnt = 0
loop_consume_diff_topic_from_ctb:
#######################################################################################
#######################################################################################
# clear consume info and consume result
# clear consume info and consume result
#run tsim/tmq/clearConsume.sim
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
# because drop table function no stable, so by create new db for consume info and result. Modify it later
$cdbName = cdb1
$cdb_index = $cdb_index + 1
$cdbName = cdb . $cdb_index
sql create database $cdbName vgroups 1
sql create database $cdbName vgroups 1
sleep 500
sleep 500
sql use $cdbName
sql use $cdbName
...
@@ -125,10 +154,6 @@ if $rows != 2 then
...
@@ -125,10 +154,6 @@ if $rows != 2 then
endi
endi
#######################################################################################
#######################################################################################
print ================ test consume from ctb
$loop_cnt = 0
loop_consume_diff_topic_from_ctb:
if $loop_cnt == 0 then
if $loop_cnt == 0 then
print == scenario 1: topic_ctb_column
print == scenario 1: topic_ctb_column
$topicList = ' . topic_ctb_column
$topicList = ' . topic_ctb_column
...
@@ -147,7 +172,7 @@ endi
...
@@ -147,7 +172,7 @@ endi
$consumerId = 0
$consumerId = 0
$totalMsgOfCtb = $rowsPerCtb
$totalMsgOfCtb = $rowsPerCtb
$expectmsgcnt = $totalMsgOfCtb
+ 1
$expectmsgcnt = $totalMsgOfCtb
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == start consumer to pull msgs from stb
...
@@ -176,11 +201,16 @@ $loop_cnt = $loop_cnt + 1
...
@@ -176,11 +201,16 @@ $loop_cnt = $loop_cnt + 1
goto loop_consume_diff_topic_from_ctb
goto loop_consume_diff_topic_from_ctb
loop_consume_diff_topic_from_ctb_end:
loop_consume_diff_topic_from_ctb_end:
print ================ test consume from ntb
$loop_cnt = 0
loop_consume_diff_topic_from_ntb:
#######################################################################################
#######################################################################################
# clear consume info and consume result
# clear consume info and consume result
#run tsim/tmq/clearConsume.sim
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
# because drop table function no stable, so by create new db for consume info and result. Modify it later
$cdbName = cdb2
$cdb_index = $cdb_index + 1
$cdbName = cdb . $cdb_index
sql create database $cdbName vgroups 1
sql create database $cdbName vgroups 1
sleep 500
sleep 500
sql use $cdbName
sql use $cdbName
...
@@ -195,10 +225,6 @@ if $rows != 2 then
...
@@ -195,10 +225,6 @@ if $rows != 2 then
endi
endi
#######################################################################################
#######################################################################################
print ================ test consume from ntb
$loop_cnt = 0
loop_consume_diff_topic_from_ntb:
if $loop_cnt == 0 then
if $loop_cnt == 0 then
print == scenario 1: topic_ntb_column
print == scenario 1: topic_ntb_column
$topicList = ' . topic_ntb_column
$topicList = ' . topic_ntb_column
...
@@ -217,7 +243,7 @@ endi
...
@@ -217,7 +243,7 @@ endi
$consumerId = 0
$consumerId = 0
$totalMsgOfNtb = $rowsPerCtb
$totalMsgOfNtb = $rowsPerCtb
$expectmsgcnt = $totalMsgOfNtb
+ 1
$expectmsgcnt = $totalMsgOfNtb
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == start consumer to pull msgs from stb
...
...
tests/script/tsim/tmq/basic2.sim
0 → 100644
浏览文件 @
98ce2f57
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
#basic1.sim: vgroups=1, one topic for one consumer, firstly insert data, then start consume. Include six topics
#basic2.sim: vgroups=1, multi topics for one consumer, firstly insert data, then start consume. Include six topics
#basic3.sim: vgroups=4, one topic for one consumer, firstly insert data, then start consume. Include six topics
#basic4.sim: vgroups=4, multi topics for one consumer, firstly insert data, then start consume. Include six topics
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
run tsim/tmq/prepareBasicEnv-1vgrp.sim
#---- global parameters start ----#
$dbName = db
$vgroups = 1
$stbPrefix = stb
$ctbPrefix = ctb
$ntbPrefix = ntb
$stbNum = 1
$ctbNum = 10
$ntbNum = 10
$rowsPerCtb = 10
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#---- global parameters end ----#
$pullDelay = 5
$ifcheckdata = 1
$showMsg = 1
$showRow = 0
sql connect
sql use $dbName
print == create topics from super table
sql create topic topic_stb_column as select ts, c3 from stb
sql create topic topic_stb_all as select ts, c1, c2, c3 from stb
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
print == create topics from child table
sql create topic topic_ctb_column as select ts, c3 from ctb0
sql create topic topic_ctb_all as select * from ctb0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ctb0
print == create topics from normal table
sql create topic topic_ntb_column as select ts, c3 from ntb0
sql create topic topic_ntb_all as select * from ntb0
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb0
#sql show topics
#if $rows != 9 then
# return -1
#endi
$keyList = ' . group.id:cgrp1
$keyList = $keyList . '
$topicNum = 3
#=============================== start consume =============================#
print ================ test consume from stb
print == multi toipcs: topic_stb_column + topic_stb_all + topic_stb_function
$topicList = ' . topic_stb_column
$topicList = $topicList . ,
$topicList = $topicList . topic_stb_all
$topicList = $topicList . ,
$topicList = $topicList . topic_stb_function
$topicList = $topicList . '
$consumerId = 0
$totalMsgOfStb = $ctbNum * $rowsPerCtb
$totalMsgOfStb = $totalMsgOfStb * $topicNum
$expectmsgcnt = $totalMsgOfStb
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start
print == check consume result
wait_consumer_end_from_stb:
sql select * from consumeresult
print ==> rows: $rows
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
sleep 1000
goto wait_consumer_end_from_stb
endi
if $data[0][1] != $consumerId then
return -1
endi
if $data[0][2] != $expectmsgcnt then
return -1
endi
if $data[0][3] != $expectmsgcnt then
return -1
endi
#######################################################################################
# clear consume info and consume result
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
$cdbName = cdb1
sql create database $cdbName vgroups 1
sleep 500
sql use $cdbName
print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
sql show tables
if $rows != 2 then
return -1
endi
#######################################################################################
print ================ test consume from ctb
print == multi toipcs: topic_ctb_column + topic_ctb_all + topic_ctb_function
$topicList = ' . topic_ctb_column
$topicList = $topicList . ,
$topicList = $topicList . topic_ctb_all
$topicList = $topicList . ,
$topicList = $topicList . topic_ctb_function
$topicList = $topicList . '
$consumerId = 0
$totalMsgOfCtb = $rowsPerCtb * $topicNum
$expectmsgcnt = $totalMsgOfCtb
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
print == check consume result
wait_consumer_end_from_ctb:
sql select * from consumeresult
print ==> rows: $rows
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
sleep 1000
goto wait_consumer_end_from_ctb
endi
if $data[0][1] != $consumerId then
return -1
endi
if $data[0][2] != $totalMsgOfCtb then
return -1
endi
if $data[0][3] != $totalMsgOfCtb then
return -1
endi
#######################################################################################
# clear consume info and consume result
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
$cdbName = cdb2
sql create database $cdbName vgroups 1
sleep 500
sql use $cdbName
print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
sql show tables
if $rows != 2 then
return -1
endi
#######################################################################################
print ================ test consume from ntb
print == multi toipcs: topic_ntb_column + topic_ntb_all + topic_ntb_function
$topicList = ' . topic_ntb_column
$topicList = $topicList . ,
$topicList = $topicList . topic_ntb_all
$topicList = $topicList . ,
$topicList = $topicList . topic_ntb_function
$topicList = $topicList . '
$consumerId = 0
$totalMsgOfNtb = $rowsPerCtb * $topicNum
$expectmsgcnt = $totalMsgOfNtb
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
print == check consume result from ntb
wait_consumer_end_from_ntb:
sql select * from consumeresult
print ==> rows: $rows
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
sleep 1000
goto wait_consumer_end_from_ntb
endi
if $data[0][1] != $consumerId then
return -1
endi
if $data[0][2] != $totalMsgOfNtb then
return -1
endi
if $data[0][3] != $totalMsgOfNtb then
return -1
endi
#------ not need stop consumer, because it exit after pull msg overthan expect msg
#system tsim/tmq/consume.sh -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/basic3.sim
0 → 100644
浏览文件 @
98ce2f57
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
#basic1.sim: vgroups=1, one topic for one consumer, firstly insert data, then start consume. Include six topics
#basic2.sim: vgroups=1, multi topics for one consumer, firstly insert data, then start consume. Include six topics
#basic3.sim: vgroups=4, one topic for one consumer, firstly insert data, then start consume. Include six topics
#basic4.sim: vgroups=4, multi topics for one consumer, firstly insert data, then start consume. Include six topics
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
run tsim/tmq/prepareBasicEnv-4vgrp.sim
#---- global parameters start ----#
$dbName = db
$vgroups = 4
$stbPrefix = stb
$ctbPrefix = ctb
$ntbPrefix = ntb
$stbNum = 1
$ctbNum = 10
$ntbNum = 10
$rowsPerCtb = 10
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#---- global parameters end ----#
$pullDelay = 5
$ifcheckdata = 1
$showMsg = 1
$showRow = 0
sql connect
sql use $dbName
print == create topics from super table
sql create topic topic_stb_column as select ts, c3 from stb
sql create topic topic_stb_all as select ts, c1, c2, c3 from stb
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
print == create topics from child table
sql create topic topic_ctb_column as select ts, c3 from ctb0
sql create topic topic_ctb_all as select * from ctb0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ctb0
print == create topics from normal table
sql create topic topic_ntb_column as select ts, c3 from ntb0
sql create topic topic_ntb_all as select * from ntb0
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb0
#sql show topics
#if $rows != 9 then
# return -1
#endi
$keyList = ' . group.id:cgrp1
$keyList = $keyList . '
$cdb_index = 0
#=============================== start consume =============================#
print ================ test consume from stb
$loop_cnt = 0
loop_consume_diff_topic_from_stb:
#######################################################################################
# clear consume info and consume result
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
$cdb_index = $cdb_index + 1
$cdbName = cdb . $cdb_index
sql create database $cdbName vgroups 1
sleep 500
sql use $cdbName
print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
sql show tables
if $rows != 2 then
return -1
endi
#######################################################################################
if $loop_cnt == 0 then
print == scenario 1: topic_stb_column
$topicList = ' . topic_stb_column
$topicList = $topicList . '
elif $loop_cnt == 1 then
print == scenario 2: topic_stb_all
$topicList = ' . topic_stb_all
$topicList = $topicList . '
elif $loop_cnt == 2 then
print == scenario 3: topic_stb_function
$topicList = ' . topic_stb_function
$topicList = $topicList . '
else
goto loop_consume_diff_topic_from_stb_end
endi
$consumerId = 0
$totalMsgOfStb = $ctbNum * $rowsPerCtb
$expectmsgcnt = $totalMsgOfStb
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
print == check consume result
wait_consumer_end_from_stb:
sql select * from consumeresult
print ==> rows: $rows
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
sleep 1000
goto wait_consumer_end_from_stb
endi
if $data[0][1] != $consumerId then
return -1
endi
if $data[0][2] != $expectmsgcnt then
return -1
endi
if $data[0][3] != $expectmsgcnt then
return -1
endi
$loop_cnt = $loop_cnt + 1
goto loop_consume_diff_topic_from_stb
loop_consume_diff_topic_from_stb_end:
print ================ test consume from ctb
$loop_cnt = 0
loop_consume_diff_topic_from_ctb:
#######################################################################################
# clear consume info and consume result
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
$cdb_index = $cdb_index + 1
$cdbName = cdb . $cdb_index
sql create database $cdbName vgroups 1
sleep 500
sql use $cdbName
print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
sql show tables
if $rows != 2 then
return -1
endi
#######################################################################################
if $loop_cnt == 0 then
print == scenario 1: topic_ctb_column
$topicList = ' . topic_ctb_column
$topicList = $topicList . '
elif $loop_cnt == 1 then
print == scenario 2: topic_ctb_all
$topicList = ' . topic_ctb_all
$topicList = $topicList . '
elif $loop_cnt == 2 then
print == scenario 3: topic_ctb_function
$topicList = ' . topic_ctb_function
$topicList = $topicList . '
else
goto loop_consume_diff_topic_from_ctb_end
endi
$consumerId = 0
$totalMsgOfCtb = $rowsPerCtb
$expectmsgcnt = $totalMsgOfCtb
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
print == check consume result
wait_consumer_end_from_ctb:
sql select * from consumeresult
print ==> rows: $rows
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
sleep 1000
goto wait_consumer_end_from_ctb
endi
if $data[0][1] != $consumerId then
return -1
endi
if $data[0][2] != $totalMsgOfCtb then
return -1
endi
if $data[0][3] != $totalMsgOfCtb then
return -1
endi
$loop_cnt = $loop_cnt + 1
goto loop_consume_diff_topic_from_ctb
loop_consume_diff_topic_from_ctb_end:
print ================ test consume from ntb
$loop_cnt = 0
loop_consume_diff_topic_from_ntb:
#######################################################################################
# clear consume info and consume result
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
$cdb_index = $cdb_index + 1
$cdbName = cdb . $cdb_index
sql create database $cdbName vgroups 1
sleep 500
sql use $cdbName
print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
sql show tables
if $rows != 2 then
return -1
endi
#######################################################################################
if $loop_cnt == 0 then
print == scenario 1: topic_ntb_column
$topicList = ' . topic_ntb_column
$topicList = $topicList . '
elif $loop_cnt == 1 then
print == scenario 2: topic_ntb_all
$topicList = ' . topic_ntb_all
$topicList = $topicList . '
elif $loop_cnt == 2 then
print == scenario 3: topic_ntb_function
$topicList = ' . topic_ntb_function
$topicList = $topicList . '
else
goto loop_consume_diff_topic_from_ntb_end
endi
$consumerId = 0
$totalMsgOfNtb = $rowsPerCtb
$expectmsgcnt = $totalMsgOfNtb
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
print == check consume result from ntb
wait_consumer_end_from_ntb:
sql select * from consumeresult
print ==> rows: $rows
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
sleep 1000
goto wait_consumer_end_from_ntb
endi
if $data[0][1] != $consumerId then
return -1
endi
if $data[0][2] != $totalMsgOfNtb then
return -1
endi
if $data[0][3] != $totalMsgOfNtb then
return -1
endi
$loop_cnt = $loop_cnt + 1
goto loop_consume_diff_topic_from_ntb
loop_consume_diff_topic_from_ntb_end:
#------ not need stop consumer, because it exit after pull msg overthan expect msg
#system tsim/tmq/consume.sh -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/basic4.sim
0 → 100644
浏览文件 @
98ce2f57
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
#basic1.sim: vgroups=1, one topic for one consumer, firstly insert data, then start consume. Include six topics
#basic2.sim: vgroups=1, multi topics for one consumer, firstly insert data, then start consume. Include six topics
#basic3.sim: vgroups=4, one topic for one consumer, firstly insert data, then start consume. Include six topics
#basic4.sim: vgroups=4, multi topics for one consumer, firstly insert data, then start consume. Include six topics
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
run tsim/tmq/prepareBasicEnv-4vgrp.sim
#---- global parameters start ----#
$dbName = db
$vgroups = 4
$stbPrefix = stb
$ctbPrefix = ctb
$ntbPrefix = ntb
$stbNum = 1
$ctbNum = 10
$ntbNum = 10
$rowsPerCtb = 10
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#---- global parameters end ----#
$pullDelay = 5
$ifcheckdata = 1
$showMsg = 1
$showRow = 0
sql connect
sql use $dbName
print == create topics from super table
sql create topic topic_stb_column as select ts, c3 from stb
sql create topic topic_stb_all as select ts, c1, c2, c3 from stb
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
print == create topics from child table
sql create topic topic_ctb_column as select ts, c3 from ctb0
sql create topic topic_ctb_all as select * from ctb0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ctb0
print == create topics from normal table
sql create topic topic_ntb_column as select ts, c3 from ntb0
sql create topic topic_ntb_all as select * from ntb0
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb0
#sql show topics
#if $rows != 9 then
# return -1
#endi
$keyList = ' . group.id:cgrp1
$keyList = $keyList . '
$topicNum = 3
print ================ test consume from stb
print == multi toipcs: topic_stb_column + topic_stb_all + topic_stb_function
$topicList = ' . topic_stb_column
$topicList = $topicList . ,
$topicList = $topicList . topic_stb_all
$topicList = $topicList . ,
$topicList = $topicList . topic_stb_function
$topicList = $topicList . '
$consumerId = 0
$totalMsgOfStb = $ctbNum * $rowsPerCtb
$totalMsgOfStb = $totalMsgOfStb * $topicNum
$expectmsgcnt = $totalMsgOfStb
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start
print == check consume result
wait_consumer_end_from_stb:
sql select * from consumeresult
print ==> rows: $rows
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
sleep 1000
goto wait_consumer_end_from_stb
endi
if $data[0][1] != $consumerId then
return -1
endi
if $data[0][2] != $expectmsgcnt then
return -1
endi
if $data[0][3] != $expectmsgcnt then
return -1
endi
#######################################################################################
# clear consume info and consume result
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
$cdbName = cdb1
sql create database $cdbName vgroups 1
sleep 500
sql use $cdbName
print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
sql show tables
if $rows != 2 then
return -1
endi
#######################################################################################
print ================ test consume from ctb
print == multi toipcs: topic_ctb_column + topic_ctb_all + topic_ctb_function
$topicList = ' . topic_ctb_column
$topicList = $topicList . ,
$topicList = $topicList . topic_ctb_all
$topicList = $topicList . ,
$topicList = $topicList . topic_ctb_function
$topicList = $topicList . '
$consumerId = 0
$totalMsgOfCtb = $rowsPerCtb * $topicNum
$expectmsgcnt = $totalMsgOfCtb
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
print == check consume result
wait_consumer_end_from_ctb:
sql select * from consumeresult
print ==> rows: $rows
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
sleep 1000
goto wait_consumer_end_from_ctb
endi
if $data[0][1] != $consumerId then
return -1
endi
if $data[0][2] != $totalMsgOfCtb then
return -1
endi
if $data[0][3] != $totalMsgOfCtb then
return -1
endi
#######################################################################################
# clear consume info and consume result
#run tsim/tmq/clearConsume.sim
# because drop table function no stable, so by create new db for consume info and result. Modify it later
$cdbName = cdb2
sql create database $cdbName vgroups 1
sleep 500
sql use $cdbName
print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
sql show tables
if $rows != 2 then
return -1
endi
#######################################################################################
print ================ test consume from ntb
print == multi toipcs: topic_ntb_column + topic_ntb_all + topic_ntb_function
$topicList = ' . topic_ntb_column
$topicList = $topicList . ,
$topicList = $topicList . topic_ntb_all
$topicList = $topicList . ,
$topicList = $topicList . topic_ntb_function
$topicList = $topicList . '
$consumerId = 0
$totalMsgOfNtb = $rowsPerCtb * $topicNum
$expectmsgcnt = $totalMsgOfNtb
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
print == start consumer to pull msgs from stb
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
print == check consume result from ntb
wait_consumer_end_from_ntb:
sql select * from consumeresult
print ==> rows: $rows
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
if $rows != 1 then
sleep 1000
goto wait_consumer_end_from_ntb
endi
if $data[0][1] != $consumerId then
return -1
endi
if $data[0][2] != $totalMsgOfNtb then
return -1
endi
if $data[0][3] != $totalMsgOfNtb then
return -1
endi
#------ not need stop consumer, because it exit after pull msg overthan expect msg
#system tsim/tmq/consume.sh -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/insertDataV1.sim
已删除
100644 → 0
浏览文件 @
bb815260
sql connect
print ================ insert data
$dbNamme = d0
$tbPrefix = ct
$tbNum = 10
$rowNum = 100
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
sql use $dbNamme
$loop_cnt = 0
loop_insert:
print ====> loop $loop_cnt insert
$loop_cnt = $loop_cnt + 1
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
$x = 0
while $x < $rowNum
$binary = ' . binary
$binary = $binary . $i
$binary = $binary . '
#print ====> insert into $tb values ($tstart , $i , $x , $binary )
#print ====> insert into ntb values ($tstart , $i , $x , $binary )
sql insert into $tb values ($tstart , $i , $x , $binary )
sql insert into ntb values ($tstart , 999 , 999 , 'binary-ntb' )
$tstart = $tstart + 1
$x = $x + 1
endw
print ====> insert rows: $rowNum into $tb and ntb
$i = $i + 1
# $tstart = 1640966400000
endw
goto loop_insert
tests/script/tsim/tmq/insertDataV4.sim
已删除
100644 → 0
浏览文件 @
bb815260
sql connect
print ================ insert data
$dbNamme = d1
$tbPrefix = ct
$tbNum = 10
$rowNum = 100
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
sql use $dbNamme
$loop_cnt = 0
loop_insert:
print ====> loop $loop_cnt insert
$loop_cnt = $loop_cnt + 1
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
$x = 0
while $x < $rowNum
$binary = ' . binary
$binary = $binary . $i
$binary = $binary . '
#print ====> insert into $tb values ($tstart , $i , $x , $binary )
#print ====> insert into ntb values ($tstart , $i , $x , $binary )
sql insert into $tb values ($tstart , $i , $x , $binary )
sql insert into ntb values ($tstart , 999 , 999 , 'binary-ntb' )
$tstart = $tstart + 1
$x = $x + 1
endw
#print ====> insert rows: $rowNum into $tb and ntb
$i = $i + 1
# $tstart = 1640966400000
endw
goto loop_insert
tests/script/tsim/tmq/insertFixedDataV2.sim
已删除
100644 → 0
浏览文件 @
bb815260
sql connect
print ================ insert data
$dbNamme = d0
$tbPrefix = ct
$tbNum = 10
$rowNum = 100
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
$loopInsertNum = 10
sql use $dbNamme
$loopIndex = 0
loop_insert:
print ====> loop $loopIndex insert
$loopIndex = $loopIndex + 1
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
$x = 0
while $x < $rowNum
$binary = ' . binary
$binary = $binary . $i
$binary = $binary . '
#print ====> insert into $tb values ($tstart , $i , $x , $binary )
#print ====> insert into ntb values ($tstart , $i , $x , $binary )
sql insert into $tb values ($tstart , $i , $x , $binary )
sql insert into ntb values ($tstart , 999 , 999 , 'binary-ntb' )
$tstart = $tstart + 1
$x = $x + 1
endw
#print ====> insert rows: $rowNum into $tb and ntb
$i = $i + 1
# $tstart = 1640966400000
endw
if $loopIndex < $loopInsertNum then
goto loop_insert
endi
print ====> insert data end ===========
tests/script/tsim/tmq/insertFixedDataV4.sim
已删除
100644 → 0
浏览文件 @
bb815260
sql connect
print ================ insert data
$dbNamme = d1
$tbPrefix = ct
$tbNum = 10
$rowNum = 100
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
$loopInsertNum = 10
sql use $dbNamme
$loopIndex = 0
loop_insert:
print ====> loop $loopIndex insert
$loopIndex = $loopIndex + 1
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
$x = 0
while $x < $rowNum
$binary = ' . binary
$binary = $binary . $i
$binary = $binary . '
#print ====> insert into $tb values ($tstart , $i , $x , $binary )
#print ====> insert into ntb values ($tstart , $i , $x , $binary )
sql insert into $tb values ($tstart , $i , $x , $binary )
sql insert into ntb values ($tstart , 999 , 999 , 'binary-ntb' )
$tstart = $tstart + 1
$x = $x + 1
endw
#print ====> insert rows: $rowNum into $tb and ntb
$i = $i + 1
# $tstart = 1640966400000
endw
if $loopIndex < $loopInsertNum then
goto loop_insert
endi
print ====> insert data end ===========
tests/script/tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim
已删除
100644 → 0
浏览文件 @
bb815260
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
# scene1: vgroups=2, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene2: vgroups=2, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene3: vgroups=4, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene4: vgroups=4, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
######## This test case include scene1 and scene3
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
$loop_cnt = 0
$vgroups = 2
$dbNamme = d0
loop_vgroups:
print =============== create database $dbNamme vgroups $vgroups
sql create database $dbNamme vgroups $vgroups
sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
if $loop_cnt == 0 then
if $rows != 2 then
return -1
endi
if $data02 != 2 then # vgroups
print vgroups: $data02
return -1
endi
else
if $rows != 3 then
return -1
endi
if $data00 == d1 then
if $data02 != 4 then # vgroups
print vgroups: $data02
return -1
endi
else
if $data12 != 4 then # vgroups
print vgroups: $data12
return -1
endi
endi
endi
sql use $dbNamme
print =============== create super table
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
sql show stables
if $rows != 1 then
return -1
endi
print =============== create child table
$tbPrefix = ct
$tbNum = 100
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using stb tags( $i )
$i = $i + 1
endw
print =============== create normal table
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
print =============== create topics from child table
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
sql create topic topic_ctb_all as select * from ct0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
#sql create topic topic_ntb_column as select ts, c1, c3 from ntb
#sql create topic topic_ntb_all as select * from ntb
#sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
sql show tables
if $rows != 101 then
return -1
endi
print =============== run_back insert data
if $loop_cnt == 0 then
run_back tsim/tmq/insertFixedDataV2.sim
else
run_back tsim/tmq/insertFixedDataV4.sim
endi
#sleep 1000
#$rowNum = 1000
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#
#$i = 0
#while $i < $tbNum
# $tb = $tbPrefix . $i
#
# $x = 0
# while $x < $rowNum
# $c = $x / 10
# $c = $c * 10
# $c = $x - $c
#
# $binary = ' . binary
# $binary = $binary . $c
# $binary = $binary . '
#
# sql insert into $tb values ($tstart , $c , $x , $binary )
# sql insert into ntb values ($tstart , $c , $x , $binary )
# $tstart = $tstart + 1
# $x = $x + 1
# endw
#
# $i = $i + 1
# $tstart = 1640966400000
#endw
#root@trd02 /home $ tmq_sim --help
# -c Configuration directory, default is
# -d The name of the database for cosumer, no default
# -t The topic string for cosumer, no default
# -k The key-value string for cosumer, no default
# -g showMsgFlag, default is 0
#
$tbNum = 10
$consumeDelay = 10
$expectMsgCntFromCtb = 300
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
print consumeDelay: $consumeDelay
print insert data child num: $tbNum
print expectMsgCntFromCtb: $expectMsgCntFromCtb
print expectMsgCntFromStb: $expectMsgCntFromStb
# supported key:
# group.id:<xxx>
# enable.auto.commit:<true | false>
# auto.offset.reset:<earliest | latest | none>
# td.connect.ip:<fqdn | ipaddress>
# td.connect.user:root
# td.connect.pass:taosdata
# td.connect.port:6030
# td.connect.db:db
$expect_result = @{consume success: @
$expect_result = $expect_result . $rowNum
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
system_content echo -n \$BUILD_DIR
$tmq_sim = $system_content . /build/bin/tmq_sim
$tsim_cfg = $system_content . /tsim/cfg
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
print cmd result----> $system_content
if $system_content != success then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
print cmd result----> $system_content
if $system_content != success then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 0
print cmd result----> $system_content
if $system_content != success then
return -1
endi
#$expect_result = @{consume success: @
#$expect_result = $expect_result . $totalMsgCnt
#$expect_result = $expect_result . @, @
#$expect_result = $expect_result . 0}
#print expect_result----> $expect_result
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#$expect_result = @{consume success: @
#$expect_result = $expect_result . $expectConsumeMsgCnt
#$expect_result = $expect_result . @, @
#$expect_result = $expect_result . 0}
#print expect_result----> $expect_result
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
##print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
##system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
##print cmd result----> $system_content
###if $system_content != @{consume success: 10000, 0}@ then
##if $system_content != success then
## return -1
##endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
#print cmd result----> $system_content
##if $system_content != @{consume success: 10000, 0}@ then
#if $system_content != success then
# return -1
#endi
if $loop_cnt == 0 then
$loop_cnt = 1
$vgroups = 4
$dbNamme = d1
goto loop_vgroups
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/main2Con1Cgrp1TopicFrStb.sim
已删除
100644 → 0
浏览文件 @
bb815260
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
# scene1: vgroups=2, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene2: vgroups=2, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene3: vgroups=4, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene4: vgroups=4, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
######## This test case include scene1 and scene3
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
$loop_cnt = 0
$vgroups = 2
$dbNamme = d0
loop_vgroups:
print =============== create database $dbNamme vgroups $vgroups
sql create database $dbNamme vgroups $vgroups
sql use $dbNamme
print =============== create super table
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
sql show stables
if $rows != 1 then
return -1
endi
print =============== create child table
$tbPrefix = ct
$tbNum = 100
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using stb tags( $i )
$i = $i + 1
endw
print =============== create normal table
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
print =============== create multi topics. notes: now only support:
print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb
print =============== will support: * from stb
sql create topic topic_stb_column as select ts, c1, c3 from stb
#sql create topic topic_stb_all as select * from stb
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
sql create topic topic_ctb_all as select * from ct0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
sql create topic topic_ntb_all as select * from ntb
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
sql show tables
if $rows != 101 then
return -1
endi
print =============== run_back insert data
if $loop_cnt == 0 then
run_back tsim/tmq/insertFixedDataV2.sim
else
run_back tsim/tmq/insertFixedDataV4.sim
endi
#sleep 1000
#$rowNum = 1000
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#
#$i = 0
#while $i < $tbNum
# $tb = $tbPrefix . $i
#
# $x = 0
# while $x < $rowNum
# $c = $x / 10
# $c = $c * 10
# $c = $x - $c
#
# $binary = ' . binary
# $binary = $binary . $c
# $binary = $binary . '
#
# sql insert into $tb values ($tstart , $c , $x , $binary )
# sql insert into ntb values ($tstart , $c , $x , $binary )
# $tstart = $tstart + 1
# $x = $x + 1
# endw
#
# $i = $i + 1
# $tstart = 1640966400000
#endw
#root@trd02 /home $ tmq_sim --help
# -c Configuration directory, default is
# -d The name of the database for cosumer, no default
# -t The topic string for cosumer, no default
# -k The key-value string for cosumer, no default
# -g showMsgFlag, default is 0
#
$tbNum = 10
$consumeDelay = 10
$expectMsgCntFromCtb = 300
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
print consumeDelay: $consumeDelay
print insert data child num: $tbNum
print expectMsgCntFromCtb: $expectMsgCntFromCtb
print expectMsgCntFromStb: $expectMsgCntFromStb
# supported key:
# group.id:<xxx>
# enable.auto.commit:<true | false>
# auto.offset.reset:<earliest | latest | none>
# td.connect.ip:<fqdn | ipaddress>
# td.connect.user:root
# td.connect.pass:taosdata
# td.connect.port:6030
# td.connect.db:db
#$expect_result = @{consume success: @
#$expect_result = $expect_result . $rowNum
#$expect_result = $expect_result . @, @
#$expect_result = $expect_result . 0}
#print expect_result----> $expect_result
system_content echo -n \$BUILD_DIR
$tmq_sim = $system_content . /build/bin/tmq_sim
$tsim_cfg = $system_content . /tsim/cfg
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#$expect_result = @{consume success: @
#$expect_result = $expect_result . $totalMsgCnt
#$expect_result = $expect_result . @, @
#$expect_result = $expect_result . 0}
#print expect_result----> $expect_result
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
$expect_result = @{consume success: @
$expect_result = $expect_result . $expectMsgCntFromStb
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0
print cmd result----> $system_content
if $system_content != success then
return -1
endi
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0
#print cmd result----> $system_content
##if $system_content != @{consume success: 10000, 0}@ then
#if $system_content != success then
# return -1
#endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0
print cmd result----> $system_content
#if $system_content != @{consume success: 10000, 0}@ then
if $system_content != success then
return -1
endi
if $loop_cnt == 0 then
$loop_cnt = 1
$vgroups = 4
$dbNamme = d1
goto loop_vgroups
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim
已删除
100644 → 0
浏览文件 @
bb815260
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
# scene1: vgroups=2, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene2: vgroups=2, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene3: vgroups=4, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene4: vgroups=4, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
######## This test case include scene1 and scene3
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
$loop_cnt = 0
$vgroups = 2
$dbNamme = d0
loop_vgroups:
print =============== create database $dbNamme vgroups $vgroups
sql create database $dbNamme vgroups $vgroups
sql use $dbNamme
print =============== create super table
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
sql show stables
if $rows != 1 then
return -1
endi
print =============== create child table
$tbPrefix = ct
$tbNum = 100
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using stb tags( $i )
$i = $i + 1
endw
print =============== create normal table
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
print =============== create topics from child table
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
sql create topic topic_ctb_all as select * from ct0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
#sql create topic topic_ntb_column as select ts, c1, c3 from ntb
#sql create topic topic_ntb_all as select * from ntb
#sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
sql show tables
if $rows != 101 then
return -1
endi
print =============== run_back insert data
if $loop_cnt == 0 then
run_back tsim/tmq/insertFixedDataV2.sim
else
run_back tsim/tmq/insertFixedDataV4.sim
endi
#sleep 1000
#$rowNum = 1000
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#
#$i = 0
#while $i < $tbNum
# $tb = $tbPrefix . $i
#
# $x = 0
# while $x < $rowNum
# $c = $x / 10
# $c = $c * 10
# $c = $x - $c
#
# $binary = ' . binary
# $binary = $binary . $c
# $binary = $binary . '
#
# sql insert into $tb values ($tstart , $c , $x , $binary )
# sql insert into ntb values ($tstart , $c , $x , $binary )
# $tstart = $tstart + 1
# $x = $x + 1
# endw
#
# $i = $i + 1
# $tstart = 1640966400000
#endw
#root@trd02 /home $ tmq_sim --help
# -c Configuration directory, default is
# -d The name of the database for cosumer, no default
# -t The topic string for cosumer, no default
# -k The key-value string for cosumer, no default
# -g showMsgFlag, default is 0
#
$tbNum = 10
$consumeDelay = 10
$expectMsgCntFromCtb = 300
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
print consumeDelay: $consumeDelay
print insert data child num: $tbNum
print expectMsgCntFromCtb: $expectMsgCntFromCtb
print expectMsgCntFromStb: $expectMsgCntFromStb
# supported key:
# group.id:<xxx>
# enable.auto.commit:<true | false>
# auto.offset.reset:<earliest | latest | none>
# td.connect.ip:<fqdn | ipaddress>
# td.connect.user:root
# td.connect.pass:taosdata
# td.connect.port:6030
# td.connect.db:db
$expect_result = @{consume success: @
$expect_result = $expect_result . $rowNum
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
system_content echo -n \$BUILD_DIR
$tmq_sim = $system_content . /build/bin/tmq_sim
$tsim_cfg = $system_content . /tsim/cfg
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
print cmd result----> $system_content
if $system_content != success then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
print cmd result----> $system_content
if $system_content != success then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
print cmd result----> $system_content
if $system_content != success then
return -1
endi
#$expect_result = @{consume success: @
#$expect_result = $expect_result . $totalMsgCnt
#$expect_result = $expect_result . @, @
#$expect_result = $expect_result . 0}
#print expect_result----> $expect_result
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 1
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#$expect_result = @{consume success: @
#$expect_result = $expect_result . $expectConsumeMsgCnt
#$expect_result = $expect_result . @, @
#$expect_result = $expect_result . 0}
#print expect_result----> $expect_result
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
##print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
##system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
##print cmd result----> $system_content
###if $system_content != @{consume success: 10000, 0}@ then
##if $system_content != success then
## return -1
##endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
#print cmd result----> $system_content
##if $system_content != @{consume success: 10000, 0}@ then
#if $system_content != success then
# return -1
#endi
if $loop_cnt == 0 then
$loop_cnt = 1
$vgroups = 4
$dbNamme = d1
goto loop_vgroups
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/main2Con1Cgrp2TopicFrStb.sim
已删除
100644 → 0
浏览文件 @
bb815260
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
# scene1: vgroups=2, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene2: vgroups=2, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene3: vgroups=4, one topic for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene4: vgroups=4, multi topics for two consumers, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
######## This test case include scene1 and scene3
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
$loop_cnt = 0
$vgroups = 2
$dbNamme = d0
loop_vgroups:
print =============== create database $dbNamme vgroups $vgroups
sql create database $dbNamme vgroups $vgroups
sql use $dbNamme
print =============== create super table
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
sql show stables
if $rows != 1 then
return -1
endi
print =============== create child table
$tbPrefix = ct
$tbNum = 100
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using stb tags( $i )
$i = $i + 1
endw
print =============== create normal table
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
print =============== create multi topics. notes: now only support:
print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb
print =============== will support: * from stb
sql create topic topic_stb_column as select ts, c1, c3 from stb
#sql create topic topic_stb_all as select * from stb
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
sql create topic topic_ctb_all as select * from ct0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
sql create topic topic_ntb_all as select * from ntb
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
sql show tables
if $rows != 101 then
return -1
endi
print =============== run_back insert data
if $loop_cnt == 0 then
run_back tsim/tmq/insertFixedDataV2.sim
else
run_back tsim/tmq/insertFixedDataV4.sim
endi
#sleep 1000
#$rowNum = 1000
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#
#$i = 0
#while $i < $tbNum
# $tb = $tbPrefix . $i
#
# $x = 0
# while $x < $rowNum
# $c = $x / 10
# $c = $c * 10
# $c = $x - $c
#
# $binary = ' . binary
# $binary = $binary . $c
# $binary = $binary . '
#
# sql insert into $tb values ($tstart , $c , $x , $binary )
# sql insert into ntb values ($tstart , $c , $x , $binary )
# $tstart = $tstart + 1
# $x = $x + 1
# endw
#
# $i = $i + 1
# $tstart = 1640966400000
#endw
#root@trd02 /home $ tmq_sim --help
# -c Configuration directory, default is
# -d The name of the database for cosumer, no default
# -t The topic string for cosumer, no default
# -k The key-value string for cosumer, no default
# -g showMsgFlag, default is 0
#
$tbNum = 10
$consumeDelay = 10
$expectMsgCntFromCtb = 300
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
print consumeDelay: $consumeDelay
print insert data child num: $tbNum
print expectMsgCntFromCtb: $expectMsgCntFromCtb
print expectMsgCntFromStb: $expectMsgCntFromStb
# supported key:
# group.id:<xxx>
# enable.auto.commit:<true | false>
# auto.offset.reset:<earliest | latest | none>
# td.connect.ip:<fqdn | ipaddress>
# td.connect.user:root
# td.connect.pass:taosdata
# td.connect.port:6030
# td.connect.db:db
#$expect_result = @{consume success: @
#$expect_result = $expect_result . $rowNum
#$expect_result = $expect_result . @, @
#$expect_result = $expect_result . 0}
#print expect_result----> $expect_result
system_content echo -n \$BUILD_DIR
$tmq_sim = $system_content . /build/bin/tmq_sim
$tsim_cfg = $system_content . /tsim/cfg
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_column" -k1 "group.id:tg2" -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_all" -k1 "group.id:tg2" -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ctb_function" -k1 "group.id:tg2" -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#$expect_result = @{consume success: @
#$expect_result = $expect_result . $totalMsgCnt
#$expect_result = $expect_result . @, @
#$expect_result = $expect_result . 0}
#print expect_result----> $expect_result
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_column" -k1 "group.id:tg2" -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_all" -k1 "group.id:tg2" -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
#
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_ntb_function" -k1 "group.id:tg2" -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
#print cmd result----> $system_content
#if $system_content != success then
# return -1
#endi
$expect_result = @{consume success: @
$expect_result = $expect_result . $expectMsgCntFromStb
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
print cmd result----> $system_content
if $system_content != success then
return -1
endi
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
#print cmd result----> $system_content
##if $system_content != @{consume success: 10000, 0}@ then
#if $system_content != success then
# return -1
#endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 1
print cmd result----> $system_content
#if $system_content != @{consume success: 10000, 0}@ then
if $system_content != success then
return -1
endi
if $loop_cnt == 0 then
$loop_cnt = 1
$vgroups = 4
$dbNamme = d1
goto loop_vgroups
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/mainConsumerInMultiTopic.sim
已删除
100644 → 0
浏览文件 @
bb815260
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
# scene1: vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene2: vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene3: vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene4: vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
######## This test case include scene2 and scene4
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
$loop_cnt = 0
$vgroups = 1
$dbNamme = d0
loop_vgroups:
print =============== create database $dbNamme vgroups $vgroups
sql create database $dbNamme vgroups $vgroups
sql use $dbNamme
print =============== create super table
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
sql show stables
if $rows != 1 then
return -1
endi
print =============== create child table
$tbPrefix = ct
$tbNum = 100
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using stb tags( $i )
$i = $i + 1
endw
print =============== create normal table
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
print =============== create multi topics. notes: now only support:
print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb
print =============== will support: * from stb
sql create topic topic_stb_column as select ts, c1, c3 from stb
#sql create topic topic_stb_all as select * from stb
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
sql create topic topic_ctb_all as select * from ct0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
sql create topic topic_ntb_all as select * from ntb
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
sql show tables
if $rows != 101 then
return -1
endi
print =============== run_back insert data
if $loop_cnt == 0 then
run_back tsim/tmq/insertFixedDataV2.sim
else
run_back tsim/tmq/insertFixedDataV4.sim
endi
#sleep 1000
#$rowNum = 1000
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#
#$i = 0
#while $i < $tbNum
# $tb = $tbPrefix . $i
#
# $x = 0
# while $x < $rowNum
# $c = $x / 10
# $c = $c * 10
# $c = $x - $c
#
# $binary = ' . binary
# $binary = $binary . $c
# $binary = $binary . '
#
# sql insert into $tb values ($tstart , $c , $x , $binary )
# sql insert into ntb values ($tstart , $c , $x , $binary )
# $tstart = $tstart + 1
# $x = $x + 1
# endw
#
# $i = $i + 1
# $tstart = 1640966400000
#endw
#root@trd02 /home $ tmq_sim --help
# -c Configuration directory, default is
# -d The name of the database for cosumer, no default
# -t The topic string for cosumer, no default
# -k The key-value string for cosumer, no default
# -g showMsgFlag, default is 0
#
$tbNum = 10
$consumeDelay = 5
$expectMsgCntFromCtb = 1000
$expectMsgCntFromNtb = 1000
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
print consumeDelay: $consumeDelay
print insert data child num: $tbNum
print expectMsgCntFromCtb: $expectMsgCntFromCtb
print expectMsgCntFromStb: $expectMsgCntFromStb
# supported key:
# group.id:<xxx>
# enable.auto.commit:<true | false>
# auto.offset.reset:<earliest | latest | none>
# td.connect.ip:<fqdn | ipaddress>
# td.connect.user:root
# td.connect.pass:taosdata
# td.connect.port:6030
# td.connect.db:db
$numOfTopics = 2
$expectMsgCntFromStb = $expectMsgCntFromStb * $numOfTopics
$expect_result = @{consume success: @
$expect_result = $expect_result . $expectMsgCntFromStb
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
system_content echo -n \$BUILD_DIR
$tmq_sim = $system_content . /build/bin/tmq_sim
$tsim_cfg = $system_content . /tsim/cfg
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
print cmd result----> $system_content
#if $system_content != @{consume success: 20000, 0}@ then
if $system_content != $expect_result then
print expect @{consume success: 20000, 0}@ , actual @system_content
return -1
endi
$numOfTopics = 3
$expectMsgCntFromCtb = $expectMsgCntFromCtb * $numOfTopics
$expect_result = @{consume success: @
$expect_result = $expect_result . $expectMsgCntFromCtb
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
print cmd result----> $system_content
#if $system_content != @{consume success: 300, 0}@ then
if $system_content != $expect_result then
return -1
endi
$numOfTopics = 3
$expectMsgCntFromNtb = $expectMsgCntFromNtb * $tbNum
$expectMsgCntFromNtb = $expectMsgCntFromNtb * $numOfTopics
$expect_result = @{consume success: @
$expect_result = $expect_result . $expectMsgCntFromNtb
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromNtb
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromNtb
print cmd result----> $system_content
#if $system_content != @{consume success: 30000, 0}@ then
if $system_content != $expect_result then
return -1
endi
if $loop_cnt == 0 then
$loop_cnt = 1
$vgroups = 4
$dbNamme = d1
goto loop_vgroups
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/mainConsumerInOneTopic.sim
已删除
100644 → 0
浏览文件 @
bb815260
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
# scene1: vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene2: vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene3: vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene4: vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
######## This test case include scene1 and scene3
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
$loop_cnt = 0
$vgroups = 1
$dbNamme = d0
loop_vgroups:
print =============== create database $dbNamme vgroups $vgroups
sql create database $dbNamme vgroups $vgroups
sql use $dbNamme
print =============== create super table
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
sql show stables
if $rows != 1 then
return -1
endi
print =============== create child table
$tbPrefix = ct
$tbNum = 100
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using stb tags( $i )
$i = $i + 1
endw
print =============== create normal table
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
print =============== create multi topics. notes: now only support:
print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb
print =============== will support: * from stb
sql create topic topic_stb_column as select ts, c1, c3 from stb
#sql create topic topic_stb_all as select * from stb
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
sql create topic topic_ctb_all as select * from ct0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
sql create topic topic_ntb_all as select * from ntb
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
sql show tables
if $rows != 101 then
return -1
endi
print =============== run_back insert data
if $loop_cnt == 0 then
run_back tsim/tmq/insertFixedDataV2.sim
else
run_back tsim/tmq/insertFixedDataV4.sim
endi
#sleep 1000
#$rowNum = 1000
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#
#$i = 0
#while $i < $tbNum
# $tb = $tbPrefix . $i
#
# $x = 0
# while $x < $rowNum
# $c = $x / 10
# $c = $c * 10
# $c = $x - $c
#
# $binary = ' . binary
# $binary = $binary . $c
# $binary = $binary . '
#
# sql insert into $tb values ($tstart , $c , $x , $binary )
# sql insert into ntb values ($tstart , $c , $x , $binary )
# $tstart = $tstart + 1
# $x = $x + 1
# endw
#
# $i = $i + 1
# $tstart = 1640966400000
#endw
#root@trd02 /home $ tmq_sim --help
# -c Configuration directory, default is
# -d The name of the database for cosumer, no default
# -t The topic string for cosumer, no default
# -k The key-value string for cosumer, no default
# -g showMsgFlag, default is 0
#
$tbNum = 10
$consumeDelay = 5
$expectMsgCntFromCtb = 1000
$expectMsgCntFromStb = $expectMsgCntFromCtb * $tbNum
print consumeDelay: $consumeDelay
print insert data child num: $tbNum
print expectMsgCntFromCtb: $expectMsgCntFromCtb
print expectMsgCntFromStb: $expectMsgCntFromStb
# supported key:
# group.id:<xxx>
# enable.auto.commit:<true | false>
# auto.offset.reset:<earliest | latest | none>
# td.connect.ip:<fqdn | ipaddress>
# td.connect.user:root
# td.connect.pass:taosdata
# td.connect.port:6030
# td.connect.db:db
$expect_result = @{consume success: @
$expect_result = $expect_result . $expectMsgCntFromStb
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
system_content echo -n \$BUILD_DIR
$tmq_sim = $system_content . /build/bin/tmq_sim
$tsim_cfg = $system_content . /tsim/cfg
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
print cmd result----> $system_content
if $system_content != $expect_result then
return -1
endi
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
#print cmd result----> $system_content
##if $system_content != @{consume success: 10000, 0}@ then
#if $system_content != $expect_result then
# return -1
#endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb
print cmd result----> $system_content
#if $system_content != @{consume success: 10000, 0}@ then
if $system_content != $expect_result then
return -1
endi
$expect_result = @{consume success: @
$expect_result = $expect_result . $expectMsgCntFromCtb
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
print cmd result----> $system_content
if $system_content != $expect_result then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
print cmd result----> $system_content
if $system_content != $expect_result then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
print cmd result----> $system_content
if $system_content != $expect_result then
return -1
endi
$expect_result = @{consume success: @
$expect_result = $expect_result . $expectMsgCntFromStb
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
print cmd result----> $system_content
if $system_content != $expect_result then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
print cmd result----> $system_content
if $system_content != $expect_result then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb
print cmd result----> $system_content
if $system_content != $expect_result then
return -1
endi
if $loop_cnt == 0 then
$loop_cnt = 1
$vgroups = 4
$dbNamme = d1
goto loop_vgroups
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/multiTopic.sim
已删除
100644 → 0
浏览文件 @
bb815260
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
# scene1: vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene2: vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene3: vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene4: vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
######## This test case include scene2 and scene4
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
$loop_cnt = 0
$vgroups = 1
$dbNamme = d0
loop_vgroups:
print =============== create database $dbNamme vgroups $vgroups
sql create database $dbNamme vgroups $vgroups
sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
if $loop_cnt == 0 then
if $rows != 3 then
return -1
endi
if $data22 != 1 then # vgroups
print vgroups: $data02
return -1
endi
else
if $rows != 4 then
return -1
endi
if $data20 == d1 then
if $data22 != 4 then # vgroups
print vgroups: $data02
return -1
endi
else
if $data32 != 4 then # vgroups
print vgroups: $data12
return -1
endi
endi
endi
sql use $dbNamme
print =============== create super table
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
sql show stables
if $rows != 1 then
return -1
endi
print =============== create child table
$tbPrefix = ct
$tbNum = 100
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using stb tags( $i )
$i = $i + 1
endw
print =============== create normal table
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
print =============== create multi topics. notes: now only support:
print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb
print =============== will support: * from stb
sql create topic topic_stb_column as select ts, c1, c3 from stb
#sql create topic topic_stb_all as select * from stb
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
sql create topic topic_ctb_all as select * from ct0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
sql create topic topic_ntb_all as select * from ntb
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
sql show tables
if $rows != 101 then
return -1
endi
print =============== insert data
$rowNum = 100
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
$x = 0
while $x < $rowNum
$c = $x / 10
$c = $c * 10
$c = $x - $c
$binary = ' . binary
$binary = $binary . $c
$binary = $binary . '
sql insert into $tb values ($tstart , $c , $x , $binary )
sql insert into ntb values ($tstart , $c , $x , $binary )
$tstart = $tstart + 1
$x = $x + 1
endw
$i = $i + 1
$tstart = 1640966400000
endw
#root@trd02 /home $ tmq_sim --help
# -c Configuration directory, default is
# -d The name of the database for cosumer, no default
# -t The topic string for cosumer, no default
# -k The key-value string for cosumer, no default
# -g showMsgFlag, default is 0
#
$totalMsgCnt = $rowNum * $tbNum
print inserted totalMsgCnt: $totalMsgCnt
# supported key:
# group.id:<xxx>
# enable.auto.commit:<true | false>
# auto.offset.reset:<earliest | latest | none>
# td.connect.ip:<fqdn | ipaddress>
# td.connect.user:root
# td.connect.pass:taosdata
# td.connect.port:6030
# td.connect.db:db
$numOfTopics = 2
$totalMsgCntOfmultiTopics = $totalMsgCnt * $numOfTopics
$expect_result = @{consume success: @
$expect_result = $expect_result . $totalMsgCntOfmultiTopics
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
system_content echo -n \$BUILD_DIR
$tmq_sim = $system_content . /build/bin/tmq_sim
$tsim_cfg = $system_content . /tsim/cfg
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2"
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2"
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2"
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2"
print cmd result----> $system_content
#if $system_content != @{consume success: 20000, 0}@ then
if $system_content != $expect_result then
return -1
endi
$numOfTopics = 3
$totalMsgCntOfmultiTopics = $rowNum * $numOfTopics
$expect_result = @{consume success: @
$expect_result = $expect_result . $totalMsgCntOfmultiTopics
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2"
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2"
print cmd result----> $system_content
#if $system_content != @{consume success: 300, 0}@ then
if $system_content != $expect_result then
return -1
endi
$numOfTopics = 3
$totalMsgCntOfmultiTopics = $totalMsgCnt * $numOfTopics
$expect_result = @{consume success: @
$expect_result = $expect_result . $totalMsgCntOfmultiTopics
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2"
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2"
print cmd result----> $system_content
#if $system_content != @{consume success: 30000, 0}@ then
if $system_content != $expect_result then
return -1
endi
if $loop_cnt == 0 then
$loop_cnt = 1
$vgroups = 4
$dbNamme = d1
goto loop_vgroups
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/oneTopic.sim
已删除
100644 → 0
浏览文件 @
bb815260
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
# scene1: vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene2: vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene3: vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene4: vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
######## This test case include scene1 and scene3
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
$loop_cnt = 0
$vgroups = 1
$dbNamme = d0
loop_vgroups:
print =============== create database $dbNamme vgroups $vgroups
sql create database $dbNamme vgroups $vgroups
sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
if $loop_cnt == 0 then
if $rows != 3 then
return -1
endi
if $data22 != 1 then # vgroups
print vgroups: $data02
return -1
endi
else
if $rows != 4 then
return -1
endi
if $data20 == d1 then
if $data22 != 4 then # vgroups
print vgroups: $data02
return -1
endi
else
if $data32 != 4 then # vgroups
print vgroups: $data12
return -1
endi
endi
endi
sql use $dbNamme
print =============== create super table
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
sql show stables
if $rows != 1 then
return -1
endi
print =============== create child table
$tbPrefix = ct
$tbNum = 100
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using stb tags( $i )
$i = $i + 1
endw
print =============== create normal table
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
print =============== create multi topics. notes: now only support:
print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb
print =============== will support: * from stb
sql create topic topic_stb_column as select ts, c1, c3 from stb
#sql create topic topic_stb_all as select * from stb
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
sql create topic topic_ctb_all as select * from ct0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
sql create topic topic_ntb_all as select * from ntb
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
sql show tables
if $rows != 101 then
return -1
endi
print =============== insert data
$rowNum = 100
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
$x = 0
while $x < $rowNum
$c = $x / 10
$c = $c * 10
$c = $x - $c
$binary = ' . binary
$binary = $binary . $c
$binary = $binary . '
sql insert into $tb values ($tstart , $c , $x , $binary )
sql insert into ntb values ($tstart , $c , $x , $binary )
$tstart = $tstart + 1
$x = $x + 1
endw
$i = $i + 1
$tstart = 1640966400000
endw
#root@trd02 /home $ tmq_sim --help
# -c Configuration directory, default is
# -d The name of the database for cosumer, no default
# -t The topic string for cosumer, no default
# -k The key-value string for cosumer, no default
# -g showMsgFlag, default is 0
#
$totalMsgCnt = $rowNum * $tbNum
print inserted totalMsgCnt: $totalMsgCnt
# supported key:
# group.id:<xxx>
# enable.auto.commit:<true | false>
# auto.offset.reset:<earliest | latest | none>
# td.connect.ip:<fqdn | ipaddress>
# td.connect.user:root
# td.connect.pass:taosdata
# td.connect.port:6030
# td.connect.db:db
$expect_result = @{consume success: @
$expect_result = $expect_result . $totalMsgCnt
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
system_content echo -n \$BUILD_DIR
$tmq_sim = $system_content . /build/bin/tmq_sim
$tsim_cfg = $system_content . /tsim/cfg
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2"
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2"
print cmd result----> $system_content
#if $system_content != @{consume success: 10000, 0}@ then
if $system_content != $expect_result then
return -1
endi
#print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2"
#system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2"
#print cmd result----> $system_content
##if $system_content != @{consume success: 10000, 0}@ then
#if $system_content != $expect_result then
# return -1
#endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2"
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2"
print cmd result----> $system_content
#if $system_content != @{consume success: 10000, 0}@ then
if $system_content != $expect_result then
return -1
endi
$expect_result = @{consume success: @
$expect_result = $expect_result . $rowNum
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2"
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2"
print cmd result----> $system_content
#if $system_content != @{consume success: 100, 0}@ then
if $system_content != $expect_result then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2"
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2"
print cmd result----> $system_content
#if $system_content != @{consume success: 100, 0}@ then
if $system_content != $expect_result then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2"
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2"
print cmd result----> $system_content
#if $system_content != @{consume success: 100, 0}@ then
if $system_content != $expect_result then
return -1
endi
$expect_result = @{consume success: @
$expect_result = $expect_result . $totalMsgCnt
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2"
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2"
print cmd result----> $system_content
#if $system_content != @{consume success: 10000, 0}@ then
if $system_content != $expect_result then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2"
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2"
print cmd result----> $system_content
#if $system_content != @{consume success: 10000, 0}@ then
if $system_content != $expect_result then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2"
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2"
print cmd result----> $system_content
#if $system_content != @{consume success: 10000, 0}@ then
if $system_content != $expect_result then
return -1
endi
if $loop_cnt == 0 then
$loop_cnt = 1
$vgroups = 4
$dbNamme = d1
goto loop_vgroups
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/overlapTopic2Con1Cgrp.sim
已删除
100644 → 0
浏览文件 @
bb815260
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
# scene1: vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene2: vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene3: vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# scene4: vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
#
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
#
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
######## This test case include scene2 and scene4
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
$loop_cnt = 0
$vgroups = 1
$dbNamme = d0
loop_vgroups:
print =============== create database $dbNamme vgroups $vgroups
sql create database $dbNamme vgroups $vgroups
sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
if $loop_cnt == 0 then
if $rows != 3 then
return -1
endi
if $data22 != 1 then # vgroups
print vgroups: $data02
return -1
endi
else
if $rows != 4 then
return -1
endi
if $data00 == d1 then
if $data02 != 4 then # vgroups
print vgroups: $data02
return -1
endi
else
if $data12 != 4 then # vgroups
print vgroups: $data12
return -1
endi
endi
endi
sql use $dbNamme
print =============== create super table
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
sql show stables
if $rows != 1 then
return -1
endi
print =============== create child table
$tbPrefix = ct
$tbNum = 10
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using stb tags( $i )
$i = $i + 1
endw
print =============== create normal table
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
print =============== create multi topics. notes: now only support:
print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb
print =============== will support: * from stb
sql create topic topic_stb_column as select ts, c1, c3 from stb
sql create topic topic_stb_all as select sqrt(c1) from stb
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
sql create topic topic_ctb_all as select * from ct0
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
sql create topic topic_ntb_all as select * from ntb
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
sql show tables
if $rows != 11 then
return -1
endi
print =============== insert data
$rowNum = 100
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
$x = 0
while $x < $rowNum
$c = $x / 10
$c = $c * 10
$c = $x - $c
$binary = ' . binary
$binary = $binary . $c
$binary = $binary . '
sql insert into $tb values ($tstart , $c , $x , $binary )
sql insert into ntb values ($tstart , $c , $x , $binary )
$tstart = $tstart + 1
$x = $x + 1
endw
$i = $i + 1
# $tstart = 1640966400000
endw
#root@trd02 /home $ tmq_sim --help
# -c Configuration directory, default is
# -d The name of the database for cosumer, no default
# -t The topic string for cosumer, no default
# -k The key-value string for cosumer, no default
# -g showMsgFlag, default is 0
#
$consumeDelay = 3
$expectMsgCntFromCtb = $rowNum
$expectMsgCntFromStb = $rowNum * $tbNum
$expectMsgCntFromNtb = $rowNum * $tbNum
print expectMsgCntFromCtb: $expectMsgCntFromCtb
print expectMsgCntFromStb: $expectMsgCntFromStb
print expectMsgCntFromNtb: $expectMsgCntFromNtb
# supported key:
# group.id:<xxx>
# enable.auto.commit:<true | false>
# auto.offset.reset:<earliest | latest | none>
# td.connect.ip:<fqdn | ipaddress>
# td.connect.user:root
# td.connect.pass:taosdata
# td.connect.port:6030
# td.connect.db:db
$numOfTopics = 3
$totalMsgCntOfmultiTopics = $expectMsgCntFromStb * $numOfTopics
$expect_result = @{consume success: @
$expect_result = $expect_result . $totalMsgCntOfmultiTopics
$expect_result = $expect_result . @, @
$expect_result = $expect_result . 0}
print expect_result----> $expect_result
$check_mode = 0
if $loop_cnt == 0 then
$check_mode = 0
else
$check_mode = 2
endi
$expectMsgCntFromStb0 = 2001
$expectMsgCntFromStb1 = 2001
system_content echo -n \$BUILD_DIR
$tmq_sim = $system_content . /build/bin/tmq_sim
$tsim_cfg = $system_content . /tsim/cfg
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column, topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb0 -m1 $expectMsgCntFromStb1 -j 2
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column, topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb0 -m1 $expectMsgCntFromStb1 -j 2
print cmd result----> $system_content
if $system_content != success then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column, topic_stb_function" -k1 "group.id:tg1" -t "topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 3
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t1 "topic_stb_column, topic_stb_function" -k1 "group.id:tg1" -t "topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 3
print cmd result----> $system_content
if $system_content != success then
return -1
endi
#$numOfTopics = 3
#$totalMsgCntOfmultiTopics = $rowNum * $numOfTopics
#$expect_result = @{consume success: @
#$expect_result = $expect_result . $totalMsgCntOfmultiTopics
#$expect_result = $expect_result . @, @
#$expect_result = $expect_result . 0}
#print expect_result----> $expect_result
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 4
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 4
print cmd result----> $system_content
if $system_content != success then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function" -k "group.id:tg1" -t "topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 3
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function" -k "group.id:tg1" -t "topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromCtb -j 3
print cmd result----> $system_content
if $system_content != success then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_function, topic_ntb_all" -k "group.id:tg2" -t "topic_ntb_column, topic_ntb_function, topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromNtb -j 4
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_function, topic_ntb_all" -k "group.id:tg2" -t "topic_ntb_column, topic_ntb_function, topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromNtb -j 4
print cmd result----> $system_content
if $system_content != success then
return -1
endi
print cmd===> system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_function" -k "group.id:tg1" -t "topic_ntb_function, topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromNtb -j 3
system_content $tmq_sim -c $tsim_cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_function" -k "group.id:tg1" -t "topic_ntb_function, topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromNtb -j 3
print cmd result----> $system_content
if $system_content != success then
return -1
endi
if $loop_cnt == 0 then
$loop_cnt = 1
$vgroups = 4
$dbNamme = d1
goto loop_vgroups
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/tmq/prepareBasicEnv.sim
→
tests/script/tsim/tmq/prepareBasicEnv
-1vgrp
.sim
浏览文件 @
98ce2f57
...
@@ -13,7 +13,7 @@ system sh/exec.sh -n dnode1 -s start
...
@@ -13,7 +13,7 @@ system sh/exec.sh -n dnode1 -s start
sql connect
sql connect
#---- global parameters start ----#
#---- global parameters start ----#
$dbName = db
$dbName
= db
$vgroups = 1
$vgroups = 1
$stbPrefix = stb
$stbPrefix = stb
$ctbPrefix = ctb
$ctbPrefix = ctb
...
@@ -21,7 +21,7 @@ $ntbPrefix = ntb
...
@@ -21,7 +21,7 @@ $ntbPrefix = ntb
$stbNum = 1
$stbNum = 1
$ctbNum = 10
$ctbNum = 10
$ntbNum = 10
$ntbNum = 10
$rowsPerCtb = 10
0
$rowsPerCtb = 10
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#---- global parameters end ----#
#---- global parameters end ----#
...
...
tests/script/tsim/tmq/prepareBasicEnv-4vgrp.sim
0 → 100644
浏览文件 @
98ce2f57
# stop all dnodes before start this case
system sh/stop_dnodes.sh
# deploy dnode 1
system sh/deploy.sh -n dnode1 -i 1
# add some config items for this case
#system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
# start dnode 1
system sh/exec.sh -n dnode1 -s start
sql connect
#---- global parameters start ----#
$dbName = db
$vgroups = 4
$stbPrefix = stb
$ctbPrefix = ctb
$ntbPrefix = ntb
$stbNum = 1
$ctbNum = 10
$ntbNum = 10
$rowsPerCtb = 10
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#---- global parameters end ----#
print == create database $dbName vgroups $vgroups
sql create database $dbName vgroups $vgroups
#wait database ready
$loop_cnt = 0
check_db_ready:
if $loop_cnt == 10 then
print ====> database not ready!
return -1
endi
sql show databases
print ==> rows: $rows
print ==> $data(db)[0] $data(db)[1] $data(db)[2] $data(db)[3] $data(db)[4] $data(db)[5] $data(db)[6] $data(db)[7] $data(db)[8] $data(db)[9] $data(db)[10] $data(db)[11] $data(db)[12]
print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $data(db)[18] $data(db)[19] $data(db)[20]
if $data(db)[20] != nostrict then
sleep 100
$loop_cnt = $loop_cnt + 1
goto check_db_ready
endi
sql use $dbName
print == create consume info table and consume result table
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
sql show tables
if $rows != 2 then
return -1
endi
print == create super table
sql create table $stbPrefix (ts timestamp, c1 int, c2 float, c3 binary(16)) tags (t1 int)
sql show stables
if $rows != 1 then
return -1
endi
print == create child table, normal table and insert data
$i = 0
while $i < $ctbNum
$ctb = $ctbPrefix . $i
$ntb = $ntbPrefix . $i
sql create table $ctb using $stbPrefix tags( $i )
sql create table $ntb (ts timestamp, c1 int, c2 float, c3 binary(16))
$x = 0
while $x < $rowsPerCtb
$binary = ' . binary-
$binary = $binary . $i
$binary = $binary . '
sql insert into $ctb values ($tstart , $i , $x , $binary )
sql insert into $ntb values ($tstart , $i , $x , $binary )
$tstart = $tstart + 1
$x = $x + 1
endw
$i = $i + 1
$tstart = 1640966400000
endw
tests/script/tsim/valgrind/checkError.sim
浏览文件 @
98ce2f57
...
@@ -71,7 +71,7 @@ print ====> start to check if there are ERRORS in vagrind log file for each dnod
...
@@ -71,7 +71,7 @@ print ====> start to check if there are ERRORS in vagrind log file for each dnod
# -n : dnode[x] be check
# -n : dnode[x] be check
system_content sh/checkValgrind.sh -n dnode1
system_content sh/checkValgrind.sh -n dnode1
print cmd return result----> [ $system_content ]
print cmd return result----> [ $system_content ]
if $system_content ==
@ERROR SUMMARY: 0 errors@
then
if $system_content ==
0
then
return 0
return 0
endi
endi
...
@@ -80,4 +80,4 @@ if $system_content == $null then
...
@@ -80,4 +80,4 @@ if $system_content == $null then
return 0
return 0
endi
endi
return -1
return -1
\ No newline at end of file
tests/test/c/tmqSim.c
浏览文件 @
98ce2f57
...
@@ -14,13 +14,14 @@
...
@@ -14,13 +14,14 @@
*/
*/
#include <assert.h>
#include <assert.h>
#include <dirent.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/types.h>
#include <time.h>
#include <time.h>
//
#include <unistd.h>
#include <unistd.h>
#include "taos.h"
#include "taos.h"
#include "taoserror.h"
#include "taoserror.h"
...
@@ -99,11 +100,11 @@ void initLogFile() {
...
@@ -99,11 +100,11 @@ void initLogFile() {
// FILE *fp = fopen(g_stConfInfo.resultFileName, "a");
// FILE *fp = fopen(g_stConfInfo.resultFileName, "a");
char
file
[
256
];
char
file
[
256
];
sprintf
(
file
,
"%s/../log/tmqlog.txt"
,
configDir
);
sprintf
(
file
,
"%s/../log/tmqlog.txt"
,
configDir
);
TdFilePtr
pFile
=
taosOpenFile
(
file
,
TD_FILE_
CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
file
,
TD_FILE_
TEXT
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
|
TD_FILE_STREAM
);
if
(
NULL
==
pFile
)
{
if
(
NULL
==
pFile
)
{
fprintf
(
stderr
,
"Failed to open %s for save result
\n
"
,
"./tmqlog.txt"
);
fprintf
(
stderr
,
"Failed to open %s for save result
\n
"
,
"./tmqlog.txt"
);
exit
(
-
1
)
;
exit
-
1
;
}
}
;
g_fp
=
pFile
;
g_fp
=
pFile
;
}
}
...
@@ -119,6 +120,7 @@ void saveConfigToLogFile() {
...
@@ -119,6 +120,7 @@ void saveConfigToLogFile() {
taosFprintfFile
(
g_fp
,
"# showMsgFlag: %d
\n
"
,
g_stConfInfo
.
showMsgFlag
);
taosFprintfFile
(
g_fp
,
"# showMsgFlag: %d
\n
"
,
g_stConfInfo
.
showMsgFlag
);
taosFprintfFile
(
g_fp
,
"# showRowFlag: %d
\n
"
,
g_stConfInfo
.
showRowFlag
);
taosFprintfFile
(
g_fp
,
"# showRowFlag: %d
\n
"
,
g_stConfInfo
.
showRowFlag
);
taosFprintfFile
(
g_fp
,
"# consumeDelay: %d
\n
"
,
g_stConfInfo
.
consumeDelay
);
taosFprintfFile
(
g_fp
,
"# consumeDelay: %d
\n
"
,
g_stConfInfo
.
consumeDelay
);
taosFprintfFile
(
g_fp
,
"# numOfThread: %d
\n
"
,
g_stConfInfo
.
numOfThread
);
for
(
int32_t
i
=
0
;
i
<
g_stConfInfo
.
numOfThread
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
g_stConfInfo
.
numOfThread
;
i
++
)
{
taosFprintfFile
(
g_fp
,
"# consumer %d info:
\n
"
,
g_stConfInfo
.
stThreads
[
i
].
consumerId
);
taosFprintfFile
(
g_fp
,
"# consumer %d info:
\n
"
,
g_stConfInfo
.
stThreads
[
i
].
consumerId
);
...
@@ -483,6 +485,7 @@ int main(int32_t argc, char* argv[]) {
...
@@ -483,6 +485,7 @@ int main(int32_t argc, char* argv[]) {
taosThreadAttrSetDetachState
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
taosThreadAttrSetDetachState
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
// pthread_create one thread to consume
// pthread_create one thread to consume
taosFprintfFile
(
g_fp
,
"==== create %d consume thread ====
\n
"
,
g_stConfInfo
.
numOfThread
);
for
(
int32_t
i
=
0
;
i
<
g_stConfInfo
.
numOfThread
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
g_stConfInfo
.
numOfThread
;
++
i
)
{
taosThreadCreate
(
&
(
g_stConfInfo
.
stThreads
[
i
].
thread
),
&
thattr
,
consumeThreadFunc
,
(
void
*
)(
&
(
g_stConfInfo
.
stThreads
[
i
])));
taosThreadCreate
(
&
(
g_stConfInfo
.
stThreads
[
i
].
thread
),
&
thattr
,
consumeThreadFunc
,
(
void
*
)(
&
(
g_stConfInfo
.
stThreads
[
i
])));
}
}
...
@@ -493,7 +496,7 @@ int main(int32_t argc, char* argv[]) {
...
@@ -493,7 +496,7 @@ int main(int32_t argc, char* argv[]) {
//printf("consumer: %d, cosumer1: %d\n", totalMsgs, pInfo->consumeMsgCnt);
//printf("consumer: %d, cosumer1: %d\n", totalMsgs, pInfo->consumeMsgCnt);
taosFprintfFile
(
g_fp
,
"
\n
"
);
taosFprintfFile
(
g_fp
,
"
==== close tmqlog ====
\n
"
);
taosCloseFile
(
&
g_fp
);
taosCloseFile
(
&
g_fp
);
return
0
;
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录