Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
怡红公子⭕
TDengine
提交
fa0f056f
T
TDengine
项目概览
怡红公子⭕
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fa0f056f
编写于
11月 12, 2019
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor some codes. fix bugs in selectivity+tags/ts query.
上级
b12e12f8
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
587 addition
and
276 deletion
+587
-276
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+496
-206
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+48
-29
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+35
-34
src/system/detail/src/vnodeQueryImpl.c
src/system/detail/src/vnodeQueryImpl.c
+7
-6
src/system/detail/src/vnodeUtil.c
src/system/detail/src/vnodeUtil.c
+1
-1
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
fa0f056f
此差异已折叠。
点击以展开。
src/client/src/tscSQLParser.c
浏览文件 @
fa0f056f
...
...
@@ -81,7 +81,7 @@ static bool validateIpAddress(char* ip);
static
bool
hasUnsupportFunctionsForMetricQuery
(
SSqlCmd
*
pCmd
);
static
bool
functionCompatibleCheck
(
SSqlCmd
*
pCmd
);
static
void
setColumnOffsetValueInResultset
(
SSqlCmd
*
pCmd
);
static
void
setColumnOffsetValueInResultset
(
SSqlCmd
*
pCmd
);
static
int32_t
parseGroupbyClause
(
SSqlCmd
*
pCmd
,
tVariantList
*
pList
);
static
int32_t
parseIntervalClause
(
SSqlCmd
*
pCmd
,
SQuerySQL
*
pQuerySql
);
...
...
@@ -94,7 +94,7 @@ static int32_t parseFillClause(SSqlCmd* pCmd, SQuerySQL* pQuerySQL);
static
int32_t
parseOrderbyClause
(
SSqlCmd
*
pCmd
,
SQuerySQL
*
pQuerySql
,
SSchema
*
pSchema
,
int32_t
numOfCols
);
static
int32_t
tsRewriteFieldNameIfNecessary
(
SSqlCmd
*
pCmd
);
static
bool
validateOneTags
(
SSqlCmd
*
pCmd
,
TAOS_FIELD
*
pTagField
);
static
bool
validateOneTags
(
SSqlCmd
*
pCmd
,
TAOS_FIELD
*
pTagField
);
static
int32_t
setAlterTableInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
static
int32_t
validateSqlFunctionInStreamSql
(
SSqlCmd
*
pCmd
);
static
int32_t
buildArithmeticExprString
(
tSQLExpr
*
pExpr
,
char
**
exprString
);
...
...
@@ -105,8 +105,8 @@ static int32_t validateLocalConfig(tDCLSQL* pOptions);
static
int32_t
validateColumnName
(
char
*
name
);
static
int32_t
setKillInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
static
bool
hasTimestampForPointInterpQuery
(
SSqlCmd
*
pCmd
);
static
void
updateTagColumnIndex
(
SSqlCmd
*
pCmd
,
int32_t
tableIndex
);
static
bool
hasTimestampForPointInterpQuery
(
SSqlCmd
*
pCmd
);
static
void
updateTagColumnIndex
(
SSqlCmd
*
pCmd
,
int32_t
tableIndex
);
static
int32_t
parseLimitClause
(
SSqlObj
*
pSql
,
SQuerySQL
*
pQuerySql
);
static
int32_t
parseCreateDBOptions
(
SCreateDBInfo
*
pCreateDbSql
,
SSqlCmd
*
pCmd
);
...
...
@@ -115,13 +115,12 @@ static int32_t getTableIndexByName(SSQLToken* pToken, SSqlCmd* pCmd, SColumnInde
static
int32_t
optrToString
(
tSQLExpr
*
pExpr
,
char
**
exprString
);
static
SColumnList
getColumnList
(
int32_t
num
,
int16_t
tableIndex
,
int32_t
columnIndex
);
static
int32_t
getMeterIndex
(
SSQLToken
*
pTableToken
,
SSqlCmd
*
pCmd
,
SColumnIndex
*
pIndex
);
static
int32_t
doFunctionsCompatibleCheck
(
SSqlObj
*
pSql
);
static
int32_t
getMeterIndex
(
SSQLToken
*
pTableToken
,
SSqlCmd
*
pCmd
,
SColumnIndex
*
pIndex
);
static
int32_t
doFunctionsCompatibleCheck
(
SSqlObj
*
pSql
);
static
int32_t
tscQueryOnlyMetricTags
(
SSqlCmd
*
pCmd
,
bool
*
queryOnMetricTags
)
{
assert
(
QUERY_IS_STABLE_QUERY
(
pCmd
->
type
));
// here colIdx == -1 means the special column tbname that is the name of each table
*
queryOnMetricTags
=
true
;
for
(
int32_t
i
=
0
;
i
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pCmd
,
i
);
...
...
@@ -1151,7 +1150,7 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql) {
}
// check the invalid sql expresssion: select count(tbname)/count(tag1)/count(tag2) from super_table interval(1d);
for
(
int32_t
i
=
0
;
i
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pCmd
,
i
);
if
(
pExpr
->
functionId
==
TSDB_FUNC_COUNT
&&
TSDB_COL_IS_TAG
(
pExpr
->
colInfo
.
flag
))
{
setErrMsg
(
pCmd
,
msg1
);
...
...
@@ -2791,10 +2790,14 @@ static bool functionCompatibleCheck(SSqlCmd* pCmd) {
// diff function cannot be executed with other function
// arithmetic function can be executed with other arithmetic functions
for
(
int32_t
i
=
startIdx
+
1
;
i
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
int16_t
functionId
=
tscSqlExprGet
(
pCmd
,
i
)
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TAGPRJ
||
functionId
==
TSDB_FUNC_TAG
||
functionId
==
TSDB_FUNC_TS
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pCmd
,
i
);
int16_t
functionId
=
pExpr
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TAGPRJ
||
functionId
==
TSDB_FUNC_TAG
||
functionId
==
TSDB_FUNC_TS
)
{
continue
;
}
if
(
functionId
==
TSDB_FUNC_PRJ
&&
pExpr
->
colInfo
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
continue
;
}
...
...
@@ -2809,9 +2812,7 @@ static bool functionCompatibleCheck(SSqlCmd* pCmd) {
for
(
int32_t
i
=
0
;
i
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
int16_t
functionId
=
tscSqlExprGet
(
pCmd
,
i
)
->
functionId
;
if
(
functionId
==
TSDB_FUNC_PRJ
||
functionId
==
TSDB_FUNC_TAGPRJ
||
functionId
==
TSDB_FUNC_TS
||
if
(
functionId
==
TSDB_FUNC_PRJ
||
functionId
==
TSDB_FUNC_TAGPRJ
||
functionId
==
TSDB_FUNC_TS
||
functionId
==
TSDB_FUNC_ARITHM
)
{
continue
;
}
...
...
@@ -4986,19 +4987,37 @@ int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd) {
int32_t
validateFunctionsInIntervalOrGroupbyQuery
(
SSqlCmd
*
pCmd
)
{
bool
isProjectionFunction
=
false
;
const
char
*
msg
=
"column projection is not compatible with interval"
;
const
char
*
msg1
=
"column projection is not compatible with interval"
;
const
char
*
msg2
=
"interval not allowed for tag queries"
;
// multi-output set/ todo refactor
for
(
int32_t
k
=
0
;
k
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
k
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pCmd
,
k
);
// projection query on primary timestamp, the selectivity function needs to be present.
if
(
pExpr
->
functionId
==
TSDB_FUNC_PRJ
&&
pExpr
->
colInfo
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
bool
hasSelectivity
=
false
;
for
(
int32_t
j
=
0
;
j
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
j
)
{
SSqlExpr
*
pEx
=
tscSqlExprGet
(
pCmd
,
j
);
if
((
aAggs
[
pEx
->
functionId
].
nStatus
&
TSDB_FUNCSTATE_SELECTIVITY
)
==
TSDB_FUNCSTATE_SELECTIVITY
)
{
hasSelectivity
=
true
;
break
;
}
}
if
(
hasSelectivity
)
{
continue
;
}
}
if
(
pExpr
->
functionId
==
TSDB_FUNC_PRJ
||
pExpr
->
functionId
==
TSDB_FUNC_DIFF
||
pExpr
->
functionId
==
TSDB_FUNC_ARITHM
)
{
pExpr
->
functionId
==
TSDB_FUNC_ARITHM
)
{
isProjectionFunction
=
true
;
}
}
if
(
isProjectionFunction
)
{
setErrMsg
(
pCmd
,
msg
);
setErrMsg
(
pCmd
,
msg
1
);
}
return
isProjectionFunction
==
true
?
TSDB_CODE_INVALID_SQL
:
TSDB_CODE_SUCCESS
;
...
...
@@ -5164,8 +5183,7 @@ int32_t parseLimitClause(SSqlObj* pSql, SQuerySQL* pQuerySql) {
if
(
UTIL_METER_IS_METRIC
(
pMeterMetaInfo
))
{
bool
queryOnTags
=
false
;
int32_t
ret
=
tscQueryOnlyMetricTags
(
pCmd
,
&
queryOnTags
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscQueryOnlyMetricTags
(
pCmd
,
&
queryOnTags
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
}
...
...
@@ -5382,8 +5400,8 @@ static void doUpdateSqlFunctionForTagPrj(SSqlCmd* pCmd) {
}
}
int16_t
resType
=
0
;
int16_t
resBytes
=
0
;
int16_t
resType
=
0
;
int16_t
resBytes
=
0
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
...
...
@@ -5464,7 +5482,7 @@ static int32_t checkUpdateTagPrjFunctions(SSqlCmd* pCmd) {
const
char
*
msg2
=
"functions not allowed"
;
bool
tagColExists
=
false
;
int16_t
numOfTimestamp
=
0
;
// primary timestamp column
int16_t
numOfTimestamp
=
0
;
// primary timestamp column
int16_t
numOfSelectivity
=
0
;
int16_t
numOfAggregation
=
0
;
...
...
@@ -5493,7 +5511,7 @@ static int32_t checkUpdateTagPrjFunctions(SSqlCmd* pCmd) {
// When the tag projection function on tag column that is not in the group by clause, aggregation function and
// selectivity function exist in select clause is not allowed.
if
(
numOfAggregation
>
0
)
{
if
(
numOfAggregation
>
0
)
{
setErrMsg
(
pCmd
,
msg1
);
return
TSDB_CODE_INVALID_SQL
;
}
...
...
@@ -5598,14 +5616,14 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) {
const
char
*
msg2
=
"interval not allowed in group by normal column"
;
const
char
*
msg3
=
"group by not allowed on projection query"
;
const
char
*
msg4
=
"tags retrieve not compatible with group by"
;
const
char
*
msg5
=
"retrieve tags not compatible with group by "
;
const
char
*
msg5
=
"retrieve tags not compatible with group by
or interval query
"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
);
// only retrieve tags, group by is not supportted
if
(
pCmd
->
command
==
TSDB_SQL_RETRIEVE_TAGS
)
{
if
(
pCmd
->
groupbyExpr
.
numOfGroupCols
>
0
)
{
if
(
pCmd
->
groupbyExpr
.
numOfGroupCols
>
0
||
pCmd
->
nAggTimeInterval
>
0
)
{
setErrMsg
(
pCmd
,
msg5
);
return
TSDB_CODE_INVALID_SQL
;
}
else
{
...
...
@@ -5634,7 +5652,7 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) {
* group by normal columns.
* Check if the column projection is identical to the group by column or not
*/
if
(
functId
==
TSDB_FUNC_PRJ
)
{
if
(
functId
==
TSDB_FUNC_PRJ
&&
pExpr
->
colInfo
.
colId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
bool
qualified
=
false
;
for
(
int32_t
j
=
0
;
j
<
pCmd
->
groupbyExpr
.
numOfGroupCols
;
++
j
)
{
SColIndexEx
*
pColIndex
=
&
pCmd
->
groupbyExpr
.
columnInfo
[
j
];
...
...
@@ -5650,7 +5668,8 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) {
}
if
(
IS_MULTIOUTPUT
(
aAggs
[
functId
].
nStatus
)
&&
functId
!=
TSDB_FUNC_TOP
&&
functId
!=
TSDB_FUNC_BOTTOM
&&
functId
!=
TSDB_FUNC_TAGPRJ
)
{
functId
!=
TSDB_FUNC_TAGPRJ
&&
(
functId
==
TSDB_FUNC_PRJ
&&
pExpr
->
colInfo
.
colId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
))
{
setErrMsg
(
pCmd
,
msg1
);
return
TSDB_CODE_INVALID_SQL
;
}
...
...
src/client/src/tscUtil.c
浏览文件 @
fa0f056f
...
...
@@ -142,7 +142,6 @@ bool tscIsSelectivityWithTagQuery(SSqlCmd* pCmd) {
return
false
;
}
void
tscGetDBInfoFromMeterId
(
char
*
meterId
,
char
*
db
)
{
char
*
st
=
strstr
(
meterId
,
TS_PATH_DELIMITER
);
if
(
st
!=
NULL
)
{
...
...
@@ -265,7 +264,7 @@ bool tscIsPointInterpQuery(SSqlCmd* pCmd) {
}
bool
tscIsTWAQuery
(
SSqlCmd
*
pCmd
)
{
for
(
int32_t
i
=
0
;
i
<
pCmd
->
exprsInfo
.
numOfExprs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCmd
->
exprsInfo
.
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pCmd
,
i
);
if
(
pExpr
==
NULL
)
{
continue
;
...
...
@@ -450,7 +449,8 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock) {
tfree
(
pDataBlock
);
}
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
short
bytes
,
uint32_t
offset
)
{
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
short
bytes
,
uint32_t
offset
)
{
uint32_t
needed
=
pDataBlock
->
numOfParams
+
1
;
if
(
needed
>
pDataBlock
->
numOfAllocedParams
)
{
needed
*=
2
;
...
...
@@ -490,13 +490,13 @@ SDataBlockList* tscCreateBlockArrayList() {
return
pDataBlockArrayList
;
}
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
)
{
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
)
{
if
(
pList
->
nSize
>=
pList
->
nAlloc
)
{
pList
->
nAlloc
=
pList
->
nAlloc
<<
1
;
pList
->
pData
=
realloc
(
pList
->
pData
,
sizeof
(
void
*
)
*
(
size_t
)
pList
->
nAlloc
);
pList
->
pData
=
realloc
(
pList
->
pData
,
sizeof
(
void
*
)
*
(
size_t
)
pList
->
nAlloc
);
// reset allocated memory
memset
(
pList
->
pData
+
pList
->
nSize
,
0
,
sizeof
(
void
*
)
*
(
pList
->
nAlloc
-
pList
->
nSize
));
memset
(
pList
->
pData
+
pList
->
nSize
,
0
,
sizeof
(
void
*
)
*
(
pList
->
nAlloc
-
pList
->
nSize
));
}
pList
->
pData
[
pList
->
nSize
++
]
=
pBlocks
;
...
...
@@ -553,7 +553,7 @@ void tscFreeUnusedDataBlocks(SDataBlockList* pList) {
}
STableDataBlocks
*
tscCreateDataBlockEx
(
size_t
size
,
int32_t
rowSize
,
int32_t
startOffset
,
char
*
name
)
{
STableDataBlocks
*
dataBuf
=
tscCreateDataBlock
(
size
);
STableDataBlocks
*
dataBuf
=
tscCreateDataBlock
(
size
);
dataBuf
->
rowSize
=
rowSize
;
dataBuf
->
size
=
startOffset
;
...
...
@@ -573,7 +573,7 @@ STableDataBlocks* tscGetDataBlockFromList(void* pHashList, SDataBlockList* pData
}
if
(
dataBuf
==
NULL
)
{
dataBuf
=
tscCreateDataBlockEx
((
size_t
)
size
,
rowSize
,
startOffset
,
tableId
);
dataBuf
=
tscCreateDataBlockEx
((
size_t
)
size
,
rowSize
,
startOffset
,
tableId
);
dataBuf
=
*
(
STableDataBlocks
**
)
taosAddIntHash
(
pHashList
,
id
,
(
char
*
)
&
dataBuf
);
tscAppendDataBlock
(
pDataBlockList
,
dataBuf
);
}
...
...
@@ -604,7 +604,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockLi
if
(
tmp
!=
NULL
)
{
dataBuf
->
pData
=
tmp
;
memset
(
dataBuf
->
pData
+
dataBuf
->
size
,
0
,
dataBuf
->
nAllocSize
-
dataBuf
->
size
);
}
else
{
// failed to allocate memory, free already allocated memory and return error code
}
else
{
// failed to allocate memory, free already allocated memory and return error code
tscError
(
"%p failed to allocate memory for merging submit block, size:%d"
,
pSql
,
dataBuf
->
nAllocSize
);
taosCleanUpIntHash
(
pVnodeDataBlockHashList
);
...
...
@@ -673,7 +673,7 @@ int tscAllocPayload(SSqlCmd* pCmd, int size) {
pCmd
->
allocSize
=
size
;
}
else
{
if
(
pCmd
->
allocSize
<
size
)
{
char
*
b
=
realloc
(
pCmd
->
payload
,
size
);
char
*
b
=
realloc
(
pCmd
->
payload
,
size
);
if
(
b
==
NULL
)
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
pCmd
->
payload
=
b
;
pCmd
->
allocSize
=
size
;
...
...
@@ -869,11 +869,11 @@ void tscClearFieldInfo(SFieldInfo* pFieldInfo) {
static
void
_exprCheckSpace
(
SSqlExprInfo
*
pExprInfo
,
int32_t
size
)
{
if
(
size
>
pExprInfo
->
numOfAlloc
)
{
int32_t
oldSize
=
pExprInfo
->
numOfAlloc
;
u
int32_t
oldSize
=
pExprInfo
->
numOfAlloc
;
int32_t
newSize
=
(
oldSize
<=
0
)
?
8
:
(
oldSize
<<
1
);
uint32_t
newSize
=
(
oldSize
<=
0
)
?
8
:
(
oldSize
<<
1U
);
while
(
newSize
<
size
)
{
newSize
=
(
newSize
<<
1
);
newSize
=
(
newSize
<<
1
U
);
}
if
(
newSize
>
TSDB_MAX_COLUMNS
)
{
...
...
@@ -1161,7 +1161,7 @@ void tscColumnBaseInfoDestroy(SColumnBaseInfo* pColumnBaseInfo) {
assert
(
pColumnBaseInfo
->
numOfCols
<=
TSDB_MAX_COLUMNS
);
for
(
int32_t
i
=
0
;
i
<
pColumnBaseInfo
->
numOfCols
;
++
i
)
{
SColumnBase
*
pColBase
=
&
(
pColumnBaseInfo
->
pColList
[
i
]);
SColumnBase
*
pColBase
=
&
(
pColumnBaseInfo
->
pColList
[
i
]);
if
(
pColBase
->
numOfFilters
>
0
)
{
for
(
int32_t
j
=
0
;
j
<
pColBase
->
numOfFilters
;
++
j
)
{
...
...
@@ -1179,8 +1179,9 @@ void tscColumnBaseInfoDestroy(SColumnBaseInfo* pColumnBaseInfo) {
tfree
(
pColumnBaseInfo
->
pColList
);
}
void
tscColumnBaseInfoReserve
(
SColumnBaseInfo
*
pColumnBaseInfo
,
int32_t
size
)
{
_cf_ensureSpace
(
pColumnBaseInfo
,
size
);
}
void
tscColumnBaseInfoReserve
(
SColumnBaseInfo
*
pColumnBaseInfo
,
int32_t
size
)
{
_cf_ensureSpace
(
pColumnBaseInfo
,
size
);
}
/*
* 1. normal name, not a keyword or number
...
...
@@ -1228,16 +1229,16 @@ int32_t tscValidateName(SSQLToken* pToken) {
int
len
=
tSQLGetToken
(
pToken
->
z
,
&
pToken
->
type
);
// single token, validate it
if
(
len
==
pToken
->
n
){
if
(
len
==
pToken
->
n
)
{
return
validateQuoteToken
(
pToken
);
}
else
{
sep
=
strnchr
(
pToken
->
z
,
TS_PATH_DELIMITER
[
0
],
pToken
->
n
,
true
);
if
(
sep
==
NULL
)
{
return
TSDB_CODE_INVALID_SQL
;
}
sep
=
strnchr
(
pToken
->
z
,
TS_PATH_DELIMITER
[
0
],
pToken
->
n
,
true
);
if
(
sep
==
NULL
)
{
return
TSDB_CODE_INVALID_SQL
;
}
return
tscValidateName
(
pToken
);
}
}
}
else
{
if
(
isNumber
(
pToken
))
{
return
TSDB_CODE_INVALID_SQL
;
...
...
@@ -1616,8 +1617,8 @@ int32_t SStringAlloc(SString* pStr, int32_t size) {
#ifdef WINDOWS
LPVOID
lpMsgBuf
;
FormatMessage
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
GetLastError
(),
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
// Default language
(
LPTSTR
)
&
lpMsgBuf
,
0
,
NULL
);
GetLastError
(),
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
// Default language
(
LPTSTR
)
&
lpMsgBuf
,
0
,
NULL
);
tscTrace
(
"failed to allocate memory, reason:%s"
,
lpMsgBuf
);
LocalFree
(
lpMsgBuf
);
#else
...
...
@@ -1652,12 +1653,11 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) {
char
*
tmp
=
realloc
(
pStr
->
z
,
newsize
);
if
(
tmp
==
NULL
)
{
#ifdef WINDOWS
LPVOID
lpMsgBuf
;
FormatMessage
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
GetLastError
(),
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
// Default language
(
LPTSTR
)
&
lpMsgBuf
,
0
,
NULL
);
GetLastError
(),
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
// Default language
(
LPTSTR
)
&
lpMsgBuf
,
0
,
NULL
);
tscTrace
(
"failed to allocate memory, reason:%s"
,
lpMsgBuf
);
LocalFree
(
lpMsgBuf
);
#else
...
...
@@ -1728,7 +1728,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int32_t vnodeIndex, int16_t tableIndex
if
(
pPrevSql
!=
NULL
)
{
pNew
->
cmd
.
type
=
pPrevSql
->
cmd
.
type
;
}
else
{
pNew
->
cmd
.
type
|=
TSDB_QUERY_TYPE_SUBQUERY
;
// it must be the subquery
pNew
->
cmd
.
type
|=
TSDB_QUERY_TYPE_SUBQUERY
;
// it must be the subquery
}
uint64_t
uid
=
pMeterMetaInfo
->
pMeterMeta
->
uid
;
...
...
@@ -1760,7 +1760,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int32_t vnodeIndex, int16_t tableIndex
char
key
[
TSDB_MAX_TAGS_LEN
+
1
]
=
{
0
};
tscGetMetricMetaCacheKey
(
pCmd
,
key
,
pMetermetaInfo
->
pMeterMeta
->
uid
);
char
*
name
=
pMeterMetaInfo
->
name
;
char
*
name
=
pMeterMetaInfo
->
name
;
SMeterMetaInfo
*
pFinalInfo
=
NULL
;
if
(
pPrevSql
==
NULL
)
{
...
...
@@ -1768,11 +1768,11 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int32_t vnodeIndex, int16_t tableIndex
SMetricMeta
*
pMetricMeta
=
taosGetDataFromCache
(
tscCacheHandle
,
key
);
pFinalInfo
=
tscAddMeterMetaInfo
(
&
pNew
->
cmd
,
name
,
pMeterMeta
,
pMetricMeta
,
pMeterMetaInfo
->
numOfTags
,
pMeterMetaInfo
->
tagColumnIndex
);
pMeterMetaInfo
->
tagColumnIndex
);
}
else
{
SMeterMetaInfo
*
pPrevInfo
=
tscGetMeterMetaInfo
(
&
pPrevSql
->
cmd
,
0
);
pFinalInfo
=
tscAddMeterMetaInfo
(
&
pNew
->
cmd
,
name
,
pPrevInfo
->
pMeterMeta
,
pPrevInfo
->
pMetricMeta
,
pMeterMetaInfo
->
numOfTags
,
pMeterMetaInfo
->
tagColumnIndex
);
pFinalInfo
=
tscAddMeterMetaInfo
(
&
pNew
->
cmd
,
name
,
pPrevInfo
->
pMeterMeta
,
pPrevInfo
->
pMetricMeta
,
pMeterMetaInfo
->
numOfTags
,
pMeterMetaInfo
->
tagColumnIndex
);
pPrevInfo
->
pMeterMeta
=
NULL
;
pPrevInfo
->
pMetricMeta
=
NULL
;
...
...
@@ -1783,13 +1783,14 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int32_t vnodeIndex, int16_t tableIndex
assert
(
pFinalInfo
->
pMetricMeta
!=
NULL
);
}
tscTrace
(
"%p new subquery %p, vnodeIdx:%d, tableIndex:%d, type:%d"
,
pSql
,
pNew
,
vnodeIndex
,
tableIndex
,
pNew
->
cmd
.
type
);
tscTrace
(
"%p new subquery %p, vnodeIdx:%d, tableIndex:%d, type:%d"
,
pSql
,
pNew
,
vnodeIndex
,
tableIndex
,
pNew
->
cmd
.
type
);
return
pNew
;
}
void
tscDoQuery
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
void
*
fp
=
pSql
->
fp
;
void
*
fp
=
pSql
->
fp
;
if
(
pCmd
->
command
>
TSDB_SQL_LOCAL
)
{
tscProcessLocalCmd
(
pSql
);
...
...
src/system/detail/src/vnodeQueryImpl.c
浏览文件 @
fa0f056f
...
...
@@ -3122,9 +3122,11 @@ static bool onlyOneQueryType(SQuery *pQuery, int32_t functId, int32_t functIdDst
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutputCols
;
++
i
)
{
int32_t
functionId
=
pQuery
->
pSelectExpr
[
i
].
pBase
.
functionId
;
if
(
functionId
==
TSDB_FUNC_TS
||
functionId
==
TSDB_FUNC_TS_DUMMY
||
functionId
==
TSDB_FUNC_TAG
)
{
if
(
functionId
==
TSDB_FUNC_TS
||
functionId
==
TSDB_FUNC_TS_DUMMY
||
functionId
==
TSDB_FUNC_TAG
||
functionId
==
TSDB_FUNC_TAG_DUMMY
)
{
continue
;
}
if
(
functionId
!=
functId
&&
functionId
!=
functIdDst
)
{
return
false
;
}
...
...
@@ -3137,10 +3139,9 @@ static bool onlyFirstQuery(SQuery *pQuery) { return onlyOneQueryType(pQuery, TSD
static
bool
onlyLastQuery
(
SQuery
*
pQuery
)
{
return
onlyOneQueryType
(
pQuery
,
TSDB_FUNC_LAST
,
TSDB_FUNC_LAST_DST
);
}
static
void
rewriteExec
Order
(
SQuery
*
pQuery
,
bool
metricQuery
)
{
static
void
changeExecuteScan
Order
(
SQuery
*
pQuery
,
bool
metricQuery
)
{
// in case of point-interpolation query, use asc order scan
char
msg
[]
=
"QInfo:%p scan order changed for %s query, old:%d, new:%d, qrange exchanged, old qrange:%lld-%lld, "
char
msg
[]
=
"QInfo:%p scan order changed for %s query, old:%d, new:%d, qrange exchanged, old qrange:%lld-%lld, "
"new qrange:%lld-%lld"
;
// descending order query
...
...
@@ -3614,7 +3615,7 @@ int32_t vnodeQuerySingleMeterPrepare(SQInfo *pQInfo, SMeterObj *pMeterObj, SMete
}
setScanLimitationByResultBuffer
(
pQuery
);
rewriteExec
Order
(
pQuery
,
false
);
changeExecuteScan
Order
(
pQuery
,
false
);
pQInfo
->
over
=
0
;
pQInfo
->
pointsRead
=
0
;
...
...
@@ -3790,7 +3791,7 @@ int32_t vnodeMultiMeterQueryPrepare(SQInfo *pQInfo, SQuery *pQuery, void *param)
pQInfo
->
pointsRead
=
0
;
pQuery
->
pointsRead
=
0
;
rewriteExec
Order
(
pQuery
,
true
);
changeExecuteScan
Order
(
pQuery
,
true
);
vnodeInitDataBlockInfo
(
&
pSupporter
->
runtimeEnv
.
loadBlockInfo
);
vnodeInitLoadCompBlockInfo
(
&
pSupporter
->
runtimeEnv
.
loadCompBlockInfo
);
...
...
src/system/detail/src/vnodeUtil.c
浏览文件 @
fa0f056f
...
...
@@ -289,7 +289,7 @@ SSqlFunctionExpr* vnodeCreateSqlFunctionExpr(SQueryMeterMsg* pQueryMsg, int32_t*
return
NULL
;
}
if
(
pExprs
[
i
].
pBase
.
functionId
==
TSDB_FUNC_TAG_DUMMY
)
{
if
(
pExprs
[
i
].
pBase
.
functionId
==
TSDB_FUNC_TAG_DUMMY
||
pExprs
[
i
].
pBase
.
functionId
==
TSDB_FUNC_TS_DUMMY
)
{
tagLen
+=
pExprs
[
i
].
resBytes
;
}
assert
(
isValidDataType
(
pExprs
[
i
].
resType
,
pExprs
[
i
].
resBytes
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录