From d79550be20a6159ab402f1e99c8b0854c14b0335 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 20 May 2024 19:18:31 +0800 Subject: [PATCH] fix:[TS-4817] check primary key(timestamp) in raw data --- source/libs/parser/src/parInsertUtil.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index 5ad9feddbc..35527d2b03 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -732,6 +732,7 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate } } } else { + bool hasTs = false; for (int i = 0; i < numFields; i++) { for (int j = 0; j < boundInfo->numOfBound; j++) { SSchema* pColSchema = &pSchema[j]; @@ -743,6 +744,10 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate goto end; } + if (pColSchema->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { + hasTs = true; + } + int8_t* offset = pStart; if (IS_VAR_DATA_TYPE(pColSchema->type)) { pStart += numOfRows * sizeof(int32_t); @@ -768,6 +773,12 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate } } + if(!hasTs){ + if (errstr != NULL) snprintf(errstr, errstrLen, "timestamp column(primary key) not found in raw data"); + ret = TSDB_CODE_INVALID_PARA; + goto end; + } + for (int c = 0; c < boundInfo->numOfBound; ++c) { if (boundInfo->pColIndex[c] != -1) { SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, c);