From bee1e40b7d3ff623c28379a924c42929283007d9 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Thu, 21 Jul 2022 14:57:52 +0800 Subject: [PATCH] fix: check type of tVariant as a column/tag name when alter table... --- src/client/src/tscSQLParser.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 3c52c32f0d..bb31b752a1 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -7401,6 +7401,9 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } SColumnIndex idx = COLUMN_INDEX_INITIALIZER; + if (pItem->pVar.nType != TSDB_DATA_TYPE_BINARY) { + return invalidOperationMsg(pMsg, msg17); + } SStrToken name = {.z = pItem->pVar.pz, .n = pItem->pVar.nLen}; if (getColumnIndexByName(&name, pQueryInfo, &idx, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { @@ -7474,6 +7477,9 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { int16_t numOfTags = tscGetNumOfTags(pTableMeta); SColumnIndex columnIndex = COLUMN_INDEX_INITIALIZER; + if (item->pVar.nType != TSDB_DATA_TYPE_BINARY) { + return invalidOperationMsg(pMsg, msg17); + } SStrToken name = {.z = item->pVar.pz, .n = item->pVar.nLen}; if (getColumnIndexByName(&name, pQueryInfo, &columnIndex, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; @@ -7619,6 +7625,9 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { tVariantListItem* pItem = taosArrayGet(pAlterSQL->varList, 0); SColumnIndex columnIndex = COLUMN_INDEX_INITIALIZER; + if (pItem->pVar.nType != TSDB_DATA_TYPE_BINARY) { + return invalidOperationMsg(pMsg, msg17); + } SStrToken name = {.z = pItem->pVar.pz, .n = pItem->pVar.nLen}; if (getColumnIndexByName(&name, pQueryInfo, &columnIndex, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { -- GitLab