Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ccfcbba6
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
ccfcbba6
编写于
4月 28, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feature/vnode_refact1
上级
0eb7890d
a5aefd01
变更
51
展开全部
隐藏空白更改
内联
并排
Showing
51 changed file
with
3904 addition
and
3092 deletion
+3904
-3092
include/common/taosdef.h
include/common/taosdef.h
+2
-0
include/common/trow.h
include/common/trow.h
+6
-4
include/common/ttokendef.h
include/common/ttokendef.h
+237
-237
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+133
-136
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+1
-1
include/libs/parser/parser.h
include/libs/parser/parser.h
+1
-0
include/libs/planner/planner.h
include/libs/planner/planner.h
+2
-2
include/util/taoserror.h
include/util/taoserror.h
+0
-1
include/util/tdef.h
include/util/tdef.h
+74
-66
source/client/inc/clientStmt.h
source/client/inc/clientStmt.h
+17
-10
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+2
-1
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+40
-16
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+1
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+4
-2
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+4
-0
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+4
-4
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
+130
-46
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+1
-0
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+22
-5
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/src/planner.c
source/libs/planner/src/planner.c
+33
-19
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+1
-1
source/libs/scalar/inc/sclInt.h
source/libs/scalar/inc/sclInt.h
+1
-1
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+7
-2
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+7
-3
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+0
-5
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+11
-10
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+30
-0
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+30
-11
source/libs/transport/src/transComm.c
source/libs/transport/src/transComm.c
+81
-0
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+638
-197
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/0-others/taosShell.py
tests/system-test/0-others/taosShell.py
+19
-17
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
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/taosdef.h
浏览文件 @
ccfcbba6
...
...
@@ -82,6 +82,8 @@ extern char *qtypeStr[];
#define TSDB_PORT_HTTP 11
#undef TD_DEBUG_PRINT_ROW
#ifdef __cplusplus
}
#endif
...
...
include/common/trow.h
浏览文件 @
ccfcbba6
...
...
@@ -214,6 +214,7 @@ STSRow *tdRowDup(STSRow *row);
static
FORCE_INLINE
SKvRowIdx
*
tdKvRowColIdxAt
(
STSRow
*
pRow
,
col_id_t
idx
)
{
return
(
SKvRowIdx
*
)
TD_ROW_COL_IDX
(
pRow
)
+
idx
;
}
static
FORCE_INLINE
int16_t
tdKvRowColIdAt
(
STSRow
*
pRow
,
col_id_t
idx
)
{
ASSERT
(
idx
>=
0
);
if
(
idx
==
0
)
{
...
...
@@ -222,6 +223,7 @@ static FORCE_INLINE int16_t tdKvRowColIdAt(STSRow *pRow, col_id_t idx) {
return
((
SKvRowIdx
*
)
TD_ROW_COL_IDX
(
pRow
)
+
idx
-
1
)
->
colId
;
}
static
FORCE_INLINE
void
*
tdKVRowColVal
(
STSRow
*
pRow
,
SKvRowIdx
*
pIdx
)
{
return
POINTER_SHIFT
(
pRow
,
pIdx
->
offset
);
}
#define TD_ROW_OFFSET(p) ((p)->toffset); // During ParseInsert when without STSchema, how to get the offset for STpRow?
...
...
@@ -1117,7 +1119,7 @@ static FORCE_INLINE bool tdGetKvRowValOfColEx(STSRowIter *pIter, col_id_t colId,
}
if
(
!
colFound
)
{
if
(
colId
<=
pIter
->
maxColId
)
{
if
(
colId
<=
pIter
->
maxColId
)
{
pVal
->
valType
=
TD_VTYPE_NONE
;
return
true
;
}
else
{
...
...
@@ -1367,14 +1369,14 @@ static void tdSCellValPrint(SCellVal *pVal, int8_t colType) {
}
}
static
void
tdSRowPrint
(
STSRow
*
row
,
STSchema
*
pSchema
)
{
static
void
tdSRowPrint
(
STSRow
*
row
,
STSchema
*
pSchema
,
const
char
*
tag
)
{
STSRowIter
iter
=
{
0
};
tdSTSRowIterInit
(
&
iter
,
pSchema
);
tdSTSRowIterReset
(
&
iter
,
row
);
printf
(
"
>>>"
);
printf
(
"
%s >>>"
,
tag
);
for
(
int
i
=
0
;
i
<
pSchema
->
numOfCols
;
++
i
)
{
STColumn
*
stCol
=
pSchema
->
columns
+
i
;
SCellVal
sVal
=
{
255
,
NULL
};
SCellVal
sVal
=
{
.
valType
=
255
,
.
val
=
NULL
};
if
(
!
tdSTSRowIterNext
(
&
iter
,
stCol
->
colId
,
stCol
->
type
,
&
sVal
))
{
break
;
}
...
...
include/common/ttokendef.h
浏览文件 @
ccfcbba6
...
...
@@ -16,244 +16,244 @@
#ifndef _TD_COMMON_TOKEN_H_
#define _TD_COMMON_TOKEN_H_
#define TK_OR
1
#define TK_AND
2
#define TK_UNION
3
#define TK_ALL
4
#define TK_MINUS
5
#define TK_EXCEPT
6
#define TK_INTERSECT
7
#define TK_NK_BITAND
8
#define TK_NK_BITOR
9
#define TK_NK_LSHIFT
10
#define TK_NK_RSHIFT
11
#define TK_NK_PLUS
12
#define TK_NK_MINUS
13
#define TK_NK_STAR
14
#define TK_NK_SLASH
15
#define TK_NK_REM
16
#define TK_NK_CONCAT
17
#define TK_CREATE
18
#define TK_ACCOUNT
19
#define TK_NK_ID
20
#define TK_PASS
21
#define TK_NK_STRING
22
#define TK_ALTER
23
#define TK_PPS
24
#define TK_TSERIES
25
#define TK_STORAGE
26
#define TK_STREAMS
27
#define TK_QTIME
28
#define TK_DBS
29
#define TK_USERS
30
#define TK_CONNS
31
#define TK_STATE
32
#define TK_USER
33
#define TK_PRIVILEGE
34
#define TK_DROP
35
#define TK_DNODE
36
#define TK_PORT
37
#define TK_NK_INTEGER
38
#define TK_DNODES
39
#define TK_NK_IPTOKEN
40
#define TK_LOCAL
41
#define TK_QNODE
42
#define TK_ON
43
#define TK_BNODE
44
#define TK_SNODE
45
#define TK_MNODE
46
#define TK_DATABASE
47
#define TK_USE
48
#define TK_IF
49
#define TK_NOT
50
#define TK_EXISTS
51
#define TK_B
LOCKS
52
#define TK_CACHE
53
#define TK_C
ACHELAST
54
#define TK_
COMP
55
#define TK_
DAYS
56
#define TK_
NK_VARIABLE
57
#define TK_
FSYNC
58
#define TK_M
AXROWS
59
#define TK_
MINROWS
60
#define TK_
KEEP
61
#define TK_P
RECISION
62
#define TK_
QUORUM
63
#define TK_REPLICA
64
#define TK_
TTL
65
#define TK_WAL
66
#define TK_VGROUPS
67
#define TK_SINGLE_STABLE
68
#define TK_
STREAM_MODE
69
#define TK_
RETENTIONS
70
#define TK_
STRICT
71
#define TK_
NK_COMMA
72
#define TK_NK_
COLON
73
#define TK_
TABLE
74
#define TK_
NK_LP
75
#define TK_
NK_RP
76
#define TK_
STABLE
77
#define TK_
ADD
78
#define TK_
COLUMN
79
#define TK_
MODIFY
80
#define TK_
RENAME
81
#define TK_
TAG
82
#define TK_
SET
83
#define TK_
NK_EQ
84
#define TK_
USING
85
#define TK_
TAGS
86
#define TK_
NK_DOT
87
#define TK_
COMMENT
88
#define TK_
BOOL
89
#define TK_
TINYINT
90
#define TK_
SMALLINT
91
#define TK_
INT
92
#define TK_
INTEGER
93
#define TK_
BIGINT
94
#define TK_
FLOAT
95
#define TK_
DOUBLE
96
#define TK_
BINARY
97
#define TK_
TIMESTAMP
98
#define TK_
NCHAR
99
#define TK_
UNSIGNED
100
#define TK_
JSON
101
#define TK_
VARCHAR
102
#define TK_
MEDIUMBLOB
103
#define TK_
BLOB
104
#define TK_
VARBINARY
105
#define TK_
DECIMAL
106
#define TK_
SMA
107
#define TK_ROLLUP
108
#define TK_
FILE_FACTOR
109
#define TK_
NK_FLOAT
110
#define TK_
DELAY
111
#define TK_
SHOW
112
#define TK_
DATABASES
113
#define TK_
TABLES
114
#define TK_
STABLES
115
#define TK_M
NODES
116
#define TK_
MODULES
117
#define TK_
QNODES
118
#define TK_
FUNCTIONS
119
#define TK_
INDEXES
120
#define TK_
FROM
121
#define TK_A
CCOUNTS
122
#define TK_
APPS
123
#define TK_
CONNECTIONS
124
#define TK_
LICENCE
125
#define TK_
GRANTS
126
#define TK_
QUERIES
127
#define TK_
SCORES
128
#define TK_
TOPICS
129
#define TK_
VARIABLES
130
#define TK_
BNODES
131
#define TK_
SNODES
132
#define TK_
CLUSTER
133
#define TK_
LIKE
134
#define TK_
INDEX
135
#define TK_FU
LLTEXT
136
#define TK_
FUNCTION
137
#define TK_
INTERVAL
138
#define TK_
TOPIC
139
#define TK_
AS
140
#define TK_
WITH
141
#define TK_
SCHEMA
142
#define TK_DESC
143
#define TK_
DESCRIBE
144
#define TK_
RESET
145
#define TK_
QUERY
146
#define TK_EXPLAIN
147
#define TK_ANALYZE
148
#define TK_VERBOSE
149
#define TK_NK_BOOL
150
#define TK_RATIO
151
#define TK_COMPACT
152
#define TK_VNODES
153
#define TK_IN
154
#define TK_OUTPUTTYPE
155
#define TK_AGGREGATE
156
#define TK_BUFSIZE
157
#define TK_STREAM
158
#define TK_INTO
159
#define TK_TRIGGER
160
#define TK_AT_ONCE
161
#define TK_WINDOW_CLOSE
162
#define TK_WATERMARK
163
#define TK_KILL
164
#define TK_CONNECTION
165
#define TK_MERGE
166
#define TK_VGROUP
167
#define TK_REDISTRIBUTE
168
#define TK_SPLIT
169
#define TK_SYNCDB
170
#define TK_NULL
171
#define TK_NK_QUESTION
172
#define TK_NK_ARROW
173
#define TK_ROWTS
174
#define TK_TBNAME
175
#define TK_QSTARTTS
176
#define TK_QENDTS
177
#define TK_WSTARTTS
178
#define TK_WENDTS
179
#define TK_WDURATION
180
#define TK_CAST
181
#define TK_NOW
182
#define TK_TODAY
183
#define TK_TIMEZONE
184
#define TK_COUNT
185
#define TK_FIRST
186
#define TK_LAST
187
#define TK_LAST_ROW
188
#define TK_BETWEEN
189
#define TK_IS
190
#define TK_NK_LT
191
#define TK_NK_GT
192
#define TK_NK_LE
193
#define TK_NK_GE
194
#define TK_NK_NE
195
#define TK_MATCH
196
#define TK_NMATCH
197
#define TK_CONTAINS
198
#define TK_JOIN
199
#define TK_INNER
200
#define TK_SELECT
201
#define TK_DISTINCT
202
#define TK_WHERE
203
#define TK_PARTITION
204
#define TK_BY
205
#define TK_SESSION
206
#define TK_STATE_WINDOW
207
#define TK_SLIDING
208
#define TK_FILL
209
#define TK_VALUE
210
#define TK_NONE
211
#define TK_PREV
212
#define TK_LINEAR
213
#define TK_NEXT
214
#define TK_GROUP
215
#define TK_HAVING
216
#define TK_ORDER
217
#define TK_SLIMIT
218
#define TK_SOFFSET
219
#define TK_LIMIT
220
#define TK_OFFSET
221
#define TK_ASC
222
#define TK_NULLS
223
#define TK_ID
224
#define TK_NK_BITNOT
225
#define TK_INSERT
226
#define TK_VALUES
227
#define TK_IMPORT
228
#define TK_NK_SEMI
229
#define TK_FILE
230
#define TK_OR 1
#define TK_AND 2
#define TK_UNION 3
#define TK_ALL 4
#define TK_MINUS 5
#define TK_EXCEPT 6
#define TK_INTERSECT 7
#define TK_NK_BITAND 8
#define TK_NK_BITOR 9
#define TK_NK_LSHIFT 10
#define TK_NK_RSHIFT 11
#define TK_NK_PLUS 12
#define TK_NK_MINUS 13
#define TK_NK_STAR 14
#define TK_NK_SLASH 15
#define TK_NK_REM 16
#define TK_NK_CONCAT 17
#define TK_CREATE 18
#define TK_ACCOUNT 19
#define TK_NK_ID 20
#define TK_PASS 21
#define TK_NK_STRING 22
#define TK_ALTER 23
#define TK_PPS 24
#define TK_TSERIES 25
#define TK_STORAGE 26
#define TK_STREAMS 27
#define TK_QTIME 28
#define TK_DBS 29
#define TK_USERS 30
#define TK_CONNS 31
#define TK_STATE 32
#define TK_USER 33
#define TK_PRIVILEGE 34
#define TK_DROP 35
#define TK_DNODE 36
#define TK_PORT 37
#define TK_NK_INTEGER 38
#define TK_DNODES 39
#define TK_NK_IPTOKEN 40
#define TK_LOCAL 41
#define TK_QNODE 42
#define TK_ON 43
#define TK_BNODE 44
#define TK_SNODE 45
#define TK_MNODE 46
#define TK_DATABASE 47
#define TK_USE 48
#define TK_IF 49
#define TK_NOT 50
#define TK_EXISTS 51
#define TK_B
UFFER
52
#define TK_CACHE
LAST
53
#define TK_C
OMP
54
#define TK_
DAYS
55
#define TK_
NK_VARIABLE
56
#define TK_
FSYNC
57
#define TK_
MAXROWS
58
#define TK_M
INROWS
59
#define TK_
KEEP
60
#define TK_
PAGES
61
#define TK_P
AGESIZE
62
#define TK_
PRECISION
63
#define TK_REPLICA 64
#define TK_
STRICT
65
#define TK_WAL 66
#define TK_VGROUPS 67
#define TK_SINGLE_STABLE 68
#define TK_
RETENTIONS
69
#define TK_
NK_COMMA
70
#define TK_
NK_COLON
71
#define TK_
TABLE
72
#define TK_NK_
LP
73
#define TK_
NK_RP
74
#define TK_
STABLE
75
#define TK_
ADD
76
#define TK_
COLUMN
77
#define TK_
MODIFY
78
#define TK_
RENAME
79
#define TK_
TAG
80
#define TK_
SET
81
#define TK_
NK_EQ
82
#define TK_
USING
83
#define TK_
TAGS
84
#define TK_
NK_DOT
85
#define TK_
COMMENT
86
#define TK_
BOOL
87
#define TK_
TINYINT
88
#define TK_
SMALLINT
89
#define TK_
INT
90
#define TK_
INTEGER
91
#define TK_
BIGINT
92
#define TK_
FLOAT
93
#define TK_
DOUBLE
94
#define TK_
BINARY
95
#define TK_
TIMESTAMP
96
#define TK_
NCHAR
97
#define TK_
UNSIGNED
98
#define TK_
JSON
99
#define TK_
VARCHAR
100
#define TK_
MEDIUMBLOB
101
#define TK_
BLOB
102
#define TK_
VARBINARY
103
#define TK_
DECIMAL
104
#define TK_
DELAY
105
#define TK_
FILE_FACTOR
106
#define TK_
NK_FLOAT
107
#define TK_ROLLUP 108
#define TK_
TTL
109
#define TK_
SMA
110
#define TK_
SHOW
111
#define TK_
DATABASES
112
#define TK_
TABLES
113
#define TK_
STABLES
114
#define TK_
MNODES
115
#define TK_M
ODULES
116
#define TK_
QNODES
117
#define TK_
FUNCTIONS
118
#define TK_
INDEXES
119
#define TK_
FROM
120
#define TK_
ACCOUNTS
121
#define TK_A
PPS
122
#define TK_
CONNECTIONS
123
#define TK_
LICENCE
124
#define TK_
GRANTS
125
#define TK_
QUERIES
126
#define TK_
SCORES
127
#define TK_
TOPICS
128
#define TK_
VARIABLES
129
#define TK_
BNODES
130
#define TK_
SNODES
131
#define TK_
CLUSTER
132
#define TK_
LIKE
133
#define TK_
INDEX
134
#define TK_
FULLTEXT
135
#define TK_FU
NCTION
136
#define TK_
INTERVAL
137
#define TK_
TOPIC
138
#define TK_
AS
139
#define TK_
WITH
140
#define TK_
SCHEMA
141
#define TK_
DESC
142
#define TK_DESC
RIBE
143
#define TK_
RESET
144
#define TK_
QUERY
145
#define TK_
CACHE
146
#define TK_EXPLAIN 147
#define TK_ANALYZE 148
#define TK_VERBOSE 149
#define TK_NK_BOOL 150
#define TK_RATIO 151
#define TK_COMPACT 152
#define TK_VNODES 153
#define TK_IN 154
#define TK_OUTPUTTYPE 155
#define TK_AGGREGATE 156
#define TK_BUFSIZE 157
#define TK_STREAM 158
#define TK_INTO 159
#define TK_TRIGGER 160
#define TK_AT_ONCE 161
#define TK_WINDOW_CLOSE 162
#define TK_WATERMARK 163
#define TK_KILL 164
#define TK_CONNECTION 165
#define TK_MERGE 166
#define TK_VGROUP 167
#define TK_REDISTRIBUTE 168
#define TK_SPLIT 169
#define TK_SYNCDB 170
#define TK_NULL 171
#define TK_NK_QUESTION 172
#define TK_NK_ARROW 173
#define TK_ROWTS 174
#define TK_TBNAME 175
#define TK_QSTARTTS 176
#define TK_QENDTS 177
#define TK_WSTARTTS 178
#define TK_WENDTS 179
#define TK_WDURATION 180
#define TK_CAST 181
#define TK_NOW 182
#define TK_TODAY 183
#define TK_TIMEZONE 184
#define TK_COUNT 185
#define TK_FIRST 186
#define TK_LAST 187
#define TK_LAST_ROW 188
#define TK_BETWEEN 189
#define TK_IS 190
#define TK_NK_LT 191
#define TK_NK_GT 192
#define TK_NK_LE 193
#define TK_NK_GE 194
#define TK_NK_NE 195
#define TK_MATCH 196
#define TK_NMATCH 197
#define TK_CONTAINS 198
#define TK_JOIN 199
#define TK_INNER 200
#define TK_SELECT 201
#define TK_DISTINCT 202
#define TK_WHERE 203
#define TK_PARTITION 204
#define TK_BY 205
#define TK_SESSION 206
#define TK_STATE_WINDOW 207
#define TK_SLIDING 208
#define TK_FILL 209
#define TK_VALUE 210
#define TK_NONE 211
#define TK_PREV 212
#define TK_LINEAR 213
#define TK_NEXT 214
#define TK_GROUP 215
#define TK_HAVING 216
#define TK_ORDER 217
#define TK_SLIMIT 218
#define TK_SOFFSET 219
#define TK_LIMIT 220
#define TK_OFFSET 221
#define TK_ASC 222
#define TK_NULLS 223
#define TK_ID 224
#define TK_NK_BITNOT 225
#define TK_INSERT 226
#define TK_VALUES 227
#define TK_IMPORT 228
#define TK_NK_SEMI 229
#define TK_FILE 230
#define TK_NK_SPACE
300
#define TK_NK_COMMENT
301
#define TK_NK_ILLEGAL
302
#define TK_NK_HEX
303
// hex number 0x123
#define TK_NK_OCT
304
// oct number
#define TK_NK_BIN
305
// bin format data 0b111
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
#define TK_NK_ILLEGAL 302
#define TK_NK_HEX
303
// hex number 0x123
#define TK_NK_OCT
304
// oct number
#define TK_NK_BIN
305
// bin format data 0b111
#define TK_NK_NIL
65535
#define TK_NK_NIL 65535
#endif
/*_TD_COMMON_TOKEN_H_*/
include/libs/nodes/cmdnodes.h
浏览文件 @
ccfcbba6
...
...
@@ -23,294 +23,291 @@ extern "C" {
#include "query.h"
#include "querynodes.h"
#define DESCRIBE_RESULT_COLS 4
#define DESCRIBE_RESULT_COLS
4
#define DESCRIBE_RESULT_FIELD_LEN (TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_TYPE_LEN
(20 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_NOTE_LEN
(8 + VARSTR_HEADER_SIZE)
typedef
struct
SDatabaseOptions
{
ENodeType
type
;
SValueNode
*
pNumOfBlocks
;
SValueNode
*
pCacheBlockSize
;
SValueNode
*
pCachelast
;
SValueNode
*
pCompressionLevel
;
ENodeType
type
;
int32_t
buffer
;
int8_t
cachelast
;
int8_t
compressionLevel
;
int32_t
daysPerFile
;
SValueNode
*
pDaysPerFile
;
SValueNode
*
pFsyncPeriod
;
SValueNode
*
pMaxRowsPerBlock
;
SValueNode
*
pMinRowsPerBlock
;
SNodeList
*
pKeep
;
SValueNode
*
pPrecision
;
SValueNode
*
pQuorum
;
SValueNode
*
pReplica
;
SValueNode
*
pTtl
;
SValueNode
*
pWalLevel
;
SValueNode
*
pNumOfVgroups
;
SValueNode
*
pSingleStable
;
SValueNode
*
pStreamMode
;
SValueNode
*
pStrict
;
SNodeList
*
pRetentions
;
int32_t
fsyncPeriod
;
int32_t
maxRowsPerBlock
;
int32_t
minRowsPerBlock
;
SNodeList
*
pKeep
;
int32_t
keep
[
3
];
int32_t
pages
;
int32_t
pagesize
;
char
precisionStr
[
3
];
int8_t
precision
;
int8_t
replica
;
int8_t
strict
;
int8_t
walLevel
;
int32_t
numOfVgroups
;
int8_t
singleStable
;
SNodeList
*
pRetentions
;
}
SDatabaseOptions
;
typedef
struct
SCreateDatabaseStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
bool
ignoreExists
;
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
bool
ignoreExists
;
SDatabaseOptions
*
pOptions
;
}
SCreateDatabaseStmt
;
typedef
struct
SUseDatabaseStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
}
SUseDatabaseStmt
;
typedef
struct
SDropDatabaseStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
bool
ignoreNotExists
;
char
dbName
[
TSDB_DB_NAME_LEN
];
bool
ignoreNotExists
;
}
SDropDatabaseStmt
;
typedef
struct
SAlterDatabaseStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
SDatabaseOptions
*
pOptions
;
}
SAlterDatabaseStmt
;
typedef
struct
STableOptions
{
ENodeType
type
;
SNodeList
*
pKeep
;
SValueNode
*
pTtl
;
SValueNode
*
pComments
;
ENodeType
type
;
char
comment
[
TSDB_STB_COMMENT_LEN
];
int32_t
delay
;
float
filesFactor
;
SNodeList
*
pRollupFuncs
;
int32_t
ttl
;
SNodeList
*
pSma
;
SNodeList
*
pFuncs
;
SValueNode
*
pFilesFactor
;
SValueNode
*
pDelay
;
}
STableOptions
;
typedef
struct
SColumnDefNode
{
ENodeType
type
;
char
colName
[
TSDB_COL_NAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
SDataType
dataType
;
char
comments
[
TSDB_STB_COMMENT_LEN
];
bool
sma
;
char
comments
[
TSDB_STB_COMMENT_LEN
];
bool
sma
;
}
SColumnDefNode
;
typedef
struct
SCreateTableStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreExists
;
SNodeList
*
pCols
;
SNodeList
*
pTags
;
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreExists
;
SNodeList
*
pCols
;
SNodeList
*
pTags
;
STableOptions
*
pOptions
;
}
SCreateTableStmt
;
typedef
struct
SCreateSubTableClause
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
useDbName
[
TSDB_DB_NAME_LEN
];
char
useTableName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreExists
;
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
useDbName
[
TSDB_DB_NAME_LEN
];
char
useTableName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreExists
;
SNodeList
*
pSpecificTags
;
SNodeList
*
pValsOfTags
;
}
SCreateSubTableClause
;
typedef
struct
SCreateMultiTableStmt
{
ENodeType
type
;
ENodeType
type
;
SNodeList
*
pSubTables
;
}
SCreateMultiTableStmt
;
typedef
struct
SDropTableClause
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreNotExists
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreNotExists
;
}
SDropTableClause
;
typedef
struct
SDropTableStmt
{
ENodeType
type
;
ENodeType
type
;
SNodeList
*
pTables
;
}
SDropTableStmt
;
typedef
struct
SDropSuperTableStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreNotExists
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreNotExists
;
}
SDropSuperTableStmt
;
typedef
struct
SAlterTableStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
int8_t
alterType
;
char
colName
[
TSDB_COL_NAME_LEN
];
char
newColName
[
TSDB_COL_NAME_LEN
];
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
int8_t
alterType
;
char
colName
[
TSDB_COL_NAME_LEN
];
char
newColName
[
TSDB_COL_NAME_LEN
];
STableOptions
*
pOptions
;
SDataType
dataType
;
SValueNode
*
pVal
;
SDataType
dataType
;
SValueNode
*
pVal
;
}
SAlterTableStmt
;
typedef
struct
SCreateUserStmt
{
ENodeType
type
;
char
useName
[
TSDB_USER_LEN
];
char
password
[
TSDB_USET_PASSWORD_LEN
];
char
useName
[
TSDB_USER_LEN
];
char
password
[
TSDB_USET_PASSWORD_LEN
];
}
SCreateUserStmt
;
typedef
struct
SAlterUserStmt
{
ENodeType
type
;
char
useName
[
TSDB_USER_LEN
];
char
password
[
TSDB_USET_PASSWORD_LEN
];
int8_t
alterType
;
char
useName
[
TSDB_USER_LEN
];
char
password
[
TSDB_USET_PASSWORD_LEN
];
int8_t
alterType
;
}
SAlterUserStmt
;
typedef
struct
SDropUserStmt
{
ENodeType
type
;
char
useName
[
TSDB_USER_LEN
];
char
useName
[
TSDB_USER_LEN
];
}
SDropUserStmt
;
typedef
struct
SCreateDnodeStmt
{
ENodeType
type
;
char
fqdn
[
TSDB_FQDN_LEN
];
int32_t
port
;
char
fqdn
[
TSDB_FQDN_LEN
];
int32_t
port
;
}
SCreateDnodeStmt
;
typedef
struct
SDropDnodeStmt
{
ENodeType
type
;
int32_t
dnodeId
;
char
fqdn
[
TSDB_FQDN_LEN
];
int32_t
port
;
int32_t
dnodeId
;
char
fqdn
[
TSDB_FQDN_LEN
];
int32_t
port
;
}
SDropDnodeStmt
;
typedef
struct
SAlterDnodeStmt
{
ENodeType
type
;
int32_t
dnodeId
;
char
config
[
TSDB_DNODE_CONFIG_LEN
];
char
value
[
TSDB_DNODE_VALUE_LEN
];
int32_t
dnodeId
;
char
config
[
TSDB_DNODE_CONFIG_LEN
];
char
value
[
TSDB_DNODE_VALUE_LEN
];
}
SAlterDnodeStmt
;
typedef
struct
SShowStmt
{
ENodeType
type
;
SNode
*
pDbName
;
// SValueNode
SNode
*
pTbNamePattern
;
// SValueNode
SNode
*
pDbName
;
// SValueNode
SNode
*
pTbNamePattern
;
// SValueNode
}
SShowStmt
;
typedef
struct
SShowCreatStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
}
SShowCreatStmt
;
typedef
enum
EIndexType
{
INDEX_TYPE_SMA
=
1
,
INDEX_TYPE_FULLTEXT
}
EIndexType
;
typedef
enum
EIndexType
{
INDEX_TYPE_SMA
=
1
,
INDEX_TYPE_FULLTEXT
}
EIndexType
;
typedef
struct
SIndexOptions
{
ENodeType
type
;
ENodeType
type
;
SNodeList
*
pFuncs
;
SNode
*
pInterval
;
SNode
*
pOffset
;
SNode
*
pSliding
;
SNode
*
pInterval
;
SNode
*
pOffset
;
SNode
*
pSliding
;
}
SIndexOptions
;
typedef
struct
SCreateIndexStmt
{
ENodeType
type
;
EIndexType
indexType
;
bool
ignoreExists
;
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
SNodeList
*
pCols
;
ENodeType
type
;
EIndexType
indexType
;
bool
ignoreExists
;
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
SNodeList
*
pCols
;
SIndexOptions
*
pOptions
;
}
SCreateIndexStmt
;
typedef
struct
SDropIndexStmt
{
ENodeType
type
;
bool
ignoreNotExists
;
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreNotExists
;
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
}
SDropIndexStmt
;
typedef
struct
SCreateComponentNodeStmt
{
ENodeType
type
;
int32_t
dnodeId
;
int32_t
dnodeId
;
}
SCreateComponentNodeStmt
;
typedef
struct
SDropComponentNodeStmt
{
ENodeType
type
;
int32_t
dnodeId
;
int32_t
dnodeId
;
}
SDropComponentNodeStmt
;
typedef
struct
STopicOptions
{
ENodeType
type
;
bool
withTable
;
bool
withSchema
;
bool
withTag
;
bool
withTable
;
bool
withSchema
;
bool
withTag
;
}
STopicOptions
;
typedef
struct
SCreateTopicStmt
{
ENodeType
type
;
char
topicName
[
TSDB_TABLE_NAME_LEN
];
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
bool
ignoreExists
;
SNode
*
pQuery
;
ENodeType
type
;
char
topicName
[
TSDB_TABLE_NAME_LEN
];
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
bool
ignoreExists
;
SNode
*
pQuery
;
STopicOptions
*
pOptions
;
}
SCreateTopicStmt
;
typedef
struct
SDropTopicStmt
{
ENodeType
type
;
char
topicName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreNotExists
;
char
topicName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreNotExists
;
}
SDropTopicStmt
;
typedef
struct
SAlterLocalStmt
{
ENodeType
type
;
char
config
[
TSDB_DNODE_CONFIG_LEN
];
char
value
[
TSDB_DNODE_VALUE_LEN
];
char
config
[
TSDB_DNODE_CONFIG_LEN
];
char
value
[
TSDB_DNODE_VALUE_LEN
];
}
SAlterLocalStmt
;
typedef
struct
SDescribeStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
STableMeta
*
pMeta
;
}
SDescribeStmt
;
typedef
struct
SKillStmt
{
ENodeType
type
;
int32_t
targetId
;
int32_t
targetId
;
}
SKillStmt
;
typedef
struct
SStreamOptions
{
ENodeType
type
;
int8_t
triggerType
;
SNode
*
pWatermark
;
int8_t
triggerType
;
SNode
*
pWatermark
;
}
SStreamOptions
;
typedef
struct
SCreateStreamStmt
{
ENodeType
type
;
char
streamName
[
TSDB_TABLE_NAME_LEN
];
char
targetDbName
[
TSDB_DB_NAME_LEN
];
char
targetTabName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreExists
;
ENodeType
type
;
char
streamName
[
TSDB_TABLE_NAME_LEN
];
char
targetDbName
[
TSDB_DB_NAME_LEN
];
char
targetTabName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreExists
;
SStreamOptions
*
pOptions
;
SNode
*
pQuery
;
SNode
*
pQuery
;
}
SCreateStreamStmt
;
typedef
struct
SDropStreamStmt
{
ENodeType
type
;
char
streamName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreNotExists
;
char
streamName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreNotExists
;
}
SDropStreamStmt
;
typedef
struct
SCreateFunctionStmt
{
ENodeType
type
;
bool
ignoreExists
;
char
funcName
[
TSDB_FUNC_NAME_LEN
];
bool
isAgg
;
char
libraryPath
[
PATH_MAX
];
bool
ignoreExists
;
char
funcName
[
TSDB_FUNC_NAME_LEN
];
bool
isAgg
;
char
libraryPath
[
PATH_MAX
];
SDataType
outputDt
;
int32_t
bufSize
;
int32_t
bufSize
;
}
SCreateFunctionStmt
;
#ifdef __cplusplus
...
...
include/libs/nodes/plannodes.h
浏览文件 @
ccfcbba6
...
...
@@ -340,7 +340,7 @@ typedef struct SQueryPlan {
int32_t
numOfSubplans
;
SNodeList
*
pSubplans
;
// Element is SNodeListNode. The execution level of subplan, starting from 0.
SExplainInfo
explainInfo
;
S
NodeList
*
pPlaceholderValues
;
S
Array
*
pPlaceholderValues
;
}
SQueryPlan
;
void
nodesWalkPhysiPlan
(
SNode
*
pNode
,
FNodeWalker
walker
,
void
*
pContext
);
...
...
include/libs/parser/parser.h
浏览文件 @
ccfcbba6
...
...
@@ -73,6 +73,7 @@ typedef struct SQuery {
SArray
*
pDbList
;
SArray
*
pTableList
;
bool
showRewrite
;
int32_t
placeholderNum
;
}
SQuery
;
int32_t
qParseQuerySql
(
SParseContext
*
pCxt
,
SQuery
**
pQuery
);
...
...
include/libs/planner/planner.h
浏览文件 @
ccfcbba6
...
...
@@ -34,7 +34,7 @@ typedef struct SPlanContext {
bool
showRewrite
;
int8_t
triggerType
;
int64_t
watermark
;
bool
isStmtQuery
;
int32_t
placeholderNum
;
void
*
pTransporter
;
struct
SCatalog
*
pCatalog
;
char
*
pMsg
;
...
...
@@ -50,7 +50,7 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
// @pSource one execution location of this group of datasource subplans
int32_t
qSetSubplanExecutionNode
(
SSubplan
*
pSubplan
,
int32_t
groupId
,
SDownstreamSourceNode
*
pSource
);
int32_t
qStmtBindParam
(
SQueryPlan
*
pPlan
,
TAOS_MULTI_BIND
*
pParams
,
int32_t
colIdx
);
int32_t
qStmtBindParam
(
SQueryPlan
*
pPlan
,
TAOS_MULTI_BIND
*
pParams
,
int32_t
colIdx
,
uint64_t
queryId
);
// Convert to subplan to string for the scheduler to send to the executor
int32_t
qSubPlanToString
(
const
SSubplan
*
pSubplan
,
char
**
pStr
,
int32_t
*
pLen
);
...
...
include/util/taoserror.h
浏览文件 @
ccfcbba6
...
...
@@ -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_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_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_ORDER TAOS_DEF_ERROR_CODE(0, 0x261E)
#define TSDB_CODE_PAR_INVALID_KEEP_VALUE TAOS_DEF_ERROR_CODE(0, 0x261F)
...
...
include/util/tdef.h
浏览文件 @
ccfcbba6
...
...
@@ -323,72 +323,80 @@ typedef enum ELogicConditionType {
#define TSDB_MULTI_TABLEMETA_MAX_NUM 100000 // maximum batch size allowed to load table meta
#define TSDB_MIN_VNODES_PER_DB 1
#define TSDB_MAX_VNODES_PER_DB 4096
#define TSDB_DEFAULT_VN_PER_DB 2
#define TSDB_MIN_CACHE_BLOCK_SIZE 1
#define TSDB_MAX_CACHE_BLOCK_SIZE 128 // 128MB for each vnode
#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16
#define TSDB_MIN_TOTAL_BLOCKS 3
#define TSDB_MAX_TOTAL_BLOCKS 10000
#define TSDB_DEFAULT_TOTAL_BLOCKS 6
#define TSDB_MIN_DAYS_PER_FILE 60 // unit minute
#define TSDB_MAX_DAYS_PER_FILE (3650 * 1440)
#define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440)
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
#define TSDB_MIN_MINROWS_FBLOCK 10
#define TSDB_MAX_MINROWS_FBLOCK 1000
#define TSDB_DEFAULT_MINROWS_FBLOCK 100
#define TSDB_MIN_MAXROWS_FBLOCK 200
#define TSDB_MAX_MAXROWS_FBLOCK 10000
#define TSDB_DEFAULT_MAXROWS_FBLOCK 4096
#define TSDB_MIN_COMMIT_TIME 30
#define TSDB_MAX_COMMIT_TIME 40960
#define TSDB_DEFAULT_COMMIT_TIME 3600
#define TSDB_MIN_FSYNC_PERIOD 0
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
#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_MAX_WAL_LEVEL 2
#define TSDB_DEFAULT_WAL_LEVEL 1
#define TSDB_MIN_PRECISION TSDB_TIME_PRECISION_MILLI
#define TSDB_MAX_PRECISION TSDB_TIME_PRECISION_NANO
#define TSDB_DEFAULT_PRECISION TSDB_TIME_PRECISION_MILLI
#define TSDB_MIN_COMP_LEVEL 0
#define TSDB_MAX_COMP_LEVEL 2
#define TSDB_DEFAULT_COMP_LEVEL 2
#define TSDB_MIN_DB_REPLICA 1
#define TSDB_MAX_DB_REPLICA 3
#define TSDB_DEFAULT_DB_REPLICA 1
#define TSDB_DB_STRICT_OFF 0
#define TSDB_DB_STRICT_ON 1
#define TSDB_DEFAULT_DB_STRICT 0
#define TSDB_MIN_DB_UPDATE 0
#define TSDB_MAX_DB_UPDATE 2
#define TSDB_DEFAULT_DB_UPDATE 0
#define TSDB_MIN_DB_CACHE_LAST_ROW 0
#define TSDB_MAX_DB_CACHE_LAST_ROW 3
#define TSDB_DEFAULT_CACHE_LAST_ROW 0
#define TSDB_DB_STREAM_MODE_OFF 0
#define TSDB_DB_STREAM_MODE_ON 1
#define TSDB_DEFAULT_DB_STREAM_MODE 0
#define TSDB_DB_SINGLE_STABLE_ON 0
#define TSDB_DB_SINGLE_STABLE_OFF 1
#define TSDB_DEFAULT_DB_SINGLE_STABLE 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_MAX_EXPLAIN_RATIO 1
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
#define TSDB_MIN_VNODES_PER_DB 1
#define TSDB_MAX_VNODES_PER_DB 4096
#define TSDB_DEFAULT_VN_PER_DB 2
#define TSDB_MIN_CACHE_BLOCK_SIZE 1
#define TSDB_MAX_CACHE_BLOCK_SIZE 128 // 128MB for each vnode
#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16
#define TSDB_MIN_TOTAL_BLOCKS 3
#define TSDB_MAX_TOTAL_BLOCKS 10000
#define TSDB_DEFAULT_TOTAL_BLOCKS 6
#define TSDB_MIN_DAYS_PER_FILE 60 // unit minute
#define TSDB_MAX_DAYS_PER_FILE (3650 * 1440)
#define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440)
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
#define TSDB_MIN_MINROWS_FBLOCK 10
#define TSDB_MAX_MINROWS_FBLOCK 1000
#define TSDB_DEFAULT_MINROWS_FBLOCK 100
#define TSDB_MIN_MAXROWS_FBLOCK 200
#define TSDB_MAX_MAXROWS_FBLOCK 10000
#define TSDB_DEFAULT_MAXROWS_FBLOCK 4096
#define TSDB_MIN_COMMIT_TIME 30
#define TSDB_MAX_COMMIT_TIME 40960
#define TSDB_DEFAULT_COMMIT_TIME 3600
#define TSDB_MIN_FSYNC_PERIOD 0
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
#define TSDB_MIN_WAL_LEVEL 1
#define TSDB_MAX_WAL_LEVEL 2
#define TSDB_DEFAULT_WAL_LEVEL 1
#define TSDB_MIN_PRECISION TSDB_TIME_PRECISION_MILLI
#define TSDB_MAX_PRECISION TSDB_TIME_PRECISION_NANO
#define TSDB_DEFAULT_PRECISION TSDB_TIME_PRECISION_MILLI
#define TSDB_MIN_COMP_LEVEL 0
#define TSDB_MAX_COMP_LEVEL 2
#define TSDB_DEFAULT_COMP_LEVEL 2
#define TSDB_MIN_DB_REPLICA 1
#define TSDB_MAX_DB_REPLICA 3
#define TSDB_DEFAULT_DB_REPLICA 1
#define TSDB_DB_STRICT_OFF 0
#define TSDB_DB_STRICT_ON 1
#define TSDB_DEFAULT_DB_STRICT 0
#define TSDB_MIN_DB_UPDATE 0
#define TSDB_MAX_DB_UPDATE 2
#define TSDB_DEFAULT_DB_UPDATE 0
#define TSDB_MIN_DB_CACHE_LAST_ROW 0
#define TSDB_MAX_DB_CACHE_LAST_ROW 3
#define TSDB_DEFAULT_CACHE_LAST_ROW 0
#define TSDB_DB_STREAM_MODE_OFF 0
#define TSDB_DB_STREAM_MODE_ON 1
#define TSDB_DEFAULT_DB_STREAM_MODE 0
#define TSDB_DB_SINGLE_STABLE_ON 0
#define TSDB_DB_SINGLE_STABLE_OFF 1
#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_EXPLAIN_RATIO 0
#define TSDB_MAX_EXPLAIN_RATIO 1
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
#define TSDB_MAX_JOIN_TABLE_NUM 10
#define TSDB_MAX_UNION_CLAUSE 5
...
...
source/client/inc/clientStmt.h
浏览文件 @
ccfcbba6
...
...
@@ -46,6 +46,12 @@ typedef struct SStmtTableCache {
void
*
boundTags
;
}
SStmtTableCache
;
typedef
struct
SQueryFields
{
TAOS_FIELD
*
fields
;
TAOS_FIELD
*
userFields
;
uint32_t
numOfCols
;
}
SQueryFields
;
typedef
struct
SStmtBindInfo
{
bool
needParse
;
uint64_t
tbUid
;
...
...
@@ -66,16 +72,17 @@ typedef struct SStmtExecInfo {
}
SStmtExecInfo
;
typedef
struct
SStmtSQLInfo
{
STMT_TYPE
type
;
STMT_STATUS
status
;
bool
autoCreate
;
uint64_t
runTimes
;
SHashObj
*
pTableCache
;
//SHash<SStmtTableCache>
SQuery
*
pQuery
;
char
*
sqlStr
;
int32_t
sqlLen
;
SArray
*
nodeList
;
SQueryPlan
*
pQueryPlan
;
STMT_TYPE
type
;
STMT_STATUS
status
;
bool
autoCreate
;
uint64_t
runTimes
;
SHashObj
*
pTableCache
;
//SHash<SStmtTableCache>
SQuery
*
pQuery
;
char
*
sqlStr
;
int32_t
sqlLen
;
SArray
*
nodeList
;
SQueryPlan
*
pQueryPlan
;
SQueryFields
fields
;
}
SStmtSQLInfo
;
typedef
struct
STscStmt
{
...
...
source/client/src/clientImpl.c
浏览文件 @
ccfcbba6
...
...
@@ -234,7 +234,8 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
.
showRewrite
=
pQuery
->
showRewrite
,
.
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
.
pMsg
=
pRequest
->
msgBuf
,
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
};
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
placeholderNum
=
pQuery
->
placeholderNum
};
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
cxt
.
pCatalog
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
...
...
source/client/src/clientStmt.c
浏览文件 @
ccfcbba6
...
...
@@ -73,6 +73,22 @@ int32_t stmtGetTbName(TAOS_STMT *stmt, char **tbName) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
stmtBackupQueryFields
(
STscStmt
*
pStmt
)
{
SQueryFields
*
pFields
=
&
pStmt
->
sql
.
fields
;
int32_t
size
=
pFields
->
numOfCols
*
sizeof
(
TAOS_FIELD
);
pFields
->
numOfCols
=
pStmt
->
exec
.
pRequest
->
body
.
resInfo
.
numOfCols
;
pFields
->
fields
=
taosMemoryMalloc
(
size
);
pFields
->
userFields
=
taosMemoryMalloc
(
size
);
if
(
NULL
==
pFields
->
fields
||
NULL
==
pFields
->
userFields
)
{
STMT_ERR_RET
(
TSDB_CODE_TSC_OUT_OF_MEMORY
);
}
memcpy
(
pFields
->
fields
,
pStmt
->
exec
.
pRequest
->
body
.
resInfo
.
fields
,
size
);
memcpy
(
pFields
->
userFields
,
pStmt
->
exec
.
pRequest
->
body
.
resInfo
.
userFields
,
size
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
stmtSetBindInfo
(
TAOS_STMT
*
stmt
,
STableMeta
*
pTableMeta
,
void
*
tags
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
...
...
@@ -258,37 +274,42 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
STableMeta
*
pTableMeta
=
NULL
;
SEpSet
ep
=
getEpSet_s
(
&
pStmt
->
taos
->
pAppInfo
->
mgmtEp
);
STMT_ERR_RET
(
catalogGetTableMeta
(
pStmt
->
pCatalog
,
pStmt
->
taos
->
pAppInfo
->
pTransporter
,
&
ep
,
&
pStmt
->
bInfo
.
sname
,
&
pTableMeta
));
if
(
pTableMeta
->
uid
==
pStmt
->
bInfo
.
tbUid
)
{
uint64_t
uid
=
pTableMeta
->
uid
;
uint64_t
suid
=
pTableMeta
->
suid
;
int8_t
tableType
=
pTableMeta
->
tableType
;
taosMemoryFree
(
pTableMeta
);
if
(
uid
==
pStmt
->
bInfo
.
tbUid
)
{
pStmt
->
bInfo
.
needParse
=
false
;
return
TSDB_CODE_SUCCESS
;
}
if
(
taosHashGet
(
pStmt
->
exec
.
pBlockHash
,
&
pTableMeta
->
uid
,
sizeof
(
pTableMeta
->
uid
)))
{
SStmtTableCache
*
pCache
=
taosHashGet
(
pStmt
->
sql
.
pTableCache
,
&
pTableMeta
->
uid
,
sizeof
(
pTableMeta
->
uid
));
if
(
taosHashGet
(
pStmt
->
exec
.
pBlockHash
,
&
uid
,
sizeof
(
uid
)))
{
SStmtTableCache
*
pCache
=
taosHashGet
(
pStmt
->
sql
.
pTableCache
,
&
uid
,
sizeof
(
uid
));
if
(
NULL
==
pCache
)
{
tscError
(
"table uid %"
PRIx64
"found in exec blockHash, but not in sql blockHash"
,
pTableMeta
->
uid
);
tscError
(
"table uid %"
PRIx64
"found in exec blockHash, but not in sql blockHash"
,
uid
);
STMT_ERR_RET
(
TSDB_CODE_TSC_APP_ERROR
);
}
pStmt
->
bInfo
.
needParse
=
false
;
pStmt
->
bInfo
.
tbUid
=
pTableMeta
->
uid
;
pStmt
->
bInfo
.
tbSuid
=
pTableMeta
->
suid
;
pStmt
->
bInfo
.
tbType
=
pTableMeta
->
tableType
;
pStmt
->
bInfo
.
tbUid
=
uid
;
pStmt
->
bInfo
.
tbSuid
=
suid
;
pStmt
->
bInfo
.
tbType
=
tableType
;
pStmt
->
bInfo
.
boundTags
=
pCache
->
boundTags
;
return
TSDB_CODE_SUCCESS
;
}
SStmtTableCache
*
pCache
=
taosHashGet
(
pStmt
->
sql
.
pTableCache
,
&
pTableMeta
->
uid
,
sizeof
(
pTableMeta
->
uid
));
SStmtTableCache
*
pCache
=
taosHashGet
(
pStmt
->
sql
.
pTableCache
,
&
uid
,
sizeof
(
uid
));
if
(
pCache
)
{
pStmt
->
bInfo
.
needParse
=
false
;
pStmt
->
bInfo
.
tbUid
=
pTableMeta
->
uid
;
pStmt
->
bInfo
.
tbSuid
=
pTableMeta
->
suid
;
pStmt
->
bInfo
.
tbType
=
pTableMeta
->
tableType
;
pStmt
->
bInfo
.
tbUid
=
uid
;
pStmt
->
bInfo
.
tbSuid
=
suid
;
pStmt
->
bInfo
.
tbType
=
tableType
;
pStmt
->
bInfo
.
boundTags
=
pCache
->
boundTags
;
STableDataBlocks
*
pNewBlock
=
NULL
;
...
...
@@ -475,9 +496,10 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx) {
STMT_ERR_RET
(
getQueryPlan
(
pStmt
->
exec
.
pRequest
,
pStmt
->
sql
.
pQuery
,
&
pStmt
->
sql
.
nodeList
));
pStmt
->
sql
.
pQueryPlan
=
pStmt
->
exec
.
pRequest
->
body
.
pDag
;
pStmt
->
exec
.
pRequest
->
body
.
pDag
=
NULL
;
STMT_ERR_RET
(
stmtBackupQueryFields
(
pStmt
));
}
STMT_RET
(
qStmtBindParam
(
pStmt
->
sql
.
pQueryPlan
,
bind
,
colIdx
));
STMT_RET
(
qStmtBindParam
(
pStmt
->
sql
.
pQueryPlan
,
bind
,
colIdx
,
pStmt
->
exec
.
pRequest
->
requestId
));
}
STableDataBlocks
**
pDataBlock
=
(
STableDataBlocks
**
)
taosHashGet
(
pStmt
->
exec
.
pBlockHash
,
(
const
char
*
)
&
pStmt
->
bInfo
.
tbUid
,
sizeof
(
pStmt
->
bInfo
.
tbUid
));
...
...
@@ -549,6 +571,8 @@ int stmtClose(TAOS_STMT *stmt) {
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_RET
(
stmtCleanSQLInfo
(
pStmt
));
taosMemoryFree
(
stmt
);
}
const
char
*
stmtErrstr
(
TAOS_STMT
*
stmt
)
{
...
...
@@ -601,7 +625,7 @@ int stmtGetParamNum(TAOS_STMT *stmt, int *nums) {
pStmt
->
exec
.
pRequest
->
body
.
pDag
=
NULL
;
}
*
nums
=
(
pStmt
->
sql
.
pQueryPlan
->
pPlaceholderValues
)
?
pStmt
->
sql
.
pQueryPlan
->
pPlaceholderValues
->
length
:
0
;
*
nums
=
taosArrayGetSize
(
pStmt
->
sql
.
pQueryPlan
->
pPlaceholderValues
)
;
}
else
{
STMT_ERR_RET
(
stmtFetchColFields
(
stmt
,
nums
,
NULL
));
}
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
ccfcbba6
...
...
@@ -107,7 +107,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pCfg
->
vgId
=
pCreate
->
vgId
;
strcpy
(
pCfg
->
dbname
,
pCreate
->
db
);
pCfg
->
szBuf
=
pCreate
->
cacheBlockSize
*
1024
*
1024
;
//
pCfg->szBuf = pCreate->cacheBlockSize * 1024 * 1024;
pCfg
->
streamMode
=
pCreate
->
streamMode
;
pCfg
->
isWeak
=
true
;
pCfg
->
tsdbCfg
.
days
=
10
;
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
ccfcbba6
...
...
@@ -268,8 +268,10 @@ static int32_t mndCheckDbName(const char *dbName, SUserObj *pUser) {
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->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
->
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
->
daysToKeep1
<
TSDB_MIN_KEEP
||
pCfg
->
daysToKeep1
>
TSDB_MAX_KEEP
)
return
-
1
;
...
...
@@ -282,7 +284,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
if
(
pCfg
->
minRows
>
pCfg
->
maxRows
)
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
->
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
->
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
;
...
...
@@ -310,7 +312,7 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
if
(
pCfg
->
maxRows
<
0
)
pCfg
->
maxRows
=
TSDB_DEFAULT_MAXROWS_FBLOCK
;
if
(
pCfg
->
commitTime
<
0
)
pCfg
->
commitTime
=
TSDB_DEFAULT_COMMIT_TIME
;
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
->
precision
<
0
)
pCfg
->
precision
=
TSDB_DEFAULT_PRECISION
;
if
(
pCfg
->
compression
<
0
)
pCfg
->
compression
=
TSDB_DEFAULT_COMP_LEVEL
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
ccfcbba6
...
...
@@ -1490,6 +1490,10 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit
pSchema1
=
metaGetTbTSchema
(
REPO_META
(
pTsdbReadHandle
->
pTsdb
),
uid
,
TD_ROW_SVER
(
row1
));
}
#ifdef TD_DEBUG_PRINT_ROW
tdSRowPrint
(
row1
,
pSchema1
,
__func__
);
#endif
if
(
isRow1DataRow
)
{
numOfColsOfRow1
=
schemaNCols
(
pSchema1
);
}
else
{
...
...
source/libs/nodes/src/nodesTraverseFuncs.c
浏览文件 @
ccfcbba6
...
...
@@ -423,6 +423,9 @@ static EDealRes dispatchPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalk
EDealRes
res
=
DEAL_RES_CONTINUE
;
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_NODE_LIST
:
res
=
walkPhysiPlans
(((
SNodeListNode
*
)
pNode
)
->
pNodeList
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
res
=
walkScanPhysi
((
SScanPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
break
;
...
...
@@ -534,10 +537,7 @@ static EDealRes dispatchPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalk
break
;
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
{
SSubplan
*
pSubplan
=
(
SSubplan
*
)
pNode
;
res
=
walkPhysiNode
((
SPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pSubplan
->
pChildren
,
order
,
walker
,
pContext
);
}
res
=
walkPhysiPlans
(
pSubplan
->
pChildren
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlan
((
SNode
*
)
pSubplan
->
pNode
,
order
,
walker
,
pContext
);
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
ccfcbba6
...
...
@@ -389,21 +389,25 @@ void nodesDestroyNode(SNodeptr pNode) {
case
QUERY_NODE_COLUMN_DEF
:
// no pointer field
case
QUERY_NODE_DOWNSTREAM_SOURCE
:
// no pointer field
break
;
case
QUERY_NODE_DATABASE_OPTIONS
:
nodesDestroyList
(((
SDatabaseOptions
*
)
pNode
)
->
pRetentions
);
case
QUERY_NODE_DATABASE_OPTIONS
:
{
SDatabaseOptions
*
pOptions
=
(
SDatabaseOptions
*
)
pNode
;
nodesDestroyNode
(
pOptions
->
pDaysPerFile
);
nodesDestroyList
(
pOptions
->
pKeep
);
nodesDestroyList
(
pOptions
->
pRetentions
);
break
;
}
case
QUERY_NODE_TABLE_OPTIONS
:
{
STableOptions
*
p
Stmt
=
(
STableOptions
*
)
pNode
;
nodesDestroyList
(
p
Stmt
->
pSma
);
nodesDestroyList
(
p
Stmt
->
pFuncs
);
STableOptions
*
p
Options
=
(
STableOptions
*
)
pNode
;
nodesDestroyList
(
p
Options
->
pSma
);
nodesDestroyList
(
p
Options
->
pRollu
pFuncs
);
break
;
}
case
QUERY_NODE_INDEX_OPTIONS
:
{
SIndexOptions
*
p
Stmt
=
(
SIndexOptions
*
)
pNode
;
nodesDestroyList
(
p
Stmt
->
pFuncs
);
nodesDestroyNode
(
p
Stmt
->
pInterval
);
nodesDestroyNode
(
p
Stmt
->
pOffset
);
nodesDestroyNode
(
p
Stmt
->
pSliding
);
SIndexOptions
*
p
Options
=
(
SIndexOptions
*
)
pNode
;
nodesDestroyList
(
p
Options
->
pFuncs
);
nodesDestroyNode
(
p
Options
->
pInterval
);
nodesDestroyNode
(
p
Options
->
pOffset
);
nodesDestroyNode
(
p
Options
->
pSliding
);
break
;
}
case
QUERY_NODE_SET_OPERATOR
:
{
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
ccfcbba6
...
...
@@ -36,8 +36,7 @@ typedef struct SAstCreateContext {
}
SAstCreateContext
;
typedef
enum
EDatabaseOptionType
{
DB_OPTION_BLOCKS
=
1
,
DB_OPTION_CACHE
,
DB_OPTION_BUFFER
=
1
,
DB_OPTION_CACHELAST
,
DB_OPTION_COMP
,
DB_OPTION_DAYS
,
...
...
@@ -45,31 +44,30 @@ typedef enum EDatabaseOptionType {
DB_OPTION_MAXROWS
,
DB_OPTION_MINROWS
,
DB_OPTION_KEEP
,
DB_OPTION_PAGES
,
DB_OPTION_PAGESIZE
,
DB_OPTION_PRECISION
,
DB_OPTION_QUORUM
,
DB_OPTION_REPLICA
,
DB_OPTION_
TTL
,
DB_OPTION_
STRICT
,
DB_OPTION_WAL
,
DB_OPTION_VGROUPS
,
DB_OPTION_SINGLE_STABLE
,
DB_OPTION_STREAM_MODE
,
DB_OPTION_STRICT
,
DB_OPTION_RETENTIONS
}
EDatabaseOptionType
;
typedef
enum
ETableOptionType
{
TABLE_OPTION_KEEP
=
1
,
TABLE_OPTION_TTL
,
TABLE_OPTION_COMMENT
,
TABLE_OPTION_SMA
,
TABLE_OPTION_COMMENT
=
1
,
TABLE_OPTION_DELAY
,
TABLE_OPTION_FILE_FACTOR
,
TABLE_OPTION_DELAY
TABLE_OPTION_ROLLUP
,
TABLE_OPTION_TTL
,
TABLE_OPTION_SMA
}
ETableOptionType
;
typedef
struct
SAlterOption
{
int32_t
type
;
S
ValueNode
*
pV
al
;
SNodeList
*
pList
;
int32_t
type
;
S
Token
v
al
;
SNodeList
*
pList
;
}
SAlterOption
;
extern
SToken
nil_token
;
...
...
@@ -121,25 +119,29 @@ SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit);
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
);
SNode
*
createSetOperator
(
SAstCreateContext
*
pCxt
,
ESetOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
);
SNode
*
createDatabaseOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
setDatabaseAlterOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
);
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createDropDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pDbName
);
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
setTableAlterOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
);
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
,
SNodeList
*
pTags
,
SNode
*
pOptions
);
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
*
createDropDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pDbName
);
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createDefaultTableOptions
(
SAstCreateContext
*
pCxt
);
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
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNodeList
*
pTags
,
SNode
*
pOptions
);
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
*
createDropTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
SNode
*
createDropTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pTables
);
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
,
const
SToken
*
pColName
,
SDataType
dataType
);
SNode
*
createAlterTableDropCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
const
SToken
*
pColName
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
ccfcbba6
...
...
@@ -137,43 +137,41 @@ not_exists_opt(A) ::= .
exists_opt(A) ::= IF EXISTS. { A = true; }
exists_opt(A) ::= . { A = false; }
db_options(A) ::= . { A = createDatabaseOptions(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) 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). { ((SDatabaseOptions*)B)->pCachelast = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
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). { ((SDatabaseOptions*)B)->pDaysPerFile = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
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). { ((SDatabaseOptions*)B)->pFsyncPeriod = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
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). { ((SDatabaseOptions*)B)->pMinRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
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). { ((SDatabaseOptions*)B)->pKeep = C; A = B; }
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) QUORUM NK_INTEGER(C). { ((SDatabaseOptions*)B)->pQuorum = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
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) TTL NK_INTEGER(C). { ((SDatabaseOptions*)B)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
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) VGROUPS NK_INTEGER(C). { ((SDatabaseOptions*)B)->pNumOfVgroups = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; }
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) 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). { ((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 = createDatabaseOptions(pCxt); A = setDatabaseAlterOption(pCxt, A, &B); }
alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setDatabaseAlterOption(pCxt, B, &C); }
db_options(A) ::= . { A = createDefaultDatabaseOptions(pCxt); }
db_options(A) ::= db_options(B) BUFFER NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BUFFER, &C); }
db_options(A) ::= db_options(B) CACHELAST NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHELAST, &C); }
db_options(A) ::= db_options(B) COMP NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_COMP, &C); }
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_VARIABLE(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); }
db_options(A) ::= db_options(B) FSYNC NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_FSYNC, &C); }
db_options(A) ::= db_options(B) MAXROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MAXROWS, &C); }
db_options(A) ::= db_options(B) MINROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MINROWS, &C); }
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 variable_list(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP, C); }
db_options(A) ::= db_options(B) PAGES NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_PAGES, &C); }
db_options(A) ::= db_options(B) PAGESIZE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_PAGESIZE, &C); }
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). { A = setDatabaseOption(pCxt, B, DB_OPTION_REPLICA, &C); }
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). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL, &C); }
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). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLE_STABLE, &C); }
db_options(A) ::= db_options(B) RETENTIONS retention_list(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_RETENTIONS, C); }
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); }
%type alter_db_option { SAlterOption }
%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) ::= FSYNC NK_INTEGER(B). { A.type = DB_OPTION_FSYNC; 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) ::= 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 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) ::= QUORUM NK_INTEGER(B). { A.type = DB_OPTION_QUORUM; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &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) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
alter_db_option(A) ::= STRICT NK_INTEGER(B). { A.type = DB_OPTION_STRICT; 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) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; }
alter_db_option(A) ::= STRICT NK_INTEGER(B). { A.type = DB_OPTION_STRICT; A.val = B; }
alter_db_option(A) ::= WAL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
%type integer_list { SNodeList* }
%destructor integer_list { nodesDestroyList($$); }
...
...
@@ -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 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) ::=
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); }
...
...
@@ -229,7 +227,7 @@ multi_create_clause(A) ::= multi_create_clause(B) create_subtable_clause(C).
create_subtable_clause(A) ::=
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* }
%destructor multi_drop_clause { nodesDestroyList($$); }
...
...
@@ -289,25 +287,21 @@ tags_def_opt(A) ::= tags_def(B).
%destructor tags_def { nodesDestroyList($$); }
tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. { A = B; }
table_options(A) ::= . { A = createTableOptions(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) KEEP integer_list(C). { ((STableOptions*)B)->pKeep = C; A = B; }
table_options(A) ::= table_options(B) KEEP variable_list(C). { ((STableOptions*)B)->pKeep = C; A = B; }
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) SMA NK_LP col_name_list(C) NK_RP. { ((STableOptions*)B)->pSma = C; A = B; }
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) 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; }
table_options(A) ::= . { A = createDefaultTableOptions(pCxt); }
table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
table_options(A) ::= table_options(B) DELAY NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_DELAY, &C); }
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) ROLLUP NK_LP func_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_ROLLUP, C); }
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_SMA, C); }
alter_table_options(A) ::= alter_table_option(B). { A = create
TableOptions(pCxt); A = setTableAlterOption(pCxt, A, &B
); }
alter_table_options(A) ::= alter_table_options(B) alter_table_option(C). { A = setTable
AlterOption(pCxt, B, &C
); }
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
Option(pCxt, B, C.type, &C.val
); }
%type alter_table_option { SAlterOption }
%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) ::= KEEP integer_list(B). { A.type = TABLE_OPTION_KEEP; A.pList = 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); }
alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.val = B; }
alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.val = B; }
%type col_name_list { SNodeList* }
%destructor col_name_list { nodesDestroyList($$); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
ccfcbba6
...
...
@@ -44,7 +44,13 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
pCxt
->
notSupport
=
false
;
pCxt
->
valid
=
true
;
pCxt
->
pRootNode
=
NULL
;
pCxt
->
placeholderNo
=
1
;
pCxt
->
placeholderNo
=
0
;
}
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
)
{
...
...
@@ -309,7 +315,7 @@ SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLitera
CHECK_OUT_OF_MEM
(
val
);
val
->
literal
=
strndup
(
pLiteral
->
z
,
pLiteral
->
n
);
CHECK_OUT_OF_MEM
(
val
->
literal
);
val
->
placeholderNo
=
pCxt
->
placeholderNo
++
;
val
->
placeholderNo
=
++
pCxt
->
placeholderNo
;
return
(
SNode
*
)
val
;
}
...
...
@@ -374,6 +380,11 @@ SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType d
CHECK_OUT_OF_MEM
(
func
);
strcpy
(
func
->
functionName
,
"cast"
);
func
->
node
.
resType
=
dt
;
if
(
TSDB_DATA_TYPE_BINARY
==
dt
.
type
)
{
func
->
node
.
resType
.
bytes
+=
2
;
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
dt
.
type
)
{
func
->
node
.
resType
.
bytes
=
func
->
node
.
resType
.
bytes
*
TSDB_NCHAR_SIZE
+
2
;
}
nodesListMakeAppend
(
&
func
->
pParameterList
,
pExpr
);
return
(
SNode
*
)
func
;
}
...
...
@@ -604,64 +615,113 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode*
return
(
SNode
*
)
setOp
;
}
SNode
*
createDatabaseOptions
(
SAstCreateContext
*
pCxt
)
{
SNode
*
createD
efaultD
atabaseOptions
(
SAstCreateContext
*
pCxt
)
{
SDatabaseOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_DATABASE_OPTIONS
);
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
;
}
SNode
*
setDatabaseAlterOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
)
{
switch
(
pAlterOption
->
type
)
{
case
DB_OPTION_BLOCKS
:
((
SDatabaseOptions
*
)
pOptions
)
->
pNumOfBlocks
=
pAlterOption
->
pVal
;
break
;
case
DB_OPTION_CACHE
:
((
SDatabaseOptions
*
)
pOptions
)
->
pCacheBlockSize
=
pAlterOption
->
pVal
;
SNode
*
createAlterDatabaseOptions
(
SAstCreateContext
*
pCxt
)
{
SDatabaseOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_DATABASE_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
buffer
=
-
1
;
pOptions
->
cachelast
=
-
1
;
pOptions
->
compressionLevel
=
-
1
;
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
;
case
DB_OPTION_CACHELAST
:
((
SDatabaseOptions
*
)
pOptions
)
->
pCachelast
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
cachelast
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
case
DB_OPTION_COMP
:
((
SDatabaseOptions
*
)
pOptions
)
->
pCompressionLevel
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
compressionLevel
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
case
DB_OPTION_DAYS
:
((
SDatabaseOptions
*
)
pOptions
)
->
pDaysPerFile
=
pAlterOption
->
pVal
;
case
DB_OPTION_DAYS
:
{
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
;
}
case
DB_OPTION_FSYNC
:
((
SDatabaseOptions
*
)
pOptions
)
->
pFsyncPeriod
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
fsyncPeriod
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
case
DB_OPTION_MAXROWS
:
((
SDatabaseOptions
*
)
pOptions
)
->
pMaxRowsPerBlock
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
maxRowsPerBlock
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
case
DB_OPTION_MINROWS
:
((
SDatabaseOptions
*
)
pOptions
)
->
pMinRowsPerBlock
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
minRowsPerBlock
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
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
;
case
DB_OPTION_PRECISION
:
((
SDatabaseOptions
*
)
pOptions
)
->
pPrecision
=
pAlterOption
->
pVal
;
copyStringFormStringToken
((
SToken
*
)
pVal
,
((
SDatabaseOptions
*
)
pOptions
)
->
precisionStr
,
sizeof
(((
SDatabaseOptions
*
)
pOptions
)
->
precisionStr
));
break
;
case
DB_OPTION_REPLICA
:
((
SDatabaseOptions
*
)
pOptions
)
->
pReplica
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
replica
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
case
DB_OPTION_
TTL
:
((
SDatabaseOptions
*
)
pOptions
)
->
pTtl
=
pAlterOption
->
pVal
;
case
DB_OPTION_
STRICT
:
((
SDatabaseOptions
*
)
pOptions
)
->
strict
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
case
DB_OPTION_WAL
:
((
SDatabaseOptions
*
)
pOptions
)
->
pWalLevel
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
walLevel
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
case
DB_OPTION_VGROUPS
:
((
SDatabaseOptions
*
)
pOptions
)
->
pNumOfVgroups
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
numOfVgroups
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
case
DB_OPTION_SINGLE_STABLE
:
((
SDatabaseOptions
*
)
pOptions
)
->
pSingleStable
=
pAlterOption
->
pVal
;
break
;
case
DB_OPTION_STREAM_MODE
:
((
SDatabaseOptions
*
)
pOptions
)
->
pStreamMode
=
pAlterOption
->
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
singleStable
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
break
;
case
DB_OPTION_RETENTIONS
:
((
SDatabaseOptions
*
)
pOptions
)
->
pRetentions
=
p
AlterOption
->
pList
;
((
SDatabaseOptions
*
)
pOptions
)
->
pRetentions
=
p
Val
;
break
;
default:
break
;
...
...
@@ -669,6 +729,17 @@ SNode* setDatabaseAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOp
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
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
))
{
return
NULL
;
...
...
@@ -703,31 +774,44 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode*
return
(
SNode
*
)
pStmt
;
}
SNode
*
createTableOptions
(
SAstCreateContext
*
pCxt
)
{
SNode
*
create
Default
TableOptions
(
SAstCreateContext
*
pCxt
)
{
STableOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_TABLE_OPTIONS
);
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
;
}
SNode
*
setTableAlterOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
)
{
switch
(
pAlterOption
->
type
)
{
case
TABLE_OPTION_KEEP
:
((
STableOptions
*
)
pOptions
)
->
pKeep
=
pAlterOption
->
pList
;
break
;
case
TABLE_OPTION_TTL
:
((
STableOptions
*
)
pOptions
)
->
pTtl
=
pAlterOption
->
pVal
;
break
;
SNode
*
createAlterTableOptions
(
SAstCreateContext
*
pCxt
)
{
STableOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_TABLE_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
delay
=
-
1
;
pOptions
->
filesFactor
=
-
1
;
pOptions
->
ttl
=
-
1
;
return
(
SNode
*
)
pOptions
;
}
SNode
*
setTableOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
ETableOptionType
type
,
void
*
pVal
)
{
switch
(
type
)
{
case
TABLE_OPTION_COMMENT
:
((
STableOptions
*
)
pOptions
)
->
pComments
=
pAlterOption
->
pVal
;
copyStringFormStringToken
((
SToken
*
)
pVal
,
((
STableOptions
*
)
pOptions
)
->
comment
,
sizeof
(((
STableOptions
*
)
pOptions
)
->
comment
));
break
;
case
TABLE_OPTION_
SMA
:
((
STableOptions
*
)
pOptions
)
->
pSma
=
pAlterOption
->
pList
;
case
TABLE_OPTION_
DELAY
:
((
STableOptions
*
)
pOptions
)
->
delay
=
strtol
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
)
;
break
;
case
TABLE_OPTION_FILE_FACTOR
:
((
STableOptions
*
)
pOptions
)
->
pFilesFactor
=
pAlterOption
->
pVal
;
((
STableOptions
*
)
pOptions
)
->
filesFactor
=
strtod
(((
SToken
*
)
pVal
)
->
z
,
NULL
)
;
break
;
case
TABLE_OPTION_DELAY
:
((
STableOptions
*
)
pOptions
)
->
pDelay
=
pAlterOption
->
pVal
;
case
TABLE_OPTION_ROLLUP
:
((
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
;
default:
break
;
...
...
@@ -778,7 +862,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode*
}
SNode
*
createCreateSubTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNode
*
pUseRealTable
,
SNodeList
*
pSpecificTags
,
SNodeList
*
pValsOfTags
)
{
SNodeList
*
pSpecificTags
,
SNodeList
*
pValsOfTags
,
SNode
*
pOptions
)
{
if
(
NULL
==
pRealTable
)
{
return
NULL
;
}
...
...
@@ -833,7 +917,7 @@ SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, S
return
(
SNode
*
)
pStmt
;
}
SNode
*
createAlterTable
Option
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
SNode
*
pOptions
)
{
SNode
*
createAlterTable
ModifyOptions
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
SNode
*
pOptions
)
{
if
(
NULL
==
pRealTable
)
{
return
NULL
;
}
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
ccfcbba6
...
...
@@ -80,6 +80,7 @@ abort_parse:
return
TSDB_CODE_OUT_OF_MEMORY
;
}
(
*
pQuery
)
->
pRoot
=
cxt
.
pRootNode
;
(
*
pQuery
)
->
placeholderNum
=
cxt
.
placeholderNo
;
}
return
cxt
.
valid
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_FAILED
;
}
source/libs/parser/src/parInsert.c
浏览文件 @
ccfcbba6
...
...
@@ -937,6 +937,11 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks,
}
*
gotRow
=
true
;
#ifdef TD_DEBUG_PRINT_ROW
STSchema
*
pSTSchema
=
tdGetSTSChemaFromSSChema
(
&
schema
,
spd
->
numOfCols
);
tdSRowPrint
(
row
,
pSTSchema
,
__func__
);
taosMemoryFree
(
pSTSchema
);
#endif
}
// *len = pBuilder->extendedRowSize;
...
...
@@ -1328,10 +1333,6 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_MULTI_BIND *bind, char *msgBuf, in
for
(
int
c
=
0
;
c
<
spd
->
numOfBound
;
++
c
)
{
SSchema
*
pColSchema
=
&
pSchema
[
spd
->
boundColumns
[
c
]
-
1
];
if
(
bind
[
c
].
buffer_type
!=
pColSchema
->
type
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"column type mis-match with buffer type"
);
}
if
(
bind
[
c
].
num
!=
rowNum
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"row number in each bind param should be the same"
);
}
...
...
@@ -1346,6 +1347,10 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_MULTI_BIND *bind, char *msgBuf, in
CHECK_CODE
(
MemRowAppend
(
&
pBuf
,
NULL
,
0
,
&
param
));
}
else
{
if
(
bind
[
c
].
buffer_type
!=
pColSchema
->
type
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"column type mis-match with buffer type"
);
}
int32_t
colLen
=
pColSchema
->
bytes
;
if
(
IS_VAR_DATA_TYPE
(
pColSchema
->
type
))
{
colLen
=
bind
[
c
].
length
[
r
];
...
...
@@ -1359,7 +1364,6 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_MULTI_BIND *bind, char *msgBuf, in
checkTimestamp
(
pDataBlock
,
(
const
char
*
)
&
tsKey
);
}
}
// set the null value for the columns that do not assign values
if
((
spd
->
numOfBound
<
spd
->
numOfCols
)
&&
TD_IS_TP_ROW
(
row
))
{
for
(
int32_t
i
=
0
;
i
<
spd
->
numOfCols
;
++
i
)
{
...
...
@@ -1369,6 +1373,11 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_MULTI_BIND *bind, char *msgBuf, in
}
}
}
#ifdef TD_DEBUG_PRINT_ROW
STSchema
*
pSTSchema
=
tdGetSTSChemaFromSSChema
(
&
pSchema
,
spd
->
numOfCols
);
tdSRowPrint
(
row
,
pSTSchema
,
__func__
);
taosMemoryFree
(
pSTSchema
);
#endif
pDataBlock
->
size
+=
extendedRowSize
;
}
...
...
@@ -1447,6 +1456,14 @@ int32_t qBindStmtSingleColValue(void *pBlock, TAOS_MULTI_BIND *bind, char *msgBu
}
}
}
#ifdef TD_DEBUG_PRINT_ROW
if
(
rowEnd
)
{
STSchema
*
pSTSchema
=
tdGetSTSChemaFromSSChema
(
&
pSchema
,
spd
->
numOfCols
);
tdSRowPrint
(
row
,
pSTSchema
,
__func__
);
taosMemoryFree
(
pSTSchema
);
}
#endif
}
if
(
rowEnd
)
{
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
ccfcbba6
...
...
@@ -43,7 +43,7 @@ static SKeyword keywordTable[] = {
{
"BETWEEN"
,
TK_BETWEEN
},
{
"BINARY"
,
TK_BINARY
},
{
"BIGINT"
,
TK_BIGINT
},
{
"BLOCKS"
,
TK_BLOCKS
},
//
{"BLOCKS", TK_BLOCKS},
{
"BNODE"
,
TK_BNODE
},
{
"BNODES"
,
TK_BNODES
},
{
"BOOL"
,
TK_BOOL
},
...
...
@@ -142,7 +142,7 @@ static SKeyword keywordTable[] = {
{
"QTIME"
,
TK_QTIME
},
{
"QUERIES"
,
TK_QUERIES
},
{
"QUERY"
,
TK_QUERY
},
{
"QUORUM"
,
TK_QUORUM
},
//
{"QUORUM", TK_QUORUM},
{
"RATIO"
,
TK_RATIO
},
{
"REPLICA"
,
TK_REPLICA
},
{
"RESET"
,
TK_RESET
},
...
...
@@ -169,7 +169,7 @@ static SKeyword keywordTable[] = {
{
"STORAGE"
,
TK_STORAGE
},
{
"STREAM"
,
TK_STREAM
},
{
"STREAMS"
,
TK_STREAMS
},
{
"STREAM_MODE"
,
TK_STREAM_MODE
},
//
{"STREAM_MODE", TK_STREAM_MODE},
{
"STRICT"
,
TK_STRICT
},
{
"SYNCDB"
,
TK_SYNCDB
},
{
"TABLE"
,
TK_TABLE
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
ccfcbba6
此差异已折叠。
点击以展开。
source/libs/parser/src/parUtil.c
浏览文件 @
ccfcbba6
...
...
@@ -68,8 +68,6 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"Invalid option %s: %s"
;
case
TSDB_CODE_PAR_INVALID_ENUM_OPTION
:
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
:
return
"Invalid number of keep options"
;
case
TSDB_CODE_PAR_INVALID_KEEP_ORDER
:
...
...
@@ -89,7 +87,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
case
TSDB_CODE_PAR_INVALID_OPTION_UNIT
:
return
"Invalid option %s unit: %c, only m, h, d allowed"
;
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
:
return
"Aggregate functions do not support nesting"
;
case
TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE
:
...
...
source/libs/parser/src/sql.c
浏览文件 @
ccfcbba6
此差异已折叠。
点击以展开。
source/libs/parser/test/par
serTestUtil.h
→
source/libs/parser/test/par
AlterTest.cpp
浏览文件 @
ccfcbba6
...
...
@@ -13,9 +13,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PARSER_TEST_UTIL_H
#define PARSER_TEST_UTIL_H
#include "parTestUtil.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
浏览文件 @
ccfcbba6
文件已移动
source/libs/parser/test/par
ser
TestMain.cpp
→
source/libs/parser/test/parTestMain.cpp
浏览文件 @
ccfcbba6
...
...
@@ -13,23 +13,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <getopt.h>
#include <gtest/gtest.h>
#ifdef WINDOWS
#define TD_USE_WINSOCK
#endif
#include "functionMgt.h"
#include "mockCatalog.h"
#include "os.h"
#include "parTestUtil.h"
#include "parToken.h"
#include "parserTestUtil.h"
bool
g_isDump
=
false
;
class
ParserEnv
:
public
testing
::
Environment
{
public:
...
...
source/libs/parser/test/parTestUtil.cpp
0 → 100644
浏览文件 @
ccfcbba6
/*
* 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
浏览文件 @
ccfcbba6
/*
* 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
浏览文件 @
ccfcbba6
...
...
@@ -19,7 +19,7 @@
#include <gtest/gtest.h>
#include "parInt.h"
#include "par
ser
TestUtil.h"
#include "parTestUtil.h"
using
namespace
std
;
using
namespace
testing
;
...
...
source/libs/planner/src/planner.c
浏览文件 @
ccfcbba6
...
...
@@ -19,26 +19,23 @@
typedef
struct
SCollectPlaceholderValuesCxt
{
int32_t
errCode
;
S
NodeList
*
pValues
;
S
Array
*
pValues
;
}
SCollectPlaceholderValuesCxt
;
static
EDealRes
collectPlaceholderValuesImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
&&
((
SValueNode
*
)
pNode
)
->
placeholderNo
>
0
)
{
SCollectPlaceholderValuesCxt
*
pCxt
=
pContext
;
pCxt
->
errCode
=
nodesListMakeAppend
(
&
pCxt
->
pValues
,
pNode
);
taosArrayInsert
(
pCxt
->
pValues
,
((
SValueNode
*
)
pNode
)
->
placeholderNo
-
1
,
&
pNode
);
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
;
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
collectPlaceholderValues
(
SPlanContext
*
pCxt
,
SQueryPlan
*
pPlan
)
{
SCollectPlaceholderValuesCxt
cxt
=
{.
errCode
=
TSDB_CODE_SUCCESS
,
.
pValues
=
NULL
};
pPlan
->
pPlaceholderValues
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
POINTER_BYTES
);
SCollectPlaceholderValuesCxt
cxt
=
{.
errCode
=
TSDB_CODE_SUCCESS
,
.
pValues
=
pPlan
->
pPlaceholderValues
};
nodesWalkPhysiPlan
((
SNode
*
)
pPlan
,
collectPlaceholderValuesImpl
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
==
cxt
.
errCode
)
{
pPlan
->
pPlaceholderValues
=
cxt
.
pValues
;
}
else
{
nodesDestroyList
(
cxt
.
pValues
);
}
return
cxt
.
errCode
;
}
...
...
@@ -60,7 +57,7 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createPhysiPlan
(
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
pCxt
->
isStmtQuery
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
pCxt
->
placeholderNum
>
0
)
{
code
=
collectPlaceholderValues
(
pCxt
,
*
pPlan
);
}
...
...
@@ -108,7 +105,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
return
TSDB_CODE_SUCCESS
;
}
pVal
->
node
.
resType
.
type
=
pParam
->
buffer_type
;
pVal
->
node
.
resType
.
bytes
=
*
(
pParam
->
length
)
;
pVal
->
node
.
resType
.
bytes
=
NULL
!=
pParam
->
length
?
*
(
pParam
->
length
)
:
tDataTypes
[
pParam
->
buffer_type
].
bytes
;
switch
(
pParam
->
buffer_type
)
{
case
TSDB_DATA_TYPE_BOOL
:
pVal
->
datum
.
b
=
*
((
bool
*
)
pParam
->
buffer
);
...
...
@@ -133,6 +130,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
break
;
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
pVal
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
+
1
);
if
(
NULL
==
pVal
->
datum
.
p
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -155,7 +153,6 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
case
TSDB_DATA_TYPE_UBIGINT
:
pVal
->
datum
.
u
=
*
((
uint64_t
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_DECIMAL
:
case
TSDB_DATA_TYPE_BLOB
:
...
...
@@ -168,18 +165,35 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
qStmtBindParam
(
SQueryPlan
*
pPlan
,
TAOS_MULTI_BIND
*
pParams
,
int32_t
colIdx
)
{
if
(
colIdx
<
0
)
{
int32_t
index
=
0
;
SNode
*
pNode
=
NULL
;
static
EDealRes
updatePlanQueryId
(
SNode
*
pNode
,
void
*
pContext
)
{
int64_t
queryId
=
*
(
uint64_t
*
)
pContext
;
if
(
QUERY_NODE_PHYSICAL_PLAN
==
nodeType
(
pNode
))
{
SQueryPlan
*
planNode
=
(
SQueryPlan
*
)
pNode
;
planNode
->
queryId
=
queryId
;
}
else
if
(
QUERY_NODE_PHYSICAL_SUBPLAN
==
nodeType
(
pNode
))
{
SSubplan
*
subplanNode
=
(
SSubplan
*
)
pNode
;
subplanNode
->
id
.
queryId
=
queryId
;
}
FOREACH
(
pNode
,
pPlan
->
pPlaceholderValues
)
{
setValueByBindParam
((
SValueNode
*
)
pNode
,
pParams
+
index
);
++
index
;
return
DEAL_RES_CONTINUE
;
}
int32_t
qStmtBindParam
(
SQueryPlan
*
pPlan
,
TAOS_MULTI_BIND
*
pParams
,
int32_t
colIdx
,
uint64_t
queryId
)
{
int32_t
size
=
taosArrayGetSize
(
pPlan
->
pPlaceholderValues
);
if
(
colIdx
<
0
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
setValueByBindParam
((
SValueNode
*
)
taosArrayGetP
(
pPlan
->
pPlaceholderValues
,
i
),
pParams
+
i
);
}
}
else
{
setValueByBindParam
((
SValueNode
*
)
nodesListGetNode
(
pPlan
->
pPlaceholderValues
,
colIdx
),
pParams
);
setValueByBindParam
((
SValueNode
*
)
taosArrayGetP
(
pPlan
->
pPlaceholderValues
,
colIdx
),
pParams
);
}
if
(
colIdx
<
0
||
((
colIdx
+
1
)
==
size
))
{
nodesWalkPhysiPlan
((
SNode
*
)
pPlan
,
updatePlanQueryId
,
&
queryId
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/planner/test/planTestUtil.cpp
浏览文件 @
ccfcbba6
...
...
@@ -14,9 +14,9 @@
*/
#include "planTestUtil.h"
#include <array>
#include <algorithm>
#include <array>
#include "cmdnodes.h"
#include "parser.h"
...
...
source/libs/scalar/inc/sclInt.h
浏览文件 @
ccfcbba6
...
...
@@ -34,7 +34,7 @@ typedef struct SScalarCtx {
#define SCL_IS_CONST_NODE(_node) ((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type))
#define SCL_IS_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList)
#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type))
#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type)
&& (((SValueNode *)_node)->placeholderNo <= 0)
)
#define sclFatal(...) qFatal(__VA_ARGS__)
#define sclError(...) qError(__VA_ARGS__)
...
...
source/libs/scalar/src/filter.c
浏览文件 @
ccfcbba6
...
...
@@ -3541,11 +3541,16 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
}
if
(
QUERY_NODE_VALUE
==
nodeType
(
*
pNode
))
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
*
pNode
;
if
(
valueNode
->
placeholderNo
>=
1
)
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
}
if
(
!
FILTER_GET_FLAG
(
stat
->
info
->
options
,
FLT_OPTION_TIMESTAMP
))
{
return
DEAL_RES_CONTINUE
;
}
SValueNode
*
valueNode
=
(
SValueNode
*
)
*
pNode
;
if
(
TSDB_DATA_TYPE_BINARY
!=
valueNode
->
node
.
resType
.
type
&&
TSDB_DATA_TYPE_NCHAR
!=
valueNode
->
node
.
resType
.
type
)
{
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -3587,7 +3592,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
if
(
node
->
opType
==
OP_TYPE_NOT_IN
||
node
->
opType
==
OP_TYPE_NOT_LIKE
||
node
->
opType
>
OP_TYPE_IS_NOT_NULL
)
{
if
(
node
->
opType
==
OP_TYPE_NOT_IN
||
node
->
opType
==
OP_TYPE_NOT_LIKE
||
node
->
opType
>
OP_TYPE_IS_NOT_NULL
||
node
->
opType
==
OP_TYPE_NOT_EQUAL
)
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
}
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
ccfcbba6
...
...
@@ -505,6 +505,7 @@ EDealRes sclRewriteBasedOnOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opT
}
res
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
res
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
res
->
datum
.
b
=
false
;
nodesDestroyNode
(
*
pNode
);
...
...
@@ -520,14 +521,14 @@ EDealRes sclRewriteOperatorForNullValue(SNode** pNode, SScalarCtx *ctx) {
if
(
node
->
pLeft
&&
(
QUERY_NODE_VALUE
==
nodeType
(
node
->
pLeft
)))
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
node
->
pLeft
;
if
(
TSDB_DATA_TYPE_NULL
==
valueNode
->
node
.
resType
.
type
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
if
(
SCL_IS_NULL_VALUE_NODE
(
valueNode
)
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
return
sclRewriteBasedOnOptr
(
pNode
,
ctx
,
node
->
opType
);
}
}
if
(
node
->
pRight
&&
(
QUERY_NODE_VALUE
==
nodeType
(
node
->
pRight
)))
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
node
->
pRight
;
if
(
TSDB_DATA_TYPE_NULL
==
valueNode
->
node
.
resType
.
type
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
if
(
SCL_IS_NULL_VALUE_NODE
(
valueNode
)
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
return
sclRewriteBasedOnOptr
(
pNode
,
ctx
,
node
->
opType
);
}
}
...
...
@@ -589,7 +590,10 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
if
(
colDataIsNull_s
(
output
.
columnData
,
0
))
{
res
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_NULL
;
}
else
{
res
->
node
.
resType
=
node
->
node
.
resType
;
res
->
node
.
resType
.
type
=
output
.
columnData
->
info
.
type
;
res
->
node
.
resType
.
bytes
=
output
.
columnData
->
info
.
bytes
;
res
->
node
.
resType
.
scale
=
output
.
columnData
->
info
.
scale
;
res
->
node
.
resType
.
precision
=
output
.
columnData
->
info
.
precision
;
int32_t
type
=
output
.
columnData
->
info
.
type
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
res
->
datum
.
p
=
taosMemoryCalloc
(
res
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
+
1
,
1
);
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
ccfcbba6
...
...
@@ -658,11 +658,6 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
int16_t
outputType
=
GET_PARAM_TYPE
(
&
pOutput
[
0
]);
int64_t
outputLen
=
GET_PARAM_BYTES
(
&
pOutput
[
0
]);
if
(
IS_VAR_DATA_TYPE
(
outputType
))
{
int32_t
factor
=
(
TSDB_DATA_TYPE_NCHAR
==
outputType
)
?
TSDB_NCHAR_SIZE
:
1
;
outputLen
=
outputLen
*
factor
+
VARSTR_HEADER_SIZE
;
}
char
*
outputBuf
=
taosMemoryCalloc
(
outputLen
*
pInput
[
0
].
numOfRows
,
1
);
char
*
output
=
outputBuf
;
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
ccfcbba6
...
...
@@ -1058,36 +1058,36 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
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
)
{
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
);
continue
;
// TODO set null or ignore
continue
;
}
*
output
=
getVectorDoubleValueFnLeft
(
LEFT_COL
,
i
)
/
getVectorDoubleValueFnRight
(
RIGHT_COL
,
i
);
/
getVectorDoubleValueFnRight
(
RIGHT_COL
,
i
);
}
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
if
(
colDataIsNull_s
(
pLeftCol
,
0
))
{
// Set pLeft->numOfRows NULL value
colDataAppendNNULL
(
pOutputCol
,
0
,
pRight
->
numOfRows
);
}
else
{
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
);
continue
;
// TODO set null or ignore
continue
;
}
*
output
=
getVectorDoubleValueFnLeft
(
LEFT_COL
,
0
)
/
getVectorDoubleValueFnRight
(
RIGHT_COL
,
i
);
}
}
}
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
);
}
else
{
for
(;
i
>=
0
&&
i
<
pLeft
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
if
(
colDataIsNull_s
(
pLeftCol
,
i
))
{
colDataAppendNULL
(
pOutputCol
,
i
);
continue
;
// TODO set null or ignore
continue
;
}
*
output
=
getVectorDoubleValueFnLeft
(
LEFT_COL
,
i
)
/
getVectorDoubleValueFnRight
(
RIGHT_COL
,
0
);
...
...
@@ -1195,9 +1195,10 @@ void vectorMathMinus(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pO
for
(;
i
<
pLeft
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
if
(
colDataIsNull_s
(
pLeft
->
columnData
,
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
);
...
...
source/libs/transport/inc/transComm.h
浏览文件 @
ccfcbba6
...
...
@@ -28,6 +28,7 @@ extern "C" {
#include "taoserror.h"
#include "tglobal.h"
#include "thash.h"
#include "theap.h"
#include "tidpool.h"
#include "tmd5.h"
#include "tmempool.h"
...
...
@@ -328,10 +329,39 @@ void transQueueClear(STransQueue* queue);
*/
void
transQueueDestroy
(
STransQueue
*
queue
);
/*
* delay queue based on uv loop and uv timer, and only used in retry
*/
typedef
struct
STaskArg
{
void
*
param1
;
void
*
param2
;
}
STaskArg
;
typedef
struct
SDelayTask
{
void
(
*
func
)(
void
*
arg
);
void
*
arg
;
uint64_t
execTime
;
HeapNode
node
;
}
SDelayTask
;
typedef
struct
SDelayQueue
{
uv_timer_t
*
timer
;
Heap
*
heap
;
uv_loop_t
*
loop
;
void
(
*
free
)(
void
*
arg
);
}
SDelayQueue
;
int
transCreateDelayQueue
(
uv_loop_t
*
loop
,
SDelayQueue
**
queue
);
void
transDestroyDelayQueue
(
SDelayQueue
*
queue
);
int
transPutTaskToDelayQueue
(
SDelayQueue
*
queue
,
void
(
*
func
)(
void
*
arg
),
void
*
arg
,
uint64_t
timeoutMs
);
/*
* init global func
*/
void
transThreadOnce
();
#ifdef __cplusplus
}
#endif
...
...
source/libs/transport/src/transCli.c
浏览文件 @
ccfcbba6
...
...
@@ -60,10 +60,10 @@ typedef struct SCliThrdObj {
// msg queue
queue
msg
;
TdThreadMutex
msgMtx
;
uint64_t
nextTimeout
;
// next timeout
void
*
pTransInst
;
//
bool
quit
;
SDelayQueue
*
delayQueue
;
uint64_t
nextTimeout
;
// next timeout
void
*
pTransInst
;
//
bool
quit
;
}
SCliThrdObj
;
typedef
struct
SCliObj
{
...
...
@@ -161,8 +161,7 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
transUnrefCliHandle(conn); \
} \
if (T_REF_VAL_GET(conn) == 1) { \
SCliThrdObj* thrd = conn->hostThrd; \
addConnToPool(thrd->pool, conn); \
transUnrefCliHandle(conn); \
} \
destroyCmsg(pMsg); \
return; \
...
...
@@ -838,12 +837,13 @@ static SCliThrdObj* createThrdObj() {
uv_loop_init
(
pThrd
->
loop
);
pThrd
->
asyncPool
=
transCreateAsyncPool
(
pThrd
->
loop
,
5
,
pThrd
,
cliAsyncCb
);
uv_timer_init
(
pThrd
->
loop
,
&
pThrd
->
timer
);
pThrd
->
timer
.
data
=
pThrd
;
pThrd
->
pool
=
createConnPool
(
4
);
transCreateDelayQueue
(
pThrd
->
loop
,
&
pThrd
->
delayQueue
);
pThrd
->
quit
=
false
;
return
pThrd
;
}
...
...
@@ -851,12 +851,13 @@ static void destroyThrdObj(SCliThrdObj* pThrd) {
if
(
pThrd
==
NULL
)
{
return
;
}
taosThreadJoin
(
pThrd
->
thread
,
NULL
);
CLI_RELEASE_UV
(
pThrd
->
loop
);
taosThreadMutexDestroy
(
&
pThrd
->
msgMtx
);
transDestroyAsyncPool
(
pThrd
->
asyncPool
);
uv_timer_stop
(
&
pThrd
->
timer
);
transDestroyDelayQueue
(
pThrd
->
delayQueue
);
taosMemoryFree
(
pThrd
->
loop
);
taosMemoryFree
(
pThrd
);
}
...
...
@@ -885,6 +886,16 @@ int cliRBChoseIdx(STrans* pTransInst) {
}
return
index
%
pTransInst
->
numOfThreads
;
}
static
void
doDelayTask
(
void
*
param
)
{
STaskArg
*
arg
=
param
;
SCliMsg
*
pMsg
=
arg
->
param1
;
SCliThrdObj
*
pThrd
=
arg
->
param2
;
cliHandleReq
(
pMsg
,
pThrd
);
taosMemoryFree
(
arg
);
}
int
cliAppCb
(
SCliConn
*
pConn
,
STransMsg
*
pResp
,
SCliMsg
*
pMsg
)
{
SCliThrdObj
*
pThrd
=
pConn
->
hostThrd
;
STrans
*
pTransInst
=
pThrd
->
pTransInst
;
...
...
@@ -908,7 +919,12 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
if
(
msgType
==
TDMT_MND_CONNECT
&&
pResp
->
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
)
{
if
(
pCtx
->
retryCount
<
pEpSet
->
numOfEps
)
{
pEpSet
->
inUse
=
(
++
pEpSet
->
inUse
)
%
pEpSet
->
numOfEps
;
cliHandleReq
(
pMsg
,
pThrd
);
STaskArg
*
arg
=
taosMemoryMalloc
(
sizeof
(
STaskArg
));
arg
->
param1
=
pMsg
;
arg
->
param2
=
pThrd
;
transPutTaskToDelayQueue
(
pThrd
->
delayQueue
,
doDelayTask
,
arg
,
TRANS_RETRY_INTERVAL
);
cliDestroy
((
uv_handle_t
*
)
pConn
->
stream
);
return
-
1
;
}
...
...
@@ -920,8 +936,11 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
tDeserializeSMEpSet
(
pResp
->
pCont
,
pResp
->
contLen
,
&
emsg
);
pCtx
->
epSet
=
emsg
.
epSet
;
}
cliHandleReq
(
pMsg
,
pThrd
);
// release pConn
STaskArg
*
arg
=
taosMemoryMalloc
(
sizeof
(
STaskArg
));
arg
->
param1
=
pMsg
;
arg
->
param2
=
pThrd
;
transPutTaskToDelayQueue
(
pThrd
->
delayQueue
,
doDelayTask
,
arg
,
TRANS_RETRY_INTERVAL
);
addConnToPool
(
pThrd
,
pConn
);
return
-
1
;
}
...
...
source/libs/transport/src/transComm.c
浏览文件 @
ccfcbba6
...
...
@@ -358,4 +358,85 @@ void transQueueDestroy(STransQueue* queue) {
transQueueClear
(
queue
);
taosArrayDestroy
(
queue
->
q
);
}
static
int32_t
timeCompare
(
const
HeapNode
*
a
,
const
HeapNode
*
b
)
{
SDelayTask
*
arg1
=
container_of
(
a
,
SDelayTask
,
node
);
SDelayTask
*
arg2
=
container_of
(
b
,
SDelayTask
,
node
);
if
(
arg1
->
execTime
>
arg2
->
execTime
)
{
return
0
;
}
else
{
return
1
;
}
}
static
void
transDelayQueueTimeout
(
uv_timer_t
*
timer
)
{
SDelayQueue
*
queue
=
timer
->
data
;
tTrace
(
"timer %p timeout"
,
timer
);
uint64_t
timeout
=
0
;
do
{
HeapNode
*
minNode
=
heapMin
(
queue
->
heap
);
if
(
minNode
==
NULL
)
break
;
SDelayTask
*
task
=
container_of
(
minNode
,
SDelayTask
,
node
);
if
(
task
->
execTime
<=
taosGetTimestampMs
())
{
heapRemove
(
queue
->
heap
,
minNode
);
task
->
func
(
task
->
arg
);
taosMemoryFree
(
task
);
timeout
=
0
;
}
else
{
timeout
=
task
->
execTime
-
taosGetTimestampMs
();
break
;
}
}
while
(
1
);
if
(
timeout
!=
0
)
{
uv_timer_start
(
queue
->
timer
,
transDelayQueueTimeout
,
timeout
,
0
);
}
}
int
transCreateDelayQueue
(
uv_loop_t
*
loop
,
SDelayQueue
**
queue
)
{
uv_timer_t
*
timer
=
taosMemoryCalloc
(
1
,
sizeof
(
uv_timer_t
));
uv_timer_init
(
loop
,
timer
);
Heap
*
heap
=
heapCreate
(
timeCompare
);
SDelayQueue
*
q
=
taosMemoryCalloc
(
1
,
sizeof
(
SDelayQueue
));
q
->
heap
=
heap
;
q
->
timer
=
timer
;
q
->
loop
=
loop
;
q
->
timer
->
data
=
q
;
*
queue
=
q
;
return
0
;
}
void
transDestroyDelayQueue
(
SDelayQueue
*
queue
)
{
taosMemoryFree
(
queue
->
timer
);
while
(
heapSize
(
queue
->
heap
)
>
0
)
{
HeapNode
*
minNode
=
heapMin
(
queue
->
heap
);
if
(
minNode
==
NULL
)
{
return
;
}
heapRemove
(
queue
->
heap
,
minNode
);
SDelayTask
*
task
=
container_of
(
minNode
,
SDelayTask
,
node
);
taosMemoryFree
(
task
);
}
heapDestroy
(
queue
->
heap
);
taosMemoryFree
(
queue
);
}
int
transPutTaskToDelayQueue
(
SDelayQueue
*
queue
,
void
(
*
func
)(
void
*
arg
),
void
*
arg
,
uint64_t
timeoutMs
)
{
SDelayTask
*
task
=
taosMemoryCalloc
(
1
,
sizeof
(
SDelayTask
));
task
->
func
=
func
;
task
->
arg
=
arg
;
task
->
execTime
=
taosGetTimestampMs
()
+
timeoutMs
;
tTrace
(
"timer %p put task into queue, timeoutMs: %"
PRIu64
""
,
queue
->
timer
,
timeoutMs
);
heapInsert
(
queue
->
heap
,
&
task
->
node
);
if
(
heapSize
(
queue
->
heap
)
==
1
)
{
uv_timer_start
(
queue
->
timer
,
transDelayQueueTimeout
,
timeoutMs
,
0
);
}
return
0
;
}
#endif
tests/script/api/batchprepare.c
浏览文件 @
ccfcbba6
此差异已折叠。
点击以展开。
tests/script/tsim/db/alter_option.sim
浏览文件 @
ccfcbba6
...
...
@@ -66,7 +66,7 @@ print ============= create database
# | REPLICA value [1 | 3]
# | 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
print rows: $rows
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
...
...
@@ -98,12 +98,12 @@ endi
if $data7_db != 1440000,1440000,1440000 then # keep
return -1
endi
if $data8_db != 3 then # cache
return -1
endi
if $data9_db != 7 then # blocks
return -1
endi
#
if $data8_db != 3 then # cache
#
return -1
#
endi
#
if $data9_db != 7 then # blocks
#
return -1
#
endi
if $data10_db != 10 then # minrows
return -1
endi
...
...
@@ -250,41 +250,41 @@ sql_error alter database db keep 0
sql_error alter database db keep -1
#sql_error alter database db keep 365001
print ============== modify cache
sql_error alter database db cache 12
sql_error alter database db cache 1
sql_error alter database db cache 60
sql_error alter database db cache 50
sql_error alter database db cache 20
sql_error alter database db cache 3
sql_error alter database db cache 129
sql_error alter database db cache 300
sql_error alter database db cache 0
sql_error alter database db cache -1
#
print ============== modify cache
#
sql_error alter database db cache 12
#
sql_error alter database db cache 1
#
sql_error alter database db cache 60
#
sql_error alter database db cache 50
#
sql_error alter database db cache 20
#
sql_error alter database db cache 3
#
sql_error alter database db cache 129
#
sql_error alter database db cache 300
#
sql_error alter database db cache 0
#
sql_error alter database db cache -1
print ============== modify blocks
sql alter database db blocks 3
sql show databases
print blocks $data9_db
if $data9_db != 3 then
return -1
endi
sql alter database db blocks 11
sql show databases
print blocks $data9_db
if $data9_db != 11 then
return -1
endi
#
print ============== modify blocks
#
sql alter database db blocks 3
#
sql show databases
#
print blocks $data9_db
#
if $data9_db != 3 then
#
return -1
#
endi
#
sql alter database db blocks 11
#
sql show databases
#
print blocks $data9_db
#
if $data9_db != 11 then
#
return -1
#
endi
sql alter database db blocks 40
sql alter database db blocks 30
sql alter database db blocks 20
sql alter database db blocks 10
sql_error alter database db blocks 2
sql_error alter database db blocks 1
sql_error alter database db blocks 0
sql_error alter database db blocks -1
sql_error alter database db blocks 10001
#
sql alter database db blocks 40
#
sql alter database db blocks 30
#
sql alter database db blocks 20
#
sql alter database db blocks 10
#
sql_error alter database db blocks 2
#
sql_error alter database db blocks 1
#
sql_error alter database db blocks 0
#
sql_error alter database db blocks -1
#
sql_error alter database db blocks 10001
print ============== modify minrows
sql_error alter database db minrows 8
...
...
tests/script/tsim/db/basic6.sim
浏览文件 @
ccfcbba6
...
...
@@ -15,7 +15,8 @@ $tb = $tbPrefix . $i
print =============== step1
# 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
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
...
...
@@ -40,12 +41,12 @@ endi
if $data27 != 3650,3650,3650 then
return -1
endi
if $data28 != 32 then
return -1
endi
if $data29 != 12 then
return -1
endi
#
if $data28 != 32 then
#
return -1
#
endi
#
if $data29 != 12 then
#
return -1
#
endi
print =============== step2
sql_error create database $db
...
...
tests/script/tsim/db/create_all_options.sim
浏览文件 @
ccfcbba6
...
...
@@ -124,12 +124,12 @@ endi
if $data7_db != 5256000,5256000,5256000 then # keep
return -1
endi
if $data8_db != 16 then # cache
return -1
endi
if $data9_db != 6 then # blocks
return -1
endi
#
if $data8_db != 16 then # cache
#
return -1
#
endi
#
if $data9_db != 6 then # blocks
#
return -1
#
endi
if $data10_db != 100 then # minrows
return -1
endi
...
...
@@ -153,42 +153,42 @@ if $data16_db != ms then # precision
endi
sql drop database db
print ====> BLOCKS value [3~1000, default: 6]
sql create database db BLOCKS 3
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
if $data9_db != 3 then
return -1
endi
sql drop database db
#
print ====> BLOCKS value [3~1000, default: 6]
#
sql create database db BLOCKS 3
#
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
#
if $data9_db != 3 then
#
return -1
#
endi
#
sql drop database db
sql create database db BLOCKS 1000
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
if $data9_db != 1000 then
return -1
endi
sql drop database db
sql_error create database db BLOCKS 2
sql_error create database db BLOCKS 0
sql_error create database db BLOCKS -1
#
sql create database db BLOCKS 1000
#
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
#
if $data9_db != 1000 then
#
return -1
#
endi
#
sql drop database db
#
sql_error create database db BLOCKS 2
#
sql_error create database db BLOCKS 0
#
sql_error create database db BLOCKS -1
print ====> CACHE value [default: 16]
sql create database db CACHE 1
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
if $data8_db != 1 then
return -1
endi
sql drop database db
#
print ====> CACHE value [default: 16]
#
sql create database db CACHE 1
#
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
#
if $data8_db != 1 then
#
return -1
#
endi
#
sql drop database db
sql create database db CACHE 128
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
if $data8_db != 128 then
return -1
endi
sql drop database db
#
sql create database db CACHE 128
#
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
#
if $data8_db != 128 then
#
return -1
#
endi
#
sql drop database db
print ====> CACHELAST value [0, 1, 2, 3, default: 0]
sql create database db CACHELAST 1
...
...
@@ -387,24 +387,24 @@ sql_error create database db REPLICA 0
sql_error create database db REPLICA -1
sql_error create database db REPLICA 4
print ====> TTL value [1d ~ , default: 1]
sql create database db TTL 1
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 ====> TTL value [1d ~ , default: 1]
#
sql create database db TTL 1
#
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
#if $dataXX_db != 1 then
# return -1
#endi
sql drop database db
#
sql drop database db
sql create database db TTL 10
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
#
sql create database db TTL 10
#
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
#if $dataXX_db != 10 then
# return -1
#endi
sql drop database db
sql_error create database db TTL 0
sql_error create database db TTL -1
#
sql drop database db
#
sql_error create database db TTL 0
#
sql_error create database db TTL -1
print ====> WAL value [1 | 2, default: 1]
sql create database db WAL 2
...
...
@@ -465,24 +465,24 @@ sql drop database db
sql_error create database db SINGLE_STABLE 2
sql_error create database db SINGLE_STABLE -1
print ====> STREAM_MODE [0 | 1, default: ]
sql create database db STREAM_MODE 1
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 ====> STREAM_MODE [0 | 1, default: ]
#
sql create database db STREAM_MODE 1
#
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
#if $dataXXX_db != 1 then
# return -1
#endi
sql drop database db
#
sql drop database db
sql create database db STREAM_MODE 0
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
#
sql create database db STREAM_MODE 0
#
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
#if $dataXXX_db != 0 then
# return -1
#endi
sql drop database db
sql_error create database db STREAM_MODE 2
sql_error create database db STREAM_MODE -1
#
sql drop database db
#
sql_error create database db STREAM_MODE 2
#
sql_error create database db STREAM_MODE -1
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
...
...
tests/script/tsim/parser/fourArithmetic-basic.sim
浏览文件 @
ccfcbba6
...
...
@@ -94,7 +94,7 @@ endi
if $data01 != 10.000000000 then
return -1
endi
if $data02 !=
-nan
then
if $data02 !=
NULL
then
return -1
endi
if $data03 != -10.000000000 then
...
...
tests/system-test/0-others/taosShell.py
浏览文件 @
ccfcbba6
...
...
@@ -11,13 +11,15 @@ from util.sql import *
from
util.cases
import
*
from
util.dnodes
import
*
def
taos_command
(
key
,
value
,
expectString
,
cfgDir
,
sqlString
=
''
,
key1
=
''
,
value1
=
''
):
def
taos_command
(
buildPath
,
key
,
value
,
expectString
,
cfgDir
,
sqlString
=
''
,
key1
=
''
,
value1
=
''
):
if
len
(
key
)
==
0
:
tdLog
.
exit
(
"taos test key is null!"
)
taosCmd
=
buildPath
+
'/build/bin/taos '
if
len
(
cfgDir
)
!=
0
:
taosCmd
=
'taos -c '
+
cfgDir
+
' -'
+
key
taosCmd
=
taosCmd
+
'-c '
+
cfgDir
taosCmd
=
taosCmd
+
' -'
+
key
if
len
(
value
)
!=
0
:
if
key
==
'p'
:
taosCmd
=
taosCmd
+
value
...
...
@@ -134,7 +136,7 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"================================ parameter: -h"
)
newDbName
=
"dbh"
sqlString
=
'create database '
+
newDbName
+
';'
retCode
=
taos_command
(
"h"
,
keyDict
[
'h'
],
"taos>"
,
keyDict
[
'c'
],
sqlString
)
retCode
=
taos_command
(
buildPath
,
"h"
,
keyDict
[
'h'
],
"taos>"
,
keyDict
[
'c'
],
sqlString
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -h %s fail"
%
keyDict
[
'h'
])
else
:
...
...
@@ -157,7 +159,7 @@ class TDTestCase:
#keyDict['P'] = 6030
newDbName
=
"dbpp"
sqlString
=
'create database '
+
newDbName
+
';'
retCode
=
taos_command
(
"P"
,
keyDict
[
'P'
],
"taos>"
,
keyDict
[
'c'
],
sqlString
)
retCode
=
taos_command
(
buildPath
,
"P"
,
keyDict
[
'P'
],
"taos>"
,
keyDict
[
'c'
],
sqlString
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -P %s fail"
%
keyDict
[
'P'
])
else
:
...
...
@@ -173,7 +175,7 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"================================ parameter: -u"
)
newDbName
=
"dbu"
sqlString
=
'create database '
+
newDbName
+
';'
retCode
=
taos_command
(
"u"
,
keyDict
[
'u'
],
"taos>"
,
keyDict
[
'c'
],
sqlString
,
"p"
,
keyDict
[
'p'
])
retCode
=
taos_command
(
buildPath
,
"u"
,
keyDict
[
'u'
],
"taos>"
,
keyDict
[
'c'
],
sqlString
,
"p"
,
keyDict
[
'p'
])
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -u %s -p%s fail"
%
(
keyDict
[
'u'
],
keyDict
[
'p'
]))
else
:
...
...
@@ -188,12 +190,12 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"================================ parameter: -A"
)
newDbName
=
"dbaa"
retCode
,
retVal
=
taos_command
(
"p"
,
keyDict
[
'p'
],
"taos>"
,
keyDict
[
'c'
],
''
,
"A"
,
''
)
retCode
,
retVal
=
taos_command
(
buildPath
,
"p"
,
keyDict
[
'p'
],
"taos>"
,
keyDict
[
'c'
],
''
,
"A"
,
''
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -A fail"
)
sqlString
=
'create database '
+
newDbName
+
';'
retCode
=
taos_command
(
"u"
,
keyDict
[
'u'
],
"taos>"
,
keyDict
[
'c'
],
sqlString
,
'a'
,
retVal
)
retCode
=
taos_command
(
buildPath
,
"u"
,
keyDict
[
'u'
],
"taos>"
,
keyDict
[
'c'
],
sqlString
,
'a'
,
retVal
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -u %s -a %s"
%
(
keyDict
[
'u'
],
retVal
))
...
...
@@ -209,7 +211,7 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"================================ parameter: -s"
)
newDbName
=
"dbss"
keyDict
[
's'
]
=
"
\"
create database "
+
newDbName
+
"
\"
"
retCode
=
taos_command
(
"s"
,
keyDict
[
's'
],
"Query OK"
,
keyDict
[
'c'
],
''
,
''
,
''
)
retCode
=
taos_command
(
buildPath
,
"s"
,
keyDict
[
's'
],
"Query OK"
,
keyDict
[
'c'
],
''
,
''
,
''
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -s fail"
)
...
...
@@ -222,17 +224,17 @@ class TDTestCase:
tdLog
.
exit
(
"create db fail after taos -s %s fail"
%
(
keyDict
[
's'
]))
keyDict
[
's'
]
=
"
\"
create table "
+
newDbName
+
".stb (ts timestamp, c int) tags (t int)
\"
"
retCode
=
taos_command
(
"s"
,
keyDict
[
's'
],
"Query OK"
,
keyDict
[
'c'
],
''
,
''
,
''
)
retCode
=
taos_command
(
buildPath
,
"s"
,
keyDict
[
's'
],
"Query OK"
,
keyDict
[
'c'
],
''
,
''
,
''
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -s create table fail"
)
keyDict
[
's'
]
=
"
\"
create table "
+
newDbName
+
".ctb0 using "
+
newDbName
+
".stb tags (0) "
+
newDbName
+
".ctb1 using "
+
newDbName
+
".stb tags (1)
\"
"
retCode
=
taos_command
(
"s"
,
keyDict
[
's'
],
"Query OK"
,
keyDict
[
'c'
],
''
,
''
,
''
)
retCode
=
taos_command
(
buildPath
,
"s"
,
keyDict
[
's'
],
"Query OK"
,
keyDict
[
'c'
],
''
,
''
,
''
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -s create table fail"
)
keyDict
[
's'
]
=
"
\"
insert into "
+
newDbName
+
".ctb0 values('2021-04-01 08:00:00.000', 10)('2021-04-01 08:00:01.000', 20) "
+
newDbName
+
".ctb1 values('2021-04-01 08:00:00.000', 11)('2021-04-01 08:00:01.000', 21)
\"
"
retCode
=
taos_command
(
"s"
,
keyDict
[
's'
],
"Query OK"
,
keyDict
[
'c'
],
''
,
''
,
''
)
retCode
=
taos_command
(
buildPath
,
"s"
,
keyDict
[
's'
],
"Query OK"
,
keyDict
[
'c'
],
''
,
''
,
''
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -s insert data fail"
)
...
...
@@ -250,18 +252,18 @@ class TDTestCase:
tdSql
.
checkData
(
1
,
1
,
21
)
keyDict
[
's'
]
=
"
\"
select * from "
+
newDbName
+
".ctb0
\"
"
retCode
=
taos_command
(
"s"
,
keyDict
[
's'
],
"2021-04-01 08:00:01.000"
,
keyDict
[
'c'
],
''
,
''
,
''
)
retCode
=
taos_command
(
buildPath
,
"s"
,
keyDict
[
's'
],
"2021-04-01 08:00:01.000"
,
keyDict
[
'c'
],
''
,
''
,
''
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -r show fail"
)
tdLog
.
printNoPrefix
(
"================================ parameter: -r"
)
keyDict
[
's'
]
=
"
\"
select * from "
+
newDbName
+
".ctb0
\"
"
retCode
=
taos_command
(
"s"
,
keyDict
[
's'
],
"1617235200000"
,
keyDict
[
'c'
],
''
,
'r'
,
''
)
retCode
=
taos_command
(
buildPath
,
"s"
,
keyDict
[
's'
],
"1617235200000"
,
keyDict
[
'c'
],
''
,
'r'
,
''
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -r show fail"
)
keyDict
[
's'
]
=
"
\"
select * from "
+
newDbName
+
".ctb1
\"
"
retCode
=
taos_command
(
"s"
,
keyDict
[
's'
],
"1617235201000"
,
keyDict
[
'c'
],
''
,
'r'
,
''
)
retCode
=
taos_command
(
buildPath
,
"s"
,
keyDict
[
's'
],
"1617235201000"
,
keyDict
[
'c'
],
''
,
'r'
,
''
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -r show fail"
)
...
...
@@ -283,7 +285,7 @@ class TDTestCase:
os
.
system
(
sql5
)
keyDict
[
'f'
]
=
pwd
+
"/0-others/sql.txt"
retCode
=
taos_command
(
"f"
,
keyDict
[
'f'
],
'performance_schema'
,
keyDict
[
'c'
],
''
,
''
,
''
)
retCode
=
taos_command
(
buildPath
,
"f"
,
keyDict
[
'f'
],
'performance_schema'
,
keyDict
[
'c'
],
''
,
''
,
''
)
print
(
"============ ret code: "
,
retCode
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -s fail"
)
...
...
@@ -310,7 +312,7 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"================================ parameter: -C"
)
newDbName
=
"dbcc"
retCode
,
retVal
=
taos_command
(
"C"
,
keyDict
[
'C'
],
"buildinfo"
,
keyDict
[
'c'
],
''
,
''
,
''
)
retCode
,
retVal
=
taos_command
(
buildPath
,
"C"
,
keyDict
[
'C'
],
"buildinfo"
,
keyDict
[
'c'
],
''
,
''
,
''
)
if
retCode
!=
"TAOS_OK"
:
tdLog
.
exit
(
"taos -C fail"
)
...
...
tests/system-test/fulltest.sh
浏览文件 @
ccfcbba6
#!/bin/bash
set
-e
#
python3 ./test.py -f 0-others/taosShell.py
python3 ./test.py
-f
0-others/taosShell.py
#python3 ./test.py -f 2-query/between.py
...
...
tools/shell/inc/shellInt.h
浏览文件 @
ccfcbba6
...
...
@@ -62,7 +62,7 @@ typedef struct {
bool
is_check
;
bool
is_startup
;
bool
is_help
;
uint16_t
port
;
int32_t
port
;
int32_t
pktLen
;
int32_t
pktNum
;
int32_t
displayWidth
;
...
...
tools/shell/src/shellArguments.c
浏览文件 @
ccfcbba6
...
...
@@ -99,6 +99,7 @@ static int32_t shellParseSingleOpt(int32_t key, char *arg) {
break
;
case
'P'
:
pArgs
->
port
=
atoi
(
arg
);
if
(
pArgs
->
port
==
0
)
pArgs
->
port
=
-
1
;
break
;
case
'u'
:
pArgs
->
user
=
arg
;
...
...
@@ -304,6 +305,11 @@ static int32_t shellCheckArgs() {
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
)
{
printf
(
"Invalid pktLen:%d, range:[%d, %d]
\n
"
,
pArgs
->
pktLen
,
SHELL_MIN_PKG_LEN
,
SHELL_MAX_PKG_LEN
);
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录