Merge pull request #22639 from taosdata/fix/TD-26025
fix create tag error
This commit is contained in:
commit
d87a525131
|
@ -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;
|
||||||
|
|
|
@ -336,7 +336,7 @@ static int32_t collectMetaKeyFromUseDatabase(SCollectMetaKeyCxt* pCxt, SUseDatab
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromCreateIndex(SCollectMetaKeyCxt* pCxt, SCreateIndexStmt* pStmt) {
|
static int32_t collectMetaKeyFromCreateIndex(SCollectMetaKeyCxt* pCxt, SCreateIndexStmt* pStmt) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (INDEX_TYPE_SMA == pStmt->indexType) {
|
if (INDEX_TYPE_SMA == pStmt->indexType || INDEX_TYPE_NORMAL == pStmt->indexType) {
|
||||||
code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
||||||
|
@ -356,8 +356,7 @@ static int32_t collectMetaKeyFromCreateTopic(SCollectMetaKeyCxt* pCxt, SCreateTo
|
||||||
return collectMetaKeyFromQuery(pCxt, pStmt->pQuery);
|
return collectMetaKeyFromQuery(pCxt, pStmt->pQuery);
|
||||||
}
|
}
|
||||||
if (NULL != pStmt->pWhere) {
|
if (NULL != pStmt->pWhere) {
|
||||||
int32_t code = collectMetaKeyFromRealTableImpl(pCxt, pStmt->subDbName, pStmt->subSTbName,
|
int32_t code = collectMetaKeyFromRealTableImpl(pCxt, pStmt->subDbName, pStmt->subSTbName, AUTH_TYPE_READ);
|
||||||
AUTH_TYPE_READ);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -387,7 +386,7 @@ static int32_t collectMetaKeyFromCreateStream(SCollectMetaKeyCxt* pCxt, SCreateS
|
||||||
if (TSDB_CODE_SUCCESS == code && pStmt->pOptions->fillHistory) {
|
if (TSDB_CODE_SUCCESS == code && pStmt->pOptions->fillHistory) {
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
||||||
code = reserveDbCfgForLastRow(pCxt, pSelect->pFromTable);
|
code = reserveDbCfgForLastRow(pCxt, pSelect->pFromTable);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,8 +589,8 @@ static int32_t collectMetaKeyFromShowCreateTable(SCollectMetaKeyCxt* pCxt, SShow
|
||||||
code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName, AUTH_TYPE_READ,
|
code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->tableName,
|
||||||
pCxt->pMetaCache);
|
AUTH_TYPE_READ, pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -18,6 +18,20 @@ sql use $dbPrefix
|
||||||
print =============== create super table and register tag index
|
print =============== create super table and register tag index
|
||||||
sql create table if not exists $mtPrefix (ts timestamp, c1 int) tags (t1 int, t2 int, t3 int, t4 int, t5 int)
|
sql create table if not exists $mtPrefix (ts timestamp, c1 int) tags (t1 int, t2 int, t3 int, t4 int, t5 int)
|
||||||
|
|
||||||
|
sql use information_schema;
|
||||||
|
|
||||||
|
sql create index t2i on ta_3_db.ta_3_mt(t2)
|
||||||
|
|
||||||
|
sql_error create index t3i on ta_3_mt(t3)
|
||||||
|
|
||||||
|
sql_error drop index t2i
|
||||||
|
sql drop index ta_3_db.t2i
|
||||||
|
|
||||||
|
|
||||||
|
sql use $dbPrefix
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sql show stables
|
sql show stables
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
|
@ -310,4 +324,5 @@ sql_error create index ti2 on $mtPrefix (t1)
|
||||||
sql_error create index t2i on ta_3_tb17 (t2)
|
sql_error create index t2i on ta_3_tb17 (t2)
|
||||||
|
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
|
Loading…
Reference in New Issue