Merge remote-tracking branch 'origin/develop' into feature/wal
This commit is contained in:
commit
0146c62784
|
@ -3,6 +3,7 @@ os: Visual Studio 2015
|
|||
environment:
|
||||
matrix:
|
||||
- ARCH: amd64
|
||||
- ARCH: x86
|
||||
|
||||
clone_folder: c:\dev\TDengine
|
||||
clone_depth: 1
|
||||
|
@ -23,6 +24,7 @@ notifications:
|
|||
- provider: Email
|
||||
to:
|
||||
- sangshuduo@gmail.com
|
||||
|
||||
on_build_success: true
|
||||
on_build_failure: true
|
||||
on_build_status_changed: true
|
||||
|
|
|
@ -22,16 +22,16 @@ extern "C" {
|
|||
|
||||
#include "tlog.h"
|
||||
|
||||
extern int32_t cDebugFlag;
|
||||
extern int32_t tscEmbedded;
|
||||
extern uint32_t cDebugFlag;
|
||||
extern uint32_t tscEmbedded;
|
||||
|
||||
#define tscFatal(...) { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }}
|
||||
#define tscError(...) { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }}
|
||||
#define tscWarn(...) { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }}
|
||||
#define tscInfo(...) { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }}
|
||||
#define tscDebug(...) { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); }}
|
||||
#define tscTrace(...) { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); }}
|
||||
#define tscDebugL(...){ if (cDebugFlag & DEBUG_DEBUG) { taosPrintLongString("TSC ", cDebugFlag, __VA_ARGS__); }}
|
||||
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define tscInfo(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define tscDebug(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define tscDebugL(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLongString("TSC ", cDebugFlag, __VA_ARGS__); }} while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ typedef struct {
|
|||
int32_t numOfTablesInSubmit;
|
||||
};
|
||||
|
||||
int32_t insertType;
|
||||
uint32_t insertType;
|
||||
int32_t clauseIndex; // index of multiple subclause query
|
||||
|
||||
char * curSql; // current sql, resume position of sql after parsing paused
|
||||
|
|
|
@ -381,6 +381,7 @@ void tscQueueAsyncError(void(*fp), void *param, int32_t code) {
|
|||
taosScheduleTask(tscQhandle, &schedMsg);
|
||||
}
|
||||
|
||||
|
||||
void tscQueueAsyncRes(SSqlObj *pSql) {
|
||||
if (pSql == NULL || pSql->signature != pSql) {
|
||||
tscDebug("%p SqlObj is freed, not add into queue async res", pSql);
|
||||
|
@ -390,7 +391,10 @@ void tscQueueAsyncRes(SSqlObj *pSql) {
|
|||
tscError("%p add into queued async res, code:%s", pSql, tstrerror(pSql->res.code));
|
||||
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
assert(pSql->fp != NULL && pSql->fetchFp != NULL);
|
||||
|
||||
if (pSql->fp == NULL || pSql->fetchFp == NULL){
|
||||
return;
|
||||
}
|
||||
|
||||
pSql->fp = pSql->fetchFp;
|
||||
(*pSql->fp)(pSql->param, pSql, pRes->code);
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
break; \
|
||||
} \
|
||||
GET_RES_INFO(ctx)->numOfRes = (res); \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define INC_INIT_VAL(ctx, res) (GET_RES_INFO(ctx)->numOfRes += (res));
|
||||
|
||||
|
@ -482,17 +482,16 @@ int32_t no_data_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId
|
|||
DO_UPDATE_TAG_COLUMNS(ctx, k); \
|
||||
(num) += 1; \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define DUPATE_DATA_WITHOUT_TS(ctx, left, right, num, sign) \
|
||||
do { \
|
||||
do { \
|
||||
if (((left) < (right)) ^ (sign)) { \
|
||||
(left) = (right); \
|
||||
DO_UPDATE_TAG_COLUMNS_WITHOUT_TS(ctx); \
|
||||
(num) += 1; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
} while (0)
|
||||
|
||||
#define LOOPCHECK_N(val, list, ctx, tsdbType, sign, num) \
|
||||
for (int32_t i = 0; i < ((ctx)->size); ++i) { \
|
||||
|
@ -709,15 +708,14 @@ static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY en
|
|||
return BLK_DATA_ALL_NEEDED;
|
||||
}
|
||||
|
||||
// the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->aOutputBuf is
|
||||
// the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid
|
||||
SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
|
||||
if (pInfo->hasResult != DATA_SET_FLAG) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
// TODO pCtx->aOutputBuf is the previous windowRes output buffer, not current unloaded block. so the following filter
|
||||
// is invalid
|
||||
// SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
|
||||
// if (pInfo->hasResult != DATA_SET_FLAG) {
|
||||
// return BLK_DATA_ALL_NEEDED;
|
||||
// } else { // data in current block is not earlier than current result
|
||||
// return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
||||
// }
|
||||
} else { // data in current block is not earlier than current result
|
||||
return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) {
|
||||
|
@ -730,16 +728,14 @@ static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end
|
|||
return BLK_DATA_ALL_NEEDED;
|
||||
}
|
||||
|
||||
// the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->aOutputBuf is
|
||||
// the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid
|
||||
SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
|
||||
if (pInfo->hasResult != DATA_SET_FLAG) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
// TODO pCtx->aOutputBuf is the previous windowRes output buffer, not current unloaded block. so the following filter
|
||||
// is invalid
|
||||
|
||||
// SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
|
||||
// if (pInfo->hasResult != DATA_SET_FLAG) {
|
||||
// return BLK_DATA_ALL_NEEDED;
|
||||
// } else {
|
||||
// return (pInfo->ts > end) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
||||
// }
|
||||
} else {
|
||||
return (pInfo->ts > end) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1909,7 +1905,7 @@ static void valuePairAssign(tValuePair *dst, int16_t type, const char *val, int6
|
|||
(dst)->timestamp = (src)->timestamp; \
|
||||
(dst)->v = (src)->v; \
|
||||
memcpy((dst)->pTags, (src)->pTags, (size_t)(__l)); \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData, int64_t ts, uint16_t type,
|
||||
SExtTagsInfo *pTagInfo, char *pTags, int16_t stage) {
|
||||
|
@ -2885,7 +2881,7 @@ static void leastsquares_function_f(SQLFunctionCtx *pCtx, int32_t index) {
|
|||
int32_t *p = pData;
|
||||
LEASTSQR_CAL(param, pInfo->startVal, p, 0, pCtx->param[1].dKey);
|
||||
break;
|
||||
};
|
||||
}
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
int8_t *p = pData;
|
||||
LEASTSQR_CAL(param, pInfo->startVal, p, 0, pCtx->param[1].dKey);
|
||||
|
|
|
@ -1292,7 +1292,6 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
|
|||
|
||||
pCmd->count = 0;
|
||||
pCmd->command = TSDB_SQL_INSERT;
|
||||
pSql->res.numOfRows = 0;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetailSafely(pCmd, pCmd->clauseIndex);
|
||||
|
||||
|
@ -1357,7 +1356,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
|
|||
ret = tscToSQLCmd(pSql, &SQLInfo);
|
||||
}
|
||||
|
||||
SQLInfoDestroy(&SQLInfo);
|
||||
SqlInfoDestroy(&SQLInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1523,7 +1522,7 @@ void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql) {
|
|||
pSql->res.code = TAOS_SYSTEM_ERROR(errno);
|
||||
tscError("%p failed to open file %s to load data from file, code:%s", pSql, pCmd->payload, tstrerror(pSql->res.code));
|
||||
|
||||
tfree(pSupporter)
|
||||
tfree(pSupporter);
|
||||
tscQueueAsyncRes(pSql);
|
||||
|
||||
return;
|
||||
|
|
|
@ -66,9 +66,9 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC
|
|||
|
||||
static int32_t setObjFullName(char* fullName, const char* account, SStrToken* pDB, SStrToken* tableName, int32_t* len);
|
||||
|
||||
static void getColumnName(tSQLExprItem* pItem, char* resultFieldName, int32_t nameLength);
|
||||
static void getColumnName(tSqlExprItem* pItem, char* resultFieldName, int32_t nameLength);
|
||||
|
||||
static int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExprItem* pItem, bool finalResult);
|
||||
static int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t colIndex, tSqlExprItem* pItem, bool finalResult);
|
||||
static int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnList* pIdList, int16_t bytes,
|
||||
int8_t type, char* fieldName, SSqlExpr* pSqlExpr);
|
||||
|
||||
|
@ -87,7 +87,7 @@ static int32_t parseIntervalClause(SSqlObj* pSql, SQueryInfo* pQueryInfo, SQuery
|
|||
static int32_t parseOffsetClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql);
|
||||
static int32_t parseSlidingClause(SSqlObj* pSql, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql);
|
||||
|
||||
static int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExprItem* pItem);
|
||||
static int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExprItem* pItem);
|
||||
|
||||
static int32_t parseWhereClause(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, SSqlObj* pSql);
|
||||
static int32_t parseFillClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL);
|
||||
|
@ -1279,7 +1279,7 @@ static void tscInsertPrimaryTSSourceColumn(SQueryInfo* pQueryInfo, SColumnIndex*
|
|||
tscColumnListInsert(pQueryInfo->colList, &tsCol);
|
||||
}
|
||||
|
||||
static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t exprIndex, tSQLExprItem* pItem) {
|
||||
static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t exprIndex, tSqlExprItem* pItem) {
|
||||
const char* msg1 = "invalid column name, illegal column type, or columns in arithmetic expression from two tables";
|
||||
const char* msg2 = "invalid arithmetic expression in select clause";
|
||||
const char* msg3 = "tag columns can not be used in arithmetic expression";
|
||||
|
@ -1420,7 +1420,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumnIndex* pIndex, tSQLExprItem* pItem) {
|
||||
static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumnIndex* pIndex, tSqlExprItem* pItem) {
|
||||
SSqlExpr* pExpr = doAddProjectCol(pQueryInfo, pIndex->columnIndex, pIndex->tableIndex);
|
||||
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pIndex->tableIndex);
|
||||
|
@ -1484,7 +1484,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
|
|||
|
||||
for (int32_t i = 0; i < pSelection->nExpr; ++i) {
|
||||
int32_t outputIndex = (int32_t)tscSqlExprNumOfExprs(pQueryInfo);
|
||||
tSQLExprItem* pItem = &pSelection->a[i];
|
||||
tSqlExprItem* pItem = &pSelection->a[i];
|
||||
|
||||
// project on all fields
|
||||
int32_t optr = pItem->pNode->nSQLOptr;
|
||||
|
@ -1643,7 +1643,7 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum
|
|||
return numOfTotalColumns;
|
||||
}
|
||||
|
||||
int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExprItem* pItem) {
|
||||
int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExprItem* pItem) {
|
||||
const char* msg0 = "invalid column name";
|
||||
const char* msg1 = "tag for normal table query is not allowed";
|
||||
|
||||
|
@ -1767,7 +1767,7 @@ static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void setResultColName(char* name, tSQLExprItem* pItem, int32_t functionId, SStrToken* pToken, bool multiCols) {
|
||||
void setResultColName(char* name, tSqlExprItem* pItem, int32_t functionId, SStrToken* pToken, bool multiCols) {
|
||||
if (pItem->aliasName != NULL) {
|
||||
tstrncpy(name, pItem->aliasName, TSDB_COL_NAME_LEN);
|
||||
} else if (multiCols) {
|
||||
|
@ -1790,7 +1790,7 @@ void setResultColName(char* name, tSQLExprItem* pItem, int32_t functionId, SStrT
|
|||
}
|
||||
}
|
||||
|
||||
int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExprItem* pItem, bool finalResult) {
|
||||
int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t colIndex, tSqlExprItem* pItem, bool finalResult) {
|
||||
STableMetaInfo* pTableMetaInfo = NULL;
|
||||
int32_t optr = pItem->pNode->nSQLOptr;
|
||||
|
||||
|
@ -1820,7 +1820,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
|
||||
if (pItem->pNode->pParam != NULL) {
|
||||
tSQLExprItem* pParamElem = &pItem->pNode->pParam->a[0];
|
||||
tSqlExprItem* pParamElem = &pItem->pNode->pParam->a[0];
|
||||
SStrToken* pToken = &pParamElem->pNode->colInfo;
|
||||
int16_t sqlOptr = pParamElem->pNode->nSQLOptr;
|
||||
if ((pToken->z == NULL || pToken->n == 0)
|
||||
|
@ -1921,7 +1921,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
}
|
||||
|
||||
tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[0]);
|
||||
tSqlExprItem* pParamElem = &(pItem->pNode->pParam->a[0]);
|
||||
if (pParamElem->pNode->nSQLOptr != TK_ALL && pParamElem->pNode->nSQLOptr != TK_ID) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
}
|
||||
|
@ -2040,7 +2040,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
|
||||
/* in first/last function, multiple columns can be add to resultset */
|
||||
for (int32_t i = 0; i < pItem->pNode->pParam->nExpr; ++i) {
|
||||
tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[i]);
|
||||
tSqlExprItem* pParamElem = &(pItem->pNode->pParam->a[i]);
|
||||
if (pParamElem->pNode->nSQLOptr != TK_ALL && pParamElem->pNode->nSQLOptr != TK_ID) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
|
@ -2153,7 +2153,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
}
|
||||
|
||||
tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[0]);
|
||||
tSqlExprItem* pParamElem = &(pItem->pNode->pParam->a[0]);
|
||||
if (pParamElem->pNode->nSQLOptr != TK_ID) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
}
|
||||
|
@ -2353,7 +2353,7 @@ static SColumnList getColumnList(int32_t num, int16_t tableIndex, int32_t column
|
|||
return columnList;
|
||||
}
|
||||
|
||||
void getColumnName(tSQLExprItem* pItem, char* resultFieldName, int32_t nameLength) {
|
||||
void getColumnName(tSqlExprItem* pItem, char* resultFieldName, int32_t nameLength) {
|
||||
if (pItem->aliasName != NULL) {
|
||||
strncpy(resultFieldName, pItem->aliasName, nameLength);
|
||||
} else {
|
||||
|
@ -3520,7 +3520,7 @@ static int32_t validateSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryInfo* pQuer
|
|||
|
||||
int32_t outputIndex = (int32_t)tscSqlExprNumOfExprs(pQueryInfo);
|
||||
|
||||
tSQLExprItem item = {.pNode = pExpr, .aliasName = NULL};
|
||||
tSqlExprItem item = {.pNode = pExpr, .aliasName = NULL};
|
||||
|
||||
// sql function list in selection clause.
|
||||
// Append the sqlExpr into exprList of pQueryInfo structure sequentially
|
||||
|
@ -3737,7 +3737,7 @@ static int32_t setExprToCond(tSQLExpr** parent, tSQLExpr* pExpr, const char* msg
|
|||
return invalidSqlErrMsg(msgBuf, msg);
|
||||
}
|
||||
|
||||
*parent = tSQLExprCreate((*parent), pExpr, parentOptr);
|
||||
*parent = tSqlExprCreate((*parent), pExpr, parentOptr);
|
||||
} else {
|
||||
*parent = pExpr;
|
||||
}
|
||||
|
@ -3785,7 +3785,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQL
|
|||
* to release expression, e.g., m1.ts = m2.ts,
|
||||
* since this expression is used to set the join query type
|
||||
*/
|
||||
tSQLExprDestroy(*pExpr);
|
||||
tSqlExprDestroy(*pExpr);
|
||||
} else {
|
||||
ret = setExprToCond(&pCondExpr->pTimewindow, *pExpr, msg3, parentOptr, pQueryInfo->msg);
|
||||
}
|
||||
|
@ -3931,17 +3931,17 @@ static void doCompactQueryExpr(tSQLExpr** pExpr) {
|
|||
|
||||
if ((*pExpr)->pLeft == NULL && (*pExpr)->pRight == NULL &&
|
||||
((*pExpr)->nSQLOptr == TK_OR || (*pExpr)->nSQLOptr == TK_AND)) {
|
||||
tSQLExprNodeDestroy(*pExpr);
|
||||
tSqlExprNodeDestroy(*pExpr);
|
||||
*pExpr = NULL;
|
||||
|
||||
} else if ((*pExpr)->pLeft == NULL && (*pExpr)->pRight != NULL) {
|
||||
tSQLExpr* tmpPtr = (*pExpr)->pRight;
|
||||
tSQLExprNodeDestroy(*pExpr);
|
||||
tSqlExprNodeDestroy(*pExpr);
|
||||
|
||||
(*pExpr) = tmpPtr;
|
||||
} else if ((*pExpr)->pRight == NULL && (*pExpr)->pLeft != NULL) {
|
||||
tSQLExpr* tmpPtr = (*pExpr)->pLeft;
|
||||
tSQLExprNodeDestroy(*pExpr);
|
||||
tSqlExprNodeDestroy(*pExpr);
|
||||
|
||||
(*pExpr) = tmpPtr;
|
||||
}
|
||||
|
@ -3964,7 +3964,7 @@ static void doExtractExprForSTable(SSqlCmd* pCmd, tSQLExpr** pExpr, SQueryInfo*
|
|||
(*pExpr) = NULL;
|
||||
|
||||
} else {
|
||||
*pOut = tSQLExprCreate(NULL, NULL, (*pExpr)->nSQLOptr);
|
||||
*pOut = tSqlExprCreate(NULL, NULL, (*pExpr)->nSQLOptr);
|
||||
|
||||
doExtractExprForSTable(pCmd, &(*pExpr)->pLeft, pQueryInfo, &((*pOut)->pLeft), tableIndex);
|
||||
doExtractExprForSTable(pCmd, &(*pExpr)->pRight, pQueryInfo, &((*pOut)->pRight), tableIndex);
|
||||
|
@ -4171,23 +4171,23 @@ static int32_t validateJoinExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondExpr
|
|||
|
||||
static void cleanQueryExpr(SCondExpr* pCondExpr) {
|
||||
if (pCondExpr->pTableCond) {
|
||||
tSQLExprDestroy(pCondExpr->pTableCond);
|
||||
tSqlExprDestroy(pCondExpr->pTableCond);
|
||||
}
|
||||
|
||||
if (pCondExpr->pTagCond) {
|
||||
tSQLExprDestroy(pCondExpr->pTagCond);
|
||||
tSqlExprDestroy(pCondExpr->pTagCond);
|
||||
}
|
||||
|
||||
if (pCondExpr->pColumnCond) {
|
||||
tSQLExprDestroy(pCondExpr->pColumnCond);
|
||||
tSqlExprDestroy(pCondExpr->pColumnCond);
|
||||
}
|
||||
|
||||
if (pCondExpr->pTimewindow) {
|
||||
tSQLExprDestroy(pCondExpr->pTimewindow);
|
||||
tSqlExprDestroy(pCondExpr->pTimewindow);
|
||||
}
|
||||
|
||||
if (pCondExpr->pJoinExpr) {
|
||||
tSQLExprDestroy(pCondExpr->pJoinExpr);
|
||||
tSqlExprDestroy(pCondExpr->pJoinExpr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4256,7 +4256,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
|
|||
tsSetSTableQueryCond(&pQueryInfo->tagCond, uid, &bw);
|
||||
doCompactQueryExpr(pExpr);
|
||||
|
||||
tSQLExprDestroy(p1);
|
||||
tSqlExprDestroy(p1);
|
||||
tExprTreeDestroy(&p, NULL);
|
||||
|
||||
taosArrayDestroy(colList);
|
||||
|
@ -6369,14 +6369,13 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
|
|||
assert(pQuerySql != NULL && (pQuerySql->from == NULL || taosArrayGetSize(pQuerySql->from) > 0));
|
||||
|
||||
const char* msg0 = "invalid table name";
|
||||
const char* msg2 = "point interpolation query needs timestamp";
|
||||
const char* msg5 = "fill only available for interval query";
|
||||
const char* msg6 = "start(end) time of query range required or time range too large";
|
||||
const char* msg7 = "illegal number of tables in from clause";
|
||||
const char* msg8 = "too many columns in selection clause";
|
||||
const char* msg9 = "TWA query requires both the start and end time";
|
||||
const char* msg10 = "too many tables in from clause";
|
||||
const char* msg11 = "invalid table alias name";
|
||||
const char* msg1 = "point interpolation query needs timestamp";
|
||||
const char* msg2 = "fill only available for interval query";
|
||||
const char* msg3 = "start(end) time of query range required or time range too large";
|
||||
const char* msg4 = "illegal number of tables in from clause";
|
||||
const char* msg5 = "too many columns in selection clause";
|
||||
const char* msg6 = "too many tables in from clause";
|
||||
const char* msg7 = "invalid table alias name";
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
|
@ -6392,7 +6391,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
|
|||
|
||||
// too many result columns not support order by in query
|
||||
if (pQuerySql->pSelection->nExpr > TSDB_MAX_COLUMNS) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg5);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -6410,13 +6409,13 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
|
|||
|
||||
size_t fromSize = taosArrayGetSize(pQuerySql->from);
|
||||
if (fromSize > TSDB_MAX_JOIN_TABLE_NUM * 2) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4);
|
||||
}
|
||||
|
||||
pQueryInfo->command = TSDB_SQL_SELECT;
|
||||
|
||||
if (fromSize > 4) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg10);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
|
||||
}
|
||||
|
||||
// set all query tables, which are maybe more than one.
|
||||
|
@ -6449,12 +6448,12 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
|
|||
|
||||
tVariantListItem* p1 = taosArrayGet(pQuerySql->from, i + 1);
|
||||
if (p1->pVar.nType != TSDB_DATA_TYPE_BINARY) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg11);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7);
|
||||
}
|
||||
|
||||
SStrToken aliasName = {.z = p1->pVar.pz, .n = p1->pVar.nLen, .type = TK_STRING};
|
||||
if (tscValidateName(&aliasName) != TSDB_CODE_SUCCESS) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg11);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7);
|
||||
}
|
||||
|
||||
// has no table alias name
|
||||
|
@ -6532,12 +6531,6 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
|
|||
}
|
||||
}
|
||||
|
||||
// user does not specified the query time window, twa is not allowed in such case.
|
||||
if ((pQueryInfo->window.skey == INT64_MIN || pQueryInfo->window.ekey == INT64_MAX ||
|
||||
(pQueryInfo->window.ekey == INT64_MAX / 1000 && tinfo.precision == TSDB_TIME_PRECISION_MILLI)) && tscIsTWAQuery(pQueryInfo)) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg9);
|
||||
}
|
||||
|
||||
// no result due to invalid query time range
|
||||
if (pQueryInfo->window.skey > pQueryInfo->window.ekey) {
|
||||
pQueryInfo->command = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
|
||||
|
@ -6545,7 +6538,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
|
|||
}
|
||||
|
||||
if (!hasTimestampForPointInterpQuery(pQueryInfo)) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
}
|
||||
|
||||
// in case of join query, time range is required.
|
||||
|
@ -6553,7 +6546,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
|
|||
int64_t timeRange = ABS(pQueryInfo->window.skey - pQueryInfo->window.ekey);
|
||||
|
||||
if (timeRange == 0 && pQueryInfo->window.skey == 0) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6573,19 +6566,19 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
|
|||
*/
|
||||
if (pQuerySql->fillType != NULL) {
|
||||
if (pQueryInfo->interval.interval == 0 && (!tscIsPointInterpQuery(pQueryInfo))) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg5);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
}
|
||||
|
||||
if (pQueryInfo->interval.interval > 0) {
|
||||
bool initialWindows = TSWINDOW_IS_EQUAL(pQueryInfo->window, TSWINDOW_INITIALIZER);
|
||||
if (initialWindows) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
|
||||
int64_t timeRange = ABS(pQueryInfo->window.skey - pQueryInfo->window.ekey);
|
||||
// number of result is not greater than 10,000,000
|
||||
if ((timeRange == 0) || (timeRange / pQueryInfo->interval.interval) > MAX_INTERVAL_TIME_WINDOW) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1267,14 +1267,14 @@ int32_t tscBuildKillMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// TODO update it
|
||||
int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||
SSqlCmd *pCmd = &(pSql->cmd);
|
||||
int32_t size = minMsgSize() + sizeof(SCMCreateTableMsg) + sizeof(SCreatedTableInfo);
|
||||
int32_t size = minMsgSize() + sizeof(SCMCreateTableMsg) + sizeof(SCreateTableMsg);
|
||||
|
||||
SCreateTableSQL *pCreateTableInfo = pInfo->pCreateTableInfo;
|
||||
if (pCreateTableInfo->type == TSQL_CREATE_TABLE_FROM_STABLE) {
|
||||
size += sizeof(STagData);
|
||||
int32_t numOfTables = (int32_t)taosArrayGetSize(pInfo->pCreateTableInfo->childTableInfo);
|
||||
size += numOfTables * (sizeof(SCreateTableMsg) + TSDB_MAX_TAGS_LEN);
|
||||
} else {
|
||||
size += sizeof(SSchema) * (pCmd->numOfCols + pCmd->count);
|
||||
}
|
||||
|
|
|
@ -384,7 +384,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
|||
}
|
||||
|
||||
SQueryInfo *pSubQueryInfo = tscGetQueryInfoDetail(&pPrevSub->cmd, 0);
|
||||
STSBuf *pTSBuf = pSubQueryInfo->tsBuf;
|
||||
STSBuf *pTsBuf = pSubQueryInfo->tsBuf;
|
||||
pSubQueryInfo->tsBuf = NULL;
|
||||
|
||||
// free result for async object will also free sqlObj
|
||||
|
@ -402,7 +402,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
|||
pSql->pSubs[i] = pNew;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pNew->cmd, 0);
|
||||
pQueryInfo->tsBuf = pTSBuf; // transfer the ownership of timestamp comp-z data to the new created object
|
||||
pQueryInfo->tsBuf = pTsBuf; // transfer the ownership of timestamp comp-z data to the new created object
|
||||
|
||||
// set the second stage sub query for join process
|
||||
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE);
|
||||
|
@ -1648,7 +1648,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
|||
|
||||
pRes->qhandle = 0x1; // hack the qhandle check
|
||||
|
||||
const uint32_t nBufferSize = (1u << 16); // 64KB
|
||||
const uint32_t nBufferSize = (1u << 16u); // 64KB
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
@ -2151,7 +2151,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
|||
|
||||
static bool needRetryInsert(SSqlObj* pParentObj, int32_t numOfSub) {
|
||||
if (pParentObj->retry > pParentObj->maxRetry) {
|
||||
tscError("%p max retry reached, abort the retry effort", pParentObj)
|
||||
tscError("%p max retry reached, abort the retry effort", pParentObj);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2501,12 +2501,12 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
|
|||
tscRestoreSQLFuncForSTableQuery(pQueryInfo);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
assert (pRes->row >= pRes->numOfRows);
|
||||
|
||||
doBuildResFromSubqueries(pSql);
|
||||
tsem_post(&pSql->rspSem);
|
||||
return;
|
||||
if (pRes->code == TSDB_CODE_SUCCESS) {
|
||||
(*pSql->fp)(pSql->param, pSql, pRes->numOfRows);
|
||||
} else {
|
||||
tscQueueAsyncRes(pSql);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ extern int32_t tsEnableStream;
|
|||
|
||||
// internal
|
||||
extern int32_t tsPrintAuth;
|
||||
extern int32_t tscEmbedded;
|
||||
extern uint32_t tscEmbedded;
|
||||
extern char configDir[];
|
||||
extern char tsVnodeDir[];
|
||||
extern char tsDnodeDir[];
|
||||
|
@ -177,7 +177,7 @@ extern int32_t tsLogKeepDays;
|
|||
extern int32_t dDebugFlag;
|
||||
extern int32_t vDebugFlag;
|
||||
extern int32_t mDebugFlag;
|
||||
extern int32_t cDebugFlag;
|
||||
extern uint32_t cDebugFlag;
|
||||
extern int32_t jniDebugFlag;
|
||||
extern int32_t tmrDebugFlag;
|
||||
extern int32_t sdbDebugFlag;
|
||||
|
@ -187,7 +187,7 @@ extern int32_t monDebugFlag;
|
|||
extern int32_t uDebugFlag;
|
||||
extern int32_t rpcDebugFlag;
|
||||
extern int32_t odbcDebugFlag;
|
||||
extern int32_t qDebugFlag;
|
||||
extern uint32_t qDebugFlag;
|
||||
extern int32_t wDebugFlag;
|
||||
extern int32_t cqDebugFlag;
|
||||
extern int32_t debugFlag;
|
||||
|
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
#include "tlog.h"
|
||||
|
||||
extern int32_t uDebugFlag;
|
||||
extern int32_t tscEmbedded;
|
||||
extern uint32_t tscEmbedded;
|
||||
|
||||
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "tutil.h"
|
||||
#include "tlocale.h"
|
||||
#include "ttimezone.h"
|
||||
#include "tsync.h"
|
||||
|
||||
// cluster
|
||||
char tsFirst[TSDB_EP_LEN] = {0};
|
||||
|
@ -172,7 +171,7 @@ int32_t tsEnableStream = 1;
|
|||
|
||||
// internal
|
||||
int32_t tsPrintAuth = 0;
|
||||
int32_t tscEmbedded = 0;
|
||||
uint32_t tscEmbedded = 0;
|
||||
char configDir[TSDB_FILENAME_LEN] = {0};
|
||||
char tsVnodeDir[TSDB_FILENAME_LEN] = {0};
|
||||
char tsDnodeDir[TSDB_FILENAME_LEN] = {0};
|
||||
|
@ -210,13 +209,13 @@ int32_t mDebugFlag = 131;
|
|||
int32_t sdbDebugFlag = 131;
|
||||
int32_t dDebugFlag = 135;
|
||||
int32_t vDebugFlag = 135;
|
||||
int32_t cDebugFlag = 131;
|
||||
uint32_t cDebugFlag = 131;
|
||||
int32_t jniDebugFlag = 131;
|
||||
int32_t odbcDebugFlag = 131;
|
||||
int32_t httpDebugFlag = 131;
|
||||
int32_t mqttDebugFlag = 131;
|
||||
int32_t monDebugFlag = 131;
|
||||
int32_t qDebugFlag = 131;
|
||||
uint32_t qDebugFlag = 131;
|
||||
int32_t rpcDebugFlag = 131;
|
||||
int32_t uDebugFlag = 131;
|
||||
int32_t debugFlag = 0;
|
||||
|
|
|
@ -86,6 +86,6 @@ extern void set_terminal_mode();
|
|||
extern int get_old_terminal_mode(struct termios* tio);
|
||||
extern void reset_terminal_mode();
|
||||
extern SShellArguments args;
|
||||
extern TAOS_RES* result;
|
||||
extern int64_t result;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,7 +46,7 @@ char CONTINUE_PROMPT[] = " -> ";
|
|||
int prompt_size = 6;
|
||||
#endif
|
||||
|
||||
TAOS_RES *result = NULL;
|
||||
int64_t result = 0;
|
||||
SShellHistory history;
|
||||
|
||||
#define DEFAULT_MAX_BINARY_DISPLAY_WIDTH 30
|
||||
|
@ -260,6 +260,14 @@ int32_t shellRunCommand(TAOS* con, char* command) {
|
|||
}
|
||||
|
||||
|
||||
void freeResultWithRid(int64_t rid) {
|
||||
SSqlObj* pSql = taosAcquireRef(tscObjRef, rid);
|
||||
if(pSql){
|
||||
taos_free_result(pSql);
|
||||
taosReleaseRef(tscObjRef, rid);
|
||||
}
|
||||
}
|
||||
|
||||
void shellRunCommandOnServer(TAOS *con, char command[]) {
|
||||
int64_t st, et;
|
||||
wordexp_t full_path;
|
||||
|
@ -294,18 +302,22 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
|
|||
|
||||
st = taosGetTimestampUs();
|
||||
|
||||
TAOS_RES* pSql = taos_query_h(con, command, &result);
|
||||
TAOS_RES* tmpSql = NULL;
|
||||
TAOS_RES* pSql = taos_query_h(con, command, &tmpSql);
|
||||
if (taos_errno(pSql)) {
|
||||
taos_error(pSql, st);
|
||||
return;
|
||||
}
|
||||
|
||||
atomic_store_64(&result, ((SSqlObj*)tmpSql)->self);
|
||||
int64_t oresult = atomic_load_64(&result);
|
||||
|
||||
if (regex_match(command, "^\\s*use\\s+[a-zA-Z0-9_]+\\s*;\\s*$", REG_EXTENDED | REG_ICASE)) {
|
||||
fprintf(stdout, "Database changed.\n\n");
|
||||
fflush(stdout);
|
||||
|
||||
atomic_store_ptr(&result, 0);
|
||||
taos_free_result(pSql);
|
||||
atomic_store_64(&result, 0);
|
||||
freeResultWithRid(oresult);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -313,8 +325,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
|
|||
int error_no = 0;
|
||||
int numOfRows = shellDumpResult(pSql, fname, &error_no, printMode);
|
||||
if (numOfRows < 0) {
|
||||
atomic_store_ptr(&result, 0);
|
||||
taos_free_result(pSql);
|
||||
atomic_store_64(&result, 0);
|
||||
freeResultWithRid(oresult);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -336,8 +348,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
|
|||
wordfree(&full_path);
|
||||
}
|
||||
|
||||
atomic_store_ptr(&result, 0);
|
||||
taos_free_result(pSql);
|
||||
atomic_store_64(&result, 0);
|
||||
freeResultWithRid(oresult);
|
||||
}
|
||||
|
||||
/* Function to do regular expression check */
|
||||
|
@ -501,7 +513,7 @@ static int dumpResultToFile(const char* fname, TAOS_RES* tres) {
|
|||
row = taos_fetch_row(tres);
|
||||
} while( row != NULL);
|
||||
|
||||
result = NULL;
|
||||
result = 0;
|
||||
fclose(fp);
|
||||
|
||||
return numOfRows;
|
||||
|
|
|
@ -19,15 +19,31 @@
|
|||
#include "tnettest.h"
|
||||
|
||||
pthread_t pid;
|
||||
static tsem_t cancelSem;
|
||||
|
||||
void shellQueryInterruptHandler(int signum) {
|
||||
tsem_post(&cancelSem);
|
||||
}
|
||||
|
||||
void *cancelHandler(void *arg) {
|
||||
while(1) {
|
||||
if (tsem_wait(&cancelSem) != 0) {
|
||||
taosMsleep(10);
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef LINUX
|
||||
void* pResHandle = atomic_val_compare_exchange_64(&result, result, 0);
|
||||
taos_stop_query(pResHandle);
|
||||
int64_t rid = atomic_val_compare_exchange_64(&result, result, 0);
|
||||
SSqlObj* pSql = taosAcquireRef(tscObjRef, rid);
|
||||
taos_stop_query(pSql);
|
||||
taosReleaseRef(tscObjRef, rid);
|
||||
#else
|
||||
printf("\nReceive ctrl+c or other signal, quit shell.\n");
|
||||
exit(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int checkVersion() {
|
||||
|
@ -105,6 +121,14 @@ int main(int argc, char* argv[]) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (tsem_init(&cancelSem, 0, 0) != 0) {
|
||||
printf("failed to create cancel semphore\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
pthread_t spid;
|
||||
pthread_create(&spid, NULL, cancelHandler, NULL);
|
||||
|
||||
/* Interrupt handler. */
|
||||
struct sigaction act;
|
||||
memset(&act, 0, sizeof(struct sigaction));
|
||||
|
|
|
@ -52,7 +52,7 @@ void taosTMemset(void *ptr, int c);
|
|||
free((void *)(x)); \
|
||||
x = 0; \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#ifdef TAOS_MEM_CHECK
|
||||
#ifdef TAOS_MEM_CHECK_TEST
|
||||
|
|
|
@ -185,7 +185,7 @@ typedef struct SQueryRuntimeEnv {
|
|||
uint16_t scanFlag; // denotes reversed scan of data or not
|
||||
SFillInfo* pFillInfo;
|
||||
SResultRowInfo windowResInfo;
|
||||
STSBuf* pTSBuf;
|
||||
STSBuf* pTsBuf;
|
||||
STSCursor cur;
|
||||
SQueryCostInfo summary;
|
||||
void* pQueryHandle;
|
||||
|
|
|
@ -202,16 +202,16 @@ typedef struct tSQLExpr {
|
|||
} tSQLExpr;
|
||||
|
||||
// used in select clause. select <tSQLExprList> from xxx
|
||||
typedef struct tSQLExprItem {
|
||||
typedef struct tSqlExprItem {
|
||||
tSQLExpr *pNode; // The list of expressions
|
||||
char * aliasName; // alias name, null-terminated string
|
||||
} tSQLExprItem;
|
||||
} tSqlExprItem;
|
||||
|
||||
// todo refactor by using SArray
|
||||
typedef struct tSQLExprList {
|
||||
int32_t nExpr; /* Number of expressions on the list */
|
||||
int32_t nAlloc; /* Number of entries allocated below */
|
||||
tSQLExprItem *a; /* One entry for each expression */
|
||||
tSqlExprItem *a; /* One entry for each expression */
|
||||
} tSQLExprList;
|
||||
|
||||
/**
|
||||
|
@ -233,63 +233,63 @@ SArray *tVariantListAppend(SArray *pList, tVariant *pVar, uint8_t sortOrder);
|
|||
SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int32_t index);
|
||||
SArray *tVariantListAppendToken(SArray *pList, SStrToken *pAliasToken, uint8_t sortOrder);
|
||||
|
||||
tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optType);
|
||||
tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType);
|
||||
|
||||
void tSQLExprDestroy(tSQLExpr *);
|
||||
void tSqlExprDestroy(tSQLExpr *pExpr);
|
||||
|
||||
tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken *pToken);
|
||||
tSQLExprList *tSqlExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken *pToken);
|
||||
|
||||
void tSQLExprListDestroy(tSQLExprList *pList);
|
||||
void tSqlExprListDestroy(tSQLExprList *pList);
|
||||
|
||||
SQuerySQL *tSetQuerySQLElems(SStrToken *pSelectToken, tSQLExprList *pSelection, SArray *pFrom, tSQLExpr *pWhere,
|
||||
SQuerySQL *tSetQuerySqlElems(SStrToken *pSelectToken, tSQLExprList *pSelection, SArray *pFrom, tSQLExpr *pWhere,
|
||||
SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval,
|
||||
SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit, SLimitVal *pGLimit);
|
||||
|
||||
SCreateTableSQL *tSetCreateSQLElems(SArray *pCols, SArray *pTags, SQuerySQL *pSelect, int32_t type);
|
||||
SCreateTableSQL *tSetCreateSqlElems(SArray *pCols, SArray *pTags, SQuerySQL *pSelect, int32_t type);
|
||||
|
||||
void tSQLExprNodeDestroy(tSQLExpr *pExpr);
|
||||
void tSqlExprNodeDestroy(tSQLExpr *pExpr);
|
||||
|
||||
SAlterTableSQL *tAlterTableSQLElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type);
|
||||
SAlterTableSQL * tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type);
|
||||
SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagVals, SStrToken *pToken, SStrToken* igExists);
|
||||
|
||||
void destroyAllSelectClause(SSubclauseInfo *pSql);
|
||||
void doDestroyQuerySql(SQuerySQL *pSql);
|
||||
void freeCreateTableInfo(void* p);
|
||||
|
||||
SSqlInfo *setSQLInfo(SSqlInfo *pInfo, void *pSqlExprInfo, SStrToken *pTableName, int32_t type);
|
||||
SSqlInfo * setSqlInfo(SSqlInfo *pInfo, void *pSqlExprInfo, SStrToken *pTableName, int32_t type);
|
||||
SSubclauseInfo *setSubclause(SSubclauseInfo *pClause, void *pSqlExprInfo);
|
||||
|
||||
SSubclauseInfo *appendSelectClause(SSubclauseInfo *pInfo, void *pSubclause);
|
||||
|
||||
void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken *pIfNotExists);
|
||||
|
||||
void SQLInfoDestroy(SSqlInfo *pInfo);
|
||||
void SqlInfoDestroy(SSqlInfo *pInfo);
|
||||
|
||||
void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParams, ...);
|
||||
void setDropDBTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck);
|
||||
void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck);
|
||||
void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* pPatterns);
|
||||
|
||||
tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SStrToken *pToken);
|
||||
|
||||
void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDBInfo *pDB, SStrToken *pIgExists);
|
||||
|
||||
void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctSQL *pAcctInfo);
|
||||
void setCreateUserSQL(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd);
|
||||
void setKillSQL(SSqlInfo *pInfo, int32_t type, SStrToken *ip);
|
||||
void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege);
|
||||
void setCreateAcctSql(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctSQL *pAcctInfo);
|
||||
void setCreateUserSql(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd);
|
||||
void setKillSql(SSqlInfo *pInfo, int32_t type, SStrToken *ip);
|
||||
void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege);
|
||||
|
||||
void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo);
|
||||
|
||||
// prefix show db.tables;
|
||||
void setDBName(SStrToken *pCpxName, SStrToken *pDB);
|
||||
void setDbName(SStrToken *pCpxName, SStrToken *pDb);
|
||||
|
||||
tSQLExpr *tSQLExprIdValueCreate(SStrToken *pToken, int32_t optType);
|
||||
tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType);
|
||||
|
||||
tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType);
|
||||
tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType);
|
||||
|
||||
void tSQLSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType);
|
||||
void tSqlSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType);
|
||||
|
||||
void tSQLSetColumnType(TAOS_FIELD *pField, SStrToken *pToken);
|
||||
void tSqlSetColumnType(TAOS_FIELD *pField, SStrToken *type);
|
||||
|
||||
void *ParseAlloc(void *(*mallocProc)(size_t));
|
||||
|
||||
|
|
|
@ -22,15 +22,15 @@ extern "C" {
|
|||
|
||||
#include "tlog.h"
|
||||
|
||||
extern int32_t qDebugFlag;
|
||||
extern int32_t tscEmbedded;
|
||||
extern uint32_t qDebugFlag;
|
||||
extern uint32_t tscEmbedded;
|
||||
|
||||
#define qFatal(...) { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", 255, __VA_ARGS__); }}
|
||||
#define qError(...) { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("QRY ERROR ", 255, __VA_ARGS__); }}
|
||||
#define qWarn(...) { if (qDebugFlag & DEBUG_WARN) { taosPrintLog("QRY WARN ", 255, __VA_ARGS__); }}
|
||||
#define qInfo(...) { if (qDebugFlag & DEBUG_INFO) { taosPrintLog("QRY ", 255, __VA_ARGS__); }}
|
||||
#define qDebug(...) { if (qDebugFlag & DEBUG_DEBUG) { taosPrintLog("QRY ", qDebugFlag, __VA_ARGS__); }}
|
||||
#define qTrace(...) { if (qDebugFlag & DEBUG_TRACE) { taosPrintLog("QRY ", qDebugFlag, __VA_ARGS__); }}
|
||||
#define qFatal(...) do { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", 255, __VA_ARGS__); }} while(0)
|
||||
#define qError(...) do { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("QRY ERROR ", 255, __VA_ARGS__); }} while(0)
|
||||
#define qWarn(...) do { if (qDebugFlag & DEBUG_WARN) { taosPrintLog("QRY WARN ", 255, __VA_ARGS__); }} while(0)
|
||||
#define qInfo(...) do { if (qDebugFlag & DEBUG_INFO) { taosPrintLog("QRY ", 255, __VA_ARGS__); }} while(0)
|
||||
#define qDebug(...) do { if (qDebugFlag & DEBUG_DEBUG) { taosPrintLog("QRY ", qDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define qTrace(...) do { if (qDebugFlag & DEBUG_TRACE) { taosPrintLog("QRY ", qDebugFlag, __VA_ARGS__); }} while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ cmd ::= CREATE TABLE create_table_args. {}
|
|||
cmd ::= CREATE TABLE create_table_list(Z). { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = Z;}
|
||||
|
||||
%type create_table_list{SCreateTableSQL*}
|
||||
%destructor create_table_list{destroyCreateTableSQL($$);}
|
||||
%destructor create_table_list{destroyCreateTableSql($$);}
|
||||
create_table_list(A) ::= create_from_stable(Z). {
|
||||
SCreateTableSQL* pCreateTable = calloc(1, sizeof(SCreateTableSQL));
|
||||
pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo));
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
* check if the primary column is load by default, otherwise, the program will
|
||||
* forced to load primary column explicitly.
|
||||
*/
|
||||
#define Q_STATUS_EQUAL(p, s) (((p) & (s)) != 0)
|
||||
#define Q_STATUS_EQUAL(p, s) (((p) & (s)) != 0u)
|
||||
#define QUERY_IS_ASC_QUERY(q) (GET_FORWARD_DIRECTION_FACTOR((q)->order.order) == QUERY_ASC_FORWARD_STEP)
|
||||
|
||||
#define IS_MASTER_SCAN(runtime) ((runtime)->scanFlag == MASTER_SCAN)
|
||||
|
@ -624,9 +624,7 @@ static int32_t setWindowOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRow
|
|||
SResultRow *pResultRow = doPrepareResultRowFromKey(pRuntimeEnv, pResultRowInfo, (char *)&win->skey, TSDB_KEYSIZE, masterscan, uid);
|
||||
if (pResultRow == NULL) {
|
||||
*newWind = false;
|
||||
|
||||
// no master scan, no result generated means error occurs
|
||||
return masterscan? -1:0;
|
||||
return masterscan? -1:0; // no master scan, no result generated means error occurs
|
||||
}
|
||||
|
||||
*newWind = true;
|
||||
|
@ -1420,7 +1418,7 @@ static char *getGroupbyColumnData(SQuery *pQuery, int16_t *type, int16_t *bytes,
|
|||
static int32_t doTSJoinFilter(SQueryRuntimeEnv *pRuntimeEnv, int32_t offset) {
|
||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||
|
||||
STSElem elem = tsBufGetElem(pRuntimeEnv->pTSBuf);
|
||||
STSElem elem = tsBufGetElem(pRuntimeEnv->pTsBuf);
|
||||
SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx;
|
||||
|
||||
// compare tag first
|
||||
|
@ -1432,8 +1430,8 @@ static int32_t doTSJoinFilter(SQueryRuntimeEnv *pRuntimeEnv, int32_t offset) {
|
|||
|
||||
#if defined(_DEBUG_VIEW)
|
||||
printf("elem in comp ts file:%" PRId64 ", key:%" PRId64 ", tag:%"PRIu64", query order:%d, ts order:%d, traverse:%d, index:%d\n",
|
||||
elem.ts, key, elem.tag.i64Key, pQuery->order.order, pRuntimeEnv->pTSBuf->tsOrder,
|
||||
pRuntimeEnv->pTSBuf->cur.order, pRuntimeEnv->pTSBuf->cur.tsIndex);
|
||||
elem.ts, key, elem.tag.i64Key, pQuery->order.order, pRuntimeEnv->pTsBuf->tsOrder,
|
||||
pRuntimeEnv->pTsBuf->cur.order, pRuntimeEnv->pTsBuf->cur.tsIndex);
|
||||
#endif
|
||||
|
||||
if (QUERY_IS_ASC_QUERY(pQuery)) {
|
||||
|
@ -1603,9 +1601,9 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
|
|||
|
||||
// from top to bottom in desc
|
||||
// from bottom to top in asc order
|
||||
if (pRuntimeEnv->pTSBuf != NULL) {
|
||||
if (pRuntimeEnv->pTsBuf != NULL) {
|
||||
qDebug("QInfo:%p process data rows, numOfRows:%d, query order:%d, ts comp order:%d", pQInfo, pDataBlockInfo->rows,
|
||||
pQuery->order.order, pRuntimeEnv->pTSBuf->cur.order);
|
||||
pQuery->order.order, pRuntimeEnv->pTsBuf->cur.order);
|
||||
}
|
||||
|
||||
int32_t offset = -1;
|
||||
|
@ -1615,7 +1613,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
|
|||
for (int32_t j = 0; j < pDataBlockInfo->rows; ++j) {
|
||||
offset = GET_COL_DATA_POS(pQuery, j, step);
|
||||
|
||||
if (pRuntimeEnv->pTSBuf != NULL) {
|
||||
if (pRuntimeEnv->pTsBuf != NULL) {
|
||||
int32_t ret = doTSJoinFilter(pRuntimeEnv, offset);
|
||||
if (ret == TS_JOIN_TAG_NOT_EQUALS) {
|
||||
break;
|
||||
|
@ -1729,9 +1727,9 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
|
|||
prevTs = tsCols[offset];
|
||||
prevRowIndex = offset;
|
||||
|
||||
if (pRuntimeEnv->pTSBuf != NULL) {
|
||||
if (pRuntimeEnv->pTsBuf != NULL) {
|
||||
// if timestamp filter list is empty, quit current query
|
||||
if (!tsBufNextPos(pRuntimeEnv->pTSBuf)) {
|
||||
if (!tsBufNextPos(pRuntimeEnv->pTsBuf)) {
|
||||
setQueryStatus(pQuery, QUERY_COMPLETED);
|
||||
break;
|
||||
}
|
||||
|
@ -1745,8 +1743,8 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
|
|||
item->lastKey = (QUERY_IS_ASC_QUERY(pQuery)? pDataBlockInfo->window.ekey:pDataBlockInfo->window.skey) + step;
|
||||
}
|
||||
|
||||
if (pRuntimeEnv->pTSBuf != NULL) {
|
||||
item->cur = tsBufGetCursor(pRuntimeEnv->pTSBuf);
|
||||
if (pRuntimeEnv->pTsBuf != NULL) {
|
||||
item->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf);
|
||||
}
|
||||
|
||||
// todo refactor: extract method
|
||||
|
@ -1768,7 +1766,7 @@ static int32_t tableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBl
|
|||
STableQueryInfo* pTableQInfo = pQuery->current;
|
||||
SResultRowInfo* pWindowResInfo = &pRuntimeEnv->windowResInfo;
|
||||
|
||||
if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL || pRuntimeEnv->groupbyNormalCol) {
|
||||
if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTsBuf != NULL || pRuntimeEnv->groupbyNormalCol) {
|
||||
rowwiseApplyFunctions(pRuntimeEnv, pStatis, pDataBlockInfo, pWindowResInfo, pDataBlock);
|
||||
} else {
|
||||
blockwiseApplyFunctions(pRuntimeEnv, pStatis, pDataBlockInfo, pWindowResInfo, searchFn, pDataBlock);
|
||||
|
@ -2109,7 +2107,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
|
|||
destroyResultBuf(pRuntimeEnv->pResultBuf);
|
||||
doFreeQueryHandle(pQInfo);
|
||||
|
||||
pRuntimeEnv->pTSBuf = tsBufDestroy(pRuntimeEnv->pTSBuf);
|
||||
pRuntimeEnv->pTsBuf = tsBufDestroy(pRuntimeEnv->pTsBuf);
|
||||
|
||||
tfree(pRuntimeEnv->offset);
|
||||
tfree(pRuntimeEnv->keyBuf);
|
||||
|
@ -2617,11 +2615,12 @@ static bool overlapWithTimeWindow(SQuery* pQuery, SDataBlockInfo* pBlockInfo) {
|
|||
}
|
||||
|
||||
int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo * pWindowResInfo, void* pQueryHandle, SDataBlockInfo* pBlockInfo, SDataStatis **pStatis, SArray** pDataBlock, uint32_t* status) {
|
||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||
|
||||
*status = BLK_DATA_NO_NEEDED;
|
||||
|
||||
if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf > 0) {
|
||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||
SQueryCostInfo* pCost = &pRuntimeEnv->summary;
|
||||
|
||||
if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTsBuf > 0) {
|
||||
*status = BLK_DATA_ALL_NEEDED;
|
||||
} else { // check if this data block is required to load
|
||||
|
||||
|
@ -2641,7 +2640,6 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo * pW
|
|||
bool masterScan = IS_MASTER_SCAN(pRuntimeEnv);
|
||||
|
||||
TSKEY k = QUERY_IS_ASC_QUERY(pQuery)? pBlockInfo->window.skey:pBlockInfo->window.ekey;
|
||||
|
||||
STimeWindow win = getActiveTimeWindow(pWindowResInfo, k, pQuery);
|
||||
if (setWindowOutputBufByKey(pRuntimeEnv, pWindowResInfo, pBlockInfo, &win, masterScan, &hasTimeWindow, &pResult) !=
|
||||
TSDB_CODE_SUCCESS) {
|
||||
|
@ -2665,35 +2663,34 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo * pW
|
|||
if ((*status) == BLK_DATA_NO_NEEDED) {
|
||||
qDebug("QInfo:%p data block discard, brange:%"PRId64 "-%"PRId64", rows:%d", GET_QINFO_ADDR(pRuntimeEnv),
|
||||
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||
pRuntimeEnv->summary.discardBlocks += 1;
|
||||
pCost->discardBlocks += 1;
|
||||
} else if ((*status) == BLK_DATA_STATIS_NEEDED) {
|
||||
|
||||
// this function never returns error?
|
||||
tsdbRetrieveDataBlockStatisInfo(pQueryHandle, pStatis);
|
||||
|
||||
pRuntimeEnv->summary.loadBlockStatis += 1;
|
||||
pCost->loadBlockStatis += 1;
|
||||
|
||||
if (*pStatis == NULL) { // data block statistics does not exist, load data block
|
||||
*pDataBlock = tsdbRetrieveDataBlock(pQueryHandle, NULL);
|
||||
pRuntimeEnv->summary.totalCheckedRows += pBlockInfo->rows;
|
||||
pCost->totalCheckedRows += pBlockInfo->rows;
|
||||
}
|
||||
} else {
|
||||
assert((*status) == BLK_DATA_ALL_NEEDED);
|
||||
|
||||
// load the data block statistics to perform further filter
|
||||
pRuntimeEnv->summary.loadBlockStatis += 1;
|
||||
pCost->loadBlockStatis += 1;
|
||||
tsdbRetrieveDataBlockStatisInfo(pQueryHandle, pStatis);
|
||||
|
||||
if (!needToLoadDataBlock(pRuntimeEnv, *pStatis, pRuntimeEnv->pCtx, pBlockInfo->rows)) {
|
||||
// current block has been discard due to filter applied
|
||||
pRuntimeEnv->summary.discardBlocks += 1;
|
||||
pCost->discardBlocks += 1;
|
||||
qDebug("QInfo:%p data block discard, brange:%"PRId64 "-%"PRId64", rows:%d", GET_QINFO_ADDR(pRuntimeEnv),
|
||||
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||
(*status) = BLK_DATA_DISCARD;
|
||||
}
|
||||
|
||||
pRuntimeEnv->summary.totalCheckedRows += pBlockInfo->rows;
|
||||
pRuntimeEnv->summary.loadBlocks += 1;
|
||||
pCost->totalCheckedRows += pBlockInfo->rows;
|
||||
pCost->loadBlocks += 1;
|
||||
*pDataBlock = tsdbRetrieveDataBlock(pQueryHandle, NULL);
|
||||
if (*pDataBlock == NULL) {
|
||||
return terrno;
|
||||
|
@ -2751,7 +2748,7 @@ int32_t binarySearchForKey(char *pValue, int num, TSKEY key, int order) {
|
|||
}
|
||||
|
||||
numOfRows = lastPos - firstPos + 1;
|
||||
midPos = (numOfRows >> 1) + firstPos;
|
||||
midPos = (numOfRows >> 1u) + firstPos;
|
||||
|
||||
if (key < keyList[midPos]) {
|
||||
lastPos = midPos - 1;
|
||||
|
@ -3009,7 +3006,7 @@ void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, void *pTable, void *tsdb) {
|
|||
|
||||
// set the join tag for first column
|
||||
SSqlFuncMsg *pFuncMsg = &pExprInfo->base;
|
||||
if ((pFuncMsg->functionId == TSDB_FUNC_TS || pFuncMsg->functionId == TSDB_FUNC_PRJ) && pRuntimeEnv->pTSBuf != NULL &&
|
||||
if ((pFuncMsg->functionId == TSDB_FUNC_TS || pFuncMsg->functionId == TSDB_FUNC_PRJ) && pRuntimeEnv->pTsBuf != NULL &&
|
||||
pFuncMsg->colInfo.colIndex == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||
assert(pFuncMsg->numOfParams == 1);
|
||||
|
||||
|
@ -3901,10 +3898,10 @@ static void setEnvBeforeReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatusI
|
|||
SQInfo *pQInfo = GET_QINFO_ADDR(pRuntimeEnv);
|
||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||
|
||||
pStatus->cur = tsBufGetCursor(pRuntimeEnv->pTSBuf); // save the cursor
|
||||
if (pRuntimeEnv->pTSBuf) {
|
||||
SWITCH_ORDER(pRuntimeEnv->pTSBuf->cur.order);
|
||||
bool ret = tsBufNextPos(pRuntimeEnv->pTSBuf);
|
||||
pStatus->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf); // save the cursor
|
||||
if (pRuntimeEnv->pTsBuf) {
|
||||
SWITCH_ORDER(pRuntimeEnv->pTsBuf->cur.order);
|
||||
bool ret = tsBufNextPos(pRuntimeEnv->pTsBuf);
|
||||
assert(ret);
|
||||
}
|
||||
|
||||
|
@ -3946,9 +3943,9 @@ static void clearEnvAfterReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatus
|
|||
SWITCH_ORDER(pQuery->order.order);
|
||||
switchCtxOrder(pRuntimeEnv);
|
||||
|
||||
tsBufSetCursor(pRuntimeEnv->pTSBuf, &pStatus->cur);
|
||||
if (pRuntimeEnv->pTSBuf) {
|
||||
pRuntimeEnv->pTSBuf->cur.order = pQuery->order.order;
|
||||
tsBufSetCursor(pRuntimeEnv->pTsBuf, &pStatus->cur);
|
||||
if (pRuntimeEnv->pTsBuf) {
|
||||
pRuntimeEnv->pTsBuf->cur.order = pQuery->order.order;
|
||||
}
|
||||
|
||||
SET_MASTER_SCAN_FLAG(pRuntimeEnv);
|
||||
|
@ -4137,7 +4134,7 @@ void setExecutionContext(SQInfo *pQInfo, int32_t groupIndex, TSKEY nextKey) {
|
|||
// lastKey needs to be updated
|
||||
pTableQueryInfo->lastKey = nextKey;
|
||||
|
||||
if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTSBuf != NULL) {
|
||||
if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTsBuf != NULL) {
|
||||
setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo);
|
||||
}
|
||||
|
||||
|
@ -4226,13 +4223,13 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, void* pTable, STableQueryInfo *pTableQ
|
|||
setTagVal(pRuntimeEnv, pTable, pQInfo->tsdb);
|
||||
|
||||
// both the master and supplement scan needs to set the correct ts comp start position
|
||||
if (pRuntimeEnv->pTSBuf != NULL) {
|
||||
if (pRuntimeEnv->pTsBuf != NULL) {
|
||||
tVariant* pTag = &pRuntimeEnv->pCtx[0].tag;
|
||||
|
||||
if (pTableQueryInfo->cur.vgroupIndex == -1) {
|
||||
tVariantAssign(&pTableQueryInfo->tag, pTag);
|
||||
|
||||
STSElem elem = tsBufGetElemStartPos(pRuntimeEnv->pTSBuf, pQInfo->vgId, &pTableQueryInfo->tag);
|
||||
STSElem elem = tsBufGetElemStartPos(pRuntimeEnv->pTsBuf, pQInfo->vgId, &pTableQueryInfo->tag);
|
||||
|
||||
// failed to find data with the specified tag value and vnodeId
|
||||
if (!tsBufIsValidElem(&elem)) {
|
||||
|
@ -4246,7 +4243,7 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, void* pTable, STableQueryInfo *pTableQ
|
|||
}
|
||||
|
||||
// keep the cursor info of current meter
|
||||
pTableQueryInfo->cur = tsBufGetCursor(pRuntimeEnv->pTSBuf);
|
||||
pTableQueryInfo->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf);
|
||||
if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex);
|
||||
} else {
|
||||
|
@ -4254,7 +4251,7 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, void* pTable, STableQueryInfo *pTableQ
|
|||
}
|
||||
|
||||
} else {
|
||||
tsBufSetCursor(pRuntimeEnv->pTSBuf, &pTableQueryInfo->cur);
|
||||
tsBufSetCursor(pRuntimeEnv->pTsBuf, &pTableQueryInfo->cur);
|
||||
|
||||
if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex);
|
||||
|
@ -4463,7 +4460,7 @@ static void stableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBloc
|
|||
SResultRowInfo * pWindowResInfo = &pTableQueryInfo->windowResInfo;
|
||||
pQuery->pos = QUERY_IS_ASC_QUERY(pQuery)? 0 : pDataBlockInfo->rows - 1;
|
||||
|
||||
if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL || pRuntimeEnv->groupbyNormalCol) {
|
||||
if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTsBuf != NULL || pRuntimeEnv->groupbyNormalCol) {
|
||||
rowwiseApplyFunctions(pRuntimeEnv, pStatis, pDataBlockInfo, pWindowResInfo, pDataBlock);
|
||||
} else {
|
||||
blockwiseApplyFunctions(pRuntimeEnv, pStatis, pDataBlockInfo, pWindowResInfo, searchFn, pDataBlock);
|
||||
|
@ -4789,7 +4786,7 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) {
|
|||
assert(*start <= pQuery->current->lastKey);
|
||||
|
||||
// if queried with value filter, do NOT forward query start position
|
||||
if (pQuery->limit.offset <= 0 || pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL || pRuntimeEnv->pFillInfo != NULL) {
|
||||
if (pQuery->limit.offset <= 0 || pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTsBuf != NULL || pRuntimeEnv->pFillInfo != NULL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4994,15 +4991,15 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
|
|||
pQInfo->vgId = vgId;
|
||||
|
||||
pRuntimeEnv->pQuery = pQuery;
|
||||
pRuntimeEnv->pTSBuf = pTsBuf;
|
||||
pRuntimeEnv->pTsBuf = pTsBuf;
|
||||
pRuntimeEnv->cur.vgroupIndex = -1;
|
||||
pRuntimeEnv->stableQuery = isSTableQuery;
|
||||
pRuntimeEnv->prevGroupId = INT32_MIN;
|
||||
pRuntimeEnv->groupbyNormalCol = isGroupbyNormalCol(pQuery->pGroupbyExpr);
|
||||
|
||||
if (pTsBuf != NULL) {
|
||||
int16_t order = (pQuery->order.order == pRuntimeEnv->pTSBuf->tsOrder) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||
tsBufSetTraverseOrder(pRuntimeEnv->pTSBuf, order);
|
||||
int16_t order = (pQuery->order.order == pRuntimeEnv->pTsBuf->tsOrder) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||
tsBufSetTraverseOrder(pRuntimeEnv->pTsBuf, order);
|
||||
}
|
||||
|
||||
int32_t ps = DEFAULT_PAGE_SIZE;
|
||||
|
@ -5096,7 +5093,7 @@ static FORCE_INLINE void setEnvForEachBlock(SQInfo* pQInfo, STableQueryInfo* pTa
|
|||
TSKEY nextKey = pBlockInfo->window.skey;
|
||||
setIntervalQueryRange(pQInfo, nextKey);
|
||||
|
||||
if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTSBuf != NULL) {
|
||||
if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTsBuf != NULL) {
|
||||
setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo);
|
||||
}
|
||||
}
|
||||
|
@ -5189,7 +5186,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
|
|||
SArray *group = GET_TABLEGROUP(pQInfo, 0);
|
||||
STableQueryInfo* pCheckInfo = taosArrayGetP(group, index);
|
||||
|
||||
if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTSBuf != NULL) {
|
||||
if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTsBuf != NULL) {
|
||||
setTagVal(pRuntimeEnv, pCheckInfo->pTable, pQInfo->tsdb);
|
||||
}
|
||||
|
||||
|
@ -5227,11 +5224,11 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
|
|||
longjmp(pRuntimeEnv->env, terrno);
|
||||
}
|
||||
|
||||
if (pRuntimeEnv->pTSBuf != NULL) {
|
||||
if (pRuntimeEnv->pTsBuf != NULL) {
|
||||
tVariant* pTag = &pRuntimeEnv->pCtx[0].tag;
|
||||
|
||||
if (pRuntimeEnv->cur.vgroupIndex == -1) {
|
||||
STSElem elem = tsBufGetElemStartPos(pRuntimeEnv->pTSBuf, pQInfo->vgId, pTag);
|
||||
STSElem elem = tsBufGetElemStartPos(pRuntimeEnv->pTsBuf, pQInfo->vgId, pTag);
|
||||
// failed to find data with the specified tag value and vnodeId
|
||||
if (!tsBufIsValidElem(&elem)) {
|
||||
if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
|
@ -5242,7 +5239,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
|
|||
|
||||
return false;
|
||||
} else {
|
||||
STSCursor cur = tsBufGetCursor(pRuntimeEnv->pTSBuf);
|
||||
STSCursor cur = tsBufGetCursor(pRuntimeEnv->pTsBuf);
|
||||
|
||||
if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz,
|
||||
|
@ -5253,10 +5250,10 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
STSElem elem = tsBufGetElem(pRuntimeEnv->pTSBuf);
|
||||
STSElem elem = tsBufGetElem(pRuntimeEnv->pTsBuf);
|
||||
if (tVariantCompare(elem.tag, &pRuntimeEnv->pCtx[0].tag) != 0) {
|
||||
|
||||
STSElem elem1 = tsBufGetElemStartPos(pRuntimeEnv->pTSBuf, pQInfo->vgId, pTag);
|
||||
STSElem elem1 = tsBufGetElemStartPos(pRuntimeEnv->pTsBuf, pQInfo->vgId, pTag);
|
||||
// failed to find data with the specified tag value and vnodeId
|
||||
if (!tsBufIsValidElem(&elem1)) {
|
||||
if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
|
@ -5267,7 +5264,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
|
|||
|
||||
return false;
|
||||
} else {
|
||||
STSCursor cur = tsBufGetCursor(pRuntimeEnv->pTSBuf);
|
||||
STSCursor cur = tsBufGetCursor(pRuntimeEnv->pTsBuf);
|
||||
if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, cur.blockIndex, cur.tsIndex);
|
||||
} else {
|
||||
|
@ -5276,8 +5273,8 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
|
|||
}
|
||||
|
||||
} else {
|
||||
tsBufSetCursor(pRuntimeEnv->pTSBuf, &pRuntimeEnv->cur);
|
||||
STSCursor cur = tsBufGetCursor(pRuntimeEnv->pTSBuf);
|
||||
tsBufSetCursor(pRuntimeEnv->pTsBuf, &pRuntimeEnv->cur);
|
||||
STSCursor cur = tsBufGetCursor(pRuntimeEnv->pTsBuf);
|
||||
if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
qDebug("QInfo:%p continue scan ts_comp file, tag:%s blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, cur.blockIndex, cur.tsIndex);
|
||||
} else {
|
||||
|
@ -5475,7 +5472,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
|
|||
clearClosedResultRows(pRuntimeEnv, &pRuntimeEnv->windowResInfo);
|
||||
break;
|
||||
}
|
||||
} else if (pRuntimeEnv->queryWindowIdentical && pRuntimeEnv->pTSBuf == NULL && !isTSCompQuery(pQuery)) {
|
||||
} else if (pRuntimeEnv->queryWindowIdentical && pRuntimeEnv->pTsBuf == NULL && !isTSCompQuery(pQuery)) {
|
||||
//super table projection query with identical query time range for all tables.
|
||||
SDataBlockInfo blockInfo = SDATA_BLOCK_INITIALIZER;
|
||||
resetDefaultResInfoOutputBuf(pRuntimeEnv);
|
||||
|
@ -5686,8 +5683,8 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
|
|||
break;
|
||||
}
|
||||
|
||||
if (pRuntimeEnv->pTSBuf != NULL) {
|
||||
pRuntimeEnv->cur = pRuntimeEnv->pTSBuf->cur;
|
||||
if (pRuntimeEnv->pTsBuf != NULL) {
|
||||
pRuntimeEnv->cur = pRuntimeEnv->pTsBuf->cur;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -5722,8 +5719,8 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
|
|||
finalizeQueryResult(pRuntimeEnv);
|
||||
}
|
||||
|
||||
if (pRuntimeEnv->pTSBuf != NULL) {
|
||||
pRuntimeEnv->cur = pRuntimeEnv->pTSBuf->cur;
|
||||
if (pRuntimeEnv->pTsBuf != NULL) {
|
||||
pRuntimeEnv->cur = pRuntimeEnv->pTsBuf->cur;
|
||||
}
|
||||
|
||||
qDebug("QInfo %p numOfTables:%" PRIu64 ", index:%d, numOfGroups:%" PRIzu ", %" PRId64
|
||||
|
@ -5741,8 +5738,8 @@ static void doSaveContext(SQInfo *pQInfo) {
|
|||
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
|
||||
SWITCH_ORDER(pQuery->order.order);
|
||||
|
||||
if (pRuntimeEnv->pTSBuf != NULL) {
|
||||
SWITCH_ORDER(pRuntimeEnv->pTSBuf->cur.order);
|
||||
if (pRuntimeEnv->pTsBuf != NULL) {
|
||||
SWITCH_ORDER(pRuntimeEnv->pTsBuf->cur.order);
|
||||
}
|
||||
|
||||
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
|
||||
|
@ -5770,8 +5767,8 @@ static void doRestoreContext(SQInfo *pQInfo) {
|
|||
|
||||
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
|
||||
|
||||
if (pRuntimeEnv->pTSBuf != NULL) {
|
||||
SWITCH_ORDER(pRuntimeEnv->pTSBuf->cur.order);
|
||||
if (pRuntimeEnv->pTsBuf != NULL) {
|
||||
SWITCH_ORDER(pRuntimeEnv->pTsBuf->cur.order);
|
||||
}
|
||||
|
||||
switchCtxOrder(pRuntimeEnv);
|
||||
|
@ -6038,7 +6035,7 @@ static void tableIntervalProcessImpl(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start)
|
|||
|
||||
// here we can ignore the records in case of no interpolation
|
||||
// todo handle offset, in case of top/bottom interval query
|
||||
if ((pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL) && pQuery->limit.offset > 0 &&
|
||||
if ((pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTsBuf != NULL) && pQuery->limit.offset > 0 &&
|
||||
pQuery->fillType == TSDB_FILL_NONE) {
|
||||
// maxOutput <= 0, means current query does not generate any results
|
||||
int32_t numOfClosed = numOfClosedResultRows(&pRuntimeEnv->windowResInfo);
|
||||
|
|
|
@ -71,13 +71,13 @@ abort_parse:
|
|||
return sqlInfo;
|
||||
}
|
||||
|
||||
tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken *pToken) {
|
||||
tSQLExprList *tSqlExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken *pToken) {
|
||||
if (pList == NULL) {
|
||||
pList = calloc(1, sizeof(tSQLExprList));
|
||||
}
|
||||
|
||||
if (pList->nAlloc <= pList->nExpr) {
|
||||
pList->nAlloc = (pList->nAlloc << 1) + 4;
|
||||
pList->nAlloc = (pList->nAlloc << 1u) + 4;
|
||||
pList->a = realloc(pList->a, pList->nAlloc * sizeof(pList->a[0]));
|
||||
if (pList->a == 0) {
|
||||
pList->nExpr = pList->nAlloc = 0;
|
||||
|
@ -87,7 +87,7 @@ tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken
|
|||
assert(pList->a != 0);
|
||||
|
||||
if (pNode || pToken) {
|
||||
struct tSQLExprItem *pItem = &pList->a[pList->nExpr++];
|
||||
struct tSqlExprItem *pItem = &pList->a[pList->nExpr++];
|
||||
memset(pItem, 0, sizeof(*pItem));
|
||||
pItem->pNode = pNode;
|
||||
if (pToken) { // set the as clause
|
||||
|
@ -101,62 +101,62 @@ tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken
|
|||
return pList;
|
||||
}
|
||||
|
||||
void tSQLExprListDestroy(tSQLExprList *pList) {
|
||||
void tSqlExprListDestroy(tSQLExprList *pList) {
|
||||
if (pList == NULL) return;
|
||||
|
||||
for (int32_t i = 0; i < pList->nExpr; ++i) {
|
||||
if (pList->a[i].aliasName != NULL) {
|
||||
free(pList->a[i].aliasName);
|
||||
}
|
||||
tSQLExprDestroy(pList->a[i].pNode);
|
||||
tSqlExprDestroy(pList->a[i].pNode);
|
||||
}
|
||||
|
||||
free(pList->a);
|
||||
free(pList);
|
||||
}
|
||||
|
||||
tSQLExpr *tSQLExprIdValueCreate(SStrToken *pToken, int32_t optrType) {
|
||||
tSQLExpr *pSQLExpr = calloc(1, sizeof(tSQLExpr));
|
||||
tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType) {
|
||||
tSQLExpr *pSqlExpr = calloc(1, sizeof(tSQLExpr));
|
||||
|
||||
if (pToken != NULL) {
|
||||
pSQLExpr->token = *pToken;
|
||||
pSqlExpr->token = *pToken;
|
||||
}
|
||||
|
||||
if (optrType == TK_INTEGER || optrType == TK_STRING || optrType == TK_FLOAT || optrType == TK_BOOL) {
|
||||
toTSDBType(pToken->type);
|
||||
|
||||
tVariantCreate(&pSQLExpr->val, pToken);
|
||||
pSQLExpr->nSQLOptr = optrType;
|
||||
tVariantCreate(&pSqlExpr->val, pToken);
|
||||
pSqlExpr->nSQLOptr = optrType;
|
||||
} else if (optrType == TK_NOW) {
|
||||
// use microsecond by default
|
||||
pSQLExpr->val.i64Key = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO);
|
||||
pSQLExpr->val.nType = TSDB_DATA_TYPE_BIGINT;
|
||||
pSQLExpr->nSQLOptr = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond
|
||||
pSqlExpr->val.i64Key = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO);
|
||||
pSqlExpr->val.nType = TSDB_DATA_TYPE_BIGINT;
|
||||
pSqlExpr->nSQLOptr = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond
|
||||
} else if (optrType == TK_VARIABLE) {
|
||||
int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSQLExpr->val.i64Key);
|
||||
int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->val.i64Key);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
pSQLExpr->val.nType = TSDB_DATA_TYPE_BIGINT;
|
||||
pSQLExpr->nSQLOptr = TK_TIMESTAMP;
|
||||
pSqlExpr->val.nType = TSDB_DATA_TYPE_BIGINT;
|
||||
pSqlExpr->nSQLOptr = TK_TIMESTAMP;
|
||||
} else { // it must be the column name (tk_id) if it is not the number
|
||||
assert(optrType == TK_ID || optrType == TK_ALL);
|
||||
if (pToken != NULL) {
|
||||
pSQLExpr->colInfo = *pToken;
|
||||
pSqlExpr->colInfo = *pToken;
|
||||
}
|
||||
|
||||
pSQLExpr->nSQLOptr = optrType;
|
||||
pSqlExpr->nSQLOptr = optrType;
|
||||
}
|
||||
|
||||
return pSQLExpr;
|
||||
return pSqlExpr;
|
||||
}
|
||||
|
||||
/*
|
||||
* pList is the parameters for function with id(optType)
|
||||
* function name is denoted by pFunctionToken
|
||||
*/
|
||||
tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType) {
|
||||
tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType) {
|
||||
if (pFuncToken == NULL) return NULL;
|
||||
|
||||
tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr));
|
||||
|
@ -177,7 +177,7 @@ tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SSt
|
|||
* create binary expression in this procedure
|
||||
* if the expr is arithmetic, calculate the result and set it to tSQLExpr Object
|
||||
*/
|
||||
tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
|
||||
tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
|
||||
tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr));
|
||||
|
||||
if (pLeft != NULL && pRight != NULL && (optrType != TK_IN)) {
|
||||
|
@ -223,8 +223,8 @@ tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
|
|||
}
|
||||
}
|
||||
|
||||
tSQLExprDestroy(pLeft);
|
||||
tSQLExprDestroy(pRight);
|
||||
tSqlExprDestroy(pLeft);
|
||||
tSqlExprDestroy(pRight);
|
||||
|
||||
} else if ((pLeft->nSQLOptr == TK_FLOAT && pRight->nSQLOptr == TK_INTEGER) || (pLeft->nSQLOptr == TK_INTEGER && pRight->nSQLOptr == TK_FLOAT) ||
|
||||
(pLeft->nSQLOptr == TK_FLOAT && pRight->nSQLOptr == TK_FLOAT)) {
|
||||
|
@ -257,8 +257,8 @@ tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
|
|||
}
|
||||
}
|
||||
|
||||
tSQLExprDestroy(pLeft);
|
||||
tSQLExprDestroy(pRight);
|
||||
tSqlExprDestroy(pLeft);
|
||||
tSqlExprDestroy(pRight);
|
||||
|
||||
} else {
|
||||
pExpr->nSQLOptr = optrType;
|
||||
|
@ -288,7 +288,7 @@ tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
|
|||
return pExpr;
|
||||
}
|
||||
|
||||
void tSQLExprNodeDestroy(tSQLExpr *pExpr) {
|
||||
void tSqlExprNodeDestroy(tSQLExpr *pExpr) {
|
||||
if (pExpr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -297,20 +297,20 @@ void tSQLExprNodeDestroy(tSQLExpr *pExpr) {
|
|||
tVariantDestroy(&pExpr->val);
|
||||
}
|
||||
|
||||
tSQLExprListDestroy(pExpr->pParam);
|
||||
tSqlExprListDestroy(pExpr->pParam);
|
||||
|
||||
free(pExpr);
|
||||
}
|
||||
|
||||
void tSQLExprDestroy(tSQLExpr *pExpr) {
|
||||
void tSqlExprDestroy(tSQLExpr *pExpr) {
|
||||
if (pExpr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
tSQLExprDestroy(pExpr->pLeft);
|
||||
tSQLExprDestroy(pExpr->pRight);
|
||||
tSqlExprDestroy(pExpr->pLeft);
|
||||
tSqlExprDestroy(pExpr->pRight);
|
||||
|
||||
tSQLExprNodeDestroy(pExpr);
|
||||
tSqlExprNodeDestroy(pExpr);
|
||||
}
|
||||
|
||||
SArray *tVariantListAppendToken(SArray *pList, SStrToken *pToken, uint8_t order) {
|
||||
|
@ -366,13 +366,13 @@ SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int
|
|||
return pList;
|
||||
}
|
||||
|
||||
void setDBName(SStrToken *pCpxName, SStrToken *pDB) {
|
||||
pCpxName->type = pDB->type;
|
||||
pCpxName->z = pDB->z;
|
||||
pCpxName->n = pDB->n;
|
||||
void setDbName(SStrToken *pCpxName, SStrToken *pDb) {
|
||||
pCpxName->type = pDb->type;
|
||||
pCpxName->z = pDb->z;
|
||||
pCpxName->n = pDb->n;
|
||||
}
|
||||
|
||||
void tSQLSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType) {
|
||||
void tSqlSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType) {
|
||||
int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]);
|
||||
|
||||
// truncate the column name
|
||||
|
@ -387,10 +387,10 @@ void tSQLSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType)
|
|||
pField->bytes = pType->bytes;
|
||||
}
|
||||
|
||||
void tSQLSetColumnType(TAOS_FIELD *pField, SStrToken *type) {
|
||||
void tSqlSetColumnType(TAOS_FIELD *pField, SStrToken *type) {
|
||||
pField->type = -1;
|
||||
|
||||
for (int8_t i = 0; i < tListLen(tDataTypeDesc); ++i) {
|
||||
for (int32_t i = 0; i < tListLen(tDataTypeDesc); ++i) {
|
||||
if ((strncasecmp(type->z, tDataTypeDesc[i].aName, tDataTypeDesc[i].nameLen) == 0) &&
|
||||
(type->n == tDataTypeDesc[i].nameLen)) {
|
||||
pField->type = i;
|
||||
|
@ -438,7 +438,7 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SStrToken *type) {
|
|||
/*
|
||||
* extract the select info out of sql string
|
||||
*/
|
||||
SQuerySQL *tSetQuerySQLElems(SStrToken *pSelectToken, tSQLExprList *pSelection, SArray *pFrom, tSQLExpr *pWhere,
|
||||
SQuerySQL *tSetQuerySqlElems(SStrToken *pSelectToken, tSQLExprList *pSelection, SArray *pFrom, tSQLExpr *pWhere,
|
||||
SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval,
|
||||
SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) {
|
||||
assert(pSelection != NULL);
|
||||
|
@ -491,11 +491,11 @@ void doDestroyQuerySql(SQuerySQL *pQuerySql) {
|
|||
return;
|
||||
}
|
||||
|
||||
tSQLExprListDestroy(pQuerySql->pSelection);
|
||||
tSqlExprListDestroy(pQuerySql->pSelection);
|
||||
|
||||
pQuerySql->pSelection = NULL;
|
||||
|
||||
tSQLExprDestroy(pQuerySql->pWhere);
|
||||
tSqlExprDestroy(pQuerySql->pWhere);
|
||||
pQuerySql->pWhere = NULL;
|
||||
|
||||
taosArrayDestroyEx(pQuerySql->pSortOrder, freeVariant);
|
||||
|
@ -526,7 +526,7 @@ void destroyAllSelectClause(SSubclauseInfo *pClause) {
|
|||
tfree(pClause->pClause);
|
||||
}
|
||||
|
||||
SCreateTableSQL *tSetCreateSQLElems(SArray *pCols, SArray *pTags, SQuerySQL *pSelect, int32_t type) {
|
||||
SCreateTableSQL *tSetCreateSqlElems(SArray *pCols, SArray *pTags, SQuerySQL *pSelect, int32_t type) {
|
||||
SCreateTableSQL *pCreate = calloc(1, sizeof(SCreateTableSQL));
|
||||
|
||||
switch (type) {
|
||||
|
@ -570,7 +570,7 @@ SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagVal
|
|||
return info;
|
||||
}
|
||||
|
||||
SAlterTableSQL *tAlterTableSQLElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type) {
|
||||
SAlterTableSQL *tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type) {
|
||||
SAlterTableSQL *pAlterTable = calloc(1, sizeof(SAlterTableSQL));
|
||||
|
||||
pAlterTable->name = *pTableName;
|
||||
|
@ -591,7 +591,7 @@ SAlterTableSQL *tAlterTableSQLElems(SStrToken *pTableName, SArray *pCols, SArray
|
|||
return pAlterTable;
|
||||
}
|
||||
|
||||
void* destroyCreateTableSQL(SCreateTableSQL* pCreate) {
|
||||
void* destroyCreateTableSql(SCreateTableSQL* pCreate) {
|
||||
doDestroyQuerySql(pCreate->pSelect);
|
||||
|
||||
taosArrayDestroy(pCreate->colInfo.pColumns);
|
||||
|
@ -603,13 +603,13 @@ void* destroyCreateTableSQL(SCreateTableSQL* pCreate) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void SQLInfoDestroy(SSqlInfo *pInfo) {
|
||||
void SqlInfoDestroy(SSqlInfo *pInfo) {
|
||||
if (pInfo == NULL) return;
|
||||
|
||||
if (pInfo->type == TSDB_SQL_SELECT) {
|
||||
destroyAllSelectClause(&pInfo->subclauseInfo);
|
||||
} else if (pInfo->type == TSDB_SQL_CREATE_TABLE) {
|
||||
pInfo->pCreateTableInfo = destroyCreateTableSQL(pInfo->pCreateTableInfo);
|
||||
pInfo->pCreateTableInfo = destroyCreateTableSql(pInfo->pCreateTableInfo);
|
||||
} else if (pInfo->type == TSDB_SQL_ALTER_TABLE) {
|
||||
taosArrayDestroyEx(pInfo->pAlterInfo->varList, freeVariant);
|
||||
taosArrayDestroy(pInfo->pAlterInfo->pAddColumns);
|
||||
|
@ -647,7 +647,7 @@ SSubclauseInfo* setSubclause(SSubclauseInfo* pSubclause, void *pSqlExprInfo) {
|
|||
return pSubclause;
|
||||
}
|
||||
|
||||
SSqlInfo* setSQLInfo(SSqlInfo *pInfo, void *pSqlExprInfo, SStrToken *pTableName, int32_t type) {
|
||||
SSqlInfo*setSqlInfo(SSqlInfo *pInfo, void *pSqlExprInfo, SStrToken *pTableName, int32_t type) {
|
||||
pInfo->type = type;
|
||||
|
||||
if (type == TSDB_SQL_SELECT) {
|
||||
|
@ -683,7 +683,7 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken
|
|||
|
||||
void tTokenListBuyMoreSpace(tDCLSQL *pTokenList) {
|
||||
if (pTokenList->nAlloc <= pTokenList->nTokens) { //
|
||||
pTokenList->nAlloc = (pTokenList->nAlloc << 1) + 4;
|
||||
pTokenList->nAlloc = (pTokenList->nAlloc << 1u) + 4;
|
||||
pTokenList->a = realloc(pTokenList->a, pTokenList->nAlloc * sizeof(pTokenList->a[0]));
|
||||
if (pTokenList->a == 0) {
|
||||
pTokenList->nTokens = pTokenList->nAlloc = 0;
|
||||
|
@ -718,7 +718,7 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
|
|||
va_end(va);
|
||||
}
|
||||
|
||||
void setDropDBTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck) {
|
||||
void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck) {
|
||||
pInfo->type = type;
|
||||
pInfo->pDCLInfo = tTokenListAppend(pInfo->pDCLInfo, pToken);
|
||||
pInfo->pDCLInfo->existsCheck = (existsCheck->n == 1);
|
||||
|
@ -758,7 +758,7 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDBI
|
|||
pInfo->pDCLInfo->dbOpt.ignoreExists = pIgExists->n; // sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
|
||||
}
|
||||
|
||||
void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctSQL *pAcctInfo) {
|
||||
void setCreateAcctSql(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctSQL *pAcctInfo) {
|
||||
pInfo->type = type;
|
||||
if (pInfo->pDCLInfo == NULL) {
|
||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||
|
@ -774,7 +774,7 @@ void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken
|
|||
}
|
||||
}
|
||||
|
||||
void setCreateUserSQL(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd) {
|
||||
void setCreateUserSql(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd) {
|
||||
pInfo->type = TSDB_SQL_CREATE_USER;
|
||||
if (pInfo->pDCLInfo == NULL) {
|
||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||
|
@ -786,7 +786,7 @@ void setCreateUserSQL(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd) {
|
|||
pInfo->pDCLInfo->user.passwd = *pPasswd;
|
||||
}
|
||||
|
||||
void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege) {
|
||||
void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege) {
|
||||
pInfo->type = TSDB_SQL_ALTER_USER;
|
||||
if (pInfo->pDCLInfo == NULL) {
|
||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||
|
@ -811,7 +811,7 @@ void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken*
|
|||
}
|
||||
}
|
||||
|
||||
void setKillSQL(SSqlInfo *pInfo, int32_t type, SStrToken *ip) {
|
||||
void setKillSql(SSqlInfo *pInfo, int32_t type, SStrToken *ip) {
|
||||
pInfo->type = type;
|
||||
if (pInfo->pDCLInfo == NULL) {
|
||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||
|
|
|
@ -1387,7 +1387,7 @@ taosArrayDestroy((yypminor->yy131));
|
|||
break;
|
||||
case 245: /* create_table_list */
|
||||
{
|
||||
destroyCreateTableSQL((yypminor->yy538));
|
||||
destroyCreateTableSql((yypminor->yy538));
|
||||
}
|
||||
break;
|
||||
case 248: /* select */
|
||||
|
@ -1399,7 +1399,7 @@ doDestroyQuerySql((yypminor->yy84));
|
|||
case 263: /* sclp */
|
||||
case 273: /* exprlist */
|
||||
{
|
||||
tSQLExprListDestroy((yypminor->yy478));
|
||||
tSqlExprListDestroy((yypminor->yy478));
|
||||
}
|
||||
break;
|
||||
case 253: /* where_opt */
|
||||
|
@ -1407,7 +1407,7 @@ tSQLExprListDestroy((yypminor->yy478));
|
|||
case 264: /* expr */
|
||||
case 274: /* expritem */
|
||||
{
|
||||
tSQLExprDestroy((yypminor->yy420));
|
||||
tSqlExprDestroy((yypminor->yy420));
|
||||
}
|
||||
break;
|
||||
case 262: /* union */
|
||||
|
@ -2114,32 +2114,33 @@ static void yy_reduce(
|
|||
case 24: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */
|
||||
{
|
||||
SStrToken token;
|
||||
setDBName(&token, &yymsp[-3].minor.yy0);
|
||||
setDbName(&token, &yymsp[-3].minor.yy0);
|
||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &yymsp[0].minor.yy0);
|
||||
}
|
||||
break;
|
||||
case 25: /* cmd ::= SHOW dbPrefix VGROUPS */
|
||||
{
|
||||
SStrToken token;
|
||||
setDBName(&token, &yymsp[-1].minor.yy0);
|
||||
setDbName(&token, &yymsp[-1].minor.yy0);
|
||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0);
|
||||
}
|
||||
break;
|
||||
case 26: /* cmd ::= SHOW dbPrefix VGROUPS ids */
|
||||
{
|
||||
SStrToken token;
|
||||
setDBName(&token, &yymsp[-2].minor.yy0);
|
||||
setDbName(&token, &yymsp[-2].minor.yy0);
|
||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &yymsp[0].minor.yy0);
|
||||
}
|
||||
break;
|
||||
case 27: /* cmd ::= DROP TABLE ifexists ids cpxName */
|
||||
{
|
||||
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
|
||||
setDropDBTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &yymsp[-1].minor.yy0, &yymsp[-2].minor.yy0);
|
||||
setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &yymsp[-1].minor.yy0, &yymsp[-2].minor.yy0);
|
||||
}
|
||||
break;
|
||||
case 28: /* cmd ::= DROP DATABASE ifexists ids */
|
||||
{ setDropDBTableInfo(pInfo, TSDB_SQL_DROP_DB, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0); }
|
||||
{
|
||||
setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0); }
|
||||
break;
|
||||
case 29: /* cmd ::= DROP DNODE ids */
|
||||
{ setDCLSQLElems(pInfo, TSDB_SQL_DROP_DNODE, 1, &yymsp[0].minor.yy0); }
|
||||
|
@ -2160,10 +2161,12 @@ static void yy_reduce(
|
|||
}
|
||||
break;
|
||||
case 34: /* cmd ::= ALTER USER ids PASS ids */
|
||||
{ setAlterUserSQL(pInfo, TSDB_ALTER_USER_PASSWD, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, NULL); }
|
||||
{
|
||||
setAlterUserSql(pInfo, TSDB_ALTER_USER_PASSWD, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, NULL); }
|
||||
break;
|
||||
case 35: /* cmd ::= ALTER USER ids PRIVILEGE ids */
|
||||
{ setAlterUserSQL(pInfo, TSDB_ALTER_USER_PRIVILEGES, &yymsp[-2].minor.yy0, NULL, &yymsp[0].minor.yy0);}
|
||||
{
|
||||
setAlterUserSql(pInfo, TSDB_ALTER_USER_PRIVILEGES, &yymsp[-2].minor.yy0, NULL, &yymsp[0].minor.yy0);}
|
||||
break;
|
||||
case 36: /* cmd ::= ALTER DNODE ids ids */
|
||||
{ setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
|
||||
|
@ -2181,10 +2184,12 @@ static void yy_reduce(
|
|||
{ SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy148, &t);}
|
||||
break;
|
||||
case 41: /* cmd ::= ALTER ACCOUNT ids acct_optr */
|
||||
{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy309);}
|
||||
{
|
||||
setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy309);}
|
||||
break;
|
||||
case 42: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
|
||||
{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy309);}
|
||||
{
|
||||
setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy309);}
|
||||
break;
|
||||
case 43: /* ids ::= ID */
|
||||
case 44: /* ids ::= STRING */ yytestcase(yyruleno==44);
|
||||
|
@ -2205,13 +2210,16 @@ static void yy_reduce(
|
|||
{ setDCLSQLElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);}
|
||||
break;
|
||||
case 50: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
|
||||
{ setCreateAcctSQL(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy309);}
|
||||
{
|
||||
setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0,
|
||||
&yymsp[0].minor.yy309);}
|
||||
break;
|
||||
case 51: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */
|
||||
{ setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy148, &yymsp[-2].minor.yy0);}
|
||||
break;
|
||||
case 52: /* cmd ::= CREATE USER ids PASS ids */
|
||||
{ setCreateUserSQL(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
|
||||
{
|
||||
setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
|
||||
break;
|
||||
case 53: /* pps ::= */
|
||||
case 55: /* tseries ::= */ yytestcase(yyruleno==55);
|
||||
|
@ -2340,7 +2348,7 @@ static void yy_reduce(
|
|||
case 110: /* typename ::= ids */
|
||||
{
|
||||
yymsp[0].minor.yy0.type = 0;
|
||||
tSQLSetColumnType (&yylhsminor.yy163, &yymsp[0].minor.yy0);
|
||||
tSqlSetColumnType(&yylhsminor.yy163, &yymsp[0].minor.yy0);
|
||||
}
|
||||
yymsp[0].minor.yy163 = yylhsminor.yy163;
|
||||
break;
|
||||
|
@ -2348,10 +2356,10 @@ static void yy_reduce(
|
|||
{
|
||||
if (yymsp[-1].minor.yy459 <= 0) {
|
||||
yymsp[-3].minor.yy0.type = 0;
|
||||
tSQLSetColumnType(&yylhsminor.yy163, &yymsp[-3].minor.yy0);
|
||||
tSqlSetColumnType(&yylhsminor.yy163, &yymsp[-3].minor.yy0);
|
||||
} else {
|
||||
yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy459; // negative value of name length
|
||||
tSQLSetColumnType(&yylhsminor.yy163, &yymsp[-3].minor.yy0);
|
||||
tSqlSetColumnType(&yylhsminor.yy163, &yymsp[-3].minor.yy0);
|
||||
}
|
||||
}
|
||||
yymsp[-3].minor.yy163 = yylhsminor.yy163;
|
||||
|
@ -2389,8 +2397,8 @@ static void yy_reduce(
|
|||
break;
|
||||
case 119: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */
|
||||
{
|
||||
yylhsminor.yy538 = tSetCreateSQLElems(yymsp[-1].minor.yy131, NULL, NULL, TSQL_CREATE_TABLE);
|
||||
setSQLInfo(pInfo, yylhsminor.yy538, NULL, TSDB_SQL_CREATE_TABLE);
|
||||
yylhsminor.yy538 = tSetCreateSqlElems(yymsp[-1].minor.yy131, NULL, NULL, TSQL_CREATE_TABLE);
|
||||
setSqlInfo(pInfo, yylhsminor.yy538, NULL, TSDB_SQL_CREATE_TABLE);
|
||||
|
||||
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
|
||||
setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0);
|
||||
|
@ -2399,8 +2407,8 @@ static void yy_reduce(
|
|||
break;
|
||||
case 120: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */
|
||||
{
|
||||
yylhsminor.yy538 = tSetCreateSQLElems(yymsp[-5].minor.yy131, yymsp[-1].minor.yy131, NULL, TSQL_CREATE_STABLE);
|
||||
setSQLInfo(pInfo, yylhsminor.yy538, NULL, TSDB_SQL_CREATE_TABLE);
|
||||
yylhsminor.yy538 = tSetCreateSqlElems(yymsp[-5].minor.yy131, yymsp[-1].minor.yy131, NULL, TSQL_CREATE_STABLE);
|
||||
setSqlInfo(pInfo, yylhsminor.yy538, NULL, TSDB_SQL_CREATE_TABLE);
|
||||
|
||||
yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n;
|
||||
setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0);
|
||||
|
@ -2417,8 +2425,8 @@ static void yy_reduce(
|
|||
break;
|
||||
case 122: /* create_table_args ::= ifnotexists ids cpxName AS select */
|
||||
{
|
||||
yylhsminor.yy538 = tSetCreateSQLElems(NULL, NULL, yymsp[0].minor.yy84, TSQL_CREATE_STREAM);
|
||||
setSQLInfo(pInfo, yylhsminor.yy538, NULL, TSDB_SQL_CREATE_TABLE);
|
||||
yylhsminor.yy538 = tSetCreateSqlElems(NULL, NULL, yymsp[0].minor.yy84, TSQL_CREATE_STREAM);
|
||||
setSqlInfo(pInfo, yylhsminor.yy538, NULL, TSDB_SQL_CREATE_TABLE);
|
||||
|
||||
yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n;
|
||||
setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0);
|
||||
|
@ -2435,7 +2443,7 @@ static void yy_reduce(
|
|||
break;
|
||||
case 125: /* column ::= ids typename */
|
||||
{
|
||||
tSQLSetColumnInfo(&yylhsminor.yy163, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy163);
|
||||
tSqlSetColumnInfo(&yylhsminor.yy163, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy163);
|
||||
}
|
||||
yymsp[-1].minor.yy163 = yylhsminor.yy163;
|
||||
break;
|
||||
|
@ -2472,7 +2480,10 @@ static void yy_reduce(
|
|||
break;
|
||||
case 137: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
|
||||
{
|
||||
yylhsminor.yy84 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy478, yymsp[-9].minor.yy131, yymsp[-8].minor.yy420, yymsp[-4].minor.yy131, yymsp[-3].minor.yy131, &yymsp[-7].minor.yy530, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy131, &yymsp[0].minor.yy284, &yymsp[-1].minor.yy284);
|
||||
yylhsminor.yy84 = tSetQuerySqlElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy478, yymsp[-9].minor.yy131,
|
||||
yymsp[-8].minor.yy420, yymsp[-4].minor.yy131, yymsp[-3].minor.yy131,
|
||||
&yymsp[-7].minor.yy530, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy131,
|
||||
&yymsp[0].minor.yy284, &yymsp[-1].minor.yy284);
|
||||
}
|
||||
yymsp[-11].minor.yy84 = yylhsminor.yy84;
|
||||
break;
|
||||
|
@ -2492,11 +2503,13 @@ static void yy_reduce(
|
|||
yymsp[-5].minor.yy513 = yylhsminor.yy513;
|
||||
break;
|
||||
case 142: /* cmd ::= union */
|
||||
{ setSQLInfo(pInfo, yymsp[0].minor.yy513, NULL, TSDB_SQL_SELECT); }
|
||||
{
|
||||
setSqlInfo(pInfo, yymsp[0].minor.yy513, NULL, TSDB_SQL_SELECT); }
|
||||
break;
|
||||
case 143: /* select ::= SELECT selcollist */
|
||||
{
|
||||
yylhsminor.yy84 = tSetQuerySQLElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy478, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
yylhsminor.yy84 = tSetQuerySqlElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy478, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
yymsp[-1].minor.yy84 = yylhsminor.yy84;
|
||||
break;
|
||||
|
@ -2509,14 +2522,15 @@ static void yy_reduce(
|
|||
break;
|
||||
case 146: /* selcollist ::= sclp expr as */
|
||||
{
|
||||
yylhsminor.yy478 = tSQLExprListAppend(yymsp[-2].minor.yy478, yymsp[-1].minor.yy420, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
|
||||
yylhsminor.yy478 = tSqlExprListAppend(yymsp[-2].minor.yy478, yymsp[-1].minor.yy420,
|
||||
yymsp[0].minor.yy0.n ? &yymsp[0].minor.yy0 : 0);
|
||||
}
|
||||
yymsp[-2].minor.yy478 = yylhsminor.yy478;
|
||||
break;
|
||||
case 147: /* selcollist ::= sclp STAR */
|
||||
{
|
||||
tSQLExpr *pNode = tSQLExprIdValueCreate(NULL, TK_ALL);
|
||||
yylhsminor.yy478 = tSQLExprListAppend(yymsp[-1].minor.yy478, pNode, 0);
|
||||
tSQLExpr *pNode = tSqlExprIdValueCreate(NULL, TK_ALL);
|
||||
yylhsminor.yy478 = tSqlExprListAppend(yymsp[-1].minor.yy478, pNode, 0);
|
||||
}
|
||||
yymsp[-1].minor.yy478 = yylhsminor.yy478;
|
||||
break;
|
||||
|
@ -2697,133 +2711,135 @@ static void yy_reduce(
|
|||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 190: /* expr ::= ID */
|
||||
{ yylhsminor.yy420 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);}
|
||||
{ yylhsminor.yy420 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);}
|
||||
yymsp[0].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 191: /* expr ::= ID DOT ID */
|
||||
{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy420 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);}
|
||||
{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy420 = tSqlExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);}
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 192: /* expr ::= ID DOT STAR */
|
||||
{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy420 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);}
|
||||
{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy420 = tSqlExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);}
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 193: /* expr ::= INTEGER */
|
||||
{ yylhsminor.yy420 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);}
|
||||
{ yylhsminor.yy420 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);}
|
||||
yymsp[0].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 194: /* expr ::= MINUS INTEGER */
|
||||
case 195: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==195);
|
||||
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy420 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);}
|
||||
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy420 = tSqlExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);}
|
||||
yymsp[-1].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 196: /* expr ::= FLOAT */
|
||||
{ yylhsminor.yy420 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);}
|
||||
{ yylhsminor.yy420 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);}
|
||||
yymsp[0].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 197: /* expr ::= MINUS FLOAT */
|
||||
case 198: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==198);
|
||||
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy420 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);}
|
||||
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy420 = tSqlExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);}
|
||||
yymsp[-1].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 199: /* expr ::= STRING */
|
||||
{ yylhsminor.yy420 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);}
|
||||
{ yylhsminor.yy420 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);}
|
||||
yymsp[0].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 200: /* expr ::= NOW */
|
||||
{ yylhsminor.yy420 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); }
|
||||
{ yylhsminor.yy420 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); }
|
||||
yymsp[0].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 201: /* expr ::= VARIABLE */
|
||||
{ yylhsminor.yy420 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);}
|
||||
{ yylhsminor.yy420 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);}
|
||||
yymsp[0].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 202: /* expr ::= BOOL */
|
||||
{ yylhsminor.yy420 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);}
|
||||
{ yylhsminor.yy420 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);}
|
||||
yymsp[0].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 203: /* expr ::= ID LP exprlist RP */
|
||||
{ yylhsminor.yy420 = tSQLExprCreateFunction(yymsp[-1].minor.yy478, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
|
||||
{ yylhsminor.yy420 = tSqlExprCreateFunction(yymsp[-1].minor.yy478, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0,
|
||||
yymsp[-3].minor.yy0.type); }
|
||||
yymsp[-3].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 204: /* expr ::= ID LP STAR RP */
|
||||
{ yylhsminor.yy420 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
|
||||
{ yylhsminor.yy420 =
|
||||
tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
|
||||
yymsp[-3].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 205: /* expr ::= expr IS NULL */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, NULL, TK_ISNULL);}
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, NULL, TK_ISNULL);}
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 206: /* expr ::= expr IS NOT NULL */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-3].minor.yy420, NULL, TK_NOTNULL);}
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-3].minor.yy420, NULL, TK_NOTNULL);}
|
||||
yymsp[-3].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 207: /* expr ::= expr LT expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_LT);}
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_LT);}
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 208: /* expr ::= expr GT expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_GT);}
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_GT);}
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 209: /* expr ::= expr LE expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_LE);}
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_LE);}
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 210: /* expr ::= expr GE expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_GE);}
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_GE);}
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 211: /* expr ::= expr NE expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_NE);}
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_NE);}
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 212: /* expr ::= expr EQ expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_EQ);}
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_EQ);}
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 213: /* expr ::= expr AND expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_AND);}
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_AND);}
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 214: /* expr ::= expr OR expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_OR); }
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_OR); }
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 215: /* expr ::= expr PLUS expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_PLUS); }
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_PLUS); }
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 216: /* expr ::= expr MINUS expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_MINUS); }
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_MINUS); }
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 217: /* expr ::= expr STAR expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_STAR); }
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_STAR); }
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 218: /* expr ::= expr SLASH expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_DIVIDE);}
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_DIVIDE);}
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 219: /* expr ::= expr REM expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_REM); }
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_REM); }
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 220: /* expr ::= expr LIKE expr */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_LIKE); }
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-2].minor.yy420, yymsp[0].minor.yy420, TK_LIKE); }
|
||||
yymsp[-2].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 221: /* expr ::= expr IN LP exprlist RP */
|
||||
{yylhsminor.yy420 = tSQLExprCreate(yymsp[-4].minor.yy420, (tSQLExpr*)yymsp[-1].minor.yy478, TK_IN); }
|
||||
{yylhsminor.yy420 = tSqlExprCreate(yymsp[-4].minor.yy420, (tSQLExpr *)yymsp[-1].minor.yy478, TK_IN); }
|
||||
yymsp[-4].minor.yy420 = yylhsminor.yy420;
|
||||
break;
|
||||
case 222: /* exprlist ::= exprlist COMMA expritem */
|
||||
{yylhsminor.yy478 = tSQLExprListAppend(yymsp[-2].minor.yy478,yymsp[0].minor.yy420,0);}
|
||||
{yylhsminor.yy478 = tSqlExprListAppend(yymsp[-2].minor.yy478, yymsp[0].minor.yy420, 0);}
|
||||
yymsp[-2].minor.yy478 = yylhsminor.yy478;
|
||||
break;
|
||||
case 223: /* exprlist ::= expritem */
|
||||
{yylhsminor.yy478 = tSQLExprListAppend(0,yymsp[0].minor.yy420,0);}
|
||||
{yylhsminor.yy478 = tSqlExprListAppend(0, yymsp[0].minor.yy420, 0);}
|
||||
yymsp[0].minor.yy478 = yylhsminor.yy478;
|
||||
break;
|
||||
case 224: /* expritem ::= expr */
|
||||
|
@ -2836,8 +2852,9 @@ static void yy_reduce(
|
|||
case 227: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
|
||||
{
|
||||
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_ADD_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
SAlterTableSQL* pAlterTable =
|
||||
tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_ADD_COLUMN);
|
||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
break;
|
||||
case 228: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
|
||||
|
@ -2847,15 +2864,16 @@ static void yy_reduce(
|
|||
toTSDBType(yymsp[0].minor.yy0.type);
|
||||
SArray* K = tVariantListAppendToken(NULL, &yymsp[0].minor.yy0, -1);
|
||||
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN);
|
||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
break;
|
||||
case 229: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
|
||||
{
|
||||
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
SAlterTableSQL* pAlterTable =
|
||||
tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN);
|
||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
break;
|
||||
case 230: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
|
||||
|
@ -2865,8 +2883,8 @@ static void yy_reduce(
|
|||
toTSDBType(yymsp[0].minor.yy0.type);
|
||||
SArray* A = tVariantListAppendToken(NULL, &yymsp[0].minor.yy0, -1);
|
||||
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN);
|
||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
break;
|
||||
case 231: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
|
||||
|
@ -2879,8 +2897,9 @@ static void yy_reduce(
|
|||
toTSDBType(yymsp[0].minor.yy0.type);
|
||||
A = tVariantListAppendToken(A, &yymsp[0].minor.yy0, -1);
|
||||
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-5].minor.yy0, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
SAlterTableSQL* pAlterTable =
|
||||
tAlterTableSqlElems(&yymsp[-5].minor.yy0, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN);
|
||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
break;
|
||||
case 232: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
|
||||
|
@ -2891,18 +2910,21 @@ static void yy_reduce(
|
|||
SArray* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1);
|
||||
A = tVariantListAppend(A, &yymsp[0].minor.yy516, -1);
|
||||
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL);
|
||||
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL);
|
||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||
}
|
||||
break;
|
||||
case 233: /* cmd ::= KILL CONNECTION INTEGER */
|
||||
{setKillSQL(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);}
|
||||
{
|
||||
setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);}
|
||||
break;
|
||||
case 234: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */
|
||||
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSQL(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);}
|
||||
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n);
|
||||
setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);}
|
||||
break;
|
||||
case 235: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */
|
||||
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSQL(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);}
|
||||
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n);
|
||||
setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
#include "tlog.h"
|
||||
|
||||
extern int32_t rpcDebugFlag;
|
||||
extern int32_t tscEmbedded;
|
||||
extern uint32_t tscEmbedded;
|
||||
|
||||
#define tFatal(...) { if (rpcDebugFlag & DEBUG_FATAL) { taosPrintLog("RPC FATAL ", tscEmbedded ? 255 : rpcDebugFlag, __VA_ARGS__); }}
|
||||
#define tError(...) { if (rpcDebugFlag & DEBUG_ERROR) { taosPrintLog("RPC ERROR ", tscEmbedded ? 255 : rpcDebugFlag, __VA_ARGS__); }}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "ttimer.h"
|
||||
#include "tutil.h"
|
||||
|
||||
extern int32_t tscEmbedded;
|
||||
extern uint32_t tscEmbedded;
|
||||
|
||||
#define tmrFatal(...) { if (tmrDebugFlag & DEBUG_FATAL) { taosPrintLog("TMR FATAL ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
|
||||
#define tmrError(...) { if (tmrDebugFlag & DEBUG_ERROR) { taosPrintLog("TMR ERROR ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
|
||||
|
|
|
@ -56,6 +56,15 @@ class TDTestCase:
|
|||
# query .. order by non-time field
|
||||
tdSql.error("select * from st order by name")
|
||||
|
||||
# TD-2133
|
||||
tdSql.error("select diff(tagtype),bottom(tagtype,1) from dev_001")
|
||||
|
||||
# TD-2190
|
||||
tdSql.error("select min(tagtype),max(tagtype) from dev_002 interval(1n) fill(prev)")
|
||||
|
||||
# TD-2208
|
||||
tdSql.error("select diff(tagtype),top(tagtype,1) from dev_001")
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
|
|
@ -115,9 +115,21 @@ if __name__ == "__main__":
|
|||
tdDnodes.init(deployPath)
|
||||
tdDnodes.setTestCluster(testCluster)
|
||||
tdDnodes.setValgrind(valgrind)
|
||||
|
||||
tdDnodes.stopAll()
|
||||
tdDnodes.deploy(1)
|
||||
is_test_framework = 0
|
||||
key_word = 'tdCases.addLinux'
|
||||
if key_word in open(fileName).read():
|
||||
is_test_framework = 1
|
||||
if is_test_framework:
|
||||
moduleName = fileName.replace(".py", "").replace("/", ".")
|
||||
uModule = importlib.import_module(moduleName)
|
||||
try:
|
||||
ucase = uModule.TDTestCase()
|
||||
tdDnodes.deploy(1,ucase.updatecfgDict)
|
||||
except :
|
||||
tdDnodes.deploy(1,{})
|
||||
else:
|
||||
tdDnodes.deploy(1,{})
|
||||
tdDnodes.start(1)
|
||||
|
||||
if masterIp == "":
|
||||
|
|
|
@ -108,6 +108,36 @@ class TDDnode:
|
|||
self.deployed = 0
|
||||
self.testCluster = False
|
||||
self.valgrind = 0
|
||||
self.cfgDict = {
|
||||
"numOfLogLines":"100000000",
|
||||
"mnodeEqualVnodeNum":"0",
|
||||
"walLevel":"2",
|
||||
"fsync":"1000",
|
||||
"statusInterval":"1",
|
||||
"numOfMnodes":"3",
|
||||
"numOfThreadsPerCore":"2.0",
|
||||
"monitor":"0",
|
||||
"maxVnodeConnections":"30000",
|
||||
"maxMgmtConnections":"30000",
|
||||
"maxMeterConnections":"30000",
|
||||
"maxShellConns":"30000",
|
||||
"locale":"en_US.UTF-8",
|
||||
"charset":"UTF-8",
|
||||
"asyncLog":"0",
|
||||
"anyIp":"0",
|
||||
"tsEnableTelemetryReporting":"0",
|
||||
"dDebugFlag":"135",
|
||||
"mDebugFlag":"135",
|
||||
"sdbDebugFlag":"135",
|
||||
"rpcDebugFlag":"135",
|
||||
"tmrDebugFlag":"131",
|
||||
"cDebugFlag":"135",
|
||||
"httpDebugFlag":"135",
|
||||
"monitorDebugFlag":"135",
|
||||
"udebugFlag":"135",
|
||||
"jnidebugFlag":"135",
|
||||
"qdebugFlag":"135"
|
||||
}
|
||||
|
||||
def init(self, path):
|
||||
self.path = path
|
||||
|
@ -131,7 +161,10 @@ class TDDnode:
|
|||
|
||||
return totalSize
|
||||
|
||||
def deploy(self):
|
||||
def addExtraCfg(self, option, value):
|
||||
self.cfgDict.update({option: value})
|
||||
|
||||
def deploy(self, *updatecfgDict):
|
||||
self.logDir = "%s/sim/dnode%d/log" % (self.path, self.index)
|
||||
self.dataDir = "%s/sim/dnode%d/data" % (self.path, self.index)
|
||||
self.cfgDir = "%s/sim/dnode%d/cfg" % (self.path, self.index)
|
||||
|
@ -175,36 +208,17 @@ class TDDnode:
|
|||
self.cfg("publicIp", "192.168.0.%d" % (self.index))
|
||||
self.cfg("internalIp", "192.168.0.%d" % (self.index))
|
||||
self.cfg("privateIp", "192.168.0.%d" % (self.index))
|
||||
self.cfg("dataDir", self.dataDir)
|
||||
self.cfg("logDir", self.logDir)
|
||||
self.cfg("numOfLogLines", "100000000")
|
||||
self.cfg("mnodeEqualVnodeNum", "0")
|
||||
self.cfg("walLevel", "2")
|
||||
self.cfg("fsync", "1000")
|
||||
self.cfg("statusInterval", "1")
|
||||
self.cfg("numOfMnodes", "3")
|
||||
self.cfg("numOfThreadsPerCore", "2.0")
|
||||
self.cfg("monitor", "0")
|
||||
self.cfg("maxVnodeConnections", "30000")
|
||||
self.cfg("maxMgmtConnections", "30000")
|
||||
self.cfg("maxMeterConnections", "30000")
|
||||
self.cfg("maxShellConns", "30000")
|
||||
self.cfg("locale", "en_US.UTF-8")
|
||||
self.cfg("charset", "UTF-8")
|
||||
self.cfg("asyncLog", "0")
|
||||
self.cfg("anyIp", "0")
|
||||
self.cfg("tsEnableTelemetryReporting", "0")
|
||||
self.cfg("dDebugFlag", "135")
|
||||
self.cfg("mDebugFlag", "135")
|
||||
self.cfg("sdbDebugFlag", "135")
|
||||
self.cfg("rpcDebugFlag", "135")
|
||||
self.cfg("tmrDebugFlag", "131")
|
||||
self.cfg("cDebugFlag", "135")
|
||||
self.cfg("httpDebugFlag", "135")
|
||||
self.cfg("monitorDebugFlag", "135")
|
||||
self.cfg("udebugFlag", "135")
|
||||
self.cfg("jnidebugFlag", "135")
|
||||
self.cfg("qdebugFlag", "135")
|
||||
|
||||
self.cfg("dataDir",self.dataDir)
|
||||
self.cfg("logDir",self.logDir)
|
||||
print(updatecfgDict)
|
||||
if updatecfgDict[0] and updatecfgDict[0][0]:
|
||||
print(updatecfgDict[0][0])
|
||||
for key,value in updatecfgDict[0][0].items():
|
||||
self.addExtraCfg(key,value)
|
||||
for key, value in self.cfgDict.items():
|
||||
self.cfg(key, value)
|
||||
|
||||
self.deployed = 1
|
||||
tdLog.debug(
|
||||
"dnode:%d is deployed and configured by %s" %
|
||||
|
@ -260,6 +274,12 @@ class TDDnode:
|
|||
key = 'from offline to online'
|
||||
bkey = bytes(key,encoding="utf8")
|
||||
logFile = self.logDir + "/taosdlog.0"
|
||||
i = 0
|
||||
while not os.path.exists(logFile):
|
||||
sleep(0.1)
|
||||
i += 1
|
||||
if i>50:
|
||||
break
|
||||
popen = subprocess.Popen('tail -f ' + logFile, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
pid = popen.pid
|
||||
print('Popen.pid:' + str(pid))
|
||||
|
@ -274,6 +294,7 @@ class TDDnode:
|
|||
tdLog.debug("wait 5 seconds for the dnode:%d to start." % (self.index))
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
# time.sleep(5)
|
||||
|
||||
def startWithoutSleep(self):
|
||||
|
@ -454,7 +475,7 @@ class TDDnodes:
|
|||
def setValgrind(self, value):
|
||||
self.valgrind = value
|
||||
|
||||
def deploy(self, index):
|
||||
def deploy(self, index, *updatecfgDict):
|
||||
self.sim.setTestCluster(self.testCluster)
|
||||
|
||||
if (self.simDeployed == False):
|
||||
|
@ -464,7 +485,7 @@ class TDDnodes:
|
|||
self.check(index)
|
||||
self.dnodes[index - 1].setTestCluster(self.testCluster)
|
||||
self.dnodes[index - 1].setValgrind(self.valgrind)
|
||||
self.dnodes[index - 1].deploy()
|
||||
self.dnodes[index - 1].deploy(updatecfgDict)
|
||||
|
||||
def cfg(self, index, option, value):
|
||||
self.check(index)
|
||||
|
|
Loading…
Reference in New Issue