From 5a7d51233a645b4c9a6dc634982ed45de8a48d2b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 3 Jul 2020 14:48:42 +0800 Subject: [PATCH] [td-225] fix bugs found in regression test. --- src/client/src/tscSQLParser.c | 2 +- src/common/inc/tdataformat.h | 6 +++--- src/common/src/tdataformat.c | 8 ++++---- src/tsdb/src/tsdbMeta.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index d90a19da27..ea500e83b9 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -4514,7 +4514,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { if (pTagsSchema->type != TSDB_DATA_TYPE_BINARY && pTagsSchema->type != TSDB_DATA_TYPE_NCHAR) { len = tDataTypeDesc[pTagsSchema->type].nSize; } else { - len = varDataTLen(pUpdateMsg->data); + len = varDataTLen(pUpdateMsg->data + schemaLen); } pUpdateMsg->tagValLen = htonl(len); // length may be changed after dump data diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index baa212d8b7..2ed4b81204 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -50,8 +50,8 @@ extern "C" { typedef struct { int8_t type; // Column type int16_t colId; // column ID - int32_t bytes; // column bytes - int32_t offset; // point offset in SDataRow after the header part + int16_t bytes; // column bytes + int16_t offset; // point offset in SDataRow after the header part } STColumn; #define colType(col) ((col)->type) @@ -116,7 +116,7 @@ typedef struct { int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version); void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder); void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version); -int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int32_t bytes); +int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int16_t bytes); STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder); // ----------------- Data row structure diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index e5cbcfd143..7e551759f9 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -43,7 +43,7 @@ int tdEncodeSchema(void **buf, STSchema *pSchema) { STColumn *pCol = schemaColAt(pSchema, i); tlen += taosEncodeFixedI8(buf, colType(pCol)); tlen += taosEncodeFixedI16(buf, colColId(pCol)); - tlen += taosEncodeFixedI32(buf, colBytes(pCol)); + tlen += taosEncodeFixedI16(buf, colBytes(pCol)); } return tlen; @@ -65,10 +65,10 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) { for (int i = 0; i < numOfCols; i++) { int8_t type = 0; int16_t colId = 0; - int32_t bytes = 0; + int16_t bytes = 0; buf = taosDecodeFixedI8(buf, &type); buf = taosDecodeFixedI16(buf, &colId); - buf = taosDecodeFixedI32(buf, &bytes); + buf = taosDecodeFixedI16(buf, &bytes); if (tdAddColToSchema(&schemaBuilder, type, colId, bytes) < 0) { tdDestroyTSchemaBuilder(&schemaBuilder); return NULL; @@ -105,7 +105,7 @@ void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) { pBuilder->version = version; } -int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int32_t bytes) { +int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int16_t bytes) { if (!isValidDataType(type)) return -1; if (pBuilder->nCols >= pBuilder->tCols) { diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 25a1cf88ab..cbbf51d862 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -283,8 +283,8 @@ int tsdbUpdateTagValue(TSDB_REPO_T *repo, SUpdateTableTagValMsg *pMsg) { for(int32_t i = 0; i < pMsg->numOfTags; ++i) { STColumn* pCol = (STColumn*) d; pCol->colId = htons(pCol->colId); - pCol->bytes = htonl(pCol->bytes); - assert(pCol->offset == 0); + pCol->bytes = htons(pCol->bytes); + pCol->offset = 0; d += sizeof(STColumn); } -- GitLab