Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
8d0a4d61
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看板
提交
8d0a4d61
编写于
6月 05, 2021
作者:
Y
yihaoDeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-4426]<fix> fix in operator bug
上级
0924b6f7
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
44 addition
and
18 deletion
+44
-18
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+35
-16
src/common/src/texpr.c
src/common/src/texpr.c
+3
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+3
-0
src/query/src/qFilterfunc.c
src/query/src/qFilterfunc.c
+1
-1
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+2
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
8d0a4d61
...
...
@@ -63,7 +63,7 @@ static SExprInfo* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t colIndex, int3
static
int32_t
setShowInfo
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
static
char
*
getAccountId
(
SSqlObj
*
pSql
);
static
bool
serializeExprListToVariant
(
SArray
*
pList
,
tVariant
**
dest
);
static
bool
serializeExprListToVariant
(
SArray
*
pList
,
tVariant
**
dest
,
int8_t
colType
);
static
int32_t
validateParamOfRelationIn
(
tVariant
*
pVar
,
int32_t
colType
);
static
bool
has
(
SArray
*
pFieldList
,
int32_t
startIdx
,
const
char
*
name
);
...
...
@@ -148,32 +148,42 @@ int16_t getNewResColId(SSqlCmd* pCmd) {
// serialize expr in exprlist to binary
// formate "type | size | value"
bool
serializeExprListToVariant
(
SArray
*
pList
,
tVariant
**
dst
)
{
bool
serializeExprListToVariant
(
SArray
*
pList
,
tVariant
**
dst
,
int8_t
colType
)
{
bool
ret
=
false
;
if
(
!
pList
||
pList
->
size
<=
0
)
{
return
ret
;
}
tSqlExprItem
*
item
=
(
tSqlExprItem
*
)
taosArrayGet
(
pList
,
0
);
int32_t
firstTokenType
=
item
->
pNode
->
token
.
type
;
int32_t
type
=
firstTokenType
;
//nchar to binary and
toTSDBType
(
type
);
if
(
colType
>=
0
)
{
if
(
type
!=
colType
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
||
colType
!=
TSDB_DATA_TYPE_NCHAR
))
{
return
false
;
}
type
=
colType
;
}
SBufferWriter
bw
=
tbufInitWriter
(
NULL
,
false
);
tbufEnsureCapacity
(
&
bw
,
512
);
tSqlExprItem
*
item
=
(
tSqlExprItem
*
)
taosArrayGet
(
pList
,
0
);
int32_t
size
=
pList
->
size
;
int32_t
type
=
item
->
pNode
->
token
.
type
;
toTSDBType
(
type
);
tbufWriteUint32
(
&
bw
,
type
);
tbufWriteInt32
(
&
bw
,
size
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
tSqlExpr
*
pSub
=
((
tSqlExprItem
*
)(
taosArrayGet
(
pList
,
i
)))
->
pNode
;
// type in exprList is same or not
toTSDBType
(
pSub
->
token
.
type
);
if
(
type
!=
pSub
->
token
.
type
)
{
// check all the token type in expr list same or not
if
(
firstTokenType
!=
pSub
->
token
.
type
)
{
break
;
}
toTSDBType
(
pSub
->
token
.
type
);
tVariant
var
;
tVariantCreate
(
&
var
,
&
pSub
->
token
);
if
(
type
==
TSDB_DATA_TYPE_BOOL
||
type
==
TSDB_DATA_TYPE_TINYINT
||
type
==
TSDB_DATA_TYPE_SMALLINT
...
...
@@ -181,8 +191,17 @@ bool serializeExprListToVariant(SArray* pList, tVariant **dst) {
tbufWriteInt64
(
&
bw
,
var
.
i64
);
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
||
type
==
TSDB_DATA_TYPE_FLOAT
)
{
tbufWriteDouble
(
&
bw
,
var
.
dKey
);
}
else
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
}
else
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
tbufWriteBinary
(
&
bw
,
var
.
pz
,
var
.
nLen
);
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
char
*
buf
=
(
char
*
)
calloc
(
1
,
(
var
.
nLen
+
1
)
*
TSDB_NCHAR_SIZE
);
if
(
tVariantDump
(
&
var
,
buf
,
type
,
false
)
!=
TSDB_CODE_SUCCESS
)
{
free
(
buf
);
tVariantDestroy
(
&
var
);
break
;
}
tbufWriteBinary
(
&
bw
,
buf
,
twcslen
((
wchar_t
*
)
buf
)
*
TSDB_NCHAR_SIZE
);
free
(
buf
);
}
tVariantDestroy
(
&
var
);
...
...
@@ -204,9 +223,8 @@ static int32_t validateParamOfRelationIn(tVariant *pVar, int32_t colType) {
if
(
pVar
->
nType
!=
TSDB_DATA_TYPE_BINARY
)
{
return
-
1
;
}
return
0
;
//SBufferReader br = tbufInitReader(pVar->pz, pVar->nLen, false);
//return tbufReadUint32(&br) == colType ? 0: -1;
SBufferReader
br
=
tbufInitReader
(
pVar
->
pz
,
pVar
->
nLen
,
false
);
return
colType
==
TSDB_DATA_TYPE_NCHAR
?
0
:
(
tbufReadUint32
(
&
br
)
==
colType
?
0
:
-
1
);
}
static
uint8_t
convertOptr
(
SStrToken
*
pToken
)
{
...
...
@@ -229,6 +247,7 @@ static uint8_t convertOptr(SStrToken *pToken) {
return
TSDB_RELATION_EQUAL
;
case
TK_PLUS
:
return
TSDB_BINARY_OP_ADD
;
case
TK_MINUS
:
return
TSDB_BINARY_OP_SUBTRACT
;
case
TK_STAR
:
...
...
@@ -3276,7 +3295,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
// TK_GT,TK_GE,TK_EQ,TK_NE are based on the pColumn->lowerBndd
}
else
if
(
pExpr
->
tokenId
==
TK_IN
)
{
tVariant
*
pVal
;
if
(
pRight
->
tokenId
!=
TK_SET
||
!
serializeExprListToVariant
(
pRight
->
pParam
,
&
pVal
)
)
{
if
(
pRight
->
tokenId
!=
TK_SET
||
!
serializeExprListToVariant
(
pRight
->
pParam
,
&
pVal
,
colType
)
||
colType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
}
if
(
validateParamOfRelationIn
(
pVal
,
colType
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -8007,7 +8026,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
return
TSDB_CODE_SUCCESS
;
}
else
if
(
pSqlExpr
->
tokenId
==
TK_SET
)
{
tVariant
*
pVal
;
if
(
serializeExprListToVariant
(
pSqlExpr
->
pParam
,
&
pVal
)
==
false
)
{
if
(
serializeExprListToVariant
(
pSqlExpr
->
pParam
,
&
pVal
,
-
1
)
==
false
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"not support filter expression"
);
}
*
pExpr
=
calloc
(
1
,
sizeof
(
tExprNode
));
...
...
src/common/src/texpr.c
浏览文件 @
8d0a4d61
...
...
@@ -485,7 +485,9 @@ void buildFilterSetFromBinary(void **q, const char *buf, int32_t len) {
taosHashPut
(
pObj
,
(
char
*
)
val
,
t
,
&
dummy
,
sizeof
(
dummy
));
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
size_t
t
=
0
;
const
char
*
val
=
tbufReadBinary
(
&
br
,
&
t
);
taosHashPut
(
pObj
,
(
char
*
)
val
,
t
,
&
dummy
,
sizeof
(
dummy
));
}
}
*
q
=
(
void
*
)
pObj
;
...
...
src/query/src/qExecutor.c
浏览文件 @
8d0a4d61
...
...
@@ -6956,6 +6956,9 @@ int32_t doCreateFilterInfo(SColumnInfo* pCols, int32_t numOfCols, int32_t numOfF
void
*
doDestroyFilterInfo
(
SSingleColumnFilterInfo
*
pFilterInfo
,
int32_t
numOfFilterCols
)
{
for
(
int32_t
i
=
0
;
i
<
numOfFilterCols
;
++
i
)
{
if
(
pFilterInfo
[
i
].
numOfFilters
>
0
)
{
if
(
pFilterInfo
[
i
].
pFilters
->
filterInfo
.
lowerRelOptr
==
TSDB_RELATION_IN
)
{
taosHashCleanup
((
SHashObj
*
)(
pFilterInfo
[
i
].
pFilters
->
q
));
}
tfree
(
pFilterInfo
[
i
].
pFilters
);
}
}
...
...
src/query/src/qFilterfunc.c
浏览文件 @
8d0a4d61
...
...
@@ -269,7 +269,7 @@ bool inOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxv
}
else
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
return
NULL
!=
taosHashGet
((
SHashObj
*
)
pFilter
->
q
,
varDataVal
(
minval
),
varDataLen
(
minval
));
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
){
return
NULL
!=
taosHashGet
((
SHashObj
*
)
pFilter
->
q
,
varDataVal
(
minval
),
varDataLen
(
minval
)
/
TSDB_NCHAR_SIZE
);
return
NULL
!=
taosHashGet
((
SHashObj
*
)
pFilter
->
q
,
varDataVal
(
minval
),
varDataLen
(
minval
));
}
return
false
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
8d0a4d61
...
...
@@ -2397,6 +2397,8 @@ static void destroyHelper(void* param) {
tQueryInfo
*
pInfo
=
(
tQueryInfo
*
)
param
;
if
(
pInfo
->
optr
!=
TSDB_RELATION_IN
)
{
tfree
(
pInfo
->
q
);
}
else
{
taosHashCleanup
((
SHashObj
*
)(
pInfo
->
q
));
}
free
(
param
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录