Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3ed27805
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
3ed27805
编写于
9月 30, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: query information_schema.ins_tags error
上级
3dbb7c43
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
159 addition
and
70 deletion
+159
-70
source/libs/parser/inc/parUtil.h
source/libs/parser/inc/parUtil.h
+1
-0
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+21
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+65
-65
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+66
-1
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+4
-2
source/libs/parser/test/parTestMain.cpp
source/libs/parser/test/parTestMain.cpp
+1
-1
source/libs/planner/test/planTestMain.cpp
source/libs/planner/test/planTestMain.cpp
+1
-1
未找到文件。
source/libs/parser/inc/parUtil.h
浏览文件 @
3ed27805
...
...
@@ -91,6 +91,7 @@ STableComInfo getTableInfo(const STableMeta* pTableMeta);
STableMeta
*
tableMetaDup
(
const
STableMeta
*
pTableMeta
);
int32_t
trimString
(
const
char
*
src
,
int32_t
len
,
char
*
dst
,
int32_t
dlen
);
int32_t
getInsTagsTableTargetName
(
int32_t
acctId
,
SNode
*
pWhere
,
SName
*
pName
);
int32_t
buildCatalogReq
(
SParseContext
*
pCxt
,
const
SParseMetaCache
*
pMetaCache
,
SCatalogReq
*
pCatalogReq
);
int32_t
putMetaDataToCache
(
const
SCatalogReq
*
pCatalogReq
,
const
SMetaData
*
pMetaData
,
SParseMetaCache
*
pMetaCache
,
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
3ed27805
...
...
@@ -125,6 +125,23 @@ static bool needGetTableIndex(SNode* pStmt) {
return
false
;
}
static
int32_t
collectMetaKeyFromInsTagsImpl
(
SCollectMetaKeyCxt
*
pCxt
,
SName
*
pName
)
{
if
(
TSDB_DB_NAME_T
==
pName
->
type
)
{
return
reserveDbVgInfoInCache
(
pName
->
acctId
,
pName
->
dbname
,
pCxt
->
pMetaCache
);
}
return
reserveTableVgroupInCacheExt
(
pName
,
pCxt
->
pMetaCache
);
}
static
int32_t
collectMetaKeyFromInsTags
(
SCollectMetaKeyCxt
*
pCxt
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pCxt
->
pStmt
;
SName
name
=
{
0
};
int32_t
code
=
getInsTagsTableTargetName
(
pCxt
->
pParseCxt
->
acctId
,
pSelect
->
pWhere
,
&
name
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
collectMetaKeyFromInsTagsImpl
(
pCxt
,
&
name
);
}
return
code
;
}
static
int32_t
collectMetaKeyFromRealTableImpl
(
SCollectMetaKeyCxt
*
pCxt
,
const
char
*
pDb
,
const
char
*
pTable
,
AUTH_TYPE
authType
)
{
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pDb
,
pTable
,
pCxt
->
pMetaCache
);
...
...
@@ -143,6 +160,10 @@ 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
&&
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TAGS
))
&&
QUERY_NODE_SELECT_STMT
==
nodeType
(
pCxt
->
pStmt
))
{
code
=
collectMetaKeyFromInsTags
(
pCxt
);
}
return
code
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
3ed27805
...
...
@@ -2198,70 +2198,70 @@ static int32_t getTagsTableVgroupListImpl(STranslateContext* pCxt, SName* pTarge
return
code
;
}
static
int32_t
getTagsTableTargetNameFromOp
(
STranslateContext
*
pCxt
,
SOperatorNode
*
pOper
,
SName
*
pName
)
{
if
(
OP_TYPE_EQUAL
!=
pOper
->
opType
)
{
return
TSDB_CODE_SUCCESS
;
}
SColumnNode
*
pCol
=
NULL
;
SValueNode
*
pVal
=
NULL
;
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pOper
->
pLeft
))
{
pCol
=
(
SColumnNode
*
)
pOper
->
pLeft
;
}
else
if
(
QUERY_NODE_VALUE
==
nodeType
(
pOper
->
pLeft
))
{
pVal
=
(
SValueNode
*
)
pOper
->
pLeft
;
}
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pOper
->
pRight
))
{
pCol
=
(
SColumnNode
*
)
pOper
->
pRight
;
}
else
if
(
QUERY_NODE_VALUE
==
nodeType
(
pOper
->
pRight
))
{
pVal
=
(
SValueNode
*
)
pOper
->
pRight
;
}
if
(
NULL
==
pCol
||
NULL
==
pVal
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
0
==
strcmp
(
pCol
->
colName
,
"db_name"
))
{
return
tNameSetDbName
(
pName
,
pCxt
->
pParseCxt
->
acctId
,
pVal
->
literal
,
strlen
(
pVal
->
literal
));
}
else
if
(
0
==
strcmp
(
pCol
->
colName
,
"table_name"
))
{
return
tNameAddTbName
(
pName
,
pVal
->
literal
,
strlen
(
pVal
->
literal
));
}
return
TSDB_CODE_SUCCESS
;
}
static
void
getTagsTableTargetObjName
(
STranslateContext
*
pCxt
,
SNode
*
pNode
,
SName
*
pName
)
{
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
pNode
))
{
getTagsTableTargetNameFromOp
(
pCxt
,
(
SOperatorNode
*
)
pNode
,
pName
);
}
}
static
int32_t
getTagsTableTargetNameFromCond
(
STranslateContext
*
pCxt
,
SLogicConditionNode
*
pCond
,
SName
*
pName
)
{
if
(
LOGIC_COND_TYPE_AND
!=
pCond
->
condType
)
{
return
TSDB_CODE_SUCCESS
;
}
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pCond
->
pParameterList
)
{
getTagsTableTargetObjName
(
pCxt
,
pNode
,
pName
);
}
if
(
'\0'
==
pName
->
dbname
[
0
])
{
pName
->
type
=
0
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
getTagsTableTargetName
(
STranslateContext
*
pCxt
,
SNode
*
pWhere
,
SName
*
pName
)
{
if
(
NULL
==
pWhere
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
pWhere
))
{
return
getTagsTableTargetNameFromOp
(
pCxt
,
(
SOperatorNode
*
)
pWhere
,
pName
);
}
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pWhere
))
{
return
getTagsTableTargetNameFromCond
(
pCxt
,
(
SLogicConditionNode
*
)
pWhere
,
pName
);
}
return
TSDB_CODE_SUCCESS
;
}
//
static int32_t getTagsTableTargetNameFromOp(STranslateContext* pCxt, SOperatorNode* pOper, SName* pName) {
//
if (OP_TYPE_EQUAL != pOper->opType) {
//
return TSDB_CODE_SUCCESS;
//
}
//
SColumnNode* pCol = NULL;
//
SValueNode* pVal = NULL;
//
if (QUERY_NODE_COLUMN == nodeType(pOper->pLeft)) {
//
pCol = (SColumnNode*)pOper->pLeft;
//
} else if (QUERY_NODE_VALUE == nodeType(pOper->pLeft)) {
//
pVal = (SValueNode*)pOper->pLeft;
//
}
//
if (QUERY_NODE_COLUMN == nodeType(pOper->pRight)) {
//
pCol = (SColumnNode*)pOper->pRight;
//
} else if (QUERY_NODE_VALUE == nodeType(pOper->pRight)) {
//
pVal = (SValueNode*)pOper->pRight;
//
}
//
if (NULL == pCol || NULL == pVal) {
//
return TSDB_CODE_SUCCESS;
//
}
//
if (0 == strcmp(pCol->colName, "db_name")) {
//
return tNameSetDbName(pName, pCxt->pParseCxt->acctId, pVal->literal, strlen(pVal->literal));
//
} else if (0 == strcmp(pCol->colName, "table_name")) {
//
return tNameAddTbName(pName, pVal->literal, strlen(pVal->literal));
//
}
//
return TSDB_CODE_SUCCESS;
//
}
//
static void getTagsTableTargetObjName(STranslateContext* pCxt, SNode* pNode, SName* pName) {
//
if (QUERY_NODE_OPERATOR == nodeType(pNode)) {
//
getTagsTableTargetNameFromOp(pCxt, (SOperatorNode*)pNode, pName);
//
}
//
}
//
static int32_t getTagsTableTargetNameFromCond(STranslateContext* pCxt, SLogicConditionNode* pCond, SName* pName) {
//
if (LOGIC_COND_TYPE_AND != pCond->condType) {
//
return TSDB_CODE_SUCCESS;
//
}
//
SNode* pNode = NULL;
//
FOREACH(pNode, pCond->pParameterList) { getTagsTableTargetObjName(pCxt, pNode, pName); }
//
if ('\0' == pName->dbname[0]) {
//
pName->type = 0;
//
}
//
return TSDB_CODE_SUCCESS;
//
}
//
static int32_t getTagsTableTargetName(STranslateContext* pCxt, SNode* pWhere, SName* pName) {
//
if (NULL == pWhere) {
//
return TSDB_CODE_SUCCESS;
//
}
//
if (QUERY_NODE_OPERATOR == nodeType(pWhere)) {
//
return getTagsTableTargetNameFromOp(pCxt, (SOperatorNode*)pWhere, pName);
//
}
//
if (QUERY_NODE_LOGIC_CONDITION == nodeType(pWhere)) {
//
return getTagsTableTargetNameFromCond(pCxt, (SLogicConditionNode*)pWhere, pName);
//
}
//
return TSDB_CODE_SUCCESS;
//
}
static
int32_t
getTagsTableVgroupList
(
STranslateContext
*
pCxt
,
SName
*
pName
,
SArray
**
pVgroupList
)
{
if
(
!
isSelectStmt
(
pCxt
->
pCurrStmt
))
{
...
...
@@ -2269,7 +2269,7 @@ static int32_t getTagsTableVgroupList(STranslateContext* pCxt, SName* pName, SAr
}
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pCxt
->
pCurrStmt
;
SName
targetName
=
{
0
};
int32_t
code
=
get
TagsTableTargetName
(
pCxt
,
pSelect
->
pWhere
,
&
targetName
);
int32_t
code
=
get
InsTagsTableTargetName
(
pCxt
->
pParseCxt
->
acctId
,
pSelect
->
pWhere
,
&
targetName
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getTagsTableVgroupListImpl
(
pCxt
,
&
targetName
,
pName
,
pVgroupList
);
}
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
3ed27805
...
...
@@ -420,6 +420,71 @@ end:
return
retCode
;
}
static
int32_t
getInsTagsTableTargetNameFromOp
(
int32_t
acctId
,
SOperatorNode
*
pOper
,
SName
*
pName
)
{
if
(
OP_TYPE_EQUAL
!=
pOper
->
opType
)
{
return
TSDB_CODE_SUCCESS
;
}
SColumnNode
*
pCol
=
NULL
;
SValueNode
*
pVal
=
NULL
;
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pOper
->
pLeft
))
{
pCol
=
(
SColumnNode
*
)
pOper
->
pLeft
;
}
else
if
(
QUERY_NODE_VALUE
==
nodeType
(
pOper
->
pLeft
))
{
pVal
=
(
SValueNode
*
)
pOper
->
pLeft
;
}
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pOper
->
pRight
))
{
pCol
=
(
SColumnNode
*
)
pOper
->
pRight
;
}
else
if
(
QUERY_NODE_VALUE
==
nodeType
(
pOper
->
pRight
))
{
pVal
=
(
SValueNode
*
)
pOper
->
pRight
;
}
if
(
NULL
==
pCol
||
NULL
==
pVal
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
0
==
strcmp
(
pCol
->
colName
,
"db_name"
))
{
return
tNameSetDbName
(
pName
,
acctId
,
pVal
->
literal
,
strlen
(
pVal
->
literal
));
}
else
if
(
0
==
strcmp
(
pCol
->
colName
,
"table_name"
))
{
return
tNameAddTbName
(
pName
,
pVal
->
literal
,
strlen
(
pVal
->
literal
));
}
return
TSDB_CODE_SUCCESS
;
}
static
void
getInsTagsTableTargetObjName
(
int32_t
acctId
,
SNode
*
pNode
,
SName
*
pName
)
{
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
pNode
))
{
getInsTagsTableTargetNameFromOp
(
acctId
,
(
SOperatorNode
*
)
pNode
,
pName
);
}
}
static
int32_t
getInsTagsTableTargetNameFromCond
(
int32_t
acctId
,
SLogicConditionNode
*
pCond
,
SName
*
pName
)
{
if
(
LOGIC_COND_TYPE_AND
!=
pCond
->
condType
)
{
return
TSDB_CODE_SUCCESS
;
}
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pCond
->
pParameterList
)
{
getInsTagsTableTargetObjName
(
acctId
,
pNode
,
pName
);
}
if
(
'\0'
==
pName
->
dbname
[
0
])
{
pName
->
type
=
0
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
getInsTagsTableTargetName
(
int32_t
acctId
,
SNode
*
pWhere
,
SName
*
pName
)
{
if
(
NULL
==
pWhere
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
pWhere
))
{
return
getInsTagsTableTargetNameFromOp
(
acctId
,
(
SOperatorNode
*
)
pWhere
,
pName
);
}
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pWhere
))
{
return
getInsTagsTableTargetNameFromCond
(
acctId
,
(
SLogicConditionNode
*
)
pWhere
,
pName
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
userAuthToString
(
int32_t
acctId
,
const
char
*
pUser
,
const
char
*
pDb
,
AUTH_TYPE
type
,
char
*
pStr
)
{
return
sprintf
(
pStr
,
"%s*%d.%s*%d"
,
pUser
,
acctId
,
pDb
,
type
);
}
...
...
@@ -1173,7 +1238,7 @@ void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request) {
taosArrayDestroy
(
p
->
pTableVgroupReq
);
p
=
taosHashIterate
(
pMetaCache
->
pInsertTables
,
p
);
}
}
taosHashCleanup
(
pMetaCache
->
pInsertTables
);
taosHashCleanup
(
pMetaCache
->
pDbVgroup
);
taosHashCleanup
(
pMetaCache
->
pDbCfg
);
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
3ed27805
...
...
@@ -420,9 +420,11 @@ TEST_F(ParserSelectTest, setOperatorSemanticCheck) {
}
TEST_F
(
ParserSelectTest
,
informationSchema
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"information_schema"
);
run
(
"SELECT * FROM ins_databases WHERE name = 'information_schema'"
);
run
(
"SELECT * FROM in
formation_schema.ins_databases WHERE name = 'information_schema
'"
);
run
(
"SELECT * FROM in
s_tags WHERE db_name = 'test' and table_name = 'st1
'"
);
}
TEST_F
(
ParserSelectTest
,
withoutFrom
)
{
...
...
source/libs/parser/test/parTestMain.cpp
浏览文件 @
3ed27805
...
...
@@ -53,7 +53,7 @@ class ParserEnv : public testing::Environment {
private:
void
initLog
(
const
char
*
path
)
{
int32_t
logLevel
=
getLogLevel
();
int32_t
logLevel
=
getLogLevel
()
|
DEBUG_SCREEN
;
dDebugFlag
=
logLevel
;
vDebugFlag
=
logLevel
;
mDebugFlag
=
logLevel
;
...
...
source/libs/planner/test/planTestMain.cpp
浏览文件 @
3ed27805
...
...
@@ -48,7 +48,7 @@ class PlannerEnv : public testing::Environment {
private:
void
initLog
(
const
char
*
path
)
{
int32_t
logLevel
=
getLogLevel
();
int32_t
logLevel
=
getLogLevel
()
|
DEBUG_SCREEN
;
dDebugFlag
=
logLevel
;
vDebugFlag
=
logLevel
;
mDebugFlag
=
logLevel
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录