From 3de91de7f958751cd0bb7ce54d5974d510669cec Mon Sep 17 00:00:00 2001 From: slzhou Date: Thu, 23 Nov 2023 11:18:05 +0800 Subject: [PATCH] fix: bi mode create tbname col error --- source/libs/parser/inc/parTranslater.h | 2 ++ source/libs/parser/src/parTranslater.c | 10 +++++++++- tests/script/tsim/query/bi_tbname_col.sim | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/source/libs/parser/inc/parTranslater.h b/source/libs/parser/inc/parTranslater.h index 0fe99e04ab..55ea71a368 100644 --- a/source/libs/parser/inc/parTranslater.h +++ b/source/libs/parser/inc/parTranslater.h @@ -23,6 +23,7 @@ extern "C" { #include "parToken.h" #include "parUtil.h" #include "parser.h" +#include "cmdnodes.h" typedef struct STranslateContext { SParseContext* pParseCxt; @@ -48,6 +49,7 @@ typedef struct STranslateContext { bool biRewriteToTbnameFunc(STranslateContext* pCxt, SNode** ppNode); int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect); +int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SCreateTableStmt* pStmt); int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STableNode** pOutput); int32_t getTargetMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta, bool couldBeView); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 496e3423e6..74a462dfda 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5726,6 +5726,12 @@ static int32_t checkTableDeleteMarkOption(STranslateContext* pCxt, STableOptions return code; } +#ifndef TD_ENTERPRISE +int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SCreateTableStmt* pStmt) { + return TSDB_CODE_SUCCESS; +} +#endif + static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt, bool createStable) { if (NULL != strchr(pStmt->tableName, '.')) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, @@ -5764,7 +5770,9 @@ static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt "configured with the 'TTL' option"); } } - + if (pCxt->pParseCxt->biMode != 0 && TSDB_CODE_SUCCESS == code) { + code = biCheckCreateTableTbnameCol(pCxt, pStmt); + } return code; } diff --git a/tests/script/tsim/query/bi_tbname_col.sim b/tests/script/tsim/query/bi_tbname_col.sim index 7cf897280b..d351a92539 100644 --- a/tests/script/tsim/query/bi_tbname_col.sim +++ b/tests/script/tsim/query/bi_tbname_col.sim @@ -31,4 +31,6 @@ if $data10 != @tba2@ then return -1 endi +sql_error create table stc(ts timestamp, `tbname` binary(200)); +sql_error create table std(ts timestamp, f1 int) tags(`tbname` binary(200)); system sh/exec.sh -n dnode1 -s stop -x SIGINT