fix invalid copy

This commit is contained in:
yihaoDeng 2024-03-12 09:47:01 +00:00
parent 5dd4d05b2e
commit 796ff03eb5
5 changed files with 86 additions and 67 deletions

View File

@ -20,13 +20,13 @@
#include "taoserror.h" #include "taoserror.h"
#include "tarray.h" #include "tarray.h"
#include "tcoding.h" #include "tcoding.h"
#include "tcol.h"
#include "tencode.h" #include "tencode.h"
#include "thash.h" #include "thash.h"
#include "tlist.h" #include "tlist.h"
#include "tname.h" #include "tname.h"
#include "trow.h" #include "trow.h"
#include "tuuid.h" #include "tuuid.h"
#include "tcol.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -154,19 +154,19 @@ typedef enum _mgmt_table {
TSDB_MGMT_TABLE_MAX, TSDB_MGMT_TABLE_MAX,
} EShowType; } EShowType;
#define TSDB_ALTER_TABLE_ADD_TAG 1 #define TSDB_ALTER_TABLE_ADD_TAG 1
#define TSDB_ALTER_TABLE_DROP_TAG 2 #define TSDB_ALTER_TABLE_DROP_TAG 2
#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3 #define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4 #define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4
#define TSDB_ALTER_TABLE_ADD_COLUMN 5 #define TSDB_ALTER_TABLE_ADD_COLUMN 5
#define TSDB_ALTER_TABLE_DROP_COLUMN 6 #define TSDB_ALTER_TABLE_DROP_COLUMN 6
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES 7 #define TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES 7
#define TSDB_ALTER_TABLE_UPDATE_TAG_BYTES 8 #define TSDB_ALTER_TABLE_UPDATE_TAG_BYTES 8
#define TSDB_ALTER_TABLE_UPDATE_OPTIONS 9 #define TSDB_ALTER_TABLE_UPDATE_OPTIONS 9
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME 10 #define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME 10
#define TSDB_ALTER_TABLE_ADD_TAG_INDEX 11 #define TSDB_ALTER_TABLE_ADD_TAG_INDEX 11
#define TSDB_ALTER_TABLE_DROP_TAG_INDEX 12 #define TSDB_ALTER_TABLE_DROP_TAG_INDEX 12
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS 13 #define TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS 13
#define TSDB_FILL_NONE 0 #define TSDB_FILL_NONE 0
#define TSDB_FILL_NULL 1 #define TSDB_FILL_NULL 1
@ -555,7 +555,7 @@ struct SSchemaExt {
#define COMPRESS_L1_TYPE_U32(type) (((type) >> 24) & 0xFF) #define COMPRESS_L1_TYPE_U32(type) (((type) >> 24) & 0xFF)
#define COMPRESS_L2_TYPE_U32(type) (((type) >> 8) & 0xFFFF) #define COMPRESS_L2_TYPE_U32(type) (((type) >> 8) & 0xFFFF)
#define COMPRESS_L2_TYPE_LEVEL_U32(type) ((type) & 0xFF) #define COMPRESS_L2_TYPE_LEVEL_U32(type) ((type)&0xFF)
// compress flag // compress flag
// |----l2lel--|----l2Alg---|---l1Alg--| // |----l2lel--|----l2Alg---|---l1Alg--|
@ -772,14 +772,14 @@ static FORCE_INLINE int32_t tDecodeSSchema(SDecoder* pDecoder, SSchema* pSchema)
} }
static FORCE_INLINE int32_t tEncodeSSchemaExt(SEncoder* pEncoder, const SSchemaExt* pSchemaExt) { static FORCE_INLINE int32_t tEncodeSSchemaExt(SEncoder* pEncoder, const SSchemaExt* pSchemaExt) {
// if (tEncodeI16v(pEncoder, pSchemaExt->colId) < 0) return -1; if (tEncodeI16v(pEncoder, pSchemaExt->colId) < 0) return -1;
// if (tEncodeU32(pEncoder, pSchemaExt->compress) < 0) return -1; if (tEncodeU32(pEncoder, pSchemaExt->compress) < 0) return -1;
return 0; return 0;
} }
static FORCE_INLINE int32_t tDecodeSSchemaExt(SDecoder* pDecoder, SSchemaExt* pSchemaExt) { static FORCE_INLINE int32_t tDecodeSSchemaExt(SDecoder* pDecoder, SSchemaExt* pSchemaExt) {
// if (tDecodeI16v(pDecoder, &pSchemaExt->colId) < 0) return -1; if (tDecodeI16v(pDecoder, &pSchemaExt->colId) < 0) return -1;
// if (tDecodeU32(pDecoder, &pSchemaExt->compress) < 0) return -1; if (tDecodeU32(pDecoder, &pSchemaExt->compress) < 0) return -1;
return 0; return 0;
} }
@ -4133,8 +4133,8 @@ int32_t tSerializeSViewMetaRsp(void* buf, int32_t bufLen, const SViewMetaRsp* pR
int32_t tDeserializeSViewMetaRsp(void* buf, int32_t bufLen, SViewMetaRsp* pRsp); int32_t tDeserializeSViewMetaRsp(void* buf, int32_t bufLen, SViewMetaRsp* pRsp);
void tFreeSViewMetaRsp(SViewMetaRsp* pRsp); void tFreeSViewMetaRsp(SViewMetaRsp* pRsp);
void setDefaultOptionsForField(SFieldWithOptions *field); void setDefaultOptionsForField(SFieldWithOptions* field);
void setFieldWithOptions(SFieldWithOptions *fieldWithOptions, SField* field); void setFieldWithOptions(SFieldWithOptions* fieldWithOptions, SField* field);
#pragma pack(pop) #pragma pack(pop)

View File

@ -53,7 +53,7 @@
#define ENCODESQL() \ #define ENCODESQL() \
do { \ do { \
if (tEncodeI32(&encoder, pReq->sqlLen) < 0) return -1; \ if (tEncodeI32(&encoder, pReq->sqlLen) < 0) return -1; \
if (pReq->sqlLen > 0) { \ if (pReq->sqlLen > 0) { \
if (tEncodeBinary(&encoder, pReq->sql, pReq->sqlLen) < 0) return -1; \ if (tEncodeBinary(&encoder, pReq->sql, pReq->sqlLen) < 0) return -1; \
} \ } \
} while (0) } while (0)
@ -4433,9 +4433,11 @@ static int32_t tEncodeSTableMetaRsp(SEncoder *pEncoder, STableMetaRsp *pRsp) {
if (tEncodeSSchema(pEncoder, pSchema) < 0) return -1; if (tEncodeSSchema(pEncoder, pSchema) < 0) return -1;
} }
for (int32_t i = 0; i < pRsp->numOfColumns; ++i) { if (pRsp->tableType == TSDB_SUPER_TABLE || pRsp->tableType == TSDB_NORMAL_TABLE) {
SSchemaExt *pSchemaExt = &pRsp->pSchemaExt[i]; for (int32_t i = 0; i < pRsp->numOfColumns; ++i) {
if (tEncodeSSchemaExt(pEncoder, pSchemaExt) < 0) return -1; SSchemaExt *pSchemaExt = &pRsp->pSchemaExt[i];
if (tEncodeSSchemaExt(pEncoder, pSchemaExt) < 0) return -1;
}
} }
return 0; return 0;
@ -4470,18 +4472,24 @@ static int32_t tDecodeSTableMetaRsp(SDecoder *pDecoder, STableMetaRsp *pRsp) {
} }
// if (tDecodeIsEnd(pDecoder)) return 0; // if (tDecodeIsEnd(pDecoder)) return 0;
if (pRsp->numOfColumns > 0) { if (!tDecodeIsEnd(pDecoder)) {
pRsp->pSchemaExt = taosMemoryMalloc(sizeof(SSchemaExt) * pRsp->numOfColumns); if (pRsp->tableType == TSDB_SUPER_TABLE || pRsp->tableType == TSDB_NORMAL_TABLE) {
if (pRsp->pSchemaExt == NULL) return -1; if (pRsp->numOfColumns > 0) {
pRsp->pSchemaExt = taosMemoryMalloc(sizeof(SSchemaExt) * pRsp->numOfColumns);
if (pRsp->pSchemaExt == NULL) return -1;
for (int32_t i = 0; i < pRsp->numOfColumns; ++i) { for (int32_t i = 0; i < pRsp->numOfColumns; ++i) {
SSchemaExt *pSchemaExt = &pRsp->pSchemaExt[i]; SSchemaExt *pSchemaExt = &pRsp->pSchemaExt[i];
if (tDecodeSSchemaExt(pDecoder, pSchemaExt) < 0) return -1; if (tDecodeSSchemaExt(pDecoder, pSchemaExt) < 0) return -1;
pSchemaExt->colId = i; pSchemaExt->colId = i;
pSchemaExt->compress = 0x02000303; pSchemaExt->compress = 0x02000303;
}
} else {
pRsp->pSchemaExt = NULL;
}
} else {
pRsp->pSchemaExt = NULL;
} }
} else {
pRsp->pSchemaExt = NULL;
} }
return 0; return 0;

