未验证 提交 98cd9450 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #22031 from taosdata/enh/TS-2500

enh: add show create database command for system dbs
......@@ -286,6 +286,9 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch
hashPrefix = pCfg->hashPrefix + dbFNameLen + 1;
}
if (IS_SYS_DBNAME(dbName)) {
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE DATABASE `%s`", dbName);
} else {
len += sprintf(
buf2 + VARSTR_HEADER_SIZE,
"CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %dm "
......@@ -301,6 +304,7 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", retentions);
taosMemoryFree(retentions);
}
}
(varDataLen(buf2)) = len;
......
......@@ -509,6 +509,10 @@ static int32_t getDBVgVersion(STranslateContext* pCxt, const char* pDbFName, int
}
static int32_t getDBCfg(STranslateContext* pCxt, const char* pDbName, SDbCfgInfo* pInfo) {
if (IS_SYS_DBNAME(pDbName)) {
return TSDB_CODE_SUCCESS;
}
SParseContext* pParCxt = pCxt->pParseCxt;
SName name;
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pDbName, strlen(pDbName));
......
......@@ -87,6 +87,14 @@ class TDTestCase:
for key,value in sql_dict.items():
create_sql += f' {key} {value}'
return create_sql
def show_create_sysdb_sql(self):
sysdb_list = {'information_schema', 'performance_schema'}
for db in sysdb_list:
tdSql.query(f'show create database {db}')
tdSql.checkEqual(f'{db}',tdSql.queryResult[0][0])
tdSql.checkEqual(f'CREATE DATABASE `{db}`',tdSql.queryResult[0][1])
def show_create_sql(self):
create_db_sql = self.set_create_database_sql(self.db_param)
print(create_db_sql)
......@@ -191,6 +199,7 @@ class TDTestCase:
self.ins_check()
self.perf_check()
self.show_create_sql()
self.show_create_sysdb_sql()
def stop(self):
tdSql.close()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册