Merge branch 'develop' into hotfix/test
This commit is contained in:
commit
d605dcfc3a
|
@ -320,6 +320,8 @@ typedef struct SSqlStream {
|
|||
SSqlObj *pSql;
|
||||
uint32_t streamId;
|
||||
char listed;
|
||||
bool isProject;
|
||||
int16_t precision;
|
||||
int64_t num; // number of computing count
|
||||
|
||||
/*
|
||||
|
@ -334,7 +336,6 @@ typedef struct SSqlStream {
|
|||
int64_t etime; // stream end query time, when time is larger then etime, the stream will be closed
|
||||
int64_t interval;
|
||||
int64_t slidingTime;
|
||||
int16_t precision;
|
||||
void * pTimer;
|
||||
|
||||
void (*fp)();
|
||||
|
|
|
@ -406,7 +406,7 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
|
|||
pSql->res.qhandle = 0x1;
|
||||
pSql->res.numOfRows = 0;
|
||||
} else if (pCmd->command == TSDB_SQL_RESET_CACHE) {
|
||||
taosCacheEmpty(tscCacheHandle,false);
|
||||
taosCacheEmpty(tscCacheHandle);
|
||||
} else if (pCmd->command == TSDB_SQL_SERV_VERSION) {
|
||||
tscProcessServerVer(pSql);
|
||||
} else if (pCmd->command == TSDB_SQL_CLI_VERSION) {
|
||||
|
|
|
@ -660,11 +660,14 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ
|
|||
int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
|
||||
const char* msg0 = "sliding value too small";
|
||||
const char* msg1 = "sliding value no larger than the interval value";
|
||||
const char* msg2 = "sliding value can not less than 1% of interval value";
|
||||
|
||||
const static int32_t INTERVAL_SLIDING_FACTOR = 100;
|
||||
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
SSQLToken* pSliding = &pQuerySql->sliding;
|
||||
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
|
||||
|
||||
SSQLToken* pSliding = &pQuerySql->sliding;
|
||||
if (pSliding->n != 0) {
|
||||
getTimestampInUsFromStr(pSliding->z, pSliding->n, &pQueryInfo->slidingTime);
|
||||
if (tinfo.precision == TSDB_TIME_PRECISION_MILLI) {
|
||||
|
@ -682,6 +685,10 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
|
|||
pQueryInfo->slidingTime = pQueryInfo->intervalTime;
|
||||
}
|
||||
|
||||
if ((pQueryInfo->intervalTime != 0) && (pQueryInfo->intervalTime/pQueryInfo->slidingTime > INTERVAL_SLIDING_FACTOR)) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -6120,16 +6127,12 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// NOTE: binary|nchar data allows the >|< type filter
|
||||
if ((*pExpr)->_node.optr != TSDB_RELATION_EQUAL && (*pExpr)->_node.optr != TSDB_RELATION_NOT_EQUAL) {
|
||||
if (pRight->nodeType == TSQL_NODE_VALUE) {
|
||||
if (pRight->pVal->nType == TSDB_DATA_TYPE_BOOL) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
if ((pRight->pVal->nType == TSDB_DATA_TYPE_BINARY || pRight->pVal->nType == TSDB_DATA_TYPE_NCHAR)
|
||||
&& (*pExpr)->_node.optr != TSDB_RELATION_LIKE) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1956,7 +1956,7 @@ int tscProcessUseDbRsp(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
int tscProcessDropDbRsp(SSqlObj *UNUSED_PARAM(pSql)) {
|
||||
taosCacheEmpty(tscCacheHandle, false);
|
||||
taosCacheEmpty(tscCacheHandle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2002,7 +2002,7 @@ int tscProcessAlterTableMsgRsp(SSqlObj *pSql) {
|
|||
|
||||
if (isSuperTable) { // if it is a super table, reset whole query cache
|
||||
tscDebug("%p reset query cache since table:%s is stable", pSql, pTableMetaInfo->name);
|
||||
taosCacheEmpty(tscCacheHandle, false);
|
||||
taosCacheEmpty(tscCacheHandle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
|
|||
|
||||
pSql->fp = tscProcessStreamQueryCallback;
|
||||
pSql->param = pStream;
|
||||
pSql->res.completed = false;
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
@ -86,7 +87,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
|
|||
// failed to get meter/metric meta, retry in 10sec.
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
int64_t retryDelayTime = tscGetRetryDelayTime(pStream->slidingTime, pStream->precision);
|
||||
tscError("%p stream:%p,get metermeta failed, retry in %" PRId64 "ms", pStream->pSql, pStream, retryDelayTime);
|
||||
tscDebug("%p stream:%p,get metermeta failed, retry in %" PRId64 "ms", pStream->pSql, pStream, retryDelayTime);
|
||||
tscSetRetryTimer(pStream, pSql, retryDelayTime);
|
||||
|
||||
} else {
|
||||
|
@ -108,7 +109,7 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
|
|||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
tscDebug("%p add into timer", pSql);
|
||||
|
||||
if (isProjectStream(pQueryInfo)) {
|
||||
if (pStream->isProject) {
|
||||
/*
|
||||
* pQueryInfo->window.ekey, which is the start time, does not change in case of
|
||||
* repeat first execution, once the first execution failed.
|
||||
|
@ -121,7 +122,19 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
|
|||
}
|
||||
} else {
|
||||
pQueryInfo->window.skey = pStream->stime - pStream->interval;
|
||||
pQueryInfo->window.ekey = pStream->stime - 1;
|
||||
int64_t etime = taosGetTimestamp(pStream->precision);
|
||||
// delay to wait all data in last time window
|
||||
if (pStream->precision == TSDB_TIME_PRECISION_MICRO) {
|
||||
etime -= tsMaxStreamComputDelay * 1000l;
|
||||
} else {
|
||||
etime -= tsMaxStreamComputDelay;
|
||||
}
|
||||
if (etime > pStream->etime) {
|
||||
etime = pStream->etime;
|
||||
} else {
|
||||
etime = pStream->stime + (etime - pStream->stime) / pStream->interval * pStream->interval;
|
||||
}
|
||||
pQueryInfo->window.ekey = etime;
|
||||
}
|
||||
|
||||
// launch stream computing in a new thread
|
||||
|
@ -137,7 +150,7 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf
|
|||
SSqlStream *pStream = (SSqlStream *)param;
|
||||
if (tres == NULL || numOfRows < 0) {
|
||||
int64_t retryDelay = tscGetRetryDelayTime(pStream->slidingTime, pStream->precision);
|
||||
tscError("%p stream:%p, query data failed, code:%d, retry in %" PRId64 "ms", pStream->pSql, pStream, numOfRows,
|
||||
tscError("%p stream:%p, query data failed, code:0x%08x, retry in %" PRId64 "ms", pStream->pSql, pStream, numOfRows,
|
||||
retryDelay);
|
||||
|
||||
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pStream->pSql->cmd, 0, 0);
|
||||
|
@ -151,17 +164,45 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf
|
|||
taos_fetch_rows_a(tres, tscProcessStreamRetrieveResult, param);
|
||||
}
|
||||
|
||||
static void tscSetTimestampForRes(SSqlStream *pStream, SSqlObj *pSql) {
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
int64_t timestamp = *(int64_t *)pRes->data;
|
||||
int64_t actualTimestamp = pStream->stime - pStream->interval;
|
||||
|
||||
if (timestamp != actualTimestamp) {
|
||||
// reset the timestamp of each agg point by using start time of each interval
|
||||
*((int64_t *)pRes->data) = actualTimestamp;
|
||||
tscWarn("%p stream:%p, timestamp of points is:%" PRId64 ", reset to %" PRId64, pSql, pStream, timestamp, actualTimestamp);
|
||||
// no need to be called as this is alreay done in the query
|
||||
static void tscStreamFillTimeGap(SSqlStream* pStream, TSKEY ts) {
|
||||
#if 0
|
||||
SSqlObj * pSql = pStream->pSql;
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
|
||||
if (pQueryInfo->fillType != TSDB_FILL_SET_VALUE && pQueryInfo->fillType != TSDB_FILL_NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
/* failed to retrieve any result in this retrieve */
|
||||
pSql->res.numOfRows = 1;
|
||||
void *row[TSDB_MAX_COLUMNS] = {0};
|
||||
char tmpRes[TSDB_MAX_BYTES_PER_ROW] = {0};
|
||||
void *oldPtr = pSql->res.data;
|
||||
pSql->res.data = tmpRes;
|
||||
int32_t rowNum = 0;
|
||||
|
||||
while (pStream->stime + pStream->slidingTime < ts) {
|
||||
pStream->stime += pStream->slidingTime;
|
||||
*(TSKEY*)row[0] = pStream->stime;
|
||||
for (int32_t i = 1; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||
int16_t offset = tscFieldInfoGetOffset(pQueryInfo, i);
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
|
||||
assignVal(pSql->res.data + offset, (char *)(&pQueryInfo->fillVal[i]), pField->bytes, pField->type);
|
||||
row[i] = pSql->res.data + offset;
|
||||
}
|
||||
(*pStream->fp)(pStream->param, pSql, row);
|
||||
++rowNum;
|
||||
}
|
||||
|
||||
if (rowNum > 0) {
|
||||
tscDebug("%p stream:%p %d rows padded", pSql, pStream, rowNum);
|
||||
}
|
||||
|
||||
pRes->numOfRows = 0;
|
||||
pRes->data = oldPtr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOfRows) {
|
||||
|
@ -170,7 +211,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
|
|||
|
||||
if (pSql == NULL || numOfRows < 0) {
|
||||
int64_t retryDelayTime = tscGetRetryDelayTime(pStream->slidingTime, pStream->precision);
|
||||
tscError("%p stream:%p, retrieve data failed, code:%d, retry in %" PRId64 "ms", pSql, pStream, numOfRows, retryDelayTime);
|
||||
tscError("%p stream:%p, retrieve data failed, code:0x%08x, retry in %" PRId64 "ms", pSql, pStream, numOfRows, retryDelayTime);
|
||||
|
||||
tscSetRetryTimer(pStream, pStream->pSql, retryDelayTime);
|
||||
return;
|
||||
|
@ -180,16 +221,11 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
|
|||
|
||||
if (numOfRows > 0) { // when reaching here the first execution of stream computing is successful.
|
||||
pStream->numOfRes += numOfRows;
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
|
||||
for(int32_t i = 0; i < numOfRows; ++i) {
|
||||
TAOS_ROW row = taos_fetch_row(res);
|
||||
tscDebug("%p stream:%p fetch result", pSql, pStream);
|
||||
if (isProjectStream(pQueryInfo)) {
|
||||
pStream->stime = *(TSKEY *)row[0];
|
||||
} else {
|
||||
tscSetTimestampForRes(pStream, pSql);
|
||||
}
|
||||
tscStreamFillTimeGap(pStream, *(TSKEY*)row[0]);
|
||||
pStream->stime = *(TSKEY *)row[0];
|
||||
|
||||
// user callback function
|
||||
(*pStream->fp)(pStream->param, res, row);
|
||||
|
@ -199,55 +235,18 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
|
|||
taos_fetch_rows_a(res, tscProcessStreamRetrieveResult, pStream);
|
||||
} else { // numOfRows == 0, all data has been retrieved
|
||||
pStream->useconds += pSql->res.useconds;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
|
||||
if (pStream->numOfRes == 0) {
|
||||
if (pQueryInfo->fillType == TSDB_FILL_SET_VALUE || pQueryInfo->fillType == TSDB_FILL_NULL) {
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
/* failed to retrieve any result in this retrieve */
|
||||
pSql->res.numOfRows = 1;
|
||||
void *row[TSDB_MAX_COLUMNS] = {0};
|
||||
char tmpRes[TSDB_MAX_BYTES_PER_ROW] = {0};
|
||||
|
||||
void *oldPtr = pSql->res.data;
|
||||
pSql->res.data = tmpRes;
|
||||
|
||||
for (int32_t i = 1; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||
int16_t offset = tscFieldInfoGetOffset(pQueryInfo, i);
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
|
||||
|
||||
assignVal(pSql->res.data + offset, (char *)(&pQueryInfo->fillVal[i]), pField->bytes, pField->type);
|
||||
row[i] = pSql->res.data + offset;
|
||||
}
|
||||
|
||||
tscSetTimestampForRes(pStream, pSql);
|
||||
row[0] = pRes->data;
|
||||
|
||||
// char result[512] = {0};
|
||||
// taos_print_row(result, row, pQueryInfo->fieldsInfo.pFields, pQueryInfo->fieldsInfo.numOfOutput);
|
||||
// tscInfo("%p stream:%p query result: %s", pSql, pStream, result);
|
||||
tscDebug("%p stream:%p fetch result", pSql, pStream);
|
||||
|
||||
// user callback function
|
||||
(*pStream->fp)(pStream->param, res, row);
|
||||
|
||||
pRes->numOfRows = 0;
|
||||
pRes->data = oldPtr;
|
||||
} else if (isProjectStream(pQueryInfo)) {
|
||||
if (pStream->isProject) {
|
||||
/* no resuls in the query range, retry */
|
||||
// todo set retry dynamic time
|
||||
int32_t retry = tsProjectExecInterval;
|
||||
tscError("%p stream:%p, retrieve no data, code:%d, retry in %" PRId32 "ms", pSql, pStream, numOfRows, retry);
|
||||
tscError("%p stream:%p, retrieve no data, code:0x%08x, retry in %" PRId32 "ms", pSql, pStream, numOfRows, retry);
|
||||
|
||||
tscSetRetryTimer(pStream, pStream->pSql, retry);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (isProjectStream(pQueryInfo)) {
|
||||
pStream->stime += 1;
|
||||
}
|
||||
} else if (pStream->isProject) {
|
||||
pStream->stime += 1;
|
||||
}
|
||||
|
||||
tscDebug("%p stream:%p, query on:%s, fetch result completed, fetched rows:%" PRId64, pSql, pStream, pTableMetaInfo->name,
|
||||
|
@ -262,10 +261,9 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
|
|||
}
|
||||
|
||||
static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
int64_t delay = getDelayValueAfterTimewindowClosed(pStream, timer);
|
||||
|
||||
if (isProjectStream(pQueryInfo)) {
|
||||
if (pStream->isProject) {
|
||||
int64_t now = taosGetTimestamp(pStream->precision);
|
||||
int64_t etime = now > pStream->etime ? pStream->etime : now;
|
||||
|
||||
|
@ -323,8 +321,7 @@ static int64_t getLaunchTimeDelay(const SSqlStream* pStream) {
|
|||
static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
|
||||
int64_t timer = 0;
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
if (isProjectStream(pQueryInfo)) {
|
||||
if (pStream->isProject) {
|
||||
/*
|
||||
* for project query, no mater fetch data successfully or not, next launch will issue
|
||||
* more than the sliding time window
|
||||
|
@ -342,7 +339,6 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
pStream->stime += pStream->slidingTime;
|
||||
if ((pStream->stime - pStream->interval) >= pStream->etime) {
|
||||
tscDebug("%p stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql, pStream,
|
||||
pStream->stime, pStream->etime);
|
||||
|
@ -409,14 +405,16 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
|
|||
|
||||
pStream->slidingTime = pQueryInfo->slidingTime;
|
||||
|
||||
pQueryInfo->intervalTime = 0; // clear the interval value to avoid the force time window split by query processor
|
||||
pQueryInfo->slidingTime = 0;
|
||||
if (pStream->isProject) {
|
||||
pQueryInfo->intervalTime = 0; // clear the interval value to avoid the force time window split by query processor
|
||||
pQueryInfo->slidingTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, int64_t stime) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
|
||||
if (isProjectStream(pQueryInfo)) {
|
||||
if (pStream->isProject) {
|
||||
// no data in table, flush all data till now to destination meter, 10sec delay
|
||||
pStream->interval = tsProjectExecInterval;
|
||||
pStream->slidingTime = tsProjectExecInterval;
|
||||
|
@ -489,7 +487,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
|
|||
|
||||
SSqlStream *pStream = (SSqlStream *)calloc(1, sizeof(SSqlStream));
|
||||
if (pStream == NULL) {
|
||||
tscError("%p open stream failed, sql:%s, reason:%s, code:%d", pSql, sqlstr, pCmd->payload, pRes->code);
|
||||
tscError("%p open stream failed, sql:%s, reason:%s, code:0x%08x", pSql, sqlstr, pCmd->payload, pRes->code);
|
||||
tscFreeSqlObj(pSql);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -514,7 +512,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
|
|||
if (pRes->code != TSDB_CODE_SUCCESS) {
|
||||
setErrorInfo(pSql, pRes->code, pCmd->payload);
|
||||
|
||||
tscError("%p open stream failed, sql:%s, reason:%s, code:%d", pSql, sqlstr, pCmd->payload, pRes->code);
|
||||
tscError("%p open stream failed, sql:%s, reason:%s, code:0x%08x", pSql, sqlstr, pCmd->payload, pRes->code);
|
||||
tscFreeSqlObj(pSql);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -523,6 +521,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
|
|||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
|
||||
|
||||
pStream->isProject = isProjectStream(pQueryInfo);
|
||||
pStream->fp = fp;
|
||||
pStream->callback = callback;
|
||||
pStream->param = param;
|
||||
|
@ -565,6 +564,8 @@ void taos_close_stream(TAOS_STREAM *handle) {
|
|||
taosTmrStopA(&(pStream->pTimer));
|
||||
|
||||
tscDebug("%p stream:%p is closed", pSql, pStream);
|
||||
// notify CQ to release the pStream object
|
||||
pStream->fp(pStream->param, NULL, NULL);
|
||||
|
||||
tscFreeSqlObj(pSql);
|
||||
pStream->pSql = NULL;
|
||||
|
|
|
@ -81,7 +81,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
|
|||
return startTime;
|
||||
}
|
||||
|
||||
int64_t start = ((startTime - slidingTime) / slidingTime + 1) * slidingTime;
|
||||
int64_t start = ((startTime - intervalTime) / slidingTime + 1) * slidingTime;
|
||||
if (!(timeUnit == 'a' || timeUnit == 'm' || timeUnit == 's' || timeUnit == 'h')) {
|
||||
/*
|
||||
* here we revised the start time of day according to the local time zone,
|
||||
|
|
|
@ -109,6 +109,8 @@ void cqClose(void *handle) {
|
|||
while (pObj) {
|
||||
SCqObj *pTemp = pObj;
|
||||
pObj = pObj->next;
|
||||
tdFreeSchema(pTemp->pSchema);
|
||||
tfree(pTemp->sqlStr);
|
||||
free(pTemp);
|
||||
}
|
||||
|
||||
|
@ -242,6 +244,10 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) {
|
|||
|
||||
static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) {
|
||||
SCqObj *pObj = (SCqObj *)param;
|
||||
if (tres == NULL && row == NULL) {
|
||||
pObj->pStream = NULL;
|
||||
return;
|
||||
}
|
||||
SCqContext *pContext = pObj->pContext;
|
||||
STSchema *pSchema = pObj->pSchema;
|
||||
if (pObj->pStream == NULL) return;
|
||||
|
|
|
@ -87,8 +87,8 @@ int32_t qKillQuery(qinfo_t qinfo);
|
|||
void* qOpenQueryMgmt(int32_t vgId);
|
||||
void qSetQueryMgmtClosed(void* pExecutor);
|
||||
void qCleanupQueryMgmt(void* pExecutor);
|
||||
void** qRegisterQInfo(void* pMgmt, void* qInfo);
|
||||
void** qAcquireQInfo(void* pMgmt, void** key);
|
||||
void** qRegisterQInfo(void* pMgmt, uint64_t qInfo);
|
||||
void** qAcquireQInfo(void* pMgmt, uint64_t key);
|
||||
void** qReleaseQInfo(void* pMgmt, void* pQInfo, bool needFree);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -473,7 +473,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
int32_t code;
|
||||
uint64_t qhandle;
|
||||
uint64_t qhandle; // query handle
|
||||
} SQueryTableRsp;
|
||||
|
||||
typedef struct {
|
||||
|
@ -486,7 +486,7 @@ typedef struct SRetrieveTableRsp {
|
|||
int32_t numOfRows;
|
||||
int8_t completed; // all results are returned to client
|
||||
int16_t precision;
|
||||
int64_t offset; // updated offset value for multi-vnode projection query
|
||||
int64_t offset; // updated offset value for multi-vnode projection query
|
||||
int64_t useconds;
|
||||
char data[];
|
||||
} SRetrieveTableRsp;
|
||||
|
|
|
@ -852,7 +852,6 @@ void multiThreadCreateTable(char* cols, bool use_metric, int threads, int ntable
|
|||
|
||||
for (int i = 0; i < threads; i++) {
|
||||
info *t_info = infos + i;
|
||||
taos_close(t_info->taos);
|
||||
sem_destroy(&(t_info->mutex_sem));
|
||||
sem_destroy(&(t_info->lock_sem));
|
||||
}
|
||||
|
|
|
@ -943,7 +943,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
|
|||
}
|
||||
|
||||
// null data, failed to allocate more memory buffer
|
||||
bool hasTimeWindow = false;
|
||||
hasTimeWindow = false;
|
||||
if (setWindowOutputBufByKey(pRuntimeEnv, pWindowResInfo, pDataBlockInfo->tid, &nextWin, masterScan, &hasTimeWindow) != TSDB_CODE_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
|
@ -1710,28 +1710,21 @@ static bool onlyQueryTags(SQuery* pQuery) {
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void getAlignQueryTimeWindow(SQuery *pQuery, int64_t key, int64_t keyFirst, int64_t keyLast, STimeWindow *realWin, STimeWindow *win) {
|
||||
void getAlignQueryTimeWindow(SQuery *pQuery, int64_t key, int64_t keyFirst, int64_t keyLast, STimeWindow *win) {
|
||||
assert(key >= keyFirst && key <= keyLast && pQuery->slidingTime <= pQuery->intervalTime);
|
||||
|
||||
win->skey = taosGetIntervalStartTimestamp(key, pQuery->slidingTime, pQuery->intervalTime, pQuery->slidingTimeUnit, pQuery->precision);
|
||||
|
||||
/*
|
||||
* if the realSkey > INT64_MAX - pQuery->intervalTime, the query duration between
|
||||
* realSkey and realEkey must be less than one interval.Therefore, no need to adjust the query ranges.
|
||||
*/
|
||||
if (keyFirst > (INT64_MAX - pQuery->intervalTime)) {
|
||||
/*
|
||||
* if the realSkey > INT64_MAX - pQuery->intervalTime, the query duration between
|
||||
* realSkey and realEkey must be less than one interval.Therefore, no need to adjust the query ranges.
|
||||
*/
|
||||
assert(keyLast - keyFirst < pQuery->intervalTime);
|
||||
|
||||
realWin->skey = keyFirst;
|
||||
realWin->ekey = keyLast;
|
||||
|
||||
win->ekey = INT64_MAX;
|
||||
return;
|
||||
} else {
|
||||
win->ekey = win->skey + pQuery->intervalTime - 1;
|
||||
}
|
||||
|
||||
win->ekey = win->skey + pQuery->intervalTime - 1;
|
||||
|
||||
realWin->skey = (win->skey < keyFirst)? keyFirst : win->skey;
|
||||
realWin->ekey = (win->ekey < keyLast) ? win->ekey : keyLast;
|
||||
}
|
||||
|
||||
static void setScanLimitationByResultBuffer(SQuery *pQuery) {
|
||||
|
@ -2247,24 +2240,20 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
|
|||
|
||||
// todo extract methods
|
||||
if (QUERY_IS_INTERVAL_QUERY(pQuery) && pRuntimeEnv->windowResInfo.prevSKey == TSKEY_INITIAL_VAL) {
|
||||
STimeWindow realWin = TSWINDOW_INITIALIZER, w = TSWINDOW_INITIALIZER;
|
||||
STimeWindow w = TSWINDOW_INITIALIZER;
|
||||
SWindowResInfo *pWindowResInfo = &pRuntimeEnv->windowResInfo;
|
||||
|
||||
if (QUERY_IS_ASC_QUERY(pQuery)) {
|
||||
getAlignQueryTimeWindow(pQuery, blockInfo.window.skey, blockInfo.window.skey, pQuery->window.ekey, &realWin, &w);
|
||||
getAlignQueryTimeWindow(pQuery, blockInfo.window.skey, blockInfo.window.skey, pQuery->window.ekey, &w);
|
||||
pWindowResInfo->startTime = w.skey;
|
||||
pWindowResInfo->prevSKey = w.skey;
|
||||
} else {
|
||||
// the start position of the first time window in the endpoint that spreads beyond the queried last timestamp
|
||||
getAlignQueryTimeWindow(pQuery, blockInfo.window.ekey, pQuery->window.ekey, blockInfo.window.ekey, &realWin, &w);
|
||||
getAlignQueryTimeWindow(pQuery, blockInfo.window.ekey, pQuery->window.ekey, blockInfo.window.ekey, &w);
|
||||
|
||||
pWindowResInfo->startTime = pQuery->window.skey;
|
||||
pWindowResInfo->prevSKey = w.skey;
|
||||
}
|
||||
|
||||
if (pRuntimeEnv->pFillInfo != NULL) {
|
||||
pRuntimeEnv->pFillInfo->start = w.skey;
|
||||
}
|
||||
}
|
||||
|
||||
// in case of prj/diff query, ensure the output buffer is sufficient to accommodate the results of current block
|
||||
|
@ -2294,10 +2283,10 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
|
|||
|
||||
if (QUERY_IS_INTERVAL_QUERY(pQuery) && IS_MASTER_SCAN(pRuntimeEnv)) {
|
||||
if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) {
|
||||
int32_t step = QUERY_IS_ASC_QUERY(pQuery) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP;
|
||||
// int32_t step = QUERY_IS_ASC_QUERY(pQuery) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP;
|
||||
|
||||
closeAllTimeWindow(&pRuntimeEnv->windowResInfo);
|
||||
removeRedundantWindow(&pRuntimeEnv->windowResInfo, pTableQueryInfo->lastKey - step, step);
|
||||
// removeRedundantWindow(&pRuntimeEnv->windowResInfo, pTableQueryInfo->lastKey - step, step);
|
||||
pRuntimeEnv->windowResInfo.curIndex = pRuntimeEnv->windowResInfo.size - 1; // point to the last time window
|
||||
} else {
|
||||
assert(Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL));
|
||||
|
@ -2914,6 +2903,9 @@ static void updateTableQueryInfoForReverseScan(SQuery *pQuery, STableQueryInfo *
|
|||
|
||||
SWITCH_ORDER(pTableQueryInfo->cur.order);
|
||||
pTableQueryInfo->cur.vgroupIndex = -1;
|
||||
|
||||
// set the index at the end of time window
|
||||
pTableQueryInfo->windowResInfo.curIndex = pTableQueryInfo->windowResInfo.size - 1;
|
||||
}
|
||||
|
||||
static void disableFuncInReverseScanImpl(SQInfo* pQInfo, SWindowResInfo *pWindowResInfo, int32_t order) {
|
||||
|
@ -3554,12 +3546,12 @@ void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
|
|||
* In ascending query, key is the first qualified timestamp. However, in the descending order query, additional
|
||||
* operations involve.
|
||||
*/
|
||||
STimeWindow w = TSWINDOW_INITIALIZER, realWin = TSWINDOW_INITIALIZER;
|
||||
STimeWindow w = TSWINDOW_INITIALIZER;
|
||||
SWindowResInfo *pWindowResInfo = &pTableQueryInfo->windowResInfo;
|
||||
|
||||
TSKEY sk = MIN(win.skey, win.ekey);
|
||||
TSKEY ek = MAX(win.skey, win.ekey);
|
||||
getAlignQueryTimeWindow(pQuery, win.skey, sk, ek, &realWin, &w);
|
||||
getAlignQueryTimeWindow(pQuery, win.skey, sk, ek, &w);
|
||||
pWindowResInfo->startTime = pTableQueryInfo->win.skey; // windowSKey may be 0 in case of 1970 timestamp
|
||||
|
||||
if (pWindowResInfo->prevSKey == TSKEY_INITIAL_VAL) {
|
||||
|
@ -3891,7 +3883,6 @@ static void queryCostStatis(SQInfo *pQInfo) {
|
|||
// double total = pSummary->fileTimeUs + pSummary->cacheTimeUs;
|
||||
// double io = pSummary->loadCompInfoUs + pSummary->loadBlocksUs + pSummary->loadFieldUs;
|
||||
|
||||
// todo add the intermediate result save cost!!
|
||||
// double computing = total - io;
|
||||
//
|
||||
// qDebug(
|
||||
|
@ -3989,7 +3980,7 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) {
|
|||
*/
|
||||
assert(pRuntimeEnv->windowResInfo.prevSKey == TSKEY_INITIAL_VAL);
|
||||
|
||||
STimeWindow w = TSWINDOW_INITIALIZER, realWin = TSWINDOW_INITIALIZER;
|
||||
STimeWindow w = TSWINDOW_INITIALIZER;
|
||||
|
||||
SWindowResInfo *pWindowResInfo = &pRuntimeEnv->windowResInfo;
|
||||
STableQueryInfo *pTableQueryInfo = pQuery->current;
|
||||
|
@ -4000,12 +3991,12 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) {
|
|||
|
||||
if (QUERY_IS_ASC_QUERY(pQuery)) {
|
||||
if (pWindowResInfo->prevSKey == TSKEY_INITIAL_VAL) {
|
||||
getAlignQueryTimeWindow(pQuery, blockInfo.window.skey, blockInfo.window.skey, pQuery->window.ekey, &realWin, &w);
|
||||
getAlignQueryTimeWindow(pQuery, blockInfo.window.skey, blockInfo.window.skey, pQuery->window.ekey, &w);
|
||||
pWindowResInfo->startTime = w.skey;
|
||||
pWindowResInfo->prevSKey = w.skey;
|
||||
}
|
||||
} else {
|
||||
getAlignQueryTimeWindow(pQuery, blockInfo.window.ekey, pQuery->window.ekey, blockInfo.window.ekey, &realWin, &w);
|
||||
getAlignQueryTimeWindow(pQuery, blockInfo.window.ekey, pQuery->window.ekey, blockInfo.window.ekey, &w);
|
||||
|
||||
pWindowResInfo->startTime = pQuery->window.skey;
|
||||
pWindowResInfo->prevSKey = w.skey;
|
||||
|
@ -4228,7 +4219,13 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
|
|||
|
||||
if (pQuery->fillType != TSDB_FILL_NONE && !isPointInterpoQuery(pQuery)) {
|
||||
SFillColInfo* pColInfo = taosCreateFillColInfo(pQuery);
|
||||
pRuntimeEnv->pFillInfo = taosInitFillInfo(pQuery->order.order, 0, 0, pQuery->rec.capacity, pQuery->numOfOutput,
|
||||
STimeWindow w = TSWINDOW_INITIALIZER;
|
||||
|
||||
TSKEY sk = MIN(pQuery->window.skey, pQuery->window.ekey);
|
||||
TSKEY ek = MAX(pQuery->window.skey, pQuery->window.ekey);
|
||||
getAlignQueryTimeWindow(pQuery, pQuery->window.skey, sk, ek, &w);
|
||||
|
||||
pRuntimeEnv->pFillInfo = taosInitFillInfo(pQuery->order.order, w.skey, 0, pQuery->rec.capacity, pQuery->numOfOutput,
|
||||
pQuery->slidingTime, pQuery->slidingTimeUnit, pQuery->precision,
|
||||
pQuery->fillType, pColInfo);
|
||||
}
|
||||
|
@ -4690,7 +4687,7 @@ static void doRestoreContext(SQInfo *pQInfo) {
|
|||
static void doCloseAllTimeWindowAfterScan(SQInfo *pQInfo) {
|
||||
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
|
||||
|
||||
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
|
||||
// int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
|
||||
|
||||
if (QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
||||
size_t numOfGroup = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||
|
@ -4701,7 +4698,7 @@ static void doCloseAllTimeWindowAfterScan(SQInfo *pQInfo) {
|
|||
for (int32_t j = 0; j < num; ++j) {
|
||||
STableQueryInfo* item = taosArrayGetP(group, j);
|
||||
closeAllTimeWindow(&item->windowResInfo);
|
||||
removeRedundantWindow(&item->windowResInfo, item->lastKey - step, step);
|
||||
// removeRedundantWindow(&item->windowResInfo, item->lastKey - step, step);
|
||||
}
|
||||
}
|
||||
} else { // close results for group result
|
||||
|
@ -4753,7 +4750,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
|
|||
el = scanMultiTableDataBlocks(pQInfo);
|
||||
qDebug("QInfo:%p reversed scan completed, elapsed time: %" PRId64 "ms", pQInfo, el);
|
||||
|
||||
doCloseAllTimeWindowAfterScan(pQInfo);
|
||||
// doCloseAllTimeWindowAfterScan(pQInfo);
|
||||
doRestoreContext(pQInfo);
|
||||
} else {
|
||||
qDebug("QInfo:%p no need to do reversed scan, query completed", pQInfo);
|
||||
|
@ -5825,7 +5822,7 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ
|
|||
qDebug("QInfo:%p no result in time range %" PRId64 "-%" PRId64 ", order %d", pQInfo, pQuery->window.skey,
|
||||
pQuery->window.ekey, pQuery->order.order);
|
||||
setQueryStatus(pQuery, QUERY_COMPLETED);
|
||||
|
||||
pQInfo->tableqinfoGroupInfo.numOfTables = 0;
|
||||
sem_post(&pQInfo->dataReady);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -6497,7 +6494,7 @@ void qSetQueryMgmtClosed(void* pQMgmt) {
|
|||
pQueryMgmt->closed = true;
|
||||
pthread_mutex_unlock(&pQueryMgmt->lock);
|
||||
|
||||
taosCacheEmpty(pQueryMgmt->qinfoPool, true);
|
||||
taosCacheRefresh(pQueryMgmt->qinfoPool, freeqinfoFn);
|
||||
}
|
||||
|
||||
void qCleanupQueryMgmt(void* pQMgmt) {
|
||||
|
@ -6520,11 +6517,13 @@ void qCleanupQueryMgmt(void* pQMgmt) {
|
|||
qDebug("vgId:%d querymgmt cleanup completed", vgId);
|
||||
}
|
||||
|
||||
void** qRegisterQInfo(void* pMgmt, void* qInfo) {
|
||||
void** qRegisterQInfo(void* pMgmt, uint64_t qInfo) {
|
||||
if (pMgmt == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const int32_t DEFAULT_QHANDLE_LIFE_SPAN = tsShellActivityTimer * 2;
|
||||
|
||||
SQueryMgmt *pQueryMgmt = pMgmt;
|
||||
if (pQueryMgmt->qinfoPool == NULL) {
|
||||
return NULL;
|
||||
|
@ -6536,21 +6535,23 @@ void** qRegisterQInfo(void* pMgmt, void* qInfo) {
|
|||
|
||||
return NULL;
|
||||
} else {
|
||||
void** handle = taosCachePut(pQueryMgmt->qinfoPool, qInfo, POINTER_BYTES, &qInfo, POINTER_BYTES, tsShellActivityTimer*2);
|
||||
uint64_t handleVal = (uint64_t) qInfo;
|
||||
|
||||
void** handle = taosCachePut(pQueryMgmt->qinfoPool, &handleVal, sizeof(int64_t), &qInfo, POINTER_BYTES, DEFAULT_QHANDLE_LIFE_SPAN);
|
||||
pthread_mutex_unlock(&pQueryMgmt->lock);
|
||||
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
|
||||
void** qAcquireQInfo(void* pMgmt, void** key) {
|
||||
void** qAcquireQInfo(void* pMgmt, uint64_t key) {
|
||||
SQueryMgmt *pQueryMgmt = pMgmt;
|
||||
|
||||
if (pQueryMgmt->qinfoPool == NULL || pQueryMgmt->closed) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void** handle = taosCacheAcquireByKey(pQueryMgmt->qinfoPool, key, POINTER_BYTES);
|
||||
void** handle = taosCacheAcquireByKey(pQueryMgmt->qinfoPool, &key, sizeof(uint64_t));
|
||||
if (handle == NULL || *handle == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
|
|
|
@ -174,7 +174,7 @@ int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
return FILL_IS_ASC_FILL(pFillInfo) ? (pFillInfo->numOfRows - pFillInfo->rowIdx) : pFillInfo->rowIdx + 1;
|
||||
return pFillInfo->numOfRows - pFillInfo->rowIdx;
|
||||
}
|
||||
|
||||
// todo: refactor
|
||||
|
|
|
@ -24,14 +24,13 @@ extern "C" {
|
|||
#include "tref.h"
|
||||
#include "hash.h"
|
||||
|
||||
typedef void (*__cache_freeres_fn_t)(void*);
|
||||
typedef void (*__cache_free_fn_t)(void*);
|
||||
|
||||
typedef struct SCacheStatis {
|
||||
int64_t missCount;
|
||||
int64_t hitCount;
|
||||
int64_t totalAccess;
|
||||
int64_t refreshCount;
|
||||
int32_t numOfCollision;
|
||||
} SCacheStatis;
|
||||
|
||||
typedef struct SCacheDataNode {
|
||||
|
@ -70,7 +69,7 @@ typedef struct {
|
|||
// void * pTimer;
|
||||
SCacheStatis statistics;
|
||||
SHashObj * pHashTable;
|
||||
__cache_freeres_fn_t freeFp;
|
||||
__cache_free_fn_t freeFp;
|
||||
uint32_t numOfElemsInTrash; // number of element in trash
|
||||
uint8_t deleting; // set the deleting flag to stop refreshing ASAP.
|
||||
pthread_t refreshWorker;
|
||||
|
@ -91,15 +90,7 @@ typedef struct {
|
|||
* @param fn free resource callback function
|
||||
* @return
|
||||
*/
|
||||
SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool extendLifespan, __cache_freeres_fn_t fn, const char *cacheName);
|
||||
|
||||
/**
|
||||
* initialize the cache object and set the free object callback function
|
||||
* @param refreshTimeInSeconds
|
||||
* @param freeCb
|
||||
* @return
|
||||
*/
|
||||
SCacheObj *taosCacheInitWithCb(int32_t keyType, int64_t refreshTimeInSeconds, bool extendLifespan, __cache_freeres_fn_t fn, const char *cacheName);
|
||||
SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool extendLifespan, __cache_free_fn_t fn, const char *cacheName);
|
||||
|
||||
/**
|
||||
* add data into cache
|
||||
|
@ -163,9 +154,8 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove);
|
|||
/**
|
||||
* move all data node into trash, clear node in trash can if it is not referenced by any clients
|
||||
* @param handle
|
||||
* @param _remove remove the data or not if refcount is greater than 0
|
||||
*/
|
||||
void taosCacheEmpty(SCacheObj *pCacheObj, bool _remove);
|
||||
void taosCacheEmpty(SCacheObj *pCacheObj);
|
||||
|
||||
/**
|
||||
* release all allocated memory and destroy the cache object.
|
||||
|
@ -180,6 +170,14 @@ void taosCacheEmpty(SCacheObj *pCacheObj, bool _remove);
|
|||
*/
|
||||
void taosCacheCleanup(SCacheObj *pCacheObj);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pCacheObj
|
||||
* @param fp
|
||||
* @return
|
||||
*/
|
||||
void taosCacheRefresh(SCacheObj *pCacheObj, __cache_free_fn_t fp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -223,9 +223,9 @@ static void doCleanupDataCache(SCacheObj *pCacheObj);
|
|||
* refresh cache to remove data in both hash list and trash, if any nodes' refcount == 0, every pCacheObj->refreshTime
|
||||
* @param handle Cache object handle
|
||||
*/
|
||||
static void* taosCacheRefresh(void *handle);
|
||||
static void* taosCacheTimedRefresh(void *pCacheObj);
|
||||
|
||||
SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool extendLifespan, __cache_freeres_fn_t fn, const char* cacheName) {
|
||||
SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool extendLifespan, __cache_free_fn_t fn, const char* cacheName) {
|
||||
if (refreshTimeInSeconds <= 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool ext
|
|||
pthread_attr_init(&thattr);
|
||||
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
pthread_create(&pCacheObj->refreshWorker, &thattr, taosCacheRefresh, pCacheObj);
|
||||
pthread_create(&pCacheObj->refreshWorker, &thattr, taosCacheTimedRefresh, pCacheObj);
|
||||
|
||||
pthread_attr_destroy(&thattr);
|
||||
return pCacheObj;
|
||||
|
@ -450,7 +450,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
|
|||
}
|
||||
}
|
||||
|
||||
void taosCacheEmpty(SCacheObj *pCacheObj, bool _remove) {
|
||||
void taosCacheEmpty(SCacheObj *pCacheObj) {
|
||||
SHashMutableIterator *pIter = taosHashCreateIter(pCacheObj->pHashTable);
|
||||
|
||||
__cache_wr_lock(pCacheObj);
|
||||
|
@ -459,8 +459,8 @@ void taosCacheEmpty(SCacheObj *pCacheObj, bool _remove) {
|
|||
break;
|
||||
}
|
||||
|
||||
SCacheDataNode *pNode = *(SCacheDataNode **)taosHashIterGet(pIter);
|
||||
if (T_REF_VAL_GET(pNode) == 0 || _remove) {
|
||||
SCacheDataNode *pNode = *(SCacheDataNode **) taosHashIterGet(pIter);
|
||||
if (T_REF_VAL_GET(pNode) == 0) {
|
||||
taosCacheReleaseNode(pCacheObj, pNode);
|
||||
} else {
|
||||
taosCacheMoveToTrash(pCacheObj, pNode);
|
||||
|
@ -469,7 +469,7 @@ void taosCacheEmpty(SCacheObj *pCacheObj, bool _remove) {
|
|||
__cache_unlock(pCacheObj);
|
||||
|
||||
taosHashDestroyIter(pIter);
|
||||
taosTrashCanEmpty(pCacheObj, _remove);
|
||||
taosTrashCanEmpty(pCacheObj, false);
|
||||
}
|
||||
|
||||
void taosCacheCleanup(SCacheObj *pCacheObj) {
|
||||
|
@ -623,8 +623,29 @@ void doCleanupDataCache(SCacheObj *pCacheObj) {
|
|||
free(pCacheObj);
|
||||
}
|
||||
|
||||
void* taosCacheRefresh(void *handle) {
|
||||
SCacheObj *pCacheObj = (SCacheObj *)handle;
|
||||
static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_free_fn_t fp) {
|
||||
SHashMutableIterator *pIter = taosHashCreateIter(pCacheObj->pHashTable);
|
||||
|
||||
__cache_wr_lock(pCacheObj);
|
||||
while (taosHashIterNext(pIter)) {
|
||||
SCacheDataNode *pNode = *(SCacheDataNode **)taosHashIterGet(pIter);
|
||||
if ((pNode->addedTime + pNode->lifespan * pNode->extendFactor) <= time && T_REF_VAL_GET(pNode) <= 0) {
|
||||
taosCacheReleaseNode(pCacheObj, pNode);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fp) {
|
||||
fp(pNode->data);
|
||||
}
|
||||
}
|
||||
|
||||
__cache_unlock(pCacheObj);
|
||||
|
||||
taosHashDestroyIter(pIter);
|
||||
}
|
||||
|
||||
void* taosCacheTimedRefresh(void *handle) {
|
||||
SCacheObj* pCacheObj = handle;
|
||||
if (pCacheObj == NULL) {
|
||||
uDebug("object is destroyed. no refresh retry");
|
||||
return NULL;
|
||||
|
@ -657,21 +678,8 @@ void* taosCacheRefresh(void *handle) {
|
|||
|
||||
// refresh data in hash table
|
||||
if (elemInHash > 0) {
|
||||
int64_t expiredTime = taosGetTimestampMs();
|
||||
|
||||
SHashMutableIterator *pIter = taosHashCreateIter(pCacheObj->pHashTable);
|
||||
|
||||
__cache_wr_lock(pCacheObj);
|
||||
while (taosHashIterNext(pIter)) {
|
||||
SCacheDataNode *pNode = *(SCacheDataNode **)taosHashIterGet(pIter);
|
||||
if ((pNode->addedTime + pNode->lifespan * pNode->extendFactor) <= expiredTime && T_REF_VAL_GET(pNode) <= 0) {
|
||||
taosCacheReleaseNode(pCacheObj, pNode);
|
||||
}
|
||||
}
|
||||
|
||||
__cache_unlock(pCacheObj);
|
||||
|
||||
taosHashDestroyIter(pIter);
|
||||
int64_t now = taosGetTimestampMs();
|
||||
doCacheRefresh(pCacheObj, now, NULL);
|
||||
}
|
||||
|
||||
taosTrashCanEmpty(pCacheObj, false);
|
||||
|
@ -679,3 +687,12 @@ void* taosCacheRefresh(void *handle) {
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void taosCacheRefresh(SCacheObj *pCacheObj, __cache_free_fn_t fp) {
|
||||
if (pCacheObj == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t now = taosGetTimestampMs();
|
||||
doCacheRefresh(pCacheObj, now, fp);
|
||||
}
|
||||
|
|
|
@ -383,10 +383,15 @@ int taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (taosKeepTcpAlive(sockFd) < 0) return -1;
|
||||
if (taosKeepTcpAlive(sockFd) < 0) {
|
||||
uError("failed to set tcp server keep-alive option, 0x%x:%hu(%s)", ip, port, strerror(errno));
|
||||
close(sockFd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (listen(sockFd, 10) < 0) {
|
||||
uError("listen tcp server socket failed, 0x%x:%hu(%s)", ip, port, strerror(errno));
|
||||
close(sockFd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ int32_t vnodeProcessRead(void *param, SReadMsg *pReadMsg) {
|
|||
}
|
||||
|
||||
static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
||||
void * pCont = pReadMsg->pCont;
|
||||
void *pCont = pReadMsg->pCont;
|
||||
int32_t contLen = pReadMsg->contLen;
|
||||
SRspRet *pRet = &pReadMsg->rspRet;
|
||||
|
||||
|
@ -74,19 +74,14 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
|||
killQueryMsg->free = htons(killQueryMsg->free);
|
||||
killQueryMsg->qhandle = htobe64(killQueryMsg->qhandle);
|
||||
|
||||
void* handle = NULL;
|
||||
if ((void**) killQueryMsg->qhandle != NULL) {
|
||||
handle = *(void**) killQueryMsg->qhandle;
|
||||
}
|
||||
|
||||
vWarn("QInfo:%p connection %p broken, kill query", handle, pReadMsg->rpcMsg.handle);
|
||||
vWarn("QInfo:%p connection %p broken, kill query", (void*) killQueryMsg->qhandle, pReadMsg->rpcMsg.handle);
|
||||
assert(pReadMsg->rpcMsg.contLen > 0 && killQueryMsg->free == 1);
|
||||
|
||||
void** qhandle = qAcquireQInfo(pVnode->qMgmt, (void**) killQueryMsg->qhandle);
|
||||
void** qhandle = qAcquireQInfo(pVnode->qMgmt, (uint64_t) killQueryMsg->qhandle);
|
||||
if (qhandle == NULL || *qhandle == NULL) {
|
||||
vWarn("QInfo:%p invalid qhandle, no matched query handle, conn:%p", (void*) killQueryMsg->qhandle, pReadMsg->rpcMsg.handle);
|
||||
} else {
|
||||
assert(qhandle == (void**) killQueryMsg->qhandle);
|
||||
assert(*qhandle == (void*) killQueryMsg->qhandle);
|
||||
qReleaseQInfo(pVnode->qMgmt, (void**) &qhandle, true);
|
||||
}
|
||||
|
||||
|
@ -110,7 +105,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
|||
|
||||
// current connect is broken
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
handle = qRegisterQInfo(pVnode->qMgmt, pQInfo);
|
||||
handle = qRegisterQInfo(pVnode->qMgmt, (uint64_t) pQInfo);
|
||||
if (handle == NULL) { // failed to register qhandle
|
||||
pRsp->code = TSDB_CODE_QRY_INVALID_QHANDLE;
|
||||
|
||||
|
@ -118,11 +113,11 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
|||
qKillQuery(pQInfo);
|
||||
} else {
|
||||
assert(*handle == pQInfo);
|
||||
pRsp->qhandle = htobe64((uint64_t) (handle));
|
||||
pRsp->qhandle = htobe64((uint64_t) pQInfo);
|
||||
}
|
||||
|
||||
pQInfo = NULL;
|
||||
if (handle != NULL && vnodeNotifyCurrentQhandle(pReadMsg->rpcMsg.handle, handle, pVnode->vgId) != TSDB_CODE_SUCCESS) {
|
||||
if (handle != NULL && vnodeNotifyCurrentQhandle(pReadMsg->rpcMsg.handle, *handle, pVnode->vgId) != TSDB_CODE_SUCCESS) {
|
||||
vError("vgId:%d, QInfo:%p, query discarded since link is broken, %p", pVnode->vgId, *handle, pReadMsg->rpcMsg.handle);
|
||||
pRsp->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||
|
||||
|
@ -136,18 +131,18 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
|||
assert(pQInfo == NULL);
|
||||
}
|
||||
if (handle != NULL) {
|
||||
dnodePutItemIntoReadQueue(pVnode, handle);
|
||||
dnodePutItemIntoReadQueue(pVnode, *handle);
|
||||
qReleaseQInfo(pVnode->qMgmt, (void**) &handle, false);
|
||||
}
|
||||
vDebug("vgId:%d, QInfo:%p, dnode query msg disposed", vgId, pQInfo);
|
||||
} else {
|
||||
assert(pCont != NULL);
|
||||
handle = qAcquireQInfo(pVnode->qMgmt, (void**) pCont);
|
||||
handle = qAcquireQInfo(pVnode->qMgmt, (uint64_t) pCont);
|
||||
if (handle == NULL) {
|
||||
vWarn("QInfo:%p invalid qhandle in continuing exec query, conn:%p", *(void**) pCont, pReadMsg->rpcMsg.handle);
|
||||
vWarn("QInfo:%p invalid qhandle in continuing exec query, conn:%p", (void*) pCont, pReadMsg->rpcMsg.handle);
|
||||
code = TSDB_CODE_QRY_INVALID_QHANDLE;
|
||||
} else {
|
||||
vDebug("vgId:%d, QInfo:%p, dnode query msg in progress", pVnode->vgId, *(void**) pCont);
|
||||
vDebug("vgId:%d, QInfo:%p, dnode query msg in progress", pVnode->vgId, (void*) pCont);
|
||||
code = TSDB_CODE_VND_ACTION_IN_PROGRESS;
|
||||
qTableQuery(*handle); // do execute query
|
||||
}
|
||||
|
@ -169,10 +164,10 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
|||
memset(pRet, 0, sizeof(SRspRet));
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
void** handle = qAcquireQInfo(pVnode->qMgmt, (void**) pRetrieve->qhandle);
|
||||
if (handle == NULL || handle != (void**) pRetrieve->qhandle) {
|
||||
void** handle = qAcquireQInfo(pVnode->qMgmt, pRetrieve->qhandle);
|
||||
if (handle == NULL || (*handle) != (void*) pRetrieve->qhandle) {
|
||||
code = TSDB_CODE_QRY_INVALID_QHANDLE;
|
||||
vDebug("vgId:%d, invalid qhandle in fetch result, QInfo:%p", pVnode->vgId, *(void**) pRetrieve->qhandle);
|
||||
vDebug("vgId:%d, invalid qhandle in fetch result, QInfo:%p", pVnode->vgId, (void*) pRetrieve->qhandle);
|
||||
|
||||
pRet->rsp = (SRetrieveTableRsp *)rpcMallocCont(sizeof(SRetrieveTableRsp));
|
||||
pRet->len = sizeof(SRetrieveTableRsp);
|
||||
|
@ -180,8 +175,8 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
|||
memset(pRet->rsp, 0, sizeof(SRetrieveTableRsp));
|
||||
SRetrieveTableRsp* pRsp = pRet->rsp;
|
||||
pRsp->numOfRows = 0;
|
||||
pRsp->completed = true;
|
||||
pRsp->useconds = 0;
|
||||
pRsp->completed = true;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -211,8 +206,8 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
|||
} else { // if failed to dump result, free qhandle immediately
|
||||
if ((code = qDumpRetrieveResult(*handle, (SRetrieveTableRsp **)&pRet->rsp, &pRet->len)) == TSDB_CODE_SUCCESS) {
|
||||
if (qHasMoreResultsToRetrieve(*handle)) {
|
||||
dnodePutItemIntoReadQueue(pVnode, handle);
|
||||
pRet->qhandle = handle;
|
||||
dnodePutItemIntoReadQueue(pVnode, *handle);
|
||||
pRet->qhandle = *handle;
|
||||
freeHandle = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,8 +145,11 @@ python3 ./test.py -f query/queryJoin.py
|
|||
python3 ./test.py -f query/select_last_crash.py
|
||||
|
||||
#stream
|
||||
python3 ./test.py -f stream/metric_1.py
|
||||
python3 ./test.py -f stream/new.py
|
||||
python3 ./test.py -f stream/stream1.py
|
||||
python3 ./test.py -f stream/stream2.py
|
||||
python3 ./test.py -f stream/parser.py
|
||||
|
||||
#alter table
|
||||
python3 ./test.py -f alter/alter_table_crash.py
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import time
|
||||
import taos
|
||||
from util.log import tdLog
|
||||
from util.cases import tdCases
|
||||
from util.sql import tdSql
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def createFuncStream(self, expr, suffix, value):
|
||||
tbname = "strm_" + suffix
|
||||
tdLog.info("create stream table %s" % tbname)
|
||||
tdSql.query("select %s from stb interval(1d)" % expr)
|
||||
tdSql.checkData(0, 1, value)
|
||||
tdSql.execute("create table %s as select %s from stb interval(1d)" % (tbname, expr))
|
||||
|
||||
def checkStreamData(self, suffix, value):
|
||||
sql = "select * from strm_" + suffix
|
||||
tdSql.waitedQuery(sql, 1, 120)
|
||||
tdSql.checkData(0, 1, value)
|
||||
|
||||
def run(self):
|
||||
tbNum = 10
|
||||
rowNum = 20
|
||||
|
||||
tdSql.prepare()
|
||||
|
||||
tdLog.info("===== preparing data =====")
|
||||
tdSql.execute(
|
||||
"create table stb(ts timestamp, tbcol int, tbcol2 float) tags(tgcol int)")
|
||||
for i in range(tbNum):
|
||||
tdSql.execute("create table tb%d using stb tags(%d)" % (i, i))
|
||||
for j in range(rowNum):
|
||||
tdSql.execute(
|
||||
"insert into tb%d values (now - %dm, %d, %d)" %
|
||||
(i, 1440 - j, j, j))
|
||||
time.sleep(0.1)
|
||||
|
||||
self.createFuncStream("count(*)", "c1", 200)
|
||||
self.createFuncStream("count(tbcol)", "c2", 200)
|
||||
self.createFuncStream("count(tbcol2)", "c3", 200)
|
||||
self.createFuncStream("avg(tbcol)", "av", 9.5)
|
||||
self.createFuncStream("sum(tbcol)", "su", 1900)
|
||||
self.createFuncStream("min(tbcol)", "mi", 0)
|
||||
self.createFuncStream("max(tbcol)", "ma", 19)
|
||||
self.createFuncStream("first(tbcol)", "fi", 0)
|
||||
self.createFuncStream("last(tbcol)", "la", 19)
|
||||
#tdSql.query("select stddev(tbcol) from stb interval(1d)")
|
||||
#tdSql.query("select leastsquares(tbcol, 1, 1) from stb interval(1d)")
|
||||
tdSql.query("select top(tbcol, 1) from stb interval(1d)")
|
||||
tdSql.query("select bottom(tbcol, 1) from stb interval(1d)")
|
||||
#tdSql.query("select percentile(tbcol, 1) from stb interval(1d)")
|
||||
#tdSql.query("select diff(tbcol) from stb interval(1d)")
|
||||
|
||||
tdSql.query("select count(tbcol) from stb where ts < now + 4m interval(1d)")
|
||||
tdSql.checkData(0, 1, 200)
|
||||
#tdSql.execute("create table strm_wh as select count(tbcol) from stb where ts < now + 4m interval(1d)")
|
||||
|
||||
self.createFuncStream("count(tbcol)", "as", 200)
|
||||
|
||||
tdSql.query("select count(tbcol) from stb interval(1d) group by tgcol")
|
||||
tdSql.checkData(0, 1, 20)
|
||||
|
||||
tdSql.query("select count(tbcol) from stb where ts < now + 4m interval(1d) group by tgcol")
|
||||
tdSql.checkData(0, 1, 20)
|
||||
|
||||
self.checkStreamData("c1", 200)
|
||||
self.checkStreamData("c2", 200)
|
||||
self.checkStreamData("c3", 200)
|
||||
self.checkStreamData("av", 9.5)
|
||||
self.checkStreamData("su", 1900)
|
||||
self.checkStreamData("mi", 0)
|
||||
self.checkStreamData("ma", 19)
|
||||
self.checkStreamData("fi", 0)
|
||||
self.checkStreamData("la", 19)
|
||||
#self.checkStreamData("wh", 200)
|
||||
self.checkStreamData("as", 200)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import time
|
||||
import taos
|
||||
from util.log import tdLog
|
||||
from util.cases import tdCases
|
||||
from util.sql import tdSql
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def run(self):
|
||||
rowNum = 200
|
||||
totalNum = 200
|
||||
tdSql.prepare()
|
||||
|
||||
tdLog.info("=============== step1")
|
||||
tdSql.execute("create table mt(ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)")
|
||||
for i in range(5):
|
||||
tdSql.execute("create table tb%d using mt tags(%d)" % (i, i))
|
||||
for j in range(rowNum):
|
||||
tdSql.execute("insert into tb%d values(now + %ds, %d, %d)" % (i, j, j, j))
|
||||
time.sleep(0.1)
|
||||
|
||||
tdLog.info("=============== step2")
|
||||
tdSql.query("select count(*), count(tbcol), count(tbcol2) from mt interval(10s)")
|
||||
tdSql.execute("create table st as select count(*), count(tbcol), count(tbcol2) from mt interval(10s)")
|
||||
|
||||
tdLog.info("=============== step3")
|
||||
tdSql.waitedQuery("select * from st", 1, 120)
|
||||
v = tdSql.getData(0, 3)
|
||||
if v >= 51:
|
||||
tdLog.exit("value is %d, which is larger than 51" % v)
|
||||
|
||||
tdLog.info("=============== step4")
|
||||
for i in range(5, 10):
|
||||
tdSql.execute("create table tb%d using mt tags(%d)" % (i, i))
|
||||
for j in range(rowNum):
|
||||
tdSql.execute("insert into tb%d values(now + %ds, %d, %d)" % (i, j, j, j))
|
||||
|
||||
tdLog.info("=============== step5")
|
||||
tdLog.sleep(30)
|
||||
tdSql.waitedQuery("select * from st order by ts desc", 1, 120)
|
||||
v = tdSql.getData(0, 3)
|
||||
if v <= 51:
|
||||
tdLog.exit("value is %d, which is smaller than 51" % v)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
|
||||
|
|
@ -0,0 +1,182 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import time
|
||||
import taos
|
||||
from util.log import tdLog
|
||||
from util.cases import tdCases
|
||||
from util.sql import tdSql
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
'''
|
||||
def bug2222(self):
|
||||
tdSql.prepare()
|
||||
tdSql.execute("create table superreal(ts timestamp, addr binary(5), val float) tags (deviceNo binary(20))")
|
||||
tdSql.execute("create table real_001 using superreal tags('001')")
|
||||
tdSql.execute("create table tj_001 as select sum(val) from real_001 interval(1m)")
|
||||
|
||||
t = datetime.datetime.now()
|
||||
for i in range(60):
|
||||
ts = t.strftime("%Y-%m-%d %H:%M")
|
||||
t += datetime.timedelta(minutes=1)
|
||||
sql = "insert into real_001 values('%s:0%d', '1', %d)" % (ts, 0, i)
|
||||
for j in range(4):
|
||||
sql += ",('%s:0%d', '%d', %d)" % (ts, j + 1, j + 1, i)
|
||||
tdSql.execute(sql)
|
||||
time.sleep(60 + random.random() * 60 - 30)
|
||||
'''
|
||||
|
||||
def tbase300(self):
|
||||
tdLog.debug("begin tbase300")
|
||||
|
||||
tdSql.prepare()
|
||||
tdSql.execute("create table mt(ts timestamp, c1 int, c2 int) tags(t1 int)")
|
||||
tdSql.execute("create table tb1 using mt tags(1)");
|
||||
tdSql.execute("create table tb2 using mt tags(2)");
|
||||
tdSql.execute("create table strm as select count(*), avg(c1), sum(c2), max(c1), min(c2),first(c1), last(c2) from mt interval(4s) sliding(2s)")
|
||||
#tdSql.execute("create table strm as select count(*), avg(c1), sum(c2), max(c1), min(c2), first(c1) from mt interval(4s) sliding(2s)")
|
||||
tdLog.sleep(10)
|
||||
tdSql.execute("insert into tb2 values(now, 1, 1)");
|
||||
tdSql.execute("insert into tb1 values(now, 1, 1)");
|
||||
tdLog.sleep(4)
|
||||
tdSql.query("select * from mt")
|
||||
tdSql.query("select * from strm")
|
||||
tdSql.execute("drop table tb1")
|
||||
|
||||
tdSql.waitedQuery("select * from strm", 1, 100)
|
||||
if tdSql.queryRows < 1 or tdSql.queryRows > 2:
|
||||
tdLog.exit("rows should be 1 or 2")
|
||||
|
||||
tdSql.execute("drop table tb2")
|
||||
tdSql.execute("drop table mt")
|
||||
tdSql.execute("drop table strm")
|
||||
|
||||
def tbase304(self):
|
||||
tdLog.debug("begin tbase304")
|
||||
# we cannot reset query cache in server side, as a workaround,
|
||||
# set super table name to mt304, need to change back to mt later
|
||||
tdSql.execute("create table mt304 (ts timestamp, c1 int) tags(t1 int, t2 int)")
|
||||
tdSql.execute("create table tb1 using mt304 tags(1, 1)")
|
||||
tdSql.execute("create table tb2 using mt304 tags(1, -1)")
|
||||
time.sleep(0.1)
|
||||
tdSql.execute("create table strm as select count(*), avg(c1) from mt304 where t2 >= 0 interval(4s) sliding(2s)")
|
||||
tdSql.execute("insert into tb1 values (now,1)")
|
||||
tdSql.execute("insert into tb2 values (now,2)")
|
||||
|
||||
tdSql.waitedQuery("select * from strm", 1, 100)
|
||||
if tdSql.queryRows < 1 or tdSql.queryRows > 2:
|
||||
tdLog.exit("rows should be 1 or 2")
|
||||
|
||||
tdSql.checkData(0, 1, 1)
|
||||
tdSql.checkData(0, 2, 1.000000000)
|
||||
tdSql.execute("alter table mt304 drop tag t2")
|
||||
tdSql.execute("insert into tb2 values (now,2)")
|
||||
tdSql.execute("insert into tb1 values (now,1)")
|
||||
tdSql.query("select * from strm")
|
||||
tdSql.execute("alter table mt304 add tag t2 int")
|
||||
tdLog.sleep(1)
|
||||
tdSql.query("select * from strm")
|
||||
|
||||
def wildcardFilterOnTags(self):
|
||||
tdLog.debug("begin wildcardFilterOnTag")
|
||||
tdSql.prepare()
|
||||
tdSql.execute("create table stb (ts timestamp, c1 int, c2 binary(10)) tags(t1 binary(10))")
|
||||
tdSql.execute("create table tb1 using stb tags('a1')")
|
||||
tdSql.execute("create table tb2 using stb tags('b2')")
|
||||
tdSql.execute("create table tb3 using stb tags('a3')")
|
||||
tdSql.execute("create table strm as select count(*), avg(c1), first(c2) from stb where t1 like 'a%' interval(4s) sliding(2s)")
|
||||
tdSql.query("describe strm")
|
||||
tdSql.checkRows(4)
|
||||
|
||||
tdLog.sleep(1)
|
||||
tdSql.execute("insert into tb1 values (now, 0, 'tb1')")
|
||||
tdLog.sleep(4)
|
||||
tdSql.execute("insert into tb2 values (now, 2, 'tb2')")
|
||||
tdLog.sleep(4)
|
||||
tdSql.execute("insert into tb3 values (now, 0, 'tb3')")
|
||||
|
||||
tdSql.waitedQuery("select * from strm", 4, 60)
|
||||
tdSql.checkRows(4)
|
||||
tdSql.checkData(0, 2, 0.000000000)
|
||||
if tdSql.getData(0, 3) == 'tb2':
|
||||
tdLog.exit("unexpected value of data03")
|
||||
if tdSql.getData(1, 3) == 'tb2':
|
||||
tdLog.exit("unexpected value of data13")
|
||||
if tdSql.getData(2, 3) == 'tb2':
|
||||
tdLog.exit("unexpected value of data23")
|
||||
if tdSql.getData(3, 3) == 'tb2':
|
||||
tdLog.exit("unexpected value of data33")
|
||||
|
||||
tdLog.info("add table tb4 to see if stream still works correctly")
|
||||
# The vnode client needs to refresh metadata cache to allow strm calculate tb4's data.
|
||||
# But the current refreshing frequency is every 10 min
|
||||
# commented out the case below to save running time
|
||||
tdSql.execute("create table tb4 using stb tags('a4')")
|
||||
tdSql.execute("insert into tb4 values(now, 4, 'tb4')")
|
||||
tdSql.waitedQuery("select * from strm order by ts desc", 6, 60)
|
||||
tdSql.checkRows(6)
|
||||
tdSql.checkData(0, 2, 4)
|
||||
tdSql.checkData(0, 3, "tb4")
|
||||
|
||||
tdLog.info("change tag values to see if stream still works correctly")
|
||||
tdSql.execute("alter table tb4 set tag t1='b4'")
|
||||
tdLog.sleep(3)
|
||||
tdSql.execute("insert into tb1 values (now, 1, 'tb1_a1')")
|
||||
tdLog.sleep(4)
|
||||
tdSql.execute("insert into tb4 values (now, -4, 'tb4_b4')")
|
||||
tdSql.waitedQuery("select * from strm order by ts desc", 8, 100)
|
||||
tdSql.checkRows(8)
|
||||
tdSql.checkData(0, 2, 1)
|
||||
tdSql.checkData(0, 3, "tb1_a1")
|
||||
|
||||
def datatypes(self):
|
||||
tdLog.debug("begin data types")
|
||||
tdSql.prepare()
|
||||
tdSql.execute("create table stb3 (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(15), c6 nchar(15), c7 bool) tags(t1 int, t2 binary(15))")
|
||||
tdSql.execute("create table tb0 using stb3 tags(0, 'tb0')")
|
||||
tdSql.execute("create table tb1 using stb3 tags(1, 'tb1')")
|
||||
tdSql.execute("create table tb2 using stb3 tags(2, 'tb2')")
|
||||
tdSql.execute("create table tb3 using stb3 tags(3, 'tb3')")
|
||||
tdSql.execute("create table tb4 using stb3 tags(4, 'tb4')")
|
||||
|
||||
tdSql.execute("create table strm0 as select count(ts), count(c1), max(c2), min(c4), first(c5), last(c6) from stb3 where ts < now + 30s interval(4s) sliding(2s)")
|
||||
#tdSql.execute("create table strm0 as select count(ts), count(c1), max(c2), min(c4), first(c5) from stb where ts < now + 30s interval(4s) sliding(2s)")
|
||||
tdLog.sleep(1)
|
||||
tdSql.execute("insert into tb0 values (now, 0, 0, 0, 0, 'binary0', '涛思0', true) tb1 values (now, 1, 1, 1, 1, 'binary1', '涛思1', false) tb2 values (now, 2, 2, 2, 2, 'binary2', '涛思2', true) tb3 values (now, 3, 3, 3, 3, 'binary3', '涛思3', false) tb4 values (now, 4, 4, 4, 4, 'binary4', '涛思4', true) ")
|
||||
|
||||
tdSql.waitedQuery("select * from strm0 order by ts desc", 2, 120)
|
||||
tdSql.checkRows(2)
|
||||
|
||||
tdSql.execute("insert into tb0 values (now, 10, 10, 10, 10, 'binary0', '涛思0', true) tb1 values (now, 11, 11, 11, 11, 'binary1', '涛思1', false) tb2 values (now, 12, 12, 12, 12, 'binary2', '涛思2', true) tb3 values (now, 13, 13, 13, 13, 'binary3', '涛思3', false) tb4 values (now, 14, 14, 14, 14, 'binary4', '涛思4', true) ")
|
||||
tdSql.waitedQuery("select * from strm0 order by ts desc", 4, 120)
|
||||
tdSql.checkRows(4)
|
||||
|
||||
def run(self):
|
||||
self.tbase300()
|
||||
self.tbase304()
|
||||
self.wildcardFilterOnTags()
|
||||
self.datatypes()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -55,10 +55,7 @@ class TDTestCase:
|
|||
tdSql.checkRows(tbNum + 1)
|
||||
|
||||
tdLog.info("===== step3 =====")
|
||||
tdLog.info("sleeping 120 seconds")
|
||||
time.sleep(120)
|
||||
tdSql.query("select * from s0")
|
||||
|
||||
tdSql.waitedQuery("select * from s0", 1, 120)
|
||||
try:
|
||||
tdSql.checkData(0, 1, rowNum)
|
||||
tdSql.checkData(0, 2, rowNum)
|
||||
|
@ -82,10 +79,7 @@ class TDTestCase:
|
|||
tdSql.checkRows(tbNum + 1)
|
||||
|
||||
tdLog.info("===== step7 =====")
|
||||
tdLog.info("sleeping 120 seconds")
|
||||
time.sleep(120)
|
||||
|
||||
tdSql.query("select * from s0")
|
||||
tdSql.waitedQuery("select * from s0", 1, 120)
|
||||
try:
|
||||
tdSql.checkData(0, 1, rowNum)
|
||||
tdSql.checkData(0, 2, rowNum)
|
||||
|
@ -108,10 +102,7 @@ class TDTestCase:
|
|||
tdSql.checkRows(tbNum + 2)
|
||||
|
||||
tdLog.info("===== step9 =====")
|
||||
tdLog.info("sleeping 120 seconds")
|
||||
time.sleep(120)
|
||||
|
||||
tdSql.query("select * from s1")
|
||||
tdSql.waitedQuery("select * from s1", 1, 120)
|
||||
try:
|
||||
tdSql.checkData(0, 1, rowNum * tbNum)
|
||||
tdSql.checkData(0, 2, rowNum * tbNum)
|
||||
|
@ -134,9 +125,7 @@ class TDTestCase:
|
|||
tdSql.checkRows(tbNum + 2)
|
||||
|
||||
tdLog.info("===== step13 =====")
|
||||
tdLog.info("sleeping 120 seconds")
|
||||
time.sleep(120)
|
||||
tdSql.query("select * from s1")
|
||||
tdSql.waitedQuery("select * from s1", 1, 120)
|
||||
try:
|
||||
tdSql.checkData(0, 1, rowNum * tbNum)
|
||||
tdSql.checkData(0, 2, rowNum * tbNum)
|
||||
|
|
|
@ -53,8 +53,7 @@ class TDTestCase:
|
|||
tdSql.checkRows(tbNum + 1)
|
||||
|
||||
tdLog.info("===== step3 =====")
|
||||
time.sleep(120)
|
||||
tdSql.query("select * from s0")
|
||||
tdSql.waitedQuery("select * from s0", 1, 120)
|
||||
try:
|
||||
tdSql.checkData(0, 1, rowNum)
|
||||
except Exception as e:
|
||||
|
@ -81,8 +80,7 @@ class TDTestCase:
|
|||
tdLog.info(repr(e))
|
||||
|
||||
tdLog.info("===== step7 =====")
|
||||
time.sleep(120)
|
||||
tdSql.query("select * from s0")
|
||||
tdSql.waitedQuery("select * from s0", 1, 120)
|
||||
try:
|
||||
tdSql.checkData(0, 1, rowNum)
|
||||
tdSql.checkData(0, 2, rowNum)
|
||||
|
@ -107,8 +105,7 @@ class TDTestCase:
|
|||
tdSql.checkRows(tbNum + 2)
|
||||
|
||||
tdLog.info("===== step9 =====")
|
||||
time.sleep(120)
|
||||
tdSql.query("select * from s1")
|
||||
tdSql.waitedQuery("select * from s1", 1, 120)
|
||||
try:
|
||||
tdSql.checkData(0, 1, totalNum)
|
||||
tdSql.checkData(0, 2, totalNum)
|
||||
|
@ -137,8 +134,7 @@ class TDTestCase:
|
|||
tdLog.info(repr(e))
|
||||
|
||||
tdLog.info("===== step13 =====")
|
||||
time.sleep(120)
|
||||
tdSql.query("select * from s1")
|
||||
tdSql.waitedQuery("select * from s1", 1, 120)
|
||||
try:
|
||||
tdSql.checkData(0, 1, totalNum)
|
||||
#tdSql.checkData(0, 2, None)
|
||||
|
|
|
@ -29,10 +29,8 @@ class TDSql:
|
|||
self.cursor = cursor
|
||||
|
||||
if (log):
|
||||
frame = inspect.stack()[1]
|
||||
callerModule = inspect.getmodule(frame[0])
|
||||
callerFilename = callerModule.__file__
|
||||
self.cursor.log(callerFilename + ".sql")
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
self.cursor.log(caller.filename + ".sql")
|
||||
|
||||
def close(self):
|
||||
self.cursor.close()
|
||||
|
@ -55,12 +53,8 @@ class TDSql:
|
|||
except BaseException:
|
||||
expectErrNotOccured = False
|
||||
if expectErrNotOccured:
|
||||
frame = inspect.stack()[1]
|
||||
callerModule = inspect.getmodule(frame[0])
|
||||
callerFilename = callerModule.__file__
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, expect error not occured" %
|
||||
(callerFilename, sql))
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
tdLog.exit("%s(%d) failed: sql:%s, expect error not occured" % (caller.filename, caller.lineno, sql))
|
||||
else:
|
||||
self.queryRows = 0
|
||||
self.queryCols = 0
|
||||
|
@ -69,75 +63,68 @@ class TDSql:
|
|||
|
||||
def query(self, sql):
|
||||
self.sql = sql
|
||||
self.cursor.execute(sql)
|
||||
self.queryResult = self.cursor.fetchall()
|
||||
self.queryRows = len(self.queryResult)
|
||||
self.queryCols = len(self.cursor.description)
|
||||
# if self.queryRows == 1 and self.queryCols == 1:
|
||||
# tdLog.info("sql:%s, rows:%d cols:%d data:%s" % (self.sql, self.queryRows, self.queryCols, self.queryResult[0][0]))
|
||||
# else:
|
||||
# tdLog.info("sql:%s, rows:%d cols:%d" % (self.sql, self.queryRows, self.queryCols))
|
||||
try:
|
||||
self.cursor.execute(sql)
|
||||
self.queryResult = self.cursor.fetchall()
|
||||
self.queryRows = len(self.queryResult)
|
||||
self.queryCols = len(self.cursor.description)
|
||||
except Exception as e:
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
args = (caller.filename, caller.lineno, sql, repr(e))
|
||||
tdLog.exit("%s(%d) failed: sql:%s, %s" % args)
|
||||
return self.queryRows
|
||||
|
||||
def waitedQuery(self, sql, expectRows, timeout):
|
||||
tdLog.info("sql: %s, try to retrieve %d rows in %d seconds" % (sql, expectRows, timeout))
|
||||
self.sql = sql
|
||||
try:
|
||||
for i in range(timeout):
|
||||
self.cursor.execute(sql)
|
||||
self.queryResult = self.cursor.fetchall()
|
||||
self.queryRows = len(self.queryResult)
|
||||
self.queryCols = len(self.cursor.description)
|
||||
if self.queryRows >= expectRows:
|
||||
return (self.queryRows, i)
|
||||
time.sleep(1)
|
||||
except Exception as e:
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
args = (caller.filename, caller.lineno, sql, repr(e))
|
||||
tdLog.exit("%s(%d) failed: sql:%s, %s" % args)
|
||||
return (self.queryRows, timeout)
|
||||
|
||||
def checkRows(self, expectRows):
|
||||
if self.queryRows != expectRows:
|
||||
frame = inspect.stack()[1]
|
||||
callerModule = inspect.getmodule(frame[0])
|
||||
callerFilename = callerModule.__file__
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, queryRows:%d != expect:%d" %
|
||||
(callerFilename, self.sql, self.queryRows, expectRows))
|
||||
tdLog.info("sql:%s, queryRows:%d == expect:%d" %
|
||||
(self.sql, self.queryRows, expectRows))
|
||||
if self.queryRows == expectRows:
|
||||
tdLog.info("sql:%s, queryRows:%d == expect:%d" % (self.sql, self.queryRows, expectRows))
|
||||
else:
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
args = (caller.filename, caller.lineno, self.sql, self.queryRows, expectRows)
|
||||
tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args)
|
||||
|
||||
def checkRowCol(self, row, col):
|
||||
caller = inspect.getframeinfo(inspect.stack()[2][0])
|
||||
if row < 0:
|
||||
args = (caller.filename, caller.lineno, self.sql, row)
|
||||
tdLog.exit("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args)
|
||||
if col < 0:
|
||||
args = (caller.filename, caller.lineno, self.sql, row)
|
||||
tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args)
|
||||
if row > self.queryRows:
|
||||
args = (caller.filename, caller.lineno, self.sql, row, self.queryRows)
|
||||
tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args)
|
||||
if col > self.queryCols:
|
||||
args = (caller.filename, caller.lineno, self.sql, col, self.queryCols)
|
||||
tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args)
|
||||
|
||||
def checkDataType(self, row, col, dataType):
|
||||
frame = inspect.stack()[1]
|
||||
callerModule = inspect.getmodule(frame[0])
|
||||
callerFilename = callerModule.__file__
|
||||
|
||||
if row < 0:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, row:%d is smaller than zero" %
|
||||
(callerFilename, self.sql, row))
|
||||
if col < 0:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, col:%d is smaller than zero" %
|
||||
(callerFilename, self.sql, col))
|
||||
if row > self.queryRows:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, row:%d is larger than queryRows:%d" %
|
||||
(callerFilename, self.sql, row, self.queryRows))
|
||||
if col > self.queryCols:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, col:%d is larger than queryCols:%d" %
|
||||
(callerFilename, self.sql, col, self.queryCols))
|
||||
|
||||
self.checkRowCol(row, col)
|
||||
return self.cursor.istype(col, dataType)
|
||||
|
||||
def checkData(self, row, col, data):
|
||||
frame = inspect.stack()[1]
|
||||
callerModule = inspect.getmodule(frame[0])
|
||||
callerFilename = callerModule.__file__
|
||||
|
||||
if row < 0:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, row:%d is smaller than zero" %
|
||||
(callerFilename, self.sql, row))
|
||||
if col < 0:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, col:%d is smaller than zero" %
|
||||
(callerFilename, self.sql, col))
|
||||
if row > self.queryRows:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, row:%d is larger than queryRows:%d" %
|
||||
(callerFilename, self.sql, row, self.queryRows))
|
||||
if col > self.queryCols:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, col:%d is larger than queryCols:%d" %
|
||||
(callerFilename, self.sql, col, self.queryCols))
|
||||
self.checkRowCol(row, col)
|
||||
if self.queryResult[row][col] != data:
|
||||
tdLog.exit("%s failed: sql:%s row:%d col:%d data:%s != expect:%s" % (
|
||||
callerFilename, self.sql, row, col, self.queryResult[row][col], data))
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data)
|
||||
tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args)
|
||||
|
||||
if data is None:
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
|
||||
|
@ -153,26 +140,7 @@ class TDSql:
|
|||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
|
||||
def getData(self, row, col):
|
||||
frame = inspect.stack()[1]
|
||||
callerModule = inspect.getmodule(frame[0])
|
||||
callerFilename = callerModule.__file__
|
||||
|
||||
if row < 0:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, row:%d is smaller than zero" %
|
||||
(callerFilename, self.sql, row))
|
||||
if col < 0:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, col:%d is smaller than zero" %
|
||||
(callerFilename, self.sql, col))
|
||||
if row > self.queryRows:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, row:%d is larger than queryRows:%d" %
|
||||
(callerFilename, self.sql, row, self.queryRows))
|
||||
if col > self.queryCols:
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, col:%d is larger than queryCols:%d" %
|
||||
(callerFilename, self.sql, col, self.queryCols))
|
||||
self.checkRowCol(row, col)
|
||||
return self.queryResult[row][col]
|
||||
|
||||
def executeTimes(self, sql, times):
|
||||
|
@ -185,20 +153,21 @@ class TDSql:
|
|||
|
||||
def execute(self, sql):
|
||||
self.sql = sql
|
||||
self.affectedRows = self.cursor.execute(sql)
|
||||
try:
|
||||
self.affectedRows = self.cursor.execute(sql)
|
||||
except Exception as e:
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
args = (caller.filename, caller.lineno, sql, repr(e))
|
||||
tdLog.exit("%s(%d) failed: sql:%s, %s" % args)
|
||||
return self.affectedRows
|
||||
|
||||
def checkAffectedRows(self, expectAffectedRows):
|
||||
if self.affectedRows != expectAffectedRows:
|
||||
frame = inspect.stack()[1]
|
||||
callerModule = inspect.getmodule(frame[0])
|
||||
callerFilename = callerModule.__file__
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
args = (caller.filename, caller.lineno, self.sql, self.affectedRows, expectAffectedRows)
|
||||
tdLog.exit("%s(%d) failed: sql:%s, affectedRows:%d != expect:%d" % args)
|
||||
|
||||
tdLog.exit(
|
||||
"%s failed: sql:%s, affectedRows:%d != expect:%d" %
|
||||
(callerFilename, self.sql, self.affectedRows, expectAffectedRows))
|
||||
tdLog.info("sql:%s, affectedRows:%d == expect:%d" %
|
||||
(self.sql, self.affectedRows, expectAffectedRows))
|
||||
tdLog.info("sql:%s, affectedRows:%d == expect:%d" % (self.sql, self.affectedRows, expectAffectedRows))
|
||||
|
||||
|
||||
tdSql = TDSql()
|
||||
|
|
|
@ -843,6 +843,14 @@ if $data81 != 4 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
# desc fill query
|
||||
print desc fill query
|
||||
sql select count(*) from m_fl_tb0 where ts>='2018-9-17 9:0:0' and ts<='2018-9-17 9:11:00' interval(1m) fill(value,10) order by ts desc;
|
||||
if $rows != 12 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
print =============== clear
|
||||
sql drop database $db
|
||||
sql show databases
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -422,4 +422,63 @@ if $data97 != @group_tb0@ then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
||||
#=========================== group by multi tags ======================
|
||||
sql create table st (ts timestamp, c int) tags (t1 int, t2 int, t3 int, t4 int);
|
||||
sql create table t1 using st tags(1, 1, 1, 1);
|
||||
sql create table t2 using st tags(1, 2, 2, 2);
|
||||
sql insert into t1 values ('2020-03-27 04:11:16.000', 1)('2020-03-27 04:11:17.000', 2) ('2020-03-27 04:11:18.000', 3) ('2020-03-27 04:11:19.000', 4) ;
|
||||
sql insert into t1 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.000', 2) ('2020-03-27 04:51:18.000', 3) ('2020-03-27 05:10:19.000', 4) ;
|
||||
sql insert into t2 values ('2020-03-27 04:11:16.000', 1)('2020-03-27 04:11:17.000', 2) ('2020-03-27 04:11:18.000', 3) ('2020-03-27 04:11:19.000', 4) ;
|
||||
sql insert into t2 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.000', 2) ('2020-03-27 04:51:18.000', 3) ('2020-03-27 05:10:19.000', 4) ;
|
||||
|
||||
sql select irate(c) from st where t1="1" and ts >= '2020-03-27 04:11:17.732' and ts < '2020-03-27 05:11:17.732' interval(1m) sliding(15s) group by tbname,t1,t2;
|
||||
if $rows != 40 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != t1 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 1.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data12 != t1 then
|
||||
return -1
|
||||
endi
|
||||
if $data13 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data14 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select irate(c) from st where t1="1" and ts >= '2020-03-27 04:11:17.732' and ts < '2020-03-27 05:11:17.732' interval(1m) sliding(15s) group by tbname,t1,t2 limit 1;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 1.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data12 != t2 then
|
||||
return -1
|
||||
endi
|
||||
if $data13 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data14 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -40,7 +40,7 @@ while $x < $rowNum
|
|||
endw
|
||||
print ====== tables created
|
||||
|
||||
sleep 60000
|
||||
sleep 6000
|
||||
|
||||
$ts = $ts0 + $delta
|
||||
$ts = $ts + 1
|
||||
|
|
|
@ -39,7 +39,7 @@ while $x < $rowNum
|
|||
endw
|
||||
print ====== tables created
|
||||
|
||||
sleep 60000
|
||||
sleep 6000
|
||||
|
||||
$ts = $ts0 + $delta
|
||||
$ts = $ts + 1
|
||||
|
|
|
@ -39,7 +39,7 @@ while $x < $rowNum
|
|||
endw
|
||||
print ====== tables created
|
||||
|
||||
sleep 60000
|
||||
sleep 6000
|
||||
|
||||
$ts = $ts + 1
|
||||
sql insert into $tb values ( $ts , -1, -1, -1, -1, -1)
|
||||
|
@ -47,7 +47,7 @@ $ts = $ts0 + $delta
|
|||
$ts = $ts + 1
|
||||
sql import into $tb values ( $ts , -2, -2, -2, -2, -2)
|
||||
|
||||
sleep 60000
|
||||
sleep 6000
|
||||
|
||||
sql show databases
|
||||
|
||||
|
|
|
@ -210,6 +210,11 @@ if $data10 != @70-01-01 08:01:40.200@ then
|
|||
return -1
|
||||
endi
|
||||
|
||||
print data06 = $data06
|
||||
print data07 = $data07
|
||||
print data08 = $data08
|
||||
print data00 = $data00
|
||||
|
||||
if $data07 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -255,14 +260,17 @@ endi
|
|||
print 3
|
||||
#agg + where condition
|
||||
sql select count(join_tb1.c3), count(join_tb0.ts) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts <= 100002 and join_tb0.c7 = true;
|
||||
|
||||
$val = 2
|
||||
if $data00 != $val then
|
||||
print expect 2, actaul: $data00
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != $val then
|
||||
print $data00
|
||||
|
||||
if $data00 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -412,7 +420,7 @@ endi
|
|||
|
||||
#======================limit offset===================================
|
||||
# tag values not int
|
||||
sql_error select count(*) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t2=join_mt1.t2; #!!!!!
|
||||
sql_error select count(*) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t2=join_mt1.t2;
|
||||
|
||||
# tag type not identical
|
||||
sql_error select count(*) from join_mt0, join_mt1 where join_mt1.t2 = join_mt0.t1 and join_mt1.ts=join_mt0.ts;
|
||||
|
|
|
@ -327,3 +327,7 @@ endi
|
|||
if $data98 != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#add one more test case
|
||||
sql select max(c1), last(c8) from lm2_db0.lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(linear) limit 10 offset 4089;"
|
||||
|
||||
|
|
|
@ -636,6 +636,15 @@ if $data00 != $data01 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select first(ts), ts from select_tags_tb1
|
||||
if $row != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != @70-01-01 08:01:50.001@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print ======= selectivity + tags + group by + tags + filter + interval ================
|
||||
sql select first(c1), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname;
|
||||
if $row != 3 then
|
||||
|
|
|
@ -0,0 +1,461 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||
system sh/cfg.sh -n dnode1 -c debugFlag -v 135
|
||||
system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sleep 1000
|
||||
sql connect
|
||||
|
||||
$dbPrefix = sliding_db
|
||||
$tbPrefix = sliding_tb
|
||||
$mtPrefix = sliding_mt
|
||||
$tbNum = 8
|
||||
$rowNum = 10000
|
||||
$totalNum = $tbNum * $rowNum
|
||||
|
||||
print =============== sliding.sim
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
|
||||
$tstart = 946656000000
|
||||
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
|
||||
sql drop database if exits $db -x step1
|
||||
step1:
|
||||
sql create database if not exists $db tables 4 keep 36500
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
$tg2 = ' . abc
|
||||
$tg2 = $tg2 . '
|
||||
sql create table $tb using $mt tags( $i , $tg2 )
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$ms = $x . m
|
||||
$c = $x / 100
|
||||
$c = $c * 100
|
||||
$c = $x - $c
|
||||
|
||||
$binary = ' . binary
|
||||
$binary = $binary . $c
|
||||
$binary = $binary . '
|
||||
|
||||
$nchar = ' . nchar
|
||||
$nchar = $nchar . $c
|
||||
$nchar = $nchar . '
|
||||
|
||||
sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar )
|
||||
$tstart = $tstart + 30
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
$tstart = 946656000000
|
||||
endw
|
||||
|
||||
sleep 100
|
||||
|
||||
$i1 = 1
|
||||
$i2 = 0
|
||||
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
|
||||
$dbPrefix = sliding_db
|
||||
$tbPrefix = sliding_tb
|
||||
$mtPrefix = sliding_mt
|
||||
|
||||
$tb1 = $tbPrefix . $i1
|
||||
$tb2 = $tbPrefix . $i2
|
||||
$ts1 = $tb1 . .ts
|
||||
$ts2 = $tb2 . .ts
|
||||
|
||||
print ===============================interval_sliding query
|
||||
sql select count(*) from sliding_tb0 interval(30s) sliding(30s);
|
||||
if $row != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @00-01-01 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != @00-01-01 00:00:30.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 1000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select stddev(c1) from sliding_tb0 interval(10a) sliding(10a)
|
||||
if $row != 10000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @00-01-01 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data90 != @00-01-01 00:00:00.270@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data91 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select stddev(c1),count(c2),first(c3),last(c4) from sliding_tb0 interval(10a) sliding(10a) order by ts desc;
|
||||
if $row != 10000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @00-01-01 00:04:59.970@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 99 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data04 != 99 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data90 != @00-01-01 00:04:59.700@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data91 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data92 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data93 != 90 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data94 != 90 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(c2),last(c4) from sliding_tb0 interval(30s) sliding(10s) order by ts asc;
|
||||
if $row != 30 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @00-01-01 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 99 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(c2),stddev(c3),first(c4),last(c4) from sliding_tb0 where ts>'2000-01-01 0:0:0' and ts<'2000-1-1 0:0:31' interval(30s) sliding(30s) order by ts asc;
|
||||
if $row != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data04 != 99 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 999 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 28.837977152 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#interval offset + limit
|
||||
sql select count(c2), first(c3),stddev(c4) from sliding_tb0 interval(10a) sliding(10a) order by ts desc limit 10 offset 990;
|
||||
if $row != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @00-01-01 00:04:30.270@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data90 != @00-01-01 00:04:30.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data91 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data92 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data93 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#interval offset test
|
||||
sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(30s) order by ts asc limit 1000 offset 1;
|
||||
if $row != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @00-01-01 00:00:30.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 99 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data80 != @00-01-01 00:04:30.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data81 != 1000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(c2),last(c4),stddev(c3) from sliding_tb0 where ts>'2000-1-1 0:0:0' and ts<'2000-1-1 0:0:31' interval(30s) sliding(30s) order by ts asc limit 1000 offset 0;
|
||||
if $row != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @00-01-01 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 999 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 99 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 28.837977152 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != @00-01-01 00:00:30.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 34 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 33 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data13 != 9.810708435 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 1;
|
||||
if $row != 14 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @00-01-01 00:00:20.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 66 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 28.866070048 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data90 != @00-01-01 00:03:20.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data91 != 1000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data92 != 66 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by ts asc limit 100 offset 14;
|
||||
if $row != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(30s) order by ts desc;
|
||||
if $row != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#00-01-01 00:04:30.000| 10| 0| 0.000000000| 0.000000000|
|
||||
if $data00 != @00-01-01 00:04:30.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(30s) sliding(20s) order by ts desc limit 1 offset 15;
|
||||
if $row != 0 then
|
||||
return -1
|
||||
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(10a) order by ts asc limit 1000;
|
||||
if $row != 100 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @00-01-01 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 9.521904571 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data05 != 33 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != @00-01-01 00:00:00.010@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 9.521904571 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data15 != 33 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data95 != 33 then
|
||||
return -1
|
||||
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(10a) order by ts desc limit 1000;
|
||||
if $row != 100 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @00-01-01 00:00:00.990@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data90 != @00-01-01 00:00:00.900@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data91 != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data92 != 1.118033989 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data93 != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data94 != 30.00000 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;
|
||||
|
||||
print ========================query on super table
|
||||
|
||||
print ========================error case
|
||||
sql_error select sum(c1) from sliding_tb0 interval(1a) sliding(1a);
|
||||
sql_error select sum(c1) from sliding_tb0 interval(10a) sliding(12a);
|
||||
sql_error select sum(c1) from sliding_tb0 sliding(1n) interval(1y);
|
||||
sql_error select sum(c1) from sliding_tb0 interval(-1y) sliding(1n);
|
||||
sql_error select sum(c1) from sliding_tb0 interval(1y) sliding(-1n);
|
||||
sql_error select sum(c1) from sliding_tb0 interval(0) sliding(0);
|
||||
sql_error select sum(c1) from sliding_tb0 interval(0m) sliding(0m);
|
||||
sql_error select sum(c1) from sliding_tb0 interval(m) sliding(m);
|
||||
sql_error select sum(c1) from sliding_tb0 sliding(4m);
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -1,212 +0,0 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||
system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 5
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sleep 3000
|
||||
sql connect
|
||||
print ======================== stream.sim
|
||||
sleep 2000
|
||||
$db = strm_db
|
||||
$tb = tb
|
||||
$mt = mt
|
||||
$strm = strm
|
||||
$tbNum = 10
|
||||
$rowNum = 20
|
||||
$totalNum = 200
|
||||
|
||||
print =============== set up DB
|
||||
$i = 0
|
||||
|
||||
sql drop database if exists $db
|
||||
sql create database $db
|
||||
sql use $db
|
||||
|
||||
|
||||
## [TBASE300]
|
||||
print ====== TBASE-300
|
||||
sql create table mt (ts timestamp, c1 int, c2 int) tags(t1 int)
|
||||
sql create table tb1 using mt tags(1)
|
||||
sql create table tb2 using mt tags(2)
|
||||
sql create table strm as select count(*), avg(c1), sum(c2), max(c1), min(c2),first(c1), last(c2) from mt interval(4s) sliding(2s)
|
||||
sleep 10000
|
||||
sql insert into tb2 values(now,1,1)
|
||||
sql insert into tb1 values(now,1,1)
|
||||
sleep 4000
|
||||
sql select * from mt
|
||||
sql select * from strm
|
||||
sql drop table tb1
|
||||
sleep 100000
|
||||
sql select * from strm
|
||||
if $rows != 2 then
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
sql drop table tb2
|
||||
sql drop table mt
|
||||
sql drop table strm
|
||||
|
||||
## [TBASE304]
|
||||
print ====== TBASE-304
|
||||
sleep 10000
|
||||
# we cannot reset query cache in server side, as a workaround,
|
||||
# set super table name to mt304, need to change back to mt later
|
||||
print create mt304
|
||||
sql create table mt304 (ts timestamp, c1 int) tags(t1 int, t2 int)
|
||||
print create tb1
|
||||
sql create table tb1 using mt304 tags(1, 1)
|
||||
print create tb2
|
||||
sql create table tb2 using mt304 tags(1, -1)
|
||||
print create strm
|
||||
sql create table strm as select count(*), avg(c1) from mt304 where t2 >= 0 interval(4s) sliding(2s)
|
||||
sql insert into tb1 values (now,1)
|
||||
sql insert into tb2 values (now,2)
|
||||
sleep 100000
|
||||
sql select * from strm;
|
||||
if $rows != 2 then
|
||||
print ==== expect rows = 2, actually returned rows = $rows
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
print data02 = $data02
|
||||
if $data02 != 1.000000000 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table mt304 drop tag t2;
|
||||
sql insert into tb2 values (now,2);
|
||||
sql insert into tb1 values (now,1);
|
||||
sql select * from strm;
|
||||
sql alter table mt304 add tag t2 int;
|
||||
sleep 10000
|
||||
sql select * from strm
|
||||
|
||||
print ================= create a stream with a wildcard filter on tags of a STable
|
||||
sql drop database $db
|
||||
sql create database $db
|
||||
sql use $db
|
||||
sql create table stb (ts timestamp, c1 int, c2 binary(10)) tags(t1 binary(10))
|
||||
sql create table tb1 using stb tags('a1')
|
||||
sql create table tb2 using stb tags('b2')
|
||||
sql create table tb3 using stb tags('a3')
|
||||
sql create table strm as select count(*), avg(c1), first(c2) from stb where t1 like 'a%' interval(4s) sliding(2s)
|
||||
sleep 11000
|
||||
sql insert into tb1 values (now, 0, 'tb1')
|
||||
sleep 4000
|
||||
sql insert into tb2 values (now, 2, 'tb2')
|
||||
sleep 4000
|
||||
sql insert into tb3 values (now, 0, 'tb3')
|
||||
sleep 60000
|
||||
|
||||
sql describe strm
|
||||
if $rows == 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from strm
|
||||
sleep 1000
|
||||
print ======== data0: $data00 $data01 $data02 $data03
|
||||
print ======== data1: $data10 $data11 $data12 $data13
|
||||
print ======== data2: $data20 $data21 $data22 $data23
|
||||
print ======== data3: $data30 $data31 $data32 $data33
|
||||
if $rows != 4 then
|
||||
print ==== expect rows = 4, actually returned rows = $rows
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 == tb2 then
|
||||
return -1
|
||||
endi
|
||||
if $data13 == tb2 then
|
||||
return -1
|
||||
endi
|
||||
if $data23 == tb2 then
|
||||
return -1
|
||||
endi
|
||||
if $data33 == tb2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
## The vnode client needs to refresh metadata cache to allow strm calculate tb4's data. But the current refreshing frequency is every 10 min
|
||||
## commented out the case below to save running time
|
||||
sql create table tb4 using stb tags('a4')
|
||||
sql insert into tb4 values(now, 4, 'tb4')
|
||||
sleep 60000
|
||||
sql select * from strm order by ts desc
|
||||
print ======== data0: $data00 $data01 $data02 $data03
|
||||
#print ======== data1: $data10 $data11 $data12 $data13
|
||||
#print ======== data2: $data20 $data21 $data22 $data23
|
||||
#print ======== data3: $data30 $data31 $data32 $data33
|
||||
if $rows != 6 then
|
||||
print ==== expect rows = 6, actually returned rows = $rows
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 4.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != tb4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== change tag values to see if stream still works correctly
|
||||
sql alter table tb4 set tag t1='b4'
|
||||
sleep 3000 # waiting for new tag valid
|
||||
sql insert into tb1 values (now, 1, 'tb1_a1')
|
||||
sleep 4000
|
||||
sql insert into tb4 values (now, -4, 'tb4_b4')
|
||||
sleep 100000
|
||||
sql select * from strm order by ts desc
|
||||
sleep 1000
|
||||
print ======== data0: $data00 $data01 $data02 $data03
|
||||
#print ======== data1: $data10 $data11 $data12 $data13
|
||||
#print ======== data2: $data20 $data21 $data22 $data23
|
||||
#print ======== data3: $data30 $data31 $data32 $data33
|
||||
if $rows != 8 then
|
||||
print ==== expect rows = 8, actually returned rows = $rows
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 1.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != tb1_a1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql drop database if exists $db
|
||||
sql drop database if exists strm_db_0
|
||||
sql create database strm_db_0
|
||||
sql use strm_db_0
|
||||
|
||||
sql create table stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(15), c6 nchar(15), c7 bool) tags(t1 int, t2 binary(15))
|
||||
sql create table tb0 using stb tags(0, 'tb0')
|
||||
sql create table tb1 using stb tags(1, 'tb1')
|
||||
sql create table tb2 using stb tags(2, 'tb2')
|
||||
sql create table tb3 using stb tags(3, 'tb3')
|
||||
sql create table tb4 using stb tags(4, 'tb4')
|
||||
|
||||
sql create table strm0 as select count(ts), count(c1), max(c2), min(c4), first(c5), last(c6) from stb where ts < now + 30s interval(4s) sliding(2s)
|
||||
sleep 1000
|
||||
sql insert into tb0 values (now, 0, 0, 0, 0, 'binary0', '涛思0', true) tb1 values (now, 1, 1, 1, 1, 'binary1', '涛思1', false) tb2 values (now, 2, 2, 2, 2, 'binary2', '涛思2', true) tb3 values (now, 3, 3, 3, 3, 'binary3', '涛思3', false) tb4 values (now, 4, 4, 4, 4, 'binary4', '涛思4', true)
|
||||
sleep 30000
|
||||
sql select * from strm0 order by ts desc
|
||||
sleep 1000
|
||||
if $rows != 2 then
|
||||
print ==== expect rows = 2, actually returned rows = $rows
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql insert into tb0 values (now, 10, 10, 10, 10, 'binary0', '涛思0', true) tb1 values (now, 11, 11, 11, 11, 'binary1', '涛思1', false) tb2 values (now, 12, 12, 12, 12, 'binary2', '涛思2', true) tb3 values (now, 13, 13, 13, 13, 'binary3', '涛思3', false) tb4 values (now, 14, 14, 14, 14, 'binary4', '涛思4', true)
|
||||
sleep 30000
|
||||
sql select * from strm0 order by ts desc
|
||||
sleep 10000
|
||||
if $rows == 4 then
|
||||
print ==== actually returned rows = $rows, expect always not equal to 4
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -28,16 +28,27 @@ sql insert into tb3 using stb (t3) tags (3.3) values ( now + 3s, 'binary3', 3
|
|||
|
||||
sql insert into tb4 (ts, c1, c2) using stb (t1, t2) tags ('tag4', 4) values ( now + 4s, 'binary4', 4)
|
||||
sql insert into tb5 (ts, c1, c3) using stb (t1, t3) tags ('tag5', 11.11) values ( now + 5s, 'binary5', 5.5)
|
||||
|
||||
sql insert into tb6 (ts, c1, c3) using stb tags ('tag5', 6, 11.11) values ( now + 5s, 'binary6', 6.6)
|
||||
sql insert into tb7 (ts, c1, c2, c3) using stb tags ('tag5', 7, 11.11) values ( now + 5s, 'binary7', 7, 7.7)
|
||||
sql select * from stb order by ts asc
|
||||
if $rows != 5 then
|
||||
if $rows != 7 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql_error insert into tb11 using stb (t1) tags () values ( now + 1s, 'binary1', 1, 1.1)
|
||||
sql_error insert into tb12 using stb (t1, t3) tags () values ( now + 1s, 'binary1', 1, 1.1)
|
||||
sql_error insert into tb13 using stb (t1, t2, t3) tags (8, 9.13, 'ac') values ( now + 1s, 'binary1', 1, 1.1)
|
||||
sql_error insert into tb14 using stb () tags (2) values ( now + 2s, 'binary2', 2, 2.2)
|
||||
sql_error insert into tb15 using stb (t2, t3) tags (3.3) values ( now + 3s, 'binary3', 3, 3.3)
|
||||
sql_error insert into tb16 (ts, c1, c2) using stb (t1, t2) tags ('tag4', 4) values ( now + 4s, 'binary4')
|
||||
sql_error insert into tb17 (ts, c1, c3) using stb (t1, t3) tags ('tag5', 11.11, 5) values ( now + 5s, 'binary5', 5.5)
|
||||
sql_error insert into tb18 (ts, c1, c3) using stb tags ('tag5', 16) values ( now + 5s, 'binary6', 6.6)
|
||||
sql_error insert into tb19 (ts, c1, c2, c3) using stb tags (19, 'tag5', 91.11) values ( now + 5s, 'binary7', 7, 7.7)
|
||||
|
||||
|
||||
|
||||
sql create table stbx (ts timestamp, c1 binary(10), c2 int, c3 float) tags (t1 binary(10), t2 int, t3 float)
|
||||
sql insert into tb100 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag100', 100, 100.9) values ( now + 10s, 'binary100', 100, 100.9) tb101 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag101', 101, 101.9) values ( now + 10s, 'binary101', 101, 101.9) tb102 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag102', 102, 102.9) values ( now + 10s, 'binary102', 102, 102.9)
|
||||
sql insert into tb100 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag100', 100, 100.123456) values ( now + 10s, 'binary100', 100, 100.9) tb101 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag101', 101, 101.9) values ( now + 10s, 'binary101', 101, 101.9) tb102 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag102', 102, 102.9) values ( now + 10s, 'binary102', 102, 102.9)
|
||||
|
||||
sql select * from stbx
|
||||
if $rows != 3 then
|
||||
|
@ -52,9 +63,38 @@ if $data05 != 100 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
#if $data06 != 100.90000 then
|
||||
# print "expect: 100.90000, act: $data06"
|
||||
# return -1
|
||||
#endi
|
||||
if $data06 != 100.12346 then
|
||||
print "expect: 100.12346, act: $data06"
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql create table stby (ts timestamp, c1 binary(10), c2 int, c3 float) tags (t1 binary(10), t2 int, t3 float)
|
||||
sql reset query cache
|
||||
sql insert into tby1 using stby (t1) tags ('tag1') values ( now + 1s, 'binary1', 1, 1.1)
|
||||
sql insert into tby2 using stby (t2) tags (2) values ( now + 2s, 'binary2', 2, 2.2)
|
||||
sql insert into tby3 using stby (t3) tags (3.3) values ( now + 3s, 'binary3', 3, 3.3)
|
||||
sql insert into tby4 (ts, c1, c2) using stby (t1, t2) tags ('tag4', 4) values ( now + 4s, 'binary4', 4)
|
||||
sql insert into tby5 (ts, c1, c3) using stby (t1, t3) tags ('tag5', 11.11) values ( now + 5s, 'binary5', 5.5)
|
||||
sql insert into tby6 (ts, c1, c3) using stby tags ('tag5', 6, 11.11) values ( now + 5s, 'binary6', 6.6)
|
||||
sql insert into tby7 (ts, c1, c2, c3) using stby tags ('tag5', 7, 11.11) values ( now + 5s, 'binary7', 7, 7.7)
|
||||
sql select * from stby order by ts asc
|
||||
if $rows != 7 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql reset query cache
|
||||
sql insert into tby1 using stby (t1) tags ('tag1') values ( now + 1s, 'binary1y', 1, 1.1)
|
||||
sql insert into tby2 using stby (t2) tags (2) values ( now + 2s, 'binary2y', 2, 2.2)
|
||||
sql insert into tby3 using stby (t3) tags (3.3) values ( now + 3s, 'binary3y', 3, 3.3)
|
||||
sql insert into tby4 (ts, c1, c2) using stby (t1, t2) tags ('tag4', 4) values ( now + 4s, 'binary4y', 4)
|
||||
sql insert into tby5 (ts, c1, c3) using stby (t1, t3) tags ('tag5', 11.11) values ( now + 5s, 'binary5y', 5.5)
|
||||
sql insert into tby6 (ts, c1, c3) using stby tags ('tag5', 6, 11.11) values ( now + 5s, 'binary6y', 6.6)
|
||||
sql insert into tby7 (ts, c1, c2, c3) using stby tags ('tag5', 7, 11.11) values ( now + 5s, 'binary7y', 7, 7.7)
|
||||
|
||||
sql select * from stby order by ts asc
|
||||
if $rows != 14 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -23,7 +23,7 @@ sql create table stb (ts timestamp, c1 int) tags (t1 binary(10))
|
|||
sql create table tb1 using stb tags('*')
|
||||
sql create table tb2 using stb tags('%')
|
||||
sql create table tb3 using stb tags('')
|
||||
sql create table tb4 using stb tags('/'')
|
||||
sql create table tb4 using stb tags('\'')
|
||||
|
||||
sql insert into tb1 values ( $ts0 , 1)
|
||||
sql insert into tb2 values ( $ts0 , 2)
|
||||
|
@ -54,7 +54,7 @@ if $data01 != 3 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select * from stb where t1 = '/''
|
||||
sql select * from stb where t1 = '\''
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -70,9 +70,8 @@ if $data01 != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql_error select * from stb where t1 > 1
|
||||
sql_error select * from stb where t1 > '1'
|
||||
sql_error select * from stb where t1 > 'a'
|
||||
sql select * from stb where t1 > '1'
|
||||
sql select * from stb where t1 > 'a'
|
||||
|
||||
## wildcard '%'
|
||||
#sql select * from stb where t1 like '%'
|
||||
|
@ -91,7 +90,7 @@ if $data01 != 3 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select * from stb where t1 like '/''
|
||||
sql select * from stb where t1 like '\''
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -104,3 +103,50 @@ sql show databases
|
|||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print ============tbase-1328
|
||||
|
||||
sql drop database if exists testselectwheretags;
|
||||
sql CREATE DATABASE IF NOT EXISTS testselectwheretags;
|
||||
sql USE testselectwheretags;
|
||||
sql CREATE TABLE IF NOT EXISTS st1 (ts TIMESTAMP, v1 INT, v2 FLOAT, v3 BOOL) TAGS (farm NCHAR(2), period NCHAR(2), line NCHAR(2), unit INT);
|
||||
sql CREATE TABLE IF NOT EXISTS a01 USING st1 TAGS ('2', 'c', '2', 2);
|
||||
sql CREATE TABLE IF NOT EXISTS a02 USING st1 TAGS ('1', 'c', 'a', 1);
|
||||
sql CREATE TABLE IF NOT EXISTS a03 USING st1 TAGS ('1', 'c', '02', 1);
|
||||
sql INSERT INTO a01 VALUES (1574872693209, 3, 3.000000, 1);
|
||||
sql INSERT INTO a02 VALUES (1574872683933, 2, 2.000000, 1);
|
||||
sql INSERT INTO a03 VALUES (1574872683933, 2, 2.000000, 1);
|
||||
|
||||
sql select * from st1 where line='02';
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql CREATE TABLE IF NOT EXISTS st2 (ts TIMESTAMP, v1 INT, v2 FLOAT) TAGS (farm BINARY(2), period BINARY(2), line BINARY(2));
|
||||
|
||||
sql CREATE TABLE IF NOT EXISTS b01 USING st2 TAGS ('01', '01', '01');
|
||||
sql CREATE TABLE IF NOT EXISTS b02 USING st2 TAGS ('01', '01', '01');
|
||||
sql CREATE TABLE IF NOT EXISTS b03 USING st2 TAGS ('01', '02', '01');
|
||||
sql CREATE TABLE IF NOT EXISTS b04 USING st2 TAGS ('01', '01', '02');
|
||||
|
||||
sql INSERT INTO b03 VALUES (1576043322749, 3, 3.000000);
|
||||
sql INSERT INTO b03 VALUES (1576043323596, 3, 3.000000);
|
||||
|
||||
sql INSERT INTO b02 VALUES (1576043315169, 2, 2.000000);
|
||||
sql INSERT INTO b02 VALUES (1576043316295, 2, 2.000000);
|
||||
sql INSERT INTO b02 VALUES (1576043317167, 2, 2.000000);
|
||||
|
||||
sql INSERT INTO b01 VALUES (1576043305972, 1, 1.000000);
|
||||
sql INSERT INTO b01 VALUES (1576043308513, 1, 1.000000);
|
||||
|
||||
sql select * from st2 where period='02';
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select sum(v2) from st2 group by farm,period,line;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,411 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||
system sh/cfg.sh -n dnode1 -c debugFlag -v 135
|
||||
system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sleep 1000
|
||||
sql connect
|
||||
|
||||
$dbPrefix = union_db
|
||||
$tbPrefix = union_tb
|
||||
$tbPrefix1 = union_tb_
|
||||
$mtPrefix = union_mt
|
||||
$tbNum = 10
|
||||
$rowNum = 10000
|
||||
$totalNum = $tbNum * $rowNum
|
||||
|
||||
print =============== union.sim
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
|
||||
$j = 1
|
||||
|
||||
$mt1 = $mtPrefix . $j
|
||||
|
||||
sql drop database if exits $db -x step1
|
||||
step1:
|
||||
sql create database if not exists $db maxtables 4
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int)
|
||||
|
||||
$i = 0
|
||||
$t = 1578203484000
|
||||
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$ms = $x * 1000
|
||||
$ms = $ms * 60
|
||||
|
||||
$c = $x / 100
|
||||
$c = $c * 100
|
||||
$c = $x - $c
|
||||
$binary = 'binary . $c
|
||||
$binary = $binary . '
|
||||
$nchar = 'nchar . $c
|
||||
$nchar = $nchar . '
|
||||
|
||||
$t1 = $t + $ms
|
||||
sql insert into $tb values ($t1 , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar )
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
sql create table $mt1 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int)
|
||||
|
||||
$j = 0
|
||||
$t = 1578203484000
|
||||
$rowNum = 1000
|
||||
$tbNum = 5
|
||||
$i = 0
|
||||
|
||||
while $i < $tbNum
|
||||
$tb1 = $tbPrefix1 . $j
|
||||
sql create table $tb1 using $mt1 tags( $i )
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$ms = $x * 1000
|
||||
$ms = $ms * 60
|
||||
|
||||
$c = $x / 100
|
||||
$c = $c * 100
|
||||
$c = $x - $c
|
||||
$binary = 'binary . $c
|
||||
$binary = $binary . '
|
||||
$nchar = 'nchar . $c
|
||||
$nchar = $nchar . '
|
||||
|
||||
$t1 = $t + $ms
|
||||
sql insert into $tb1 values ($t1 , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar )
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
$j = $j + 1
|
||||
endw
|
||||
|
||||
print sleep 1sec.
|
||||
sleep 1000
|
||||
|
||||
$i = 1
|
||||
$tb = $tbPrefix . $i
|
||||
|
||||
## column type not identical
|
||||
sql_error select count(*) as a from union_mt0 union all select avg(c1) as a from union_mt0
|
||||
sql_error select count(*) as a from union_mt0 union all select spread(c1) as a from union_mt0;
|
||||
|
||||
## union not supported
|
||||
sql_error (select count(*) from union_mt0) union (select count(*) from union_mt0);
|
||||
|
||||
## column type not identical
|
||||
sql_error select c1 from union_mt0 limit 10 union all select c2 from union_tb1 limit 20;
|
||||
|
||||
## union not support recursively union
|
||||
sql_error select c1 from union_tb0 limit 2 union all (select c1 from union_tb1 limit 1 union all select c1 from union_tb3 limit 2);
|
||||
sql_error (select c1 from union_tb0 limit 1 union all select c1 from union_tb1 limit 1) union all (select c1 from union_tb0 limit 10 union all select c1 from union_tb1 limit 10);
|
||||
|
||||
# union as subclause
|
||||
sql_error (select c1 from union_tb0 limit 1 union all select c1 from union_tb1 limit 1) limit 1
|
||||
|
||||
# sql with parenthese
|
||||
sql (((select c1 from union_tb0)))
|
||||
if $rows != 10000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# mixed order
|
||||
sql select ts, c1 from union_tb1 order by ts asc limit 10 union all select ts, c1 from union_tb0 order by ts desc limit 2 union all select ts, c1 from union_tb2 order by ts asc limit 10
|
||||
if $rows != 22 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @20-01-05 13:51:24.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != @20-01-05 13:52:24.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data90 != @20-01-05 14:00:24.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data91 != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# different sort order
|
||||
|
||||
# super table & normal table mixed up
|
||||
sql select c3 from union_tb0 limit 2 union all select sum(c1) as c3 from union_mt0;
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data20 != 4950000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# type compatible
|
||||
sql select c3 from union_tb0 limit 2 union all select sum(c1) as c3 from union_tb1;
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data20 != 495000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# two join subclause
|
||||
sql select count(*) as c from union_tb0, union_tb1 where union_tb0.ts=union_tb1.ts union all select union_tb0.c3 as c from union_tb0, union_tb1 where union_tb0.ts=union_tb1.ts limit 10
|
||||
if $rows != 11 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 10000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data20 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data90 != 8 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print ===========================================tags union
|
||||
# two super table tag union, limit is not active during retrieve tags query
|
||||
sql select t1 from union_mt0 union all select t1 from union_mt0 limit 1
|
||||
if $rows != 20 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data90 != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#========================================== two super table join subclause
|
||||
print ================two super table join subclause
|
||||
sql select avg(union_mt0.c1) as c from union_mt0 interval(1h) limit 10 union all select union_mt1.ts, union_mt1.c1/1.0 as c from union_mt0, union_mt1 where union_mt1.ts=union_mt0.ts and union_mt1.t1=union_mt0.t1 limit 5;
|
||||
print the rows value is: $rows
|
||||
|
||||
if $rows != 15 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# first subclause are empty
|
||||
sql select count(*) as c from union_tb0 where ts>now+10y union all select sum(c1) as c from union_tb1;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 495000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# all subclause are empty
|
||||
sql select c1 from union_tb0 limit 0 union all select c1 from union_tb1 where ts>'2021-1-1 0:0:0'
|
||||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# middle subclause empty
|
||||
sql select c1 from union_tb0 limit 1 union all select c1 from union_tb1 where ts>'2030-1-1 0:0:0' union all select last(c1) as c1 from union_tb1;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != 99 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# multi-vnode projection query
|
||||
sql (select c1 from union_mt0) union all select c1 from union_mt0;
|
||||
if $rows != 200000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# multi-vnode projection query + limit
|
||||
sql (select ts, c1 from union_mt0 limit 1) union all (select ts, c1 from union_mt0 limit 1);
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @20-01-05 13:51:24.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != @20-01-05 13:51:24.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# two aggregated functions for super tables
|
||||
sql select sum(c1) as a from union_mt0 interval(1s) limit 9 union all select ts, max(c3) as a from union_mt0 limit 2;
|
||||
if $rows != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @20-01-05 13:51:24.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != @20-01-05 13:52:24.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data20 != @20-01-05 13:53:24.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data21 != 20 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data90 != @20-01-05 15:30:24.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data91 != 99 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#1111111111111111111111111111111111111111111111111
|
||||
# two aggregated functions for normal tables
|
||||
sql select sum(c1) as a from union_tb0 limit 1 union all select sum(c3) as a from union_tb1 limit 2;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 495000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != 495000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# two super table query + interval + limit
|
||||
sql select ts, first(c3) as a from union_mt0 limit 1 union all select sum(c3) as a from union_mt0 interval(1h) limit 1;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @20-01-05 13:51:24.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != @20-01-05 13:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 360 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select server_status() union all select server_status()
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select client_version() union all select server_version()
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select database() union all select database()
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @union_db0@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != @union_db0@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -277,4 +277,44 @@ if $rows != 2 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
print ==========tbase-1363
|
||||
#sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int)
|
||||
|
||||
$i = 0
|
||||
while $i < 1
|
||||
$tb = test_null_filter
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = 0
|
||||
while $x < 10000
|
||||
$ms = $x . m
|
||||
$c = $x / 100
|
||||
$c = $c * 100
|
||||
$c = $x - $c
|
||||
$binary = 'binary . $c
|
||||
$binary = $binary . '
|
||||
$nchar = 'nchar . $c
|
||||
$nchar = $nchar . '
|
||||
sql insert into $tb values (now + $ms , null , null , null , null , null , null , null , null , null )
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
sleep 2000
|
||||
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sql select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter');
|
||||
if $row != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter');
|
||||
if $row != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -1,287 +0,0 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sleep 3000
|
||||
sql connect
|
||||
|
||||
print ======================== dnode1 start
|
||||
|
||||
$dbPrefix = m1_db
|
||||
$tbPrefix = m1_tb
|
||||
$mtPrefix = m1_mt
|
||||
$stPrefix = m1_st
|
||||
$tbNum = 10
|
||||
$rowNum = 20
|
||||
$totalNum = 200
|
||||
|
||||
print =============== step1
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
$st = $stPrefix . $i
|
||||
|
||||
sql drop databae $db -x step1
|
||||
step1:
|
||||
sql create database $db
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = -1440
|
||||
$y = 0
|
||||
while $y < $rowNum
|
||||
$ms = $x . m
|
||||
sql insert into $tb values (now $ms , $y , $y )
|
||||
$x = $x + 1
|
||||
$y = $y + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
sleep 100
|
||||
|
||||
print =============== step2 c1
|
||||
$i = 0
|
||||
$mt = $mtPrefix . $i
|
||||
|
||||
sql select count(*) from $mt interval(1d)
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . c1
|
||||
sql create table $st as select count(*) from $mt interval(1d)
|
||||
|
||||
print =============== step3 c2
|
||||
sql select count(tbcol) from $mt interval(1d)
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . c2
|
||||
sql create table $st as select count(tbcol) from $mt interval(1d)
|
||||
|
||||
print =============== step4 c3
|
||||
sql select count(tbcol2) from $mt interval(1d)
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . c3
|
||||
sql create table $st as select count(tbcol2) from $mt interval(1d)
|
||||
|
||||
print =============== step5 avg
|
||||
sql select avg(tbcol) from $mt interval(1d)
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 9.500000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . av
|
||||
print create table $st as select avg(tbcol) from $mt interval(1d)
|
||||
sql create table $st as select avg(tbcol) from $mt interval(1d)
|
||||
|
||||
print =============== step6 su
|
||||
sql select sum(tbcol) from $mt interval(1d)
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 1900 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . su
|
||||
sql create table $st as select sum(tbcol) from $mt interval(1d)
|
||||
|
||||
print =============== step7 mi
|
||||
sql select min(tbcol) from $mt interval(1d)
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . mi
|
||||
sql create table $st as select min(tbcol) from $mt interval(1d)
|
||||
|
||||
print =============== step8 ma
|
||||
sql select max(tbcol) from $mt interval(1d)
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 19 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . ma
|
||||
sql create table $st as select max(tbcol) from $mt interval(1d)
|
||||
|
||||
print =============== step9 fi
|
||||
sql select first(tbcol) from $mt interval(1d)
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . fi
|
||||
sql create table $st as select first(tbcol) from $mt interval(1d)
|
||||
|
||||
print =============== step10 la
|
||||
sql select last(tbcol) from $mt interval(1d)
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 19 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . la
|
||||
sql create table $st as select last(tbcol) from $mt interval(1d)
|
||||
|
||||
print =============== step11 st
|
||||
sql select stddev(tbcol) from $mt interval(1d) -x step11
|
||||
return -1
|
||||
step11:
|
||||
|
||||
print =============== step12 le
|
||||
sql select leastsquares(tbcol, 1, 1) from $mt interval(1d) -x step12
|
||||
return -1
|
||||
step12:
|
||||
|
||||
print =============== step13
|
||||
sql select top(tbcol, 1) from $mt interval(1d)
|
||||
|
||||
print =============== step14
|
||||
|
||||
sql select bottom(tbcol, 1) from $mt interval(1d)
|
||||
|
||||
print =============== step15 pe
|
||||
|
||||
sql select percentile(tbcol, 1) from $mt interval(1d) -x step15
|
||||
return -1
|
||||
step15:
|
||||
|
||||
print =============== step16
|
||||
sql select diff(tbcol) from $mt interval(1d) -x step16
|
||||
return -1
|
||||
step16:
|
||||
|
||||
print =============== step17 wh
|
||||
sql select count(tbcol) from $mt where ts < now + 4m interval(1d)
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . wh
|
||||
#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d)
|
||||
|
||||
print =============== step18 as
|
||||
sql select count(tbcol) from $mt interval(1d)
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . as
|
||||
sql create table $st as select count(tbcol) as c from $mt interval(1d)
|
||||
|
||||
print =============== step19 gb
|
||||
sql select count(tbcol) from $mt interval(1d) group by tgcol
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 20 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step20 x
|
||||
sql select count(tbcol) from $mt where ts < now + 4m interval(1d) group by tgcol
|
||||
print ===> $data00 $data01
|
||||
if $data01 != 20 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step21
|
||||
print sleep 120 seconds
|
||||
sleep 120000
|
||||
|
||||
print =============== step22
|
||||
$st = $stPrefix . c1
|
||||
sql select * from $st
|
||||
print ===> select * from $st ===> $data00 $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . c2
|
||||
sql select * from $st
|
||||
print ===> select * from $st ===> $data00 $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . c3
|
||||
sql select * from $st
|
||||
print ===> select * from $st ===> $data00 $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . av
|
||||
sql select * from $st
|
||||
print ===> select * from $st ===> $data00 $data01
|
||||
if $data01 != 9.500000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . su
|
||||
sql select * from $st
|
||||
print ===> select * from $st ===> $data00 $data01
|
||||
if $data01 != 1900 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . mi
|
||||
sql select * from $st
|
||||
print ===> select * from $st ===> $data00 $data01
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . ma
|
||||
sql select * from $st
|
||||
print ===> select * from $st ===> $data00 $data01
|
||||
if $data01 != 19 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . fi
|
||||
sql select * from $st
|
||||
print ===> select * from $st ===> $data00 $data01
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$st = $stPrefix . la
|
||||
sql select * from $st
|
||||
print ===> select * from $st ===> $data00 $data01
|
||||
if $data01 != 19 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#$st = $stPrefix . wh
|
||||
#sql select * from $st
|
||||
#print ===> select * from $st ===> $data00 $data01
|
||||
#if $data01 != 200 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
$st = $stPrefix . as
|
||||
sql select * from $st
|
||||
print ===> select * from $st ===> $data00 $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
|
@ -1,106 +0,0 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||
system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 10
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sleep 3000
|
||||
sql connect
|
||||
print ======================== dnode1 start
|
||||
|
||||
$dbPrefix = ns_db
|
||||
$tbPrefix = ns_tb
|
||||
$mtPrefix = ns_mt
|
||||
$stPrefix = ns_st
|
||||
$tbNum = 5
|
||||
$rowNum = 200
|
||||
$totalNum = 200
|
||||
|
||||
print =============== step1
|
||||
|
||||
$i = 0
|
||||
$db = $dbPrefix
|
||||
$mt = $mtPrefix
|
||||
$st = $stPrefix
|
||||
|
||||
sql create database $db
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = 0
|
||||
$y = 0
|
||||
while $y < $rowNum
|
||||
$ms = $x . s
|
||||
sql insert into $tb values (now + $ms , $y , $y )
|
||||
$x = $x + 1
|
||||
$y = $y + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
sleep 100
|
||||
|
||||
print =============== step2
|
||||
|
||||
sql select count(*), count(tbcol), count(tbcol2) from $mt interval(10s)
|
||||
print $data00 $data01 $data02 $data03
|
||||
|
||||
sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(10s)
|
||||
|
||||
print =============== step3
|
||||
print sleep 120 seconds
|
||||
sleep 120000
|
||||
|
||||
print =============== step4
|
||||
|
||||
sql select * from $st
|
||||
print $st ==> $rows1 $data00 $data01 $data02 $data03
|
||||
if $data03 >= 51 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step5
|
||||
|
||||
$tbNum = 10
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
if $i == 0 then
|
||||
sleep 2000
|
||||
endi
|
||||
|
||||
$x = 0
|
||||
$y = 0
|
||||
while $y < $rowNum
|
||||
$ms = $x . s
|
||||
sql insert into $tb values (now + $ms , $y , $y )
|
||||
$x = $x + 1
|
||||
$y = $y + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
print =============== step6
|
||||
print sleep 120 seconds
|
||||
sleep 120000
|
||||
|
||||
print =============== step7
|
||||
|
||||
sql select * from $st order by ts desc
|
||||
print $st ==> $rows1 $data00 $data01 $data02 $data03
|
||||
if $data03 <= 51 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sleep 3000
|
||||
sql connect
|
||||
|
||||
print ======================== dnode1 start
|
||||
|
||||
$dbPrefix = s1_db
|
||||
$tbPrefix = s1_tb
|
||||
$mtPrefix = s1_mt
|
||||
$stPrefix = s1_st
|
||||
$tbNum = 10
|
||||
$rowNum = 20
|
||||
$totalNum = 200
|
||||
|
||||
print =============== step1
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
$st = $stPrefix . $i
|
||||
|
||||
sql drop databae $db -x step1
|
||||
step1:
|
||||
sql create database $db
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = -1440
|
||||
$y = 0
|
||||
while $y < $rowNum
|
||||
$ms = $x . m
|
||||
sql insert into $tb values (now $ms , $y , $y )
|
||||
$x = $x + 1
|
||||
$y = $y + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
sleep 100
|
||||
|
||||
print =============== step2
|
||||
$i = 0
|
||||
$tb = $tbPrefix . $i
|
||||
$st = $stPrefix . $i
|
||||
|
||||
sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d)
|
||||
print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) ===> $data00 $data01 $data02, $data03
|
||||
if $data01 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show tables
|
||||
if $rows != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d)
|
||||
|
||||
sql show tables
|
||||
if $rows != 11 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step3
|
||||
print sleep 120 seconds
|
||||
sleep 120000
|
||||
sql select * from $st
|
||||
print select * from $st => $data01
|
||||
if $data01 != 20 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 20 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 20 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step4
|
||||
sql drop table $st
|
||||
sql show tables
|
||||
if $rows != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step5
|
||||
sql select * from $st -x step4
|
||||
return -1
|
||||
step4:
|
||||
|
||||
print =============== step6
|
||||
sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d)
|
||||
sql show tables
|
||||
if $rows != 11 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step7
|
||||
print sleep 120 seconds
|
||||
sleep 120000
|
||||
sql select * from $st
|
||||
print select * from $st => $data01
|
||||
if $data01 != 20 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 20 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 20 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step8
|
||||
$i = 1
|
||||
$st = $stPrefix . $i
|
||||
|
||||
sql select count(*), count(tbcol), count(tbcol2) from $mt interval(1d)
|
||||
print select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) ===> $data00 $data01 $data02, $data03
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 200 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show tables
|
||||
if $rows != 11 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(1d)
|
||||
|
||||
sql show tables
|
||||
if $rows != 12 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step9
|
||||
print sleep 120 seconds
|
||||
sleep 120000
|
||||
sql select * from $st
|
||||
print select * from $st => $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 200 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step10
|
||||
sql drop table $st
|
||||
sql show tables
|
||||
if $rows != 11 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step11
|
||||
sql select * from $st -x step10
|
||||
return -1
|
||||
step10:
|
||||
|
||||
print =============== step12
|
||||
sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(1d)
|
||||
|
||||
sql show tables
|
||||
if $rows != 12 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step13
|
||||
print sleep 120 seconds
|
||||
sleep 120000
|
||||
sql select * from $st
|
||||
print select * from $st => $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 200 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sleep 3000
|
||||
sql connect
|
||||
|
||||
print ======================== dnode1 start
|
||||
|
||||
$dbPrefix = s2_db
|
||||
$tbPrefix = s2_tb
|
||||
$mtPrefix = s2_mt
|
||||
$stPrefix = s2_st
|
||||
$tbNum = 10
|
||||
$rowNum = 20
|
||||
$totalNum = 200
|
||||
|
||||
print =============== step1
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
$st = $stPrefix . $i
|
||||
|
||||
sql drop databae $db -x step1
|
||||
step1:
|
||||
sql create database $db
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = -1440
|
||||
$y = 0
|
||||
while $y < $rowNum
|
||||
$ms = $x . m
|
||||
sql insert into $tb values (now $ms , $y , $y )
|
||||
$x = $x + 1
|
||||
$y = $y + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
sleep 100
|
||||
|
||||
print =============== step2
|
||||
$i = 0
|
||||
$tb = $tbPrefix . $i
|
||||
$st = $stPrefix . $i
|
||||
|
||||
sql select count(tbcol) from $tb interval(1d)
|
||||
print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 $data02, $data03
|
||||
if $data01 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show tables
|
||||
if $rows != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql create table $st as select count(tbcol) from $tb interval(1d)
|
||||
|
||||
sql show tables
|
||||
if $rows != 11 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step3
|
||||
print sleep 120 seconds
|
||||
sleep 120000
|
||||
sql select * from $st
|
||||
print select * from $st => $data01
|
||||
if $data01 != 20 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step4
|
||||
sql drop table $st
|
||||
sql show tables
|
||||
if $rows != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step5
|
||||
sql select * from $st -x step4
|
||||
return -1
|
||||
step4:
|
||||
|
||||
print =============== step6
|
||||
sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d)
|
||||
sql show tables
|
||||
if $rows != 11 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step7
|
||||
print sleep 120 seconds
|
||||
sleep 120000
|
||||
sql select * from $st
|
||||
print select * from $st => $data01
|
||||
if $data01 != 20 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 20 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 20 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step8
|
||||
$i = 1
|
||||
$st = $stPrefix . $i
|
||||
|
||||
sql select count(*), count(tbcol), count(tbcol2) from $mt interval(1d)
|
||||
print select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) ===> $data00 $data01 $data02, $data03
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 200 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql show tables
|
||||
if $rows != 11 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(1d)
|
||||
|
||||
sql show tables
|
||||
if $rows != 12 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step9
|
||||
print sleep 120 seconds
|
||||
sleep 120000
|
||||
sql select * from $st
|
||||
print select * from $st => $data01 $data02, $data03
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 200 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step10
|
||||
sql drop table $st
|
||||
sql show tables
|
||||
if $rows != 11 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step11
|
||||
sql select * from $st -x step10
|
||||
return -1
|
||||
step10:
|
||||
|
||||
print =============== step12
|
||||
sql create table $st as select count(tbcol) from $mt interval(1d)
|
||||
|
||||
sql show tables
|
||||
if $rows != 12 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step13
|
||||
print sleep 120 seconds
|
||||
sleep 120000
|
||||
sql select * from $st
|
||||
print select * from $st => $data01 $data02, $data03
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != null then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != null then
|
||||
return -1
|
||||
endi
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
run general/stream/stream_1.sim
|
||||
run general/stream/stream_2.sim
|
||||
run general/stream/stream_3.sim
|
||||
run general/stream/stream_restart.sim
|
||||
run general/stream/table_1.sim
|
||||
run general/stream/metrics_1.sim
|
||||
run general/stream/table_n.sim
|
||||
run general/stream/metrics_n.sim
|
||||
run general/stream/table_del.sim
|
||||
|
|
|
@ -136,6 +136,7 @@ cd ../../../debug; make
|
|||
./test.sh -f general/parser/limit2.sim
|
||||
./test.sh -f general/parser/fill.sim
|
||||
./test.sh -f general/parser/fill_stb.sim
|
||||
#./test.sh -f general/parser/fill_us.sim
|
||||
./test.sh -f general/parser/where.sim
|
||||
./test.sh -f general/parser/slimit.sim
|
||||
./test.sh -f general/parser/select_with_tags.sim
|
||||
|
@ -143,6 +144,9 @@ cd ../../../debug; make
|
|||
./test.sh -f general/parser/tags_dynamically_specifiy.sim
|
||||
./test.sh -f general/parser/groupby.sim
|
||||
./test.sh -f general/parser/set_tag_vals.sim
|
||||
#./test.sh -f general/parser/sliding.sim
|
||||
./test.sh -f general/parser/tags_dynamically_specifiy.sim
|
||||
./test.sh -f general/parser/tags_filter.sim
|
||||
./test.sh -f general/parser/slimit_alter_tags.sim
|
||||
./test.sh -f general/parser/join.sim
|
||||
./test.sh -f general/parser/join_multivnode.sim
|
||||
|
@ -309,17 +313,12 @@ cd ../../../debug; make
|
|||
|
||||
# stream still has bugs
|
||||
#./test.sh -f general/parser/stream_on_sys.sim
|
||||
#./test.sh -f general/parser/stream.sim
|
||||
#./test.sh -f general/parser/repeatStream.sim
|
||||
#./test.sh -f general/stream/new_stream.sim
|
||||
|
||||
./test.sh -f general/stream/metrics_1.sim
|
||||
./test.sh -f general/stream/metrics_del.sim
|
||||
./test.sh -f general/stream/metrics_n.sim
|
||||
./test.sh -f general/stream/metrics_replica1_vnoden.sim
|
||||
./test.sh -f general/stream/restart_stream.sim
|
||||
./test.sh -f general/stream/stream_1.sim
|
||||
./test.sh -f general/stream/stream_2.sim
|
||||
./test.sh -f general/stream/stream_3.sim
|
||||
./test.sh -f general/stream/stream_restart.sim
|
||||
./test.sh -f general/stream/table_1.sim
|
||||
|
|
|
@ -148,7 +148,6 @@ cd ../../../debug; make
|
|||
./test.sh -f general/parser/binary_escapeCharacter.sim
|
||||
./test.sh -f general/parser/bug.sim
|
||||
#./test.sh -f general/parser/stream_on_sys.sim
|
||||
./test.sh -f general/parser/stream.sim
|
||||
./test.sh -f general/parser/repeatAlter.sim
|
||||
#./test.sh -f general/parser/repeatStream.sim
|
||||
|
||||
|
|
Loading…
Reference in New Issue