Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3f3f98cf
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3f3f98cf
编写于
5月 12, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into fix/hzcheng_3.0
上级
eff8656c
aad78647
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
109 addition
and
6 deletion
+109
-6
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+9
-4
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+3
-0
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+41
-0
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+55
-2
tests/script/tsim/stable/alter1.sim
tests/script/tsim/stable/alter1.sim
+1
-0
未找到文件。
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
3f3f98cf
...
@@ -318,6 +318,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
...
@@ -318,6 +318,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
pOld
->
updateTime
=
pNew
->
updateTime
;
pOld
->
updateTime
=
pNew
->
updateTime
;
pOld
->
version
=
pNew
->
version
;
pOld
->
version
=
pNew
->
version
;
pOld
->
nextColId
=
pNew
->
nextColId
;
pOld
->
nextColId
=
pNew
->
nextColId
;
pOld
->
ttl
=
pNew
->
ttl
;
pOld
->
numOfColumns
=
pNew
->
numOfColumns
;
pOld
->
numOfColumns
=
pNew
->
numOfColumns
;
pOld
->
numOfTags
=
pNew
->
numOfTags
;
pOld
->
numOfTags
=
pNew
->
numOfTags
;
memcpy
(
pOld
->
pColumns
,
pNew
->
pColumns
,
pOld
->
numOfColumns
*
sizeof
(
SSchema
));
memcpy
(
pOld
->
pColumns
,
pNew
->
pColumns
,
pOld
->
numOfColumns
*
sizeof
(
SSchema
));
...
@@ -832,7 +833,7 @@ static int32_t mndProcessVCreateStbRsp(SNodeMsg *pRsp) {
...
@@ -832,7 +833,7 @@ static int32_t mndProcessVCreateStbRsp(SNodeMsg *pRsp) {
}
}
static
int32_t
mndCheckAlterStbReq
(
SMAlterStbReq
*
pAlter
)
{
static
int32_t
mndCheckAlterStbReq
(
SMAlterStbReq
*
pAlter
)
{
if
(
pAlter
->
commentLen
!=
0
)
return
0
;
if
(
pAlter
->
commentLen
!=
0
||
pAlter
->
ttl
!=
0
)
return
0
;
if
(
pAlter
->
numOfFields
<
1
||
pAlter
->
numOfFields
!=
(
int32_t
)
taosArrayGetSize
(
pAlter
->
pFields
))
{
if
(
pAlter
->
numOfFields
<
1
||
pAlter
->
numOfFields
!=
(
int32_t
)
taosArrayGetSize
(
pAlter
->
pFields
))
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
...
@@ -883,7 +884,8 @@ static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
...
@@ -883,7 +884,8 @@ static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
return
0
;
return
0
;
}
}
static
int32_t
mndUpdateStbComment
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
char
*
pComment
,
int32_t
commentLen
)
{
static
int32_t
mndUpdateStbCommentAndTTL
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
char
*
pComment
,
int32_t
commentLen
,
int32_t
ttl
)
{
if
(
commentLen
>
0
)
{
if
(
commentLen
>
0
)
{
pNew
->
commentLen
=
commentLen
;
pNew
->
commentLen
=
commentLen
;
pNew
->
comment
=
taosMemoryCalloc
(
1
,
commentLen
);
pNew
->
comment
=
taosMemoryCalloc
(
1
,
commentLen
);
...
@@ -893,6 +895,9 @@ static int32_t mndUpdateStbComment(const SStbObj *pOld, SStbObj *pNew, char *pCo
...
@@ -893,6 +895,9 @@ static int32_t mndUpdateStbComment(const SStbObj *pOld, SStbObj *pNew, char *pCo
}
}
memcpy
(
pNew
->
comment
,
pComment
,
commentLen
);
memcpy
(
pNew
->
comment
,
pComment
,
commentLen
);
}
}
if
(
ttl
>=
0
)
{
pNew
->
ttl
=
ttl
;
}
if
(
mndAllocStbSchemas
(
pOld
,
pNew
)
!=
0
)
{
if
(
mndAllocStbSchemas
(
pOld
,
pNew
)
!=
0
)
{
return
-
1
;
return
-
1
;
...
@@ -1232,7 +1237,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SNodeMsg *pReq, const SMAlterStbReq *
...
@@ -1232,7 +1237,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SNodeMsg *pReq, const SMAlterStbReq *
code
=
mndAlterStbColumnBytes
(
pOld
,
&
stbObj
,
pField0
);
code
=
mndAlterStbColumnBytes
(
pOld
,
&
stbObj
,
pField0
);
break
;
break
;
case
TSDB_ALTER_TABLE_UPDATE_OPTIONS
:
case
TSDB_ALTER_TABLE_UPDATE_OPTIONS
:
code
=
mndUpdateStbComment
(
pOld
,
&
stbObj
,
pAlter
->
comment
,
pAlter
->
commentLen
);
code
=
mndUpdateStbComment
AndTTL
(
pOld
,
&
stbObj
,
pAlter
->
comment
,
pAlter
->
commentLen
,
pAlter
->
ttl
);
break
;
break
;
default:
default:
terrno
=
TSDB_CODE_OPS_NOT_SUPPORT
;
terrno
=
TSDB_CODE_OPS_NOT_SUPPORT
;
...
@@ -1723,7 +1728,7 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
...
@@ -1723,7 +1728,7 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStb
->
updateTime
,
false
);
// number of tables
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStb
->
updateTime
,
false
);
// number of tables
char
*
p
=
taosMemory
Malloc
(
pStb
->
commentLen
+
VARSTR_HEADER_SIZE
);
// check malloc failures
char
*
p
=
taosMemory
Calloc
(
1
,
pStb
->
commentLen
+
1
+
VARSTR_HEADER_SIZE
);
// check malloc failures
if
(
p
!=
NULL
)
{
if
(
p
!=
NULL
)
{
if
(
pStb
->
commentLen
!=
0
)
{
if
(
pStb
->
commentLen
!=
0
)
{
STR_TO_VARSTR
(
p
,
pStb
->
comment
);
STR_TO_VARSTR
(
p
,
pStb
->
comment
);
...
...
source/libs/function/inc/builtinsimpl.h
浏览文件 @
3f3f98cf
...
@@ -95,6 +95,9 @@ bool stateFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
...
@@ -95,6 +95,9 @@ bool stateFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
int32_t
stateCountFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stateCountFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stateDurationFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stateDurationFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getCsumFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
int32_t
csumFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getSelectivityFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getSelectivityFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/libs/function/src/builtins.c
浏览文件 @
3f3f98cf
...
@@ -308,6 +308,37 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
...
@@ -308,6 +308,37 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
translateCsum
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
if
(
1
!=
LIST_LENGTH
(
pFunc
->
pParameterList
))
{
return
TSDB_CODE_SUCCESS
;
}
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pPara
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The input parameter of CSUM function can only be column"
);
}
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
resType
;
if
(
!
IS_NUMERIC_TYPE
(
colType
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
else
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
colType
))
{
resType
=
TSDB_DATA_TYPE_BIGINT
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
colType
))
{
resType
=
TSDB_DATA_TYPE_UBIGINT
;
}
else
if
(
IS_FLOAT_TYPE
(
colType
))
{
resType
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
{
ASSERT
(
0
);
}
}
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
tDataTypes
[
resType
].
bytes
,
.
type
=
resType
};
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateLastRow
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
static
int32_t
translateLastRow
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
// todo
// todo
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -742,6 +773,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -742,6 +773,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
processFunc
=
stateDurationFunction
,
.
processFunc
=
stateDurationFunction
,
.
finalizeFunc
=
NULL
.
finalizeFunc
=
NULL
},
},
{
.
name
=
"csum"
,
.
type
=
FUNCTION_TYPE_CSUM
,
.
classification
=
FUNC_MGT_NONSTANDARD_SQL_FUNC
|
FUNC_MGT_TIMELINE_FUNC
,
.
translateFunc
=
translateCsum
,
.
getEnvFunc
=
getCsumFuncEnv
,
.
initFunc
=
functionSetup
,
.
processFunc
=
csumFunction
,
.
finalizeFunc
=
NULL
},
{
{
.
name
=
"abs"
,
.
name
=
"abs"
,
.
type
=
FUNCTION_TYPE_ABS
,
.
type
=
FUNCTION_TYPE_ABS
,
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
3f3f98cf
...
@@ -2818,7 +2818,6 @@ int32_t stateCountFunction(SqlFunctionCtx* pCtx) {
...
@@ -2818,7 +2818,6 @@ int32_t stateCountFunction(SqlFunctionCtx* pCtx) {
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
SColumnInfoData
*
pTsOutput
=
pCtx
->
pTsOutput
;
int32_t
numOfElems
=
0
;
int32_t
numOfElems
=
0
;
SColumnInfoData
*
pOutput
=
(
SColumnInfoData
*
)
pCtx
->
pOutput
;
SColumnInfoData
*
pOutput
=
(
SColumnInfoData
*
)
pCtx
->
pOutput
;
...
@@ -2856,7 +2855,6 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) {
...
@@ -2856,7 +2855,6 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) {
TSKEY
*
tsList
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
TSKEY
*
tsList
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
SColumnInfoData
*
pTsOutput
=
pCtx
->
pTsOutput
;
int32_t
numOfElems
=
0
;
int32_t
numOfElems
=
0
;
SColumnInfoData
*
pOutput
=
(
SColumnInfoData
*
)
pCtx
->
pOutput
;
SColumnInfoData
*
pOutput
=
(
SColumnInfoData
*
)
pCtx
->
pOutput
;
...
@@ -2896,3 +2894,58 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) {
...
@@ -2896,3 +2894,58 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) {
return
numOfElems
;
return
numOfElems
;
}
}
bool
getCsumFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
)
{
pEnv
->
calcMemSize
=
sizeof
(
SSumRes
);
return
true
;
}
int32_t
csumFunction
(
SqlFunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SSumRes
*
pSumRes
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
TSKEY
*
tsList
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
SColumnInfoData
*
pTsOutput
=
pCtx
->
pTsOutput
;
SColumnInfoData
*
pOutput
=
(
SColumnInfoData
*
)
pCtx
->
pOutput
;
int32_t
numOfElems
=
0
;
int32_t
type
=
pInputCol
->
info
.
type
;
int32_t
startOffset
=
pCtx
->
offset
;
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
int32_t
pos
=
startOffset
+
numOfElems
;
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
//colDataAppendNULL(pOutput, i);
continue
;
}
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
int64_t
v
;
GET_TYPED_DATA
(
v
,
int64_t
,
type
,
data
);
pSumRes
->
isum
+=
v
;
colDataAppend
(
pOutput
,
pos
,
(
char
*
)
&
pSumRes
->
isum
,
false
);
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
uint64_t
v
;
GET_TYPED_DATA
(
v
,
uint64_t
,
type
,
data
);
pSumRes
->
usum
+=
v
;
colDataAppend
(
pOutput
,
pos
,
(
char
*
)
&
pSumRes
->
usum
,
false
);
}
else
if
(
IS_FLOAT_TYPE
(
type
))
{
double
v
;
GET_TYPED_DATA
(
v
,
double
,
type
,
data
);
pSumRes
->
dsum
+=
v
;
colDataAppend
(
pOutput
,
pos
,
(
char
*
)
&
pSumRes
->
dsum
,
false
);
}
//TODO: remove this after pTsOutput is handled
if
(
pTsOutput
!=
NULL
)
{
colDataAppendInt64
(
pTsOutput
,
pos
,
&
tsList
[
i
]);
}
numOfElems
++
;
}
return
numOfElems
;
}
tests/script/tsim/stable/alter1.sim
浏览文件 @
3f3f98cf
...
@@ -159,6 +159,7 @@ sql alter table db.stb rename tag t1 tx
...
@@ -159,6 +159,7 @@ sql alter table db.stb rename tag t1 tx
print ========== alter common
print ========== alter common
sql alter table db.stb comment 'abcde' ;
sql alter table db.stb comment 'abcde' ;
sql alter table db.stb ttl 10 ;
sql show db.stables;
sql show db.stables;
if $data[0][6] != abcde then
if $data[0][6] != abcde then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录