Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6298f92d
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看板
提交
6298f92d
编写于
11月 09, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: some problems of parser
上级
0656cd8f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
4 deletion
+34
-4
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+32
-4
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+2
-0
未找到文件。
source/libs/parser/src/parTranslater.c
浏览文件 @
6298f92d
...
...
@@ -2393,6 +2393,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
if
(
TSDB_SUPER_TABLE
==
pRealTable
->
pMeta
->
tableType
)
{
pCxt
->
stableQuery
=
true
;
}
if
(
TSDB_SYSTEM_TABLE
==
pRealTable
->
pMeta
->
tableType
&&
isSelectStmt
(
pCxt
->
pCurrStmt
))
{
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
isTimeLineResult
=
false
;
}
code
=
addNamespace
(
pCxt
,
pRealTable
);
}
break
;
...
...
@@ -3428,6 +3431,19 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) {
return
(
SNode
*
)
pCol
;
}
// 0 means equal, 1 means the left shall prevail, -1 means the right shall prevail
static
int32_t
dataTypeComp
(
const
SDataType
*
l
,
const
SDataType
*
r
)
{
if
(
l
->
type
!=
r
->
type
)
{
return
1
;
}
if
(
l
->
bytes
!=
r
->
bytes
)
{
return
l
->
bytes
>
r
->
bytes
?
1
:
-
1
;
}
return
(
l
->
precision
==
r
->
precision
&&
l
->
scale
==
r
->
scale
)
?
0
:
1
;
}
static
int32_t
translateSetOperProject
(
STranslateContext
*
pCxt
,
SSetOperator
*
pSetOperator
)
{
SNodeList
*
pLeftProjections
=
getProjectList
(
pSetOperator
->
pLeft
);
SNodeList
*
pRightProjections
=
getProjectList
(
pSetOperator
->
pRight
);
...
...
@@ -3440,7 +3456,8 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
FORBOTH
(
pLeft
,
pLeftProjections
,
pRight
,
pRightProjections
)
{
SExprNode
*
pLeftExpr
=
(
SExprNode
*
)
pLeft
;
SExprNode
*
pRightExpr
=
(
SExprNode
*
)
pRight
;
if
(
!
dataTypeEqual
(
&
pLeftExpr
->
resType
,
&
pRightExpr
->
resType
))
{
int32_t
comp
=
dataTypeComp
(
&
pLeftExpr
->
resType
,
&
pRightExpr
->
resType
);
if
(
comp
>
0
)
{
SNode
*
pRightFunc
=
NULL
;
int32_t
code
=
createCastFunc
(
pCxt
,
pRight
,
pLeftExpr
->
resType
,
&
pRightFunc
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
...
...
@@ -3448,9 +3465,20 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
}
REPLACE_LIST2_NODE
(
pRightFunc
);
pRightExpr
=
(
SExprNode
*
)
pRightFunc
;
}
strcpy
(
pRightExpr
->
aliasName
,
pLeftExpr
->
aliasName
);
pRightExpr
->
aliasName
[
strlen
(
pLeftExpr
->
aliasName
)]
=
'\0'
;
}
else
if
(
comp
<
0
)
{
SNode
*
pLeftFunc
=
NULL
;
int32_t
code
=
createCastFunc
(
pCxt
,
pLeft
,
pRightExpr
->
resType
,
&
pLeftFunc
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
REPLACE_LIST1_NODE
(
pLeftFunc
);
SExprNode
*
pLeftFuncExpr
=
(
SExprNode
*
)
pLeftFunc
;
snprintf
(
pLeftFuncExpr
->
aliasName
,
sizeof
(
pLeftFuncExpr
->
aliasName
),
"%s"
,
pLeftExpr
->
aliasName
);
snprintf
(
pLeftFuncExpr
->
userAlias
,
sizeof
(
pLeftFuncExpr
->
userAlias
),
"%s"
,
pLeftExpr
->
userAlias
);
pLeft
=
pLeftFunc
;
pLeftExpr
=
pLeftFuncExpr
;
}
snprintf
(
pRightExpr
->
aliasName
,
sizeof
(
pRightExpr
->
aliasName
),
"%s"
,
pLeftExpr
->
aliasName
);
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pSetOperator
->
pProjectionList
,
createSetOperProject
(
pSetOperator
->
stmtName
,
pLeft
)))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
6298f92d
...
...
@@ -425,6 +425,8 @@ TEST_F(ParserSelectTest, informationSchema) {
run
(
"SELECT * FROM ins_databases WHERE name = 'information_schema'"
);
run
(
"SELECT * FROM ins_tags WHERE db_name = 'test' and table_name = 'st1'"
);
run
(
"SELECT * FROM (SELECT table_name FROM ins_tables) t WHERE table_name = 'a'"
);
}
TEST_F
(
ParserSelectTest
,
withoutFrom
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录