Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5122a7e9
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
5122a7e9
编写于
12月 12, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
12月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18902 from taosdata/fix/main_bugfix_wxy
fix: create stream error
上级
88bf65ff
6d282321
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
11 deletion
+40
-11
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+40
-11
未找到文件。
source/libs/parser/src/parTranslater.c
浏览文件 @
5122a7e9
...
...
@@ -2837,7 +2837,7 @@ static int32_t rewriteProjectAlias(SNodeList* pProjectionList) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
checkProjectAlias
(
STranslateContext
*
pCxt
,
SNodeList
*
pProjectionList
)
{
static
int32_t
checkProjectAlias
(
STranslateContext
*
pCxt
,
SNodeList
*
pProjectionList
,
SHashObj
**
pOutput
)
{
SHashObj
*
pUserAliasSet
=
taosHashInit
(
LIST_LENGTH
(
pProjectionList
),
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
SNode
*
pProject
=
NULL
;
...
...
@@ -2849,13 +2849,17 @@ static int32_t checkProjectAlias(STranslateContext* pCxt, SNodeList* pProjection
}
taosHashPut
(
pUserAliasSet
,
pExpr
->
userAlias
,
strlen
(
pExpr
->
userAlias
),
&
pExpr
,
POINTER_BYTES
);
}
taosHashCleanup
(
pUserAliasSet
);
if
(
NULL
==
pOutput
)
{
taosHashCleanup
(
pUserAliasSet
);
}
else
{
*
pOutput
=
pUserAliasSet
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateProjectionList
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
if
(
pSelect
->
isSubquery
)
{
return
checkProjectAlias
(
pCxt
,
pSelect
->
pProjectionList
);
return
checkProjectAlias
(
pCxt
,
pSelect
->
pProjectionList
,
NULL
);
}
return
rewriteProjectAlias
(
pSelect
->
pProjectionList
);
}
...
...
@@ -3888,8 +3892,7 @@ static int32_t checkDbKeepOption(STranslateContext* pCxt, SDatabaseOptions* pOpt
pOptions
->
keep
[
0
]
>
tsdbMaxKeep
||
pOptions
->
keep
[
1
]
>
tsdbMaxKeep
||
pOptions
->
keep
[
2
]
>
tsdbMaxKeep
)
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_DB_OPTION
,
"Invalid option keep: %"
PRId64
", %"
PRId64
", %"
PRId64
" valid range: [%dm, %dm]"
,
pOptions
->
keep
[
0
],
pOptions
->
keep
[
1
],
pOptions
->
keep
[
2
],
TSDB_MIN_KEEP
,
tsdbMaxKeep
);
pOptions
->
keep
[
0
],
pOptions
->
keep
[
1
],
pOptions
->
keep
[
2
],
TSDB_MIN_KEEP
,
tsdbMaxKeep
);
}
if
(
!
((
pOptions
->
keep
[
0
]
<=
pOptions
->
keep
[
1
])
&&
(
pOptions
->
keep
[
1
]
<=
pOptions
->
keep
[
2
])))
{
...
...
@@ -4044,7 +4047,7 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
code
=
checkDbPrecisionOption
(
pCxt
,
pOptions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkDbKeepOption
(
pCxt
,
pOptions
);
// use precision
code
=
checkDbKeepOption
(
pCxt
,
pOptions
);
// use precision
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkDbRangeOption
(
pCxt
,
"pages"
,
pOptions
->
pages
,
TSDB_MIN_PAGES_PER_VNODE
,
TSDB_MAX_PAGES_PER_VNODE
);
...
...
@@ -5504,9 +5507,24 @@ static void getSourceDatabase(SNode* pStmt, int32_t acctId, char* pDbFName) {
tNameGetFullDbName
(
&
name
,
pDbFName
);
}
static
int32_t
addWstartTsToCreateStreamQuery
(
SNode
*
pStmt
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pStmt
;
SNode
*
pProj
=
nodesListGetNode
(
pSelect
->
pProjectionList
,
0
);
static
void
getStreamQueryFirstProjectAliasName
(
SHashObj
*
pUserAliasSet
,
char
*
aliasName
,
int32_t
len
)
{
if
(
NULL
==
taosHashGet
(
pUserAliasSet
,
"_wstart"
,
strlen
(
"_wstart"
)))
{
snprintf
(
aliasName
,
len
,
"%s"
,
"_wstart"
);
return
;
}
if
(
NULL
==
taosHashGet
(
pUserAliasSet
,
"ts"
,
strlen
(
"ts"
)))
{
snprintf
(
aliasName
,
len
,
"%s"
,
"ts"
);
return
;
}
do
{
taosRandStr
(
aliasName
,
len
-
1
);
aliasName
[
len
-
1
]
=
'\0'
;
}
while
(
NULL
!=
taosHashGet
(
pUserAliasSet
,
aliasName
,
strlen
(
aliasName
)));
return
;
}
static
int32_t
addWstartTsToCreateStreamQueryImpl
(
SSelectStmt
*
pSelect
,
SHashObj
*
pUserAliasSet
)
{
SNode
*
pProj
=
nodesListGetNode
(
pSelect
->
pProjectionList
,
0
);
if
(
NULL
==
pSelect
->
pWindow
||
(
QUERY_NODE_FUNCTION
==
nodeType
(
pProj
)
&&
0
==
strcmp
(
"_wstart"
,
((
SFunctionNode
*
)
pProj
)
->
functionName
)))
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -5516,7 +5534,7 @@ static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
return
TSDB_CODE_OUT_OF_MEMORY
;
}
strcpy
(
pFunc
->
functionName
,
"_wstart"
);
strcpy
(
pFunc
->
node
.
aliasName
,
pFunc
->
functionName
);
getStreamQueryFirstProjectAliasName
(
pUserAliasSet
,
pFunc
->
node
.
aliasName
,
sizeof
(
pFunc
->
node
.
aliasName
)
);
int32_t
code
=
nodesListPushFront
(
pSelect
->
pProjectionList
,
(
SNode
*
)
pFunc
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
((
SNode
*
)
pFunc
);
...
...
@@ -5524,6 +5542,17 @@ static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
return
code
;
}
static
int32_t
addWstartTsToCreateStreamQuery
(
STranslateContext
*
pCxt
,
SNode
*
pStmt
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pStmt
;
SHashObj
*
pUserAliasSet
=
NULL
;
int32_t
code
=
checkProjectAlias
(
pCxt
,
pSelect
->
pProjectionList
,
&
pUserAliasSet
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addWstartTsToCreateStreamQueryImpl
(
pSelect
,
pUserAliasSet
);
}
taosHashCleanup
(
pUserAliasSet
);
return
code
;
}
static
int32_t
addTagsToCreateStreamQuery
(
STranslateContext
*
pCxt
,
SCreateStreamStmt
*
pStmt
,
SSelectStmt
*
pSelect
)
{
if
(
NULL
==
pStmt
->
pTags
)
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -5626,7 +5655,7 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SSelectStmt* pSelect) {
static
int32_t
buildCreateStreamQuery
(
STranslateContext
*
pCxt
,
SCreateStreamStmt
*
pStmt
,
SCMCreateStreamReq
*
pReq
)
{
pCxt
->
createStream
=
true
;
int32_t
code
=
addWstartTsToCreateStreamQuery
(
pStmt
->
pQuery
);
int32_t
code
=
addWstartTsToCreateStreamQuery
(
p
Cxt
,
p
Stmt
->
pQuery
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addSubtableInfoToCreateStreamQuery
(
pCxt
,
pStmt
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录