Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9b073353
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9b073353
编写于
6月 07, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bug found by regression test.
上级
678cc06f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
121 deletion
+21
-121
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+19
-119
tests/script/general/parser/last_cache.sim
tests/script/general/parser/last_cache.sim
+1
-1
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
9b073353
...
@@ -2161,7 +2161,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
...
@@ -2161,7 +2161,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
case
TSDB_FUNC_STDDEV
:
case
TSDB_FUNC_STDDEV
:
case
TSDB_FUNC_LEASTSQR
:
{
case
TSDB_FUNC_LEASTSQR
:
{
// 1. valid the number of parameters
// 1. valid the number of parameters
int32_t
numOfParams
=
taosArrayGetSize
(
pItem
->
pNode
->
pParam
);
int32_t
numOfParams
=
(
pItem
->
pNode
->
pParam
==
NULL
)
?
0
:
taosArrayGetSize
(
pItem
->
pNode
->
pParam
);
if
(
pItem
->
pNode
->
pParam
==
NULL
||
if
(
pItem
->
pNode
->
pParam
==
NULL
||
(
functionId
!=
TSDB_FUNC_LEASTSQR
&&
functionId
!=
TSDB_FUNC_DERIVATIVE
&&
numOfParams
!=
1
)
||
(
functionId
!=
TSDB_FUNC_LEASTSQR
&&
functionId
!=
TSDB_FUNC_DERIVATIVE
&&
numOfParams
!=
1
)
||
((
functionId
==
TSDB_FUNC_LEASTSQR
||
functionId
==
TSDB_FUNC_DERIVATIVE
)
&&
numOfParams
!=
3
))
{
((
functionId
==
TSDB_FUNC_LEASTSQR
||
functionId
==
TSDB_FUNC_DERIVATIVE
)
&&
numOfParams
!=
3
))
{
...
...
src/query/src/qAggMain.c
浏览文件 @
9b073353
...
@@ -234,7 +234,6 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
...
@@ -234,7 +234,6 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
//TODO twa function definit error.
if
(
isSuperTable
)
{
if
(
isSuperTable
)
{
if
(
functionId
==
TSDB_FUNC_MIN
||
functionId
==
TSDB_FUNC_MAX
)
{
if
(
functionId
==
TSDB_FUNC_MIN
||
functionId
==
TSDB_FUNC_MAX
)
{
*
type
=
TSDB_DATA_TYPE_BINARY
;
*
type
=
TSDB_DATA_TYPE_BINARY
;
...
@@ -3420,18 +3419,6 @@ static bool diff_function_setup(SQLFunctionCtx *pCtx) {
...
@@ -3420,18 +3419,6 @@ static bool diff_function_setup(SQLFunctionCtx *pCtx) {
return
false
;
return
false
;
}
}
#define DIFF_IMPL(ctx, d, type) \
do { \
if ((ctx)->param[1].nType == INITIAL_VALUE_NOT_ASSIGNED) { \
(ctx)->param[1].nType = (ctx)->inputType; \
*(type *)&(ctx)->param[1].i64 = *(type *)(d); \
} else { \
*(type *)(ctx)->pOutput = *(type *)(d) - (*(type *)(&(ctx)->param[1].i64)); \
*(type *)(&(ctx)->param[1].i64) = *(type *)(d); \
*(int64_t *)(ctx)->ptsOutputBuf = GET_TS_DATA(ctx, index); \
} \
} while (0);
static
bool
deriv_function_setup
(
SQLFunctionCtx
*
pCtx
)
{
static
bool
deriv_function_setup
(
SQLFunctionCtx
*
pCtx
)
{
if
(
!
function_setup
(
pCtx
))
{
if
(
!
function_setup
(
pCtx
))
{
return
false
;
return
false
;
...
@@ -3480,7 +3467,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
...
@@ -3480,7 +3467,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pOutput
+=
1
;
pTimestamp
+=
1
;
pTimestamp
+=
1
;
}
}
...
@@ -3508,7 +3494,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
...
@@ -3508,7 +3494,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pOutput
+=
1
;
pTimestamp
+=
1
;
pTimestamp
+=
1
;
}
}
...
@@ -3535,7 +3520,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
...
@@ -3535,7 +3520,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pOutput
+=
1
;
pTimestamp
+=
1
;
pTimestamp
+=
1
;
}
}
...
@@ -3563,7 +3547,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
...
@@ -3563,7 +3547,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pOutput
+=
1
;
pTimestamp
+=
1
;
pTimestamp
+=
1
;
}
}
...
@@ -3590,7 +3573,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
...
@@ -3590,7 +3573,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pOutput
+=
1
;
pTimestamp
+=
1
;
pTimestamp
+=
1
;
}
}
...
@@ -3646,18 +3628,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
...
@@ -3646,18 +3628,6 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
}
}
}
}
#define DIFF_IMPL(ctx, d, type) \
do { \
if ((ctx)->param[1].nType == INITIAL_VALUE_NOT_ASSIGNED) { \
(ctx)->param[1].nType = (ctx)->inputType; \
*(type *)&(ctx)->param[1].i64 = *(type *)(d); \
} else { \
*(type *)(ctx)->pOutput = *(type *)(d) - (*(type *)(&(ctx)->param[1].i64)); \
*(type *)(&(ctx)->param[1].i64) = *(type *)(d); \
*(int64_t *)(ctx)->ptsOutputBuf = GET_TS_DATA(ctx, index); \
} \
} while (0);
#define DIFF_IMPL(ctx, d, type) \
#define DIFF_IMPL(ctx, d, type) \
do { \
do { \
if ((ctx)->param[1].nType == INITIAL_VALUE_NOT_ASSIGNED) { \
if ((ctx)->param[1].nType == INITIAL_VALUE_NOT_ASSIGNED) { \
...
@@ -3693,20 +3663,10 @@ static void diff_function(SQLFunctionCtx *pCtx) {
...
@@ -3693,20 +3663,10 @@ static void diff_function(SQLFunctionCtx *pCtx) {
continue
;
continue
;
}
}
if
(
pCtx
->
param
[
1
].
nType
==
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
pCtx
->
param
[
1
].
i64
=
pData
[
i
];
pCtx
->
param
[
1
].
nType
=
pCtx
->
inputType
;
}
else
if
((
i
==
0
&&
pCtx
->
order
==
TSDB_ORDER_ASC
)
||
(
i
==
pCtx
->
size
-
1
&&
pCtx
->
order
==
TSDB_ORDER_DESC
))
{
*
pOutput
=
(
int32_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pTimestamp
+=
1
;
}
else
{
*
pOutput
=
(
int32_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
// direct previous may be null
*
pOutput
=
(
int32_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
// direct previous may be null
*
pTimestamp
=
tsList
[
i
];
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pOutput
+=
1
;
pTimestamp
+=
1
;
pTimestamp
+=
1
;
}
}
...
@@ -3725,20 +3685,10 @@ static void diff_function(SQLFunctionCtx *pCtx) {
...
@@ -3725,20 +3685,10 @@ static void diff_function(SQLFunctionCtx *pCtx) {
continue
;
continue
;
}
}
if
(
pCtx
->
param
[
1
].
nType
==
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
pCtx
->
param
[
1
].
i64
=
pData
[
i
];
*
pOutput
=
(
int32_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
// direct previous may be null
pCtx
->
param
[
1
].
nType
=
pCtx
->
inputType
;
}
else
if
((
i
==
0
&&
pCtx
->
order
==
TSDB_ORDER_ASC
)
||
(
i
==
pCtx
->
size
-
1
&&
pCtx
->
order
==
TSDB_ORDER_DESC
))
{
*
pOutput
=
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
;
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pTimestamp
+=
1
;
}
else
{
*
pOutput
=
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
;
*
pTimestamp
=
tsList
[
i
];
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pOutput
+=
1
;
pTimestamp
+=
1
;
pTimestamp
+=
1
;
}
}
...
@@ -3757,22 +3707,14 @@ static void diff_function(SQLFunctionCtx *pCtx) {
...
@@ -3757,22 +3707,14 @@ static void diff_function(SQLFunctionCtx *pCtx) {
continue
;
continue
;
}
}
if
(
pCtx
->
param
[
1
].
nType
==
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
pCtx
->
param
[
1
].
dKey
=
pData
[
i
];
*
pOutput
=
(
int32_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
// direct previous may be null
pCtx
->
param
[
1
].
nType
=
pCtx
->
inputType
;
}
else
if
((
i
==
0
&&
pCtx
->
order
==
TSDB_ORDER_ASC
)
||
(
i
==
pCtx
->
size
-
1
&&
pCtx
->
order
==
TSDB_ORDER_DESC
))
{
*
pOutput
=
pData
[
i
]
-
pCtx
->
param
[
1
].
dKey
;
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pTimestamp
+=
1
;
}
else
{
*
pOutput
=
pData
[
i
]
-
pCtx
->
param
[
1
].
dKey
;
*
pTimestamp
=
tsList
[
i
];
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pOutput
+=
1
;
pTimestamp
+=
1
;
pTimestamp
+=
1
;
}
}
pCtx
->
param
[
1
].
dKey
=
pData
[
i
];
pCtx
->
param
[
1
].
i64
=
pData
[
i
];
pCtx
->
param
[
1
].
nType
=
pCtx
->
inputType
;
pCtx
->
param
[
1
].
nType
=
pCtx
->
inputType
;
notNullElems
++
;
notNullElems
++
;
}
}
...
@@ -3787,25 +3729,14 @@ static void diff_function(SQLFunctionCtx *pCtx) {
...
@@ -3787,25 +3729,14 @@ static void diff_function(SQLFunctionCtx *pCtx) {
continue
;
continue
;
}
}
if
(
pCtx
->
param
[
1
].
nType
==
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
pCtx
->
param
[
1
].
dKey
=
pData
[
i
];
*
pOutput
=
(
int32_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
// direct previous may be null
pCtx
->
param
[
1
].
nType
=
pCtx
->
inputType
;
}
else
if
((
i
==
0
&&
pCtx
->
order
==
TSDB_ORDER_ASC
)
||
(
i
==
pCtx
->
size
-
1
&&
pCtx
->
order
==
TSDB_ORDER_DESC
))
{
*
pOutput
=
(
float
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
dKey
);
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pTimestamp
+=
1
;
}
else
{
*
pOutput
=
(
float
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
dKey
);
*
pTimestamp
=
tsList
[
i
];
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pOutput
+=
1
;
pTimestamp
+=
1
;
pTimestamp
+=
1
;
}
}
// keep the last value, the remain may be all null
pCtx
->
param
[
1
].
i64
=
pData
[
i
];
pCtx
->
param
[
1
].
dKey
=
pData
[
i
];
pCtx
->
param
[
1
].
nType
=
pCtx
->
inputType
;
pCtx
->
param
[
1
].
nType
=
pCtx
->
inputType
;
notNullElems
++
;
notNullElems
++
;
}
}
...
@@ -3820,19 +3751,10 @@ static void diff_function(SQLFunctionCtx *pCtx) {
...
@@ -3820,19 +3751,10 @@ static void diff_function(SQLFunctionCtx *pCtx) {
continue
;
continue
;
}
}
if
(
pCtx
->
param
[
1
].
nType
==
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
pCtx
->
param
[
1
].
i64
=
pData
[
i
];
*
pOutput
=
(
int32_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
// direct previous may be null
pCtx
->
param
[
1
].
nType
=
pCtx
->
inputType
;
}
else
if
((
i
==
0
&&
pCtx
->
order
==
TSDB_ORDER_ASC
)
||
(
i
==
pCtx
->
size
-
1
&&
pCtx
->
order
==
TSDB_ORDER_DESC
))
{
*
pOutput
=
(
int16_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pTimestamp
+=
1
;
}
else
{
*
pOutput
=
(
int16_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
*
pTimestamp
=
tsList
[
i
];
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pOutput
+=
1
;
pTimestamp
+=
1
;
pTimestamp
+=
1
;
}
}
...
@@ -3851,20 +3773,10 @@ static void diff_function(SQLFunctionCtx *pCtx) {
...
@@ -3851,20 +3773,10 @@ static void diff_function(SQLFunctionCtx *pCtx) {
continue
;
continue
;
}
}
if
(
pCtx
->
param
[
1
].
nType
==
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
pCtx
->
param
[
1
].
i64
=
pData
[
i
];
*
pOutput
=
(
int32_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
// direct previous may be null
pCtx
->
param
[
1
].
nType
=
pCtx
->
inputType
;
}
else
if
((
i
==
0
&&
pCtx
->
order
==
TSDB_ORDER_ASC
)
||
(
i
==
pCtx
->
size
-
1
&&
pCtx
->
order
==
TSDB_ORDER_DESC
))
{
*
pOutput
=
(
int8_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pTimestamp
+=
1
;
}
else
{
*
pOutput
=
(
int8_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
*
pTimestamp
=
tsList
[
i
];
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pOutput
+=
1
;
pTimestamp
+=
1
;
pTimestamp
+=
1
;
}
}
...
@@ -3892,18 +3804,6 @@ static void diff_function(SQLFunctionCtx *pCtx) {
...
@@ -3892,18 +3804,6 @@ static void diff_function(SQLFunctionCtx *pCtx) {
}
}
}
}
#define DIFF_IMPL(ctx, d, type) \
do { \
if ((ctx)->param[1].nType == INITIAL_VALUE_NOT_ASSIGNED) { \
(ctx)->param[1].nType = (ctx)->inputType; \
*(type *)&(ctx)->param[1].i64 = *(type *)(d); \
} else { \
*(type *)(ctx)->pOutput = *(type *)(d) - (*(type *)(&(ctx)->param[1].i64)); \
*(type *)(&(ctx)->param[1].i64) = *(type *)(d); \
*(int64_t *)(ctx)->ptsOutputBuf = GET_TS_DATA(ctx, index); \
} \
} while (0);
static
void
diff_function_f
(
SQLFunctionCtx
*
pCtx
,
int32_t
index
)
{
static
void
diff_function_f
(
SQLFunctionCtx
*
pCtx
,
int32_t
index
)
{
char
*
pData
=
GET_INPUT_DATA
(
pCtx
,
index
);
char
*
pData
=
GET_INPUT_DATA
(
pCtx
,
index
);
if
(
pCtx
->
hasNull
&&
isNull
(
pData
,
pCtx
->
inputType
))
{
if
(
pCtx
->
hasNull
&&
isNull
(
pData
,
pCtx
->
inputType
))
{
...
...
tests/script/general/parser/last_cache.sim
浏览文件 @
9b073353
...
@@ -9,7 +9,7 @@ sql connect
...
@@ -9,7 +9,7 @@ sql connect
print ======================== dnode1 start
print ======================== dnode1 start
$db = testdb
$db = testdb
sql drop database if exists $db
sql create database $db cachelast 2
sql create database $db cachelast 2
sql use $db
sql use $db
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录