Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
71ab6565
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看板
提交
71ab6565
编写于
7月 04, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: some problems of parser and planner
上级
41e67fb2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
16 deletion
+20
-16
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+6
-0
source/libs/parser/test/parInitialATest.cpp
source/libs/parser/test/parInitialATest.cpp
+14
-16
未找到文件。
source/libs/parser/src/parAstParser.c
浏览文件 @
71ab6565
...
...
@@ -247,6 +247,10 @@ static int32_t collectMetaKeyFromAlterTable(SCollectMetaKeyCxt* pCxt, SAlterTabl
return
code
;
}
static
int32_t
collectMetaKeyFromAlterStable
(
SCollectMetaKeyCxt
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
return
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
}
static
int32_t
collectMetaKeyFromUseDatabase
(
SCollectMetaKeyCxt
*
pCxt
,
SUseDatabaseStmt
*
pStmt
)
{
return
reserveDbVgVersionInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pCxt
->
pMetaCache
);
}
...
...
@@ -483,6 +487,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromDropTable
(
pCxt
,
(
SDropTableStmt
*
)
pStmt
);
case
QUERY_NODE_ALTER_TABLE_STMT
:
return
collectMetaKeyFromAlterTable
(
pCxt
,
(
SAlterTableStmt
*
)
pStmt
);
case
QUERY_NODE_ALTER_SUPER_TABLE_STMT
:
return
collectMetaKeyFromAlterStable
(
pCxt
,
(
SAlterTableStmt
*
)
pStmt
);
case
QUERY_NODE_USE_DATABASE_STMT
:
return
collectMetaKeyFromUseDatabase
(
pCxt
,
(
SUseDatabaseStmt
*
)
pStmt
);
case
QUERY_NODE_CREATE_INDEX_STMT
:
...
...
source/libs/parser/test/parInitialATest.cpp
浏览文件 @
71ab6565
...
...
@@ -77,8 +77,6 @@ TEST_F(ParserInitialATest, alterLocal) {
clearAlterLocal
();
}
// todo ALTER stable
/*
* ALTER TABLE [db_name.]tb_name alter_table_clause
*
...
...
@@ -157,7 +155,7 @@ TEST_F(ParserInitialATest, alterSTable) {
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_ALTER_TABLE_STMT
);
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_ALTER_
SUPER_
TABLE_STMT
);
SMAlterStbReq
req
=
{
0
};
ASSERT_EQ
(
tDeserializeSMAlterStbReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
std
::
string
(
req
.
name
),
std
::
string
(
expect
.
name
));
...
...
@@ -181,44 +179,44 @@ TEST_F(ParserInitialATest, alterSTable) {
});
// setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, nullptr, 10);
// run("ALTER TABLE st1 TTL 10");
// run("ALTER
S
TABLE st1 TTL 10");
// clearAlterStbReq();
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_OPTIONS
,
0
,
nullptr
,
0
,
0
,
nullptr
,
"test"
);
run
(
"ALTER TABLE st1 COMMENT 'test'"
);
run
(
"ALTER
S
TABLE st1 COMMENT 'test'"
);
clearAlterStbReq
();
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_ADD_COLUMN
,
1
,
"cc1"
,
TSDB_DATA_TYPE_BIGINT
);
run
(
"ALTER TABLE st1 ADD COLUMN cc1 BIGINT"
);
run
(
"ALTER
S
TABLE st1 ADD COLUMN cc1 BIGINT"
);
clearAlterStbReq
();
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_DROP_COLUMN
,
1
,
"c1"
);
run
(
"ALTER TABLE st1 DROP COLUMN c1"
);
run
(
"ALTER
S
TABLE st1 DROP COLUMN c1"
);
clearAlterStbReq
();
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
,
1
,
"c2"
,
TSDB_DATA_TYPE_VARCHAR
,
30
+
VARSTR_HEADER_SIZE
);
run
(
"ALTER TABLE st1 MODIFY COLUMN c2 VARCHAR(30)"
);
run
(
"ALTER
S
TABLE st1 MODIFY COLUMN c2 VARCHAR(30)"
);
clearAlterStbReq
();
// setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, 2, "c1", 0, 0, "cc1");
// run("ALTER TABLE st1 RENAME COLUMN c1 cc1");
// run("ALTER
S
TABLE st1 RENAME COLUMN c1 cc1");
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_ADD_TAG
,
1
,
"tag11"
,
TSDB_DATA_TYPE_BIGINT
);
run
(
"ALTER TABLE st1 ADD TAG tag11 BIGINT"
);
run
(
"ALTER
S
TABLE st1 ADD TAG tag11 BIGINT"
);
clearAlterStbReq
();
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_DROP_TAG
,
1
,
"tag1"
);
run
(
"ALTER TABLE st1 DROP TAG tag1"
);
run
(
"ALTER
S
TABLE st1 DROP TAG tag1"
);
clearAlterStbReq
();
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
,
1
,
"tag2"
,
TSDB_DATA_TYPE_VARCHAR
,
30
+
VARSTR_HEADER_SIZE
);
run
(
"ALTER TABLE st1 MODIFY TAG tag2 VARCHAR(30)"
);
run
(
"ALTER
S
TABLE st1 MODIFY TAG tag2 VARCHAR(30)"
);
clearAlterStbReq
();
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
,
2
,
"tag1"
,
0
,
0
,
"tag11"
);
run
(
"ALTER TABLE st1 RENAME TAG tag1 tag11"
);
run
(
"ALTER
S
TABLE st1 RENAME TAG tag1 tag11"
);
clearAlterStbReq
();
// todo
...
...
@@ -228,11 +226,11 @@ TEST_F(ParserInitialATest, alterSTable) {
TEST_F
(
ParserInitialATest
,
alterSTableSemanticCheck
)
{
useDb
(
"root"
,
"test"
);
run
(
"ALTER TABLE st1 RENAME COLUMN c1 cc1"
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
run
(
"ALTER
S
TABLE st1 RENAME COLUMN c1 cc1"
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
run
(
"ALTER TABLE st1 MODIFY COLUMN c2 NCHAR(10)"
,
TSDB_CODE_PAR_INVALID_MODIFY_COL
);
run
(
"ALTER
S
TABLE st1 MODIFY COLUMN c2 NCHAR(10)"
,
TSDB_CODE_PAR_INVALID_MODIFY_COL
);
run
(
"ALTER TABLE st1 MODIFY TAG tag2 NCHAR(10)"
,
TSDB_CODE_PAR_INVALID_MODIFY_COL
);
run
(
"ALTER
S
TABLE st1 MODIFY TAG tag2 NCHAR(10)"
,
TSDB_CODE_PAR_INVALID_MODIFY_COL
);
}
TEST_F
(
ParserInitialATest
,
alterTable
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录