|
|
|
@ -526,7 +526,8 @@ static int32_t getTargetMeta(STranslateContext* pCxt, const SName* pName, STable
|
|
|
|
|
|
|
|
|
|
static int32_t getTableMeta(STranslateContext* pCxt, const char* pDbName, const char* pTableName, STableMeta** pMeta) {
|
|
|
|
|
SName name;
|
|
|
|
|
return getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name), pMeta, false);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name);
|
|
|
|
|
return getTargetMeta(pCxt, &name, pMeta, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int32_t getTableCfg(STranslateContext* pCxt, const SName* pName, STableCfg** pCfg) {
|
|
|
|
@ -557,7 +558,7 @@ static int32_t refreshGetTableMeta(STranslateContext* pCxt, const char* pDbName,
|
|
|
|
|
STableMeta** pMeta) {
|
|
|
|
|
SParseContext* pParCxt = pCxt->pParseCxt;
|
|
|
|
|
SName name;
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name);
|
|
|
|
|
int32_t code = TSDB_CODE_SUCCESS;
|
|
|
|
|
if (pParCxt->async) {
|
|
|
|
|
code = getTableMetaFromCache(pCxt->pMetaCache, &name, pMeta);
|
|
|
|
@ -635,7 +636,8 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam
|
|
|
|
|
static int32_t getTableHashVgroup(STranslateContext* pCxt, const char* pDbName, const char* pTableName,
|
|
|
|
|
SVgroupInfo* pInfo) {
|
|
|
|
|
SName name;
|
|
|
|
|
return getTableHashVgroupImpl(pCxt, toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name), pInfo);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name);
|
|
|
|
|
return getTableHashVgroupImpl(pCxt, &name, pInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int32_t getDBVgVersion(STranslateContext* pCxt, const char* pDbFName, int32_t* pVersion, int64_t* pDbId,
|
|
|
|
@ -4016,7 +4018,7 @@ static int32_t setTableTsmas(STranslateContext* pCxt, SName* pName, SRealTableNo
|
|
|
|
|
SName tsmaTargetTbName = {0};
|
|
|
|
|
SVgroupInfo vgInfo = {0};
|
|
|
|
|
bool exists = false;
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName);
|
|
|
|
|
int32_t len = snprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name,
|
|
|
|
|
pRealTable->table.tableName);
|
|
|
|
|
len = taosCreateMD5Hash(buf, len);
|
|
|
|
@ -4678,9 +4680,8 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare
|
|
|
|
|
// The SRealTableNode created through ROLLUP already has STableMeta.
|
|
|
|
|
if (NULL == pRealTable->pMeta) {
|
|
|
|
|
SName name;
|
|
|
|
|
code = getTargetMeta(
|
|
|
|
|
pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name),
|
|
|
|
|
&(pRealTable->pMeta), true);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name);
|
|
|
|
|
code = getTargetMeta( pCxt, &name, &(pRealTable->pMeta), true);
|
|
|
|
|
if (TSDB_CODE_SUCCESS != code) {
|
|
|
|
|
(void)generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
|
|
|
|
|
return code;
|
|
|
|
@ -6232,7 +6233,7 @@ static void findVgroupsFromEqualTbname(STranslateContext* pCxt, SArray* aTbnames
|
|
|
|
|
for (int j = 0; j < nTbls; ++j) {
|
|
|
|
|
SName snameTb;
|
|
|
|
|
char* tbName = taosArrayGetP(aTbnames, j);
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, dbName, tbName, &snameTb);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, dbName, tbName, &snameTb);
|
|
|
|
|
SVgroupInfo vgInfo = {0};
|
|
|
|
|
bool bExists;
|
|
|
|
|
int32_t code = catalogGetCachedTableHashVgroup(pCxt->pParseCxt->pCatalog, &snameTb, &vgInfo, &bExists);
|
|
|
|
@ -6261,7 +6262,7 @@ static int32_t replaceToChildTableQuery(STranslateContext* pCxt, SEqCondTbNameTa
|
|
|
|
|
int32_t code = 0;
|
|
|
|
|
SRealTableNode* pRealTable = pInfo->pRealTable;
|
|
|
|
|
char* tbName = taosArrayGetP(pInfo->aTbnames, 0);
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, tbName, &snameTb);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, tbName, &snameTb);
|
|
|
|
|
|
|
|
|
|
STableMeta* pMeta = NULL;
|
|
|
|
|
TAOS_CHECK_RETURN(catalogGetCachedTableMeta(pCxt->pParseCxt->pCatalog, &snameTb, &pMeta));
|
|
|
|
@ -6282,7 +6283,7 @@ static int32_t replaceToChildTableQuery(STranslateContext* pCxt, SEqCondTbNameTa
|
|
|
|
|
for (int32_t i = 0; i < pRealTable->pTsmas->size; ++i) {
|
|
|
|
|
STableTSMAInfo* pTsma = taosArrayGetP(pRealTable->pTsmas, i);
|
|
|
|
|
SName tsmaTargetTbName = {0};
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName);
|
|
|
|
|
int32_t len = snprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name,
|
|
|
|
|
pRealTable->table.tableName);
|
|
|
|
|
len = taosCreateMD5Hash(buf, len);
|
|
|
|
@ -8822,7 +8823,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
|
|
|
|
|
}
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
pReq->numOfFuncs = taosArrayGetSize(pReq->pFuncs);
|
|
|
|
|
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pReq->name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName);
|
|
|
|
|
code = tNameExtractFullName(&tableName, pReq->name);
|
|
|
|
|
}
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code)
|
|
|
|
|
code = collectUseTable(&tableName, pCxt->pTables);
|
|
|
|
@ -8866,19 +8868,20 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt
|
|
|
|
|
SDropTableClause* pClause = (SDropTableClause*)nodesListGetNode(pStmt->pTables, 0);
|
|
|
|
|
SName tableName;
|
|
|
|
|
if (pStmt->withTsma) return TSDB_CODE_SUCCESS;
|
|
|
|
|
return doTranslateDropSuperTable(
|
|
|
|
|
pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), pClause->ignoreNotExists);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName);
|
|
|
|
|
return doTranslateDropSuperTable( pCxt, &tableName, pClause->ignoreNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int32_t translateDropSuperTable(STranslateContext* pCxt, SDropSuperTableStmt* pStmt) {
|
|
|
|
|
SName tableName;
|
|
|
|
|
return doTranslateDropSuperTable(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName),
|
|
|
|
|
pStmt->ignoreNotExists);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName);
|
|
|
|
|
return doTranslateDropSuperTable(pCxt, &tableName, pStmt->ignoreNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, SMAlterStbReq* pAlterReq) {
|
|
|
|
|
SName tableName;
|
|
|
|
|
int32_t code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pAlterReq->name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName);
|
|
|
|
|
int32_t code = tNameExtractFullName(&tableName, pAlterReq->name);
|
|
|
|
|
if (TSDB_CODE_SUCCESS != code) return code;
|
|
|
|
|
pAlterReq->alterType = pStmt->alterType;
|
|
|
|
|
|
|
|
|
@ -9394,10 +9397,12 @@ static int32_t getSmaIndexAst(STranslateContext* pCxt, SCreateIndexStmt* pStmt,
|
|
|
|
|
|
|
|
|
|
static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SMCreateSmaReq* pReq) {
|
|
|
|
|
SName name;
|
|
|
|
|
int32_t code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name), pReq->name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name);
|
|
|
|
|
int32_t code = tNameExtractFullName(&name, pReq->name);
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
memset(&name, 0, sizeof(SName));
|
|
|
|
|
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name), pReq->stb);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
|
|
|
|
code = tNameExtractFullName(&name, pReq->stb);
|
|
|
|
|
}
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
pReq->igExists = pStmt->ignoreExists;
|
|
|
|
@ -9545,10 +9550,12 @@ static int32_t buildCreateFullTextReq(STranslateContext* pCxt, SCreateIndexStmt*
|
|
|
|
|
|
|
|
|
|
static int32_t buildCreateTagIndexReq(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SCreateTagIndexReq* pReq) {
|
|
|
|
|
SName name;
|
|
|
|
|
int32_t code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name), pReq->idxName);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name);
|
|
|
|
|
int32_t code = tNameExtractFullName(&name, pReq->idxName);
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
memset(&name, 0, sizeof(SName));
|
|
|
|
|
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name), pReq->stbName);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
|
|
|
|
code = tNameExtractFullName(&name, pReq->stbName);
|
|
|
|
|
}
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
memset(&name, 0, sizeof(SName));
|
|
|
|
@ -9584,8 +9591,8 @@ static int32_t translateCreateNormalIndex(STranslateContext* pCxt, SCreateIndexS
|
|
|
|
|
int32_t code = 0;
|
|
|
|
|
SName name;
|
|
|
|
|
STableMeta* pMeta = NULL;
|
|
|
|
|
|
|
|
|
|
code = getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name), &pMeta, false);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
|
|
|
|
code = getTargetMeta(pCxt, &name, &pMeta, false);
|
|
|
|
|
if (code) {
|
|
|
|
|
taosMemoryFree(pMeta);
|
|
|
|
|
return code;
|
|
|
|
@ -9627,7 +9634,8 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p
|
|
|
|
|
static int32_t translateDropIndex(STranslateContext* pCxt, SDropIndexStmt* pStmt) {
|
|
|
|
|
SMDropSmaReq dropSmaReq = {0};
|
|
|
|
|
SName name;
|
|
|
|
|
int32_t code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name), dropSmaReq.name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name);
|
|
|
|
|
int32_t code = tNameExtractFullName(&name, dropSmaReq.name);
|
|
|
|
|
if (TSDB_CODE_SUCCESS != code) return code;
|
|
|
|
|
dropSmaReq.igNotExists = pStmt->ignoreNotExists;
|
|
|
|
|
return buildCmdMsg(pCxt, TDMT_MND_DROP_SMA, (FSerializeFunc)tSerializeSMDropSmaReq, &dropSmaReq);
|
|
|
|
@ -9702,11 +9710,11 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
|
|
|
|
|
SName name;
|
|
|
|
|
if ('\0' != pStmt->subSTbName[0]) {
|
|
|
|
|
pReq->subType = TOPIC_SUB_TYPE__TABLE;
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name);
|
|
|
|
|
(void)tNameGetFullDbName(&name, pReq->subDbName);
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
(void)tNameExtractFullName(&name, pReq->subStbName);
|
|
|
|
|
if (pStmt->pQuery != NULL) {
|
|
|
|
|
code = tNameExtractFullName(&name, pReq->subStbName);
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code && pStmt->pQuery != NULL) {
|
|
|
|
|
code = nodesNodeToString(pStmt->pQuery, false, &pReq->ast, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -9829,8 +9837,8 @@ static int32_t buildQueryForTableTopic(STranslateContext* pCxt, SCreateTopicStmt
|
|
|
|
|
.mgmtEps = pParCxt->mgmtEpSet};
|
|
|
|
|
SName name;
|
|
|
|
|
STableMeta* pMeta = NULL;
|
|
|
|
|
int32_t code =
|
|
|
|
|
getTargetMeta(pCxt, toName(pParCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name), &pMeta, false);
|
|
|
|
|
toName(pParCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name);
|
|
|
|
|
int32_t code = getTargetMeta(pCxt, &name, &pMeta, false);
|
|
|
|
|
if (code) {
|
|
|
|
|
taosMemoryFree(pMeta);
|
|
|
|
|
return code;
|
|
|
|
@ -9952,7 +9960,7 @@ static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt)
|
|
|
|
|
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
|
|
|
|
|
int32_t origCode = code;
|
|
|
|
|
SName name;
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
|
|
|
|
SViewMeta* pMeta = NULL;
|
|
|
|
|
code = getViewMetaFromMetaCache(pCxt, &name, &pMeta);
|
|
|
|
|
if (TSDB_CODE_SUCCESS != code) {
|
|
|
|
@ -10072,9 +10080,8 @@ static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pSt
|
|
|
|
|
SName name;
|
|
|
|
|
STableMeta* pMeta = NULL;
|
|
|
|
|
int8_t tableType = 0;
|
|
|
|
|
int32_t code =
|
|
|
|
|
getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name),
|
|
|
|
|
&pMeta, true);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name);
|
|
|
|
|
int32_t code = getTargetMeta(pCxt, &name, &pMeta, true);
|
|
|
|
|
if (NULL != pMeta) {
|
|
|
|
|
tableType = pMeta->tableType;
|
|
|
|
|
taosMemoryFree(pMeta);
|
|
|
|
@ -11103,10 +11110,11 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
|
|
|
|
|
if ('\0' != pStmt->targetTabName[0]) {
|
|
|
|
|
strcpy(name.dbname, pStmt->targetDbName);
|
|
|
|
|
strcpy(name.tname, pStmt->targetTabName);
|
|
|
|
|
(void)tNameExtractFullName(&name, pReq->targetStbFullName);
|
|
|
|
|
code = tNameExtractFullName(&name, pReq->targetStbFullName);
|
|
|
|
|
}
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
code = buildCreateStreamQuery(pCxt, pStmt, pReq);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
code = buildCreateStreamQuery(pCxt, pStmt, pReq);
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
pReq->sql = taosStrdup(pCxt->pParseCxt->pSql);
|
|
|
|
|
if (NULL == pReq->sql) {
|
|
|
|
@ -11312,7 +11320,7 @@ static int32_t translateCreateView(STranslateContext* pCxt, SCreateViewStmt* pSt
|
|
|
|
|
SParseSqlRes res = {.resType = PARSE_SQL_RES_SCHEMA};
|
|
|
|
|
SName name;
|
|
|
|
|
char dbFName[TSDB_DB_FNAME_LEN];
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
|
|
|
|
|
(void)tNameGetFullDbName(&name, dbFName);
|
|
|
|
|
|
|
|
|
|
int32_t code = validateCreateView(pCxt, pStmt);
|
|
|
|
@ -11363,7 +11371,7 @@ static int32_t translateDropView(STranslateContext* pCxt, SDropViewStmt* pStmt)
|
|
|
|
|
return TSDB_CODE_OUT_OF_MEMORY;
|
|
|
|
|
}
|
|
|
|
|
dropReq.igNotExists = pStmt->ignoreNotExists;
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
|
|
|
|
|
code = collectUseTable(&name, pCxt->pTargetTables);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -11399,7 +11407,8 @@ static int32_t readFromFile(char* pName, int32_t* len, char** buf) {
|
|
|
|
|
|
|
|
|
|
int64_t s = taosReadFile(tfile, *buf, *len);
|
|
|
|
|
if (s != *len) {
|
|
|
|
|
(void)taosCloseFile(&tfile);
|
|
|
|
|
int32_t code = taosCloseFile(&tfile);
|
|
|
|
|
qError("failed to close file: %s in %s:%d, err: %s", pName, __func__, __LINE__, tstrerror(code));
|
|
|
|
|
taosMemoryFreeClear(*buf);
|
|
|
|
|
return TSDB_CODE_APP_ERROR;
|
|
|
|
|
}
|
|
|
|
@ -11473,8 +11482,8 @@ static int32_t translateGrantTagCond(STranslateContext* pCxt, SGrantStmt* pStmt,
|
|
|
|
|
int32_t code = createRealTableForGrantTable(pStmt, &pTable);
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
SName name;
|
|
|
|
|
code = getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pTable->table.dbName, pTable->table.tableName, &name),
|
|
|
|
|
&(pTable->pMeta), false);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pTable->table.dbName, pTable->table.tableName, &name);
|
|
|
|
|
code = getTargetMeta(pCxt, &name, &(pTable->pMeta), false);
|
|
|
|
|
if (code) {
|
|
|
|
|
nodesDestroyNode((SNode*)pTable);
|
|
|
|
|
return code;
|
|
|
|
@ -11516,8 +11525,8 @@ static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) {
|
|
|
|
|
if (0 != pStmt->tabName[0]) {
|
|
|
|
|
SName name;
|
|
|
|
|
STableMeta* pTableMeta = NULL;
|
|
|
|
|
code =
|
|
|
|
|
getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, &name), &pTableMeta, true);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, &name);
|
|
|
|
|
code = getTargetMeta(pCxt, &name, &pTableMeta, true);
|
|
|
|
|
if (TSDB_CODE_SUCCESS != code) {
|
|
|
|
|
if (TSDB_CODE_PAR_TABLE_NOT_EXIST != code) {
|
|
|
|
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
|
|
|
|
@ -11552,8 +11561,8 @@ static int32_t translateRevoke(STranslateContext* pCxt, SRevokeStmt* pStmt) {
|
|
|
|
|
if (0 != pStmt->tabName[0]) {
|
|
|
|
|
SName name;
|
|
|
|
|
STableMeta* pTableMeta = NULL;
|
|
|
|
|
code =
|
|
|
|
|
getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, &name), &pTableMeta, true);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, &name);
|
|
|
|
|
code = getTargetMeta(pCxt, &name, &pTableMeta, true);
|
|
|
|
|
if (TSDB_CODE_SUCCESS != code) {
|
|
|
|
|
if (TSDB_CODE_PAR_TABLE_NOT_EXIST != code) {
|
|
|
|
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
|
|
|
|
@ -11667,7 +11676,7 @@ static int32_t translateShowCreateTable(STranslateContext* pCxt, SShowCreateTabl
|
|
|
|
|
int32_t code = getDBCfg(pCxt, pStmt->dbName, (SDbCfgInfo*)pStmt->pDbCfg);
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
SName name;
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
|
|
|
|
code = getTableCfg(pCxt, &name, (STableCfg**)&pStmt->pTableCfg);
|
|
|
|
|
}
|
|
|
|
|
return code;
|
|
|
|
@ -11678,7 +11687,7 @@ static int32_t translateShowCreateView(STranslateContext* pCxt, SShowCreateViewS
|
|
|
|
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
|
|
|
|
#else
|
|
|
|
|
SName name;
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
|
|
|
|
|
return getViewMetaFromMetaCache(pCxt, &name, (SViewMeta**)&pStmt->pViewMeta);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -11949,10 +11958,11 @@ static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStm
|
|
|
|
|
SName name;
|
|
|
|
|
SDbCfgInfo pDbInfo = {0};
|
|
|
|
|
int32_t code = TSDB_CODE_SUCCESS;
|
|
|
|
|
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name), pReq->name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name);
|
|
|
|
|
code = tNameExtractFullName(&name, pReq->name);
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
memset(&name, 0, sizeof(SName));
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, useTbName);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, useTbName);
|
|
|
|
|
code = tNameExtractFullName(useTbName, pReq->stb);
|
|
|
|
|
}
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
@ -12025,7 +12035,8 @@ static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStm
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
memset(useTbName, 0, sizeof(SName));
|
|
|
|
|
memcpy(pStmt->originalTbName, pRecursiveTsma->tb, TSDB_TABLE_NAME_LEN);
|
|
|
|
|
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pRecursiveTsma->tb, useTbName), pReq->stb);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pRecursiveTsma->tb, useTbName);
|
|
|
|
|
code = tNameExtractFullName(useTbName, pReq->stb);
|
|
|
|
|
}
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
numOfCols = pRecursiveTsma->pUsedCols->size;
|
|
|
|
@ -12146,7 +12157,7 @@ int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSData
|
|
|
|
|
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
SName name = {0};
|
|
|
|
|
(void)toName(pParseCxt->acctId, pStmt->dbName, pStmt->originalTbName, &name);
|
|
|
|
|
toName(pParseCxt->acctId, pStmt->dbName, pStmt->originalTbName, &name);
|
|
|
|
|
code = collectUseTable(&name, cxt.pTargetTables);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -12165,13 +12176,14 @@ static int32_t translateDropTSMA(STranslateContext* pCxt, SDropTSMAStmt* pStmt)
|
|
|
|
|
SMDropSmaReq dropReq = {0};
|
|
|
|
|
SName name;
|
|
|
|
|
STableTSMAInfo* pTsma = NULL;
|
|
|
|
|
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name), dropReq.name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name);
|
|
|
|
|
code = tNameExtractFullName(&name, dropReq.name);
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
dropReq.igNotExists = pStmt->ignoreNotExists;
|
|
|
|
|
code = getTsma(pCxt, &name, &pTsma);
|
|
|
|
|
}
|
|
|
|
|
if (code == TSDB_CODE_SUCCESS) {
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pTsma->tb, &name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pTsma->tb, &name);
|
|
|
|
|
code = collectUseTable(&name, pCxt->pTargetTables);
|
|
|
|
|
}
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code)
|
|
|
|
@ -13071,10 +13083,8 @@ static int32_t checkShowTags(STranslateContext* pCxt, const SShowStmt* pShow) {
|
|
|
|
|
int32_t code = 0;
|
|
|
|
|
SName name;
|
|
|
|
|
STableMeta* pTableMeta = NULL;
|
|
|
|
|
code = getTargetMeta(pCxt,
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, ((SValueNode*)pShow->pDbName)->literal,
|
|
|
|
|
((SValueNode*)pShow->pTbName)->literal, &name),
|
|
|
|
|
&pTableMeta, true);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, ((SValueNode*)pShow->pDbName)->literal, ((SValueNode*)pShow->pTbName)->literal, &name);
|
|
|
|
|
code = getTargetMeta(pCxt, &name, &pTableMeta, true);
|
|
|
|
|
if (TSDB_CODE_SUCCESS != code) {
|
|
|
|
|
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
|
|
|
|
|
goto _exit;
|
|
|
|
@ -13433,7 +13443,7 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
|
|
|
|
|
int32_t code = checkCreateTable(pCxt, pStmt, false);
|
|
|
|
|
SVgroupInfo info = {0};
|
|
|
|
|
SName name;
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
code = getTableHashVgroupImpl(pCxt, &name, &info);
|
|
|
|
|
}
|
|
|
|
@ -13681,7 +13691,7 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
|
|
|
|
|
}
|
|
|
|
|
if (TSDB_CODE_SUCCESS == code) {
|
|
|
|
|
SName name;
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
|
|
|
|
code = collectUseTable(&name, pCxt->pTargetTables);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -14447,7 +14457,7 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) {
|
|
|
|
|
FOREACH(pNode, pStmt->pTables) {
|
|
|
|
|
SDropTableClause* pClause = (SDropTableClause*)pNode;
|
|
|
|
|
SName name;
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name);
|
|
|
|
|
int32_t code = buildDropTableVgroupHashmap(pCxt, pClause, &name, &tableType, pVgroupHashmap);
|
|
|
|
|
if (TSDB_CODE_SUCCESS != code) {
|
|
|
|
|
taosHashCleanup(pVgroupHashmap);
|
|
|
|
@ -14523,7 +14533,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
|
|
|
|
SArray* pTsmas = NULL;
|
|
|
|
|
int32_t code = TSDB_CODE_SUCCESS;
|
|
|
|
|
if (pCxt->pMetaCache) {
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tbName);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tbName);
|
|
|
|
|
code = getTableTsmasFromCache(pCxt->pMetaCache, &tbName, &pTsmas);
|
|
|
|
|
if (code != TSDB_CODE_SUCCESS) return code;
|
|
|
|
|
if (pTsmas && pTsmas->size > 0) return TSDB_CODE_TSMA_MUST_BE_DROPPED;
|
|
|
|
@ -14707,7 +14717,7 @@ static int32_t buildRenameColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt
|
|
|
|
|
SArray* pTsmas = NULL;
|
|
|
|
|
SName tbName;
|
|
|
|
|
int32_t code = 0;
|
|
|
|
|
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tbName);
|
|
|
|
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tbName);
|
|
|
|
|
if (pCxt->pMetaCache) code = getTableTsmasFromCache(pCxt->pMetaCache, &tbName, &pTsmas);
|
|
|
|
|
if (TSDB_CODE_SUCCESS != code) return code;
|
|
|
|
|
if (pTsmas && pTsmas->size > 0) {
|
|
|
|
|