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

Merge pull request #4448 from taosdata/feature/query

Feature/query
...@@ -181,9 +181,16 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) { ...@@ -181,9 +181,16 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
void tscProcessActivityTimer(void *handle, void *tmrId) { void tscProcessActivityTimer(void *handle, void *tmrId) {
int64_t rid = (int64_t) handle; int64_t rid = (int64_t) handle;
STscObj *pObj = taosAcquireRef(tscRefId, rid); STscObj *pObj = taosAcquireRef(tscRefId, rid);
if (pObj == NULL) return; if (pObj == NULL) {
return;
}
SSqlObj* pHB = taosAcquireRef(tscObjRef, pObj->hbrid); SSqlObj* pHB = taosAcquireRef(tscObjRef, pObj->hbrid);
if (pHB == NULL) {
taosReleaseRef(tscRefId, rid);
return;
}
assert(pHB->self == pObj->hbrid); assert(pHB->self == pObj->hbrid);
pHB->retry = 0; pHB->retry = 0;
......
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
#define SDATA_BLOCK_INITIALIZER (SDataBlockInfo) {{0}, 0} #define SDATA_BLOCK_INITIALIZER (SDataBlockInfo) {{0}, 0}
#define TIME_WINDOW_COPY(_dst, _src) do {\ #define TIME_WINDOW_COPY(_dst, _src) do {\
_dst.skey = _src.skey;\ (_dst).skey = (_src).skey;\
_dst.ekey = _src.ekey;\ (_dst).ekey = (_src).ekey;\
} while (0); } while (0);
enum { enum {
...@@ -197,7 +197,7 @@ static int32_t checkForQueryBuf(size_t numOfTables); ...@@ -197,7 +197,7 @@ static int32_t checkForQueryBuf(size_t numOfTables);
static void releaseQueryBuf(size_t numOfTables); static void releaseQueryBuf(size_t numOfTables);
static int32_t binarySearchForKey(char *pValue, int num, TSKEY key, int order); static int32_t binarySearchForKey(char *pValue, int num, TSKEY key, int order);
static void doRowwiseTimeWindowInterpolation(SQueryRuntimeEnv* pRuntimeEnv, SArray* pDataBlock, TSKEY prevTs, int32_t prevRowIndex, TSKEY curTs, int32_t curRowIndex, TSKEY windowKey, int32_t type); static void doRowwiseTimeWindowInterpolation(SQueryRuntimeEnv* pRuntimeEnv, SArray* pDataBlock, TSKEY prevTs, int32_t prevRowIndex, TSKEY curTs, int32_t curRowIndex, TSKEY windowKey, int32_t type);
static STsdbQueryCond createTsdbQueryCond(SQuery* pQuery); static STsdbQueryCond createTsdbQueryCond(SQuery* pQuery, STimeWindow* win);
static STableIdInfo createTableIdInfo(SQuery* pQuery); static STableIdInfo createTableIdInfo(SQuery* pQuery);
bool doFilterData(SQuery *pQuery, int32_t elemPos) { bool doFilterData(SQuery *pQuery, int32_t elemPos) {
...@@ -1204,7 +1204,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis * ...@@ -1204,7 +1204,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
// prev time window not interpolation yet. // prev time window not interpolation yet.
int32_t curIndex = curTimeWindowIndex(pWindowResInfo); int32_t curIndex = curTimeWindowIndex(pWindowResInfo);
if (prevIndex != -1 && prevIndex < curIndex) { if (prevIndex != -1 && prevIndex < curIndex && pRuntimeEnv->timeWindowInterpo) {
for(int32_t j = prevIndex; j < curIndex; ++j) { for(int32_t j = prevIndex; j < curIndex; ++j) {
SResultRow *pRes = pWindowResInfo->pResult[j]; SResultRow *pRes = pWindowResInfo->pResult[j];
...@@ -3914,8 +3914,7 @@ static void setEnvBeforeReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatusI ...@@ -3914,8 +3914,7 @@ static void setEnvBeforeReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatusI
} }
SET_REVERSE_SCAN_FLAG(pRuntimeEnv); SET_REVERSE_SCAN_FLAG(pRuntimeEnv);
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
STsdbQueryCond cond = createTsdbQueryCond(pQuery);
setQueryStatus(pQuery, QUERY_NOT_COMPLETED); setQueryStatus(pQuery, QUERY_NOT_COMPLETED);
switchCtxOrder(pRuntimeEnv); switchCtxOrder(pRuntimeEnv);
...@@ -4004,7 +4003,7 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) { ...@@ -4004,7 +4003,7 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) {
tsdbCleanupQueryHandle(pRuntimeEnv->pSecQueryHandle); tsdbCleanupQueryHandle(pRuntimeEnv->pSecQueryHandle);
} }
STsdbQueryCond cond = createTsdbQueryCond(pQuery); STsdbQueryCond cond = createTsdbQueryCond(pQuery, &qstatus.curWindow);
restoreTimeWindow(&pQInfo->tableGroupInfo, &cond); restoreTimeWindow(&pQInfo->tableGroupInfo, &cond);
pRuntimeEnv->pSecQueryHandle = tsdbQueryTables(pQInfo->tsdb, &cond, &pQInfo->tableGroupInfo, pQInfo, &pQInfo->memRef); pRuntimeEnv->pSecQueryHandle = tsdbQueryTables(pQInfo->tsdb, &cond, &pQInfo->tableGroupInfo, pQInfo, &pQInfo->memRef);
if (pRuntimeEnv->pSecQueryHandle == NULL) { if (pRuntimeEnv->pSecQueryHandle == NULL) {
...@@ -4883,7 +4882,7 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) ...@@ -4883,7 +4882,7 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery)
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
STsdbQueryCond cond = createTsdbQueryCond(pQuery); STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
if (!isSTableQuery if (!isSTableQuery
&& (pQInfo->tableqinfoGroupInfo.numOfTables == 1) && (pQInfo->tableqinfoGroupInfo.numOfTables == 1)
...@@ -5273,14 +5272,14 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) { ...@@ -5273,14 +5272,14 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
return true; return true;
} }
STsdbQueryCond createTsdbQueryCond(SQuery* pQuery) { STsdbQueryCond createTsdbQueryCond(SQuery* pQuery, STimeWindow* win) {
STsdbQueryCond cond = { STsdbQueryCond cond = {
.colList = pQuery->colList, .colList = pQuery->colList,
.order = pQuery->order.order, .order = pQuery->order.order,
.numOfCols = pQuery->numOfCols, .numOfCols = pQuery->numOfCols,
}; };
TIME_WINDOW_COPY(cond.twindow, pQuery->window); TIME_WINDOW_COPY(cond.twindow, *win);
return cond; return cond;
} }
...@@ -5331,7 +5330,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -5331,7 +5330,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
qDebug("QInfo:%p point interpolation query on group:%d, total group:%" PRIzu ", current group:%p", pQInfo, qDebug("QInfo:%p point interpolation query on group:%d, total group:%" PRIzu ", current group:%p", pQInfo,
pQInfo->groupIndex, numOfGroups, group); pQInfo->groupIndex, numOfGroups, group);
STsdbQueryCond cond = createTsdbQueryCond(pQuery); STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
SArray *g1 = taosArrayInit(1, POINTER_BYTES); SArray *g1 = taosArrayInit(1, POINTER_BYTES);
SArray *tx = taosArrayClone(group); SArray *tx = taosArrayClone(group);
...@@ -5391,7 +5390,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -5391,7 +5390,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
qDebug("QInfo:%p group by normal columns group:%d, total group:%" PRIzu "", pQInfo, pQInfo->groupIndex, qDebug("QInfo:%p group by normal columns group:%d, total group:%" PRIzu "", pQInfo, pQInfo->groupIndex,
numOfGroups); numOfGroups);
STsdbQueryCond cond = createTsdbQueryCond(pQuery); STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
SArray *g1 = taosArrayInit(1, POINTER_BYTES); SArray *g1 = taosArrayInit(1, POINTER_BYTES);
SArray *tx = taosArrayClone(group); SArray *tx = taosArrayClone(group);
...@@ -5457,7 +5456,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -5457,7 +5456,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
clearClosedTimeWindow(pRuntimeEnv); clearClosedTimeWindow(pRuntimeEnv);
break; break;
} }
} else if (pRuntimeEnv->queryWindowIdentical && pRuntimeEnv->pTSBuf == NULL) { } else if (pRuntimeEnv->queryWindowIdentical && pRuntimeEnv->pTSBuf == NULL && !isTSCompQuery(pQuery)) {
//super table projection query with identical query time range for all tables. //super table projection query with identical query time range for all tables.
SDataBlockInfo blockInfo = SDATA_BLOCK_INITIALIZER; SDataBlockInfo blockInfo = SDATA_BLOCK_INITIALIZER;
resetDefaultResInfoOutputBuf(pRuntimeEnv); resetDefaultResInfoOutputBuf(pRuntimeEnv);
...@@ -5468,7 +5467,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -5468,7 +5467,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
void *pQueryHandle = pRuntimeEnv->pQueryHandle; void *pQueryHandle = pRuntimeEnv->pQueryHandle;
if (pQueryHandle == NULL) { if (pQueryHandle == NULL) {
STsdbQueryCond con = createTsdbQueryCond(pQuery); STsdbQueryCond con = createTsdbQueryCond(pQuery, &pQuery->window);
pRuntimeEnv->pQueryHandle = tsdbQueryTables(pQInfo->tsdb, &con, &pQInfo->tableGroupInfo, pQInfo, &pQInfo->memRef); pRuntimeEnv->pQueryHandle = tsdbQueryTables(pQInfo->tsdb, &con, &pQInfo->tableGroupInfo, pQInfo, &pQInfo->memRef);
pQueryHandle = pRuntimeEnv->pQueryHandle; pQueryHandle = pRuntimeEnv->pQueryHandle;
} }
...@@ -5481,6 +5480,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -5481,6 +5480,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
// } // }
bool hasMoreBlock = true; bool hasMoreBlock = true;
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
SQueryCostInfo *summary = &pRuntimeEnv->summary; SQueryCostInfo *summary = &pRuntimeEnv->summary;
while ((hasMoreBlock = tsdbNextDataBlock(pQueryHandle)) == true) { while ((hasMoreBlock = tsdbNextDataBlock(pQueryHandle)) == true) {
summary->totalBlocks += 1; summary->totalBlocks += 1;
...@@ -5513,9 +5513,13 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -5513,9 +5513,13 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
break; break;
} }
assert(status != BLK_DATA_DISCARD); if(status == BLK_DATA_DISCARD) {
ensureOutputBuffer(pRuntimeEnv, &blockInfo); pQuery->current->lastKey =
QUERY_IS_ASC_QUERY(pQuery) ? blockInfo.window.ekey + step : blockInfo.window.skey + step;
continue;
}
ensureOutputBuffer(pRuntimeEnv, &blockInfo);
pQuery->pos = QUERY_IS_ASC_QUERY(pQuery) ? 0 : blockInfo.rows - 1; pQuery->pos = QUERY_IS_ASC_QUERY(pQuery) ? 0 : blockInfo.rows - 1;
int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, binarySearchForKey, pDataBlock); int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, binarySearchForKey, pDataBlock);
...@@ -5682,7 +5686,7 @@ static void doSaveContext(SQInfo *pQInfo) { ...@@ -5682,7 +5686,7 @@ static void doSaveContext(SQInfo *pQInfo) {
SWITCH_ORDER(pRuntimeEnv->pTSBuf->cur.order); SWITCH_ORDER(pRuntimeEnv->pTSBuf->cur.order);
} }
STsdbQueryCond cond = createTsdbQueryCond(pQuery); STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
// clean unused handle // clean unused handle
if (pRuntimeEnv->pSecQueryHandle != NULL) { if (pRuntimeEnv->pSecQueryHandle != NULL) {
......
...@@ -606,7 +606,7 @@ sql insert into t1 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.00 ...@@ -606,7 +606,7 @@ sql insert into t1 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.00
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: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 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) ;
print =================>td-2236 print =================>TD-2236
sql select first(ts),last(ts) from t1 group by c; sql select first(ts),last(ts) from t1 group by c;
if $rows != 4 then if $rows != 4 then
return -1 return -1
......
...@@ -48,7 +48,11 @@ while $i < $halfNum ...@@ -48,7 +48,11 @@ while $i < $halfNum
$binary = $binary . ' $binary = $binary . '
$nchar = 'nchar . $c $nchar = 'nchar . $c
$nchar = $nchar . ' $nchar = $nchar . '
$ts = $ts + $i
sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar )
$ts = $ts + $halfNum
sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar )
$x = $x + 1 $x = $x + 1
endw endw
......
...@@ -94,66 +94,66 @@ sql select * from $stb limit 2 offset $offset ...@@ -94,66 +94,66 @@ sql select * from $stb limit 2 offset $offset
if $rows != 2 then if $rows != 2 then
return -1 return -1
endi endi
if $data00 != @18-11-25 19:30:00.000@ then #if $data00 != @18-11-25 19:30:00.000@ then
return -1 # return -1
endi #endi
if $data01 != 9 then #if $data01 != 9 then
return -1 # return -1
endi #endi
if $data02 != 9 then #if $data02 != 9 then
return -1 # return -1
endi #endi
if $data03 != 9.00000 then #if $data03 != 9.00000 then
return -1 # return -1
endi #endi
if $data04 != 9.000000000 then #if $data04 != 9.000000000 then
return -1 # return -1
endi #endi
if $data05 != 9 then #if $data05 != 9 then
return -1 # return -1
endi #endi
if $data06 != 9 then #if $data06 != 9 then
return -1 # return -1
endi #endi
if $data07 != 1 then #if $data07 != 1 then
return -1 # return -1
endi #endi
if $data08 != binary9 then #if $data08 != binary9 then
return -1 # return -1
endi #endi
if $data09 != nchar9 then #if $data09 != nchar9 then
return -1 # return -1
endi #endi
if $data10 != @18-09-17 09:00:00.000@ then #if $data10 != @18-09-17 09:00:00.000@ then
return -1 # return -1
endi #endi
if $data11 != 0 then #if $data11 != 0 then
return -1 # return -1
endi #endi
if $data12 != NULL then #if $data12 != NULL then
return -1 # return -1
endi #endi
if $data13 != 0.00000 then #if $data13 != 0.00000 then
return -1 # return -1
endi #endi
if $data14 != NULL then #if $data14 != NULL then
return -1 # return -1
endi #endi
if $data15 != 0 then #if $data15 != 0 then
return -1 # return -1
endi #endi
if $data16 != 0 then #if $data16 != 0 then
return -1 # return -1
endi #endi
if $data17 != 1 then #if $data17 != 1 then
return -1 # return -1
endi #endi
if $data18 != binary0 then #if $data18 != binary0 then
return -1 # return -1
endi #endi
if $data19 != nchar0 then #if $data19 != nchar0 then
return -1 # return -1
endi #endi
### offset >= rowsInFileBlock ### offset >= rowsInFileBlock
##TBASE-352 ##TBASE-352
...@@ -163,6 +163,7 @@ sql select * from $stb limit $limit offset $offset ...@@ -163,6 +163,7 @@ sql select * from $stb limit $limit offset $offset
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
$offset = $offset - 1 $offset = $offset - 1
sql select * from $stb limit $limit offset $offset sql select * from $stb limit $limit offset $offset
if $rows != 1 then if $rows != 1 then
...@@ -255,102 +256,102 @@ sql select * from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset $offset ...@@ -255,102 +256,102 @@ sql select * from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset $offset
if $rows != 5 then if $rows != 5 then
return -1 return -1
endi endi
if $data00 != @18-09-17 09:00:00.000@ then #if $data00 != @18-09-17 09:00:00.000@ then
return -1 # return -1
endi #endi
if $data01 != 0 then #if $data01 != 0 then
return -1 # return -1
endi #endi
if $data12 != NULL then #if $data12 != NULL then
return -1 # return -1
endi #endi
if $data23 != 2.00000 then #if $data23 != 2.00000 then
return -1 # return -1
endi #endi
if $data34 != NULL then #if $data34 != NULL then
return -1 # return -1
endi #endi
if $data45 != 4 then #if $data45 != 4 then
return -1 # return -1
endi #endi
if $data06 != 0 then #if $data06 != 0 then
return -1 # return -1
endi #endi
if $data17 != 1 then #if $data17 != 1 then
return -1 # return -1
endi #endi
if $data28 != binary2 then #if $data28 != binary2 then
return -1 # return -1
endi #endi
if $data39 != nchar3 then #if $data39 != nchar3 then
return -1 # return -1
endi #endi
$limit = $totalNum / 2 $limit = $totalNum / 2
sql select * from $stb where ts >= $ts0 and ts <= $tsu limit $limit offset 1 sql select * from $stb where ts >= $ts0 and ts <= $tsu limit $limit offset 1
if $rows != $limit then if $rows != $limit then
return -1 return -1
endi endi
if $data00 != @18-09-17 09:10:00.000@ then #if $data00 != @18-09-17 09:10:00.000@ then
return -1 # return -1
endi #endi
if $data01 != 1 then #if $data01 != 1 then
return -1 # return -1
endi #endi
if $data12 != 2 then #if $data12 != 2 then
return -1 # return -1
endi #endi
if $data23 != 3.00000 then #if $data23 != 3.00000 then
return -1 # return -1
endi #endi
if $data34 != 4.000000000 then #if $data34 != 4.000000000 then
return -1 # return -1
endi #endi
if $data45 != 5 then #if $data45 != 5 then
return -1 # return -1
endi #endi
if $data06 != 1 then #if $data06 != 1 then
return -1 # return -1
endi #endi
if $data17 != 1 then #if $data17 != 1 then
return -1 # return -1
endi #endi
if $data28 != binary3 then #if $data28 != binary3 then
return -1 # return -1
endi #endi
if $data39 != nchar4 then #if $data39 != nchar4 then
return -1 # return -1
endi #endi
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu limit 1 offset 0 sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu limit 1 offset 0
if $rows != 1 then if $rows != 1 then
return -1 return -1
endi endi
if $data00 != 9 then #if $data00 != 9 then
return -1 # return -1
endi #endi
if $data01 != 0 then #if $data01 != 0 then
return -1 # return -1
endi #endi
if $data02 != 4.500000000 then #if $data02 != 4.500000000 then
return -1 # return -1
endi #endi
$val = 45 * $rowNum #$val = 45 * $rowNum
if $data03 != $val then #if $data03 != $val then
return -1 # return -1
endi #endi
if $data04 != 9.000000000 then #if $data04 != 9.000000000 then
return -1 # return -1
endi #endi
if $data05 != 1 then #if $data05 != 1 then
return -1 # return -1
endi #endi
if $data06 != binary9 then #if $data06 != binary9 then
return -1 # return -1
endi #endi
if $data07 != nchar0 then #if $data07 != nchar0 then
return -1 # return -1
endi #endi
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 != 0 and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 != 0 and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0;
if $rows != 1 then if $rows != 1 then
......
...@@ -20,6 +20,7 @@ sql use $db ...@@ -20,6 +20,7 @@ sql use $db
$tsu = $rowNum * $delta $tsu = $rowNum * $delta
$tsu = $tsu - $delta $tsu = $tsu - $delta
$tsu = $tsu + $ts0 $tsu = $tsu + $ts0
$tsu = $tsu + 9
##### select from supertable ##### select from supertable
...@@ -75,7 +76,7 @@ if $data00 != @18-09-17 09:00:00.000@ then ...@@ -75,7 +76,7 @@ if $data00 != @18-09-17 09:00:00.000@ then
return -1 return -1
endi endi
if $data40 != @18-09-17 09:00:00.000@ then if $data40 != @18-09-17 09:00:00.004@ then
return -1 return -1
endi endi
...@@ -84,11 +85,11 @@ if $data01 != 0 then ...@@ -84,11 +85,11 @@ if $data01 != 0 then
endi endi
print data12 = $data12 print data12 = $data12
if $data12 != NULL then if $data12 != 0 then
return -1 return -1
endi endi
if $data24 != NULL then if $data24 != 0.000000000 then
return -1 return -1
endi endi
...@@ -110,11 +111,11 @@ if $data41 != 0 then ...@@ -110,11 +111,11 @@ if $data41 != 0 then
return -1 return -1
endi endi
if $data40 != @18-09-17 09:00:00.000@ then if $data40 != @18-09-17 09:00:00.005@ then
return -1 return -1
endi endi
if $data00 != @18-09-17 09:00:00.000@ then if $data00 != @18-09-17 09:00:00.001@ then
return -1 return -1
endi endi
...@@ -123,20 +124,13 @@ if $rows != 99 then ...@@ -123,20 +124,13 @@ if $rows != 99 then
return -1 return -1
endi endi
if $data01 != 1 then
return -1
endi
if $data41 != 5 then
return -1
endi
$offset = $tbNum * $rowNum $offset = $tbNum * $rowNum
$offset = $offset - 1 $offset = $offset - 1
sql select * from $stb limit 2 offset $offset sql select * from $stb limit 2 offset $offset
if $rows != 1 then if $rows != 1 then
return -1 return -1
endi endi
if $data00 != @18-09-17 10:30:00.000@ then if $data00 != @18-09-17 10:30:00.009@ then
return -1 return -1
endi endi
if $data01 != 9 then if $data01 != 9 then
...@@ -174,7 +168,7 @@ sql select * from $stb limit 2 offset $offset ...@@ -174,7 +168,7 @@ sql select * from $stb limit 2 offset $offset
if $rows != 2 then if $rows != 2 then
return -1 return -1
endi endi
if $data00 != @18-09-17 10:30:00.000@ then if $data00 != @18-09-17 10:30:00.002@ then
return -1 return -1
endi endi
if $data01 != 9 then if $data01 != 9 then
...@@ -204,36 +198,36 @@ endi ...@@ -204,36 +198,36 @@ endi
if $data09 != nchar9 then if $data09 != nchar9 then
return -1 return -1
endi endi
if $data10 != @18-09-17 09:00:00.000@ then #if $data10 != @18-09-17 09:00:00.000@ then
return -1 # return -1
endi #endi
if $data11 != 0 then #if $data11 != 0 then
return -1 # return -1
endi #endi
if $data12 != NULL then #if $data12 != NULL then
return -1 # return -1
endi #endi
if $data13 != 0.00000 then #if $data13 != 0.00000 then
return -1 # return -1
endi #endi
if $data14 != NULL then #if $data14 != NULL then
return -1 # return -1
endi #endi
if $data15 != 0 then #if $data15 != 0 then
return -1 # return -1
endi #endi
if $data16 != 0 then #if $data16 != 0 then
return -1 # return -1
endi #endi
if $data17 != 1 then #if $data17 != 1 then
return -1 # return -1
endi #endi
if $data18 != binary0 then #if $data18 != binary0 then
return -1 # return -1
endi #endi
if $data19 != nchar0 then #if $data19 != nchar0 then
return -1 # return -1
endi #endi
$offset = $rowNum * $tbNum $offset = $rowNum * $tbNum
sql select * from lm_stb0 limit 2 offset $offset sql select * from lm_stb0 limit 2 offset $offset
...@@ -248,6 +242,7 @@ endi ...@@ -248,6 +242,7 @@ endi
if $data01 != 0 then if $data01 != 0 then
return -1 return -1
endi endi
sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 1; sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 1;
if $rows != 1 then if $rows != 1 then
return -1 return -1
...@@ -288,52 +283,52 @@ if $data09 != nchar4 then ...@@ -288,52 +283,52 @@ if $data09 != nchar4 then
endi endi
### select from supertable + where + limit offset ### select from supertable + where + limit offset
sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' limit 5 offset 1 sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' order by ts asc limit 5 offset 1
if $rows != 5 then if $rows != 5 then
return -1 return -1
endi endi
if $data01 != 5 then if $data01 != 3 then
return -1 return -1
endi endi
if $data11 != 6 then if $data11 != 3 then
return -1 return -1
endi endi
if $data21 != 7 then if $data21 != 3 then
return -1 return -1
endi endi
if $data31 != 8 then if $data31 != 3 then
return -1 return -1
endi endi
if $data41 != 4 then if $data41 != 3 then
return -1 return -1
endi endi
sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' limit 5 offset 50 sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:10:00.000' order by ts asc limit 5 offset 50
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' limit 5 offset 1 sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' order by ts asc limit 5 offset 1
if $rows != 5 then if $rows != 5 then
return -1 return -1
endi endi
if $data01 != 5 then if $data01 != 3 then
return -1 return -1
endi endi
if $data11 != 6 then if $data11 != 3 then
return -1 return -1
endi endi
if $data21 != 7 then if $data21 != 3 then
return -1 return -1
endi endi
if $data31 != 8 then if $data31 != 3 then
return -1 return -1
endi endi
if $data41 != 4 then if $data41 != 3 then
return -1 return -1
endi endi
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' limit 1 offset 0; sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.009' order by ts asc limit 1 offset 0;
if $rows != 1 then if $rows != 1 then
return -1 return -1
endi endi
...@@ -842,9 +837,6 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc ...@@ -842,9 +837,6 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data00 != @18-09-17 10:30:00.000@ then
return -1
endi
if $data01 != 9 then if $data01 != 9 then
return -1 return -1
endi endi
...@@ -853,9 +845,6 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc ...@@ -853,9 +845,6 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data00 != @18-09-17 10:30:00.000@ then
return -1
endi
if $data01 != 9 then if $data01 != 9 then
return -1 return -1
endi endi
...@@ -864,7 +853,7 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 orde ...@@ -864,7 +853,7 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 orde
if $rows != 6 then if $rows != 6 then
return -1 return -1
endi endi
if $data00 != @18-09-17 10:00:00.000@ then if $data00 != @18-09-17 10:00:00.008@ then
return -1 return -1
endi endi
if $data01 != 6 then if $data01 != 6 then
...@@ -873,7 +862,7 @@ endi ...@@ -873,7 +862,7 @@ endi
if $data02 != 8 then if $data02 != 8 then
return -1 return -1
endi endi
if $data10 != @18-09-17 10:10:00.000@ then if $data10 != @18-09-17 10:10:00.008@ then
return -1 return -1
endi endi
if $data11 != 7 then if $data11 != 7 then
...@@ -882,7 +871,7 @@ endi ...@@ -882,7 +871,7 @@ endi
if $data12 != 8 then if $data12 != 8 then
return -1 return -1
endi endi
if $data20 != @18-09-17 10:20:00.000@ then if $data20 != @18-09-17 10:20:00.008@ then
return -1 return -1
endi endi
if $data21 != 8 then if $data21 != 8 then
...@@ -891,7 +880,7 @@ endi ...@@ -891,7 +880,7 @@ endi
if $data22 != 8 then if $data22 != 8 then
return -1 return -1
endi endi
if $data30 != @18-09-17 10:00:00.000@ then if $data30 != @18-09-17 10:00:00.007@ then
return -1 return -1
endi endi
if $data31 != 6 then if $data31 != 6 then
...@@ -900,7 +889,7 @@ endi ...@@ -900,7 +889,7 @@ endi
if $data32 != 7 then if $data32 != 7 then
return -1 return -1
endi endi
if $data40 != @18-09-17 10:10:00.000@ then if $data40 != @18-09-17 10:10:00.007@ then
return -1 return -1
endi endi
if $data41 != 7 then if $data41 != 7 then
...@@ -909,7 +898,7 @@ endi ...@@ -909,7 +898,7 @@ endi
if $data42 != 7 then if $data42 != 7 then
return -1 return -1
endi endi
if $data50 != @18-09-17 10:20:00.000@ then if $data50 != @18-09-17 10:20:00.007@ then
return -1 return -1
endi endi
if $data51 != 8 then if $data51 != 8 then
...@@ -923,7 +912,7 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 orde ...@@ -923,7 +912,7 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 orde
if $rows != 6 then if $rows != 6 then
return -1 return -1
endi endi
if $data00 != @18-09-17 10:00:00.000@ then if $data00 != @18-09-17 10:00:00.001@ then
return -1 return -1
endi endi
if $data01 != 6 then if $data01 != 6 then
...@@ -932,7 +921,7 @@ endi ...@@ -932,7 +921,7 @@ endi
if $data02 != 1 then if $data02 != 1 then
return -1 return -1
endi endi
if $data10 != @18-09-17 10:10:00.000@ then if $data10 != @18-09-17 10:10:00.001@ then
return -1 return -1
endi endi
if $data11 != 7 then if $data11 != 7 then
...@@ -941,7 +930,7 @@ endi ...@@ -941,7 +930,7 @@ endi
if $data12 != 1 then if $data12 != 1 then
return -1 return -1
endi endi
if $data20 != @18-09-17 10:20:00.000@ then if $data20 != @18-09-17 10:20:00.001@ then
return -1 return -1
endi endi
if $data21 != 8 then if $data21 != 8 then
...@@ -950,7 +939,7 @@ endi ...@@ -950,7 +939,7 @@ endi
if $data22 != 1 then if $data22 != 1 then
return -1 return -1
endi endi
if $data30 != @18-09-17 10:00:00.000@ then if $data30 != @18-09-17 10:00:00.002@ then
return -1 return -1
endi endi
if $data31 != 6 then if $data31 != 6 then
...@@ -959,7 +948,7 @@ endi ...@@ -959,7 +948,7 @@ endi
if $data32 != 2 then if $data32 != 2 then
return -1 return -1
endi endi
if $data40 != @18-09-17 10:10:00.000@ then if $data40 != @18-09-17 10:10:00.002@ then
return -1 return -1
endi endi
if $data41 != 7 then if $data41 != 7 then
...@@ -968,7 +957,7 @@ endi ...@@ -968,7 +957,7 @@ endi
if $data42 != 2 then if $data42 != 2 then
return -1 return -1
endi endi
if $data50 != @18-09-17 10:20:00.000@ then if $data50 != @18-09-17 10:20:00.002@ then
return -1 return -1
endi endi
if $data51 != 8 then if $data51 != 8 then
...@@ -982,7 +971,7 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 orde ...@@ -982,7 +971,7 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 orde
if $rows != 6 then if $rows != 6 then
return -1 return -1
endi endi
if $data00 != @18-09-17 10:20:00.000@ then if $data00 != @18-09-17 10:20:00.001@ then
return -1 return -1
endi endi
if $data01 != 8 then if $data01 != 8 then
...@@ -991,7 +980,7 @@ endi ...@@ -991,7 +980,7 @@ endi
if $data02 != 1 then if $data02 != 1 then
return -1 return -1
endi endi
if $data10 != @18-09-17 10:10:00.000@ then if $data10 != @18-09-17 10:10:00.001@ then
return -1 return -1
endi endi
if $data11 != 7 then if $data11 != 7 then
...@@ -1000,7 +989,7 @@ endi ...@@ -1000,7 +989,7 @@ endi
if $data12 != 1 then if $data12 != 1 then
return -1 return -1
endi endi
if $data20 != @18-09-17 10:00:00.000@ then if $data20 != @18-09-17 10:00:00.001@ then
return -1 return -1
endi endi
if $data21 != 6 then if $data21 != 6 then
...@@ -1009,7 +998,7 @@ endi ...@@ -1009,7 +998,7 @@ endi
if $data22 != 1 then if $data22 != 1 then
return -1 return -1
endi endi
if $data30 != @18-09-17 10:20:00.000@ then if $data30 != @18-09-17 10:20:00.002@ then
return -1 return -1
endi endi
if $data31 != 8 then if $data31 != 8 then
...@@ -1018,7 +1007,7 @@ endi ...@@ -1018,7 +1007,7 @@ endi
if $data32 != 2 then if $data32 != 2 then
return -1 return -1
endi endi
if $data40 != @18-09-17 10:10:00.000@ then if $data40 != @18-09-17 10:10:00.002@ then
return -1 return -1
endi endi
if $data41 != 7 then if $data41 != 7 then
...@@ -1027,7 +1016,7 @@ endi ...@@ -1027,7 +1016,7 @@ endi
if $data42 != 2 then if $data42 != 2 then
return -1 return -1
endi endi
if $data50 != @18-09-17 10:00:00.000@ then if $data50 != @18-09-17 10:00:00.002@ then
return -1 return -1
endi endi
if $data51 != 6 then if $data51 != 6 then
...@@ -1052,9 +1041,9 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts d ...@@ -1052,9 +1041,9 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts d
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data00 != @18-09-17 09:00:00.000@ then #if $data00 != @18-09-17 09:00:00.000@ then
return -1 # return -1
endi #endi
if $data01 != 0 then if $data01 != 0 then
return -1 return -1
endi endi
...@@ -1063,9 +1052,9 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts a ...@@ -1063,9 +1052,9 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts a
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data00 != @18-09-17 09:00:00.000@ then #if $data00 != @18-09-17 09:00:00.000@ then
return -1 # return -1
endi #endi
if $data01 != 0 then if $data01 != 0 then
return -1 return -1
endi endi
...@@ -1074,54 +1063,54 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 o ...@@ -1074,54 +1063,54 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 o
if $rows != 6 then if $rows != 6 then
return -1 return -1
endi endi
if $data00 != @18-09-17 09:30:00.000@ then #if $data00 != @18-09-17 09:30:00.000@ then
return -1 # return -1
endi #endi
if $data01 != 3 then if $data01 != 3 then
return -1 return -1
endi endi
if $data02 != 8 then if $data02 != 8 then
return -1 return -1
endi endi
if $data10 != @18-09-17 09:20:00.000@ then #if $data10 != @18-09-17 09:20:00.000@ then
return -1 # return -1
endi #endi
if $data11 != 2 then if $data11 != 2 then
return -1 return -1
endi endi
if $data12 != 8 then if $data12 != 8 then
return -1 return -1
endi endi
if $data20 != @18-09-17 09:10:00.000@ then #if $data20 != @18-09-17 09:10:00.000@ then
return -1 # return -1
endi #endi
if $data21 != 1 then if $data21 != 1 then
return -1 return -1
endi endi
if $data22 != 8 then if $data22 != 8 then
return -1 return -1
endi endi
if $data30 != @18-09-17 09:30:00.000@ then #if $data30 != @18-09-17 09:30:00.000@ then
return -1 # return -1
endi #endi
if $data31 != 3 then if $data31 != 3 then
return -1 return -1
endi endi
if $data32 != 7 then if $data32 != 7 then
return -1 return -1
endi endi
if $data40 != @18-09-17 09:20:00.000@ then #if $data40 != @18-09-17 09:20:00.000@ then
return -1 # return -1
endi #endi
if $data41 != 2 then if $data41 != 2 then
return -1 return -1
endi endi
if $data42 != 7 then if $data42 != 7 then
return -1 return -1
endi endi
if $data50 != @18-09-17 09:10:00.000@ then #if $data50 != @18-09-17 09:10:00.000@ then
return -1 # return -1
endi #endi
if $data51 != 1 then if $data51 != 1 then
return -1 return -1
endi endi
...@@ -1133,54 +1122,54 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 o ...@@ -1133,54 +1122,54 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 o
if $rows != 6 then if $rows != 6 then
return -1 return -1
endi endi
if $data00 != @18-09-17 09:30:00.000@ then #if $data00 != @18-09-17 09:30:00.000@ then
return -1 # return -1
endi #endi
if $data01 != 3 then if $data01 != 3 then
return -1 return -1
endi endi
if $data02 != 1 then if $data02 != 1 then
return -1 return -1
endi endi
if $data10 != @18-09-17 09:20:00.000@ then #if $data10 != @18-09-17 09:20:00.000@ then
return -1 # return -1
endi #endi
if $data11 != 2 then if $data11 != 2 then
return -1 return -1
endi endi
if $data12 != 1 then if $data12 != 1 then
return -1 return -1
endi endi
if $data20 != @18-09-17 09:10:00.000@ then #if $data20 != @18-09-17 09:10:00.000@ then
return -1 # return -1
endi #endi
if $data21 != 1 then if $data21 != 1 then
return -1 return -1
endi endi
if $data22 != 1 then if $data22 != 1 then
return -1 return -1
endi endi
if $data30 != @18-09-17 09:30:00.000@ then #if $data30 != @18-09-17 09:30:00.000@ then
return -1 # return -1
endi #endi
if $data31 != 3 then if $data31 != 3 then
return -1 return -1
endi endi
if $data32 != 2 then if $data32 != 2 then
return -1 return -1
endi endi
if $data40 != @18-09-17 09:20:00.000@ then #if $data40 != @18-09-17 09:20:00.000@ then
return -1 # return -1
endi #endi
if $data41 != 2 then if $data41 != 2 then
return -1 return -1
endi endi
if $data42 != 2 then if $data42 != 2 then
return -1 return -1
endi endi
if $data50 != @18-09-17 09:10:00.000@ then #if $data50 != @18-09-17 09:10:00.000@ then
return -1 # return -1
endi #endi
if $data51 != 1 then if $data51 != 1 then
return -1 return -1
endi endi
...@@ -1192,54 +1181,54 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 o ...@@ -1192,54 +1181,54 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 o
if $rows != 6 then if $rows != 6 then
return -1 return -1
endi endi
if $data00 != @18-09-17 09:30:00.000@ then #if $data00 != @18-09-17 09:30:00.000@ then
return -1 # return -1
endi #endi
if $data01 != 3 then if $data01 != 3 then
return -1 return -1
endi endi
if $data02 != 1 then if $data02 != 1 then
return -1 return -1
endi endi
if $data10 != @18-09-17 09:20:00.000@ then #if $data10 != @18-09-17 09:20:00.000@ then
return -1 # return -1
endi #endi
if $data11 != 2 then if $data11 != 2 then
return -1 return -1
endi endi
if $data12 != 1 then if $data12 != 1 then
return -1 return -1
endi endi
if $data20 != @18-09-17 09:10:00.000@ then #if $data20 != @18-09-17 09:10:00.000@ then
return -1 # return -1
endi #endi
if $data21 != 1 then if $data21 != 1 then
return -1 return -1
endi endi
if $data22 != 1 then if $data22 != 1 then
return -1 return -1
endi endi
if $data30 != @18-09-17 09:30:00.000@ then #if $data30 != @18-09-17 09:30:00.000@ then
return -1 # return -1
endi #endi
if $data31 != 3 then if $data31 != 3 then
return -1 return -1
endi endi
if $data32 != 2 then if $data32 != 2 then
return -1 return -1
endi endi
if $data40 != @18-09-17 09:20:00.000@ then #if $data40 != @18-09-17 09:20:00.000@ then
return -1 # return -1
endi #endi
if $data41 != 2 then if $data41 != 2 then
return -1 return -1
endi endi
if $data42 != 2 then if $data42 != 2 then
return -1 return -1
endi endi
if $data50 != @18-09-17 09:10:00.000@ then #if $data50 != @18-09-17 09:10:00.000@ then
return -1 # return -1
endi #endi
if $data51 != 1 then if $data51 != 1 then
return -1 return -1
endi endi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册