From 174eb2d8625f3eea04407e5529ea9f4bc51f1694 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Sat, 28 May 2022 20:13:59 +0800 Subject: [PATCH] fix: add more debug logs --- source/common/src/tdataformat.c | 4 ++-- source/common/src/tmsg.c | 2 ++ source/dnode/vnode/src/meta/metaTable.c | 2 +- source/libs/parser/src/parTranslater.c | 13 +++++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 1a7f5fa3fb..dce7c1739e 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -619,7 +619,7 @@ void debugPrintSTag(STag *pTag, const char *tag, int32_t ln) { tagVal.cid = *(int16_t *)POINTER_SHIFT(p, offset); } printf("%s:%d loop[%d-%d] offset=%d\n", __func__, __LINE__, (int32_t)pTag->nTag, (int32_t)n, (int32_t)offset); - tGetTagVal(p, &tagVal, isJson); + tGetTagVal(p + offset, &tagVal, isJson); debugPrintTagVal(tagVal.type, tagVal.pData, tagVal.nData, __func__, __LINE__); } printf("\n"); @@ -703,7 +703,7 @@ int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag) { ASSERT(szTag <= INT16_MAX); // build tag - (*ppTag) = (STag *)taosMemoryMalloc(szTag); + (*ppTag) = (STag *)taosMemoryCalloc(szTag, 1); if ((*ppTag) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 721eb9587b..e10dfc2996 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -3847,6 +3847,7 @@ int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) { if (pReq->type == TSDB_CHILD_TABLE) { if (tEncodeI64(pCoder, pReq->ctb.suid) < 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) { if (tEncodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1; } else { @@ -3870,6 +3871,7 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) { if (pReq->type == TSDB_CHILD_TABLE) { if (tDecodeI64(pCoder, &pReq->ctb.suid) < 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) { if (tDecodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1; } else { diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 753bd8bce7..aa235c1cc9 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -578,7 +578,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA STagVal tagVal = {.cid = pCol->colId}; if (tTagGet(pOldTag, &tagVal) && tagVal.pData) { if (IS_VAR_DATA_TYPE(pCol->type)) { - tTagValPush(pTagArray, &pCol->colId, pCol->type, tagVal.pData, varDataTLen(tagVal.pData), false); + tTagValPush(pTagArray, &pCol->colId, pCol->type, varDataVal(tagVal.pData), varDataLen(tagVal.pData), false); } else { tTagValPush(pTagArray, &pCol->colId, pCol->type, tagVal.pData, pCol->bytes, false); } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 22357cab44..fd0377f998 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -4030,6 +4030,19 @@ static int32_t serializeVgroupCreateTableBatch(SVgroupCreateTableBatch* pTbBatch pVgData->numOfTables = (int32_t)taosArrayGetSize(pTbBatch->req.pArray); 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; } -- GitLab