Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
70761fd9
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
70761fd9
编写于
4月 28, 2023
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: optimize tbname condition
上级
ad7c3218
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
1 deletion
+68
-1
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+1
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+67
-0
未找到文件。
source/libs/catalog/src/ctgCache.c
浏览文件 @
70761fd9
...
...
@@ -1082,7 +1082,7 @@ int32_t ctgUpdateUserEnqueue(SCatalog *pCtg, SGetUserAuthRsp *pAuth, bool syncOp
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateUserMsg
));
taosMemoryFree
(
op
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
CTG_ERR_
J
RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
msg
->
pCtg
=
pCtg
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
70761fd9
...
...
@@ -30,6 +30,11 @@
#define SYSTABLE_SHOW_TYPE_OFFSET QUERY_NODE_SHOW_DNODES_STMT
typedef
struct
SRewriteTbNameContext
{
int32_t
errCode
;
char
*
pTbName
;
}
SRewriteTbNameContext
;
typedef
struct
STranslateContext
{
SParseContext
*
pParseCxt
;
int32_t
errCode
;
...
...
@@ -2541,6 +2546,64 @@ static int32_t setTableCacheLastMode(STranslateContext* pCxt, SSelectStmt* pSele
return
code
;
}
static
EDealRes
doTranslateTbName
(
SNode
**
pNode
,
void
*
pContext
)
{
switch
(
nodeType
(
*
pNode
))
{
case
QUERY_NODE_FUNCTION
:
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
*
pNode
;
if
(
FUNCTION_TYPE_TBNAME
==
pFunc
->
funcType
)
{
SRewriteTbNameContext
*
pCxt
=
(
SRewriteTbNameContext
*
)
pContext
;
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
if
(
NULL
==
pVal
)
{
pCxt
->
errCode
=
TSDB_CODE_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
}
int32_t
tbLen
=
strlen
(
pCxt
->
pTbName
);
pVal
->
literal
=
taosStrdup
(
pCxt
->
pTbName
);
if
(
NULL
==
pVal
->
literal
)
{
pCxt
->
errCode
=
TSDB_CODE_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
}
pVal
->
isDuration
=
false
;
pVal
->
translate
=
true
;
pVal
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BINARY
;
pVal
->
node
.
resType
.
bytes
=
tbLen
+
VARSTR_HEADER_SIZE
;
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
tbLen
+
VARSTR_HEADER_SIZE
+
1
);
varDataSetLen
(
pVal
->
datum
.
p
,
tbLen
);
strncpy
(
varDataVal
(
pVal
->
datum
.
p
),
pVal
->
literal
,
tbLen
);
strcpy
(
pVal
->
node
.
userAlias
,
pFunc
->
node
.
userAlias
);
strcpy
(
pVal
->
node
.
aliasName
,
pFunc
->
node
.
aliasName
);
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
pVal
;
}
break
;
}
default:
break
;
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
replaceTbName
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
if
(
QUERY_NODE_REAL_TABLE
!=
nodeType
(
pSelect
->
pFromTable
))
{
return
TSDB_CODE_SUCCESS
;
}
SRealTableNode
*
pTable
=
(
SRealTableNode
*
)
pSelect
->
pFromTable
;
if
(
TSDB_CHILD_TABLE
!=
pTable
->
pMeta
->
tableType
&&
TSDB_NORMAL_TABLE
!=
pTable
->
pMeta
->
tableType
&&
TSDB_SYSTEM_TABLE
!=
pTable
->
pMeta
->
tableType
)
{
return
TSDB_CODE_SUCCESS
;
}
SNode
**
pNode
=
NULL
;
SRewriteTbNameContext
pRewriteCxt
=
{
0
};
pRewriteCxt
.
pTbName
=
pTable
->
table
.
tableName
;
nodesRewriteExprPostOrder
(
&
pSelect
->
pWhere
,
doTranslateTbName
,
&
pRewriteCxt
);
return
pRewriteCxt
.
errCode
;
}
static
int32_t
checkJoinTable
(
STranslateContext
*
pCxt
,
SJoinTableNode
*
pJoinTable
)
{
if
((
QUERY_NODE_TEMP_TABLE
==
nodeType
(
pJoinTable
->
pLeft
)
&&
!
isTimeLineQuery
(((
STempTableNode
*
)
pJoinTable
->
pLeft
)
->
pSubquery
))
||
...
...
@@ -3649,6 +3712,10 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setTableCacheLastMode
(
pCxt
,
pSelect
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
replaceTbName
(
pCxt
,
pSelect
);
}
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录