Merge pull request #22130 from taosdata/fix/TD-25270
enh: support show create table for system tables
This commit is contained in:
commit
d81727afa9
|
@ -39,6 +39,7 @@ int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char *dbFName, char *stbFName, vo
|
|||
|
||||
void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst);
|
||||
void mndExtractShortDbNameFromStbFullName(const char *stbFullName, char *dst);
|
||||
void mndExtractShortDbNameFromDbFullName(const char *stbFullName, char *dst);
|
||||
void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t dstSize);
|
||||
|
||||
const char *mndGetStbStr(const char *src);
|
||||
|
|
|
@ -2498,12 +2498,14 @@ static int32_t mndProcessTableCfgReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
if (0 == strcmp(cfgReq.dbFName, TSDB_INFORMATION_SCHEMA_DB)) {
|
||||
char dbName[TSDB_DB_NAME_LEN] = {0};
|
||||
mndExtractShortDbNameFromDbFullName(cfgReq.dbFName, dbName);
|
||||
if (0 == strcmp(dbName, TSDB_INFORMATION_SCHEMA_DB)) {
|
||||
mInfo("information_schema table:%s.%s, start to retrieve cfg", cfgReq.dbFName, cfgReq.tbName);
|
||||
if (mndBuildInsTableCfg(pMnode, cfgReq.dbFName, cfgReq.tbName, &cfgRsp) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
} else if (0 == strcmp(cfgReq.dbFName, TSDB_PERFORMANCE_SCHEMA_DB)) {
|
||||
} else if (0 == strcmp(dbName, TSDB_PERFORMANCE_SCHEMA_DB)) {
|
||||
mInfo("performance_schema table:%s.%s, start to retrieve cfg", cfgReq.dbFName, cfgReq.tbName);
|
||||
if (mndBuildPerfsTableCfg(pMnode, cfgReq.dbFName, cfgReq.tbName, &cfgRsp) != 0) {
|
||||
goto _OVER;
|
||||
|
@ -2672,6 +2674,13 @@ void mndExtractShortDbNameFromStbFullName(const char *stbFullName, char *dst) {
|
|||
tNameGetDbName(&name, dst);
|
||||
}
|
||||
|
||||
void mndExtractShortDbNameFromDbFullName(const char *stbFullName, char *dst) {
|
||||
SName name = {0};
|
||||
tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB);
|
||||
|
||||
tNameGetDbName(&name, dst);
|
||||
}
|
||||
|
||||
void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t dstSize) {
|
||||
int32_t pos = -1;
|
||||
int32_t num = 0;
|
||||
|
|
|
@ -2090,7 +2090,7 @@ int32_t ctgLaunchGetTbCfgTask(SCtgTask* pTask) {
|
|||
}
|
||||
|
||||
CTG_CACHE_NHIT_INC(CTG_CI_TBL_CFG, 1);
|
||||
|
||||
|
||||
if (pCtx->tbType <= 0) {
|
||||
CTG_ERR_JRET(ctgReadTbTypeFromCache(pCtg, dbFName, pCtx->pName->tname, &pCtx->tbType));
|
||||
if (pCtx->tbType <= 0) {
|
||||
|
@ -2102,7 +2102,7 @@ int32_t ctgLaunchGetTbCfgTask(SCtgTask* pTask) {
|
|||
}
|
||||
}
|
||||
|
||||
if (TSDB_SUPER_TABLE == pCtx->tbType) {
|
||||
if (TSDB_SUPER_TABLE == pCtx->tbType || TSDB_SYSTEM_TABLE == pCtx->tbType) {
|
||||
CTG_ERR_JRET(ctgGetTableCfgFromMnode(pCtg, pConn, pCtx->pName, NULL, pTask));
|
||||
} else {
|
||||
if (NULL == pCtx->pVgInfo) {
|
||||
|
|
|
@ -95,6 +95,23 @@ class TDTestCase:
|
|||
tdSql.checkEqual(f'{db}',tdSql.queryResult[0][0])
|
||||
tdSql.checkEqual(f'CREATE DATABASE `{db}`',tdSql.queryResult[0][1])
|
||||
|
||||
def show_create_systb_sql(self):
|
||||
for param in self.ins_param_list:
|
||||
tdSql.query(f'show create table information_schema.ins_{param}')
|
||||
tdSql.checkEqual(f'ins_{param}',tdSql.queryResult[0][0])
|
||||
|
||||
tdSql.execute(f'use information_schema')
|
||||
tdSql.query(f'show create table ins_{param}')
|
||||
tdSql.checkEqual(f'ins_{param}',tdSql.queryResult[0][0])
|
||||
|
||||
for param in self.perf_param_list:
|
||||
tdSql.query(f'show create table performance_schema.perf_{param}')
|
||||
tdSql.checkEqual(f'perf_{param}',tdSql.queryResult[0][0])
|
||||
|
||||
tdSql.execute(f'use performance_schema')
|
||||
tdSql.query(f'show create table perf_{param}')
|
||||
tdSql.checkEqual(f'perf_{param}',tdSql.queryResult[0][0])
|
||||
|
||||
def show_create_sql(self):
|
||||
create_db_sql = self.set_create_database_sql(self.db_param)
|
||||
print(create_db_sql)
|
||||
|
@ -200,6 +217,7 @@ class TDTestCase:
|
|||
self.perf_check()
|
||||
self.show_create_sql()
|
||||
self.show_create_sysdb_sql()
|
||||
self.show_create_systb_sql()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
Loading…
Reference in New Issue