fix create tag error
This commit is contained in:
parent
701ac939c1
commit
89bb80db65
|
@ -506,9 +506,9 @@ tag_item(A) ::= column_name(B) AS column_alias(C).
|
||||||
|
|
||||||
/************************************************ create index ********************************************************/
|
/************************************************ create index ********************************************************/
|
||||||
cmd ::= CREATE SMA INDEX not_exists_opt(D)
|
cmd ::= CREATE SMA INDEX not_exists_opt(D)
|
||||||
full_index_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); }
|
col_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); }
|
||||||
cmd ::= CREATE INDEX not_exists_opt(D)
|
cmd ::= CREATE INDEX not_exists_opt(D)
|
||||||
full_index_name(A) ON full_table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, D, A, B, C, NULL); }
|
col_name(A) ON full_table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, D, A, B, C, NULL); }
|
||||||
cmd ::= DROP INDEX exists_opt(B) full_index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); }
|
cmd ::= DROP INDEX exists_opt(B) full_index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); }
|
||||||
|
|
||||||
full_index_name(A) ::= index_name(B). { A = createRealTableNodeForIndexName(pCxt, NULL, &B); }
|
full_index_name(A) ::= index_name(B). { A = createRealTableNodeForIndexName(pCxt, NULL, &B); }
|
||||||
|
|
|
@ -348,7 +348,8 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken*
|
||||||
return (SNode*)val;
|
return (SNode*)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool addHintNodeToList(SAstCreateContext* pCxt, SNodeList** ppHintList, EHintOption opt, SToken* paramList, int32_t paramNum) {
|
bool addHintNodeToList(SAstCreateContext* pCxt, SNodeList** ppHintList, EHintOption opt, SToken* paramList,
|
||||||
|
int32_t paramNum) {
|
||||||
void* value = NULL;
|
void* value = NULL;
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case HINT_BATCH_SCAN:
|
case HINT_BATCH_SCAN:
|
||||||
|
@ -361,7 +362,7 @@ bool addHintNodeToList(SAstCreateContext* pCxt, SNodeList** ppHintList, EHintOpt
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SHintNode* hint = (SHintNode*)nodesMakeNode(QUERY_NODE_HINT);
|
SHintNode* hint = (SHintNode*)nodesMakeNode(QUERY_NODE_HINT);
|
||||||
CHECK_OUT_OF_MEM(hint);
|
CHECK_OUT_OF_MEM(hint);
|
||||||
hint->option = opt;
|
hint->option = opt;
|
||||||
|
@ -385,15 +386,15 @@ SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral) {
|
||||||
if (NULL == pLiteral || pLiteral->n <= 5) {
|
if (NULL == pLiteral || pLiteral->n <= 5) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SNodeList* pHintList = NULL;
|
SNodeList* pHintList = NULL;
|
||||||
char* hint = strndup(pLiteral->z + 3, pLiteral->n - 5);
|
char* hint = strndup(pLiteral->z + 3, pLiteral->n - 5);
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
bool inParamList = false;
|
bool inParamList = false;
|
||||||
bool lastComma = false;
|
bool lastComma = false;
|
||||||
EHintOption opt = 0;
|
EHintOption opt = 0;
|
||||||
int32_t paramNum = 0;
|
int32_t paramNum = 0;
|
||||||
SToken paramList[10];
|
SToken paramList[10];
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
SToken t0 = {0};
|
SToken t0 = {0};
|
||||||
if (hint[i] == 0) {
|
if (hint[i] == 0) {
|
||||||
|
@ -412,7 +413,7 @@ SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral) {
|
||||||
}
|
}
|
||||||
opt = HINT_BATCH_SCAN;
|
opt = HINT_BATCH_SCAN;
|
||||||
break;
|
break;
|
||||||
case TK_NO_BATCH_SCAN:
|
case TK_NO_BATCH_SCAN:
|
||||||
lastComma = false;
|
lastComma = false;
|
||||||
if (0 != opt || inParamList) {
|
if (0 != opt || inParamList) {
|
||||||
quit = true;
|
quit = true;
|
||||||
|
@ -446,7 +447,7 @@ SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral) {
|
||||||
paramList[paramNum++] = t0;
|
paramList[paramNum++] = t0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TK_NK_COMMA:
|
case TK_NK_COMMA:
|
||||||
if (lastComma) {
|
if (lastComma) {
|
||||||
quit = true;
|
quit = true;
|
||||||
}
|
}
|
||||||
|
@ -962,11 +963,12 @@ SNode* addFillClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pFill) {
|
||||||
return pStmt;
|
return pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable, SNodeList* pHint) {
|
SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable,
|
||||||
|
SNodeList* pHint) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SNode* select = createSelectStmtImpl(isDistinct, pProjectionList, pTable, pHint);
|
SNode* select = createSelectStmtImpl(isDistinct, pProjectionList, pTable, pHint);
|
||||||
CHECK_OUT_OF_MEM(select);
|
CHECK_OUT_OF_MEM(select);
|
||||||
return select;
|
return select;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* setSelectStmtTagMode(SAstCreateContext* pCxt, SNode* pStmt, bool bSelectTags) {
|
SNode* setSelectStmtTagMode(SAstCreateContext* pCxt, SNode* pStmt, bool bSelectTags) {
|
||||||
|
@ -1766,8 +1768,23 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->indexType = type;
|
pStmt->indexType = type;
|
||||||
pStmt->ignoreExists = ignoreExists;
|
pStmt->ignoreExists = ignoreExists;
|
||||||
snprintf(pStmt->indexDbName, sizeof(pStmt->indexDbName), "%s", ((SRealTableNode*)pIndexName)->table.dbName);
|
|
||||||
snprintf(pStmt->indexName, sizeof(pStmt->indexName), "%s", ((SRealTableNode*)pIndexName)->table.tableName);
|
SRealTableNode* pFullTable = (SRealTableNode*)pRealTable;
|
||||||
|
if (strlen(pFullTable->table.dbName) == 0) {
|
||||||
|
// no db specified,
|
||||||
|
if (pCxt->pQueryCxt->db == NULL) {
|
||||||
|
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DB_NOT_SPECIFIED);
|
||||||
|
nodesDestroyNode(pIndexName);
|
||||||
|
nodesDestroyNode(pRealTable);
|
||||||
|
nodesDestroyNode(pOptions);
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
snprintf(pStmt->indexDbName, sizeof(pStmt->indexDbName), "%s", pCxt->pQueryCxt->db);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
snprintf(pStmt->indexDbName, sizeof(pStmt->indexDbName), "%s", pFullTable->table.dbName);
|
||||||
|
}
|
||||||
|
snprintf(pStmt->indexName, sizeof(pStmt->indexName), "%s", ((SColumnNode*)pIndexName)->colName);
|
||||||
snprintf(pStmt->dbName, sizeof(pStmt->dbName), "%s", ((SRealTableNode*)pRealTable)->table.dbName);
|
snprintf(pStmt->dbName, sizeof(pStmt->dbName), "%s", ((SRealTableNode*)pRealTable)->table.dbName);
|
||||||
snprintf(pStmt->tableName, sizeof(pStmt->tableName), "%s", ((SRealTableNode*)pRealTable)->table.tableName);
|
snprintf(pStmt->tableName, sizeof(pStmt->tableName), "%s", ((SRealTableNode*)pRealTable)->table.tableName);
|
||||||
nodesDestroyNode(pIndexName);
|
nodesDestroyNode(pIndexName);
|
||||||
|
@ -1884,8 +1901,7 @@ SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pCGroupId,
|
SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pCGroupId, SToken* pTopicName) {
|
||||||
SToken* pTopicName) {
|
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
if (!checkTopicName(pCxt, pTopicName)) {
|
if (!checkTopicName(pCxt, pTopicName)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue