Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
316772ec
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看板
提交
316772ec
编写于
4月 28, 2022
作者:
P
plum-lihui
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into test-v3.0/lihui
上级
f93ff5d6
38c89b7e
变更
39
展开全部
显示空白变更内容
内联
并排
Showing
39 changed file
with
3334 addition
and
2934 deletion
+3334
-2934
include/common/ttokendef.h
include/common/ttokendef.h
+237
-237
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+133
-136
include/util/taoserror.h
include/util/taoserror.h
+0
-1
include/util/tdef.h
include/util/tdef.h
+74
-66
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+3
-3
source/client/src/clientMain.c
source/client/src/clientMain.c
+15
-12
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+1
-1
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+8
-9
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+3
-3
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+4
-2
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+50
-46
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+5
-14
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+43
-50
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+14
-10
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+28
-26
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+43
-49
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+123
-44
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+3
-3
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+122
-220
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+1
-3
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1837
-1863
source/libs/parser/test/parAlterTest.cpp
source/libs/parser/test/parAlterTest.cpp
+9
-4
source/libs/parser/test/parInsertTest.cpp
source/libs/parser/test/parInsertTest.cpp
+0
-0
source/libs/parser/test/parTestMain.cpp
source/libs/parser/test/parTestMain.cpp
+3
-4
source/libs/parser/test/parTestUtil.cpp
source/libs/parser/test/parTestUtil.cpp
+149
-0
source/libs/parser/test/parTestUtil.h
source/libs/parser/test/parTestUtil.h
+37
-0
source/libs/parser/test/parserAstTest.cpp
source/libs/parser/test/parserAstTest.cpp
+1
-1
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+1
-1
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+11
-10
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+2
-0
tests/script/tsim/db/alter_option.sim
tests/script/tsim/db/alter_option.sim
+40
-40
tests/script/tsim/db/basic6.sim
tests/script/tsim/db/basic6.sim
+8
-7
tests/script/tsim/db/create_all_options.sim
tests/script/tsim/db/create_all_options.sim
+61
-61
tests/script/tsim/parser/fourArithmetic-basic.sim
tests/script/tsim/parser/fourArithmetic-basic.sim
+1
-1
tests/system-test/2-query/Now.py
tests/system-test/2-query/Now.py
+124
-1
tests/system-test/2-query/To_iso8061.py
tests/system-test/2-query/To_iso8061.py
+69
-0
tests/system-test/2-query/timezone.py
tests/system-test/2-query/timezone.py
+64
-5
tools/shell/inc/shellInt.h
tools/shell/inc/shellInt.h
+1
-1
tools/shell/src/shellArguments.c
tools/shell/src/shellArguments.c
+6
-0
未找到文件。
include/common/ttokendef.h
浏览文件 @
316772ec
...
@@ -67,101 +67,101 @@
...
@@ -67,101 +67,101 @@
#define TK_IF 49
#define TK_IF 49
#define TK_NOT 50
#define TK_NOT 50
#define TK_EXISTS 51
#define TK_EXISTS 51
#define TK_B
LOCKS
52
#define TK_B
UFFER
52
#define TK_CACHE
53
#define TK_CACHE
LAST
53
#define TK_C
ACHELAST
54
#define TK_C
OMP
54
#define TK_
COMP
55
#define TK_
DAYS
55
#define TK_
DAYS
56
#define TK_
NK_VARIABLE
56
#define TK_
NK_VARIABLE
57
#define TK_
FSYNC
57
#define TK_
FSYNC
58
#define TK_
MAXROWS
58
#define TK_M
AXROWS
59
#define TK_M
INROWS
59
#define TK_
MINROWS
60
#define TK_
KEEP
60
#define TK_
KEEP
61
#define TK_
PAGES
61
#define TK_P
RECISION
62
#define TK_P
AGESIZE
62
#define TK_
QUORUM
63
#define TK_
PRECISION
63
#define TK_REPLICA 64
#define TK_REPLICA 64
#define TK_
TTL
65
#define TK_
STRICT
65
#define TK_WAL 66
#define TK_WAL 66
#define TK_VGROUPS 67
#define TK_VGROUPS 67
#define TK_SINGLE_STABLE 68
#define TK_SINGLE_STABLE 68
#define TK_
STREAM_MODE
69
#define TK_
RETENTIONS
69
#define TK_
RETENTIONS
70
#define TK_
NK_COMMA
70
#define TK_
STRICT
71
#define TK_
NK_COLON
71
#define TK_
NK_COMMA
72
#define TK_
TABLE
72
#define TK_NK_
COLON
73
#define TK_NK_
LP
73
#define TK_
TABLE
74
#define TK_
NK_RP
74
#define TK_
NK_LP
75
#define TK_
STABLE
75
#define TK_
NK_RP
76
#define TK_
ADD
76
#define TK_
STABLE
77
#define TK_
COLUMN
77
#define TK_
ADD
78
#define TK_
MODIFY
78
#define TK_
COLUMN
79
#define TK_
RENAME
79
#define TK_
MODIFY
80
#define TK_
TAG
80
#define TK_
RENAME
81
#define TK_
SET
81
#define TK_
TAG
82
#define TK_
NK_EQ
82
#define TK_
SET
83
#define TK_
USING
83
#define TK_
NK_EQ
84
#define TK_
TAGS
84
#define TK_
USING
85
#define TK_
NK_DOT
85
#define TK_
TAGS
86
#define TK_
COMMENT
86
#define TK_
NK_DOT
87
#define TK_
BOOL
87
#define TK_
COMMENT
88
#define TK_
TINYINT
88
#define TK_
BOOL
89
#define TK_
SMALLINT
89
#define TK_
TINYINT
90
#define TK_
INT
90
#define TK_
SMALLINT
91
#define TK_
INTEGER
91
#define TK_
INT
92
#define TK_
BIGINT
92
#define TK_
INTEGER
93
#define TK_
FLOAT
93
#define TK_
BIGINT
94
#define TK_
DOUBLE
94
#define TK_
FLOAT
95
#define TK_
BINARY
95
#define TK_
DOUBLE
96
#define TK_
TIMESTAMP
96
#define TK_
BINARY
97
#define TK_
NCHAR
97
#define TK_
TIMESTAMP
98
#define TK_
UNSIGNED
98
#define TK_
NCHAR
99
#define TK_
JSON
99
#define TK_
UNSIGNED
100
#define TK_
VARCHAR
100
#define TK_
JSON
101
#define TK_
MEDIUMBLOB
101
#define TK_
VARCHAR
102
#define TK_
BLOB
102
#define TK_
MEDIUMBLOB
103
#define TK_
VARBINARY
103
#define TK_
BLOB
104
#define TK_
DECIMAL
104
#define TK_
VARBINARY
105
#define TK_
DELAY
105
#define TK_
DECIMAL
106
#define TK_
FILE_FACTOR
106
#define TK_
SMA
107
#define TK_
NK_FLOAT
107
#define TK_ROLLUP 108
#define TK_ROLLUP 108
#define TK_
FILE_FACTOR
109
#define TK_
TTL
109
#define TK_
NK_FLOAT
110
#define TK_
SMA
110
#define TK_
DELAY
111
#define TK_
SHOW
111
#define TK_
SHOW
112
#define TK_
DATABASES
112
#define TK_
DATABASES
113
#define TK_
TABLES
113
#define TK_
TABLES
114
#define TK_
STABLES
114
#define TK_
STABLES
115
#define TK_
MNODES
115
#define TK_M
NODES
116
#define TK_M
ODULES
116
#define TK_
MODULES
117
#define TK_
QNODES
117
#define TK_
QNODES
118
#define TK_
FUNCTIONS
118
#define TK_
FUNCTIONS
119
#define TK_
INDEXES
119
#define TK_
INDEXES
120
#define TK_
FROM
120
#define TK_
FROM
121
#define TK_
ACCOUNTS
121
#define TK_A
CCOUNTS
122
#define TK_A
PPS
122
#define TK_
APPS
123
#define TK_
CONNECTIONS
123
#define TK_
CONNECTIONS
124
#define TK_
LICENCE
124
#define TK_
LICENCE
125
#define TK_
GRANTS
125
#define TK_
GRANTS
126
#define TK_
QUERIES
126
#define TK_
QUERIES
127
#define TK_
SCORES
127
#define TK_
SCORES
128
#define TK_
TOPICS
128
#define TK_
TOPICS
129
#define TK_
VARIABLES
129
#define TK_
VARIABLES
130
#define TK_
BNODES
130
#define TK_
BNODES
131
#define TK_
SNODES
131
#define TK_
SNODES
132
#define TK_
CLUSTER
132
#define TK_
CLUSTER
133
#define TK_
LIKE
133
#define TK_
LIKE
134
#define TK_
INDEX
134
#define TK_
INDEX
135
#define TK_
FULLTEXT
135
#define TK_FU
LLTEXT
136
#define TK_FU
NCTION
136
#define TK_
FUNCTION
137
#define TK_
INTERVAL
137
#define TK_
INTERVAL
138
#define TK_
TOPIC
138
#define TK_
TOPIC
139
#define TK_
AS
139
#define TK_
AS
140
#define TK_
WITH
140
#define TK_
WITH
141
#define TK_
SCHEMA
141
#define TK_
SCHEMA
142
#define TK_
DESC
142
#define TK_DESC
143
#define TK_DESC
RIBE
143
#define TK_
DESCRIBE
144
#define TK_
RESET
144
#define TK_
RESET
145
#define TK_
QUERY
145
#define TK_
QUERY
146
#define TK_
CACHE
146
#define TK_EXPLAIN 147
#define TK_EXPLAIN 147
#define TK_ANALYZE 148
#define TK_ANALYZE 148
#define TK_VERBOSE 149
#define TK_VERBOSE 149
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
316772ec
...
@@ -30,24 +30,25 @@ extern "C" {
...
@@ -30,24 +30,25 @@ extern "C" {
typedef
struct
SDatabaseOptions
{
typedef
struct
SDatabaseOptions
{
ENodeType
type
;
ENodeType
type
;
SValueNode
*
pNumOfBlocks
;
int32_t
buffer
;
SValueNode
*
pCacheBlockSize
;
int8_t
cachelast
;
SValueNode
*
pCachelast
;
int8_t
compressionLevel
;
SValueNode
*
pCompressionLevel
;
int32_t
daysPerFile
;
SValueNode
*
pDaysPerFile
;
SValueNode
*
pDaysPerFile
;
SValueNode
*
pF
syncPeriod
;
int32_t
f
syncPeriod
;
SValueNode
*
pM
axRowsPerBlock
;
int32_t
m
axRowsPerBlock
;
SValueNode
*
pM
inRowsPerBlock
;
int32_t
m
inRowsPerBlock
;
SNodeList
*
pKeep
;
SNodeList
*
pKeep
;
SValueNode
*
pPrecision
;
int32_t
keep
[
3
];
SValueNode
*
pQuorum
;
int32_t
pages
;
SValueNode
*
pReplica
;
int32_t
pagesize
;
SValueNode
*
pTtl
;
char
precisionStr
[
3
];
SValueNode
*
pWalLevel
;
int8_t
precision
;
SValueNode
*
pNumOfVgroups
;
int8_t
replica
;
SValueNode
*
pSingleStable
;
int8_t
strict
;
SValueNode
*
pStreamMode
;
int8_t
walLevel
;
SValueNode
*
pStrict
;
int32_t
numOfVgroups
;
int8_t
singleStable
;
SNodeList
*
pRetentions
;
SNodeList
*
pRetentions
;
}
SDatabaseOptions
;
}
SDatabaseOptions
;
...
@@ -77,13 +78,12 @@ typedef struct SAlterDatabaseStmt {
...
@@ -77,13 +78,12 @@ typedef struct SAlterDatabaseStmt {
typedef
struct
STableOptions
{
typedef
struct
STableOptions
{
ENodeType
type
;
ENodeType
type
;
SNodeList
*
pKeep
;
char
comment
[
TSDB_STB_COMMENT_LEN
];
SValueNode
*
pTtl
;
int32_t
delay
;
SValueNode
*
pComments
;
float
filesFactor
;
SNodeList
*
pRollupFuncs
;
int32_t
ttl
;
SNodeList
*
pSma
;
SNodeList
*
pSma
;
SNodeList
*
pFuncs
;
SValueNode
*
pFilesFactor
;
SValueNode
*
pDelay
;
}
STableOptions
;
}
STableOptions
;
typedef
struct
SColumnDefNode
{
typedef
struct
SColumnDefNode
{
...
@@ -201,10 +201,7 @@ typedef struct SShowCreatStmt {
...
@@ -201,10 +201,7 @@ typedef struct SShowCreatStmt {
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
}
SShowCreatStmt
;
}
SShowCreatStmt
;
typedef
enum
EIndexType
{
typedef
enum
EIndexType
{
INDEX_TYPE_SMA
=
1
,
INDEX_TYPE_FULLTEXT
}
EIndexType
;
INDEX_TYPE_SMA
=
1
,
INDEX_TYPE_FULLTEXT
}
EIndexType
;
typedef
struct
SIndexOptions
{
typedef
struct
SIndexOptions
{
ENodeType
type
;
ENodeType
type
;
...
...
include/util/taoserror.h
浏览文件 @
316772ec
...
@@ -586,7 +586,6 @@ int32_t* taosGetErrno();
...
@@ -586,7 +586,6 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_RANGE_OPTION TAOS_DEF_ERROR_CODE(0, 0x2619)
#define TSDB_CODE_PAR_INVALID_RANGE_OPTION TAOS_DEF_ERROR_CODE(0, 0x2619)
#define TSDB_CODE_PAR_INVALID_STR_OPTION TAOS_DEF_ERROR_CODE(0, 0x261A)
#define TSDB_CODE_PAR_INVALID_STR_OPTION TAOS_DEF_ERROR_CODE(0, 0x261A)
#define TSDB_CODE_PAR_INVALID_ENUM_OPTION TAOS_DEF_ERROR_CODE(0, 0x261B)
#define TSDB_CODE_PAR_INVALID_ENUM_OPTION TAOS_DEF_ERROR_CODE(0, 0x261B)
#define TSDB_CODE_PAR_INVALID_TTL_OPTION TAOS_DEF_ERROR_CODE(0, 0x261C)
#define TSDB_CODE_PAR_INVALID_KEEP_NUM TAOS_DEF_ERROR_CODE(0, 0x261D)
#define TSDB_CODE_PAR_INVALID_KEEP_NUM TAOS_DEF_ERROR_CODE(0, 0x261D)
#define TSDB_CODE_PAR_INVALID_KEEP_ORDER TAOS_DEF_ERROR_CODE(0, 0x261E)
#define TSDB_CODE_PAR_INVALID_KEEP_ORDER TAOS_DEF_ERROR_CODE(0, 0x261E)
#define TSDB_CODE_PAR_INVALID_KEEP_VALUE TAOS_DEF_ERROR_CODE(0, 0x261F)
#define TSDB_CODE_PAR_INVALID_KEEP_VALUE TAOS_DEF_ERROR_CODE(0, 0x261F)
...
...
include/util/tdef.h
浏览文件 @
316772ec
...
@@ -350,8 +350,6 @@ typedef enum ELogicConditionType {
...
@@ -350,8 +350,6 @@ typedef enum ELogicConditionType {
#define TSDB_MIN_FSYNC_PERIOD 0
#define TSDB_MIN_FSYNC_PERIOD 0
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
#define TSDB_MIN_DB_TTL 1
#define TSDB_DEFAULT_DB_TTL 1
#define TSDB_MIN_WAL_LEVEL 1
#define TSDB_MIN_WAL_LEVEL 1
#define TSDB_MAX_WAL_LEVEL 2
#define TSDB_MAX_WAL_LEVEL 2
#define TSDB_DEFAULT_WAL_LEVEL 1
#define TSDB_DEFAULT_WAL_LEVEL 1
...
@@ -379,13 +377,23 @@ typedef enum ELogicConditionType {
...
@@ -379,13 +377,23 @@ typedef enum ELogicConditionType {
#define TSDB_DB_SINGLE_STABLE_ON 0
#define TSDB_DB_SINGLE_STABLE_ON 0
#define TSDB_DB_SINGLE_STABLE_OFF 1
#define TSDB_DB_SINGLE_STABLE_OFF 1
#define TSDB_DEFAULT_DB_SINGLE_STABLE 0
#define TSDB_DEFAULT_DB_SINGLE_STABLE 0
#define TSDB_MIN_BUFFER_PER_VNODE 3 // unit MB
#define TSDB_DEFAULT_BUFFER_PER_VNODE 96
#define TSDB_MIN_PAGES_PER_VNODE 64
#define TSDB_DEFAULT_PAGES_PER_VNODE 256
#define TSDB_MIN_PAGESIZE_PER_VNODE 1 // unit KB
#define TSDB_MAX_PAGESIZE_PER_VNODE 16384
#define TSDB_DEFAULT_PAGESIZE_PER_VNODE 4
#define TSDB_MIN_ROLLUP_FILE_FACTOR 0
#define TSDB_MAX_ROLLUP_FILE_FACTOR 1
#define TSDB_DEFAULT_ROLLUP_FILE_FACTOR 0.1
#define TSDB_MIN_ROLLUP_DELAY 1
#define TSDB_MAX_ROLLUP_DELAY 10
#define TSDB_DEFAULT_ROLLUP_DELAY 2
#define TSDB_MIN_TABLE_TTL 0
#define TSDB_DEFAULT_TABLE_TTL 0
#define TSDB_MIN_DB_FILE_FACTOR 0
#define TSDB_MAX_DB_FILE_FACTOR 1
#define TSDB_DEFAULT_DB_FILE_FACTOR 0.1
#define TSDB_MIN_DB_DELAY 1
#define TSDB_MAX_DB_DELAY 10
#define TSDB_DEFAULT_DB_DELAY 2
#define TSDB_MIN_EXPLAIN_RATIO 0
#define TSDB_MIN_EXPLAIN_RATIO 0
#define TSDB_MAX_EXPLAIN_RATIO 1
#define TSDB_MAX_EXPLAIN_RATIO 1
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
...
...
source/client/inc/clientInt.h
浏览文件 @
316772ec
...
@@ -188,6 +188,7 @@ typedef struct SRequestSendRecvBody {
...
@@ -188,6 +188,7 @@ typedef struct SRequestSendRecvBody {
typedef
struct
{
typedef
struct
{
int8_t
resType
;
int8_t
resType
;
int32_t
code
;
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
int32_t
vgId
;
int32_t
vgId
;
SSchemaWrapper
schema
;
SSchemaWrapper
schema
;
...
@@ -311,7 +312,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
...
@@ -311,7 +312,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
int32_t
getQueryPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SArray
**
pNodeList
);
int32_t
getQueryPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SArray
**
pNodeList
);
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
);
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/client/src/clientMain.c
浏览文件 @
316772ec
...
@@ -110,16 +110,23 @@ int taos_errno(TAOS_RES *tres) {
...
@@ -110,16 +110,23 @@ int taos_errno(TAOS_RES *tres) {
return
terrno
;
return
terrno
;
}
}
if
(
TD_RES_TMQ
(
tres
))
{
return
0
;
}
return
((
SRequestObj
*
)
tres
)
->
code
;
return
((
SRequestObj
*
)
tres
)
->
code
;
}
}
const
char
*
taos_errstr
(
TAOS_RES
*
res
)
{
const
char
*
taos_errstr
(
TAOS_RES
*
res
)
{
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
res
;
if
(
res
==
NULL
)
{
if
(
pRequest
==
NULL
)
{
return
(
const
char
*
)
tstrerror
(
terrno
);
return
(
const
char
*
)
tstrerror
(
terrno
);
}
}
if
(
TD_RES_TMQ
(
res
))
{
return
"success"
;
}
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
res
;
if
(
NULL
!=
pRequest
->
msgBuf
&&
(
strlen
(
pRequest
->
msgBuf
)
>
0
||
pRequest
->
code
==
TSDB_CODE_RPC_FQDN_ERROR
))
{
if
(
NULL
!=
pRequest
->
msgBuf
&&
(
strlen
(
pRequest
->
msgBuf
)
>
0
||
pRequest
->
code
==
TSDB_CODE_RPC_FQDN_ERROR
))
{
return
pRequest
->
msgBuf
;
return
pRequest
->
msgBuf
;
}
else
{
}
else
{
...
@@ -632,9 +639,7 @@ int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) {
...
@@ -632,9 +639,7 @@ int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) {
return
stmtSetTbName
(
stmt
,
name
);
return
stmtSetTbName
(
stmt
,
name
);
}
}
int
taos_stmt_set_sub_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
)
{
int
taos_stmt_set_sub_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
)
{
return
taos_stmt_set_tbname
(
stmt
,
name
);
}
return
taos_stmt_set_tbname
(
stmt
,
name
);
}
int
taos_stmt_bind_param
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
)
{
int
taos_stmt_bind_param
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
)
{
if
(
stmt
==
NULL
||
bind
==
NULL
)
{
if
(
stmt
==
NULL
||
bind
==
NULL
)
{
...
@@ -750,9 +755,7 @@ TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) {
...
@@ -750,9 +755,7 @@ TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) {
return
stmtUseResult
(
stmt
);
return
stmtUseResult
(
stmt
);
}
}
char
*
taos_stmt_errstr
(
TAOS_STMT
*
stmt
)
{
char
*
taos_stmt_errstr
(
TAOS_STMT
*
stmt
)
{
return
(
char
*
)
stmtErrstr
(
stmt
);
}
return
(
char
*
)
stmtErrstr
(
stmt
);
}
int
taos_stmt_affected_rows
(
TAOS_STMT
*
stmt
)
{
int
taos_stmt_affected_rows
(
TAOS_STMT
*
stmt
)
{
if
(
stmt
==
NULL
)
{
if
(
stmt
==
NULL
)
{
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
316772ec
...
@@ -107,7 +107,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
...
@@ -107,7 +107,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pCfg
->
vgId
=
pCreate
->
vgId
;
pCfg
->
vgId
=
pCreate
->
vgId
;
strcpy
(
pCfg
->
dbname
,
pCreate
->
db
);
strcpy
(
pCfg
->
dbname
,
pCreate
->
db
);
pCfg
->
szBuf
=
pCreate
->
cacheBlockSize
*
1024
*
1024
;
//
pCfg->szBuf = pCreate->cacheBlockSize * 1024 * 1024;
pCfg
->
streamMode
=
pCreate
->
streamMode
;
pCfg
->
streamMode
=
pCreate
->
streamMode
;
pCfg
->
isWeak
=
true
;
pCfg
->
isWeak
=
true
;
pCfg
->
tsdbCfg
.
days
=
10
;
pCfg
->
tsdbCfg
.
days
=
10
;
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
316772ec
...
@@ -514,12 +514,12 @@ void* tDecodeSMqVgEp(const void* buf, SMqVgEp* pVgEp);
...
@@ -514,12 +514,12 @@ void* tDecodeSMqVgEp(const void* buf, SMqVgEp* pVgEp);
typedef
struct
{
typedef
struct
{
int64_t
consumerId
;
// -1 for unassigned
int64_t
consumerId
;
// -1 for unassigned
SArray
*
vgs
;
// SArray<SMqVgEp*>
SArray
*
vgs
;
// SArray<SMqVgEp*>
}
SMqConsumerEp
InSub
;
}
SMqConsumerEp
;
SMqConsumerEp
InSub
*
tCloneSMqConsumerEpInSub
(
const
SMqConsumerEpInSub
*
pEpInSub
);
SMqConsumerEp
*
tCloneSMqConsumerEp
(
const
SMqConsumerEp
*
pEp
);
void
tDeleteSMqConsumerEpInSub
(
SMqConsumerEpInSub
*
pEpInSub
);
void
tDeleteSMqConsumerEp
(
SMqConsumerEp
*
pEp
);
int32_t
tEncodeSMqConsumerEpInSub
(
void
**
buf
,
const
SMqConsumerEpInSub
*
pEpInSub
);
int32_t
tEncodeSMqConsumerEp
(
void
**
buf
,
const
SMqConsumerEp
*
pEp
);
void
*
tDecodeSMqConsumerEpInSub
(
const
void
*
buf
,
SMqConsumerEpInSub
*
pEpInSub
);
void
*
tDecodeSMqConsumerEp
(
const
void
*
buf
,
SMqConsumerEp
*
pEp
);
typedef
struct
{
typedef
struct
{
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
];
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
];
...
@@ -529,9 +529,8 @@ typedef struct {
...
@@ -529,9 +529,8 @@ typedef struct {
int8_t
withTbName
;
int8_t
withTbName
;
int8_t
withSchema
;
int8_t
withSchema
;
int8_t
withTag
;
int8_t
withTag
;
SHashObj
*
consumerHash
;
// consumerId -> SMqConsumerEpInSub
SHashObj
*
consumerHash
;
// consumerId -> SMqConsumerEp
// TODO put -1 into unassignVgs
SArray
*
unassignedVgs
;
// SArray<SMqVgEp*>
// SArray* unassignedVgs;
}
SMqSubscribeObj
;
}
SMqSubscribeObj
;
SMqSubscribeObj
*
tNewSubscribeObj
(
const
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
]);
SMqSubscribeObj
*
tNewSubscribeObj
(
const
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
]);
...
@@ -542,7 +541,7 @@ void* tDecodeSubscribeObj(const void* buf, SMqSubscribeObj* pSub);
...
@@ -542,7 +541,7 @@ void* tDecodeSubscribeObj(const void* buf, SMqSubscribeObj* pSub);
typedef
struct
{
typedef
struct
{
int32_t
epoch
;
int32_t
epoch
;
SArray
*
consumers
;
// SArray<SMqConsumerEp
InSub
*>
SArray
*
consumers
;
// SArray<SMqConsumerEp*>
}
SMqSubActionLogEntry
;
}
SMqSubActionLogEntry
;
SMqSubActionLogEntry
*
tCloneSMqSubActionLogEntry
(
SMqSubActionLogEntry
*
pEntry
);
SMqSubActionLogEntry
*
tCloneSMqSubActionLogEntry
(
SMqSubActionLogEntry
*
pEntry
);
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
316772ec
...
@@ -302,8 +302,8 @@ static int32_t mndProcessAskEpReq(SNodeMsg *pMsg) {
...
@@ -302,8 +302,8 @@ static int32_t mndProcessAskEpReq(SNodeMsg *pMsg) {
mndReleaseTopic
(
pMnode
,
pTopic
);
mndReleaseTopic
(
pMnode
,
pTopic
);
// 2.2 iterate all vg assigned to the consumer of that topic
// 2.2 iterate all vg assigned to the consumer of that topic
SMqConsumerEp
InSub
*
pEpInSub
=
taosHashGet
(
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
));
SMqConsumerEp
*
pConsumerEp
=
taosHashGet
(
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
));
int32_t
vgNum
=
taosArrayGetSize
(
pEpInSub
->
vgs
);
int32_t
vgNum
=
taosArrayGetSize
(
pConsumerEp
->
vgs
);
topicEp
.
vgs
=
taosArrayInit
(
vgNum
,
sizeof
(
SMqSubVgEp
));
topicEp
.
vgs
=
taosArrayInit
(
vgNum
,
sizeof
(
SMqSubVgEp
));
if
(
topicEp
.
vgs
==
NULL
)
{
if
(
topicEp
.
vgs
==
NULL
)
{
...
@@ -313,7 +313,7 @@ static int32_t mndProcessAskEpReq(SNodeMsg *pMsg) {
...
@@ -313,7 +313,7 @@ static int32_t mndProcessAskEpReq(SNodeMsg *pMsg) {
}
}
for
(
int32_t
j
=
0
;
j
<
vgNum
;
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
vgNum
;
j
++
)
{
SMqVgEp
*
pVgEp
=
taosArrayGetP
(
p
EpInSub
->
vgs
,
j
);
SMqVgEp
*
pVgEp
=
taosArrayGetP
(
p
ConsumerEp
->
vgs
,
j
);
char
offsetKey
[
TSDB_PARTITION_KEY_LEN
];
char
offsetKey
[
TSDB_PARTITION_KEY_LEN
];
mndMakePartitionKey
(
offsetKey
,
pConsumer
->
cgroup
,
topic
,
pVgEp
->
vgId
);
mndMakePartitionKey
(
offsetKey
,
pConsumer
->
cgroup
,
topic
,
pVgEp
->
vgId
);
// 2.2.1 build vg ep
// 2.2.1 build vg ep
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
316772ec
...
@@ -268,8 +268,10 @@ static int32_t mndCheckDbName(const char *dbName, SUserObj *pUser) {
...
@@ -268,8 +268,10 @@ static int32_t mndCheckDbName(const char *dbName, SUserObj *pUser) {
static
int32_t
mndCheckDbCfg
(
SMnode
*
pMnode
,
SDbCfg
*
pCfg
)
{
static
int32_t
mndCheckDbCfg
(
SMnode
*
pMnode
,
SDbCfg
*
pCfg
)
{
if
(
pCfg
->
numOfVgroups
<
TSDB_MIN_VNODES_PER_DB
||
pCfg
->
numOfVgroups
>
TSDB_MAX_VNODES_PER_DB
)
return
-
1
;
if
(
pCfg
->
numOfVgroups
<
TSDB_MIN_VNODES_PER_DB
||
pCfg
->
numOfVgroups
>
TSDB_MAX_VNODES_PER_DB
)
return
-
1
;
/*
if (pCfg->cacheBlockSize < TSDB_MIN_CACHE_BLOCK_SIZE || pCfg->cacheBlockSize > TSDB_MAX_CACHE_BLOCK_SIZE) return -1;
if (pCfg->cacheBlockSize < TSDB_MIN_CACHE_BLOCK_SIZE || pCfg->cacheBlockSize > TSDB_MAX_CACHE_BLOCK_SIZE) return -1;
if (pCfg->totalBlocks < TSDB_MIN_TOTAL_BLOCKS || pCfg->totalBlocks > TSDB_MAX_TOTAL_BLOCKS) return -1;
if (pCfg->totalBlocks < TSDB_MIN_TOTAL_BLOCKS || pCfg->totalBlocks > TSDB_MAX_TOTAL_BLOCKS) return -1;
*/
if
(
pCfg
->
daysPerFile
<
TSDB_MIN_DAYS_PER_FILE
||
pCfg
->
daysPerFile
>
TSDB_MAX_DAYS_PER_FILE
)
return
-
1
;
if
(
pCfg
->
daysPerFile
<
TSDB_MIN_DAYS_PER_FILE
||
pCfg
->
daysPerFile
>
TSDB_MAX_DAYS_PER_FILE
)
return
-
1
;
if
(
pCfg
->
daysToKeep0
<
TSDB_MIN_KEEP
||
pCfg
->
daysToKeep0
>
TSDB_MAX_KEEP
)
return
-
1
;
if
(
pCfg
->
daysToKeep0
<
TSDB_MIN_KEEP
||
pCfg
->
daysToKeep0
>
TSDB_MAX_KEEP
)
return
-
1
;
if
(
pCfg
->
daysToKeep1
<
TSDB_MIN_KEEP
||
pCfg
->
daysToKeep1
>
TSDB_MAX_KEEP
)
return
-
1
;
if
(
pCfg
->
daysToKeep1
<
TSDB_MIN_KEEP
||
pCfg
->
daysToKeep1
>
TSDB_MAX_KEEP
)
return
-
1
;
...
@@ -282,7 +284,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
...
@@ -282,7 +284,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
if
(
pCfg
->
minRows
>
pCfg
->
maxRows
)
return
-
1
;
if
(
pCfg
->
minRows
>
pCfg
->
maxRows
)
return
-
1
;
if
(
pCfg
->
commitTime
<
TSDB_MIN_COMMIT_TIME
||
pCfg
->
commitTime
>
TSDB_MAX_COMMIT_TIME
)
return
-
1
;
if
(
pCfg
->
commitTime
<
TSDB_MIN_COMMIT_TIME
||
pCfg
->
commitTime
>
TSDB_MAX_COMMIT_TIME
)
return
-
1
;
if
(
pCfg
->
fsyncPeriod
<
TSDB_MIN_FSYNC_PERIOD
||
pCfg
->
fsyncPeriod
>
TSDB_MAX_FSYNC_PERIOD
)
return
-
1
;
if
(
pCfg
->
fsyncPeriod
<
TSDB_MIN_FSYNC_PERIOD
||
pCfg
->
fsyncPeriod
>
TSDB_MAX_FSYNC_PERIOD
)
return
-
1
;
if
(
pCfg
->
ttl
<
TSDB_MIN_DB
_TTL
)
return
-
1
;
// if (pCfg->ttl < TSDB_MIN_TABLE
_TTL) return -1;
if
(
pCfg
->
walLevel
<
TSDB_MIN_WAL_LEVEL
||
pCfg
->
walLevel
>
TSDB_MAX_WAL_LEVEL
)
return
-
1
;
if
(
pCfg
->
walLevel
<
TSDB_MIN_WAL_LEVEL
||
pCfg
->
walLevel
>
TSDB_MAX_WAL_LEVEL
)
return
-
1
;
if
(
pCfg
->
precision
<
TSDB_MIN_PRECISION
&&
pCfg
->
precision
>
TSDB_MAX_PRECISION
)
return
-
1
;
if
(
pCfg
->
precision
<
TSDB_MIN_PRECISION
&&
pCfg
->
precision
>
TSDB_MAX_PRECISION
)
return
-
1
;
if
(
pCfg
->
compression
<
TSDB_MIN_COMP_LEVEL
||
pCfg
->
compression
>
TSDB_MAX_COMP_LEVEL
)
return
-
1
;
if
(
pCfg
->
compression
<
TSDB_MIN_COMP_LEVEL
||
pCfg
->
compression
>
TSDB_MAX_COMP_LEVEL
)
return
-
1
;
...
@@ -310,7 +312,7 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
...
@@ -310,7 +312,7 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
if
(
pCfg
->
maxRows
<
0
)
pCfg
->
maxRows
=
TSDB_DEFAULT_MAXROWS_FBLOCK
;
if
(
pCfg
->
maxRows
<
0
)
pCfg
->
maxRows
=
TSDB_DEFAULT_MAXROWS_FBLOCK
;
if
(
pCfg
->
commitTime
<
0
)
pCfg
->
commitTime
=
TSDB_DEFAULT_COMMIT_TIME
;
if
(
pCfg
->
commitTime
<
0
)
pCfg
->
commitTime
=
TSDB_DEFAULT_COMMIT_TIME
;
if
(
pCfg
->
fsyncPeriod
<
0
)
pCfg
->
fsyncPeriod
=
TSDB_DEFAULT_FSYNC_PERIOD
;
if
(
pCfg
->
fsyncPeriod
<
0
)
pCfg
->
fsyncPeriod
=
TSDB_DEFAULT_FSYNC_PERIOD
;
if
(
pCfg
->
ttl
<
0
)
pCfg
->
ttl
=
TSDB_DEFAULT_
DB
_TTL
;
if
(
pCfg
->
ttl
<
0
)
pCfg
->
ttl
=
TSDB_DEFAULT_
TABLE
_TTL
;
if
(
pCfg
->
walLevel
<
0
)
pCfg
->
walLevel
=
TSDB_DEFAULT_WAL_LEVEL
;
if
(
pCfg
->
walLevel
<
0
)
pCfg
->
walLevel
=
TSDB_DEFAULT_WAL_LEVEL
;
if
(
pCfg
->
precision
<
0
)
pCfg
->
precision
=
TSDB_DEFAULT_PRECISION
;
if
(
pCfg
->
precision
<
0
)
pCfg
->
precision
=
TSDB_DEFAULT_PRECISION
;
if
(
pCfg
->
compression
<
0
)
pCfg
->
compression
=
TSDB_DEFAULT_COMP_LEVEL
;
if
(
pCfg
->
compression
<
0
)
pCfg
->
compression
=
TSDB_DEFAULT_COMP_LEVEL
;
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
316772ec
...
@@ -211,42 +211,47 @@ void *tDecodeSMqVgEp(const void *buf, SMqVgEp *pVgEp) {
...
@@ -211,42 +211,47 @@ void *tDecodeSMqVgEp(const void *buf, SMqVgEp *pVgEp) {
return
(
void
*
)
buf
;
return
(
void
*
)
buf
;
}
}
SMqConsumerEp
InSub
*
tCloneSMqConsumerEpInSub
(
const
SMqConsumerEpInSub
*
pEpInSub
)
{
SMqConsumerEp
*
tCloneSMqConsumerEp
(
const
SMqConsumerEp
*
pConsumerEpOld
)
{
SMqConsumerEp
InSub
*
pEpInSubNew
=
taosMemoryMalloc
(
sizeof
(
SMqConsumerEpInSub
));
SMqConsumerEp
*
pConsumerEpNew
=
taosMemoryMalloc
(
sizeof
(
SMqConsumerEp
));
if
(
p
EpInSub
New
==
NULL
)
return
NULL
;
if
(
p
ConsumerEp
New
==
NULL
)
return
NULL
;
p
EpInSubNew
->
consumerId
=
pEpInSub
->
consumerId
;
p
ConsumerEpNew
->
consumerId
=
pConsumerEpOld
->
consumerId
;
p
EpInSubNew
->
vgs
=
taosArrayDeepCopy
(
pEpInSub
->
vgs
,
(
FCopy
)
tCloneSMqVgEp
);
p
ConsumerEpNew
->
vgs
=
taosArrayDeepCopy
(
pConsumerEpOld
->
vgs
,
(
FCopy
)
tCloneSMqVgEp
);
return
p
EpInSub
New
;
return
p
ConsumerEp
New
;
}
}
void
tDeleteSMqConsumerEpInSub
(
SMqConsumerEpInSub
*
pEpInSub
)
{
void
tDeleteSMqConsumerEp
(
SMqConsumerEp
*
pConsumerEp
)
{
taosArrayDestroyEx
(
pEpInSub
->
vgs
,
(
FDelete
)
tDeleteSMqVgEp
);
//
taosArrayDestroyP
(
pConsumerEp
->
vgs
,
(
FDelete
)
tDeleteSMqVgEp
);
}
}
int32_t
tEncodeSMqConsumerEp
InSub
(
void
**
buf
,
const
SMqConsumerEpInSub
*
pEpInSub
)
{
int32_t
tEncodeSMqConsumerEp
(
void
**
buf
,
const
SMqConsumerEp
*
pConsumerEp
)
{
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pEpInSub
->
consumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pConsumerEp
->
consumerId
);
int32_t
sz
=
taosArrayGetSize
(
pEpInSub
->
vgs
);
tlen
+=
taosEncodeArray
(
buf
,
pConsumerEp
->
vgs
,
(
FEncode
)
tEncodeSMqVgEp
);
#if 0
int32_t sz = taosArrayGetSize(pConsumerEp->vgs);
tlen += taosEncodeFixedI32(buf, sz);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
for (int32_t i = 0; i < sz; i++) {
SMqVgEp
*
pVgEp
=
taosArrayGetP
(
p
EpInSub
->
vgs
,
i
);
SMqVgEp *pVgEp = taosArrayGetP(p
ConsumerEp
->vgs, i);
tlen += tEncodeSMqVgEp(buf, pVgEp);
tlen += tEncodeSMqVgEp(buf, pVgEp);
}
}
/*tlen += taosEncodeArray(buf, pEpInSub->vgs, (FEncode)tEncodeSMqVgEp);*/
#endif
return
tlen
;
return
tlen
;
}
}
void
*
tDecodeSMqConsumerEpInSub
(
const
void
*
buf
,
SMqConsumerEpInSub
*
pEpInSub
)
{
void
*
tDecodeSMqConsumerEp
(
const
void
*
buf
,
SMqConsumerEp
*
pConsumerEp
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pEpInSub
->
consumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pConsumerEp
->
consumerId
);
/*buf = taosDecodeArray(buf, &pEpInSub->vgs, (FDecode)tDecodeSMqVgEp, sizeof(SMqSubVgEp));*/
buf
=
taosDecodeArray
(
buf
,
&
pConsumerEp
->
vgs
,
(
FDecode
)
tDecodeSMqVgEp
,
sizeof
(
SMqSubVgEp
));
#if 0
int32_t sz;
int32_t sz;
buf = taosDecodeFixedI32(buf, &sz);
buf = taosDecodeFixedI32(buf, &sz);
p
EpInSub
->
vgs
=
taosArrayInit
(
sz
,
sizeof
(
void
*
));
p
ConsumerEp
->vgs = taosArrayInit(sz, sizeof(void *));
for (int32_t i = 0; i < sz; i++) {
for (int32_t i = 0; i < sz; i++) {
SMqVgEp *pVgEp = taosMemoryMalloc(sizeof(SMqVgEp));
SMqVgEp *pVgEp = taosMemoryMalloc(sizeof(SMqVgEp));
buf = tDecodeSMqVgEp(buf, pVgEp);
buf = tDecodeSMqVgEp(buf, pVgEp);
taosArrayPush
(
p
EpInSub
->
vgs
,
&
pVgEp
);
taosArrayPush(p
ConsumerEp
->vgs, &pVgEp);
}
}
#endif
return
(
void
*
)
buf
;
return
(
void
*
)
buf
;
}
}
...
@@ -258,13 +263,11 @@ SMqSubscribeObj *tNewSubscribeObj(const char key[TSDB_SUBSCRIBE_KEY_LEN]) {
...
@@ -258,13 +263,11 @@ SMqSubscribeObj *tNewSubscribeObj(const char key[TSDB_SUBSCRIBE_KEY_LEN]) {
taosInitRWLatch
(
&
pSubNew
->
lock
);
taosInitRWLatch
(
&
pSubNew
->
lock
);
pSubNew
->
vgNum
=
0
;
pSubNew
->
vgNum
=
0
;
pSubNew
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
pSubNew
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
// TODO set free fp
// TODO set hash free fp
SMqConsumerEpInSub
epInSub
=
{
/*taosHashSetFreeFp(pSubNew->consumerHash, tDeleteSMqConsumerEp);*/
.
consumerId
=
-
1
,
.
vgs
=
taosArrayInit
(
0
,
sizeof
(
void
*
)),
pSubNew
->
unassignedVgs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
};
int64_t
unexistKey
=
-
1
;
taosHashPut
(
pSubNew
->
consumerHash
,
&
unexistKey
,
sizeof
(
int64_t
),
&
epInSub
,
sizeof
(
SMqConsumerEpInSub
));
return
pSubNew
;
return
pSubNew
;
}
}
...
@@ -281,25 +284,27 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
...
@@ -281,25 +284,27 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
pSubNew
->
vgNum
=
pSub
->
vgNum
;
pSubNew
->
vgNum
=
pSub
->
vgNum
;
pSubNew
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
pSubNew
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
/*taosHashSetFreeFp(pSubNew->consumerHash, taosArrayDestroy);*/
// TODO set hash free fp
/*taosHashSetFreeFp(pSubNew->consumerHash, tDeleteSMqConsumerEp);*/
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
SMqConsumerEp
InSub
*
pEpInSub
=
NULL
;
SMqConsumerEp
*
pConsumerEp
=
NULL
;
while
(
1
)
{
while
(
1
)
{
pIter
=
taosHashIterate
(
pSub
->
consumerHash
,
pIter
);
pIter
=
taosHashIterate
(
pSub
->
consumerHash
,
pIter
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
p
EpInSub
=
(
SMqConsumerEpInSub
*
)
pIter
;
p
ConsumerEp
=
(
SMqConsumerEp
*
)
pIter
;
SMqConsumerEp
InSub
newEp
=
{
SMqConsumerEp
newEp
=
{
.
consumerId
=
p
EpInSub
->
consumerId
,
.
consumerId
=
p
ConsumerEp
->
consumerId
,
.
vgs
=
taosArrayDeepCopy
(
p
EpInSub
->
vgs
,
(
FCopy
)
tCloneSMqVgEp
),
.
vgs
=
taosArrayDeepCopy
(
p
ConsumerEp
->
vgs
,
(
FCopy
)
tCloneSMqVgEp
),
};
};
taosHashPut
(
pSubNew
->
consumerHash
,
&
newEp
.
consumerId
,
sizeof
(
int64_t
),
&
newEp
,
sizeof
(
SMqConsumerEp
InSub
));
taosHashPut
(
pSubNew
->
consumerHash
,
&
newEp
.
consumerId
,
sizeof
(
int64_t
),
&
newEp
,
sizeof
(
SMqConsumerEp
));
}
}
pSubNew
->
unassignedVgs
=
taosArrayDeepCopy
(
pSub
->
unassignedVgs
,
(
FCopy
)
tCloneSMqVgEp
);
return
pSubNew
;
return
pSubNew
;
}
}
void
tDeleteSubscribeObj
(
SMqSubscribeObj
*
pSub
)
{
void
tDeleteSubscribeObj
(
SMqSubscribeObj
*
pSub
)
{
/*taosArrayDestroyEx(pSub->consumerEps, (FDelete)tDeleteSMqConsumerEpInSub);*/
taosHashCleanup
(
pSub
->
consumerHash
);
taosHashCleanup
(
pSub
->
consumerHash
);
taosArrayDestroyP
(
pSub
->
unassignedVgs
,
(
FDelete
)
tDeleteSMqVgEp
);
}
}
int32_t
tEncodeSubscribeObj
(
void
**
buf
,
const
SMqSubscribeObj
*
pSub
)
{
int32_t
tEncodeSubscribeObj
(
void
**
buf
,
const
SMqSubscribeObj
*
pSub
)
{
...
@@ -319,12 +324,12 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
...
@@ -319,12 +324,12 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
while
(
1
)
{
while
(
1
)
{
pIter
=
taosHashIterate
(
pSub
->
consumerHash
,
pIter
);
pIter
=
taosHashIterate
(
pSub
->
consumerHash
,
pIter
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
SMqConsumerEp
InSub
*
pEpInSub
=
(
SMqConsumerEpInSub
*
)
pIter
;
SMqConsumerEp
*
pConsumerEp
=
(
SMqConsumerEp
*
)
pIter
;
tlen
+=
tEncodeSMqConsumerEp
InSub
(
buf
,
pEpInSub
);
tlen
+=
tEncodeSMqConsumerEp
(
buf
,
pConsumerEp
);
cnt
++
;
cnt
++
;
}
}
ASSERT
(
cnt
==
sz
);
ASSERT
(
cnt
==
sz
);
/*tlen += taosEncodeArray(buf, pSub->consumerEps, (FEncode)tEncodeSMqConsumerEpInSub);*/
tlen
+=
taosEncodeArray
(
buf
,
pSub
->
unassignedVgs
,
(
FEncode
)
tEncodeSMqVgEp
);
return
tlen
;
return
tlen
;
}
}
...
@@ -342,13 +347,12 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
...
@@ -342,13 +347,12 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
pSub
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
pSub
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
/*SMqConsumerEpInSub* pEpInSub = taosMemoryMalloc(sizeof(SMqConsumerEpInSub));*/
SMqConsumerEp
consumerEp
=
{
0
};
SMqConsumerEpInSub
epInSub
=
{
0
};
buf
=
tDecodeSMqConsumerEp
(
buf
,
&
consumerEp
);
buf
=
tDecodeSMqConsumerEpInSub
(
buf
,
&
epInSub
);
taosHashPut
(
pSub
->
consumerHash
,
&
consumerEp
.
consumerId
,
sizeof
(
int64_t
),
&
consumerEp
,
sizeof
(
SMqConsumerEp
));
taosHashPut
(
pSub
->
consumerHash
,
&
epInSub
.
consumerId
,
sizeof
(
int64_t
),
&
epInSub
,
sizeof
(
SMqConsumerEpInSub
));
}
}
/*buf = taosDecodeArray(buf, &pSub->consumerEps, (FDecode)tDecodeSMqConsumerEpInSub, sizeof(SMqConsumerEpInSub));*/
buf
=
taosDecodeArray
(
buf
,
&
pSub
->
unassignedVgs
,
(
FDecode
)
tDecodeSMqVgEp
,
sizeof
(
SMqVgEp
));
return
(
void
*
)
buf
;
return
(
void
*
)
buf
;
}
}
...
@@ -356,12 +360,12 @@ SMqSubActionLogEntry *tCloneSMqSubActionLogEntry(SMqSubActionLogEntry *pEntry) {
...
@@ -356,12 +360,12 @@ SMqSubActionLogEntry *tCloneSMqSubActionLogEntry(SMqSubActionLogEntry *pEntry) {
SMqSubActionLogEntry
*
pEntryNew
=
taosMemoryMalloc
(
sizeof
(
SMqSubActionLogEntry
));
SMqSubActionLogEntry
*
pEntryNew
=
taosMemoryMalloc
(
sizeof
(
SMqSubActionLogEntry
));
if
(
pEntryNew
==
NULL
)
return
NULL
;
if
(
pEntryNew
==
NULL
)
return
NULL
;
pEntryNew
->
epoch
=
pEntry
->
epoch
;
pEntryNew
->
epoch
=
pEntry
->
epoch
;
pEntryNew
->
consumers
=
taosArrayDeepCopy
(
pEntry
->
consumers
,
(
FCopy
)
tCloneSMqConsumerEp
InSub
);
pEntryNew
->
consumers
=
taosArrayDeepCopy
(
pEntry
->
consumers
,
(
FCopy
)
tCloneSMqConsumerEp
);
return
pEntryNew
;
return
pEntryNew
;
}
}
void
tDeleteSMqSubActionLogEntry
(
SMqSubActionLogEntry
*
pEntry
)
{
void
tDeleteSMqSubActionLogEntry
(
SMqSubActionLogEntry
*
pEntry
)
{
taosArrayDestroyEx
(
pEntry
->
consumers
,
(
FDelete
)
tDeleteSMqConsumerEp
InSub
);
taosArrayDestroyEx
(
pEntry
->
consumers
,
(
FDelete
)
tDeleteSMqConsumerEp
);
}
}
int32_t
tEncodeSMqSubActionLogEntry
(
void
**
buf
,
const
SMqSubActionLogEntry
*
pEntry
)
{
int32_t
tEncodeSMqSubActionLogEntry
(
void
**
buf
,
const
SMqSubActionLogEntry
*
pEntry
)
{
...
@@ -381,12 +385,12 @@ SMqSubActionLogObj *tCloneSMqSubActionLogObj(SMqSubActionLogObj *pLog) {
...
@@ -381,12 +385,12 @@ SMqSubActionLogObj *tCloneSMqSubActionLogObj(SMqSubActionLogObj *pLog) {
SMqSubActionLogObj
*
pLogNew
=
taosMemoryMalloc
(
sizeof
(
SMqSubActionLogObj
));
SMqSubActionLogObj
*
pLogNew
=
taosMemoryMalloc
(
sizeof
(
SMqSubActionLogObj
));
if
(
pLogNew
==
NULL
)
return
pLogNew
;
if
(
pLogNew
==
NULL
)
return
pLogNew
;
memcpy
(
pLogNew
->
key
,
pLog
->
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
memcpy
(
pLogNew
->
key
,
pLog
->
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
pLogNew
->
logs
=
taosArrayDeepCopy
(
pLog
->
logs
,
(
FCopy
)
tCloneSMqConsumerEp
InSub
);
pLogNew
->
logs
=
taosArrayDeepCopy
(
pLog
->
logs
,
(
FCopy
)
tCloneSMqConsumerEp
);
return
pLogNew
;
return
pLogNew
;
}
}
void
tDeleteSMqSubActionLogObj
(
SMqSubActionLogObj
*
pLog
)
{
void
tDeleteSMqSubActionLogObj
(
SMqSubActionLogObj
*
pLog
)
{
taosArrayDestroyEx
(
pLog
->
logs
,
(
FDelete
)
tDeleteSMqConsumerEp
InSub
);
taosArrayDestroyEx
(
pLog
->
logs
,
(
FDelete
)
tDeleteSMqConsumerEp
);
}
}
int32_t
tEncodeSMqSubActionLogObj
(
void
**
buf
,
const
SMqSubActionLogObj
*
pLog
)
{
int32_t
tEncodeSMqSubActionLogObj
(
void
**
buf
,
const
SMqSubActionLogObj
*
pLog
)
{
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
316772ec
...
@@ -504,11 +504,8 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
...
@@ -504,11 +504,8 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
plan
=
nodesListGetNode
(
inner
->
pNodeList
,
0
);
plan
=
nodesListGetNode
(
inner
->
pNodeList
,
0
);
}
}
int64_t
unexistKey
=
-
1
;
ASSERT
(
pSub
->
unassignedVgs
);
SMqConsumerEpInSub
*
pEpInSub
=
taosHashGet
(
pSub
->
consumerHash
,
&
unexistKey
,
sizeof
(
int64_t
));
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
0
);
ASSERT
(
pEpInSub
);
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
1
);
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
while
(
1
)
{
...
@@ -524,7 +521,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
...
@@ -524,7 +521,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
SMqVgEp
*
pVgEp
=
taosMemoryMalloc
(
sizeof
(
SMqVgEp
));
SMqVgEp
*
pVgEp
=
taosMemoryMalloc
(
sizeof
(
SMqVgEp
));
pVgEp
->
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
pVgEp
->
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
pVgEp
->
vgId
=
pVgroup
->
vgId
;
pVgEp
->
vgId
=
pVgroup
->
vgId
;
taosArrayPush
(
p
EpInSub
->
v
gs
,
&
pVgEp
);
taosArrayPush
(
p
Sub
->
unassignedV
gs
,
&
pVgEp
);
mDebug
(
"init subscription %s, assign vg: %d"
,
pSub
->
key
,
pVgEp
->
vgId
);
mDebug
(
"init subscription %s, assign vg: %d"
,
pSub
->
key
,
pVgEp
->
vgId
);
...
@@ -543,17 +540,11 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
...
@@ -543,17 +540,11 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
}
else
{
}
else
{
pVgEp
->
qmsg
=
strdup
(
""
);
pVgEp
->
qmsg
=
strdup
(
""
);
}
}
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
1
);
/*taosArrayPush(pSub->unassignedVg, &consumerEp);*/
}
}
pEpInSub
=
taosHashGet
(
pSub
->
consumerHash
,
&
unexistKey
,
sizeof
(
int64_t
));
ASSERT
(
pSub
->
unassignedVgs
->
size
>
0
);
ASSERT
(
pEpInSub
->
vgs
->
size
>
0
);
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
1
);
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
0
);
qDestroyQueryPlan
(
pPlan
);
qDestroyQueryPlan
(
pPlan
);
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
316772ec
...
@@ -85,7 +85,8 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic,
...
@@ -85,7 +85,8 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic,
pSub
->
withSchema
=
pTopic
->
withSchema
;
pSub
->
withSchema
=
pTopic
->
withSchema
;
pSub
->
withTag
=
pTopic
->
withTag
;
pSub
->
withTag
=
pTopic
->
withTag
;
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
1
);
ASSERT
(
pSub
->
unassignedVgs
->
size
==
0
);
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
0
);
if
(
mndSchedInitSubEp
(
pMnode
,
pTopic
,
pSub
)
<
0
)
{
if
(
mndSchedInitSubEp
(
pMnode
,
pTopic
,
pSub
)
<
0
)
{
tDeleteSubscribeObj
(
pSub
);
tDeleteSubscribeObj
(
pSub
);
...
@@ -93,7 +94,8 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic,
...
@@ -93,7 +94,8 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic,
return
NULL
;
return
NULL
;
}
}
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
1
);
ASSERT
(
pSub
->
unassignedVgs
->
size
>
0
);
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
0
);
return
pSub
;
return
pSub
;
}
}
...
@@ -185,7 +187,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -185,7 +187,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
if
(
pInput
->
pTopic
!=
NULL
)
{
if
(
pInput
->
pTopic
!=
NULL
)
{
// create subscribe
// create subscribe
pOutput
->
pSub
=
mndCreateSub
(
pMnode
,
pInput
->
pTopic
,
pInput
->
pRebInfo
->
key
);
pOutput
->
pSub
=
mndCreateSub
(
pMnode
,
pInput
->
pTopic
,
pInput
->
pRebInfo
->
key
);
ASSERT
(
taosHashGetSize
(
pOutput
->
pSub
->
consumerHash
)
==
1
);
ASSERT
(
taosHashGetSize
(
pOutput
->
pSub
->
consumerHash
)
==
0
);
}
else
{
}
else
{
pOutput
->
pSub
=
tCloneSubscribeObj
(
pInput
->
pOldSub
);
pOutput
->
pSub
=
tCloneSubscribeObj
(
pInput
->
pOldSub
);
}
}
...
@@ -196,21 +198,20 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -196,21 +198,20 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
// 1. build temporary hash(vgId -> SMqRebOutputVg) to store modified vg
// 1. build temporary hash(vgId -> SMqRebOutputVg) to store modified vg
SHashObj
*
pHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
SHashObj
*
pHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
ASSERT
(
taosHashGetSize
(
pOutput
->
pSub
->
consumerHash
)
>
0
);
// 2. check and get actual removed consumers, put their vg into hash
// 2. check and get actual removed consumers, put their vg into hash
int32_t
removedNum
=
taosArrayGetSize
(
pInput
->
pRebInfo
->
removedConsumers
);
int32_t
removedNum
=
taosArrayGetSize
(
pInput
->
pRebInfo
->
removedConsumers
);
int32_t
actualRemoved
=
0
;
int32_t
actualRemoved
=
0
;
for
(
int32_t
i
=
0
;
i
<
removedNum
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
removedNum
;
i
++
)
{
int64_t
consumerId
=
*
(
int64_t
*
)
taosArrayGet
(
pInput
->
pRebInfo
->
removedConsumers
,
i
);
int64_t
consumerId
=
*
(
int64_t
*
)
taosArrayGet
(
pInput
->
pRebInfo
->
removedConsumers
,
i
);
ASSERT
(
consumerId
>
0
);
ASSERT
(
consumerId
>
0
);
SMqConsumerEp
InSub
*
pEpInSub
=
taosHashGet
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
));
SMqConsumerEp
*
pConsumerEp
=
taosHashGet
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
));
ASSERT
(
p
EpInSub
);
ASSERT
(
p
ConsumerEp
);
if
(
p
EpInSub
)
{
if
(
p
ConsumerEp
)
{
ASSERT
(
consumerId
==
p
EpInSub
->
consumerId
);
ASSERT
(
consumerId
==
p
ConsumerEp
->
consumerId
);
actualRemoved
++
;
actualRemoved
++
;
int32_t
consumerVgNum
=
taosArrayGetSize
(
p
EpInSub
->
vgs
);
int32_t
consumerVgNum
=
taosArrayGetSize
(
p
ConsumerEp
->
vgs
);
for
(
int32_t
j
=
0
;
j
<
consumerVgNum
;
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
consumerVgNum
;
j
++
)
{
SMqVgEp
*
pVgEp
=
taosArrayGetP
(
p
EpInSub
->
vgs
,
j
);
SMqVgEp
*
pVgEp
=
taosArrayGetP
(
p
ConsumerEp
->
vgs
,
j
);
SMqRebOutputVg
outputVg
=
{
SMqRebOutputVg
outputVg
=
{
.
oldConsumerId
=
consumerId
,
.
oldConsumerId
=
consumerId
,
.
newConsumerId
=
-
1
,
.
newConsumerId
=
-
1
,
...
@@ -224,16 +225,12 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -224,16 +225,12 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
}
}
}
}
ASSERT
(
removedNum
==
actualRemoved
);
ASSERT
(
removedNum
==
actualRemoved
);
ASSERT
(
taosHashGetSize
(
pOutput
->
pSub
->
consumerHash
)
>
0
);
// if previously no consumer, there are vgs not assigned
// if previously no consumer, there are vgs not assigned
{
{
int64_t
unexistKey
=
-
1
;
int32_t
consumerVgNum
=
taosArrayGetSize
(
pOutput
->
pSub
->
unassignedVgs
);
SMqConsumerEpInSub
*
pEpInSub
=
taosHashGet
(
pOutput
->
pSub
->
consumerHash
,
&
unexistKey
,
sizeof
(
int64_t
));
ASSERT
(
pEpInSub
);
int32_t
consumerVgNum
=
taosArrayGetSize
(
pEpInSub
->
vgs
);
for
(
int32_t
i
=
0
;
i
<
consumerVgNum
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
consumerVgNum
;
i
++
)
{
SMqVgEp
*
pVgEp
=
*
(
SMqVgEp
**
)
taosArrayPop
(
p
EpInSub
->
v
gs
);
SMqVgEp
*
pVgEp
=
*
(
SMqVgEp
**
)
taosArrayPop
(
p
Output
->
pSub
->
unassignedV
gs
);
SMqRebOutputVg
rebOutput
=
{
SMqRebOutputVg
rebOutput
=
{
.
oldConsumerId
=
-
1
,
.
oldConsumerId
=
-
1
,
.
newConsumerId
=
-
1
,
.
newConsumerId
=
-
1
,
...
@@ -246,7 +243,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -246,7 +243,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
// 3. calc vg number of each consumer
// 3. calc vg number of each consumer
int32_t
oldSz
=
0
;
int32_t
oldSz
=
0
;
if
(
pInput
->
pOldSub
)
{
if
(
pInput
->
pOldSub
)
{
oldSz
=
taosHashGetSize
(
pInput
->
pOldSub
->
consumerHash
)
-
1
;
oldSz
=
taosHashGetSize
(
pInput
->
pOldSub
->
consumerHash
);
}
}
int32_t
afterRebConsumerNum
=
int32_t
afterRebConsumerNum
=
oldSz
+
taosArrayGetSize
(
pInput
->
pRebInfo
->
newConsumers
)
-
taosArrayGetSize
(
pInput
->
pRebInfo
->
removedConsumers
);
oldSz
+
taosArrayGetSize
(
pInput
->
pRebInfo
->
newConsumers
)
-
taosArrayGetSize
(
pInput
->
pRebInfo
->
removedConsumers
);
...
@@ -264,23 +261,22 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -264,23 +261,22 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
while
(
1
)
{
while
(
1
)
{
pIter
=
taosHashIterate
(
pOutput
->
pSub
->
consumerHash
,
pIter
);
pIter
=
taosHashIterate
(
pOutput
->
pSub
->
consumerHash
,
pIter
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
SMqConsumerEpInSub
*
pEpInSub
=
(
SMqConsumerEpInSub
*
)
pIter
;
SMqConsumerEp
*
pConsumerEp
=
(
SMqConsumerEp
*
)
pIter
;
if
(
pEpInSub
->
consumerId
==
-
1
)
continue
;
ASSERT
(
pConsumerEp
->
consumerId
>
0
);
ASSERT
(
pEpInSub
->
consumerId
>
0
);
int32_t
consumerVgNum
=
taosArrayGetSize
(
pConsumerEp
->
vgs
);
int32_t
consumerVgNum
=
taosArrayGetSize
(
pEpInSub
->
vgs
);
// all old consumers still existing are touched
// all old consumers still existing are touched
// TODO optimize: touch only consumer whose vgs changed
// TODO optimize: touch only consumer whose vgs changed
taosArrayPush
(
pOutput
->
touchedConsumers
,
&
p
EpInSub
->
consumerId
);
taosArrayPush
(
pOutput
->
touchedConsumers
,
&
p
ConsumerEp
->
consumerId
);
if
(
consumerVgNum
>
minVgCnt
)
{
if
(
consumerVgNum
>
minVgCnt
)
{
if
(
imbCnt
<
imbConsumerNum
)
{
if
(
imbCnt
<
imbConsumerNum
)
{
if
(
consumerVgNum
==
minVgCnt
+
1
)
{
if
(
consumerVgNum
==
minVgCnt
+
1
)
{
continue
;
continue
;
}
else
{
}
else
{
// pop until equal minVg + 1
// pop until equal minVg + 1
while
(
taosArrayGetSize
(
p
EpInSub
->
vgs
)
>
minVgCnt
+
1
)
{
while
(
taosArrayGetSize
(
p
ConsumerEp
->
vgs
)
>
minVgCnt
+
1
)
{
SMqVgEp
*
pVgEp
=
*
(
SMqVgEp
**
)
taosArrayPop
(
p
EpInSub
->
vgs
);
SMqVgEp
*
pVgEp
=
*
(
SMqVgEp
**
)
taosArrayPop
(
p
ConsumerEp
->
vgs
);
SMqRebOutputVg
outputVg
=
{
SMqRebOutputVg
outputVg
=
{
.
oldConsumerId
=
p
EpInSub
->
consumerId
,
.
oldConsumerId
=
p
ConsumerEp
->
consumerId
,
.
newConsumerId
=
-
1
,
.
newConsumerId
=
-
1
,
.
pVgEp
=
pVgEp
,
.
pVgEp
=
pVgEp
,
};
};
...
@@ -290,10 +286,10 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -290,10 +286,10 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
}
}
}
else
{
}
else
{
// pop until equal minVg
// pop until equal minVg
while
(
taosArrayGetSize
(
p
EpInSub
->
vgs
)
>
minVgCnt
)
{
while
(
taosArrayGetSize
(
p
ConsumerEp
->
vgs
)
>
minVgCnt
)
{
SMqVgEp
*
pVgEp
=
*
(
SMqVgEp
**
)
taosArrayPop
(
p
EpInSub
->
vgs
);
SMqVgEp
*
pVgEp
=
*
(
SMqVgEp
**
)
taosArrayPop
(
p
ConsumerEp
->
vgs
);
SMqRebOutputVg
outputVg
=
{
SMqRebOutputVg
outputVg
=
{
.
oldConsumerId
=
p
EpInSub
->
consumerId
,
.
oldConsumerId
=
p
ConsumerEp
->
consumerId
,
.
newConsumerId
=
-
1
,
.
newConsumerId
=
-
1
,
.
pVgEp
=
pVgEp
,
.
pVgEp
=
pVgEp
,
};
};
...
@@ -309,12 +305,11 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -309,12 +305,11 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
for
(
int32_t
i
=
0
;
i
<
consumerNum
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
consumerNum
;
i
++
)
{
int64_t
consumerId
=
*
(
int64_t
*
)
taosArrayGet
(
pInput
->
pRebInfo
->
newConsumers
,
i
);
int64_t
consumerId
=
*
(
int64_t
*
)
taosArrayGet
(
pInput
->
pRebInfo
->
newConsumers
,
i
);
ASSERT
(
consumerId
>
0
);
ASSERT
(
consumerId
>
0
);
SMqConsumerEp
InSub
newConsumerEp
;
SMqConsumerEp
newConsumerEp
;
newConsumerEp
.
consumerId
=
consumerId
;
newConsumerEp
.
consumerId
=
consumerId
;
newConsumerEp
.
vgs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
newConsumerEp
.
vgs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
taosHashPut
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
),
&
newConsumerEp
,
taosHashPut
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
),
&
newConsumerEp
,
sizeof
(
SMqConsumerEp
));
sizeof
(
SMqConsumerEpInSub
));
/*SMqConsumer* pTestNew = taosHashGet(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t));*/
/*SMqConsumerEpInSub *pTestNew = taosHashGet(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t));*/
/*ASSERT(pTestNew->consumerId == consumerId);*/
/*ASSERT(pTestNew->consumerId == consumerId);*/
/*ASSERT(pTestNew->vgs == newConsumerEp.vgs);*/
/*ASSERT(pTestNew->vgs == newConsumerEp.vgs);*/
taosArrayPush
(
pOutput
->
newConsumers
,
&
consumerId
);
taosArrayPush
(
pOutput
->
newConsumers
,
&
consumerId
);
...
@@ -329,25 +324,24 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -329,25 +324,24 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
while
(
1
)
{
while
(
1
)
{
pIter
=
taosHashIterate
(
pOutput
->
pSub
->
consumerHash
,
pIter
);
pIter
=
taosHashIterate
(
pOutput
->
pSub
->
consumerHash
,
pIter
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
SMqConsumerEpInSub
*
pEpInSub
=
(
SMqConsumerEpInSub
*
)
pIter
;
SMqConsumerEp
*
pConsumerEp
=
(
SMqConsumerEp
*
)
pIter
;
if
(
pEpInSub
->
consumerId
==
-
1
)
continue
;
ASSERT
(
pConsumerEp
->
consumerId
>
0
);
ASSERT
(
pEpInSub
->
consumerId
>
0
);
// push until equal minVg
// push until equal minVg
while
(
taosArrayGetSize
(
p
EpInSub
->
vgs
)
<
minVgCnt
)
{
while
(
taosArrayGetSize
(
p
ConsumerEp
->
vgs
)
<
minVgCnt
)
{
// iter hash and find one vg
// iter hash and find one vg
pRemovedIter
=
taosHashIterate
(
pHash
,
pRemovedIter
);
pRemovedIter
=
taosHashIterate
(
pHash
,
pRemovedIter
);
ASSERT
(
pRemovedIter
);
ASSERT
(
pRemovedIter
);
pRebVg
=
(
SMqRebOutputVg
*
)
pRemovedIter
;
pRebVg
=
(
SMqRebOutputVg
*
)
pRemovedIter
;
// push
// push
taosArrayPush
(
p
EpInSub
->
vgs
,
&
pRebVg
->
pVgEp
);
taosArrayPush
(
p
ConsumerEp
->
vgs
,
&
pRebVg
->
pVgEp
);
pRebVg
->
newConsumerId
=
p
EpInSub
->
consumerId
;
pRebVg
->
newConsumerId
=
p
ConsumerEp
->
consumerId
;
taosArrayPush
(
pOutput
->
rebVgs
,
pRebVg
);
taosArrayPush
(
pOutput
->
rebVgs
,
pRebVg
);
}
}
}
}
// 7. handle unassigned vg
// 7. handle unassigned vg
if
(
taosHashGetSize
(
pOutput
->
pSub
->
consumerHash
)
!=
1
)
{
if
(
taosHashGetSize
(
pOutput
->
pSub
->
consumerHash
)
!=
0
)
{
// if has consumer, assign all left vg
// if has consumer, assign all left vg
while
(
1
)
{
while
(
1
)
{
pRemovedIter
=
taosHashIterate
(
pHash
,
pRemovedIter
);
pRemovedIter
=
taosHashIterate
(
pHash
,
pRemovedIter
);
...
@@ -355,20 +349,14 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -355,20 +349,14 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
pIter
=
taosHashIterate
(
pOutput
->
pSub
->
consumerHash
,
pIter
);
pIter
=
taosHashIterate
(
pOutput
->
pSub
->
consumerHash
,
pIter
);
ASSERT
(
pIter
);
ASSERT
(
pIter
);
pRebVg
=
(
SMqRebOutputVg
*
)
pRemovedIter
;
pRebVg
=
(
SMqRebOutputVg
*
)
pRemovedIter
;
SMqConsumerEpInSub
*
pEpInSub
=
(
SMqConsumerEpInSub
*
)
pIter
;
SMqConsumerEp
*
pConsumerEp
=
(
SMqConsumerEp
*
)
pIter
;
if
(
pEpInSub
->
consumerId
==
-
1
)
continue
;
ASSERT
(
pConsumerEp
->
consumerId
>
0
);
ASSERT
(
pEpInSub
->
consumerId
>
0
);
taosArrayPush
(
pConsumerEp
->
vgs
,
&
pRebVg
->
pVgEp
);
taosArrayPush
(
pEpInSub
->
vgs
,
&
pRebVg
->
pVgEp
);
pRebVg
->
newConsumerId
=
pConsumerEp
->
consumerId
;
pRebVg
->
newConsumerId
=
pEpInSub
->
consumerId
;
taosArrayPush
(
pOutput
->
rebVgs
,
pRebVg
);
taosArrayPush
(
pOutput
->
rebVgs
,
pRebVg
);
}
}
}
else
{
}
else
{
// if all consumer is removed, put all vg into unassigned
// if all consumer is removed, put all vg into unassigned
int64_t
unexistKey
=
-
1
;
SMqConsumerEpInSub
*
pEpInSub
=
taosHashGet
(
pOutput
->
pSub
->
consumerHash
,
&
unexistKey
,
sizeof
(
int64_t
));
ASSERT
(
pEpInSub
);
ASSERT
(
pEpInSub
->
consumerId
==
-
1
);
pIter
=
NULL
;
pIter
=
NULL
;
SMqRebOutputVg
*
pRebOutput
=
NULL
;
SMqRebOutputVg
*
pRebOutput
=
NULL
;
while
(
1
)
{
while
(
1
)
{
...
@@ -376,7 +364,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -376,7 +364,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
pRebOutput
=
(
SMqRebOutputVg
*
)
pIter
;
pRebOutput
=
(
SMqRebOutputVg
*
)
pIter
;
ASSERT
(
pRebOutput
->
newConsumerId
==
-
1
);
ASSERT
(
pRebOutput
->
newConsumerId
==
-
1
);
taosArrayPush
(
p
EpInSub
->
v
gs
,
&
pRebOutput
->
pVgEp
);
taosArrayPush
(
p
Output
->
pSub
->
unassignedV
gs
,
&
pRebOutput
->
pVgEp
);
taosArrayPush
(
pOutput
->
rebVgs
,
pRebOutput
);
taosArrayPush
(
pOutput
->
rebVgs
,
pRebOutput
);
}
}
}
}
...
@@ -512,6 +500,7 @@ static int32_t mndProcessRebalanceReq(SNodeMsg *pMsg) {
...
@@ -512,6 +500,7 @@ static int32_t mndProcessRebalanceReq(SNodeMsg *pMsg) {
// possibly no vg is changed
// possibly no vg is changed
/*ASSERT(taosArrayGetSize(rebOutput.rebVgs) != 0);*/
/*ASSERT(taosArrayGetSize(rebOutput.rebVgs) != 0);*/
// TODO replace assert with error check
ASSERT
(
mndPersistRebResult
(
pMnode
,
pMsg
,
&
rebOutput
)
==
0
);
ASSERT
(
mndPersistRebResult
(
pMnode
,
pMsg
,
&
rebOutput
)
==
0
);
if
(
rebInput
.
pTopic
)
{
if
(
rebInput
.
pTopic
)
{
...
@@ -631,6 +620,10 @@ static int32_t mndSubActionUpdate(SSdb *pSdb, SMqSubscribeObj *pOldSub, SMqSubsc
...
@@ -631,6 +620,10 @@ static int32_t mndSubActionUpdate(SSdb *pSdb, SMqSubscribeObj *pOldSub, SMqSubsc
pOldSub
->
consumerHash
=
pNewSub
->
consumerHash
;
pOldSub
->
consumerHash
=
pNewSub
->
consumerHash
;
pNewSub
->
consumerHash
=
tmp
;
pNewSub
->
consumerHash
=
tmp
;
SArray
*
tmp1
=
pOldSub
->
unassignedVgs
;
pOldSub
->
unassignedVgs
=
pNewSub
->
unassignedVgs
;
pNewSub
->
unassignedVgs
=
tmp1
;
taosWUnLockLatch
(
&
pOldSub
->
lock
);
taosWUnLockLatch
(
&
pOldSub
->
lock
);
return
0
;
return
0
;
}
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
316772ec
...
@@ -389,21 +389,25 @@ void nodesDestroyNode(SNodeptr pNode) {
...
@@ -389,21 +389,25 @@ void nodesDestroyNode(SNodeptr pNode) {
case
QUERY_NODE_COLUMN_DEF
:
// no pointer field
case
QUERY_NODE_COLUMN_DEF
:
// no pointer field
case
QUERY_NODE_DOWNSTREAM_SOURCE
:
// no pointer field
case
QUERY_NODE_DOWNSTREAM_SOURCE
:
// no pointer field
break
;
break
;
case
QUERY_NODE_DATABASE_OPTIONS
:
case
QUERY_NODE_DATABASE_OPTIONS
:
{
nodesDestroyList
(((
SDatabaseOptions
*
)
pNode
)
->
pRetentions
);
SDatabaseOptions
*
pOptions
=
(
SDatabaseOptions
*
)
pNode
;
nodesDestroyNode
(
pOptions
->
pDaysPerFile
);
nodesDestroyList
(
pOptions
->
pKeep
);
nodesDestroyList
(
pOptions
->
pRetentions
);
break
;
break
;
}
case
QUERY_NODE_TABLE_OPTIONS
:
{
case
QUERY_NODE_TABLE_OPTIONS
:
{
STableOptions
*
p
Stmt
=
(
STableOptions
*
)
pNode
;
STableOptions
*
p
Options
=
(
STableOptions
*
)
pNode
;
nodesDestroyList
(
p
Stmt
->
pSma
);
nodesDestroyList
(
p
Options
->
pSma
);
nodesDestroyList
(
p
Stmt
->
pFuncs
);
nodesDestroyList
(
p
Options
->
pRollu
pFuncs
);
break
;
break
;
}
}
case
QUERY_NODE_INDEX_OPTIONS
:
{
case
QUERY_NODE_INDEX_OPTIONS
:
{
SIndexOptions
*
p
Stmt
=
(
SIndexOptions
*
)
pNode
;
SIndexOptions
*
p
Options
=
(
SIndexOptions
*
)
pNode
;
nodesDestroyList
(
p
Stmt
->
pFuncs
);
nodesDestroyList
(
p
Options
->
pFuncs
);
nodesDestroyNode
(
p
Stmt
->
pInterval
);
nodesDestroyNode
(
p
Options
->
pInterval
);
nodesDestroyNode
(
p
Stmt
->
pOffset
);
nodesDestroyNode
(
p
Options
->
pOffset
);
nodesDestroyNode
(
p
Stmt
->
pSliding
);
nodesDestroyNode
(
p
Options
->
pSliding
);
break
;
break
;
}
}
case
QUERY_NODE_SET_OPERATOR
:
{
case
QUERY_NODE_SET_OPERATOR
:
{
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
316772ec
...
@@ -36,8 +36,7 @@ typedef struct SAstCreateContext {
...
@@ -36,8 +36,7 @@ typedef struct SAstCreateContext {
}
SAstCreateContext
;
}
SAstCreateContext
;
typedef
enum
EDatabaseOptionType
{
typedef
enum
EDatabaseOptionType
{
DB_OPTION_BLOCKS
=
1
,
DB_OPTION_BUFFER
=
1
,
DB_OPTION_CACHE
,
DB_OPTION_CACHELAST
,
DB_OPTION_CACHELAST
,
DB_OPTION_COMP
,
DB_OPTION_COMP
,
DB_OPTION_DAYS
,
DB_OPTION_DAYS
,
...
@@ -45,30 +44,29 @@ typedef enum EDatabaseOptionType {
...
@@ -45,30 +44,29 @@ typedef enum EDatabaseOptionType {
DB_OPTION_MAXROWS
,
DB_OPTION_MAXROWS
,
DB_OPTION_MINROWS
,
DB_OPTION_MINROWS
,
DB_OPTION_KEEP
,
DB_OPTION_KEEP
,
DB_OPTION_PAGES
,
DB_OPTION_PAGESIZE
,
DB_OPTION_PRECISION
,
DB_OPTION_PRECISION
,
DB_OPTION_QUORUM
,
DB_OPTION_REPLICA
,
DB_OPTION_REPLICA
,
DB_OPTION_
TTL
,
DB_OPTION_
STRICT
,
DB_OPTION_WAL
,
DB_OPTION_WAL
,
DB_OPTION_VGROUPS
,
DB_OPTION_VGROUPS
,
DB_OPTION_SINGLE_STABLE
,
DB_OPTION_SINGLE_STABLE
,
DB_OPTION_STREAM_MODE
,
DB_OPTION_STRICT
,
DB_OPTION_RETENTIONS
DB_OPTION_RETENTIONS
}
EDatabaseOptionType
;
}
EDatabaseOptionType
;
typedef
enum
ETableOptionType
{
typedef
enum
ETableOptionType
{
TABLE_OPTION_KEEP
=
1
,
TABLE_OPTION_COMMENT
=
1
,
TABLE_OPTION_TTL
,
TABLE_OPTION_DELAY
,
TABLE_OPTION_COMMENT
,
TABLE_OPTION_SMA
,
TABLE_OPTION_FILE_FACTOR
,
TABLE_OPTION_FILE_FACTOR
,
TABLE_OPTION_DELAY
TABLE_OPTION_ROLLUP
,
TABLE_OPTION_TTL
,
TABLE_OPTION_SMA
}
ETableOptionType
;
}
ETableOptionType
;
typedef
struct
SAlterOption
{
typedef
struct
SAlterOption
{
int32_t
type
;
int32_t
type
;
S
ValueNode
*
pV
al
;
S
Token
v
al
;
SNodeList
*
pList
;
SNodeList
*
pList
;
}
SAlterOption
;
}
SAlterOption
;
...
@@ -121,25 +119,29 @@ SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit);
...
@@ -121,25 +119,29 @@ SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit);
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
);
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
);
SNode
*
createSetOperator
(
SAstCreateContext
*
pCxt
,
ESetOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
);
SNode
*
createSetOperator
(
SAstCreateContext
*
pCxt
,
ESetOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
);
SNode
*
createDatabaseOptions
(
SAstCreateContext
*
pCxt
);
SDataType
createDataType
(
uint8_t
type
);
SNode
*
setDatabaseAlterOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
);
SDataType
createVarLenDataType
(
uint8_t
type
,
const
SToken
*
pLen
);
SNode
*
createDefaultDatabaseOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createAlterDatabaseOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
setDatabaseOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
EDatabaseOptionType
type
,
void
*
pVal
);
SNode
*
setAlterDatabaseOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
);
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createDropDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pDbName
);
SNode
*
createDropDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pDbName
);
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createDefaultTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
setTableAlterOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
);
SNode
*
createAlterTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
setTableOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
ETableOptionType
type
,
void
*
pVal
);
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
);
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
);
SDataType
createDataType
(
uint8_t
type
);
SDataType
createVarLenDataType
(
uint8_t
type
,
const
SToken
*
pLen
);
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNodeList
*
pTags
,
SNode
*
pOptions
);
SNodeList
*
pTags
,
SNode
*
pOptions
);
SNode
*
createCreateSubTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNode
*
pUseRealTable
,
SNode
*
createCreateSubTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNode
*
pUseRealTable
,
SNodeList
*
pSpecificTags
,
SNodeList
*
pValsOfTags
);
SNodeList
*
pSpecificTags
,
SNodeList
*
pValsOfTags
,
SNode
*
pOptions
);
SNode
*
createCreateMultiTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pSubTables
);
SNode
*
createCreateMultiTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pSubTables
);
SNode
*
createDropTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
SNode
*
createDropTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
SNode
*
createDropTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pTables
);
SNode
*
createDropTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pTables
);
SNode
*
createDropSuperTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
SNode
*
createDropSuperTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
SNode
*
createAlterTable
Option
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
SNode
*
pOptions
);
SNode
*
createAlterTable
ModifyOptions
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
SNode
*
pOptions
);
SNode
*
createAlterTableAddModifyCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
SNode
*
createAlterTableAddModifyCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
const
SToken
*
pColName
,
SDataType
dataType
);
const
SToken
*
pColName
,
SDataType
dataType
);
SNode
*
createAlterTableDropCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
const
SToken
*
pColName
);
SNode
*
createAlterTableDropCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
const
SToken
*
pColName
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
316772ec
...
@@ -137,43 +137,41 @@ not_exists_opt(A) ::= .
...
@@ -137,43 +137,41 @@ not_exists_opt(A) ::= .
exists_opt(A) ::= IF EXISTS. { A = true; }
exists_opt(A) ::= IF EXISTS. { A = true; }
exists_opt(A) ::= . { A = false; }
exists_opt(A) ::= . { A = false; }
db_options(A) ::= . { A = createDatabaseOptions(pCxt); }
db_options(A) ::= . { A = createDefaultDatabaseOptions(pCxt); }
db_options(A) ::= db_options(B) BLOCKS NK_INTEGER(C). { ((SDatabaseOptions*)B)->pNumOfBlocks = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) BUFFER NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BUFFER, &C); }
db_options(A) ::= db_options(B) CACHE NK_INTEGER(C). { ((SDatabaseOptions*)B)->pCacheBlockSize = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) CACHELAST NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHELAST, &C); }
db_options(A) ::= db_options(B) CACHELAST NK_INTEGER(C). { ((SDatabaseOptions*)B)->pCachelast = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) COMP NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_COMP, &C); }
db_options(A) ::= db_options(B) COMP NK_INTEGER(C). { ((SDatabaseOptions*)B)->pCompressionLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) DAYS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); }
db_options(A) ::= db_options(B) DAYS NK_INTEGER(C). { ((SDatabaseOptions*)B)->pDaysPerFile = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) DAYS NK_VARIABLE(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); }
db_options(A) ::= db_options(B) DAYS NK_VARIABLE(C). { ((SDatabaseOptions*)B)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, &C); A = B; }
db_options(A) ::= db_options(B) FSYNC NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_FSYNC, &C); }
db_options(A) ::= db_options(B) FSYNC NK_INTEGER(C). { ((SDatabaseOptions*)B)->pFsyncPeriod = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) MAXROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MAXROWS, &C); }
db_options(A) ::= db_options(B) MAXROWS NK_INTEGER(C). { ((SDatabaseOptions*)B)->pMaxRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) MINROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MINROWS, &C); }
db_options(A) ::= db_options(B) MINROWS NK_INTEGER(C). { ((SDatabaseOptions*)B)->pMinRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) KEEP integer_list(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP, C); }
db_options(A) ::= db_options(B) KEEP integer_list(C). { ((SDatabaseOptions*)B)->pKeep = C; A = B; }
db_options(A) ::= db_options(B) KEEP variable_list(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP, C); }
db_options(A) ::= db_options(B) KEEP variable_list(C). { ((SDatabaseOptions*)B)->pKeep = C; A = B; }
db_options(A) ::= db_options(B) PAGES NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_PAGES, &C); }
db_options(A) ::= db_options(B) PRECISION NK_STRING(C). { ((SDatabaseOptions*)B)->pPrecision = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &C); A = B; }
db_options(A) ::= db_options(B) PAGESIZE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_PAGESIZE, &C); }
db_options(A) ::= db_options(B) QUORUM NK_INTEGER(C). { ((SDatabaseOptions*)B)->pQuorum = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) PRECISION NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_PRECISION, &C); }
db_options(A) ::= db_options(B) REPLICA NK_INTEGER(C). { ((SDatabaseOptions*)B)->pReplica = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) REPLICA NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_REPLICA, &C); }
db_options(A) ::= db_options(B) TTL NK_INTEGER(C). { ((SDatabaseOptions*)B)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) STRICT NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STRICT, &C); }
db_options(A) ::= db_options(B) WAL NK_INTEGER(C). { ((SDatabaseOptions*)B)->pWalLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) WAL NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL, &C); }
db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C). { ((SDatabaseOptions*)B)->pNumOfVgroups = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_VGROUPS, &C); }
db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). { ((SDatabaseOptions*)B)->pSingleStable = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLE_STABLE, &C); }
db_options(A) ::= db_options(B) STREAM_MODE NK_INTEGER(C). { ((SDatabaseOptions*)B)->pStreamMode = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
db_options(A) ::= db_options(B) RETENTIONS retention_list(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_RETENTIONS, C); }
db_options(A) ::= db_options(B) RETENTIONS retention_list(C). { ((SDatabaseOptions*)B)->pRetentions = C; A = B; }
db_options(A) ::= db_options(B) STRICT NK_INTEGER(C). { ((SDatabaseOptions*)B)->pStrict = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); }
alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); }
alter_db_options(A) ::= alter_db_option(B). { A = createDatabaseOptions(pCxt); A = setDatabaseAlterOption(pCxt, A, &B); }
alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setDatabaseAlterOption(pCxt, B, &C); }
%type alter_db_option { SAlterOption }
%type alter_db_option { SAlterOption }
%destructor alter_db_option { }
%destructor alter_db_option { }
alter_db_option(A) ::= BLOCKS NK_INTEGER(B). { A.type = DB_OPTION_BLOCKS; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
alter_db_option(A) ::= BUFFER NK_INTEGER(B). { A.type = DB_OPTION_BUFFER; A.val = B; }
alter_db_option(A) ::= FSYNC NK_INTEGER(B). { A.type = DB_OPTION_FSYNC; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
alter_db_option(A) ::= CACHELAST NK_INTEGER(B). { A.type = DB_OPTION_CACHELAST; A.val = B; }
alter_db_option(A) ::= FSYNC NK_INTEGER(B). { A.type = DB_OPTION_FSYNC; A.val = B; }
alter_db_option(A) ::= KEEP integer_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
alter_db_option(A) ::= KEEP integer_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
alter_db_option(A) ::= KEEP variable_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
alter_db_option(A) ::= KEEP variable_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
alter_db_option(A) ::= WAL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
alter_db_option(A) ::= PAGES NK_INTEGER(B). { A.type = DB_OPTION_PAGES; A.val = B; }
alter_db_option(A) ::= QUORUM NK_INTEGER(B). { A.type = DB_OPTION_QUORUM; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; }
alter_db_option(A) ::= CACHELAST NK_INTEGER(B). { A.type = DB_OPTION_CACHELAST; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
alter_db_option(A) ::= STRICT NK_INTEGER(B). { A.type = DB_OPTION_STRICT; A.val = B; }
alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
alter_db_option(A) ::= WAL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
alter_db_option(A) ::= STRICT NK_INTEGER(B). { A.type = DB_OPTION_STRICT; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
%type integer_list { SNodeList* }
%type integer_list { SNodeList* }
%destructor integer_list { nodesDestroyList($$); }
%destructor integer_list { nodesDestroyList($$); }
...
@@ -204,7 +202,7 @@ cmd ::= DROP STABLE exists_opt(A) full_table_name(B).
...
@@ -204,7 +202,7 @@ cmd ::= DROP STABLE exists_opt(A) full_table_name(B).
cmd ::= ALTER TABLE alter_table_clause(A). { pCxt->pRootNode = A; }
cmd ::= ALTER TABLE alter_table_clause(A). { pCxt->pRootNode = A; }
cmd ::= ALTER STABLE alter_table_clause(A). { pCxt->pRootNode = A; }
cmd ::= ALTER STABLE alter_table_clause(A). { pCxt->pRootNode = A; }
alter_table_clause(A) ::= full_table_name(B) alter_table_options(C). { A = createAlterTable
Option
(pCxt, B, C); }
alter_table_clause(A) ::= full_table_name(B) alter_table_options(C). { A = createAlterTable
ModifyOptions
(pCxt, B, C); }
alter_table_clause(A) ::=
alter_table_clause(A) ::=
full_table_name(B) ADD COLUMN column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D); }
full_table_name(B) ADD COLUMN column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D); }
alter_table_clause(A) ::= full_table_name(B) DROP COLUMN column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_DROP_COLUMN, &C); }
alter_table_clause(A) ::= full_table_name(B) DROP COLUMN column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_DROP_COLUMN, &C); }
...
@@ -229,7 +227,7 @@ multi_create_clause(A) ::= multi_create_clause(B) create_subtable_clause(C).
...
@@ -229,7 +227,7 @@ multi_create_clause(A) ::= multi_create_clause(B) create_subtable_clause(C).
create_subtable_clause(A) ::=
create_subtable_clause(A) ::=
not_exists_opt(B) full_table_name(C) USING full_table_name(D)
not_exists_opt(B) full_table_name(C) USING full_table_name(D)
specific_tags_opt(E) TAGS NK_LP literal_list(F) NK_RP
. { A = createCreateSubTableClause(pCxt, B, C, D, E, F
); }
specific_tags_opt(E) TAGS NK_LP literal_list(F) NK_RP
table_options(G). { A = createCreateSubTableClause(pCxt, B, C, D, E, F, G
); }
%type multi_drop_clause { SNodeList* }
%type multi_drop_clause { SNodeList* }
%destructor multi_drop_clause { nodesDestroyList($$); }
%destructor multi_drop_clause { nodesDestroyList($$); }
...
@@ -289,25 +287,21 @@ tags_def_opt(A) ::= tags_def(B).
...
@@ -289,25 +287,21 @@ tags_def_opt(A) ::= tags_def(B).
%destructor tags_def { nodesDestroyList($$); }
%destructor tags_def { nodesDestroyList($$); }
tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. { A = B; }
tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. { A = B; }
table_options(A) ::= . { A = createTableOptions(pCxt); }
table_options(A) ::= . { A = createDefaultTableOptions(pCxt); }
table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { ((STableOptions*)B)->pComments = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &C); A = B; }
table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
table_options(A) ::= table_options(B) KEEP integer_list(C). { ((STableOptions*)B)->pKeep = C; A = B; }
table_options(A) ::= table_options(B) DELAY NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_DELAY, &C); }
table_options(A) ::= table_options(B) KEEP variable_list(C). { ((STableOptions*)B)->pKeep = C; A = B; }
table_options(A) ::= table_options(B) FILE_FACTOR NK_FLOAT(C). { A = setTableOption(pCxt, B, TABLE_OPTION_FILE_FACTOR, &C); }
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { ((STableOptions*)B)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
table_options(A) ::= table_options(B) ROLLUP NK_LP func_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_ROLLUP, C); }
table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { ((STableOptions*)B)->pSma = C; A = B; }
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
table_options(A) ::= table_options(B) ROLLUP NK_LP func_name_list(C) NK_RP. { ((STableOptions*)B)->pFuncs = C; A = B; }
table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_SMA, C); }
table_options(A) ::= table_options(B) FILE_FACTOR NK_FLOAT(C). { ((STableOptions*)B)->pFilesFactor = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &C); A = B; }
table_options(A) ::= table_options(B) DELAY NK_INTEGER(C). { ((STableOptions*)B)->pDelay = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
alter_table_options(A) ::= alter_table_option(B). { A = create
TableOptions(pCxt); A = setTableAlterOption(pCxt, A, &B
); }
alter_table_options(A) ::= alter_table_option(B). { A = create
AlterTableOptions(pCxt); A = setTableOption(pCxt, A, B.type, &B.val
); }
alter_table_options(A) ::= alter_table_options(B) alter_table_option(C). { A = setTable
AlterOption(pCxt, B, &C
); }
alter_table_options(A) ::= alter_table_options(B) alter_table_option(C). { A = setTable
Option(pCxt, B, C.type, &C.val
); }
%type alter_table_option { SAlterOption }
%type alter_table_option { SAlterOption }
%destructor alter_table_option { }
%destructor alter_table_option { }
alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.val = B; }
alter_table_option(A) ::= KEEP integer_list(B). { A.type = TABLE_OPTION_KEEP; A.pList = B; }
alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.val = B; }
alter_table_option(A) ::= KEEP variable_list(B). { A.type = TABLE_OPTION_KEEP; A.pList = B; }
alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
%type col_name_list { SNodeList* }
%type col_name_list { SNodeList* }
%destructor col_name_list { nodesDestroyList($$); }
%destructor col_name_list { nodesDestroyList($$); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
316772ec
...
@@ -47,6 +47,12 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
...
@@ -47,6 +47,12 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
pCxt
->
placeholderNo
=
1
;
pCxt
->
placeholderNo
=
1
;
}
}
static
void
copyStringFormStringToken
(
SToken
*
pToken
,
char
*
pBuf
,
int32_t
len
)
{
if
(
pToken
->
n
>
2
)
{
strncpy
(
pBuf
,
pToken
->
z
+
1
,
TMIN
(
pToken
->
n
-
2
,
len
-
1
));
}
}
static
void
trimEscape
(
SToken
*
pName
)
{
static
void
trimEscape
(
SToken
*
pName
)
{
// todo need to deal with `ioo``ii` -> ioo`ii
// todo need to deal with `ioo``ii` -> ioo`ii
if
(
NULL
!=
pName
&&
pName
->
n
>
1
&&
'`'
==
pName
->
z
[
0
])
{
if
(
NULL
!=
pName
&&
pName
->
n
>
1
&&
'`'
==
pName
->
z
[
0
])
{
...
@@ -604,64 +610,113 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode*
...
@@ -604,64 +610,113 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode*
return
(
SNode
*
)
setOp
;
return
(
SNode
*
)
setOp
;
}
}
SNode
*
createDatabaseOptions
(
SAstCreateContext
*
pCxt
)
{
SNode
*
createD
efaultD
atabaseOptions
(
SAstCreateContext
*
pCxt
)
{
SDatabaseOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_DATABASE_OPTIONS
);
SDatabaseOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_DATABASE_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
buffer
=
TSDB_DEFAULT_BUFFER_PER_VNODE
;
pOptions
->
cachelast
=
TSDB_DEFAULT_CACHE_LAST_ROW
;
pOptions
->
compressionLevel
=
TSDB_DEFAULT_COMP_LEVEL
;
pOptions
->
daysPerFile
=
TSDB_DEFAULT_DAYS_PER_FILE
;
pOptions
->
fsyncPeriod
=
TSDB_DEFAULT_FSYNC_PERIOD
;
pOptions
->
maxRowsPerBlock
=
TSDB_DEFAULT_MAXROWS_FBLOCK
;
pOptions
->
minRowsPerBlock
=
TSDB_DEFAULT_MINROWS_FBLOCK
;
pOptions
->
keep
[
0
]
=
TSDB_DEFAULT_KEEP
;
pOptions
->
keep
[
1
]
=
TSDB_DEFAULT_KEEP
;
pOptions
->
keep
[
2
]
=
TSDB_DEFAULT_KEEP
;
pOptions
->
pages
=
TSDB_DEFAULT_PAGES_PER_VNODE
;
pOptions
->
pagesize
=
TSDB_DEFAULT_PAGESIZE_PER_VNODE
;
pOptions
->
precision
=
TSDB_DEFAULT_PRECISION
;
pOptions
->
replica
=
TSDB_DEFAULT_DB_REPLICA
;
pOptions
->
strict
=
TSDB_DEFAULT_DB_STRICT
;
pOptions
->
walLevel
=
TSDB_DEFAULT_WAL_LEVEL
;
pOptions
->
numOfVgroups
=
TSDB_DEFAULT_VN_PER_DB
;
pOptions
->
singleStable
=
TSDB_DEFAULT_DB_SINGLE_STABLE
;
return
(
SNode
*
)
pOptions
;
return
(
SNode
*
)
pOptions
;
}
}
SNode
*
setDatabaseAlterOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
)
{
SNode
*
createAlterDatabaseOptions
(
SAstCreateContext
*
pCxt
)
{
switch
(
pAlterOption
->
type
)
{
SDatabaseOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_DATABASE_OPTIONS
);
case
DB_OPTION_BLOCKS
:
CHECK_OUT_OF_MEM
(
pOptions
);
((
SDatabaseOptions
*
)
pOptions
)
->
pNumOfBlocks
=
pAlterOption
->
pVal
;
pOptions
->
buffer
=
-
1
;
break
;
pOptions
->
cachelast
=
-
1
;
case
DB_OPTION_CACHE
:
pOptions
->
compressionLevel
=
-
1
;
((
SDatabaseOptions
*
)
pOptions
)
->
pCacheBlockSize
=
pAlterOption
->
pVal
;
pOptions
->
daysPerFile
=
-
1
;
pOptions
->
fsyncPeriod
=
-
1
;
pOptions
->
maxRowsPerBlock
=
-
1
;
pOptions
->
minRowsPerBlock
=
-
1
;
pOptions
->
keep
[
0
]
=
-
1
;
pOptions
->
keep
[
1
]
=
-
1
;
pOptions
->
keep
[
2
]
=
-
1
;
pOptions
->
pages
=
-
1
;
pOptions
->
pagesize
=
-
1
;
pOptions
->
precision
=
-
1
;
pOptions
->
replica
=
-
1
;
pOptions
->
strict
=
-
1
;
pOptions
->
walLevel
=
-
1
;
pOptions
->
numOfVgroups
=
-
1
;
pOptions
->
singleStable
=
-
1
;
return
(
SNode
*
)
pOptions
;
}
SNode
*
setDatabaseOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
EDatabaseOptionType
type
,
void
*
pVal
)
{
switch
(
type
)
{
case
DB_OPTION_BUFFER
:
((
SDatabaseOptions
*
)
pOptions
)
->
buffer
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
break
;
break
;
case
DB_OPTION_CACHELAST
:
case
DB_OPTION_CACHELAST
:
((
SDatabaseOptions
*
)
pOptions
)
->
pCachelast
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
cachelast
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
break
;
case
DB_OPTION_COMP
:
case
DB_OPTION_COMP
:
((
SDatabaseOptions
*
)
pOptions
)
->
pCompressionLevel
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
compressionLevel
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
break
;
case
DB_OPTION_DAYS
:
case
DB_OPTION_DAYS
:
{
((
SDatabaseOptions
*
)
pOptions
)
->
pDaysPerFile
=
pAlterOption
->
pVal
;
SToken
*
pToken
=
pVal
;
if
(
TK_NK_INTEGER
==
pToken
->
type
)
{
((
SDatabaseOptions
*
)
pOptions
)
->
daysPerFile
=
strtol
(
pToken
->
z
,
NULL
,
10
);
}
else
{
((
SDatabaseOptions
*
)
pOptions
)
->
pDaysPerFile
=
(
SValueNode
*
)
createDurationValueNode
(
pCxt
,
pToken
);
}
break
;
break
;
}
case
DB_OPTION_FSYNC
:
case
DB_OPTION_FSYNC
:
((
SDatabaseOptions
*
)
pOptions
)
->
pFsyncPeriod
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
fsyncPeriod
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
break
;
case
DB_OPTION_MAXROWS
:
case
DB_OPTION_MAXROWS
:
((
SDatabaseOptions
*
)
pOptions
)
->
pMaxRowsPerBlock
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
maxRowsPerBlock
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
break
;
case
DB_OPTION_MINROWS
:
case
DB_OPTION_MINROWS
:
((
SDatabaseOptions
*
)
pOptions
)
->
pMinRowsPerBlock
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
minRowsPerBlock
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
break
;
case
DB_OPTION_KEEP
:
case
DB_OPTION_KEEP
:
((
SDatabaseOptions
*
)
pOptions
)
->
pKeep
=
pAlterOption
->
pList
;
((
SDatabaseOptions
*
)
pOptions
)
->
pKeep
=
pVal
;
break
;
case
DB_OPTION_PAGES
:
((
SDatabaseOptions
*
)
pOptions
)
->
pages
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
break
;
case
DB_OPTION_PAGESIZE
:
((
SDatabaseOptions
*
)
pOptions
)
->
pagesize
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
break
;
break
;
case
DB_OPTION_PRECISION
:
case
DB_OPTION_PRECISION
:
((
SDatabaseOptions
*
)
pOptions
)
->
pPrecision
=
pAlterOption
->
pVal
;
copyStringFormStringToken
((
SToken
*
)
pVal
,
((
SDatabaseOptions
*
)
pOptions
)
->
precisionStr
,
sizeof
(((
SDatabaseOptions
*
)
pOptions
)
->
precisionStr
));
break
;
break
;
case
DB_OPTION_REPLICA
:
case
DB_OPTION_REPLICA
:
((
SDatabaseOptions
*
)
pOptions
)
->
pReplica
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
replica
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
break
;
case
DB_OPTION_
TTL
:
case
DB_OPTION_
STRICT
:
((
SDatabaseOptions
*
)
pOptions
)
->
pTtl
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
strict
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
break
;
case
DB_OPTION_WAL
:
case
DB_OPTION_WAL
:
((
SDatabaseOptions
*
)
pOptions
)
->
pWalLevel
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
walLevel
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
break
;
case
DB_OPTION_VGROUPS
:
case
DB_OPTION_VGROUPS
:
((
SDatabaseOptions
*
)
pOptions
)
->
pNumOfVgroups
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
numOfVgroups
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
break
;
case
DB_OPTION_SINGLE_STABLE
:
case
DB_OPTION_SINGLE_STABLE
:
((
SDatabaseOptions
*
)
pOptions
)
->
pSingleStable
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
singleStable
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
break
;
case
DB_OPTION_STREAM_MODE
:
((
SDatabaseOptions
*
)
pOptions
)
->
pStreamMode
=
pAlterOption
->
pVal
;
break
;
break
;
case
DB_OPTION_RETENTIONS
:
case
DB_OPTION_RETENTIONS
:
((
SDatabaseOptions
*
)
pOptions
)
->
pRetentions
=
p
AlterOption
->
pList
;
((
SDatabaseOptions
*
)
pOptions
)
->
pRetentions
=
p
Val
;
break
;
break
;
default:
default:
break
;
break
;
...
@@ -669,6 +724,17 @@ SNode* setDatabaseAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOp
...
@@ -669,6 +724,17 @@ SNode* setDatabaseAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOp
return
pOptions
;
return
pOptions
;
}
}
SNode
*
setAlterDatabaseOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
)
{
switch
(
pAlterOption
->
type
)
{
case
DB_OPTION_KEEP
:
case
DB_OPTION_RETENTIONS
:
return
setDatabaseOption
(
pCxt
,
pOptions
,
pAlterOption
->
type
,
pAlterOption
->
pList
);
default:
break
;
}
return
setDatabaseOption
(
pCxt
,
pOptions
,
pAlterOption
->
type
,
&
pAlterOption
->
val
);
}
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pDbName
,
SNode
*
pOptions
)
{
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pDbName
,
SNode
*
pOptions
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
))
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
))
{
return
NULL
;
return
NULL
;
...
@@ -703,31 +769,44 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode*
...
@@ -703,31 +769,44 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode*
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
SNode
*
createTableOptions
(
SAstCreateContext
*
pCxt
)
{
SNode
*
create
Default
TableOptions
(
SAstCreateContext
*
pCxt
)
{
STableOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_TABLE_OPTIONS
);
STableOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_TABLE_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
delay
=
TSDB_DEFAULT_ROLLUP_DELAY
;
pOptions
->
filesFactor
=
TSDB_DEFAULT_ROLLUP_FILE_FACTOR
;
pOptions
->
ttl
=
TSDB_DEFAULT_TABLE_TTL
;
return
(
SNode
*
)
pOptions
;
return
(
SNode
*
)
pOptions
;
}
}
SNode
*
setTableAlterOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
)
{
SNode
*
createAlterTableOptions
(
SAstCreateContext
*
pCxt
)
{
switch
(
pAlterOption
->
type
)
{
STableOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_TABLE_OPTIONS
);
case
TABLE_OPTION_KEEP
:
CHECK_OUT_OF_MEM
(
pOptions
);
((
STableOptions
*
)
pOptions
)
->
pKeep
=
pAlterOption
->
pList
;
pOptions
->
delay
=
-
1
;
break
;
pOptions
->
filesFactor
=
-
1
;
case
TABLE_OPTION_TTL
:
pOptions
->
ttl
=
-
1
;
((
STableOptions
*
)
pOptions
)
->
pTtl
=
pAlterOption
->
pVal
;
return
(
SNode
*
)
pOptions
;
break
;
}
SNode
*
setTableOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
ETableOptionType
type
,
void
*
pVal
)
{
switch
(
type
)
{
case
TABLE_OPTION_COMMENT
:
case
TABLE_OPTION_COMMENT
:
((
STableOptions
*
)
pOptions
)
->
pComments
=
pAlterOption
->
pVal
;
copyStringFormStringToken
((
SToken
*
)
pVal
,
((
STableOptions
*
)
pOptions
)
->
comment
,
sizeof
(((
STableOptions
*
)
pOptions
)
->
comment
));
break
;
break
;
case
TABLE_OPTION_
SMA
:
case
TABLE_OPTION_
DELAY
:
((
STableOptions
*
)
pOptions
)
->
pSma
=
pAlterOption
->
pList
;
((
STableOptions
*
)
pOptions
)
->
delay
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
break
;
case
TABLE_OPTION_FILE_FACTOR
:
case
TABLE_OPTION_FILE_FACTOR
:
((
STableOptions
*
)
pOptions
)
->
pFilesFactor
=
pAlterOption
->
pVal
;
((
STableOptions
*
)
pOptions
)
->
filesFactor
=
strtod
(((
SToken
*
)
pVal
)
->
z
,
NULL
)
;
break
;
break
;
case
TABLE_OPTION_DELAY
:
case
TABLE_OPTION_ROLLUP
:
((
STableOptions
*
)
pOptions
)
->
pDelay
=
pAlterOption
->
pVal
;
((
STableOptions
*
)
pOptions
)
->
pRollupFuncs
=
pVal
;
break
;
case
TABLE_OPTION_TTL
:
((
STableOptions
*
)
pOptions
)
->
ttl
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
break
;
case
TABLE_OPTION_SMA
:
((
STableOptions
*
)
pOptions
)
->
pSma
=
pVal
;
break
;
break
;
default:
default:
break
;
break
;
...
@@ -778,7 +857,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode*
...
@@ -778,7 +857,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode*
}
}
SNode
*
createCreateSubTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNode
*
pUseRealTable
,
SNode
*
createCreateSubTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNode
*
pUseRealTable
,
SNodeList
*
pSpecificTags
,
SNodeList
*
pValsOfTags
)
{
SNodeList
*
pSpecificTags
,
SNodeList
*
pValsOfTags
,
SNode
*
pOptions
)
{
if
(
NULL
==
pRealTable
)
{
if
(
NULL
==
pRealTable
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -833,7 +912,7 @@ SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, S
...
@@ -833,7 +912,7 @@ SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, S
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
SNode
*
createAlterTable
Option
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
SNode
*
pOptions
)
{
SNode
*
createAlterTable
ModifyOptions
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
SNode
*
pOptions
)
{
if
(
NULL
==
pRealTable
)
{
if
(
NULL
==
pRealTable
)
{
return
NULL
;
return
NULL
;
}
}
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
316772ec
...
@@ -43,7 +43,7 @@ static SKeyword keywordTable[] = {
...
@@ -43,7 +43,7 @@ static SKeyword keywordTable[] = {
{
"BETWEEN"
,
TK_BETWEEN
},
{
"BETWEEN"
,
TK_BETWEEN
},
{
"BINARY"
,
TK_BINARY
},
{
"BINARY"
,
TK_BINARY
},
{
"BIGINT"
,
TK_BIGINT
},
{
"BIGINT"
,
TK_BIGINT
},
{
"BLOCKS"
,
TK_BLOCKS
},
//
{"BLOCKS", TK_BLOCKS},
{
"BNODE"
,
TK_BNODE
},
{
"BNODE"
,
TK_BNODE
},
{
"BNODES"
,
TK_BNODES
},
{
"BNODES"
,
TK_BNODES
},
{
"BOOL"
,
TK_BOOL
},
{
"BOOL"
,
TK_BOOL
},
...
@@ -142,7 +142,7 @@ static SKeyword keywordTable[] = {
...
@@ -142,7 +142,7 @@ static SKeyword keywordTable[] = {
{
"QTIME"
,
TK_QTIME
},
{
"QTIME"
,
TK_QTIME
},
{
"QUERIES"
,
TK_QUERIES
},
{
"QUERIES"
,
TK_QUERIES
},
{
"QUERY"
,
TK_QUERY
},
{
"QUERY"
,
TK_QUERY
},
{
"QUORUM"
,
TK_QUORUM
},
//
{"QUORUM", TK_QUORUM},
{
"RATIO"
,
TK_RATIO
},
{
"RATIO"
,
TK_RATIO
},
{
"REPLICA"
,
TK_REPLICA
},
{
"REPLICA"
,
TK_REPLICA
},
{
"RESET"
,
TK_RESET
},
{
"RESET"
,
TK_RESET
},
...
@@ -169,7 +169,7 @@ static SKeyword keywordTable[] = {
...
@@ -169,7 +169,7 @@ static SKeyword keywordTable[] = {
{
"STORAGE"
,
TK_STORAGE
},
{
"STORAGE"
,
TK_STORAGE
},
{
"STREAM"
,
TK_STREAM
},
{
"STREAM"
,
TK_STREAM
},
{
"STREAMS"
,
TK_STREAMS
},
{
"STREAMS"
,
TK_STREAMS
},
{
"STREAM_MODE"
,
TK_STREAM_MODE
},
//
{"STREAM_MODE", TK_STREAM_MODE},
{
"STRICT"
,
TK_STRICT
},
{
"STRICT"
,
TK_STRICT
},
{
"SYNCDB"
,
TK_SYNCDB
},
{
"SYNCDB"
,
TK_SYNCDB
},
{
"TABLE"
,
TK_TABLE
},
{
"TABLE"
,
TK_TABLE
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
316772ec
此差异已折叠。
点击以展开。
source/libs/parser/src/parUtil.c
浏览文件 @
316772ec
...
@@ -68,8 +68,6 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -68,8 +68,6 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"Invalid option %s: %s"
;
return
"Invalid option %s: %s"
;
case
TSDB_CODE_PAR_INVALID_ENUM_OPTION
:
case
TSDB_CODE_PAR_INVALID_ENUM_OPTION
:
return
"Invalid option %s: %"
PRId64
", only %d, %d allowed"
;
return
"Invalid option %s: %"
PRId64
", only %d, %d allowed"
;
case
TSDB_CODE_PAR_INVALID_TTL_OPTION
:
return
"Invalid option ttl: %"
PRId64
", should be greater than or equal to %d"
;
case
TSDB_CODE_PAR_INVALID_KEEP_NUM
:
case
TSDB_CODE_PAR_INVALID_KEEP_NUM
:
return
"Invalid number of keep options"
;
return
"Invalid number of keep options"
;
case
TSDB_CODE_PAR_INVALID_KEEP_ORDER
:
case
TSDB_CODE_PAR_INVALID_KEEP_ORDER
:
...
@@ -89,7 +87,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -89,7 +87,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
case
TSDB_CODE_PAR_INVALID_OPTION_UNIT
:
case
TSDB_CODE_PAR_INVALID_OPTION_UNIT
:
return
"Invalid option %s unit: %c, only m, h, d allowed"
;
return
"Invalid option %s unit: %c, only m, h, d allowed"
;
case
TSDB_CODE_PAR_INVALID_KEEP_UNIT
:
case
TSDB_CODE_PAR_INVALID_KEEP_UNIT
:
return
"Invalid option keep unit: %c,
%c, %c,
only m, h, d allowed"
;
return
"Invalid option keep unit: %c, only m, h, d allowed"
;
case
TSDB_CODE_PAR_AGG_FUNC_NESTING
:
case
TSDB_CODE_PAR_AGG_FUNC_NESTING
:
return
"Aggregate functions do not support nesting"
;
return
"Aggregate functions do not support nesting"
;
case
TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE
:
case
TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE
:
...
...
source/libs/parser/src/sql.c
浏览文件 @
316772ec
此差异已折叠。
点击以展开。
source/libs/parser/test/par
serTestUtil.h
→
source/libs/parser/test/par
AlterTest.cpp
浏览文件 @
316772ec
...
@@ -13,9 +13,14 @@
...
@@ -13,9 +13,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef PARSER_TEST_UTIL_H
#include "parTestUtil.h"
#define PARSER_TEST_UTIL_H
extern
bool
g_isDump
;
using
namespace
std
;
#endif // PARSER_TEST_UTIL_H
class
ParserAlterTest
:
public
ParserTestBase
{};
TEST_F
(
ParserAlterTest
,
stmt
)
{
useDb
(
"root"
,
"test"
);
run
(
"create database db1"
);
}
source/libs/parser/test/par
ser
InsertTest.cpp
→
source/libs/parser/test/parInsertTest.cpp
浏览文件 @
316772ec
文件已移动
source/libs/parser/test/par
ser
TestMain.cpp
→
source/libs/parser/test/parTestMain.cpp
浏览文件 @
316772ec
...
@@ -13,23 +13,22 @@
...
@@ -13,23 +13,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <getopt.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string>
#include <string>
#include <getopt.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#ifdef WINDOWS
#ifdef WINDOWS
#define TD_USE_WINSOCK
#define TD_USE_WINSOCK
#endif
#endif
#include "functionMgt.h"
#include "functionMgt.h"
#include "mockCatalog.h"
#include "mockCatalog.h"
#include "os.h"
#include "os.h"
#include "parTestUtil.h"
#include "parToken.h"
#include "parToken.h"
#include "parserTestUtil.h"
bool
g_isDump
=
false
;
class
ParserEnv
:
public
testing
::
Environment
{
class
ParserEnv
:
public
testing
::
Environment
{
public:
public:
...
...
source/libs/parser/test/parTestUtil.cpp
0 → 100644
浏览文件 @
316772ec
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "parTestUtil.h"
#include <algorithm>
#include <array>
#include "parInt.h"
using
namespace
std
;
using
namespace
testing
;
#define DO_WITH_THROW(func, ...) \
do { \
int32_t code__ = func(__VA_ARGS__); \
if (TSDB_CODE_SUCCESS != code__) { \
throw runtime_error("sql:[" + stmtEnv_.sql_ + "] " #func " code:" + to_string(code__) + \
", strerror:" + string(tstrerror(code__)) + ", msg:" + string(stmtEnv_.msgBuf_.data())); \
} \
} while (0);
bool
g_isDump
=
false
;
class
ParserTestBaseImpl
{
public:
void
useDb
(
const
string
&
acctId
,
const
string
&
db
)
{
caseEnv_
.
acctId_
=
acctId
;
caseEnv_
.
db_
=
db
;
}
void
run
(
const
string
&
sql
)
{
reset
();
try
{
SParseContext
cxt
=
{
0
};
setParseContext
(
sql
,
&
cxt
);
SQuery
*
pQuery
=
nullptr
;
doParse
(
&
cxt
,
&
pQuery
);
doTranslate
(
&
cxt
,
pQuery
);
doCalculateConstant
(
&
cxt
,
pQuery
);
if
(
g_isDump
)
{
dump
();
}
}
catch
(...)
{
dump
();
throw
;
}
}
private:
struct
caseEnv
{
string
acctId_
;
string
db_
;
};
struct
stmtEnv
{
string
sql_
;
array
<
char
,
1024
>
msgBuf_
;
};
struct
stmtRes
{
string
parsedAst_
;
string
translatedAst_
;
string
calcConstAst_
;
};
void
reset
()
{
stmtEnv_
.
sql_
.
clear
();
stmtEnv_
.
msgBuf_
.
fill
(
0
);
res_
.
parsedAst_
.
clear
();
res_
.
translatedAst_
.
clear
();
res_
.
calcConstAst_
.
clear
();
}
void
dump
()
{
cout
<<
"==========================================sql : ["
<<
stmtEnv_
.
sql_
<<
"]"
<<
endl
;
cout
<<
"raw syntax tree : "
<<
endl
;
cout
<<
res_
.
parsedAst_
<<
endl
;
cout
<<
"translated syntax tree : "
<<
endl
;
cout
<<
res_
.
translatedAst_
<<
endl
;
cout
<<
"optimized syntax tree : "
<<
endl
;
cout
<<
res_
.
calcConstAst_
<<
endl
;
}
void
setParseContext
(
const
string
&
sql
,
SParseContext
*
pCxt
)
{
stmtEnv_
.
sql_
=
sql
;
transform
(
stmtEnv_
.
sql_
.
begin
(),
stmtEnv_
.
sql_
.
end
(),
stmtEnv_
.
sql_
.
begin
(),
::
tolower
);
pCxt
->
acctId
=
atoi
(
caseEnv_
.
acctId_
.
c_str
());
pCxt
->
db
=
caseEnv_
.
db_
.
c_str
();
pCxt
->
pSql
=
stmtEnv_
.
sql_
.
c_str
();
pCxt
->
sqlLen
=
stmtEnv_
.
sql_
.
length
();
pCxt
->
pMsg
=
stmtEnv_
.
msgBuf_
.
data
();
pCxt
->
msgLen
=
stmtEnv_
.
msgBuf_
.
max_size
();
}
void
doParse
(
SParseContext
*
pCxt
,
SQuery
**
pQuery
)
{
DO_WITH_THROW
(
parse
,
pCxt
,
pQuery
);
res_
.
parsedAst_
=
toString
((
*
pQuery
)
->
pRoot
);
}
void
doTranslate
(
SParseContext
*
pCxt
,
SQuery
*
pQuery
)
{
DO_WITH_THROW
(
translate
,
pCxt
,
pQuery
);
res_
.
translatedAst_
=
toString
(
pQuery
->
pRoot
);
}
void
doCalculateConstant
(
SParseContext
*
pCxt
,
SQuery
*
pQuery
)
{
DO_WITH_THROW
(
calculateConstant
,
pCxt
,
pQuery
);
res_
.
calcConstAst_
=
toString
(
pQuery
->
pRoot
);
}
string
toString
(
const
SNode
*
pRoot
)
{
char
*
pStr
=
NULL
;
int32_t
len
=
0
;
DO_WITH_THROW
(
nodesNodeToString
,
pRoot
,
false
,
&
pStr
,
&
len
)
string
str
(
pStr
);
taosMemoryFreeClear
(
pStr
);
return
str
;
}
caseEnv
caseEnv_
;
stmtEnv
stmtEnv_
;
stmtRes
res_
;
};
ParserTestBase
::
ParserTestBase
()
:
impl_
(
new
ParserTestBaseImpl
())
{}
ParserTestBase
::~
ParserTestBase
()
{}
void
ParserTestBase
::
useDb
(
const
std
::
string
&
acctId
,
const
std
::
string
&
db
)
{
impl_
->
useDb
(
acctId
,
db
);
}
void
ParserTestBase
::
run
(
const
std
::
string
&
sql
)
{
return
impl_
->
run
(
sql
);
}
source/libs/parser/test/parTestUtil.h
0 → 100644
浏览文件 @
316772ec
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PARSER_TEST_UTIL_H
#define PARSER_TEST_UTIL_H
#include <gtest/gtest.h>
class
ParserTestBaseImpl
;
class
ParserTestBase
:
public
testing
::
Test
{
public:
ParserTestBase
();
virtual
~
ParserTestBase
();
void
useDb
(
const
std
::
string
&
acctId
,
const
std
::
string
&
db
);
void
run
(
const
std
::
string
&
sql
);
private:
std
::
unique_ptr
<
ParserTestBaseImpl
>
impl_
;
};
extern
bool
g_isDump
;
#endif // PARSER_TEST_UTIL_H
source/libs/parser/test/parserAstTest.cpp
浏览文件 @
316772ec
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include "parInt.h"
#include "parInt.h"
#include "par
ser
TestUtil.h"
#include "parTestUtil.h"
using
namespace
std
;
using
namespace
std
;
using
namespace
testing
;
using
namespace
testing
;
...
...
source/libs/planner/test/planTestUtil.cpp
浏览文件 @
316772ec
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
*/
*/
#include "planTestUtil.h"
#include "planTestUtil.h"
#include <array>
#include <algorithm>
#include <algorithm>
#include <array>
#include "cmdnodes.h"
#include "cmdnodes.h"
#include "parser.h"
#include "parser.h"
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
316772ec
...
@@ -1058,36 +1058,36 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
...
@@ -1058,36 +1058,36 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
// check for the 0 value
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
if
(
colDataIsNull_s
(
pLeft
->
columnData
,
i
)
||
colDataIsNull_s
(
pRight
->
columnData
,
i
)
)
{
if
(
colDataIsNull_s
(
pLeft
->
columnData
,
i
)
||
colDataIsNull_s
(
pRight
->
columnData
,
i
)
||
(
getVectorDoubleValueFnRight
(
RIGHT_COL
,
i
)
==
0
))
{
//divide by 0 check
colDataAppendNULL
(
pOutputCol
,
i
);
colDataAppendNULL
(
pOutputCol
,
i
);
continue
;
// TODO set null or ignore
continue
;
}
}
*
output
=
getVectorDoubleValueFnLeft
(
LEFT_COL
,
i
)
*
output
=
getVectorDoubleValueFnLeft
(
LEFT_COL
,
i
)
/
getVectorDoubleValueFnRight
(
RIGHT_COL
,
i
);
/
getVectorDoubleValueFnRight
(
RIGHT_COL
,
i
);
}
}
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
if
(
colDataIsNull_s
(
pLeftCol
,
0
))
{
// Set pLeft->numOfRows NULL value
if
(
colDataIsNull_s
(
pLeftCol
,
0
))
{
// Set pLeft->numOfRows NULL value
colDataAppendNNULL
(
pOutputCol
,
0
,
pRight
->
numOfRows
);
colDataAppendNNULL
(
pOutputCol
,
0
,
pRight
->
numOfRows
);
}
else
{
}
else
{
for
(;
i
>=
0
&&
i
<
pRight
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
if
(
colDataIsNull_s
(
pRightCol
,
i
)
)
{
if
(
colDataIsNull_s
(
pRightCol
,
i
)
||
(
getVectorDoubleValueFnRight
(
RIGHT_COL
,
i
)
==
0
))
{
// divide by 0 check
colDataAppendNULL
(
pOutputCol
,
i
);
colDataAppendNULL
(
pOutputCol
,
i
);
continue
;
// TODO set null or ignore
continue
;
}
}
*
output
=
getVectorDoubleValueFnLeft
(
LEFT_COL
,
0
)
*
output
=
getVectorDoubleValueFnLeft
(
LEFT_COL
,
0
)
/
getVectorDoubleValueFnRight
(
RIGHT_COL
,
i
);
/
getVectorDoubleValueFnRight
(
RIGHT_COL
,
i
);
}
}
}
}
}
else
if
(
pRight
->
numOfRows
==
1
)
{
}
else
if
(
pRight
->
numOfRows
==
1
)
{
if
(
colDataIsNull_s
(
pRightCol
,
0
)
)
{
// Set pLeft->numOfRows NULL value
if
(
colDataIsNull_s
(
pRightCol
,
0
)
||
(
getVectorDoubleValueFnRight
(
RIGHT_COL
,
0
)
==
0
))
{
// Set pLeft->numOfRows NULL value (divde by 0 check)
colDataAppendNNULL
(
pOutputCol
,
0
,
pLeft
->
numOfRows
);
colDataAppendNNULL
(
pOutputCol
,
0
,
pLeft
->
numOfRows
);
}
else
{
}
else
{
for
(;
i
>=
0
&&
i
<
pLeft
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
if
(
colDataIsNull_s
(
pLeftCol
,
i
))
{
if
(
colDataIsNull_s
(
pLeftCol
,
i
))
{
colDataAppendNULL
(
pOutputCol
,
i
);
colDataAppendNULL
(
pOutputCol
,
i
);
continue
;
// TODO set null or ignore
continue
;
}
}
*
output
=
getVectorDoubleValueFnLeft
(
LEFT_COL
,
i
)
*
output
=
getVectorDoubleValueFnLeft
(
LEFT_COL
,
i
)
/
getVectorDoubleValueFnRight
(
RIGHT_COL
,
0
);
/
getVectorDoubleValueFnRight
(
RIGHT_COL
,
0
);
...
@@ -1195,9 +1195,10 @@ void vectorMathMinus(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pO
...
@@ -1195,9 +1195,10 @@ void vectorMathMinus(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pO
for
(;
i
<
pLeft
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pLeft
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
if
(
colDataIsNull_s
(
pLeft
->
columnData
,
i
))
{
if
(
colDataIsNull_s
(
pLeft
->
columnData
,
i
))
{
colDataAppendNULL
(
pOutputCol
,
i
);
colDataAppendNULL
(
pOutputCol
,
i
);
continue
;
// TODO set null or ignore
continue
;
}
}
*
output
=
-
getVectorDoubleValueFnLeft
(
LEFT_COL
,
i
);
double
result
=
getVectorDoubleValueFnLeft
(
LEFT_COL
,
i
);
*
output
=
(
result
==
0
)
?
0
:
-
result
;
}
}
doReleaseVec
(
pLeftCol
,
leftConvert
);
doReleaseVec
(
pLeftCol
,
leftConvert
);
...
...
tests/pytest/util/sql.py
浏览文件 @
316772ec
...
@@ -16,6 +16,7 @@ import os
...
@@ -16,6 +16,7 @@ import os
import
time
import
time
import
datetime
import
datetime
import
inspect
import
inspect
import
traceback
import
psutil
import
psutil
import
shutil
import
shutil
import
pandas
as
pd
import
pandas
as
pd
...
@@ -88,6 +89,7 @@ class TDSql:
...
@@ -88,6 +89,7 @@ class TDSql:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
sql
,
repr
(
e
))
args
=
(
caller
.
filename
,
caller
.
lineno
,
sql
,
repr
(
e
))
tdLog
.
notice
(
"%s(%d) failed: sql:%s, %s"
%
args
)
tdLog
.
notice
(
"%s(%d) failed: sql:%s, %s"
%
args
)
traceback
.
print_exc
()
raise
Exception
(
repr
(
e
))
raise
Exception
(
repr
(
e
))
if
row_tag
:
if
row_tag
:
return
self
.
queryResult
return
self
.
queryResult
...
...
tests/script/tsim/db/alter_option.sim
浏览文件 @
316772ec
...
@@ -66,7 +66,7 @@ print ============= create database
...
@@ -66,7 +66,7 @@ print ============= create database
# | REPLICA value [1 | 3]
# | REPLICA value [1 | 3]
# | WAL value [1 | 2]
# | WAL value [1 | 2]
sql create database db
BLOCKS 7 CACHE 3 CACHELAST 3 COMP 0 DAYS 345600 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1440000 PRECISION 'ns' REPLICA 1 TTL 7 WAL 2 VGROUPS 6 SINGLE_STABLE 1 STREAM_MOD
E 1
sql create database db
CACHELAST 3 COMP 0 DAYS 345600 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1440000 PRECISION 'ns' REPLICA 1 WAL 2 VGROUPS 6 SINGLE_STABL
E 1
sql show databases
sql show databases
print rows: $rows
print rows: $rows
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
...
@@ -98,12 +98,12 @@ endi
...
@@ -98,12 +98,12 @@ endi
if $data7_db != 1440000,1440000,1440000 then # keep
if $data7_db != 1440000,1440000,1440000 then # keep
return -1
return -1
endi
endi
if $data8_db != 3 then # cache
#
if $data8_db != 3 then # cache
return -1
#
return -1
endi
#
endi
if $data9_db != 7 then # blocks
#
if $data9_db != 7 then # blocks
return -1
#
return -1
endi
#
endi
if $data10_db != 10 then # minrows
if $data10_db != 10 then # minrows
return -1
return -1
endi
endi
...
@@ -250,41 +250,41 @@ sql_error alter database db keep 0
...
@@ -250,41 +250,41 @@ sql_error alter database db keep 0
sql_error alter database db keep -1
sql_error alter database db keep -1
#sql_error alter database db keep 365001
#sql_error alter database db keep 365001
print ============== modify cache
#
print ============== modify cache
sql_error alter database db cache 12
#
sql_error alter database db cache 12
sql_error alter database db cache 1
#
sql_error alter database db cache 1
sql_error alter database db cache 60
#
sql_error alter database db cache 60
sql_error alter database db cache 50
#
sql_error alter database db cache 50
sql_error alter database db cache 20
#
sql_error alter database db cache 20
sql_error alter database db cache 3
#
sql_error alter database db cache 3
sql_error alter database db cache 129
#
sql_error alter database db cache 129
sql_error alter database db cache 300
#
sql_error alter database db cache 300
sql_error alter database db cache 0
#
sql_error alter database db cache 0
sql_error alter database db cache -1
#
sql_error alter database db cache -1
print ============== modify blocks
#
print ============== modify blocks
sql alter database db blocks 3
#
sql alter database db blocks 3
sql show databases
#
sql show databases
print blocks $data9_db
#
print blocks $data9_db
if $data9_db != 3 then
#
if $data9_db != 3 then
return -1
#
return -1
endi
#
endi
sql alter database db blocks 11
#
sql alter database db blocks 11
sql show databases
#
sql show databases
print blocks $data9_db
#
print blocks $data9_db
if $data9_db != 11 then
#
if $data9_db != 11 then
return -1
#
return -1
endi
#
endi
sql alter database db blocks 40
#
sql alter database db blocks 40
sql alter database db blocks 30
#
sql alter database db blocks 30
sql alter database db blocks 20
#
sql alter database db blocks 20
sql alter database db blocks 10
#
sql alter database db blocks 10
sql_error alter database db blocks 2
#
sql_error alter database db blocks 2
sql_error alter database db blocks 1
#
sql_error alter database db blocks 1
sql_error alter database db blocks 0
#
sql_error alter database db blocks 0
sql_error alter database db blocks -1
#
sql_error alter database db blocks -1
sql_error alter database db blocks 10001
#
sql_error alter database db blocks 10001
print ============== modify minrows
print ============== modify minrows
sql_error alter database db minrows 8
sql_error alter database db minrows 8
...
...
tests/script/tsim/db/basic6.sim
浏览文件 @
316772ec
...
@@ -15,7 +15,8 @@ $tb = $tbPrefix . $i
...
@@ -15,7 +15,8 @@ $tb = $tbPrefix . $i
print =============== step1
print =============== step1
# quorum presicion
# quorum presicion
sql create database $db vgroups 8 replica 1 days 2880 keep 3650 cache 32 blocks 12 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us'
#sql create database $db vgroups 8 replica 1 days 2880 keep 3650 cache 32 blocks 12 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us'
sql create database $db vgroups 8 replica 1 days 2880 keep 3650 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us'
sql show databases
sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
...
@@ -40,12 +41,12 @@ endi
...
@@ -40,12 +41,12 @@ endi
if $data27 != 3650,3650,3650 then
if $data27 != 3650,3650,3650 then
return -1
return -1
endi
endi
if $data28 != 32 then
#
if $data28 != 32 then
return -1
#
return -1
endi
#
endi
if $data29 != 12 then
#
if $data29 != 12 then
return -1
#
return -1
endi
#
endi
print =============== step2
print =============== step2
sql_error create database $db
sql_error create database $db
...
...
tests/script/tsim/db/create_all_options.sim
浏览文件 @
316772ec
...
@@ -124,12 +124,12 @@ endi
...
@@ -124,12 +124,12 @@ endi
if $data7_db != 5256000,5256000,5256000 then # keep
if $data7_db != 5256000,5256000,5256000 then # keep
return -1
return -1
endi
endi
if $data8_db != 16 then # cache
#
if $data8_db != 16 then # cache
return -1
#
return -1
endi
#
endi
if $data9_db != 6 then # blocks
#
if $data9_db != 6 then # blocks
return -1
#
return -1
endi
#
endi
if $data10_db != 100 then # minrows
if $data10_db != 100 then # minrows
return -1
return -1
endi
endi
...
@@ -153,42 +153,42 @@ if $data16_db != ms then # precision
...
@@ -153,42 +153,42 @@ if $data16_db != ms then # precision
endi
endi
sql drop database db
sql drop database db
print ====> BLOCKS value [3~1000, default: 6]
#
print ====> BLOCKS value [3~1000, default: 6]
sql create database db BLOCKS 3
#
sql create database db BLOCKS 3
sql show databases
#
sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data9_db != 3 then
#
if $data9_db != 3 then
return -1
#
return -1
endi
#
endi
sql drop database db
#
sql drop database db
sql create database db BLOCKS 1000
#
sql create database db BLOCKS 1000
sql show databases
#
sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data9_db != 1000 then
#
if $data9_db != 1000 then
return -1
#
return -1
endi
#
endi
sql drop database db
#
sql drop database db
sql_error create database db BLOCKS 2
#
sql_error create database db BLOCKS 2
sql_error create database db BLOCKS 0
#
sql_error create database db BLOCKS 0
sql_error create database db BLOCKS -1
#
sql_error create database db BLOCKS -1
print ====> CACHE value [default: 16]
#
print ====> CACHE value [default: 16]
sql create database db CACHE 1
#
sql create database db CACHE 1
sql show databases
#
sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data8_db != 1 then
#
if $data8_db != 1 then
return -1
#
return -1
endi
#
endi
sql drop database db
#
sql drop database db
sql create database db CACHE 128
#
sql create database db CACHE 128
sql show databases
#
sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data8_db != 128 then
#
if $data8_db != 128 then
return -1
#
return -1
endi
#
endi
sql drop database db
#
sql drop database db
print ====> CACHELAST value [0, 1, 2, 3, default: 0]
print ====> CACHELAST value [0, 1, 2, 3, default: 0]
sql create database db CACHELAST 1
sql create database db CACHELAST 1
...
@@ -387,24 +387,24 @@ sql_error create database db REPLICA 0
...
@@ -387,24 +387,24 @@ sql_error create database db REPLICA 0
sql_error create database db REPLICA -1
sql_error create database db REPLICA -1
sql_error create database db REPLICA 4
sql_error create database db REPLICA 4
print ====> TTL value [1d ~ , default: 1]
#
print ====> TTL value [1d ~ , default: 1]
sql create database db TTL 1
#
sql create database db TTL 1
sql show databases
#
sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#if $dataXX_db != 1 then
#if $dataXX_db != 1 then
# return -1
# return -1
#endi
#endi
sql drop database db
#
sql drop database db
sql create database db TTL 10
#
sql create database db TTL 10
sql show databases
#
sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#if $dataXX_db != 10 then
#if $dataXX_db != 10 then
# return -1
# return -1
#endi
#endi
sql drop database db
#
sql drop database db
sql_error create database db TTL 0
#
sql_error create database db TTL 0
sql_error create database db TTL -1
#
sql_error create database db TTL -1
print ====> WAL value [1 | 2, default: 1]
print ====> WAL value [1 | 2, default: 1]
sql create database db WAL 2
sql create database db WAL 2
...
@@ -465,24 +465,24 @@ sql drop database db
...
@@ -465,24 +465,24 @@ sql drop database db
sql_error create database db SINGLE_STABLE 2
sql_error create database db SINGLE_STABLE 2
sql_error create database db SINGLE_STABLE -1
sql_error create database db SINGLE_STABLE -1
print ====> STREAM_MODE [0 | 1, default: ]
#
print ====> STREAM_MODE [0 | 1, default: ]
sql create database db STREAM_MODE 1
#
sql create database db STREAM_MODE 1
sql show databases
#
sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#if $dataXXX_db != 1 then
#if $dataXXX_db != 1 then
# return -1
# return -1
#endi
#endi
sql drop database db
#
sql drop database db
sql create database db STREAM_MODE 0
#
sql create database db STREAM_MODE 0
sql show databases
#
sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#if $dataXXX_db != 0 then
#if $dataXXX_db != 0 then
# return -1
# return -1
#endi
#endi
sql drop database db
#
sql drop database db
sql_error create database db STREAM_MODE 2
#
sql_error create database db STREAM_MODE 2
sql_error create database db STREAM_MODE -1
#
sql_error create database db STREAM_MODE -1
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
...
...
tests/script/tsim/parser/fourArithmetic-basic.sim
浏览文件 @
316772ec
...
@@ -94,7 +94,7 @@ endi
...
@@ -94,7 +94,7 @@ endi
if $data01 != 10.000000000 then
if $data01 != 10.000000000 then
return -1
return -1
endi
endi
if $data02 !=
-nan
then
if $data02 !=
NULL
then
return -1
return -1
endi
endi
if $data03 != -10.000000000 then
if $data03 != -10.000000000 then
...
...
tests/system-test/2-query/Now.py
浏览文件 @
316772ec
from
util.dnodes
import
*
from
util.dnodes
import
*
from
util.log
import
*
from
util.log
import
*
from
util.sql
import
*
from
util.sql
import
*
...
@@ -111,21 +110,72 @@ class TDTestCase:
...
@@ -111,21 +110,72 @@ class TDTestCase:
tdSql
.
query
(
"select * from ntb where ts<now()"
)
tdSql
.
query
(
"select * from ntb where ts<now()"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
1
,
1
,
3
)
tdSql
.
checkData
(
1
,
1
,
3
)
tdSql
.
query
(
"select * from db.ntb where ts<now()"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
1
,
1
,
3
)
tdSql
.
query
(
"select * from ntb where ts<=now()"
)
tdSql
.
query
(
"select * from ntb where ts<=now()"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
2
,
1
,
1
)
tdSql
.
checkData
(
2
,
1
,
1
)
tdSql
.
query
(
"select * from db.ntb where ts<=now()"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
2
,
1
,
1
)
tdSql
.
query
(
"select c1 from ntb where ts=now()"
)
tdSql
.
query
(
"select c1 from ntb where ts=now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select c1 from db.ntb where ts=now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from ntb where ts>=now()"
)
tdSql
.
query
(
"select * from ntb where ts>=now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from db.ntb where ts>=now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from ntb where ts>now()"
)
tdSql
.
query
(
"select * from ntb where ts>now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from db.ntb where ts>now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select now() from ntb where ts=today()"
)
tdSql
.
query
(
"select now() from ntb where ts=today()"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select now() from db.ntb where ts=today()"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select now()+1 from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select now()+1 from db.ntb"
)
tdSql
.
checkRows
(
3
)
# tdSql.query("select now()+9223372036854775807 from ntb")
# tdSql.checkRows(3)
tdSql
.
error
(
"select now()+1.5 from ntb"
)
tdSql
.
error
(
"select now()+1.5 from db.ntb"
)
tdSql
.
error
(
"select now()+'abc' from ntb"
)
tdSql
.
error
(
"select now()+'abc' from db.ntb"
)
tdSql
.
error
(
"select now()+abc from ntb"
)
tdSql
.
error
(
"select now()+abc from db.ntb"
)
tdSql
.
error
(
"select now()+! from ntb"
)
tdSql
.
error
(
"select now()+! from db.ntb"
)
tdSql
.
query
(
"select now()+null from ntb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()+null from db.ntb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()-null from ntb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()-null from db.ntb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()*null from ntb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()*null from db.ntb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()/null from ntb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()/null from db.ntb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
error
(
"select now() +today() from ntb"
)
tdSql
.
error
(
"select now() +today() from db.ntb"
)
# stable
# stable
tdSql
.
query
(
"select now() from stb"
)
tdSql
.
query
(
"select now() from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select now() from db.stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select now() +1w from stb"
)
tdSql
.
query
(
"select now() +1w from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select now() +1w from db.stb"
)
tdSql
.
query
(
"select now() +1w from db.stb"
)
...
@@ -198,16 +248,52 @@ class TDTestCase:
...
@@ -198,16 +248,52 @@ class TDTestCase:
# tdSql.checkData(2,1,1)
# tdSql.checkData(2,1,1)
tdSql
.
query
(
"select c1 from stb where ts=now()"
)
tdSql
.
query
(
"select c1 from stb where ts=now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select c1 from db.stb where ts=now()"
)
tdSql
.
checkRows
(
0
)
# tdSql.query("select * from stb where ts>=now()")
# tdSql.query("select * from stb where ts>=now()")
# tdSql.checkRows(0)
# tdSql.checkRows(0)
# tdSql.query("select * from stb where ts>now()")
# tdSql.query("select * from stb where ts>now()")
# tdSql.checkRows(0)
# tdSql.checkRows(0)
tdSql
.
query
(
"select now() from stb where ts=today()"
)
tdSql
.
query
(
"select now() from stb where ts=today()"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select now() from db.stb where ts=today()"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select now() +1 from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select now() +1 from db.stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
error
(
"select now() +'abc' from stb"
)
tdSql
.
error
(
"select now() +'abc' from db.stb"
)
tdSql
.
error
(
"select now() + ! from stb"
)
tdSql
.
error
(
"select now() + ! from db.stb"
)
tdSql
.
error
(
"select now() + today() from stb"
)
tdSql
.
error
(
"select now() + today() from db.stb"
)
tdSql
.
error
(
"select now() -today() from stb"
)
tdSql
.
error
(
"select now() - today() from db.stb"
)
tdSql
.
query
(
"select now()+null from stb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()+null from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()-null from stb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()-null from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()*null from stb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()*null from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()/null from stb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()/null from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
None
)
# table
# table
tdSql
.
query
(
"select now() from stb_1"
)
tdSql
.
query
(
"select now() from stb_1"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select now() from db.stb_1"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select now() +1w from stb_1"
)
tdSql
.
query
(
"select now() +1w from stb_1"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select now() +1w from db.stb_1"
)
tdSql
.
query
(
"select now() +1w from db.stb_1"
)
...
@@ -275,15 +361,27 @@ class TDTestCase:
...
@@ -275,15 +361,27 @@ class TDTestCase:
tdSql
.
query
(
"select * from stb_1 where ts<now()"
)
tdSql
.
query
(
"select * from stb_1 where ts<now()"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
1
,
1
,
3
)
tdSql
.
checkData
(
1
,
1
,
3
)
tdSql
.
query
(
"select * from db.stb_1 where ts<now()"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
1
,
1
,
3
)
tdSql
.
query
(
"select * from stb_1 where ts<=now()"
)
tdSql
.
query
(
"select * from stb_1 where ts<=now()"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
2
,
1
,
1
)
tdSql
.
checkData
(
2
,
1
,
1
)
tdSql
.
query
(
"select * from db.stb_1 where ts<=now()"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
2
,
1
,
1
)
tdSql
.
query
(
"select c1 from stb_1 where ts=now()"
)
tdSql
.
query
(
"select c1 from stb_1 where ts=now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select c1 from db.stb_1 where ts=now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from stb_1 where ts>=now()"
)
tdSql
.
query
(
"select * from stb_1 where ts>=now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from db.stb_1 where ts>=now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from stb_1 where ts>now()"
)
tdSql
.
query
(
"select * from stb_1 where ts>now()"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from db.stb_1 where ts>now()"
)
tdSql
.
checkRows
(
0
)
# tdSql.query("select * from stb_1 where ts<now")
# tdSql.query("select * from stb_1 where ts<now")
# tdSql.checkRows(3)
# tdSql.checkRows(3)
...
@@ -301,6 +399,31 @@ class TDTestCase:
...
@@ -301,6 +399,31 @@ class TDTestCase:
tdSql
.
query
(
"select now() from stb_1 where ts=today()"
)
tdSql
.
query
(
"select now() from stb_1 where ts=today()"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select now() +'abc' from stb_1"
)
tdSql
.
error
(
"select now() +'abc' from db.stb_1"
)
tdSql
.
error
(
"select now() + ! from stb_1"
)
tdSql
.
error
(
"select now() + ! from db.stb_1"
)
tdSql
.
error
(
"select now() + today() from stb_1"
)
tdSql
.
error
(
"select now() + today() from db.stb_1"
)
tdSql
.
error
(
"select now() - today() from stb_1"
)
tdSql
.
error
(
"select now()-today() from db.stb_1"
)
tdSql
.
query
(
"select now()+null from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()+null from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()-null from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()-null from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()*null from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()*null from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()/null from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select now()/null from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
None
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
...
...
tests/system-test/2-query/To_iso8061.py
浏览文件 @
316772ec
...
@@ -67,6 +67,75 @@ class TDTestCase:
...
@@ -67,6 +67,75 @@ class TDTestCase:
tdSql
.
error
(
"select to_iso8601(timezone()) from ntb"
)
tdSql
.
error
(
"select to_iso8601(timezone()) from ntb"
)
tdSql
.
error
(
"select to_iso8601('abc') from ntb"
)
tdSql
.
error
(
"select to_iso8601('abc') from ntb"
)
tdSql
.
query
(
"select to_iso8601(today()) *null from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) +null from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) -null from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) /null from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) *null from db.ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) +null from db.ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) -null from db.ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) /null from db.ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(now) from stb"
)
tdSql
.
query
(
"select to_iso8601(now()) from stb"
)
tdSql
.
checkRows
(
3
)
for
i
in
range
(
1
,
10
):
tdSql
.
query
(
"select to_iso8601(1) from stb"
)
tdSql
.
checkData
(
0
,
0
,
"1970-01-01T08:00:01+0800"
)
i
+=
1
sleep
(
0.2
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select to_iso8601(ts) from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select to_iso8601(ts)+1 from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select to_iso8601(ts)+'a' from stb "
)
tdSql
.
checkRows
(
3
)
# tdSql.query()
tdSql
.
query
(
"select to_iso8601(today()) *null from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) +null from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) -null from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) /null from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) *null from db.stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) +null from db.stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) -null from db.stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_iso8601(today()) /null from db.stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
...
...
tests/system-test/2-query/timezone.py
浏览文件 @
316772ec
...
@@ -45,20 +45,15 @@ class TDTestCase:
...
@@ -45,20 +45,15 @@ class TDTestCase:
tdSql
.
query
(
"select timezone() from ntb"
)
tdSql
.
query
(
"select timezone() from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
query
(
"select timezone() from db.ntb"
)
tdSql
.
query
(
"select timezone() from db.ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
query
(
"select timezone() from stb"
)
tdSql
.
query
(
"select timezone() from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
query
(
"select timezone() from db.stb"
)
tdSql
.
query
(
"select timezone() from db.stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
query
(
"select timezone() from stb_1"
)
tdSql
.
query
(
"select timezone() from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
...
@@ -66,14 +61,78 @@ class TDTestCase:
...
@@ -66,14 +61,78 @@ class TDTestCase:
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
checkData
(
0
,
0
,
time_zone
)
tdSql
.
error
(
"select timezone(1) from stb"
)
tdSql
.
error
(
"select timezone(1) from db.stb"
)
tdSql
.
error
(
"select timezone(1) from ntb"
)
tdSql
.
error
(
"select timezone(1) from ntb"
)
tdSql
.
error
(
"select timezone(1) from db.ntb"
)
tdSql
.
error
(
"select timezone(1) from stb_1"
)
tdSql
.
error
(
"select timezone(1) from db.stb_1"
)
tdSql
.
error
(
"select timezone(now()) from stb"
)
tdSql
.
error
(
"select timezone(now()) from stb"
)
tdSql
.
error
(
"select timezone(now()) from db.stb"
)
tdSql
.
query
(
f
"select * from ntb where timezone()='
{
time_zone
}
'"
)
tdSql
.
query
(
f
"select * from ntb where timezone()='
{
time_zone
}
'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from ntb"
)
tdSql
.
query
(
"select timezone()+1 from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from db.ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from db.stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1 from db.stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1.5 from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()+1.5 from db.ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()-100 from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()*100 from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select timezone()/10 from ntb"
)
# tdSql.query("select timezone()/0 from ntb")
tdSql
.
query
(
"select timezone()+null from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()-null from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()*null from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()/null from ntb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
# tdSql.query("select timezone()")
tdSql
.
query
(
"select timezone()+null from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()-null from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()*null from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()/null from stb"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()+null from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()-null from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()*null from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select timezone()/null from stb_1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
...
...
tools/shell/inc/shellInt.h
浏览文件 @
316772ec
...
@@ -62,7 +62,7 @@ typedef struct {
...
@@ -62,7 +62,7 @@ typedef struct {
bool
is_check
;
bool
is_check
;
bool
is_startup
;
bool
is_startup
;
bool
is_help
;
bool
is_help
;
uint16_t
port
;
int32_t
port
;
int32_t
pktLen
;
int32_t
pktLen
;
int32_t
pktNum
;
int32_t
pktNum
;
int32_t
displayWidth
;
int32_t
displayWidth
;
...
...
tools/shell/src/shellArguments.c
浏览文件 @
316772ec
...
@@ -99,6 +99,7 @@ static int32_t shellParseSingleOpt(int32_t key, char *arg) {
...
@@ -99,6 +99,7 @@ static int32_t shellParseSingleOpt(int32_t key, char *arg) {
break
;
break
;
case
'P'
:
case
'P'
:
pArgs
->
port
=
atoi
(
arg
);
pArgs
->
port
=
atoi
(
arg
);
if
(
pArgs
->
port
==
0
)
pArgs
->
port
=
-
1
;
break
;
break
;
case
'u'
:
case
'u'
:
pArgs
->
user
=
arg
;
pArgs
->
user
=
arg
;
...
@@ -304,6 +305,11 @@ static int32_t shellCheckArgs() {
...
@@ -304,6 +305,11 @@ static int32_t shellCheckArgs() {
return
-
1
;
return
-
1
;
}
}
if
(
pArgs
->
port
<
0
||
pArgs
->
port
>
65535
)
{
printf
(
"Invalid port
\n
"
);
return
-
1
;
}
if
(
pArgs
->
pktLen
<
SHELL_MIN_PKG_LEN
||
pArgs
->
pktLen
>
SHELL_MAX_PKG_LEN
)
{
if
(
pArgs
->
pktLen
<
SHELL_MIN_PKG_LEN
||
pArgs
->
pktLen
>
SHELL_MAX_PKG_LEN
)
{
printf
(
"Invalid pktLen:%d, range:[%d, %d]
\n
"
,
pArgs
->
pktLen
,
SHELL_MIN_PKG_LEN
,
SHELL_MAX_PKG_LEN
);
printf
(
"Invalid pktLen:%d, range:[%d, %d]
\n
"
,
pArgs
->
pktLen
,
SHELL_MIN_PKG_LEN
,
SHELL_MAX_PKG_LEN
);
return
-
1
;
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录