Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8a2795b5
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8a2795b5
编写于
12月 30, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix assert in builtinsimpl.c
上级
763f702f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
58 addition
and
42 deletion
+58
-42
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+58
-42
未找到文件。
source/libs/function/src/builtinsimpl.c
浏览文件 @
8a2795b5
...
...
@@ -506,7 +506,6 @@ static int32_t getNumOfElems(SqlFunctionCtx* pCtx) {
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
if
(
pInput
->
colDataSMAIsSet
&&
pInput
->
totalRows
==
pInput
->
numOfRows
&&
!
IS_VAR_DATA_TYPE
(
pInputCol
->
info
.
type
))
{
numOfElem
=
pInput
->
numOfRows
-
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
;
ASSERT
(
numOfElem
>=
0
);
}
else
{
if
(
pInputCol
->
hasNull
)
{
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
startRowIndex
+
pInput
->
numOfRows
;
++
i
)
{
...
...
@@ -596,7 +595,6 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) {
if
(
pInput
->
colDataSMAIsSet
)
{
numOfElem
=
pInput
->
numOfRows
-
pAgg
->
numOfNull
;
ASSERT
(
numOfElem
>=
0
);
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
pSumRes
->
isum
+=
pAgg
->
sum
;
...
...
@@ -661,7 +659,6 @@ int32_t sumInvertFunction(SqlFunctionCtx* pCtx) {
if
(
pInput
->
colDataSMAIsSet
)
{
numOfElem
=
pInput
->
numOfRows
-
pAgg
->
numOfNull
;
ASSERT
(
numOfElem
>=
0
);
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
pSumRes
->
isum
-=
pAgg
->
sum
;
...
...
@@ -832,7 +829,6 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple
int32_t
dstSlotId
=
pc
->
pExpr
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pDstCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
dstSlotId
);
ASSERT
(
pc
->
pExpr
->
base
.
resSchema
.
bytes
==
pDstCol
->
info
.
bytes
);
if
(
nullList
[
j
])
{
colDataAppendNULL
(
pDstCol
,
rowIndex
);
}
else
{
...
...
@@ -876,7 +872,6 @@ void appendSelectivityValue(SqlFunctionCtx* pCtx, int32_t rowIndex, int32_t pos)
int32_t
dstSlotId
=
pc
->
pExpr
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pDstCol
=
taosArrayGet
(
pCtx
->
pDstBlock
->
pDataBlock
,
dstSlotId
);
ASSERT
(
pc
->
pExpr
->
base
.
resSchema
.
bytes
==
pDstCol
->
info
.
bytes
);
if
(
colDataIsNull_s
(
pSrcCol
,
rowIndex
)
==
true
)
{
colDataAppendNULL
(
pDstCol
,
pos
);
...
...
@@ -1145,7 +1140,9 @@ static void stddevTransferInfo(SStddevRes* pInput, SStddevRes* pOutput) {
int32_t
stddevFunctionMerge
(
SqlFunctionCtx
*
pCtx
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SStddevRes
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
...
@@ -1841,7 +1838,9 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) {
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SAPercentileInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
...
@@ -2009,9 +2008,6 @@ static void prepareBuf(SqlFunctionCtx* pCtx) {
pCtx
->
subsidiaries
.
rowLen
=
rowLen
+
pCtx
->
subsidiaries
.
num
*
sizeof
(
bool
);
pCtx
->
subsidiaries
.
buf
=
taosMemoryMalloc
(
pCtx
->
subsidiaries
.
rowLen
);
}
ASSERT
(
pCtx
->
subsidiaries
.
buf
!=
NULL
);
ASSERT
(
pCtx
->
subsidiaries
.
rowLen
>
0
);
}
static
void
firstlastSaveTupleData
(
const
SSDataBlock
*
pSrcBlock
,
int32_t
rowIndex
,
SqlFunctionCtx
*
pCtx
,
...
...
@@ -2060,8 +2056,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
}
// All null data column, return directly.
if
(
pInput
->
colDataSMAIsSet
&&
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
))
{
ASSERT
(
pInputCol
->
hasNull
==
true
);
if
(
pInput
->
colDataSMAIsSet
&&
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
)
&&
pInputCol
->
hasNull
==
true
)
{
// save selectivity value for column consisted of all null values
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2168,8 +2163,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
}
// All null data column, return directly.
if
(
pInput
->
colDataSMAIsSet
&&
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
))
{
ASSERT
(
pInputCol
->
hasNull
==
true
);
if
(
pInput
->
colDataSMAIsSet
&&
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
)
&&
pInputCol
->
hasNull
==
true
)
{
// save selectivity value for column consisted of all null values
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2333,7 +2327,9 @@ static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, S
static
int32_t
firstLastFunctionMergeImpl
(
SqlFunctionCtx
*
pCtx
,
bool
isFirstQuery
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SFirstLastRes
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
...
@@ -2528,7 +2524,7 @@ bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
return
true
;
}
static
void
doSetPrevVal
(
SDiffInfo
*
pDiffInfo
,
int32_t
type
,
const
char
*
pv
,
int64_t
ts
)
{
static
int32_t
doSetPrevVal
(
SDiffInfo
*
pDiffInfo
,
int32_t
type
,
const
char
*
pv
,
int64_t
ts
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
pDiffInfo
->
prev
.
i64
=
*
(
bool
*
)
pv
?
1
:
0
;
...
...
@@ -2553,12 +2549,14 @@ static void doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv, int
pDiffInfo
->
prev
.
d64
=
*
(
double
*
)
pv
;
break
;
default:
ASSERT
(
0
)
;
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
pDiffInfo
->
prevTs
=
ts
;
return
TSDB_CODE_SUCCESS
;
}
static
void
doHandleDiff
(
SDiffInfo
*
pDiffInfo
,
int32_t
type
,
const
char
*
pv
,
SColumnInfoData
*
pOutput
,
int32_t
pos
,
static
int32_t
doHandleDiff
(
SDiffInfo
*
pDiffInfo
,
int32_t
type
,
const
char
*
pv
,
SColumnInfoData
*
pOutput
,
int32_t
pos
,
int32_t
order
,
int64_t
ts
)
{
int32_t
factor
=
(
order
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
pDiffInfo
->
prevTs
=
ts
;
...
...
@@ -2633,8 +2631,10 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo
break
;
}
default:
ASSERT
(
0
)
;
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
diffFunction
(
SqlFunctionCtx
*
pCtx
)
{
...
...
@@ -2671,7 +2671,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
if
(
tsList
[
i
]
==
pDiffInfo
->
prevTs
)
{
return
TSDB_CODE_FUNC_DUP_TIMESTAMP
;
}
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
,
tsList
[
i
]);
int32_t
code
=
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
,
tsList
[
i
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
// handle selectivity
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
appendSelectivityValue
(
pCtx
,
i
,
pos
);
...
...
@@ -2679,7 +2682,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
numOfElems
++
;
}
else
{
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
tsList
[
i
]);
int32_t
code
=
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
tsList
[
i
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
pDiffInfo
->
hasPrev
=
true
;
...
...
@@ -2704,7 +2710,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
if
(
tsList
[
i
]
==
pDiffInfo
->
prevTs
)
{
return
TSDB_CODE_FUNC_DUP_TIMESTAMP
;
}
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
,
tsList
[
i
]);
int32_t
code
=
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
,
tsList
[
i
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
// handle selectivity
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
appendSelectivityValue
(
pCtx
,
i
,
pos
);
...
...
@@ -2712,7 +2721,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
numOfElems
++
;
}
else
{
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
tsList
[
i
]);
int32_t
code
=
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
tsList
[
i
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
pDiffInfo
->
hasPrev
=
true
;
...
...
@@ -2967,10 +2979,9 @@ static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf
releaseBufPage
(
pHandle
->
pBuf
,
pPage
);
}
else
{
// other tuple save policy
if
(
streamStateFuncPut
(
pHandle
->
pState
,
&
key
,
pBuf
,
length
)
<
0
)
{
ASSERT
(
0
)
;
if
(
streamStateFuncPut
(
pHandle
->
pState
,
&
key
,
pBuf
,
length
)
>=
0
)
{
p
.
streamTupleKey
=
key
;
}
p
.
streamTupleKey
=
key
;
}
return
p
;
...
...
@@ -2982,12 +2993,13 @@ STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBloc
STupleKey
key
;
if
(
pCtx
->
saveHandle
.
pBuf
==
NULL
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pSrcBlock
->
pDataBlock
,
0
);
ASSERT
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
int64_t
skey
=
*
(
int64_t
*
)
colDataGetData
(
pColInfo
,
rowIndex
);
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
skey
=
*
(
int64_t
*
)
colDataGetData
(
pColInfo
,
rowIndex
);
key
.
groupId
=
pSrcBlock
->
info
.
id
.
groupId
;
key
.
ts
=
skey
;
key
.
exprIdx
=
pCtx
->
exprIdx
;
key
.
groupId
=
pSrcBlock
->
info
.
id
.
groupId
;
key
.
ts
=
skey
;
key
.
exprIdx
=
pCtx
->
exprIdx
;
}
}
char
*
buf
=
serializeTupleData
(
pSrcBlock
,
rowIndex
,
&
pCtx
->
subsidiaries
,
pCtx
->
subsidiaries
.
buf
);
...
...
@@ -3225,7 +3237,9 @@ static void spreadTransferInfo(SSpreadInfo* pInput, SSpreadInfo* pOutput) {
int32_t
spreadFunctionMerge
(
SqlFunctionCtx
*
pCtx
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SSpreadInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
...
@@ -3404,7 +3418,9 @@ static void elapsedTransferInfo(SElapsedInfo* pInput, SElapsedInfo* pOutput) {
int32_t
elapsedFunctionMerge
(
SqlFunctionCtx
*
pCtx
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SElapsedInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
...
@@ -3574,7 +3590,9 @@ static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t
intervals
[
0
]
=
-
INFINITY
;
intervals
[
numOfBins
-
1
]
=
INFINITY
;
// in case of desc bin orders, -inf/inf should be swapped
ASSERT
(
numOfBins
>=
4
);
if
(
numOfBins
<
4
)
{
return
false
;
}
if
(
intervals
[
1
]
>
intervals
[
numOfBins
-
2
])
{
TSWAP
(
intervals
[
0
],
intervals
[
numOfBins
-
1
]);
}
...
...
@@ -3717,7 +3735,9 @@ static void histogramTransferInfo(SHistoFuncInfo* pInput, SHistoFuncInfo* pOutpu
int32_t
histogramFunctionMerge
(
SqlFunctionCtx
*
pCtx
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SHistoFuncInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
...
@@ -4099,7 +4119,7 @@ static bool checkStateOp(int8_t op, SColumnInfoData* pCol, int32_t index, SVaria
break
;
}
default:
{
ASSERT
(
0
)
;
return
false
;
}
}
return
false
;
...
...
@@ -4900,11 +4920,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
int32_t
i
=
pInput
->
startRowIndex
;
if
(
pCtx
->
start
.
key
!=
INT64_MIN
)
{
// ASSERT((pCtx->start.key < tsList[i] && pCtx->order == TSDB_ORDER_ASC) ||
// (pCtx->start.key > tsList[i] && pCtx->order == TSDB_ORDER_DESC));
ASSERT
(
last
->
key
==
INT64_MIN
);
if
(
pCtx
->
start
.
key
!=
INT64_MIN
&&
last
->
key
==
INT64_MIN
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
...
...
@@ -5124,7 +5140,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
default:
ASSERT
(
0
)
;
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
// the last interpolated time window value
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录