fix:add grammar support

This commit is contained in:
wangmm0220 2023-05-23 17:47:17 +08:00
parent a7a85fb796
commit 8c1c2a2f97
2 changed files with 29 additions and 2 deletions

View File

@ -530,9 +530,9 @@ cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C).
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B)
WITH META AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, true); }
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B)
AS STABLE full_table_name(C). { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, A, &B, C, false); }
AS STABLE full_table_name(C) where_clause_opt(D). { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, A, &B, C, false, D); }
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B)
WITH META AS STABLE full_table_name(C). { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, A, &B, C, true); }
WITH META AS STABLE full_table_name(C) where_clause_opt(D). { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, A, &B, C, true, D); }
cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); }
cmd ::= DROP CONSUMER GROUP exists_opt(A) cgroup_name(B) ON topic_name(C). { pCxt->pRootNode = createDropCGroupStmt(pCxt, A, &B, &C); }

View File

@ -1713,6 +1713,33 @@ SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists,
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
pStmt->ignoreExists = ignoreExists;
pStmt->withMeta = withMeta;
// SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT);
// if (NULL == pSelect) {
// return TSDB_CODE_OUT_OF_MEMORY;
// }
// sprintf(pSelect->stmtName, "%p", pSelect);
//
// SRealTableNode* pRealTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE);
// if (NULL == pRealTable) {
// nodesDestroyNode((SNode*)pSelect);
// return TSDB_CODE_OUT_OF_MEMORY;
// }
// snprintf(pRealTable->table.dbName, sizeof(pRealTable->table.dbName), "%s", pDb);
// snprintf(pRealTable->table.tableName, sizeof(pRealTable->table.tableName), "%s", pTable);
// snprintf(pRealTable->table.tableAlias, sizeof(pRealTable->table.tableAlias), "%s", pTable);
// pSelect->pFromTable = (SNode*)pRealTable;
//
// if (numOfProjs >= 0) {
// pSelect->pProjectionList = createProjectCols(numOfProjs, pProjCol);
// if (NULL == pSelect->pProjectionList) {
// nodesDestroyNode((SNode*)pSelect);
// return TSDB_CODE_OUT_OF_MEMORY;
// }
// }
//
// pStmt->pQuery = pSelect;
strcpy(pStmt->subDbName, ((SRealTableNode*)pRealTable)->table.dbName);
strcpy(pStmt->subSTbName, ((SRealTableNode*)pRealTable)->table.tableName);
nodesDestroyNode(pRealTable);