提交 4573d7f6 编写于 作者: haoranc's avatar haoranc

Merge branch 'master' into test/chr

...@@ -69,7 +69,6 @@ IF (TD_LINUX_32) ...@@ -69,7 +69,6 @@ IF (TD_LINUX_32)
ENDIF () ENDIF ()
IF (TD_ARM_64) IF (TD_ARM_64)
ADD_DEFINITIONS(-D_M_X64)
ADD_DEFINITIONS(-D_TD_ARM_64) ADD_DEFINITIONS(-D_TD_ARM_64)
ADD_DEFINITIONS(-D_TD_ARM_) ADD_DEFINITIONS(-D_TD_ARM_)
ADD_DEFINITIONS(-DUSE_LIBICONV) ADD_DEFINITIONS(-DUSE_LIBICONV)
...@@ -86,17 +85,19 @@ IF (TD_ARM_32) ...@@ -86,17 +85,19 @@ IF (TD_ARM_32)
ENDIF () ENDIF ()
IF (TD_MIPS_64) IF (TD_MIPS_64)
ADD_DEFINITIONS(-D_TD_MIPS_64_) ADD_DEFINITIONS(-D_TD_MIPS_)
ADD_DEFINITIONS(-D_TD_MIPS_64)
ADD_DEFINITIONS(-DUSE_LIBICONV) ADD_DEFINITIONS(-DUSE_LIBICONV)
MESSAGE(STATUS "mips64 is defined") MESSAGE(STATUS "mips64 is defined")
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ENDIF () ENDIF ()
IF (TD_MIPS_32) IF (TD_MIPS_32)
ADD_DEFINITIONS(-D_TD_MIPS_32_) ADD_DEFINITIONS(-D_TD_MIPS_)
ADD_DEFINITIONS(-D_TD_MIPS_32)
ADD_DEFINITIONS(-DUSE_LIBICONV) ADD_DEFINITIONS(-DUSE_LIBICONV)
MESSAGE(STATUS "mips32 is defined") MESSAGE(STATUS "mips32 is defined")
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ENDIF () ENDIF ()
IF (TD_APLHINE) IF (TD_APLHINE)
......
...@@ -283,7 +283,7 @@ void tscQueueAsyncError(void(*fp), void *param, int32_t code) { ...@@ -283,7 +283,7 @@ void tscQueueAsyncError(void(*fp), void *param, int32_t code) {
static void tscAsyncResultCallback(SSchedMsg *pMsg) { static void tscAsyncResultCallback(SSchedMsg *pMsg) {
SSqlObj* pSql = (SSqlObj*)taosAcquireRef(tscObjRef, (int64_t)pMsg->ahandle); SSqlObj* pSql = (SSqlObj*)taosAcquireRef(tscObjRef, (int64_t)pMsg->ahandle);
if (pSql == NULL || pSql->signature != pSql) { if (pSql == NULL || pSql->signature != pSql) {
tscDebug("0x%"PRIx64" SqlObj is freed, not add into queue async res", pSql->self); tscDebug("%p SqlObj is freed, not add into queue async res", pMsg->ahandle);
return; return;
} }
......
...@@ -273,7 +273,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { ...@@ -273,7 +273,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
pSdesc->num = htobe64(pStream->num); pSdesc->num = htobe64(pStream->num);
pSdesc->useconds = htobe64(pStream->useconds); pSdesc->useconds = htobe64(pStream->useconds);
pSdesc->stime = htobe64(pStream->stime - pStream->interval.interval); pSdesc->stime = (pStream->stime == INT64_MIN) ? htobe64(pStream->stime) : htobe64(pStream->stime - pStream->interval.interval);
pSdesc->ctime = htobe64(pStream->ctime); pSdesc->ctime = htobe64(pStream->ctime);
pSdesc->slidingTime = htobe64(pStream->interval.sliding); pSdesc->slidingTime = htobe64(pStream->interval.sliding);
......
...@@ -3078,7 +3078,7 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumn* pColumn) { ...@@ -3078,7 +3078,7 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumn* pColumn) {
return pColFilterInfo; return pColFilterInfo;
} }
static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SColumnFilterInfo* pColumnFilter, static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, STableMeta* pTableMeta, SColumnFilterInfo* pColumnFilter,
int16_t colType, tSqlExpr* pExpr) { int16_t colType, tSqlExpr* pExpr) {
const char* msg = "not supported filter condition"; const char* msg = "not supported filter condition";
...@@ -3093,6 +3093,12 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, ...@@ -3093,6 +3093,12 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
if (TSDB_CODE_SUCCESS != retVal) { if (TSDB_CODE_SUCCESS != retVal) {
return retVal; return retVal;
} }
} else if ((colType == TSDB_DATA_TYPE_TIMESTAMP) && (TSDB_DATA_TYPE_BIGINT == pRight->value.nType)) {
STableComInfo tinfo = tscGetTableInfo(pTableMeta);
if ((tinfo.precision == TSDB_TIME_PRECISION_MILLI) && (pRight->flags & (1 << EXPR_FLAG_US_TIMESTAMP))) {
pRight->value.i64 /= 1000;
}
} }
int32_t retVal = TSDB_CODE_SUCCESS; int32_t retVal = TSDB_CODE_SUCCESS;
...@@ -3291,7 +3297,7 @@ static int32_t extractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SC ...@@ -3291,7 +3297,7 @@ static int32_t extractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SC
int16_t colType = pSchema->type; int16_t colType = pSchema->type;
return doExtractColumnFilterInfo(pCmd, pQueryInfo, pColFilter, colType, pExpr); return doExtractColumnFilterInfo(pCmd, pQueryInfo, pTableMeta, pColFilter, colType, pExpr);
} }
static int32_t getTablenameCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pTableCond, SStringBuilder* sb) { static int32_t getTablenameCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pTableCond, SStringBuilder* sb) {
...@@ -3916,6 +3922,10 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr ...@@ -3916,6 +3922,10 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr
const char* msg1 = "query condition between different columns must use 'AND'"; const char* msg1 = "query condition between different columns must use 'AND'";
if ((*pExpr)->flags & (1 << EXPR_FLAG_TS_ERROR)) {
return TSDB_CODE_TSC_INVALID_SQL;
}
tSqlExpr* pLeft = (*pExpr)->pLeft; tSqlExpr* pLeft = (*pExpr)->pLeft;
tSqlExpr* pRight = (*pExpr)->pRight; tSqlExpr* pRight = (*pExpr)->pRight;
...@@ -3953,6 +3963,14 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr ...@@ -3953,6 +3963,14 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr
exchangeExpr(*pExpr); exchangeExpr(*pExpr);
if (pLeft->tokenId == TK_ID && pRight->tokenId == TK_TIMESTAMP && (pRight->flags & (1 << EXPR_FLAG_TIMESTAMP_VAR))) {
return TSDB_CODE_TSC_INVALID_SQL;
}
if ((pLeft->flags & (1 << EXPR_FLAG_TS_ERROR)) || (pRight->flags & (1 << EXPR_FLAG_TS_ERROR))) {
return TSDB_CODE_TSC_INVALID_SQL;
}
return handleExprInQueryCond(pCmd, pQueryInfo, pExpr, pCondExpr, type, parentOptr); return handleExprInQueryCond(pCmd, pQueryInfo, pExpr, pCondExpr, type, parentOptr);
} }
...@@ -6927,7 +6945,10 @@ static int32_t handleExprInHavingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t ...@@ -6927,7 +6945,10 @@ static int32_t handleExprInHavingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
} }
} }
int32_t ret = doExtractColumnFilterInfo(pCmd, pQueryInfo, pColFilter, pInfo->field.type, pExpr); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
int32_t ret = doExtractColumnFilterInfo(pCmd, pQueryInfo, pTableMeta, pColFilter, pInfo->field.type, pExpr);
if (ret) { if (ret) {
return ret; return ret;
} }
......
...@@ -101,11 +101,19 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) { ...@@ -101,11 +101,19 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) {
return; return;
} }
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo) && (pTableMetaInfo->pVgroupTables == NULL) && (pTableMetaInfo->vgroupList == NULL || pTableMetaInfo->vgroupList->numOfVgroups <= 0)) {
tscDebug("%p empty vgroup list", pSql);
pTableMetaInfo->vgroupList = tscVgroupInfoClear(pTableMetaInfo->vgroupList);
code = TSDB_CODE_TSC_APP_ERROR;
}
// failed to get table Meta or vgroup list, retry in 10sec. // failed to get table Meta or vgroup list, retry in 10sec.
if (code == TSDB_CODE_SUCCESS) { if (code == TSDB_CODE_SUCCESS) {
tscTansformFuncForSTableQuery(pQueryInfo); tscTansformFuncForSTableQuery(pQueryInfo);
tscDebug("0x%"PRIx64" stream:%p, start stream query on:%s", pSql->self, pStream, tNameGetTableName(&pTableMetaInfo->name)); tscDebug("0x%"PRIx64" stream:%p, start stream query on:%s", pSql->self, pStream, tNameGetTableName(&pTableMetaInfo->name));
pQueryInfo->command = TSDB_SQL_SELECT;
pSql->fp = tscProcessStreamQueryCallback; pSql->fp = tscProcessStreamQueryCallback;
pSql->fetchFp = tscProcessStreamQueryCallback; pSql->fetchFp = tscProcessStreamQueryCallback;
tscDoQuery(pSql); tscDoQuery(pSql);
...@@ -402,10 +410,12 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) { ...@@ -402,10 +410,12 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
taos_close_stream(pStream); taos_close_stream(pStream);
return; return;
} }
timer = pStream->stime - taosGetTimestamp(pStream->precision); if (pStream->stime > 0) {
if (timer < 0) { timer = pStream->stime - taosGetTimestamp(pStream->precision);
timer = 0; if (timer < 0) {
timer = 0;
}
} }
} }
...@@ -473,6 +483,10 @@ static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) { ...@@ -473,6 +483,10 @@ static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, int64_t stime) { static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, int64_t stime) {
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
if (stime == INT64_MIN) {
return stime;
}
if (pStream->isProject) { if (pStream->isProject) {
// no data in table, flush all data till now to destination meter, 10sec delay // no data in table, flush all data till now to destination meter, 10sec delay
......
...@@ -449,7 +449,7 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { ...@@ -449,7 +449,7 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) {
pObj->tmrId = 0; pObj->tmrId = 0;
if (pObj->pStream == NULL) { if (pObj->pStream == NULL) {
pObj->pStream = taos_open_stream(pContext->dbConn, pObj->sqlStr, cqProcessStreamRes, 0, (void *)pObj->rid, NULL); pObj->pStream = taos_open_stream(pContext->dbConn, pObj->sqlStr, cqProcessStreamRes, INT64_MIN, (void *)pObj->rid, NULL);
// TODO the pObj->pStream may be released if error happens // TODO the pObj->pStream may be released if error happens
if (pObj->pStream) { if (pObj->pStream) {
......
...@@ -210,6 +210,8 @@ ...@@ -210,6 +210,8 @@
#define TK_SPACE 300 #define TK_SPACE 300
#define TK_COMMENT 301 #define TK_COMMENT 301
#define TK_ILLEGAL 302 #define TK_ILLEGAL 302
......
...@@ -554,19 +554,13 @@ SArguments g_args = { ...@@ -554,19 +554,13 @@ SArguments g_args = {
"./output.txt", // output_file "./output.txt", // output_file
0, // mode : sync or async 0, // mode : sync or async
{ {
"TINYINT", // datatype "INT", // datatype
"SMALLINT", "INT", // datatype
"INT", "INT", // datatype
"BIGINT", "INT", // datatype
"FLOAT",
"DOUBLE",
"BINARY",
"NCHAR",
"BOOL",
"TIMESTAMP"
}, },
16, // len_of_binary 16, // len_of_binary
10, // num_of_CPR 4, // num_of_CPR
10, // num_of_connections/thread 10, // num_of_connections/thread
0, // insert_interval 0, // insert_interval
1, // query_times 1, // query_times
...@@ -2395,8 +2389,10 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, ...@@ -2395,8 +2389,10 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
return 0; return 0;
} }
static int createSuperTable(TAOS * taos, char* dbName, static int createSuperTable(
TAOS * taos, char* dbName,
SSuperTable* superTbl) { SSuperTable* superTbl) {
char command[BUFFER_SIZE] = "\0"; char command[BUFFER_SIZE] = "\0";
char cols[STRING_LEN] = "\0"; char cols[STRING_LEN] = "\0";
...@@ -2885,19 +2881,17 @@ static void createChildTables() { ...@@ -2885,19 +2881,17 @@ static void createChildTables() {
} else { } else {
// normal table // normal table
len = snprintf(tblColsBuf, MAX_SQL_SIZE, "(TS TIMESTAMP"); len = snprintf(tblColsBuf, MAX_SQL_SIZE, "(TS TIMESTAMP");
int j = 0; for (int j = 0; j < g_args.num_of_CPR; j++) {
while(g_args.datatype[j]) {
if ((strncasecmp(g_args.datatype[j], "BINARY", strlen("BINARY")) == 0) if ((strncasecmp(g_args.datatype[j], "BINARY", strlen("BINARY")) == 0)
|| (strncasecmp(g_args.datatype[j], || (strncasecmp(g_args.datatype[j],
"NCHAR", strlen("NCHAR")) == 0)) { "NCHAR", strlen("NCHAR")) == 0)) {
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, snprintf(tblColsBuf + len, MAX_SQL_SIZE - len,
", COL%d %s(60)", j, g_args.datatype[j]); ", COL%d %s(%d)", j, g_args.datatype[j], g_args.len_of_binary);
} else { } else {
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, snprintf(tblColsBuf + len, MAX_SQL_SIZE - len,
", COL%d %s", j, g_args.datatype[j]); ", COL%d %s", j, g_args.datatype[j]);
} }
len = strlen(tblColsBuf); len = strlen(tblColsBuf);
j++;
} }
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, ")"); snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, ")");
...@@ -4479,7 +4473,7 @@ static int32_t generateData(char *recBuf, char **data_type, ...@@ -4479,7 +4473,7 @@ static int32_t generateData(char *recBuf, char **data_type,
exit(-1); exit(-1);
} }
for (int i = 0; i < num_of_cols; i++) { for (int i = 0; i < c; i++) {
if (strcasecmp(data_type[i % c], "tinyint") == 0) { if (strcasecmp(data_type[i % c], "tinyint") == 0) {
pstr += sprintf(pstr, ", %d", rand_tinyint() ); pstr += sprintf(pstr, ", %d", rand_tinyint() );
} else if (strcasecmp(data_type[i % c], "smallint") == 0) { } else if (strcasecmp(data_type[i % c], "smallint") == 0) {
...@@ -4501,7 +4495,7 @@ static int32_t generateData(char *recBuf, char **data_type, ...@@ -4501,7 +4495,7 @@ static int32_t generateData(char *recBuf, char **data_type,
rand_string(s, lenOfBinary); rand_string(s, lenOfBinary);
pstr += sprintf(pstr, ", \"%s\"", s); pstr += sprintf(pstr, ", \"%s\"", s);
free(s); free(s);
}else if (strcasecmp(data_type[i % c], "nchar") == 0) { } else if (strcasecmp(data_type[i % c], "nchar") == 0) {
char *s = malloc(lenOfBinary); char *s = malloc(lenOfBinary);
rand_string(s, lenOfBinary); rand_string(s, lenOfBinary);
pstr += sprintf(pstr, ", \"%s\"", s); pstr += sprintf(pstr, ", \"%s\"", s);
...@@ -4685,7 +4679,7 @@ static int generateDataTail( ...@@ -4685,7 +4679,7 @@ static int generateDataTail(
if (len > remainderBufLen) if (len > remainderBufLen)
break; break;
pstr += sprintf(pstr, " %s", data); pstr += sprintf(pstr, "%s", data);
k++; k++;
len += retLen; len += retLen;
remainderBufLen -= retLen; remainderBufLen -= retLen;
...@@ -5421,9 +5415,9 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -5421,9 +5415,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
if (superTblInfo) { if (superTblInfo) {
int limit, offset; int limit, offset;
if ((superTblInfo->childTblExists == TBL_NO_EXISTS) && if ((NULL != g_args.sqlFile) && (superTblInfo->childTblExists == TBL_NO_EXISTS) &&
((superTblInfo->childTblOffset != 0) || (superTblInfo->childTblLimit >= 0))) { ((superTblInfo->childTblOffset != 0) || (superTblInfo->childTblLimit >= 0))) {
printf("WARNING: offset and limit will not be used since the child tables are not exists!\n"); printf("WARNING: offset and limit will not be used since the child tables not exists!\n");
} }
if ((superTblInfo->childTblExists == TBL_ALREADY_EXISTS) if ((superTblInfo->childTblExists == TBL_ALREADY_EXISTS)
......
...@@ -214,8 +214,8 @@ static struct argp_option options[] = { ...@@ -214,8 +214,8 @@ static struct argp_option options[] = {
// dump format options // dump format options
{"schemaonly", 's', 0, 0, "Only dump schema.", 3}, {"schemaonly", 's', 0, 0, "Only dump schema.", 3},
{"with-property", 'M', 0, 0, "Dump schema with properties.", 3}, {"with-property", 'M', 0, 0, "Dump schema with properties.", 3},
{"start-time", 'S', "START_TIME", 0, "Start time to dump.", 3}, {"start-time", 'S', "START_TIME", 0, "Start time to dump. Either Epoch or ISO8601/RFC3339 format is acceptable. Epoch precision millisecond. ISO8601 format example: 2017-10-01T18:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 3},
{"end-time", 'E', "END_TIME", 0, "End time to dump. Epoch or ISO8601/RFC3339 format is acceptable. For example: 2017-10-01T18:00:00+0800", 3}, {"end-time", 'E', "END_TIME", 0, "End time to dump. Either Epoch or ISO8601/RFC3339 format is acceptable. Epoch precision millisecond. ISO8601 format example: 2017-10-01T18:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 3},
{"data-batch", 'N', "DATA_BATCH", 0, "Number of data point per insert statement. Default is 1.", 3}, {"data-batch", 'N', "DATA_BATCH", 0, "Number of data point per insert statement. Default is 1.", 3},
{"max-sql-len", 'L', "SQL_LEN", 0, "Max length of one sql. Default is 65480.", 3}, {"max-sql-len", 'L', "SQL_LEN", 0, "Max length of one sql. Default is 65480.", 3},
{"table-batch", 't', "TABLE_BATCH", 0, "Number of table dumpout into one output file. Default is 1.", 3}, {"table-batch", 't', "TABLE_BATCH", 0, "Number of table dumpout into one output file. Default is 1.", 3},
...@@ -482,29 +482,35 @@ static int queryDbImpl(TAOS *taos, char *command) { ...@@ -482,29 +482,35 @@ static int queryDbImpl(TAOS *taos, char *command) {
static void parse_args(int argc, char *argv[], SArguments *arguments) { static void parse_args(int argc, char *argv[], SArguments *arguments) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-E") == 0) { if ((strcmp(argv[i], "-S") == 0)
char *tmp = strdup(argv[++i]); || (strcmp(argv[i], "-E") == 0)) {
if (argv[i+1]) {
if (tmp) { char *tmp = strdup(argv[++i]);
int64_t tmpEpoch;
if (strchr(tmp, ':') && strchr(tmp, '-')) { if (tmp) {
if (TSDB_CODE_SUCCESS != taosParseTime( int64_t tmpEpoch;
tmp, &tmpEpoch, strlen(tmp), TSDB_TIME_PRECISION_MILLI, 0)) { if (strchr(tmp, ':') && strchr(tmp, '-')) {
fprintf(stderr, "Input end time error!\n"); if (TSDB_CODE_SUCCESS != taosParseTime(
free(tmp); tmp, &tmpEpoch, strlen(tmp), TSDB_TIME_PRECISION_MILLI, 0)) {
return; fprintf(stderr, "Input end time error!\n");
free(tmp);
return;
}
} else {
tmpEpoch = atoll(tmp);
} }
sprintf(argv[i], "%"PRId64"", tmpEpoch);
debugPrint("%s() LN%d, tmp is: %s, argv[%d]: %s\n",
__func__, __LINE__, tmp, i, argv[i]);
free(tmp);
} else { } else {
tmpEpoch = atoll(tmp); errorPrint("%s() LN%d, strdup() cannot allocate memory\n", __func__, __LINE__);
exit(-1);
} }
sprintf(argv[i], "%"PRId64"", tmpEpoch);
debugPrint("%s() LN%d, tmp is: %s, argv[%d]: %s\n",
__func__, __LINE__, tmp, i, argv[i]);
free(tmp);
} else { } else {
errorPrint("%s() LN%d, strdup() cannot allocate memory\n", __func__, __LINE__); errorPrint("%s need a valid value following!\n", argv[i]);
exit(-1); exit(-1);
} }
} else if (strcmp(argv[i], "-g") == 0) { } else if (strcmp(argv[i], "-g") == 0) {
......
...@@ -32,6 +32,10 @@ extern "C" { ...@@ -32,6 +32,10 @@ extern "C" {
#include "osArm32.h" #include "osArm32.h"
#endif #endif
#ifdef _TD_MIPS_64
#include "osMips64.h"
#endif
#ifdef _TD_LINUX_64 #ifdef _TD_LINUX_64
#include "osLinux64.h" #include "osLinux64.h"
#endif #endif
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_OS_MIPS64_H
#define TDENGINE_OS_MIPS64_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include <argp.h>
#include <arpa/inet.h>
#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <endian.h>
#include <errno.h>
#include <float.h>
#include <ifaddrs.h>
#include <libgen.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <pthread.h>
#include <pwd.h>
#include <regex.h>
#include <semaphore.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <sys/epoll.h>
#include <sys/eventfd.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/sendfile.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/statvfs.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <syslog.h>
#include <termios.h>
#include <unistd.h>
#include <wchar.h>
#include <wordexp.h>
#include <wctype.h>
#include <inttypes.h>
#include <fcntl.h>
#include <sys/utsname.h>
#include <sys/resource.h>
#include <error.h>
#include <linux/sysctl.h>
#include <math.h>
#include <poll.h>
#ifdef __cplusplus
}
#endif
#endif
...@@ -25,7 +25,7 @@ const char *httpContextStateStr(HttpContextState state); ...@@ -25,7 +25,7 @@ const char *httpContextStateStr(HttpContextState state);
HttpContext *httpCreateContext(SOCKET fd); HttpContext *httpCreateContext(SOCKET fd);
bool httpInitContext(HttpContext *pContext); bool httpInitContext(HttpContext *pContext);
HttpContext *httpGetContext(void * pContext); HttpContext *httpGetContext(void * pContext);
void httpReleaseContext(HttpContext *pContext, bool clearRes); void httpReleaseContext(HttpContext *pContext/*, bool clearRes*/);
void httpCloseContextByServer(HttpContext *pContext); void httpCloseContextByServer(HttpContext *pContext);
void httpCloseContextByApp(HttpContext *pContext); void httpCloseContextByApp(HttpContext *pContext);
void httpNotifyContextClose(HttpContext *pContext); void httpNotifyContextClose(HttpContext *pContext);
......
...@@ -146,20 +146,20 @@ HttpContext *httpGetContext(void *ptr) { ...@@ -146,20 +146,20 @@ HttpContext *httpGetContext(void *ptr) {
return NULL; return NULL;
} }
void httpReleaseContext(HttpContext *pContext, bool clearRes) { void httpReleaseContext(HttpContext *pContext/*, bool clearRes*/) {
int32_t refCount = atomic_sub_fetch_32(&pContext->refCount, 1); int32_t refCount = atomic_sub_fetch_32(&pContext->refCount, 1);
if (refCount < 0) { if (refCount < 0) {
httpError("context:%p, is already released, refCount:%d", pContext, refCount); httpError("context:%p, is already released, refCount:%d", pContext, refCount);
return; return;
} }
/*
if (clearRes) { if (clearRes) {
if (pContext->parser) { if (pContext->parser) {
httpClearParser(pContext->parser); httpClearParser(pContext->parser);
} }
memset(&pContext->singleCmd, 0, sizeof(HttpSqlCmd)); memset(&pContext->singleCmd, 0, sizeof(HttpSqlCmd));
} }
*/
HttpContext **ppContext = pContext->ppContext; HttpContext **ppContext = pContext->ppContext;
httpTrace("context:%p, is released, data:%p refCount:%d", pContext, ppContext, refCount); httpTrace("context:%p, is released, data:%p refCount:%d", pContext, ppContext, refCount);
...@@ -217,7 +217,7 @@ void httpCloseContextByApp(HttpContext *pContext) { ...@@ -217,7 +217,7 @@ void httpCloseContextByApp(HttpContext *pContext) {
httpContextStateStr(pContext->state), pContext->state); httpContextStateStr(pContext->state), pContext->state);
} }
httpReleaseContext(pContext, true); httpReleaseContext(pContext/*, true*/);
} }
void httpCloseContextByServer(HttpContext *pContext) { void httpCloseContextByServer(HttpContext *pContext) {
...@@ -235,5 +235,5 @@ void httpCloseContextByServer(HttpContext *pContext) { ...@@ -235,5 +235,5 @@ void httpCloseContextByServer(HttpContext *pContext) {
pContext->parsed = false; pContext->parsed = false;
httpRemoveContextFromEpoll(pContext); httpRemoveContextFromEpoll(pContext);
httpReleaseContext(pContext, true); httpReleaseContext(pContext/*, true*/);
} }
...@@ -177,7 +177,7 @@ static void httpProcessHttpData(void *param) { ...@@ -177,7 +177,7 @@ static void httpProcessHttpData(void *param) {
if (!httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_READY)) { if (!httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_READY)) {
httpDebug("context:%p, fd:%d, state:%s, not in ready state, ignore read events", pContext, pContext->fd, httpDebug("context:%p, fd:%d, state:%s, not in ready state, ignore read events", pContext, pContext->fd,
httpContextStateStr(pContext->state)); httpContextStateStr(pContext->state));
httpReleaseContext(pContext, true); httpReleaseContext(pContext/*, true*/);
continue; continue;
} }
...@@ -191,7 +191,7 @@ static void httpProcessHttpData(void *param) { ...@@ -191,7 +191,7 @@ static void httpProcessHttpData(void *param) {
(*(pThread->processData))(pContext); (*(pThread->processData))(pContext);
atomic_fetch_add_32(&pServer->requestNum, 1); atomic_fetch_add_32(&pServer->requestNum, 1);
} else { } else {
httpReleaseContext(pContext, false); httpReleaseContext(pContext/*, false*/);
} }
} }
} }
...@@ -275,7 +275,7 @@ static void *httpAcceptHttpConnection(void *arg) { ...@@ -275,7 +275,7 @@ static void *httpAcceptHttpConnection(void *arg) {
httpError("context:%p, fd:%d, ip:%s, thread:%s, failed to add http fd for epoll, error:%s", pContext, connFd, httpError("context:%p, fd:%d, ip:%s, thread:%s, failed to add http fd for epoll, error:%s", pContext, connFd,
pContext->ipstr, pThread->label, strerror(errno)); pContext->ipstr, pThread->label, strerror(errno));
taosCloseSocket(pContext->fd); taosCloseSocket(pContext->fd);
httpReleaseContext(pContext, true); httpReleaseContext(pContext/*, true*/);
continue; continue;
} }
......
...@@ -376,6 +376,8 @@ void httpExecCmd(HttpContext *pContext) { ...@@ -376,6 +376,8 @@ void httpExecCmd(HttpContext *pContext) {
httpCloseContextByApp(pContext); httpCloseContextByApp(pContext);
break; break;
} }
memset(&pContext->singleCmd, 0, sizeof(HttpSqlCmd));
} }
void httpProcessRequestCb(void *param, TAOS_RES *result, int32_t code) { void httpProcessRequestCb(void *param, TAOS_RES *result, int32_t code) {
......
...@@ -44,6 +44,12 @@ enum SQL_NODE_FROM_TYPE { ...@@ -44,6 +44,12 @@ enum SQL_NODE_FROM_TYPE {
SQL_NODE_FROM_NAMELIST = 2, SQL_NODE_FROM_NAMELIST = 2,
}; };
enum SQL_EXPR_FLAG {
EXPR_FLAG_TS_ERROR = 1,
EXPR_FLAG_US_TIMESTAMP = 2,
EXPR_FLAG_TIMESTAMP_VAR = 3,
};
extern char tTokenTypeSwitcher[13]; extern char tTokenTypeSwitcher[13];
#define toTSDBType(x) \ #define toTSDBType(x) \
...@@ -237,7 +243,8 @@ typedef struct tSqlExpr { ...@@ -237,7 +243,8 @@ typedef struct tSqlExpr {
SStrToken colInfo; // table column info SStrToken colInfo; // table column info
tVariant value; // the use input value tVariant value; // the use input value
SStrToken token; // original sql expr string SStrToken token; // original sql expr string
uint32_t flags;
struct tSqlExpr *pLeft; // left child struct tSqlExpr *pLeft; // left child
struct tSqlExpr *pRight; // right child struct tSqlExpr *pRight; // right child
struct SArray *pParam; // function parameters list struct SArray *pParam; // function parameters list
......
...@@ -674,6 +674,8 @@ expr(A) ::= PLUS(X) FLOAT(Y). { X.n += Y.n; X.type = TK_FLOAT; A = tSqlExprCr ...@@ -674,6 +674,8 @@ expr(A) ::= PLUS(X) FLOAT(Y). { X.n += Y.n; X.type = TK_FLOAT; A = tSqlExprCr
expr(A) ::= STRING(X). { A = tSqlExprCreateIdValue(&X, TK_STRING);} expr(A) ::= STRING(X). { A = tSqlExprCreateIdValue(&X, TK_STRING);}
expr(A) ::= NOW(X). { A = tSqlExprCreateIdValue(&X, TK_NOW); } expr(A) ::= NOW(X). { A = tSqlExprCreateIdValue(&X, TK_NOW); }
expr(A) ::= VARIABLE(X). { A = tSqlExprCreateIdValue(&X, TK_VARIABLE);} expr(A) ::= VARIABLE(X). { A = tSqlExprCreateIdValue(&X, TK_VARIABLE);}
expr(A) ::= PLUS(X) VARIABLE(Y). { X.n += Y.n; X.type = TK_VARIABLE; A = tSqlExprCreateIdValue(&X, TK_VARIABLE);}
expr(A) ::= MINUS(X) VARIABLE(Y). { X.n += Y.n; X.type = TK_VARIABLE; A = tSqlExprCreateIdValue(&X, TK_VARIABLE);}
expr(A) ::= BOOL(X). { A = tSqlExprCreateIdValue(&X, TK_BOOL);} expr(A) ::= BOOL(X). { A = tSqlExprCreateIdValue(&X, TK_BOOL);}
expr(A) ::= NULL(X). { A = tSqlExprCreateIdValue(&X, TK_NULL);} expr(A) ::= NULL(X). { A = tSqlExprCreateIdValue(&X, TK_NULL);}
......
...@@ -2615,6 +2615,10 @@ static void top_function_f(SQLFunctionCtx *pCtx, int32_t index) { ...@@ -2615,6 +2615,10 @@ static void top_function_f(SQLFunctionCtx *pCtx, int32_t index) {
STopBotInfo *pRes = getTopBotOutputInfo(pCtx); STopBotInfo *pRes = getTopBotOutputInfo(pCtx);
assert(pRes->num >= 0); assert(pRes->num >= 0);
if ((void *)pRes->res[0] != (void *)((char *)pRes + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) {
buildTopBotStruct(pRes, pCtx);
}
SET_VAL(pCtx, 1, 1); SET_VAL(pCtx, 1, 1);
TSKEY ts = GET_TS_DATA(pCtx, index); TSKEY ts = GET_TS_DATA(pCtx, index);
......
...@@ -144,12 +144,15 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) { ...@@ -144,12 +144,15 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) {
pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT;
pSqlExpr->tokenId = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond pSqlExpr->tokenId = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond
pSqlExpr->type = SQL_NODE_VALUE; pSqlExpr->type = SQL_NODE_VALUE;
pSqlExpr->flags |= 1 << EXPR_FLAG_US_TIMESTAMP;
} else if (optrType == TK_VARIABLE) { } else if (optrType == TK_VARIABLE) {
int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64); int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
} }
pSqlExpr->flags |= 1 << EXPR_FLAG_US_TIMESTAMP;
pSqlExpr->flags |= 1 << EXPR_FLAG_TIMESTAMP_VAR;
pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT;
pSqlExpr->tokenId = TK_TIMESTAMP; pSqlExpr->tokenId = TK_TIMESTAMP;
pSqlExpr->type = SQL_NODE_VALUE; pSqlExpr->type = SQL_NODE_VALUE;
...@@ -217,6 +220,15 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) { ...@@ -217,6 +220,15 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
pExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pExpr->value.nType = TSDB_DATA_TYPE_BIGINT;
pExpr->tokenId = pLeft->tokenId; pExpr->tokenId = pLeft->tokenId;
pExpr->type = SQL_NODE_VALUE; pExpr->type = SQL_NODE_VALUE;
pExpr->flags = pLeft->flags | pRight->flags;
if ((pLeft->flags & (1 << EXPR_FLAG_TIMESTAMP_VAR)) && (pRight->flags & (1 << EXPR_FLAG_TIMESTAMP_VAR))) {
pExpr->flags |= 1 << EXPR_FLAG_TS_ERROR;
} else {
pExpr->flags &= ~(1 << EXPR_FLAG_TIMESTAMP_VAR);
pExpr->flags &= ~(1 << EXPR_FLAG_TS_ERROR);
}
switch (optrType) { switch (optrType) {
case TK_PLUS: { case TK_PLUS: {
...@@ -245,7 +257,6 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) { ...@@ -245,7 +257,6 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
tSqlExprDestroy(pLeft); tSqlExprDestroy(pLeft);
tSqlExprDestroy(pRight); tSqlExprDestroy(pRight);
} else if ((pLeft->tokenId == TK_FLOAT && pRight->tokenId == TK_INTEGER) || } else if ((pLeft->tokenId == TK_FLOAT && pRight->tokenId == TK_INTEGER) ||
(pLeft->tokenId == TK_INTEGER && pRight->tokenId == TK_FLOAT) || (pLeft->tokenId == TK_INTEGER && pRight->tokenId == TK_FLOAT) ||
(pLeft->tokenId == TK_FLOAT && pRight->tokenId == TK_FLOAT)) { (pLeft->tokenId == TK_FLOAT && pRight->tokenId == TK_FLOAT)) {
......
此差异已折叠。
...@@ -736,7 +736,7 @@ static uint32_t table[16][256] = { ...@@ -736,7 +736,7 @@ static uint32_t table[16][256] = {
0x9c221d09, 0x6e2e10f7, 0x7dd67004, 0x8fda7dfa} 0x9c221d09, 0x6e2e10f7, 0x7dd67004, 0x8fda7dfa}
}; };
#ifndef _TD_ARM_ #if !defined(_TD_ARM_) && !defined(_TD_MIPS_)
static uint32_t long_shifts[4][256] = { static uint32_t long_shifts[4][256] = {
{0x00000000, 0xe040e0ac, 0xc56db7a9, 0x252d5705, 0x8f3719a3, 0x6f77f90f, {0x00000000, 0xe040e0ac, 0xc56db7a9, 0x252d5705, 0x8f3719a3, 0x6f77f90f,
0x4a5aae0a, 0xaa1a4ea6, 0x1b8245b7, 0xfbc2a51b, 0xdeeff21e, 0x3eaf12b2, 0x4a5aae0a, 0xaa1a4ea6, 0x1b8245b7, 0xfbc2a51b, 0xdeeff21e, 0x3eaf12b2,
...@@ -1187,7 +1187,7 @@ uint32_t crc32c_sf(uint32_t crci, crc_stream input, size_t length) { ...@@ -1187,7 +1187,7 @@ uint32_t crc32c_sf(uint32_t crci, crc_stream input, size_t length) {
} }
return (uint32_t)crc ^ 0xffffffff; return (uint32_t)crc ^ 0xffffffff;
} }
#ifndef _TD_ARM_ #if !defined(_TD_ARM_) && !defined(_TD_MIPS_)
/* Apply the zeros operator table to crc. */ /* Apply the zeros operator table to crc. */
static uint32_t shift_crc(uint32_t shift_table[][256], uint32_t crc) { static uint32_t shift_crc(uint32_t shift_table[][256], uint32_t crc) {
return shift_table[0][crc & 0xff] ^ shift_table[1][(crc >> 8) & 0xff] ^ return shift_table[0][crc & 0xff] ^ shift_table[1][(crc >> 8) & 0xff] ^
...@@ -1198,7 +1198,7 @@ static uint32_t shift_crc(uint32_t shift_table[][256], uint32_t crc) { ...@@ -1198,7 +1198,7 @@ static uint32_t shift_crc(uint32_t shift_table[][256], uint32_t crc) {
version. Otherwise, use the software version. */ version. Otherwise, use the software version. */
uint32_t (*crc32c)(uint32_t crci, crc_stream bytes, size_t len) = crc32c_sf; uint32_t (*crc32c)(uint32_t crci, crc_stream bytes, size_t len) = crc32c_sf;
#ifndef _TD_ARM_ #if !defined(_TD_ARM_) && !defined(_TD_MIPS_)
/* Compute CRC-32C using the Intel hardware instruction. */ /* Compute CRC-32C using the Intel hardware instruction. */
uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) { uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) {
crc_stream next = buf; crc_stream next = buf;
...@@ -1353,7 +1353,7 @@ uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) { ...@@ -1353,7 +1353,7 @@ uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) {
#endif // #ifndef _TD_ARM_ #endif // #ifndef _TD_ARM_
void taosResolveCRC() { void taosResolveCRC() {
#if defined _TD_ARM_ || defined WINDOWS #if defined _TD_ARM_ || defined _TD_MIPS_ || defined WINDOWS
crc32c = crc32c_sf; crc32c = crc32c_sf;
#else #else
int sse42; int sse42;
......
...@@ -435,11 +435,15 @@ void verify_async(TAOS* taos) { ...@@ -435,11 +435,15 @@ void verify_async(TAOS* taos) {
} }
void stream_callback(void *param, TAOS_RES *res, TAOS_ROW row) { void stream_callback(void *param, TAOS_RES *res, TAOS_ROW row) {
if (res == NULL || row == NULL) {
return;
}
int num_fields = taos_num_fields(res); int num_fields = taos_num_fields(res);
TAOS_FIELD* fields = taos_fetch_fields(res); TAOS_FIELD* fields = taos_fetch_fields(res);
printf("got one row from stream_callback\n"); printf("got one row from stream_callback\n");
char temp[256]; char temp[256] = {0};
taos_print_row(temp, row, fields, num_fields); taos_print_row(temp, row, fields, num_fields);
puts(temp); puts(temp);
} }
......
...@@ -18,6 +18,7 @@ import ( ...@@ -18,6 +18,7 @@ import (
"database/sql" "database/sql"
"flag" "flag"
"fmt" "fmt"
"log"
"math/rand" "math/rand"
"os" "os"
"runtime" "runtime"
...@@ -26,8 +27,6 @@ import ( ...@@ -26,8 +27,6 @@ import (
"time" "time"
_ "github.com/taosdata/driver-go/taosSql" _ "github.com/taosdata/driver-go/taosSql"
//"golang.org/x/sys/unix"
) )
const ( const (
...@@ -48,6 +47,7 @@ type config struct { ...@@ -48,6 +47,7 @@ type config struct {
dbName string dbName string
supTblName string supTblName string
tablePrefix string tablePrefix string
mode string
numOftables int numOftables int
numOfRecordsPerTable int numOfRecordsPerTable int
numOfRecordsPerReq int numOfRecordsPerReq int
...@@ -70,6 +70,7 @@ func init() { ...@@ -70,6 +70,7 @@ func init() {
flag.StringVar(&configPara.password, "P", "taosdata", "The password to use when connecting to the server.") flag.StringVar(&configPara.password, "P", "taosdata", "The password to use when connecting to the server.")
flag.StringVar(&configPara.dbName, "d", "test", "Destination database.") flag.StringVar(&configPara.dbName, "d", "test", "Destination database.")
flag.StringVar(&configPara.tablePrefix, "m", "d", "Table prefix name.") flag.StringVar(&configPara.tablePrefix, "m", "d", "Table prefix name.")
flag.StringVar(&configPara.mode, "M", "r", "mode,r:raw,s:stmt")
flag.IntVar(&configPara.numOftables, "t", 2, "The number of tables.") flag.IntVar(&configPara.numOftables, "t", 2, "The number of tables.")
flag.IntVar(&configPara.numOfRecordsPerTable, "n", 10, "The number of records per table.") flag.IntVar(&configPara.numOfRecordsPerTable, "n", 10, "The number of records per table.")
flag.IntVar(&configPara.numOfRecordsPerReq, "r", 3, "The number of records per request.") flag.IntVar(&configPara.numOfRecordsPerReq, "r", 3, "The number of records per request.")
...@@ -94,6 +95,7 @@ func printAllArgs() { ...@@ -94,6 +95,7 @@ func printAllArgs() {
fmt.Printf("usr: %v\n", configPara.user) fmt.Printf("usr: %v\n", configPara.user)
fmt.Printf("password: %v\n", configPara.password) fmt.Printf("password: %v\n", configPara.password)
fmt.Printf("dbName: %v\n", configPara.dbName) fmt.Printf("dbName: %v\n", configPara.dbName)
fmt.Printf("mode: %v\n", configPara.mode)
fmt.Printf("tablePrefix: %v\n", configPara.tablePrefix) fmt.Printf("tablePrefix: %v\n", configPara.tablePrefix)
fmt.Printf("numOftables: %v\n", configPara.numOftables) fmt.Printf("numOftables: %v\n", configPara.numOftables)
fmt.Printf("numOfRecordsPerTable: %v\n", configPara.numOfRecordsPerTable) fmt.Printf("numOfRecordsPerTable: %v\n", configPara.numOfRecordsPerTable)
...@@ -119,6 +121,24 @@ func main() { ...@@ -119,6 +121,24 @@ func main() {
//defer db.Close() //defer db.Close()
rand.Seed(time.Now().Unix()) rand.Seed(time.Now().Unix())
if configPara.mode == "s" {
fmt.Printf("\n======== start stmt mode test ========\n")
db, err := sql.Open("taosSql", url)
if err != nil {
log.Fatalf("Open database error: %s\n", err)
}
defer db.Close()
demodbStmt := configPara.dbName
demotStmt := "demotStmt"
drop_database_stmt(db, demodbStmt)
create_database_stmt(db, demodbStmt)
use_database_stmt(db, demodbStmt)
create_table_stmt(db, demotStmt)
insert_data_stmt(db, demotStmt)
select_data_stmt(db, demotStmt)
return
}
createDatabase(configPara.dbName, configPara.supTblName) createDatabase(configPara.dbName, configPara.supTblName)
fmt.Printf("======== create database success! ========\n\n") fmt.Printf("======== create database success! ========\n\n")
...@@ -407,6 +427,132 @@ func selectTest(dbName string, tbPrefix string, supTblName string) { ...@@ -407,6 +427,132 @@ func selectTest(dbName string, tbPrefix string, supTblName string) {
checkErr(err, "rows next iteration error") checkErr(err, "rows next iteration error")
} }
} }
func drop_database_stmt(db *sql.DB, demodb string) {
st := time.Now().Nanosecond()
// drop test db
res, err := db.Exec("drop database if exists " + demodb)
checkErr(err, "drop database "+demodb)
affectd, err := res.RowsAffected()
checkErr(err, "drop db, res.RowsAffected")
et := time.Now().Nanosecond()
fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
}
func create_database_stmt(db *sql.DB, demodb string) {
st := time.Now().Nanosecond()
// create database
//var stmt interface{}
stmt, err := db.Prepare("create database ?")
checkErr(err, "create db, db.Prepare")
//var res driver.Result
res, err := stmt.Exec(demodb)
checkErr(err, "create db, stmt.Exec")
//fmt.Printf("Query OK, %d row(s) affected()", res.RowsAffected())
affectd, err := res.RowsAffected()
checkErr(err, "create db, res.RowsAffected")
et := time.Now().Nanosecond()
fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
}
func use_database_stmt(db *sql.DB, demodb string) {
st := time.Now().Nanosecond()
// create database
//var stmt interface{}
stmt, err := db.Prepare("use " + demodb)
checkErr(err, "use db, db.Prepare")
res, err := stmt.Exec()
checkErr(err, "use db, stmt.Exec")
affectd, err := res.RowsAffected()
checkErr(err, "use db, res.RowsAffected")
et := time.Now().Nanosecond()
fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
}
func create_table_stmt(db *sql.DB, demot string) {
st := time.Now().Nanosecond()
// create table
// (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double)
stmt, err := db.Prepare("create table ? (? timestamp, ? int, ? binary(10), ? tinyint, ? bool, ? binary(8), ? float, ? double)")
checkErr(err, "create table db.Prepare")
res, err := stmt.Exec(demot, "ts", "id", "name", "len", "flag", "notes", "fv", "dv")
checkErr(err, "create table stmt.Exec")
affectd, err := res.RowsAffected()
checkErr(err, "create table res.RowsAffected")
et := time.Now().Nanosecond()
fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
}
func insert_data_stmt(db *sql.DB, demot string) {
st := time.Now().Nanosecond()
// insert data into table
stmt, err := db.Prepare("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?)")
checkErr(err, "insert db.Prepare")
res, err := stmt.Exec(demot, "now", 1000, "'haidian'", 6, true, "'AI world'", 6987.654, 321.987,
"now+1s", 1001, "'changyang'", 7, false, "'DeepMode'", 12356.456, 128634.456,
"now+2s", 1002, "'chuangping'", 8, true, "'database'", 3879.456, 65433478.456)
checkErr(err, "insert data, stmt.Exec")
affectd, err := res.RowsAffected()
checkErr(err, "res.RowsAffected")
et := time.Now().Nanosecond()
fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
}
func select_data_stmt(db *sql.DB, demot string) {
st := time.Now().Nanosecond()
stmt, err := db.Prepare("select ?, ?, ?, ?, ?, ?, ?, ? from ?") // go binary mode
checkErr(err, "db.Prepare")
rows, err := stmt.Query("ts", "id", "name", "len", "flag", "notes", "fv", "dv", demot)
checkErr(err, "stmt.Query")
fmt.Printf("%10s%s%8s %5s %8s%s %s %10s%s %7s%s %8s%s %11s%s %14s%s\n", " ", "ts", " ", "id", " ", "name", " ", "len", " ", "flag", " ", "notes", " ", "fv", " ", " ", "dv")
var affectd int
for rows.Next() {
var ts string
var name string
var id int
var len int8
var flag bool
var notes string
var fv float32
var dv float64
err = rows.Scan(&ts, &id, &name, &len, &flag, &notes, &fv, &dv)
//fmt.Println("start scan fields from row.rs, &fv:", &fv)
//err = rows.Scan(&fv)
checkErr(err, "rows.Scan")
fmt.Printf("%s\t", ts)
fmt.Printf("%d\t", id)
fmt.Printf("%10s\t", name)
fmt.Printf("%d\t", len)
fmt.Printf("%t\t", flag)
fmt.Printf("%s\t", notes)
fmt.Printf("%06.3f\t", fv)
fmt.Printf("%09.6f\n", dv)
affectd++
}
et := time.Now().Nanosecond()
fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
}
func checkErr(err error, prompt string) { func checkErr(err error, prompt string) {
if err != nil { if err != nil {
fmt.Printf("%s\n", prompt) fmt.Printf("%s\n", prompt)
......
...@@ -64,7 +64,7 @@ function runQueryPerfTest { ...@@ -64,7 +64,7 @@ function runQueryPerfTest {
[ -f $PERFORMANCE_TEST_REPORT ] && rm $PERFORMANCE_TEST_REPORT [ -f $PERFORMANCE_TEST_REPORT ] && rm $PERFORMANCE_TEST_REPORT
nohup $WORK_DIR/TDengine/debug/build/bin/taosd -c /etc/taosperf/ > /dev/null 2>&1 & nohup $WORK_DIR/TDengine/debug/build/bin/taosd -c /etc/taosperf/ > /dev/null 2>&1 &
echoInfo "Wait TDengine to start" echoInfo "Wait TDengine to start"
sleep 120 sleep 300
echoInfo "Run Performance Test" echoInfo "Run Performance Test"
cd $WORK_DIR/TDengine/tests/pytest cd $WORK_DIR/TDengine/tests/pytest
......
###################################################################
# 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(f"start to execute {__file__}")
tdSql.init(conn.cursor(), logSql)
def run(self):
tdSql.execute("drop database if exists db")
tdSql.execute("create database if not exists db keep 36500")
tdSql.execute("use db")
tdLog.printNoPrefix("==========step1:create table && insert data")
# timestamp list:
# 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00"
# -631180800000 -> "1950-01-01 00:00:00"
ts1 = 0
ts2 = -28800000
ts3 = -946800000000
ts4 = "1950-01-01 00:00:00"
tdSql.execute(
"create table stb2ts (ts timestamp, ts1 timestamp, ts2 timestamp, c1 int, ts3 timestamp) TAGS(t1 int)"
)
tdSql.execute("create table t2ts1 using stb2ts tags(1)")
tdSql.execute(f"insert into t2ts1 values ({ts1}, {ts1}, {ts1}, 1, {ts1})")
tdSql.execute(f"insert into t2ts1 values ({ts2}, {ts2}, {ts2}, 2, {ts2})")
tdSql.execute(f"insert into t2ts1 values ({ts3}, {ts3}, {ts3}, 4, {ts3})")
tdSql.execute(f"insert into t2ts1 values ('{ts4}', '{ts4}', '{ts4}', 3, '{ts4}')")
tdLog.printNoPrefix("==========step2:check inserted data")
tdSql.query("select * from stb2ts where ts1=0 and ts2='1970-01-01 08:00:00' ")
tdSql.checkRows(1)
tdSql.checkData(0, 4,'1970-01-01 08:00:00')
tdSql.query("select * from stb2ts where ts1=-28800000 and ts2='1970-01-01 00:00:00' ")
tdSql.checkRows(1)
tdSql.checkData(0, 4, '1970-01-01 00:00:00')
tdSql.query("select * from stb2ts where ts1=-946800000000 and ts2='1940-01-01 00:00:00' ")
tdSql.checkRows(1)
tdSql.checkData(0, 4, '1940-01-01 00:00:00')
tdSql.query("select * from stb2ts where ts1=-631180800000 and ts2='1950-01-01 00:00:00' ")
tdSql.checkRows(1)
tdSql.checkData(0, 4, '1950-01-01 00:00:00')
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -223,6 +223,7 @@ python3 ./test.py -f query/bug3375.py ...@@ -223,6 +223,7 @@ python3 ./test.py -f query/bug3375.py
python3 ./test.py -f query/queryJoin10tables.py python3 ./test.py -f query/queryJoin10tables.py
python3 ./test.py -f query/queryStddevWithGroupby.py python3 ./test.py -f query/queryStddevWithGroupby.py
python3 ./test.py -f query/querySecondtscolumnTowherenow.py python3 ./test.py -f query/querySecondtscolumnTowherenow.py
python3 ./test.py -f query/queryFilterTswithDateUnit.py
...@@ -241,6 +242,7 @@ python3 ./test.py -f stream/table_n.py ...@@ -241,6 +242,7 @@ python3 ./test.py -f stream/table_n.py
#alter table #alter table
python3 ./test.py -f alter/alter_table_crash.py python3 ./test.py -f alter/alter_table_crash.py
python3 ./test.py -f alter/alterTabAddTagWithNULL.py python3 ./test.py -f alter/alterTabAddTagWithNULL.py
python3 ./test.py -f alter/alterTimestampColDataProcess.py
# client # client
python3 ./test.py -f client/client.py python3 ./test.py -f client/client.py
...@@ -311,6 +313,11 @@ python3 ./test.py -f insert/unsignedSmallint.py ...@@ -311,6 +313,11 @@ python3 ./test.py -f insert/unsignedSmallint.py
python3 ./test.py -f insert/unsignedTinyint.py python3 ./test.py -f insert/unsignedTinyint.py
python3 ./test.py -f query/filterAllUnsignedIntTypes.py python3 ./test.py -f query/filterAllUnsignedIntTypes.py
python3 ./test.py -f tag_lite/unsignedInt.py
python3 ./test.py -f tag_lite/unsignedBigint.py
python3 ./test.py -f tag_lite/unsignedSmallint.py
python3 ./test.py -f tag_lite/unsignedTinyint.py
python3 ./test.py -f functions/function_percentile2.py python3 ./test.py -f functions/function_percentile2.py
python3 ./test.py -f insert/boundary2.py python3 ./test.py -f insert/boundary2.py
python3 ./test.py -f alter/alter_debugFlag.py python3 ./test.py -f alter/alter_debugFlag.py
......
###################################################################
# 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(f"start to execute {__file__}")
tdSql.init(conn.cursor(), logSql)
def insertnow(self, tsp1, tsp2, tsp3):
tdSql.execute(
"create table stbts (ts timestamp, ts1 timestamp, c1 int, ts2 timestamp) TAGS(t1 int)"
)
tdSql.execute("create table tts1 using stbts tags(1)")
tdSql.execute("insert into tts1 values (now+1d, now+1d, 6, now+1d)")
tdSql.execute("insert into tts1 values (now, now, 5, now)")
tdSql.execute("insert into tts1 values (now-1d, now-1d, 4, now-1d)")
tdSql.execute(f"insert into tts1 values ({tsp1}, {tsp1}, 3, {tsp1})")
tdSql.execute(f"insert into tts1 values ({tsp2}, {tsp2}, 2, {tsp2})")
tdSql.execute(f"insert into tts1 values ({tsp3}, {tsp3}, 1, {tsp3})")
def querynow(self):
tdLog.printNoPrefix("==========step query: execute query operation")
time.sleep(1)
cols = ["ts", "ts1", "ts2"]
for col in cols:
tdSql.error(f" select * from tts1 where {col} = 1d ")
tdSql.error(f" select * from tts1 where {col} < 1d ")
tdSql.error(f" select * from tts1 where {col} > 1d ")
tdSql.error(f" select * from tts1 where {col} >= 1d ")
tdSql.error(f" select * from tts1 where {col} <= 1d ")
tdSql.error(f" select * from tts1 where {col} <> 1d ")
tdSql.error(f" select * from tts1 where {col} = 1m ")
tdSql.error(f" select * from tts1 where {col} < 1m ")
tdSql.error(f" select * from tts1 where {col} > 1m ")
tdSql.error(f" select * from tts1 where {col} >= 1m ")
tdSql.error(f" select * from tts1 where {col} <= 1m ")
tdSql.error(f" select * from tts1 where {col} <> 1m ")
tdSql.error(f" select * from tts1 where {col} = 1s ")
tdSql.error(f" select * from tts1 where {col} < 1s ")
tdSql.error(f" select * from tts1 where {col} > 1s ")
tdSql.error(f" select * from tts1 where {col} >= 1s ")
tdSql.error(f" select * from tts1 where {col} <= 1s ")
tdSql.error(f" select * from tts1 where {col} <> 1s ")
tdSql.error(f" select * from tts1 where {col} = 1a ")
tdSql.error(f" select * from tts1 where {col} < 1a ")
tdSql.error(f" select * from tts1 where {col} > 1a ")
tdSql.error(f" select * from tts1 where {col} >= 1a ")
tdSql.error(f" select * from tts1 where {col} <= 1a ")
tdSql.error(f" select * from tts1 where {col} <> 1a ")
tdSql.error(f" select * from tts1 where {col} = 1h ")
tdSql.error(f" select * from tts1 where {col} < 1h ")
tdSql.error(f" select * from tts1 where {col} > 1h ")
tdSql.error(f" select * from tts1 where {col} >= 1h ")
tdSql.error(f" select * from tts1 where {col} <= 1h ")
tdSql.error(f" select * from tts1 where {col} <> 1h ")
tdSql.error(f" select * from tts1 where {col} = 1w ")
tdSql.error(f" select * from tts1 where {col} < 1w ")
tdSql.error(f" select * from tts1 where {col} > 1w ")
tdSql.error(f" select * from tts1 where {col} >= 1w ")
tdSql.error(f" select * from tts1 where {col} <= 1w ")
tdSql.error(f" select * from tts1 where {col} <> 1w ")
tdSql.error(f" select * from tts1 where {col} = 1u ")
tdSql.error(f" select * from tts1 where {col} < 1u ")
tdSql.error(f" select * from tts1 where {col} > 1u ")
tdSql.error(f" select * from tts1 where {col} >= 1u ")
tdSql.error(f" select * from tts1 where {col} <= 1u ")
tdSql.error(f" select * from tts1 where {col} <> 1u ")
tdSql.error(f" select * from tts1 where {col} = 0d ")
tdSql.error(f" select * from tts1 where {col} < 0s ")
tdSql.error(f" select * from tts1 where {col} > 0a ")
tdSql.error(f" select * from tts1 where {col} >= 0m ")
tdSql.error(f" select * from tts1 where {col} <= 0h ")
tdSql.error(f" select * from tts1 where {col} <> 0u ")
tdSql.error(f" select * from tts1 where {col} <> 0w ")
tdSql.error(f" select * from tts1 where {col} = 1m+1h ")
tdSql.error(f" select * from tts1 where {col} < 1w-1d ")
tdSql.error(f" select * from tts1 where {col} > 0a/1u ")
tdSql.error(f" select * from tts1 where {col} >= 1d/0s ")
tdSql.error(f" select * from tts1 where {col} <= 1s*1a ")
tdSql.error(f" select * from tts1 where {col} <> 0w/0d ")
tdSql.error(f" select * from tts1 where {col} = 1m+1h ")
tdSql.error(f" select * from tts1 where {col} < 1w-1d ")
tdSql.error(f" select * from tts1 where {col} > 0a/1u ")
tdSql.error(f" select * from tts1 where {col} >= 1d/0s ")
tdSql.error(f" select * from tts1 where {col} <= 1s*1a ")
tdSql.error(f" select * from tts1 where {col} <> 0w/0d ")
tdSql.error(f" select * from tts1 where {col} = 1u+1 ")
tdSql.error(f" select * from tts1 where {col} < 1a-1 ")
tdSql.error(f" select * from tts1 where {col} > 1s*1 ")
tdSql.error(f" select * from tts1 where {col} >= 1m/1 ")
tdSql.error(f" select * from tts1 where {col} <= 1h/0 ")
tdSql.error(f" select * from tts1 where {col} <> 0/1d ")
tdSql.error(f" select * from tts1 where {col} <> 1w+'2010-01-01 00:00:00' ")
def run(self):
tdSql.execute("drop database if exists dbms")
tdSql.execute("drop database if exists dbus")
# timestamp list:
# 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00"
# -631180800000 -> "1950-01-01 00:00:00"
tdLog.printNoPrefix("==========step1:create table precision ms && insert data && query")
# create databases precision is ms
tdSql.execute("create database if not exists dbms keep 36500")
tdSql.execute("use dbms")
tsp1 = 0
tsp2 = -28800000
tsp3 = -946800000000
self.insertnow(tsp1,tsp2,tsp3)
self.querynow()
tdLog.printNoPrefix("==========step2:create table precision us && insert data && query")
# create databases precision is us
tdSql.execute("create database if not exists dbus keep 36500 precision 'us' ")
tdSql.execute("use dbus")
tsp2 = -28800000 * 1000
tsp3 = -946800000000 * 1000
self.insertnow(tsp1,tsp2,tsp3)
self.querynow()
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -42,7 +42,7 @@ class TDTestCase: ...@@ -42,7 +42,7 @@ class TDTestCase:
tdLog.info("=============== step3") tdLog.info("=============== step3")
start = time.time() start = time.time()
tdSql.waitedQuery("select * from st", 1, 120) tdSql.waitedQuery("select * from st", 1, 180)
delay = int(time.time() - start) + 80 delay = int(time.time() - start) + 80
v = tdSql.getData(0, 3) v = tdSql.getData(0, 3)
if v >= 51: if v >= 51:
......
...@@ -88,6 +88,8 @@ class TDTestCase: ...@@ -88,6 +88,8 @@ class TDTestCase:
except Exception as e: except Exception as e:
tdLog.info(repr(e)) tdLog.info(repr(e))
time.sleep(5)
tdSql.query("show streams") tdSql.query("show streams")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.checkData(0, 2, 's0') tdSql.checkData(0, 2, 's0')
...@@ -146,6 +148,7 @@ class TDTestCase: ...@@ -146,6 +148,7 @@ class TDTestCase:
except Exception as e: except Exception as e:
tdLog.info(repr(e)) tdLog.info(repr(e))
time.sleep(5)
tdSql.query("show streams") tdSql.query("show streams")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 2, 's1') tdSql.checkData(0, 2, 's1')
......
...@@ -47,7 +47,7 @@ class TDTestCase: ...@@ -47,7 +47,7 @@ class TDTestCase:
"select * from iostrm", "select * from iostrm",
] ]
for sql in sqls: for sql in sqls:
(rows, _) = tdSql.waitedQuery(sql, 1, 120) (rows, _) = tdSql.waitedQuery(sql, 1, 240)
if rows < 1: if rows < 1:
tdLog.exit("failed: sql:%s, expect at least one row" % sql) tdLog.exit("failed: sql:%s, expect at least one row" % sql)
......
...@@ -100,8 +100,8 @@ class TDTestCase: ...@@ -100,8 +100,8 @@ class TDTestCase:
print("alter table test.meters add column col10 int") print("alter table test.meters add column col10 int")
tdSql.execute("alter table test.meters add column col10 int") tdSql.execute("alter table test.meters add column col10 int")
print("insert into test.t9 values (now, 1, 2, 3, 4, 0.1, 0.01,'test', '测试', TRUE, 1610000000000, 0)") print("insert into test.t9 values (now, 1, 2, 3, 4, 0)")
tdSql.execute("insert into test.t9 values (now, 1, 2, 3, 4, 0.1, 0.01,'test', '测试', TRUE, 1610000000000, 0)") tdSql.execute("insert into test.t9 values (now, 1, 2, 3, 4, 0)")
def run(self): def run(self):
tdSql.prepare() tdSql.prepare()
......
...@@ -87,6 +87,7 @@ class TDSql: ...@@ -87,6 +87,7 @@ class TDSql:
self.queryResult = self.cursor.fetchall() self.queryResult = self.cursor.fetchall()
self.queryRows = len(self.queryResult) self.queryRows = len(self.queryResult)
self.queryCols = len(self.cursor.description) self.queryCols = len(self.cursor.description)
tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows))
if self.queryRows >= expectRows: if self.queryRows >= expectRows:
return (self.queryRows, i) return (self.queryRows, i)
time.sleep(1) time.sleep(1)
......
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ======================== dnode1 start
$dbPrefix = s3_db
$tbPrefix = s3_tb
$mtPrefix = s3_mt
$stPrefix = s3_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 keep 36500
sql use $db
sql create stable $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)
sql create table cq1 as select count(*) from $mt interval(10s);
sleep 1000
sql create table $st using $mt tags(1);
sql insert into $st values (-50000, 1, 1.0);
sql insert into $st values (-10000, 1, 1.0);
sql insert into $st values (10000, 1, 1.0);
$i = 0
while $i < 12
sql select * from cq1;
if $rows != 3 then
sleep 10000
else
if $data00 != @70-01-01 07:59:10.000@ then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data10 != @70-01-01 07:59:50.000@ then
return -1
endi
if $data11 != 1 then
return -1
endi
if $data20 != @70-01-01 08:00:10.000@ then
return -1
endi
if $data21 != 1 then
return -1
endi
$i = 12
endi
$i = $i + 1
endw
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册