Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ae6224d9
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看板
未验证
提交
ae6224d9
编写于
3月 17, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
3月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10802 from taosdata/feature/3.0_query_integrate_wxy
TD-14043 show statement bugfix
上级
59625a7b
40228a00
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
147 addition
and
76 deletion
+147
-76
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+10
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+67
-47
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+33
-10
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+18
-13
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+9
-4
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+2
-1
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+7
-0
未找到文件。
include/libs/nodes/querynodes.h
浏览文件 @
ae6224d9
...
...
@@ -125,6 +125,7 @@ typedef struct SRealTableNode {
STableNode
table
;
// QUERY_NODE_REAL_TABLE
struct
STableMeta
*
pMeta
;
SVgroupsInfo
*
pVgroupList
;
char
useDbName
[
TSDB_DB_NAME_LEN
];
}
SRealTableNode
;
typedef
struct
STempTableNode
{
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
ae6224d9
...
...
@@ -111,6 +111,10 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
exprNodeCopy
((
const
SExprNode
*
)
pSrc
,
(
SExprNode
*
)
pDst
);
COPY_CHAR_POINT_FIELD
(
literal
);
COPY_SCALAR_FIELD
(
isDuration
);
COPY_SCALAR_FIELD
(
translate
);
if
(
!
pSrc
->
translate
)
{
return
(
SNode
*
)
pDst
;
}
switch
(
pSrc
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_NULL
:
break
;
...
...
@@ -137,7 +141,12 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
COPY_CHAR_POINT_FIELD
(
datum
.
p
);
pDst
->
datum
.
p
=
malloc
(
pSrc
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
);
if
(
NULL
==
pDst
->
datum
.
p
)
{
nodesDestroyNode
(
pDst
);
return
NULL
;
}
memcpy
(
pDst
->
datum
.
p
,
pSrc
->
datum
.
p
,
pSrc
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
);
break
;
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_DECIMAL
:
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
ae6224d9
...
...
@@ -321,103 +321,109 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
static
bool
checkUserName
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
)
{
if
(
NULL
==
pUserName
)
{
return
false
;
}
if
(
pUserName
->
n
>=
TSDB_USER_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG
);
pCxt
->
valid
=
false
;
}
else
{
if
(
pUserName
->
n
>=
TSDB_USER_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG
);
pCxt
->
valid
=
false
;
}
}
return
pCxt
->
valid
;
}
static
bool
checkPassword
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pPasswordToken
,
char
*
pPassword
)
{
if
(
NULL
==
pPasswordToken
)
{
return
false
;
}
if
(
pPasswordToken
->
n
>=
(
TSDB_USET_PASSWORD_LEN
-
2
))
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG
);
pCxt
->
valid
=
false
;
return
false
;
}
strncpy
(
pPassword
,
pPasswordToken
->
z
,
pPasswordToken
->
n
);
strdequote
(
pPassword
);
if
(
strtrim
(
pPassword
)
<=
0
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_PASSWD_EMPTY
);
}
else
if
(
pPasswordToken
->
n
>=
(
TSDB_USET_PASSWORD_LEN
-
2
))
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG
);
pCxt
->
valid
=
false
;
}
else
{
strncpy
(
pPassword
,
pPasswordToken
->
z
,
pPasswordToken
->
n
);
strdequote
(
pPassword
);
if
(
strtrim
(
pPassword
)
<=
0
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_PASSWD_EMPTY
);
pCxt
->
valid
=
false
;
}
}
return
pCxt
->
valid
;
}
static
bool
checkAndSplitEndpoint
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pEp
,
char
*
pFqdn
,
int32_t
*
pPort
)
{
if
(
NULL
==
pEp
)
{
return
false
;
}
if
(
pEp
->
n
>=
TSDB_FQDN_LEN
+
2
+
6
)
{
// format 'fqdn:port'
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG
);
pCxt
->
valid
=
false
;
}
char
ep
[
TSDB_FQDN_LEN
+
2
+
6
];
strncpy
(
ep
,
pEp
->
z
,
pEp
->
n
);
strdequote
(
ep
);
strtrim
(
ep
);
char
*
pColon
=
strchr
(
ep
,
':'
);
if
(
NULL
==
pColon
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ENDPOINT
);
pCxt
->
valid
=
false
;
}
strncpy
(
pFqdn
,
ep
,
pColon
-
ep
);
*
pPort
=
strtol
(
pColon
+
1
,
NULL
,
10
);
if
(
*
pPort
>=
UINT16_MAX
||
*
pPort
<=
0
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_PORT
);
}
else
if
(
pEp
->
n
>=
TSDB_FQDN_LEN
+
2
+
6
)
{
// format 'fqdn:port'
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG
);
pCxt
->
valid
=
false
;
}
else
{
char
ep
[
TSDB_FQDN_LEN
+
2
+
6
];
strncpy
(
ep
,
pEp
->
z
,
pEp
->
n
);
strdequote
(
ep
);
strtrim
(
ep
);
char
*
pColon
=
strchr
(
ep
,
':'
);
if
(
NULL
==
pColon
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ENDPOINT
);
pCxt
->
valid
=
false
;
}
else
{
strncpy
(
pFqdn
,
ep
,
pColon
-
ep
);
*
pPort
=
strtol
(
pColon
+
1
,
NULL
,
10
);
if
(
*
pPort
>=
UINT16_MAX
||
*
pPort
<=
0
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_PORT
);
pCxt
->
valid
=
false
;
}
}
}
return
pCxt
->
valid
;
}
static
bool
checkFqdn
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFqdn
)
{
if
(
NULL
==
pFqdn
)
{
return
false
;
}
if
(
pFqdn
->
n
>=
TSDB_FQDN_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG
);
pCxt
->
valid
=
false
;
}
else
{
if
(
pFqdn
->
n
>=
TSDB_FQDN_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG
);
pCxt
->
valid
=
false
;
}
}
return
pCxt
->
valid
;
}
static
bool
checkPort
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pPortToken
,
int32_t
*
pPort
)
{
if
(
NULL
==
pPortToken
)
{
return
false
;
}
*
pPort
=
strtol
(
pPortToken
->
z
,
NULL
,
10
);
if
(
*
pPort
>=
UINT16_MAX
||
*
pPort
<=
0
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_PORT
);
pCxt
->
valid
=
false
;
}
else
{
*
pPort
=
strtol
(
pPortToken
->
z
,
NULL
,
10
);
if
(
*
pPort
>=
UINT16_MAX
||
*
pPort
<=
0
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_PORT
);
pCxt
->
valid
=
false
;
}
}
return
pCxt
->
valid
;
}
static
bool
checkDbName
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
,
bool
query
)
{
if
(
NULL
==
pDbName
)
{
return
(
query
?
NULL
!=
pCxt
->
pQueryCxt
->
db
:
true
);
pCxt
->
valid
=
(
query
?
NULL
!=
pCxt
->
pQueryCxt
->
db
:
true
);
}
else
{
pCxt
->
valid
=
pDbName
->
n
<
TSDB_DB_NAME_LEN
?
true
:
false
;
}
pCxt
->
valid
=
pDbName
->
n
<
TSDB_DB_NAME_LEN
?
true
:
false
;
return
pCxt
->
valid
;
}
static
bool
checkTableName
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pTableName
)
{
if
(
NULL
==
pTableName
)
{
return
true
;
pCxt
->
valid
=
true
;
}
else
{
pCxt
->
valid
=
pTableName
->
n
<
TSDB_TABLE_NAME_LEN
?
true
:
false
;
}
pCxt
->
valid
=
pTableName
->
n
<
TSDB_TABLE_NAME_LEN
?
true
:
false
;
return
pCxt
->
valid
;
}
static
bool
checkColumnName
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pColumnName
)
{
if
(
NULL
==
pColumnName
)
{
return
true
;
pCxt
->
valid
=
true
;
}
else
{
pCxt
->
valid
=
pColumnName
->
n
<
TSDB_COL_NAME_LEN
?
true
:
false
;
}
pCxt
->
valid
=
pColumnName
->
n
<
TSDB_COL_NAME_LEN
?
true
:
false
;
return
pCxt
->
valid
;
}
...
...
@@ -517,6 +523,10 @@ SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral)
}
SNode
*
createDefaultDatabaseCondValue
(
SAstCreateContext
*
pCxt
)
{
if
(
NULL
==
pCxt
->
pQueryCxt
->
db
)
{
return
NULL
;
}
SValueNode
*
val
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
CHECK_OUT_OF_MEM
(
val
);
val
->
literal
=
strdup
(
pCxt
->
pQueryCxt
->
db
);
...
...
@@ -590,6 +600,7 @@ SNode* createRealTableNode(SAstCreateContext* pCxt, const SToken* pDbName, const
strncpy
(
realTable
->
table
.
tableAlias
,
pTableName
->
z
,
pTableName
->
n
);
}
strncpy
(
realTable
->
table
.
tableName
,
pTableName
->
z
,
pTableName
->
n
);
strcpy
(
realTable
->
useDbName
,
pCxt
->
pQueryCxt
->
db
);
return
(
SNode
*
)
realTable
;
}
...
...
@@ -920,7 +931,16 @@ SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) {
return
(
SNode
*
)
pStmt
;
}
static
bool
needDbShowStmt
(
ENodeType
type
)
{
return
QUERY_NODE_SHOW_TABLES_STMT
==
type
||
QUERY_NODE_SHOW_STABLES_STMT
==
type
||
QUERY_NODE_SHOW_VGROUPS_STMT
==
type
;
}
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
SNode
*
pDbName
,
SNode
*
pTbNamePattern
)
{
if
(
needDbShowStmt
(
type
)
&&
NULL
==
pDbName
&&
NULL
==
pCxt
->
pQueryCxt
->
db
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"db not specified"
);
pCxt
->
valid
=
false
;
return
NULL
;
}
SShowStmt
*
pStmt
=
nodesMakeNode
(
type
);;
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
pDbName
=
pDbName
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
ae6224d9
...
...
@@ -559,6 +559,33 @@ static int32_t toVgroupsInfo(SArray* pVgs, SVgroupsInfo** pVgsInfo) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
setSysTableVgroupList
(
SParseContext
*
pCxt
,
SName
*
pName
,
SRealTableNode
*
pRealTable
)
{
// todo release
// if (0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USER_TABLES)) {
// return TSDB_CODE_SUCCESS;
// }
int32_t
code
=
TSDB_CODE_SUCCESS
;
SArray
*
vgroupList
=
NULL
;
if
(
'\0'
!=
pRealTable
->
useDbName
[
0
])
{
code
=
getDBVgInfo
(
pCxt
,
pRealTable
->
useDbName
,
&
vgroupList
);
}
else
{
code
=
getDBVgInfoImpl
(
pCxt
,
pName
,
&
vgroupList
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
// todo remove
if
(
NULL
!=
vgroupList
&&
taosArrayGetSize
(
vgroupList
)
>
0
&&
0
!=
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_USER_TABLES
))
{
taosArrayPopTailBatch
(
vgroupList
,
taosArrayGetSize
(
vgroupList
)
-
1
);
}
code
=
toVgroupsInfo
(
vgroupList
,
&
pRealTable
->
pVgroupList
);
}
taosArrayDestroy
(
vgroupList
);
return
code
;
}
static
int32_t
setTableVgroupList
(
SParseContext
*
pCxt
,
SName
*
pName
,
SRealTableNode
*
pRealTable
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
TSDB_SUPER_TABLE
==
pRealTable
->
pMeta
->
tableType
)
{
...
...
@@ -569,12 +596,7 @@ static int32_t setTableVgroupList(SParseContext* pCxt, SName* pName, SRealTableN
}
taosArrayDestroy
(
vgroupList
);
}
else
if
(
TSDB_SYSTEM_TABLE
==
pRealTable
->
pMeta
->
tableType
)
{
SArray
*
vgroupList
=
NULL
;
code
=
getDBVgInfoImpl
(
pCxt
,
pName
,
&
vgroupList
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
toVgroupsInfo
(
vgroupList
,
&
pRealTable
->
pVgroupList
);
}
taosArrayDestroy
(
vgroupList
);
code
=
setSysTableVgroupList
(
pCxt
,
pName
,
pRealTable
);
}
else
{
pRealTable
->
pVgroupList
=
calloc
(
1
,
sizeof
(
SVgroupsInfo
)
+
sizeof
(
SVgroupInfo
));
if
(
NULL
==
pRealTable
->
pVgroupList
)
{
...
...
@@ -1165,9 +1187,6 @@ static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) {
static
int32_t
translateShowTables
(
STranslateContext
*
pCxt
)
{
SVShowTablesReq
*
pShowReq
=
calloc
(
1
,
sizeof
(
SVShowTablesReq
));
if
(
pCxt
->
pParseCxt
->
db
==
NULL
||
strlen
(
pCxt
->
pParseCxt
->
db
)
==
0
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_TSC_INVALID_OPERATION
,
"db not specified"
);
}
SArray
*
array
=
NULL
;
int32_t
code
=
getDBVgInfo
(
pCxt
->
pParseCxt
,
pCxt
->
pParseCxt
->
db
,
&
array
);
...
...
@@ -1355,7 +1374,7 @@ static int32_t createOperatorNode(EOperatorType opType, const char* pColName, SN
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pOper
->
opType
=
OP_TYPE_LIKE
;
pOper
->
opType
=
opType
;
pOper
->
pLeft
=
nodesMakeNode
(
QUERY_NODE_COLUMN
);
pOper
->
pRight
=
nodesCloneNode
(
pRight
);
if
(
NULL
==
pOper
->
pLeft
||
NULL
==
pOper
->
pRight
)
{
...
...
@@ -1413,6 +1432,10 @@ static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect)
pSelect
->
pWhere
=
(
NULL
==
pDbCond
?
pTbCond
:
pDbCond
);
}
if
(
NULL
!=
pShow
->
pDbName
)
{
strcpy
(((
SRealTableNode
*
)
pSelect
->
pFromTable
)
->
useDbName
,
((
SValueNode
*
)
pShow
->
pDbName
)
->
literal
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
ae6224d9
...
...
@@ -28,58 +28,58 @@ namespace {
void
generateInformationSchema
(
MockCatalogService
*
mcs
)
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"dnodes"
,
TSDB_
NORMAL
_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"dnodes"
,
TSDB_
SYSTEM
_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"mnodes"
,
TSDB_
NORMAL
_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"mnodes"
,
TSDB_
SYSTEM
_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"modules"
,
TSDB_
NORMAL
_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"modules"
,
TSDB_
SYSTEM
_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"qnodes"
,
TSDB_
NORMAL
_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"qnodes"
,
TSDB_
SYSTEM
_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_databases"
,
TSDB_
NORMAL
_TABLE
,
1
).
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_databases"
,
TSDB_
SYSTEM
_TABLE
,
1
).
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_functions"
,
TSDB_
NORMAL
_TABLE
,
1
).
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_FUNC_NAME_LEN
);
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_functions"
,
TSDB_
SYSTEM
_TABLE
,
1
).
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_FUNC_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_indexes"
,
TSDB_
NORMAL
_TABLE
,
2
)
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_indexes"
,
TSDB_
SYSTEM
_TABLE
,
2
)
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
).
addColumn
(
"table_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_stables"
,
TSDB_
NORMAL
_TABLE
,
2
)
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_stables"
,
TSDB_
SYSTEM
_TABLE
,
2
)
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
).
addColumn
(
"stable_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_streams"
,
TSDB_
NORMAL
_TABLE
,
1
).
addColumn
(
"stream_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_streams"
,
TSDB_
SYSTEM
_TABLE
,
1
).
addColumn
(
"stream_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_tables"
,
TSDB_
NORMAL
_TABLE
,
2
)
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_tables"
,
TSDB_
SYSTEM
_TABLE
,
2
)
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
).
addColumn
(
"table_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_table_distributed"
,
TSDB_
NORMAL
_TABLE
,
1
).
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_table_distributed"
,
TSDB_
SYSTEM
_TABLE
,
1
).
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_users"
,
TSDB_
NORMAL
_TABLE
,
1
).
addColumn
(
"user_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
);
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_users"
,
TSDB_
SYSTEM
_TABLE
,
1
).
addColumn
(
"user_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"vgroups"
,
TSDB_
NORMAL
_TABLE
,
1
).
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"vgroups"
,
TSDB_
SYSTEM
_TABLE
,
1
).
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
builder
.
done
();
}
}
...
...
@@ -124,6 +124,10 @@ int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* ve
return
0
;
}
int32_t
__catalogGetDBVgInfo
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbFName
,
SArray
**
vgroupList
)
{
return
0
;
}
void
initMetaDataEnv
()
{
mockCatalogService
.
reset
(
new
MockCatalogService
());
...
...
@@ -133,6 +137,7 @@ void initMetaDataEnv() {
stub
.
set
(
catalogGetTableHashVgroup
,
__catalogGetTableHashVgroup
);
stub
.
set
(
catalogGetTableDistVgInfo
,
__catalogGetTableDistVgInfo
);
stub
.
set
(
catalogGetDBVgVersion
,
__catalogGetDBVgVersion
);
stub
.
set
(
catalogGetDBVgInfo
,
__catalogGetDBVgInfo
);
// {
// AddrAny any("libcatalog.so");
// std::map<std::string,void*> result;
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
ae6224d9
...
...
@@ -272,10 +272,15 @@ static SPhysiNode* createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubp
SSystemTableScanPhysiNode
*
pScan
=
(
SSystemTableScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
);
CHECK_ALLOC
(
pScan
,
NULL
);
CHECK_CODE
(
initScanPhysiNode
(
pCxt
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pScan
),
(
SPhysiNode
*
)
pScan
);
for
(
int32_t
i
=
0
;
i
<
pScanLogicNode
->
pVgroupList
->
numOfVgroups
;
++
i
)
{
SQueryNodeAddr
addr
;
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
+
i
,
&
addr
);
taosArrayPush
(
pCxt
->
pExecNodeList
,
&
addr
);
if
(
0
==
strcmp
(
pScanLogicNode
->
tableName
.
tname
,
TSDB_INS_TABLE_USER_TABLES
))
{
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
taosArrayPush
(
pCxt
->
pExecNodeList
,
&
pSubplan
->
execNode
);
}
else
{
for
(
int32_t
i
=
0
;
i
<
pScanLogicNode
->
pVgroupList
->
numOfVgroups
;
++
i
)
{
SQueryNodeAddr
addr
;
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
+
i
,
&
addr
);
taosArrayPush
(
pCxt
->
pExecNodeList
,
&
addr
);
}
}
pScan
->
mgmtEpSet
=
pCxt
->
pPlanCxt
->
mgmtEpSet
;
tNameGetFullDbName
(
&
pScanLogicNode
->
tableName
,
pSubplan
->
dbFName
);
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
ae6224d9
...
...
@@ -44,7 +44,8 @@ typedef struct SStsInfo {
}
SStsInfo
;
static
SLogicNode
*
stsMatchByNode
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
)
&&
TSDB_SUPER_TABLE
==
((
SScanLogicNode
*
)
pNode
)
->
pMeta
->
tableType
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
)
&&
NULL
!=
((
SScanLogicNode
*
)
pNode
)
->
pVgroupList
&&
((
SScanLogicNode
*
)
pNode
)
->
pVgroupList
->
numOfVgroups
>
1
)
{
return
pNode
;
}
SNode
*
pChild
;
...
...
source/libs/planner/test/plannerTest.cpp
浏览文件 @
ae6224d9
...
...
@@ -173,3 +173,10 @@ TEST_F(PlannerTest, interval) {
bind
(
"SELECT count(*) FROM t1 interval(10s)"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
PlannerTest
,
showTables
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show tables"
);
ASSERT_TRUE
(
run
());
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录