Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b0a25e92
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
未验证
提交
b0a25e92
编写于
9月 17, 2021
作者:
D
dapan1121
提交者:
GitHub
9月 17, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7899 from taosdata/feature/TD-5925
td-5925
上级
f2127b43
b2aaac17
变更
27
展开全部
隐藏空白更改
内联
并排
Showing
27 changed file
with
3230 addition
and
1512 deletion
+3230
-1512
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+70
-329
src/client/src/tscServer.c
src/client/src/tscServer.c
+0
-13
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+5
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+8
-22
src/common/inc/texpr.h
src/common/inc/texpr.h
+0
-1
src/common/src/texpr.c
src/common/src/texpr.c
+0
-99
src/inc/taosmsg.h
src/inc/taosmsg.h
+0
-2
src/inc/tsdb.h
src/inc/tsdb.h
+1
-2
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+1
-1
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+10
-5
src/query/inc/qFilter.h
src/query/inc/qFilter.h
+11
-2
src/query/inc/qTableMeta.h
src/query/inc/qTableMeta.h
+2
-7
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+30
-18
src/query/src/qFilter.c
src/query/src/qFilter.c
+113
-82
src/query/src/queryMain.c
src/query/src/queryMain.c
+1
-2
src/tsdb/CMakeLists.txt
src/tsdb/CMakeLists.txt
+1
-0
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+89
-352
src/util/src/tcompare.c
src/util/src/tcompare.c
+16
-7
tests/pytest/functions/queryTestCases.py
tests/pytest/functions/queryTestCases.py
+1
-1
tests/pytest/query/filterOtherTypes.py
tests/pytest/query/filterOtherTypes.py
+16
-8
tests/pytest/query/isNullTest.py
tests/pytest/query/isNullTest.py
+2
-2
tests/script/general/parser/between_and.sim
tests/script/general/parser/between_and.sim
+2
-2
tests/script/general/parser/condition.sim
tests/script/general/parser/condition.sim
+139
-1
tests/script/general/parser/condition_query.sim
tests/script/general/parser/condition_query.sim
+153
-548
tests/script/general/parser/condition_query2.sim
tests/script/general/parser/condition_query2.sim
+2345
-0
tests/script/general/parser/condition_query3.sim
tests/script/general/parser/condition_query3.sim
+210
-0
tests/script/general/parser/tbnameIn_query.sim
tests/script/general/parser/tbnameIn_query.sim
+4
-5
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
b0a25e92
此差异已折叠。
点击以展开。
src/client/src/tscServer.c
浏览文件 @
b0a25e92
...
@@ -703,11 +703,6 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql) {
...
@@ -703,11 +703,6 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql) {
}
}
}
}
SCond
*
pCond
=
&
pQueryInfo
->
tagCond
.
tbnameCond
;
if
(
pCond
->
len
>
0
)
{
srcColListSize
+=
pCond
->
len
;
}
return
MIN_QUERY_MSG_PKT_SIZE
+
minMsgSize
()
+
sizeof
(
SQueryTableMsg
)
+
srcColListSize
+
srcColFilterSize
+
srcTagFilterSize
+
return
MIN_QUERY_MSG_PKT_SIZE
+
minMsgSize
()
+
sizeof
(
SQueryTableMsg
)
+
srcColListSize
+
srcColFilterSize
+
srcTagFilterSize
+
exprSize
+
tsBufSize
+
tableSerialize
+
sqlLen
+
4096
+
pQueryInfo
->
bufLen
;
exprSize
+
tsBufSize
+
tableSerialize
+
sqlLen
+
4096
+
pQueryInfo
->
bufLen
;
}
}
...
@@ -956,8 +951,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -956,8 +951,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pQueryMsg
->
numOfOutput
=
htons
((
int16_t
)
query
.
numOfOutput
);
// this is the stage one output column number
pQueryMsg
->
numOfOutput
=
htons
((
int16_t
)
query
.
numOfOutput
);
// this is the stage one output column number
pQueryMsg
->
numOfGroupCols
=
htons
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
);
pQueryMsg
->
numOfGroupCols
=
htons
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
);
pQueryMsg
->
tagNameRelType
=
htons
(
pQueryInfo
->
tagCond
.
relType
);
pQueryMsg
->
tbnameCondLen
=
htonl
(
pQueryInfo
->
tagCond
.
tbnameCond
.
len
);
pQueryMsg
->
queryType
=
htonl
(
pQueryInfo
->
type
);
pQueryMsg
->
queryType
=
htonl
(
pQueryInfo
->
type
);
pQueryMsg
->
prevResultLen
=
htonl
(
pQueryInfo
->
bufLen
);
pQueryMsg
->
prevResultLen
=
htonl
(
pQueryInfo
->
bufLen
);
...
@@ -1076,12 +1069,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1076,12 +1069,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
+=
pQueryInfo
->
bufLen
;
pMsg
+=
pQueryInfo
->
bufLen
;
}
}
SCond
*
pCond
=
&
pQueryInfo
->
tagCond
.
tbnameCond
;
if
(
pCond
->
len
>
0
)
{
strncpy
(
pMsg
,
pCond
->
cond
,
pCond
->
len
);
pMsg
+=
pCond
->
len
;
}
// compressed ts block
// compressed ts block
pQueryMsg
->
tsBuf
.
tsOffset
=
htonl
((
int32_t
)(
pMsg
-
pCmd
->
payload
));
pQueryMsg
->
tsBuf
.
tsOffset
=
htonl
((
int32_t
)(
pMsg
-
pCmd
->
payload
));
...
...
src/client/src/tscSubquery.c
浏览文件 @
b0a25e92
...
@@ -1347,7 +1347,11 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -1347,7 +1347,11 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
pCmd
->
command
=
TSDB_SQL_SELECT
;
pCmd
->
command
=
TSDB_SQL_SELECT
;
tscResetForNextRetrieve
(
&
pSql
->
res
);
tscResetForNextRetrieve
(
&
pSql
->
res
);
assert
(
pSupporter
->
f
==
NULL
);
if
(
pSupporter
->
f
!=
NULL
)
{
fclose
(
pSupporter
->
f
);
pSupporter
->
f
=
NULL
;
}
taosGetTmpfilePath
(
"ts-join"
,
pSupporter
->
path
);
taosGetTmpfilePath
(
"ts-join"
,
pSupporter
->
path
);
// TODO check for failure
// TODO check for failure
...
...
src/client/src/tscUtil.c
浏览文件 @
b0a25e92
...
@@ -814,7 +814,7 @@ typedef struct SDummyInputInfo {
...
@@ -814,7 +814,7 @@ typedef struct SDummyInputInfo {
SSDataBlock
*
block
;
SSDataBlock
*
block
;
STableQueryInfo
*
pTableQueryInfo
;
STableQueryInfo
*
pTableQueryInfo
;
SSqlObj
*
pSql
;
// refactor: remove it
SSqlObj
*
pSql
;
// refactor: remove it
SFilterInfo
*
pFilterInfo
;
void
*
pFilterInfo
;
}
SDummyInputInfo
;
}
SDummyInputInfo
;
typedef
struct
SJoinStatus
{
typedef
struct
SJoinStatus
{
...
@@ -830,7 +830,7 @@ typedef struct SJoinOperatorInfo {
...
@@ -830,7 +830,7 @@ typedef struct SJoinOperatorInfo {
SRspResultInfo
resultInfo
;
// todo refactor, add this info for each operator
SRspResultInfo
resultInfo
;
// todo refactor, add this info for each operator
}
SJoinOperatorInfo
;
}
SJoinOperatorInfo
;
static
void
doSetupSDataBlock
(
SSqlRes
*
pRes
,
SSDataBlock
*
pBlock
,
SFilterInfo
*
pFilterInfo
)
{
static
void
doSetupSDataBlock
(
SSqlRes
*
pRes
,
SSDataBlock
*
pBlock
,
void
*
pFilterInfo
)
{
int32_t
offset
=
0
;
int32_t
offset
=
0
;
char
*
pData
=
pRes
->
data
;
char
*
pData
=
pRes
->
data
;
...
@@ -847,8 +847,9 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, SFilterInfo* p
...
@@ -847,8 +847,9 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, SFilterInfo* p
// filter data if needed
// filter data if needed
if
(
pFilterInfo
)
{
if
(
pFilterInfo
)
{
//doSetFilterColumnInfo(pFilterInfo, numOfFilterCols, pBlock);
SColumnDataParam
param
=
{.
numOfCols
=
pBlock
->
info
.
numOfCols
,
.
pDataBlock
=
pBlock
->
pDataBlock
};
filterSetColFieldData
(
pFilterInfo
,
pBlock
->
info
.
numOfCols
,
pBlock
->
pDataBlock
);
filterSetColFieldData
(
pFilterInfo
,
&
param
,
getColumnDataFromId
);
bool
gotNchar
=
false
;
bool
gotNchar
=
false
;
filterConverNcharColumns
(
pFilterInfo
,
pBlock
->
info
.
rows
,
&
gotNchar
);
filterConverNcharColumns
(
pFilterInfo
,
pBlock
->
info
.
rows
,
&
gotNchar
);
int8_t
*
p
=
NULL
;
int8_t
*
p
=
NULL
;
...
@@ -1111,7 +1112,7 @@ static void destroyDummyInputOperator(void* param, int32_t numOfOutput) {
...
@@ -1111,7 +1112,7 @@ static void destroyDummyInputOperator(void* param, int32_t numOfOutput) {
}
}
// todo this operator servers as the adapter for Operator tree and SqlRes result, remove it later
// todo this operator servers as the adapter for Operator tree and SqlRes result, remove it later
SOperatorInfo
*
createDummyInputOperator
(
SSqlObj
*
pSql
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
SFilterInfo
*
pFilters
)
{
SOperatorInfo
*
createDummyInputOperator
(
SSqlObj
*
pSql
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
void
*
pFilters
)
{
assert
(
numOfCols
>
0
);
assert
(
numOfCols
>
0
);
STimeWindow
win
=
{.
skey
=
INT64_MIN
,
.
ekey
=
INT64_MAX
};
STimeWindow
win
=
{.
skey
=
INT64_MIN
,
.
ekey
=
INT64_MAX
};
...
@@ -1253,7 +1254,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
...
@@ -1253,7 +1254,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
// if it is a join query, create join operator here
// if it is a join query, create join operator here
int32_t
numOfCol1
=
pTableMeta
->
tableInfo
.
numOfColumns
;
int32_t
numOfCol1
=
pTableMeta
->
tableInfo
.
numOfColumns
;
SFilterInfo
*
pFilters
=
NULL
;
void
*
pFilters
=
NULL
;
STblCond
*
pCond
=
NULL
;
STblCond
*
pCond
=
NULL
;
if
(
px
->
colCond
)
{
if
(
px
->
colCond
)
{
pCond
=
tsGetTableFilter
(
px
->
colCond
,
pTableMeta
->
id
.
uid
,
0
);
pCond
=
tsGetTableFilter
(
px
->
colCond
,
pTableMeta
->
id
.
uid
,
0
);
...
@@ -1280,7 +1281,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
...
@@ -1280,7 +1281,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
for
(
int32_t
i
=
1
;
i
<
px
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
1
;
i
<
px
->
numOfTables
;
++
i
)
{
STableMeta
*
pTableMeta1
=
tscGetMetaInfo
(
px
,
i
)
->
pTableMeta
;
STableMeta
*
pTableMeta1
=
tscGetMetaInfo
(
px
,
i
)
->
pTableMeta
;
numOfCol1
=
pTableMeta1
->
tableInfo
.
numOfColumns
;
numOfCol1
=
pTableMeta1
->
tableInfo
.
numOfColumns
;
SFilterInfo
*
pFilters1
=
NULL
;
void
*
pFilters1
=
NULL
;
SSchema
*
pSchema1
=
tscGetTableSchema
(
pTableMeta1
);
SSchema
*
pSchema1
=
tscGetTableSchema
(
pTableMeta1
);
int32_t
n
=
pTableMeta1
->
tableInfo
.
numOfColumns
;
int32_t
n
=
pTableMeta1
->
tableInfo
.
numOfColumns
;
...
@@ -2906,16 +2907,6 @@ bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId, int32_t
...
@@ -2906,16 +2907,6 @@ bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId, int32_t
int32_t
tscTagCondCopy
(
STagCond
*
dest
,
const
STagCond
*
src
)
{
int32_t
tscTagCondCopy
(
STagCond
*
dest
,
const
STagCond
*
src
)
{
memset
(
dest
,
0
,
sizeof
(
STagCond
));
memset
(
dest
,
0
,
sizeof
(
STagCond
));
if
(
src
->
tbnameCond
.
cond
!=
NULL
)
{
dest
->
tbnameCond
.
cond
=
strdup
(
src
->
tbnameCond
.
cond
);
if
(
dest
->
tbnameCond
.
cond
==
NULL
)
{
return
-
1
;
}
}
dest
->
tbnameCond
.
uid
=
src
->
tbnameCond
.
uid
;
dest
->
tbnameCond
.
len
=
src
->
tbnameCond
.
len
;
dest
->
joinInfo
.
hasJoin
=
src
->
joinInfo
.
hasJoin
;
dest
->
joinInfo
.
hasJoin
=
src
->
joinInfo
.
hasJoin
;
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_JOIN_TABLE_NUM
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_JOIN_TABLE_NUM
;
++
i
)
{
...
@@ -2934,9 +2925,6 @@ int32_t tscTagCondCopy(STagCond* dest, const STagCond* src) {
...
@@ -2934,9 +2925,6 @@ int32_t tscTagCondCopy(STagCond* dest, const STagCond* src) {
}
}
}
}
dest
->
relType
=
src
->
relType
;
if
(
src
->
pCond
==
NULL
)
{
if
(
src
->
pCond
==
NULL
)
{
return
0
;
return
0
;
}
}
...
@@ -3026,8 +3014,6 @@ void tscColCondRelease(SArray** pCond) {
...
@@ -3026,8 +3014,6 @@ void tscColCondRelease(SArray** pCond) {
void
tscTagCondRelease
(
STagCond
*
pTagCond
)
{
void
tscTagCondRelease
(
STagCond
*
pTagCond
)
{
free
(
pTagCond
->
tbnameCond
.
cond
);
if
(
pTagCond
->
pCond
!=
NULL
)
{
if
(
pTagCond
->
pCond
!=
NULL
)
{
size_t
s
=
taosArrayGetSize
(
pTagCond
->
pCond
);
size_t
s
=
taosArrayGetSize
(
pTagCond
->
pCond
);
for
(
int32_t
i
=
0
;
i
<
s
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
s
;
++
i
)
{
...
...
src/common/inc/texpr.h
浏览文件 @
b0a25e92
...
@@ -88,7 +88,6 @@ void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *));
...
@@ -88,7 +88,6 @@ void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *));
void
exprTreeToBinary
(
SBufferWriter
*
bw
,
tExprNode
*
pExprTree
);
void
exprTreeToBinary
(
SBufferWriter
*
bw
,
tExprNode
*
pExprTree
);
tExprNode
*
exprTreeFromBinary
(
const
void
*
data
,
size_t
size
);
tExprNode
*
exprTreeFromBinary
(
const
void
*
data
,
size_t
size
);
tExprNode
*
exprTreeFromTableName
(
const
char
*
tbnameCond
);
tExprNode
*
exprdup
(
tExprNode
*
pTree
);
tExprNode
*
exprdup
(
tExprNode
*
pTree
);
void
exprTreeToBinary
(
SBufferWriter
*
bw
,
tExprNode
*
pExprTree
);
void
exprTreeToBinary
(
SBufferWriter
*
bw
,
tExprNode
*
pExprTree
);
...
...
src/common/src/texpr.c
浏览文件 @
b0a25e92
...
@@ -325,14 +325,6 @@ static void* exception_calloc(size_t nmemb, size_t size) {
...
@@ -325,14 +325,6 @@ static void* exception_calloc(size_t nmemb, size_t size) {
return
p
;
return
p
;
}
}
static
void
*
exception_malloc
(
size_t
size
)
{
void
*
p
=
malloc
(
size
);
if
(
p
==
NULL
)
{
THROW
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
return
p
;
}
static
UNUSED_FUNC
char
*
exception_strdup
(
const
char
*
str
)
{
static
UNUSED_FUNC
char
*
exception_strdup
(
const
char
*
str
)
{
char
*
p
=
strdup
(
str
);
char
*
p
=
strdup
(
str
);
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
...
@@ -395,97 +387,6 @@ tExprNode* exprTreeFromBinary(const void* data, size_t size) {
...
@@ -395,97 +387,6 @@ tExprNode* exprTreeFromBinary(const void* data, size_t size) {
return
exprTreeFromBinaryImpl
(
&
br
);
return
exprTreeFromBinaryImpl
(
&
br
);
}
}
tExprNode
*
exprTreeFromTableName
(
const
char
*
tbnameCond
)
{
if
(
!
tbnameCond
)
{
return
NULL
;
}
int32_t
anchor
=
CLEANUP_GET_ANCHOR
();
tExprNode
*
expr
=
exception_calloc
(
1
,
sizeof
(
tExprNode
));
CLEANUP_PUSH_VOID_PTR_PTR
(
true
,
tExprTreeDestroy
,
expr
,
NULL
);
expr
->
nodeType
=
TSQL_NODE_EXPR
;
tExprNode
*
left
=
exception_calloc
(
1
,
sizeof
(
tExprNode
));
expr
->
_node
.
pLeft
=
left
;
left
->
nodeType
=
TSQL_NODE_COL
;
SSchema
*
pSchema
=
exception_calloc
(
1
,
sizeof
(
SSchema
));
left
->
pSchema
=
pSchema
;
*
pSchema
=
*
tGetTbnameColumnSchema
();
tExprNode
*
right
=
exception_calloc
(
1
,
sizeof
(
tExprNode
));
expr
->
_node
.
pRight
=
right
;
if
(
strncmp
(
tbnameCond
,
QUERY_COND_REL_PREFIX_LIKE
,
QUERY_COND_REL_PREFIX_LIKE_LEN
)
==
0
)
{
right
->
nodeType
=
TSQL_NODE_VALUE
;
expr
->
_node
.
optr
=
TSDB_RELATION_LIKE
;
tVariant
*
pVal
=
exception_calloc
(
1
,
sizeof
(
tVariant
));
right
->
pVal
=
pVal
;
size_t
len
=
strlen
(
tbnameCond
+
QUERY_COND_REL_PREFIX_LIKE_LEN
)
+
1
;
pVal
->
pz
=
exception_malloc
(
len
);
memcpy
(
pVal
->
pz
,
tbnameCond
+
QUERY_COND_REL_PREFIX_LIKE_LEN
,
len
);
pVal
->
nType
=
TSDB_DATA_TYPE_BINARY
;
pVal
->
nLen
=
(
int32_t
)
len
;
}
else
if
(
strncmp
(
tbnameCond
,
QUERY_COND_REL_PREFIX_MATCH
,
QUERY_COND_REL_PREFIX_MATCH_LEN
)
==
0
)
{
right
->
nodeType
=
TSQL_NODE_VALUE
;
expr
->
_node
.
optr
=
TSDB_RELATION_MATCH
;
tVariant
*
pVal
=
exception_calloc
(
1
,
sizeof
(
tVariant
));
right
->
pVal
=
pVal
;
size_t
len
=
strlen
(
tbnameCond
+
QUERY_COND_REL_PREFIX_MATCH_LEN
)
+
1
;
pVal
->
pz
=
exception_malloc
(
len
);
memcpy
(
pVal
->
pz
,
tbnameCond
+
QUERY_COND_REL_PREFIX_MATCH_LEN
,
len
);
pVal
->
nType
=
TSDB_DATA_TYPE_BINARY
;
pVal
->
nLen
=
(
int32_t
)
len
;
}
else
if
(
strncmp
(
tbnameCond
,
QUERY_COND_REL_PREFIX_NMATCH
,
QUERY_COND_REL_PREFIX_NMATCH_LEN
)
==
0
)
{
right
->
nodeType
=
TSQL_NODE_VALUE
;
expr
->
_node
.
optr
=
TSDB_RELATION_NMATCH
;
tVariant
*
pVal
=
exception_calloc
(
1
,
sizeof
(
tVariant
));
right
->
pVal
=
pVal
;
size_t
len
=
strlen
(
tbnameCond
+
QUERY_COND_REL_PREFIX_NMATCH_LEN
)
+
1
;
pVal
->
pz
=
exception_malloc
(
len
);
memcpy
(
pVal
->
pz
,
tbnameCond
+
QUERY_COND_REL_PREFIX_NMATCH_LEN
,
len
);
pVal
->
nType
=
TSDB_DATA_TYPE_BINARY
;
pVal
->
nLen
=
(
int32_t
)
len
;
}
else
if
(
strncmp
(
tbnameCond
,
QUERY_COND_REL_PREFIX_IN
,
QUERY_COND_REL_PREFIX_IN_LEN
)
==
0
)
{
right
->
nodeType
=
TSQL_NODE_VALUE
;
expr
->
_node
.
optr
=
TSDB_RELATION_IN
;
tVariant
*
pVal
=
exception_calloc
(
1
,
sizeof
(
tVariant
));
right
->
pVal
=
pVal
;
pVal
->
nType
=
TSDB_DATA_TYPE_POINTER_ARRAY
;
pVal
->
arr
=
taosArrayInit
(
2
,
POINTER_BYTES
);
const
char
*
cond
=
tbnameCond
+
QUERY_COND_REL_PREFIX_IN_LEN
;
for
(
const
char
*
e
=
cond
;
*
e
!=
0
;
e
++
)
{
if
(
*
e
==
TS_PATH_DELIMITER
[
0
])
{
cond
=
e
+
1
;
}
else
if
(
*
e
==
','
)
{
size_t
len
=
e
-
cond
;
char
*
p
=
exception_malloc
(
len
+
VARSTR_HEADER_SIZE
);
STR_WITH_SIZE_TO_VARSTR
(
p
,
cond
,
(
VarDataLenT
)
len
);
cond
+=
len
;
taosArrayPush
(
pVal
->
arr
,
&
p
);
}
}
if
(
*
cond
!=
0
)
{
size_t
len
=
strlen
(
cond
)
+
VARSTR_HEADER_SIZE
;
char
*
p
=
exception_malloc
(
len
);
STR_WITH_SIZE_TO_VARSTR
(
p
,
cond
,
(
VarDataLenT
)(
len
-
VARSTR_HEADER_SIZE
));
taosArrayPush
(
pVal
->
arr
,
&
p
);
}
taosArraySortString
(
pVal
->
arr
,
taosArrayCompareString
);
}
CLEANUP_EXECUTE_TO
(
anchor
,
false
);
return
expr
;
}
void
buildFilterSetFromBinary
(
void
**
q
,
const
char
*
buf
,
int32_t
len
)
{
void
buildFilterSetFromBinary
(
void
**
q
,
const
char
*
buf
,
int32_t
len
)
{
SBufferReader
br
=
tbufInitReader
(
buf
,
len
,
false
);
SBufferReader
br
=
tbufInitReader
(
buf
,
len
,
false
);
uint32_t
type
=
tbufReadUint32
(
&
br
);
uint32_t
type
=
tbufReadUint32
(
&
br
);
...
...
src/inc/taosmsg.h
浏览文件 @
b0a25e92
...
@@ -492,7 +492,6 @@ typedef struct {
...
@@ -492,7 +492,6 @@ typedef struct {
SSessionWindow
sw
;
// session window
SSessionWindow
sw
;
// session window
uint16_t
tagCondLen
;
// tag length in current query
uint16_t
tagCondLen
;
// tag length in current query
uint16_t
colCondLen
;
// column length in current query
uint16_t
colCondLen
;
// column length in current query
uint32_t
tbnameCondLen
;
// table name filter condition string length
int16_t
numOfGroupCols
;
// num of group by columns
int16_t
numOfGroupCols
;
// num of group by columns
int16_t
orderByIdx
;
int16_t
orderByIdx
;
int16_t
orderType
;
// used in group by xx order by xxx
int16_t
orderType
;
// used in group by xx order by xxx
...
@@ -502,7 +501,6 @@ typedef struct {
...
@@ -502,7 +501,6 @@ typedef struct {
int64_t
offset
;
int64_t
offset
;
uint32_t
queryType
;
// denote another query process
uint32_t
queryType
;
// denote another query process
int16_t
numOfOutput
;
// final output columns numbers
int16_t
numOfOutput
;
// final output columns numbers
int16_t
tagNameRelType
;
// relation of tag criteria and tbname criteria
int16_t
fillType
;
// interpolate type
int16_t
fillType
;
// interpolate type
uint64_t
fillVal
;
// default value array list
uint64_t
fillVal
;
// default value array list
int32_t
secondStageOutput
;
int32_t
secondStageOutput
;
...
...
src/inc/tsdb.h
浏览文件 @
b0a25e92
...
@@ -352,8 +352,7 @@ SArray *tsdbRetrieveDataBlock(TsdbQueryHandleT *pQueryHandle, SArray *pColumnIdL
...
@@ -352,8 +352,7 @@ SArray *tsdbRetrieveDataBlock(TsdbQueryHandleT *pQueryHandle, SArray *pColumnIdL
* @param pTagCond. tag query condition
* @param pTagCond. tag query condition
*/
*/
int32_t
tsdbQuerySTableByTagCond
(
STsdbRepo
*
tsdb
,
uint64_t
uid
,
TSKEY
key
,
const
char
*
pTagCond
,
size_t
len
,
int32_t
tsdbQuerySTableByTagCond
(
STsdbRepo
*
tsdb
,
uint64_t
uid
,
TSKEY
key
,
const
char
*
pTagCond
,
size_t
len
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupList
,
STableGroupInfo
*
pGroupList
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
);
SColIndex
*
pColIndex
,
int32_t
numOfCols
);
/**
/**
* destroy the created table group list, which is generated by tag query
* destroy the created table group list, which is generated by tag query
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
b0a25e92
...
@@ -569,7 +569,7 @@ static void shellPrintNChar(const char *str, int length, int width) {
...
@@ -569,7 +569,7 @@ static void shellPrintNChar(const char *str, int length, int width) {
while
(
pos
<
length
)
{
while
(
pos
<
length
)
{
wchar_t
wc
;
wchar_t
wc
;
int
bytes
=
mbtowc
(
&
wc
,
str
+
pos
,
MB_CUR_MAX
);
int
bytes
=
mbtowc
(
&
wc
,
str
+
pos
,
MB_CUR_MAX
);
if
(
bytes
=
=
0
)
{
if
(
bytes
<
=
0
)
{
break
;
break
;
}
}
pos
+=
bytes
;
pos
+=
bytes
;
...
...
src/query/inc/qExecutor.h
浏览文件 @
b0a25e92
...
@@ -264,7 +264,7 @@ typedef struct SQueryAttr {
...
@@ -264,7 +264,7 @@ typedef struct SQueryAttr {
SOrderedPrjQueryInfo
prjInfo
;
// limit value for each vgroup, only available in global order projection query.
SOrderedPrjQueryInfo
prjInfo
;
// limit value for each vgroup, only available in global order projection query.
SSingleColumnFilterInfo
*
pFilterInfo
;
SSingleColumnFilterInfo
*
pFilterInfo
;
SFilterInfo
*
pFilters
;
void
*
pFilters
;
void
*
tsdb
;
void
*
tsdb
;
SMemRef
memRef
;
SMemRef
memRef
;
...
@@ -399,7 +399,6 @@ typedef struct SQueryParam {
...
@@ -399,7 +399,6 @@ typedef struct SQueryParam {
char
*
sql
;
char
*
sql
;
char
*
tagCond
;
char
*
tagCond
;
char
*
colCond
;
char
*
colCond
;
char
*
tbnameCond
;
char
*
prevResult
;
char
*
prevResult
;
SArray
*
pTableIdList
;
SArray
*
pTableIdList
;
SSqlExpr
**
pExpr
;
SSqlExpr
**
pExpr
;
...
@@ -407,7 +406,7 @@ typedef struct SQueryParam {
...
@@ -407,7 +406,7 @@ typedef struct SQueryParam {
SExprInfo
*
pExprs
;
SExprInfo
*
pExprs
;
SExprInfo
*
pSecExprs
;
SExprInfo
*
pSecExprs
;
SFilterInfo
*
pFilters
;
void
*
pFilters
;
SColIndex
*
pGroupColIndex
;
SColIndex
*
pGroupColIndex
;
SColumnInfo
*
pTagColumnInfo
;
SColumnInfo
*
pTagColumnInfo
;
...
@@ -417,6 +416,11 @@ typedef struct SQueryParam {
...
@@ -417,6 +416,11 @@ typedef struct SQueryParam {
SUdfInfo
*
pUdfInfo
;
SUdfInfo
*
pUdfInfo
;
}
SQueryParam
;
}
SQueryParam
;
typedef
struct
SColumnDataParam
{
int32_t
numOfCols
;
SArray
*
pDataBlock
;
}
SColumnDataParam
;
typedef
struct
STableScanInfo
{
typedef
struct
STableScanInfo
{
void
*
pQueryHandle
;
void
*
pQueryHandle
;
int32_t
numOfBlocks
;
int32_t
numOfBlocks
;
...
@@ -640,11 +644,11 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp
...
@@ -640,11 +644,11 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp
int32_t
createIndirectQueryFuncExprFromMsg
(
SQueryTableMsg
*
pQueryMsg
,
int32_t
numOfOutput
,
SExprInfo
**
pExprInfo
,
int32_t
createIndirectQueryFuncExprFromMsg
(
SQueryTableMsg
*
pQueryMsg
,
int32_t
numOfOutput
,
SExprInfo
**
pExprInfo
,
SSqlExpr
**
pExpr
,
SExprInfo
*
prevExpr
,
SUdfInfo
*
pUdfInfo
);
SSqlExpr
**
pExpr
,
SExprInfo
*
prevExpr
,
SUdfInfo
*
pUdfInfo
);
int32_t
createQueryFilter
(
char
*
data
,
uint16_t
len
,
SFilterInfo
**
pFilters
);
int32_t
createQueryFilter
(
char
*
data
,
uint16_t
len
,
void
**
pFilters
);
SGroupbyExpr
*
createGroupbyExprFromMsg
(
SQueryTableMsg
*
pQueryMsg
,
SColIndex
*
pColIndex
,
int32_t
*
code
);
SGroupbyExpr
*
createGroupbyExprFromMsg
(
SQueryTableMsg
*
pQueryMsg
,
SColIndex
*
pColIndex
,
int32_t
*
code
);
SQInfo
*
createQInfoImpl
(
SQueryTableMsg
*
pQueryMsg
,
SGroupbyExpr
*
pGroupbyExpr
,
SExprInfo
*
pExprs
,
SQInfo
*
createQInfoImpl
(
SQueryTableMsg
*
pQueryMsg
,
SGroupbyExpr
*
pGroupbyExpr
,
SExprInfo
*
pExprs
,
SExprInfo
*
pSecExprs
,
STableGroupInfo
*
pTableGroupInfo
,
SColumnInfo
*
pTagCols
,
SFilterInfo
*
pFilters
,
int32_t
vgId
,
char
*
sql
,
uint64_t
qId
,
SUdfInfo
*
pUdfInfo
);
SExprInfo
*
pSecExprs
,
STableGroupInfo
*
pTableGroupInfo
,
SColumnInfo
*
pTagCols
,
void
*
pFilters
,
int32_t
vgId
,
char
*
sql
,
uint64_t
qId
,
SUdfInfo
*
pUdfInfo
);
int32_t
initQInfo
(
STsBufInfo
*
pTsBufInfo
,
void
*
tsdb
,
void
*
sourceOptr
,
SQInfo
*
pQInfo
,
SQueryParam
*
param
,
char
*
start
,
int32_t
initQInfo
(
STsBufInfo
*
pTsBufInfo
,
void
*
tsdb
,
void
*
sourceOptr
,
SQInfo
*
pQInfo
,
SQueryParam
*
param
,
char
*
start
,
int32_t
prevResultLen
,
void
*
merger
);
int32_t
prevResultLen
,
void
*
merger
);
...
@@ -684,5 +688,6 @@ void freeQueryAttr(SQueryAttr *pQuery);
...
@@ -684,5 +688,6 @@ void freeQueryAttr(SQueryAttr *pQuery);
int32_t
getMaximumIdleDurationSec
();
int32_t
getMaximumIdleDurationSec
();
void
doInvokeUdf
(
SUdfInfo
*
pUdfInfo
,
SQLFunctionCtx
*
pCtx
,
int32_t
idx
,
int32_t
type
);
void
doInvokeUdf
(
SUdfInfo
*
pUdfInfo
,
SQLFunctionCtx
*
pCtx
,
int32_t
idx
,
int32_t
type
);
int32_t
getColumnDataFromId
(
void
*
param
,
int32_t
id
,
void
**
data
);
#endif // TDENGINE_QEXECUTOR_H
#endif // TDENGINE_QEXECUTOR_H
src/query/inc/qFilter.h
浏览文件 @
b0a25e92
...
@@ -83,6 +83,12 @@ enum {
...
@@ -83,6 +83,12 @@ enum {
RANGE_TYPE_MR_CTX
=
3
,
RANGE_TYPE_MR_CTX
=
3
,
};
};
enum
{
FI_ACTION_NO_NEED
=
1
,
FI_ACTION_CONTINUE
,
FI_ACTION_STOP
,
};
typedef
struct
OptrStr
{
typedef
struct
OptrStr
{
uint16_t
optr
;
uint16_t
optr
;
char
*
str
;
char
*
str
;
...
@@ -106,6 +112,7 @@ typedef struct SFilterColRange {
...
@@ -106,6 +112,7 @@ typedef struct SFilterColRange {
typedef
bool
(
*
rangeCompFunc
)
(
const
void
*
,
const
void
*
,
const
void
*
,
const
void
*
,
__compar_fn_t
);
typedef
bool
(
*
rangeCompFunc
)
(
const
void
*
,
const
void
*
,
const
void
*
,
const
void
*
,
__compar_fn_t
);
typedef
int32_t
(
*
filter_desc_compare_func
)(
const
void
*
,
const
void
*
);
typedef
int32_t
(
*
filter_desc_compare_func
)(
const
void
*
,
const
void
*
);
typedef
bool
(
*
filter_exec_func
)(
void
*
,
int32_t
,
int8_t
**
,
SDataStatis
*
,
int16_t
);
typedef
bool
(
*
filter_exec_func
)(
void
*
,
int32_t
,
int8_t
**
,
SDataStatis
*
,
int16_t
);
typedef
int32_t
(
*
filer_get_col_from_id
)(
void
*
,
int32_t
,
void
**
);
typedef
struct
SFilterRangeCompare
{
typedef
struct
SFilterRangeCompare
{
int64_t
s
;
int64_t
s
;
...
@@ -323,14 +330,16 @@ typedef struct SFilterInfo {
...
@@ -323,14 +330,16 @@ typedef struct SFilterInfo {
#define FILTER_EMPTY_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_EMPTY)
#define FILTER_EMPTY_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_EMPTY)
extern
int32_t
filterInitFromTree
(
tExprNode
*
tree
,
SFilterInfo
**
pinfo
,
uint32_t
options
);
extern
int32_t
filterInitFromTree
(
tExprNode
*
tree
,
void
**
pinfo
,
uint32_t
options
);
extern
bool
filterExecute
(
SFilterInfo
*
info
,
int32_t
numOfRows
,
int8_t
**
p
,
SDataStatis
*
statis
,
int16_t
numOfCols
);
extern
bool
filterExecute
(
SFilterInfo
*
info
,
int32_t
numOfRows
,
int8_t
**
p
,
SDataStatis
*
statis
,
int16_t
numOfCols
);
extern
int32_t
filterSetColFieldData
(
SFilterInfo
*
info
,
int32_t
numOfCols
,
SArray
*
pDataBlock
);
extern
int32_t
filterSetColFieldData
(
SFilterInfo
*
info
,
void
*
param
,
filer_get_col_from_id
fp
);
extern
int32_t
filterGetTimeRange
(
SFilterInfo
*
info
,
STimeWindow
*
win
);
extern
int32_t
filterGetTimeRange
(
SFilterInfo
*
info
,
STimeWindow
*
win
);
extern
int32_t
filterConverNcharColumns
(
SFilterInfo
*
pFilterInfo
,
int32_t
rows
,
bool
*
gotNchar
);
extern
int32_t
filterConverNcharColumns
(
SFilterInfo
*
pFilterInfo
,
int32_t
rows
,
bool
*
gotNchar
);
extern
int32_t
filterFreeNcharColumns
(
SFilterInfo
*
pFilterInfo
);
extern
int32_t
filterFreeNcharColumns
(
SFilterInfo
*
pFilterInfo
);
extern
void
filterFreeInfo
(
SFilterInfo
*
info
);
extern
void
filterFreeInfo
(
SFilterInfo
*
info
);
extern
bool
filterRangeExecute
(
SFilterInfo
*
info
,
SDataStatis
*
pDataStatis
,
int32_t
numOfCols
,
int32_t
numOfRows
);
extern
bool
filterRangeExecute
(
SFilterInfo
*
info
,
SDataStatis
*
pDataStatis
,
int32_t
numOfCols
,
int32_t
numOfRows
);
extern
int32_t
filterIsIndexedColumnQuery
(
SFilterInfo
*
info
,
int32_t
idxId
,
bool
*
res
);
extern
int32_t
filterGetIndexedColumnInfo
(
SFilterInfo
*
info
,
char
**
val
,
int32_t
*
order
,
int32_t
*
flag
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/query/inc/qTableMeta.h
浏览文件 @
b0a25e92
...
@@ -38,12 +38,6 @@ typedef struct SJoinInfo {
...
@@ -38,12 +38,6 @@ typedef struct SJoinInfo {
}
SJoinInfo
;
}
SJoinInfo
;
typedef
struct
STagCond
{
typedef
struct
STagCond
{
// relation between tbname list and query condition, including : TK_AND or TK_OR
int16_t
relType
;
// tbname query condition, only support tbname query condition on one table
SCond
tbnameCond
;
// join condition, only support two tables join currently
// join condition, only support two tables join currently
SJoinInfo
joinInfo
;
SJoinInfo
joinInfo
;
...
@@ -93,6 +87,7 @@ typedef struct STableMetaInfo {
...
@@ -93,6 +87,7 @@ typedef struct STableMetaInfo {
SName
name
;
SName
name
;
char
aliasName
[
TSDB_TABLE_NAME_LEN
];
// alias name of table specified in query sql
char
aliasName
[
TSDB_TABLE_NAME_LEN
];
// alias name of table specified in query sql
SArray
*
tagColList
;
// SArray<SColumn*>, involved tag columns
SArray
*
tagColList
;
// SArray<SColumn*>, involved tag columns
int32_t
joinTagNum
;
}
STableMetaInfo
;
}
STableMetaInfo
;
struct
SQInfo
;
// global merge operator
struct
SQInfo
;
// global merge operator
...
@@ -100,7 +95,7 @@ struct SQueryAttr; // query object
...
@@ -100,7 +95,7 @@ struct SQueryAttr; // query object
typedef
struct
STableFilter
{
typedef
struct
STableFilter
{
uint64_t
uid
;
uint64_t
uid
;
SFilterInfo
info
;
void
*
info
;
}
STableFilter
;
}
STableFilter
;
typedef
struct
SQueryInfo
{
typedef
struct
SQueryInfo
{
...
...
src/query/src/qExecutor.c
浏览文件 @
b0a25e92
...
@@ -2969,6 +2969,10 @@ void filterRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSingleColumnFilterInf
...
@@ -2969,6 +2969,10 @@ void filterRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSingleColumnFilterInf
}
}
if
(
!
tsBufNextPos
(
pRuntimeEnv
->
pTsBuf
))
{
if
(
!
tsBufNextPos
(
pRuntimeEnv
->
pTsBuf
))
{
if
(
i
<
(
numOfRows
-
1
))
{
all
=
false
;
}
break
;
break
;
}
}
}
}
...
@@ -3010,11 +3014,15 @@ void filterColRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSDataBlock* pBlock
...
@@ -3010,11 +3014,15 @@ void filterColRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSDataBlock* pBlock
p
[
offset
]
=
true
;
p
[
offset
]
=
true
;
}
}
if
(
!
tsBufNextPos
(
pRuntimeEnv
->
pTsBuf
))
{
if
(
!
tsBufNextPos
(
pRuntimeEnv
->
pTsBuf
))
{
if
(
i
<
(
numOfRows
-
1
))
{
all
=
false
;
}
break
;
break
;
}
}
}
}
// save the cursor status
// save the cursor status
pRuntimeEnv
->
current
->
cur
=
tsBufGetCursor
(
pRuntimeEnv
->
pTsBuf
);
pRuntimeEnv
->
current
->
cur
=
tsBufGetCursor
(
pRuntimeEnv
->
pTsBuf
);
}
else
{
}
else
{
...
@@ -3076,6 +3084,22 @@ void doSetFilterColumnInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFi
...
@@ -3076,6 +3084,22 @@ 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
;
for
(
int32_t
j
=
0
;
j
<
numOfCols
;
++
j
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pDataBlock
,
j
);
if
(
id
==
pColInfo
->
info
.
colId
)
{
*
data
=
pColInfo
->
pData
;
break
;
}
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
loadDataBlockOnDemand
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
STableScanInfo
*
pTableScanInfo
,
SSDataBlock
*
pBlock
,
int32_t
loadDataBlockOnDemand
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
STableScanInfo
*
pTableScanInfo
,
SSDataBlock
*
pBlock
,
uint32_t
*
status
)
{
uint32_t
*
status
)
{
*
status
=
BLK_DATA_NO_NEEDED
;
*
status
=
BLK_DATA_NO_NEEDED
;
...
@@ -3230,7 +3254,8 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
...
@@ -3230,7 +3254,8 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
}
}
if
(
pQueryAttr
->
pFilters
!=
NULL
)
{
if
(
pQueryAttr
->
pFilters
!=
NULL
)
{
filterSetColFieldData
(
pQueryAttr
->
pFilters
,
pBlock
->
info
.
numOfCols
,
pBlock
->
pDataBlock
);
SColumnDataParam
param
=
{.
numOfCols
=
pBlock
->
info
.
numOfCols
,
.
pDataBlock
=
pBlock
->
pDataBlock
};
filterSetColFieldData
(
pQueryAttr
->
pFilters
,
&
param
,
getColumnDataFromId
);
}
}
if
(
pQueryAttr
->
pFilters
!=
NULL
||
pRuntimeEnv
->
pTsBuf
!=
NULL
)
{
if
(
pQueryAttr
->
pFilters
!=
NULL
||
pRuntimeEnv
->
pTsBuf
!=
NULL
)
{
...
@@ -7517,7 +7542,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
...
@@ -7517,7 +7542,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
pQueryMsg
->
order
=
htons
(
pQueryMsg
->
order
);
pQueryMsg
->
order
=
htons
(
pQueryMsg
->
order
);
pQueryMsg
->
orderColId
=
htons
(
pQueryMsg
->
orderColId
);
pQueryMsg
->
orderColId
=
htons
(
pQueryMsg
->
orderColId
);
pQueryMsg
->
queryType
=
htonl
(
pQueryMsg
->
queryType
);
pQueryMsg
->
queryType
=
htonl
(
pQueryMsg
->
queryType
);
pQueryMsg
->
tagNameRelType
=
htons
(
pQueryMsg
->
tagNameRelType
);
pQueryMsg
->
numOfCols
=
htons
(
pQueryMsg
->
numOfCols
);
pQueryMsg
->
numOfCols
=
htons
(
pQueryMsg
->
numOfCols
);
pQueryMsg
->
numOfOutput
=
htons
(
pQueryMsg
->
numOfOutput
);
pQueryMsg
->
numOfOutput
=
htons
(
pQueryMsg
->
numOfOutput
);
...
@@ -7532,7 +7556,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
...
@@ -7532,7 +7556,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
pQueryMsg
->
tsBuf
.
tsOrder
=
htonl
(
pQueryMsg
->
tsBuf
.
tsOrder
);
pQueryMsg
->
tsBuf
.
tsOrder
=
htonl
(
pQueryMsg
->
tsBuf
.
tsOrder
);
pQueryMsg
->
numOfTags
=
htonl
(
pQueryMsg
->
numOfTags
);
pQueryMsg
->
numOfTags
=
htonl
(
pQueryMsg
->
numOfTags
);
pQueryMsg
->
tbnameCondLen
=
htonl
(
pQueryMsg
->
tbnameCondLen
);
pQueryMsg
->
secondStageOutput
=
htonl
(
pQueryMsg
->
secondStageOutput
);
pQueryMsg
->
secondStageOutput
=
htonl
(
pQueryMsg
->
secondStageOutput
);
pQueryMsg
->
sqlstrLen
=
htonl
(
pQueryMsg
->
sqlstrLen
);
pQueryMsg
->
sqlstrLen
=
htonl
(
pQueryMsg
->
sqlstrLen
);
pQueryMsg
->
prevResultLen
=
htonl
(
pQueryMsg
->
prevResultLen
);
pQueryMsg
->
prevResultLen
=
htonl
(
pQueryMsg
->
prevResultLen
);
...
@@ -7776,17 +7799,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
...
@@ -7776,17 +7799,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
pMsg
+=
pQueryMsg
->
prevResultLen
;
pMsg
+=
pQueryMsg
->
prevResultLen
;
}
}
if
(
pQueryMsg
->
tbnameCondLen
>
0
)
{
param
->
tbnameCond
=
calloc
(
1
,
pQueryMsg
->
tbnameCondLen
+
1
);
if
(
param
->
tbnameCond
==
NULL
)
{
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
goto
_cleanup
;
}
strncpy
(
param
->
tbnameCond
,
pMsg
,
pQueryMsg
->
tbnameCondLen
);
pMsg
+=
pQueryMsg
->
tbnameCondLen
;
}
//skip ts buf
//skip ts buf
if
((
pQueryMsg
->
tsBuf
.
tsOffset
+
pQueryMsg
->
tsBuf
.
tsLen
)
>
0
)
{
if
((
pQueryMsg
->
tsBuf
.
tsOffset
+
pQueryMsg
->
tsBuf
.
tsLen
)
>
0
)
{
pMsg
=
(
char
*
)
pQueryMsg
+
pQueryMsg
->
tsBuf
.
tsOffset
+
pQueryMsg
->
tsBuf
.
tsLen
;
pMsg
=
(
char
*
)
pQueryMsg
+
pQueryMsg
->
tsBuf
.
tsOffset
+
pQueryMsg
->
tsBuf
.
tsLen
;
...
@@ -8167,7 +8179,7 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp
...
@@ -8167,7 +8179,7 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
createQueryFilter
(
char
*
data
,
uint16_t
len
,
SFilterInfo
**
pFilters
)
{
int32_t
createQueryFilter
(
char
*
data
,
uint16_t
len
,
void
**
pFilters
)
{
tExprNode
*
expr
=
NULL
;
tExprNode
*
expr
=
NULL
;
TRY
(
TSDB_MAX_TAG_CONDITIONS
)
{
TRY
(
TSDB_MAX_TAG_CONDITIONS
)
{
...
@@ -8421,7 +8433,7 @@ FORCE_INLINE bool checkQIdEqual(void *qHandle, uint64_t qId) {
...
@@ -8421,7 +8433,7 @@ FORCE_INLINE bool checkQIdEqual(void *qHandle, uint64_t qId) {
}
}
SQInfo
*
createQInfoImpl
(
SQueryTableMsg
*
pQueryMsg
,
SGroupbyExpr
*
pGroupbyExpr
,
SExprInfo
*
pExprs
,
SQInfo
*
createQInfoImpl
(
SQueryTableMsg
*
pQueryMsg
,
SGroupbyExpr
*
pGroupbyExpr
,
SExprInfo
*
pExprs
,
SExprInfo
*
pSecExprs
,
STableGroupInfo
*
pTableGroupInfo
,
SColumnInfo
*
pTagCols
,
SFilterInfo
*
pFilters
,
int32_t
vgId
,
SExprInfo
*
pSecExprs
,
STableGroupInfo
*
pTableGroupInfo
,
SColumnInfo
*
pTagCols
,
void
*
pFilters
,
int32_t
vgId
,
char
*
sql
,
uint64_t
qId
,
SUdfInfo
*
pUdfInfo
)
{
char
*
sql
,
uint64_t
qId
,
SUdfInfo
*
pUdfInfo
)
{
int16_t
numOfCols
=
pQueryMsg
->
numOfCols
;
int16_t
numOfCols
=
pQueryMsg
->
numOfCols
;
int16_t
numOfOutput
=
pQueryMsg
->
numOfOutput
;
int16_t
numOfOutput
=
pQueryMsg
->
numOfOutput
;
...
...
src/query/src/qFilter.c
浏览文件 @
b0a25e92
...
@@ -28,14 +28,14 @@ OptrStr gOptrStr[] = {
...
@@ -28,14 +28,14 @@ OptrStr gOptrStr[] = {
{
TSDB_RELATION_GREATER_EQUAL
,
">="
},
{
TSDB_RELATION_GREATER_EQUAL
,
">="
},
{
TSDB_RELATION_NOT_EQUAL
,
"!="
},
{
TSDB_RELATION_NOT_EQUAL
,
"!="
},
{
TSDB_RELATION_LIKE
,
"like"
},
{
TSDB_RELATION_LIKE
,
"like"
},
{
TSDB_RELATION_MATCH
,
"match"
},
{
TSDB_RELATION_MATCH
,
"nmatch"
},
{
TSDB_RELATION_ISNULL
,
"is null"
},
{
TSDB_RELATION_ISNULL
,
"is null"
},
{
TSDB_RELATION_NOTNULL
,
"not null"
},
{
TSDB_RELATION_NOTNULL
,
"not null"
},
{
TSDB_RELATION_IN
,
"in"
},
{
TSDB_RELATION_IN
,
"in"
},
{
TSDB_RELATION_AND
,
"and"
},
{
TSDB_RELATION_AND
,
"and"
},
{
TSDB_RELATION_OR
,
"or"
},
{
TSDB_RELATION_OR
,
"or"
},
{
TSDB_RELATION_NOT
,
"not"
}
{
TSDB_RELATION_NOT
,
"not"
},
{
TSDB_RELATION_MATCH
,
"match"
},
{
TSDB_RELATION_NMATCH
,
"nmatch"
},
};
};
static
FORCE_INLINE
int32_t
filterFieldColDescCompare
(
const
void
*
desc1
,
const
void
*
desc2
)
{
static
FORCE_INLINE
int32_t
filterFieldColDescCompare
(
const
void
*
desc1
,
const
void
*
desc2
)
{
...
@@ -937,7 +937,7 @@ int32_t filterAddUnitToGroup(SFilterGroup *group, uint16_t unitIdx) {
...
@@ -937,7 +937,7 @@ int32_t filterAddUnitToGroup(SFilterGroup *group, uint16_t unitIdx) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
filterConvertSetFromBinary
(
void
**
q
,
const
char
*
buf
,
int32_t
len
,
uint32_t
tType
)
{
int32_t
filterConvertSetFromBinary
(
void
**
q
,
const
char
*
buf
,
int32_t
len
,
uint32_t
tType
,
bool
tolower
)
{
SBufferReader
br
=
tbufInitReader
(
buf
,
len
,
false
);
SBufferReader
br
=
tbufInitReader
(
buf
,
len
,
false
);
uint32_t
sType
=
tbufReadUint32
(
&
br
);
uint32_t
sType
=
tbufReadUint32
(
&
br
);
SHashObj
*
pObj
=
taosHashInit
(
256
,
taosGetDefaultHashFunction
(
tType
),
true
,
false
);
SHashObj
*
pObj
=
taosHashInit
(
256
,
taosGetDefaultHashFunction
(
tType
),
true
,
false
);
...
@@ -1113,6 +1113,10 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
...
@@ -1113,6 +1113,10 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
}
}
t
=
varDataLen
(
tmp
);
t
=
varDataLen
(
tmp
);
pvar
=
varDataVal
(
tmp
);
pvar
=
varDataVal
(
tmp
);
if
(
tolower
)
{
strntolower_s
(
pvar
,
pvar
,
(
int32_t
)
t
);
}
break
;
break
;
}
}
case
TSDB_DATA_TYPE_NCHAR
:
{
case
TSDB_DATA_TYPE_NCHAR
:
{
...
@@ -1157,7 +1161,7 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
...
@@ -1157,7 +1161,7 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
if
(
tree
->
_node
.
optr
==
TSDB_RELATION_IN
&&
(
!
IS_VAR_DATA_TYPE
(
type
)))
{
if
(
tree
->
_node
.
optr
==
TSDB_RELATION_IN
&&
(
!
IS_VAR_DATA_TYPE
(
type
)))
{
void
*
data
=
NULL
;
void
*
data
=
NULL
;
filterConvertSetFromBinary
((
void
**
)
&
data
,
var
->
pz
,
var
->
nLen
,
type
);
filterConvertSetFromBinary
((
void
**
)
&
data
,
var
->
pz
,
var
->
nLen
,
type
,
false
);
CHK_LRET
(
data
==
NULL
,
TSDB_CODE_QRY_APP_ERROR
,
"failed to convert in param"
);
CHK_LRET
(
data
==
NULL
,
TSDB_CODE_QRY_APP_ERROR
,
"failed to convert in param"
);
if
(
taosHashGetSize
((
SHashObj
*
)
data
)
<=
0
)
{
if
(
taosHashGetSize
((
SHashObj
*
)
data
)
<=
0
)
{
...
@@ -1484,19 +1488,6 @@ _return:
...
@@ -1484,19 +1488,6 @@ _return:
return
code
;
return
code
;
}
}
#if 0
int32_t filterInitUnitFunc(SFilterInfo *info) {
for (uint16_t i = 0; i < info->unitNum; ++i) {
SFilterUnit* unit = &info->units[i];
info->cunits[i].func = getComparFunc(FILTER_UNIT_DATA_TYPE(unit), unit->compare.optr);
}
return TSDB_CODE_SUCCESS;
}
#endif
void
filterDumpInfoToString
(
SFilterInfo
*
info
,
const
char
*
msg
,
int32_t
options
)
{
void
filterDumpInfoToString
(
SFilterInfo
*
info
,
const
char
*
msg
,
int32_t
options
)
{
if
(
qDebugFlag
&
DEBUG_DEBUG
)
{
if
(
qDebugFlag
&
DEBUG_DEBUG
)
{
CHK_LRETV
(
info
==
NULL
,
"%s - FilterInfo: EMPTY"
,
msg
);
CHK_LRETV
(
info
==
NULL
,
"%s - FilterInfo: EMPTY"
,
msg
);
...
@@ -1811,7 +1802,10 @@ int32_t filterInitValFieldData(SFilterInfo *info) {
...
@@ -1811,7 +1802,10 @@ int32_t filterInitValFieldData(SFilterInfo *info) {
}
}
if
(
unit
->
compare
.
optr
==
TSDB_RELATION_IN
)
{
if
(
unit
->
compare
.
optr
==
TSDB_RELATION_IN
)
{
filterConvertSetFromBinary
((
void
**
)
&
fi
->
data
,
var
->
pz
,
var
->
nLen
,
type
);
SSchema
*
sch
=
FILTER_UNIT_COL_DESC
(
info
,
unit
);
bool
tolower
=
(
sch
->
colId
==
-
1
)
?
true
:
false
;
filterConvertSetFromBinary
((
void
**
)
&
fi
->
data
,
var
->
pz
,
var
->
nLen
,
type
,
tolower
);
CHK_LRET
(
fi
->
data
==
NULL
,
TSDB_CODE_QRY_APP_ERROR
,
"failed to convert in param"
);
CHK_LRET
(
fi
->
data
==
NULL
,
TSDB_CODE_QRY_APP_ERROR
,
"failed to convert in param"
);
FILTER_SET_FLAG
(
fi
->
flag
,
FLD_DATA_IS_HASH
);
FILTER_SET_FLAG
(
fi
->
flag
,
FLD_DATA_IS_HASH
);
...
@@ -2544,8 +2538,6 @@ int32_t filterPostProcessRange(SFilterInfo *info) {
...
@@ -2544,8 +2538,6 @@ int32_t filterPostProcessRange(SFilterInfo *info) {
int32_t
filterGenerateComInfo
(
SFilterInfo
*
info
)
{
int32_t
filterGenerateComInfo
(
SFilterInfo
*
info
)
{
uint16_t
n
=
0
;
info
->
cunits
=
malloc
(
info
->
unitNum
*
sizeof
(
*
info
->
cunits
));
info
->
cunits
=
malloc
(
info
->
unitNum
*
sizeof
(
*
info
->
cunits
));
info
->
blkUnitRes
=
malloc
(
sizeof
(
*
info
->
blkUnitRes
)
*
info
->
unitNum
);
info
->
blkUnitRes
=
malloc
(
sizeof
(
*
info
->
blkUnitRes
)
*
info
->
unitNum
);
info
->
blkUnits
=
malloc
(
sizeof
(
*
info
->
blkUnits
)
*
(
info
->
unitNum
+
1
)
*
info
->
groupNum
);
info
->
blkUnits
=
malloc
(
sizeof
(
*
info
->
blkUnits
)
*
(
info
->
unitNum
+
1
)
*
info
->
groupNum
);
...
@@ -2573,24 +2565,6 @@ int32_t filterGenerateComInfo(SFilterInfo *info) {
...
@@ -2573,24 +2565,6 @@ int32_t filterGenerateComInfo(SFilterInfo *info) {
info
->
cunits
[
i
].
dataSize
=
FILTER_UNIT_COL_SIZE
(
info
,
unit
);
info
->
cunits
[
i
].
dataSize
=
FILTER_UNIT_COL_SIZE
(
info
,
unit
);
info
->
cunits
[
i
].
dataType
=
FILTER_UNIT_DATA_TYPE
(
unit
);
info
->
cunits
[
i
].
dataType
=
FILTER_UNIT_DATA_TYPE
(
unit
);
}
}
uint16_t
cgroupNum
=
info
->
groupNum
+
1
;
for
(
uint16_t
i
=
0
;
i
<
info
->
groupNum
;
++
i
)
{
cgroupNum
+=
info
->
groups
[
i
].
unitNum
;
}
info
->
cgroups
=
malloc
(
cgroupNum
*
sizeof
(
*
info
->
cgroups
));
for
(
uint16_t
i
=
0
;
i
<
info
->
groupNum
;
++
i
)
{
info
->
cgroups
[
n
++
]
=
info
->
groups
[
i
].
unitNum
;
for
(
uint16_t
m
=
0
;
m
<
info
->
groups
[
i
].
unitNum
;
++
m
)
{
info
->
cgroups
[
n
++
]
=
info
->
groups
[
i
].
unitIdxs
[
m
];
}
}
info
->
cgroups
[
n
]
=
0
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2664,10 +2638,12 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SDataStatis *pDataStatis, int32_t
...
@@ -2664,10 +2638,12 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SDataStatis *pDataStatis, int32_t
SDataStatis
*
pDataBlockst
=
&
pDataStatis
[
index
];
SDataStatis
*
pDataBlockst
=
&
pDataStatis
[
index
];
void
*
minVal
,
*
maxVal
;
void
*
minVal
,
*
maxVal
;
float
minv
=
0
;
float
maxv
=
0
;
if
(
cunit
->
dataType
==
TSDB_DATA_TYPE_FLOAT
)
{
if
(
cunit
->
dataType
==
TSDB_DATA_TYPE_FLOAT
)
{
float
minv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
min
));
minv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
min
));
float
maxv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
max
));
maxv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
max
));
minVal
=
&
minv
;
minVal
=
&
minv
;
maxVal
=
&
maxv
;
maxVal
=
&
maxv
;
...
@@ -2786,8 +2762,10 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p,
...
@@ -2786,8 +2762,10 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p,
bool
all
=
true
;
bool
all
=
true
;
uint16_t
*
unitIdx
=
NULL
;
uint16_t
*
unitIdx
=
NULL
;
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
if
(
*
p
==
NULL
)
{
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
//FILTER_UNIT_CLR_F(info);
//FILTER_UNIT_CLR_F(info);
...
@@ -2889,12 +2867,14 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows,
...
@@ -2889,12 +2867,14 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows,
return
all
;
return
all
;
}
}
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
if
(
*
p
==
NULL
)
{
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
uint16_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
uint16_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
(
char
*
)
info
->
cunits
[
uidx
].
colData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
void
*
colData
=
(
char
*
)
info
->
cunits
[
uidx
].
colData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
(
*
p
)[
i
]
=
isNull
(
colData
,
info
->
cunits
[
uidx
].
dataType
);
(
*
p
)[
i
]
=
((
colData
==
NULL
)
||
isNull
(
colData
,
info
->
cunits
[
uidx
].
dataType
)
);
if
((
*
p
)[
i
]
==
0
)
{
if
((
*
p
)[
i
]
==
0
)
{
all
=
false
;
all
=
false
;
}
}
...
@@ -2910,12 +2890,14 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows
...
@@ -2910,12 +2890,14 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows
return
all
;
return
all
;
}
}
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
if
(
*
p
==
NULL
)
{
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
uint16_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
uint16_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
(
char
*
)
info
->
cunits
[
uidx
].
colData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
void
*
colData
=
(
char
*
)
info
->
cunits
[
uidx
].
colData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
(
*
p
)[
i
]
=
!
isNull
(
colData
,
info
->
cunits
[
uidx
].
dataType
);
(
*
p
)[
i
]
=
((
colData
!=
NULL
)
&&
!
isNull
(
colData
,
info
->
cunits
[
uidx
].
dataType
)
);
if
((
*
p
)[
i
]
==
0
)
{
if
((
*
p
)[
i
]
==
0
)
{
all
=
false
;
all
=
false
;
}
}
...
@@ -2938,10 +2920,12 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SDataSta
...
@@ -2938,10 +2920,12 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SDataSta
return
all
;
return
all
;
}
}
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
if
(
*
p
==
NULL
)
{
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
if
(
isNull
(
colData
,
info
->
cunits
[
0
].
dataType
))
{
if
(
colData
==
NULL
||
isNull
(
colData
,
info
->
cunits
[
0
].
dataType
))
{
all
=
false
;
all
=
false
;
colData
+=
dataSize
;
colData
+=
dataSize
;
continue
;
continue
;
...
@@ -2966,13 +2950,16 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
...
@@ -2966,13 +2950,16 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
if
(
filterExecuteBasedOnStatis
(
info
,
numOfRows
,
p
,
statis
,
numOfCols
,
&
all
)
==
0
)
{
if
(
filterExecuteBasedOnStatis
(
info
,
numOfRows
,
p
,
statis
,
numOfCols
,
&
all
)
==
0
)
{
return
all
;
return
all
;
}
}
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
if
(
*
p
==
NULL
)
{
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
uint16_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
uint16_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
(
char
*
)
info
->
cunits
[
uidx
].
colData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
void
*
colData
=
(
char
*
)
info
->
cunits
[
uidx
].
colData
+
info
->
cunits
[
uidx
].
dataSize
*
i
;
if
(
isNull
(
colData
,
info
->
cunits
[
uidx
].
dataType
))
{
if
(
colData
==
NULL
||
isNull
(
colData
,
info
->
cunits
[
uidx
].
dataType
))
{
(
*
p
)[
i
]
=
0
;
all
=
false
;
all
=
false
;
continue
;
continue
;
}
}
...
@@ -2996,8 +2983,10 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
...
@@ -2996,8 +2983,10 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
return
all
;
return
all
;
}
}
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
if
(
*
p
==
NULL
)
{
*
p
=
calloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
//FILTER_UNIT_CLR_F(info);
//FILTER_UNIT_CLR_F(info);
...
@@ -3013,7 +3002,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
...
@@ -3013,7 +3002,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
//} else {
//} else {
uint8_t
optr
=
cunit
->
optr
;
uint8_t
optr
=
cunit
->
optr
;
if
(
isNull
(
colData
,
cunit
->
dataType
))
{
if
(
colData
==
NULL
||
isNull
(
colData
,
cunit
->
dataType
))
{
(
*
p
)[
i
]
=
optr
==
TSDB_RELATION_ISNULL
?
true
:
false
;
(
*
p
)[
i
]
=
optr
==
TSDB_RELATION_ISNULL
?
true
:
false
;
}
else
{
}
else
{
if
(
optr
==
TSDB_RELATION_NOTNULL
)
{
if
(
optr
==
TSDB_RELATION_NOTNULL
)
{
...
@@ -3132,7 +3121,7 @@ _return:
...
@@ -3132,7 +3121,7 @@ _return:
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
filterSetColFieldData
(
SFilterInfo
*
info
,
int32_t
numOfCols
,
SArray
*
pDataBlock
)
{
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
==
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
,
TSDB_CODE_QRY_APP_ERROR
,
"no column fileds"
);
...
@@ -3143,15 +3132,8 @@ int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDat
...
@@ -3143,15 +3132,8 @@ int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDat
for
(
uint16_t
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_COLUMN
].
num
;
++
i
)
{
for
(
uint16_t
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_COLUMN
].
num
;
++
i
)
{
SFilterField
*
fi
=
&
info
->
fields
[
FLD_TYPE_COLUMN
].
fields
[
i
];
SFilterField
*
fi
=
&
info
->
fields
[
FLD_TYPE_COLUMN
].
fields
[
i
];
SSchema
*
sch
=
fi
->
desc
;
SSchema
*
sch
=
fi
->
desc
;
for
(
int32_t
j
=
0
;
j
<
numOfCols
;
++
j
)
{
(
*
fp
)(
param
,
sch
->
colId
,
&
fi
->
data
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pDataBlock
,
j
);
if
(
sch
->
colId
==
pColInfo
->
info
.
colId
)
{
fi
->
data
=
pColInfo
->
pData
;
break
;
}
}
}
}
filterUpdateComUnits
(
info
);
filterUpdateComUnits
(
info
);
...
@@ -3160,7 +3142,7 @@ int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDat
...
@@ -3160,7 +3142,7 @@ int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDat
}
}
int32_t
filterInitFromTree
(
tExprNode
*
tree
,
SFilterInfo
**
pinfo
,
uint32_t
options
)
{
int32_t
filterInitFromTree
(
tExprNode
*
tree
,
void
**
pinfo
,
uint32_t
options
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SFilterInfo
*
info
=
NULL
;
SFilterInfo
*
info
=
NULL
;
...
@@ -3197,8 +3179,6 @@ int32_t filterInitFromTree(tExprNode* tree, SFilterInfo **pinfo, uint32_t option
...
@@ -3197,8 +3179,6 @@ int32_t filterInitFromTree(tExprNode* tree, SFilterInfo **pinfo, uint32_t option
taosArrayDestroy
(
group
);
taosArrayDestroy
(
group
);
return
code
;
return
code
;
}
}
//ERR_JRET(filterInitUnitFunc(info));
}
}
info
->
unitRes
=
malloc
(
info
->
unitNum
*
sizeof
(
*
info
->
unitRes
));
info
->
unitRes
=
malloc
(
info
->
unitNum
*
sizeof
(
*
info
->
unitRes
));
...
@@ -3257,30 +3237,35 @@ bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t num
...
@@ -3257,30 +3237,35 @@ bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t num
break
;
break
;
}
}
if
((
pDataStatis
[
index
].
numOfNull
<=
0
)
&&
(
ctx
->
isnull
&&
!
ctx
->
notnull
&&
!
ctx
->
isrange
))
{
if
(
pDataStatis
[
index
].
numOfNull
<=
0
)
{
ret
=
false
;
if
(
ctx
->
isnull
&&
!
ctx
->
notnull
&&
!
ctx
->
isrange
)
{
break
;
}
// all data in current column are NULL, no need to check its boundary value
if
(
pDataStatis
[
index
].
numOfNull
==
numOfRows
)
{
// if isNULL query exists, load the null data column
if
((
ctx
->
notnull
||
ctx
->
isrange
)
&&
(
!
ctx
->
isnull
))
{
ret
=
false
;
ret
=
false
;
break
;
break
;
}
}
}
else
if
(
pDataStatis
[
index
].
numOfNull
>
0
)
{
if
(
pDataStatis
[
index
].
numOfNull
==
numOfRows
)
{
if
((
ctx
->
notnull
||
ctx
->
isrange
)
&&
(
!
ctx
->
isnull
))
{
ret
=
false
;
break
;
}
continue
;
continue
;
}
else
{
if
(
ctx
->
isnull
)
{
continue
;
}
}
}
}
SDataStatis
*
pDataBlockst
=
&
pDataStatis
[
index
];
SDataStatis
*
pDataBlockst
=
&
pDataStatis
[
index
];
SFilterRangeNode
*
r
=
ctx
->
rs
;
SFilterRangeNode
*
r
=
ctx
->
rs
;
float
minv
=
0
;
float
maxv
=
0
;
if
(
ctx
->
type
==
TSDB_DATA_TYPE_FLOAT
)
{
if
(
ctx
->
type
==
TSDB_DATA_TYPE_FLOAT
)
{
float
minv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
min
));
minv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
min
));
float
maxv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
max
));
maxv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
max
));
minVal
=
&
minv
;
minVal
=
&
minv
;
maxVal
=
&
maxv
;
maxVal
=
&
maxv
;
...
@@ -3441,6 +3426,52 @@ int32_t filterFreeNcharColumns(SFilterInfo* info) {
...
@@ -3441,6 +3426,52 @@ int32_t filterFreeNcharColumns(SFilterInfo* info) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
filterIsIndexedColumnQuery
(
SFilterInfo
*
info
,
int32_t
idxId
,
bool
*
res
)
{
CHK_LRET
(
info
==
NULL
,
TSDB_CODE_QRY_APP_ERROR
,
"null parameter"
);
CHK_JMP
(
info
->
fields
[
FLD_TYPE_COLUMN
].
num
>
1
||
info
->
fields
[
FLD_TYPE_COLUMN
].
num
<=
0
);
CHK_JMP
(
info
->
unitNum
>
1
||
info
->
unitNum
<=
0
);
CHK_JMP
(
FILTER_GET_COL_FIELD_ID
(
FILTER_GET_COL_FIELD
(
info
,
0
))
!=
idxId
);
int32_t
optr
=
FILTER_UNIT_OPTR
(
info
->
units
);
CHK_JMP
(
optr
==
TSDB_RELATION_LIKE
||
optr
==
TSDB_RELATION_IN
||
optr
==
TSDB_RELATION_MATCH
||
optr
==
TSDB_RELATION_ISNULL
||
optr
==
TSDB_RELATION_NOTNULL
);
*
res
=
true
;
return
TSDB_CODE_SUCCESS
;
_return:
*
res
=
false
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
filterGetIndexedColumnInfo
(
SFilterInfo
*
info
,
char
**
val
,
int32_t
*
order
,
int32_t
*
flag
)
{
SFilterComUnit
*
cunit
=
info
->
cunits
;
uint8_t
optr
=
cunit
->
optr
;
*
val
=
cunit
->
valData
;
*
order
=
TSDB_ORDER_ASC
;
if
(
optr
==
TSDB_RELATION_LESS
||
optr
==
TSDB_RELATION_LESS_EQUAL
)
{
*
order
=
TSDB_ORDER_DESC
;
}
if
(
optr
==
TSDB_RELATION_NOT_EQUAL
)
{
*
order
=
TSDB_ORDER_ASC
|
TSDB_ORDER_DESC
;
}
if
(
cunit
->
valData2
==
cunit
->
valData
&&
optr
!=
TSDB_RELATION_EQUAL
)
{
FILTER_SET_FLAG
(
*
flag
,
FI_ACTION_NO_NEED
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
src/query/src/queryMain.c
浏览文件 @
b0a25e92
...
@@ -53,7 +53,6 @@ static void freeqinfoFn(void *qhandle) {
...
@@ -53,7 +53,6 @@ static void freeqinfoFn(void *qhandle) {
void
freeParam
(
SQueryParam
*
param
)
{
void
freeParam
(
SQueryParam
*
param
)
{
tfree
(
param
->
sql
);
tfree
(
param
->
sql
);
tfree
(
param
->
tagCond
);
tfree
(
param
->
tagCond
);
tfree
(
param
->
tbnameCond
);
tfree
(
param
->
pTableIdList
);
tfree
(
param
->
pTableIdList
);
taosArrayDestroy
(
param
->
pOperator
);
taosArrayDestroy
(
param
->
pOperator
);
tfree
(
param
->
pExprs
);
tfree
(
param
->
pExprs
);
...
@@ -140,7 +139,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi
...
@@ -140,7 +139,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi
qDebug
(
"qmsg:%p query stable, uid:%"
PRIu64
", tid:%d"
,
pQueryMsg
,
id
->
uid
,
id
->
tid
);
qDebug
(
"qmsg:%p query stable, uid:%"
PRIu64
", tid:%d"
,
pQueryMsg
,
id
->
uid
,
id
->
tid
);
code
=
tsdbQuerySTableByTagCond
(
tsdb
,
id
->
uid
,
pQueryMsg
->
window
.
skey
,
param
.
tagCond
,
pQueryMsg
->
tagCondLen
,
code
=
tsdbQuerySTableByTagCond
(
tsdb
,
id
->
uid
,
pQueryMsg
->
window
.
skey
,
param
.
tagCond
,
pQueryMsg
->
tagCondLen
,
pQueryMsg
->
tagNameRelType
,
param
.
tbnameCond
,
&
tableGroupInfo
,
param
.
pGroupColIndex
,
numOfGroupByCols
);
&
tableGroupInfo
,
param
.
pGroupColIndex
,
numOfGroupByCols
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"qmsg:%p failed to query stable, reason: %s"
,
pQueryMsg
,
tstrerror
(
code
));
qError
(
"qmsg:%p failed to query stable, reason: %s"
,
pQueryMsg
,
tstrerror
(
code
));
...
...
src/tsdb/CMakeLists.txt
浏览文件 @
b0a25e92
...
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
...
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
ADD_LIBRARY
(
tsdb
${
SRC
}
)
ADD_LIBRARY
(
tsdb
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
tsdb tfs common tutil
)
TARGET_LINK_LIBRARIES
(
tsdb tfs common tutil
)
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
b0a25e92
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "tlosertree.h"
#include "tlosertree.h"
#include "tsdbint.h"
#include "tsdbint.h"
#include "texpr.h"
#include "texpr.h"
#include "qFilter.h"
#define EXTRA_BYTES 2
#define EXTRA_BYTES 2
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
...
@@ -167,6 +168,7 @@ static int32_t doGetExternalRow(STsdbQueryHandle* pQueryHandle, int16_t type, SM
...
@@ -167,6 +168,7 @@ static int32_t doGetExternalRow(STsdbQueryHandle* pQueryHandle, int16_t type, SM
static
void
*
doFreeColumnInfoData
(
SArray
*
pColumnInfoData
);
static
void
*
doFreeColumnInfoData
(
SArray
*
pColumnInfoData
);
static
void
*
destroyTableCheckInfo
(
SArray
*
pTableCheckInfo
);
static
void
*
destroyTableCheckInfo
(
SArray
*
pTableCheckInfo
);
static
bool
tsdbGetExternalRow
(
TsdbQueryHandleT
pHandle
);
static
bool
tsdbGetExternalRow
(
TsdbQueryHandleT
pHandle
);
static
int32_t
tsdbQueryTableList
(
STable
*
pTable
,
SArray
*
pRes
,
void
*
filterInfo
);
static
void
tsdbInitDataBlockLoadInfo
(
SDataBlockLoadInfo
*
pBlockLoadInfo
)
{
static
void
tsdbInitDataBlockLoadInfo
(
SDataBlockLoadInfo
*
pBlockLoadInfo
)
{
pBlockLoadInfo
->
slot
=
-
1
;
pBlockLoadInfo
->
slot
=
-
1
;
...
@@ -2688,21 +2690,6 @@ static int32_t getAllTableList(STable* pSuperTable, SArray* list) {
...
@@ -2688,21 +2690,6 @@ static int32_t getAllTableList(STable* pSuperTable, SArray* list) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
destroyHelper
(
void
*
param
)
{
if
(
param
==
NULL
)
{
return
;
}
tQueryInfo
*
pInfo
=
(
tQueryInfo
*
)
param
;
if
(
pInfo
->
optr
!=
TSDB_RELATION_IN
)
{
tfree
(
pInfo
->
q
);
}
else
{
taosHashCleanup
((
SHashObj
*
)(
pInfo
->
q
));
}
free
(
param
);
}
static
bool
loadBlockOfActiveTable
(
STsdbQueryHandle
*
pQueryHandle
)
{
static
bool
loadBlockOfActiveTable
(
STsdbQueryHandle
*
pQueryHandle
)
{
if
(
pQueryHandle
->
checkFiles
)
{
if
(
pQueryHandle
->
checkFiles
)
{
// check if the query range overlaps with the file data block
// check if the query range overlaps with the file data block
...
@@ -3637,109 +3624,8 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
...
@@ -3637,109 +3624,8 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
return
pTableGroup
;
return
pTableGroup
;
}
}
static
bool
tableFilterFp
(
const
void
*
pNode
,
void
*
param
)
{
int32_t
tsdbQuerySTableByTagCond
(
STsdbRepo
*
tsdb
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
tQueryInfo
*
pInfo
=
(
tQueryInfo
*
)
param
;
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
)
{
STable
*
pTable
=
(
STable
*
)(
SL_GET_NODE_DATA
((
SSkipListNode
*
)
pNode
));
char
*
val
=
NULL
;
if
(
pInfo
->
sch
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
val
=
(
char
*
)
TABLE_NAME
(
pTable
);
}
else
{
val
=
tdGetKVRowValOfCol
(
pTable
->
tagVal
,
pInfo
->
sch
.
colId
);
}
if
(
pInfo
->
optr
==
TSDB_RELATION_ISNULL
||
pInfo
->
optr
==
TSDB_RELATION_NOTNULL
)
{
if
(
pInfo
->
optr
==
TSDB_RELATION_ISNULL
)
{
return
(
val
==
NULL
)
||
isNull
(
val
,
pInfo
->
sch
.
type
);
}
else
if
(
pInfo
->
optr
==
TSDB_RELATION_NOTNULL
)
{
return
(
val
!=
NULL
)
&&
(
!
isNull
(
val
,
pInfo
->
sch
.
type
));
}
}
else
if
(
pInfo
->
optr
==
TSDB_RELATION_IN
)
{
int
type
=
pInfo
->
sch
.
type
;
if
(
type
==
TSDB_DATA_TYPE_BOOL
||
IS_SIGNED_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
));
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
uint64_t
v
;
GET_TYPED_DATA
(
v
,
uint64_t
,
pInfo
->
sch
.
type
,
val
);
return
NULL
!=
taosHashGet
((
SHashObj
*
)
pInfo
->
q
,
(
char
*
)
&
v
,
sizeof
(
v
));
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
||
type
==
TSDB_DATA_TYPE_FLOAT
)
{
double
v
;
GET_TYPED_DATA
(
v
,
double
,
pInfo
->
sch
.
type
,
val
);
return
NULL
!=
taosHashGet
((
SHashObj
*
)
pInfo
->
q
,
(
char
*
)
&
v
,
sizeof
(
v
));
}
else
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
){
return
NULL
!=
taosHashGet
((
SHashObj
*
)
pInfo
->
q
,
varDataVal
(
val
),
varDataLen
(
val
));
}
}
int32_t
ret
=
0
;
if
(
val
==
NULL
)
{
//the val is possible to be null, so check it out carefully
ret
=
-
1
;
// val is missing in table tags value pairs
}
else
{
ret
=
pInfo
->
compare
(
val
,
pInfo
->
q
);
}
switch
(
pInfo
->
optr
)
{
case
TSDB_RELATION_EQUAL
:
{
return
ret
==
0
;
}
case
TSDB_RELATION_NOT_EQUAL
:
{
return
ret
!=
0
;
}
case
TSDB_RELATION_GREATER_EQUAL
:
{
return
ret
>=
0
;
}
case
TSDB_RELATION_GREATER
:
{
return
ret
>
0
;
}
case
TSDB_RELATION_LESS_EQUAL
:
{
return
ret
<=
0
;
}
case
TSDB_RELATION_LESS
:
{
return
ret
<
0
;
}
case
TSDB_RELATION_LIKE
:
{
return
ret
==
0
;
}
case
TSDB_RELATION_MATCH
:
{
return
ret
==
0
;
}
case
TSDB_RELATION_NMATCH
:
{
return
ret
==
0
;
}
case
TSDB_RELATION_IN
:
{
return
ret
==
1
;
}
default:
assert
(
false
);
}
return
true
;
}
static
void
getTableListfromSkipList
(
tExprNode
*
pExpr
,
SSkipList
*
pSkipList
,
SArray
*
result
,
SExprTraverseSupp
*
param
);
static
int32_t
doQueryTableList
(
STable
*
pSTable
,
SArray
*
pRes
,
tExprNode
*
pExpr
)
{
// query according to the expression tree
SExprTraverseSupp
supp
=
{
.
nodeFilterFn
=
(
__result_filter_fn_t
)
tableFilterFp
,
.
setupInfoFn
=
filterPrepare
,
.
pExtInfo
=
pSTable
->
tagSchema
,
};
getTableListfromSkipList
(
pExpr
,
pSTable
->
pIndex
,
pRes
,
&
supp
);
tExprTreeDestroy
(
pExpr
,
destroyHelper
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
tsdbQuerySTableByTagCond
(
STsdbRepo
*
tsdb
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
)
{
if
(
tsdbRLockRepoMeta
(
tsdb
)
<
0
)
goto
_error
;
if
(
tsdbRLockRepoMeta
(
tsdb
)
<
0
)
goto
_error
;
STable
*
pTable
=
tsdbGetTableByUid
(
tsdbGetMeta
(
tsdb
),
uid
);
STable
*
pTable
=
tsdbGetTableByUid
(
tsdbGetMeta
(
tsdb
),
uid
);
...
@@ -3765,7 +3651,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
...
@@ -3765,7 +3651,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
STSchema
*
pTagSchema
=
tsdbGetTableTagSchema
(
pTable
);
STSchema
*
pTagSchema
=
tsdbGetTableTagSchema
(
pTable
);
// no tags and tbname condition, all child tables of this stable are involved
// no tags and tbname condition, all child tables of this stable are involved
if
(
tbnameCond
==
NULL
&&
(
pTagCond
==
NULL
||
len
==
0
)
)
{
if
(
pTagCond
==
NULL
||
len
==
0
)
{
int32_t
ret
=
getAllTableList
(
pTable
,
res
);
int32_t
ret
=
getAllTableList
(
pTable
,
res
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tsdbUnlockRepoMeta
(
tsdb
);
tsdbUnlockRepoMeta
(
tsdb
);
...
@@ -3787,25 +3673,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
...
@@ -3787,25 +3673,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
tExprNode
*
expr
=
NULL
;
tExprNode
*
expr
=
NULL
;
TRY
(
TSDB_MAX_TAG_CONDITIONS
)
{
TRY
(
TSDB_MAX_TAG_CONDITIONS
)
{
expr
=
exprTreeFromTableName
(
tbnameCond
);
expr
=
exprTreeFromBinary
(
pTagCond
,
len
);
if
(
expr
==
NULL
)
{
expr
=
exprTreeFromBinary
(
pTagCond
,
len
);
}
else
{
CLEANUP_PUSH_VOID_PTR_PTR
(
true
,
tExprTreeDestroy
,
expr
,
NULL
);
tExprNode
*
tagExpr
=
exprTreeFromBinary
(
pTagCond
,
len
);
if
(
tagExpr
!=
NULL
)
{
CLEANUP_PUSH_VOID_PTR_PTR
(
true
,
tExprTreeDestroy
,
tagExpr
,
NULL
);
tExprNode
*
tbnameExpr
=
expr
;
expr
=
calloc
(
1
,
sizeof
(
tExprNode
));
if
(
expr
==
NULL
)
{
THROW
(
TSDB_CODE_TDB_OUT_OF_MEMORY
);
}
expr
->
nodeType
=
TSQL_NODE_EXPR
;
expr
->
_node
.
optr
=
(
uint8_t
)
tagNameRelType
;
expr
->
_node
.
pLeft
=
tagExpr
;
expr
->
_node
.
pRight
=
tbnameExpr
;
}
}
CLEANUP_EXECUTE
();
CLEANUP_EXECUTE
();
}
CATCH
(
code
)
{
}
CATCH
(
code
)
{
...
@@ -3817,7 +3685,20 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
...
@@ -3817,7 +3685,20 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
// TODO: more error handling
// TODO: more error handling
}
END_TRY
}
END_TRY
doQueryTableList
(
pTable
,
res
,
expr
);
void
*
filterInfo
=
NULL
;
ret
=
filterInitFromTree
(
expr
,
&
filterInfo
,
0
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
ret
;
goto
_error
;
}
tsdbQueryTableList
(
pTable
,
res
,
filterInfo
);
filterFreeInfo
(
filterInfo
);
tExprTreeDestroy
(
expr
,
NULL
);
pGroupInfo
->
numOfTables
=
(
uint32_t
)
taosArrayGetSize
(
res
);
pGroupInfo
->
numOfTables
=
(
uint32_t
)
taosArrayGetSize
(
res
);
pGroupInfo
->
pGroupList
=
createTableGroup
(
res
,
pTagSchema
,
pColIndex
,
numOfCols
,
skey
);
pGroupInfo
->
pGroupList
=
createTableGroup
(
res
,
pTagSchema
,
pColIndex
,
numOfCols
,
skey
);
...
@@ -4001,259 +3882,115 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) {
...
@@ -4001,259 +3882,115 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) {
pGroupList
->
numOfTables
=
0
;
pGroupList
->
numOfTables
=
0
;
}
}
static
void
applyFilterToSkipListNode
(
SSkipList
*
pSkipList
,
tExprNode
*
pExpr
,
SArray
*
pResult
,
SExprTraverseSupp
*
param
)
{
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
pSkipList
);
// Scan each node in the skiplist by using iterator
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
if
(
exprTreeApplyFilter
(
pExpr
,
pNode
,
param
))
{
taosArrayPush
(
pResult
,
&
(
SL_GET_NODE_DATA
(
pNode
)));
}
}
tSkipListDestroyIter
(
iter
);
}
typedef
struct
{
static
FORCE_INLINE
int32_t
tsdbGetTagDataFromId
(
void
*
param
,
int32_t
id
,
void
**
data
)
{
char
*
v
;
STable
*
pTable
=
(
STable
*
)(
SL_GET_NODE_DATA
((
SSkipListNode
*
)
param
));
int32_t
optr
;
}
SEndPoint
;
if
(
id
==
TSDB_TBNAME_COLUMN_INDEX
)
{
*
data
=
TABLE_NAME
(
pTable
);
typedef
struct
{
}
else
{
SEndPoint
*
start
;
*
data
=
tdGetKVRowValOfCol
(
pTable
->
tagVal
,
id
);
SEndPoint
*
end
;
}
SQueryCond
;
// todo check for malloc failure
static
int32_t
setQueryCond
(
tQueryInfo
*
queryColInfo
,
SQueryCond
*
pCond
)
{
int32_t
optr
=
queryColInfo
->
optr
;
if
(
optr
==
TSDB_RELATION_GREATER
||
optr
==
TSDB_RELATION_GREATER_EQUAL
||
optr
==
TSDB_RELATION_EQUAL
||
optr
==
TSDB_RELATION_NOT_EQUAL
)
{
pCond
->
start
=
calloc
(
1
,
sizeof
(
SEndPoint
));
pCond
->
start
->
optr
=
queryColInfo
->
optr
;
pCond
->
start
->
v
=
queryColInfo
->
q
;
}
else
if
(
optr
==
TSDB_RELATION_LESS
||
optr
==
TSDB_RELATION_LESS_EQUAL
)
{
pCond
->
end
=
calloc
(
1
,
sizeof
(
SEndPoint
));
pCond
->
end
->
optr
=
queryColInfo
->
optr
;
pCond
->
end
->
v
=
queryColInfo
->
q
;
}
else
if
(
optr
==
TSDB_RELATION_IN
)
{
pCond
->
start
=
calloc
(
1
,
sizeof
(
SEndPoint
));
pCond
->
start
->
optr
=
queryColInfo
->
optr
;
pCond
->
start
->
v
=
queryColInfo
->
q
;
}
else
if
(
optr
==
TSDB_RELATION_LIKE
)
{
assert
(
0
);
}
else
if
(
optr
==
TSDB_RELATION_MATCH
)
{
assert
(
0
);
}
else
if
(
optr
==
TSDB_RELATION_NMATCH
)
{
assert
(
0
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
queryIndexedColumn
(
SSkipList
*
pSkipList
,
tQueryInfo
*
pQueryInfo
,
SArray
*
result
)
{
SSkipListIterator
*
iter
=
NULL
;
SQueryCond
cond
=
{
0
};
if
(
setQueryCond
(
pQueryInfo
,
&
cond
)
!=
TSDB_CODE_SUCCESS
)
{
//todo handle error
}
if
(
cond
.
start
!=
NULL
)
{
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
char
*
)
cond
.
start
->
v
,
pSkipList
->
type
,
TSDB_ORDER_ASC
);
}
else
{
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
char
*
)(
cond
.
end
?
cond
.
end
->
v
:
NULL
),
pSkipList
->
type
,
TSDB_ORDER_DESC
);
}
if
(
cond
.
start
!=
NULL
)
{
int32_t
optr
=
cond
.
start
->
optr
;
if
(
optr
==
TSDB_RELATION_EQUAL
)
{
// equals
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
int32_t
ret
=
pQueryInfo
->
compare
(
SL_GET_NODE_KEY
(
pSkipList
,
pNode
),
cond
.
start
->
v
);
if
(
ret
!=
0
)
{
break
;
}
STableKeyInfo
info
=
{.
pTable
=
(
void
*
)
SL_GET_NODE_DATA
(
pNode
),
.
lastKey
=
TSKEY_INITIAL_VAL
};
taosArrayPush
(
result
,
&
info
);
}
}
else
if
(
optr
==
TSDB_RELATION_GREATER
||
optr
==
TSDB_RELATION_GREATER_EQUAL
)
{
// greater equal
bool
comp
=
true
;
int32_t
ret
=
0
;
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
if
(
comp
)
{
ret
=
pQueryInfo
->
compare
(
SL_GET_NODE_KEY
(
pSkipList
,
pNode
),
cond
.
start
->
v
);
assert
(
ret
>=
0
);
}
if
(
ret
==
0
&&
optr
==
TSDB_RELATION_GREATER
)
{
continue
;
}
else
{
STableKeyInfo
info
=
{.
pTable
=
(
void
*
)
SL_GET_NODE_DATA
(
pNode
),
.
lastKey
=
TSKEY_INITIAL_VAL
};
taosArrayPush
(
result
,
&
info
);
comp
=
false
;
}
}
}
else
if
(
optr
==
TSDB_RELATION_NOT_EQUAL
)
{
// not equal
bool
comp
=
true
;
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
comp
=
comp
&&
(
pQueryInfo
->
compare
(
SL_GET_NODE_KEY
(
pSkipList
,
pNode
),
cond
.
start
->
v
)
==
0
);
if
(
comp
)
{
continue
;
}
STableKeyInfo
info
=
{.
pTable
=
(
void
*
)
SL_GET_NODE_DATA
(
pNode
),
.
lastKey
=
TSKEY_INITIAL_VAL
};
taosArrayPush
(
result
,
&
info
);
}
tSkipListDestroyIter
(
iter
);
comp
=
true
;
static
void
queryIndexedColumn
(
SSkipList
*
pSkipList
,
void
*
filterInfo
,
SArray
*
res
)
{
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
char
*
)
cond
.
start
->
v
,
pSkipList
->
type
,
TSDB_ORDER_DESC
);
SSkipListIterator
*
iter
=
NULL
;
while
(
tSkipListIterNext
(
iter
))
{
char
*
startVal
=
NULL
;
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
int32_t
order
=
0
;
comp
=
comp
&&
(
pQueryInfo
->
compare
(
SL_GET_NODE_KEY
(
pSkipList
,
pNode
),
cond
.
start
->
v
)
==
0
);
int32_t
inRange
=
0
;
if
(
comp
)
{
int32_t
flag
=
0
;
continue
;
bool
all
=
false
;
}
int8_t
*
addToResult
=
NULL
;
STableKeyInfo
info
=
{.
pTable
=
(
void
*
)
SL_GET_NODE_DATA
(
pNode
),
.
lastKey
=
TSKEY_INITIAL_VAL
};
taosArrayPush
(
result
,
&
info
);
}
}
else
if
(
optr
==
TSDB_RELATION_IN
)
{
filterGetIndexedColumnInfo
(
filterInfo
,
&
startVal
,
&
order
,
&
flag
);
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
int32_t
ret
=
pQueryInfo
->
compare
(
SL_GET_NODE_KEY
(
pSkipList
,
pNode
),
cond
.
start
->
v
);
tsdbDebug
(
"filter index column start, order:%d, flag:%d"
,
order
,
flag
);
if
(
ret
!=
0
)
{
break
;
}
STableKeyInfo
info
=
{.
pTable
=
(
void
*
)
SL_GET_NODE_DATA
(
pNode
),
.
lastKey
=
TSKEY_INITIAL_VAL
};
while
(
order
)
{
taosArrayPush
(
result
,
&
info
);
if
(
FILTER_GET_FLAG
(
order
,
TSDB_ORDER_ASC
))
{
}
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
startVal
,
pSkipList
->
type
,
TSDB_ORDER_ASC
);
FILTER_CLR_FLAG
(
order
,
TSDB_ORDER_ASC
);
}
else
{
}
else
{
assert
(
0
);
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
startVal
,
pSkipList
->
type
,
TSDB_ORDER_DESC
);
FILTER_CLR_FLAG
(
order
,
TSDB_ORDER_DESC
);
}
}
}
else
{
int32_t
optr
=
cond
.
end
?
cond
.
end
->
optr
:
TSDB_RELATION_INVALID
;
while
(
tSkipListIterNext
(
iter
))
{
if
(
optr
==
TSDB_RELATION_LESS
||
optr
==
TSDB_RELATION_LESS_EQUAL
)
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
bool
comp
=
true
;
int32_t
ret
=
0
;
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
if
(
comp
)
{
ret
=
pQueryInfo
->
compare
(
SL_GET_NODE_KEY
(
pSkipList
,
pNode
),
cond
.
end
->
v
);
assert
(
ret
<=
0
);
}
if
(
ret
==
0
&&
optr
==
TSDB_RELATION_LESS
)
{
if
(
inRange
==
0
||
!
FILTER_GET_FLAG
(
flag
,
FI_ACTION_NO_NEED
))
{
continue
;
tsdbDebug
(
"filter index column, filter it"
);
}
else
{
filterSetColFieldData
(
filterInfo
,
pNode
,
tsdbGetTagDataFromId
);
STableKeyInfo
info
=
{.
pTable
=
(
void
*
)
SL_GET_NODE_DATA
(
pNode
),
.
lastKey
=
TSKEY_INITIAL_VAL
};
all
=
filterExecute
(
filterInfo
,
1
,
&
addToResult
,
NULL
,
0
);
taosArrayPush
(
result
,
&
info
);
comp
=
false
;
// no need to compare anymore
}
}
}
}
else
{
assert
(
pQueryInfo
->
optr
==
TSDB_RELATION_ISNULL
||
pQueryInfo
->
optr
==
TSDB_RELATION_NOTNULL
);
char
*
pData
=
SL_GET_NODE_DATA
(
pNode
);
while
(
tSkipListIterNext
(
iter
))
{
tsdbDebug
(
"filter index column, table:%s, result:%d"
,
((
STable
*
)
pData
)
->
name
->
data
,
all
);
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
bool
isnull
=
isNull
(
SL_GET_NODE_KEY
(
pSkipList
,
pNode
),
pQueryInfo
->
sch
.
type
);
if
(
all
||
(
addToResult
&&
*
addToResult
))
{
if
((
pQueryInfo
->
optr
==
TSDB_RELATION_ISNULL
&&
isnull
)
||
STableKeyInfo
info
=
{.
pTable
=
(
void
*
)
pData
,
.
lastKey
=
TSKEY_INITIAL_VAL
};
(
pQueryInfo
->
optr
==
TSDB_RELATION_NOTNULL
&&
(
!
isnull
)))
{
taosArrayPush
(
res
,
&
info
);
STableKeyInfo
info
=
{.
pTable
=
(
void
*
)
SL_GET_NODE_DATA
(
pNode
),
.
lastKey
=
TSKEY_INITIAL_VAL
}
;
inRange
=
1
;
taosArrayPush
(
result
,
&
info
);
}
else
if
(
inRange
){
}
break
;
}
}
}
}
inRange
=
0
;
tfree
(
addToResult
);
tSkipListDestroyIter
(
iter
);
}
}
free
(
cond
.
start
);
tsdbDebug
(
"filter index column end"
);
free
(
cond
.
end
);
tSkipListDestroyIter
(
iter
);
}
}
static
void
queryIndexlessColumn
(
SSkipList
*
pSkipList
,
tQueryInfo
*
pQueryInfo
,
SArray
*
res
,
__result_filter_fn_t
filterFp
)
{
static
void
queryIndexlessColumn
(
SSkipList
*
pSkipList
,
void
*
filterInfo
,
SArray
*
res
)
{
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
pSkipList
);
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
pSkipList
);
int8_t
*
addToResult
=
NULL
;
while
(
tSkipListIterNext
(
iter
))
{
while
(
tSkipListIterNext
(
iter
))
{
bool
addToResult
=
false
;
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
filterSetColFieldData
(
filterInfo
,
pNode
,
tsdbGetTagDataFromId
);
char
*
pData
=
SL_GET_NODE_DATA
(
pNode
);
char
*
pData
=
SL_GET_NODE_DATA
(
pNode
);
tstr
*
name
=
(
tstr
*
)
tsdbGetTableName
((
void
*
)
pData
);
// todo speed up by using hash
if
(
pQueryInfo
->
sch
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
pQueryInfo
->
optr
==
TSDB_RELATION_IN
)
{
addToResult
=
pQueryInfo
->
compare
(
name
,
pQueryInfo
->
q
);
}
else
if
(
pQueryInfo
->
optr
==
TSDB_RELATION_LIKE
||
pQueryInfo
->
optr
==
TSDB_RELATION_MATCH
||
pQueryInfo
->
optr
==
TSDB_RELATION_NMATCH
)
{
addToResult
=
!
pQueryInfo
->
compare
(
name
,
pQueryInfo
->
q
);
}
}
else
{
addToResult
=
filterFp
(
pNode
,
pQueryInfo
);
}
if
(
addToResult
)
{
bool
all
=
filterExecute
(
filterInfo
,
1
,
&
addToResult
,
NULL
,
0
);
if
(
all
||
(
addToResult
&&
*
addToResult
))
{
STableKeyInfo
info
=
{.
pTable
=
(
void
*
)
pData
,
.
lastKey
=
TSKEY_INITIAL_VAL
};
STableKeyInfo
info
=
{.
pTable
=
(
void
*
)
pData
,
.
lastKey
=
TSKEY_INITIAL_VAL
};
taosArrayPush
(
res
,
&
info
);
taosArrayPush
(
res
,
&
info
);
}
}
}
}
tfree
(
addToResult
);
tSkipListDestroyIter
(
iter
);
tSkipListDestroyIter
(
iter
);
}
}
// Apply the filter expression to each node in the skiplist to acquire the qualified nodes in skip list
void
getTableListfromSkipList
(
tExprNode
*
pExpr
,
SSkipList
*
pSkipList
,
SArray
*
result
,
SExprTraverseSupp
*
param
)
{
if
(
pExpr
==
NULL
)
{
return
;
}
tExprNode
*
pLeft
=
pExpr
->
_node
.
pLeft
;
tExprNode
*
pRight
=
pExpr
->
_node
.
pRight
;
// column project
static
int32_t
tsdbQueryTableList
(
STable
*
pTable
,
SArray
*
pRes
,
void
*
filterInfo
)
{
if
(
pLeft
->
nodeType
!=
TSQL_NODE_EXPR
&&
pRight
->
nodeType
!=
TSQL_NODE_EXPR
)
{
STSchema
*
pTSSchema
=
pTable
->
tagSchema
;
assert
(
pLeft
->
nodeType
==
TSQL_NODE_COL
&&
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
||
pRight
->
nodeType
==
TSQL_NODE_DUMMY
));
bool
indexQuery
=
false
;
SSkipList
*
pSkipList
=
pTable
->
pIndex
;
param
->
setupInfoFn
(
pExpr
,
param
->
pExtInfo
);
filterIsIndexedColumnQuery
(
filterInfo
,
pTSSchema
->
columns
->
colId
,
&
indexQuery
);
if
(
indexQuery
)
{
queryIndexedColumn
(
pSkipList
,
filterInfo
,
pRes
);
}
else
{
queryIndexlessColumn
(
pSkipList
,
filterInfo
,
pRes
);
}
tQueryInfo
*
pQueryInfo
=
pExpr
->
_node
.
info
;
return
TSDB_CODE_SUCCESS
;
if
(
pQueryInfo
->
indexed
&&
(
pQueryInfo
->
optr
!=
TSDB_RELATION_LIKE
}
&&
pQueryInfo
->
optr
!=
TSDB_RELATION_MATCH
&&
pQueryInfo
->
optr
!=
TSDB_RELATION_NMATCH
&&
pQueryInfo
->
optr
!=
TSDB_RELATION_IN
))
{
queryIndexedColumn
(
pSkipList
,
pQueryInfo
,
result
);
}
else
{
queryIndexlessColumn
(
pSkipList
,
pQueryInfo
,
result
,
param
->
nodeFilterFn
);
}
return
;
}
// The value of hasPK is always 0.
uint8_t
weight
=
pLeft
->
_node
.
hasPK
+
pRight
->
_node
.
hasPK
;
assert
(
weight
==
0
&&
pSkipList
!=
NULL
&&
taosArrayGetSize
(
result
)
==
0
);
//apply the hierarchical filter expression to every node in skiplist to find the qualified nodes
applyFilterToSkipListNode
(
pSkipList
,
pExpr
,
result
,
param
);
}
src/util/src/tcompare.c
浏览文件 @
b0a25e92
...
@@ -233,14 +233,20 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
...
@@ -233,14 +233,20 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
int32_t
i
=
0
;
int32_t
i
=
0
;
int32_t
j
=
0
;
int32_t
j
=
0
;
int32_t
o
=
0
;
int32_t
m
=
0
;
while
((
c
=
patterStr
[
i
++
])
!=
0
)
{
while
((
c
=
patterStr
[
i
++
])
!=
0
)
{
if
(
c
==
pInfo
->
matchAll
)
{
/* Match "*" */
if
(
c
==
pInfo
->
matchAll
)
{
/* Match "*" */
while
((
c
=
patterStr
[
i
++
])
==
pInfo
->
matchAll
||
c
==
pInfo
->
matchOne
)
{
while
((
c
=
patterStr
[
i
++
])
==
pInfo
->
matchAll
||
c
==
pInfo
->
matchOne
)
{
if
(
c
==
pInfo
->
matchOne
&&
(
j
>
size
||
str
[
j
++
]
==
0
))
{
if
(
c
==
pInfo
->
matchOne
)
{
// empty string, return not match
if
(
j
>
size
||
str
[
j
++
]
==
0
)
{
return
TSDB_PATTERN_NOWILDCARDMATCH
;
// empty string, return not match
return
TSDB_PATTERN_NOWILDCARDMATCH
;
}
else
{
++
o
;
}
}
}
}
}
...
@@ -249,9 +255,10 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
...
@@ -249,9 +255,10 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
}
}
char
next
[
3
]
=
{
toupper
(
c
),
tolower
(
c
),
0
};
char
next
[
3
]
=
{
toupper
(
c
),
tolower
(
c
),
0
};
m
=
o
;
while
(
1
)
{
while
(
1
)
{
size_t
n
=
strcspn
(
str
,
next
);
size_t
n
=
strcspn
(
str
+
m
,
next
);
str
+=
n
;
str
+=
m
+
n
;
if
(
str
[
0
]
==
0
||
(
n
>=
size
))
{
if
(
str
[
0
]
==
0
||
(
n
>=
size
))
{
break
;
break
;
...
@@ -261,12 +268,14 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
...
@@ -261,12 +268,14 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
if
(
ret
!=
TSDB_PATTERN_NOMATCH
)
{
if
(
ret
!=
TSDB_PATTERN_NOMATCH
)
{
return
ret
;
return
ret
;
}
}
m
=
0
;
}
}
return
TSDB_PATTERN_NOWILDCARDMATCH
;
return
TSDB_PATTERN_NOWILDCARDMATCH
;
}
}
c1
=
str
[
j
++
];
c1
=
str
[
j
++
];
++
o
;
if
(
j
<=
size
)
{
if
(
j
<=
size
)
{
if
(
c
==
'\\'
&&
patterStr
[
i
]
==
'_'
&&
c1
==
'_'
)
{
i
++
;
continue
;
}
if
(
c
==
'\\'
&&
patterStr
[
i
]
==
'_'
&&
c1
==
'_'
)
{
i
++
;
continue
;
}
if
(
c
==
c1
||
tolower
(
c
)
==
tolower
(
c1
)
||
(
c
==
pInfo
->
matchOne
&&
c1
!=
0
))
{
if
(
c
==
c1
||
tolower
(
c
)
==
tolower
(
c1
)
||
(
c
==
pInfo
->
matchOne
&&
c1
!=
0
))
{
...
@@ -292,7 +301,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c
...
@@ -292,7 +301,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c
if
(
c
==
matchAll
)
{
/* Match "%" */
if
(
c
==
matchAll
)
{
/* Match "%" */
while
((
c
=
patterStr
[
i
++
])
==
matchAll
||
c
==
matchOne
)
{
while
((
c
=
patterStr
[
i
++
])
==
matchAll
||
c
==
matchOne
)
{
if
(
c
==
matchOne
&&
(
j
>
size
||
str
[
j
++
]
==
0
))
{
if
(
c
==
matchOne
&&
(
j
>
=
size
||
str
[
j
++
]
==
0
))
{
return
TSDB_PATTERN_NOWILDCARDMATCH
;
return
TSDB_PATTERN_NOWILDCARDMATCH
;
}
}
}
}
...
...
tests/pytest/functions/queryTestCases.py
浏览文件 @
b0a25e92
...
@@ -769,7 +769,7 @@ class TDTestCase:
...
@@ -769,7 +769,7 @@ class TDTestCase:
tdSql
.
query
(
f
"select distinct c1,c2 from (select * from t1 where c1 <
{
tbnum
}
) "
)
tdSql
.
query
(
f
"select distinct c1,c2 from (select * from t1 where c1 <
{
tbnum
}
) "
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
f
"select distinct c1,c2 from (select * from stb1 where t2 !=0 and t2 != 1) "
)
tdSql
.
query
(
f
"select distinct c1,c2 from (select * from stb1 where t2 !=0 and t2 != 1) "
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkRows
(
0
)
tdSql
.
error
(
"select distinct c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) "
)
tdSql
.
error
(
"select distinct c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) "
)
tdSql
.
error
(
"select c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) "
)
tdSql
.
error
(
"select c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) "
)
tdSql
.
query
(
"select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 ) where c1 < 4"
)
tdSql
.
query
(
"select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 ) where c1 < 4"
)
...
...
tests/pytest/query/filterOtherTypes.py
浏览文件 @
b0a25e92
...
@@ -80,10 +80,12 @@ class TDTestCase:
...
@@ -80,10 +80,12 @@ class TDTestCase:
tdSql
.
error
(
"select * from st where tbcol1 like '____'"
)
tdSql
.
error
(
"select * from st where tbcol1 like '____'"
)
# > for nchar type on column
# > for nchar type on column
tdSql
.
error
(
"select * from st where tbcol2 > 'taosdata'"
)
tdSql
.
query
(
"select * from st where tbcol2 > 'taosdata'"
)
tdSql
.
checkRows
(
10
)
# >= for nchar type on column
# >= for nchar type on column
tdSql
.
error
(
"select * from st where tbcol2 >= 'taosdata'"
)
tdSql
.
query
(
"select * from st where tbcol2 >= 'taosdata'"
)
tdSql
.
checkRows
(
10
)
# = for nchar type on column
# = for nchar type on column
tdSql
.
query
(
"select * from st where tbcol2 = 'taosdata1'"
)
tdSql
.
query
(
"select * from st where tbcol2 = 'taosdata1'"
)
...
@@ -98,10 +100,12 @@ class TDTestCase:
...
@@ -98,10 +100,12 @@ class TDTestCase:
tdSql
.
checkRows
(
9
)
tdSql
.
checkRows
(
9
)
# > for nchar type on column
# > for nchar type on column
tdSql
.
error
(
"select * from st where tbcol2 < 'taodata'"
)
tdSql
.
query
(
"select * from st where tbcol2 < 'taodata'"
)
tdSql
.
checkRows
(
0
)
# >= for nchar type on column
# >= for nchar type on column
tdSql
.
error
(
"select * from st where tbcol2 <= 'taodata'"
)
tdSql
.
query
(
"select * from st where tbcol2 <= 'taodata'"
)
tdSql
.
checkRows
(
0
)
# % for nchar type on column case 1
# % for nchar type on column case 1
tdSql
.
query
(
"select * from st where tbcol2 like '%'"
)
tdSql
.
query
(
"select * from st where tbcol2 like '%'"
)
...
@@ -140,10 +144,12 @@ class TDTestCase:
...
@@ -140,10 +144,12 @@ class TDTestCase:
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
# > for binary type on column
# > for binary type on column
tdSql
.
error
(
"select * from st where tbcol3 > '涛思数据'"
)
tdSql
.
query
(
"select * from st where tbcol3 > '涛思数据'"
)
tdSql
.
checkRows
(
10
)
# >= for binary type on column
# >= for binary type on column
tdSql
.
error
(
"select * from st where tbcol3 >= '涛思数据'"
)
tdSql
.
query
(
"select * from st where tbcol3 >= '涛思数据'"
)
tdSql
.
checkRows
(
10
)
# = for binary type on column
# = for binary type on column
tdSql
.
query
(
"select * from st where tbcol3 = '涛思数据1'"
)
tdSql
.
query
(
"select * from st where tbcol3 = '涛思数据1'"
)
...
@@ -158,10 +164,12 @@ class TDTestCase:
...
@@ -158,10 +164,12 @@ class TDTestCase:
tdSql
.
checkRows
(
9
)
tdSql
.
checkRows
(
9
)
# > for binary type on column
# > for binary type on column
tdSql
.
error
(
"select * from st where tbcol3 < '涛思数据'"
)
tdSql
.
query
(
"select * from st where tbcol3 < '涛思数据'"
)
tdSql
.
checkRows
(
0
)
# >= for binary type on column
# >= for binary type on column
tdSql
.
error
(
"select * from st where tbcol3 <= '涛思数据'"
)
tdSql
.
query
(
"select * from st where tbcol3 <= '涛思数据'"
)
tdSql
.
checkRows
(
0
)
# % for binary type on column case 1
# % for binary type on column case 1
tdSql
.
query
(
"select * from st where tbcol3 like '%'"
)
tdSql
.
query
(
"select * from st where tbcol3 like '%'"
)
...
...
tests/pytest/query/isNullTest.py
浏览文件 @
b0a25e92
...
@@ -66,7 +66,7 @@ class TDTestCase:
...
@@ -66,7 +66,7 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
12
)
tdSql
.
checkData
(
0
,
0
,
12
)
tdSql
.
query
(
"select count(*) from st where t2 <> '' "
)
tdSql
.
query
(
"select count(*) from st where t2 <> '' "
)
tdSql
.
checkData
(
0
,
0
,
24
)
tdSql
.
checkData
(
0
,
0
,
12
)
tdSql
.
query
(
"select count(*) from st where t3 is null"
)
tdSql
.
query
(
"select count(*) from st where t3 is null"
)
tdSql
.
checkData
(
0
,
0
,
12
)
tdSql
.
checkData
(
0
,
0
,
12
)
...
@@ -81,7 +81,7 @@ class TDTestCase:
...
@@ -81,7 +81,7 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
12
)
tdSql
.
checkData
(
0
,
0
,
12
)
tdSql
.
query
(
"select count(*) from st where t3 <> '' "
)
tdSql
.
query
(
"select count(*) from st where t3 <> '' "
)
tdSql
.
checkData
(
0
,
0
,
24
)
tdSql
.
checkData
(
0
,
0
,
12
)
tdSql
.
query
(
"select count(*) from st where c1 is not null"
)
tdSql
.
query
(
"select count(*) from st where c1 is not null"
)
tdSql
.
checkData
(
0
,
0
,
30
)
tdSql
.
checkData
(
0
,
0
,
30
)
...
...
tests/script/general/parser/between_and.sim
浏览文件 @
b0a25e92
...
@@ -159,7 +159,7 @@ if $data11 != 3 then
...
@@ -159,7 +159,7 @@ if $data11 != 3 then
endi
endi
sql_error select * from st2 where f7 between 2.0 and 3.0;
sql_error select * from st2 where f7 between 2.0 and 3.0;
sql
_error
select * from st2 where f8 between 2.0 and 3.0;
sql select * from st2 where f8 between 2.0 and 3.0;
sql
_error
select * from st2 where f9 between 2.0 and 3.0;
sql select * from st2 where f9 between 2.0 and 3.0;
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/general/parser/condition.sim
浏览文件 @
b0a25e92
...
@@ -2,7 +2,7 @@ system sh/stop_dnodes.sh
...
@@ -2,7 +2,7 @@ system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c maxtablespervnode -v
4
system sh/cfg.sh -n dnode1 -c maxtablespervnode -v
6
system sh/cfg.sh -n dnode1 -c cache -v 1
system sh/cfg.sh -n dnode1 -c cache -v 1
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode1 -s start
...
@@ -135,11 +135,63 @@ while $i < $blockNum
...
@@ -135,11 +135,63 @@ while $i < $blockNum
$ts0 = $ts0 + 259200000
$ts0 = $ts0 + 259200000
endw
endw
sql create table stb5 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 timestamp, t2 int, t3 float, t4 bigint, t5 smallint, t6 tinyint, t7 double, t8 bool, t9 binary(100), t10 nchar(10))
sql create table tb5_1 using stb5 tags('2021-05-05 18:19:01',1,1.0,1,1,1,1.0,true ,'111111111','1')
sql create table tb5_2 using stb5 tags('2021-05-05 18:19:02',2,2.0,2,2,2,2.0,true ,'222222222','2')
sql create table tb5_3 using stb5 tags('2021-05-05 18:19:03',3,3.0,3,3,3,3.0,false,'333333333','3')
sql create table tb5_4 using stb5 tags('2021-05-05 18:19:04',4,4.0,4,4,4,4.0,false,'444444444','4')
sql create table tb5_5 using stb5 tags('2021-05-05 18:19:05',5,5.0,5,5,5,5.0,true,'555555555','5')
sql create table tb5_6 using stb5 tags('2021-05-05 18:19:06',6,6.0,6,6,6,6.0,true,'666666666','6')
sql create table tb5_7 using stb5 tags(NULL,7,NULL,7,NULL,7,NULL,false,NULL,'7')
sql create table tb5_8 using stb5 tags('2021-05-05 18:19:08',NULL,8.0,NULL,8,NULL,8.0,NULL,'888888888',NULL)
sql insert into tb5_1 values ('2021-05-05 18:19:00',1,1.0,1,1,1,1.0,true ,'1','1')
sql insert into tb5_1 values ('2021-05-05 18:19:01',2,2.0,2,2,2,2.0,true ,'2','2')
sql insert into tb5_1 values ('2021-05-05 18:19:02',3,3.0,3,3,3,3.0,false,'3','3')
sql insert into tb5_1 values ('2021-05-05 18:19:03',4,4.0,4,4,4,4.0,false,'4','4')
sql insert into tb5_1 values ('2021-05-05 18:19:04',11,11.0,11,11,11,11.0,true ,'11','11')
sql insert into tb5_1 values ('2021-05-05 18:19:05',12,12.0,12,12,12,12.0,true ,'12','12')
sql insert into tb5_1 values ('2021-05-05 18:19:06',13,13.0,13,13,13,13.0,false,'13','13')
sql insert into tb5_1 values ('2021-05-05 18:19:07',14,14.0,14,14,14,14.0,false,'14','14')
sql insert into tb5_2 values ('2021-05-05 18:19:08',21,21.0,21,21,21,21.0,true ,'21','21')
sql insert into tb5_2 values ('2021-05-05 18:19:09',22,22.0,22,22,22,22.0,true ,'22','22')
sql insert into tb5_2 values ('2021-05-05 18:19:10',23,23.0,23,23,23,23.0,false,'23','23')
sql insert into tb5_2 values ('2021-05-05 18:19:11',24,24.0,24,24,24,24.0,false,'24','24')
sql insert into tb5_3 values ('2021-05-05 18:19:12',31,31.0,31,31,31,31.0,true ,'31','31')
sql insert into tb5_3 values ('2021-05-05 18:19:13',32,32.0,32,32,32,32.0,true ,'32','32')
sql insert into tb5_3 values ('2021-05-05 18:19:14',33,33.0,33,33,33,33.0,false,'33','33')
sql insert into tb5_3 values ('2021-05-05 18:19:15',34,34.0,34,34,34,34.0,false,'34','34')
sql insert into tb5_4 values ('2021-05-05 18:19:16',41,41.0,41,41,41,41.0,true ,'41','41')
sql insert into tb5_4 values ('2021-05-05 18:19:17',42,42.0,42,42,42,42.0,true ,'42','42')
sql insert into tb5_4 values ('2021-05-05 18:19:18',43,43.0,43,43,43,43.0,false,'43','43')
sql insert into tb5_4 values ('2021-05-05 18:19:19',44,44.0,44,44,44,44.0,false,'44','44')
sql insert into tb5_5 values ('2021-05-05 18:19:20',51,51.0,51,51,51,51.0,true ,'51','51')
sql insert into tb5_5 values ('2021-05-05 18:19:21',52,52.0,52,52,52,52.0,true ,'52','52')
sql insert into tb5_5 values ('2021-05-05 18:19:22',53,53.0,53,53,53,53.0,false,'53','53')
sql insert into tb5_5 values ('2021-05-05 18:19:23',54,54.0,54,54,54,54.0,false,'54','54')
sql insert into tb5_6 values ('2021-05-05 18:19:24',61,61.0,61,61,61,61.0,true ,'61','61')
sql insert into tb5_6 values ('2021-05-05 18:19:25',62,62.0,62,62,62,62.0,true ,'62','62')
sql insert into tb5_6 values ('2021-05-05 18:19:26',63,63.0,63,63,63,63.0,false,'63','63')
sql insert into tb5_6 values ('2021-05-05 18:19:27',64,64.0,64,64,64,64.0,false,'64','64')
sql insert into tb5_6 values ('2021-05-05 18:19:28',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
sql insert into tb5_7 values ('2021-05-05 18:19:29',71,71.0,71,71,71,71.0,true ,'71','71')
sql insert into tb5_7 values ('2021-05-05 18:19:30',72,72.0,72,72,72,72.0,true ,'72','72')
sql insert into tb5_7 values ('2021-05-05 18:19:31',73,73.0,73,73,73,73.0,false,'73','73')
sql insert into tb5_7 values ('2021-05-05 18:19:32',74,74.0,74,74,74,74.0,false,'74','74')
sql insert into tb5_7 values ('2021-05-05 18:19:33',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
sql insert into tb5_8 values ('2021-05-05 18:19:34',81,81.0,81,81,81,81.0,true ,'81','81')
sql insert into tb5_8 values ('2021-05-05 18:19:35',82,82.0,82,82,82,82.0,true ,'82','82')
sql insert into tb5_8 values ('2021-05-05 18:19:36',83,83.0,83,83,83,83.0,false,'83','83')
sql insert into tb5_8 values ('2021-05-05 18:19:37',84,84.0,84,84,84,84.0,false,'84','84')
sql insert into tb5_8 values ('2021-05-05 18:19:38',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
sleep 100
sleep 100
sql connect
sql connect
run general/parser/condition_query.sim
run general/parser/condition_query.sim
run general/parser/condition_query2.sim
print ================== restart server to commit data into disk
print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
...
@@ -150,4 +202,90 @@ sql connect
...
@@ -150,4 +202,90 @@ sql connect
sleep 100
sleep 100
run general/parser/condition_query.sim
run general/parser/condition_query.sim
run general/parser/condition_query2.sim
sql drop database if exists cdb
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 100
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 1000
system sh/cfg.sh -n dnode1 -c minTablesPerVnode -v 1000
system sh/exec.sh -n dnode1 -s start
sql create database if not exists cdb
sql use cdb
sql create table stba (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int)
sql create table stbb (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 bool)
sql create table stbc (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 float)
sql create table stbd (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 binary(10))
sql create table stbe (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 nchar(10))
sql create table tba_0 using stba tags(0)
sql create table tba_1 using stba tags(1)
sql create table tba_2 using stba tags(2)
sql create table tba_3 using stba tags(3)
sql create table tba_4 using stba tags(4)
sql create table tba_5 using stba tags(5)
sql create table tba_6 using stba tags(6)
sql create table tba_7 using stba tags(7)
sql create table tba_8 using stba tags(8)
sql create table tba_9 using stba tags(9)
sql create table tbb_0 using stbb tags(true)
sql create table tbb_1 using stbb tags(false)
sql create table tbb_2 using stbb tags(true)
sql create table tbb_3 using stbb tags(false)
sql create table tbb_4 using stbb tags(true)
sql create table tbb_5 using stbb tags(false)
sql create table tbb_6 using stbb tags(true)
sql create table tbb_7 using stbb tags(false)
sql create table tbb_8 using stbb tags(true)
sql create table tbb_9 using stbb tags(false)
sql create table tbc_0 using stbc tags(0)
sql create table tbc_1 using stbc tags(1)
sql create table tbc_2 using stbc tags(2)
sql create table tbc_3 using stbc tags(3)
sql create table tbc_4 using stbc tags(4)
sql create table tbc_5 using stbc tags(5)
sql create table tbc_6 using stbc tags(6)
sql create table tbc_7 using stbc tags(7)
sql create table tbc_8 using stbc tags(8)
sql create table tbc_9 using stbc tags(9)
sql create table tbd_0 using stbd tags('0000')
sql create table tbd_1 using stbd tags('1111')
sql create table tbd_2 using stbd tags('2222')
sql create table tbd_3 using stbd tags('3333')
sql create table tbd_4 using stbd tags('4444')
sql create table tbd_5 using stbd tags('5555')
sql create table tbd_6 using stbd tags('6666')
sql create table tbd_7 using stbd tags('7777')
sql create table tbd_8 using stbd tags('8888')
sql create table tbd_9 using stbd tags('9999')
sql create table tbe_0 using stbe tags('0000')
sql create table tbe_1 using stbe tags('1111')
sql create table tbe_2 using stbe tags('2222')
sql create table tbe_3 using stbe tags('3333')
sql create table tbe_4 using stbe tags('4444')
sql create table tbe_5 using stbe tags('5555')
sql create table tbe_6 using stbe tags('6666')
sql create table tbe_7 using stbe tags('7777')
sql create table tbe_8 using stbe tags('8888')
sql create table tbe_9 using stbe tags('9999')
run general/parser/condition_query3.sim
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 100
system sh/exec.sh -n dnode1 -s start
run general/parser/condition_query3.sim
tests/script/general/parser/condition_query.sim
浏览文件 @
b0a25e92
此差异已折叠。
点击以展开。
tests/script/general/parser/condition_query2.sim
0 → 100644
浏览文件 @
b0a25e92
此差异已折叠。
点击以展开。
tests/script/general/parser/condition_query3.sim
0 → 100644
浏览文件 @
b0a25e92
sql use cdb;
print "index tag test"
sql select tbname,t1 from stba;
if $rows != 10 then
return -1
endi
sql select tbname,t1 from stba where t1 > 2;
if $rows != 7 then
return -1
endi
sql select tbname,t1 from stba where t1 >= 4;
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stba where t1 >= 3 and t1 <= 6;
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stba where t1 = 3;
if $rows != 1 then
return -1
endi
sql select tbname,t1 from stba where t1 <> 6;
if $rows != 9 then
return -1
endi
sql select tbname,t1 from stba where t1 < 6;
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stba where t1 < 6 and t1 >= 2;
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stba where t1 is null;
if $rows != 0 then
return -1
endi
sql select tbname,t1 from stba where t1 is not null;
if $rows != 10 then
return -1
endi
sql_error select tbname,t1 from stbb where t1 > true;
sql select tbname,t1 from stbb where t1 = true;
if $rows != 5 then
return -1
endi
sql select tbname,t1 from stbb where t1 <> true;
if $rows != 5 then
return -1
endi
sql select tbname,t1 from stbb where t1 is null;
if $rows != 0 then
return -1
endi
sql select tbname,t1 from stbb where t1 is not null;
if $rows != 10 then
return -1
endi
sql select tbname,t1 from stbc;
if $rows != 10 then
return -1
endi
sql select tbname,t1 from stbc where t1 > 2;
if $rows != 7 then
return -1
endi
sql select tbname,t1 from stbc where t1 >= 4;
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbc where t1 >= 3 and t1 <= 6;
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbc where t1 = 3;
if $rows != 1 then
return -1
endi
sql select tbname,t1 from stbc where t1 <> 6;
if $rows != 9 then
return -1
endi
sql select tbname,t1 from stbc where t1 < 6;
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbc where t1 < 6 and t1 >= 2;
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbc where t1 is null;
if $rows != 0 then
return -1
endi
sql select tbname,t1 from stbc where t1 is not null;
if $rows != 10 then
return -1
endi
sql select tbname,t1 from stbd where t1 > '2222';
if $rows != 7 then
return -1
endi
sql select tbname,t1 from stbd where t1 >= '4444';
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbd where t1 >= '3333' and t1 <= '6666';
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbd where t1 = '3333';
if $rows != 1 then
return -1
endi
sql select tbname,t1 from stbd where t1 <> '6666';
if $rows != 9 then
return -1
endi
sql select tbname,t1 from stbd where t1 < '6666';
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbd where t1 < '6666' and t1 >= '2222';
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbd where t1 is null;
if $rows != 0 then
return -1
endi
sql select tbname,t1 from stbd where t1 is not null;
if $rows != 10 then
return -1
endi
sql select tbname,t1 from stbe where t1 > '2222';
if $rows != 7 then
return -1
endi
sql select tbname,t1 from stbe where t1 >= '4444';
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbe where t1 >= '3333' and t1 <= '6666';
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbe where t1 = '3333';
if $rows != 1 then
return -1
endi
sql select tbname,t1 from stbe where t1 <> '6666';
if $rows != 9 then
return -1
endi
sql select tbname,t1 from stbe where t1 < '6666';
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbe where t1 < '6666' and t1 >= '2222';
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbe where t1 is null;
if $rows != 0 then
return -1
endi
sql select tbname,t1 from stbe where t1 is not null;
if $rows != 10 then
return -1
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/general/parser/tbnameIn_query.sim
浏览文件 @
b0a25e92
...
@@ -125,11 +125,10 @@ if $data21 != 2 then
...
@@ -125,11 +125,10 @@ if $data21 != 2 then
return -1
return -1
endi
endi
# multiple tbname in is not allowed NOW
sql select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and tbname in ('ti_tb5', 'ti_tb1000') group by t1 order by t1 asc
sql_error select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and tbname in ('ti_tb5', 'ti_tb1000') group by t1 order by t1 asc
if $rows != 0 then
#if $rows != 4 then
return -1
# return -1
endi
#endi
#if $data00 != $rowNum then
#if $data00 != $rowNum then
# return -1
# return -1
#endi
#endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录