Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
76a0598c
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1181
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
76a0598c
编写于
3月 07, 2023
作者:
X
Xiaoyu Wang
提交者:
GitHub
3月 07, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20299 from taosdata/feat/compact_with_time_range_wxy
feat: the compact command adds 'start with end with' clause
上级
424a37fd
0d89431f
变更
15
展开全部
隐藏空白更改
内联
并排
Showing
15 changed file
with
3340 addition
and
3250 deletion
+3340
-3250
include/common/tmsg.h
include/common/tmsg.h
+2
-1
include/common/ttokendef.h
include/common/ttokendef.h
+162
-162
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+2
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+4
-0
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+11
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+3
-1
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+8
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+25
-1
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+3090
-3070
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+3
-1
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+4
-3
source/libs/parser/test/mockCatalogService.h
source/libs/parser/test/mockCatalogService.h
+2
-1
source/libs/parser/test/parInitialCTest.cpp
source/libs/parser/test/parInitialCTest.cpp
+19
-4
source/libs/parser/test/parTestUtil.cpp
source/libs/parser/test/parTestUtil.cpp
+4
-3
未找到文件。
include/common/tmsg.h
浏览文件 @
76a0598c
...
@@ -1031,7 +1031,8 @@ int32_t tDeserializeSUserAuthBatchRsp(void* buf, int32_t bufLen, SUserAuthBatchR
...
@@ -1031,7 +1031,8 @@ int32_t tDeserializeSUserAuthBatchRsp(void* buf, int32_t bufLen, SUserAuthBatchR
void
tFreeSUserAuthBatchRsp
(
SUserAuthBatchRsp
*
pRsp
);
void
tFreeSUserAuthBatchRsp
(
SUserAuthBatchRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
STimeWindow
timeRange
;
}
SCompactDbReq
;
}
SCompactDbReq
;
int32_t
tSerializeSCompactDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCompactDbReq
*
pReq
);
int32_t
tSerializeSCompactDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCompactDbReq
*
pReq
);
...
...
include/common/ttokendef.h
浏览文件 @
76a0598c
...
@@ -110,168 +110,168 @@
...
@@ -110,168 +110,168 @@
#define TK_TABLE_SUFFIX 92
#define TK_TABLE_SUFFIX 92
#define TK_NK_COLON 93
#define TK_NK_COLON 93
#define TK_MAX_SPEED 94
#define TK_MAX_SPEED 94
#define TK_
TABLE
95
#define TK_
START
95
#define TK_
NK_LP
96
#define TK_
WITH
96
#define TK_
NK_RP
97
#define TK_
TIMESTAMP
97
#define TK_
STABLE
98
#define TK_
END
98
#define TK_
ADD
99
#define TK_
TABLE
99
#define TK_
COLUMN
100
#define TK_
NK_LP
100
#define TK_
MODIFY
101
#define TK_
NK_RP
101
#define TK_
RENAM
E 102
#define TK_
STABL
E 102
#define TK_
TAG
103
#define TK_
ADD
103
#define TK_
SET
104
#define TK_
COLUMN
104
#define TK_
NK_EQ
105
#define TK_
MODIFY
105
#define TK_
USING
106
#define TK_
RENAME
106
#define TK_TAG
S
107
#define TK_TAG
107
#define TK_
COMMENT
108
#define TK_
SET
108
#define TK_
BOOL
109
#define TK_
NK_EQ
109
#define TK_
TINYINT
110
#define TK_
USING
110
#define TK_
SMALLINT
111
#define TK_
TAGS
111
#define TK_
INT
112
#define TK_
COMMENT
112
#define TK_
INTEGER
113
#define TK_
BOOL
113
#define TK_
BIGINT
114
#define TK_
TINYINT
114
#define TK_
FLOAT
115
#define TK_
SMALLINT
115
#define TK_
DOUBLE
116
#define TK_
INT
116
#define TK_
BINARY
117
#define TK_
INTEGER
117
#define TK_
TIMESTAMP
118
#define TK_
BIGINT
118
#define TK_
NCHAR
119
#define TK_
FLOAT
119
#define TK_
UNSIGNED
120
#define TK_
DOUBLE
120
#define TK_
JSON
121
#define TK_
BINARY
121
#define TK_
VARCHAR
122
#define TK_
NCHAR
122
#define TK_
MEDIUMBLOB
123
#define TK_
UNSIGNED
123
#define TK_
BLOB
124
#define TK_
JSON
124
#define TK_VAR
BINARY
125
#define TK_VAR
CHAR
125
#define TK_
DECIMAL
126
#define TK_
MEDIUMBLOB
126
#define TK_
MAX_DELAY
127
#define TK_
BLOB
127
#define TK_
WATERMARK
128
#define TK_
VARBINARY
128
#define TK_
ROLLUP
129
#define TK_
DECIMAL
129
#define TK_
TTL
130
#define TK_
MAX_DELAY
130
#define TK_
SMA
131
#define TK_
WATERMARK
131
#define TK_
DELETE_MARK
132
#define TK_
ROLLUP
132
#define TK_
FIRST
133
#define TK_
TTL
133
#define TK_
LAST
134
#define TK_
SMA
134
#define TK_
SHOW
135
#define TK_
DELETE_MARK
135
#define TK_
PRIVILEGES
136
#define TK_
FIRST
136
#define TK_
DATABASES
137
#define TK_
LAST
137
#define TK_
TABLES
138
#define TK_
SHOW
138
#define TK_
STABLES
139
#define TK_
PRIVILEGES
139
#define TK_
MNODES
140
#define TK_
DATABASES
140
#define TK_
QNOD
ES 141
#define TK_
TABL
ES 141
#define TK_
FUNCTIONS
142
#define TK_
STABLES
142
#define TK_
INDEXES
143
#define TK_
MNODES
143
#define TK_
ACCOUNTS
144
#define TK_
QNODES
144
#define TK_
APPS
145
#define TK_
FUNCTIONS
145
#define TK_
CONNECTIONS
146
#define TK_
INDEXES
146
#define TK_
LICENCE
S 147
#define TK_
ACCOUNT
S 147
#define TK_
GRANTS
148
#define TK_
APPS
148
#define TK_
QUERIES
149
#define TK_
CONNECTIONS
149
#define TK_
SCORES
150
#define TK_
LICENCES
150
#define TK_
TOPIC
S 151
#define TK_
GRANT
S 151
#define TK_
VARIABLES
152
#define TK_
QUERIES
152
#define TK_
CLUSTER
153
#define TK_
SCORES
153
#define TK_
BNODE
S 154
#define TK_
TOPIC
S 154
#define TK_
SNODES
155
#define TK_
VARIABLES
155
#define TK_
TRANSACTIONS
156
#define TK_
CLUSTER
156
#define TK_
DISTRIBUTED
157
#define TK_
BNODES
157
#define TK_
CONSUMERS
158
#define TK_
SNODES
158
#define TK_
SUBSCRIPTIONS
159
#define TK_
TRANSACTIONS
159
#define TK_
VNODES
160
#define TK_
DISTRIBUTED
160
#define TK_
ALIVE
161
#define TK_
CONSUMERS
161
#define TK_
LIKE
162
#define TK_
SUBSCRIPTIONS
162
#define TK_
TBNAME
163
#define TK_
VNODES
163
#define TK_
QTAGS
164
#define TK_
ALIVE
164
#define TK_
AS
165
#define TK_
LIKE
165
#define TK_
INDEX
166
#define TK_
TBNAME
166
#define TK_
FUNCTION
167
#define TK_
QTAGS
167
#define TK_
INTERVAL
168
#define TK_
AS
168
#define TK_
COUNT
169
#define TK_
INDEX
169
#define TK_
LAST_ROW
170
#define TK_
FUNCTION
170
#define TK_
TOPIC
171
#define TK_
INTERVAL
171
#define TK_
WITH
172
#define TK_
COUNT
172
#define TK_
META
173
#define TK_
LAST_ROW
173
#define TK_
CONSUMER
174
#define TK_
TOPIC
174
#define TK_
GROUP
175
#define TK_
META
175
#define TK_
DESC
176
#define TK_
CONSUMER
176
#define TK_
DESCRIBE
177
#define TK_
GROUP
177
#define TK_
RESET
178
#define TK_
DESC
178
#define TK_
QUERY
179
#define TK_
DESCRIBE
179
#define TK_
CACHE
180
#define TK_
RESET
180
#define TK_
EXPLAIN
181
#define TK_
QUERY
181
#define TK_
ANALYZE
182
#define TK_
CACHE
182
#define TK_
VERBOSE
183
#define TK_
EXPLAIN
183
#define TK_
NK_BOOL
184
#define TK_
ANALYZE
184
#define TK_
RATIO
185
#define TK_
VERBOSE
185
#define TK_NK_
FLOAT
186
#define TK_NK_
BOOL
186
#define TK_
OUTPUTTYPE
187
#define TK_
RATIO
187
#define TK_
AGGREGATE
188
#define TK_
NK_FLOAT
188
#define TK_
BUFSIZE
189
#define TK_
OUTPUTTYPE
189
#define TK_
STREAM
190
#define TK_
AGGREGATE
190
#define TK_
INTO
191
#define TK_
BUFSIZE
191
#define TK_
TRIGGER
192
#define TK_
STREAM
192
#define TK_
AT_ONCE
193
#define TK_
INTO
193
#define TK_
WINDOW_CLOSE
194
#define TK_
TRIGGER
194
#define TK_
IGNORE
195
#define TK_
AT_ONCE
195
#define TK_
EXPIRED
196
#define TK_
WINDOW_CLOSE
196
#define TK_
FILL_HISTORY
197
#define TK_
IGNORE
197
#define TK_
UPDATE
198
#define TK_
EXPIRED
198
#define TK_
SUBTABLE
199
#define TK_
FILL_HISTORY
199
#define TK_
KILL
200
#define TK_
UPDATE
200
#define TK_
CONNECTION
201
#define TK_
SUBTABLE
201
#define TK_
TRANSACTION
202
#define TK_
KILL
202
#define TK_
BALANCE
203
#define TK_
CONNECTION
203
#define TK_
VGROUP
204
#define TK_
TRANSACTION
204
#define TK_
MERGE
205
#define TK_
BALANCE
205
#define TK_
REDISTRIBUTE
206
#define TK_
VGROUP
206
#define TK_
SPLIT
207
#define TK_
MERGE
207
#define TK_
DELETE
208
#define TK_
REDISTRIBUTE
208
#define TK_
INSERT
209
#define TK_
SPLIT
209
#define TK_
NULL
210
#define TK_
DELETE
210
#define TK_
NK_QUESTION
211
#define TK_
INSERT
211
#define TK_N
K_ARROW
212
#define TK_N
ULL
212
#define TK_
ROWTS
213
#define TK_
NK_QUESTION
213
#define TK_
QSTART
214
#define TK_
NK_ARROW
214
#define TK_
QEND
215
#define TK_
ROWTS
215
#define TK_Q
DURATION
216
#define TK_Q
START
216
#define TK_
WSTART
217
#define TK_
QEND
217
#define TK_
WEND
218
#define TK_
QDURATION
218
#define TK_W
DURATION
219
#define TK_W
START
219
#define TK_
IROWTS
220
#define TK_
WEND
220
#define TK_
ISFILLED
221
#define TK_
WDURATION
221
#define TK_
CAST
222
#define TK_
IROWTS
222
#define TK_
NOW
223
#define TK_
ISFILLED
223
#define TK_
TODAY
224
#define TK_
CAST
224
#define TK_
TIMEZONE
225
#define TK_
NOW
225
#define TK_
CLIENT_VERSION
226
#define TK_
TODAY
226
#define TK_
SERVER_VERSION
227
#define TK_
TIMEZONE
227
#define TK_
SERVER_STATUS
228
#define TK_
CLIENT_VERSION
228
#define TK_
CURRENT_USER
229
#define TK_
SERVER_VERSION
229
#define TK_
CASE
230
#define TK_
SERVER_STATUS
230
#define TK_
END
231
#define TK_
CURRENT_USER
231
#define TK_
WHEN
232
#define TK_
CASE
232
#define TK_
T
HEN 233
#define TK_
W
HEN 233
#define TK_
ELSE
234
#define TK_
THEN
234
#define TK_
BETWEEN
235
#define TK_
ELSE
235
#define TK_
IS
236
#define TK_
BETWEEN
236
#define TK_
NK_LT
237
#define TK_
IS
237
#define TK_NK_
G
T 238
#define TK_NK_
L
T 238
#define TK_NK_
LE
239
#define TK_NK_
GT
239
#define TK_NK_
G
E 240
#define TK_NK_
L
E 240
#define TK_NK_
N
E 241
#define TK_NK_
G
E 241
#define TK_
MATCH
242
#define TK_
NK_NE
242
#define TK_
NMATCH
243
#define TK_
MATCH
243
#define TK_
CONTAINS
244
#define TK_
NMATCH
244
#define TK_
IN
245
#define TK_
CONTAINS
245
#define TK_
JOIN
246
#define TK_
IN
246
#define TK_
INNER
247
#define TK_
JOIN
247
#define TK_
SELECT
248
#define TK_
INNER
248
#define TK_
DISTINCT
249
#define TK_
SELECT
249
#define TK_
WHERE
250
#define TK_
DISTINCT
250
#define TK_
PARTITION
251
#define TK_
WHERE
251
#define TK_
BY
252
#define TK_
PARTITION
252
#define TK_
SESSION
253
#define TK_
BY
253
#define TK_S
TATE_WINDOW
254
#define TK_S
ESSION
254
#define TK_
EVENT
_WINDOW 255
#define TK_
STATE
_WINDOW 255
#define TK_
START
256
#define TK_
EVENT_WINDOW
256
#define TK_SLIDING 257
#define TK_SLIDING 257
#define TK_FILL 258
#define TK_FILL 258
#define TK_VALUE 259
#define TK_VALUE 259
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
76a0598c
...
@@ -128,6 +128,8 @@ typedef struct STrimDatabaseStmt {
...
@@ -128,6 +128,8 @@ typedef struct STrimDatabaseStmt {
typedef
struct
SCompactDatabaseStmt
{
typedef
struct
SCompactDatabaseStmt
{
ENodeType
type
;
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
SNode
*
pStart
;
SNode
*
pEnd
;
}
SCompactDatabaseStmt
;
}
SCompactDatabaseStmt
;
typedef
struct
STableOptions
{
typedef
struct
STableOptions
{
...
...
source/common/src/tmsg.c
浏览文件 @
76a0598c
...
@@ -2531,6 +2531,8 @@ int32_t tSerializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq)
...
@@ -2531,6 +2531,8 @@ int32_t tSerializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq)
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
timeRange
.
skey
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
timeRange
.
ekey
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -2544,6 +2546,8 @@ int32_t tDeserializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq
...
@@ -2544,6 +2546,8 @@ int32_t tDeserializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
timeRange
.
skey
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
timeRange
.
ekey
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
76a0598c
...
@@ -151,7 +151,7 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, STo
...
@@ -151,7 +151,7 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, STo
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createFlushDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
);
SNode
*
createFlushDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
);
SNode
*
createTrimDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
int32_t
maxSpeed
);
SNode
*
createTrimDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
int32_t
maxSpeed
);
SNode
*
createCompactStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
);
SNode
*
createCompactStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pStart
,
SNode
*
pEnd
);
SNode
*
createDefaultTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createDefaultTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createAlterTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createAlterTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
setTableOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
ETableOptionType
type
,
void
*
pVal
);
SNode
*
setTableOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
ETableOptionType
type
,
void
*
pVal
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
76a0598c
...
@@ -167,7 +167,7 @@ cmd ::= USE db_name(A).
...
@@ -167,7 +167,7 @@ cmd ::= USE db_name(A).
cmd ::= ALTER DATABASE db_name(A) alter_db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); }
cmd ::= ALTER DATABASE db_name(A) alter_db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); }
cmd ::= FLUSH DATABASE db_name(A). { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &A); }
cmd ::= FLUSH DATABASE db_name(A). { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &A); }
cmd ::= TRIM DATABASE db_name(A) speed_opt(B). { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &A, B); }
cmd ::= TRIM DATABASE db_name(A) speed_opt(B). { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &A, B); }
cmd ::= COMPACT DATABASE db_name(A)
. { pCxt->pRootNode = createCompactStmt(pCxt, &A
); }
cmd ::= COMPACT DATABASE db_name(A)
start_opt(B) end_opt(C). { pCxt->pRootNode = createCompactStmt(pCxt, &A, B, C
); }
%type not_exists_opt { bool }
%type not_exists_opt { bool }
%destructor not_exists_opt { }
%destructor not_exists_opt { }
...
@@ -259,6 +259,16 @@ retention(A) ::= NK_VARIABLE(B) NK_COLON NK_VARIABLE(C).
...
@@ -259,6 +259,16 @@ retention(A) ::= NK_VARIABLE(B) NK_COLON NK_VARIABLE(C).
speed_opt(A) ::= . { A = 0; }
speed_opt(A) ::= . { A = 0; }
speed_opt(A) ::= MAX_SPEED NK_INTEGER(B). { A = taosStr2Int32(B.z, NULL, 10); }
speed_opt(A) ::= MAX_SPEED NK_INTEGER(B). { A = taosStr2Int32(B.z, NULL, 10); }
start_opt(A) ::= . { A = NULL; }
start_opt(A) ::= START WITH NK_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
start_opt(A) ::= START WITH NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &B); }
start_opt(A) ::= START WITH TIMESTAMP NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &B); }
end_opt(A) ::= . { A = NULL; }
end_opt(A) ::= END WITH NK_INTEGER(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); }
end_opt(A) ::= END WITH NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &B); }
end_opt(A) ::= END WITH TIMESTAMP NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &B); }
/************************************************ create/drop table/stable ********************************************/
/************************************************ create/drop table/stable ********************************************/
cmd ::= CREATE TABLE not_exists_opt(A) full_table_name(B)
cmd ::= CREATE TABLE not_exists_opt(A) full_table_name(B)
NK_LP column_def_list(C) NK_RP tags_def_opt(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E); }
NK_LP column_def_list(C) NK_RP tags_def_opt(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
76a0598c
...
@@ -1105,7 +1105,7 @@ SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, int32_t
...
@@ -1105,7 +1105,7 @@ SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, int32_t
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
SNode
*
createCompactStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
)
{
SNode
*
createCompactStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pStart
,
SNode
*
pEnd
)
{
CHECK_PARSER_STATUS
(
pCxt
);
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
))
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
))
{
return
NULL
;
return
NULL
;
...
@@ -1113,6 +1113,8 @@ SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName) {
...
@@ -1113,6 +1113,8 @@ SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName) {
SCompactDatabaseStmt
*
pStmt
=
(
SCompactDatabaseStmt
*
)
nodesMakeNode
(
QUERY_NODE_COMPACT_DATABASE_STMT
);
SCompactDatabaseStmt
*
pStmt
=
(
SCompactDatabaseStmt
*
)
nodesMakeNode
(
QUERY_NODE_COMPACT_DATABASE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
CHECK_OUT_OF_MEM
(
pStmt
);
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
dbName
,
pDbName
);
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
dbName
,
pDbName
);
pStmt
->
pStart
=
pStart
;
pStmt
->
pEnd
=
pEnd
;
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
76a0598c
...
@@ -166,7 +166,8 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c
...
@@ -166,7 +166,8 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c
code
=
reserveDnodeRequiredInCache
(
pCxt
->
pMetaCache
);
code
=
reserveDnodeRequiredInCache
(
pCxt
->
pMetaCache
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
if
(
TSDB_CODE_SUCCESS
==
code
&&
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TAGS
)
||
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TABLES
)
||
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_COLS
))
&&
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TAGS
)
||
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TABLES
)
||
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_COLS
))
&&
QUERY_NODE_SELECT_STMT
==
nodeType
(
pCxt
->
pStmt
))
{
QUERY_NODE_SELECT_STMT
==
nodeType
(
pCxt
->
pStmt
))
{
code
=
collectMetaKeyFromInsTags
(
pCxt
);
code
=
collectMetaKeyFromInsTags
(
pCxt
);
}
}
...
@@ -605,6 +606,10 @@ static int32_t collectMetaKeyFromShowSubscriptions(SCollectMetaKeyCxt* pCxt, SSh
...
@@ -605,6 +606,10 @@ static int32_t collectMetaKeyFromShowSubscriptions(SCollectMetaKeyCxt* pCxt, SSh
pCxt
->
pMetaCache
);
pCxt
->
pMetaCache
);
}
}
static
int32_t
collectMetaKeyFromCompactDatabase
(
SCollectMetaKeyCxt
*
pCxt
,
SCompactDatabaseStmt
*
pStmt
)
{
return
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pCxt
->
pMetaCache
);
}
static
int32_t
collectMetaKeyFromQuery
(
SCollectMetaKeyCxt
*
pCxt
,
SNode
*
pStmt
)
{
static
int32_t
collectMetaKeyFromQuery
(
SCollectMetaKeyCxt
*
pCxt
,
SNode
*
pStmt
)
{
pCxt
->
pStmt
=
pStmt
;
pCxt
->
pStmt
=
pStmt
;
switch
(
nodeType
(
pStmt
))
{
switch
(
nodeType
(
pStmt
))
{
...
@@ -636,6 +641,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
...
@@ -636,6 +641,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromExplain
(
pCxt
,
(
SExplainStmt
*
)
pStmt
);
return
collectMetaKeyFromExplain
(
pCxt
,
(
SExplainStmt
*
)
pStmt
);
case
QUERY_NODE_DESCRIBE_STMT
:
case
QUERY_NODE_DESCRIBE_STMT
:
return
collectMetaKeyFromDescribe
(
pCxt
,
(
SDescribeStmt
*
)
pStmt
);
return
collectMetaKeyFromDescribe
(
pCxt
,
(
SDescribeStmt
*
)
pStmt
);
case
QUERY_NODE_COMPACT_DATABASE_STMT
:
return
collectMetaKeyFromCompactDatabase
(
pCxt
,
(
SCompactDatabaseStmt
*
)
pStmt
);
case
QUERY_NODE_CREATE_STREAM_STMT
:
case
QUERY_NODE_CREATE_STREAM_STMT
:
return
collectMetaKeyFromCreateStream
(
pCxt
,
(
SCreateStreamStmt
*
)
pStmt
);
return
collectMetaKeyFromCreateStream
(
pCxt
,
(
SCreateStreamStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_DNODES_STMT
:
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
76a0598c
...
@@ -5626,12 +5626,36 @@ static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt)
...
@@ -5626,12 +5626,36 @@ static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt)
return
refreshGetTableMeta
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
pStmt
->
pMeta
);
return
refreshGetTableMeta
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
pStmt
->
pMeta
);
}
}
static
int32_t
translateCompactRange
(
STranslateContext
*
pCxt
,
SCompactDatabaseStmt
*
pStmt
,
SCompactDbReq
*
pReq
)
{
SDbCfgInfo
dbCfg
=
{
0
};
int32_t
code
=
getDBCfg
(
pCxt
,
pStmt
->
dbName
,
&
dbCfg
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pStmt
->
pStart
)
{
((
SValueNode
*
)
pStmt
->
pStart
)
->
node
.
resType
.
precision
=
dbCfg
.
precision
;
((
SValueNode
*
)
pStmt
->
pStart
)
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
code
=
doTranslateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pStart
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pStmt
->
pEnd
)
{
((
SValueNode
*
)
pStmt
->
pEnd
)
->
node
.
resType
.
precision
=
dbCfg
.
precision
;
((
SValueNode
*
)
pStmt
->
pEnd
)
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
code
=
doTranslateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pEnd
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pReq
->
timeRange
.
skey
=
NULL
!=
pStmt
->
pStart
?
((
SValueNode
*
)
pStmt
->
pStart
)
->
datum
.
i
:
INT64_MIN
;
pReq
->
timeRange
.
ekey
=
NULL
!=
pStmt
->
pEnd
?
((
SValueNode
*
)
pStmt
->
pEnd
)
->
datum
.
i
:
INT64_MAX
;
}
return
code
;
}
static
int32_t
translateCompact
(
STranslateContext
*
pCxt
,
SCompactDatabaseStmt
*
pStmt
)
{
static
int32_t
translateCompact
(
STranslateContext
*
pCxt
,
SCompactDatabaseStmt
*
pStmt
)
{
SCompactDbReq
compactReq
=
{
0
};
SCompactDbReq
compactReq
=
{
0
};
SName
name
;
SName
name
;
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
strlen
(
pStmt
->
dbName
));
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
strlen
(
pStmt
->
dbName
));
tNameGetFullDbName
(
&
name
,
compactReq
.
db
);
tNameGetFullDbName
(
&
name
,
compactReq
.
db
);
return
buildCmdMsg
(
pCxt
,
TDMT_MND_COMPACT_DB
,
(
FSerializeFunc
)
tSerializeSCompactDbReq
,
&
compactReq
);
int32_t
code
=
translateCompactRange
(
pCxt
,
pStmt
,
&
compactReq
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_COMPACT_DB
,
(
FSerializeFunc
)
tSerializeSCompactDbReq
,
&
compactReq
);
}
return
code
;
}
}
static
int32_t
translateKillConnection
(
STranslateContext
*
pCxt
,
SKillStmt
*
pStmt
)
{
static
int32_t
translateKillConnection
(
STranslateContext
*
pCxt
,
SKillStmt
*
pStmt
)
{
...
...
source/libs/parser/src/sql.c
浏览文件 @
76a0598c
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
76a0598c
...
@@ -226,6 +226,7 @@ void generateDatabases(MockCatalogService* mcs) {
...
@@ -226,6 +226,7 @@ void generateDatabases(MockCatalogService* mcs) {
generateTestTables
(
g_mockCatalogService
.
get
(),
"cache_db"
);
generateTestTables
(
g_mockCatalogService
.
get
(),
"cache_db"
);
generateTestStables
(
g_mockCatalogService
.
get
(),
"cache_db"
);
generateTestStables
(
g_mockCatalogService
.
get
(),
"cache_db"
);
mcs
->
createDatabase
(
"rollup_db"
,
true
);
mcs
->
createDatabase
(
"rollup_db"
,
true
);
mcs
->
createDatabase
(
"testus"
,
false
,
0
,
TSDB_TIME_PRECISION_NANO
);
}
}
}
// namespace
}
// namespace
...
@@ -252,7 +253,8 @@ int32_t __catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableNam
...
@@ -252,7 +253,8 @@ int32_t __catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableNam
return
code
;
return
code
;
}
}
int32_t
__catalogGetCachedTableVgMeta
(
SCatalog
*
pCtg
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
,
STableMeta
**
pTableMeta
)
{
int32_t
__catalogGetCachedTableVgMeta
(
SCatalog
*
pCtg
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
,
STableMeta
**
pTableMeta
)
{
int32_t
code
=
g_mockCatalogService
->
catalogGetTableMeta
(
pTableName
,
pTableMeta
,
true
);
int32_t
code
=
g_mockCatalogService
->
catalogGetTableMeta
(
pTableName
,
pTableMeta
,
true
);
if
(
code
)
return
code
;
if
(
code
)
return
code
;
code
=
g_mockCatalogService
->
catalogGetTableHashVgroup
(
pTableName
,
pVgroup
,
true
);
code
=
g_mockCatalogService
->
catalogGetTableHashVgroup
(
pTableName
,
pVgroup
,
true
);
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
76a0598c
...
@@ -346,12 +346,13 @@ class MockCatalogServiceImpl {
...
@@ -346,12 +346,13 @@ class MockCatalogServiceImpl {
dnode_
.
insert
(
std
::
make_pair
(
dnodeId
,
epSet
));
dnode_
.
insert
(
std
::
make_pair
(
dnodeId
,
epSet
));
}
}
void
createDatabase
(
const
string
&
db
,
bool
rollup
,
int8_t
cacheLast
)
{
void
createDatabase
(
const
string
&
db
,
bool
rollup
,
int8_t
cacheLast
,
int8_t
precision
)
{
SDbCfgInfo
cfg
=
{
0
};
SDbCfgInfo
cfg
=
{
0
};
if
(
rollup
)
{
if
(
rollup
)
{
cfg
.
pRetensions
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
sizeof
(
SRetention
));
cfg
.
pRetensions
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
sizeof
(
SRetention
));
}
}
cfg
.
cacheLast
=
cacheLast
;
cfg
.
cacheLast
=
cacheLast
;
cfg
.
precision
=
precision
;
dbCfg_
.
insert
(
std
::
make_pair
(
db
,
cfg
));
dbCfg_
.
insert
(
std
::
make_pair
(
db
,
cfg
));
}
}
...
@@ -681,8 +682,8 @@ void MockCatalogService::createDnode(int32_t dnodeId, const string& host, int16_
...
@@ -681,8 +682,8 @@ void MockCatalogService::createDnode(int32_t dnodeId, const string& host, int16_
impl_
->
createDnode
(
dnodeId
,
host
,
port
);
impl_
->
createDnode
(
dnodeId
,
host
,
port
);
}
}
void
MockCatalogService
::
createDatabase
(
const
string
&
db
,
bool
rollup
,
int8_t
cacheLast
)
{
void
MockCatalogService
::
createDatabase
(
const
string
&
db
,
bool
rollup
,
int8_t
cacheLast
,
int8_t
precision
)
{
impl_
->
createDatabase
(
db
,
rollup
,
cacheLast
);
impl_
->
createDatabase
(
db
,
rollup
,
cacheLast
,
precision
);
}
}
int32_t
MockCatalogService
::
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
MockCatalogService
::
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
...
...
source/libs/parser/test/mockCatalogService.h
浏览文件 @
76a0598c
...
@@ -65,7 +65,8 @@ class MockCatalogService {
...
@@ -65,7 +65,8 @@ class MockCatalogService {
void
createFunction
(
const
std
::
string
&
func
,
int8_t
funcType
,
int8_t
outputType
,
int32_t
outputLen
,
int32_t
bufSize
);
void
createFunction
(
const
std
::
string
&
func
,
int8_t
funcType
,
int8_t
outputType
,
int32_t
outputLen
,
int32_t
bufSize
);
void
createSmaIndex
(
const
SMCreateSmaReq
*
pReq
);
void
createSmaIndex
(
const
SMCreateSmaReq
*
pReq
);
void
createDnode
(
int32_t
dnodeId
,
const
std
::
string
&
host
,
int16_t
port
);
void
createDnode
(
int32_t
dnodeId
,
const
std
::
string
&
host
,
int16_t
port
);
void
createDatabase
(
const
std
::
string
&
db
,
bool
rollup
=
false
,
int8_t
cacheLast
=
0
);
void
createDatabase
(
const
std
::
string
&
db
,
bool
rollup
=
false
,
int8_t
cacheLast
=
0
,
int8_t
precision
=
TSDB_TIME_PRECISION_MILLI
);
int32_t
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
bool
onlyCache
=
false
)
const
;
int32_t
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
bool
onlyCache
=
false
)
const
;
int32_t
catalogGetTableHashVgroup
(
const
SName
*
pTableName
,
SVgroupInfo
*
vgInfo
,
bool
onlyCache
=
false
)
const
;
int32_t
catalogGetTableHashVgroup
(
const
SName
*
pTableName
,
SVgroupInfo
*
vgInfo
,
bool
onlyCache
=
false
)
const
;
...
...
source/libs/parser/test/parInitialCTest.cpp
浏览文件 @
76a0598c
...
@@ -22,12 +22,16 @@ namespace ParserTest {
...
@@ -22,12 +22,16 @@ namespace ParserTest {
class
ParserInitialCTest
:
public
ParserDdlTest
{};
class
ParserInitialCTest
:
public
ParserDdlTest
{};
/*
/*
* COMPACT DATABASE db_name
* COMPACT DATABASE db_name
[START WITH start_time] [END WITH END_time]
*/
*/
TEST_F
(
ParserInitialCTest
,
compact
)
{
TEST_F
(
ParserInitialCTest
,
compact
)
{
SCompactDbReq
expect
=
{
0
};
SCompactDbReq
expect
=
{
0
};
auto
setCompactDbReq
=
[
&
](
const
char
*
pDb
)
{
snprintf
(
expect
.
db
,
sizeof
(
expect
.
db
),
"0.%s"
,
pDb
);
};
auto
setCompactDbReq
=
[
&
](
const
char
*
pDb
,
int64_t
start
=
INT64_MIN
,
int64_t
end
=
INT64_MAX
)
{
snprintf
(
expect
.
db
,
sizeof
(
expect
.
db
),
"0.%s"
,
pDb
);
expect
.
timeRange
.
skey
=
start
;
expect
.
timeRange
.
ekey
=
end
;
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_COMPACT_DATABASE_STMT
);
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_COMPACT_DATABASE_STMT
);
...
@@ -35,10 +39,21 @@ TEST_F(ParserInitialCTest, compact) {
...
@@ -35,10 +39,21 @@ TEST_F(ParserInitialCTest, compact) {
SCompactDbReq
req
=
{
0
};
SCompactDbReq
req
=
{
0
};
ASSERT_EQ
(
tDeserializeSCompactDbReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
tDeserializeSCompactDbReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
std
::
string
(
req
.
db
),
std
::
string
(
expect
.
db
));
ASSERT_EQ
(
std
::
string
(
req
.
db
),
std
::
string
(
expect
.
db
));
ASSERT_EQ
(
req
.
timeRange
.
skey
,
expect
.
timeRange
.
skey
);
ASSERT_EQ
(
req
.
timeRange
.
ekey
,
expect
.
timeRange
.
ekey
);
});
});
setCompactDbReq
(
"wxy_db"
);
setCompactDbReq
(
"test"
);
run
(
"COMPACT DATABASE wxy_db"
);
run
(
"COMPACT DATABASE test"
);
setCompactDbReq
(
"test"
,
1678168883000
,
1678255283000
);
run
(
"COMPACT DATABASE test START WITH '2023-03-07 14:01:23' END WITH '2023-03-08 14:01:23'"
);
setCompactDbReq
(
"testus"
,
1673071283000000000
);
run
(
"COMPACT DATABASE testus START WITH TIMESTAMP '2023-01-07 14:01:23'"
);
setCompactDbReq
(
"testus"
,
INT64_MIN
,
1675749683000000000
);
run
(
"COMPACT DATABASE testus END WITH 1675749683000000000"
);
}
}
/*
/*
...
...
source/libs/parser/test/parTestUtil.cpp
浏览文件 @
76a0598c
...
@@ -65,15 +65,16 @@ int32_t getLogLevel() { return g_logLevel; }
...
@@ -65,15 +65,16 @@ int32_t getLogLevel() { return g_logLevel; }
class
ParserTestBaseImpl
{
class
ParserTestBaseImpl
{
public:
public:
ParserTestBaseImpl
(
ParserTestBase
*
pBase
)
:
pBase_
(
pBase
),
sqlNo_
(
0
),
sqlNum_
(
0
)
{}
ParserTestBaseImpl
(
ParserTestBase
*
pBase
)
:
pBase_
(
pBase
),
sqlNo_
(
0
),
sqlNum_
(
0
)
{
caseEnv_
.
numOfSkipSql_
=
g_skipSql
;
caseEnv_
.
numOfLimitSql_
=
g_limitSql
;
}
void
login
(
const
std
::
string
&
user
)
{
caseEnv_
.
user_
=
user
;
}
void
login
(
const
std
::
string
&
user
)
{
caseEnv_
.
user_
=
user
;
}
void
useDb
(
const
string
&
acctId
,
const
string
&
db
)
{
void
useDb
(
const
string
&
acctId
,
const
string
&
db
)
{
caseEnv_
.
acctId_
=
acctId
;
caseEnv_
.
acctId_
=
acctId
;
caseEnv_
.
db_
=
db
;
caseEnv_
.
db_
=
db
;
caseEnv_
.
numOfSkipSql_
=
g_skipSql
;
caseEnv_
.
numOfLimitSql_
=
g_limitSql
;
}
}
void
run
(
const
string
&
sql
,
int32_t
expect
,
ParserStage
checkStage
)
{
void
run
(
const
string
&
sql
,
int32_t
expect
,
ParserStage
checkStage
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录