Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6b818f2c
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看板
提交
6b818f2c
编写于
5月 09, 2022
作者:
X
xywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(query): added bitwise operations
上级
a180c499
变更
16
展开全部
隐藏空白更改
内联
并排
Showing
16 changed file
with
2562 addition
and
2001 deletion
+2562
-2001
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+201
-77
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-1
src/common/src/tarithoperator.c
src/common/src/tarithoperator.c
+419
-215
src/common/src/texpr.c
src/common/src/texpr.c
+26
-161
src/inc/taosdef.h
src/inc/taosdef.h
+6
-1
src/inc/ttokendef.h
src/inc/ttokendef.h
+171
-171
src/inc/ttype.h
src/inc/ttype.h
+1
-0
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+22
-10
src/query/inc/qFilter.h
src/query/inc/qFilter.h
+13
-6
src/query/inc/sql.y
src/query/inc/sql.y
+7
-2
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+4
-0
src/query/src/qFilter.c
src/query/src/qFilter.c
+172
-21
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+72
-2
src/query/src/sql.c
src/query/src/sql.c
+1372
-1328
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+70
-6
src/util/src/ttokenizer.c
src/util/src/ttokenizer.c
+5
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
6b818f2c
此差异已折叠。
点击以展开。
src/client/src/tscUtil.c
浏览文件 @
6b818f2c
...
...
@@ -1026,7 +1026,7 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, void* pFilterI
int8_t
*
p
=
NULL
;
//bool all = doFilterDataBlock(pFilterInfo, numOfFilterCols, pBlock->info.rows, p);
bool
all
=
filterExecute
(
pFilterInfo
,
pBlock
->
info
.
rows
,
&
p
,
NULL
,
0
);
bool
all
=
filterExecute
(
pFilterInfo
,
pBlock
->
info
.
rows
,
&
p
,
NULL
,
(
int16_t
)
taosArrayGetSize
(
pBlock
->
pDataBlock
)
);
if
(
!
all
)
{
if
(
p
)
{
doCompactSDataBlock
(
pBlock
,
pBlock
->
info
.
rows
,
p
);
...
...
src/common/src/tarithoperator.c
浏览文件 @
6b818f2c
此差异已折叠。
点击以展开。
src/common/src/texpr.c
浏览文件 @
6b818f2c
...
...
@@ -109,7 +109,6 @@ int32_t exprTreeValidateFunctionNode(char* msgbuf, tExprNode *pExpr) {
int32_t
exprTreeValidateExprNode
(
tExprNode
*
pExpr
)
{
int16_t
leftType
=
pExpr
->
_node
.
pLeft
->
resultType
;
int16_t
rightType
=
pExpr
->
_node
.
pRight
->
resultType
;
int16_t
resultType
=
leftType
;
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_ADD
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_SUBTRACT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_MULTIPLY
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_DIVIDE
||
...
...
@@ -135,171 +134,31 @@ int32_t exprTreeValidateExprNode(tExprNode *pExpr) {
pExpr
->
resultBytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
;
}
return
TSDB_CODE_SUCCESS
;
}
else
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITAND
)
{
if
((
leftType
!=
TSDB_DATA_TYPE_BOOL
&&
!
IS_SIGNED_NUMERIC_TYPE
(
leftType
)
&&
!
IS_UNSIGNED_NUMERIC_TYPE
(
leftType
))
||
(
rightType
!=
TSDB_DATA_TYPE_BOOL
&&
!
IS_SIGNED_NUMERIC_TYPE
(
rightType
)
&&
!
IS_UNSIGNED_NUMERIC_TYPE
(
rightType
)))
{
}
else
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITAND
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITOR
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITXOR
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_LSHIFT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_RSHIFT
)
{
if
(
!
IS_NUMERIC_TYPE
(
leftType
)
||
!
IS_NUMERIC_TYPE
(
rightType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
uint8_t
schemaType
;
// now leftType and rightType are both numeric
if
(
pExpr
->
_node
.
pLeft
->
nodeType
==
TSQL_NODE_COL
&&
pExpr
->
_node
.
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
if
(
leftType
!=
rightType
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
}
else
if
(
pExpr
->
_node
.
pLeft
->
nodeType
==
TSQL_NODE_COL
)
{
if
(
pExpr
->
_node
.
pRight
->
nodeType
!=
TSQL_NODE_VALUE
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
else
{
schemaType
=
pExpr
->
_node
.
pLeft
->
pSchema
->
type
;
int64_t
sVal
=
pExpr
->
_node
.
pRight
->
pVal
->
i64
;
uint64_t
uVal
=
pExpr
->
_node
.
pRight
->
pVal
->
u64
;
switch
(
schemaType
)
{
case
TSDB_DATA_TYPE_BOOL
:
if
((
pExpr
->
_node
.
pRight
->
pVal
->
nType
!=
TSDB_DATA_TYPE_BOOL
)
||
(
pExpr
->
_node
.
pRight
->
pVal
->
i64
!=
0
&&
pExpr
->
_node
.
pRight
->
pVal
->
i64
!=
1
&&
pExpr
->
_node
.
pRight
->
pVal
->
i64
!=
TSDB_DATA_BOOL_NULL
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
break
;
case
TSDB_DATA_TYPE_TINYINT
:
if
(
sVal
<
-
128
||
sVal
>
127
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
if
(
sVal
<
-
32768
||
sVal
>
32767
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
break
;
case
TSDB_DATA_TYPE_INT
:
if
(
sVal
<
INT32_MIN
||
sVal
>
INT32_MAX
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
break
;
case
TSDB_DATA_TYPE_BIGINT
:
if
(
sVal
<
INT64_MIN
||
sVal
>
INT64_MAX
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
if
(
uVal
>
255
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
if
(
uVal
>
65535
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
break
;
case
TSDB_DATA_TYPE_UINT
:
if
(
uVal
>
UINT32_MAX
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
if
(
uVal
>
UINT64_MAX
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
break
;
}
pExpr
->
_node
.
pRight
->
pSchema
->
type
=
schemaType
;
pExpr
->
_node
.
pRight
->
pVal
->
nType
=
schemaType
;
pExpr
->
_node
.
pRight
->
resultType
=
schemaType
;
pExpr
->
_node
.
pRight
->
resultBytes
=
tDataTypes
[
schemaType
].
bytes
;
}
}
else
{
if
(
pExpr
->
_node
.
pLeft
->
nodeType
!=
TSQL_NODE_VALUE
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
else
{
schemaType
=
pExpr
->
_node
.
pRight
->
pSchema
->
type
;
int64_t
sVal
=
pExpr
->
_node
.
pLeft
->
pVal
->
i64
;
uint64_t
uVal
=
pExpr
->
_node
.
pLeft
->
pVal
->
u64
;
switch
(
schemaType
)
{
case
TSDB_DATA_TYPE_BOOL
:
if
((
pExpr
->
_node
.
pLeft
->
pVal
->
nType
!=
TSDB_DATA_TYPE_BOOL
)
||
(
pExpr
->
_node
.
pLeft
->
pVal
->
i64
!=
0
&&
pExpr
->
_node
.
pLeft
->
pVal
->
i64
!=
1
&&
pExpr
->
_node
.
pLeft
->
pVal
->
i64
!=
TSDB_DATA_BOOL_NULL
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
pExpr
->
_node
.
pLeft
->
pVal
->
nLen
=
1
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
if
(
sVal
<
-
128
||
sVal
>
127
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
pExpr
->
_node
.
pLeft
->
pVal
->
nLen
=
1
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
if
(
sVal
<
-
32768
||
sVal
>
32767
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
pExpr
->
_node
.
pLeft
->
pVal
->
nLen
=
2
;
break
;
case
TSDB_DATA_TYPE_INT
:
if
(
sVal
<
INT32_MIN
||
sVal
>
INT32_MAX
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
pExpr
->
_node
.
pLeft
->
pVal
->
nLen
=
4
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
if
(
sVal
<
INT64_MIN
||
sVal
>
INT64_MAX
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
pExpr
->
_node
.
pLeft
->
pVal
->
nLen
=
8
;
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
if
(
uVal
>
255
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
pExpr
->
_node
.
pLeft
->
pVal
->
nLen
=
1
;
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
if
(
uVal
>
65535
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
pExpr
->
_node
.
pLeft
->
pVal
->
nLen
=
2
;
break
;
case
TSDB_DATA_TYPE_UINT
:
if
(
uVal
>
UINT32_MAX
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
pExpr
->
_node
.
pLeft
->
pVal
->
nLen
=
4
;
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
if
(
uVal
>
UINT64_MAX
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
pExpr
->
_node
.
pLeft
->
pVal
->
nLen
=
8
;
break
;
}
pExpr
->
_node
.
pLeft
->
pSchema
->
type
=
schemaType
;
pExpr
->
_node
.
pLeft
->
pVal
->
nType
=
schemaType
;
pExpr
->
_node
.
pLeft
->
resultType
=
schemaType
;
pExpr
->
_node
.
pLeft
->
resultBytes
=
tDataTypes
[
schemaType
].
bytes
;
}
resultType
=
schemaType
;
if
(
IS_FLOAT_TYPE
(
leftType
)
||
IS_FLOAT_TYPE
(
rightType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
resultType
==
TSDB_DATA_TYPE_BOOL
)
{
pExpr
->
resultType
=
TSDB_DATA_TYPE_BOOL
;
pExpr
->
resultBytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_LSHIFT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_RSHIFT
)
{
pExpr
->
resultType
=
leftType
;
pExpr
->
resultBytes
=
tDataTypes
[
leftType
].
bytes
;
}
else
{
pExpr
->
resultType
=
resultType
;
pExpr
->
resultBytes
=
tDataTypes
[
resultType
].
bytes
;
pExpr
->
resultType
=
TSDB_DATA_TYPE_BIGINT
;
pExpr
->
resultBytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
;
}
return
TSDB_CODE_SUCCESS
;
}
else
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITNOT
)
{
if
(
!
IS_NUMERIC_TYPE
(
leftType
)
||
IS_FLOAT_TYPE
(
leftType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
pExpr
->
resultType
=
leftType
;
pExpr
->
resultBytes
=
tDataTypes
[
leftType
].
bytes
;
return
TSDB_CODE_SUCCESS
;
}
else
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -689,6 +548,9 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI
rightType
=
pRight
->
pSchema
->
type
;
rightNum
=
numOfRows
;
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_DUMMY
)
{
/* BITNOT */
rightNum
=
0
;
}
else
{
assert
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
);
rightIn
=
(
char
*
)
&
pRight
->
pVal
->
i64
;
...
...
@@ -703,7 +565,10 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI
if
(
leftType
==
TSDB_DATA_TYPE_TIMESTAMP
||
rightType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
output
->
type
=
TSDB_DATA_TYPE_BIGINT
;
}
else
{
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITAND
)
{
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITAND
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITOR
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITXOR
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITNOT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_LSHIFT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_RSHIFT
)
{
output
->
type
=
leftType
;
// rightType must be the same as leftType
}
else
{
output
->
type
=
TSDB_DATA_TYPE_DOUBLE
;
...
...
src/inc/taosdef.h
浏览文件 @
6b818f2c
...
...
@@ -184,10 +184,15 @@ do { \
#define TSDB_BINARY_OP_DIVIDE 33
#define TSDB_BINARY_OP_REMAINDER 34
#define TSDB_BINARY_OP_BITAND 35
#define TSDB_BINARY_OP_BITOR 36
#define TSDB_BINARY_OP_BITXOR 37
#define TSDB_BINARY_OP_BITNOT 38
#define TSDB_BINARY_OP_LSHIFT 39
#define TSDB_BINARY_OP_RSHIFT 40
#define IS_RELATION_OPTR(op) (((op) >= TSDB_RELATION_LESS) && ((op) < TSDB_RELATION_IN))
#define IS_ARITHMETIC_OPTR(op) (((op) >= TSDB_BINARY_OP_ADD) && ((op) <= TSDB_BINARY_OP_
BITAND
))
#define IS_ARITHMETIC_OPTR(op) (((op) >= TSDB_BINARY_OP_ADD) && ((op) <= TSDB_BINARY_OP_
RSHIFT
))
#define TS_PATH_DELIMITER_LEN 1
...
...
src/inc/ttokendef.h
浏览文件 @
6b818f2c
...
...
@@ -50,177 +50,177 @@
#define TK_LE 32
#define TK_BITAND 33
#define TK_BITOR 34
#define TK_
LSHIFT
35
#define TK_
R
SHIFT 36
#define TK_
PLUS
37
#define TK_
MINUS
38
#define TK_
DIVIDE
39
#define TK_
TIMES
40
#define TK_
STAR
41
#define TK_S
LASH
42
#define TK_
REM
43
#define TK_
UMINUS
44
#define TK_U
PLUS
45
#define TK_
BITNOT
46
#define TK_
ARROW
47
#define TK_
SHOW
48
#define TK_
DATABASES
49
#define TK_
TOPICS
50
#define TK_
FUNCTIONS
51
#define TK_
MNODES
52
#define TK_
D
NODES 53
#define TK_
ACCOUNTS
54
#define TK_
USERS
55
#define TK_
MODULES
56
#define TK_
QUERI
ES 57
#define TK_
CONNECTIONS
58
#define TK_
STREAMS
59
#define TK_
VARIABLES
60
#define TK_
SCORES
61
#define TK_
GRANT
S 62
#define TK_
VNODE
S 63
#define TK_
DOT
64
#define TK_
CREATE
65
#define TK_
TABLE
66
#define TK_
STABLE
67
#define TK_
DATABASE
68
#define TK_
TABLES
69
#define TK_
STABLES
70
#define TK_
VGROUP
S 71
#define TK_
DROP
72
#define TK_
TOPIC
73
#define TK_
FUNCTION
74
#define TK_
DNODE
75
#define TK_
USER
76
#define TK_
ACCOUNT
77
#define TK_
USE
78
#define TK_
DESCRIBE
79
#define TK_DESC
80
#define TK_
ALTER
81
#define TK_
PASS
82
#define TK_P
RIVILEGE
83
#define TK_
LOCAL
84
#define TK_
COMPACT
85
#define TK_
LP
86
#define TK_
R
P 87
#define TK_
IF
88
#define TK_
EXISTS
89
#define TK_
AS
90
#define TK_
OUTPUTTYPE
91
#define TK_
AGGREGATE
92
#define TK_
BUFSIZE
93
#define TK_
PPS
94
#define TK_
TSERIES
95
#define TK_
DBS
96
#define TK_
STORAGE
97
#define TK_
QTIME
98
#define TK_
CONNS
99
#define TK_
STATE
100
#define TK_
COMMA
101
#define TK_
KEEP
102
#define TK_
CACHE
103
#define TK_
REPLICA
104
#define TK_
QUORUM
105
#define TK_
DAYS
106
#define TK_
MINROWS
107
#define TK_M
AX
ROWS 108
#define TK_
BLOCKS
109
#define TK_
CTIME
110
#define TK_
WAL
111
#define TK_
FSYNC
112
#define TK_
COMP
113
#define TK_
PRECISION
114
#define TK_
UPDATE
115
#define TK_
CACHELAST
116
#define TK_
PARTITIONS
117
#define TK_
UNSIGNED
118
#define TK_
TAGS
119
#define TK_
USING
120
#define TK_
TO
121
#define TK_
SPLIT
122
#define TK_
NULL
123
#define TK_N
OW
124
#define TK_
VARIABLE
125
#define TK_
SELECT
126
#define TK_
UNION
127
#define TK_
ALL
128
#define TK_
DISTINCT
129
#define TK_
FROM
130
#define TK_
RANGE
131
#define TK_
INTERVAL
132
#define TK_
EVERY
133
#define TK_
SESSION
134
#define TK_S
TATE_WINDOW
135
#define TK_
FILL
136
#define TK_
SLIDING
137
#define TK_
ORDER
138
#define TK_
BY
139
#define TK_
ASC
140
#define TK_
GROUP
141
#define TK_
HAVING
142
#define TK_
LIMIT
143
#define TK_
OFFSET
144
#define TK_
SLIMI
T 145
#define TK_S
OFFSET
146
#define TK_
WHERE
147
#define TK_
TODAY
148
#define TK_
RESET
149
#define TK_
QUERY
150
#define TK_
SYNCDB
151
#define TK_
ADD
152
#define TK_
COLUMN
153
#define TK_
MODIFY
154
#define TK_
TAG
155
#define TK_
CHANGE
156
#define TK_
SET
157
#define TK_
KILL
158
#define TK_
CONNECTION
159
#define TK_
STREAM
160
#define TK_
COLON
161
#define TK_
DELETE
162
#define TK_
ABORT
163
#define TK_A
FTER
164
#define TK_A
TTACH
165
#define TK_
BEFORE
166
#define TK_BE
GIN
167
#define TK_
CASCADE
168
#define TK_C
LUSTER
169
#define TK_C
ONFLICT
170
#define TK_CO
PY
171
#define TK_
DEFERRED
172
#define TK_DE
LIMITERS
173
#define TK_DE
TACH
174
#define TK_
EACH
175
#define TK_E
ND
176
#define TK_E
XPLAIN
177
#define TK_
FAIL
178
#define TK_F
OR
179
#define TK_
IGNORE
180
#define TK_I
MMEDIATE
181
#define TK_I
NITIALLY
182
#define TK_IN
STEAD
183
#define TK_
KEY
184
#define TK_
OF
185
#define TK_
RAISE
186
#define TK_R
EPLACE
187
#define TK_RE
STRICT
188
#define TK_R
OW
189
#define TK_
STATEMENT
190
#define TK_
TRIGGER
191
#define TK_
VIEW
192
#define TK_
IPTOKEN
193
#define TK_
SEMI
194
#define TK_
NONE
195
#define TK_
PREV
196
#define TK_
LINEAR
197
#define TK_
IMPORT
198
#define TK_
TBNAME
199
#define TK_
JOIN
200
#define TK_
INSERT
201
#define TK_IN
TO
202
#define TK_
VALUES
203
#define TK_
FILE
204
#define TK_
BITXOR
35
#define TK_
L
SHIFT 36
#define TK_
RSHIFT
37
#define TK_
PLUS
38
#define TK_
MINUS
39
#define TK_
DIVIDE
40
#define TK_
TIMES
41
#define TK_S
TAR
42
#define TK_
SLASH
43
#define TK_
REM
44
#define TK_U
MINUS
45
#define TK_
UPLUS
46
#define TK_
BITNOT
47
#define TK_
ARROW
48
#define TK_
SHOW
49
#define TK_
DATABASES
50
#define TK_
TOPICS
51
#define TK_
FUNCTIONS
52
#define TK_
M
NODES 53
#define TK_
DNODES
54
#define TK_
ACCOUNTS
55
#define TK_
USERS
56
#define TK_
MODUL
ES 57
#define TK_
QUERIES
58
#define TK_
CONNECTIONS
59
#define TK_
STREAMS
60
#define TK_
VARIABLES
61
#define TK_
SCORE
S 62
#define TK_
GRANT
S 63
#define TK_
VNODES
64
#define TK_
DOT
65
#define TK_
CREATE
66
#define TK_
TABLE
67
#define TK_
STABLE
68
#define TK_
DATABASE
69
#define TK_
TABLES
70
#define TK_
STABLE
S 71
#define TK_
VGROUPS
72
#define TK_
DROP
73
#define TK_
TOPIC
74
#define TK_
FUNCTION
75
#define TK_
DNODE
76
#define TK_
USER
77
#define TK_
ACCOUNT
78
#define TK_
USE
79
#define TK_DESC
RIBE
80
#define TK_
DESC
81
#define TK_
ALTER
82
#define TK_P
ASS
83
#define TK_
PRIVILEGE
84
#define TK_
LOCAL
85
#define TK_
COMPACT
86
#define TK_
L
P 87
#define TK_
RP
88
#define TK_
IF
89
#define TK_
EXISTS
90
#define TK_
AS
91
#define TK_
OUTPUTTYPE
92
#define TK_
AGGREGATE
93
#define TK_
BUFSIZE
94
#define TK_
PPS
95
#define TK_
TSERIES
96
#define TK_
DBS
97
#define TK_
STORAGE
98
#define TK_
QTIME
99
#define TK_
CONNS
100
#define TK_
STATE
101
#define TK_
COMMA
102
#define TK_
KEEP
103
#define TK_
CACHE
104
#define TK_
REPLICA
105
#define TK_
QUORUM
106
#define TK_
DAYS
107
#define TK_M
IN
ROWS 108
#define TK_
MAXROWS
109
#define TK_
BLOCKS
110
#define TK_
CTIME
111
#define TK_
WAL
112
#define TK_
FSYNC
113
#define TK_
COMP
114
#define TK_
PRECISION
115
#define TK_
UPDATE
116
#define TK_
CACHELAST
117
#define TK_
PARTITIONS
118
#define TK_
UNSIGNED
119
#define TK_
TAGS
120
#define TK_
USING
121
#define TK_
TO
122
#define TK_
SPLIT
123
#define TK_N
ULL
124
#define TK_
NOW
125
#define TK_
VARIABLE
126
#define TK_
SELECT
127
#define TK_
UNION
128
#define TK_
ALL
129
#define TK_
DISTINCT
130
#define TK_
FROM
131
#define TK_
RANGE
132
#define TK_
INTERVAL
133
#define TK_
EVERY
134
#define TK_S
ESSION
135
#define TK_
STATE_WINDOW
136
#define TK_
FILL
137
#define TK_
SLIDING
138
#define TK_
ORDER
139
#define TK_
BY
140
#define TK_
ASC
141
#define TK_
GROUP
142
#define TK_
HAVING
143
#define TK_
LIMIT
144
#define TK_
OFFSE
T 145
#define TK_S
LIMIT
146
#define TK_
SOFFSET
147
#define TK_
WHERE
148
#define TK_
TODAY
149
#define TK_
RESET
150
#define TK_
QUERY
151
#define TK_
SYNCDB
152
#define TK_
ADD
153
#define TK_
COLUMN
154
#define TK_
MODIFY
155
#define TK_
TAG
156
#define TK_
CHANGE
157
#define TK_
SET
158
#define TK_
KILL
159
#define TK_
CONNECTION
160
#define TK_
STREAM
161
#define TK_
COLON
162
#define TK_
DELETE
163
#define TK_A
BORT
164
#define TK_A
FTER
165
#define TK_
ATTACH
166
#define TK_BE
FORE
167
#define TK_
BEGIN
168
#define TK_C
ASCADE
169
#define TK_C
LUSTER
170
#define TK_CO
NFLICT
171
#define TK_
COPY
172
#define TK_DE
FERRED
173
#define TK_DE
LIMITERS
174
#define TK_
DETACH
175
#define TK_E
ACH
176
#define TK_E
ND
177
#define TK_
EXPLAIN
178
#define TK_F
AIL
179
#define TK_
FOR
180
#define TK_I
GNORE
181
#define TK_I
MMEDIATE
182
#define TK_IN
ITIALLY
183
#define TK_
INSTEAD
184
#define TK_
KEY
185
#define TK_
OF
186
#define TK_R
AISE
187
#define TK_RE
PLACE
188
#define TK_R
ESTRICT
189
#define TK_
ROW
190
#define TK_
STATEMENT
191
#define TK_
TRIGGER
192
#define TK_
VIEW
193
#define TK_
IPTOKEN
194
#define TK_
SEMI
195
#define TK_
NONE
196
#define TK_
PREV
197
#define TK_
LINEAR
198
#define TK_
IMPORT
199
#define TK_
TBNAME
200
#define TK_
JOIN
201
#define TK_IN
SERT
202
#define TK_
INTO
203
#define TK_
VALUES
204
#define TK_FILE 205
#define TK_SPACE 300
#define TK_COMMENT 301
...
...
src/inc/ttype.h
浏览文件 @
6b818f2c
...
...
@@ -293,6 +293,7 @@ int32_t tStrToInteger(const char* z, int16_t type, int32_t n, int64_t* value, bo
#define SET_DOUBLE_NULL(v) (*(uint64_t *)(v) = TSDB_DATA_DOUBLE_NULL)
#define SET_TIMESTAMP_NULL(v) (*(uint64_t *)(v) = TSDB_DATA_TIMESTAMP_NULL)
#define SET_BIGINT_NULL(v) (*(int64_t *)(v) = TSDB_DATA_BIGINT_NULL)
#ifdef __cplusplus
}
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
6b818f2c
...
...
@@ -244,22 +244,34 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
int64_t
st
,
et
;
wordexp_t
full_path
;
char
*
sptr
=
NULL
;
char
*
tmp
=
NULL
;
char
*
cptr
=
NULL
;
char
*
fname
=
NULL
;
bool
printMode
=
false
;
if
((
sptr
=
tstrstr
(
command
,
">>"
,
true
))
!=
NULL
)
{
cptr
=
tstrstr
(
command
,
";"
,
true
);
if
(
cptr
!=
NULL
)
{
*
cptr
=
'\0'
;
}
sptr
=
command
;
while
((
sptr
=
tstrstr
(
sptr
,
">>"
,
true
))
!=
NULL
)
{
// find the last ">>" if any
tmp
=
sptr
;
sptr
+=
2
;
}
if
(
wordexp
(
sptr
+
2
,
&
full_path
,
0
)
!=
0
)
{
fprintf
(
stderr
,
"ERROR: invalid filename: %s
\n
"
,
sptr
+
2
);
return
;
sptr
=
tmp
;
if
(
sptr
!=
NULL
)
{
if
(
regex_match
(
sptr
+
2
,
"^
\\
s*[0-9]+
\\
s*[
\\
>|
\\
<|
\\
<=|
\\
>=|=|!=]
\\
s*.*;
\\
s*$"
,
REG_EXTENDED
|
REG_ICASE
)
==
0
)
{
cptr
=
tstrstr
(
command
,
";"
,
true
);
if
(
cptr
!=
NULL
)
{
*
cptr
=
'\0'
;
}
if
(
wordexp
(
sptr
+
2
,
&
full_path
,
0
)
!=
0
)
{
fprintf
(
stderr
,
"ERROR: invalid filename: %s
\n
"
,
sptr
+
2
);
return
;
}
*
sptr
=
'\0'
;
fname
=
full_path
.
we_wordv
[
0
];
}
*
sptr
=
'\0'
;
fname
=
full_path
.
we_wordv
[
0
];
}
if
((
sptr
=
tstrstr
(
command
,
"
\\
G"
,
true
))
!=
NULL
)
{
...
...
src/query/inc/qFilter.h
浏览文件 @
6b818f2c
...
...
@@ -38,11 +38,12 @@ extern "C" {
enum
{
FLD_TYPE_COLUMN
=
1
,
FLD_TYPE_VALUE
=
2
,
FLD_TYPE_MAX
=
3
,
FLD_DESC_NO_FREE
=
4
,
FLD_DATA_NO_FREE
=
8
,
FLD_DATA_IS_HASH
=
16
,
FLD_TYPE_VALUE
=
2
,
FLD_TYPE_EXPR
=
3
,
FLD_TYPE_MAX
=
4
,
FLD_DESC_NO_FREE
=
16
,
FLD_DATA_NO_FREE
=
32
,
FLD_DATA_IS_HASH
=
64
};
enum
{
...
...
@@ -182,6 +183,7 @@ typedef struct SFilterGroupCtx {
uint32_t
colNum
;
uint32_t
*
colIdx
;
SFilterColInfo
*
colInfo
;
bool
hasExpr
;
}
SFilterGroupCtx
;
typedef
struct
SFilterColCtx
{
...
...
@@ -206,6 +208,8 @@ typedef struct SFilterComUnit {
void
*
colData
;
void
*
valData
;
void
*
valData2
;
void
*
expr
;
void
*
exprData
;
uint16_t
colId
;
uint16_t
dataSize
;
uint8_t
dataType
;
...
...
@@ -289,7 +293,10 @@ typedef struct SFilterInfo {
#define FILTER_GET_VAL_FIELD_TYPE(fi) (((tVariant *)((fi)->desc))->nType)
#define FILTER_GET_VAL_FIELD_DATA(fi) ((char *)(fi)->data)
#define FILTER_GET_JSON_VAL_FIELD_DATA(fi) ((char *)(fi)->desc)
#define FILTER_GET_TYPE(fl) ((fl) & FLD_TYPE_MAX)
#define FILTER_GET_TYPE(fl) ((fl) & 0xF)
#define FILTER_GET_FIELD_DESC(fi) ((fi)->desc)
#define FILTER_GET_EXPR_TYPE(i, id) (((tExprNode*)(FILTER_GET_FIELD_DESC(FILTER_GET_FIELD(i, id))))->resultType)
#define FILTER_GET_EXPR_SIZE(i, id) (((tExprNode*)(FILTER_GET_FIELD_DESC(FILTER_GET_FIELD(i, id))))->resultBytes)
#define FILTER_GROUP_UNIT(i, g, uid) ((i)->units + (g)->unitIdxs[uid])
#define FILTER_UNIT_LEFT_FIELD(i, u) FILTER_GET_FIELD(i, (u)->left)
...
...
src/query/inc/sql.y
浏览文件 @
6b818f2c
...
...
@@ -13,7 +13,7 @@
%right NOT.
%left EQ NE ISNULL NOTNULL IS LIKE MATCH NMATCH CONTAINS GLOB BETWEEN IN.
%left GT GE LT LE.
%left BITAND BITOR LSHIFT RSHIFT.
%left BITAND BITOR
BITXOR
LSHIFT RSHIFT.
%left PLUS MINUS.
%left DIVIDE TIMES.
%left STAR SLASH REM.
...
...
@@ -802,6 +802,11 @@ expr(A) ::= expr(X) STAR expr(Y). {A = tSqlExprCreate(X, Y, TK_STAR); }
expr(A) ::= expr(X) SLASH expr(Y). {A = tSqlExprCreate(X, Y, TK_DIVIDE);}
expr(A) ::= expr(X) REM expr(Y). {A = tSqlExprCreate(X, Y, TK_REM); }
expr(A) ::= expr(X) BITAND expr(Y). {A = tSqlExprCreate(X, Y, TK_BITAND);}
expr(A) ::= expr(X) BITOR expr(Y). {A = tSqlExprCreate(X, Y, TK_BITOR); }
expr(A) ::= expr(X) BITXOR expr(Y). {A = tSqlExprCreate(X, Y, TK_BITXOR);}
expr(A) ::= BITNOT expr(X). {A = tSqlExprCreate(X, NULL, TK_BITNOT);}
expr(A) ::= expr(X) LSHIFT expr(Y). {A = tSqlExprCreate(X, Y, TK_LSHIFT);}
expr(A) ::= expr(X) RSHIFT expr(Y). {A = tSqlExprCreate(X, Y, TK_RSHIFT);}
// like expression
expr(A) ::= expr(X) LIKE expr(Y). {A = tSqlExprCreate(X, Y, TK_LIKE); }
...
...
@@ -997,4 +1002,4 @@ cmd ::= DELETE FROM ifexists(Y) ids(X) cpxName(Z) where_opt(W). {
%fallback ID ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CLUSTER CONFLICT COPY DATABASE DEFERRED
DELIMITERS DESC DETACH EACH END EXPLAIN FAIL FOR GLOB IGNORE IMMEDIATE INITIALLY INSTEAD
LIKE MATCH NMATCH KEY OF OFFSET RAISE REPLACE RESTRICT ROW STATEMENT TRIGGER VIEW ALL
NOW TODAY IPTOKEN SEMI NONE PREV LINEAR IMPORT TBNAME JOIN STABLE NULL INSERT INTO VALUES FILE.
\ No newline at end of file
NOW TODAY IPTOKEN SEMI NONE PREV LINEAR IMPORT TBNAME JOIN STABLE NULL INSERT INTO VALUES FILE.
src/query/src/qExecutor.c
浏览文件 @
6b818f2c
...
...
@@ -3164,6 +3164,10 @@ void doSetFilterColumnInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFi
FORCE_INLINE
int32_t
getColumnDataFromId
(
void
*
param
,
int32_t
id
,
void
**
data
)
{
int32_t
numOfCols
=
((
SColumnDataParam
*
)
param
)
->
numOfCols
;
SArray
*
pDataBlock
=
((
SColumnDataParam
*
)
param
)
->
pDataBlock
;
if
(
id
==
INT32_MAX
)
{
*
data
=
pDataBlock
;
return
TSDB_CODE_SUCCESS
;
}
for
(
int32_t
j
=
0
;
j
<
numOfCols
;
++
j
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pDataBlock
,
j
);
...
...
src/query/src/qFilter.c
浏览文件 @
6b818f2c
...
...
@@ -54,11 +54,16 @@ static FORCE_INLINE int32_t filterFieldValDescCompare(const void *desc1, const v
return
tVariantCompare
(
val1
,
val2
);
}
static
FORCE_INLINE
int32_t
filterExprCompare
(
const
void
*
desc1
,
const
void
*
desc2
)
{
return
-
1
;
}
filter_desc_compare_func
gDescCompare
[
FLD_TYPE_MAX
]
=
{
NULL
,
filterFieldColDescCompare
,
filterFieldValDescCompare
filterFieldValDescCompare
,
filterExprCompare
};
bool
filterRangeCompGi
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
...
...
@@ -834,7 +839,7 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type,
info
->
fields
[
type
].
fields
[
idx
].
desc
=
desc
;
info
->
fields
[
type
].
fields
[
idx
].
data
=
data
?
*
data
:
NULL
;
if
(
type
==
FLD_TYPE_COLUMN
)
{
if
(
type
==
FLD_TYPE_COLUMN
||
type
==
FLD_TYPE_EXPR
)
{
FILTER_SET_FLAG
(
info
->
fields
[
type
].
fields
[
idx
].
flag
,
FLD_DATA_NO_FREE
);
}
...
...
@@ -874,7 +879,8 @@ static FORCE_INLINE int32_t filterAddColFieldFromField(SFilterInfo *info, SFilte
int32_t
filterAddFieldFromNode
(
SFilterInfo
*
info
,
tExprNode
*
node
,
SFilterFieldId
*
fid
)
{
CHK_LRET
(
node
==
NULL
,
TSDB_CODE_QRY_APP_ERROR
,
"empty node"
);
CHK_RET
(
node
->
nodeType
!=
TSQL_NODE_COL
&&
node
->
nodeType
!=
TSQL_NODE_VALUE
,
TSDB_CODE_QRY_APP_ERROR
);
CHK_RET
(
node
->
nodeType
!=
TSQL_NODE_COL
&&
node
->
nodeType
!=
TSQL_NODE_VALUE
&&
node
->
nodeType
!=
TSQL_NODE_EXPR
,
TSDB_CODE_QRY_APP_ERROR
);
int32_t
type
;
void
*
v
;
...
...
@@ -883,6 +889,9 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, tExprNode *node, SFilterFieldI
type
=
FLD_TYPE_COLUMN
;
v
=
node
->
pSchema
;
node
->
pSchema
=
NULL
;
}
else
if
(
node
->
nodeType
==
TSQL_NODE_EXPR
)
{
type
=
FLD_TYPE_EXPR
;
v
=
node
;
}
else
{
type
=
FLD_TYPE_VALUE
;
v
=
node
->
pVal
;
...
...
@@ -934,9 +943,11 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi
}
SFilterField
*
col
=
FILTER_UNIT_LEFT_FIELD
(
info
,
u
);
assert
(
FILTER_GET_FLAG
(
col
->
flag
,
FLD_TYPE_COLUMN
));
info
->
units
[
info
->
unitNum
].
compare
.
type
=
FILTER_GET_COL_FIELD_TYPE
(
col
);
if
(
FILTER_GET_TYPE
(
col
->
flag
)
==
FLD_TYPE_COLUMN
)
{
info
->
units
[
info
->
unitNum
].
compare
.
type
=
FILTER_GET_COL_FIELD_TYPE
(
col
);
}
else
{
info
->
units
[
info
->
unitNum
].
compare
.
type
=
(
uint8_t
)
FILTER_GET_EXPR_TYPE
(
info
,
u
->
left
);
}
*
uidx
=
info
->
unitNum
;
...
...
@@ -1189,7 +1200,7 @@ static int32_t filterDealJson(SFilterInfo *info, tExprNode* tree, tExprNode** pL
jsonKeyMd5
((
*
pLeft
)
->
_node
.
pRight
->
pVal
->
pz
,
(
*
pLeft
)
->
_node
.
pRight
->
pVal
->
nLen
,
keyMd5
);
memcpy
(
schema
->
name
,
keyMd5
,
TSDB_MAX_JSON_KEY_MD5_LEN
);
(
*
pLeft
)
=
(
*
pLeft
)
->
_node
.
pLeft
;
// -> operation use left as input
}
else
if
(((
*
pLeft
)
->
pSchema
->
type
==
TSDB_DATA_TYPE_JSON
)
&&
}
else
if
((
*
pLeft
)
->
nodeType
==
TSQL_NODE_COL
&&
(
(
*
pLeft
)
->
pSchema
->
type
==
TSDB_DATA_TYPE_JSON
)
&&
(
tree
->
_node
.
optr
==
TSDB_RELATION_ISNULL
||
tree
->
_node
.
optr
==
TSDB_RELATION_NOTNULL
)){
SSchema
*
schema
=
(
*
pLeft
)
->
pSchema
;
char
keyMd5
[
TSDB_MAX_JSON_KEY_MD5_LEN
]
=
{
0
};
...
...
@@ -1213,7 +1224,16 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
if
((
ret
=
filterDealJson
(
info
,
tree
,
&
pLeft
))
!=
TSDB_CODE_SUCCESS
)
return
ret
;
SFilterFieldId
left
=
{
0
},
right
=
{
0
};
filterAddFieldFromNode
(
info
,
pLeft
,
&
left
);
uint8_t
type
=
FILTER_GET_COL_FIELD_TYPE
(
FILTER_GET_FIELD
(
info
,
left
));
if
(
pLeft
->
nodeType
!=
TSQL_NODE_VALUE
&&
pLeft
->
nodeType
!=
TSQL_NODE_COL
)
{
tree
->
_node
.
pLeft
=
NULL
;
}
uint8_t
type
;
if
(
left
.
type
==
FLD_TYPE_EXPR
)
{
type
=
(
uint8_t
)
FILTER_GET_EXPR_TYPE
(
info
,
left
);
}
else
{
type
=
FILTER_GET_COL_FIELD_TYPE
(
FILTER_GET_FIELD
(
info
,
left
));
}
int32_t
len
=
0
;
uint32_t
uidx
=
0
;
...
...
@@ -1577,6 +1597,9 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
char
str
[
512
]
=
{
0
};
SFilterField
*
left
=
FILTER_UNIT_LEFT_FIELD
(
info
,
unit
);
if
(
FILTER_GET_TYPE
(
left
->
flag
)
==
FLD_TYPE_EXPR
)
{
continue
;
}
SSchema
*
sch
=
left
->
desc
;
if
(
unit
->
compare
.
optr
>=
TSDB_RELATION_INVALID
&&
unit
->
compare
.
optr
<=
TSDB_RELATION_CONTAINS
){
len
=
sprintf
(
str
,
"UNIT[%d] => [%d][%s] %s ["
,
i
,
sch
->
colId
,
sch
->
name
,
gOptrStr
[
unit
->
compare
.
optr
].
str
);
...
...
@@ -1752,6 +1775,9 @@ void filterFreeField(SFilterField* field, int32_t type) {
if
(
!
FILTER_GET_FLAG
(
field
->
flag
,
FLD_DESC_NO_FREE
))
{
if
(
type
==
FLD_TYPE_VALUE
)
{
tVariantDestroy
(
field
->
desc
);
}
else
if
(
type
==
FLD_TYPE_EXPR
)
{
tExprTreeDestroy
(
field
->
desc
,
NULL
);
field
->
desc
=
NULL
;
}
tfree
(
field
->
desc
);
...
...
@@ -2101,20 +2127,30 @@ _return:
int32_t
filterMergeGroupUnits
(
SFilterInfo
*
info
,
SFilterGroupCtx
**
gRes
,
int32_t
*
gResNum
)
{
bool
empty
=
false
;
if
(
info
->
fields
[
FLD_TYPE_COLUMN
].
num
==
0
)
{
return
TSDB_CODE_SUCCESS
;
}
uint32_t
*
colIdx
=
malloc
(
info
->
fields
[
FLD_TYPE_COLUMN
].
num
*
sizeof
(
uint32_t
));
uint32_t
colIdxi
=
0
;
uint32_t
gResIdx
=
0
;
bool
hasExpr
=
false
;
for
(
uint32_t
i
=
0
;
i
<
info
->
groupNum
;
++
i
)
{
SFilterGroup
*
g
=
info
->
groups
+
i
;
gRes
[
gResIdx
]
=
calloc
(
1
,
sizeof
(
SFilterGroupCtx
));
gRes
[
gResIdx
]
->
colInfo
=
calloc
(
info
->
fields
[
FLD_TYPE_COLUMN
].
num
,
sizeof
(
SFilterColInfo
));
gRes
[
gResIdx
]
->
hasExpr
=
false
;
colIdxi
=
0
;
empty
=
false
;
for
(
uint32_t
j
=
0
;
j
<
g
->
unitNum
;
++
j
)
{
SFilterUnit
*
u
=
FILTER_GROUP_UNIT
(
info
,
g
,
j
);
if
(
u
->
left
.
type
==
FLD_TYPE_EXPR
)
{
gRes
[
gResIdx
]
->
hasExpr
=
true
;
hasExpr
=
true
;
continue
;
}
uint32_t
cidx
=
FILTER_UNIT_COL_IDX
(
u
);
if
(
gRes
[
gResIdx
]
->
colInfo
[
cidx
].
info
==
NULL
)
{
...
...
@@ -2161,6 +2197,9 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t
++
gResIdx
;
}
if
(
hasExpr
)
{
FILTER_CLR_FLAG
(
info
->
status
,
FI_STATUS_REWRITE
);
}
tfree
(
colIdx
);
*
gResNum
=
gResIdx
;
...
...
@@ -2175,6 +2214,10 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t
void
filterCheckColConflict
(
SFilterGroupCtx
*
gRes1
,
SFilterGroupCtx
*
gRes2
,
bool
*
conflict
)
{
uint32_t
idx1
=
0
,
idx2
=
0
,
m
=
0
,
n
=
0
;
bool
equal
=
false
;
if
(
gRes1
->
hasExpr
||
gRes2
->
hasExpr
)
{
*
conflict
=
true
;
return
;
}
for
(;
m
<
gRes1
->
colNum
;
++
m
)
{
idx1
=
gRes1
->
colIdx
[
m
];
...
...
@@ -2647,7 +2690,12 @@ int32_t filterGenerateComInfo(SFilterInfo *info) {
info
->
cunits
[
i
].
rfunc
=
filterGetRangeCompFuncFromOptrs
(
unit
->
compare
.
optr
,
unit
->
compare
.
optr2
);
info
->
cunits
[
i
].
optr
=
FILTER_UNIT_OPTR
(
unit
);
info
->
cunits
[
i
].
colData
=
NULL
;
info
->
cunits
[
i
].
colId
=
FILTER_UNIT_COL_ID
(
info
,
unit
);
info
->
cunits
[
i
].
expr
=
NULL
;
if
(
unit
->
left
.
type
==
FLD_TYPE_COLUMN
)
{
info
->
cunits
[
i
].
colId
=
FILTER_UNIT_COL_ID
(
info
,
unit
);
}
else
if
(
unit
->
left
.
type
==
FLD_TYPE_EXPR
)
{
info
->
cunits
[
i
].
expr
=
FILTER_GET_FIELD_DESC
(
FILTER_GET_FIELD
(
info
,
unit
->
left
));
}
if
(
unit
->
right
.
type
==
FLD_TYPE_VALUE
)
{
if
(
FILTER_UNIT_DATA_TYPE
(
unit
)
==
TSDB_DATA_TYPE_JSON
){
// json value is tVariant
...
...
@@ -2663,8 +2711,12 @@ int32_t filterGenerateComInfo(SFilterInfo *info) {
}
else
{
info
->
cunits
[
i
].
valData2
=
info
->
cunits
[
i
].
valData
;
}
info
->
cunits
[
i
].
dataSize
=
FILTER_UNIT_COL_SIZE
(
info
,
unit
);
if
(
unit
->
left
.
type
==
FLD_TYPE_COLUMN
)
{
info
->
cunits
[
i
].
dataSize
=
FILTER_UNIT_COL_SIZE
(
info
,
unit
);
}
else
{
info
->
cunits
[
i
].
dataSize
=
FILTER_GET_EXPR_SIZE
(
info
,
unit
->
left
);
}
info
->
cunits
[
i
].
dataType
=
FILTER_UNIT_DATA_TYPE
(
unit
);
}
...
...
@@ -2674,8 +2726,14 @@ int32_t filterGenerateComInfo(SFilterInfo *info) {
int32_t
filterUpdateComUnits
(
SFilterInfo
*
info
)
{
for
(
uint32_t
i
=
0
;
i
<
info
->
unitNum
;
++
i
)
{
SFilterUnit
*
unit
=
&
info
->
units
[
i
];
info
->
cunits
[
i
].
colData
=
FILTER_UNIT_COL_DATA
(
info
,
unit
,
0
);
if
(
unit
->
left
.
type
==
FLD_TYPE_EXPR
)
{
SFilterField
*
t
=
FILTER_UNIT_LEFT_FIELD
(
info
,
unit
);
info
->
cunits
[
i
].
colData
=
NULL
;
info
->
cunits
[
i
].
exprData
=
t
->
data
;
}
else
{
info
->
cunits
[
i
].
colData
=
FILTER_UNIT_COL_DATA
(
info
,
unit
,
0
);
info
->
cunits
[
i
].
exprData
=
NULL
;
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2924,6 +2982,11 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p,
int32_t
filterExecuteBasedOnStatis
(
SFilterInfo
*
info
,
int32_t
numOfRows
,
int8_t
**
p
,
SDataStatis
*
statis
,
int16_t
numOfCols
,
bool
*
all
)
{
for
(
uint32_t
i
=
0
;
i
<
info
->
unitNum
;
++
i
)
{
if
(
info
->
cunits
[
i
].
expr
)
{
return
1
;
}
}
if
(
statis
&&
numOfRows
>=
FILTER_RM_UNIT_MIN_ROWS
)
{
info
->
blkFlag
=
0
;
...
...
@@ -2954,6 +3017,20 @@ _return:
return
TSDB_CODE_SUCCESS
;
}
char
*
getExprColumnData
(
void
*
param
,
const
char
*
name
,
int32_t
colId
)
{
void
*
data
=
NULL
;
getColumnDataFromId
(
param
,
colId
,
&
data
);
return
(
char
*
)
data
;
}
void
*
filterExprTraverse
(
SFilterInfo
*
info
,
int32_t
numOfRows
,
int16_t
numOfCols
)
{
tExprOperandInfo
output
;
output
.
data
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
SSDataBlock
*
pBlock
=
(
SSDataBlock
*
)
info
->
cunits
[
0
].
exprData
;
SColumnDataParam
param
=
{.
numOfCols
=
numOfCols
,
.
pDataBlock
=
(
SArray
*
)
pBlock
};
exprTreeNodeTraverse
(
info
->
cunits
[
0
].
expr
,
numOfRows
,
&
output
,
&
param
,
TSDB_ORDER_ASC
,
getExprColumnData
);
return
output
.
data
;
}
static
FORCE_INLINE
bool
filterExecuteImplAll
(
void
*
info
,
int32_t
numOfRows
,
int8_t
**
p
,
SDataStatis
*
statis
,
int16_t
numOfCols
)
{
return
true
;
...
...
@@ -2964,18 +3041,26 @@ static FORCE_INLINE bool filterExecuteImplEmpty(void *info, int32_t numOfRows, i
static
FORCE_INLINE
bool
filterExecuteImplIsNull
(
void
*
pinfo
,
int32_t
numOfRows
,
int8_t
**
p
,
SDataStatis
*
statis
,
int16_t
numOfCols
)
{
SFilterInfo
*
info
=
(
SFilterInfo
*
)
pinfo
;
bool
all
=
true
;
char
*
exprData
=
NULL
;
uint32_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
NULL
;
if
(
filterExecuteBasedOnStatis
(
info
,
numOfRows
,
p
,
statis
,
numOfCols
,
&
all
)
==
0
)
{
return
all
;
}
if
(
info
->
cunits
[
0
].
expr
)
{
exprData
=
filterExprTraverse
(
info
,
numOfRows
,
numOfCols
);
}
else
{
exprData
=
info
->
cunits
[
uidx
].
colData
;
}
if
(
*
p
==
NULL
)
{
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
uint32_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
(
char
*
)
info
->
cunits
[
uidx
].
colData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
colData
=
(
char
*
)
exprData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
if
(
info
->
cunits
[
uidx
].
dataType
==
TSDB_DATA_TYPE_JSON
){
if
(
!
colData
){
// for json->'key' is null
(
*
p
)[
i
]
=
1
;
...
...
@@ -2993,23 +3078,35 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows,
}
}
if
(
info
->
cunits
[
0
].
expr
)
{
tfree
(
exprData
);
}
return
all
;
}
static
FORCE_INLINE
bool
filterExecuteImplNotNull
(
void
*
pinfo
,
int32_t
numOfRows
,
int8_t
**
p
,
SDataStatis
*
statis
,
int16_t
numOfCols
)
{
SFilterInfo
*
info
=
(
SFilterInfo
*
)
pinfo
;
bool
all
=
true
;
char
*
exprData
=
NULL
;
uint32_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
NULL
;
if
(
filterExecuteBasedOnStatis
(
info
,
numOfRows
,
p
,
statis
,
numOfCols
,
&
all
)
==
0
)
{
return
all
;
}
if
(
info
->
cunits
[
0
].
expr
)
{
exprData
=
filterExprTraverse
(
info
,
numOfRows
,
numOfCols
);
}
else
{
exprData
=
info
->
cunits
[
uidx
].
colData
;
}
if
(
*
p
==
NULL
)
{
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
uint32_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
(
char
*
)
info
->
cunits
[
uidx
].
colData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
colData
=
(
char
*
)
exprData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
if
(
info
->
cunits
[
uidx
].
dataType
==
TSDB_DATA_TYPE_JSON
){
if
(
!
colData
)
{
// for json->'key' is not null
...
...
@@ -3029,6 +3126,10 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows
}
}
if
(
info
->
cunits
[
0
].
expr
)
{
tfree
(
exprData
);
}
return
all
;
}
...
...
@@ -3082,11 +3183,16 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SDataSta
void
*
valData
=
info
->
cunits
[
0
].
valData
;
void
*
valData2
=
info
->
cunits
[
0
].
valData2
;
__compar_fn_t
func
=
gDataCompare
[
info
->
cunits
[
0
].
func
];
char
*
exprData
=
NULL
;
if
(
filterExecuteBasedOnStatis
(
info
,
numOfRows
,
p
,
statis
,
numOfCols
,
&
all
)
==
0
)
{
return
all
;
}
if
(
info
->
cunits
[
0
].
expr
)
{
exprData
=
colData
=
filterExprTraverse
(
info
,
numOfRows
,
numOfCols
);
}
if
(
*
p
==
NULL
)
{
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
}
...
...
@@ -3106,6 +3212,9 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SDataSta
colData
+=
dataSize
;
}
if
(
info
->
cunits
[
0
].
expr
)
{
tfree
(
exprData
);
}
return
all
;
}
...
...
@@ -3113,18 +3222,26 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SDataSta
bool
filterExecuteImplMisc
(
void
*
pinfo
,
int32_t
numOfRows
,
int8_t
**
p
,
SDataStatis
*
statis
,
int16_t
numOfCols
)
{
SFilterInfo
*
info
=
(
SFilterInfo
*
)
pinfo
;
bool
all
=
true
;
char
*
exprData
=
NULL
;
uint32_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
NULL
;
if
(
filterExecuteBasedOnStatis
(
info
,
numOfRows
,
p
,
statis
,
numOfCols
,
&
all
)
==
0
)
{
return
all
;
}
if
(
info
->
cunits
[
0
].
expr
)
{
exprData
=
filterExprTraverse
(
info
,
numOfRows
,
numOfCols
);
}
else
{
exprData
=
info
->
cunits
[
uidx
].
colData
;
}
if
(
*
p
==
NULL
)
{
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
uint32_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
(
char
*
)
info
->
cunits
[
uidx
].
colData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
colData
=
(
char
*
)
exprData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
if
(
colData
==
NULL
||
isNull
(
colData
,
info
->
cunits
[
uidx
].
dataType
))
{
(
*
p
)[
i
]
=
0
;
all
=
false
;
...
...
@@ -3153,6 +3270,10 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
}
}
if
(
info
->
cunits
[
0
].
expr
)
{
tfree
(
exprData
);
}
return
all
;
}
...
...
@@ -3168,6 +3289,27 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
}
SArray
*
tmpData
=
NULL
;
for
(
uint32_t
g
=
0
;
g
<
info
->
groupNum
;
++
g
)
{
SFilterGroup
*
group
=
&
info
->
groups
[
g
];
for
(
uint32_t
u
=
0
;
u
<
group
->
unitNum
;
++
u
)
{
uint32_t
uidx
=
group
->
unitIdxs
[
u
];
SFilterComUnit
*
cunit
=
&
info
->
cunits
[
uidx
];
if
(
cunit
->
expr
)
{
if
(
!
tmpData
)
{
tmpData
=
taosArrayInit
(
10
,
POINTER_BYTES
);
}
tExprOperandInfo
output
;
output
.
data
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
taosArrayPush
(
tmpData
,
output
.
data
);
SSDataBlock
*
pBlock
=
(
SSDataBlock
*
)
cunit
->
exprData
;
SColumnDataParam
param
=
{.
numOfCols
=
numOfCols
,
.
pDataBlock
=
(
SArray
*
)
pBlock
};
exprTreeNodeTraverse
(
cunit
->
expr
,
numOfRows
,
&
output
,
&
param
,
TSDB_ORDER_ASC
,
getExprColumnData
);
cunit
->
colData
=
(
char
*
)
output
.
data
;
}
}
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
//FILTER_UNIT_CLR_F(info);
...
...
@@ -3229,6 +3371,9 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
}
}
if
(
tmpData
)
{
taosArrayDestroy
(
&
tmpData
);
}
return
all
;
}
...
...
@@ -3318,7 +3463,8 @@ _return:
int32_t
filterSetColFieldData
(
SFilterInfo
*
info
,
void
*
param
,
filer_get_col_from_id
fp
)
{
CHK_LRET
(
info
==
NULL
,
TSDB_CODE_QRY_APP_ERROR
,
"info NULL"
);
CHK_LRET
(
info
->
fields
[
FLD_TYPE_COLUMN
].
num
<=
0
,
TSDB_CODE_QRY_APP_ERROR
,
"no column fileds"
);
CHK_LRET
(
info
->
fields
[
FLD_TYPE_COLUMN
].
num
<=
0
&&
info
->
fields
[
FLD_TYPE_EXPR
].
num
<=
0
,
TSDB_CODE_QRY_APP_ERROR
,
"no column fileds"
);
if
(
FILTER_ALL_RES
(
info
)
||
FILTER_EMPTY_RES
(
info
))
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -3331,6 +3477,11 @@ int32_t filterSetColFieldData(SFilterInfo *info, void *param, filer_get_col_from
(
*
fp
)(
param
,
sch
->
colId
,
&
fi
->
data
);
}
for
(
uint32_t
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_EXPR
].
num
;
++
i
)
{
SFilterField
*
fi
=
&
info
->
fields
[
FLD_TYPE_EXPR
].
fields
[
i
];
(
*
fp
)(
param
,
INT32_MAX
,
&
fi
->
data
);
}
filterUpdateComUnits
(
info
);
return
TSDB_CODE_SUCCESS
;
...
...
src/query/src/qSqlParser.c
浏览文件 @
6b818f2c
...
...
@@ -345,7 +345,9 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
if
((
pLeft
!=
NULL
&&
pRight
!=
NULL
)
&&
(
optrType
==
TK_PLUS
||
optrType
==
TK_MINUS
||
optrType
==
TK_STAR
||
optrType
==
TK_DIVIDE
||
optrType
==
TK_REM
||
optrType
==
TK_EQ
||
optrType
==
TK_NE
||
optrType
==
TK_LT
||
optrType
==
TK_GT
||
optrType
==
TK_LE
||
optrType
==
TK_GE
||
optrType
==
TK_AND
||
optrType
==
TK_OR
))
{
optrType
==
TK_AND
||
optrType
==
TK_OR
||
optrType
==
TK_BITAND
||
optrType
==
TK_BITOR
||
optrType
==
TK_BITXOR
||
optrType
==
TK_LSHIFT
||
optrType
==
TK_RSHIFT
))
{
/*
* if a exprToken is noted as the TK_TIMESTAMP, the time precision is microsecond
* Otherwise, the time precision is adaptive, determined by the time precision from databases.
...
...
@@ -422,6 +424,61 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
pExpr
->
value
.
i64
=
(
pLeft
->
value
.
i64
||
pRight
->
value
.
i64
)
?
1
:
0
;
break
;
}
case
TK_BITAND
:
{
if
(
pLeft
->
tokenId
==
TK_BOOL
||
pRight
->
tokenId
==
TK_BOOL
||
pLeft
->
tokenId
==
TK_FLOAT
||
pRight
->
tokenId
==
TK_FLOAT
||
pLeft
->
tokenId
==
TK_TIMESTAMP
||
pRight
->
tokenId
==
TK_TIMESTAMP
)
{
pExpr
->
value
.
i64
=
TSDB_DATA_BIGINT_NULL
;
}
else
{
pExpr
->
value
.
i64
=
pLeft
->
value
.
i64
&
pRight
->
value
.
i64
;
}
break
;
}
case
TK_BITOR
:
{
if
(
pLeft
->
tokenId
==
TK_BOOL
||
pRight
->
tokenId
==
TK_BOOL
||
pLeft
->
tokenId
==
TK_FLOAT
||
pRight
->
tokenId
==
TK_FLOAT
||
pLeft
->
tokenId
==
TK_TIMESTAMP
||
pRight
->
tokenId
==
TK_TIMESTAMP
)
{
pExpr
->
value
.
i64
=
TSDB_DATA_BIGINT_NULL
;
}
else
{
pExpr
->
value
.
i64
=
pLeft
->
value
.
i64
|
pRight
->
value
.
i64
;
}
break
;
}
case
TK_BITXOR
:
{
if
(
pLeft
->
tokenId
==
TK_BOOL
||
pRight
->
tokenId
==
TK_BOOL
||
pLeft
->
tokenId
==
TK_FLOAT
||
pRight
->
tokenId
==
TK_FLOAT
||
pLeft
->
tokenId
==
TK_TIMESTAMP
||
pRight
->
tokenId
==
TK_TIMESTAMP
)
{
pExpr
->
value
.
i64
=
TSDB_DATA_BIGINT_NULL
;
}
else
{
pExpr
->
value
.
i64
=
pLeft
->
value
.
i64
^
pRight
->
value
.
i64
;
}
break
;
}
case
TK_LSHIFT
:
{
if
(
pLeft
->
tokenId
==
TK_BOOL
||
pRight
->
tokenId
==
TK_BOOL
||
pLeft
->
tokenId
==
TK_FLOAT
||
pRight
->
tokenId
==
TK_FLOAT
||
pLeft
->
tokenId
==
TK_TIMESTAMP
||
pRight
->
tokenId
==
TK_TIMESTAMP
)
{
pExpr
->
value
.
i64
=
TSDB_DATA_BIGINT_NULL
;
}
else
{
pExpr
->
value
.
i64
=
pLeft
->
value
.
i64
<<
pRight
->
value
.
i64
;
}
break
;
}
case
TK_RSHIFT
:
{
if
(
pLeft
->
tokenId
==
TK_BOOL
||
pRight
->
tokenId
==
TK_BOOL
||
pLeft
->
tokenId
==
TK_FLOAT
||
pRight
->
tokenId
==
TK_FLOAT
||
pLeft
->
tokenId
==
TK_TIMESTAMP
||
pRight
->
tokenId
==
TK_TIMESTAMP
)
{
pExpr
->
value
.
i64
=
TSDB_DATA_BIGINT_NULL
;
}
else
{
pExpr
->
value
.
i64
=
pLeft
->
value
.
i64
>>
pRight
->
value
.
i64
;
}
break
;
}
}
tSqlExprDestroy
(
pLeft
);
...
...
@@ -533,6 +590,13 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
pExpr
->
value
.
i64
=
(
left
||
right
)
?
1
:
0
;
break
;
}
case
TK_BITAND
:
case
TK_BITOR
:
case
TK_BITXOR
:
case
TK_LSHIFT
:
case
TK_RSHIFT
:
pExpr
->
value
.
i64
=
TSDB_DATA_DOUBLE_NULL
;
break
;
}
tSqlExprDestroy
(
pLeft
);
...
...
@@ -566,6 +630,12 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
}
pExpr
->
pRight
=
pRight
;
if
(
optrType
==
TK_BITNOT
)
{
pExpr
->
exprToken
.
z
=
pLeft
->
exprToken
.
z
-
1
;
pExpr
->
exprToken
.
n
=
pLeft
->
exprToken
.
n
+
1
;
pExpr
->
exprToken
.
type
=
pLeft
->
exprToken
.
type
;
}
}
return
pExpr
;
...
...
@@ -1488,4 +1558,4 @@ SDelData* tGetDelData(SStrToken* pTableName, SStrToken* existsCheck, tSqlExpr* p
pDelData
->
pWhere
=
pWhere
;
return
pDelData
;
}
\ No newline at end of file
}
src/query/src/sql.c
浏览文件 @
6b818f2c
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbRead.c
浏览文件 @
6b818f2c
...
...
@@ -156,7 +156,7 @@ typedef struct STsdbQueryHandle {
SArray
*
prev
;
// previous row which is before than time window
SArray
*
next
;
// next row which is after the query time window
SIOCostSummary
cost
;
// callback
readover_callback
readover_cb
;
void
*
param
;
...
...
@@ -173,6 +173,11 @@ typedef struct SRange {
int32_t
to
;
}
SRange
;
typedef
struct
STagBlockInfo
{
SSkipListNode
*
pSkipListNode
;
SArray
*
pBlock
;
}
STagBlockInfo
;
static
STimeWindow
updateLastrowForEachGroup
(
STableGroupInfo
*
groupList
);
static
int32_t
checkForCachedLastRow
(
STsdbQueryHandle
*
pQueryHandle
,
STableGroupInfo
*
groupList
);
static
int32_t
checkForCachedLast
(
STsdbQueryHandle
*
pQueryHandle
);
...
...
@@ -4333,7 +4338,15 @@ static FORCE_INLINE int32_t tsdbGetTagDataFromId(void *param, int32_t id, void *
return
TSDB_CODE_SUCCESS
;
}
static
FORCE_INLINE
int32_t
tsdbGetTagData
(
void
*
param
,
int32_t
id
,
void
**
data
)
{
STagBlockInfo
*
pInfo
=
(
STagBlockInfo
*
)
param
;
if
(
id
==
INT32_MAX
)
{
*
data
=
pInfo
->
pBlock
;
}
else
{
return
tsdbGetTagDataFromId
(
pInfo
->
pSkipListNode
,
id
,
data
);
}
return
TSDB_CODE_SUCCESS
;
}
static
void
queryIndexedColumn
(
SSkipList
*
pSkipList
,
void
*
filterInfo
,
SArray
*
res
)
{
SSkipListIterator
*
iter
=
NULL
;
...
...
@@ -4388,26 +4401,77 @@ static void queryIndexedColumn(SSkipList* pSkipList, void* filterInfo, SArray* r
tsdbDebug
(
"filter index column end"
);
}
static
void
getAllExprColId
(
tExprNode
*
pExpr
,
SArray
*
array
)
{
if
(
!
pExpr
)
{
return
;
}
if
(
pExpr
->
nodeType
==
TSQL_NODE_FUNC
)
{
for
(
int32_t
i
=
0
;
i
<
pExpr
->
_func
.
numChildren
;
++
i
)
{
getAllExprColId
(
pExpr
->
_func
.
pChildren
[
i
],
array
);
}
}
else
if
(
pExpr
->
nodeType
==
TSQL_NODE_EXPR
)
{
getAllExprColId
(
pExpr
->
_node
.
pLeft
,
array
);
getAllExprColId
(
pExpr
->
_node
.
pRight
,
array
);
}
else
if
(
pExpr
->
nodeType
==
TSQL_NODE_COL
)
{
taosArrayPush
(
array
,
&
pExpr
->
pSchema
->
colId
);
}
}
static
void
getAllFilterExprColId
(
SFilterFields
*
pSf
,
SArray
*
array
)
{
for
(
uint32_t
i
=
0
;
i
<
pSf
->
num
;
++
i
)
{
SFilterField
*
fi
=
&
(
pSf
->
fields
[
i
]);
if
(
FILTER_GET_TYPE
(
fi
->
flag
)
==
FLD_TYPE_EXPR
)
{
getAllExprColId
(
fi
->
desc
,
array
);
}
}
taosArraySort
(
array
,
getComparFunc
(
TSDB_DATA_TYPE_SMALLINT
,
0
));
taosArrayRemoveDuplicate
(
array
,
getComparFunc
(
TSDB_DATA_TYPE_SMALLINT
,
0
),
NULL
);
}
static
void
queryIndexlessColumn
(
SSkipList
*
pSkipList
,
void
*
filterInfo
,
SArray
*
res
)
{
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
pSkipList
);
int8_t
*
addToResult
=
NULL
;
SFilterInfo
*
sfInfo
=
(
SFilterInfo
*
)
filterInfo
;
SArray
*
array
=
NULL
;
SArray
*
pDataBlock
=
NULL
;
if
(
sfInfo
->
fields
[
FLD_TYPE_EXPR
].
num
>
0
)
{
array
=
taosArrayInit
(
10
,
sizeof
(
int16_t
));
getAllFilterExprColId
(
&
(
sfInfo
->
fields
[
FLD_TYPE_EXPR
]),
array
);
}
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
filterSetColFieldData
(
filterInfo
,
pNode
,
tsdbGetTagDataFromId
);
char
*
pData
=
SL_GET_NODE_DATA
(
pNode
);
if
(
sfInfo
->
fields
[
FLD_TYPE_EXPR
].
num
>
0
)
{
pDataBlock
=
taosArrayInit
(
10
,
sizeof
(
SColumnInfoData
));
size_t
num
=
taosArrayGetSize
(
array
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int16_t
*
pColId
=
taosArrayGet
(
array
,
i
);
void
*
data
=
NULL
;
tsdbGetTagDataFromId
(
pNode
,
*
pColId
,
&
data
);
SColumnInfoData
colData
=
{{
0
}};
colData
.
pData
=
data
;
colData
.
info
.
colId
=
*
pColId
;
taosArrayPush
(
pDataBlock
,
&
colData
);
}
}
STagBlockInfo
stInfo
=
{.
pSkipListNode
=
pNode
,
.
pBlock
=
pDataBlock
};
filterSetColFieldData
(
filterInfo
,
&
stInfo
,
tsdbGetTagData
);
bool
all
=
filterExecute
(
filterInfo
,
1
,
&
addToResult
,
NULL
,
0
);
char
*
pData
=
SL_GET_NODE_DATA
(
pNode
);
int16_t
numOfCols
=
array
?
(
int16_t
)
taosArrayGetSize
(
array
)
:
0
;
bool
all
=
filterExecute
(
filterInfo
,
1
,
&
addToResult
,
NULL
,
numOfCols
);
if
(
all
||
(
addToResult
&&
*
addToResult
))
{
STableKeyInfo
info
=
{.
pTable
=
(
void
*
)
pData
,
.
lastKey
=
TSKEY_INITIAL_VAL
};
taosArrayPush
(
res
,
&
info
);
}
taosArrayDestroy
(
&
pDataBlock
);
}
taosArrayDestroy
(
&
array
);
tfree
(
addToResult
);
tSkipListDestroyIter
(
iter
);
...
...
@@ -4696,4 +4760,4 @@ void tsdbAddScanCallback(TsdbQueryHandleT* queryHandle, readover_callback callba
int32_t
tsdbTableTid
(
void
*
pTable
)
{
STable
*
p
=
(
STable
*
)
pTable
;
return
p
->
tableId
.
tid
;
}
\ No newline at end of file
}
src/util/src/ttokenizer.c
浏览文件 @
6b818f2c
...
...
@@ -58,6 +58,7 @@ static SKeyword keywordTable[] = {
{
"IN"
,
TK_IN
},
{
"BITAND"
,
TK_BITAND
},
{
"BITOR"
,
TK_BITOR
},
{
"BITXOR"
,
TK_BITXOR
},
{
"LSHIFT"
,
TK_LSHIFT
},
{
"RSHIFT"
,
TK_RSHIFT
},
{
"PLUS"
,
TK_PLUS
},
...
...
@@ -411,6 +412,10 @@ uint32_t tGetToken(char* z, uint32_t* tokenId) {
*
tokenId
=
TK_BITNOT
;
return
1
;
}
case
'^'
:
{
*
tokenId
=
TK_BITXOR
;
return
1
;
}
case
'?'
:
{
*
tokenId
=
TK_QUESTION
;
return
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录