Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
079e063b
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看板
提交
079e063b
编写于
8月 03, 2021
作者:
W
wpan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test case
上级
f4974fd8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
97 addition
and
112 deletion
+97
-112
src/common/src/texpr.c
src/common/src/texpr.c
+1
-1
src/query/inc/qFilter.h
src/query/inc/qFilter.h
+6
-14
src/query/src/qFilter.c
src/query/src/qFilter.c
+69
-94
src/query/tests/rangeMergeTest.cpp
src/query/tests/rangeMergeTest.cpp
+4
-0
tests/script/general/parser/condition_query.sim
tests/script/general/parser/condition_query.sim
+17
-3
未找到文件。
src/common/src/texpr.c
浏览文件 @
079e063b
...
...
@@ -586,7 +586,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t
if
(
bufLen
<
t
)
{
tmp
=
realloc
(
tmp
,
t
*
TSDB_NCHAR_SIZE
);
bufLen
=
t
;
bufLen
=
(
int32_t
)
t
;
}
switch
(
tType
)
{
...
...
src/query/inc/qFilter.h
浏览文件 @
079e063b
...
...
@@ -51,14 +51,11 @@ enum {
};
enum
{
RA_EXCLUDE
=
1
,
RA_INCLUDE
=
2
,
RA_NULL
=
4
,
RA
NGE_FLG
_EXCLUDE
=
1
,
RA
NGE_FLG
_INCLUDE
=
2
,
RA
NGE_FLG
_NULL
=
4
,
};
#define RA_EMPTY (RA_EXCLUDE|RA_INCLUDE)
#define RA_ALL (RA_EXCLUDE|RA_INCLUDE)
enum
{
FI_OPTION_NO_REWRITE
=
1
,
FI_OPTION_TIMESTAMP
=
2
,
...
...
@@ -232,7 +229,7 @@ typedef struct SFilterInfo {
#define SIMPLE_COPY_VALUES(dst, src) *((int64_t *)dst) = *((int64_t *)src)
#define FILTER_PACKAGE_UNIT_HASH_KEY(v, optr, idx1, idx2) do { char *_t = (char *)v; _t[0] = optr; *(uint16_t *)(_t + 1) = idx1; *(uint16_t *)(_t + 3) = idx2; } while (0)
#define FILTER_GREATER(cr,sflag,eflag) ((cr > 0) || ((cr == 0) && (FILTER_GET_FLAG(sflag,RA
_EXCLUDE) || FILTER_GET_FLAG(eflag,RA
_EXCLUDE))))
#define FILTER_GREATER(cr,sflag,eflag) ((cr > 0) || ((cr == 0) && (FILTER_GET_FLAG(sflag,RA
NGE_FLG_EXCLUDE) || FILTER_GET_FLAG(eflag,RANGE_FLG
_EXCLUDE))))
#define FILTER_COPY_RA(dst, src) do { (dst)->sflag = (src)->sflag; (dst)->eflag = (src)->eflag; (dst)->s = (src)->s; (dst)->e = (src)->e; } while (0)
#define RESET_RANGE(ctx, r) do { (r)->next = (ctx)->rf; (ctx)->rf = r; } while (0)
...
...
@@ -243,11 +240,11 @@ typedef struct SFilterInfo {
#define ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { return _code; } } while (0)
#define ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { qError(__VA_ARGS__); return _code; } } while (0)
#define ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { goto _
err_
return; } } while (0)
#define ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { goto _return; } } while (0)
#define CHK_RETV(c) do { if (c) { return; } } while (0)
#define CHK_RET(c, r) do { if (c) { return r; } } while (0)
#define CHK_JMP(c) do { if (c) { goto _
err_
return; } } while (0)
#define CHK_JMP(c) do { if (c) { goto _return; } } while (0)
#define CHK_LRETV(c,...) do { if (c) { qError(__VA_ARGS__); return; } } while (0)
#define CHK_LRET(c, r,...) do { if (c) { qError(__VA_ARGS__); return r; } } while (0)
...
...
@@ -291,15 +288,10 @@ typedef int32_t(*filter_desc_compare_func)(const void *, const void *);
extern
int32_t
filterInitFromTree
(
tExprNode
*
tree
,
SFilterInfo
**
pinfo
,
uint32_t
options
);
extern
bool
filterExecute
(
SFilterInfo
*
info
,
int32_t
numOfRows
,
int8_t
*
p
);
extern
int32_t
filterSetColFieldData
(
SFilterInfo
*
info
,
int16_t
colId
,
void
*
data
);
extern
void
*
filterInitRangeCtx
(
int32_t
type
,
int32_t
options
);
extern
int32_t
filterGetRangeNum
(
void
*
h
,
int32_t
*
num
);
extern
int32_t
filterGetRangeRes
(
void
*
h
,
SFilterRange
*
ra
);
extern
int32_t
filterFreeRangeCtx
(
void
*
h
);
extern
int32_t
filterGetTimeRange
(
SFilterInfo
*
info
,
STimeWindow
*
win
);
extern
int32_t
filterConverNcharColumns
(
SFilterInfo
*
pFilterInfo
,
int32_t
rows
,
bool
*
gotNchar
);
extern
int32_t
filterFreeNcharColumns
(
SFilterInfo
*
pFilterInfo
);
extern
void
filterFreeInfo
(
SFilterInfo
*
info
);
extern
bool
filterIsEmptyRes
(
SFilterInfo
*
info
);
extern
bool
filterRangeExecute
(
SFilterInfo
*
info
,
SDataStatis
*
pDataStatis
,
int32_t
numOfCols
,
int32_t
numOfRows
);
#ifdef __cplusplus
...
...
src/query/src/qFilter.c
浏览文件 @
079e063b
...
...
@@ -83,31 +83,31 @@ bool filterRangeCompie (const void *minv, const void *maxv, const void *minr, co
}
rangeCompFunc
filterGetRangeCompFunc
(
char
sflag
,
char
eflag
)
{
if
(
FILTER_GET_FLAG
(
sflag
,
RA_NULL
))
{
if
(
FILTER_GET_FLAG
(
eflag
,
RA_EXCLUDE
))
{
if
(
FILTER_GET_FLAG
(
sflag
,
RA
NGE_FLG
_NULL
))
{
if
(
FILTER_GET_FLAG
(
eflag
,
RA
NGE_FLG
_EXCLUDE
))
{
return
filterRangeCompLe
;
}
return
filterRangeCompLi
;
}
if
(
FILTER_GET_FLAG
(
eflag
,
RA_NULL
))
{
if
(
FILTER_GET_FLAG
(
sflag
,
RA_EXCLUDE
))
{
if
(
FILTER_GET_FLAG
(
eflag
,
RA
NGE_FLG
_NULL
))
{
if
(
FILTER_GET_FLAG
(
sflag
,
RA
NGE_FLG
_EXCLUDE
))
{
return
filterRangeCompGe
;
}
return
filterRangeCompGi
;
}
if
(
FILTER_GET_FLAG
(
sflag
,
RA_EXCLUDE
))
{
if
(
FILTER_GET_FLAG
(
eflag
,
RA_EXCLUDE
))
{
if
(
FILTER_GET_FLAG
(
sflag
,
RA
NGE_FLG
_EXCLUDE
))
{
if
(
FILTER_GET_FLAG
(
eflag
,
RA
NGE_FLG
_EXCLUDE
))
{
return
filterRangeCompee
;
}
return
filterRangeCompei
;
}
if
(
FILTER_GET_FLAG
(
eflag
,
RA_EXCLUDE
))
{
if
(
FILTER_GET_FLAG
(
eflag
,
RA
NGE_FLG
_EXCLUDE
))
{
return
filterRangeCompie
;
}
...
...
@@ -207,22 +207,22 @@ int32_t filterReuseRangeCtx(SFilterRangeCtx *ctx, int32_t type, int32_t options)
int32_t
filterConvertRange
(
SFilterRangeCtx
*
cur
,
SFilterRange
*
ra
,
bool
*
notNull
)
{
if
(
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_NULL
))
{
if
(
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RA
NGE_FLG
_NULL
))
{
int32_t
sr
=
cur
->
pCompareFunc
(
&
ra
->
s
,
getDataMin
(
cur
->
type
));
if
(
sr
==
0
)
{
FILTER_SET_FLAG
(
ra
->
sflag
,
RA_NULL
);
FILTER_SET_FLAG
(
ra
->
sflag
,
RA
NGE_FLG
_NULL
);
}
}
if
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_NULL
))
{
if
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RA
NGE_FLG
_NULL
))
{
int32_t
er
=
cur
->
pCompareFunc
(
&
ra
->
e
,
getDataMax
(
cur
->
type
));
if
(
er
==
0
)
{
FILTER_SET_FLAG
(
ra
->
eflag
,
RA_NULL
);
FILTER_SET_FLAG
(
ra
->
eflag
,
RA
NGE_FLG
_NULL
);
}
}
if
(
FILTER_GET_FLAG
(
ra
->
sflag
,
RA
_NULL
)
&&
FILTER_GET_FLAG
(
ra
->
eflag
,
RA
_NULL
))
{
if
(
FILTER_GET_FLAG
(
ra
->
sflag
,
RA
NGE_FLG_NULL
)
&&
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG
_NULL
))
{
*
notNull
=
true
;
}
else
{
*
notNull
=
false
;
...
...
@@ -396,12 +396,12 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) {
int32_t
filterAddRange
(
void
*
h
,
SFilterRange
*
ra
,
int32_t
optr
)
{
SFilterRangeCtx
*
ctx
=
(
SFilterRangeCtx
*
)
h
;
if
(
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_NULL
))
{
if
(
FILTER_GET_FLAG
(
ra
->
sflag
,
RA
NGE_FLG
_NULL
))
{
SIMPLE_COPY_VALUES
(
&
ra
->
s
,
getDataMin
(
ctx
->
type
));
//FILTER_CLR_FLAG(ra->sflag, RA_NULL);
}
if
(
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_NULL
))
{
if
(
FILTER_GET_FLAG
(
ra
->
eflag
,
RA
NGE_FLG
_NULL
))
{
SIMPLE_COPY_VALUES
(
&
ra
->
e
,
getDataMax
(
ctx
->
type
));
//FILTER_CLR_FLAG(ra->eflag, RA_NULL);
}
...
...
@@ -597,8 +597,6 @@ int32_t filterFreeRangeCtx(void* h) {
int32_t
filterDetachCnfGroup
(
SFilterGroup
*
gp1
,
SFilterGroup
*
gp2
,
SArray
*
group
)
{
SFilterGroup
gp
=
{
0
};
//TODO CHECK DUP
gp
.
unitNum
=
gp1
->
unitNum
+
gp2
->
unitNum
;
gp
.
unitIdxs
=
calloc
(
gp
.
unitNum
,
sizeof
(
*
gp
.
unitIdxs
));
memcpy
(
gp
.
unitIdxs
,
gp1
->
unitIdxs
,
gp1
->
unitNum
*
sizeof
(
*
gp
.
unitIdxs
));
...
...
@@ -781,7 +779,7 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi
SFilterField
*
val
=
FILTER_UNIT_RIGHT_FIELD
(
info
,
u
);
assert
(
FILTER_GET_FLAG
(
val
->
flag
,
FLD_TYPE_VALUE
));
}
else
{
assert
(
optr
==
TSDB_RELATION_ISNULL
||
optr
==
TSDB_RELATION_NOTNULL
);
assert
(
optr
==
TSDB_RELATION_ISNULL
||
optr
==
TSDB_RELATION_NOTNULL
||
optr
==
FILTER_DUMMY_EMPTY_OPTR
);
}
SFilterField
*
col
=
FILTER_UNIT_LEFT_FIELD
(
info
,
u
);
...
...
@@ -917,7 +915,7 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
continue
;
}
goto
_
err_
return
;
goto
_return
;
}
pvar
=
&
val
;
t
=
sizeof
(
val
);
...
...
@@ -932,7 +930,7 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
continue
;
}
goto
_
err_
return
;
goto
_return
;
}
pvar
=
&
val
;
t
=
sizeof
(
val
);
...
...
@@ -947,7 +945,7 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
continue
;
}
goto
_
err_
return
;
goto
_return
;
}
pvar
=
&
val
;
t
=
sizeof
(
val
);
...
...
@@ -957,7 +955,7 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
{
if
(
tVariantDump
(
&
tmpVar
,
(
char
*
)
&
val
,
tType
,
false
))
{
goto
_
err_
return
;
goto
_return
;
}
pvar
=
&
val
;
t
=
sizeof
(
val
);
...
...
@@ -965,7 +963,7 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
if
(
tVariantDump
(
&
tmpVar
,
(
char
*
)
&
val
,
tType
,
false
))
{
goto
_
err_
return
;
goto
_return
;
}
pvar
=
&
val
;
t
=
sizeof
(
val
);
...
...
@@ -979,7 +977,7 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
continue
;
}
goto
_
err_
return
;
goto
_return
;
}
pvar
=
&
val
;
t
=
sizeof
(
val
);
...
...
@@ -987,7 +985,7 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
}
case
TSDB_DATA_TYPE_BINARY
:
{
if
(
tVariantDump
(
&
tmpVar
,
tmp
,
tType
,
true
))
{
goto
_
err_
return
;
goto
_return
;
}
t
=
varDataLen
(
tmp
);
pvar
=
varDataVal
(
tmp
);
...
...
@@ -995,14 +993,14 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
}
case
TSDB_DATA_TYPE_NCHAR
:
{
if
(
tVariantDump
(
&
tmpVar
,
tmp
,
tType
,
true
))
{
goto
_
err_
return
;
goto
_return
;
}
t
=
varDataLen
(
tmp
);
pvar
=
varDataVal
(
tmp
);
break
;
}
default:
goto
_
err_
return
;
goto
_return
;
}
taosHashPut
(
pObj
,
(
char
*
)
pvar
,
t
,
&
dummy
,
sizeof
(
dummy
));
...
...
@@ -1010,12 +1008,10 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
memset
(
&
tmpVar
,
0
,
sizeof
(
tmpVar
));
}
CHK_JMP
(
taosHashGetSize
(
pObj
)
<=
0
);
*
q
=
(
void
*
)
pObj
;
pObj
=
NULL
;
_
err_
return:
_return:
tVariantDestroy
(
&
tmpVar
);
taosHashCleanup
(
pObj
);
tfree
(
tmp
);
...
...
@@ -1040,6 +1036,18 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
filterConvertSetFromBinary
((
void
**
)
&
data
,
var
->
pz
,
var
->
nLen
,
type
);
CHK_LRET
(
data
==
NULL
,
TSDB_CODE_QRY_APP_ERROR
,
"failed to convert in param"
);
if
(
taosHashGetSize
((
SHashObj
*
)
data
)
<=
0
)
{
filterAddUnit
(
info
,
FILTER_DUMMY_EMPTY_OPTR
,
&
left
,
NULL
,
&
uidx
);
SFilterGroup
fgroup
=
{
0
};
filterAddUnitToGroup
(
&
fgroup
,
uidx
);
taosArrayPush
(
group
,
&
fgroup
);
taosHashCleanup
(
data
);
return
TSDB_CODE_SUCCESS
;
}
void
*
p
=
taosHashIterate
((
SHashObj
*
)
data
,
NULL
);
while
(
p
)
{
void
*
key
=
taosHashGetDataKey
((
SHashObj
*
)
data
,
p
);
...
...
@@ -1155,9 +1163,9 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
SFilterRange
*
ra
=
&
ctx
->
rs
->
ra
;
assert
(
!
((
FILTER_GET_FLAG
(
ra
->
sflag
,
RA
_NULL
))
&&
(
FILTER_GET_FLAG
(
ra
->
eflag
,
RA
_NULL
))));
assert
(
!
((
FILTER_GET_FLAG
(
ra
->
sflag
,
RA
NGE_FLG_NULL
))
&&
(
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG
_NULL
))));
if
((
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RA
_NULL
))
&&
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RA
_NULL
)))
{
if
((
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RA
NGE_FLG_NULL
))
&&
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG
_NULL
)))
{
__compar_fn_t
func
=
getComparFunc
(
type
,
0
);
if
(
func
(
&
ra
->
s
,
&
ra
->
e
)
==
0
)
{
void
*
data
=
malloc
(
sizeof
(
int64_t
));
...
...
@@ -1169,19 +1177,19 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
}
}
if
(
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_NULL
))
{
if
(
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RA
NGE_FLG
_NULL
))
{
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
s
);
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
sflag
,
RA
NGE_FLG
_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
if
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_NULL
))
{
if
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RA
NGE_FLG
_NULL
))
{
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
e
);
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
eflag
,
RA
NGE_FLG
_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
...
...
@@ -1221,7 +1229,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
while
(
r
)
{
memset
(
g
,
0
,
sizeof
(
*
g
));
if
((
!
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA
_NULL
))
&&
(
!
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA
_NULL
)))
{
if
((
!
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA
NGE_FLG_NULL
))
&&
(
!
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RANGE_FLG
_NULL
)))
{
__compar_fn_t
func
=
getComparFunc
(
type
,
0
);
if
(
func
(
&
r
->
ra
.
s
,
&
r
->
ra
.
e
)
==
0
)
{
void
*
data
=
malloc
(
sizeof
(
int64_t
));
...
...
@@ -1237,19 +1245,19 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
}
}
if
(
!
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA_NULL
))
{
if
(
!
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA
NGE_FLG
_NULL
))
{
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
r
->
ra
.
s
);
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA
NGE_FLG
_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
if
(
!
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA_NULL
))
{
if
(
!
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA
NGE_FLG
_NULL
))
{
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
r
->
ra
.
e
);
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA
NGE_FLG
_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
...
...
@@ -1311,7 +1319,7 @@ int32_t filterTreeToGroup(tExprNode* tree, SFilterInfo *info, SArray* group) {
code
=
filterAddGroupUnitFromNode
(
info
,
tree
,
group
);
_
err_
return:
_return:
taosArrayDestroyEx
(
leftGroup
,
filterFreeGroup
);
taosArrayDestroyEx
(
rightGroup
,
filterFreeGroup
);
...
...
@@ -1410,20 +1418,20 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
while
(
r
)
{
char
str
[
256
]
=
{
0
};
int32_t
tlen
=
0
;
if
(
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA_NULL
))
{
if
(
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA
NGE_FLG
_NULL
))
{
strcat
(
str
,
"(NULL)"
);
}
else
{
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA_EXCLUDE
)
?
strcat
(
str
,
"("
)
:
strcat
(
str
,
"["
);
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA
NGE_FLG
_EXCLUDE
)
?
strcat
(
str
,
"("
)
:
strcat
(
str
,
"["
);
converToStr
(
str
+
strlen
(
str
),
ctx
->
type
,
&
r
->
ra
.
s
,
tlen
>
32
?
32
:
tlen
,
&
tlen
);
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA_EXCLUDE
)
?
strcat
(
str
,
")"
)
:
strcat
(
str
,
"]"
);
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA
NGE_FLG
_EXCLUDE
)
?
strcat
(
str
,
")"
)
:
strcat
(
str
,
"]"
);
}
strcat
(
str
,
" - "
);
if
(
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA_NULL
))
{
if
(
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA
NGE_FLG
_NULL
))
{
strcat
(
str
,
"(NULL)"
);
}
else
{
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA_EXCLUDE
)
?
strcat
(
str
,
"("
)
:
strcat
(
str
,
"["
);
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA
NGE_FLG
_EXCLUDE
)
?
strcat
(
str
,
"("
)
:
strcat
(
str
,
"["
);
converToStr
(
str
+
strlen
(
str
),
ctx
->
type
,
&
r
->
ra
.
e
,
tlen
>
32
?
32
:
tlen
,
&
tlen
);
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA_EXCLUDE
)
?
strcat
(
str
,
")"
)
:
strcat
(
str
,
"]"
);
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA
NGE_FLG
_EXCLUDE
)
?
strcat
(
str
,
")"
)
:
strcat
(
str
,
"]"
);
}
qDebug
(
"range: %s"
,
str
);
...
...
@@ -1577,7 +1585,7 @@ int32_t filterInitValFieldData(SFilterInfo *info) {
for
(
uint16_t
i
=
0
;
i
<
info
->
unitNum
;
++
i
)
{
SFilterUnit
*
unit
=
&
info
->
units
[
i
];
if
(
unit
->
right
.
type
!=
FLD_TYPE_VALUE
)
{
assert
(
unit
->
compare
.
optr
==
TSDB_RELATION_ISNULL
||
unit
->
compare
.
optr
==
TSDB_RELATION_NOTNULL
);
assert
(
unit
->
compare
.
optr
==
TSDB_RELATION_ISNULL
||
unit
->
compare
.
optr
==
TSDB_RELATION_NOTNULL
||
unit
->
compare
.
optr
==
FILTER_DUMMY_EMPTY_OPTR
);
continue
;
}
...
...
@@ -1641,7 +1649,6 @@ int32_t filterInitValFieldData(SFilterInfo *info) {
}
bool
filterDoCompare
(
SFilterUnit
*
unit
,
void
*
left
,
void
*
right
)
{
int32_t
ret
=
unit
->
compare
.
pCompareFunc
(
left
,
right
);
...
...
@@ -1689,21 +1696,21 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit* u, SFilterRangeCtx *c
switch
(
uoptr
)
{
case
TSDB_RELATION_GREATER
:
SIMPLE_COPY_VALUES
(
&
ra
.
s
,
val
);
FILTER_SET_FLAG
(
ra
.
sflag
,
RA_EXCLUDE
);
FILTER_SET_FLAG
(
ra
.
eflag
,
RA_NULL
);
FILTER_SET_FLAG
(
ra
.
sflag
,
RA
NGE_FLG
_EXCLUDE
);
FILTER_SET_FLAG
(
ra
.
eflag
,
RA
NGE_FLG
_NULL
);
break
;
case
TSDB_RELATION_GREATER_EQUAL
:
SIMPLE_COPY_VALUES
(
&
ra
.
s
,
val
);
FILTER_SET_FLAG
(
ra
.
eflag
,
RA_NULL
);
FILTER_SET_FLAG
(
ra
.
eflag
,
RA
NGE_FLG
_NULL
);
break
;
case
TSDB_RELATION_LESS
:
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
val
);
FILTER_SET_FLAG
(
ra
.
eflag
,
RA_EXCLUDE
);
FILTER_SET_FLAG
(
ra
.
sflag
,
RA_NULL
);
FILTER_SET_FLAG
(
ra
.
eflag
,
RA
NGE_FLG
_EXCLUDE
);
FILTER_SET_FLAG
(
ra
.
sflag
,
RA
NGE_FLG
_NULL
);
break
;
case
TSDB_RELATION_LESS_EQUAL
:
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
val
);
FILTER_SET_FLAG
(
ra
.
sflag
,
RA_NULL
);
FILTER_SET_FLAG
(
ra
.
sflag
,
RA
NGE_FLG
_NULL
);
break
;
case
TSDB_RELATION_NOT_EQUAL
:
assert
(
type
==
TSDB_DATA_TYPE_BOOL
);
...
...
@@ -1754,7 +1761,7 @@ int32_t filterCompareRangeCtx(SFilterRangeCtx *ctx1, SFilterRangeCtx *ctx2, bool
return
TSDB_CODE_SUCCESS
;
_
err_
return:
_return:
*
equal
=
false
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1785,14 +1792,13 @@ int32_t filterMergeUnits(SFilterInfo *info, SFilterGroupCtx* gRes, uint16_t colI
return
TSDB_CODE_SUCCESS
;
_
err_
return:
_return:
*
empty
=
true
;
filterFreeRangeCtx
(
ctx
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2033,7 +2039,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter
return
TSDB_CODE_SUCCESS
;
_
err_
return:
_return:
if
(
colCtxs
)
{
if
(
taosArrayGetSize
(
colCtxs
)
>
0
)
{
...
...
@@ -2129,7 +2135,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR
return
TSDB_CODE_SUCCESS
;
_
err_
return:
_return:
FILTER_SET_FLAG
(
info
->
status
,
FI_STATUS_ALL
);
...
...
@@ -2303,7 +2309,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_
}
}
_
err_
return:
_return:
tfree
(
idxNum
);
tfree
(
idxs
);
...
...
@@ -2492,7 +2498,7 @@ int32_t filterInitFromTree(tExprNode* tree, SFilterInfo **pinfo, uint32_t option
return
code
;
_
err_
return:
_return:
qInfo
(
"No filter, code:%d"
,
code
);
taosArrayDestroy
(
group
);
...
...
@@ -2667,7 +2673,7 @@ int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win) {
qDebug
(
"qFilter time range:[%"
PRId64
"]-[%"
PRId64
"]"
,
win
->
skey
,
win
->
ekey
);
return
TSDB_CODE_SUCCESS
;
_
err_
return:
_return:
*
win
=
TSWINDOW_DESC_INITIALIZER
;
...
...
@@ -2704,41 +2710,10 @@ int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar
}
}
#if 0
for (int32_t i = 0; i < numOfFilterCols; ++i) {
if (pFilterInfo[i].info.type == TSDB_DATA_TYPE_NCHAR) {
pFilterInfo[i].pData2 = pFilterInfo[i].pData;
pFilterInfo[i].pData = malloc(rows * pFilterInfo[i].info.bytes);
int32_t bufSize = pFilterInfo[i].info.bytes - VARSTR_HEADER_SIZE;
for (int32_t j = 0; j < rows; ++j) {
char* dst = (char *)pFilterInfo[i].pData + j * pFilterInfo[i].info.bytes;
char* src = (char *)pFilterInfo[i].pData2 + j * pFilterInfo[i].info.bytes;
int32_t len = 0;
taosMbsToUcs4(varDataVal(src), varDataLen(src), varDataVal(dst), bufSize, &len);
varDataLen(dst) = len;
}
*gotNchar = true;
}
}
#endif
return
TSDB_CODE_SUCCESS
;
}
int32_t
filterFreeNcharColumns
(
SFilterInfo
*
info
)
{
#if 0
for (int32_t i = 0; i < numOfFilterCols; ++i) {
if (pFilterInfo[i].info.type == TSDB_DATA_TYPE_NCHAR) {
if (pFilterInfo[i].pData2) {
tfree(pFilterInfo[i].pData);
pFilterInfo[i].pData = pFilterInfo[i].pData2;
pFilterInfo[i].pData2 = NULL;
}
}
}
#endif
for
(
uint16_t
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_COLUMN
].
num
;
++
i
)
{
SFilterField
*
fi
=
&
info
->
fields
[
FLD_TYPE_COLUMN
].
fields
[
i
];
int32_t
type
=
FILTER_GET_COL_FIELD_TYPE
(
fi
);
...
...
src/query/tests/rangeMergeTest.cpp
浏览文件 @
079e063b
...
...
@@ -11,6 +11,10 @@
#pragma GCC diagnostic ignored "-Wunused-variable"
extern
"C"
{
extern
void
*
filterInitRangeCtx
(
int32_t
type
,
int32_t
options
);
extern
int32_t
filterGetRangeNum
(
void
*
h
,
int32_t
*
num
);
extern
int32_t
filterGetRangeRes
(
void
*
h
,
SFilterRange
*
ra
);
extern
int32_t
filterFreeRangeCtx
(
void
*
h
);
extern
int32_t
filterAddRange
(
void
*
h
,
SFilterRange
*
ra
,
int32_t
optr
);
}
...
...
tests/script/general/parser/condition_query.sim
浏览文件 @
079e063b
...
...
@@ -1865,9 +1865,23 @@ if $rows != 28 then
return -1
endi
sql select * from stb1 where c5 in (-9999999999);
#sql select * from stb1 where c5 in (9999999999);
#sql select * from stb1 where c5 in (-9999999999,3,4,9999999999);
if $rows != 0 then
return -1
endi
sql select * from stb1 where c5 in (9999999999);
if $rows != 0 then
return -1
endi
sql select * from stb1 where c5 in (-9999999999,3,4,9999999999);
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:03.000@ then
return -1
endi
sql select * from stb3 where c1 > 3 and c1 < 2;
if $rows != 0 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录