show create db
This commit is contained in:
parent
3599b26526
commit
2dc7bcbefc
|
@ -667,6 +667,23 @@ int32_t tSerializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp
|
||||||
|
|
||||||
int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
|
int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char tbName[TSDB_TABLE_NAME_LEN];
|
||||||
|
char stbName[TSDB_TABLE_NAME_LEN];
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
int32_t numOfTags;
|
||||||
|
int32_t numOfColumns;
|
||||||
|
int8_t tableType;
|
||||||
|
int64_t delay1;
|
||||||
|
int64_t delay2;
|
||||||
|
int64_t watermark1;
|
||||||
|
int64_t watermark2;
|
||||||
|
int32_t ttl;
|
||||||
|
char* pAst1;
|
||||||
|
char* pAst2;
|
||||||
|
SSchema* pSchemas;
|
||||||
|
} STableCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
int32_t numOfVgroups;
|
int32_t numOfVgroups;
|
||||||
|
|
|
@ -68,6 +68,7 @@ typedef struct SCatalogReq {
|
||||||
SArray* pIndex; // element is index name
|
SArray* pIndex; // element is index name
|
||||||
SArray* pUser; // element is SUserAuthInfo
|
SArray* pUser; // element is SUserAuthInfo
|
||||||
SArray* pTableIndex; // element is SNAME
|
SArray* pTableIndex; // element is SNAME
|
||||||
|
SArray* pTableCfg; // element is SNAME
|
||||||
bool qNodeRequired; // valid qnode
|
bool qNodeRequired; // valid qnode
|
||||||
bool forceUpdate;
|
bool forceUpdate;
|
||||||
} SCatalogReq;
|
} SCatalogReq;
|
||||||
|
@ -88,6 +89,7 @@ typedef struct SMetaData {
|
||||||
SArray* pIndex; // pRes = SIndexInfo*
|
SArray* pIndex; // pRes = SIndexInfo*
|
||||||
SArray* pUser; // pRes = bool*
|
SArray* pUser; // pRes = bool*
|
||||||
SArray* pQnodeList; // pRes = SQueryNodeAddr*
|
SArray* pQnodeList; // pRes = SQueryNodeAddr*
|
||||||
|
SArray* pTableCfg;
|
||||||
} SMetaData;
|
} SMetaData;
|
||||||
|
|
||||||
typedef struct SCatalogCfg {
|
typedef struct SCatalogCfg {
|
||||||
|
|
|
@ -28,6 +28,10 @@ extern "C" {
|
||||||
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
|
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
|
||||||
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)
|
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
|
#define SHOW_CREATE_DB_RESULT_COLS 2
|
||||||
|
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
|
||||||
|
#define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
|
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
|
||||||
|
|
||||||
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
|
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
|
||||||
|
@ -218,7 +222,7 @@ typedef struct SShowCreateTableStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char dbName[TSDB_DB_NAME_LEN];
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
char tableName[TSDB_TABLE_NAME_LEN];
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
STableMeta* pMeta;
|
void* pCfg; // STableCfg
|
||||||
} SShowCreateTableStmt;
|
} SShowCreateTableStmt;
|
||||||
|
|
||||||
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType;
|
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType;
|
||||||
|
|
|
@ -1394,7 +1394,7 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam
|
||||||
if (orig) {
|
if (orig) {
|
||||||
origType = orig->tableType;
|
origType = orig->tableType;
|
||||||
|
|
||||||
if (origType == meta->tableType && orig->uid == meta->uid && orig->sversion >= meta->sversion && orig->tversion >= meta->tversion) {
|
if (origType == meta->tableType && orig->uid == meta->uid && (origType == TSDB_CHILD_TABLE || (orig->sversion >= meta->sversion && orig->tversion >= meta->tversion))) {
|
||||||
taosMemoryFree(meta);
|
taosMemoryFree(meta);
|
||||||
ctgDebug("ignore table %s meta update", tbName);
|
ctgDebug("ignore table %s meta update", tbName);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
|
||||||
static int32_t getSchemaBytes(const SSchema* pSchema) {
|
static int32_t getSchemaBytes(const SSchema* pSchema) {
|
||||||
switch (pSchema->type) {
|
switch (pSchema->type) {
|
||||||
|
@ -123,7 +124,163 @@ static int32_t execDescribe(SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||||
|
|
||||||
static int32_t execResetQueryCache() { return catalogClearCache(); }
|
static int32_t execResetQueryCache() { return catalogClearCache(); }
|
||||||
|
|
||||||
static int32_t execShowCreateDatabase(SShowCreateDatabaseStmt* pStmt) { return TSDB_CODE_FAILED; }
|
|
||||||
|
static SSDataBlock* buildCreateDBResultDataBlock() {
|
||||||
|
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
|
pBlock->info.numOfCols = SHOW_CREATE_DB_RESULT_COLS;
|
||||||
|
pBlock->info.hasVarCol = true;
|
||||||
|
|
||||||
|
pBlock->pDataBlock = taosArrayInit(pBlock->info.numOfCols, sizeof(SColumnInfoData));
|
||||||
|
|
||||||
|
SColumnInfoData infoData = {0};
|
||||||
|
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
|
infoData.info.bytes = SHOW_CREATE_DB_RESULT_FIELD1_LEN;
|
||||||
|
|
||||||
|
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||||
|
|
||||||
|
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
|
infoData.info.bytes = SHOW_CREATE_DB_RESULT_FIELD2_LEN;
|
||||||
|
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||||
|
|
||||||
|
return pBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t getValOfDiffPrecision(int8_t unit, int64_t val) {
|
||||||
|
int64_t v = 0;
|
||||||
|
switch (unit) {
|
||||||
|
case 's':
|
||||||
|
v = val / 1000;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
v = val / tsTickPerMin[TSDB_TIME_PRECISION_MILLI];
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 60);
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 24 * 60);
|
||||||
|
break;
|
||||||
|
case 'w':
|
||||||
|
v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 24 * 60 * 7);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *buildRetension(SArray *pRetension) {
|
||||||
|
size_t size = taosArrayGetSize(pRetension);
|
||||||
|
if (size == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *p1 = taosMemoryCalloc(1, 100);
|
||||||
|
SRetention *p = taosArrayGet(pRetension, 0);
|
||||||
|
|
||||||
|
int32_t len = 0;
|
||||||
|
|
||||||
|
int64_t v1 = getValOfDiffPrecision(p->freqUnit, p->freq);
|
||||||
|
int64_t v2 = getValOfDiffPrecision(p->keepUnit, p->keep);
|
||||||
|
len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit);
|
||||||
|
|
||||||
|
if (size > 1) {
|
||||||
|
len += sprintf(p1 + len, ",");
|
||||||
|
p = taosArrayGet(pRetension, 1);
|
||||||
|
|
||||||
|
v1 = getValOfDiffPrecision(p->freqUnit, p->freq);
|
||||||
|
v2 = getValOfDiffPrecision(p->keepUnit, p->keep);
|
||||||
|
len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size > 2) {
|
||||||
|
len += sprintf(p1 + len, ",");
|
||||||
|
p = taosArrayGet(pRetension, 2);
|
||||||
|
|
||||||
|
v1 = getValOfDiffPrecision(p->freqUnit, p->freq);
|
||||||
|
v2 = getValOfDiffPrecision(p->keepUnit, p->keep);
|
||||||
|
len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
return p1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char *dbFName, SDbCfgInfo* pCfg) {
|
||||||
|
blockDataEnsureCapacity(pBlock, 1);
|
||||||
|
pBlock->info.rows = 1;
|
||||||
|
|
||||||
|
SColumnInfoData* pCol1 = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
char buf1[SHOW_CREATE_DB_RESULT_FIELD1_LEN] = {0};
|
||||||
|
STR_TO_VARSTR(buf1, dbFName);
|
||||||
|
colDataAppend(pCol1, 0, buf1, false);
|
||||||
|
|
||||||
|
SColumnInfoData* pCol2 = taosArrayGet(pBlock->pDataBlock, 1);
|
||||||
|
char buf2[SHOW_CREATE_DB_RESULT_FIELD2_LEN] = {0};
|
||||||
|
int32_t len = 0;
|
||||||
|
char *prec = NULL;
|
||||||
|
switch (pCfg->precision) {
|
||||||
|
case TSDB_TIME_PRECISION_MILLI:
|
||||||
|
prec = TSDB_TIME_PRECISION_MILLI_STR;
|
||||||
|
break;
|
||||||
|
case TSDB_TIME_PRECISION_MICRO:
|
||||||
|
prec = TSDB_TIME_PRECISION_MICRO_STR;
|
||||||
|
break;
|
||||||
|
case TSDB_TIME_PRECISION_NANO:
|
||||||
|
prec = TSDB_TIME_PRECISION_NANO_STR;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
prec = "none";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *retentions = buildRetension(pCfg->pRetensions);
|
||||||
|
|
||||||
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE DATABASE `%s` BUFFER %d CACHELAST %d COMP %d DURATION %dm "
|
||||||
|
"FSYNC %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
|
||||||
|
"STRICT %d WAL %d VGROUPS %d SINGLE_STABLE %d",
|
||||||
|
dbFName, pCfg->buffer, pCfg->cacheLastRow, pCfg->compression, pCfg->daysPerFile,
|
||||||
|
pCfg->fsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2,
|
||||||
|
pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->strict, pCfg->walLevel, pCfg->numOfVgroups,
|
||||||
|
1 == pCfg->numOfStables);
|
||||||
|
|
||||||
|
if (retentions) {
|
||||||
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", retentions);
|
||||||
|
taosMemoryFree(retentions);
|
||||||
|
}
|
||||||
|
|
||||||
|
(varDataLen(buf2)) = len;
|
||||||
|
|
||||||
|
colDataAppend(pCol2, 0, buf2, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int32_t execShowCreateDatabase(SShowCreateDatabaseStmt* pStmt, SRetrieveTableRsp** pRsp) {
|
||||||
|
SSDataBlock* pBlock = buildCreateDBResultDataBlock();
|
||||||
|
setCreateDBResultIntoDataBlock(pBlock, pStmt->dbName, pStmt->pCfg);
|
||||||
|
|
||||||
|
size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock);
|
||||||
|
*pRsp = taosMemoryCalloc(1, rspSize);
|
||||||
|
if (NULL == *pRsp) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*pRsp)->useconds = 0;
|
||||||
|
(*pRsp)->completed = 1;
|
||||||
|
(*pRsp)->precision = 0;
|
||||||
|
(*pRsp)->compressed = 0;
|
||||||
|
(*pRsp)->compLen = 0;
|
||||||
|
(*pRsp)->numOfRows = htonl(1);
|
||||||
|
(*pRsp)->numOfCols = htonl(SHOW_CREATE_DB_RESULT_COLS);
|
||||||
|
|
||||||
|
int32_t len = 0;
|
||||||
|
blockCompressEncode(pBlock, (*pRsp)->data, &len, SHOW_CREATE_DB_RESULT_COLS, false);
|
||||||
|
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
||||||
|
|
||||||
|
blockDataDestroy(pBlock);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt) { return TSDB_CODE_FAILED; }
|
static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt) { return TSDB_CODE_FAILED; }
|
||||||
|
|
||||||
|
@ -138,7 +295,7 @@ int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||||
case QUERY_NODE_RESET_QUERY_CACHE_STMT:
|
case QUERY_NODE_RESET_QUERY_CACHE_STMT:
|
||||||
return execResetQueryCache();
|
return execResetQueryCache();
|
||||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
return execShowCreateDatabase((SShowCreateDatabaseStmt*)pStmt);
|
return execShowCreateDatabase((SShowCreateDatabaseStmt*)pStmt, pRsp);
|
||||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
return execShowCreateTable((SShowCreateTableStmt*)pStmt);
|
return execShowCreateTable((SShowCreateTableStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
|
|
|
@ -47,6 +47,7 @@ typedef struct SParseMetaCache {
|
||||||
SHashObj* pUserAuth; // key is SUserAuthInfo serialized string, element is bool indicating whether or not to pass
|
SHashObj* pUserAuth; // key is SUserAuthInfo serialized string, element is bool indicating whether or not to pass
|
||||||
SHashObj* pUdf; // key is funcName, element is SFuncInfo*
|
SHashObj* pUdf; // key is funcName, element is SFuncInfo*
|
||||||
SHashObj* pTableIndex; // key is tbFName, element is SArray<STableIndexInfo>*
|
SHashObj* pTableIndex; // key is tbFName, element is SArray<STableIndexInfo>*
|
||||||
|
SHashObj* pTableCfg; // key is tbFName, element is STableMeta*
|
||||||
} SParseMetaCache;
|
} SParseMetaCache;
|
||||||
|
|
||||||
int32_t generateSyntaxErrMsg(SMsgBuf* pBuf, int32_t errCode, ...);
|
int32_t generateSyntaxErrMsg(SMsgBuf* pBuf, int32_t errCode, ...);
|
||||||
|
@ -77,6 +78,7 @@ int32_t reserveUserAuthInCache(int32_t acctId, const char* pUser, const char* pD
|
||||||
int32_t reserveUserAuthInCacheExt(const char* pUser, const SName* pName, AUTH_TYPE type, SParseMetaCache* pMetaCache);
|
int32_t reserveUserAuthInCacheExt(const char* pUser, const SName* pName, AUTH_TYPE type, SParseMetaCache* pMetaCache);
|
||||||
int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache);
|
int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache);
|
||||||
int32_t reserveTableIndexInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache);
|
int32_t reserveTableIndexInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache);
|
||||||
|
int32_t reserveTableCfgInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache);
|
||||||
int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta);
|
int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta);
|
||||||
int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SArray** pVgInfo);
|
int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SArray** pVgInfo);
|
||||||
int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName, SVgroupInfo* pVgroup);
|
int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName, SVgroupInfo* pVgroup);
|
||||||
|
@ -87,6 +89,7 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con
|
||||||
bool* pPass);
|
bool* pPass);
|
||||||
int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFuncInfo* pInfo);
|
int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFuncInfo* pInfo);
|
||||||
int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes);
|
int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes);
|
||||||
|
int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const char* pFunc, STableCfg** pInfo);
|
||||||
void destoryParseMetaCache(SParseMetaCache* pMetaCache);
|
void destoryParseMetaCache(SParseMetaCache* pMetaCache);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -402,7 +402,7 @@ static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SS
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowCreateTable(SCollectMetaKeyCxt* pCxt, SShowCreateTableStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowCreateTable(SCollectMetaKeyCxt* pCxt, SShowCreateTableStmt* pStmt) {
|
||||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
return reserveTableCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowApps(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowApps(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
|
|
@ -133,6 +133,30 @@ static int32_t getTableMeta(STranslateContext* pCxt, const char* pDbName, const
|
||||||
return getTableMetaImpl(pCxt, toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name), pMeta);
|
return getTableMetaImpl(pCxt, toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name), pMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t getTableCfg(STranslateContext* pCxt, const SName* pName, STableCfg** pCfg) {
|
||||||
|
SParseContext* pParCxt = pCxt->pParseCxt;
|
||||||
|
int32_t code = collectUseDatabase(pName, pCxt->pDbs);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = collectUseTable(pName, pCxt->pTables);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
if (pParCxt->async) {
|
||||||
|
code = getTableCfgFromCache(pCxt->pMetaCache, pName, pCfg);
|
||||||
|
} else {
|
||||||
|
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||||
|
.requestId = pParCxt->requestId,
|
||||||
|
.requestObjRefId = pParCxt->requestRid,
|
||||||
|
.mgmtEps = pParCxt->mgmtEpSet};
|
||||||
|
code = catalogGetTableCfg(pParCxt->pCatalog, &conn, pName, pCfg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
parserError("catalogGetTableMeta error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname,
|
||||||
|
pName->tname);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t refreshGetTableMeta(STranslateContext* pCxt, const char* pDbName, const char* pTableName,
|
static int32_t refreshGetTableMeta(STranslateContext* pCxt, const char* pDbName, const char* pTableName,
|
||||||
STableMeta** pMeta) {
|
STableMeta** pMeta) {
|
||||||
SParseContext* pParCxt = pCxt->pParseCxt;
|
SParseContext* pParCxt = pCxt->pParseCxt;
|
||||||
|
@ -4168,7 +4192,7 @@ static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateD
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateShowCreateTable(STranslateContext* pCxt, SShowCreateTableStmt* pStmt) {
|
static int32_t translateShowCreateTable(STranslateContext* pCxt, SShowCreateTableStmt* pStmt) {
|
||||||
return getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta);
|
return getTableCfg(pCxt, pStmt->dbName, pStmt->tableName, (STableCfg*)&pStmt->pCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||||
|
|
|
@ -559,6 +559,9 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = buildTableReq(pMetaCache->pTableIndex, &pCatalogReq->pTableIndex);
|
code = buildTableReq(pMetaCache->pTableIndex, &pCatalogReq->pTableIndex);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = buildTableReq(pMetaCache->pTableCfg, &pCatalogReq->pTableCfg);
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,6 +657,9 @@ int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMet
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = putTableDataToCache(pCatalogReq->pTableIndex, pMetaData->pTableIndex, &pMetaCache->pTableIndex);
|
code = putTableDataToCache(pCatalogReq->pTableIndex, pMetaData->pTableIndex, &pMetaCache->pTableIndex);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = putTableDataToCache(pCatalogReq->pTableCfg, pMetaData->pTableCfg, &pMetaCache->pTableCfg);
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,6 +865,10 @@ int32_t reserveTableIndexInCache(int32_t acctId, const char* pDb, const char* pT
|
||||||
return reserveTableReqInCache(acctId, pDb, pTable, &pMetaCache->pTableIndex);
|
return reserveTableReqInCache(acctId, pDb, pTable, &pMetaCache->pTableIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t reserveTableCfgInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache) {
|
||||||
|
return reserveTableReqInCache(acctId, pDb, pTable, &pMetaCache->pTableCfg);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes) {
|
int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes) {
|
||||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||||
tNameExtractFullName(pName, fullName);
|
tNameExtractFullName(pName, fullName);
|
||||||
|
@ -873,6 +883,20 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName,
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const char* pFunc, STableCfg** pOutput) {
|
||||||
|
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
tNameExtractFullName(pName, fullName);
|
||||||
|
STableCfg* pCfg = NULL;
|
||||||
|
int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableIndex, (void**)&pCfg);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
*pOutput = tableCfgDup(pCfg);
|
||||||
|
if (NULL == *pOutput) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
void destoryParseMetaCache(SParseMetaCache* pMetaCache) {
|
void destoryParseMetaCache(SParseMetaCache* pMetaCache) {
|
||||||
taosHashCleanup(pMetaCache->pTableMeta);
|
taosHashCleanup(pMetaCache->pTableMeta);
|
||||||
taosHashCleanup(pMetaCache->pDbVgroup);
|
taosHashCleanup(pMetaCache->pDbVgroup);
|
||||||
|
@ -882,4 +906,5 @@ void destoryParseMetaCache(SParseMetaCache* pMetaCache) {
|
||||||
taosHashCleanup(pMetaCache->pUserAuth);
|
taosHashCleanup(pMetaCache->pUserAuth);
|
||||||
taosHashCleanup(pMetaCache->pUdf);
|
taosHashCleanup(pMetaCache->pUdf);
|
||||||
taosHashCleanup(pMetaCache->pTableIndex);
|
taosHashCleanup(pMetaCache->pTableIndex);
|
||||||
|
taosHashCleanup(pMetaCache->pTableCfg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1390,7 +1390,7 @@ void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncIndex
|
||||||
syncUtilU642Addr((pSyncNode->replicasId)[i].addr, host, sizeof(host), &port);
|
syncUtilU642Addr((pSyncNode->replicasId)[i].addr, host, sizeof(host), &port);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char eventLog[128];
|
char eventLog[256];
|
||||||
snprintf(eventLog, sizeof(eventLog), "snapshot sender reset for %lu, newIndex:%d, %s:%d, %p",
|
snprintf(eventLog, sizeof(eventLog), "snapshot sender reset for %lu, newIndex:%d, %s:%d, %p",
|
||||||
(pSyncNode->replicasId)[i].addr, i, host, port, oldSenders[j]);
|
(pSyncNode->replicasId)[i].addr, i, host, port, oldSenders[j]);
|
||||||
syncNodeEventLog(pSyncNode, eventLog);
|
syncNodeEventLog(pSyncNode, eventLog);
|
||||||
|
@ -1405,7 +1405,7 @@ void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncIndex
|
||||||
(pSyncNode->senders)[i]->replicaIndex = i;
|
(pSyncNode->senders)[i]->replicaIndex = i;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char eventLog[128];
|
char eventLog[256];
|
||||||
snprintf(eventLog, sizeof(eventLog), "snapshot sender udpate replicaIndex from %d to %d, %s:%d, %p, reset:%d",
|
snprintf(eventLog, sizeof(eventLog), "snapshot sender udpate replicaIndex from %d to %d, %s:%d, %p, reset:%d",
|
||||||
oldreplicaIndex, i, host, port, (pSyncNode->senders)[i], reset);
|
oldreplicaIndex, i, host, port, (pSyncNode->senders)[i], reset);
|
||||||
syncNodeEventLog(pSyncNode, eventLog);
|
syncNodeEventLog(pSyncNode, eventLog);
|
||||||
|
|
Loading…
Reference in New Issue