未验证 提交 a838ce83 编写于 作者: H haojun Liao 提交者: GitHub

Merge pull request #5440 from taosdata/feature/qrefactor

[td-3294]fix bug found by regression test.
...@@ -1360,7 +1360,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) { ...@@ -1360,7 +1360,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
} }
} }
} else { } else {
SSqlInfo SQLInfo = qSQLParse(pSql->sqlstr); SSqlInfo SQLInfo = qSqlParse(pSql->sqlstr);
ret = tscToSQLCmd(pSql, &SQLInfo); ret = tscToSQLCmd(pSql, &SQLInfo);
if (ret == TSDB_CODE_TSC_INVALID_SQL && pSql->parseRetry == 0 && SQLInfo.type == TSDB_SQL_NULL) { if (ret == TSDB_CODE_TSC_INVALID_SQL && pSql->parseRetry == 0 && SQLInfo.type == TSDB_SQL_NULL) {
tscResetSqlCmd(pCmd, true); tscResetSqlCmd(pCmd, true);
......
此差异已折叠。
...@@ -1350,7 +1350,7 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1350,7 +1350,7 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd *pCmd = &(pSql->cmd); SSqlCmd *pCmd = &(pSql->cmd);
int32_t size = minMsgSize() + sizeof(SCMCreateTableMsg) + sizeof(SCreateTableMsg); int32_t size = minMsgSize() + sizeof(SCMCreateTableMsg) + sizeof(SCreateTableMsg);
SCreateTableSQL *pCreateTableInfo = pInfo->pCreateTableInfo; SCreateTableSql *pCreateTableInfo = pInfo->pCreateTableInfo;
if (pCreateTableInfo->type == TSQL_CREATE_TABLE_FROM_STABLE) { if (pCreateTableInfo->type == TSQL_CREATE_TABLE_FROM_STABLE) {
int32_t numOfTables = (int32_t)taosArrayGetSize(pInfo->pCreateTableInfo->childTableInfo); int32_t numOfTables = (int32_t)taosArrayGetSize(pInfo->pCreateTableInfo->childTableInfo);
size += numOfTables * (sizeof(SCreateTableMsg) + TSDB_MAX_TAGS_LEN); size += numOfTables * (sizeof(SCreateTableMsg) + TSDB_MAX_TAGS_LEN);
...@@ -1359,7 +1359,7 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1359,7 +1359,7 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) {
} }
if (pCreateTableInfo->pSelect != NULL) { if (pCreateTableInfo->pSelect != NULL) {
size += (pCreateTableInfo->pSelect->selectToken.n + 1); size += (pCreateTableInfo->pSelect->sqlstr.n + 1);
} }
return size + TSDB_EXTRA_PAYLOAD_SIZE; return size + TSDB_EXTRA_PAYLOAD_SIZE;
...@@ -1417,7 +1417,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1417,7 +1417,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pCreateMsg->tableName); int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pCreateMsg->tableName);
assert(code == 0); assert(code == 0);
SCreateTableSQL *pCreateTable = pInfo->pCreateTableInfo; SCreateTableSql *pCreateTable = pInfo->pCreateTableInfo;
pCreateMsg->igExists = pCreateTable->existCheck ? 1 : 0; pCreateMsg->igExists = pCreateTable->existCheck ? 1 : 0;
pCreateMsg->numOfColumns = htons(pCmd->numOfCols); pCreateMsg->numOfColumns = htons(pCmd->numOfCols);
...@@ -1440,11 +1440,11 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1440,11 +1440,11 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg = (char *)pSchema; pMsg = (char *)pSchema;
if (type == TSQL_CREATE_STREAM) { // check if it is a stream sql if (type == TSQL_CREATE_STREAM) { // check if it is a stream sql
SQuerySQL *pQuerySql = pInfo->pCreateTableInfo->pSelect; SQuerySqlNode *pQuerySql = pInfo->pCreateTableInfo->pSelect;
strncpy(pMsg, pQuerySql->selectToken.z, pQuerySql->selectToken.n + 1); strncpy(pMsg, pQuerySql->sqlstr.z, pQuerySql->sqlstr.n + 1);
pCreateMsg->sqlLen = htons(pQuerySql->selectToken.n + 1); pCreateMsg->sqlLen = htons(pQuerySql->sqlstr.n + 1);
pMsg += pQuerySql->selectToken.n + 1; pMsg += pQuerySql->sqlstr.n + 1;
} }
} }
......
...@@ -27,6 +27,18 @@ extern "C" { ...@@ -27,6 +27,18 @@ extern "C" {
#include "tvariant.h" #include "tvariant.h"
#define ParseTOKENTYPE SStrToken #define ParseTOKENTYPE SStrToken
#define NON_ARITHMEIC_EXPR 0
#define NORMAL_ARITHMETIC 1
#define AGG_ARIGHTMEIC 2
enum SQL_NODE_TYPE {
SQL_NODE_TABLE_COLUMN= 1,
SQL_NODE_SQLFUNCTION = 2,
SQL_NODE_VALUE = 3,
SQL_NODE_EXPR = 4,
};
extern char tTokenTypeSwitcher[13]; extern char tTokenTypeSwitcher[13];
#define toTSDBType(x) \ #define toTSDBType(x) \
...@@ -38,6 +50,9 @@ extern char tTokenTypeSwitcher[13]; ...@@ -38,6 +50,9 @@ extern char tTokenTypeSwitcher[13];
} \ } \
} while (0) } while (0)
#define TPARSER_HAS_TOKEN(_t) ((_t).n > 0)
#define TPARSER_SET_NONE_TOKEN(_t) ((_t).n = 0)
typedef struct SLimitVal { typedef struct SLimitVal {
int64_t limit; int64_t limit;
int64_t offset; int64_t offset;
...@@ -63,20 +78,20 @@ typedef struct SSessionWindowVal { ...@@ -63,20 +78,20 @@ typedef struct SSessionWindowVal {
SStrToken gap; SStrToken gap;
} SSessionWindowVal; } SSessionWindowVal;
typedef struct SQuerySQL { typedef struct SQuerySqlNode {
struct tSQLExprList *pSelection; // select clause struct SArray *pSelectList; // select clause
SArray * from; // from clause SArray<tVariantListItem> SArray *from; // from clause SArray<SQuerySqlNode>
struct tSQLExpr * pWhere; // where clause [optional] struct tSqlExpr *pWhere; // where clause [optional]
SArray * pGroupby; // groupby clause, only for tags[optional], SArray<tVariantListItem> SArray *pGroupby; // groupby clause, only for tags[optional], SArray<tVariantListItem>
SArray * pSortOrder; // orderby [optional], SArray<tVariantListItem> SArray *pSortOrder; // orderby [optional], SArray<tVariantListItem>
SArray *fillType; // fill type[optional], SArray<tVariantListItem>
SIntervalVal interval; // (interval, interval_offset) [optional] SIntervalVal interval; // (interval, interval_offset) [optional]
SSessionWindowVal sessionVal; // session window [optional] SSessionWindowVal sessionVal; // session window [optional]
SStrToken sliding; // sliding window [optional] SStrToken sliding; // sliding window [optional]
SLimitVal limit; // limit offset [optional] SLimitVal limit; // limit offset [optional]
SLimitVal slimit; // group limit offset [optional] SLimitVal slimit; // group limit offset [optional]
SArray * fillType; // fill type[optional], SArray<tVariantListItem> SStrToken sqlstr; // sql string in select clause
SStrToken selectToken; // sql string } SQuerySqlNode;
} SQuerySQL;
typedef struct SCreatedTableInfo { typedef struct SCreatedTableInfo {
SStrToken name; // table name token SStrToken name; // table name token
...@@ -88,7 +103,7 @@ typedef struct SCreatedTableInfo { ...@@ -88,7 +103,7 @@ typedef struct SCreatedTableInfo {
int8_t igExist; // ignore if exists int8_t igExist; // ignore if exists
} SCreatedTableInfo; } SCreatedTableInfo;
typedef struct SCreateTableSQL { typedef struct SCreateTableSql {
SStrToken name; // table name, create table [name] xxx SStrToken name; // table name, create table [name] xxx
int8_t type; // create normal table/from super table/ stream int8_t type; // create normal table/from super table/ stream
bool existCheck; bool existCheck;
...@@ -99,8 +114,8 @@ typedef struct SCreateTableSQL { ...@@ -99,8 +114,8 @@ typedef struct SCreateTableSQL {
} colInfo; } colInfo;
SArray *childTableInfo; // SArray<SCreatedTableInfo> SArray *childTableInfo; // SArray<SCreatedTableInfo>
SQuerySQL *pSelect; SQuerySqlNode *pSelect;
} SCreateTableSQL; } SCreateTableSql;
typedef struct SAlterTableInfo { typedef struct SAlterTableInfo {
SStrToken name; SStrToken name;
...@@ -174,7 +189,7 @@ typedef struct SMiscInfo { ...@@ -174,7 +189,7 @@ typedef struct SMiscInfo {
} SMiscInfo; } SMiscInfo;
typedef struct SSubclauseInfo { // "UNION" multiple select sub-clause typedef struct SSubclauseInfo { // "UNION" multiple select sub-clause
SQuerySQL **pClause; SQuerySqlNode **pClause;
int32_t numOfClause; int32_t numOfClause;
} SSubclauseInfo; } SSubclauseInfo;
...@@ -184,26 +199,15 @@ typedef struct SSqlInfo { ...@@ -184,26 +199,15 @@ typedef struct SSqlInfo {
SSubclauseInfo subclauseInfo; SSubclauseInfo subclauseInfo;
char msg[256]; char msg[256];
union { union {
SCreateTableSQL *pCreateTableInfo; SCreateTableSql *pCreateTableInfo;
SAlterTableInfo *pAlterInfo; SAlterTableInfo *pAlterInfo;
SMiscInfo *pMiscInfo; SMiscInfo *pMiscInfo;
}; };
} SSqlInfo; } SSqlInfo;
#define NON_ARITHMEIC_EXPR 0 typedef struct tSqlExpr {
#define NORMAL_ARITHMETIC 1
#define AGG_ARIGHTMEIC 2
enum SQL_NODE_TYPE {
SQL_NODE_TABLE_COLUMN= 1,
SQL_NODE_SQLFUNCTION = 2,
SQL_NODE_VALUE = 3,
SQL_NODE_EXPR = 4,
};
typedef struct tSQLExpr {
uint16_t type; // sql node type uint16_t type; // sql node type
uint32_t tokenId; // TK_FUNCTION: sql function, TK_LE: less than(binary expr) uint32_t tokenId; // TK_LE: less than(binary expr)
// the whole string of the function(col, param), while the function name is kept in token // the whole string of the function(col, param), while the function name is kept in token
SStrToken operand; SStrToken operand;
...@@ -213,70 +217,49 @@ typedef struct tSQLExpr { ...@@ -213,70 +217,49 @@ typedef struct tSQLExpr {
tVariant value; // the use input value tVariant value; // the use input value
SStrToken token; // original sql expr string SStrToken token; // original sql expr string
struct tSQLExpr *pLeft; // left child struct tSqlExpr *pLeft; // left child
struct tSQLExpr *pRight; // right child struct tSqlExpr *pRight; // right child
struct tSQLExprList *pParam; // function parameters list struct SArray *pParam; // function parameters list
} tSQLExpr; } tSqlExpr;
// used in select clause. select <tSQLExprList> from xxx // used in select clause. select <SArray> from xxx
typedef struct tSqlExprItem { typedef struct tSqlExprItem {
tSQLExpr *pNode; // The list of expressions tSqlExpr *pNode; // The list of expressions
char * aliasName; // alias name, null-terminated string char *aliasName; // alias name, null-terminated string
bool distinct; bool distinct;
} 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 */
} tSQLExprList;
/**
*
* @param yyp The parser
* @param yymajor The major token code number
* @param yyminor The value for the token
*/
void Parse(void *yyp, int yymajor, ParseTOKENTYPE yyminor, SSqlInfo *);
/**
*
* @param p The parser to be deleted
* @param freeProc Function used to reclaim memory
*/
void ParseFree(void *p, void (*freeProc)(void *));
SArray *tVariantListAppend(SArray *pList, tVariant *pVar, uint8_t sortOrder); SArray *tVariantListAppend(SArray *pList, tVariant *pVar, uint8_t sortOrder);
SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int32_t index); SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int32_t index);
SArray *tVariantListAppendToken(SArray *pList, SStrToken *pAliasToken, uint8_t sortOrder); SArray *tVariantListAppendToken(SArray *pList, SStrToken *pAliasToken, uint8_t sortOrder);
tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType); // sql expr leaf node
tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType);
tSqlExpr *tSqlExprCreateFunction(SArray *pParam, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType);
tSQLExpr *tSqlExprClone(tSQLExpr *pSrc); tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType);
tSqlExpr *tSqlExprClone(tSqlExpr *pSrc);
void tSqlExprCompact(tSqlExpr** pExpr);
bool tSqlExprIsLeaf(tSqlExpr* pExpr);
bool tSqlExprIsParentOfLeaf(tSqlExpr* pExpr);
void tSqlExprDestroy(tSqlExpr *pExpr);
SArray *tSqlExprListAppend(SArray *pList, tSqlExpr *pNode, SStrToken *pDistinct, SStrToken *pToken);
void tSqlExprListDestroy(SArray *pList);
void tSqlExprDestroy(tSQLExpr *pExpr); SQuerySqlNode *tSetQuerySqlNode(SStrToken *pSelectToken, SArray *pSelectList, SArray *pFrom, tSqlExpr *pWhere,
SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval, SSessionWindowVal *ps,
SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit, SLimitVal *pgLimit);
tSQLExprList *tSqlExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken *pDistinct, SStrToken *pToken); SCreateTableSql *tSetCreateTableInfo(SArray *pCols, SArray *pTags, SQuerySqlNode *pSelect, int32_t type);
void tSqlExprListDestroy(tSQLExprList *pList); SAlterTableInfo *tSetAlterTableInfo(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, int16_t tableTable);
SQuerySQL *tSetQuerySqlNode(SStrToken *pSelectToken, tSQLExprList *pSelection, SArray *pFrom, tSQLExpr *pWhere,
SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval, SSessionWindowVal *pSession,
SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit, SLimitVal *pGLimit);
SCreateTableSQL *tSetCreateSqlElems(SArray *pCols, SArray *pTags, SQuerySQL *pSelect, int32_t type);
void tSqlExprNodeDestroy(tSQLExpr *pExpr);
SAlterTableInfo * tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, int16_t tableTable);
SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagNames, SArray *pTagVals, SStrToken *pToken, SStrToken* igExists); SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagNames, SArray *pTagVals, SStrToken *pToken, SStrToken* igExists);
void destroyAllSelectClause(SSubclauseInfo *pSql); void destroyAllSelectClause(SSubclauseInfo *pSql);
void doDestroyQuerySql(SQuerySQL *pSql); void destroyQuerySqlNode(SQuerySqlNode *pSql);
void freeCreateTableInfo(void* p); 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 *setSubclause(SSubclauseInfo *pClause, void *pSqlExprInfo);
SSubclauseInfo *appendSelectClause(SSubclauseInfo *pInfo, void *pSubclause); SSubclauseInfo *appendSelectClause(SSubclauseInfo *pInfo, void *pSubclause);
...@@ -285,7 +268,7 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken ...@@ -285,7 +268,7 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken
void SqlInfoDestroy(SSqlInfo *pInfo); void SqlInfoDestroy(SSqlInfo *pInfo);
void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParams, ...); void setDCLSqlElems(SSqlInfo *pInfo, int32_t type, int32_t nParams, ...);
void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck,int16_t dbType,int16_t tableType); void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck,int16_t dbType,int16_t tableType);
void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* pPatterns); void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* pPatterns);
...@@ -300,19 +283,39 @@ void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo); ...@@ -300,19 +283,39 @@ void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo);
void setDefaultCreateTopicOption(SCreateDbInfo *pDBInfo); void setDefaultCreateTopicOption(SCreateDbInfo *pDBInfo);
// prefix show db.tables; // prefix show db.tables;
void setDbName(SStrToken *pCpxName, SStrToken *pDb); void tSetDbName(SStrToken *pCpxName, SStrToken *pDb);
tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType); void tSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType);
void tSetColumnType(TAOS_FIELD *pField, SStrToken *type);
tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType); /**
*
void tSqlSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType); * @param yyp The parser
* @param yymajor The major token code number
* @param yyminor The value for the token
*/
void Parse(void *yyp, int yymajor, ParseTOKENTYPE yyminor, SSqlInfo *);
void tSqlSetColumnType(TAOS_FIELD *pField, SStrToken *type); /**
*
* @param p The parser to be deleted
* @param freeProc Function used to reclaim memory
*/
void ParseFree(void *p, void (*freeProc)(void *));
/**
*
* @param mallocProc The parser allocator
* @return
*/
void *ParseAlloc(void *(*mallocProc)(size_t)); void *ParseAlloc(void *(*mallocProc)(size_t));
SSqlInfo qSQLParse(const char *str); /**
*
* @param str sql string
* @return sql ast
*/
SSqlInfo qSqlParse(const char *str);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -476,18 +476,37 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes ...@@ -476,18 +476,37 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes
return getResultRow(pResultRowInfo, pResultRowInfo->curIndex); return getResultRow(pResultRowInfo, pResultRowInfo->curIndex);
} }
static void getInitialStartTimeWindow(SQuery* pQuery, TSKEY ts, STimeWindow* w) {
if (QUERY_IS_ASC_QUERY(pQuery)) {
getAlignQueryTimeWindow(pQuery, ts, ts, pQuery->window.ekey, w);
} else {
// the start position of the first time window in the endpoint that spreads beyond the queried last timestamp
getAlignQueryTimeWindow(pQuery, ts, pQuery->window.ekey, ts, w);
int64_t key = w->skey;
while(key < ts) { // moving towards end
if (pQuery->interval.intervalUnit == 'n' || pQuery->interval.intervalUnit == 'y') {
key = taosTimeAdd(key, pQuery->interval.sliding, pQuery->interval.slidingUnit, pQuery->precision);
} else {
key += pQuery->interval.sliding;
}
if (key >= ts) {
break;
}
w->skey = key;
}
}
}
// get the correct time window according to the handled timestamp // get the correct time window according to the handled timestamp
static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t ts, SQuery *pQuery) { static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t ts, SQuery *pQuery) {
STimeWindow w = {0}; STimeWindow w = {0};
if (pResultRowInfo->curIndex == -1) { // the first window, from the previous stored value if (pResultRowInfo->curIndex == -1) { // the first window, from the previous stored value
if (pResultRowInfo->prevSKey == TSKEY_INITIAL_VAL) { if (pResultRowInfo->prevSKey == TSKEY_INITIAL_VAL) {
if (QUERY_IS_ASC_QUERY(pQuery)) { getInitialStartTimeWindow(pQuery, ts, &w);
getAlignQueryTimeWindow(pQuery, ts, ts, pQuery->window.ekey, &w);
} else { // the start position of the first time window in the endpoint that spreads beyond the queried last timestamp
getAlignQueryTimeWindow(pQuery, ts, pQuery->window.ekey, ts, &w);
}
pResultRowInfo->prevSKey = w.skey; pResultRowInfo->prevSKey = w.skey;
} else { } else {
w.skey = pResultRowInfo->prevSKey; w.skey = pResultRowInfo->prevSKey;
...@@ -4564,7 +4583,7 @@ static SSDataBlock* doOffset(void* param) { ...@@ -4564,7 +4583,7 @@ static SSDataBlock* doOffset(void* param) {
if (pRuntimeEnv->currentOffset == 0) { if (pRuntimeEnv->currentOffset == 0) {
return pBlock; return pBlock;
} else if (pRuntimeEnv->currentOffset > pBlock->info.rows) { } else if (pRuntimeEnv->currentOffset >= pBlock->info.rows) {
pRuntimeEnv->currentOffset -= pBlock->info.rows; pRuntimeEnv->currentOffset -= pBlock->info.rows;
} else { } else {
int32_t remain = (int32_t)(pBlock->info.rows - pRuntimeEnv->currentOffset); int32_t remain = (int32_t)(pBlock->info.rows - pRuntimeEnv->currentOffset);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "ttokendef.h" #include "ttokendef.h"
#include "tutil.h" #include "tutil.h"
SSqlInfo qSQLParse(const char *pStr) { SSqlInfo qSqlParse(const char *pStr) {
void *pParser = ParseAlloc(malloc); void *pParser = ParseAlloc(malloc);
SSqlInfo sqlInfo = {0}; SSqlInfo sqlInfo = {0};
...@@ -80,53 +80,48 @@ abort_parse: ...@@ -80,53 +80,48 @@ abort_parse:
return sqlInfo; return sqlInfo;
} }
tSQLExprList *tSqlExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken *pDistinct, SStrToken *pToken) { SArray *tSqlExprListAppend(SArray *pList, tSqlExpr *pNode, SStrToken *pDistinct, SStrToken *pToken) {
if (pList == NULL) { if (pList == NULL) {
pList = calloc(1, sizeof(tSQLExprList)); pList = taosArrayInit(4, sizeof(tSqlExprItem));
} }
if (pList->nAlloc <= pList->nExpr) {
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;
return pList;
}
}
assert(pList->a != 0);
if (pNode || pToken) { if (pNode || pToken) {
struct tSqlExprItem *pItem = &pList->a[pList->nExpr++]; struct tSqlExprItem item = {0};
memset(pItem, 0, sizeof(*pItem));
pItem->pNode = pNode; item.pNode = pNode;
item.distinct = (pDistinct != NULL);
if (pToken) { // set the as clause if (pToken) { // set the as clause
pItem->aliasName = malloc(pToken->n + 1); item.aliasName = malloc(pToken->n + 1);
strncpy(pItem->aliasName, pToken->z, pToken->n); strncpy(item.aliasName, pToken->z, pToken->n);
pItem->aliasName[pToken->n] = 0; item.aliasName[pToken->n] = 0;
strdequote(pItem->aliasName); strdequote(item.aliasName);
} }
pItem->distinct = (pDistinct != NULL);
taosArrayPush(pList, &item);
} }
return pList; return pList;
} }
void tSqlExprListDestroy(tSQLExprList *pList) { static void freeExprElem(void* item) {
if (pList == NULL) return; tSqlExprItem* exprItem = item;
for (int32_t i = 0; i < pList->nExpr; ++i) { tfree(exprItem->aliasName);
if (pList->a[i].aliasName != NULL) { tSqlExprDestroy(exprItem->pNode);
free(pList->a[i].aliasName); }
}
tSqlExprDestroy(pList->a[i].pNode); void tSqlExprListDestroy(SArray *pList) {
if (pList == NULL) {
return;
} }
free(pList->a); taosArrayDestroyEx(pList, freeExprElem);
free(pList);
} }
tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType) { tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) {
tSQLExpr *pSqlExpr = calloc(1, sizeof(tSQLExpr)); tSqlExpr *pSqlExpr = calloc(1, sizeof(tSqlExpr));
if (pToken != NULL) { if (pToken != NULL) {
pSqlExpr->token = *pToken; pSqlExpr->token = *pToken;
...@@ -171,15 +166,15 @@ tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType) { ...@@ -171,15 +166,15 @@ tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType) {
* pList is the parameters for function with id(optType) * pList is the parameters for function with id(optType)
* function name is denoted by pFunctionToken * function name is denoted by pFunctionToken
*/ */
tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType) { tSqlExpr *tSqlExprCreateFunction(SArray *pParam, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType) {
if (pFuncToken == NULL) { if (pFuncToken == NULL) {
return NULL; return NULL;
} }
tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr)); tSqlExpr *pExpr = calloc(1, sizeof(tSqlExpr));
pExpr->tokenId = optType; pExpr->tokenId = optType;
pExpr->type = SQL_NODE_SQLFUNCTION; pExpr->type = SQL_NODE_SQLFUNCTION;
pExpr->pParam = pList; pExpr->pParam = pParam;
int32_t len = (int32_t)((endToken->z + endToken->n) - pFuncToken->z); int32_t len = (int32_t)((endToken->z + endToken->n) - pFuncToken->z);
pExpr->operand = (*pFuncToken); pExpr->operand = (*pFuncToken);
...@@ -193,10 +188,10 @@ tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SSt ...@@ -193,10 +188,10 @@ tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SSt
/* /*
* create binary expression in this procedure * create binary expression in this procedure
* if the expr is arithmetic, calculate the result and set it to tSQLExpr Object * 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)); tSqlExpr *pExpr = calloc(1, sizeof(tSqlExpr));
pExpr->type = SQL_NODE_EXPR; pExpr->type = SQL_NODE_EXPR;
if (pLeft != NULL && pRight != NULL && (optrType != TK_IN)) { if (pLeft != NULL && pRight != NULL && (optrType != TK_IN)) {
...@@ -291,9 +286,9 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) { ...@@ -291,9 +286,9 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
pExpr->tokenId = optrType; pExpr->tokenId = optrType;
pExpr->pLeft = pLeft; pExpr->pLeft = pLeft;
tSQLExpr *pRSub = calloc(1, sizeof(tSQLExpr)); tSqlExpr *pRSub = calloc(1, sizeof(tSqlExpr));
pRSub->tokenId = TK_SET; // TODO refactor ..... pRSub->tokenId = TK_SET; // TODO refactor .....
pRSub->pParam = (tSQLExprList *)pRight; pRSub->pParam = (SArray *)pRight;
pExpr->pRight = pRSub; pExpr->pRight = pRSub;
} else { } else {
...@@ -301,7 +296,7 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) { ...@@ -301,7 +296,7 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
pExpr->pLeft = pLeft; pExpr->pLeft = pLeft;
if (pLeft != NULL && pRight == NULL) { if (pLeft != NULL && pRight == NULL) {
pRight = calloc(1, sizeof(tSQLExpr)); pRight = calloc(1, sizeof(tSqlExpr));
} }
pExpr->pRight = pRight; pExpr->pRight = pRight;
...@@ -310,10 +305,8 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) { ...@@ -310,10 +305,8 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
return pExpr; return pExpr;
} }
tSqlExpr *tSqlExprClone(tSqlExpr *pSrc) {
tSqlExpr *pExpr = calloc(1, sizeof(tSqlExpr));
tSQLExpr *tSqlExprClone(tSQLExpr *pSrc) {
tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr));
memcpy(pExpr, pSrc, sizeof(*pSrc)); memcpy(pExpr, pSrc, sizeof(*pSrc));
...@@ -327,12 +320,51 @@ tSQLExpr *tSqlExprClone(tSQLExpr *pSrc) { ...@@ -327,12 +320,51 @@ tSQLExpr *tSqlExprClone(tSQLExpr *pSrc) {
//we don't clone pParam now because clone is only used for between/and //we don't clone pParam now because clone is only used for between/and
assert(pSrc->pParam == NULL); assert(pSrc->pParam == NULL);
return pExpr; return pExpr;
} }
void tSqlExprCompact(tSqlExpr** pExpr) {
if (*pExpr == NULL || tSqlExprIsParentOfLeaf(*pExpr)) {
return;
}
if ((*pExpr)->pLeft) {
tSqlExprCompact(&(*pExpr)->pLeft);
}
if ((*pExpr)->pRight) {
tSqlExprCompact(&(*pExpr)->pRight);
}
if ((*pExpr)->pLeft == NULL && (*pExpr)->pRight == NULL && ((*pExpr)->tokenId == TK_OR || (*pExpr)->tokenId == TK_AND)) {
tSqlExprDestroy(*pExpr);
*pExpr = NULL;
} else if ((*pExpr)->pLeft == NULL && (*pExpr)->pRight != NULL) {
tSqlExpr* tmpPtr = (*pExpr)->pRight;
(*pExpr)->pRight = NULL;
tSqlExprDestroy(*pExpr);
(*pExpr) = tmpPtr;
} else if ((*pExpr)->pRight == NULL && (*pExpr)->pLeft != NULL) {
tSqlExpr* tmpPtr = (*pExpr)->pLeft;
(*pExpr)->pLeft = NULL;
tSqlExprDestroy(*pExpr);
(*pExpr) = tmpPtr;
}
}
bool tSqlExprIsLeaf(tSqlExpr* pExpr) {
return (pExpr->pRight == NULL && pExpr->pLeft == NULL) &&
(pExpr->tokenId == 0 || pExpr->tokenId == TK_ID || (pExpr->tokenId >= TK_BOOL && pExpr->tokenId <= TK_NCHAR) || pExpr->tokenId == TK_SET);
}
bool tSqlExprIsParentOfLeaf(tSqlExpr* pExpr) {
return (pExpr->pLeft != NULL && pExpr->pRight != NULL) &&
(tSqlExprIsLeaf(pExpr->pLeft) && tSqlExprIsLeaf(pExpr->pRight));
}
void tSqlExprNodeDestroy(tSQLExpr *pExpr) { static void doDestroySqlExprNode(tSqlExpr *pExpr) {
if (pExpr == NULL) { if (pExpr == NULL) {
return; return;
} }
...@@ -342,11 +374,10 @@ void tSqlExprNodeDestroy(tSQLExpr *pExpr) { ...@@ -342,11 +374,10 @@ void tSqlExprNodeDestroy(tSQLExpr *pExpr) {
} }
tSqlExprListDestroy(pExpr->pParam); tSqlExprListDestroy(pExpr->pParam);
free(pExpr); free(pExpr);
} }
void tSqlExprDestroy(tSQLExpr *pExpr) { void tSqlExprDestroy(tSqlExpr *pExpr) {
if (pExpr == NULL) { if (pExpr == NULL) {
return; return;
} }
...@@ -355,7 +386,8 @@ void tSqlExprDestroy(tSQLExpr *pExpr) { ...@@ -355,7 +386,8 @@ void tSqlExprDestroy(tSQLExpr *pExpr) {
pExpr->pLeft = NULL; pExpr->pLeft = NULL;
tSqlExprDestroy(pExpr->pRight); tSqlExprDestroy(pExpr->pRight);
pExpr->pRight = NULL; pExpr->pRight = NULL;
tSqlExprNodeDestroy(pExpr);
doDestroySqlExprNode(pExpr);
} }
SArray *tVariantListAppendToken(SArray *pList, SStrToken *pToken, uint8_t order) { SArray *tVariantListAppendToken(SArray *pList, SStrToken *pToken, uint8_t order) {
...@@ -411,13 +443,13 @@ SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int ...@@ -411,13 +443,13 @@ SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int
return pList; return pList;
} }
void setDbName(SStrToken *pCpxName, SStrToken *pDb) { void tSetDbName(SStrToken *pCpxName, SStrToken *pDb) {
pCpxName->type = pDb->type; pCpxName->type = pDb->type;
pCpxName->z = pDb->z; pCpxName->z = pDb->z;
pCpxName->n = pDb->n; pCpxName->n = pDb->n;
} }
void tSqlSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType) { void tSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType) {
int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]); int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]);
// truncate the column name // truncate the column name
...@@ -485,7 +517,7 @@ static int32_t tryParseNameTwoParts(SStrToken *type) { ...@@ -485,7 +517,7 @@ static int32_t tryParseNameTwoParts(SStrToken *type) {
} }
} }
void tSqlSetColumnType(TAOS_FIELD *pField, SStrToken *type) { void tSetColumnType(TAOS_FIELD *pField, SStrToken *type) {
// set the field type invalid // set the field type invalid
pField->type = -1; pField->type = -1;
pField->name[0] = 0; pField->name[0] = 0;
...@@ -550,43 +582,59 @@ void tSqlSetColumnType(TAOS_FIELD *pField, SStrToken *type) { ...@@ -550,43 +582,59 @@ void tSqlSetColumnType(TAOS_FIELD *pField, SStrToken *type) {
/* /*
* extract the select info out of sql string * extract the select info out of sql string
*/ */
SQuerySQL *tSetQuerySqlNode(SStrToken *pSelectToken, tSQLExprList *pSelection, SArray *pFrom, tSQLExpr *pWhere, SQuerySqlNode *tSetQuerySqlNode(SStrToken *pSelectToken, SArray *pSelectList, SArray *pFrom, tSqlExpr *pWhere,
SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval, SSessionWindowVal *pSession, SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval, SSessionWindowVal *pSession,
SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) { SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit, SLimitVal *psLimit) {
assert(pSelection != NULL); assert(pSelectList != NULL);
SQuerySqlNode *pSqlNode = calloc(1, sizeof(SQuerySqlNode));
SQuerySQL *pQuery = calloc(1, sizeof(SQuerySQL)); // all later sql string are belonged to the stream sql
pQuery->selectToken = *pSelectToken; pSqlNode->sqlstr = *pSelectToken;
pQuery->selectToken.n = (uint32_t)strlen(pQuery->selectToken.z); // all later sql string are belonged to the stream sql pSqlNode->sqlstr.n = (uint32_t)strlen(pSqlNode->sqlstr.z);
pQuery->pSelection = pSelection; pSqlNode->pSelectList = pSelectList;
pQuery->from = pFrom; pSqlNode->from = pFrom;
pQuery->pGroupby = pGroupby; pSqlNode->pGroupby = pGroupby;
pQuery->pSortOrder = pSortOrder; pSqlNode->pSortOrder = pSortOrder;
pQuery->pWhere = pWhere; pSqlNode->pWhere = pWhere;
pSqlNode->fillType = pFill;
if (pLimit != NULL) { if (pLimit != NULL) {
pQuery->limit = *pLimit; pSqlNode->limit = *pLimit;
} else {
pSqlNode->limit.limit = -1;
pSqlNode->limit.offset = 0;
} }
if (pGLimit != NULL) { if (psLimit != NULL) {
pQuery->slimit = *pGLimit; pSqlNode->slimit = *psLimit;
} else {
pSqlNode->slimit.limit = -1;
pSqlNode->slimit.offset = 0;
} }
if (pInterval != NULL) { if (pInterval != NULL) {
pQuery->interval = *pInterval; pSqlNode->interval = *pInterval;
} else {
TPARSER_SET_NONE_TOKEN(pSqlNode->interval.interval);
TPARSER_SET_NONE_TOKEN(pSqlNode->interval.offset);
} }
if (pSliding != NULL) { if (pSliding != NULL) {
pQuery->sliding = *pSliding; pSqlNode->sliding = *pSliding;
} else {
TPARSER_SET_NONE_TOKEN(pSqlNode->sliding);
} }
if (pSession != NULL) { if (pSession != NULL) {
pQuery->sessionVal = *pSession; pSqlNode->sessionVal = *pSession;
} else {
TPARSER_SET_NONE_TOKEN(pSqlNode->sessionVal.gap);
TPARSER_SET_NONE_TOKEN(pSqlNode->sessionVal.col);
} }
pQuery->fillType = pFill; return pSqlNode;
return pQuery;
} }
static void freeVariant(void *pItem) { static void freeVariant(void *pItem) {
...@@ -602,14 +650,14 @@ void freeCreateTableInfo(void* p) { ...@@ -602,14 +650,14 @@ void freeCreateTableInfo(void* p) {
tfree(pInfo->tagdata.data); tfree(pInfo->tagdata.data);
} }
void doDestroyQuerySql(SQuerySQL *pQuerySql) { void destroyQuerySqlNode(SQuerySqlNode *pQuerySql) {
if (pQuerySql == NULL) { if (pQuerySql == NULL) {
return; return;
} }
tSqlExprListDestroy(pQuerySql->pSelection); tSqlExprListDestroy(pQuerySql->pSelectList);
pQuerySql->pSelection = NULL; pQuerySql->pSelectList = NULL;
tSqlExprDestroy(pQuerySql->pWhere); tSqlExprDestroy(pQuerySql->pWhere);
pQuerySql->pWhere = NULL; pQuerySql->pWhere = NULL;
...@@ -635,15 +683,15 @@ void destroyAllSelectClause(SSubclauseInfo *pClause) { ...@@ -635,15 +683,15 @@ void destroyAllSelectClause(SSubclauseInfo *pClause) {
} }
for(int32_t i = 0; i < pClause->numOfClause; ++i) { for(int32_t i = 0; i < pClause->numOfClause; ++i) {
SQuerySQL *pQuerySql = pClause->pClause[i]; SQuerySqlNode *pQuerySql = pClause->pClause[i];
doDestroyQuerySql(pQuerySql); destroyQuerySqlNode(pQuerySql);
} }
tfree(pClause->pClause); tfree(pClause->pClause);
} }
SCreateTableSQL *tSetCreateSqlElems(SArray *pCols, SArray *pTags, SQuerySQL *pSelect, int32_t type) { SCreateTableSql *tSetCreateTableInfo(SArray *pCols, SArray *pTags, SQuerySqlNode *pSelect, int32_t type) {
SCreateTableSQL *pCreate = calloc(1, sizeof(SCreateTableSQL)); SCreateTableSql *pCreate = calloc(1, sizeof(SCreateTableSql));
switch (type) { switch (type) {
case TSQL_CREATE_TABLE: { case TSQL_CREATE_TABLE: {
...@@ -687,7 +735,7 @@ SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagNam ...@@ -687,7 +735,7 @@ SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagNam
return info; return info;
} }
SAlterTableInfo *tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, int16_t tableType) { SAlterTableInfo *tSetAlterTableInfo(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, int16_t tableType) {
SAlterTableInfo *pAlterTable = calloc(1, sizeof(SAlterTableInfo)); SAlterTableInfo *pAlterTable = calloc(1, sizeof(SAlterTableInfo));
pAlterTable->name = *pTableName; pAlterTable->name = *pTableName;
...@@ -709,8 +757,8 @@ SAlterTableInfo *tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArra ...@@ -709,8 +757,8 @@ SAlterTableInfo *tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArra
return pAlterTable; return pAlterTable;
} }
void* destroyCreateTableSql(SCreateTableSQL* pCreate) { void* destroyCreateTableSql(SCreateTableSql* pCreate) {
doDestroyQuerySql(pCreate->pSelect); destroyQuerySqlNode(pCreate->pSelect);
taosArrayDestroy(pCreate->colInfo.pColumns); taosArrayDestroy(pCreate->colInfo.pColumns);
taosArrayDestroy(pCreate->colInfo.pTagColumns); taosArrayDestroy(pCreate->colInfo.pTagColumns);
...@@ -757,7 +805,7 @@ SSubclauseInfo* setSubclause(SSubclauseInfo* pSubclause, void *pSqlExprInfo) { ...@@ -757,7 +805,7 @@ SSubclauseInfo* setSubclause(SSubclauseInfo* pSubclause, void *pSqlExprInfo) {
return pSubclause; return pSubclause;
} }
pSubclause->pClause = (SQuerySQL**) tmp; pSubclause->pClause = (SQuerySqlNode**) tmp;
pSubclause->pClause[newSize - 1] = pSqlExprInfo; pSubclause->pClause[newSize - 1] = pSqlExprInfo;
pSubclause->numOfClause++; pSubclause->numOfClause++;
...@@ -765,7 +813,7 @@ SSubclauseInfo* setSubclause(SSubclauseInfo* pSubclause, void *pSqlExprInfo) { ...@@ -765,7 +813,7 @@ SSubclauseInfo* setSubclause(SSubclauseInfo* pSubclause, void *pSqlExprInfo) {
return pSubclause; 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; pInfo->type = type;
if (type == TSDB_SQL_SELECT) { if (type == TSDB_SQL_SELECT) {
...@@ -788,7 +836,7 @@ SSubclauseInfo* appendSelectClause(SSubclauseInfo *pQueryInfo, void *pSubclause) ...@@ -788,7 +836,7 @@ SSubclauseInfo* appendSelectClause(SSubclauseInfo *pQueryInfo, void *pSubclause)
return pQueryInfo; return pQueryInfo;
} }
pQueryInfo->pClause = (SQuerySQL**) tmp; pQueryInfo->pClause = (SQuerySqlNode**) tmp;
pQueryInfo->pClause[pQueryInfo->numOfClause++] = pSubclause; pQueryInfo->pClause[pQueryInfo->numOfClause++] = pSubclause;
return pQueryInfo; return pQueryInfo;
...@@ -799,7 +847,7 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken ...@@ -799,7 +847,7 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken
pInfo->pCreateTableInfo->existCheck = (pIfNotExists->n != 0); pInfo->pCreateTableInfo->existCheck = (pIfNotExists->n != 0);
} }
void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) { void setDCLSqlElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
pInfo->type = type; pInfo->type = type;
if (nParam == 0) { if (nParam == 0) {
return; return;
......
此差异已折叠。
...@@ -469,11 +469,12 @@ if $data25 != 33 then ...@@ -469,11 +469,12 @@ if $data25 != 33 then
endi endi
sql select count(*),stddev(c1),count(c1),first(c2),last(c3) from sliding_tb0 where ts>'2000-1-1 00:00:00' and ts<'2000-1-1 00:00:01.002' and c2 >= 0 interval(30s) sliding(10s) order by ts desc limit 1000; sql select count(*),stddev(c1),count(c1),first(c2),last(c3) from sliding_tb0 where ts>'2000-1-1 00:00:00' and ts<'2000-1-1 00:00:01.002' and c2 >= 0 interval(30s) sliding(10s) order by ts desc limit 1000;
if $row != 1 then if $row != 3 then
return -1 return -1
endi endi
if $data00 != @99-12-31 23:59:40.000@ then if $data00 != @00-01-01 00:00:00.000@ then
print expect 00-01-01 00:00:00.000, actual: $data00
return -1 return -1
endi endi
...@@ -489,7 +490,28 @@ if $data03 != 33 then ...@@ -489,7 +490,28 @@ if $data03 != 33 then
return -1 return -1
endi endi
print check boundary check crash at client side if $data10 != @99-12-31 23:59:50.000@ then
return -1
endi
if $data11 != 33 then
return -1
endi
if $data12 != 9.521904571 then
return -1
endi
if $data20 != @99-12-31 23:59:40.000@ then
return -1
endi
if $data21 != 33 then
return -1
endi
if $data22 != 9.521904571 then
return -1
endi
print ====================>check boundary check crash at client side
sql select count(*) from sliding_mt0 where ts>now and ts < now-1h; sql select count(*) from sliding_mt0 where ts>now and ts < now-1h;
print ========================query on super table print ========================query on super table
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册