Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
5342e859
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5342e859
编写于
1月 14, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-2571
上级
72719cc6
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
1839 addition
and
1923 deletion
+1839
-1923
src/inc/ttokendef.h
src/inc/ttokendef.h
+199
-198
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+2
-1
src/query/inc/sql.y
src/query/inc/sql.y
+9
-5
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+2
-1
src/query/src/qTokenizer.c
src/query/src/qTokenizer.c
+1
-0
src/query/src/sql.c
src/query/src/sql.c
+1626
-1718
未找到文件。
src/inc/ttokendef.h
浏览文件 @
5342e859
...
...
@@ -16,105 +16,106 @@
#ifndef TDENGINE_TTOKENDEF_H
#define TDENGINE_TTOKENDEF_H
#define TK_ID 1
#define TK_BOOL 2
#define TK_TINYINT 3
#define TK_SMALLINT 4
#define TK_INTEGER 5
#define TK_BIGINT 6
#define TK_FLOAT 7
#define TK_DOUBLE 8
#define TK_STRING 9
#define TK_TIMESTAMP 10
#define TK_BINARY 11
#define TK_NCHAR 12
#define TK_OR 13
#define TK_AND 14
#define TK_NOT 15
#define TK_EQ 16
#define TK_NE 17
#define TK_ISNULL 18
#define TK_NOTNULL 19
#define TK_IS 20
#define TK_LIKE 21
#define TK_GLOB 22
#define TK_BETWEEN 23
#define TK_IN 24
#define TK_GT 25
#define TK_GE 26
#define TK_LT 27
#define TK_LE 28
#define TK_BITAND 29
#define TK_BITOR 30
#define TK_LSHIFT 31
#define TK_RSHIFT 32
#define TK_PLUS 33
#define TK_MINUS 34
#define TK_DIVIDE 35
#define TK_TIMES 36
#define TK_STAR 37
#define TK_SLASH 38
#define TK_REM 39
#define TK_CONCAT 40
#define TK_UMINUS 41
#define TK_UPLUS 42
#define TK_BITNOT 43
#define TK_SHOW 44
#define TK_DATABASES 45
#define TK_MNODES 46
#define TK_DNODES 47
#define TK_ACCOUNTS 48
#define TK_USERS 49
#define TK_MODULES 50
#define TK_QUERIES 51
#define TK_CONNECTIONS 52
#define TK_STREAMS 53
#define TK_VARIABLES 54
#define TK_SCORES 55
#define TK_GRANTS 56
#define TK_VNODES 57
#define TK_IPTOKEN 58
#define TK_DOT 59
#define TK_CREATE 60
#define TK_TABLE 61
#define TK_DATABASE 62
#define TK_TABLES 63
#define TK_STABLES 64
#define TK_VGROUPS 65
#define TK_DROP 66
#define TK_DNODE 67
#define TK_USER 68
#define TK_ACCOUNT 69
#define TK_USE 70
#define TK_DESCRIBE 71
#define TK_ALTER 72
#define TK_PASS 73
#define TK_PRIVILEGE 74
#define TK_LOCAL 75
#define TK_IF 76
#define TK_EXISTS 77
#define TK_PPS 78
#define TK_TSERIES 79
#define TK_DBS 80
#define TK_STORAGE 81
#define TK_QTIME 82
#define TK_CONNS 83
#define TK_STATE 84
#define TK_KEEP 85
#define TK_CACHE 86
#define TK_REPLICA 87
#define TK_QUORUM 88
#define TK_DAYS 89
#define TK_MINROWS 90
#define TK_MAXROWS 91
#define TK_BLOCKS 92
#define TK_CTIME 93
#define TK_WAL 94
#define TK_FSYNC 95
#define TK_COMP 96
#define TK_PRECISION 97
#define TK_UPDATE 98
#define TK_CACHELAST 99
#define TK_ID 1
#define TK_BOOL 2
#define TK_TINYINT 3
#define TK_SMALLINT 4
#define TK_INTEGER 5
#define TK_BIGINT 6
#define TK_FLOAT 7
#define TK_DOUBLE 8
#define TK_STRING 9
#define TK_TIMESTAMP 10
#define TK_BINARY 11
#define TK_NCHAR 12
#define TK_OR 13
#define TK_AND 14
#define TK_NOT 15
#define TK_EQ 16
#define TK_NE 17
#define TK_ISNULL 18
#define TK_NOTNULL 19
#define TK_IS 20
#define TK_LIKE 21
#define TK_GLOB 22
#define TK_BETWEEN 23
#define TK_IN 24
#define TK_GT 25
#define TK_GE 26
#define TK_LT 27
#define TK_LE 28
#define TK_BITAND 29
#define TK_BITOR 30
#define TK_LSHIFT 31
#define TK_RSHIFT 32
#define TK_PLUS 33
#define TK_MINUS 34
#define TK_DIVIDE 35
#define TK_TIMES 36
#define TK_STAR 37
#define TK_SLASH 38
#define TK_REM 39
#define TK_CONCAT 40
#define TK_UMINUS 41
#define TK_UPLUS 42
#define TK_BITNOT 43
#define TK_SHOW 44
#define TK_DATABASES 45
#define TK_MNODES 46
#define TK_DNODES 47
#define TK_ACCOUNTS 48
#define TK_USERS 49
#define TK_MODULES 50
#define TK_QUERIES 51
#define TK_CONNECTIONS 52
#define TK_STREAMS 53
#define TK_VARIABLES 54
#define TK_SCORES 55
#define TK_GRANTS 56
#define TK_VNODES 57
#define TK_IPTOKEN 58
#define TK_DOT 59
#define TK_CREATE 60
#define TK_TABLE 61
#define TK_DATABASE 62
#define TK_TABLES 63
#define TK_STABLES 64
#define TK_VGROUPS 65
#define TK_DROP 66
#define TK_DNODE 67
#define TK_USER 68
#define TK_ACCOUNT 69
#define TK_USE 70
#define TK_DESCRIBE 71
#define TK_ALTER 72
#define TK_PASS 73
#define TK_PRIVILEGE 74
#define TK_LOCAL 75
#define TK_IF 76
#define TK_EXISTS 77
#define TK_PPS 78
#define TK_TSERIES 79
#define TK_DBS 80
#define TK_STORAGE 81
#define TK_QTIME 82
#define TK_CONNS 83
#define TK_STATE 84
#define TK_KEEP 85
#define TK_CACHE 86
#define TK_REPLICA 87
#define TK_QUORUM 88
#define TK_DAYS 89
#define TK_MINROWS 90
#define TK_MAXROWS 91
#define TK_BLOCKS 92
#define TK_CTIME 93
#define TK_WAL 94
#define TK_FSYNC 95
#define TK_COMP 96
#define TK_PRECISION 97
#define TK_UPDATE 98
#define TK_CACHELAST 99
#define TK_LP 100
#define TK_RP 101
#define TK_UNSIGNED 102
...
...
@@ -126,105 +127,105 @@
#define TK_SELECT 108
#define TK_UNION 109
#define TK_ALL 110
#define TK_
FROM
111
#define TK_
VARIABLE
112
#define TK_
INTERVAL
113
#define TK_
FILL
114
#define TK_
SLIDING
115
#define TK_
ORDER
116
#define TK_
BY
117
#define TK_
ASC
118
#define TK_
DESC
119
#define TK_
GROUP
120
#define TK_
HAVING
121
#define TK_
LIMIT
122
#define TK_
OFFSET
123
#define TK_
SLIMI
T 124
#define TK_S
OFFSET
125
#define TK_
WHERE
126
#define TK_
NOW
127
#define TK_
RESET
128
#define TK_
QUERY
129
#define TK_
ADD
130
#define TK_
COLUMN
131
#define TK_
TAG
132
#define TK_
CHANGE
133
#define TK_
SET
134
#define TK_
KILL
135
#define TK_
CONNECTION
136
#define TK_
STREAM
137
#define TK_
COLON
138
#define TK_
ABORT
139
#define TK_A
FTER
140
#define TK_A
TTACH
141
#define TK_
BEFORE
142
#define TK_BE
GIN
143
#define TK_
CASCADE
144
#define TK_C
LUSTER
145
#define TK_C
ONFLICT
146
#define TK_CO
PY
147
#define TK_
DEFERRED
148
#define TK_DE
LIMITERS
149
#define TK_DE
TACH
150
#define TK_
EACH
151
#define TK_E
ND
152
#define TK_E
XPLAIN
153
#define TK_
FAIL
154
#define TK_F
OR
155
#define TK_
IGNORE
156
#define TK_I
MMEDIATE
157
#define TK_I
NITIALLY
158
#define TK_IN
STEAD
159
#define TK_
MATCH
160
#define TK_
KEY
161
#define TK_
OF
162
#define TK_
RAISE
163
#define TK_R
EPLACE
164
#define TK_RE
STRICT
165
#define TK_R
OW
166
#define TK_
STATEMENT
167
#define TK_
TRIGGER
168
#define TK_
VIEW
169
#define TK_
COUNT
170
#define TK_
SUM
171
#define TK_
AVG
172
#define TK_
MIN
173
#define TK_M
AX
174
#define TK_
FIRST
175
#define TK_
LAST
176
#define TK_
TOP
177
#define TK_
BOTTOM
178
#define TK_
STDDEV
179
#define TK_
PERCENTILE
180
#define TK_
APERCENTILE
181
#define TK_
LEASTSQUARES
182
#define TK_
HISTOGRAM
183
#define TK_
DIFF
184
#define TK_
SPREAD
185
#define TK_
TWA
186
#define TK_
INTERP
187
#define TK_
LAST_ROW
188
#define TK_
RATE
189
#define TK_
IRATE
190
#define TK_
SUM_RATE
191
#define TK_SUM_
IRATE
192
#define TK_
AVG_RATE
193
#define TK_AVG_
IRATE
194
#define TK_
TBID
195
#define TK_
SEMI
196
#define TK_
NONE
197
#define TK_
PREV
198
#define TK_
LINEAR
199
#define TK_
IMPORT
200
#define TK_
METRIC
201
#define TK_
TBNAME
202
#define TK_
JOIN
203
#define TK_
METRICS
204
#define TK_
STABLE
205
#define TK_
INSERT
206
#define TK_IN
TO
207
#define TK_
VALUES
208
#define TK_
DISTINCT
111
#define TK_
FROM
112
#define TK_
VARIABLE
113
#define TK_
INTERVAL
114
#define TK_
FILL
115
#define TK_
SLIDING
116
#define TK_
ORDER
117
#define TK_
BY
118
#define TK_
ASC
119
#define TK_
DESC
120
#define TK_
GROUP
121
#define TK_
HAVING
122
#define TK_
LIMIT
123
#define TK_
OFFSE
T 124
#define TK_S
LIMIT
125
#define TK_
SOFFSET
126
#define TK_
WHERE
127
#define TK_
NOW
128
#define TK_
RESET
129
#define TK_
QUERY
130
#define TK_
ADD
131
#define TK_
COLUMN
132
#define TK_
TAG
133
#define TK_
CHANGE
134
#define TK_
SET
135
#define TK_
KILL
136
#define TK_
CONNECTION
137
#define TK_
STREAM
138
#define TK_
COLON
139
#define TK_A
BORT
140
#define TK_A
FTER
141
#define TK_
ATTACH
142
#define TK_BE
FORE
143
#define TK_
BEGIN
144
#define TK_C
ASCADE
145
#define TK_C
LUSTER
146
#define TK_CO
NFLICT
147
#define TK_
COPY
148
#define TK_DE
FERRED
149
#define TK_DE
LIMITERS
150
#define TK_
DETACH
151
#define TK_E
ACH
152
#define TK_E
ND
153
#define TK_
EXPLAIN
154
#define TK_F
AIL
155
#define TK_
FOR
156
#define TK_I
GNORE
157
#define TK_I
MMEDIATE
158
#define TK_IN
ITIALLY
159
#define TK_
INSTEAD
160
#define TK_
MATCH
161
#define TK_
KEY
162
#define TK_
OF
163
#define TK_R
AISE
164
#define TK_RE
PLACE
165
#define TK_R
ESTRICT
166
#define TK_
ROW
167
#define TK_
STATEMENT
168
#define TK_
TRIGGER
169
#define TK_
VIEW
170
#define TK_
COUNT
171
#define TK_
SUM
172
#define TK_
AVG
173
#define TK_M
IN
174
#define TK_
MAX
175
#define TK_
FIRST
176
#define TK_
LAST
177
#define TK_
TOP
178
#define TK_
BOTTOM
179
#define TK_
STDDEV
180
#define TK_
PERCENTILE
181
#define TK_
APERCENTILE
182
#define TK_
LEASTSQUARES
183
#define TK_
HISTOGRAM
184
#define TK_
DIFF
185
#define TK_
SPREAD
186
#define TK_
TWA
187
#define TK_
INTERP
188
#define TK_
LAST_ROW
189
#define TK_
RATE
190
#define TK_
IRATE
191
#define TK_SUM_
RATE
192
#define TK_
SUM_IRATE
193
#define TK_AVG_
RATE
194
#define TK_
AVG_IRATE
195
#define TK_
TBID
196
#define TK_
SEMI
197
#define TK_
NONE
198
#define TK_
PREV
199
#define TK_
LINEAR
200
#define TK_
IMPORT
201
#define TK_
METRIC
202
#define TK_
TBNAME
203
#define TK_
JOIN
204
#define TK_
METRICS
205
#define TK_
STABLE
206
#define TK_IN
SERT
207
#define TK_
INTO
208
#define TK_VALUES 209
#define TK_SPACE 300
...
...
src/query/inc/qSqlparser.h
浏览文件 @
5342e859
...
...
@@ -206,6 +206,7 @@ typedef struct tSQLExpr {
typedef
struct
tSqlExprItem
{
tSQLExpr
*
pNode
;
// The list of expressions
char
*
aliasName
;
// alias name, null-terminated string
bool
distinct
;
}
tSqlExprItem
;
// todo refactor by using SArray
...
...
@@ -238,7 +239,7 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType);
void
tSqlExprDestroy
(
tSQLExpr
*
pExpr
);
tSQLExprList
*
tSqlExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SStrToken
*
pToken
);
tSQLExprList
*
tSqlExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SStrToken
*
p
Distinct
,
SStrToken
*
p
Token
);
void
tSqlExprListDestroy
(
tSQLExprList
*
pList
);
...
...
src/query/inc/sql.y
浏览文件 @
5342e859
...
...
@@ -448,13 +448,13 @@ select(A) ::= SELECT(T) selcollist(W). {
%destructor sclp {tSqlExprListDestroy($$);}
sclp(A) ::= selcollist(X) COMMA. {A = X;}
sclp(A) ::= . {A = 0;}
selcollist(A) ::= sclp(P) expr(X) as(Y). {
A = tSqlExprListAppend(P, X, Y.n?&Y:0);
selcollist(A) ::= sclp(P)
distinct(Z)
expr(X) as(Y). {
A = tSqlExprListAppend(P, X,
Z.n? &Z:0,
Y.n?&Y:0);
}
selcollist(A) ::= sclp(P) STAR. {
tSQLExpr *pNode = tSqlExprIdValueCreate(NULL, TK_ALL);
A = tSqlExprListAppend(P, pNode, 0);
A = tSqlExprListAppend(P, pNode, 0
, 0
);
}
// An option "AS <id>" phrase that can follow one of the expressions that
...
...
@@ -465,6 +465,10 @@ as(X) ::= AS ids(Y). { X = Y; }
as(X) ::= ids(Y). { X = Y; }
as(X) ::= . { X.n = 0; }
%type distinct {SStrToken}
distinct(X) ::= DISTINCT(Y). { X = Y; }
distinct(X) ::= . { X.n = 0;}
// A complete FROM clause.
%type from {SArray*}
// current not support query from no-table
...
...
@@ -672,8 +676,8 @@ expr(A) ::= expr(X) IN LP exprlist(Y) RP. {A = tSqlExprCreate(X, (tSQLExpr*)Y,
%type expritem {tSQLExpr*}
%destructor expritem {tSqlExprDestroy($$);}
exprlist(A) ::= exprlist(X) COMMA expritem(Y). {A = tSqlExprListAppend(X,Y,0);}
exprlist(A) ::= expritem(X). {A = tSqlExprListAppend(0,X,0);}
exprlist(A) ::= exprlist(X) COMMA expritem(Y). {A = tSqlExprListAppend(X,Y,0
, 0
);}
exprlist(A) ::= expritem(X). {A = tSqlExprListAppend(0,X,0
, 0
);}
expritem(A) ::= expr(X). {A = X;}
expritem(A) ::= . {A = 0;}
...
...
src/query/src/qParserImpl.c
浏览文件 @
5342e859
...
...
@@ -71,7 +71,7 @@ abort_parse:
return
sqlInfo
;
}
tSQLExprList
*
tSqlExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SStrToken
*
pToken
)
{
tSQLExprList
*
tSqlExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SStrToken
*
p
Distinct
,
SStrToken
*
p
Token
)
{
if
(
pList
==
NULL
)
{
pList
=
calloc
(
1
,
sizeof
(
tSQLExprList
));
}
...
...
@@ -97,6 +97,7 @@ tSQLExprList *tSqlExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken
strdequote
(
pItem
->
aliasName
);
}
pItem
->
distinct
=
(
pDistinct
!=
NULL
);
}
return
pList
;
}
...
...
src/query/src/qTokenizer.c
浏览文件 @
5342e859
...
...
@@ -240,6 +240,7 @@ static SKeyword keywordTable[] = {
{
"AVG_RATE"
,
TK_AVG_RATE
},
{
"AVG_IRATE"
,
TK_AVG_IRATE
},
{
"CACHELAST"
,
TK_CACHELAST
},
{
"DISTINCT"
,
TK_DISTINCT
},
};
static
const
char
isIdChar
[]
=
{
...
...
src/query/src/sql.c
浏览文件 @
5342e859
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录