fix: bug fix for tag refactor

This commit is contained in:
Cary Xu 2022-05-29 20:28:54 +08:00
parent 174eb2d862
commit fdf7d77856
4 changed files with 16 additions and 27 deletions

View File

@ -638,7 +638,6 @@ static int32_t tPutTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson) {
// type // type
n += tPutI8(p ? p + n : p, pTagVal->type); n += tPutI8(p ? p + n : p, pTagVal->type);
debugPrintTagVal(pTagVal->type, pTagVal->pData, pTagVal->nData, __func__, __LINE__);
// value // value
if (IS_VAR_DATA_TYPE(pTagVal->type)) { if (IS_VAR_DATA_TYPE(pTagVal->type)) {
n += tPutBinary(p ? p + n : p, pTagVal->pData, pTagVal->nData); n += tPutBinary(p ? p + n : p, pTagVal->pData, pTagVal->nData);
@ -799,7 +798,10 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag) {
return tEncodeBinary(pEncoder, (const uint8_t *)pTag, pTag->len); return tEncodeBinary(pEncoder, (const uint8_t *)pTag, pTag->len);
} }
int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag) { return tDecodeBinary(pDecoder, (uint8_t **)ppTag, NULL); } int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag) {
uint32_t len = 0;
return tDecodeBinary(pDecoder, (uint8_t **)ppTag, &len);
}
int32_t tTagToValArray(const STag *pTag, SArray **ppArray) { int32_t tTagToValArray(const STag *pTag, SArray **ppArray) {
int32_t code = 0; int32_t code = 0;

View File

@ -3847,7 +3847,6 @@ int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) {
if (pReq->type == TSDB_CHILD_TABLE) { if (pReq->type == TSDB_CHILD_TABLE) {
if (tEncodeI64(pCoder, pReq->ctb.suid) < 0) return -1; if (tEncodeI64(pCoder, pReq->ctb.suid) < 0) return -1;
if (tEncodeTag(pCoder, (const STag *)pReq->ctb.pTag) < 0) return -1; if (tEncodeTag(pCoder, (const STag *)pReq->ctb.pTag) < 0) return -1;
debugPrintSTag((STag*)pReq->ctb.pTag, __func__, __LINE__);
} else if (pReq->type == TSDB_NORMAL_TABLE) { } else if (pReq->type == TSDB_NORMAL_TABLE) {
if (tEncodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1; if (tEncodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1;
} else { } else {
@ -3871,7 +3870,6 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
if (pReq->type == TSDB_CHILD_TABLE) { if (pReq->type == TSDB_CHILD_TABLE) {
if (tDecodeI64(pCoder, &pReq->ctb.suid) < 0) return -1; if (tDecodeI64(pCoder, &pReq->ctb.suid) < 0) return -1;
if (tDecodeTag(pCoder, (STag **)&pReq->ctb.pTag) < 0) return -1; if (tDecodeTag(pCoder, (STag **)&pReq->ctb.pTag) < 0) return -1;
debugPrintSTag((STag*)pReq->ctb.pTag, __func__, __LINE__);
} else if (pReq->type == TSDB_NORMAL_TABLE) { } else if (pReq->type == TSDB_NORMAL_TABLE) {
if (tDecodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1; if (tDecodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1;
} else { } else {

View File

@ -726,17 +726,17 @@ static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
return tdbTbInsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), NULL, 0, &pMeta->txn); return tdbTbInsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), NULL, 0, &pMeta->txn);
} }
static int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int8_t type, tb_uid_t uid, static int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int32_t nTagData, int8_t type, tb_uid_t uid,
STagIdxKey **ppTagIdxKey, int32_t *nTagIdxKey) { STagIdxKey **ppTagIdxKey, int32_t *nTagIdxKey) {
int32_t nTagData = 0; // int32_t nTagData = 0;
if (pTagData) { // if (pTagData) {
if (IS_VAR_DATA_TYPE(type)) { // if (IS_VAR_DATA_TYPE(type)) {
nTagData = varDataTLen(pTagData); // nTagData = varDataTLen(pTagData);
} else { // } else {
nTagData = tDataTypes[type].bytes; // nTagData = tDataTypes[type].bytes;
} // }
} // }
*nTagIdxKey = sizeof(STagIdxKey) + nTagData + sizeof(tb_uid_t); *nTagIdxKey = sizeof(STagIdxKey) + nTagData + sizeof(tb_uid_t);
*ppTagIdxKey = (STagIdxKey *)taosMemoryMalloc(*nTagIdxKey); *ppTagIdxKey = (STagIdxKey *)taosMemoryMalloc(*nTagIdxKey);
@ -768,6 +768,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
int32_t nTagIdxKey; int32_t nTagIdxKey;
const SSchema *pTagColumn; // = &stbEntry.stbEntry.schema.pSchema[0]; const SSchema *pTagColumn; // = &stbEntry.stbEntry.schema.pSchema[0];
const void *pTagData = NULL; // const void *pTagData = NULL; //
int32_t nTagData = 0;
SDecoder dc = {0}; SDecoder dc = {0};
// get super table // get super table
@ -784,6 +785,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
STagVal tagVal = {.cid = pTagColumn->colId}; STagVal tagVal = {.cid = pTagColumn->colId};
tTagGet((const STag *)pCtbEntry->ctbEntry.pTags, &tagVal); tTagGet((const STag *)pCtbEntry->ctbEntry.pTags, &tagVal);
pTagData = tagVal.pData; pTagData = tagVal.pData;
nTagData = (int32_t)tagVal.nData;
// update tag index // update tag index
#ifdef USE_INVERTED_INDEX #ifdef USE_INVERTED_INDEX
@ -798,7 +800,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
int ret = indexPut((SIndex *)pMeta->pTagIvtIdx, tmGroup, tuid); int ret = indexPut((SIndex *)pMeta->pTagIvtIdx, tmGroup, tuid);
indexMultiTermDestroy(tmGroup); indexMultiTermDestroy(tmGroup);
#else #else
if (metaCreateTagIdxKey(pCtbEntry->ctbEntry.suid, pTagColumn->colId, pTagData, pTagColumn->type, pCtbEntry->uid, if (metaCreateTagIdxKey(pCtbEntry->ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, pCtbEntry->uid,
&pTagIdxKey, &nTagIdxKey) < 0) { &pTagIdxKey, &nTagIdxKey) < 0) {
return -1; return -1;
} }

View File

@ -4030,19 +4030,6 @@ static int32_t serializeVgroupCreateTableBatch(SVgroupCreateTableBatch* pTbBatch
pVgData->numOfTables = (int32_t)taosArrayGetSize(pTbBatch->req.pArray); pVgData->numOfTables = (int32_t)taosArrayGetSize(pTbBatch->req.pArray);
taosArrayPush(pBufArray, &pVgData); taosArrayPush(pBufArray, &pVgData);
#if 1 // debug print
SDecoder decoder = {0};
SVCreateTbBatchReq req = {0};
// decode
tDecoderInit(&decoder, pBuf, tlen - sizeof(SMsgHead));
if (tDecodeSVCreateTbBatchReq(&decoder, &req) < 0) {
ASSERT(0);
}
tDecoderClear(&decoder);
#endif
printf("%s:%d: OK in send \n", __func__, __LINE__);
ASSERT(0);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }