Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e5de317f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
e5de317f
编写于
3月 09, 2023
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: alter database stt_trigger/minrows
上级
afd01bb9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
2057 addition
and
2021 deletion
+2057
-2021
include/common/tmsg.h
include/common/tmsg.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+4
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+12
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+3
-3
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2023
-2018
source/libs/parser/test/parAlterToBalanceTest.cpp
source/libs/parser/test/parAlterToBalanceTest.cpp
+13
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
e5de317f
...
...
@@ -845,6 +845,7 @@ typedef struct {
int8_t
cacheLast
;
int8_t
replications
;
int32_t
sstTrigger
;
int32_t
minRows
;
}
SAlterDbReq
;
int32_t
tSerializeSAlterDbReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterDbReq
*
pReq
);
...
...
source/common/src/tmsg.c
浏览文件 @
e5de317f
...
...
@@ -2219,6 +2219,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
if
(
tEncodeI8
(
&
encoder
,
pReq
->
cacheLast
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
replications
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
sstTrigger
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
minRows
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
...
...
@@ -2246,6 +2247,9 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
cacheLast
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
replications
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
sstTrigger
)
<
0
)
return
-
1
;
if
(
!
tDecodeIsEnd
(
&
decoder
))
{
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
minRows
)
<
0
)
return
-
1
;
}
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
e5de317f
...
...
@@ -725,6 +725,18 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
terrno
=
0
;
}
if
(
pAlter
->
sstTrigger
>
0
&&
pAlter
->
sstTrigger
!=
pDb
->
cfg
.
sstTrigger
)
{
pDb
->
cfg
.
sstTrigger
=
pAlter
->
sstTrigger
;
pDb
->
vgVersion
++
;
terrno
=
0
;
}
if
(
pAlter
->
minRows
>
0
&&
pAlter
->
minRows
!=
pDb
->
cfg
.
minRows
)
{
pDb
->
cfg
.
minRows
=
pAlter
->
minRows
;
pDb
->
vgVersion
++
;
terrno
=
0
;
}
return
terrno
;
}
...
...
source/libs/parser/inc/sql.y
浏览文件 @
e5de317f
...
...
@@ -236,6 +236,7 @@ alter_db_option(A) ::= REPLICA NK_INTEGER(B).
//alter_db_option(A) ::= STRICT NK_STRING(B). { A.type = DB_OPTION_STRICT; A.val = B; }
alter_db_option(A) ::= WAL_LEVEL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
alter_db_option(A) ::= STT_TRIGGER NK_INTEGER(B). { A.type = DB_OPTION_STT_TRIGGER; A.val = B; }
alter_db_option(A) ::= MINROWS NK_INTEGER(B). { A.type = DB_OPTION_MINROWS; A.val = B; }
%type integer_list { SNodeList* }
%destructor integer_list { nodesDestroyList($$); }
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
e5de317f
...
...
@@ -2500,9 +2500,8 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
STempTableNode
*
pTempTable
=
(
STempTableNode
*
)
pTable
;
code
=
translateSubquery
(
pCxt
,
pTempTable
->
pSubquery
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pTempTable
->
pSubquery
)
&&
((
SSelectStmt
*
)
pTempTable
->
pSubquery
)
->
isEmptyResult
&&
isSelectStmt
(
pCxt
->
pCurrStmt
))
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pTempTable
->
pSubquery
)
&&
((
SSelectStmt
*
)
pTempTable
->
pSubquery
)
->
isEmptyResult
&&
isSelectStmt
(
pCxt
->
pCurrStmt
))
{
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
isEmptyResult
=
true
;
}
...
...
@@ -4254,6 +4253,7 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
pReq
->
cacheLastSize
=
pStmt
->
pOptions
->
cacheLastSize
;
pReq
->
replications
=
pStmt
->
pOptions
->
replica
;
pReq
->
sstTrigger
=
pStmt
->
pOptions
->
sstTrigger
;
pReq
->
minRows
=
pStmt
->
pOptions
->
minRowsPerBlock
;
return
;
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
e5de317f
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
source/libs/parser/test/parAlterToBalanceTest.cpp
浏览文件 @
e5de317f
...
...
@@ -108,6 +108,7 @@ TEST_F(ParserInitialATest, alterDnode) {
* | REPLICA int_value -- todo: enum 1, 3, default 1, unit replica
* | WAL_LEVEL int_value -- enum 1, 2, default 1
* | STT_TRIGGER int_value -- rang [1, 16], default 8
* | MINROWS int_value -- rang [10, 1000], default 100
* }
*/
TEST_F
(
ParserInitialATest
,
alterDatabase
)
{
...
...
@@ -133,6 +134,7 @@ TEST_F(ParserInitialATest, alterDatabase) {
expect
.
cacheLastSize
=
-
1
;
expect
.
replications
=
-
1
;
expect
.
sstTrigger
=
-
1
;
expect
.
minRows
=
-
1
;
};
auto
setAlterDbBuffer
=
[
&
](
int32_t
buffer
)
{
expect
.
buffer
=
buffer
;
};
auto
setAlterDbPageSize
=
[
&
](
int32_t
pageSize
)
{
expect
.
pageSize
=
pageSize
;
};
...
...
@@ -150,6 +152,7 @@ TEST_F(ParserInitialATest, alterDatabase) {
auto
setAlterDbCacheModel
=
[
&
](
int8_t
cacheModel
)
{
expect
.
cacheLast
=
cacheModel
;
};
auto
setAlterDbReplica
=
[
&
](
int8_t
replications
)
{
expect
.
replications
=
replications
;
};
auto
setAlterDbSttTrigger
=
[
&
](
int8_t
sstTrigger
)
{
expect
.
sstTrigger
=
sstTrigger
;
};
auto
setAlterDbMinRows
=
[
&
](
int32_t
minRows
)
{
expect
.
minRows
=
minRows
;
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_ALTER_DATABASE_STMT
);
...
...
@@ -170,6 +173,7 @@ TEST_F(ParserInitialATest, alterDatabase) {
ASSERT_EQ
(
req
.
cacheLast
,
expect
.
cacheLast
);
ASSERT_EQ
(
req
.
replications
,
expect
.
replications
);
ASSERT_EQ
(
req
.
sstTrigger
,
expect
.
sstTrigger
);
ASSERT_EQ
(
req
.
minRows
,
expect
.
minRows
);
});
const
int32_t
MINUTE_PER_DAY
=
MILLISECOND_PER_DAY
/
MILLISECOND_PER_MINUTE
;
...
...
@@ -277,6 +281,15 @@ TEST_F(ParserInitialATest, alterDatabase) {
setAlterDbSttTrigger
(
16
);
run
(
"ALTER DATABASE test STT_TRIGGER 16"
);
clearAlterDbReq
();
initAlterDb
(
"test"
);
setAlterDbMinRows
(
10
);
run
(
"ALTER DATABASE test MINROWS 10"
);
setAlterDbMinRows
(
50
);
run
(
"ALTER DATABASE test MINROWS 50"
);
setAlterDbMinRows
(
1000
);
run
(
"ALTER DATABASE test MINROWS 1000"
);
clearAlterDbReq
();
}
TEST_F
(
ParserInitialATest
,
alterDatabaseSemanticCheck
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录