Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2ccc7471
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看板
提交
2ccc7471
编写于
8月 31, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: query get dbcfg optimization
上级
2030db5b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
17 deletion
+45
-17
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+2
-1
source/libs/function/src/functionMgt.c
source/libs/function/src/functionMgt.c
+8
-0
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+21
-7
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+14
-9
未找到文件。
include/libs/function/functionMgt.h
浏览文件 @
2ccc7471
...
...
@@ -176,7 +176,8 @@ int32_t fmGetFuncInfo(SFunctionNode* pFunc, char* pMsg, int32_t msgLen);
EFuncReturnRows
fmGetFuncReturnRows
(
SFunctionNode
*
pFunc
);
bool
fmIsBuiltinFunc
(
const
char
*
pFunc
);
bool
fmIsBuiltinFunc
(
const
char
*
pFunc
);
EFunctionType
fmGetFuncType
(
const
char
*
pFunc
);
bool
fmIsAggFunc
(
int32_t
funcId
);
bool
fmIsScalarFunc
(
int32_t
funcId
);
...
...
source/libs/function/src/functionMgt.c
浏览文件 @
2ccc7471
...
...
@@ -101,6 +101,14 @@ bool fmIsBuiltinFunc(const char* pFunc) {
return
NULL
!=
taosHashGet
(
gFunMgtService
.
pFuncNameHashTable
,
pFunc
,
strlen
(
pFunc
));
}
EFunctionType
fmGetFuncType
(
const
char
*
pFunc
)
{
void
*
pVal
=
taosHashGet
(
gFunMgtService
.
pFuncNameHashTable
,
pFunc
,
strlen
(
pFunc
));
if
(
NULL
!=
pVal
)
{
return
funcMgtBuiltins
[
*
(
int32_t
*
)
pVal
].
type
;
}
return
FUNCTION_TYPE_UDF
;
}
EFuncDataRequired
fmFuncDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
)
{
if
(
fmIsUserDefinedFunc
(
pFunc
->
funcId
)
||
pFunc
->
funcId
<
0
||
pFunc
->
funcId
>=
funcMgtBuiltinsNum
)
{
return
FUNC_DATA_REQUIRED_DATA_LOAD
;
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
2ccc7471
...
...
@@ -97,16 +97,23 @@ typedef struct SCollectMetaKeyCxt {
typedef
struct
SCollectMetaKeyFromExprCxt
{
SCollectMetaKeyCxt
*
pComCxt
;
bool
hasLastRow
;
int32_t
errCode
;
}
SCollectMetaKeyFromExprCxt
;
static
int32_t
collectMetaKeyFromQuery
(
SCollectMetaKeyCxt
*
pCxt
,
SNode
*
pStmt
);
static
EDealRes
collectMetaKeyFromFunction
(
SCollectMetaKeyFromExprCxt
*
pCxt
,
SFunctionNode
*
pFunc
)
{
if
(
fmIsBuiltinFunc
(
pFunc
->
functionName
))
{
return
DEAL_RES_CONTINUE
;
switch
(
fmGetFuncType
(
pFunc
->
functionName
))
{
case
FUNCTION_TYPE_LAST_ROW
:
pCxt
->
hasLastRow
=
true
;
break
;
case
FUNCTION_TYPE_UDF
:
pCxt
->
errCode
=
reserveUdfInCache
(
pFunc
->
functionName
,
pCxt
->
pComCxt
->
pMetaCache
);
break
;
default:
break
;
}
pCxt
->
errCode
=
reserveUdfInCache
(
pFunc
->
functionName
,
pCxt
->
pComCxt
->
pMetaCache
);
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
;
}
...
...
@@ -136,9 +143,6 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c
if
(
TSDB_CODE_SUCCESS
==
code
&&
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_DNODE_VARIABLES
)))
{
code
=
reserveDnodeRequiredInCache
(
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pDb
,
pCxt
->
pMetaCache
);
}
return
code
;
}
...
...
@@ -185,9 +189,19 @@ static int32_t collectMetaKeyFromSetOperator(SCollectMetaKeyCxt* pCxt, SSetOpera
return
code
;
}
static
int32_t
reserveDbCfgForLastRow
(
SCollectMetaKeyCxt
*
pCxt
,
SNode
*
pTable
)
{
if
(
NULL
==
pTable
||
QUERY_NODE_REAL_TABLE
!=
nodeType
(
pTable
))
{
return
TSDB_CODE_SUCCESS
;
}
return
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SRealTableNode
*
)
pTable
)
->
table
.
dbName
,
pCxt
->
pMetaCache
);
}
static
int32_t
collectMetaKeyFromSelect
(
SCollectMetaKeyCxt
*
pCxt
,
SSelectStmt
*
pStmt
)
{
SCollectMetaKeyFromExprCxt
cxt
=
{.
pComCxt
=
pCxt
,
.
errCode
=
TSDB_CODE_SUCCESS
};
SCollectMetaKeyFromExprCxt
cxt
=
{.
pComCxt
=
pCxt
,
.
hasLastRow
=
false
,
.
errCode
=
TSDB_CODE_SUCCESS
};
nodesWalkSelectStmt
(
pStmt
,
SQL_CLAUSE_FROM
,
collectMetaKeyFromExprImpl
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
==
cxt
.
errCode
&&
cxt
.
hasLastRow
)
{
cxt
.
errCode
=
reserveDbCfgForLastRow
(
pCxt
,
pStmt
->
pFromTable
);
}
return
cxt
.
errCode
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
2ccc7471
...
...
@@ -2160,15 +2160,16 @@ static int32_t setTableIndex(STranslateContext* pCxt, SName* pName, SRealTableNo
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
setTableCacheLastMode
(
STranslateContext
*
pCxt
,
S
Name
*
pName
,
SRealTableNode
*
pRealTable
)
{
if
(
TSDB_SYSTEM_TABLE
==
pRealTable
->
pMeta
->
tableType
)
{
static
int32_t
setTableCacheLastMode
(
STranslateContext
*
pCxt
,
S
SelectStmt
*
pSelect
)
{
if
(
!
pSelect
->
hasLastRowFunc
||
QUERY_NODE_REAL_TABLE
!=
nodeType
(
pSelect
->
pFromTable
)
)
{
return
TSDB_CODE_SUCCESS
;
}
SDbCfgInfo
dbCfg
=
{
0
};
int32_t
code
=
getDBCfg
(
pCxt
,
pRealTable
->
table
.
dbName
,
&
dbCfg
);
SRealTableNode
*
pTable
=
(
SRealTableNode
*
)
pSelect
->
pFromTable
;
SDbCfgInfo
dbCfg
=
{
0
};
int32_t
code
=
getDBCfg
(
pCxt
,
pTable
->
table
.
dbName
,
&
dbCfg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
p
Real
Table
->
cacheLastMode
=
dbCfg
.
cacheLast
;
pTable
->
cacheLastMode
=
dbCfg
.
cacheLast
;
}
return
code
;
}
...
...
@@ -2192,9 +2193,6 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setTableIndex
(
pCxt
,
&
name
,
pRealTable
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setTableCacheLastMode
(
pCxt
,
&
name
,
pRealTable
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pRealTable
->
table
.
precision
=
pRealTable
->
pMeta
->
tableInfo
.
precision
;
...
...
@@ -2273,10 +2271,14 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pExpr
))
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pExpr
;
len
=
snprintf
(
buf
,
sizeof
(
buf
),
"%s(%s.%s)"
,
pSrcFunc
->
functionName
,
pCol
->
tableAlias
,
pCol
->
colName
);
strncpy
(
pFunc
->
node
.
aliasName
,
buf
,
TMIN
(
len
,
sizeof
(
pFunc
->
node
.
aliasName
)
-
1
));
len
=
snprintf
(
buf
,
sizeof
(
buf
),
"%s(%s)"
,
pSrcFunc
->
functionName
,
pCol
->
colName
);
strncpy
(
pFunc
->
node
.
userAlias
,
buf
,
TMIN
(
len
,
sizeof
(
pFunc
->
node
.
userAlias
)
-
1
));
}
else
{
len
=
snprintf
(
buf
,
sizeof
(
buf
),
"%s(%s)"
,
pSrcFunc
->
functionName
,
pExpr
->
aliasName
);
strncpy
(
pFunc
->
node
.
aliasName
,
buf
,
TMIN
(
len
,
sizeof
(
pFunc
->
node
.
aliasName
)
-
1
));
strncpy
(
pFunc
->
node
.
userAlias
,
buf
,
TMIN
(
len
,
sizeof
(
pFunc
->
node
.
userAlias
)
-
1
));
}
strncpy
(
pFunc
->
node
.
aliasName
,
buf
,
TMIN
(
len
,
sizeof
(
pFunc
->
node
.
aliasName
)
-
1
));
return
(
SNode
*
)
pFunc
;
}
...
...
@@ -3140,6 +3142,9 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
replaceOrderByAliasForSelect
(
pCxt
,
pSelect
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setTableCacheLastMode
(
pCxt
,
pSelect
);
}
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录