Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
730fbe42
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看板
提交
730fbe42
编写于
1月 05, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:add logic for system table ins_columns
上级
b0662557
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
225 addition
and
7 deletion
+225
-7
include/client/taos.h
include/client/taos.h
+1
-0
include/common/systable.h
include/common/systable.h
+1
-0
include/common/tmsg.h
include/common/tmsg.h
+1
-0
source/client/src/clientMain.c
source/client/src/clientMain.c
+25
-0
source/common/src/systable.c
source/common/src/systable.c
+13
-0
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+2
-0
source/libs/executor/src/sysscanoperator.c
source/libs/executor/src/sysscanoperator.c
+137
-3
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+28
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+11
-3
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+4
-0
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+2
-1
未找到文件。
include/client/taos.h
浏览文件 @
730fbe42
...
...
@@ -208,6 +208,7 @@ DLL_EXPORT TAOS_ROW *taos_result_block(TAOS_RES *res);
DLL_EXPORT
const
char
*
taos_get_server_info
(
TAOS
*
taos
);
DLL_EXPORT
const
char
*
taos_get_client_info
();
DLL_EXPORT
const
char
*
taos_get_current_db
(
TAOS
*
taos
,
size_t
*
required
);
DLL_EXPORT
const
char
*
taos_errstr
(
TAOS_RES
*
res
);
DLL_EXPORT
int
taos_errno
(
TAOS_RES
*
res
);
...
...
include/common/systable.h
浏览文件 @
730fbe42
...
...
@@ -36,6 +36,7 @@ extern "C" {
#define TSDB_INS_TABLE_STABLES "ins_stables"
#define TSDB_INS_TABLE_TABLES "ins_tables"
#define TSDB_INS_TABLE_TAGS "ins_tags"
#define TSDB_INS_TABLE_COLS "ins_columns"
#define TSDB_INS_TABLE_TABLE_DISTRIBUTED "ins_table_distributed"
#define TSDB_INS_TABLE_USERS "ins_users"
#define TSDB_INS_TABLE_LICENCES "ins_grants"
...
...
include/common/tmsg.h
浏览文件 @
730fbe42
...
...
@@ -115,6 +115,7 @@ typedef enum _mgmt_table {
TSDB_MGMT_TABLE_STREAMS
,
TSDB_MGMT_TABLE_TABLE
,
TSDB_MGMT_TABLE_TAG
,
TSDB_MGMT_TABLE_COL
,
TSDB_MGMT_TABLE_USER
,
TSDB_MGMT_TABLE_GRANTS
,
TSDB_MGMT_TABLE_VGROUP
,
...
...
source/client/src/clientMain.c
浏览文件 @
730fbe42
...
...
@@ -430,6 +430,22 @@ const char *taos_data_type(int type) {
return
"TSDB_DATA_TYPE_NCHAR"
;
case
TSDB_DATA_TYPE_JSON
:
return
"TSDB_DATA_TYPE_JSON"
;
case
TSDB_DATA_TYPE_UTINYINT
:
return
"TSDB_DATA_TYPE_UTINYINT"
;
case
TSDB_DATA_TYPE_USMALLINT
:
return
"TSDB_DATA_TYPE_USMALLINT"
;
case
TSDB_DATA_TYPE_UINT
:
return
"TSDB_DATA_TYPE_UINT"
;
case
TSDB_DATA_TYPE_UBIGINT
:
return
"TSDB_DATA_TYPE_UBIGINT"
;
case
TSDB_DATA_TYPE_VARBINARY
:
return
"TSDB_DATA_TYPE_VARBINARY"
;
case
TSDB_DATA_TYPE_DECIMAL
:
return
"TSDB_DATA_TYPE_DECIMAL"
;
case
TSDB_DATA_TYPE_BLOB
:
return
"TSDB_DATA_TYPE_BLOB"
;
case
TSDB_DATA_TYPE_MEDIUMBLOB
:
return
"TSDB_DATA_TYPE_MEDIUMBLOB"
;
default:
return
"UNKNOWN"
;
}
...
...
@@ -670,6 +686,15 @@ const char *taos_get_server_info(TAOS *taos) {
return
pTscObj
->
sDetailVer
;
}
const
char
*
taos_get_current_db
(
TAOS
*
taos
,
size_t
*
required
)
{
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
pTscObj
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
return
pTscObj
->
db
;
}
static
void
destoryTablesReq
(
void
*
p
)
{
STablesReq
*
pRes
=
(
STablesReq
*
)
p
;
taosArrayDestroy
(
pRes
->
pTables
);
...
...
source/common/src/systable.c
浏览文件 @
730fbe42
...
...
@@ -176,6 +176,18 @@ static const SSysDbTableSchema userTagsSchema[] = {
{.
name
=
"tag_value"
,
.
bytes
=
TSDB_MAX_TAGS_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
};
static
const
SSysDbTableSchema
userColsSchema
[]
=
{
{.
name
=
"table_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"stable_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"col_name"
,
.
bytes
=
TSDB_COL_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"col_type"
,
.
bytes
=
32
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"col_length"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
,
.
sysInfo
=
false
},
{.
name
=
"col_precision"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
,
.
sysInfo
=
false
},
{.
name
=
"col_scale"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
,
.
sysInfo
=
false
},
{.
name
=
"col_nullable"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
,
.
sysInfo
=
false
},
};
static
const
SSysDbTableSchema
userTblDistSchema
[]
=
{
{.
name
=
"db_name"
,
.
bytes
=
32
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
true
},
{.
name
=
"table_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
true
},
...
...
@@ -292,6 +304,7 @@ static const SSysTableMeta infosMeta[] = {
{
TSDB_INS_TABLE_STABLES
,
userStbsSchema
,
tListLen
(
userStbsSchema
),
false
},
{
TSDB_INS_TABLE_TABLES
,
userTblsSchema
,
tListLen
(
userTblsSchema
),
false
},
{
TSDB_INS_TABLE_TAGS
,
userTagsSchema
,
tListLen
(
userTagsSchema
),
false
},
{
TSDB_INS_TABLE_COLS
,
userColsSchema
,
tListLen
(
userColsSchema
),
false
},
// {TSDB_INS_TABLE_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)},
{
TSDB_INS_TABLE_USERS
,
userUsersSchema
,
tListLen
(
userUsersSchema
),
false
},
{
TSDB_INS_TABLE_LICENCES
,
grantsSchema
,
tListLen
(
grantsSchema
),
true
},
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
730fbe42
...
...
@@ -76,6 +76,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
type
=
TSDB_MGMT_TABLE_TABLE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TAGS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_TAG
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_COLS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_COL
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TABLE_DISTRIBUTED
,
len
)
==
0
)
{
// type = TSDB_MGMT_TABLE_DIST;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USERS
,
len
)
==
0
)
{
...
...
source/libs/executor/src/sysscanoperator.c
浏览文件 @
730fbe42
...
...
@@ -413,6 +413,135 @@ static bool sysTableIsCondOnOneTable(SNode* pCond, char* condTable) {
return
false
;
}
static
SSDataBlock
*
sysTableScanUserCols
(
SOperatorInfo
*
pOperator
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SSysTableScanInfo
*
pInfo
=
pOperator
->
info
;
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
}
blockDataCleanup
(
pInfo
->
pRes
);
int32_t
numOfRows
=
0
;
SSDataBlock
*
dataBlock
=
buildInfoSchemaTableMetaBlock
(
TSDB_INS_TABLE_COLS
);
blockDataEnsureCapacity
(
dataBlock
,
pOperator
->
resultInfo
.
capacity
);
const
char
*
db
=
NULL
;
int32_t
vgId
=
0
;
vnodeGetInfo
(
pInfo
->
readHandle
.
vnode
,
&
db
,
&
vgId
);
SName
sn
=
{
0
};
char
dbname
[
TSDB_DB_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
tNameFromString
(
&
sn
,
db
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameGetDbName
(
&
sn
,
varDataVal
(
dbname
));
varDataSetLen
(
dbname
,
strlen
(
varDataVal
(
dbname
)));
char
condTableName
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
// optimize when sql like where table_name='tablename' and xxx.
if
(
pInfo
->
pCondition
&&
sysTableIsCondOnOneTable
(
pInfo
->
pCondition
,
condTableName
))
{
char
tableName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
tableName
,
condTableName
);
SMetaReader
smrChildTable
=
{
0
};
metaReaderInit
(
&
smrChildTable
,
pInfo
->
readHandle
.
meta
,
0
);
int32_t
code
=
metaGetTableEntryByName
(
&
smrChildTable
,
condTableName
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// terrno has been set by metaGetTableEntryByName, therefore, return directly
metaReaderClear
(
&
smrChildTable
);
blockDataDestroy
(
dataBlock
);
pInfo
->
loadInfo
.
totalRows
=
0
;
return
NULL
;
}
if
(
smrChildTable
.
me
.
type
!=
TSDB_CHILD_TABLE
)
{
metaReaderClear
(
&
smrChildTable
);
blockDataDestroy
(
dataBlock
);
pInfo
->
loadInfo
.
totalRows
=
0
;
return
NULL
;
}
SMetaReader
smrSuperTable
=
{
0
};
metaReaderInit
(
&
smrSuperTable
,
pInfo
->
readHandle
.
meta
,
META_READER_NOLOCK
);
code
=
metaGetTableEntryByUid
(
&
smrSuperTable
,
smrChildTable
.
me
.
ctbEntry
.
suid
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// terrno has been set by metaGetTableEntryByUid
metaReaderClear
(
&
smrSuperTable
);
metaReaderClear
(
&
smrChildTable
);
blockDataDestroy
(
dataBlock
);
return
NULL
;
}
sysTableUserTagsFillOneTableTags
(
pInfo
,
&
smrSuperTable
,
&
smrChildTable
,
dbname
,
tableName
,
&
numOfRows
,
dataBlock
);
metaReaderClear
(
&
smrSuperTable
);
metaReaderClear
(
&
smrChildTable
);
if
(
numOfRows
>
0
)
{
relocateAndFilterSysTagsScanResult
(
pInfo
,
numOfRows
,
dataBlock
,
pOperator
->
exprSupp
.
pFilterInfo
);
numOfRows
=
0
;
}
blockDataDestroy
(
dataBlock
);
pInfo
->
loadInfo
.
totalRows
+=
pInfo
->
pRes
->
info
.
rows
;
setOperatorCompleted
(
pOperator
);
return
(
pInfo
->
pRes
->
info
.
rows
==
0
)
?
NULL
:
pInfo
->
pRes
;
}
int32_t
ret
=
0
;
if
(
pInfo
->
pCur
==
NULL
)
{
pInfo
->
pCur
=
metaOpenTbCursor
(
pInfo
->
readHandle
.
meta
);
}
while
((
ret
=
metaTbCursorNext
(
pInfo
->
pCur
))
==
0
)
{
if
(
pInfo
->
pCur
->
mr
.
me
.
type
!=
TSDB_CHILD_TABLE
)
{
continue
;
}
char
tableName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
tableName
,
pInfo
->
pCur
->
mr
.
me
.
name
);
SMetaReader
smrSuperTable
=
{
0
};
metaReaderInit
(
&
smrSuperTable
,
pInfo
->
readHandle
.
meta
,
0
);
uint64_t
suid
=
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
suid
;
int32_t
code
=
metaGetTableEntryByUid
(
&
smrSuperTable
,
suid
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to get super table meta, uid:0x%"
PRIx64
", code:%s, %s"
,
suid
,
tstrerror
(
terrno
),
GET_TASKID
(
pTaskInfo
));
metaReaderClear
(
&
smrSuperTable
);
metaCloseTbCursor
(
pInfo
->
pCur
);
pInfo
->
pCur
=
NULL
;
T_LONG_JMP
(
pTaskInfo
->
env
,
terrno
);
}
sysTableUserTagsFillOneTableTags
(
pInfo
,
&
smrSuperTable
,
&
pInfo
->
pCur
->
mr
,
dbname
,
tableName
,
&
numOfRows
,
dataBlock
);
metaReaderClear
(
&
smrSuperTable
);
if
(
numOfRows
>=
pOperator
->
resultInfo
.
capacity
)
{
relocateAndFilterSysTagsScanResult
(
pInfo
,
numOfRows
,
dataBlock
,
pOperator
->
exprSupp
.
pFilterInfo
);
numOfRows
=
0
;
if
(
pInfo
->
pRes
->
info
.
rows
>
0
)
{
break
;
}
}
}
if
(
numOfRows
>
0
)
{
relocateAndFilterSysTagsScanResult
(
pInfo
,
numOfRows
,
dataBlock
,
pOperator
->
exprSupp
.
pFilterInfo
);
numOfRows
=
0
;
}
blockDataDestroy
(
dataBlock
);
if
(
ret
!=
0
)
{
metaCloseTbCursor
(
pInfo
->
pCur
);
pInfo
->
pCur
=
NULL
;
setOperatorCompleted
(
pOperator
);
}
pInfo
->
loadInfo
.
totalRows
+=
pInfo
->
pRes
->
info
.
rows
;
return
(
pInfo
->
pRes
->
info
.
rows
==
0
)
?
NULL
:
pInfo
->
pRes
;
}
static
SSDataBlock
*
sysTableScanUserTags
(
SOperatorInfo
*
pOperator
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SSysTableScanInfo
*
pInfo
=
pOperator
->
info
;
...
...
@@ -1321,6 +1450,8 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
pBlock
=
sysTableScanUserTables
(
pOperator
);
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TAGS
,
TSDB_TABLE_FNAME_LEN
)
==
0
)
{
pBlock
=
sysTableScanUserTags
(
pOperator
);
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_COLS
,
TSDB_TABLE_FNAME_LEN
)
==
0
)
{
pBlock
=
sysTableScanUserCols
(
pOperator
);
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_STABLES
,
TSDB_TABLE_FNAME_LEN
)
==
0
&&
pInfo
->
showRewrite
&&
IS_SYS_DBNAME
(
dbName
))
{
pBlock
=
sysTableScanUserSTables
(
pOperator
);
...
...
@@ -1427,6 +1558,7 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
readHandle
,
SSystemTableScanPhysiNode
*
pScanPhyNode
,
const
char
*
pUser
,
SExecTaskInfo
*
pTaskInfo
)
{
int32_t
code
=
TDB_CODE_SUCCESS
;
SSysTableScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SSysTableScanInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
...
@@ -1437,7 +1569,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
SDataBlockDescNode
*
pDescNode
=
pScanNode
->
node
.
pOutputDataBlockDesc
;
int32_t
num
=
0
;
int32_t
code
=
extractColMatchInfo
(
pScanNode
->
pScanCols
,
pDescNode
,
&
num
,
COL_MATCH_FROM_COL_ID
,
&
pInfo
->
matchInfo
);
code
=
extractColMatchInfo
(
pScanNode
->
pScanCols
,
pDescNode
,
&
num
,
COL_MATCH_FROM_COL_ID
,
&
pInfo
->
matchInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -1463,7 +1595,8 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
const
char
*
name
=
tNameGetTableName
(
&
pInfo
->
name
);
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TABLES
,
TSDB_TABLE_FNAME_LEN
)
==
0
||
strncasecmp
(
name
,
TSDB_INS_TABLE_TAGS
,
TSDB_TABLE_FNAME_LEN
)
==
0
)
{
strncasecmp
(
name
,
TSDB_INS_TABLE_TAGS
,
TSDB_TABLE_FNAME_LEN
)
==
0
||
strncasecmp
(
name
,
TSDB_INS_TABLE_COLS
,
TSDB_TABLE_FNAME_LEN
)
==
0
)
{
pInfo
->
readHandle
=
*
(
SReadHandle
*
)
readHandle
;
}
else
{
tsem_init
(
&
pInfo
->
ready
,
0
,
0
);
...
...
@@ -1513,7 +1646,8 @@ void destroySysScanOperator(void* param) {
const
char
*
name
=
tNameGetTableName
(
&
pInfo
->
name
);
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TABLES
,
TSDB_TABLE_FNAME_LEN
)
==
0
||
strncasecmp
(
name
,
TSDB_INS_TABLE_TAGS
,
TSDB_TABLE_FNAME_LEN
)
==
0
||
pInfo
->
pCur
!=
NULL
)
{
strncasecmp
(
name
,
TSDB_INS_TABLE_TAGS
,
TSDB_TABLE_FNAME_LEN
)
==
0
||
strncasecmp
(
name
,
TSDB_INS_TABLE_COLS
,
TSDB_TABLE_FNAME_LEN
)
==
0
||
pInfo
->
pCur
!=
NULL
)
{
metaCloseTbCursor
(
pInfo
->
pCur
);
pInfo
->
pCur
=
NULL
;
}
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
730fbe42
...
...
@@ -147,6 +147,16 @@ static int32_t collectMetaKeyFromInsTags(SCollectMetaKeyCxt* pCxt) {
return
code
;
}
static
int32_t
collectMetaKeyFromInsCols
(
SCollectMetaKeyCxt
*
pCxt
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pCxt
->
pStmt
;
SName
name
=
{
0
};
int32_t
code
=
getVnodeSysTableTargetName
(
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
);
...
...
@@ -170,6 +180,11 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c
QUERY_NODE_SELECT_STMT
==
nodeType
(
pCxt
->
pStmt
))
{
code
=
collectMetaKeyFromInsTags
(
pCxt
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_COLS
)
&&
QUERY_NODE_SELECT_STMT
==
nodeType
(
pCxt
->
pStmt
))
{
code
=
collectMetaKeyFromInsCols
(
pCxt
);
}
return
code
;
}
...
...
@@ -475,6 +490,19 @@ static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* p
return
code
;
}
static
int32_t
collectMetaKeyFromShowCols
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_COLS
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pStmt
->
pTbName
)
{
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
((
SValueNode
*
)
pStmt
->
pTbName
)
->
literal
,
pCxt
->
pMetaCache
);
}
return
code
;
}
static
int32_t
collectMetaKeyFromShowStableTags
(
SCollectMetaKeyCxt
*
pCxt
,
SShowTableTagsStmt
*
pStmt
)
{
return
collectMetaKeyFromRealTableImpl
(
pCxt
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
((
SValueNode
*
)
pStmt
->
pTbName
)
->
literal
,
AUTH_TYPE_READ
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
730fbe42
...
...
@@ -162,6 +162,13 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_TAGS_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_COLS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_USERS_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
...
...
@@ -2210,7 +2217,7 @@ static int32_t dnodeToVgroupsInfo(SArray* pDnodes, SVgroupsInfo** pVgsInfo) {
}
static
bool
sysTableFromVnode
(
const
char
*
pTable
)
{
return
((
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TABLES
))
||
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TAGS
)));
return
((
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TABLES
))
||
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TAGS
))
||
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_COLS
))
);
}
static
bool
sysTableFromDnode
(
const
char
*
pTable
)
{
return
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_DNODE_VARIABLES
);
}
...
...
@@ -2273,7 +2280,7 @@ static int32_t setVnodeSysTableVgroupList(STranslateContext* pCxt, SName* pName,
SArray
*
pVgs
=
NULL
;
int32_t
code
=
getVnodeSysTableVgroupList
(
pCxt
,
pName
,
&
pVgs
,
&
hasUserDbCond
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TAGS
)
&&
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TAGS
)
&&
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_COLS
)
&&
isSelectStmt
(
pCxt
->
pCurrStmt
)
&&
0
==
taosArrayGetSize
(
pVgs
))
{
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
isEmptyResult
=
true
;
}
...
...
@@ -2376,7 +2383,8 @@ static bool isSingleTable(SRealTableNode* pRealTable) {
int8_t
tableType
=
pRealTable
->
pMeta
->
tableType
;
if
(
TSDB_SYSTEM_TABLE
==
tableType
)
{
return
0
!=
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TABLES
)
&&
0
!=
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TAGS
);
0
!=
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_TAGS
)
&&
0
!=
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_COLS
);
}
return
(
TSDB_CHILD_TABLE
==
tableType
||
TSDB_NORMAL_TABLE
==
tableType
);
}
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
730fbe42
...
...
@@ -102,6 +102,10 @@ void generateInformationSchema(MockCatalogService* mcs) {
.
addColumn
(
"table_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
)
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
)
.
done
();
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_COLS
,
TSDB_SYSTEM_TABLE
,
2
)
.
addColumn
(
"table_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
)
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
)
.
done
();
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_USER_PRIVILEGES
,
TSDB_SYSTEM_TABLE
,
2
)
.
addColumn
(
"user_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
)
.
addColumn
(
"privilege"
,
TSDB_DATA_TYPE_BINARY
,
10
)
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
730fbe42
...
...
@@ -609,7 +609,8 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
pScan
->
accountId
=
pCxt
->
pPlanCxt
->
acctId
;
pScan
->
sysInfo
=
pCxt
->
pPlanCxt
->
sysInfo
;
if
(
0
==
strcmp
(
pScanLogicNode
->
tableName
.
tname
,
TSDB_INS_TABLE_TABLES
)
||
0
==
strcmp
(
pScanLogicNode
->
tableName
.
tname
,
TSDB_INS_TABLE_TAGS
))
{
0
==
strcmp
(
pScanLogicNode
->
tableName
.
tname
,
TSDB_INS_TABLE_TAGS
)
||
0
==
strcmp
(
pScanLogicNode
->
tableName
.
tname
,
TSDB_INS_TABLE_COLS
))
{
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
}
else
{
pSubplan
->
execNode
.
nodeId
=
MNODE_HANDLE
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录