Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
be1791e4
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
be1791e4
编写于
6月 16, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
6月 16, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2302 from taosdata/hotfix/fixbug-query
fix bug revealed by coverity
上级
eee0a9c6
8a6eab00
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
95 addition
and
89 deletion
+95
-89
src/client/tests/timeParseTest.cpp
src/client/tests/timeParseTest.cpp
+37
-37
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+4
-2
src/query/src/qast.c
src/query/src/qast.c
+6
-3
src/query/src/qextbuffer.c
src/query/src/qextbuffer.c
+2
-0
src/query/src/qparserImpl.c
src/query/src/qparserImpl.c
+2
-7
src/query/src/qpercentile.c
src/query/src/qpercentile.c
+3
-3
src/query/src/qresultBuf.c
src/query/src/qresultBuf.c
+7
-3
src/query/src/qtsbuf.c
src/query/src/qtsbuf.c
+1
-1
src/query/src/tvariant.c
src/query/src/tvariant.c
+1
-1
src/query/tests/unitTest.cpp
src/query/tests/unitTest.cpp
+32
-32
未找到文件。
src/client/tests/timeParseTest.cpp
浏览文件 @
be1791e4
...
...
@@ -24,19 +24,19 @@ TEST(testCase, parse_time) {
int64_t
time
=
0
,
time1
=
0
;
taosParseTime
(
t1
,
&
time
,
strlen
(
t1
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t1
,
&
time
,
strlen
(
t1
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
1514739661952
);
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
timezone
*
MILLISECOND_PER_SECOND
);
char
t2
[]
=
"2018-1-1T1:1:1.952Z"
;
taosParseTime
(
t2
,
&
time
,
strlen
(
t2
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t2
,
&
time
,
strlen
(
t2
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
1514739661952
+
28800000
);
char
t3
[]
=
"2018-1-1 1:01:01.952"
;
taosParseTime
(
t3
,
&
time
,
strlen
(
t3
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t3
,
&
time
,
strlen
(
t3
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
1514739661952
);
char
t4
[]
=
"2018-1-1 1:01:01.9"
;
...
...
@@ -45,122 +45,122 @@ TEST(testCase, parse_time) {
char
t7
[]
=
"2018-01-01 01:01:01.9"
;
char
t8
[]
=
"2018-01-01 01:01:01.9007865"
;
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t5
,
&
time1
,
strlen
(
t5
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t5
,
&
time1
,
strlen
(
t5
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t6
,
&
time1
,
strlen
(
t6
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t6
,
&
time1
,
strlen
(
t6
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t7
,
&
time1
,
strlen
(
t7
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t7
,
&
time1
,
strlen
(
t7
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
taosParseTime
(
t5
,
&
time
,
strlen
(
t5
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t8
,
&
time1
,
strlen
(
t8
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t5
,
&
time
,
strlen
(
t5
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t8
,
&
time1
,
strlen
(
t8
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t9
[]
=
"2017-4-3 1:1:2.980"
;
char
t10
[]
=
"2017-4-3T2:1:2.98+9:00"
;
taosParseTime
(
t9
,
&
time
,
strlen
(
t9
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t10
,
&
time1
,
strlen
(
t10
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t9
,
&
time
,
strlen
(
t9
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t10
,
&
time1
,
strlen
(
t10
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t11
[]
=
"2017-4-3T2:1:2.98+09:00"
;
taosParseTime
(
t11
,
&
time
,
strlen
(
t11
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t10
,
&
time1
,
strlen
(
t10
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t11
,
&
time
,
strlen
(
t11
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t10
,
&
time1
,
strlen
(
t10
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t12
[]
=
"2017-4-3T2:1:2.98+0900"
;
taosParseTime
(
t11
,
&
time
,
strlen
(
t11
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t12
,
&
time1
,
strlen
(
t12
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t11
,
&
time
,
strlen
(
t11
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t12
,
&
time1
,
strlen
(
t12
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
taos_options
(
TSDB_OPTION_TIMEZONE
,
"UTC"
);
deltaToUtcInitOnce
();
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
0
);
taos_options
(
TSDB_OPTION_TIMEZONE
,
"Asia/Shanghai"
);
deltaToUtcInitOnce
();
char
t14
[]
=
"1970-1-1T0:0:0Z"
;
taosParseTime
(
t14
,
&
time
,
strlen
(
t14
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t14
,
&
time
,
strlen
(
t14
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
0
);
char
t40
[]
=
"1970-1-1 0:0:0.999999999"
;
taosParseTime
(
t40
,
&
time
,
strlen
(
t40
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t40
,
&
time
,
strlen
(
t40
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
999
+
timezone
*
MILLISECOND_PER_SECOND
);
char
t41
[]
=
"1997-1-1 0:0:0.999999999"
;
taosParseTime
(
t41
,
&
time
,
strlen
(
t41
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t41
,
&
time
,
strlen
(
t41
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
852048000999
);
int64_t
k
=
timezone
;
char
t42
[]
=
"1997-1-1T0:0:0.999999999Z"
;
taosParseTime
(
t42
,
&
time
,
strlen
(
t42
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t42
,
&
time
,
strlen
(
t42
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
852048000999
-
timezone
*
MILLISECOND_PER_SECOND
);
////////////////////////////////////////////////////////////////////
// illegal timestamp format
char
t15
[]
=
"2017-12-33 0:0:0"
;
EXPECT_EQ
(
taosParseTime
(
t15
,
&
time
,
strlen
(
t15
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t15
,
&
time
,
strlen
(
t15
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t16
[]
=
"2017-12-31 99:0:0"
;
EXPECT_EQ
(
taosParseTime
(
t16
,
&
time
,
strlen
(
t16
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t16
,
&
time
,
strlen
(
t16
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t17
[]
=
"2017-12-31T9:0:0"
;
EXPECT_EQ
(
taosParseTime
(
t17
,
&
time
,
strlen
(
t17
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t17
,
&
time
,
strlen
(
t17
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t18
[]
=
"2017-12-31T9:0:0.Z"
;
EXPECT_EQ
(
taosParseTime
(
t18
,
&
time
,
strlen
(
t18
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t18
,
&
time
,
strlen
(
t18
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t19
[]
=
"2017-12-31 9:0:0.-1"
;
EXPECT_EQ
(
taosParseTime
(
t19
,
&
time
,
strlen
(
t19
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t19
,
&
time
,
strlen
(
t19
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t20
[]
=
"2017-12-31 9:0:0.1+12:99"
;
EXPECT_EQ
(
taosParseTime
(
t20
,
&
time
,
strlen
(
t20
),
TSDB_TIME_PRECISION_MILLI
),
0
);
EXPECT_EQ
(
taosParseTime
(
t20
,
&
time
,
strlen
(
t20
),
TSDB_TIME_PRECISION_MILLI
,
0
),
0
);
EXPECT_EQ
(
time
,
1514682000100
);
char
t21
[]
=
"2017-12-31T9:0:0.1+12:99"
;
EXPECT_EQ
(
taosParseTime
(
t21
,
&
time
,
strlen
(
t21
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t21
,
&
time
,
strlen
(
t21
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t22
[]
=
"2017-12-31 9:0:0.1+13:1"
;
EXPECT_EQ
(
taosParseTime
(
t22
,
&
time
,
strlen
(
t22
),
TSDB_TIME_PRECISION_MILLI
),
0
);
EXPECT_EQ
(
taosParseTime
(
t22
,
&
time
,
strlen
(
t22
),
TSDB_TIME_PRECISION_MILLI
,
0
),
0
);
char
t23
[]
=
"2017-12-31T9:0:0.1+13:1"
;
EXPECT_EQ
(
taosParseTime
(
t23
,
&
time
,
strlen
(
t23
),
TSDB_TIME_PRECISION_MILLI
),
0
);
EXPECT_EQ
(
taosParseTime
(
t23
,
&
time
,
strlen
(
t23
),
TSDB_TIME_PRECISION_MILLI
,
0
),
0
);
//======================== add some case ============================//
char
b1
[]
=
"9999-12-31 23:59:59.999"
;
taosParseTime
(
b1
,
&
time
,
strlen
(
b1
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
b1
,
&
time
,
strlen
(
b1
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
253402271999999
);
char
b2
[]
=
"2020-01-01 01:01:01.321"
;
taosParseTime
(
b2
,
&
time
,
strlen
(
b2
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
b2
,
&
time
,
strlen
(
b2
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
1577811661321
);
taos_options
(
TSDB_OPTION_TIMEZONE
,
"America/New_York"
);
deltaToUtcInitOnce
();
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
18000
*
MILLISECOND_PER_SECOND
);
taos_options
(
TSDB_OPTION_TIMEZONE
,
"Asia/Tokyo"
);
deltaToUtcInitOnce
();
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
-
32400
*
MILLISECOND_PER_SECOND
);
taos_options
(
TSDB_OPTION_TIMEZONE
,
"Asia/Shanghai"
);
deltaToUtcInitOnce
();
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
-
28800
*
MILLISECOND_PER_SECOND
);
}
...
...
src/query/src/qExecutor.c
浏览文件 @
be1791e4
...
...
@@ -847,7 +847,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
}
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pQuery
->
order
.
order
);
if
(
isIntervalQuery
(
pQuery
))
{
if
(
isIntervalQuery
(
pQuery
)
&&
tsCols
!=
NULL
)
{
int32_t
offset
=
GET_COL_DATA_POS
(
pQuery
,
0
,
step
);
TSKEY
ts
=
tsCols
[
offset
];
...
...
@@ -4263,7 +4263,8 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
assert
(
taosArrayGetSize
(
s
)
>=
1
);
setTagVal
(
pRuntimeEnv
,
(
STableId
*
)
taosArrayGet
(
s
,
0
),
pQInfo
->
tsdb
);
taosArrayDestroy
(
s
);
if
(
isFirstLastRowQuery
(
pQuery
))
{
assert
(
taosArrayGetSize
(
s
)
==
1
);
}
...
...
@@ -4328,6 +4329,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
SWindowResInfo
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
// no results generated for current group, continue to try the next group
taosArrayDestroy
(
s
);
if
(
pWindowResInfo
->
size
<=
0
)
{
continue
;
}
...
...
src/query/src/qast.c
浏览文件 @
be1791e4
...
...
@@ -496,7 +496,6 @@ static int32_t setQueryCond(tQueryInfo *queryColInfo, SQueryCond* pCond) {
printf
(
"relation is like
\n
"
);
assert
(
0
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -511,7 +510,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
if
(
cond
.
start
!=
NULL
)
{
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
char
*
)
cond
.
start
->
v
,
pSkipList
->
keyInfo
.
type
,
TSDB_ORDER_ASC
);
}
else
{
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
char
*
)
cond
.
end
->
v
,
pSkipList
->
keyInfo
.
type
,
TSDB_ORDER_DESC
);
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
char
*
)
(
cond
.
end
?
cond
.
end
->
v
:
NULL
)
,
pSkipList
->
keyInfo
.
type
,
TSDB_ORDER_DESC
);
}
if
(
cond
.
start
!=
NULL
)
{
...
...
@@ -601,6 +600,9 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
}
}
}
free
(
cond
.
start
);
free
(
cond
.
end
);
tSkipListDestroyIter
(
iter
);
}
int32_t
merge
(
SArray
*
pLeft
,
SArray
*
pRight
,
SArray
*
pFinalRes
)
{
...
...
@@ -748,6 +750,7 @@ static void exprTreeTraverseImpl(tExprNode *pExpr, SArray *pResult, SExprTravers
}
taosArrayCopy
(
pResult
,
array
);
taosArrayDestroy
(
array
);
}
static
void
tSQLBinaryTraverseOnSkipList
(
tExprNode
*
pExpr
,
SArray
*
pResult
,
SSkipList
*
pSkipList
,
SExprTraverseSupp
*
param
)
{
...
...
@@ -1182,4 +1185,4 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
CLEANUP_EXECUTE_TO
(
anchor
,
false
);
return
expr
;
}
\ No newline at end of file
}
src/query/src/qextbuffer.c
浏览文件 @
be1791e4
...
...
@@ -896,6 +896,7 @@ void tColModelDisplay(SColumnModel *pModel, void *pData, int32_t numOfRows, int3
char
buf
[
4096
]
=
{
0
};
taosUcs4ToMbs
(
val
,
pModel
->
pFields
[
j
].
field
.
bytes
,
buf
);
printf
(
"%s
\t
"
,
buf
);
break
;
}
case
TSDB_DATA_TYPE_BINARY
:
{
printBinaryData
(
val
,
pModel
->
pFields
[
j
].
field
.
bytes
);
...
...
@@ -947,6 +948,7 @@ void tColModelDisplayEx(SColumnModel *pModel, void *pData, int32_t numOfRows, in
char
buf
[
128
]
=
{
0
};
taosUcs4ToMbs
(
val
,
pModel
->
pFields
[
j
].
field
.
bytes
,
buf
);
printf
(
"%s
\t
"
,
buf
);
break
;
}
case
TSDB_DATA_TYPE_BINARY
:
{
printBinaryDataEx
(
val
,
pModel
->
pFields
[
j
].
field
.
bytes
,
&
param
[
j
]);
...
...
src/query/src/qparserImpl.c
浏览文件 @
be1791e4
...
...
@@ -775,19 +775,14 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
while
(
nParam
--
>
0
)
{
SSQLToken
*
pToken
=
va_arg
(
va
,
SSQLToken
*
);
(
void
)
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
pInfo
->
pDCLInfo
=
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
}
va_end
(
va
);
}
void
setDropDBTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SSQLToken
*
existsCheck
)
{
pInfo
->
type
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
}
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
pInfo
->
pDCLInfo
=
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
pInfo
->
pDCLInfo
->
existsCheck
=
(
existsCheck
->
n
==
1
);
}
...
...
src/query/src/qpercentile.c
浏览文件 @
be1791e4
...
...
@@ -241,7 +241,6 @@ void tBucketDoubleHash(tMemBucket *pBucket, void *value, int16_t *segIdx, int16_
tMemBucket
*
tMemBucketCreate
(
int32_t
totalSlots
,
int32_t
nBufferSize
,
int16_t
nElemSize
,
int16_t
dataType
,
tOrderDescriptor
*
pDesc
)
{
tMemBucket
*
pBucket
=
(
tMemBucket
*
)
malloc
(
sizeof
(
tMemBucket
));
pBucket
->
nTotalSlots
=
totalSlots
;
pBucket
->
nSlotsOfSeg
=
1
<<
6
;
// 64 Segments, 16 slots each seg.
pBucket
->
dataType
=
dataType
;
...
...
@@ -258,6 +257,7 @@ tMemBucket *tMemBucketCreate(int32_t totalSlots, int32_t nBufferSize, int16_t nE
pBucket
->
numOfTotalPages
=
pBucket
->
nTotalBufferSize
/
pBucket
->
pageSize
;
pBucket
->
numOfAvailPages
=
pBucket
->
numOfTotalPages
;
pBucket
->
pSegs
=
NULL
;
pBucket
->
pOrderDesc
=
pDesc
;
switch
(
pBucket
->
dataType
)
{
...
...
@@ -315,7 +315,7 @@ tMemBucket *tMemBucketCreate(int32_t totalSlots, int32_t nBufferSize, int16_t nE
pBucket
->
pSegs
[
i
].
pBoundingEntries
=
NULL
;
}
uTrace
(
"MemBucket:%p,created,buffer size:%d,elem size:%d"
,
pBucket
,
pBucket
->
numOfTotalPages
*
DEFAULT_PAGE_SIZE
,
uTrace
(
"MemBucket:%p,created,buffer size:%
l
d,elem size:%d"
,
pBucket
,
pBucket
->
numOfTotalPages
*
DEFAULT_PAGE_SIZE
,
pBucket
->
nElemSize
);
return
pBucket
;
...
...
@@ -751,7 +751,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
char
*
thisVal
=
buffer
->
data
+
pMemBucket
->
nElemSize
*
currentIdx
;
char
*
nextVal
=
thisVal
+
pMemBucket
->
nElemSize
;
double
td
,
nd
;
double
td
=
1
.
0
,
nd
=
1
.
0
;
switch
(
pMemBucket
->
dataType
)
{
case
TSDB_DATA_TYPE_SMALLINT
:
{
td
=
*
(
int16_t
*
)
thisVal
;
...
...
src/query/src/qresultBuf.c
浏览文件 @
be1791e4
...
...
@@ -6,7 +6,12 @@
#include "queryLog.h"
int32_t
createDiskbasedResultBuffer
(
SDiskbasedResultBuf
**
pResultBuf
,
int32_t
size
,
int32_t
rowSize
,
void
*
handle
)
{
SDiskbasedResultBuf
*
pResBuf
=
calloc
(
1
,
sizeof
(
SDiskbasedResultBuf
));
*
pResultBuf
=
calloc
(
1
,
sizeof
(
SDiskbasedResultBuf
));
SDiskbasedResultBuf
*
pResBuf
=
*
pResultBuf
;
if
(
pResBuf
==
NULL
)
{
return
TSDB_CODE_COM_OUT_OF_MEMORY
;
}
pResBuf
->
numOfRowsPerPage
=
(
DEFAULT_INTERN_BUF_PAGE_SIZE
-
sizeof
(
tFilePage
))
/
rowSize
;
pResBuf
->
numOfPages
=
size
;
...
...
@@ -46,7 +51,6 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t si
qTrace
(
"QInfo:%p create tmp file for output result, %s, %"
PRId64
"bytes"
,
handle
,
pResBuf
->
path
,
pResBuf
->
totalBufSize
);
*
pResultBuf
=
pResBuf
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -210,7 +214,7 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf, void* handle) {
}
int32_t
getLastPageId
(
SIDList
*
pList
)
{
if
(
pList
==
NULL
&&
pList
->
size
<=
0
)
{
if
(
pList
==
NULL
||
pList
->
size
<=
0
)
{
return
-
1
;
}
...
...
src/query/src/qtsbuf.c
浏览文件 @
be1791e4
...
...
@@ -533,7 +533,7 @@ STSVnodeBlockInfo* tsBufGetVnodeBlockInfo(STSBuf* pTSBuf, int32_t vnodeId) {
}
int32_t
STSBufUpdateHeader
(
STSBuf
*
pTSBuf
,
STSBufFileHeader
*
pHeader
)
{
if
((
pTSBuf
->
f
==
NULL
)
||
pHeader
==
NULL
||
pHeader
->
numOfVnode
<
0
||
pHeader
->
magic
!=
TS_COMP_FILE_MAGIC
)
{
if
((
pTSBuf
->
f
==
NULL
)
||
pHeader
==
NULL
||
pHeader
->
numOfVnode
==
0
||
pHeader
->
magic
!=
TS_COMP_FILE_MAGIC
)
{
return
-
1
;
}
...
...
src/query/src/tvariant.c
浏览文件 @
be1791e4
...
...
@@ -357,7 +357,7 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
size_t
newSize
=
pVariant
->
nLen
*
TSDB_NCHAR_SIZE
;
if
(
pBuf
!=
NULL
)
{
if
(
newSize
>
INITIAL_ALLOC_SIZE
)
{
if
(
newSize
>
=
INITIAL_ALLOC_SIZE
)
{
pBuf
=
realloc
(
pBuf
,
newSize
+
1
);
}
...
...
src/query/tests/unitTest.cpp
浏览文件 @
be1791e4
...
...
@@ -334,19 +334,19 @@ TEST(testCase, parse_time) {
int64_t
time
=
0
,
time1
=
0
;
taosParseTime
(
t1
,
&
time
,
strlen
(
t1
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t1
,
&
time
,
strlen
(
t1
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
1514739661952
);
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
timezone
*
MILLISECOND_PER_SECOND
);
char
t2
[]
=
"2018-1-1T1:1:1.952Z"
;
taosParseTime
(
t2
,
&
time
,
strlen
(
t2
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t2
,
&
time
,
strlen
(
t2
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
1514739661952
+
28800000
);
char
t3
[]
=
"2018-1-1 1:01:01.952"
;
taosParseTime
(
t3
,
&
time
,
strlen
(
t3
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t3
,
&
time
,
strlen
(
t3
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
1514739661952
);
char
t4
[]
=
"2018-1-1 1:01:01.9"
;
...
...
@@ -355,89 +355,89 @@ TEST(testCase, parse_time) {
char
t7
[]
=
"2018-01-01 01:01:01.9"
;
char
t8
[]
=
"2018-01-01 01:01:01.9007865"
;
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t5
,
&
time1
,
strlen
(
t5
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t5
,
&
time1
,
strlen
(
t5
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t6
,
&
time1
,
strlen
(
t6
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t6
,
&
time1
,
strlen
(
t6
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t7
,
&
time1
,
strlen
(
t7
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t7
,
&
time1
,
strlen
(
t7
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
taosParseTime
(
t5
,
&
time
,
strlen
(
t5
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t8
,
&
time1
,
strlen
(
t8
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t5
,
&
time
,
strlen
(
t5
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t8
,
&
time1
,
strlen
(
t8
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t9
[]
=
"2017-4-3 1:1:2.980"
;
char
t10
[]
=
"2017-4-3T2:1:2.98+9:00"
;
taosParseTime
(
t9
,
&
time
,
strlen
(
t9
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t10
,
&
time1
,
strlen
(
t10
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t9
,
&
time
,
strlen
(
t9
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t10
,
&
time1
,
strlen
(
t10
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t11
[]
=
"2017-4-3T2:1:2.98+09:00"
;
taosParseTime
(
t11
,
&
time
,
strlen
(
t11
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t10
,
&
time1
,
strlen
(
t10
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t11
,
&
time
,
strlen
(
t11
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t10
,
&
time1
,
strlen
(
t10
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t12
[]
=
"2017-4-3T2:1:2.98+0900"
;
taosParseTime
(
t11
,
&
time
,
strlen
(
t11
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t12
,
&
time1
,
strlen
(
t12
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t11
,
&
time
,
strlen
(
t11
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t12
,
&
time1
,
strlen
(
t12
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
taos_options
(
TSDB_OPTION_TIMEZONE
,
"UTC"
);
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t13
,
&
time
,
strlen
(
t13
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
0
);
taos_options
(
TSDB_OPTION_TIMEZONE
,
"Asia/Shanghai"
);
char
t14
[]
=
"1970-1-1T0:0:0Z"
;
taosParseTime
(
t14
,
&
time
,
strlen
(
t14
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t14
,
&
time
,
strlen
(
t14
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
0
);
char
t40
[]
=
"1970-1-1 0:0:0.999999999"
;
taosParseTime
(
t40
,
&
time
,
strlen
(
t40
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t40
,
&
time
,
strlen
(
t40
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
999
+
timezone
*
MILLISECOND_PER_SECOND
);
char
t41
[]
=
"1997-1-1 0:0:0.999999999"
;
taosParseTime
(
t41
,
&
time
,
strlen
(
t41
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t41
,
&
time
,
strlen
(
t41
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
852048000999
);
int64_t
k
=
timezone
;
char
t42
[]
=
"1997-1-1T0:0:0.999999999Z"
;
taosParseTime
(
t42
,
&
time
,
strlen
(
t42
),
TSDB_TIME_PRECISION_MILLI
);
taosParseTime
(
t42
,
&
time
,
strlen
(
t42
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
852048000999
-
timezone
*
MILLISECOND_PER_SECOND
);
////////////////////////////////////////////////////////////////////
// illegal timestamp format
char
t15
[]
=
"2017-12-33 0:0:0"
;
EXPECT_EQ
(
taosParseTime
(
t15
,
&
time
,
strlen
(
t15
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t15
,
&
time
,
strlen
(
t15
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t16
[]
=
"2017-12-31 99:0:0"
;
EXPECT_EQ
(
taosParseTime
(
t16
,
&
time
,
strlen
(
t16
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t16
,
&
time
,
strlen
(
t16
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t17
[]
=
"2017-12-31T9:0:0"
;
EXPECT_EQ
(
taosParseTime
(
t17
,
&
time
,
strlen
(
t17
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t17
,
&
time
,
strlen
(
t17
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t18
[]
=
"2017-12-31T9:0:0.Z"
;
EXPECT_EQ
(
taosParseTime
(
t18
,
&
time
,
strlen
(
t18
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t18
,
&
time
,
strlen
(
t18
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t19
[]
=
"2017-12-31 9:0:0.-1"
;
EXPECT_EQ
(
taosParseTime
(
t19
,
&
time
,
strlen
(
t19
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t19
,
&
time
,
strlen
(
t19
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t20
[]
=
"2017-12-31 9:0:0.1+12:99"
;
EXPECT_EQ
(
taosParseTime
(
t20
,
&
time
,
strlen
(
t20
),
TSDB_TIME_PRECISION_MILLI
),
0
);
EXPECT_EQ
(
taosParseTime
(
t20
,
&
time
,
strlen
(
t20
),
TSDB_TIME_PRECISION_MILLI
,
0
),
0
);
EXPECT_EQ
(
time
,
1514682000100
);
char
t21
[]
=
"2017-12-31T9:0:0.1+12:99"
;
EXPECT_EQ
(
taosParseTime
(
t21
,
&
time
,
strlen
(
t21
),
TSDB_TIME_PRECISION_MILLI
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t21
,
&
time
,
strlen
(
t21
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t22
[]
=
"2017-12-31 9:0:0.1+13:1"
;
EXPECT_EQ
(
taosParseTime
(
t22
,
&
time
,
strlen
(
t22
),
TSDB_TIME_PRECISION_MILLI
),
0
);
EXPECT_EQ
(
taosParseTime
(
t22
,
&
time
,
strlen
(
t22
),
TSDB_TIME_PRECISION_MILLI
,
0
),
0
);
char
t23
[]
=
"2017-12-31T9:0:0.1+13:1"
;
EXPECT_EQ
(
taosParseTime
(
t23
,
&
time
,
strlen
(
t23
),
TSDB_TIME_PRECISION_MILLI
),
0
);
EXPECT_EQ
(
taosParseTime
(
t23
,
&
time
,
strlen
(
t23
),
TSDB_TIME_PRECISION_MILLI
,
0
),
0
);
}
TEST
(
testCase
,
tvariant_convert
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录