Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b7056f58
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看板
提交
b7056f58
编写于
10月 25, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: alter table check
上级
efb56e84
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
6 deletion
+72
-6
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+48
-1
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+3
-4
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+21
-1
未找到文件。
source/libs/parser/src/parTranslater.c
浏览文件 @
b7056f58
...
...
@@ -4847,6 +4847,11 @@ static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTable
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_ONLY_ONE_JSON_TAG
);
}
int32_t
tagsLen
=
0
;
for
(
int32_t
i
=
0
;
i
<
pTableMeta
->
tableInfo
.
numOfTags
;
++
i
)
{
tagsLen
+=
pTagsSchema
[
i
].
bytes
;
}
if
(
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
==
pStmt
->
alterType
||
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
==
pStmt
->
alterType
)
{
if
(
TSDB_SUPER_TABLE
!=
pTableMeta
->
tableType
)
{
...
...
@@ -4860,7 +4865,38 @@ static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTable
pSchema
->
bytes
>=
calcTypeBytes
(
pStmt
->
dataType
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_MODIFY_COL
);
}
if
(
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
==
pStmt
->
alterType
&&
pTableMeta
->
tableInfo
.
rowSize
+
calcTypeBytes
(
pStmt
->
dataType
)
-
pSchema
->
bytes
>
TSDB_MAX_BYTES_PER_ROW
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ROW_LENGTH
,
TSDB_MAX_BYTES_PER_ROW
);
}
if
(
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
==
pStmt
->
alterType
&&
tagsLen
+
calcTypeBytes
(
pStmt
->
dataType
)
-
pSchema
->
bytes
>
TSDB_MAX_TAGS_LEN
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TAGS_LENGTH
,
TSDB_MAX_TAGS_LEN
);
}
}
if
(
TSDB_ALTER_TABLE_ADD_COLUMN
==
pStmt
->
alterType
)
{
if
(
TSDB_MAX_COLUMNS
==
pTableMeta
->
tableInfo
.
numOfColumns
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TOO_MANY_COLUMNS
);
}
if
(
pTableMeta
->
tableInfo
.
rowSize
+
calcTypeBytes
(
pStmt
->
dataType
)
>
TSDB_MAX_BYTES_PER_ROW
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ROW_LENGTH
,
TSDB_MAX_BYTES_PER_ROW
);
}
}
if
(
TSDB_ALTER_TABLE_ADD_TAG
==
pStmt
->
alterType
)
{
if
(
TSDB_MAX_TAGS
==
pTableMeta
->
tableInfo
.
numOfTags
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TAGS_NUM
);
}
if
(
tagsLen
+
calcTypeBytes
(
pStmt
->
dataType
)
>
TSDB_MAX_TAGS_LEN
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TAGS_LENGTH
,
TSDB_MAX_TAGS_LEN
);
}
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -7078,6 +7114,14 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_DUPLICATED_COLUMN
);
}
if
(
TSDB_MAX_COLUMNS
==
pTableMeta
->
tableInfo
.
numOfColumns
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TOO_MANY_COLUMNS
);
}
if
(
pTableMeta
->
tableInfo
.
rowSize
+
calcTypeBytes
(
pStmt
->
dataType
)
>
TSDB_MAX_BYTES_PER_ROW
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ROW_LENGTH
,
TSDB_MAX_BYTES_PER_ROW
);
}
pReq
->
colName
=
strdup
(
pStmt
->
colName
);
if
(
NULL
==
pReq
->
colName
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -7085,7 +7129,6 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S
pReq
->
type
=
pStmt
->
dataType
.
type
;
pReq
->
flags
=
COL_SMA_ON
;
// pReq->bytes = pStmt->dataType.bytes;
pReq
->
bytes
=
calcTypeBytes
(
pStmt
->
dataType
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -7123,6 +7166,10 @@ static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_MODIFY_COL
);
}
if
(
pTableMeta
->
tableInfo
.
rowSize
+
pReq
->
colModBytes
-
pSchema
->
bytes
>
TSDB_MAX_BYTES_PER_ROW
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ROW_LENGTH
,
TSDB_MAX_BYTES_PER_ROW
);
}
pReq
->
colName
=
strdup
(
pStmt
->
colName
);
if
(
NULL
==
pReq
->
colName
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
b7056f58
...
...
@@ -624,8 +624,6 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
return
code
;
}
static
bool
isInterpFunc
(
int32_t
funcId
)
{
return
fmIsInterpFunc
(
funcId
)
||
fmIsInterpPseudoColumnFunc
(
funcId
);
}
static
int32_t
createInterpFuncLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
if
(
!
pSelect
->
hasInterpFunc
)
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -640,7 +638,8 @@ static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
pInterpFunc
->
node
.
requireDataOrder
=
getRequireDataOrder
(
true
,
pSelect
);
pInterpFunc
->
node
.
resultDataOrder
=
pInterpFunc
->
node
.
requireDataOrder
;
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_SELECT
,
isInterpFunc
,
&
pInterpFunc
->
pFuncs
);
// interp functions and _group_key functions
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_SELECT
,
fmIsVectorFunc
,
&
pInterpFunc
->
pFuncs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExprsForSelect
(
pInterpFunc
->
pFuncs
,
pSelect
,
SQL_CLAUSE_SELECT
);
}
...
...
@@ -728,7 +727,7 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createWindowLogicNodeFinalize
(
pCxt
,
pSelect
,
pWindow
,
pLogicNode
);
}
return
code
;
}
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
b7056f58
...
...
@@ -2242,6 +2242,26 @@ static EDealRes lastRowScanOptSetColDataType(SNode* pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
static
void
lastRowScanOptSetLastTargets
(
SNodeList
*
pTargets
,
SNodeList
*
pLastCols
)
{
SNode
*
pTarget
=
NULL
;
WHERE_EACH
(
pTarget
,
pTargets
)
{
bool
found
=
false
;
SNode
*
pCol
=
NULL
;
FOREACH
(
pCol
,
pLastCols
)
{
if
(
nodesEqualNode
(
pCol
,
pTarget
))
{
getLastCacheDataType
(
&
(((
SColumnNode
*
)
pTarget
)
->
node
.
resType
));
found
=
true
;
break
;
}
}
if
(
!
found
)
{
ERASE_NODE
(
pTargets
);
continue
;
}
WHERE_NEXT
;
}
}
static
int32_t
lastRowScanOptimize
(
SOptimizeContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
)
{
SAggLogicNode
*
pAgg
=
(
SAggLogicNode
*
)
optFindPossibleNode
(
pLogicSubplan
->
pNode
,
lastRowScanOptMayBeOptimized
);
...
...
@@ -2276,7 +2296,7 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic
cxt
.
doAgg
=
false
;
nodesWalkExprs
(
pScan
->
pScanCols
,
lastRowScanOptSetColDataType
,
&
cxt
);
nodesWalkExprs
(
pScan
->
pScanPseudoCols
,
lastRowScanOptSetColDataType
,
&
cxt
);
nodesWalkExprs
(
pScan
->
node
.
pTargets
,
lastRowScanOptSetColDataType
,
&
cxt
);
lastRowScanOptSetLastTargets
(
pScan
->
node
.
pTargets
,
cxt
.
pLastCols
);
nodesClearList
(
cxt
.
pLastCols
);
}
pAgg
->
hasLastRow
=
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录