fix: fix address sanitizer error

This commit is contained in:
slzhou 2023-09-20 13:25:26 +08:00
parent 1f1657a160
commit 0c6338dc15
4 changed files with 3601 additions and 3602 deletions

View File

@ -89,7 +89,7 @@ typedef struct STokenPair {
typedef struct SShowTablesOption {
EShowKind kind;
SNode* pDbName;
SToken dbName;
} SShowTablesOption;
extern SToken nil_token;
@ -190,6 +190,7 @@ SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, EShowKind showKind);
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type);
SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbName,
EOperatorType tableCondType);
SNode* createShowTablesStmt(SAstCreateContext* pCxt, SShowTablesOption option, SNode* pTbName, EOperatorType tableCondType);
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
SNode* createShowAliveStmt(SAstCreateContext* pCxt, SNode* pDbName, ENodeType type);
SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable);

View File

@ -463,8 +463,7 @@ cmd ::= SHOW db_kind_opt(A) DATABASES.
setShowKind(pCxt, pCxt->pRootNode, A);
}
cmd ::= SHOW table_kind_db_name_cond_opt(A) TABLES like_pattern_opt(B). {
pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, A.pDbName, B, OP_TYPE_LIKE);
setShowKind(pCxt, pCxt->pRootNode, A.kind);
pCxt->pRootNode = createShowTablesStmt(pCxt, A, B, OP_TYPE_LIKE);
}
cmd ::= SHOW db_name_cond_opt(A) STABLES like_pattern_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, A, B, OP_TYPE_LIKE); }
cmd ::= SHOW db_name_cond_opt(A) VGROUPS. { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, A, NULL, OP_TYPE_LIKE); }
@ -509,18 +508,16 @@ cmd ::= SHOW CLUSTER ALIVE.
%type table_kind_db_name_cond_opt { SShowTablesOption }
%destructor table_kind_db_name_cond_opt { }
table_kind_db_name_cond_opt(A) ::= . { A.kind = SHOW_KIND_ALL; A.pDbName = NULL; }
table_kind_db_name_cond_opt(A) ::= table_kind(B). { A.kind = B; A.pDbName = NULL; }
table_kind_db_name_cond_opt(A) ::= db_name_cond(C). { A.kind = SHOW_KIND_ALL; A.pDbName = C; }
table_kind_db_name_cond_opt(A) ::= table_kind(B) db_name_cond(C). { A.kind = B; A.pDbName = C; }
table_kind_db_name_cond_opt(A) ::= . { A.kind = SHOW_KIND_ALL; A.dbName = nil_token; }
table_kind_db_name_cond_opt(A) ::= table_kind(B). { A.kind = B; A.dbName = nil_token; }
table_kind_db_name_cond_opt(A) ::= db_name(C) NK_DOT. { A.kind = SHOW_KIND_ALL; A.dbName = C; }
table_kind_db_name_cond_opt(A) ::= table_kind(B) db_name(C) NK_DOT. { A.kind = B; A.dbName = C; }
%type table_kind { EShowKind }
%destructor table_kind { }
table_kind(A) ::= NORMAL. { A = SHOW_KIND_TABLES_NORMAL; }
table_kind(A) ::= CHILD. { A = SHOW_KIND_TABLES_CHILD; }
db_name_cond(A) ::= db_name(B) NK_DOT. { A = createIdentifierValueNode(pCxt, &B); }
db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createIdentifierValueNode(pCxt, &B); }

View File

@ -1564,9 +1564,6 @@ SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, EShowKind showKind) {
SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbName,
EOperatorType tableCondType) {
CHECK_PARSER_STATUS(pCxt);
if (NULL == pDbName) {
pDbName = createDefaultDatabaseCondValue(pCxt);
}
if (needDbShowStmt(type) && NULL == pDbName) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "database not specified");
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
@ -1580,6 +1577,19 @@ SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pD
return (SNode*)pStmt;
}
SNode* createShowTablesStmt(SAstCreateContext* pCxt, SShowTablesOption option, SNode* pTbName, EOperatorType tableCondType) {
CHECK_PARSER_STATUS(pCxt);
SNode* pDbName = NULL;
if (option.dbName.type == TK_NK_NIL) {
pDbName = createDefaultDatabaseCondValue(pCxt);
} else {
pDbName = createIdentifierValueNode(pCxt, &option.dbName);
}
SNode* pStmt = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, pDbName, pTbName, tableCondType);
setShowKind(pCxt, pStmt, option.kind);
return pStmt;
}
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) {
CHECK_PARSER_STATUS(pCxt);
if (!checkDbName(pCxt, pDbName, true)) {

File diff suppressed because it is too large Load Diff