From 255777ec099a6b751e09de3346f52679ccf8c026 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 22 Mar 2022 22:59:20 -0400 Subject: [PATCH] TD-13077 `string` identifier implement --- source/libs/parser/inc/parAst.h | 2 +- source/libs/parser/src/parAstCreater.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 2dd0b531a2..eb33dec721 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -142,7 +142,7 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName); SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pOldColName, const SToken* pNewColName); SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const SToken* pTagName, SNode* pVal); -SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName); +SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName); SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern); SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword); SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, const SToken* pVal); diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 020296e9b6..fbf74b96a3 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1046,7 +1046,10 @@ SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const return (SNode*)pStmt; } -SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) { +SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) { + if (!checkDbName(pCxt, pDbName, false)) { + return NULL; + } SUseDatabaseStmt* pStmt = (SUseDatabaseStmt*)nodesMakeNode(QUERY_NODE_USE_DATABASE_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->dbName, pDbName->z, pDbName->n);