提交 cef85dc7 编写于 作者: S Shengliang Guan

Merge branch 'feature/wal' of https://github.com/taosdata/TDengine into feature/wal

......@@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS)
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF (TD_MVN_INSTALLED)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.13-dist.jar DESTINATION connector/jdbc)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.14-dist.jar DESTINATION connector/jdbc)
ENDIF ()
ELSEIF (TD_DARWIN)
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
......
......@@ -12,7 +12,7 @@ TDengine采用关系型数据模型,需要建库、建表。因此对于一个
CREATE DATABASE power KEEP 365 DAYS 10 BLOCKS 4;
```
上述语句将创建一个名为power的库,这个库的数据将保留365天(超过365天将被自动删除),每10天一个数据文件,内存块数为4。详细的语法及参数请见<a href="https://www.taosdata.com/cn/documentation20/taos-sql/">TAOS SQL</a>
创建库之后,需要使用SQL命令USE将当前库切换过来,例如:
```cmd
......@@ -20,7 +20,7 @@ USE power;
```
就当前连接里操作的库换为power,否则对具体表操作前,需要使用“库名.表名”来指定库的名字。
**注意:**
- 任何一张表或超级表是属于一个库的,在创建表之前,必须先创建库。
......@@ -44,15 +44,17 @@ CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2);
```
其中d1001是表名,meters是超级表的表名,后面紧跟标签Location的具体标签值”Beijing.Chaoyang",标签groupId的具体标签值2。虽然在创建表时,需要指定标签值,但可以事后修改。详细细则请见 TAOS SQL。
**注意:**目前 TDengine 没有从技术层面限制使用一个 database (dbA)的超级表作为模板建立另一个 database (dbB)的子表,后续会禁止这种用法,不建议使用这种方法建表。
TDengine建议将数据采集点的全局唯一ID作为表名(比如设备序列号)。但对于有的场景,并没有唯一的ID,可以将多个ID组合成一个唯一的ID。不建议将具有唯一性的ID作为标签值。
**自动建表**:在某些特殊场景中,用户在写数据时并不确定某个数据采集点的表是否存在,此时可在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。比如:
```cmd
INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 219, 0.32);
```
上述SQL语句将记录(now, 10.2, 219, 0.32) 插入进表d1001。如果表d1001还未创建,则使用超级表meters做模板自动创建,同时打上标签值“Beijing.Chaoyang", 2。
## 多列模型 vs 单列模型
TDengine支持多列模型,只要物理量是一个数据采集点同时采集的(时间戳一致),这些量就可以作为不同列放在一张超级表里。但还有一种极限的设计,单列模型,每个采集的物理量都单独建表,因此每种类型的物理量都单独建立一超级表。比如电流、电压、相位,就建三张超级表。
......
......@@ -36,16 +36,20 @@
5. ping服务器FQDN,如果没有反应,请检查你的网络,DNS设置,或客户端所在计算机的系统hosts文件
6. 检查防火墙设置,确认TCP/UDP 端口6030-6042 是打开的
6. 检查防火墙设置(Ubuntu 使用 ufw status,CentOS 使用 firewall-cmd --list-port),确认TCP/UDP 端口6030-6042 是打开的
7. 对于Linux上的JDBC(ODBC, Python, Go等接口类似)连接, 确保*libtaos.so*在目录*/usr/local/taos/driver*里, 并且*/usr/local/taos/driver*在系统库函数搜索路径*LD_LIBRARY_PATH*
8. 对于windows上的JDBC, ODBC, Python, Go等连接,确保*C:\TDengine\driver\taos.dll*在你的系统库函数搜索目录里 (建议*taos.dll*放在目录 *C:\Windows\System32*)
9. 如果仍不能排除连接故障,请使用命令行工具nc来分别判断指定端口的TCP和UDP连接是否通畅
检查UDP端口连接是否工作:`nc -vuz {hostIP} {port} `
检查服务器侧TCP端口连接是否工作:`nc -l {port}`
检查客户端侧TCP端口连接是否工作:`nc {hostIP} {port}`
9. 如果仍不能排除连接故障
* Linux 系统请使用命令行工具nc来分别判断指定端口的TCP和UDP连接是否通畅
检查UDP端口连接是否工作:`nc -vuz {hostIP} {port} `
检查服务器侧TCP端口连接是否工作:`nc -l {port}`
检查客户端侧TCP端口连接是否工作:`nc {hostIP} {port}`
* Windows 系统请使用 PowerShell 命令 Net-TestConnection -ComputerName {fqdn} -Port {port} 检测服务段端口是否访问
10. 也可以使用taos程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅(包括TCP和UDP):[TDengine 内嵌网络检测工具使用指南](https://www.taosdata.com/blog/2020/09/08/1816.html)
......
......@@ -92,7 +92,7 @@ typedef struct SVgroupTableInfo {
} SVgroupTableInfo;
static FORCE_INLINE SQueryInfo* tscGetQueryInfoDetail(SSqlCmd* pCmd, int32_t subClauseIndex) {
assert(pCmd != NULL && subClauseIndex >= 0 && subClauseIndex < TSDB_MAX_UNION_CLAUSE);
assert(pCmd != NULL && subClauseIndex >= 0);
if (pCmd->pQueryInfo == NULL || subClauseIndex >= pCmd->numOfClause) {
return NULL;
......
......@@ -54,8 +54,8 @@
#define DO_UPDATE_TAG_COLUMNS(ctx, ts) \
do { \
for (int32_t i = 0; i < (ctx)->tagInfo.numOfTagCols; ++i) { \
SQLFunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[i]; \
for (int32_t _i = 0; _i < (ctx)->tagInfo.numOfTagCols; ++_i) { \
SQLFunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[_i]; \
if (__ctx->functionId == TSDB_FUNC_TS_DUMMY) { \
__ctx->tag.i64Key = (ts); \
__ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; \
......@@ -66,8 +66,8 @@
#define DO_UPDATE_TAG_COLUMNS_WITHOUT_TS(ctx) \
do { \
for (int32_t i = 0; i < (ctx)->tagInfo.numOfTagCols; ++i) { \
SQLFunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[i]; \
for (int32_t _i = 0; _i < (ctx)->tagInfo.numOfTagCols; ++_i) { \
SQLFunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[_i]; \
aAggs[TSDB_FUNC_TAG].xFunction(__ctx); \
} \
} while (0);
......@@ -305,7 +305,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
} else if (functionId == TSDB_FUNC_FIRST || functionId == TSDB_FUNC_LAST) {
*type = (int16_t)dataType;
*bytes = (int16_t)dataBytes;
*interBytes = dataBytes;
*interBytes = (int16_t)(dataBytes + sizeof(SFirstLastInfo));
} else if (functionId == TSDB_FUNC_SPREAD) {
*type = (int16_t)TSDB_DATA_TYPE_DOUBLE;
*bytes = sizeof(double);
......@@ -1169,8 +1169,8 @@ static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *outp
if ((*(int32_t *)output < v) ^ isMin) {
*(int32_t *)output = v;
for (int32_t i = 0; i < pCtx->tagInfo.numOfTagCols; ++i) {
SQLFunctionCtx *__ctx = pCtx->tagInfo.pTagCtxList[i];
for (int32_t j = 0; j < pCtx->tagInfo.numOfTagCols; ++j) {
SQLFunctionCtx *__ctx = pCtx->tagInfo.pTagCtxList[j];
aAggs[TSDB_FUNC_TAG].xFunction(__ctx);
}
......@@ -1679,16 +1679,35 @@ static void last_function_f(SQLFunctionCtx *pCtx, int32_t index) {
if (pCtx->hasNull && isNull(pData, pCtx->inputType)) {
return;
}
SET_VAL(pCtx, 1, 1);
memcpy(pCtx->aOutputBuf, pData, pCtx->inputBytes);
TSKEY ts = pCtx->ptsList[index];
DO_UPDATE_TAG_COLUMNS(pCtx, ts);
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
pResInfo->hasResult = DATA_SET_FLAG;
pResInfo->complete = true; // set query completed
// the scan order is not the required order, ignore it
if (pCtx->order != pCtx->param[0].i64Key) {
return;
}
if (pCtx->order == TSDB_ORDER_DESC) {
SET_VAL(pCtx, 1, 1);
memcpy(pCtx->aOutputBuf, pData, pCtx->inputBytes);
TSKEY ts = pCtx->ptsList[index];
DO_UPDATE_TAG_COLUMNS(pCtx, ts);
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
pResInfo->hasResult = DATA_SET_FLAG;
pResInfo->complete = true; // set query completed
} else { // in case of ascending order check, all data needs to be checked
SResultRowCellInfo* pResInfo = GET_RES_INFO(pCtx);
TSKEY ts = pCtx->ptsList[index];
char* buf = GET_ROWCELL_INTERBUF(pResInfo);
if (pResInfo->hasResult != DATA_SET_FLAG || (*(TSKEY*)buf) < ts) {
pResInfo->hasResult = DATA_SET_FLAG;
memcpy(pCtx->aOutputBuf, pData, pCtx->inputBytes);
*(TSKEY*)buf = ts;
DO_UPDATE_TAG_COLUMNS(pCtx, ts);
}
}
}
static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t index) {
......@@ -1711,7 +1730,7 @@ static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t ind
static void last_dist_function(SQLFunctionCtx *pCtx) {
/*
* 1. for scan data in asc order, no need to check data
* 1. for scan data is not the required order
* 2. for data blocks that are not loaded, no need to check data
*/
if (pCtx->order != pCtx->param[0].i64Key) {
......@@ -2447,7 +2466,7 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx) {
static void percentile_function(SQLFunctionCtx *pCtx) {
int32_t notNullElems = 0;
SResultRowCellInfo * pResInfo = GET_RES_INFO(pCtx);
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
SPercentileInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo);
// the first stage, only acquire the min/max value
......@@ -2548,12 +2567,14 @@ static void percentile_finalizer(SQLFunctionCtx *pCtx) {
double v = pCtx->param[0].nType == TSDB_DATA_TYPE_INT ? pCtx->param[0].i64Key : pCtx->param[0].dKey;
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
tMemBucket * pMemBucket = ((SPercentileInfo *)GET_ROWCELL_INTERBUF(pResInfo))->pMemBucket;
if (pMemBucket->total > 0) { // check for null
*(double *)pCtx->aOutputBuf = getPercentile(pMemBucket, v);
} else {
SPercentileInfo* ppInfo = (SPercentileInfo *) GET_ROWCELL_INTERBUF(pResInfo);
tMemBucket * pMemBucket = ppInfo->pMemBucket;
if (pMemBucket == NULL || pMemBucket->total == 0) { // check for null
assert(ppInfo->numOfElems == 0);
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes);
} else {
*(double *)pCtx->aOutputBuf = getPercentile(pMemBucket, v);
}
tMemBucketDestroy(pMemBucket);
......
......@@ -1633,7 +1633,7 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen)
int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize) {
int32_t maxRowSize = MAX(rowSize, finalRowSize);
char* pbuf = calloc(1, pOutput->num * maxRowSize);
char* pbuf = calloc(1, (size_t)(pOutput->num * maxRowSize));
size_t size = tscNumOfFields(pQueryInfo);
SArithmeticSupport arithSup = {0};
......@@ -1660,16 +1660,16 @@ int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_
tExprTreeCalcTraverse(arithSup.pArithExpr->pExpr, (int32_t) pOutput->num, pbuf + pOutput->num*offset, &arithSup, TSDB_ORDER_ASC, getArithmeticInputSrc);
} else {
SSqlExpr* pExpr = pSup->pSqlExpr;
memcpy(pbuf + pOutput->num * offset, pExpr->offset * pOutput->num + pOutput->data, pExpr->resBytes * pOutput->num);
memcpy(pbuf + pOutput->num * offset, pExpr->offset * pOutput->num + pOutput->data, (size_t)(pExpr->resBytes * pOutput->num));
}
offset += pSup->field.bytes;
}
memcpy(pOutput->data, pbuf, pOutput->num * offset);
memcpy(pOutput->data, pbuf, (size_t)(pOutput->num * offset));
tfree(pbuf);
tfree(arithSup.data);
return offset;
}
\ No newline at end of file
}
......@@ -181,9 +181,16 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
void tscProcessActivityTimer(void *handle, void *tmrId) {
int64_t rid = (int64_t) handle;
STscObj *pObj = taosAcquireRef(tscRefId, rid);
if (pObj == NULL) return;
if (pObj == NULL) {
return;
}
SSqlObj* pHB = taosAcquireRef(tscObjRef, pObj->hbrid);
if (pHB == NULL) {
taosReleaseRef(tscRefId, rid);
return;
}
assert(pHB->self == pObj->hbrid);
pHB->retry = 0;
......
......@@ -292,16 +292,18 @@ void taos_close(TAOS *taos) {
pObj->signature = NULL;
taosTmrStopA(&(pObj->pTimer));
SSqlObj* pHb = (SSqlObj*)taosAcquireRef(tscObjRef, pObj->hbrid);
if (pHb != NULL) {
if (pHb->rpcRid > 0) { // wait for rsp from dnode
rpcCancelRequest(pHb->rpcRid);
pHb->rpcRid = -1;
}
if (pObj->hbrid > 0) {
SSqlObj* pHb = (SSqlObj*)taosAcquireRef(tscObjRef, pObj->hbrid);
if (pHb != NULL) {
if (pHb->rpcRid > 0) { // wait for rsp from dnode
rpcCancelRequest(pHb->rpcRid);
pHb->rpcRid = -1;
}
tscDebug("%p HB is freed", pHb);
taos_free_result(pHb);
taosReleaseRef(tscObjRef, pHb->self);
tscDebug("%p HB is freed", pHb);
taos_free_result(pHb);
taosReleaseRef(tscObjRef, pHb->self);
}
}
int32_t ref = T_REF_DEC(pObj);
......
......@@ -25,6 +25,8 @@ void extractTableName(const char *tableId, char *name);
char* extractDBName(const char *tableId, char *name);
size_t tableIdPrefix(const char* name, char* prefix, int32_t len);
void extractTableNameFromToken(SStrToken *pToken, SStrToken* pTable);
SSchema tGetTableNameColumnSchema();
......
......@@ -39,6 +39,13 @@ char* extractDBName(const char* tableId, char* name) {
return strncpy(name, &tableId[offset1 + 1], len);
}
size_t tableIdPrefix(const char* name, char* prefix, int32_t len) {
tstrncpy(prefix, name, len);
strcat(prefix, TS_PATH_DELIMITER);
return strlen(prefix);
}
SSchema tGetTableNameColumnSchema() {
SSchema s = {0};
s.bytes = TSDB_TABLE_NAME_LEN - 1 + VARSTR_HEADER_SIZE;
......@@ -198,4 +205,4 @@ SSchema tscGetTbnameColumnSchema() {
strcpy(s.name, TSQL_TBNAME_L);
return s;
}
\ No newline at end of file
}
......@@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED)
ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME}
POST_BUILD
COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.13-dist.jar ${LIBRARY_OUTPUT_PATH}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.14-dist.jar ${LIBRARY_OUTPUT_PATH}
COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
COMMENT "build jdbc driver")
ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME})
......
......@@ -5,7 +5,7 @@
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
<version>2.0.13</version>
<version>2.0.14</version>
<packaging>jar</packaging>
<name>JDBCDriver</name>
......
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
<version>2.0.13</version>
<version>2.0.14</version>
<packaging>jar</packaging>
<name>JDBCDriver</name>
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
......
......@@ -236,7 +236,14 @@ PRASE_EPS_OVER:
dnodeResetEps(eps);
if (eps) free(eps);
#if 0
dnodeUpdateEp(dnodeGetDnodeId(), tsLocalEp, tsLocalFqdn, &tsServerPort);
#else
if (dnodeCheckEpChanged(dnodeGetDnodeId(), tsLocalEp)) {
dError("dnode:%d, localEp is changed to %s in dnodeEps.json and need reconfigured", dnodeGetDnodeId(), tsLocalEp);
return -1;
}
#endif
terrno = 0;
return 0;
......
......@@ -157,12 +157,13 @@ static void dnodeResetMInfos(SMInfos *pMinfos) {
}
static int32_t dnodeReadMInfos() {
int32_t len = 0;
int32_t maxLen = 2000;
char * content = calloc(1, maxLen + 1);
cJSON * root = NULL;
FILE * fp = NULL;
SMInfos minfos = {0};
int32_t len = 0;
int32_t maxLen = 2000;
char * content = calloc(1, maxLen + 1);
cJSON * root = NULL;
FILE * fp = NULL;
SMInfos minfos = {0};
bool nodeChanged = false;
char file[TSDB_FILENAME_LEN + 20] = {0};
sprintf(file, "%s/mnodeEpSet.json", tsDnodeDir);
......@@ -221,14 +222,19 @@ static int32_t dnodeReadMInfos() {
dError("failed to read mnodeEpSet.json, nodeId not found");
goto PARSE_MINFOS_OVER;
}
minfos.mnodeInfos[i].mnodeId = nodeId->valueint;
cJSON *nodeEp = cJSON_GetObjectItem(nodeInfo, "nodeEp");
if (!nodeEp || nodeEp->type != cJSON_String || nodeEp->valuestring == NULL) {
dError("failed to read mnodeEpSet.json, nodeName not found");
goto PARSE_MINFOS_OVER;
}
strncpy(minfos.mnodeInfos[i].mnodeEp, nodeEp->valuestring, TSDB_EP_LEN);
SMInfo *pMinfo = &minfos.mnodeInfos[i];
pMinfo->mnodeId = nodeId->valueint;
tstrncpy(pMinfo->mnodeEp, nodeEp->valuestring, TSDB_EP_LEN);
bool changed = dnodeCheckEpChanged(pMinfo->mnodeId, pMinfo->mnodeEp);
if (changed) nodeChanged = changed;
}
dInfo("read file %s successed", file);
......@@ -245,6 +251,11 @@ PARSE_MINFOS_OVER:
dnodeUpdateEp(mInfo->mnodeId, mInfo->mnodeEp, NULL, NULL);
}
dnodeResetMInfos(&minfos);
if (nodeChanged) {
dnodeWriteMInfos();
}
return 0;
}
......
......@@ -58,10 +58,10 @@ typedef struct {
static const SDnodeComponent tsDnodeComponents[] = {
{"tfile", tfInit, tfCleanup},
{"rpc", rpcInit, rpcCleanup},
{"globalcfg" ,taosCheckGlobalCfg, NULL},
{"storage", dnodeInitStorage, dnodeCleanupStorage},
{"dnodecfg", dnodeInitCfg, dnodeCleanupCfg},
{"dnodeeps", dnodeInitEps, dnodeCleanupEps},
{"globalcfg" ,taosCheckGlobalCfg, NULL},
{"mnodeinfos",dnodeInitMInfos, dnodeCleanupMInfos},
{"wal", walInit, walCleanUp},
{"check", dnodeInitCheck, dnodeCleanupCheck}, // NOTES: dnodeInitCheck must be behind the dnodeinitStorage component !!!
......
......@@ -339,7 +339,12 @@ static int32_t dnodeOpenVnodes() {
}
free(threads);
dInfo("there are total vnodes:%d, openned:%d failed:%d", numOfVnodes, openVnodes, failedVnodes);
dInfo("there are total vnodes:%d, openned:%d", numOfVnodes, openVnodes);
if (failedVnodes != 0) {
dError("there are total vnodes:%d, failed:%d", numOfVnodes, failedVnodes);
return -1;
}
return TSDB_CODE_SUCCESS;
}
......
......@@ -428,11 +428,6 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf
#define TSDB_PORT_SYNC 10
#define TSDB_PORT_HTTP 11
#define TSDB_PORT_ARBITRATOR 12
#define TSDB_PORT_DNODESHELL 0
#define TSDB_PORT_DNODEDNODE 5
#define TSDB_PORT_SYNC 10
#define TSDB_PORT_HTTP 11
#define TSDB_PORT_ARBITRATOR 12
#define TSDB_MAX_WAL_SIZE (1024*1024)
......
......@@ -64,7 +64,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_TRAN_ID, 0, 0x000F, "Invalid tr
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_SESSION_ID, 0, 0x0010, "Invalid session id")
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_MSG_TYPE, 0, 0x0011, "Invalid message type")
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_RESPONSE_TYPE, 0, 0x0012, "Invalid response type")
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_TIME_STAMP, 0, 0x0013, "Invalid timestamp")
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_TIME_STAMP, 0, 0x0013, "Client and server's time is not synchronized")
TAOS_DEFINE_ERROR(TSDB_CODE_APP_NOT_READY, 0, 0x0014, "Database not ready")
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_FQDN_ERROR, 0, 0x0015, "Unable to resolve FQDN")
......
......@@ -1734,6 +1734,16 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
if (pTable->info.type == TSDB_CHILD_TABLE) {
STagData *pTagData = (STagData *)pCreate->schema; // it is a tag key
char prefix[64] = {0};
size_t prefixLen = tableIdPrefix(pMsg->pDb->name, prefix, 64);
if (0 != strncasecmp(prefix, pTagData->name, prefixLen)) {
mError("msg:%p, app:%p table:%s, corresponding super table:%s not in this db", pMsg, pMsg->rpcMsg.ahandle,
pCreate->tableId, pTagData->name);
mnodeDestroyChildTable(pTable);
return TSDB_CODE_TDB_INVALID_CREATE_TB_MSG;
}
if (pMsg->pSTable == NULL) pMsg->pSTable = mnodeGetSuperTable(pTagData->name);
if (pMsg->pSTable == NULL) {
mError("msg:%p, app:%p table:%s, corresponding super table:%s does not exist", pMsg, pMsg->rpcMsg.ahandle,
......@@ -2629,9 +2639,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
char prefix[64] = {0};
tstrncpy(prefix, pDb->name, 64);
strcat(prefix, TS_PATH_DELIMITER);
int32_t prefixLen = strlen(prefix);
int32_t prefixLen = tableIdPrefix(pDb->name, prefix, 64);
char* pattern = NULL;
if (pShow->payloadLen > 0) {
......
......@@ -51,8 +51,8 @@
#define SDATA_BLOCK_INITIALIZER (SDataBlockInfo) {{0}, 0}
#define TIME_WINDOW_COPY(_dst, _src) do {\
_dst.skey = _src.skey;\
_dst.ekey = _src.ekey;\
(_dst).skey = (_src).skey;\
(_dst).ekey = (_src).ekey;\
} while (0);
enum {
......@@ -197,7 +197,7 @@ static int32_t checkForQueryBuf(size_t numOfTables);
static void releaseQueryBuf(size_t numOfTables);
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 STsdbQueryCond createTsdbQueryCond(SQuery* pQuery);
static STsdbQueryCond createTsdbQueryCond(SQuery* pQuery, STimeWindow* win);
static STableIdInfo createTableIdInfo(SQuery* pQuery);
bool doFilterData(SQuery *pQuery, int32_t elemPos) {
......@@ -1204,7 +1204,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
// prev time window not interpolation yet.
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) {
SResultRow *pRes = pWindowResInfo->pResult[j];
......@@ -3914,8 +3914,7 @@ static void setEnvBeforeReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatusI
}
SET_REVERSE_SCAN_FLAG(pRuntimeEnv);
STsdbQueryCond cond = createTsdbQueryCond(pQuery);
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
setQueryStatus(pQuery, QUERY_NOT_COMPLETED);
switchCtxOrder(pRuntimeEnv);
......@@ -4004,7 +4003,7 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) {
tsdbCleanupQueryHandle(pRuntimeEnv->pSecQueryHandle);
}
STsdbQueryCond cond = createTsdbQueryCond(pQuery);
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &qstatus.curWindow);
restoreTimeWindow(&pQInfo->tableGroupInfo, &cond);
pRuntimeEnv->pSecQueryHandle = tsdbQueryTables(pQInfo->tsdb, &cond, &pQInfo->tableGroupInfo, pQInfo, &pQInfo->memRef);
if (pRuntimeEnv->pSecQueryHandle == NULL) {
......@@ -4883,7 +4882,7 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery)
return TSDB_CODE_SUCCESS;
}
STsdbQueryCond cond = createTsdbQueryCond(pQuery);
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
if (!isSTableQuery
&& (pQInfo->tableqinfoGroupInfo.numOfTables == 1)
......@@ -5273,14 +5272,14 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
return true;
}
STsdbQueryCond createTsdbQueryCond(SQuery* pQuery) {
STsdbQueryCond createTsdbQueryCond(SQuery* pQuery, STimeWindow* win) {
STsdbQueryCond cond = {
.colList = pQuery->colList,
.order = pQuery->order.order,
.numOfCols = pQuery->numOfCols,
};
TIME_WINDOW_COPY(cond.twindow, pQuery->window);
TIME_WINDOW_COPY(cond.twindow, *win);
return cond;
}
......@@ -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,
pQInfo->groupIndex, numOfGroups, group);
STsdbQueryCond cond = createTsdbQueryCond(pQuery);
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
SArray *g1 = taosArrayInit(1, POINTER_BYTES);
SArray *tx = taosArrayClone(group);
......@@ -5391,7 +5390,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
qDebug("QInfo:%p group by normal columns group:%d, total group:%" PRIzu "", pQInfo, pQInfo->groupIndex,
numOfGroups);
STsdbQueryCond cond = createTsdbQueryCond(pQuery);
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
SArray *g1 = taosArrayInit(1, POINTER_BYTES);
SArray *tx = taosArrayClone(group);
......@@ -5457,7 +5456,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
clearClosedTimeWindow(pRuntimeEnv);
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.
SDataBlockInfo blockInfo = SDATA_BLOCK_INITIALIZER;
resetDefaultResInfoOutputBuf(pRuntimeEnv);
......@@ -5468,7 +5467,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
void *pQueryHandle = pRuntimeEnv->pQueryHandle;
if (pQueryHandle == NULL) {
STsdbQueryCond con = createTsdbQueryCond(pQuery);
STsdbQueryCond con = createTsdbQueryCond(pQuery, &pQuery->window);
pRuntimeEnv->pQueryHandle = tsdbQueryTables(pQInfo->tsdb, &con, &pQInfo->tableGroupInfo, pQInfo, &pQInfo->memRef);
pQueryHandle = pRuntimeEnv->pQueryHandle;
}
......@@ -5481,6 +5480,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
// }
bool hasMoreBlock = true;
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
SQueryCostInfo *summary = &pRuntimeEnv->summary;
while ((hasMoreBlock = tsdbNextDataBlock(pQueryHandle)) == true) {
summary->totalBlocks += 1;
......@@ -5513,9 +5513,13 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
break;
}
assert(status != BLK_DATA_DISCARD);
ensureOutputBuffer(pRuntimeEnv, &blockInfo);
if(status == BLK_DATA_DISCARD) {
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;
int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, binarySearchForKey, pDataBlock);
......@@ -5682,7 +5686,7 @@ static void doSaveContext(SQInfo *pQInfo) {
SWITCH_ORDER(pRuntimeEnv->pTSBuf->cur.order);
}
STsdbQueryCond cond = createTsdbQueryCond(pQuery);
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
// clean unused handle
if (pRuntimeEnv->pSecQueryHandle != NULL) {
......@@ -5833,7 +5837,7 @@ static void doSecondaryArithmeticProcess(SQuery* pQuery) {
tFilePage **data = calloc(pQuery->numOfExpr2, POINTER_BYTES);
for (int32_t i = 0; i < pQuery->numOfExpr2; ++i) {
int32_t bytes = pQuery->pExpr2[i].bytes;
data[i] = (tFilePage *)malloc(bytes * pQuery->rec.rows + sizeof(tFilePage));
data[i] = (tFilePage *)malloc((size_t)(bytes * pQuery->rec.rows) + sizeof(tFilePage));
}
arithSup.offset = 0;
......@@ -5855,7 +5859,7 @@ static void doSecondaryArithmeticProcess(SQuery* pQuery) {
for (int32_t j = 0; j < pQuery->numOfOutput; ++j) {
if (pSqlFunc->functionId == pQuery->pExpr1[j].base.functionId &&
pSqlFunc->colInfo.colId == pQuery->pExpr1[j].base.colInfo.colId) {
memcpy(data[i]->data, pQuery->sdata[j]->data, pQuery->pExpr1[j].bytes * pQuery->rec.rows);
memcpy(data[i]->data, pQuery->sdata[j]->data, (size_t)(pQuery->pExpr1[j].bytes * pQuery->rec.rows));
break;
}
}
......@@ -5867,7 +5871,7 @@ static void doSecondaryArithmeticProcess(SQuery* pQuery) {
}
for (int32_t i = 0; i < pQuery->numOfExpr2; ++i) {
memcpy(pQuery->sdata[i]->data, data[i]->data, pQuery->pExpr2[i].bytes * pQuery->rec.rows);
memcpy(pQuery->sdata[i]->data, data[i]->data, (size_t)(pQuery->pExpr2[i].bytes * pQuery->rec.rows));
}
for (int32_t i = 0; i < pQuery->numOfExpr2; ++i) {
......
......@@ -226,7 +226,7 @@ int64_t syncStart(const SSyncInfo *pInfo) {
}
if (pNode->selfIndex < 0) {
sInfo("vgId:%d, this node is not configured", pNode->vgId);
sError("vgId:%d, this node is not configured", pNode->vgId);
terrno = TSDB_CODE_SYN_INVALID_CONFIG;
syncStop(pNode->rid);
return -1;
......
......@@ -242,9 +242,8 @@ int32_t vnodeReadCfg(SVnodeObj *pVnode) {
}
tstrncpy(node->nodeEp, nodeEp->valuestring, TSDB_EP_LEN);
if (!nodeChanged) {
nodeChanged = dnodeCheckEpChanged(node->nodeId, node->nodeEp);
}
bool changed = dnodeCheckEpChanged(node->nodeId, node->nodeEp);
if (changed) nodeChanged = changed;
}
ret = TSDB_CODE_SUCCESS;
......
......@@ -362,9 +362,8 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
pVnode->role = TAOS_SYNC_ROLE_MASTER;
#else
if (pVnode->sync <= 0) {
vError("vgId:%d, failed to open sync module, replica:%d reason:%s", pVnode->vgId, pVnode->syncCfg.replica,
vError("vgId:%d, failed to open sync, replica:%d reason:%s", pVnode->vgId, pVnode->syncCfg.replica,
tstrerror(terrno));
vnodeRelease(pVnode);
vnodeCleanUp(pVnode);
return terrno;
}
......
......@@ -160,6 +160,8 @@ python3 ./test.py -f query/bug1874.py
python3 ./test.py -f query/bug1875.py
python3 ./test.py -f query/bug1876.py
python3 ./test.py -f query/bug2218.py
python3 ./test.py -f query/bug2117.py
python3 ./test.py -f query/bug2143.py
python3 ./test.py -f query/sliding.py
#stream
......
......@@ -33,14 +33,29 @@ class TDTestCase:
for i in range(insertRows):
ret = tdSql.execute(
"insert into mt0 values (%d , %d,%d,%d,%d,%d,%d,%d,'%s','%s')" %
(t0+i,i%100,i/2,i%41,i%100,i%100,i*1.0,i%2,'taos'+str(i%100),'涛思'+str(i%100)))
(t0+i,i%100,i/2.0,i%41,i%51,i%53,i*1.0,i%2,'taos'+str(i%43),'涛思'+str(i%41)))
print("==========step2")
print("test last with group by normal_col ")
tdSql.query('select last(c1) from mt0 group by c3')
tdSql.checkData(0,0,84)
tdSql.checkData(0,1,85)
tdSql.query('select last(*) from mt0 group by c3')
tdSql.checkData(0,1,84)
tdSql.checkData(0,9,'涛思0')
tdSql.checkData(1,1,85)
tdSql.checkData(1,9,'涛思1')
tdSql.query('select last(*) from mt0 group by c7')
tdSql.checkData(0,1,98)
tdSql.checkData(0,9,'涛思14')
tdSql.checkData(1,1,99)
tdSql.checkData(1,9,'涛思15')
tdSql.query('select last(*) from mt0 group by c8')
tdSql.checkData(0,3,5)
tdSql.checkData(0,4,20)
tdSql.checkData(3,1,92)
tdSql.checkData(3,9,'涛思8')
tdSql.query('select last(*) from mt0 group by c9')
tdSql.checkData(0,3,0)
tdSql.checkData(0,8,'taos38')
tdSql.checkData(40,1,83)
tdSql.checkData(40,3,40)
def stop(self):
tdSql.close()
......
###################################################################
# 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
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def run(self):
tdSql.prepare()
print("==========step1")
print("create table && insert data")
tdSql.execute("create table mt0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool,c8 binary(20),c9 nchar(20))")
insertRows = 1000
t0 = 1604298064000
tdLog.info("insert %d rows" % (insertRows))
for i in range(insertRows):
ret = tdSql.execute(
"insert into mt0 values (%d , %d,%d,%d,%d,%d,%d,%d,'%s','%s')" %
(t0+i,i%100,i/2.0,i%41,i%51,i%53,i*1.0,i%2,'taos'+str(i%43),'涛思'+str(i%41)))
print("==========step2")
print("test group by normal_col with limit offset")
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 3 offset 2')
tdSql.checkData(0,0,99)
tdSql.checkData(0,1,2)
tdSql.checkData(0,2,2)
tdSql.checkData(0,3,86)
tdSql.checkData(1,0,95)
tdSql.checkData(2,1,1)
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 3 offset 40')
tdSql.checkRows(1)
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 3 offset 41')
tdSql.checkRows(0)
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 3 offset 99')
tdSql.checkRows(0)
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 70 offset 3')
tdSql.checkRows(38)
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c8 limit 3 offset 2')
tdSql.checkData(0,0,91)
tdSql.checkData(0,1,2)
tdSql.checkData(0,2,2)
tdSql.checkData(0,3,91)
tdSql.checkData(1,0,92)
tdSql.checkData(2,1,4)
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c9 limit 2 offset 9')
tdSql.checkData(0,0,96)
tdSql.checkData(0,1,1)
tdSql.checkData(0,2,9)
tdSql.checkData(0,3,93)
tdSql.checkData(1,0,97)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
......@@ -606,6 +606,44 @@ 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: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
sql select first(ts),last(ts) from t1 group by c;
if $rows != 4 then
return -1
endi
if $data00 != @20-03-27 04:11:16.000@ then
return -1
endi
if $data01 != @20-03-27 04:21:16.000@ then
return -1
endi
if $data10 != @20-03-27 04:11:17.000@ then
return -1
endi
if $data11 != @20-03-27 04:31:17.000@ then
return -1
endi
if $data20 != @20-03-27 04:11:18.000@ then
return -1
endi
if $data21 != @20-03-27 04:51:18.000@ then
return -1
endi
if $data30 != @20-03-27 04:11:19.000@ then
return -1
endi
if $data31 != @20-03-27 05:10:19.000@ 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;
#if $rows != 40 then
# return -1
......
......@@ -48,8 +48,12 @@ while $i < $halfNum
$binary = $binary . '
$nchar = 'nchar . $c
$nchar = $nchar . '
sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar )
sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar )
$ts = $ts + $i
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 )
$x = $x + 1
endw
......
......@@ -94,66 +94,66 @@ sql select * from $stb limit 2 offset $offset
if $rows != 2 then
return -1
endi
if $data00 != @18-11-25 19:30:00.000@ then
return -1
endi
if $data01 != 9 then
return -1
endi
if $data02 != 9 then
return -1
endi
if $data03 != 9.00000 then
return -1
endi
if $data04 != 9.000000000 then
return -1
endi
if $data05 != 9 then
return -1
endi
if $data06 != 9 then
return -1
endi
if $data07 != 1 then
return -1
endi
if $data08 != binary9 then
return -1
endi
if $data09 != nchar9 then
return -1
endi
if $data10 != @18-09-17 09:00:00.000@ then
return -1
endi
if $data11 != 0 then
return -1
endi
if $data12 != NULL then
return -1
endi
if $data13 != 0.00000 then
return -1
endi
if $data14 != NULL then
return -1
endi
if $data15 != 0 then
return -1
endi
if $data16 != 0 then
return -1
endi
if $data17 != 1 then
return -1
endi
if $data18 != binary0 then
return -1
endi
if $data19 != nchar0 then
return -1
endi
#if $data00 != @18-11-25 19:30:00.000@ then
# return -1
#endi
#if $data01 != 9 then
# return -1
#endi
#if $data02 != 9 then
# return -1
#endi
#if $data03 != 9.00000 then
# return -1
#endi
#if $data04 != 9.000000000 then
# return -1
#endi
#if $data05 != 9 then
# return -1
#endi
#if $data06 != 9 then
# return -1
#endi
#if $data07 != 1 then
# return -1
#endi
#if $data08 != binary9 then
# return -1
#endi
#if $data09 != nchar9 then
# return -1
#endi
#if $data10 != @18-09-17 09:00:00.000@ then
# return -1
#endi
#if $data11 != 0 then
# return -1
#endi
#if $data12 != NULL then
# return -1
#endi
#if $data13 != 0.00000 then
# return -1
#endi
#if $data14 != NULL then
# return -1
#endi
#if $data15 != 0 then
# return -1
#endi
#if $data16 != 0 then
# return -1
#endi
#if $data17 != 1 then
# return -1
#endi
#if $data18 != binary0 then
# return -1
#endi
#if $data19 != nchar0 then
# return -1
#endi
### offset >= rowsInFileBlock
##TBASE-352
......@@ -163,6 +163,7 @@ sql select * from $stb limit $limit offset $offset
if $rows != 0 then
return -1
endi
$offset = $offset - 1
sql select * from $stb limit $limit offset $offset
if $rows != 1 then
......@@ -255,102 +256,102 @@ sql select * from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset $offset
if $rows != 5 then
return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
return -1
endi
if $data01 != 0 then
return -1
endi
if $data12 != NULL then
return -1
endi
if $data23 != 2.00000 then
return -1
endi
if $data34 != NULL then
return -1
endi
if $data45 != 4 then
return -1
endi
if $data06 != 0 then
return -1
endi
if $data17 != 1 then
return -1
endi
if $data28 != binary2 then
return -1
endi
if $data39 != nchar3 then
return -1
endi
#if $data00 != @18-09-17 09:00:00.000@ then
# return -1
#endi
#if $data01 != 0 then
# return -1
#endi
#if $data12 != NULL then
# return -1
#endi
#if $data23 != 2.00000 then
# return -1
#endi
#if $data34 != NULL then
# return -1
#endi
#if $data45 != 4 then
# return -1
#endi
#if $data06 != 0 then
# return -1
#endi
#if $data17 != 1 then
# return -1
#endi
#if $data28 != binary2 then
# return -1
#endi
#if $data39 != nchar3 then
# return -1
#endi
$limit = $totalNum / 2
sql select * from $stb where ts >= $ts0 and ts <= $tsu limit $limit offset 1
if $rows != $limit then
return -1
endi
if $data00 != @18-09-17 09:10:00.000@ then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data23 != 3.00000 then
return -1
endi
if $data34 != 4.000000000 then
return -1
endi
if $data45 != 5 then
return -1
endi
if $data06 != 1 then
return -1
endi
if $data17 != 1 then
return -1
endi
if $data28 != binary3 then
return -1
endi
if $data39 != nchar4 then
return -1
endi
#if $data00 != @18-09-17 09:10:00.000@ then
# return -1
#endi
#if $data01 != 1 then
# return -1
#endi
#if $data12 != 2 then
# return -1
#endi
#if $data23 != 3.00000 then
# return -1
#endi
#if $data34 != 4.000000000 then
# return -1
#endi
#if $data45 != 5 then
# return -1
#endi
#if $data06 != 1 then
# return -1
#endi
#if $data17 != 1 then
# return -1
#endi
#if $data28 != binary3 then
# return -1
#endi
#if $data39 != nchar4 then
# return -1
#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
if $rows != 1 then
return -1
endi
if $data00 != 9 then
return -1
endi
if $data01 != 0 then
return -1
endi
if $data02 != 4.500000000 then
return -1
endi
$val = 45 * $rowNum
if $data03 != $val then
return -1
endi
if $data04 != 9.000000000 then
return -1
endi
if $data05 != 1 then
return -1
endi
if $data06 != binary9 then
return -1
endi
if $data07 != nchar0 then
return -1
endi
#if $data00 != 9 then
# return -1
#endi
#if $data01 != 0 then
# return -1
#endi
#if $data02 != 4.500000000 then
# return -1
#endi
#$val = 45 * $rowNum
#if $data03 != $val then
# return -1
#endi
#if $data04 != 9.000000000 then
# return -1
#endi
#if $data05 != 1 then
# return -1
#endi
#if $data06 != binary9 then
# return -1
#endi
#if $data07 != nchar0 then
# return -1
#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;
if $rows != 1 then
......
......@@ -20,6 +20,7 @@ sql use $db
$tsu = $rowNum * $delta
$tsu = $tsu - $delta
$tsu = $tsu + $ts0
$tsu = $tsu + 9
##### select from supertable
......@@ -75,7 +76,7 @@ if $data00 != @18-09-17 09:00:00.000@ then
return -1
endi
if $data40 != @18-09-17 09:00:00.000@ then
if $data40 != @18-09-17 09:00:00.004@ then
return -1
endi
......@@ -84,11 +85,11 @@ if $data01 != 0 then
endi
print data12 = $data12
if $data12 != NULL then
if $data12 != 0 then
return -1
endi
if $data24 != NULL then
if $data24 != 0.000000000 then
return -1
endi
......@@ -110,11 +111,11 @@ if $data41 != 0 then
return -1
endi
if $data40 != @18-09-17 09:00:00.000@ then
if $data40 != @18-09-17 09:00:00.005@ then
return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
if $data00 != @18-09-17 09:00:00.001@ then
return -1
endi
......@@ -123,20 +124,13 @@ if $rows != 99 then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data41 != 5 then
return -1
endi
$offset = $tbNum * $rowNum
$offset = $offset - 1
sql select * from $stb limit 2 offset $offset
if $rows != 1 then
return -1
endi
if $data00 != @18-09-17 10:30:00.000@ then
if $data00 != @18-09-17 10:30:00.009@ then
return -1
endi
if $data01 != 9 then
......@@ -174,7 +168,7 @@ sql select * from $stb limit 2 offset $offset
if $rows != 2 then
return -1
endi
if $data00 != @18-09-17 10:30:00.000@ then
if $data00 != @18-09-17 10:30:00.002@ then
return -1
endi
if $data01 != 9 then
......@@ -204,36 +198,36 @@ endi
if $data09 != nchar9 then
return -1
endi
if $data10 != @18-09-17 09:00:00.000@ then
return -1
endi
if $data11 != 0 then
return -1
endi
if $data12 != NULL then
return -1
endi
if $data13 != 0.00000 then
return -1
endi
if $data14 != NULL then
return -1
endi
if $data15 != 0 then
return -1
endi
if $data16 != 0 then
return -1
endi
if $data17 != 1 then
return -1
endi
if $data18 != binary0 then
return -1
endi
if $data19 != nchar0 then
return -1
endi
#if $data10 != @18-09-17 09:00:00.000@ then
# return -1
#endi
#if $data11 != 0 then
# return -1
#endi
#if $data12 != NULL then
# return -1
#endi
#if $data13 != 0.00000 then
# return -1
#endi
#if $data14 != NULL then
# return -1
#endi
#if $data15 != 0 then
# return -1
#endi
#if $data16 != 0 then
# return -1
#endi
#if $data17 != 1 then
# return -1
#endi
#if $data18 != binary0 then
# return -1
#endi
#if $data19 != nchar0 then
# return -1
#endi
$offset = $rowNum * $tbNum
sql select * from lm_stb0 limit 2 offset $offset
......@@ -248,6 +242,7 @@ endi
if $data01 != 0 then
return -1
endi
sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 1;
if $rows != 1 then
return -1
......@@ -288,52 +283,52 @@ if $data09 != nchar4 then
endi
### 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
return -1
endi
if $data01 != 5 then
if $data01 != 3 then
return -1
endi
if $data11 != 6 then
if $data11 != 3 then
return -1
endi
if $data21 != 7 then
if $data21 != 3 then
return -1
endi
if $data31 != 8 then
if $data31 != 3 then
return -1
endi
if $data41 != 4 then
if $data41 != 3 then
return -1
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
return -1
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
return -1
endi
if $data01 != 5 then
if $data01 != 3 then
return -1
endi
if $data11 != 6 then
if $data11 != 3 then
return -1
endi
if $data21 != 7 then
if $data21 != 3 then
return -1
endi
if $data31 != 8 then
if $data31 != 3 then
return -1
endi
if $data41 != 4 then
if $data41 != 3 then
return -1
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
return -1
endi
......@@ -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
return -1
endi
if $data00 != @18-09-17 10:30:00.000@ then
return -1
endi
if $data01 != 9 then
return -1
endi
......@@ -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
return -1
endi
if $data00 != @18-09-17 10:30:00.000@ then
return -1
endi
if $data01 != 9 then
return -1
endi
......@@ -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
return -1
endi
if $data00 != @18-09-17 10:00:00.000@ then
if $data00 != @18-09-17 10:00:00.008@ then
return -1
endi
if $data01 != 6 then
......@@ -873,7 +862,7 @@ endi
if $data02 != 8 then
return -1
endi
if $data10 != @18-09-17 10:10:00.000@ then
if $data10 != @18-09-17 10:10:00.008@ then
return -1
endi
if $data11 != 7 then
......@@ -882,7 +871,7 @@ endi
if $data12 != 8 then
return -1
endi
if $data20 != @18-09-17 10:20:00.000@ then
if $data20 != @18-09-17 10:20:00.008@ then
return -1
endi
if $data21 != 8 then
......@@ -891,7 +880,7 @@ endi
if $data22 != 8 then
return -1
endi
if $data30 != @18-09-17 10:00:00.000@ then
if $data30 != @18-09-17 10:00:00.007@ then
return -1
endi
if $data31 != 6 then
......@@ -900,7 +889,7 @@ endi
if $data32 != 7 then
return -1
endi
if $data40 != @18-09-17 10:10:00.000@ then
if $data40 != @18-09-17 10:10:00.007@ then
return -1
endi
if $data41 != 7 then
......@@ -909,7 +898,7 @@ endi
if $data42 != 7 then
return -1
endi
if $data50 != @18-09-17 10:20:00.000@ then
if $data50 != @18-09-17 10:20:00.007@ then
return -1
endi
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
if $rows != 6 then
return -1
endi
if $data00 != @18-09-17 10:00:00.000@ then
if $data00 != @18-09-17 10:00:00.001@ then
return -1
endi
if $data01 != 6 then
......@@ -932,7 +921,7 @@ endi
if $data02 != 1 then
return -1
endi
if $data10 != @18-09-17 10:10:00.000@ then
if $data10 != @18-09-17 10:10:00.001@ then
return -1
endi
if $data11 != 7 then
......@@ -941,7 +930,7 @@ endi
if $data12 != 1 then
return -1
endi
if $data20 != @18-09-17 10:20:00.000@ then
if $data20 != @18-09-17 10:20:00.001@ then
return -1
endi
if $data21 != 8 then
......@@ -950,7 +939,7 @@ endi
if $data22 != 1 then
return -1
endi
if $data30 != @18-09-17 10:00:00.000@ then
if $data30 != @18-09-17 10:00:00.002@ then
return -1
endi
if $data31 != 6 then
......@@ -959,7 +948,7 @@ endi
if $data32 != 2 then
return -1
endi
if $data40 != @18-09-17 10:10:00.000@ then
if $data40 != @18-09-17 10:10:00.002@ then
return -1
endi
if $data41 != 7 then
......@@ -968,7 +957,7 @@ endi
if $data42 != 2 then
return -1
endi
if $data50 != @18-09-17 10:20:00.000@ then
if $data50 != @18-09-17 10:20:00.002@ then
return -1
endi
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
if $rows != 6 then
return -1
endi
if $data00 != @18-09-17 10:20:00.000@ then
if $data00 != @18-09-17 10:20:00.001@ then
return -1
endi
if $data01 != 8 then
......@@ -991,7 +980,7 @@ endi
if $data02 != 1 then
return -1
endi
if $data10 != @18-09-17 10:10:00.000@ then
if $data10 != @18-09-17 10:10:00.001@ then
return -1
endi
if $data11 != 7 then
......@@ -1000,7 +989,7 @@ endi
if $data12 != 1 then
return -1
endi
if $data20 != @18-09-17 10:00:00.000@ then
if $data20 != @18-09-17 10:00:00.001@ then
return -1
endi
if $data21 != 6 then
......@@ -1009,7 +998,7 @@ endi
if $data22 != 1 then
return -1
endi
if $data30 != @18-09-17 10:20:00.000@ then
if $data30 != @18-09-17 10:20:00.002@ then
return -1
endi
if $data31 != 8 then
......@@ -1018,7 +1007,7 @@ endi
if $data32 != 2 then
return -1
endi
if $data40 != @18-09-17 10:10:00.000@ then
if $data40 != @18-09-17 10:10:00.002@ then
return -1
endi
if $data41 != 7 then
......@@ -1027,7 +1016,7 @@ endi
if $data42 != 2 then
return -1
endi
if $data50 != @18-09-17 10:00:00.000@ then
if $data50 != @18-09-17 10:00:00.002@ then
return -1
endi
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
if $rows != 3 then
return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
return -1
endi
#if $data00 != @18-09-17 09:00:00.000@ then
# return -1
#endi
if $data01 != 0 then
return -1
endi
......@@ -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
return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
return -1
endi
#if $data00 != @18-09-17 09:00:00.000@ then
# return -1
#endi
if $data01 != 0 then
return -1
endi
......@@ -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
return -1
endi
if $data00 != @18-09-17 09:30:00.000@ then
return -1
endi
#if $data00 != @18-09-17 09:30:00.000@ then
# return -1
#endi
if $data01 != 3 then
return -1
endi
if $data02 != 8 then
return -1
endi
if $data10 != @18-09-17 09:20:00.000@ then
return -1
endi
#if $data10 != @18-09-17 09:20:00.000@ then
# return -1
#endi
if $data11 != 2 then
return -1
endi
if $data12 != 8 then
return -1
endi
if $data20 != @18-09-17 09:10:00.000@ then
return -1
endi
#if $data20 != @18-09-17 09:10:00.000@ then
# return -1
#endi
if $data21 != 1 then
return -1
endi
if $data22 != 8 then
return -1
endi
if $data30 != @18-09-17 09:30:00.000@ then
return -1
endi
#if $data30 != @18-09-17 09:30:00.000@ then
# return -1
#endi
if $data31 != 3 then
return -1
endi
if $data32 != 7 then
return -1
endi
if $data40 != @18-09-17 09:20:00.000@ then
return -1
endi
#if $data40 != @18-09-17 09:20:00.000@ then
# return -1
#endi
if $data41 != 2 then
return -1
endi
if $data42 != 7 then
return -1
endi
if $data50 != @18-09-17 09:10:00.000@ then
return -1
endi
#if $data50 != @18-09-17 09:10:00.000@ then
# return -1
#endi
if $data51 != 1 then
return -1
endi
......@@ -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
return -1
endi
if $data00 != @18-09-17 09:30:00.000@ then
return -1
endi
#if $data00 != @18-09-17 09:30:00.000@ then
# return -1
#endi
if $data01 != 3 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data10 != @18-09-17 09:20:00.000@ then
return -1
endi
#if $data10 != @18-09-17 09:20:00.000@ then
# return -1
#endi
if $data11 != 2 then
return -1
endi
if $data12 != 1 then
return -1
endi
if $data20 != @18-09-17 09:10:00.000@ then
return -1
endi
#if $data20 != @18-09-17 09:10:00.000@ then
# return -1
#endi
if $data21 != 1 then
return -1
endi
if $data22 != 1 then
return -1
endi
if $data30 != @18-09-17 09:30:00.000@ then
return -1
endi
#if $data30 != @18-09-17 09:30:00.000@ then
# return -1
#endi
if $data31 != 3 then
return -1
endi
if $data32 != 2 then
return -1
endi
if $data40 != @18-09-17 09:20:00.000@ then
return -1
endi
#if $data40 != @18-09-17 09:20:00.000@ then
# return -1
#endi
if $data41 != 2 then
return -1
endi
if $data42 != 2 then
return -1
endi
if $data50 != @18-09-17 09:10:00.000@ then
return -1
endi
#if $data50 != @18-09-17 09:10:00.000@ then
# return -1
#endi
if $data51 != 1 then
return -1
endi
......@@ -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
return -1
endi
if $data00 != @18-09-17 09:30:00.000@ then
return -1
endi
#if $data00 != @18-09-17 09:30:00.000@ then
# return -1
#endi
if $data01 != 3 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data10 != @18-09-17 09:20:00.000@ then
return -1
endi
#if $data10 != @18-09-17 09:20:00.000@ then
# return -1
#endi
if $data11 != 2 then
return -1
endi
if $data12 != 1 then
return -1
endi
if $data20 != @18-09-17 09:10:00.000@ then
return -1
endi
#if $data20 != @18-09-17 09:10:00.000@ then
# return -1
#endi
if $data21 != 1 then
return -1
endi
if $data22 != 1 then
return -1
endi
if $data30 != @18-09-17 09:30:00.000@ then
return -1
endi
#if $data30 != @18-09-17 09:30:00.000@ then
# return -1
#endi
if $data31 != 3 then
return -1
endi
if $data32 != 2 then
return -1
endi
if $data40 != @18-09-17 09:20:00.000@ then
return -1
endi
#if $data40 != @18-09-17 09:20:00.000@ then
# return -1
#endi
if $data41 != 2 then
return -1
endi
if $data42 != 2 then
return -1
endi
if $data50 != @18-09-17 09:10:00.000@ then
return -1
endi
#if $data50 != @18-09-17 09:10:00.000@ then
# return -1
#endi
if $data51 != 1 then
return -1
endi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册