rebuild index at tag0
This commit is contained in:
parent
1990a891c2
commit
cf9f9ab471
|
@ -79,9 +79,12 @@ int32_t mndInitIdx(SMnode *pMnode) {
|
|||
return sdbSetTable(pMnode->pSdb, table);
|
||||
}
|
||||
|
||||
static int32_t mndFindSuperTableTagId(const SStbObj *pStb, const char *tagName) {
|
||||
static int32_t mndFindSuperTableTagId(const SStbObj *pStb, const char *tagName, int8_t *hasIdx) {
|
||||
for (int32_t tag = 0; tag < pStb->numOfTags; tag++) {
|
||||
if (strcasecmp(pStb->pTags[tag].name, tagName) == 0) {
|
||||
if (IS_IDX_ON(&pStb->pTags[tag])) {
|
||||
*hasIdx = 1;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
@ -597,7 +600,8 @@ static int32_t mndSetUpdateIdxStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb
|
|||
pNew->updateTime = taosGetTimestampMs();
|
||||
pNew->lock = 0;
|
||||
|
||||
int32_t tag = mndFindSuperTableTagId(pOld, tagName);
|
||||
int8_t hasIdx = 0;
|
||||
int32_t tag = mndFindSuperTableTagId(pOld, tagName, &hasIdx);
|
||||
if (tag < 0) {
|
||||
terrno = TSDB_CODE_MND_TAG_NOT_EXIST;
|
||||
return -1;
|
||||
|
@ -612,14 +616,14 @@ static int32_t mndSetUpdateIdxStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb
|
|||
SSchema *pTag = pNew->pTags + tag;
|
||||
|
||||
if (on == 1) {
|
||||
if (IS_IDX_ON(pTag)) {
|
||||
if (hasIdx && tag != 0) {
|
||||
terrno = TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST;
|
||||
return -1;
|
||||
} else {
|
||||
SSCHMEA_SET_IDX_ON(pTag);
|
||||
}
|
||||
} else {
|
||||
if (!IS_IDX_ON(pTag)) {
|
||||
if (hasIdx == 0) {
|
||||
terrno = TSDB_CODE_MND_SMA_NOT_EXIST;
|
||||
} else {
|
||||
SSCHMEA_SET_IDX_OFF(pTag);
|
||||
|
@ -667,7 +671,42 @@ _OVER:
|
|||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
}
|
||||
int8_t mndCheckIndexNameByTagName(SMnode *pMnode, SIdxObj *pIdxObj) {
|
||||
// build index on first tag, and no index name;
|
||||
int8_t exist = 0;
|
||||
SDbObj *pDb = NULL;
|
||||
if (strlen(pIdxObj->db) > 0) {
|
||||
pDb = mndAcquireDb(pMnode, pIdxObj->db);
|
||||
if (pDb == NULL) return 0;
|
||||
}
|
||||
SSmaAndTagIter *pIter = NULL;
|
||||
SIdxObj *pIdx = NULL;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
while (1) {
|
||||
pIter = sdbFetch(pSdb, SDB_IDX, pIter, (void **)&pIdx);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (NULL != pDb && pIdx->dbUid != pDb->uid) {
|
||||
sdbRelease(pSdb, pIdx);
|
||||
continue;
|
||||
}
|
||||
if (pIdxObj->stbUid != pIdx->stbUid) {
|
||||
sdbRelease(pSdb, pIdx);
|
||||
continue;
|
||||
}
|
||||
if (strncmp(pIdxObj->colName, pIdx->colName, TSDB_COL_NAME_LEN) == 0) {
|
||||
sdbRelease(pSdb, pIdx);
|
||||
sdbCancelFetch(pSdb, pIdx);
|
||||
exist = 1;
|
||||
break;
|
||||
}
|
||||
sdbRelease(pSdb, pIdx);
|
||||
}
|
||||
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
return exist;
|
||||
}
|
||||
static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *req, SDbObj *pDb, SStbObj *pStb) {
|
||||
int32_t code = -1;
|
||||
SIdxObj idxObj = {0};
|
||||
|
@ -681,11 +720,20 @@ static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *re
|
|||
idxObj.stbUid = pStb->uid;
|
||||
idxObj.dbUid = pStb->dbUid;
|
||||
|
||||
int32_t tag = mndFindSuperTableTagId(pStb, req->colName);
|
||||
int8_t hasIdx = 0;
|
||||
int32_t tag = mndFindSuperTableTagId(pStb, req->colName, &hasIdx);
|
||||
if (tag < 0) {
|
||||
terrno = TSDB_CODE_MND_TAG_NOT_EXIST;
|
||||
return -1;
|
||||
} else if (tag == 0) {
|
||||
}
|
||||
int8_t exist = 0;
|
||||
if (tag == 0 && hasIdx == 1) {
|
||||
exist = mndCheckIndexNameByTagName(pMnode, &idxObj);
|
||||
if (exist) {
|
||||
terrno = TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST;
|
||||
return -1;
|
||||
}
|
||||
} else if (hasIdx == 1) {
|
||||
terrno = TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
@ -695,11 +743,11 @@ static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *re
|
|||
return -1;
|
||||
}
|
||||
|
||||
SSchema *pTag = pStb->pTags + tag;
|
||||
if (IS_IDX_ON(pTag)) {
|
||||
terrno = TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST;
|
||||
return -1;
|
||||
}
|
||||
// SSchema *pTag = pStb->pTags + tag;
|
||||
// if (IS_IDX_ON(pTag)) {
|
||||
// terrno = TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST;
|
||||
// return -1;
|
||||
// }
|
||||
code = mndAddIndexImpl(pMnode, pReq, pDb, pStb, &idxObj);
|
||||
|
||||
return code;
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
#include "osMemory.h"
|
||||
#include "tencode.h"
|
||||
|
||||
void _metaReaderInit(SMetaReader* pReader, void* pVnode, int32_t flags, SStoreMeta* pAPI) {
|
||||
SMeta* pMeta = ((SVnode*)pVnode)->pMeta;
|
||||
void _metaReaderInit(SMetaReader *pReader, void *pVnode, int32_t flags, SStoreMeta *pAPI) {
|
||||
SMeta *pMeta = ((SVnode *)pVnode)->pMeta;
|
||||
metaReaderDoInit(pReader, pMeta, flags);
|
||||
pReader->pAPI = pAPI;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) {
|
|||
int metaGetTableNameByUid(void *pVnode, uint64_t uid, char *tbName) {
|
||||
int code = 0;
|
||||
SMetaReader mr = {0};
|
||||
metaReaderDoInit(&mr, ((SVnode*)pVnode)->pMeta, 0);
|
||||
metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, 0);
|
||||
code = metaReaderGetTableEntryByUid(&mr, uid);
|
||||
if (code < 0) {
|
||||
metaReaderClear(&mr);
|
||||
|
@ -195,7 +195,7 @@ int metaGetTableUidByName(void *pVnode, char *tbName, uint64_t *uid) {
|
|||
int metaGetTableTypeByName(void *pVnode, char *tbName, ETableType *tbType) {
|
||||
int code = 0;
|
||||
SMetaReader mr = {0};
|
||||
metaReaderDoInit(&mr, ((SVnode*)pVnode)->pMeta, 0);
|
||||
metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, 0);
|
||||
|
||||
code = metaGetTableEntryByName(&mr, tbName);
|
||||
if (code == 0) *tbType = mr.me.type;
|
||||
|
@ -244,7 +244,7 @@ SMTbCursor *metaOpenTbCursor(void *pVnode) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SVnode* pVnodeObj = pVnode;
|
||||
SVnode *pVnodeObj = pVnode;
|
||||
// tdbTbcMoveToFirst((TBC *)pTbCur->pDbc);
|
||||
pTbCur->pMeta = pVnodeObj->pMeta;
|
||||
pTbCur->paused = 1;
|
||||
|
@ -1139,7 +1139,7 @@ int32_t metaFilterTtl(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
pCursor->type = param->type;
|
||||
|
||||
metaRLock(pMeta);
|
||||
//ret = tdbTbcOpen(pMeta->pTtlIdx, &pCursor->pCur, NULL);
|
||||
// ret = tdbTbcOpen(pMeta->pTtlIdx, &pCursor->pCur, NULL);
|
||||
|
||||
END:
|
||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||
|
@ -1194,7 +1194,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
ret = -1;
|
||||
for (int i = 0; i < oStbEntry.stbEntry.schemaTag.nCols; i++) {
|
||||
SSchema *schema = oStbEntry.stbEntry.schemaTag.pSchema + i;
|
||||
if (schema->colId == param->cid && param->type == schema->type && (IS_IDX_ON(schema) || i == 0)) {
|
||||
if (schema->colId == param->cid && param->type == schema->type && (IS_IDX_ON(schema))) {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -450,12 +450,13 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
goto _err;
|
||||
}
|
||||
if (IS_IDX_ON(pNew) && !IS_IDX_ON(pOld)) {
|
||||
if (diffIdx != -1) goto _err;
|
||||
// if (diffIdx != -1) goto _err;
|
||||
diffIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (diffIdx == -1 || diffIdx == 0) {
|
||||
if (diffIdx == -1) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -586,7 +587,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
|||
for (int i = 0; i < oStbEntry.stbEntry.schemaTag.nCols; i++) {
|
||||
SSchema *schema = oStbEntry.stbEntry.schemaTag.pSchema + i;
|
||||
if (0 == strncmp(schema->name, pReq->colName, sizeof(pReq->colName))) {
|
||||
if (i != 0 || IS_IDX_ON(schema)) {
|
||||
if (IS_IDX_ON(schema)) {
|
||||
pCol = schema;
|
||||
}
|
||||
break;
|
||||
|
@ -2094,7 +2095,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
|
|||
} else {
|
||||
for (int i = 0; i < pTagSchema->nCols; i++) {
|
||||
pTagColumn = &pTagSchema->pSchema[i];
|
||||
if (i != 0 && !IS_IDX_ON(pTagColumn)) continue;
|
||||
if (!IS_IDX_ON(pTagColumn)) continue;
|
||||
|
||||
STagVal tagVal = {.cid = pTagColumn->colId};
|
||||
tTagGet((const STag *)pCtbEntry->ctbEntry.pTags, &tagVal);
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#define SYSTABLE_SHOW_TYPE_OFFSET QUERY_NODE_SHOW_DNODES_STMT
|
||||
|
||||
typedef struct SRewriteTbNameContext {
|
||||
int32_t errCode;
|
||||
char* pTbName;
|
||||
int32_t errCode;
|
||||
char* pTbName;
|
||||
} SRewriteTbNameContext;
|
||||
|
||||
typedef struct STranslateContext {
|
||||
|
@ -54,7 +54,7 @@ typedef struct STranslateContext {
|
|||
bool stableQuery;
|
||||
bool showRewrite;
|
||||
SNode* pPrevRoot;
|
||||
SNode* pPostRoot;
|
||||
SNode* pPostRoot;
|
||||
} STranslateContext;
|
||||
|
||||
typedef struct SBuildTopicContext {
|
||||
|
@ -278,10 +278,11 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
|||
static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode);
|
||||
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode);
|
||||
static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal);
|
||||
static int32_t createSimpleSelectStmtFromProjList(const char* pDb, const char* pTable, SNodeList* pProjectionList, SSelectStmt** pStmt);
|
||||
static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta, SNode** pQuery);
|
||||
static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery);
|
||||
static int32_t setRefreshMate(STranslateContext* pCxt, SQuery* pQuery);
|
||||
static int32_t createSimpleSelectStmtFromProjList(const char* pDb, const char* pTable, SNodeList* pProjectionList,
|
||||
SSelectStmt** pStmt);
|
||||
static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta, SNode** pQuery);
|
||||
static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery);
|
||||
static int32_t setRefreshMate(STranslateContext* pCxt, SQuery* pQuery);
|
||||
|
||||
static bool afterGroupBy(ESqlClause clause) { return clause > SQL_CLAUSE_GROUP_BY; }
|
||||
|
||||
|
@ -772,7 +773,8 @@ static SNodeList* getProjectList(const SNode* pNode) {
|
|||
|
||||
static bool isTimeLineQuery(SNode* pStmt) {
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) {
|
||||
return (TIME_LINE_MULTI == ((SSelectStmt*)pStmt)->timeLineResMode) || (TIME_LINE_GLOBAL == ((SSelectStmt*)pStmt)->timeLineResMode);
|
||||
return (TIME_LINE_MULTI == ((SSelectStmt*)pStmt)->timeLineResMode) ||
|
||||
(TIME_LINE_GLOBAL == ((SSelectStmt*)pStmt)->timeLineResMode);
|
||||
} else if (QUERY_NODE_SET_OPERATOR == nodeType(pStmt)) {
|
||||
return TIME_LINE_GLOBAL == ((SSetOperator*)pStmt)->timeLineResMode;
|
||||
} else {
|
||||
|
@ -791,7 +793,7 @@ static bool isGlobalTimeLineQuery(SNode* pStmt) {
|
|||
}
|
||||
|
||||
static bool isTimeLineAlignedQuery(SNode* pStmt) {
|
||||
SSelectStmt *pSelect = (SSelectStmt *)pStmt;
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
||||
if (isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -801,7 +803,7 @@ static bool isTimeLineAlignedQuery(SNode* pStmt) {
|
|||
if (QUERY_NODE_SELECT_STMT != nodeType(((STempTableNode*)pSelect->pFromTable)->pSubquery)) {
|
||||
return false;
|
||||
}
|
||||
SSelectStmt *pSub = (SSelectStmt *)((STempTableNode*)pSelect->pFromTable)->pSubquery;
|
||||
SSelectStmt* pSub = (SSelectStmt*)((STempTableNode*)pSelect->pFromTable)->pSubquery;
|
||||
if (nodesListMatch(pSelect->pPartitionByList, pSub->pPartitionByList)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -822,18 +824,18 @@ static bool isPrimaryKeyImpl(SNode* pExpr) {
|
|||
return true;
|
||||
}
|
||||
} else if (QUERY_NODE_OPERATOR == nodeType(pExpr)) {
|
||||
SOperatorNode* pOper = (SOperatorNode*)pExpr;
|
||||
if (OP_TYPE_ADD != pOper->opType && OP_TYPE_SUB != pOper->opType) {
|
||||
return false;
|
||||
}
|
||||
if (!isPrimaryKeyImpl(pOper->pLeft)) {
|
||||
return false;
|
||||
}
|
||||
if (QUERY_NODE_VALUE != nodeType(pOper->pRight)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
SOperatorNode* pOper = (SOperatorNode*)pExpr;
|
||||
if (OP_TYPE_ADD != pOper->opType && OP_TYPE_SUB != pOper->opType) {
|
||||
return false;
|
||||
}
|
||||
if (!isPrimaryKeyImpl(pOper->pLeft)) {
|
||||
return false;
|
||||
}
|
||||
if (QUERY_NODE_VALUE != nodeType(pOper->pRight)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -860,7 +862,7 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p
|
|||
pCol->tableType = pTable->pMeta->tableType;
|
||||
pCol->colId = pColSchema->colId;
|
||||
pCol->colType = (tagFlag >= 0 ? COLUMN_TYPE_TAG : COLUMN_TYPE_COLUMN);
|
||||
pCol->hasIndex = ((0 == tagFlag) || (pColSchema != NULL && IS_IDX_ON(pColSchema)));
|
||||
pCol->hasIndex = (pColSchema != NULL && IS_IDX_ON(pColSchema));
|
||||
pCol->node.resType.type = pColSchema->type;
|
||||
pCol->node.resType.bytes = pColSchema->bytes;
|
||||
if (TSDB_DATA_TYPE_TIMESTAMP == pCol->node.resType.type) {
|
||||
|
@ -1406,7 +1408,7 @@ static bool isCountStar(SFunctionNode* pFunc) {
|
|||
}
|
||||
|
||||
static int32_t rewriteCountStarAsCount1(STranslateContext* pCxt, SFunctionNode* pCount) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
if (NULL == pVal) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1608,9 +1610,11 @@ static int32_t translateInterpFunc(STranslateContext* pCxt, SFunctionNode* pFunc
|
|||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||
}
|
||||
|
||||
if (pSelect->hasInterpFunc && (FUNC_RETURN_ROWS_INDEFINITE == pSelect->returnRows || pSelect->returnRows != fmGetFuncReturnRows(pFunc))) {
|
||||
if (pSelect->hasInterpFunc &&
|
||||
(FUNC_RETURN_ROWS_INDEFINITE == pSelect->returnRows || pSelect->returnRows != fmGetFuncReturnRows(pFunc))) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
|
||||
"%s ignoring null value options cannot be used when applying to multiple columns", pFunc->functionName);
|
||||
"%s ignoring null value options cannot be used when applying to multiple columns",
|
||||
pFunc->functionName);
|
||||
}
|
||||
|
||||
if (NULL != pSelect->pWindow || NULL != pSelect->pGroupByList) {
|
||||
|
@ -1648,7 +1652,8 @@ static int32_t translateTimelineFunc(STranslateContext* pCxt, SFunctionNode* pFu
|
|||
}
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
||||
if (NULL != pSelect->pFromTable && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) &&
|
||||
!isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery) && !isTimeLineAlignedQuery(pCxt->pCurrStmt)) {
|
||||
!isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery) &&
|
||||
!isTimeLineAlignedQuery(pCxt->pCurrStmt)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
|
||||
"%s function requires valid time series input", pFunc->functionName);
|
||||
}
|
||||
|
@ -1718,8 +1723,8 @@ static int32_t translateForbidSysTableFunc(STranslateContext* pCxt, SFunctionNod
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
||||
SNode* pTable = pSelect->pFromTable;
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
||||
SNode* pTable = pSelect->pFromTable;
|
||||
if (NULL != pTable && QUERY_NODE_REAL_TABLE == nodeType(pTable) &&
|
||||
TSDB_SYSTEM_TABLE == ((SRealTableNode*)pTable)->pMeta->tableType) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED_FUNC, pFunc->functionName);
|
||||
|
@ -2308,7 +2313,8 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
|||
}
|
||||
}
|
||||
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||
if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc || (isDistinctOrderBy(pCxt) && pCxt->currClause == SQL_CLAUSE_ORDER_BY)) {
|
||||
if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc ||
|
||||
(isDistinctOrderBy(pCxt) && pCxt->currClause == SQL_CLAUSE_ORDER_BY)) {
|
||||
return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt), ((SExprNode*)(*pNode))->userAlias);
|
||||
} else {
|
||||
return rewriteColToSelectValFunc(pCxt, pNode);
|
||||
|
@ -2403,14 +2409,14 @@ static int32_t checkHavingGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect)
|
|||
if (NULL != pSelect->pHaving) {
|
||||
code = checkExprForGroupBy(pCxt, &pSelect->pHaving);
|
||||
}
|
||||
/*
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pProjectionList) {
|
||||
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pProjectionList);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pOrderByList) {
|
||||
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pProjectionList) {
|
||||
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pProjectionList);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pOrderByList) {
|
||||
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
|
||||
}
|
||||
*/
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -2669,10 +2675,10 @@ static int32_t setTableCacheLastMode(STranslateContext* pCxt, SSelectStmt* pSele
|
|||
static EDealRes doTranslateTbName(SNode** pNode, void* pContext) {
|
||||
switch (nodeType(*pNode)) {
|
||||
case QUERY_NODE_FUNCTION: {
|
||||
SFunctionNode *pFunc = (SFunctionNode *)*pNode;
|
||||
SFunctionNode* pFunc = (SFunctionNode*)*pNode;
|
||||
if (FUNCTION_TYPE_TBNAME == pFunc->funcType) {
|
||||
SRewriteTbNameContext *pCxt = (SRewriteTbNameContext*)pContext;
|
||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SRewriteTbNameContext* pCxt = (SRewriteTbNameContext*)pContext;
|
||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
if (NULL == pVal) {
|
||||
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
|
@ -2711,11 +2717,12 @@ static int32_t replaceTbName(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
}
|
||||
|
||||
SRealTableNode* pTable = (SRealTableNode*)pSelect->pFromTable;
|
||||
if (TSDB_CHILD_TABLE != pTable->pMeta->tableType && TSDB_NORMAL_TABLE != pTable->pMeta->tableType && TSDB_SYSTEM_TABLE != pTable->pMeta->tableType) {
|
||||
if (TSDB_CHILD_TABLE != pTable->pMeta->tableType && TSDB_NORMAL_TABLE != pTable->pMeta->tableType &&
|
||||
TSDB_SYSTEM_TABLE != pTable->pMeta->tableType) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SNode** pNode = NULL;
|
||||
SNode** pNode = NULL;
|
||||
SRewriteTbNameContext pRewriteCxt = {0};
|
||||
pRewriteCxt.pTbName = pTable->table.tableName;
|
||||
|
||||
|
@ -3122,7 +3129,8 @@ static int32_t convertFillValue(STranslateContext* pCxt, SDataType dt, SNodeList
|
|||
code = scalarCalculateConstants(pCastFunc, &pCell->pNode);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_VALUE != nodeType(pCell->pNode)) {
|
||||
code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Fill value can only accept constant");
|
||||
code =
|
||||
generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Fill value can only accept constant");
|
||||
} else if (TSDB_CODE_SUCCESS != code) {
|
||||
code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Filled data type mismatch");
|
||||
}
|
||||
|
@ -3588,7 +3596,6 @@ static int32_t createDefaultEveryNode(STranslateContext* pCxt, SNode** pOutput)
|
|||
pEvery->isDuration = true;
|
||||
pEvery->literal = taosStrdup("1s");
|
||||
|
||||
|
||||
*pOutput = (SNode*)pEvery;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -3683,15 +3690,15 @@ static int32_t translateInterp(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
static int32_t translatePartitionBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
pCxt->currClause = SQL_CLAUSE_PARTITION_BY;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
|
||||
if (pSelect->pPartitionByList) {
|
||||
int8_t typeType = getTableTypeFromTableNode(pSelect->pFromTable);
|
||||
SNode* pPar = nodesListGetNode(pSelect->pPartitionByList, 0);
|
||||
if (!((TSDB_NORMAL_TABLE == typeType || TSDB_CHILD_TABLE == typeType) &&
|
||||
1 == pSelect->pPartitionByList->length && (QUERY_NODE_FUNCTION == nodeType(pPar) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pPar)->funcType))) {
|
||||
if (!((TSDB_NORMAL_TABLE == typeType || TSDB_CHILD_TABLE == typeType) && 1 == pSelect->pPartitionByList->length &&
|
||||
(QUERY_NODE_FUNCTION == nodeType(pPar) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pPar)->funcType))) {
|
||||
pSelect->timeLineResMode = TIME_LINE_MULTI;
|
||||
}
|
||||
|
||||
|
||||
code = translateExprList(pCxt, pSelect->pPartitionByList);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -3955,9 +3962,9 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
|
|||
}
|
||||
snprintf(pRightExpr->aliasName, sizeof(pRightExpr->aliasName), "%s", pLeftExpr->aliasName);
|
||||
SNode* pProj = createSetOperProject(pSetOperator->stmtName, pLeft);
|
||||
if (QUERY_NODE_COLUMN == nodeType(pLeft) && QUERY_NODE_COLUMN == nodeType(pRight)
|
||||
&& ((SColumnNode*)pLeft)->colId == PRIMARYKEY_TIMESTAMP_COL_ID
|
||||
&& ((SColumnNode*)pRight)->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
if (QUERY_NODE_COLUMN == nodeType(pLeft) && QUERY_NODE_COLUMN == nodeType(pRight) &&
|
||||
((SColumnNode*)pLeft)->colId == PRIMARYKEY_TIMESTAMP_COL_ID &&
|
||||
((SColumnNode*)pRight)->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
((SColumnNode*)pProj)->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pSetOperator->pProjectionList, pProj)) {
|
||||
|
@ -5737,7 +5744,6 @@ static int32_t translateRestoreDnode(STranslateContext* pCxt, SRestoreComponentN
|
|||
return buildCmdMsg(pCxt, TDMT_MND_RESTORE_DNODE, (FSerializeFunc)tSerializeSRestoreDnodeReq, &restoreReq);
|
||||
}
|
||||
|
||||
|
||||
static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, const char* pDbName, const char* pTableName,
|
||||
int32_t* pVgId) {
|
||||
SVgroupInfo vg = {0};
|
||||
|
@ -5865,7 +5871,7 @@ static int32_t checkCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pS
|
|||
}
|
||||
|
||||
static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
|
||||
int32_t code = checkCreateSmaIndex(pCxt, pStmt);
|
||||
int32_t code = checkCreateSmaIndex(pCxt, pStmt);
|
||||
pStmt->pReq = taosMemoryCalloc(1, sizeof(SMCreateSmaReq));
|
||||
if (pStmt->pReq == NULL) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -5879,13 +5885,15 @@ int32_t createIntervalFromCreateSmaIndexStmt(SCreateIndexStmt* pStmt, SInterval*
|
|||
pInterval->interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i;
|
||||
pInterval->intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit;
|
||||
pInterval->offset = NULL != pStmt->pOptions->pOffset ? ((SValueNode*)pStmt->pOptions->pOffset)->datum.i : 0;
|
||||
pInterval->sliding = NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pInterval->interval;
|
||||
pInterval->slidingUnit = NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pInterval->intervalUnit;
|
||||
pInterval->sliding =
|
||||
NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pInterval->interval;
|
||||
pInterval->slidingUnit =
|
||||
NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pInterval->intervalUnit;
|
||||
pInterval->precision = pStmt->pOptions->tsPrecision;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, void ** pResRow) {
|
||||
int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SCreateIndexStmt* pStmt = (SCreateIndexStmt*)pQuery->pRoot;
|
||||
int64_t lastTs = 0;
|
||||
|
@ -6053,7 +6061,7 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
|
|||
toName(pCxt->pParseCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name);
|
||||
tNameGetFullDbName(&name, pReq->subDbName);
|
||||
tNameExtractFullName(&name, pReq->subStbName);
|
||||
if(pStmt->pQuery != NULL) {
|
||||
if (pStmt->pQuery != NULL) {
|
||||
code = nodesNodeToString(pStmt->pQuery, false, &pReq->ast, NULL);
|
||||
}
|
||||
} else if ('\0' != pStmt->subDbName[0]) {
|
||||
|
@ -6108,11 +6116,12 @@ static EDealRes checkColumnTagsInCond(SNode* pNode, void* pContext) {
|
|||
addTagList(&pCxt->pTags, nodesCloneNode(pNode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt* pStmt, STableMeta* pMeta, SNodeList** ppProjection) {
|
||||
static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt* pStmt, STableMeta* pMeta,
|
||||
SNodeList** ppProjection) {
|
||||
SBuildTopicContext colCxt = {.colExists = false, .colNotFound = false, .pMeta = pMeta, .pTags = NULL};
|
||||
nodesWalkExprPostOrder(pStmt->pWhere, checkColumnTagsInCond, &colCxt);
|
||||
if (colCxt.colNotFound) {
|
||||
|
@ -6122,18 +6131,18 @@ static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt*
|
|||
nodesDestroyList(colCxt.pTags);
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Columns are forbidden in where clause");
|
||||
}
|
||||
if (NULL == colCxt.pTags) { // put one column to select
|
||||
// for (int32_t i = 0; i < pMeta->tableInfo.numOfColumns; ++i) {
|
||||
SSchema* column = &pMeta->schema[0];
|
||||
SColumnNode* col = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == col) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(col->colName, column->name);
|
||||
strcpy(col->node.aliasName, col->colName);
|
||||
strcpy(col->node.userAlias, col->colName);
|
||||
addTagList(&colCxt.pTags, (SNode*)col);
|
||||
// }
|
||||
if (NULL == colCxt.pTags) { // put one column to select
|
||||
// for (int32_t i = 0; i < pMeta->tableInfo.numOfColumns; ++i) {
|
||||
SSchema* column = &pMeta->schema[0];
|
||||
SColumnNode* col = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == col) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(col->colName, column->name);
|
||||
strcpy(col->node.aliasName, col->colName);
|
||||
strcpy(col->node.userAlias, col->colName);
|
||||
addTagList(&colCxt.pTags, (SNode*)col);
|
||||
// }
|
||||
}
|
||||
|
||||
*ppProjection = colCxt.pTags;
|
||||
|
@ -6141,13 +6150,13 @@ static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt*
|
|||
}
|
||||
|
||||
static int32_t buildQueryForTableTopic(STranslateContext* pCxt, SCreateTopicStmt* pStmt, SNode** pSelect) {
|
||||
SParseContext* pParCxt = pCxt->pParseCxt;
|
||||
SRequestConnInfo connInfo = {.pTrans = pParCxt->pTransporter,
|
||||
.requestId = pParCxt->requestId,
|
||||
SParseContext* pParCxt = pCxt->pParseCxt;
|
||||
SRequestConnInfo connInfo = {.pTrans = pParCxt->pTransporter,
|
||||
.requestId = pParCxt->requestId,
|
||||
.requestObjRefId = pParCxt->requestRid,
|
||||
.mgmtEps = pParCxt->mgmtEpSet};
|
||||
SName name;
|
||||
STableMeta* pMeta = NULL;
|
||||
SName name;
|
||||
STableMeta* pMeta = NULL;
|
||||
int32_t code = getTableMetaImpl(pCxt, toName(pParCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name), &pMeta);
|
||||
if (code) {
|
||||
taosMemoryFree(pMeta);
|
||||
|
@ -6156,7 +6165,7 @@ static int32_t buildQueryForTableTopic(STranslateContext* pCxt, SCreateTopicStmt
|
|||
if (TSDB_SUPER_TABLE != pMeta->tableType) {
|
||||
taosMemoryFree(pMeta);
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Only supertable table can be used");
|
||||
}
|
||||
}
|
||||
|
||||
SNodeList* pProjection = NULL;
|
||||
code = checkCollectTopicTags(pCxt, pStmt, pMeta, &pProjection);
|
||||
|
@ -6554,7 +6563,8 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm
|
|||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||
"SUBTABLE expression must be of VARCHAR type");
|
||||
}
|
||||
if (NULL != pSelect->pSubtable && 0 == LIST_LENGTH(pSelect->pPartitionByList) && subtableExprHasColumnOrPseudoColumn(pSelect->pSubtable)) {
|
||||
if (NULL != pSelect->pSubtable && 0 == LIST_LENGTH(pSelect->pPartitionByList) &&
|
||||
subtableExprHasColumnOrPseudoColumn(pSelect->pSubtable)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||
"SUBTABLE expression must not has column when no partition by clause");
|
||||
}
|
||||
|
@ -6910,28 +6920,28 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
|
|||
if (NULL == col) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
strcpy(col->tableAlias, pTable);
|
||||
strcpy(col->colName, pMeta->schema[0].name);
|
||||
SNodeList* pParamterList = nodesMakeList();
|
||||
if (NULL == pParamterList) {
|
||||
nodesDestroyNode((SNode *)col);
|
||||
nodesDestroyNode((SNode*)col);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t code = nodesListStrictAppend(pParamterList, (SNode *)col);
|
||||
|
||||
int32_t code = nodesListStrictAppend(pParamterList, (SNode*)col);
|
||||
if (code) {
|
||||
nodesDestroyNode((SNode *)col);
|
||||
nodesDestroyNode((SNode*)col);
|
||||
nodesDestroyList(pParamterList);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
SNode* pFunc = (SNode*)createFunction("last", pParamterList);
|
||||
if (NULL == pFunc) {
|
||||
nodesDestroyList(pParamterList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
SNodeList* pProjectionList = nodesMakeList();
|
||||
if (NULL == pProjectionList) {
|
||||
nodesDestroyList(pParamterList);
|
||||
|
@ -6943,8 +6953,8 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
|
|||
nodesDestroyList(pProjectionList);
|
||||
return code;
|
||||
}
|
||||
|
||||
code = createSimpleSelectStmtFromProjList(pDb, pTable, pProjectionList, (SSelectStmt **)pQuery);
|
||||
|
||||
code = createSimpleSelectStmtFromProjList(pDb, pTable, pProjectionList, (SSelectStmt**)pQuery);
|
||||
if (code) {
|
||||
nodesDestroyList(pProjectionList);
|
||||
return code;
|
||||
|
@ -6982,14 +6992,14 @@ static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt
|
|||
if (TSDB_CODE_SUCCESS == code && pStmt->pOptions->fillHistory) {
|
||||
SRealTableNode* pTable = (SRealTableNode*)(((SSelectStmt*)pStmt->pQuery)->pFromTable);
|
||||
code = createLastTsSelectStmt(pTable->table.dbName, pTable->table.tableName, pTable->pMeta, &pStmt->pPrevQuery);
|
||||
/*
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STranslateContext cxt = {0};
|
||||
int32_t code = initTranslateContext(pCxt->pParseCxt, pCxt->pMetaCache, &cxt);
|
||||
code = translateQuery(&cxt, pStmt->pPrevQuery);
|
||||
destroyTranslateContext(&cxt);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STranslateContext cxt = {0};
|
||||
int32_t code = initTranslateContext(pCxt->pParseCxt, pCxt->pMetaCache, &cxt);
|
||||
code = translateQuery(&cxt, pStmt->pPrevQuery);
|
||||
destroyTranslateContext(&cxt);
|
||||
}
|
||||
*/
|
||||
}
|
||||
taosMemoryFree(pMeta);
|
||||
return code;
|
||||
|
@ -7084,7 +7094,7 @@ static int32_t buildIntervalForCreateStream(SCreateStreamStmt* pStmt, SInterval*
|
|||
if (NULL == pSelect->pWindow || QUERY_NODE_INTERVAL_WINDOW != nodeType(pSelect->pWindow)) {
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
SIntervalWindowNode* pWindow = (SIntervalWindowNode*)pSelect->pWindow;
|
||||
pInterval->interval = ((SValueNode*)pWindow->pInterval)->datum.i;
|
||||
pInterval->intervalUnit = ((SValueNode*)pWindow->pInterval)->unit;
|
||||
|
@ -7092,16 +7102,16 @@ static int32_t buildIntervalForCreateStream(SCreateStreamStmt* pStmt, SInterval*
|
|||
pInterval->sliding = (NULL != pWindow->pSliding ? ((SValueNode*)pWindow->pSliding)->datum.i : pInterval->interval);
|
||||
pInterval->slidingUnit =
|
||||
(NULL != pWindow->pSliding ? ((SValueNode*)pWindow->pSliding)->unit : pInterval->intervalUnit);
|
||||
pInterval->precision = ((SColumnNode*)pWindow->pCol)->node.resType.precision;
|
||||
pInterval->precision = ((SColumnNode*)pWindow->pCol)->node.resType.precision;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow) {
|
||||
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pQuery->pRoot;
|
||||
STranslateContext cxt = {0};
|
||||
SInterval interval = {0};
|
||||
int64_t lastTs = 0;
|
||||
STranslateContext cxt = {0};
|
||||
SInterval interval = {0};
|
||||
int64_t lastTs = 0;
|
||||
|
||||
int32_t code = initTranslateContext(pParseCxt, NULL, &cxt);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -7136,7 +7146,6 @@ int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void
|
|||
return code;
|
||||
}
|
||||
|
||||
|
||||
static int32_t translateDropStream(STranslateContext* pCxt, SDropStreamStmt* pStmt) {
|
||||
SMDropStreamReq dropReq = {0};
|
||||
SName name;
|
||||
|
@ -7261,7 +7270,7 @@ static int32_t translateGrantTagCond(STranslateContext* pCxt, SGrantStmt* pStmt,
|
|||
}
|
||||
}
|
||||
|
||||
int32_t code = createRealTableForGrantTable(pStmt, &pTable);
|
||||
int32_t code = createRealTableForGrantTable(pStmt, &pTable);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SName name;
|
||||
code = getTableMetaImpl(pCxt, toName(pCxt->pParseCxt->acctId, pTable->table.dbName, pTable->table.tableName, &name),
|
||||
|
@ -7821,7 +7830,8 @@ static SNodeList* createProjectCols(int32_t ncols, const char* const pCols[]) {
|
|||
return pProjections;
|
||||
}
|
||||
|
||||
static int32_t createSimpleSelectStmtImpl(const char* pDb, const char* pTable, SNodeList* pProjectionList, SSelectStmt** pStmt) {
|
||||
static int32_t createSimpleSelectStmtImpl(const char* pDb, const char* pTable, SNodeList* pProjectionList,
|
||||
SSelectStmt** pStmt) {
|
||||
SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
||||
if (NULL == pSelect) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -7844,9 +7854,8 @@ static int32_t createSimpleSelectStmtImpl(const char* pDb, const char* pTable, S
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int32_t createSimpleSelectStmtFromCols(const char* pDb, const char* pTable, int32_t numOfProjs,
|
||||
const char* const pProjCol[], SSelectStmt** pStmt) {
|
||||
const char* const pProjCol[], SSelectStmt** pStmt) {
|
||||
SNodeList* pProjectionList = NULL;
|
||||
if (numOfProjs >= 0) {
|
||||
pProjectionList = createProjectCols(numOfProjs, pProjCol);
|
||||
|
@ -7858,13 +7867,15 @@ static int32_t createSimpleSelectStmtFromCols(const char* pDb, const char* pTabl
|
|||
return createSimpleSelectStmtImpl(pDb, pTable, pProjectionList, pStmt);
|
||||
}
|
||||
|
||||
static int32_t createSimpleSelectStmtFromProjList(const char* pDb, const char* pTable, SNodeList* pProjectionList, SSelectStmt** pStmt) {
|
||||
static int32_t createSimpleSelectStmtFromProjList(const char* pDb, const char* pTable, SNodeList* pProjectionList,
|
||||
SSelectStmt** pStmt) {
|
||||
return createSimpleSelectStmtImpl(pDb, pTable, pProjectionList, pStmt);
|
||||
}
|
||||
|
||||
static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt) {
|
||||
const SSysTableShowAdapter* pShow = &sysTableShowAdapter[showType - SYSTABLE_SHOW_TYPE_OFFSET];
|
||||
return createSimpleSelectStmtFromCols(pShow->pDbName, pShow->pTableName, pShow->numOfShowCols, pShow->pShowCols, pStmt);
|
||||
return createSimpleSelectStmtFromCols(pShow->pDbName, pShow->pTableName, pShow->numOfShowCols, pShow->pShowCols,
|
||||
pStmt);
|
||||
}
|
||||
|
||||
static int32_t createSelectStmtForShowTableDist(SShowTableDistributedStmt* pStmt, SSelectStmt** pOutput) {
|
||||
|
@ -8002,8 +8013,8 @@ static int32_t createShowTableTagsProjections(SNodeList** pProjections, SNodeLis
|
|||
static int32_t rewriteShowStableTags(STranslateContext* pCxt, SQuery* pQuery) {
|
||||
SShowTableTagsStmt* pShow = (SShowTableTagsStmt*)pQuery->pRoot;
|
||||
SSelectStmt* pSelect = NULL;
|
||||
int32_t code = createSimpleSelectStmtFromCols(((SValueNode*)pShow->pDbName)->literal, ((SValueNode*)pShow->pTbName)->literal,
|
||||
-1, NULL, &pSelect);
|
||||
int32_t code = createSimpleSelectStmtFromCols(((SValueNode*)pShow->pDbName)->literal,
|
||||
((SValueNode*)pShow->pTbName)->literal, -1, NULL, &pSelect);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createShowTableTagsProjections(&pSelect->pProjectionList, &pShow->pTags);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue