Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
7654cb6d
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看板
提交
7654cb6d
编写于
6月 17, 2021
作者:
Y
yihaoDeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3086]<feature>tag support timestamp and in_operator support timestamp
上级
100b2443
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
14 deletion
+34
-14
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+28
-11
src/common/src/texpr.c
src/common/src/texpr.c
+4
-1
src/query/src/qFilterfunc.c
src/query/src/qFilterfunc.c
+1
-1
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+1
-1
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
7654cb6d
...
...
@@ -63,7 +63,8 @@ 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
,
int16_t
colType
);
static
int
convertTimestampStrToInt64
(
tVariant
*
pVar
,
int32_t
precision
);
static
bool
serializeExprListToVariant
(
SArray
*
pList
,
tVariant
**
dest
,
int16_t
colType
,
uint8_t
precision
);
static
int32_t
validateParamOfRelationIn
(
tVariant
*
pVar
,
int32_t
colType
);
static
bool
has
(
SArray
*
pFieldList
,
int32_t
startIdx
,
const
char
*
name
);
...
...
@@ -149,7 +150,7 @@ int16_t getNewResColId(SSqlCmd* pCmd) {
// serialize expr in exprlist to binary
// formate "type | size | value"
bool
serializeExprListToVariant
(
SArray
*
pList
,
tVariant
**
dst
,
int16_t
colType
)
{
bool
serializeExprListToVariant
(
SArray
*
pList
,
tVariant
**
dst
,
int16_t
colType
,
uint8_t
precision
)
{
bool
ret
=
false
;
if
(
!
pList
||
pList
->
size
<=
0
||
colType
<
0
)
{
return
ret
;
...
...
@@ -161,9 +162,11 @@ bool serializeExprListToVariant(SArray* pList, tVariant **dst, int16_t colType)
//nchar to binary and
toTSDBType
(
type
);
if
(
type
!=
colType
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
||
colType
!=
TSDB_DATA_TYPE_NCHAR
))
{
return
false
;
}
if
(
colType
!=
TSDB_DATA_TYPE_TIMESTAMP
)
{
if
(
type
!=
colType
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
||
colType
!=
TSDB_DATA_TYPE_NCHAR
))
{
return
false
;
}
}
type
=
colType
;
SBufferWriter
bw
=
tbufInitWriter
(
NULL
,
false
);
...
...
@@ -185,8 +188,7 @@ bool serializeExprListToVariant(SArray* pList, tVariant **dst, int16_t colType)
tVariant
var
;
tVariantCreate
(
&
var
,
&
pSub
->
token
);
if
(
type
==
TSDB_DATA_TYPE_BOOL
||
type
==
TSDB_DATA_TYPE_TINYINT
||
type
==
TSDB_DATA_TYPE_SMALLINT
||
type
==
TSDB_DATA_TYPE_BIGINT
||
type
==
TSDB_DATA_TYPE_INT
)
{
if
(
type
==
TSDB_DATA_TYPE_BOOL
||
IS_SIGNED_NUMERIC_TYPE
(
type
)
||
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
tbufWriteInt64
(
&
bw
,
var
.
i64
);
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
||
type
==
TSDB_DATA_TYPE_FLOAT
)
{
tbufWriteDouble
(
&
bw
,
var
.
dKey
);
...
...
@@ -201,6 +203,16 @@ bool serializeExprListToVariant(SArray* pList, tVariant **dst, int16_t colType)
}
tbufWriteBinary
(
&
bw
,
buf
,
twcslen
((
wchar_t
*
)
buf
)
*
TSDB_NCHAR_SIZE
);
free
(
buf
);
}
else
if
(
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
if
(
var
.
nType
==
TSDB_DATA_TYPE_BINARY
)
{
if
(
convertTimestampStrToInt64
(
&
var
,
precision
)
<
0
)
{
tVariantDestroy
(
&
var
);
break
;
}
tbufWriteInt64
(
&
bw
,
var
.
i64
);
}
else
if
(
var
.
nType
==
TSDB_DATA_TYPE_BIGINT
)
{
tbufWriteInt64
(
&
bw
,
var
.
i64
);
}
}
tVariantDestroy
(
&
var
);
...
...
@@ -3340,7 +3352,8 @@ 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
,
colType
)
||
colType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
if
(
pRight
->
tokenId
!=
TK_SET
||
!
serializeExprListToVariant
(
pRight
->
pParam
,
&
pVal
,
colType
,
timePrecision
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
}
if
(
validateParamOfRelationIn
(
pVal
,
colType
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -3352,7 +3365,6 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
pColumnFilter
->
len
=
pVal
->
nLen
;
pColumnFilter
->
filterstr
=
1
;
memcpy
((
char
*
)(
pColumnFilter
->
pz
),
(
char
*
)(
pVal
->
pz
),
pVal
->
nLen
);
//retVal = tVariantDump(pVal, (char *)(pColumnFilter->pz), TSDB_DATA_TYPE_BINARY, false);
tVariantDestroy
(
pVal
);
free
(
pVal
);
...
...
@@ -3485,6 +3497,7 @@ static int32_t extractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SC
const
char
*
msg1
=
"non binary column not support like operator"
;
const
char
*
msg2
=
"binary column not support this operator"
;
const
char
*
msg3
=
"bool column not support this operator"
;
const
char
*
msg4
=
"primary key not support this operator"
;
SColumn
*
pColumn
=
tscColumnListInsert
(
pQueryInfo
->
colList
,
pIndex
->
columnIndex
,
pTableMeta
->
id
.
uid
,
pSchema
);
SColumnFilterInfo
*
pColFilter
=
NULL
;
...
...
@@ -3541,6 +3554,9 @@ static int32_t extractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SC
pColumn
->
columnIndex
=
pIndex
->
columnIndex
;
pColumn
->
tableUid
=
pTableMeta
->
id
.
uid
;
if
(
pColumn
->
columnIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
&&
pExpr
->
tokenId
==
TK_IN
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
return
doExtractColumnFilterInfo
(
pCmd
,
pQueryInfo
,
tinfo
.
precision
,
pColFilter
,
pSchema
->
type
,
pExpr
);
...
...
@@ -8116,14 +8132,15 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
colType
=
pSchema
->
type
;
}
}
tVariant
*
pVal
;
if
(
colType
>=
TSDB_DATA_TYPE_TINYINT
&&
colType
<=
TSDB_DATA_TYPE_BIGINT
)
{
colType
=
TSDB_DATA_TYPE_BIGINT
;
}
else
if
(
colType
==
TSDB_DATA_TYPE_FLOAT
||
colType
==
TSDB_DATA_TYPE_DOUBLE
)
{
colType
=
TSDB_DATA_TYPE_DOUBLE
;
}
if
(
serializeExprListToVariant
(
pSqlExpr
->
pParam
,
&
pVal
,
colType
)
==
false
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
if
(
serializeExprListToVariant
(
pSqlExpr
->
pParam
,
&
pVal
,
colType
,
tinfo
.
precision
)
==
false
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"not support filter expression"
);
}
*
pExpr
=
calloc
(
1
,
sizeof
(
tExprNode
));
...
...
src/common/src/texpr.c
浏览文件 @
7654cb6d
...
...
@@ -476,7 +476,10 @@ void buildFilterSetFromBinary(void **q, const char *buf, int32_t len) {
int
dummy
=
-
1
;
int32_t
sz
=
tbufReadInt32
(
&
br
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
if
(
type
==
TSDB_DATA_TYPE_BOOL
||
type
==
TSDB_DATA_TYPE_TINYINT
||
type
==
TSDB_DATA_TYPE_SMALLINT
||
type
==
TSDB_DATA_TYPE_BIGINT
||
type
==
TSDB_DATA_TYPE_INT
)
{
if
(
type
==
TSDB_DATA_TYPE_BOOL
||
IS_SIGNED_NUMERIC_TYPE
(
type
)
||
IS_UNSIGNED_NUMERIC_TYPE
(
type
)
||
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
val
=
tbufReadInt64
(
&
br
);
taosHashPut
(
pObj
,
(
char
*
)
&
val
,
sizeof
(
val
),
&
dummy
,
sizeof
(
dummy
));
}
else
if
(
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
val
=
tbufReadInt64
(
&
br
);
taosHashPut
(
pObj
,
(
char
*
)
&
val
,
sizeof
(
val
),
&
dummy
,
sizeof
(
dummy
));
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
||
type
==
TSDB_DATA_TYPE_FLOAT
)
{
...
...
src/query/src/qFilterfunc.c
浏览文件 @
7654cb6d
...
...
@@ -254,7 +254,7 @@ bool notNullOperator(SColumnFilterElem *pFilter, const char* minval, const char*
return
true
;
}
bool
inOperator
(
SColumnFilterElem
*
pFilter
,
const
char
*
minval
,
const
char
*
maxval
,
int16_t
type
)
{
if
(
type
==
TSDB_DATA_TYPE_BOOL
||
type
==
TSDB_DATA_TYPE_TINYINT
||
type
==
TSDB_DATA_TYPE_SMALLINT
||
type
==
TSDB_DATA_TYPE_BIGINT
||
type
==
TSDB_DATA_TYPE_INT
)
{
if
(
type
==
TSDB_DATA_TYPE_BOOL
||
IS_SIGNED_NUMERIC_TYPE
(
type
)
||
IS_UNSIGNED_NUMERIC_TYPE
(
type
)
||
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
minv
=
-
1
,
maxv
=
-
1
;
GET_TYPED_DATA
(
minv
,
int64_t
,
type
,
minval
);
GET_TYPED_DATA
(
maxv
,
int64_t
,
type
,
maxval
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
7654cb6d
...
...
@@ -3355,7 +3355,7 @@ static bool tableFilterFp(const void* pNode, void* param) {
}
}
else
if
(
pInfo
->
optr
==
TSDB_RELATION_IN
)
{
int
type
=
pInfo
->
sch
.
type
;
if
(
type
==
TSDB_DATA_TYPE_BOOL
||
type
==
TSDB_DATA_TYPE_TINYINT
||
type
==
TSDB_DATA_TYPE_SMALLINT
||
type
==
TSDB_DATA_TYPE_BIGINT
||
type
==
TSDB_DATA_TYPE_INT
)
{
if
(
type
==
TSDB_DATA_TYPE_BOOL
||
IS_SIGNED_NUMERIC_TYPE
(
type
)
||
IS_UNSIGNED_NUMERIC_TYPE
(
type
)
||
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
v
;
GET_TYPED_DATA
(
v
,
int64_t
,
pInfo
->
sch
.
type
,
val
);
return
NULL
!=
taosHashGet
((
SHashObj
*
)
pInfo
->
q
,
(
char
*
)
&
v
,
sizeof
(
v
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录