Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a4258a5a
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
a4258a5a
编写于
4月 23, 2023
作者:
H
Haojun Liao
提交者:
GitHub
4月 23, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21019 from taosdata/fix/tagFilterError
fix filter err
上级
64a1c181
acee9e18
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
246 addition
and
13 deletion
+246
-13
source/libs/index/src/indexFilter.c
source/libs/index/src/indexFilter.c
+172
-13
tests/script/tsim/tag/bigint.sim
tests/script/tsim/tag/bigint.sim
+11
-0
tests/script/tsim/tag/double.sim
tests/script/tsim/tag/double.sim
+9
-0
tests/script/tsim/tag/float.sim
tests/script/tsim/tag/float.sim
+10
-0
tests/script/tsim/tag/int.sim
tests/script/tsim/tag/int.sim
+10
-0
tests/script/tsim/tag/int_float.sim
tests/script/tsim/tag/int_float.sim
+12
-0
tests/script/tsim/tag/tinyint.sim
tests/script/tsim/tag/tinyint.sim
+22
-0
未找到文件。
source/libs/index/src/indexFilter.c
浏览文件 @
a4258a5a
...
...
@@ -221,6 +221,71 @@ static FORCE_INLINE int32_t sifInitJsonParam(SNode *node, SIFParam *param, SIFCt
param
->
status
=
SFLT_COARSE_INDEX
;
return
0
;
}
static
int32_t
sifNeedConvertCond
(
SNode
*
l
,
SNode
*
r
)
{
if
(
nodeType
(
l
)
!=
QUERY_NODE_COLUMN
||
nodeType
(
r
)
!=
QUERY_NODE_VALUE
)
{
return
0
;
}
SColumnNode
*
c
=
(
SColumnNode
*
)
l
;
SValueNode
*
v
=
(
SValueNode
*
)
r
;
int32_t
ctype
=
c
->
node
.
resType
.
type
;
int32_t
vtype
=
v
->
node
.
resType
.
type
;
if
(
!
IS_VAR_DATA_TYPE
(
ctype
)
&&
IS_VAR_DATA_TYPE
(
vtype
))
{
return
1
;
}
return
0
;
}
static
int32_t
sifInitParamValByCol
(
SNode
*
r
,
SNode
*
l
,
SIFParam
*
param
,
SIFCtx
*
ctx
)
{
param
->
status
=
SFLT_COARSE_INDEX
;
SColumnNode
*
cn
=
(
SColumnNode
*
)
r
;
SValueNode
*
vn
=
(
SValueNode
*
)
l
;
if
(
vn
->
typeData
==
TSDB_DATA_TYPE_NULL
&&
(
vn
->
literal
==
NULL
||
strlen
(
vn
->
literal
)
==
0
))
{
param
->
status
=
SFLT_NOT_INDEX
;
return
0
;
}
SDataType
*
pType
=
&
cn
->
node
.
resType
;
int32_t
type
=
pType
->
type
;
SDataType
*
pVType
=
&
vn
->
node
.
resType
;
int32_t
vtype
=
pVType
->
type
;
char
*
pData
=
nodesGetValueFromNode
(
vn
);
int32_t
valLen
=
0
;
char
**
value
=
&
param
->
condValue
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
int32_t
dataLen
=
varDataTLen
(
pData
);
if
(
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
*
pData
==
TSDB_DATA_TYPE_NULL
)
{
dataLen
=
0
;
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_NCHAR
)
{
dataLen
=
varDataTLen
(
pData
);
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_DOUBLE
)
{
dataLen
=
LONG_BYTES
;
}
else
if
(
*
pData
==
TSDB_DATA_TYPE_BOOL
)
{
dataLen
=
CHAR_BYTES
;
}
dataLen
+=
CHAR_BYTES
;
}
valLen
=
dataLen
;
}
else
{
valLen
=
pType
->
bytes
;
}
char
*
tv
=
taosMemoryCalloc
(
1
,
valLen
+
1
);
if
(
tv
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
memcpy
(
tv
,
pData
,
valLen
);
*
value
=
tv
;
param
->
colId
=
-
1
;
param
->
colValType
=
(
uint8_t
)(
vn
->
node
.
resType
.
type
);
if
(
vn
->
literal
!=
NULL
&&
strlen
(
vn
->
literal
)
<=
sizeof
(
param
->
colName
))
{
memcpy
(
param
->
colName
,
vn
->
literal
,
strlen
(
vn
->
literal
));
}
else
{
param
->
status
=
SFLT_NOT_INDEX
;
}
return
0
;
}
static
int32_t
sifInitParam
(
SNode
*
node
,
SIFParam
*
param
,
SIFCtx
*
ctx
)
{
param
->
status
=
SFLT_COARSE_INDEX
;
switch
(
nodeType
(
node
))
{
...
...
@@ -317,8 +382,13 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
return
TSDB_CODE_SUCCESS
;
}
else
{
SIF_ERR_JRET
(
sifInitParam
(
node
->
pLeft
,
&
paramList
[
0
],
ctx
));
if
(
nParam
>
1
)
{
// if (sifNeedConvertCond(node->pLeft, node->pRight)) {
// SIF_ERR_JRET(sifInitParamValByCol(node->pLeft, node->pRight, ¶mList[1], ctx));
// } else {
SIF_ERR_JRET
(
sifInitParam
(
node
->
pRight
,
&
paramList
[
1
],
ctx
));
// }
// if (paramList[0].colValType == TSDB_DATA_TYPE_JSON &&
// ((SOperatorNode *)(node))->opType == OP_TYPE_JSON_CONTAINS) {
// return TSDB_CODE_OUT_OF_MEMORY;
...
...
@@ -404,60 +474,149 @@ static FORCE_INLINE FilterFunc sifGetFilterFunc(EIndexQueryType type, bool *reve
}
return
NULL
;
}
int32_t
sifStr2Num
(
char
*
buf
,
int32_t
len
,
int8_t
type
,
void
*
val
)
{
// signed/unsigned/float
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
int64_t
v
=
0
;
if
(
0
!=
toInteger
(
buf
,
len
,
10
,
&
v
))
{
return
-
1
;
}
if
(
type
==
TSDB_DATA_TYPE_BIGINT
)
{
*
(
int64_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_INT
)
{
*
(
int32_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_TINYINT
)
{
*
(
int8_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_SMALLINT
)
{
*
(
int16_t
*
)
val
=
v
;
}
}
else
if
(
IS_FLOAT_TYPE
(
type
))
{
if
(
type
==
TSDB_DATA_TYPE_FLOAT
)
{
*
(
float
*
)
val
=
taosStr2Float
(
buf
,
NULL
);
}
else
{
*
(
double
*
)
val
=
taosStr2Double
(
buf
,
NULL
);
}
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
uint64_t
v
=
0
;
if
(
0
!=
toUInteger
(
buf
,
len
,
10
,
&
v
))
{
return
-
1
;
}
if
(
type
==
TSDB_DATA_TYPE_UBIGINT
)
{
*
(
uint64_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_UINT
)
{
*
(
uint32_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_UTINYINT
)
{
*
(
uint8_t
*
)
val
=
v
;
}
else
if
(
type
==
TSDB_DATA_TYPE_USMALLINT
)
{
*
(
uint16_t
*
)
val
=
v
;
}
}
else
{
return
-
1
;
}
return
0
;
}
static
void
sifSetFltParam
(
SIFParam
*
left
,
SIFParam
*
right
,
SDataTypeBuf
*
typedata
,
SMetaFltParam
*
param
)
{
static
int32_t
sifSetFltParam
(
SIFParam
*
left
,
SIFParam
*
right
,
SDataTypeBuf
*
typedata
,
SMetaFltParam
*
param
)
{
int32_t
code
=
0
;
int8_t
ltype
=
left
->
colValType
,
rtype
=
right
->
colValType
;
if
(
!
IS_NUMERIC_TYPE
(
ltype
)
||
!
((
IS_NUMERIC_TYPE
(
rtype
))
||
rtype
==
TSDB_DATA_TYPE_VARCHAR
))
{
return
-
1
;
}
if
(
ltype
==
TSDB_DATA_TYPE_FLOAT
)
{
float
f
=
0
;
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
f
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_FLOAT
,
&
f
));
}
typedata
->
f
=
f
;
param
->
val
=
&
typedata
->
f
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
d
=
0
;
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
d
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_DOUBLE
,
&
d
));
}
typedata
->
d
=
d
;
param
->
val
=
&
typedata
->
d
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_BIGINT
)
{
int64_t
i64
=
0
;
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i64
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_BIGINT
,
&
i64
));
}
typedata
->
i64
=
i64
;
param
->
val
=
&
typedata
->
i64
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_INT
)
{
int32_t
i32
=
0
;
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i32
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_INT
,
&
i32
));
}
typedata
->
i32
=
i32
;
param
->
val
=
&
typedata
->
i32
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_SMALLINT
)
{
int16_t
i16
=
0
;
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i16
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_SMALLINT
,
&
i16
));
}
typedata
->
i16
=
i16
;
param
->
val
=
&
typedata
->
i16
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_TINYINT
)
{
int8_t
i8
=
0
;
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i8
)
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
i8
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_TINYINT
,
&
i8
));
}
typedata
->
i8
=
i8
;
param
->
val
=
&
typedata
->
i8
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_UBIGINT
)
{
uint64_t
u64
=
0
;
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u64
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_UBIGINT
,
&
u64
));
}
typedata
->
u64
=
u64
;
param
->
val
=
&
typedata
->
u64
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_UINT
)
{
uint32_t
u32
=
0
;
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u32
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_UINT
,
&
u32
));
}
typedata
->
u32
=
u32
;
param
->
val
=
&
typedata
->
u32
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_USMALLINT
)
{
uint16_t
u16
=
0
;
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u16
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_USMALLINT
,
&
u16
));
}
typedata
->
u16
=
u16
;
param
->
val
=
&
typedata
->
u16
;
}
else
if
(
ltype
==
TSDB_DATA_TYPE_UTINYINT
)
{
uint8_t
u8
=
0
;
if
(
IS_NUMERIC_TYPE
(
rtype
))
{
SIF_DATA_CONVERT
(
rtype
,
right
->
condValue
,
u8
);
}
else
{
SIF_ERR_RET
(
sifStr2Num
(
varDataVal
(
right
->
condValue
),
varDataLen
(
right
->
condValue
),
TSDB_DATA_TYPE_UTINYINT
,
&
u8
));
}
typedata
->
u8
=
u8
;
param
->
val
=
&
typedata
->
u8
;
}
return
0
;
}
static
int32_t
sifDoIndex
(
SIFParam
*
left
,
SIFParam
*
right
,
int8_t
operType
,
SIFParam
*
output
)
{
int
ret
=
0
;
...
...
@@ -498,7 +657,7 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP
param
.
val
=
buf
;
}
}
else
{
sifSetFltParam
(
left
,
right
,
&
typedata
,
&
param
)
;
if
(
sifSetFltParam
(
left
,
right
,
&
typedata
,
&
param
)
!=
0
)
return
-
1
;
}
ret
=
metaFilterTableIds
(
arg
->
metaEx
,
&
param
,
output
->
result
);
}
...
...
tests/script/tsim/tag/bigint.sim
浏览文件 @
a4258a5a
...
...
@@ -123,6 +123,17 @@ sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '1'
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
tests/script/tsim/tag/double.sim
浏览文件 @
a4258a5a
...
...
@@ -123,6 +123,15 @@ sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '1';
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1.0"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
tests/script/tsim/tag/float.sim
浏览文件 @
a4258a5a
...
...
@@ -123,6 +123,16 @@ sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1.0"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
tests/script/tsim/tag/int.sim
浏览文件 @
a4258a5a
...
...
@@ -123,6 +123,16 @@ sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '1'
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1";
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
tests/script/tsim/tag/int_float.sim
浏览文件 @
a4258a5a
...
...
@@ -85,10 +85,22 @@ sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '1'
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
tests/script/tsim/tag/tinyint.sim
浏览文件 @
a4258a5a
...
...
@@ -115,14 +115,36 @@ sql select * from $mt where tgcol = 0
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '0'
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "0"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 0
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = "1"
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol = '1'
if $rows != 100 then
return -1
endi
sql select * from $mt where tgcol <> 1
if $rows != 100 then
return -1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录