View File

@ -1939,6 +1939,12 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
} }
pRsp->pSchemaExt = taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchemaExt));
if (pRsp->pSchemaExt == NULL) {
taosRUnLockLatch(&pStb->lock);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
tstrncpy(pRsp->dbFName, pStb->db, sizeof(pRsp->dbFName)); tstrncpy(pRsp->dbFName, pStb->db, sizeof(pRsp->dbFName));
tstrncpy(pRsp->tbName, tbName, sizeof(pRsp->tbName)); tstrncpy(pRsp->tbName, tbName, sizeof(pRsp->tbName));
@ -1972,6 +1978,12 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
pSchema->colId = pSrcSchema->colId; pSchema->colId = pSrcSchema->colId;
pSchema->bytes = pSrcSchema->bytes; pSchema->bytes = pSrcSchema->bytes;
} }
for (int32_t i = 0; i < pStb->numOfColumns; i++) {
SCmprObj *pCmpr = &pStb->pCmpr[i];
SSchemaExt *pSchEx = &pRsp->pSchemaExt[i];
pSchEx->colId = pCmpr->colId;
pSchEx->compress = pCmpr->cmprAlg;
}
taosRUnLockLatch(&pStb->lock); taosRUnLockLatch(&pStb->lock);
return 0; return 0;
@ -2027,6 +2039,7 @@ static int32_t mndBuildStbCfgImp(SDbObj *pDb, SStbObj *pStb, const char *tbName,
if (pStb->numOfFuncs > 0) { if (pStb->numOfFuncs > 0) {
pRsp->pFuncs = taosArrayDup(pStb->pFuncs, NULL); pRsp->pFuncs = taosArrayDup(pStb->pFuncs, NULL);
} }
taosRUnLockLatch(&pStb->lock); taosRUnLockLatch(&pStb->lock);
return 0; return 0;

View File

@ -142,7 +142,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
case TSDB_CODE_PAR_CANNOT_DROP_PRIMARY_KEY: case TSDB_CODE_PAR_CANNOT_DROP_PRIMARY_KEY:
return "Primary timestamp column cannot be dropped"; return "Primary timestamp column cannot be dropped";
case TSDB_CODE_PAR_INVALID_MODIFY_COL: case TSDB_CODE_PAR_INVALID_MODIFY_COL:
return "Only varbinary/binary/nchar/geometry column length could be modified, and the length can only be increased, not decreased"; return "Only varbinary/binary/nchar/geometry column length could be modified, and the length can only be "
"increased, not decreased";
case TSDB_CODE_PAR_INVALID_TBNAME: case TSDB_CODE_PAR_INVALID_TBNAME:
return "Invalid tbname pseudo column"; return "Invalid tbname pseudo column";
case TSDB_CODE_PAR_INVALID_FUNCTION_NAME: case TSDB_CODE_PAR_INVALID_FUNCTION_NAME:
@ -265,14 +266,14 @@ int32_t getNumOfTags(const STableMeta* pTableMeta) { return getTableInfo(pTableM
STableComInfo getTableInfo(const STableMeta* pTableMeta) { return pTableMeta->tableInfo; } STableComInfo getTableInfo(const STableMeta* pTableMeta) { return pTableMeta->tableInfo; }
int32_t getTableTypeFromTableNode(SNode *pTable) { int32_t getTableTypeFromTableNode(SNode* pTable) {
if (NULL == pTable) { if (NULL == pTable) {
return -1; return -1;
} }
if (QUERY_NODE_REAL_TABLE != nodeType(pTable)) { if (QUERY_NODE_REAL_TABLE != nodeType(pTable)) {
return -1; return -1;
} }
return ((SRealTableNode *)pTable)->pMeta->tableType; return ((SRealTableNode*)pTable)->pMeta->tableType;
} }
STableMeta* tableMetaDup(const STableMeta* pTableMeta) { STableMeta* tableMetaDup(const STableMeta* pTableMeta) {
@ -707,13 +708,12 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog
#ifdef TD_ENTERPRISE #ifdef TD_ENTERPRISE
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = buildTableReqFromDb(pMetaCache->pTableMeta, &pCatalogReq->pView); code = buildTableReqFromDb(pMetaCache->pTableMeta, &pCatalogReq->pView);
} }
#endif #endif
pCatalogReq->dNodeRequired = pMetaCache->dnodeRequired; pCatalogReq->dNodeRequired = pMetaCache->dnodeRequired;
return code; return code;
} }
SNode* createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode* pTable, SNodeList* pHint) { SNode* createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode* pTable, SNodeList* pHint) {
SSelectStmt* select = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT); SSelectStmt* select = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT);
if (NULL == select) { if (NULL == select) {
@ -848,7 +848,7 @@ int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMet
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = putDbTableDataToCache(pCatalogReq->pView, pMetaData->pView, &pMetaCache->pViews); code = putDbTableDataToCache(pCatalogReq->pView, pMetaData->pView, &pMetaCache->pViews);
} }
#endif #endif
pMetaCache->pDnodes = pMetaData->pDnodeList; pMetaCache->pDnodes = pMetaData->pDnodeList;
return code; return code;
} }
@ -930,10 +930,10 @@ int32_t buildTableMetaFromViewMeta(STableMeta** pMeta, SViewMeta* pViewMeta) {
(*pMeta)->tableInfo.precision = pViewMeta->precision; (*pMeta)->tableInfo.precision = pViewMeta->precision;
(*pMeta)->tableInfo.numOfColumns = pViewMeta->numOfCols; (*pMeta)->tableInfo.numOfColumns = pViewMeta->numOfCols;
memcpy((*pMeta)->schema, pViewMeta->pSchema, sizeof(SSchema) * pViewMeta->numOfCols); memcpy((*pMeta)->schema, pViewMeta->pSchema, sizeof(SSchema) * pViewMeta->numOfCols);
for (int32_t i = 0; i < pViewMeta->numOfCols; ++i) { for (int32_t i = 0; i < pViewMeta->numOfCols; ++i) {
(*pMeta)->tableInfo.rowSize += (*pMeta)->schema[i].bytes; (*pMeta)->tableInfo.rowSize += (*pMeta)->schema[i].bytes;
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -941,14 +941,13 @@ int32_t getViewMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, ST
char fullName[TSDB_TABLE_FNAME_LEN]; char fullName[TSDB_TABLE_FNAME_LEN];
tNameExtractFullName(pName, fullName); tNameExtractFullName(pName, fullName);
SViewMeta* pViewMeta = NULL; SViewMeta* pViewMeta = NULL;
int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pViews, (void**)&pViewMeta); int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pViews, (void**)&pViewMeta);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = buildTableMetaFromViewMeta(pMeta, pViewMeta); code = buildTableMetaFromViewMeta(pMeta, pViewMeta);
} }
return code; return code;
} }
static int32_t reserveDbReqInCache(int32_t acctId, const char* pDb, SHashObj** pDbs) { static int32_t reserveDbReqInCache(int32_t acctId, const char* pDb, SHashObj** pDbs) {
if (NULL == *pDbs) { if (NULL == *pDbs) {
*pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); *pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
@ -1044,15 +1043,13 @@ int32_t reserveUserAuthInCache(int32_t acctId, const char* pUser, const char* pD
return reserveUserAuthInCacheImpl(key, len, pMetaCache); return reserveUserAuthInCacheImpl(key, len, pMetaCache);
} }
int32_t reserveViewUserAuthInCache(int32_t acctId, const char* pUser, const char* pDb, const char* pTable, AUTH_TYPE type, int32_t reserveViewUserAuthInCache(int32_t acctId, const char* pUser, const char* pDb, const char* pTable,
SParseMetaCache* pMetaCache) { AUTH_TYPE type, SParseMetaCache* pMetaCache) {
char key[USER_AUTH_KEY_MAX_LEN] = {0}; char key[USER_AUTH_KEY_MAX_LEN] = {0};
int32_t len = userAuthToString(acctId, pUser, pDb, pTable, type, key, true); int32_t len = userAuthToString(acctId, pUser, pDb, pTable, type, key, true);
return reserveUserAuthInCacheImpl(key, len, pMetaCache); return reserveUserAuthInCacheImpl(key, len, pMetaCache);
} }
int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, SUserAuthInfo* pAuthReq, SUserAuthRes* pAuthRes) { int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, SUserAuthInfo* pAuthReq, SUserAuthRes* pAuthRes) {
char key[USER_AUTH_KEY_MAX_LEN] = {0}; char key[USER_AUTH_KEY_MAX_LEN] = {0};
int32_t len = userAuthToString(pAuthReq->tbName.acctId, pAuthReq->user, pAuthReq->tbName.dbname, int32_t len = userAuthToString(pAuthReq->tbName.acctId, pAuthReq->user, pAuthReq->tbName.dbname,
@ -1228,5 +1225,3 @@ int64_t int64SafeSub(int64_t a, int64_t b) {
} }
return res; return res;
} }

View File

@ -24,7 +24,7 @@
#pragma GCC diagnostic ignored "-Wformat-truncation" #pragma GCC diagnostic ignored "-Wformat-truncation"
#endif #endif
int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen, int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
void *(*mallocFp)(int64_t)) = {0}; void *(*mallocFp)(int64_t)) = {0};
int32_t (*queryProcessMsgRsp[TDMT_MAX])(void *output, char *msg, int32_t msgSize) = {0}; int32_t (*queryProcessMsgRsp[TDMT_MAX])(void *output, char *msg, int32_t msgSize) = {0};
@ -43,7 +43,8 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
pOut->dbVgroup->hashSuffix = usedbRsp->hashSuffix; pOut->dbVgroup->hashSuffix = usedbRsp->hashSuffix;
pOut->dbVgroup->stateTs = usedbRsp->stateTs; pOut->dbVgroup->stateTs = usedbRsp->stateTs;
qDebug("Got %d vgroup for db %s, vgVersion:%d, stateTs:%" PRId64, usedbRsp->vgNum, usedbRsp->db, usedbRsp->vgVersion, usedbRsp->stateTs); qDebug("Got %d vgroup for db %s, vgVersion:%d, stateTs:%" PRId64, usedbRsp->vgNum, usedbRsp->db, usedbRsp->vgVersion,
usedbRsp->stateTs);
if (usedbRsp->vgNum <= 0) { if (usedbRsp->vgNum <= 0) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -68,7 +69,7 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
void *(*mallcFp)(int64_t)) { void *(*mallcFp)(int64_t)) {
SBuildTableInput *pInput = input; SBuildTableInput *pInput = input;
if (NULL == input || NULL == msg || NULL == msgLen) { if (NULL == input || NULL == msg || NULL == msgLen) {
@ -205,7 +206,7 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen,
void *(*mallcFp)(int64_t)) { void *(*mallcFp)(int64_t)) {
if (NULL == msg || NULL == msgLen) { if (NULL == msg || NULL == msgLen) {
return TSDB_CODE_TSC_INVALID_INPUT; return TSDB_CODE_TSC_INVALID_INPUT;
@ -291,7 +292,7 @@ int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32
return TSDB_CODE_TSC_INVALID_INPUT; return TSDB_CODE_TSC_INVALID_INPUT;
} }
SViewMetaReq req = {0}; SViewMetaReq req = {0};
strncpy(req.fullname, input, sizeof(req.fullname) - 1); strncpy(req.fullname, input, sizeof(req.fullname) - 1);
int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req); int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req);
@ -408,7 +409,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta *
qError("calloc size[%d] failed", metaSize); qError("calloc size[%d] failed", metaSize);
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
SSchemaExt* pSchemaExt = (SSchemaExt*)((char*)pTableMeta + metaSize); SSchemaExt *pSchemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
pTableMeta->vgId = isStb ? 0 : msg->vgId; pTableMeta->vgId = isStb ? 0 : msg->vgId;
pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType; pTableMeta->tableType = isStb ? TSDB_SUPER_TABLE : msg->tableType;
@ -421,15 +422,18 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta *
pTableMeta->tableInfo.precision = msg->precision; pTableMeta->tableInfo.precision = msg->precision;
pTableMeta->tableInfo.numOfColumns = msg->numOfColumns; pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
pTableMeta->schemaExt = pSchemaExt; if (pTableMeta->tableType == TSDB_SUPER_TABLE || pTableMeta->tableType == TSDB_NORMAL_TABLE) {
memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total); pTableMeta->schemaExt = pSchemaExt;
memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize); memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
}
for (int32_t i = 0; i < msg->numOfColumns; ++i) { for (int32_t i = 0; i < msg->numOfColumns; ++i) {
pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes; pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
} }
qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64 " sver %d tver %d" qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64
" sver %d tver %d"
" tagNum %d colNum %d precision %d rowSize %d", " tagNum %d colNum %d precision %d rowSize %d",
msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName, msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName,
pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags, pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags,
@ -610,7 +614,7 @@ int32_t queryProcessRetrieveFuncRsp(void *output, char *msg, int32_t msgSize) {
memcpy(output, funcInfo, sizeof(*funcInfo)); memcpy(output, funcInfo, sizeof(*funcInfo));
taosArrayDestroy(out.pFuncInfos); taosArrayDestroy(out.pFuncInfos);
taosArrayDestroy(out.pFuncExtraInfos); taosArrayDestroy(out.pFuncExtraInfos);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -679,7 +683,6 @@ int32_t queryProcessGetViewMetaRsp(void *output, char *msg, int32_t msgSize) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
void initQueryModuleMsgHandle() { void initQueryModuleMsgHandle() {
queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg; queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg;
queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryBuildTableMetaReqMsg; queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryBuildTableMetaReqMsg;