Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
aba07934
T
TDengine
项目概览
loser646
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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,发现更多精彩内容 >>
未验证
提交
aba07934
编写于
8月 03, 2021
作者:
H
Haojun Liao
提交者:
GitHub
8月 03, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7111 from taosdata/feature/query
Feature/query
上级
f0a37123
4fd1d1f1
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
152 addition
and
134 deletion
+152
-134
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+2
-3
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+9
-13
src/client/src/tscServer.c
src/client/src/tscServer.c
+2
-4
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+2
-0
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-2
src/os/inc/osTime.h
src/os/inc/osTime.h
+1
-1
src/os/src/detail/osTime.c
src/os/src/detail/osTime.c
+4
-4
src/query/inc/sql.y
src/query/inc/sql.y
+1
-1
src/query/src/qPlan.c
src/query/src/qPlan.c
+39
-37
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+2
-1
src/query/src/sql.c
src/query/src/sql.c
+61
-61
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+1
-3
src/vnode/inc/vnodeInt.h
src/vnode/inc/vnodeInt.h
+1
-0
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+25
-4
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
aba07934
...
...
@@ -84,8 +84,6 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
int64_t
useconds
=
0
;
char
*
pTokenEnd
=
*
next
;
index
=
0
;
if
(
pToken
->
type
==
TK_NOW
)
{
useconds
=
taosGetTimestamp
(
timePrec
);
}
else
if
(
strncmp
(
pToken
->
z
,
"0"
,
1
)
==
0
&&
pToken
->
n
==
1
)
{
...
...
@@ -130,7 +128,8 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
return
tscInvalidOperationMsg
(
error
,
"value expected in timestamp"
,
sToken
.
z
);
}
if
(
parseAbsoluteDuration
(
valueToken
.
z
,
valueToken
.
n
,
&
interval
,
timePrec
)
!=
TSDB_CODE_SUCCESS
)
{
char
unit
=
0
;
if
(
parseAbsoluteDuration
(
valueToken
.
z
,
valueToken
.
n
,
&
interval
,
&
unit
,
timePrec
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
aba07934
...
...
@@ -1289,35 +1289,31 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SStrToken* pSl
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
SInterval
*
pInterval
=
&
pQueryInfo
->
interval
;
if
(
pSliding
->
n
==
0
)
{
p
QueryInfo
->
interval
.
slidingUnit
=
pQueryInfo
->
interval
.
intervalUnit
;
p
QueryInfo
->
interval
.
sliding
=
pQueryInfo
->
interval
.
interval
;
p
Interval
->
slidingUnit
=
pInterval
->
intervalUnit
;
p
Interval
->
sliding
=
pInterval
->
interval
;
return
TSDB_CODE_SUCCESS
;
}
if
(
p
QueryInfo
->
interval
.
intervalUnit
==
'n'
||
pQueryInfo
->
interval
.
intervalUnit
==
'y'
)
{
if
(
p
Interval
->
intervalUnit
==
'n'
||
pInterval
->
intervalUnit
==
'y'
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
parseAbsoluteDuration
(
pSliding
->
z
,
pSliding
->
n
,
&
p
QueryInfo
->
interval
.
sliding
,
tinfo
.
precision
);
parseAbsoluteDuration
(
pSliding
->
z
,
pSliding
->
n
,
&
p
Interval
->
sliding
,
&
pInterval
->
slidingUnit
,
tinfo
.
precision
);
if
(
pQueryInfo
->
interval
.
sliding
<
convertTimePrecision
(
tsMinSlidingTime
,
TSDB_TIME_PRECISION_MILLI
,
tinfo
.
precision
))
{
if
(
pInterval
->
sliding
<
convertTimePrecision
(
tsMinSlidingTime
,
TSDB_TIME_PRECISION_MILLI
,
tinfo
.
precision
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg0
);
}
if
(
p
QueryInfo
->
interval
.
sliding
>
pQueryInfo
->
interval
.
interval
)
{
if
(
p
Interval
->
sliding
>
pInterval
->
interval
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
((
p
QueryInfo
->
interval
.
interval
!=
0
)
&&
(
pQueryInfo
->
interval
.
interval
/
pQueryInfo
->
interval
.
sliding
>
INTERVAL_SLIDING_FACTOR
))
{
if
((
p
Interval
->
interval
!=
0
)
&&
(
pInterval
->
interval
/
pInterval
->
sliding
>
INTERVAL_SLIDING_FACTOR
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
// if (pQueryInfo->interval.sliding != pQueryInfo->interval.interval && pSql->pStream == NULL) {
// return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
// }
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -8775,8 +8771,8 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
#if 0
SQueryNode* p = qCreateQueryPlan(pQueryInfo);
char* s = queryPlanToString(p);
printf("%s\n", s);
tfree(s);
qDestroyQueryPlan(p);
#endif
...
...
src/client/src/tscServer.c
浏览文件 @
aba07934
...
...
@@ -401,10 +401,8 @@ static void doProcessMsgFromServer(SSchedMsg* pSchedMsg) {
// single table query error need to be handled here.
if
((
cmd
==
TSDB_SQL_SELECT
||
cmd
==
TSDB_SQL_UPDATE_TAGS_VAL
)
&&
(((
rpcMsg
->
code
==
TSDB_CODE_TDB_INVALID_TABLE_ID
||
rpcMsg
->
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
))
||
rpcMsg
->
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
rpcMsg
->
code
==
TSDB_CODE_APP_NOT_READY
))
{
(((
rpcMsg
->
code
==
TSDB_CODE_TDB_INVALID_TABLE_ID
||
rpcMsg
->
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
))
||
rpcMsg
->
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
rpcMsg
->
code
==
TSDB_CODE_APP_NOT_READY
))
{
// 1. super table subquery
// 2. nest queries are all not updated the tablemeta and retry parse the sql after cleanup local tablemeta/vgroup id buffer
...
...
src/client/src/tscSubquery.c
浏览文件 @
aba07934
...
...
@@ -1635,6 +1635,8 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
continue
;
}
SSqlRes
*
pRes1
=
&
pSql1
->
res
;
if
(
pRes1
->
row
>=
pRes1
->
numOfRows
)
{
subquerySetState
(
pSql1
,
&
pSql
->
subState
,
i
,
0
);
...
...
src/client/src/tscUtil.c
浏览文件 @
aba07934
...
...
@@ -3645,8 +3645,8 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
}
if
(
pQueryInfo
->
fillType
!=
TSDB_FILL_NONE
)
{
//just make memory memory sanitizer happy
//refator later
//just make memory memory sanitizer happy
//refa
c
tor later
pNewQueryInfo
->
fillVal
=
calloc
(
1
,
pQueryInfo
->
fieldsInfo
.
numOfOutput
*
sizeof
(
int64_t
));
if
(
pNewQueryInfo
->
fillVal
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
...
src/os/inc/osTime.h
浏览文件 @
aba07934
...
...
@@ -97,7 +97,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision);
int64_t
taosTimeTruncate
(
int64_t
t
,
const
SInterval
*
pInterval
,
int32_t
precision
);
int32_t
taosTimeCountInterval
(
int64_t
skey
,
int64_t
ekey
,
int64_t
interval
,
char
unit
,
int32_t
precision
);
int32_t
parseAbsoluteDuration
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
ts
,
int32_t
timePrecision
);
int32_t
parseAbsoluteDuration
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
ts
,
char
*
unit
,
int32_t
timePrecision
);
int32_t
parseNatualDuration
(
const
char
*
token
,
int32_t
tokenLen
,
int64_t
*
duration
,
char
*
unit
,
int32_t
timePrecision
);
int32_t
taosParseTime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
len
,
int32_t
timePrec
,
int8_t
dayligth
);
...
...
src/os/src/detail/osTime.c
浏览文件 @
aba07934
...
...
@@ -397,7 +397,7 @@ static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t time
* n - Months (30 days)
* y - Years (365 days)
*/
int32_t
parseAbsoluteDuration
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
duration
,
int32_t
timePrecision
)
{
int32_t
parseAbsoluteDuration
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
duration
,
char
*
unit
,
int32_t
timePrecision
)
{
errno
=
0
;
char
*
endPtr
=
NULL
;
...
...
@@ -408,12 +408,12 @@ int32_t parseAbsoluteDuration(char* token, int32_t tokenlen, int64_t* duration,
}
/* natual month/year are not allowed in absolute duration */
char
unit
=
token
[
tokenlen
-
1
];
if
(
unit
==
'n'
||
unit
==
'y'
)
{
*
unit
=
token
[
tokenlen
-
1
];
if
(
*
unit
==
'n'
||
*
unit
==
'y'
)
{
return
-
1
;
}
return
getDuration
(
timestamp
,
unit
,
duration
,
timePrecision
);
return
getDuration
(
timestamp
,
*
unit
,
duration
,
timePrecision
);
}
int32_t
parseNatualDuration
(
const
char
*
token
,
int32_t
tokenLen
,
int64_t
*
duration
,
char
*
unit
,
int32_t
timePrecision
)
{
...
...
src/query/inc/sql.y
浏览文件 @
aba07934
...
...
@@ -479,7 +479,7 @@ tagitem(A) ::= PLUS(X) FLOAT(Y). {
//////////////////////// The SELECT statement /////////////////////////////////
%type select {SSqlNode*}
%destructor select {destroySqlNode($$);}
select(A) ::= SELECT(T) selcollist(W) from(X) where_opt(Y) interval_opt(K) s
ession_option(H) windowstate_option(D) fill_opt(F) sliding_opt(S)
groupby_opt(P) having_opt(N) orderby_opt(Z) slimit_opt(G) limit_opt(L). {
select(A) ::= SELECT(T) selcollist(W) from(X) where_opt(Y) interval_opt(K) s
liding_opt(S) session_option(H) windowstate_option(D) fill_opt(F)
groupby_opt(P) having_opt(N) orderby_opt(Z) slimit_opt(G) limit_opt(L). {
A = tSetQuerySqlNode(&T, W, X, Y, P, Z, &K, &H, &D, &S, F, &L, &G, N);
}
...
...
src/query/src/qPlan.c
浏览文件 @
aba07934
...
...
@@ -32,8 +32,8 @@ typedef struct SJoinCond {
SColumn
*
colCond
[
2
];
}
SJoinCond
;
static
SQueryNode
*
createQueryNode
(
int32_t
type
,
const
char
*
name
,
SQueryNode
**
prev
,
int32_t
numOfPrev
,
SExprInfo
**
pExpr
,
int32_t
numOfOutput
,
SQueryTableInfo
*
pTableInfo
,
static
SQueryNode
*
createQueryNode
(
int32_t
type
,
const
char
*
name
,
SQueryNode
**
prev
,
int32_t
numOfPrev
,
SExprInfo
**
pExpr
,
int32_t
numOfOutput
,
SQueryTableInfo
*
pTableInfo
,
void
*
pExtInfo
)
{
SQueryNode
*
pNode
=
calloc
(
1
,
sizeof
(
SQueryNode
));
...
...
@@ -112,8 +112,8 @@ static SQueryNode* doAddTableColumnNode(SQueryInfo* pQueryInfo, STableMetaInfo*
}
STimeWindow
*
window
=
&
pQueryInfo
->
window
;
SQueryNode
*
pNode
=
createQueryNode
(
QNODE_TABLESCAN
,
"TableScan"
,
NULL
,
0
,
NULL
,
0
,
info
,
window
);
SQueryNode
*
pNode
=
createQueryNode
(
QNODE_TABLESCAN
,
"TableScan"
,
NULL
,
0
,
NULL
,
0
,
info
,
window
);
if
(
pQueryInfo
->
projectionQuery
)
{
int32_t
numOfOutput
=
(
int32_t
)
taosArrayGetSize
(
pExprs
);
pNode
=
createQueryNode
(
QNODE_PROJECT
,
"Projection"
,
&
pNode
,
1
,
pExprs
->
pData
,
numOfOutput
,
info
,
NULL
);
...
...
@@ -146,39 +146,41 @@ static SQueryNode* doAddTableColumnNode(SQueryInfo* pQueryInfo, STableMetaInfo*
}
static
SQueryNode
*
doCreateQueryPlanForOneTableImpl
(
SQueryInfo
*
pQueryInfo
,
SQueryNode
*
pNode
,
SQueryTableInfo
*
info
,
SArray
*
pExprs
)
{
// check for aggregation
if
(
pQueryInfo
->
interval
.
interval
>
0
)
{
int32_t
numOfOutput
=
(
int32_t
)
taosArrayGetSize
(
pExprs
);
pNode
=
createQueryNode
(
QNODE_TIMEWINDOW
,
"TimeWindowAgg"
,
&
pNode
,
1
,
pExprs
->
pData
,
numOfOutput
,
info
,
&
pQueryInfo
->
interval
);
}
else
if
(
pQueryInfo
->
groupbyColumn
)
{
int32_t
numOfOutput
=
(
int32_t
)
taosArrayGetSize
(
pExprs
);
pNode
=
createQueryNode
(
QNODE_GROUPBY
,
"Groupby"
,
&
pNode
,
1
,
pExprs
->
pData
,
numOfOutput
,
info
,
&
pQueryInfo
->
groupbyExpr
);
}
else
if
(
pQueryInfo
->
sessionWindow
.
gap
>
0
)
{
pNode
=
createQueryNode
(
QNODE_SESSIONWINDOW
,
"SessionWindowAgg"
,
&
pNode
,
1
,
NULL
,
0
,
info
,
NULL
);
}
else
if
(
pQueryInfo
->
simpleAgg
)
{
int32_t
numOfOutput
=
(
int32_t
)
taosArrayGetSize
(
pExprs
);
pNode
=
createQueryNode
(
QNODE_AGGREGATE
,
"Aggregate"
,
&
pNode
,
1
,
pExprs
->
pData
,
numOfOutput
,
info
,
NULL
);
}
if
(
pQueryInfo
->
havingFieldNum
>
0
||
pQueryInfo
->
arithmeticOnAgg
)
{
int32_t
numOfExpr
=
(
int32_t
)
taosArrayGetSize
(
pQueryInfo
->
exprList1
);
pNode
=
createQueryNode
(
QNODE_PROJECT
,
"Projection"
,
&
pNode
,
1
,
pQueryInfo
->
exprList1
->
pData
,
numOfExpr
,
info
,
NULL
);
}
SArray
*
pExprs
)
{
// check for aggregation
if
(
pQueryInfo
->
interval
.
interval
>
0
)
{
int32_t
numOfOutput
=
(
int32_t
)
taosArrayGetSize
(
pExprs
);
pNode
=
createQueryNode
(
QNODE_TIMEWINDOW
,
"TimeWindowAgg"
,
&
pNode
,
1
,
pExprs
->
pData
,
numOfOutput
,
info
,
&
pQueryInfo
->
interval
);
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
!=
0
)
{
pNode
=
createQueryNode
(
QNODE_GROUPBY
,
"Groupby"
,
&
pNode
,
1
,
pExprs
->
pData
,
numOfOutput
,
info
,
&
pQueryInfo
->
groupbyExpr
);
}
}
else
if
(
pQueryInfo
->
groupbyColumn
)
{
int32_t
numOfOutput
=
(
int32_t
)
taosArrayGetSize
(
pExprs
);
pNode
=
createQueryNode
(
QNODE_GROUPBY
,
"Groupby"
,
&
pNode
,
1
,
pExprs
->
pData
,
numOfOutput
,
info
,
&
pQueryInfo
->
groupbyExpr
);
}
else
if
(
pQueryInfo
->
sessionWindow
.
gap
>
0
)
{
pNode
=
createQueryNode
(
QNODE_SESSIONWINDOW
,
"SessionWindowAgg"
,
&
pNode
,
1
,
NULL
,
0
,
info
,
NULL
);
}
else
if
(
pQueryInfo
->
simpleAgg
)
{
int32_t
numOfOutput
=
(
int32_t
)
taosArrayGetSize
(
pExprs
);
pNode
=
createQueryNode
(
QNODE_AGGREGATE
,
"Aggregate"
,
&
pNode
,
1
,
pExprs
->
pData
,
numOfOutput
,
info
,
NULL
);
}
if
(
pQueryInfo
->
fillType
!=
TSDB_FILL_NONE
)
{
SFillEssInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SFillEssInfo
)
);
pInfo
->
fillType
=
pQueryInfo
->
fillType
;
pInfo
->
val
=
calloc
(
pNode
->
numOfOutput
,
sizeof
(
int64_t
)
);
memcpy
(
pInfo
->
val
,
pQueryInfo
->
fillVal
,
pNode
->
numOfOutput
);
if
(
pQueryInfo
->
havingFieldNum
>
0
||
pQueryInfo
->
arithmeticOnAgg
)
{
int32_t
numOfExpr
=
(
int32_t
)
taosArrayGetSize
(
pQueryInfo
->
exprList1
);
pNode
=
createQueryNode
(
QNODE_PROJECT
,
"Projection"
,
&
pNode
,
1
,
pQueryInfo
->
exprList1
->
pData
,
numOfExpr
,
info
,
NULL
);
}
pNode
=
createQueryNode
(
QNODE_FILL
,
"Fill"
,
&
pNode
,
1
,
NULL
,
0
,
info
,
pInfo
);
}
if
(
pQueryInfo
->
fillType
!=
TSDB_FILL_NONE
)
{
SFillEssInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SFillEssInfo
));
pInfo
->
fillType
=
pQueryInfo
->
fillType
;
pInfo
->
val
=
calloc
(
pNode
->
numOfOutput
,
sizeof
(
int64_t
));
memcpy
(
pInfo
->
val
,
pQueryInfo
->
fillVal
,
pNode
->
numOfOutput
);
pNode
=
createQueryNode
(
QNODE_FILL
,
"Fill"
,
&
pNode
,
1
,
NULL
,
0
,
info
,
pInfo
);
}
if
(
pQueryInfo
->
limit
.
limit
!=
-
1
||
pQueryInfo
->
limit
.
offset
!=
0
)
{
pNode
=
createQueryNode
(
QNODE_LIMIT
,
"Limit"
,
&
pNode
,
1
,
NULL
,
0
,
info
,
&
pQueryInfo
->
limit
);
...
...
@@ -330,7 +332,7 @@ static int32_t doPrintPlan(char* buf, SQueryNode* pQueryNode, int32_t level, int
switch
(
pQueryNode
->
info
.
type
)
{
case
QNODE_TABLESCAN
:
{
STimeWindow
*
win
=
(
STimeWindow
*
)
pQueryNode
->
pExtInfo
;
len1
=
sprintf
(
buf
+
len
,
"%s #
0x%"
PRIx
64
") time_range: %"
PRId64
" - %"
PRId64
"
\n
"
,
len1
=
sprintf
(
buf
+
len
,
"%s #
%"
PRIu
64
") time_range: %"
PRId64
" - %"
PRId64
"
\n
"
,
pQueryNode
->
tableInfo
.
tableName
,
pQueryNode
->
tableInfo
.
id
.
uid
,
win
->
skey
,
win
->
ekey
);
len
+=
len1
;
break
;
...
...
@@ -401,8 +403,8 @@ static int32_t doPrintPlan(char* buf, SQueryNode* pQueryNode, int32_t level, int
len
+=
len1
;
SInterval
*
pInterval
=
pQueryNode
->
pExtInfo
;
len1
=
sprintf
(
buf
+
len
,
"interval:%"
PRId64
"(%
c), sliding:%"
PRId64
"(%c
), offset:%"
PRId64
"
\n
"
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
sliding
,
pInterval
->
slidingUnit
,
len1
=
sprintf
(
buf
+
len
,
"interval:%"
PRId64
"(%
s), sliding:%"
PRId64
"(%s
), offset:%"
PRId64
"
\n
"
,
pInterval
->
interval
,
TSDB_TIME_PRECISION_MILLI_STR
,
pInterval
->
sliding
,
TSDB_TIME_PRECISION_MILLI_STR
,
pInterval
->
offset
);
len
+=
len1
;
...
...
src/query/src/qSqlParser.c
浏览文件 @
aba07934
...
...
@@ -166,7 +166,8 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) {
// use nanosecond by default
// TODO set value after getting database precision
if
(
pToken
)
{
int32_t
ret
=
parseAbsoluteDuration
(
pToken
->
z
,
pToken
->
n
,
&
pSqlExpr
->
value
.
i64
,
TSDB_TIME_PRECISION_NANO
);
char
unit
=
0
;
int32_t
ret
=
parseAbsoluteDuration
(
pToken
->
z
,
pToken
->
n
,
&
pSqlExpr
->
value
.
i64
,
&
unit
,
TSDB_TIME_PRECISION_NANO
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
}
...
...
src/query/src/sql.c
浏览文件 @
aba07934
...
...
@@ -257,27 +257,27 @@ static const YYACTIONTYPE yy_action[] = {
/* 480 */
208
,
211
,
205
,
212
,
213
,
217
,
218
,
219
,
216
,
202
,
/* 490 */
1143
,
1082
,
1135
,
236
,
267
,
1079
,
1078
,
237
,
338
,
151
,
/* 500 */
1035
,
1046
,
47
,
1065
,
1043
,
149
,
1064
,
1025
,
1028
,
1044
,
/* 510 */
274
,
1048
,
153
,
170
,
15
7
,
1009
,
278
,
283
,
171
,
1007
,
/* 510 */
274
,
1048
,
153
,
170
,
15
8
,
1009
,
278
,
285
,
171
,
1007
,
/* 520 */
172
,
233
,
166
,
280
,
161
,
757
,
160
,
173
,
162
,
922
,
/* 530 */
163
,
299
,
300
,
301
,
304
,
305
,
28
7
,
292
,
45
,
290
,
/* 530 */
163
,
299
,
300
,
301
,
304
,
305
,
28
2
,
292
,
45
,
290
,
/* 540 */
75
,
200
,
288
,
813
,
272
,
41
,
72
,
49
,
316
,
164
,
/* 550 */
916
,
323
,
1142
,
110
,
1141
,
1138
,
286
,
179
,
330
,
1134
,
/* 560 */
284
,
116
,
1133
,
1130
,
180
,
28
2
,
942
,
42
,
39
,
46
,
/* 570 */
201
,
904
,
279
,
126
,
48
,
902
,
128
,
129
,
900
,
899
,
/* 560 */
284
,
116
,
1133
,
1130
,
180
,
28
1
,
942
,
42
,
39
,
46
,
/* 570 */
201
,
904
,
279
,
126
,
303
,
902
,
128
,
129
,
900
,
899
,
/* 580 */
259
,
191
,
897
,
896
,
895
,
894
,
893
,
892
,
891
,
194
,
/* 590 */
196
,
888
,
886
,
884
,
882
,
198
,
879
,
199
,
303
,
81
,
/* 600 */
86
,
348
,
28
1
,
1066
,
121
,
340
,
341
,
342
,
343
,
344
,
/* 590 */
196
,
888
,
886
,
884
,
882
,
198
,
879
,
199
,
48
,
81
,
/* 600 */
86
,
348
,
28
3
,
1066
,
121
,
340
,
341
,
342
,
343
,
344
,
/* 610 */
223
,
345
,
346
,
356
,
855
,
243
,
298
,
260
,
261
,
854
,
/* 620 */
263
,
220
,
221
,
264
,
853
,
836
,
104
,
921
,
920
,
105
,
/* 630 */
835
,
268
,
273
,
10
,
293
,
734
,
275
,
84
,
30
,
87
,
/* 640 */
89
8
,
890
,
182
,
943
,
186
,
181
,
184
,
140
,
183
,
187
,
/* 650 */
18
5
,
141
,
142
,
889
,
4
,
143
,
980
,
881
,
880
,
944
,
/* 660 */
759
,
165
,
167
,
168
,
1
55
,
169
,
762
,
156
,
2
,
990
,
/* 670 */
88
,
235
,
764
,
89
,
285
,
31
,
768
,
158
,
11
,
1
2
,
/* 680 */
1
3
,
32
,
27
,
295
,
28
,
96
,
98
,
101
,
35
,
100
,
/* 630 */
835
,
268
,
273
,
10
,
293
,
734
,
275
,
84
,
30
,
898
,
/* 640 */
89
0
,
183
,
182
,
943
,
187
,
181
,
184
,
185
,
2
,
140
,
/* 650 */
18
6
,
141
,
142
,
889
,
4
,
143
,
980
,
881
,
87
,
944
,
/* 660 */
759
,
165
,
167
,
168
,
1
69
,
880
,
155
,
157
,
768
,
156
,
/* 670 */
235
,
762
,
88
,
89
,
990
,
764
,
287
,
31
,
11
,
3
2
,
/* 680 */
1
2
,
13
,
27
,
295
,
28
,
96
,
98
,
101
,
35
,
100
,
/* 690 */
632
,
36
,
102
,
667
,
665
,
664
,
663
,
661
,
660
,
659
,
/* 700 */
656
,
314
,
622
,
106
,
7
,
320
,
812
,
814
,
8
,
321
,
/* 710 */
109
,
111
,
68
,
69
,
115
,
704
,
703
,
38
,
117
,
700
,
/* 700 */
656
,
314
,
622
,
106
,
7
,
320
,
812
,
321
,
8
,
109
,
/* 710 */
814
,
111
,
68
,
69
,
115
,
704
,
703
,
38
,
117
,
700
,
/* 720 */
648
,
646
,
638
,
644
,
640
,
642
,
636
,
634
,
670
,
669
,
/* 730 */
668
,
666
,
662
,
658
,
657
,
190
,
620
,
585
,
583
,
859
,
/* 740 */
858
,
858
,
858
,
858
,
858
,
858
,
858
,
858
,
858
,
858
,
...
...
@@ -338,24 +338,24 @@ static const YYCODETYPE yy_lookahead[] = {
/* 510 */
246
,
199
,
199
,
250
,
199
,
246
,
269
,
199
,
199
,
199
,
/* 520 */
199
,
269
,
254
,
269
,
259
,
124
,
260
,
199
,
258
,
199
,
/* 530 */
257
,
199
,
199
,
199
,
199
,
199
,
269
,
130
,
199
,
134
,
/* 540 */
136
,
199
,
12
9
,
117
,
200
,
199
,
138
,
135
,
199
,
256
,
/* 550 */
199
,
199
,
199
,
199
,
199
,
199
,
12
8
,
199
,
199
,
199
,
/* 560 */
12
7
,
199
,
199
,
199
,
199
,
126
,
199
,
199
,
199
,
199
,
/* 570 */
199
,
199
,
125
,
199
,
140
,
199
,
199
,
199
,
199
,
199
,
/* 540 */
136
,
199
,
12
8
,
117
,
200
,
199
,
138
,
135
,
199
,
256
,
/* 550 */
199
,
199
,
199
,
199
,
199
,
199
,
12
7
,
199
,
199
,
199
,
/* 560 */
12
6
,
199
,
199
,
199
,
199
,
129
,
199
,
199
,
199
,
199
,
/* 570 */
199
,
199
,
125
,
199
,
89
,
199
,
199
,
199
,
199
,
199
,
/* 580 */
199
,
199
,
199
,
199
,
199
,
199
,
199
,
199
,
199
,
199
,
/* 590 */
199
,
199
,
199
,
199
,
199
,
199
,
199
,
199
,
89
,
200
,
/* 590 */
199
,
199
,
199
,
199
,
199
,
199
,
199
,
199
,
140
,
200
,
/* 600 */
200
,
113
,
200
,
200
,
96
,
95
,
51
,
92
,
94
,
55
,
/* 610 */
200
,
93
,
91
,
84
,
5
,
200
,
200
,
153
,
5
,
5
,
/* 620 */
153
,
200
,
200
,
5
,
5
,
100
,
206
,
210
,
210
,
206
,
/* 630 */
99
,
142
,
120
,
82
,
115
,
83
,
97
,
121
,
82
,
97
,
/* 640 */
200
,
2
00
,
217
,
219
,
215
,
218
,
216
,
201
,
213
,
212
,
/* 650 */
21
4
,
201
,
201
,
200
,
202
,
201
,
237
,
200
,
200
,
221
,
/* 660 */
83
,
255
,
253
,
252
,
82
,
251
,
83
,
97
,
207
,
237
,
/* 670 */
82
,
1
,
83
,
82
,
82
,
97
,
83
,
82
,
131
,
131
,
/* 680 */
82
,
97
,
82
,
115
,
82
,
116
,
78
,
71
,
87
,
86
,
/* 630 */
99
,
142
,
120
,
82
,
115
,
83
,
97
,
121
,
82
,
200
,
/* 640 */
200
,
2
13
,
217
,
219
,
212
,
218
,
216
,
214
,
207
,
201
,
/* 650 */
21
5
,
201
,
201
,
200
,
202
,
201
,
237
,
200
,
97
,
221
,
/* 660 */
83
,
255
,
253
,
252
,
251
,
200
,
82
,
97
,
83
,
82
,
/* 670 */
1
,
83
,
82
,
82
,
237
,
83
,
82
,
97
,
131
,
97
,
/* 680 */
131
,
82
,
82
,
115
,
82
,
116
,
78
,
71
,
87
,
86
,
/* 690 */
5
,
87
,
86
,
9
,
5
,
5
,
5
,
5
,
5
,
5
,
/* 700 */
5
,
15
,
85
,
78
,
82
,
24
,
83
,
117
,
82
,
59
,
/* 710 */
1
4
7
,
147
,
16
,
16
,
147
,
5
,
5
,
97
,
147
,
83
,
/* 700 */
5
,
15
,
85
,
78
,
82
,
24
,
83
,
59
,
82
,
147
,
/* 710 */
1
1
7
,
147
,
16
,
16
,
147
,
5
,
5
,
97
,
147
,
83
,
/* 720 */
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
/* 730 */
5
,
5
,
5
,
5
,
5
,
97
,
85
,
61
,
60
,
0
,
/* 740 */
276
,
276
,
276
,
276
,
276
,
276
,
276
,
276
,
276
,
276
,
...
...
@@ -399,9 +399,9 @@ static const unsigned short int yy_shift_ofst[] = {
/* 120 */
143
,
143
,
143
,
143
,
143
,
143
,
143
,
143
,
143
,
143
,
/* 130 */
143
,
143
,
143
,
143
,
143
,
143
,
143
,
143
,
143
,
143
,
/* 140 */
143
,
143
,
143
,
143
,
143
,
143
,
143
,
143
,
143
,
143
,
/* 150 */
143
,
444
,
444
,
444
,
401
,
401
,
401
,
4
44
,
401
,
444
,
/* 160 */
404
,
408
,
407
,
412
,
405
,
41
3
,
428
,
433
,
439
,
447
,
/* 170 */
4
34
,
444
,
444
,
444
,
509
,
509
,
488
,
12
,
12
,
444
,
/* 150 */
143
,
444
,
444
,
444
,
401
,
401
,
401
,
4
01
,
444
,
444
,
/* 160 */
404
,
408
,
407
,
412
,
405
,
41
4
,
429
,
434
,
436
,
447
,
/* 170 */
4
58
,
444
,
444
,
444
,
485
,
485
,
488
,
12
,
12
,
444
,
/* 180 */
444
,
508
,
510
,
555
,
515
,
514
,
554
,
518
,
521
,
488
,
/* 190 */
13
,
444
,
529
,
529
,
444
,
529
,
444
,
529
,
444
,
444
,
/* 200 */
753
,
753
,
54
,
81
,
81
,
108
,
81
,
134
,
188
,
205
,
...
...
@@ -411,12 +411,12 @@ static const unsigned short int yy_shift_ofst[] = {
/* 240 */
345
,
347
,
348
,
343
,
350
,
357
,
431
,
375
,
426
,
366
,
/* 250 */
118
,
308
,
314
,
459
,
460
,
324
,
327
,
361
,
331
,
373
,
/* 260 */
609
,
464
,
613
,
614
,
467
,
618
,
619
,
525
,
531
,
489
,
/* 270 */
512
,
519
,
551
,
516
,
552
,
556
,
539
,
5
42
,
577
,
582
,
/* 280 */
58
3
,
570
,
588
,
589
,
591
,
670
,
592
,
593
,
595
,
578
,
/* 290 */
547
,
58
4
,
548
,
598
,
519
,
600
,
568
,
602
,
569
,
608
,
/* 270 */
512
,
519
,
551
,
516
,
552
,
556
,
539
,
5
61
,
577
,
584
,
/* 280 */
58
5
,
587
,
588
,
570
,
590
,
592
,
591
,
669
,
594
,
580
,
/* 290 */
547
,
58
2
,
549
,
599
,
519
,
600
,
568
,
602
,
569
,
608
,
/* 300 */
601
,
603
,
616
,
685
,
604
,
606
,
684
,
689
,
690
,
691
,
/* 310 */
692
,
693
,
694
,
695
,
617
,
686
,
625
,
622
,
623
,
59
0
,
/* 320 */
626
,
681
,
6
50
,
696
,
563
,
564
,
620
,
620
,
620
,
620
,
/* 310 */
692
,
693
,
694
,
695
,
617
,
686
,
625
,
622
,
623
,
59
3
,
/* 320 */
626
,
681
,
6
48
,
696
,
562
,
564
,
620
,
620
,
620
,
620
,
/* 330 */
697
,
567
,
571
,
620
,
620
,
620
,
710
,
711
,
636
,
620
,
/* 340 */
715
,
716
,
717
,
718
,
719
,
720
,
721
,
722
,
723
,
724
,
/* 350 */
725
,
726
,
727
,
728
,
729
,
638
,
651
,
730
,
731
,
676
,
...
...
@@ -424,7 +424,7 @@ static const unsigned short int yy_shift_ofst[] = {
};
#define YY_REDUCE_COUNT (201)
#define YY_REDUCE_MIN (-265)
#define YY_REDUCE_MAX (46
1
)
#define YY_REDUCE_MAX (46
5
)
static
const
short
yy_reduce_ofst
[]
=
{
/* 0 */
-
27
,
-
33
,
-
33
,
-
193
,
-
193
,
-
76
,
-
203
,
-
199
,
-
175
,
-
184
,
/* 10 */
-
130
,
-
134
,
93
,
24
,
67
,
119
,
126
,
135
,
142
,
148
,
...
...
@@ -441,12 +441,12 @@ static const short yy_reduce_ofst[] = {
/* 120 */
365
,
367
,
368
,
369
,
370
,
371
,
372
,
374
,
376
,
377
,
/* 130 */
378
,
379
,
380
,
381
,
382
,
383
,
384
,
385
,
386
,
387
,
/* 140 */
388
,
389
,
390
,
391
,
392
,
393
,
394
,
395
,
396
,
397
,
/* 150 */
398
,
344
,
399
,
400
,
247
,
252
,
254
,
402
,
267
,
403
,
/* 150 */
398
,
344
,
399
,
400
,
247
,
252
,
254
,
267
,
402
,
403
,
/* 160 */
246
,
266
,
265
,
270
,
273
,
293
,
406
,
268
,
409
,
411
,
/* 170 */
41
4
,
410
,
415
,
416
,
417
,
418
,
419
,
420
,
423
,
421
,
/* 180 */
422
,
424
,
427
,
425
,
4
35
,
430
,
436
,
429
,
437
,
432
,
/* 190 */
438
,
4
40
,
446
,
450
,
441
,
451
,
453
,
454
,
457
,
458
,
/* 200 */
4
6
1
,
452
,
/* 170 */
41
3
,
410
,
415
,
416
,
417
,
418
,
419
,
420
,
423
,
421
,
/* 180 */
422
,
424
,
427
,
425
,
4
28
,
430
,
433
,
435
,
432
,
437
,
/* 190 */
438
,
4
39
,
448
,
450
,
440
,
451
,
453
,
454
,
457
,
465
,
/* 200 */
4
4
1
,
452
,
};
static
const
YYACTIONTYPE
yy_default
[]
=
{
/* 0 */
856
,
979
,
918
,
989
,
905
,
915
,
1126
,
1126
,
1126
,
856
,
...
...
@@ -464,8 +464,8 @@ static const YYACTIONTYPE yy_default[] = {
/* 120 */
856
,
856
,
856
,
856
,
856
,
856
,
903
,
856
,
901
,
856
,
/* 130 */
856
,
856
,
856
,
856
,
856
,
856
,
856
,
856
,
856
,
856
,
/* 140 */
856
,
856
,
856
,
856
,
887
,
856
,
856
,
856
,
856
,
856
,
/* 150 */
856
,
878
,
878
,
878
,
856
,
856
,
856
,
8
78
,
856
,
878
,
/* 160 */
1076
,
1080
,
1062
,
1074
,
1070
,
10
61
,
1057
,
1055
,
1053
,
1052
,
/* 150 */
856
,
878
,
878
,
878
,
856
,
856
,
856
,
8
56
,
878
,
878
,
/* 160 */
1076
,
1080
,
1062
,
1074
,
1070
,
10
57
,
1055
,
1053
,
1061
,
1052
,
/* 170 */
1084
,
878
,
878
,
878
,
923
,
923
,
919
,
915
,
915
,
878
,
/* 180 */
878
,
941
,
939
,
937
,
929
,
935
,
931
,
933
,
927
,
906
,
/* 190 */
856
,
878
,
913
,
913
,
878
,
913
,
878
,
913
,
878
,
878
,
...
...
@@ -1039,10 +1039,10 @@ static const char *const yyTokenName[] = {
/* 250 */
"from"
,
/* 251 */
"where_opt"
,
/* 252 */
"interval_opt"
,
/* 253 */
"s
ession_option
"
,
/* 254 */
"
windowstate
_option"
,
/* 255 */
"
fill_opt
"
,
/* 256 */
"
sliding
_opt"
,
/* 253 */
"s
liding_opt
"
,
/* 254 */
"
session
_option"
,
/* 255 */
"
windowstate_option
"
,
/* 256 */
"
fill
_opt"
,
/* 257 */
"groupby_opt"
,
/* 258 */
"having_opt"
,
/* 259 */
"orderby_opt"
,
...
...
@@ -1235,7 +1235,7 @@ static const char *const yyRuleName[] = {
/* 163 */
"tagitem ::= MINUS FLOAT"
,
/* 164 */
"tagitem ::= PLUS INTEGER"
,
/* 165 */
"tagitem ::= PLUS FLOAT"
,
/* 166 */
"select ::= SELECT selcollist from where_opt interval_opt s
ession_option windowstate_option fill_opt sliding
_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt"
,
/* 166 */
"select ::= SELECT selcollist from where_opt interval_opt s
liding_opt session_option windowstate_option fill
_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt"
,
/* 167 */
"select ::= LP select RP"
,
/* 168 */
"union ::= select"
,
/* 169 */
"union ::= union UNION ALL select"
,
...
...
@@ -1490,7 +1490,7 @@ tSqlExprListDestroy((yypminor->yy525));
case
243
:
/* columnlist */
case
244
:
/* tagitemlist */
case
245
:
/* tagNamelist */
case
25
5
:
/* fill_opt */
case
25
6
:
/* fill_opt */
case
257
:
/* groupby_opt */
case
259
:
/* orderby_opt */
case
270
:
/* sortlist */
...
...
@@ -1991,7 +1991,7 @@ static const struct {
{
248
,
-
2
},
/* (163) tagitem ::= MINUS FLOAT */
{
248
,
-
2
},
/* (164) tagitem ::= PLUS INTEGER */
{
248
,
-
2
},
/* (165) tagitem ::= PLUS FLOAT */
{
246
,
-
14
},
/* (166) select ::= SELECT selcollist from where_opt interval_opt s
ession_option windowstate_option fill_opt sliding
_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */
{
246
,
-
14
},
/* (166) select ::= SELECT selcollist from where_opt interval_opt s
liding_opt session_option windowstate_option fill
_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */
{
246
,
-
3
},
/* (167) select ::= LP select RP */
{
262
,
-
1
},
/* (168) union ::= select */
{
262
,
-
4
},
/* (169) union ::= union UNION ALL select */
...
...
@@ -2019,15 +2019,15 @@ static const struct {
{
252
,
-
4
},
/* (191) interval_opt ::= INTERVAL LP tmvar RP */
{
252
,
-
6
},
/* (192) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
{
252
,
0
},
/* (193) interval_opt ::= */
{
25
3
,
0
},
/* (194) session_option ::= */
{
25
3
,
-
7
},
/* (195) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */
{
25
4
,
0
},
/* (196) windowstate_option ::= */
{
25
4
,
-
4
},
/* (197) windowstate_option ::= STATE_WINDOW LP ids RP */
{
25
5
,
0
},
/* (198) fill_opt ::= */
{
25
5
,
-
6
},
/* (199) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{
25
5
,
-
4
},
/* (200) fill_opt ::= FILL LP ID RP */
{
25
6
,
-
4
},
/* (201) sliding_opt ::= SLIDING LP tmvar RP */
{
25
6
,
0
},
/* (202) sliding_opt ::= */
{
25
4
,
0
},
/* (194) session_option ::= */
{
25
4
,
-
7
},
/* (195) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */
{
25
5
,
0
},
/* (196) windowstate_option ::= */
{
25
5
,
-
4
},
/* (197) windowstate_option ::= STATE_WINDOW LP ids RP */
{
25
6
,
0
},
/* (198) fill_opt ::= */
{
25
6
,
-
6
},
/* (199) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{
25
6
,
-
4
},
/* (200) fill_opt ::= FILL LP ID RP */
{
25
3
,
-
4
},
/* (201) sliding_opt ::= SLIDING LP tmvar RP */
{
25
3
,
0
},
/* (202) sliding_opt ::= */
{
259
,
0
},
/* (203) orderby_opt ::= */
{
259
,
-
3
},
/* (204) orderby_opt ::= ORDER BY sortlist */
{
270
,
-
4
},
/* (205) sortlist ::= sortlist COMMA item sortorder */
...
...
@@ -2723,9 +2723,9 @@ static void yy_reduce(
}
yymsp
[
-
1
].
minor
.
yy506
=
yylhsminor
.
yy506
;
break
;
case
166
:
/* select ::= SELECT selcollist from where_opt interval_opt s
ession_option windowstate_option fill_opt sliding
_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */
case
166
:
/* select ::= SELECT selcollist from where_opt interval_opt s
liding_opt session_option windowstate_option fill
_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */
{
yylhsminor
.
yy464
=
tSetQuerySqlNode
(
&
yymsp
[
-
13
].
minor
.
yy0
,
yymsp
[
-
12
].
minor
.
yy525
,
yymsp
[
-
11
].
minor
.
yy412
,
yymsp
[
-
10
].
minor
.
yy370
,
yymsp
[
-
4
].
minor
.
yy525
,
yymsp
[
-
2
].
minor
.
yy525
,
&
yymsp
[
-
9
].
minor
.
yy520
,
&
yymsp
[
-
8
].
minor
.
yy259
,
&
yymsp
[
-
7
].
minor
.
yy144
,
&
yymsp
[
-
5
].
minor
.
yy0
,
yymsp
[
-
6
].
minor
.
yy525
,
&
yymsp
[
0
].
minor
.
yy126
,
&
yymsp
[
-
1
].
minor
.
yy126
,
yymsp
[
-
3
].
minor
.
yy370
);
yylhsminor
.
yy464
=
tSetQuerySqlNode
(
&
yymsp
[
-
13
].
minor
.
yy0
,
yymsp
[
-
12
].
minor
.
yy525
,
yymsp
[
-
11
].
minor
.
yy412
,
yymsp
[
-
10
].
minor
.
yy370
,
yymsp
[
-
4
].
minor
.
yy525
,
yymsp
[
-
2
].
minor
.
yy525
,
&
yymsp
[
-
9
].
minor
.
yy520
,
&
yymsp
[
-
7
].
minor
.
yy259
,
&
yymsp
[
-
6
].
minor
.
yy144
,
&
yymsp
[
-
8
].
minor
.
yy0
,
yymsp
[
-
5
].
minor
.
yy525
,
&
yymsp
[
0
].
minor
.
yy126
,
&
yymsp
[
-
1
].
minor
.
yy126
,
yymsp
[
-
3
].
minor
.
yy370
);
}
yymsp
[
-
13
].
minor
.
yy464
=
yylhsminor
.
yy464
;
break
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
aba07934
...
...
@@ -1234,7 +1234,6 @@ static int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t c
static
void
moveDataToFront
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
numOfRows
,
int32_t
numOfCols
);
static
void
doCheckGeneratedBlockRange
(
STsdbQueryHandle
*
pQueryHandle
);
static
void
copyAllRemainRowsFromFileBlock
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
SDataBlockInfo
*
pBlockInfo
,
int32_t
endPos
);
static
TSKEY
extractFirstTraverseKey
(
STableCheckInfo
*
pCheckInfo
,
int32_t
order
,
int32_t
update
);
static
int32_t
handleDataMergeIfNeeded
(
STsdbQueryHandle
*
pQueryHandle
,
SBlock
*
pBlock
,
STableCheckInfo
*
pCheckInfo
){
SQueryFilePos
*
cur
=
&
pQueryHandle
->
cur
;
...
...
@@ -1244,7 +1243,6 @@ static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SBlock* p
int32_t
code
=
TSDB_CODE_SUCCESS
;
/*bool hasData = */
initTableMemIterator
(
pQueryHandle
,
pCheckInfo
);
assert
(
cur
->
pos
>=
0
&&
cur
->
pos
<=
binfo
.
rows
);
key
=
extractFirstTraverseKey
(
pCheckInfo
,
pQueryHandle
->
order
,
pCfg
->
update
);
...
...
@@ -1255,7 +1253,6 @@ static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SBlock* p
tsdbDebug
(
"%p no data in mem, 0x%"
PRIx64
,
pQueryHandle
,
pQueryHandle
->
qId
);
}
if
((
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
&&
(
key
!=
TSKEY_INITIAL_VAL
&&
key
<=
binfo
.
window
.
ekey
))
||
(
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
&&
(
key
!=
TSKEY_INITIAL_VAL
&&
key
>=
binfo
.
window
.
skey
)))
{
...
...
@@ -2708,6 +2705,7 @@ static bool loadBlockOfActiveTable(STsdbQueryHandle* pQueryHandle) {
}
if
(
exists
)
{
tsdbRetrieveDataBlock
((
TsdbQueryHandleT
*
)
pQueryHandle
,
NULL
);
if
(
pQueryHandle
->
currentLoadExternalRows
&&
pQueryHandle
->
window
.
skey
==
pQueryHandle
->
window
.
ekey
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
0
);
assert
(
*
(
int64_t
*
)
pColInfo
->
pData
==
pQueryHandle
->
window
.
skey
);
...
...
src/vnode/inc/vnodeInt.h
浏览文件 @
aba07934
...
...
@@ -26,6 +26,7 @@ extern "C" {
#include "vnode.h"
extern
int32_t
vDebugFlag
;
extern
int32_t
vNumOfExistedQHandle
;
// current initialized and existed query handle in current dnode
#define vFatal(...) { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", 255, __VA_ARGS__); }}
#define vError(...) { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", 255, __VA_ARGS__); }}
...
...
src/vnode/src/vnodeRead.c
浏览文件 @
aba07934
...
...
@@ -21,6 +21,8 @@
#include "query.h"
#include "vnodeStatus.h"
int32_t
vNumOfExistedQHandle
;
// current initialized and existed query handle in current dnode
static
int32_t
(
*
vnodeProcessReadMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
);
static
int32_t
vnodeProcessQueryMsg
(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
);
static
int32_t
vnodeProcessFetchMsg
(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
);
...
...
@@ -247,7 +249,8 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
if
(
handle
==
NULL
)
{
// failed to register qhandle
pRsp
->
code
=
terrno
;
terrno
=
0
;
vError
(
"vgId:%d, QInfo:0x%"
PRIx64
"-%p register qhandle failed, return to app, code:%s"
,
pVnode
->
vgId
,
qId
,
(
void
*
)
pQInfo
,
vError
(
"vgId:%d, QInfo:0x%"
PRIx64
"-%p register qhandle failed, return to app, code:%s,"
,
pVnode
->
vgId
,
qId
,
(
void
*
)
pQInfo
,
tstrerror
(
pRsp
->
code
));
qDestroyQueryInfo
(
pQInfo
);
// destroy it directly
return
pRsp
->
code
;
...
...
@@ -260,10 +263,12 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
vnodeNotifyCurrentQhandle
(
pRead
->
rpcHandle
,
qId
,
*
handle
,
pVnode
->
vgId
)
!=
TSDB_CODE_SUCCESS
)
{
vError
(
"vgId:%d, QInfo:0x%"
PRIx64
"-%p, query discarded since link is broken, %p"
,
pVnode
->
vgId
,
qId
,
*
handle
,
pRead
->
rpcHandle
);
pRsp
->
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
return
pRsp
->
code
;
}
}
else
{
assert
(
pQInfo
==
NULL
);
}
...
...
@@ -277,6 +282,9 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
return
pRsp
->
code
;
}
}
int32_t
remain
=
atomic_add_fetch_32
(
&
vNumOfExistedQHandle
,
1
);
vTrace
(
"vgId:%d, new qhandle created, total qhandle:%d"
,
pVnode
->
vgId
,
remain
);
}
else
{
assert
(
pCont
!=
NULL
);
void
**
qhandle
=
(
void
**
)
pRead
->
qhandle
;
...
...
@@ -318,8 +326,14 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
// NOTE: if the qhandle is not put into vread queue or query is completed, free the qhandle.
// If the building of result is not required, simply free it. Otherwise, mandatorily free the qhandle
if
(
freehandle
||
(
!
buildRes
))
{
if
(
freehandle
)
{
int32_t
remain
=
atomic_sub_fetch_32
(
&
vNumOfExistedQHandle
,
1
);
vTrace
(
"vgId:%d, QInfo:%p, start to free qhandle, remain qhandle:%d"
,
pVnode
->
vgId
,
*
qhandle
,
remain
);
}
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
qhandle
,
freehandle
);
}
}
}
...
...
@@ -357,7 +371,10 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
// kill current query and free corresponding resources.
if
(
pRetrieve
->
free
==
1
)
{
vWarn
(
"vgId:%d, QInfo:%"
PRIx64
"-%p, retrieve msg received to kill query and free qhandle"
,
pVnode
->
vgId
,
pRetrieve
->
qId
,
*
handle
);
int32_t
remain
=
atomic_sub_fetch_32
(
&
vNumOfExistedQHandle
,
1
);
vWarn
(
"vgId:%d, QInfo:%"
PRIx64
"-%p, retrieve msg received to kill query and free qhandle, remain qhandle:%d"
,
pVnode
->
vgId
,
pRetrieve
->
qId
,
*
handle
,
remain
);
qKillQuery
(
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
...
...
@@ -368,7 +385,10 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
// register the qhandle to connect to quit query immediate if connection is broken
if
(
vnodeNotifyCurrentQhandle
(
pRead
->
rpcHandle
,
pRetrieve
->
qId
,
*
handle
,
pVnode
->
vgId
)
!=
TSDB_CODE_SUCCESS
)
{
vError
(
"vgId:%d, QInfo:%"
PRIu64
"-%p, retrieve discarded since link is broken, conn:%p"
,
pVnode
->
vgId
,
pRetrieve
->
qhandle
,
*
handle
,
pRead
->
rpcHandle
);
int32_t
remain
=
atomic_sub_fetch_32
(
&
vNumOfExistedQHandle
,
1
);
vError
(
"vgId:%d, QInfo:%"
PRIu64
"-%p, retrieve discarded since link is broken, conn:%p, remain qhandle:%d"
,
pVnode
->
vgId
,
pRetrieve
->
qhandle
,
*
handle
,
pRead
->
rpcHandle
,
remain
);
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
qKillQuery
(
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
...
...
@@ -390,7 +410,6 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
if
(
!
tsRetrieveBlockingModel
)
{
if
(
!
buildRes
)
{
assert
(
pRead
->
rpcHandle
!=
NULL
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
false
);
return
TSDB_CODE_QRY_NOT_READY
;
}
...
...
@@ -403,6 +422,8 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
// If qhandle is not added into vread queue, the query should be completed already or paused with error.
// Here free qhandle immediately
if
(
freeHandle
)
{
int32_t
remain
=
atomic_sub_fetch_32
(
&
vNumOfExistedQHandle
,
1
);
vTrace
(
"vgId:%d, QInfo:%p, start to free qhandle, remain qhandle:%d"
,
pVnode
->
vgId
,
*
handle
,
remain
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录