提交 2167d0fc 编写于 作者: A Alex Duan

Merge branch 'develop' into fix/TS-802-D1

...@@ -8,6 +8,7 @@ def skipbuild = 0 ...@@ -8,6 +8,7 @@ def skipbuild = 0
def win_stop = 0 def win_stop = 0
def scope = [] def scope = []
def mod = [0,1,2,3,4] def mod = [0,1,2,3,4]
def sim_mod = [0,1,2,3]
def abortPreviousBuilds() { def abortPreviousBuilds() {
def currentJobName = env.JOB_NAME def currentJobName = env.JOB_NAME
...@@ -45,6 +46,7 @@ def pre_test(){ ...@@ -45,6 +46,7 @@ def pre_test(){
killall -9 gdb || echo "no gdb running" killall -9 gdb || echo "no gdb running"
killall -9 python3.8 || echo "no python program running" killall -9 python3.8 || echo "no python program running"
cd ${WKC} cd ${WKC}
[ -f src/connector/grafanaplugin/README.md ] && rm -f src/connector/grafanaplugin/README.md > /dev/null || echo "failed to remove grafanaplugin README.md"
git reset --hard HEAD~10 >/dev/null git reset --hard HEAD~10 >/dev/null
''' '''
script { script {
...@@ -120,6 +122,7 @@ def pre_test_noinstall(){ ...@@ -120,6 +122,7 @@ def pre_test_noinstall(){
sh'hostname' sh'hostname'
sh''' sh'''
cd ${WKC} cd ${WKC}
[ -f src/connector/grafanaplugin/README.md ] && rm -f src/connector/grafanaplugin/README.md > /dev/null || echo "failed to remove grafanaplugin README.md"
git reset --hard HEAD~10 >/dev/null git reset --hard HEAD~10 >/dev/null
''' '''
script { script {
...@@ -192,6 +195,7 @@ def pre_test_mac(){ ...@@ -192,6 +195,7 @@ def pre_test_mac(){
sh'hostname' sh'hostname'
sh''' sh'''
cd ${WKC} cd ${WKC}
[ -f src/connector/grafanaplugin/README.md ] && rm -f src/connector/grafanaplugin/README.md > /dev/null || echo "failed to remove grafanaplugin README.md"
git reset --hard HEAD~10 >/dev/null git reset --hard HEAD~10 >/dev/null
''' '''
script { script {
...@@ -382,7 +386,9 @@ pipeline { ...@@ -382,7 +386,9 @@ pipeline {
temp = (gitlog =~ /\((.*?)\)/) temp = (gitlog =~ /\((.*?)\)/)
temp = temp[0].remove(1) temp = temp[0].remove(1)
scope = temp.split(",") scope = temp.split(",")
scope = ['connector','query','insert','other','tools','taosAdapter']
Collections.shuffle mod Collections.shuffle mod
Collections.shuffle sim_mod
} }
} }
...@@ -400,7 +406,7 @@ pipeline { ...@@ -400,7 +406,7 @@ pipeline {
} }
parallel { parallel {
stage('python_1') { stage('python_1') {
agent{label " slave1 || slave6 || slave11 || slave16 "} agent{label " slave1 || slave11 "}
steps { steps {
pre_test() pre_test()
timeout(time: 100, unit: 'MINUTES'){ timeout(time: 100, unit: 'MINUTES'){
...@@ -417,7 +423,7 @@ pipeline { ...@@ -417,7 +423,7 @@ pipeline {
} }
} }
stage('python_2') { stage('python_2') {
agent{label " slave2 || slave7 || slave12 || slave17 "} agent{label " slave2 || slave12 "}
steps { steps {
pre_test() pre_test()
timeout(time: 100, unit: 'MINUTES'){ timeout(time: 100, unit: 'MINUTES'){
...@@ -434,7 +440,7 @@ pipeline { ...@@ -434,7 +440,7 @@ pipeline {
} }
} }
stage('python_3') { stage('python_3') {
agent{label " slave3 || slave8 || slave13 ||slave18 "} agent{label " slave3 || slave13 "}
steps { steps {
timeout(time: 105, unit: 'MINUTES'){ timeout(time: 105, unit: 'MINUTES'){
pre_test() pre_test()
...@@ -451,7 +457,7 @@ pipeline { ...@@ -451,7 +457,7 @@ pipeline {
} }
} }
stage('python_4') { stage('python_4') {
agent{label " slave4 || slave9 || slave14 || slave19 "} agent{label " slave4 || slave14 "}
steps { steps {
timeout(time: 100, unit: 'MINUTES'){ timeout(time: 100, unit: 'MINUTES'){
pre_test() pre_test()
...@@ -469,7 +475,7 @@ pipeline { ...@@ -469,7 +475,7 @@ pipeline {
} }
} }
stage('python_5') { stage('python_5') {
agent{label " slave5 || slave10 || slave15 || slave20 "} agent{label " slave5 || slave15 "}
steps { steps {
timeout(time: 100, unit: 'MINUTES'){ timeout(time: 100, unit: 'MINUTES'){
pre_test() pre_test()
...@@ -486,34 +492,97 @@ pipeline { ...@@ -486,34 +492,97 @@ pipeline {
} }
} }
} }
stage('arm64centos7') { stage('sim_1') {
agent{label " arm64centos7 "} agent{label " slave6 || slave16 "}
steps { steps {
pre_test_noinstall() pre_test()
timeout(time: 100, unit: 'MINUTES'){
sh """
date
cd ${WKC}/tests
./test-CI.sh sim 4 ${sim_mod[0]}
date"""
} }
} }
stage('arm64centos8') { }
agent{label " arm64centos8 "} stage('sim_2') {
agent{label " slave7 || slave17 "}
steps { steps {
pre_test_noinstall() pre_test()
timeout(time: 100, unit: 'MINUTES'){
sh """
date
cd ${WKC}/tests
./test-CI.sh sim 4 ${sim_mod[1]}
date"""
} }
} }
stage('arm32bionic') { }
agent{label " arm32bionic "} stage('sim_3') {
agent{label " slave8 || slave18 "}
steps { steps {
pre_test_noinstall() timeout(time: 105, unit: 'MINUTES'){
pre_test()
sh """
date
cd ${WKC}/tests
./test-CI.sh sim 4 ${sim_mod[2]}
date"""
} }
} }
stage('arm64bionic') { }
agent{label " arm64bionic "} stage('sim_4') {
agent{label " slave9 || slave19 "}
steps { steps {
pre_test_noinstall() timeout(time: 100, unit: 'MINUTES'){
pre_test()
sh """
date
cd ${WKC}/tests
./test-CI.sh sim 4 ${sim_mod[3]}
date"""
} }
} }
stage('arm64focal') {
agent{label " arm64focal "} }
stage('other') {
agent{label " slave10 || slave20 "}
steps { steps {
pre_test_noinstall() timeout(time: 100, unit: 'MINUTES'){
pre_test()
timeout(time: 60, unit: 'MINUTES'){
sh '''
cd ${WKC}/tests/pytest
./crash_gen.sh -a -p -t 4 -s 2000
'''
}
timeout(time: 60, unit: 'MINUTES'){
sh '''
cd ${WKC}/tests/pytest
rm -rf /var/lib/taos/*
rm -rf /var/log/taos/*
./handle_crash_gen_val_log.sh
'''
sh '''
cd ${WKC}/tests/pytest
rm -rf /var/lib/taos/*
rm -rf /var/log/taos/*
./handle_taosd_val_log.sh
'''
}
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''
cd ${WKC}/tests/pytest
./valgrind-test.sh 2>&1 > mem-error-out.log
./handle_val_log.sh
'''
}
sh '''
cd ${WKC}/tests
./test-all.sh full unit
date
'''
}
} }
} }
stage('centos7') { stage('centos7') {
...@@ -546,7 +615,36 @@ pipeline { ...@@ -546,7 +615,36 @@ pipeline {
pre_test_mac() pre_test_mac()
} }
} }
stage('arm64centos7') {
agent{label " arm64centos7 "}
steps {
pre_test_noinstall()
}
}
stage('arm64centos8') {
agent{label " arm64centos8 "}
steps {
pre_test_noinstall()
}
}
stage('arm32bionic') {
agent{label " arm32bionic "}
steps {
pre_test_noinstall()
}
}
stage('arm64bionic') {
agent{label " arm64bionic "}
steps {
pre_test_noinstall()
}
}
stage('arm64focal') {
agent{label " arm64focal "}
steps {
pre_test_noinstall()
}
}
stage('build'){ stage('build'){
agent{label " wintest "} agent{label " wintest "}
steps { steps {
...@@ -561,6 +659,7 @@ pipeline { ...@@ -561,6 +659,7 @@ pipeline {
stage('test'){ stage('test'){
agent{label "win"} agent{label "win"}
steps{ steps{
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
pre_test_win() pre_test_win()
timeout(time: 20, unit: 'MINUTES'){ timeout(time: 20, unit: 'MINUTES'){
......
...@@ -902,7 +902,7 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) { ...@@ -902,7 +902,7 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) {
// not belongs to the same group, return the result of current group; // not belongs to the same group, return the result of current group;
setInputDataBlock(pOperator, pAggInfo->binfo.pCtx, pAggInfo->pExistBlock, TSDB_ORDER_ASC); setInputDataBlock(pOperator, pAggInfo->binfo.pCtx, pAggInfo->pExistBlock, TSDB_ORDER_ASC);
updateOutputBuf(&pAggInfo->binfo, &pAggInfo->bufCapacity, pAggInfo->pExistBlock->info.rows); updateOutputBuf(&pAggInfo->binfo, &pAggInfo->bufCapacity, pAggInfo->pExistBlock->info.rows, pOperator->pRuntimeEnv);
{ // reset output buffer { // reset output buffer
for(int32_t j = 0; j < pOperator->numOfOutput; ++j) { for(int32_t j = 0; j < pOperator->numOfOutput; ++j) {
...@@ -954,7 +954,7 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) { ...@@ -954,7 +954,7 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) {
// not belongs to the same group, return the result of current group // not belongs to the same group, return the result of current group
setInputDataBlock(pOperator, pAggInfo->binfo.pCtx, pBlock, TSDB_ORDER_ASC); setInputDataBlock(pOperator, pAggInfo->binfo.pCtx, pBlock, TSDB_ORDER_ASC);
updateOutputBuf(&pAggInfo->binfo, &pAggInfo->bufCapacity, pBlock->info.rows * pAggInfo->resultRowFactor); updateOutputBuf(&pAggInfo->binfo, &pAggInfo->bufCapacity, pBlock->info.rows * pAggInfo->resultRowFactor, pOperator->pRuntimeEnv);
doExecuteFinalMerge(pOperator, pOperator->numOfOutput, pBlock); doExecuteFinalMerge(pOperator, pOperator->numOfOutput, pBlock);
savePrevOrderColumns(pAggInfo->currentGroupColData, pAggInfo->groupColumnList, pBlock, 0, &pAggInfo->hasGroupColData); savePrevOrderColumns(pAggInfo->currentGroupColData, pAggInfo->groupColumnList, pBlock, 0, &pAggInfo->hasGroupColData);
......
...@@ -1866,6 +1866,7 @@ int tscProcessRetrieveGlobalMergeRsp(SSqlObj *pSql) { ...@@ -1866,6 +1866,7 @@ int tscProcessRetrieveGlobalMergeRsp(SSqlObj *pSql) {
bool convertJson = true; bool convertJson = true;
if (pQueryInfo->isStddev == true) convertJson = false; if (pQueryInfo->isStddev == true) convertJson = false;
convertQueryResult(pRes, pQueryInfo, pSql->self, true, convertJson); convertQueryResult(pRes, pQueryInfo, pSql->self, true, convertJson);
pRes->code = pQueryInfo->pQInfo->code;
code = pRes->code; code = pRes->code;
if (pRes->code == TSDB_CODE_SUCCESS) { if (pRes->code == TSDB_CODE_SUCCESS) {
......
...@@ -173,6 +173,7 @@ typedef void *TsdbQueryHandleT; // Use void to hide implementation details ...@@ -173,6 +173,7 @@ typedef void *TsdbQueryHandleT; // Use void to hide implementation details
typedef struct STsdbQueryCond { typedef struct STsdbQueryCond {
STimeWindow twindow; STimeWindow twindow;
int32_t order; // desc|asc order to iterate the data block int32_t order; // desc|asc order to iterate the data block
int64_t offset; // skip offset put down to tsdb
int32_t numOfCols; int32_t numOfCols;
SColumnInfo *colList; SColumnInfo *colList;
bool loadExternalRows; // load external rows or not bool loadExternalRows; // load external rows or not
...@@ -391,6 +392,9 @@ void tsdbResetQueryHandleForNewTable(TsdbQueryHandleT queryHandle, STsdbQueryCon ...@@ -391,6 +392,9 @@ void tsdbResetQueryHandleForNewTable(TsdbQueryHandleT queryHandle, STsdbQueryCon
int32_t tsdbGetFileBlocksDistInfo(TsdbQueryHandleT* queryHandle, STableBlockDist* pTableBlockInfo); int32_t tsdbGetFileBlocksDistInfo(TsdbQueryHandleT* queryHandle, STableBlockDist* pTableBlockInfo);
// obtain queryHandle attribute
int64_t tsdbSkipOffset(TsdbQueryHandleT queryHandle);
/** /**
* get the statistics of repo usage * get the statistics of repo usage
* @param repo. point to the tsdbrepo * @param repo. point to the tsdbrepo
......
Subproject commit dd78bfff5549c08153798719c1707ab441b5f4ab Subproject commit 59f00a69f36b08cea86a70a22c29b2c27ef506ae
...@@ -171,7 +171,6 @@ static void monSaveSystemInfo(); ...@@ -171,7 +171,6 @@ static void monSaveSystemInfo();
static void monSaveClusterInfo(); static void monSaveClusterInfo();
static void monSaveDnodesInfo(); static void monSaveDnodesInfo();
static void monSaveVgroupsInfo(); static void monSaveVgroupsInfo();
static void monSaveSlowQueryInfo();
static void monSaveDisksInfo(); static void monSaveDisksInfo();
static void monSaveGrantsInfo(); static void monSaveGrantsInfo();
static void monSaveHttpReqInfo(); static void monSaveHttpReqInfo();
...@@ -321,7 +320,6 @@ static void *monThreadFunc(void *param) { ...@@ -321,7 +320,6 @@ static void *monThreadFunc(void *param) {
monSaveClusterInfo(); monSaveClusterInfo();
} }
monSaveVgroupsInfo(); monSaveVgroupsInfo();
monSaveSlowQueryInfo();
monSaveDisksInfo(); monSaveDisksInfo();
monSaveGrantsInfo(); monSaveGrantsInfo();
monSaveHttpReqInfo(); monSaveHttpReqInfo();
...@@ -383,9 +381,9 @@ static void monBuildMonitorSql(char *sql, int32_t cmd) { ...@@ -383,9 +381,9 @@ static void monBuildMonitorSql(char *sql, int32_t cmd) {
tsMonitorDbName, TSDB_DEFAULT_USER); tsMonitorDbName, TSDB_DEFAULT_USER);
} else if (cmd == MON_CMD_CREATE_TB_SLOWQUERY) { } else if (cmd == MON_CMD_CREATE_TB_SLOWQUERY) {
snprintf(sql, SQL_LENGTH, snprintf(sql, SQL_LENGTH,
"create table if not exists %s.slowquery(ts timestamp, query_id " "create table if not exists %s.slowquery(ts timestamp, username "
"binary(%d), username binary(%d), qid binary(%d), created_time timestamp, time bigint, end_point binary(%d), sql binary(%d))", "binary(%d), created_time timestamp, time bigint, sql binary(%d))",
tsMonitorDbName, QUERY_ID_LEN, TSDB_TABLE_FNAME_LEN - 1, QUERY_ID_LEN, TSDB_EP_LEN, TSDB_SLOW_QUERY_SQL_LEN); tsMonitorDbName, TSDB_TABLE_FNAME_LEN - 1, TSDB_SLOW_QUERY_SQL_LEN);
} else if (cmd == MON_CMD_CREATE_TB_LOG) { } else if (cmd == MON_CMD_CREATE_TB_LOG) {
snprintf(sql, SQL_LENGTH, snprintf(sql, SQL_LENGTH,
"create table if not exists %s.log(ts timestamp, level tinyint, " "create table if not exists %s.log(ts timestamp, level tinyint, "
...@@ -1213,91 +1211,6 @@ static void monSaveVgroupsInfo() { ...@@ -1213,91 +1211,6 @@ static void monSaveVgroupsInfo() {
taos_free_result(result); taos_free_result(result);
} }
static void monSaveSlowQueryInfo() {
int64_t ts = taosGetTimestampUs();
char * sql = tsMonitor.sql;
int32_t pos = snprintf(sql, SQL_LENGTH, "insert into %s.slowquery values(%" PRId64, tsMonitorDbName, ts);
bool has_slowquery = false;
TAOS_RES *result = taos_query(tsMonitor.conn, "show queries");
int32_t code = taos_errno(result);
if (code != TSDB_CODE_SUCCESS) {
monError("failed to execute cmd: show queries, reason:%s", tstrerror(code));
}
TAOS_ROW row;
int32_t num_fields = taos_num_fields(result);
TAOS_FIELD *fields = taos_fetch_fields(result);
int32_t charLen;
while ((row = taos_fetch_row(result))) {
for (int i = 0; i < num_fields; ++i) {
if (strcmp(fields[i].name, "query_id") == 0) {
has_slowquery = true;
charLen = monGetRowElemCharLen(fields[i], (char *)row[i]);
if (charLen < 0) {
monError("failed to save slow_query info, reason: invalid row %s len, sql:%s", (char *)row[i], tsMonitor.sql);
goto DONE;
}
pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 1, ", "SQL_STR_FMT, (char *)row[i]);
} else if (strcmp(fields[i].name, "user") == 0) {
charLen = monGetRowElemCharLen(fields[i], (char *)row[i]);
if (charLen < 0) {
monError("failed to save slow_query info, reason: invalid row %s len, sql:%s", (char *)row[i], tsMonitor.sql);
goto DONE;
}
pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 1, ", "SQL_STR_FMT, (char *)row[i]);
} else if (strcmp(fields[i].name, "qid") == 0) {
charLen = monGetRowElemCharLen(fields[i], (char *)row[i]);
if (charLen < 0) {
monError("failed to save slow_query info, reason: invalid row %s len, sql:%s", (char *)row[i], tsMonitor.sql);
goto DONE;
}
pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 1, ", "SQL_STR_FMT, (char *)row[i]);
} else if (strcmp(fields[i].name, "created_time") == 0) {
int64_t create_time = *(int64_t *)row[i];
create_time = convertTimePrecision(create_time, TSDB_TIME_PRECISION_MILLI, TSDB_TIME_PRECISION_MICRO);
pos += snprintf(sql + pos, SQL_LENGTH, ", %" PRId64 "", create_time);
} else if (strcmp(fields[i].name, "time") == 0) {
pos += snprintf(sql + pos, SQL_LENGTH, ", %" PRId64 "", *(int64_t *)row[i]);
} else if (strcmp(fields[i].name, "ep") == 0) {
charLen = monGetRowElemCharLen(fields[i], (char *)row[i]);
if (charLen < 0) {
monError("failed to save slow_query info, reason: invalid row %s len, sql:%s", (char *)row[i], tsMonitor.sql);
goto DONE;
}
pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 1, ", "SQL_STR_FMT, (char *)row[i]);
} else if (strcmp(fields[i].name, "sql") == 0) {
charLen = monGetRowElemCharLen(fields[i], (char *)row[i]);
if (charLen < 0) {
monError("failed to save slow_query info, reason: invalid row %s len, sql:%s", (char *)row[i], tsMonitor.sql);
goto DONE;
}
pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 2, ", "SQL_STR_FMT")", (char *)row[i]);
}
}
}
monDebug("save slow query, sql:%s", sql);
if (!has_slowquery) {
goto DONE;
}
void *res = taos_query(tsMonitor.conn, tsMonitor.sql);
code = taos_errno(res);
taos_free_result(res);
if (code != 0) {
monError("failed to save slowquery info, reason:%s, sql:%s", tstrerror(code), tsMonitor.sql);
} else {
monIncSubmitReqCnt();
monDebug("successfully to save slowquery info, sql:%s", tsMonitor.sql);
}
DONE:
taos_free_result(result);
return;
}
static void monSaveDisksInfo() { static void monSaveDisksInfo() {
int64_t ts = taosGetTimestampUs(); int64_t ts = taosGetTimestampUs();
char * sql = tsMonitor.sql; char * sql = tsMonitor.sql;
......
...@@ -237,6 +237,7 @@ typedef struct SQueryAttr { ...@@ -237,6 +237,7 @@ typedef struct SQueryAttr {
bool createFilterOperator; // if filter operator is needed bool createFilterOperator; // if filter operator is needed
bool multigroupResult; // multigroup result can exist in one SSDataBlock bool multigroupResult; // multigroup result can exist in one SSDataBlock
bool needSort; // need sort rowRes bool needSort; // need sort rowRes
bool skipOffset; // can skip offset if true
int32_t interBufSize; // intermediate buffer sizse int32_t interBufSize; // intermediate buffer sizse
int32_t havingNum; // having expr number int32_t havingNum; // having expr number
...@@ -659,7 +660,7 @@ void* doDestroyFilterInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFil ...@@ -659,7 +660,7 @@ void* doDestroyFilterInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFil
void setInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order); void setInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order);
int32_t getNumOfResult(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx* pCtx, int32_t numOfOutput); int32_t getNumOfResult(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx* pCtx, int32_t numOfOutput);
void finalizeQueryResult(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset); void finalizeQueryResult(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset);
void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOfInputRows); void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOfInputRows, SQueryRuntimeEnv* runtimeEnv);
void clearOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity); void clearOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity);
void copyTsColoum(SSDataBlock* pRes, SQLFunctionCtx* pCtx, int32_t numOfOutput); void copyTsColoum(SSDataBlock* pRes, SQLFunctionCtx* pCtx, int32_t numOfOutput);
......
...@@ -1432,7 +1432,7 @@ static void doWindowBorderInterpolation(SOperatorInfo* pOperatorInfo, SSDataBloc ...@@ -1432,7 +1432,7 @@ static void doWindowBorderInterpolation(SOperatorInfo* pOperatorInfo, SSDataBloc
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order); int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order);
if (pBlock->pDataBlock == NULL){ if (pBlock->pDataBlock == NULL){
tscError("pBlock->pDataBlock == NULL"); qError("window border interpolation: pBlock->pDataBlock == NULL");
return; return;
} }
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, 0); SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, 0);
...@@ -3586,7 +3586,7 @@ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, i ...@@ -3586,7 +3586,7 @@ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, i
initCtxOutputBuffer(pCtx, pDataBlock->info.numOfCols); initCtxOutputBuffer(pCtx, pDataBlock->info.numOfCols);
} }
void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOfInputRows) { void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOfInputRows, SQueryRuntimeEnv* runtimeEnv) {
SSDataBlock* pDataBlock = pBInfo->pRes; SSDataBlock* pDataBlock = pBInfo->pRes;
int32_t newSize = pDataBlock->info.rows + numOfInputRows + 5; // extra output buffer int32_t newSize = pDataBlock->info.rows + numOfInputRows + 5; // extra output buffer
...@@ -3594,7 +3594,7 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOf ...@@ -3594,7 +3594,7 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOf
for(int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) { for(int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) {
SColumnInfoData *pColInfo = taosArrayGet(pDataBlock->pDataBlock, i); SColumnInfoData *pColInfo = taosArrayGet(pDataBlock->pDataBlock, i);
char* p = realloc(pColInfo->pData, newSize * pColInfo->info.bytes); char* p = realloc(pColInfo->pData, ((size_t)newSize) * pColInfo->info.bytes);
if (p != NULL) { if (p != NULL) {
pColInfo->pData = p; pColInfo->pData = p;
...@@ -3602,7 +3602,10 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOf ...@@ -3602,7 +3602,10 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOf
pBInfo->pCtx[i].pOutput = pColInfo->pData; pBInfo->pCtx[i].pOutput = pColInfo->pData;
(*bufCapacity) = newSize; (*bufCapacity) = newSize;
} else { } else {
// longjmp size_t allocateSize = ((size_t)(newSize)) * pColInfo->info.bytes;
qError("can not allocate %zu bytes for output. Rows: %d, colBytes %d",
allocateSize, newSize, pColInfo->info.bytes);
longjmp(runtimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
} }
} }
...@@ -3610,7 +3613,7 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOf ...@@ -3610,7 +3613,7 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOf
for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) { for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) {
SColumnInfoData *pColInfo = taosArrayGet(pDataBlock->pDataBlock, i); SColumnInfoData *pColInfo = taosArrayGet(pDataBlock->pDataBlock, i);
pBInfo->pCtx[i].pOutput = pColInfo->pData + pColInfo->info.bytes * pDataBlock->info.rows; pBInfo->pCtx[i].pOutput = pColInfo->pData + (size_t)pColInfo->info.bytes * pDataBlock->info.rows;
// set the correct pointer after the memory buffer reallocated. // set the correct pointer after the memory buffer reallocated.
int32_t functionId = pBInfo->pCtx[i].functionId; int32_t functionId = pBInfo->pCtx[i].functionId;
...@@ -4902,6 +4905,11 @@ STsdbQueryCond createTsdbQueryCond(SQueryAttr* pQueryAttr, STimeWindow* win) { ...@@ -4902,6 +4905,11 @@ STsdbQueryCond createTsdbQueryCond(SQueryAttr* pQueryAttr, STimeWindow* win) {
.loadExternalRows = false, .loadExternalRows = false,
}; };
// set offset with
if(pQueryAttr->skipOffset) {
cond.offset = pQueryAttr->limit.offset;
}
TIME_WINDOW_COPY(cond.twindow, *win); TIME_WINDOW_COPY(cond.twindow, *win);
return cond; return cond;
} }
...@@ -5767,7 +5775,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) { ...@@ -5767,7 +5775,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) {
// the pDataBlock are always the same one, no need to call this again // the pDataBlock are always the same one, no need to call this again
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order);
updateOutputBuf(&pProjectInfo->binfo, &pProjectInfo->bufCapacity, pBlock->info.rows); updateOutputBuf(&pProjectInfo->binfo, &pProjectInfo->bufCapacity, pBlock->info.rows, pOperator->pRuntimeEnv);
projectApplyFunctions(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput); projectApplyFunctions(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput);
if (pTableQueryInfo != NULL) { if (pTableQueryInfo != NULL) {
...@@ -5833,7 +5841,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) { ...@@ -5833,7 +5841,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) {
// the pDataBlock are always the same one, no need to call this again // the pDataBlock are always the same one, no need to call this again
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order);
updateOutputBuf(&pProjectInfo->binfo, &pProjectInfo->bufCapacity, pBlock->info.rows); updateOutputBuf(&pProjectInfo->binfo, &pProjectInfo->bufCapacity, pBlock->info.rows, pOperator->pRuntimeEnv);
projectApplyFunctions(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput); projectApplyFunctions(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput);
if (pTableQueryInfo != NULL) { if (pTableQueryInfo != NULL) {
...@@ -5870,19 +5878,38 @@ static SSDataBlock* doLimit(void* param, bool* newgroup) { ...@@ -5870,19 +5878,38 @@ static SSDataBlock* doLimit(void* param, bool* newgroup) {
return NULL; return NULL;
} }
bool move = false;
int32_t skip = 0;
int32_t remain = 0;
int64_t srows = tsdbSkipOffset(pRuntimeEnv->pQueryHandle);
if (pRuntimeEnv->currentOffset == 0) { if (pRuntimeEnv->currentOffset == 0) {
break; break;
}
else if(srows > 0) {
if(pRuntimeEnv->currentOffset - srows >= pBlock->info.rows) {
pRuntimeEnv->currentOffset -= pBlock->info.rows;
} else {
move = true;
skip = (int32_t)(pRuntimeEnv->currentOffset - srows);
remain = (int32_t)(pBlock->info.rows - skip);
}
} else if (pRuntimeEnv->currentOffset >= pBlock->info.rows) { } else if (pRuntimeEnv->currentOffset >= pBlock->info.rows) {
pRuntimeEnv->currentOffset -= pBlock->info.rows; pRuntimeEnv->currentOffset -= pBlock->info.rows;
} else { } else {
int32_t remain = (int32_t)(pBlock->info.rows - pRuntimeEnv->currentOffset); move = true;
pBlock->info.rows = remain; skip = (int32_t)pRuntimeEnv->currentOffset;
remain = (int32_t)(pBlock->info.rows - pRuntimeEnv->currentOffset);
}
// need move
if(move) {
pBlock->info.rows = remain;
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) { for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i); SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
int16_t bytes = pColInfoData->info.bytes; int16_t bytes = pColInfoData->info.bytes;
memmove(pColInfoData->pData, pColInfoData->pData + bytes * pRuntimeEnv->currentOffset, remain * bytes); memmove(pColInfoData->pData, pColInfoData->pData + skip * bytes, remain * bytes);
} }
pRuntimeEnv->currentOffset = 0; pRuntimeEnv->currentOffset = 0;
...@@ -6330,7 +6357,7 @@ static void doTimeEveryImpl(SOperatorInfo* pOperator, SQLFunctionCtx *pCtx, SSDa ...@@ -6330,7 +6357,7 @@ static void doTimeEveryImpl(SOperatorInfo* pOperator, SQLFunctionCtx *pCtx, SSDa
break; break;
} }
updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, 0); updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, 0, pOperator->pRuntimeEnv);
} }
} }
} }
...@@ -6350,7 +6377,7 @@ static SSDataBlock* doTimeEvery(void* param, bool* newgroup) { ...@@ -6350,7 +6377,7 @@ static SSDataBlock* doTimeEvery(void* param, bool* newgroup) {
pRes->info.rows = 0; pRes->info.rows = 0;
if (!pEveryInfo->groupDone) { if (!pEveryInfo->groupDone) {
updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, 0); updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, 0, pOperator->pRuntimeEnv);
doTimeEveryImpl(pOperator, pInfo->pCtx, pEveryInfo->lastBlock, false); doTimeEveryImpl(pOperator, pInfo->pCtx, pEveryInfo->lastBlock, false);
if (pRes->info.rows >= pRuntimeEnv->resultInfo.threshold) { if (pRes->info.rows >= pRuntimeEnv->resultInfo.threshold) {
copyTsColoum(pRes, pInfo->pCtx, pOperator->numOfOutput); copyTsColoum(pRes, pInfo->pCtx, pOperator->numOfOutput);
...@@ -6386,7 +6413,7 @@ static SSDataBlock* doTimeEvery(void* param, bool* newgroup) { ...@@ -6386,7 +6413,7 @@ static SSDataBlock* doTimeEvery(void* param, bool* newgroup) {
// the pDataBlock are always the same one, no need to call this again // the pDataBlock are always the same one, no need to call this again
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order);
updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, pBlock->info.rows); updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, pBlock->info.rows, pOperator->pRuntimeEnv);
doTimeEveryImpl(pOperator, pInfo->pCtx, pBlock, *newgroup); doTimeEveryImpl(pOperator, pInfo->pCtx, pBlock, *newgroup);
if (pEveryInfo->groupDone && pOperator->upstream[0]->notify) { if (pEveryInfo->groupDone && pOperator->upstream[0]->notify) {
...@@ -6412,7 +6439,7 @@ static SSDataBlock* doTimeEvery(void* param, bool* newgroup) { ...@@ -6412,7 +6439,7 @@ static SSDataBlock* doTimeEvery(void* param, bool* newgroup) {
if (!pEveryInfo->groupDone) { if (!pEveryInfo->groupDone) {
pEveryInfo->allDone = true; pEveryInfo->allDone = true;
updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, 0); updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, 0, pOperator->pRuntimeEnv);
doTimeEveryImpl(pOperator, pInfo->pCtx, NULL, false); doTimeEveryImpl(pOperator, pInfo->pCtx, NULL, false);
if (pRes->info.rows >= pRuntimeEnv->resultInfo.threshold) { if (pRes->info.rows >= pRuntimeEnv->resultInfo.threshold) {
break; break;
...@@ -6433,7 +6460,7 @@ static SSDataBlock* doTimeEvery(void* param, bool* newgroup) { ...@@ -6433,7 +6460,7 @@ static SSDataBlock* doTimeEvery(void* param, bool* newgroup) {
// Return result of the previous group in the firstly. // Return result of the previous group in the firstly.
if (*newgroup) { if (*newgroup) {
if (!pEveryInfo->groupDone) { if (!pEveryInfo->groupDone) {
updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, 0); updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, 0, pOperator->pRuntimeEnv);
doTimeEveryImpl(pOperator, pInfo->pCtx, NULL, false); doTimeEveryImpl(pOperator, pInfo->pCtx, NULL, false);
if (pRes->info.rows >= pRuntimeEnv->resultInfo.threshold) { if (pRes->info.rows >= pRuntimeEnv->resultInfo.threshold) {
pEveryInfo->existDataBlock = pBlock; pEveryInfo->existDataBlock = pBlock;
...@@ -6469,7 +6496,7 @@ static SSDataBlock* doTimeEvery(void* param, bool* newgroup) { ...@@ -6469,7 +6496,7 @@ static SSDataBlock* doTimeEvery(void* param, bool* newgroup) {
// the pDataBlock are always the same one, no need to call this again // the pDataBlock are always the same one, no need to call this again
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order);
updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, pBlock->info.rows); updateOutputBuf(&pEveryInfo->binfo, &pEveryInfo->bufCapacity, pBlock->info.rows, pOperator->pRuntimeEnv);
pEveryInfo->groupDone = false; pEveryInfo->groupDone = false;
...@@ -8957,6 +8984,14 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S ...@@ -8957,6 +8984,14 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S
doUpdateExprColumnIndex(pQueryAttr); doUpdateExprColumnIndex(pQueryAttr);
// calc skipOffset
if(pQueryMsg->offset > 0 && TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_PROJECTION_QUERY)) {
if(pQueryAttr->stableQuery)
pQueryAttr->skipOffset = false;
else
pQueryAttr->skipOffset = pQueryAttr->pFilters == NULL;
}
if (pSecExprs != NULL) { if (pSecExprs != NULL) {
int32_t resultRowSize = 0; int32_t resultRowSize = 0;
......
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
.tid = (_checkInfo)->tableId.tid, \ .tid = (_checkInfo)->tableId.tid, \
.uid = (_checkInfo)->tableId.uid}) .uid = (_checkInfo)->tableId.uid})
// limit offset start optimization for rows read over this value
#define OFFSET_SKIP_THRESHOLD 5000
enum { enum {
TSDB_QUERY_TYPE_ALL = 1, TSDB_QUERY_TYPE_ALL = 1,
TSDB_QUERY_TYPE_LAST = 2, TSDB_QUERY_TYPE_LAST = 2,
...@@ -117,6 +120,9 @@ typedef struct STsdbQueryHandle { ...@@ -117,6 +120,9 @@ typedef struct STsdbQueryHandle {
STsdbRepo* pTsdb; STsdbRepo* pTsdb;
SQueryFilePos cur; // current position SQueryFilePos cur; // current position
int16_t order; int16_t order;
int64_t offset; // limit offset
int64_t srows; // skip offset rows
int64_t frows; // forbid skip offset rows
STimeWindow window; // the primary query time window that applies to all queries STimeWindow window; // the primary query time window that applies to all queries
SDataStatis* statis; // query level statistics, only one table block statistics info exists at any time SDataStatis* statis; // query level statistics, only one table block statistics info exists at any time
int32_t numOfBlocks; int32_t numOfBlocks;
...@@ -155,6 +161,11 @@ typedef struct STableGroupSupporter { ...@@ -155,6 +161,11 @@ typedef struct STableGroupSupporter {
STSchema* pTagSchema; STSchema* pTagSchema;
} STableGroupSupporter; } STableGroupSupporter;
typedef struct SRange {
int32_t from;
int32_t to;
} SRange;
static STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList); static STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList);
static int32_t checkForCachedLastRow(STsdbQueryHandle* pQueryHandle, STableGroupInfo *groupList); static int32_t checkForCachedLastRow(STsdbQueryHandle* pQueryHandle, STableGroupInfo *groupList);
static int32_t checkForCachedLast(STsdbQueryHandle* pQueryHandle); static int32_t checkForCachedLast(STsdbQueryHandle* pQueryHandle);
...@@ -413,6 +424,9 @@ static STsdbQueryHandle* tsdbQueryTablesImpl(STsdbRepo* tsdb, STsdbQueryCond* pC ...@@ -413,6 +424,9 @@ static STsdbQueryHandle* tsdbQueryTablesImpl(STsdbRepo* tsdb, STsdbQueryCond* pC
} }
pQueryHandle->order = pCond->order; pQueryHandle->order = pCond->order;
pQueryHandle->offset = pCond->offset;
pQueryHandle->srows = 0;
pQueryHandle->frows = 0;
pQueryHandle->pTsdb = tsdb; pQueryHandle->pTsdb = tsdb;
pQueryHandle->type = TSDB_QUERY_TYPE_ALL; pQueryHandle->type = TSDB_QUERY_TYPE_ALL;
pQueryHandle->cur.fid = INT32_MIN; pQueryHandle->cur.fid = INT32_MIN;
...@@ -529,6 +543,9 @@ void tsdbResetQueryHandle(TsdbQueryHandleT queryHandle, STsdbQueryCond *pCond) { ...@@ -529,6 +543,9 @@ void tsdbResetQueryHandle(TsdbQueryHandleT queryHandle, STsdbQueryCond *pCond) {
} }
pQueryHandle->order = pCond->order; pQueryHandle->order = pCond->order;
pQueryHandle->offset = pCond->offset;
pQueryHandle->srows = 0;
pQueryHandle->frows = 0;
pQueryHandle->window = pCond->twindow; pQueryHandle->window = pCond->twindow;
pQueryHandle->type = TSDB_QUERY_TYPE_ALL; pQueryHandle->type = TSDB_QUERY_TYPE_ALL;
pQueryHandle->cur.fid = -1; pQueryHandle->cur.fid = -1;
...@@ -1073,63 +1090,302 @@ static int32_t binarySearchForBlock(SBlock* pBlock, int32_t numOfBlocks, TSKEY s ...@@ -1073,63 +1090,302 @@ static int32_t binarySearchForBlock(SBlock* pBlock, int32_t numOfBlocks, TSKEY s
return midSlot; return midSlot;
} }
static int32_t loadBlockInfo(STsdbQueryHandle * pQueryHandle, int32_t index, int32_t* numOfBlocks) { // array :1 2 3 5 7 -2 (8 9) skip 4 and 6
int32_t code = 0; int32_t memMoveByArray(SBlock *blocks, SArray *pArray) {
// pArray is NULL or size is zero , no need block to move
if(pArray == NULL)
return 0;
size_t count = taosArrayGetSize(pArray);
if(count == 0)
return 0;
STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, index); // memmove
pCheckInfo->numOfBlocks = 0; int32_t num = 0;
SRange* ranges = (SRange*)TARRAY_GET_START(pArray);
for(size_t i = 0; i < count; i++) {
int32_t step = ranges[i].to - ranges[i].from + 1;
memmove(blocks + num, blocks + ranges[i].from, sizeof(SBlock) * step);
num += step;
}
if (tsdbSetReadTable(&pQueryHandle->rhelper, pCheckInfo->pTableObj) != TSDB_CODE_SUCCESS) { return num;
code = terrno; }
return code;
// if block data in memory return false else true
bool blockNoItemInMem(STsdbQueryHandle* q, SBlock* pBlock) {
if(q->pMemRef == NULL) {
return false;
} }
SBlockIdx* compIndex = pQueryHandle->rhelper.pBlkIdx; // mem
if(q->pMemRef->snapshot.mem) {
SMemTable* mem = q->pMemRef->snapshot.mem;
if(timeIntersect(mem->keyFirst, mem->keyLast, pBlock->keyFirst, pBlock->keyLast))
return false;
}
// imem
if(q->pMemRef->snapshot.imem) {
SMemTable* imem = q->pMemRef->snapshot.imem;
if(timeIntersect(imem->keyFirst, imem->keyLast, pBlock->keyFirst, pBlock->keyLast))
return false;
}
// no data block in this file, try next file return true;
if (compIndex == NULL || compIndex->uid != pCheckInfo->tableId.uid) { }
return 0; // no data blocks in the file belongs to pCheckInfo->pTable
#define MAYBE_IN_MEMORY_ROWS 4000 // approximately the capacity of one block
// skip blocks . return value is skip blocks number, skip rows reduce from *pOffset
static int32_t offsetSkipBlock(STsdbQueryHandle* q, SBlockInfo* pBlockInfo, int64_t skey, int64_t ekey,
int32_t sblock, int32_t eblock, SArray** ppArray, bool order) {
int32_t num = 0;
SBlock* blocks = pBlockInfo->blocks;
SArray* pArray = NULL;
SRange range;
range.from = -1;
//
// ASC
//
if(order) {
for(int32_t i = sblock; i < eblock; i++) {
bool skip = false;
SBlock* pBlock = &blocks[i];
if(i == sblock && skey > pBlock->keyFirst) {
q->frows += pBlock->numOfRows; // some rows time < s
} else {
// check can skip
if(q->srows + q->frows + pBlock->numOfRows + MAYBE_IN_MEMORY_ROWS < q->offset) { // approximately calculate
if(blockNoItemInMem(q, pBlock)) {
// can skip
q->srows += pBlock->numOfRows;
skip = true;
} else {
q->frows += pBlock->numOfRows; // maybe have some row in memroy
}
} else {
// the remainder be put to pArray
if(pArray == NULL)
pArray = taosArrayInit(1, sizeof(SRange));
if(range.from == -1) {
range.from = i;
} else {
if(range.to + 1 != i) {
// add the previous
taosArrayPush(pArray, &range);
range.from = i;
}
}
range.to = eblock - 1;
taosArrayPush(pArray, &range);
range.from = -1;
break;
}
} }
assert(compIndex->len > 0); if(skip) {
num ++;
} else {
// can't skip, append block index to pArray
if(pArray == NULL)
pArray = taosArrayInit(10, sizeof(SRange));
if(range.from == -1) {
range.from = i;
} else {
if(range.to + 1 != i) {
// add the previous
taosArrayPush(pArray, &range);
range.from = i;
}
}
range.to = i;
}
}
// end append
if(range.from != -1) {
if(pArray == NULL)
pArray = taosArrayInit(1, sizeof(SRange));
taosArrayPush(pArray, &range);
}
if (tsdbLoadBlockInfo(&(pQueryHandle->rhelper), (void**)(&pCheckInfo->pCompInfo), // ASC return
(uint32_t*)(&pCheckInfo->compSize)) < 0) { *ppArray = pArray;
return terrno; return num;
} }
SBlockInfo* pCompInfo = pCheckInfo->pCompInfo;
TSKEY s = TSKEY_INITIAL_VAL, e = TSKEY_INITIAL_VAL; // DES
for(int32_t i = eblock - 1; i >= sblock; i--) {
bool skip = false;
SBlock* pBlock = &blocks[i];
if(i == eblock - 1 && ekey < pBlock->keyLast) {
q->frows += pBlock->numOfRows; // some rows time > e
} else {
// check can skip
if(q->srows + q->frows + pBlock->numOfRows + MAYBE_IN_MEMORY_ROWS < q->offset) { // approximately calculate
if(blockNoItemInMem(q, pBlock)) {
// can skip
q->srows += pBlock->numOfRows;
skip = true;
} else {
q->frows += pBlock->numOfRows; // maybe have some row in memroy
}
} else {
// the remainder be put to pArray
if(pArray == NULL)
pArray = taosArrayInit(1, sizeof(SRange));
if(range.from == -1) {
range.from = i;
} else {
if(range.to - 1 != i) {
// add the previous
taosArrayPush(pArray, &range);
range.from = i;
}
}
range.to = 0;
taosArrayPush(pArray, &range);
range.from = -1;
break;
}
}
if (ASCENDING_TRAVERSE(pQueryHandle->order)) { if(skip) {
num ++;
} else {
// can't skip, append block index to pArray
if(pArray == NULL)
pArray = taosArrayInit(10, sizeof(SRange));
if(range.from == -1) {
range.from = i;
} else {
if(range.to + 1 != i) {
// add the previous
taosArrayPush(pArray, &range);
range.from = i;
}
}
range.to = i;
}
}
// end append
if(range.from != -1) {
if(pArray == NULL)
pArray = taosArrayInit(1, sizeof(SRange));
taosArrayPush(pArray, &range);
}
if(pArray == NULL)
return num;
// reverse array
size_t count = taosArrayGetSize(pArray);
SRange* ranges = TARRAY_GET_START(pArray);
SArray* pArray1 = taosArrayInit(count, sizeof(SRange));
size_t i = count - 1;
while(i >= 0) {
range.from = ranges[i].to;
range.to = ranges[i].from;
taosArrayPush(pArray1, &range);
if(i == 0)
break;
i --;
}
*ppArray = pArray1;
taosArrayDestroy(&pArray);
return num;
}
// shrink blocks by condition of query
static void shrinkBlocksByQuery(STsdbQueryHandle *pQueryHandle, STableCheckInfo *pCheckInfo) {
SBlockInfo *pCompInfo = pCheckInfo->pCompInfo;
SBlockIdx *compIndex = pQueryHandle->rhelper.pBlkIdx;
bool order = ASCENDING_TRAVERSE(pQueryHandle->order);
if (order) {
assert(pCheckInfo->lastKey <= pQueryHandle->window.ekey && pQueryHandle->window.skey <= pQueryHandle->window.ekey); assert(pCheckInfo->lastKey <= pQueryHandle->window.ekey && pQueryHandle->window.skey <= pQueryHandle->window.ekey);
} else { } else {
assert(pCheckInfo->lastKey >= pQueryHandle->window.ekey && pQueryHandle->window.skey >= pQueryHandle->window.ekey); assert(pCheckInfo->lastKey >= pQueryHandle->window.ekey && pQueryHandle->window.skey >= pQueryHandle->window.ekey);
} }
TSKEY s = TSKEY_INITIAL_VAL, e = TSKEY_INITIAL_VAL;
s = MIN(pCheckInfo->lastKey, pQueryHandle->window.ekey); s = MIN(pCheckInfo->lastKey, pQueryHandle->window.ekey);
e = MAX(pCheckInfo->lastKey, pQueryHandle->window.ekey); e = MAX(pCheckInfo->lastKey, pQueryHandle->window.ekey);
// discard the unqualified data block based on the query time window // discard the unqualified data block based on the query time window
int32_t start = binarySearchForBlock(pCompInfo->blocks, compIndex->numOfBlocks, s, TSDB_ORDER_ASC); int32_t start = binarySearchForBlock(pCompInfo->blocks, compIndex->numOfBlocks, s, TSDB_ORDER_ASC);
int32_t end = start;
if (s > pCompInfo->blocks[start].keyLast) { if (s > pCompInfo->blocks[start].keyLast) {
return 0; return ;
} }
// todo speedup the procedure of located end block int32_t end = start;
// locate e index of blocks -> end
while (end < (int32_t)compIndex->numOfBlocks && (pCompInfo->blocks[end].keyFirst <= e)) { while (end < (int32_t)compIndex->numOfBlocks && (pCompInfo->blocks[end].keyFirst <= e)) {
end += 1; end += 1;
} }
pCheckInfo->numOfBlocks = (end - start); // calc offset can skip blocks number
int32_t nSkip = 0;
SArray *pArray = NULL;
if(pQueryHandle->offset > 0) {
nSkip = offsetSkipBlock(pQueryHandle, pCompInfo, s, e, start, end, &pArray, order);
}
if (start > 0) { if(nSkip > 0) { // have offset and can skip
pCheckInfo->numOfBlocks = memMoveByArray(pCompInfo->blocks, pArray);
} else { // no offset
pCheckInfo->numOfBlocks = end - start;
if(start > 0)
memmove(pCompInfo->blocks, &pCompInfo->blocks[start], pCheckInfo->numOfBlocks * sizeof(SBlock)); memmove(pCompInfo->blocks, &pCompInfo->blocks[start], pCheckInfo->numOfBlocks * sizeof(SBlock));
} }
if(pArray)
taosArrayDestroy(&pArray);
}
// load one table (tsd_index point to) need load blocks info and put into pCheckInfo->pCompInfo->blocks
static int32_t loadBlockInfo(STsdbQueryHandle * pQueryHandle, int32_t tsd_index, int32_t* numOfBlocks) {
//
// ONE PART. Load all blocks info from one table of tsd_index
//
int32_t code = 0;
STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, tsd_index);
pCheckInfo->numOfBlocks = 0;
if (tsdbSetReadTable(&pQueryHandle->rhelper, pCheckInfo->pTableObj) != TSDB_CODE_SUCCESS) {
code = terrno;
return code;
}
SBlockIdx* compIndex = pQueryHandle->rhelper.pBlkIdx;
// no data block in this file, try next file
if (compIndex == NULL || compIndex->uid != pCheckInfo->tableId.uid) {
return 0; // no data blocks in the file belongs to pCheckInfo->pTable
}
if (pCheckInfo->compSize < (int32_t)compIndex->len) {
assert(compIndex->len > 0);
char* t = realloc(pCheckInfo->pCompInfo, compIndex->len);
if (t == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
code = TSDB_CODE_TDB_OUT_OF_MEMORY;
return code;
}
pCheckInfo->pCompInfo = (SBlockInfo*)t;
pCheckInfo->compSize = compIndex->len;
}
if (tsdbLoadBlockInfo(&(pQueryHandle->rhelper), (void**)(&pCheckInfo->pCompInfo),
(uint32_t*)(&pCheckInfo->compSize)) < 0) {
return terrno;
}
//
// TWO PART. shrink no need blocks from all blocks by condition of query
//
shrinkBlocksByQuery(pQueryHandle, pCheckInfo);
(*numOfBlocks) += pCheckInfo->numOfBlocks; (*numOfBlocks) += pCheckInfo->numOfBlocks;
return 0; return 0;
} }
...@@ -4312,4 +4568,11 @@ end: ...@@ -4312,4 +4568,11 @@ end:
return string; return string;
} }
// obtain queryHandle attribute
int64_t tsdbSkipOffset(TsdbQueryHandleT queryHandle) {
STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*)queryHandle;
if (pQueryHandle) {
return pQueryHandle->srows;
}
return 0;
}
\ No newline at end of file
...@@ -58,6 +58,13 @@ static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *tar ...@@ -58,6 +58,13 @@ static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *tar
memcpy(target, context.digest, TSDB_KEY_LEN); memcpy(target, context.digest, TSDB_KEY_LEN);
} }
//
// TSKEY util
//
// if time area(s1,e1) intersect with time area(s2,e2) then return true else return false
bool timeIntersect(TSKEY s1, TSKEY e1, TSKEY s2, TSKEY e2);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -549,3 +549,16 @@ FORCE_INLINE double taos_align_get_double(const char* pBuf) { ...@@ -549,3 +549,16 @@ FORCE_INLINE double taos_align_get_double(const char* pBuf) {
memcpy(&dv, pBuf, sizeof(dv)); // in ARM, return *((const double*)(pBuf)) may cause problem memcpy(&dv, pBuf, sizeof(dv)); // in ARM, return *((const double*)(pBuf)) may cause problem
return dv; return dv;
} }
//
// TSKEY util
//
// if time area(s1,e1) intersect with time area(s2,e2) then return true else return false
bool timeIntersect(TSKEY s1, TSKEY e1, TSKEY s2, TSKEY e2) {
// s1,e1 and s2,e2 have 7 scenarios, 5 is intersection, 2 is no intersection, so we pick up 2.
if(e2 < s1 || s2 > e1)
return false;
else
return true;
}
\ No newline at end of file
#!/bin/bash #!/bin/bash
ulimit -c unlimited ulimit -c unlimited
#======================p1-start=============== #======================p1-start===============
#python3 ./test.py -f dbmgmt/database-name-boundary.py #python3 ./test.py -f dbmgmt/database-name-boundary.py
python3 test.py -f dbmgmt/nanoSecondCheck.py python3 test.py -f dbmgmt/nanoSecondCheck.py
# #
python3 ./test.py -f tsdb/tsdbComp.py python3 ./test.py -f tsdb/tsdbComp.py
# user # user
python3 ./test.py -f user/user_create.py python3 ./test.py -f user/user_create.py
python3 ./test.py -f user/pass_len.py python3 ./test.py -f user/pass_len.py
#======================p1-end=============== #======================p1-end===============
#======================p2-start=============== #======================p2-start===============
# perfbenchmark # perfbenchmark
python3 ./test.py -f perfbenchmark/bug3433.py python3 ./test.py -f perfbenchmark/bug3433.py
#python3 ./test.py -f perfbenchmark/bug3589.py #python3 ./test.py -f perfbenchmark/bug3589.py
#python3 ./test.py -f perfbenchmark/taosdemoInsert.py #python3 ./test.py -f perfbenchmark/taosdemoInsert.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 python3 ./test.py -f alter/alterTimestampColDataProcess.py
#======================p2-end=============== #======================p2-end===============
#======================p3-start=============== #======================p3-start===============
python3 ./test.py -f alter/alter_table.py python3 ./test.py -f alter/alter_table.py
python3 ./test.py -f alter/alter_debugFlag.py python3 ./test.py -f alter/alter_debugFlag.py
python3 ./test.py -f alter/alter_keep.py python3 ./test.py -f alter/alter_keep.py
python3 ./test.py -f alter/alter_cacheLastRow.py python3 ./test.py -f alter/alter_cacheLastRow.py
python3 ./test.py -f alter/alter_create_exception.py python3 ./test.py -f alter/alter_create_exception.py
python3 ./test.py -f alter/alterColMultiTimes.py python3 ./test.py -f alter/alterColMultiTimes.py
#======================p3-end=============== #======================p3-end===============
#======================p4-start=============== #======================p4-start===============
python3 ./test.py -f account/account_create.py python3 ./test.py -f account/account_create.py
# client # client
python3 ./test.py -f client/client.py python3 ./test.py -f client/client.py
python3 ./test.py -f client/version.py python3 ./test.py -f client/version.py
...@@ -50,12 +39,10 @@ python3 ./test.py -f client/taoshellCheckCase.py ...@@ -50,12 +39,10 @@ python3 ./test.py -f client/taoshellCheckCase.py
# python3 ./test.py -f client/change_time_1_2.py # python3 ./test.py -f client/change_time_1_2.py
python3 client/twoClients.py python3 client/twoClients.py
python3 testMinTablesPerVnode.py python3 testMinTablesPerVnode.py
# topic # topic
python3 ./test.py -f topic/topicQuery.py python3 ./test.py -f topic/topicQuery.py
#======================p4-end=============== #======================p4-end===============
#======================p5-start=============== #======================p5-start===============
python3 ./test.py -f ../system-test/0-management/1-stable/create_col_tag.py python3 ./test.py -f ../system-test/0-management/1-stable/create_col_tag.py
python3 ./test.py -f ../develop-test/0-management/3-tag/json_tag.py python3 ./test.py -f ../develop-test/0-management/3-tag/json_tag.py
#======================p5-end=============== #======================p5-end===============
#!/bin/bash #!/bin/bash
ulimit -c unlimited ulimit -c unlimited
#======================p1-start=============== #======================p1-start===============
# timezone # timezone
python3 ./test.py -f TimeZone/TestCaseTimeZone.py python3 ./test.py -f TimeZone/TestCaseTimeZone.py
#stable #stable
python3 ./test.py -f stable/insert.py python3 ./test.py -f stable/insert.py
python3 ./test.py -f stable/query_after_reset.py python3 ./test.py -f stable/query_after_reset.py
#table #table
python3 ./test.py -f table/alter_wal0.py python3 ./test.py -f table/alter_wal0.py
python3 ./test.py -f table/column_name.py python3 ./test.py -f table/column_name.py
...@@ -22,7 +19,6 @@ python3 ./test.py -f table/boundary.py ...@@ -22,7 +19,6 @@ python3 ./test.py -f table/boundary.py
#python3 ./test.py -f table/create.py #python3 ./test.py -f table/create.py
python3 ./test.py -f table/del_stable.py python3 ./test.py -f table/del_stable.py
python3 ./test.py -f table/create_db_from_normal_db.py python3 ./test.py -f table/create_db_from_normal_db.py
# tag # tag
python3 ./test.py -f tag_lite/filter.py python3 ./test.py -f tag_lite/filter.py
python3 ./test.py -f tag_lite/create-tags-boundary.py python3 ./test.py -f tag_lite/create-tags-boundary.py
...@@ -38,10 +34,8 @@ python3 ./test.py -f tag_lite/bool_binary.py ...@@ -38,10 +34,8 @@ python3 ./test.py -f tag_lite/bool_binary.py
python3 ./test.py -f tag_lite/bool_int.py python3 ./test.py -f tag_lite/bool_int.py
python3 ./test.py -f tag_lite/bool.py python3 ./test.py -f tag_lite/bool.py
python3 ./test.py -f tag_lite/change.py python3 ./test.py -f tag_lite/change.py
#======================p1-end=============== #======================p1-end===============
#======================p2-start=============== #======================p2-start===============
python3 ./test.py -f tag_lite/column.py python3 ./test.py -f tag_lite/column.py
python3 ./test.py -f tag_lite/commit.py python3 ./test.py -f tag_lite/commit.py
python3 ./test.py -f tag_lite/create.py python3 ./test.py -f tag_lite/create.py
...@@ -65,10 +59,8 @@ python3 ./test.py -f tag_lite/unsignedTinyint.py ...@@ -65,10 +59,8 @@ python3 ./test.py -f tag_lite/unsignedTinyint.py
python3 ./test.py -f tag_lite/alter_tag.py python3 ./test.py -f tag_lite/alter_tag.py
python3 ./test.py -f tag_lite/drop_auto_create.py python3 ./test.py -f tag_lite/drop_auto_create.py
python3 ./test.py -f tag_lite/json_tag_extra.py python3 ./test.py -f tag_lite/json_tag_extra.py
#======================p2-end=============== #======================p2-end===============
#======================p3-start=============== #======================p3-start===============
#query #query
python3 ./test.py -f query/distinctOneColTb.py python3 ./test.py -f query/distinctOneColTb.py
python3 ./test.py -f query/filter.py python3 ./test.py -f query/filter.py
...@@ -118,10 +110,8 @@ python3 ./test.py -f query/subqueryFilter.py ...@@ -118,10 +110,8 @@ python3 ./test.py -f query/subqueryFilter.py
python3 ./test.py -f query/nestedQuery/queryInterval.py python3 ./test.py -f query/nestedQuery/queryInterval.py
python3 ./test.py -f query/queryStateWindow.py python3 ./test.py -f query/queryStateWindow.py
# python3 ./test.py -f query/nestedQuery/queryWithOrderLimit.py # python3 ./test.py -f query/nestedQuery/queryWithOrderLimit.py
#======================p3-end=============== #======================p3-end===============
#======================p4-start=============== #======================p4-start===============
python3 ./test.py -f query/nestquery_last_row.py python3 ./test.py -f query/nestquery_last_row.py
python3 ./test.py -f query/nestedQuery/nestedQuery.py python3 ./test.py -f query/nestedQuery/nestedQuery.py
python3 ./test.py -f query/nestedQuery/nestedQuery_datacheck.py python3 ./test.py -f query/nestedQuery/nestedQuery_datacheck.py
...@@ -145,7 +135,6 @@ python3 ./test.py -f query/query.py ...@@ -145,7 +135,6 @@ python3 ./test.py -f query/query.py
python3 ./test.py -f query/queryDiffColsTagsAndOr.py python3 ./test.py -f query/queryDiffColsTagsAndOr.py
python3 ./test.py -f query/queryGroupTbname.py python3 ./test.py -f query/queryGroupTbname.py
python3 ./test.py -f query/queryRegex.py python3 ./test.py -f query/queryRegex.py
#stream #stream
python3 ./test.py -f stream/metric_1.py python3 ./test.py -f stream/metric_1.py
python3 ./test.py -f stream/metric_n.py python3 ./test.py -f stream/metric_n.py
...@@ -159,18 +148,14 @@ python3 ./test.py -f stream/table_1.py ...@@ -159,18 +148,14 @@ python3 ./test.py -f stream/table_1.py
python3 ./test.py -f stream/table_n.py python3 ./test.py -f stream/table_n.py
python3 ./test.py -f stream/showStreamExecTimeisNull.py python3 ./test.py -f stream/showStreamExecTimeisNull.py
python3 ./test.py -f stream/cqSupportBefore1970.py python3 ./test.py -f stream/cqSupportBefore1970.py
python3 ./test.py -f query/queryGroupbyWithInterval.py python3 ./test.py -f query/queryGroupbyWithInterval.py
python3 queryCount.py python3 queryCount.py
# subscribe # subscribe
python3 test.py -f subscribe/singlemeter.py python3 test.py -f subscribe/singlemeter.py
#python3 test.py -f subscribe/stability.py #python3 test.py -f subscribe/stability.py
python3 test.py -f subscribe/supertable.py python3 test.py -f subscribe/supertable.py
#======================p4-end=============== #======================p4-end===============
#======================p5-start=============== #======================p5-start===============
# functions # functions
python3 ./test.py -f functions/all_null_value.py python3 ./test.py -f functions/all_null_value.py
python3 ./test.py -f functions/function_avg.py -r 1 python3 ./test.py -f functions/function_avg.py -r 1
...@@ -208,12 +193,6 @@ python3 ./test.py -f functions/function_mavg.py ...@@ -208,12 +193,6 @@ python3 ./test.py -f functions/function_mavg.py
python3 ./test.py -f functions/function_csum.py python3 ./test.py -f functions/function_csum.py
python3 ./test.py -f functions/function_percentile2.py python3 ./test.py -f functions/function_percentile2.py
python3 ./test.py -f functions/variable_httpDbNameMandatory.py python3 ./test.py -f functions/variable_httpDbNameMandatory.py
######## system-test ######## system-test
#python3 ./test.py -f ../system-test/2-query/9-others/TD-11389.py # this case will run when this bug fix TD-11389 #python3 ./test.py -f ../system-test/2-query/9-others/TD-11389.py # this case will run when this bug fix TD-11389
#======================p5-end=============== #======================p5-end===============
#!/bin/bash #!/bin/bash
ulimit -c unlimited ulimit -c unlimited
#======================p1-start=============== #======================p1-start===============
# tools # tools
python3 test.py -f tools/taosdumpTest.py python3 test.py -f tools/taosdumpTest.py
python3 test.py -f tools/taosdumpTest2.py python3 test.py -f tools/taosdumpTest2.py
python3 test.py -f tools/taosdemoTest.py python3 test.py -f tools/taosdemoTest.py
python3 test.py -f tools/taosdemoTestWithoutMetric.py python3 test.py -f tools/taosdemoTestWithoutMetric.py
python3 test.py -f tools/taosdemoTestWithJson.py python3 test.py -f tools/taosdemoTestWithJson.py
#======================p1-end=============== #======================p1-end===============
#======================p2-start=============== #======================p2-start===============
python3 test.py -f tools/taosdemoTestLimitOffset.py python3 test.py -f tools/taosdemoTestLimitOffset.py
python3 test.py -f tools/taosdemoTestTblAlt.py python3 test.py -f tools/taosdemoTestTblAlt.py
python3 test.py -f tools/taosdemoTestSampleData.py python3 test.py -f tools/taosdemoTestSampleData.py
...@@ -21,7 +17,6 @@ python3 test.py -f tools/taosdemoTestQuery.py ...@@ -21,7 +17,6 @@ python3 test.py -f tools/taosdemoTestQuery.py
python3 ./test.py -f tools/taosdemoTestdatatype.py python3 ./test.py -f tools/taosdemoTestdatatype.py
#======================p2-end=============== #======================p2-end===============
#======================p3-start=============== #======================p3-start===============
# nano support # nano support
python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py
python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py
...@@ -31,28 +26,14 @@ python3 test.py -f tools/taosdumpTestNanoSupport.py ...@@ -31,28 +26,14 @@ python3 test.py -f tools/taosdumpTestNanoSupport.py
python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJson.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJson.py
#======================p3-end=============== #======================p3-end===============
#======================p4-start=============== #======================p4-start===============
python3 test.py -f tools/taosdemoAllTest/taosdemoTestQueryWithJson.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestQueryWithJson.py
python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertAllType.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertAllType.py
python3 test.py -f tools/taosdemoAllTest/TD-4985/query-limit-offset.py python3 test.py -f tools/taosdemoAllTest/TD-4985/query-limit-offset.py
python3 test.py -f tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py python3 test.py -f tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py
python3 test.py -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py python3 test.py -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py
python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py
python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py
python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertShell.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertShell.py
#======================p4-end=============== #======================p4-end===============
#======================p5-start=============== #======================p5-start===============
#======================p5-end=============== #======================p5-end===============
...@@ -287,6 +287,7 @@ python3 ./test.py -f query/queryCnameDisplay.py ...@@ -287,6 +287,7 @@ python3 ./test.py -f query/queryCnameDisplay.py
python3 test.py -f query/nestedQuery/queryWithSpread.py python3 test.py -f query/nestedQuery/queryWithSpread.py
python3 ./test.py -f query/bug6586.py python3 ./test.py -f query/bug6586.py
# python3 ./test.py -f query/bug5903.py # python3 ./test.py -f query/bug5903.py
python3 ./test.py -f query/queryLimit.py
#stream #stream
python3 ./test.py -f stream/metric_1.py python3 ./test.py -f stream/metric_1.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 numpy.lib.function_base import insert
import taos
from util.log import *
from util.cases import *
from util.sql import *
import numpy as np
# constant define
WAITS = 5 # wait seconds
class TDTestCase:
#
# --------------- main frame -------------------
#
def caseDescription(self):
'''
limit and offset keyword function test cases;
case1: limit offset base function test
case2: limit offset advance test
'''
return
# init
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
tdSql.prepare()
self.create_tables();
self.ts = 1500000000000
# run case
def run(self):
# insert data
self.insert_data("t1", self.ts, 300*10000, 30000);
# test base case
self.test_case1()
tdLog.debug(" LIMIT test_case1 ............ [OK]")
# test advance case
self.test_case2()
tdLog.debug(" LIMIT test_case2 ............ [OK]")
# stop
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
#
# --------------- case -------------------
#
# create table
def create_tables(self):
# super table
tdSql.execute("create table st(ts timestamp, i1 int) tags(area int)");
# child table
tdSql.execute("create table t1 using st tags(1)");
tdSql.execute("create table t2 using st tags(2)");
tdSql.execute("create table t3 using st tags(3)");
return
# insert data1
def insert_data(self, tbname, ts_start, count, batch_num):
pre_insert = "insert into %s values"%tbname
sql = pre_insert
tdLog.debug("doing insert table %s rows=%d ..."%(tbname, count))
for i in range(count):
sql += " (%d,%d)"%(ts_start + i*1000, i)
if i >0 and i%batch_num == 0:
tdSql.execute(sql)
sql = pre_insert
# end sql
if sql != pre_insert:
tdSql.execute(sql)
tdLog.debug("INSERT TABLE DATA ............ [OK]")
return
# test case1 base
def test_case1(self):
#
# limit base function
#
# base no where
sql = "select * from t1 limit 10"
tdSql.waitedQuery(sql, 10, WAITS)
tdSql.checkData(0, 1, 0)
tdSql.checkData(9, 1, 9)
sql = "select * from t1 order by ts desc limit 10" # desc
tdSql.waitedQuery(sql, 10, WAITS)
tdSql.checkData(0, 1, 2999999)
tdSql.checkData(9, 1, 2999990)
# have where
sql = "select * from t1 where ts>='2017-07-14 10:40:01' and ts<'2017-07-14 10:40:06' limit 10"
tdSql.waitedQuery(sql, 5, WAITS)
tdSql.checkData(0, 1, 1)
tdSql.checkData(4, 1, 5)
sql = "select * from t1 where ts>='2017-08-18 03:59:52' and ts<'2017-08-18 03:59:57' order by ts desc limit 10" # desc
tdSql.waitedQuery(sql, 5, WAITS)
tdSql.checkData(0, 1, 2999996)
tdSql.checkData(4, 1, 2999992)
#
# offset base function
#
# no where
sql = "select * from t1 limit 10 offset 5"
tdSql.waitedQuery(sql, 10, WAITS)
tdSql.checkData(0, 1, 5)
tdSql.checkData(9, 1, 14)
sql = "select * from t1 order by ts desc limit 10 offset 5" # desc
tdSql.waitedQuery(sql, 10, WAITS)
tdSql.checkData(0, 1, 2999994)
tdSql.checkData(9, 1, 2999985)
# have where only ts
sql = "select * from t1 where ts>='2017-07-14 10:40:10' and ts<'2017-07-14 10:40:20' limit 10 offset 5"
tdSql.waitedQuery(sql, 5, WAITS)
tdSql.checkData(0, 1, 15)
tdSql.checkData(4, 1, 19)
sql = "select * from t1 where ts>='2017-08-18 03:59:52' and ts<'2017-08-18 03:59:57' order by ts desc limit 10 offset 4" # desc
tdSql.waitedQuery(sql, 1, WAITS)
tdSql.checkData(0, 1, 2999992)
# have where with other column condition
sql = "select * from t1 where i1>=1 and i1<11 limit 10 offset 5"
tdSql.waitedQuery(sql, 5, WAITS)
tdSql.checkData(0, 1, 6)
tdSql.checkData(4, 1, 10)
sql = "select * from t1 where i1>=300000 and i1<=500000 order by ts desc limit 10 offset 100000" # desc
tdSql.waitedQuery(sql, 10, WAITS)
tdSql.checkData(0, 1, 400000)
tdSql.checkData(9, 1, 399991)
# have where with ts and other column condition
sql = "select * from t1 where ts>='2017-07-14 10:40:10' and ts<'2017-07-14 10:40:50' and i1>=20 and i1<=25 limit 10 offset 5"
tdSql.waitedQuery(sql, 1, WAITS)
tdSql.checkData(0, 1, 25)
return
# test advance
def test_case2(self):
#
# OFFSET merge file data with memory data
#
# offset
sql = "select * from t1 limit 10 offset 72000"
tdSql.waitedQuery(sql, 10, WAITS)
tdSql.checkData(0, 1, 72000)
# each insert one row into NO.0 NO.2 NO.7 blocks
sql = "insert into t1 values (%d, 0) (%d, 2) (%d, 7)"%(self.ts+1, self.ts + 2*3300*1000+1, self.ts + 7*3300*1000+1)
tdSql.execute(sql)
# query result
sql = "select * from t1 limit 10 offset 72000"
tdSql.waitedQuery(sql, 10, WAITS)
tdSql.checkData(0, 1, 72000 - 3)
# have where
sql = "select * from t1 where ts>='2017-07-14 10:40:10' and ts<'2017-07-22 18:40:10' limit 10 offset 72000"
tdSql.waitedQuery(sql, 10, WAITS)
tdSql.checkData(0, 1, 72000 - 3 + 10 + 1)
# have where desc
sql = "select * from t1 where ts<'2017-07-14 20:40:00' order by ts desc limit 15 offset 36000"
tdSql.waitedQuery(sql, 3, WAITS)
tdSql.checkData(0, 1, 1)
#
# add case with filename
#
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -360,4 +360,12 @@ sql select * from (select * from where_ts) where ts<now; ...@@ -360,4 +360,12 @@ sql select * from (select * from where_ts) where ts<now;
if $rows != 5 then if $rows != 5 then
return -1 return -1
endi endi
print ======================>td-11169
sql drop table where_ts;
sql create stable m1 (ts timestamp , k int) tags(a binary(15000));
sql create table tm0 using m1 tags('abc');
sql insert into tm0 values(now, 1);
sql select top(k, 100), a from m1;
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
cd ../../../debug; cmake .. cd ../../../debug; cmake ..
cd ../../../debug; make cd ../../../debug; make
#======================b1-start=============== #======================b1-start===============
./test.sh -f general/field/2.sim ./test.sh -f general/field/2.sim
./test.sh -f general/field/3.sim ./test.sh -f general/field/3.sim
./test.sh -f general/field/4.sim ./test.sh -f general/field/4.sim
...@@ -14,8 +12,6 @@ cd ../../../debug; make ...@@ -14,8 +12,6 @@ cd ../../../debug; make
./test.sh -f general/field/single.sim ./test.sh -f general/field/single.sim
./test.sh -f general/field/smallint.sim ./test.sh -f general/field/smallint.sim
./test.sh -f general/field/tinyint.sim ./test.sh -f general/field/tinyint.sim
# ./test.sh -f general/http/autocreate.sim # ./test.sh -f general/http/autocreate.sim
# ./test.sh -f general/http/chunked.sim # ./test.sh -f general/http/chunked.sim
# ./test.sh -f general/http/gzip.sim # ./test.sh -f general/http/gzip.sim
...@@ -27,7 +23,6 @@ cd ../../../debug; make ...@@ -27,7 +23,6 @@ cd ../../../debug; make
# ./test.sh -f general/http/telegraf.sim # ./test.sh -f general/http/telegraf.sim
# ./test.sh -f general/http/grafana_bug.sim # ./test.sh -f general/http/grafana_bug.sim
# ./test.sh -f general/http/grafana.sim # ./test.sh -f general/http/grafana.sim
./test.sh -f general/insert/basic.sim ./test.sh -f general/insert/basic.sim
./test.sh -f general/insert/insert_drop.sim ./test.sh -f general/insert/insert_drop.sim
./test.sh -f general/insert/query_block1_memory.sim ./test.sh -f general/insert/query_block1_memory.sim
...@@ -37,7 +32,6 @@ cd ../../../debug; make ...@@ -37,7 +32,6 @@ cd ../../../debug; make
./test.sh -f general/insert/query_file_memory.sim ./test.sh -f general/insert/query_file_memory.sim
./test.sh -f general/insert/query_multi_file.sim ./test.sh -f general/insert/query_multi_file.sim
./test.sh -f general/insert/tcp.sim ./test.sh -f general/insert/tcp.sim
./test.sh -f general/parser/alter.sim ./test.sh -f general/parser/alter.sim
./test.sh -f general/parser/alter1.sim ./test.sh -f general/parser/alter1.sim
./test.sh -f general/parser/alter_stable.sim ./test.sh -f general/parser/alter_stable.sim
...@@ -90,30 +84,22 @@ cd ../../../debug; make ...@@ -90,30 +84,22 @@ cd ../../../debug; make
./test.sh -f general/db/nosuchfile.sim ./test.sh -f general/db/nosuchfile.sim
./test.sh -f general/parser/function.sim ./test.sh -f general/parser/function.sim
./test.sh -f unique/cluster/vgroup100.sim ./test.sh -f unique/cluster/vgroup100.sim
# ./test.sh -f unique/http/admin.sim # ./test.sh -f unique/http/admin.sim
# ./test.sh -f unique/http/opentsdb.sim # ./test.sh -f unique/http/opentsdb.sim
./test.sh -f unique/import/replica2.sim ./test.sh -f unique/import/replica2.sim
./test.sh -f unique/import/replica3.sim ./test.sh -f unique/import/replica3.sim
./test.sh -f general/alter/cached_schema_after_alter.sim ./test.sh -f general/alter/cached_schema_after_alter.sim
#======================b1-end=============== #======================b1-end===============
#======================b2-start=============== #======================b2-start===============
#./test.sh -f general/wal/sync.sim #./test.sh -f general/wal/sync.sim
./test.sh -f general/wal/kill.sim ./test.sh -f general/wal/kill.sim
./test.sh -f general/wal/maxtables.sim ./test.sh -f general/wal/maxtables.sim
./test.sh -f general/user/authority.sim ./test.sh -f general/user/authority.sim
./test.sh -f general/user/monitor.sim ./test.sh -f general/user/monitor.sim
./test.sh -f general/user/pass_alter.sim ./test.sh -f general/user/pass_alter.sim
./test.sh -f general/user/pass_len.sim ./test.sh -f general/user/pass_len.sim
./test.sh -f general/user/user_create.sim ./test.sh -f general/user/user_create.sim
./test.sh -f general/user/user_len.sim ./test.sh -f general/user/user_len.sim
./test.sh -f general/vector/metrics_field.sim ./test.sh -f general/vector/metrics_field.sim
./test.sh -f general/vector/metrics_mix.sim ./test.sh -f general/vector/metrics_mix.sim
./test.sh -f general/vector/metrics_query.sim ./test.sh -f general/vector/metrics_query.sim
...@@ -125,7 +111,6 @@ cd ../../../debug; make ...@@ -125,7 +111,6 @@ cd ../../../debug; make
./test.sh -f general/vector/table_mix.sim ./test.sh -f general/vector/table_mix.sim
./test.sh -f general/vector/table_query.sim ./test.sh -f general/vector/table_query.sim
./test.sh -f general/vector/table_time.sim ./test.sh -f general/vector/table_time.sim
./test.sh -f unique/account/account_create.sim ./test.sh -f unique/account/account_create.sim
./test.sh -f unique/account/account_delete.sim ./test.sh -f unique/account/account_delete.sim
./test.sh -f unique/account/account_len.sim ./test.sh -f unique/account/account_len.sim
...@@ -137,24 +122,17 @@ cd ../../../debug; make ...@@ -137,24 +122,17 @@ cd ../../../debug; make
./test.sh -f unique/account/usage.sim ./test.sh -f unique/account/usage.sim
./test.sh -f unique/account/user_create.sim ./test.sh -f unique/account/user_create.sim
./test.sh -f unique/account/user_len.sim ./test.sh -f unique/account/user_len.sim
./test.sh -f unique/big/maxvnodes.sim ./test.sh -f unique/big/maxvnodes.sim
./test.sh -f unique/big/tcp.sim ./test.sh -f unique/big/tcp.sim
./test.sh -f unique/cluster/alter.sim ./test.sh -f unique/cluster/alter.sim
./test.sh -f unique/cluster/cache.sim ./test.sh -f unique/cluster/cache.sim
#./test.sh -f unique/http/admin.sim #./test.sh -f unique/http/admin.sim
#./test.sh -f unique/http/opentsdb.sim #./test.sh -f unique/http/opentsdb.sim
./test.sh -f unique/import/replica2.sim ./test.sh -f unique/import/replica2.sim
./test.sh -f unique/import/replica3.sim ./test.sh -f unique/import/replica3.sim
./test.sh -f general/alter/cached_schema_after_alter.sim ./test.sh -f general/alter/cached_schema_after_alter.sim
#======================b2-end=============== #======================b2-end===============
#======================b3-start=============== #======================b3-start===============
./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim ./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim
#./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim #./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim
./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim ./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim
...@@ -175,7 +153,6 @@ cd ../../../debug; make ...@@ -175,7 +153,6 @@ cd ../../../debug; make
./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim ./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim
./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim ./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim
./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim ./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim
./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim ./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim
./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim ./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim
./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim ./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim
...@@ -189,19 +166,16 @@ cd ../../../debug; make ...@@ -189,19 +166,16 @@ cd ../../../debug; make
./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim ./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim
./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim ./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim
./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim ./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim
./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim ./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim
./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim ./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim
./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim ./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim
./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim ./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim
./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim ./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim
./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim ./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim
./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim ./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim
./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim ./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim
./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim ./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim
./test.sh -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim ./test.sh -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim
./test.sh -f unique/stable/balance_replica1.sim ./test.sh -f unique/stable/balance_replica1.sim
./test.sh -f unique/stable/dnode2_stop.sim ./test.sh -f unique/stable/dnode2_stop.sim
./test.sh -f unique/stable/dnode2.sim ./test.sh -f unique/stable/dnode2.sim
...@@ -210,11 +184,8 @@ cd ../../../debug; make ...@@ -210,11 +184,8 @@ cd ../../../debug; make
./test.sh -f unique/stable/replica2_vnode3.sim ./test.sh -f unique/stable/replica2_vnode3.sim
./test.sh -f unique/stable/replica3_dnode6.sim ./test.sh -f unique/stable/replica3_dnode6.sim
./test.sh -f unique/stable/replica3_vnode3.sim ./test.sh -f unique/stable/replica3_vnode3.sim
#======================b3-end=============== #======================b3-end===============
#======================b4-start=============== #======================b4-start===============
./test.sh -f general/alter/count.sim ./test.sh -f general/alter/count.sim
./test.sh -f general/alter/dnode.sim ./test.sh -f general/alter/dnode.sim
./test.sh -f general/alter/import.sim ./test.sh -f general/alter/import.sim
...@@ -222,22 +193,17 @@ cd ../../../debug; make ...@@ -222,22 +193,17 @@ cd ../../../debug; make
./test.sh -f general/alter/insert2.sim ./test.sh -f general/alter/insert2.sim
./test.sh -f general/alter/metrics.sim ./test.sh -f general/alter/metrics.sim
./test.sh -f general/alter/table.sim ./test.sh -f general/alter/table.sim
./test.sh -f general/cache/new_metrics.sim ./test.sh -f general/cache/new_metrics.sim
./test.sh -f general/cache/restart_metrics.sim ./test.sh -f general/cache/restart_metrics.sim
./test.sh -f general/cache/restart_table.sim ./test.sh -f general/cache/restart_table.sim
./test.sh -f general/connection/connection.sim ./test.sh -f general/connection/connection.sim
./test.sh -f general/column/commit.sim ./test.sh -f general/column/commit.sim
./test.sh -f general/column/metrics.sim ./test.sh -f general/column/metrics.sim
./test.sh -f general/column/table.sim ./test.sh -f general/column/table.sim
./test.sh -f general/compress/commitlog.sim ./test.sh -f general/compress/commitlog.sim
./test.sh -f general/compress/compress.sim ./test.sh -f general/compress/compress.sim
./test.sh -f general/compress/compress2.sim ./test.sh -f general/compress/compress2.sim
./test.sh -f general/compress/uncompress.sim ./test.sh -f general/compress/uncompress.sim
./test.sh -f general/stable/disk.sim ./test.sh -f general/stable/disk.sim
./test.sh -f general/stable/dnode3.sim ./test.sh -f general/stable/dnode3.sim
./test.sh -f general/stable/metrics.sim ./test.sh -f general/stable/metrics.sim
...@@ -245,7 +211,6 @@ cd ../../../debug; make ...@@ -245,7 +211,6 @@ cd ../../../debug; make
./test.sh -f general/stable/show.sim ./test.sh -f general/stable/show.sim
./test.sh -f general/stable/values.sim ./test.sh -f general/stable/values.sim
./test.sh -f general/stable/vnode3.sim ./test.sh -f general/stable/vnode3.sim
./test.sh -f unique/column/replica3.sim ./test.sh -f unique/column/replica3.sim
./test.sh -f issue/TD-2713.sim ./test.sh -f issue/TD-2713.sim
./test.sh -f general/parser/select_distinct_tag.sim ./test.sh -f general/parser/select_distinct_tag.sim
...@@ -253,10 +218,8 @@ cd ../../../debug; make ...@@ -253,10 +218,8 @@ cd ../../../debug; make
./test.sh -f issue/TD-2677.sim ./test.sh -f issue/TD-2677.sim
./test.sh -f issue/TD-2680.sim ./test.sh -f issue/TD-2680.sim
./test.sh -f unique/dnode/lossdata.sim ./test.sh -f unique/dnode/lossdata.sim
#======================b4-end=============== #======================b4-end===============
#======================b5-start=============== #======================b5-start===============
./test.sh -f unique/dnode/alternativeRole.sim ./test.sh -f unique/dnode/alternativeRole.sim
./test.sh -f unique/dnode/balance1.sim ./test.sh -f unique/dnode/balance1.sim
./test.sh -f unique/dnode/balance2.sim ./test.sh -f unique/dnode/balance2.sim
...@@ -264,7 +227,6 @@ cd ../../../debug; make ...@@ -264,7 +227,6 @@ cd ../../../debug; make
./test.sh -f unique/dnode/balancex.sim ./test.sh -f unique/dnode/balancex.sim
./test.sh -f unique/dnode/offline1.sim ./test.sh -f unique/dnode/offline1.sim
./test.sh -f unique/dnode/offline2.sim ./test.sh -f unique/dnode/offline2.sim
./test.sh -f general/stream/metrics_del.sim ./test.sh -f general/stream/metrics_del.sim
./test.sh -f general/stream/metrics_replica1_vnoden.sim ./test.sh -f general/stream/metrics_replica1_vnoden.sim
./test.sh -f general/stream/restart_stream.sim ./test.sh -f general/stream/restart_stream.sim
...@@ -272,22 +234,18 @@ cd ../../../debug; make ...@@ -272,22 +234,18 @@ cd ../../../debug; make
./test.sh -f general/stream/stream_restart.sim ./test.sh -f general/stream/stream_restart.sim
./test.sh -f general/stream/table_del.sim ./test.sh -f general/stream/table_del.sim
./test.sh -f general/stream/table_replica1_vnoden.sim ./test.sh -f general/stream/table_replica1_vnoden.sim
./test.sh -f general/connection/test_old_data.sim ./test.sh -f general/connection/test_old_data.sim
./test.sh -f unique/dnode/datatrans_3node.sim ./test.sh -f unique/dnode/datatrans_3node.sim
./test.sh -f unique/dnode/datatrans_3node_2.sim ./test.sh -f unique/dnode/datatrans_3node_2.sim
./test.sh -f general/db/alter_tables_d2.sim ./test.sh -f general/db/alter_tables_d2.sim
./test.sh -f general/db/alter_tables_v1.sim ./test.sh -f general/db/alter_tables_v1.sim
./test.sh -f general/db/alter_tables_v4.sim ./test.sh -f general/db/alter_tables_v4.sim
#======================b5-end=============== #======================b5-end===============
#======================b6-start=============== #======================b6-start===============
./test.sh -f unique/dnode/reason.sim ./test.sh -f unique/dnode/reason.sim
./test.sh -f unique/dnode/remove1.sim ./test.sh -f unique/dnode/remove1.sim
./test.sh -f unique/dnode/remove2.sim ./test.sh -f unique/dnode/remove2.sim
./test.sh -f unique/dnode/vnode_clean.sim ./test.sh -f unique/dnode/vnode_clean.sim
./test.sh -f unique/db/commit.sim ./test.sh -f unique/db/commit.sim
./test.sh -f unique/db/delete.sim ./test.sh -f unique/db/delete.sim
./test.sh -f unique/db/delete_part.sim ./test.sh -f unique/db/delete_part.sim
...@@ -298,14 +256,12 @@ cd ../../../debug; make ...@@ -298,14 +256,12 @@ cd ../../../debug; make
./test.sh -f unique/db/replica_reduce32.sim ./test.sh -f unique/db/replica_reduce32.sim
./test.sh -f unique/db/replica_reduce31.sim ./test.sh -f unique/db/replica_reduce31.sim
./test.sh -f unique/db/replica_part.sim ./test.sh -f unique/db/replica_part.sim
./test.sh -f unique/vnode/many.sim ./test.sh -f unique/vnode/many.sim
./test.sh -f unique/vnode/replica2_basic2.sim ./test.sh -f unique/vnode/replica2_basic2.sim
./test.sh -f unique/vnode/replica2_repeat.sim ./test.sh -f unique/vnode/replica2_repeat.sim
./test.sh -f unique/vnode/replica3_basic.sim ./test.sh -f unique/vnode/replica3_basic.sim
./test.sh -f unique/vnode/replica3_repeat.sim ./test.sh -f unique/vnode/replica3_repeat.sim
./test.sh -f unique/vnode/replica3_vgroup.sim ./test.sh -f unique/vnode/replica3_vgroup.sim
./test.sh -f unique/dnode/monitor.sim ./test.sh -f unique/dnode/monitor.sim
./test.sh -f unique/dnode/monitor_bug.sim ./test.sh -f unique/dnode/monitor_bug.sim
./test.sh -f unique/dnode/simple.sim ./test.sh -f unique/dnode/simple.sim
...@@ -315,7 +271,6 @@ cd ../../../debug; make ...@@ -315,7 +271,6 @@ cd ../../../debug; make
./test.sh -f unique/dnode/offline3.sim ./test.sh -f unique/dnode/offline3.sim
./test.sh -f general/wal/kill.sim ./test.sh -f general/wal/kill.sim
./test.sh -f general/wal/maxtables.sim ./test.sh -f general/wal/maxtables.sim
./test.sh -f general/import/basic.sim ./test.sh -f general/import/basic.sim
./test.sh -f general/import/commit.sim ./test.sh -f general/import/commit.sim
./test.sh -f general/import/large.sim ./test.sh -f general/import/large.sim
...@@ -323,10 +278,8 @@ cd ../../../debug; make ...@@ -323,10 +278,8 @@ cd ../../../debug; make
./test.sh -f unique/cluster/balance1.sim ./test.sh -f unique/cluster/balance1.sim
./test.sh -f unique/cluster/balance2.sim ./test.sh -f unique/cluster/balance2.sim
./test.sh -f unique/cluster/balance3.sim ./test.sh -f unique/cluster/balance3.sim
#======================b6-end=============== #======================b6-end===============
#======================b7-start=============== #======================b7-start===============
./test.sh -f general/compute/avg.sim ./test.sh -f general/compute/avg.sim
./test.sh -f general/compute/bottom.sim ./test.sh -f general/compute/bottom.sim
./test.sh -f general/compute/count.sim ./test.sh -f general/compute/count.sim
...@@ -343,7 +296,6 @@ cd ../../../debug; make ...@@ -343,7 +296,6 @@ cd ../../../debug; make
./test.sh -f general/compute/stddev.sim ./test.sh -f general/compute/stddev.sim
./test.sh -f general/compute/sum.sim ./test.sh -f general/compute/sum.sim
./test.sh -f general/compute/top.sim ./test.sh -f general/compute/top.sim
./test.sh -f general/db/alter_option.sim ./test.sh -f general/db/alter_option.sim
./test.sh -f general/db/alter_vgroups.sim ./test.sh -f general/db/alter_vgroups.sim
./test.sh -f general/db/basic.sim ./test.sh -f general/db/basic.sim
...@@ -392,7 +344,6 @@ cd ../../../debug; make ...@@ -392,7 +344,6 @@ cd ../../../debug; make
./test.sh -f general/table/tinyint.sim ./test.sh -f general/table/tinyint.sim
./test.sh -f general/table/vgroup.sim ./test.sh -f general/table/vgroup.sim
./test.sh -f general/table/createmulti.sim ./test.sh -f general/table/createmulti.sim
./test.sh -f unique/mnode/mgmt20.sim ./test.sh -f unique/mnode/mgmt20.sim
./test.sh -f unique/mnode/mgmt21.sim ./test.sh -f unique/mnode/mgmt21.sim
./test.sh -f unique/mnode/mgmt22.sim ./test.sh -f unique/mnode/mgmt22.sim
...@@ -403,7 +354,6 @@ cd ../../../debug; make ...@@ -403,7 +354,6 @@ cd ../../../debug; make
./test.sh -f unique/mnode/mgmt33.sim ./test.sh -f unique/mnode/mgmt33.sim
./test.sh -f unique/mnode/mgmt34.sim ./test.sh -f unique/mnode/mgmt34.sim
./test.sh -f unique/mnode/mgmtr2.sim ./test.sh -f unique/mnode/mgmtr2.sim
#./test.sh -f unique/arbitrator/insert_duplicationTs.sim #./test.sh -f unique/arbitrator/insert_duplicationTs.sim
./test.sh -f general/parser/join_manyblocks.sim ./test.sh -f general/parser/join_manyblocks.sim
./test.sh -f general/parser/stableOp.sim ./test.sh -f general/parser/stableOp.sim
...@@ -415,9 +365,7 @@ cd ../../../debug; make ...@@ -415,9 +365,7 @@ cd ../../../debug; make
./test.sh -f general/parser/last_cache.sim ./test.sh -f general/parser/last_cache.sim
./test.sh -f unique/big/balance.sim ./test.sh -f unique/big/balance.sim
./test.sh -f general/parser/nestquery.sim ./test.sh -f general/parser/nestquery.sim
./test.sh -f general/parser/udf.sim ./test.sh -f general/parser/udf.sim
./test.sh -f general/parser/udf_dll.sim ./test.sh -f general/parser/udf_dll.sim
./test.sh -f general/parser/udf_dll_stable.sim ./test.sh -f general/parser/udf_dll_stable.sim
#======================b7-end=============== #======================b7-end===============
...@@ -32,68 +32,85 @@ class TDTestCase: ...@@ -32,68 +32,85 @@ class TDTestCase:
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
self.tmpdir = "tmp"
now = time.time() now = time.time()
self.ts = int(round(now * 1000)) self.ts = int(round(now * 1000))
def table1_checkall(self,sql): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosdump" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def table1_checkall(self, sql):
tdLog.info(sql) tdLog.info(sql)
tdSql.query(sql) tdSql.query(sql)
tdSql.checkData(0,1,1) tdSql.checkData(0, 1, 1)
tdSql.checkData(0,2,2) tdSql.checkData(0, 2, 2)
tdSql.checkData(0,3,3) tdSql.checkData(0, 3, 3)
tdSql.checkData(0,4,4) tdSql.checkData(0, 4, 4)
tdSql.checkData(0,5,'True') tdSql.checkData(0, 5, 'True')
tdSql.checkData(0,6,6) tdSql.checkData(0, 6, 6)
tdSql.checkData(0,7,7) tdSql.checkData(0, 7, 7)
tdSql.checkData(0,8,8) tdSql.checkData(0, 8, 8)
tdSql.checkData(0,9,9) tdSql.checkData(0, 9, 9)
tdSql.checkData(0,10,'1970-01-01 08:00:00.010') tdSql.checkData(0, 10, '1970-01-01 08:00:00.010')
def table1_checkall_1(self,sql): def table1_checkall_1(self, sql):
tdSql.query(sql) tdSql.query(sql)
tdSql.checkData(0,1,1) tdSql.checkData(0, 1, 1)
def table1_checkall_2(self,sql): def table1_checkall_2(self, sql):
self.table1_checkall_1(sql) self.table1_checkall_1(sql)
tdSql.checkData(0,2,2) tdSql.checkData(0, 2, 2)
def table1_checkall_3(self,sql): def table1_checkall_3(self, sql):
self.table1_checkall_2(sql) self.table1_checkall_2(sql)
tdSql.checkData(0,3,3) tdSql.checkData(0, 3, 3)
def table1_checkall_4(self,sql): def table1_checkall_4(self, sql):
self.table1_checkall_3(sql) self.table1_checkall_3(sql)
tdSql.checkData(0,4,4) tdSql.checkData(0, 4, 4)
def table1_checkall_5(self,sql): def table1_checkall_5(self, sql):
self.table1_checkall_4(sql) self.table1_checkall_4(sql)
tdSql.checkData(0,5,'True') tdSql.checkData(0, 5, 'True')
def table1_checkall_6(self,sql): def table1_checkall_6(self, sql):
self.table1_checkall_5(sql) self.table1_checkall_5(sql)
tdSql.checkData(0,6,6) tdSql.checkData(0, 6, 6)
def table1_checkall_7(self,sql): def table1_checkall_7(self, sql):
self.table1_checkall_6(sql) self.table1_checkall_6(sql)
tdSql.checkData(0,7,7) tdSql.checkData(0, 7, 7)
def table1_checkall_8(self,sql): def table1_checkall_8(self, sql):
self.table1_checkall_7(sql) self.table1_checkall_7(sql)
tdSql.checkData(0,8,8) tdSql.checkData(0, 8, 8)
def table1_checkall_9(self,sql): def table1_checkall_9(self, sql):
self.table1_checkall_8(sql) self.table1_checkall_8(sql)
tdSql.checkData(0,9,9) tdSql.checkData(0, 9, 9)
def table1_checkall_10(self,sql): def table1_checkall_10(self, sql):
self.table1_checkall_9(sql) self.table1_checkall_9(sql)
tdSql.checkData(0,10,'1970-01-01 08:00:00.010') tdSql.checkData(0, 10, '1970-01-01 08:00:00.010')
def run(self): def run(self):
testcaseFilename = os.path.split(__file__)[-1] testcaseFilename = os.path.split(__file__)[-1]
os.system("rm -rf 5-taos-tools/%s.sql" % testcaseFilename ) os.system("rm -rf 5-taos-tools/%s.sql" % testcaseFilename)
os.system("rm db*") os.system("rm %s/db*" % self.tmpdir)
os.system("rm dump_result.txt*") os.system("rm dump_result.txt*")
tdSql.prepare() tdSql.prepare()
...@@ -103,7 +120,8 @@ class TDTestCase: ...@@ -103,7 +120,8 @@ class TDTestCase:
tdSql.execute("create database db2") tdSql.execute("create database db2")
tdSql.execute("use db2") tdSql.execute("use db2")
print("==============new version [escape character] for stable==============") print(
"==============new version [escape character] for stable==============")
print("==============step1,#create db.stable,db.table; insert db.table; show db.table; select db.table; drop db.table;") print("==============step1,#create db.stable,db.table; insert db.table; show db.table; select db.table; drop db.table;")
print("prepare data") print("prepare data")
...@@ -112,141 +130,159 @@ class TDTestCase: ...@@ -112,141 +130,159 @@ class TDTestCase:
self.col_base = "123~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" self.col_base = "123~!@#$%^&*()-_+=[]{}':,<.>/?stST13579"
self.col_int = "stable_col_int%s" %self.col_base self.col_int = "stable_col_int%s" % self.col_base
print(self.col_int) print(self.col_int)
self.col_bigint = "stable_col_bigint%s" %self.col_base self.col_bigint = "stable_col_bigint%s" % self.col_base
self.col_smallint = "stable_col_smallint%s" %self.col_base self.col_smallint = "stable_col_smallint%s" % self.col_base
self.col_tinyint = "stable_col_tinyint%s" %self.col_base self.col_tinyint = "stable_col_tinyint%s" % self.col_base
self.col_bool = "stable_col_bool%s" %self.col_base self.col_bool = "stable_col_bool%s" % self.col_base
self.col_binary = "stable_col_binary%s" %self.col_base self.col_binary = "stable_col_binary%s" % self.col_base
self.col_nchar = "stable_col_nchar%s" %self.col_base self.col_nchar = "stable_col_nchar%s" % self.col_base
self.col_float = "stable_col_float%s" %self.col_base self.col_float = "stable_col_float%s" % self.col_base
self.col_double = "stable_col_double%s" %self.col_base self.col_double = "stable_col_double%s" % self.col_base
self.col_ts = "stable_col_ts%s" %self.col_base self.col_ts = "stable_col_ts%s" % self.col_base
self.tag_base = "abc~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" self.tag_base = "abc~!@#$%^&*()-_+=[]{}':,<.>/?stST13579"
self.tag_int = "stable_tag_int%s" %self.tag_base self.tag_int = "stable_tag_int%s" % self.tag_base
self.tag_bigint = "stable_tag_bigint%s" %self.tag_base self.tag_bigint = "stable_tag_bigint%s" % self.tag_base
self.tag_smallint = "stable_tag_smallint%s" %self.tag_base self.tag_smallint = "stable_tag_smallint%s" % self.tag_base
self.tag_tinyint = "stable_tag_tinyint%s" %self.tag_base self.tag_tinyint = "stable_tag_tinyint%s" % self.tag_base
self.tag_bool = "stable_tag_bool%s" %self.tag_base self.tag_bool = "stable_tag_bool%s" % self.tag_base
self.tag_binary = "stable_tag_binary%s" %self.tag_base self.tag_binary = "stable_tag_binary%s" % self.tag_base
self.tag_nchar = "stable_tag_nchar%s" %self.tag_base self.tag_nchar = "stable_tag_nchar%s" % self.tag_base
self.tag_float = "stable_tag_float%s" %self.tag_base self.tag_float = "stable_tag_float%s" % self.tag_base
self.tag_double = "stable_tag_double%s" %self.tag_base self.tag_double = "stable_tag_double%s" % self.tag_base
self.tag_ts = "stable_tag_ts%s" %self.tag_base self.tag_ts = "stable_tag_ts%s" % self.tag_base
tdSql.execute('''create stable db.`%s` (ts timestamp, `%s` int , `%s` bigint , `%s` smallint , `%s` tinyint, `%s` bool , tdSql.execute('''create stable db.`%s` (ts timestamp, `%s` int , `%s` bigint , `%s` smallint , `%s` tinyint, `%s` bool ,
`%s` binary(20) , `%s` nchar(20) ,`%s` float , `%s` double , `%s` timestamp) `%s` binary(20) , `%s` nchar(20) ,`%s` float , `%s` double , `%s` timestamp)
tags(loc nchar(20), `%s` int , `%s` bigint , `%s` smallint , `%s` tinyint, `%s` bool , tags(loc nchar(20), `%s` int , `%s` bigint , `%s` smallint , `%s` tinyint, `%s` bool ,
`%s` binary(20) , `%s` nchar(20) ,`%s` float , `%s` double , `%s` timestamp);''' `%s` binary(20) , `%s` nchar(20) ,`%s` float , `%s` double , `%s` timestamp);'''
%(self.stb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, % (self.stb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool,
self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,
self.tag_int, self.tag_bigint, self.tag_smallint, self.tag_tinyint, self.tag_bool, self.tag_int, self.tag_bigint, self.tag_smallint, self.tag_tinyint, self.tag_bool,
self.tag_binary, self.tag_nchar, self.tag_float, self.tag_double, self.tag_ts)) self.tag_binary, self.tag_nchar, self.tag_float, self.tag_double, self.tag_ts))
tdSql.query("describe db.`%s` ; " %self.stb1) tdSql.query("describe db.`%s` ; " % self.stb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.query("select _block_dist() from db.`%s` ; " %self.stb1) tdSql.query("select _block_dist() from db.`%s` ; " % self.stb1)
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("show create stable db.`%s` ; " %self.stb1) tdSql.query("show create stable db.`%s` ; " % self.stb1)
tdSql.checkData(0, 0, self.stb1) tdSql.checkData(0, 0, self.stb1)
tdSql.checkData(0, 1, "create table `%s` (`ts` TIMESTAMP,`%s` INT,`%s` BIGINT,`%s` SMALLINT,`%s` TINYINT,`%s` BOOL,`%s` BINARY(20),`%s` NCHAR(20),`%s` FLOAT,`%s` DOUBLE,`%s` TIMESTAMP)\ tdSql.checkData(0, 1, "create table `%s` (`ts` TIMESTAMP,`%s` INT,`%s` BIGINT,`%s` SMALLINT,`%s` TINYINT,`%s` BOOL,`%s` BINARY(20),`%s` NCHAR(20),`%s` FLOAT,`%s` DOUBLE,`%s` TIMESTAMP)\
TAGS (`loc` NCHAR(20),`%s` INT,`%s` BIGINT,`%s` SMALLINT,`%s` TINYINT,`%s` BOOL,`%s` BINARY(20),`%s` NCHAR(20),`%s` FLOAT,`%s` DOUBLE,`%s` TIMESTAMP)" TAGS (`loc` NCHAR(20),`%s` INT,`%s` BIGINT,`%s` SMALLINT,`%s` TINYINT,`%s` BOOL,`%s` BINARY(20),`%s` NCHAR(20),`%s` FLOAT,`%s` DOUBLE,`%s` TIMESTAMP)"
%(self.stb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, % (self.stb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool,
self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,
self.tag_int, self.tag_bigint, self.tag_smallint, self.tag_tinyint, self.tag_bool, self.tag_int, self.tag_bigint, self.tag_smallint, self.tag_tinyint, self.tag_bool,
self.tag_binary, self.tag_nchar, self.tag_float, self.tag_double, self.tag_ts)) self.tag_binary, self.tag_nchar, self.tag_float, self.tag_double, self.tag_ts))
tdSql.execute("create table db.`table!1` using db.`%s` tags('table_1' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')" %self.stb1) tdSql.execute(
"create table db.`table!1` using db.`%s` tags('table_1' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')" %
self.stb1)
tdSql.query("describe db.`table!1` ; ") tdSql.query("describe db.`table!1` ; ")
tdSql.checkRows(22) tdSql.checkRows(22)
time.sleep(10) time.sleep(10)
tdSql.query("show create table db.`table!1` ; ") tdSql.query("show create table db.`table!1` ; ")
tdSql.checkData(0, 0, "table!1") tdSql.checkData(0, 0, "table!1")
tdSql.checkData(0, 1, "CREATE TABLE `table!1` USING `%s` TAGS (\"table_1\",0,0,0,0,false,\"0\",\"0\",0.000000,0.000000,\"0\")" %self.stb1) tdSql.checkData(
0,
tdSql.execute("insert into db.`table!1` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)") 1,
"CREATE TABLE `table!1` USING `%s` TAGS (\"table_1\",0,0,0,0,false,\"0\",\"0\",0.000000,0.000000,\"0\")" %
self.stb1)
tdSql.execute(
"insert into db.`table!1` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)")
sql = " select * from db.`table!1`; " sql = " select * from db.`table!1`; "
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(1) tdSql.checkRows(1)
sql = '''select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`table!1`; '''\ sql = '''select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`table!1`; '''\
%(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) % (self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(1) tdSql.checkRows(1)
time.sleep(1) time.sleep(1)
tdSql.execute('''insert into db.`table!1`(ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`) values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)'''\ tdSql.execute('''insert into db.`table!1`(ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`) values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)'''
%(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) ) % (self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts))
sql = " select * from db.`table!1`; " sql = " select * from db.`table!1`; "
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select count(*) from db.`table!1`; ") tdSql.query("select count(*) from db.`table!1`; ")
tdSql.checkData(0, 0, 2) tdSql.checkData(0, 0, 2)
tdSql.query("select _block_dist() from db.`%s` ; " %self.stb1) tdSql.query("select _block_dist() from db.`%s` ; " % self.stb1)
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.execute("create table db.`%s` using db.`%s` TAGS (\"table_2\",2,2,2,2,true,\"2\",\"2\",2.000000,2.000000,\"2\")" %(self.tb1,self.stb1)) tdSql.execute(
tdSql.query("describe db.`%s` ; " %self.tb1) "create table db.`%s` using db.`%s` TAGS (\"table_2\",2,2,2,2,true,\"2\",\"2\",2.000000,2.000000,\"2\")" %
(self.tb1, self.stb1))
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.query("show create table db.`%s` ; " %self.tb1) tdSql.query("show create table db.`%s` ; " % self.tb1)
tdSql.checkData(0, 0, self.tb1) tdSql.checkData(0, 0, self.tb1)
tdSql.checkData(0, 1, "CREATE TABLE `%s` USING `%s` TAGS (\"table_2\",2,2,2,2,true,\"2\",\"2\",2.000000,2.000000,\"2\")" %(self.tb1,self.stb1)) tdSql.checkData(
0,
tdSql.execute("insert into db.`%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %self.tb1) 1,
sql = "select * from db.`%s` ; " %self.tb1 "CREATE TABLE `%s` USING `%s` TAGS (\"table_2\",2,2,2,2,true,\"2\",\"2\",2.000000,2.000000,\"2\")" %
(self.tb1,
self.stb1))
tdSql.execute(
"insert into db.`%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %
self.tb1)
sql = "select * from db.`%s` ; " % self.tb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(1) tdSql.checkRows(1)
sql = '''select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s` ; '''\ sql = '''select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s` ; '''\
%(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,\ % (self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,
self.tag_int, self.tag_bigint, self.tag_smallint, self.tag_tinyint, self.tag_bool, self.tag_binary, self.tag_nchar, self.tag_float, self.tag_double, self.tag_ts, self.tb1) self.tag_int, self.tag_bigint, self.tag_smallint, self.tag_tinyint, self.tag_bool, self.tag_binary, self.tag_nchar, self.tag_float, self.tag_double, self.tag_ts, self.tb1)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(1) tdSql.checkRows(1)
time.sleep(1) time.sleep(1)
tdSql.execute('''insert into db.`%s`(ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`) values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)'''\ tdSql.execute('''insert into db.`%s`(ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`) values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)'''
%(self.tb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) ) % (self.tb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts))
sql = " select * from db.`%s` ; " %self.tb1 sql = " select * from db.`%s` ; " % self.tb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(2) tdSql.checkRows(2)
sql = " select * from db.`%s` where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10; " \ sql = " select * from db.`%s` where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10; " \
%(self.tb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) % (self.tb1, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select count(*) from db.`%s`; " %self.tb1) tdSql.query("select count(*) from db.`%s`; " % self.tb1)
tdSql.checkData(0, 0, 2) tdSql.checkData(0, 0, 2)
sql = "select * from db.`%s` ; " %self.stb1 sql = "select * from db.`%s` ; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(4) tdSql.checkRows(4)
tdSql.query("select count(*) from db.`%s`; " %self.stb1) tdSql.query("select count(*) from db.`%s`; " % self.stb1)
tdSql.checkData(0, 0, 4) tdSql.checkData(0, 0, 4)
sql = "select * from (select * from db.`%s`) ; " %self.stb1 sql = "select * from (select * from db.`%s`) ; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(4) tdSql.checkRows(4)
tdSql.query("select count(*) from (select * from db.`%s`) ; " %self.stb1) tdSql.query(
"select count(*) from (select * from db.`%s`) ; " %
self.stb1)
tdSql.checkData(0, 0, 4) tdSql.checkData(0, 0, 4)
sql = "select * from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s`) ; " \ sql = "select * from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s`) ; " \
%(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.stb1) % (self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.stb1)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(4) tdSql.checkRows(4)
sql = "select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s`) ; " \ sql = "select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s`) ; " \
%(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,\ % (self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,
self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.stb1) self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.stb1)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(4) tdSql.checkRows(4)
sql = "select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s`\ sql = "select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db.`%s`\
where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10 ) ; " \ where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10 ) ; " \
%(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,\ % (self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,
self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.stb1, \ self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.stb1,
self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(4) tdSql.checkRows(4)
...@@ -257,325 +293,442 @@ class TDTestCase: ...@@ -257,325 +293,442 @@ class TDTestCase:
tdSql.checkRows(2) tdSql.checkRows(2)
self.cr_tb1 = "create_table_1~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" self.cr_tb1 = "create_table_1~!@#$%^&*()-_+=[]{}':,<.>/?stST13579"
tdSql.execute("create table db.`%s` as select avg(`%s`) from db.`%s` where ts > now interval(1m) sliding(30s);" %(self.cr_tb1,self.col_bigint,self.stb1)) tdSql.execute(
"create table db.`%s` as select avg(`%s`) from db.`%s` where ts > now interval(1m) sliding(30s);" %
(self.cr_tb1, self.col_bigint, self.stb1))
tdSql.query("show db.tables like 'create_table_%' ") tdSql.query("show db.tables like 'create_table_%' ")
tdSql.checkRows(1) tdSql.checkRows(1)
print("==============drop\ add\ change\ modify column or tag") print(r"==============drop\ add\ change\ modify column or tag")
print("==============drop==============") print("==============drop==============")
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_ts)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP TAG `%s`; " %
(self.stb1, self.tag_ts))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(21) tdSql.checkRows(21)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_double)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP TAG `%s`; " %
(self.stb1, self.tag_double))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(20) tdSql.checkRows(20)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_float)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP TAG `%s`; " %
(self.stb1, self.tag_float))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(19) tdSql.checkRows(19)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_nchar)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP TAG `%s`; " %
(self.stb1, self.tag_nchar))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(18) tdSql.checkRows(18)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_binary)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP TAG `%s`; " %
(self.stb1, self.tag_binary))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(17) tdSql.checkRows(17)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_bool)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP TAG `%s`; " %
(self.stb1, self.tag_bool))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(16) tdSql.checkRows(16)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_tinyint)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP TAG `%s`; " %
(self.stb1, self.tag_tinyint))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(15) tdSql.checkRows(15)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_smallint)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP TAG `%s`; " %
(self.stb1, self.tag_smallint))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(14) tdSql.checkRows(14)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_bigint)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP TAG `%s`; " %
(self.stb1, self.tag_bigint))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(13) tdSql.checkRows(13)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_int)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP TAG `%s`; " %
(self.stb1, self.tag_int))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(12) tdSql.checkRows(12)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_ts)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP COLUMN `%s`; " %
(self.stb1, self.col_ts))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall_9(sql) datacheck = self.table1_checkall_9(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(11) tdSql.checkRows(11)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_double)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP COLUMN `%s`; " %
(self.stb1, self.col_double))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall_8(sql) datacheck = self.table1_checkall_8(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_float)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP COLUMN `%s`; " %
(self.stb1, self.col_float))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall_7(sql) datacheck = self.table1_checkall_7(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(9) tdSql.checkRows(9)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_nchar)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP COLUMN `%s`; " %
(self.stb1, self.col_nchar))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall_6(sql) datacheck = self.table1_checkall_6(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(8) tdSql.checkRows(8)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_binary)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP COLUMN `%s`; " %
(self.stb1, self.col_binary))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall_5(sql) datacheck = self.table1_checkall_5(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(7) tdSql.checkRows(7)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_bool)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP COLUMN `%s`; " %
(self.stb1, self.col_bool))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall_4(sql) datacheck = self.table1_checkall_4(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(6) tdSql.checkRows(6)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_tinyint)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP COLUMN `%s`; " %
(self.stb1, self.col_tinyint))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall_3(sql) datacheck = self.table1_checkall_3(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(5) tdSql.checkRows(5)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_smallint)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP COLUMN `%s`; " %
(self.stb1, self.col_smallint))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall_2(sql) datacheck = self.table1_checkall_2(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(4) tdSql.checkRows(4)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_bigint)) tdSql.execute(
sql = " select * from db.`%s`; " %self.stb1 "ALTER TABLE db.`%s` DROP COLUMN `%s`; " %
(self.stb1, self.col_bigint))
sql = " select * from db.`%s`; " % self.stb1
datacheck = self.table1_checkall_1(sql) datacheck = self.table1_checkall_1(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.error("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_int)) tdSql.error(
tdSql.query("describe db.`%s` ; " %self.tb1) "ALTER TABLE db.`%s` DROP COLUMN `%s`; " %
(self.stb1, self.col_int))
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(3) tdSql.checkRows(3)
print("==============add==============") print("==============add==============")
tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` bigint; " %(self.stb1, self.col_bigint)) tdSql.execute(
tdSql.query("describe db.`%s` ; " %self.tb1) "ALTER TABLE db.`%s` ADD COLUMN `%s` bigint; " %
(self.stb1, self.col_bigint))
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(4) tdSql.checkRows(4)
tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` smallint; " %(self.stb1, self.col_smallint)) tdSql.execute(
tdSql.query("describe db.`%s` ; " %self.tb1) "ALTER TABLE db.`%s` ADD COLUMN `%s` smallint; " %
(self.stb1, self.col_smallint))
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(5) tdSql.checkRows(5)
tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` tinyint; " %(self.stb1, self.col_tinyint)) tdSql.execute(
tdSql.query("describe db.`%s` ; " %self.tb1) "ALTER TABLE db.`%s` ADD COLUMN `%s` tinyint; " %
(self.stb1, self.col_tinyint))
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(6) tdSql.checkRows(6)
tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` bool; " %(self.stb1, self.col_bool)) tdSql.execute(
tdSql.query("describe db.`%s` ; " %self.tb1) "ALTER TABLE db.`%s` ADD COLUMN `%s` bool; " %
(self.stb1, self.col_bool))
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(7) tdSql.checkRows(7)
tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` binary(20); " %(self.stb1, self.col_binary)) tdSql.execute(
tdSql.query("describe db.`%s` ; " %self.tb1) "ALTER TABLE db.`%s` ADD COLUMN `%s` binary(20); " %
(self.stb1, self.col_binary))
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(8) tdSql.checkRows(8)
tdSql.execute("insert into db.`%s` values(now, 1 , 2, 3, 4, 5, 6)" %self.tb1) tdSql.execute(
sql = "select * from db.`%s` order by ts desc; " %self.tb1 "insert into db.`%s` values(now, 1 , 2, 3, 4, 5, 6)" %
self.tb1)
sql = "select * from db.`%s` order by ts desc; " % self.tb1
datacheck = self.table1_checkall_5(sql) datacheck = self.table1_checkall_5(sql)
tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` nchar(20); " %(self.stb1, self.col_nchar)) tdSql.execute(
tdSql.query("describe db.`%s` ; " %self.tb1) "ALTER TABLE db.`%s` ADD COLUMN `%s` nchar(20); " %
(self.stb1, self.col_nchar))
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(9) tdSql.checkRows(9)
tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` float; " %(self.stb1, self.col_float)) tdSql.execute(
tdSql.query("describe db.`%s` ; " %self.tb1) "ALTER TABLE db.`%s` ADD COLUMN `%s` float; " %
(self.stb1, self.col_float))
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` double; " %(self.stb1, self.col_double)) tdSql.execute(
tdSql.query("describe db.`%s` ; " %self.tb1) "ALTER TABLE db.`%s` ADD COLUMN `%s` double; " %
(self.stb1, self.col_double))
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(11) tdSql.checkRows(11)
tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` timestamp; " %(self.stb1, self.col_ts)) tdSql.execute(
tdSql.query("describe db.`%s` ; " %self.tb1) "ALTER TABLE db.`%s` ADD COLUMN `%s` timestamp; " %
(self.stb1, self.col_ts))
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(12) tdSql.checkRows(12)
tdSql.execute("insert into db.`%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %self.tb1) tdSql.execute(
sql = "select * from db.`%s` order by ts desc; " %self.tb1 "insert into db.`%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %
self.tb1)
sql = "select * from db.`%s` order by ts desc; " % self.tb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` int; " %(self.stb1, self.tag_int)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` ADD TAG `%s` int; " %
(self.stb1, self.tag_int))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(13) tdSql.checkRows(13)
tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` bigint; " %(self.stb1, self.tag_bigint)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` ADD TAG `%s` bigint; " %
(self.stb1, self.tag_bigint))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(14) tdSql.checkRows(14)
tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` smallint; " %(self.stb1, self.tag_smallint)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` ADD TAG `%s` smallint; " %
(self.stb1, self.tag_smallint))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(15) tdSql.checkRows(15)
tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` tinyint; " %(self.stb1, self.tag_tinyint)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` ADD TAG `%s` tinyint; " %
(self.stb1, self.tag_tinyint))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(16) tdSql.checkRows(16)
tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` bool; " %(self.stb1, self.tag_bool)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` ADD TAG `%s` bool; " %
(self.stb1, self.tag_bool))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(17) tdSql.checkRows(17)
tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` binary(20); " %(self.stb1, self.tag_binary)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` ADD TAG `%s` binary(20); " %
(self.stb1, self.tag_binary))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(18) tdSql.checkRows(18)
tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` nchar(20); " %(self.stb1, self.tag_nchar)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` ADD TAG `%s` nchar(20); " %
(self.stb1, self.tag_nchar))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(19) tdSql.checkRows(19)
tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` float; " %(self.stb1, self.tag_float)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` ADD TAG `%s` float; " %
(self.stb1, self.tag_float))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(20) tdSql.checkRows(20)
tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` double; " %(self.stb1, self.tag_double)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` ADD TAG `%s` double; " %
(self.stb1, self.tag_double))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(21) tdSql.checkRows(21)
tdSql.execute("ALTER TABLE db.`%s` ADD TAG `%s` timestamp; " %(self.stb1, self.tag_ts)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` ADD TAG `%s` timestamp; " %
(self.stb1, self.tag_ts))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
print("==============change==============") print("==============change==============")
self.tag_base_change = "abcdas" self.tag_base_change = "abcdas"
self.tag_int_change = "stable_tag_int%s" %self.tag_base_change self.tag_int_change = "stable_tag_int%s" % self.tag_base_change
self.tag_bigint_change = "stable_tag_bigint%s" %self.tag_base_change self.tag_bigint_change = "stable_tag_bigint%s" % self.tag_base_change
self.tag_smallint_change = "stable_tag_smallint%s" %self.tag_base_change self.tag_smallint_change = "stable_tag_smallint%s" % self.tag_base_change
self.tag_tinyint_change = "stable_tag_tinyint%s" %self.tag_base_change self.tag_tinyint_change = "stable_tag_tinyint%s" % self.tag_base_change
self.tag_bool_change = "stable_tag_bool%s" %self.tag_base_change self.tag_bool_change = "stable_tag_bool%s" % self.tag_base_change
self.tag_binary_change = "stable_tag_binary%s" %self.tag_base_change self.tag_binary_change = "stable_tag_binary%s" % self.tag_base_change
self.tag_nchar_change = "stable_tag_nchar%s" %self.tag_base_change self.tag_nchar_change = "stable_tag_nchar%s" % self.tag_base_change
self.tag_float_change = "stable_tag_float%s" %self.tag_base_change self.tag_float_change = "stable_tag_float%s" % self.tag_base_change
self.tag_double_change = "stable_tag_double%s" %self.tag_base_change self.tag_double_change = "stable_tag_double%s" % self.tag_base_change
self.tag_ts_change = "stable_tag_ts%s" %self.tag_base_change self.tag_ts_change = "stable_tag_ts%s" % self.tag_base_change
tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_int, self.tag_int_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %
datacheck = self.table1_checkall(sql) (self.stb1, self.tag_int, self.tag_int_change))
tdSql.query("describe db.`%s` ; " %self.tb1) sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_bigint, self.tag_bigint_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %
(self.stb1, self.tag_bigint, self.tag_bigint_change))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_smallint, self.tag_smallint_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %
(self.stb1, self.tag_smallint, self.tag_smallint_change))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_tinyint, self.tag_tinyint_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %
(self.stb1, self.tag_tinyint, self.tag_tinyint_change))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_bool, self.tag_bool_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %
(self.stb1, self.tag_bool, self.tag_bool_change))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_binary, self.tag_binary_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %
(self.stb1, self.tag_binary, self.tag_binary_change))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_nchar, self.tag_nchar_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %
(self.stb1, self.tag_nchar, self.tag_nchar_change))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_float, self.tag_float_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %
(self.stb1, self.tag_float, self.tag_float_change))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_double, self.tag_double_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %
(self.stb1, self.tag_double, self.tag_double_change))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %(self.stb1, self.tag_ts, self.tag_ts_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER TABLE db.`%s` CHANGE TAG `%s` `%s`; " %
(self.stb1, self.tag_ts, self.tag_ts_change))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
print("==============modify==============") print("==============modify==============")
# TD-10810 # TD-10810
tdSql.execute("ALTER STABLE db.`%s` MODIFY TAG `%s` binary(30); ; " %(self.stb1, self.tag_binary_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER STABLE db.`%s` MODIFY TAG `%s` binary(30); ; " %
(self.stb1, self.tag_binary_change))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER STABLE db.`%s` MODIFY TAG `%s` nchar(30); ; " %(self.stb1, self.tag_nchar_change)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER STABLE db.`%s` MODIFY TAG `%s` nchar(30); ; " %
(self.stb1, self.tag_nchar_change))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER STABLE db.`%s` MODIFY COLUMN `%s` binary(30); ; " %(self.stb1, self.col_binary)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER STABLE db.`%s` MODIFY COLUMN `%s` binary(30); ; " %
(self.stb1, self.col_binary))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
tdSql.execute("ALTER STABLE db.`%s` MODIFY COLUMN `%s` nchar(30); ; " %(self.stb1, self.col_nchar)) tdSql.execute(
sql = " select * from db.`%s` order by ts desc; " %self.stb1 "ALTER STABLE db.`%s` MODIFY COLUMN `%s` nchar(30); ; " %
(self.stb1, self.col_nchar))
sql = " select * from db.`%s` order by ts desc; " % self.stb1
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; " %self.tb1) tdSql.query("describe db.`%s` ; " % self.tb1)
tdSql.checkRows(22) tdSql.checkRows(22)
print("==============drop table\stable") print(r"==============drop table\stable")
try: try:
tdSql.execute("drop table db.`%s` " %self.tb1) tdSql.execute("drop table db.`%s` " % self.tb1)
except Exception as e: except Exception as e:
tdLog.exit(e) tdLog.exit(e)
tdSql.error("select * from db.`%s`" %self.tb1) tdSql.error("select * from db.`%s`" % self.tb1)
tdSql.query("show db.stables like 'stable_1%' ") tdSql.query("show db.stables like 'stable_1%' ")
tdSql.checkRows(1) tdSql.checkRows(1)
try: try:
tdSql.execute("drop table db.`%s` " %self.stb1) tdSql.execute("drop table db.`%s` " % self.stb1)
except Exception as e: except Exception as e:
tdLog.exit(e) tdLog.exit(e)
tdSql.error("select * from db.`%s`" %self.tb1) tdSql.error("select * from db.`%s`" % self.tb1)
tdSql.error("select * from db.`%s`" %self.stb1) tdSql.error("select * from db.`%s`" % self.stb1)
print("==============step2,#create stable,table; insert table; show table; select table; drop table") print("==============step2,#create stable,table; insert table; show table; select table; drop table")
self.stb2 = "stable_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" self.stb2 = "stable_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
self.tb2 = "table_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" self.tb2 = "table_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
tdSql.execute("create stable `%s` (ts timestamp, i int) tags(j int);" %self.stb2) tdSql.execute(
tdSql.query("describe `%s` ; "%self.stb2) "create stable `%s` (ts timestamp, i int) tags(j int);" %
self.stb2)
tdSql.query("describe `%s` ; " % self.stb2)
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.query("select _block_dist() from `%s` ; " %self.stb2) tdSql.query("select _block_dist() from `%s` ; " % self.stb2)
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("show create stable `%s` ; " %self.stb2) tdSql.query("show create stable `%s` ; " % self.stb2)
tdSql.checkData(0, 0, self.stb2) tdSql.checkData(0, 0, self.stb2)
tdSql.checkData(0, 1, "create table `%s` (`ts` TIMESTAMP,`i` INT) TAGS (`j` INT)" %self.stb2) tdSql.checkData(
0,
1,
"create table `%s` (`ts` TIMESTAMP,`i` INT) TAGS (`j` INT)" %
self.stb2)
tdSql.execute("create table `table!2` using `%s` tags(1)" %self.stb2) tdSql.execute("create table `table!2` using `%s` tags(1)" % self.stb2)
tdSql.query("describe `table!2` ; ") tdSql.query("describe `table!2` ; ")
tdSql.checkRows(3) tdSql.checkRows(3)
...@@ -583,34 +736,42 @@ class TDTestCase: ...@@ -583,34 +736,42 @@ class TDTestCase:
tdSql.query("show create table `table!2` ; ") tdSql.query("show create table `table!2` ; ")
tdSql.checkData(0, 0, "table!2") tdSql.checkData(0, 0, "table!2")
tdSql.checkData(0, 1, "CREATE TABLE `table!2` USING `%s` TAGS (1)" %self.stb2) tdSql.checkData(
0,
1,
"CREATE TABLE `table!2` USING `%s` TAGS (1)" %
self.stb2)
tdSql.execute("insert into `table!2` values(now, 1)") tdSql.execute("insert into `table!2` values(now, 1)")
tdSql.query("select * from `table!2`; ") tdSql.query("select * from `table!2`; ")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select count(*) from `table!2`; ") tdSql.query("select count(*) from `table!2`; ")
tdSql.checkData(0, 0, 1) tdSql.checkData(0, 0, 1)
tdSql.query("select _block_dist() from `%s` ; " %self.stb2) tdSql.query("select _block_dist() from `%s` ; " % self.stb2)
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.execute("create table `%s` using `%s` tags(1)" %(self.tb2,self.stb2)) tdSql.execute(
tdSql.query("describe `%s` ; " %self.tb2) "create table `%s` using `%s` tags(1)" %
(self.tb2, self.stb2))
tdSql.query("describe `%s` ; " % self.tb2)
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.query("show create table `%s` ; " %self.tb2) tdSql.query("show create table `%s` ; " % self.tb2)
tdSql.checkData(0, 0, self.tb2) tdSql.checkData(0, 0, self.tb2)
tdSql.checkData(0, 1, "CREATE TABLE `%s` USING `%s` TAGS (1)" %(self.tb2,self.stb2)) tdSql.checkData(
tdSql.execute("insert into `%s` values(now, 1)" %self.tb2) 0, 1, "CREATE TABLE `%s` USING `%s` TAGS (1)" %
tdSql.query("select * from `%s` ; " %self.tb2) (self.tb2, self.stb2))
tdSql.execute("insert into `%s` values(now, 1)" % self.tb2)
tdSql.query("select * from `%s` ; " % self.tb2)
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select count(*) from `%s`; " %self.tb2) tdSql.query("select count(*) from `%s`; " % self.tb2)
tdSql.checkData(0, 0, 1) tdSql.checkData(0, 0, 1)
tdSql.query("select * from `%s` ; " %self.stb2) tdSql.query("select * from `%s` ; " % self.stb2)
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select count(*) from `%s`; " %self.stb2) tdSql.query("select count(*) from `%s`; " % self.stb2)
tdSql.checkData(0, 0, 2) tdSql.checkData(0, 0, 2)
tdSql.query("select * from (select * from `%s`) ; " %self.stb2) tdSql.query("select * from (select * from `%s`) ; " % self.stb2)
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select count(*) from (select * from `%s` ); " %self.stb2) tdSql.query("select count(*) from (select * from `%s` ); " % self.stb2)
tdSql.checkData(0, 0, 2) tdSql.checkData(0, 0, 2)
tdSql.query("show stables like 'stable_2%' ") tdSql.query("show stables like 'stable_2%' ")
...@@ -618,278 +779,348 @@ class TDTestCase: ...@@ -618,278 +779,348 @@ class TDTestCase:
tdSql.query("show tables like 'table%' ") tdSql.query("show tables like 'table%' ")
tdSql.checkRows(2) tdSql.checkRows(2)
# TD-10536
#TD-10536
self.cr_tb2 = "create_table_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" self.cr_tb2 = "create_table_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
tdSql.execute("create table `%s` as select * from `%s` ;" %(self.cr_tb2,self.stb2)) tdSql.execute(
"create table `%s` as select * from `%s` ;" %
(self.cr_tb2, self.stb2))
tdSql.query("show db.tables like 'create_table_%' ") tdSql.query("show db.tables like 'create_table_%' ")
tdSql.checkRows(1) tdSql.checkRows(1)
print("==============step3,#create regular_table; insert regular_table; show regular_table; select regular_table; drop regular_table") print("==============step3,#create regular_table; insert regular_table; show regular_table; select regular_table; drop regular_table")
self.regular_table = "regular_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" self.regular_table = "regular_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
self.regular_col_base = "123@#$%^&*()-_+=[]{};:,<.>/?~!$%^" self.regular_col_base = "123@#$%^&*()-_+=[]{};:,<.>/?~!$%^"
self.col_int = "regular_table_col_int%s" %self.regular_col_base self.col_int = "regular_table_col_int%s" % self.regular_col_base
print(self.col_int) print(self.col_int)
self.col_bigint = "regular_table_col_bigint%s" %self.regular_col_base self.col_bigint = "regular_table_col_bigint%s" % self.regular_col_base
self.col_smallint = "regular_table_col_smallint%s" %self.regular_col_base self.col_smallint = "regular_table_col_smallint%s" % self.regular_col_base
self.col_tinyint = "regular_table_col_tinyint%s" %self.regular_col_base self.col_tinyint = "regular_table_col_tinyint%s" % self.regular_col_base
self.col_bool = "regular_table_col_bool%s" %self.regular_col_base self.col_bool = "regular_table_col_bool%s" % self.regular_col_base
self.col_binary = "regular_table_col_binary%s" %self.regular_col_base self.col_binary = "regular_table_col_binary%s" % self.regular_col_base
self.col_nchar = "regular_table_col_nchar%s" %self.regular_col_base self.col_nchar = "regular_table_col_nchar%s" % self.regular_col_base
self.col_float = "regular_table_col_float%s" %self.regular_col_base self.col_float = "regular_table_col_float%s" % self.regular_col_base
self.col_double = "regular_table_col_double%s" %self.regular_col_base self.col_double = "regular_table_col_double%s" % self.regular_col_base
self.col_ts = "regular_table_col_ts%s" %self.regular_col_base self.col_ts = "regular_table_col_ts%s" % self.regular_col_base
tdSql.execute("create table `%s` (ts timestamp,`%s` int , `%s` bigint , `%s` smallint , `%s` tinyint, `%s` bool , \ tdSql.execute("create table `%s` (ts timestamp,`%s` int , `%s` bigint , `%s` smallint , `%s` tinyint, `%s` bool , \
`%s` binary(20) , `%s` nchar(20) ,`%s` float , `%s` double , `%s` timestamp) ;"\ `%s` binary(20) , `%s` nchar(20) ,`%s` float , `%s` double , `%s` timestamp) ;"
%(self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, % (self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool,
self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)) self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts))
tdSql.query("describe `%s` ; "%self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(11) tdSql.checkRows(11)
tdSql.query("select _block_dist() from `%s` ; " %self.regular_table) tdSql.query("select _block_dist() from `%s` ; " % self.regular_table)
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("show create table `%s` ; " %self.regular_table) tdSql.query("show create table `%s` ; " % self.regular_table)
tdSql.checkData(0, 0, self.regular_table) tdSql.checkData(0, 0, self.regular_table)
tdSql.checkData(0, 1, "create table `%s` (`ts` TIMESTAMP,`%s` INT,`%s` BIGINT,`%s` SMALLINT,`%s` TINYINT,`%s` BOOL,`%s` BINARY(20),`%s` NCHAR(20),`%s` FLOAT,`%s` DOUBLE,`%s` TIMESTAMP)" tdSql.checkData(0, 1, "create table `%s` (`ts` TIMESTAMP,`%s` INT,`%s` BIGINT,`%s` SMALLINT,`%s` TINYINT,`%s` BOOL,`%s` BINARY(20),`%s` NCHAR(20),`%s` FLOAT,`%s` DOUBLE,`%s` TIMESTAMP)"
%(self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, % (self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool,
self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)) self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts))
tdSql.execute("insert into `%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %self.regular_table) tdSql.execute(
sql = "select * from `%s` ; " %self.regular_table "insert into `%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %
self.regular_table)
sql = "select * from `%s` ; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(1) tdSql.checkRows(1)
sql = '''select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db2.`%s`; '''\ sql = '''select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db2.`%s`; '''\
%(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.regular_table) % (self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.regular_table)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(1) tdSql.checkRows(1)
time.sleep(1) time.sleep(1)
tdSql.execute('''insert into db2.`%s` (ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`) values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)'''\ tdSql.execute('''insert into db2.`%s` (ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`) values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)'''
%(self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) ) % (self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts))
sql = " select * from db2.`%s`; " %self.regular_table sql = " select * from db2.`%s`; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(2) tdSql.checkRows(2)
sql = " select * from db2.`%s` where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10; " \ sql = " select * from db2.`%s` where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10; " \
%(self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) % (self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select count(*) from `%s`; " %self.regular_table) tdSql.query("select count(*) from `%s`; " % self.regular_table)
tdSql.checkData(0, 0, 2) tdSql.checkData(0, 0, 2)
tdSql.query("select _block_dist() from `%s` ; " %self.regular_table) tdSql.query("select _block_dist() from `%s` ; " % self.regular_table)
tdSql.checkRows(1) tdSql.checkRows(1)
sql = "select * from (select * from `%s`) ; " %self.regular_table sql = "select * from (select * from `%s`) ; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(2) tdSql.checkRows(2)
sql = "select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db2.`%s`\ sql = "select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db2.`%s`\
where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10 ) ; " \ where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10 ) ; " \
%(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,\ % (self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,
self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.regular_table, \ self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.regular_table,
self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select count(*) from (select * from `%s` ); " %self.regular_table) tdSql.query(
"select count(*) from (select * from `%s` ); " %
self.regular_table)
tdSql.checkData(0, 0, 2) tdSql.checkData(0, 0, 2)
tdSql.query("show tables like 'regular_table%' ") tdSql.query("show tables like 'regular_table%' ")
tdSql.checkRows(1) tdSql.checkRows(1)
self.crr_tb = "create_r_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" self.crr_tb = "create_r_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
tdSql.execute("create table `%s` as select * from `%s` ;" %(self.crr_tb,self.regular_table)) tdSql.execute(
"create table `%s` as select * from `%s` ;" %
(self.crr_tb, self.regular_table))
tdSql.query("show db2.tables like 'create_r_table%' ") tdSql.query("show db2.tables like 'create_r_table%' ")
tdSql.checkRows(1) tdSql.checkRows(1)
print(r"==============drop\ add\ change\ modify column ")
print("==============drop\ add\ change\ modify column ")
print("==============drop==============") print("==============drop==============")
tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_ts)) tdSql.execute(
sql = " select * from db2.`%s`; " %self.regular_table "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_ts))
sql = " select * from db2.`%s`; " % self.regular_table
datacheck = self.table1_checkall_9(sql) datacheck = self.table1_checkall_9(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_double)) tdSql.execute(
sql = " select * from `%s`; " %self.regular_table "ALTER TABLE `%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_double))
sql = " select * from `%s`; " % self.regular_table
datacheck = self.table1_checkall_8(sql) datacheck = self.table1_checkall_8(sql)
tdSql.query("describe `%s` ; " %self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(9) tdSql.checkRows(9)
tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_float)) tdSql.execute(
sql = " select * from db2.`%s`; " %self.regular_table "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_float))
sql = " select * from db2.`%s`; " % self.regular_table
datacheck = self.table1_checkall_7(sql) datacheck = self.table1_checkall_7(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(8) tdSql.checkRows(8)
tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_nchar)) tdSql.execute(
sql = " select * from `%s`; " %self.regular_table "ALTER TABLE `%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_nchar))
sql = " select * from `%s`; " % self.regular_table
datacheck = self.table1_checkall_6(sql) datacheck = self.table1_checkall_6(sql)
tdSql.query("describe `%s` ; " %self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(7) tdSql.checkRows(7)
tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_binary)) tdSql.execute(
sql = " select * from db2.`%s`; " %self.regular_table "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_binary))
sql = " select * from db2.`%s`; " % self.regular_table
datacheck = self.table1_checkall_5(sql) datacheck = self.table1_checkall_5(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(6) tdSql.checkRows(6)
tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_bool)) tdSql.execute(
sql = " select * from `%s`; " %self.regular_table "ALTER TABLE `%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_bool))
sql = " select * from `%s`; " % self.regular_table
datacheck = self.table1_checkall_4(sql) datacheck = self.table1_checkall_4(sql)
tdSql.query("describe `%s` ; " %self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(5) tdSql.checkRows(5)
tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_tinyint)) tdSql.execute(
sql = " select * from db2.`%s`; " %self.regular_table "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_tinyint))
sql = " select * from db2.`%s`; " % self.regular_table
datacheck = self.table1_checkall_3(sql) datacheck = self.table1_checkall_3(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(4) tdSql.checkRows(4)
tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_smallint)) tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %
sql = " select * from `%s`; " %self.regular_table (self.regular_table, self.col_smallint))
sql = " select * from `%s`; " % self.regular_table
datacheck = self.table1_checkall_2(sql) datacheck = self.table1_checkall_2(sql)
tdSql.query("describe `%s` ; " %self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_bigint)) tdSql.execute(
sql = " select * from db2.`%s`; " %self.regular_table "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_bigint))
sql = " select * from db2.`%s`; " % self.regular_table
datacheck = self.table1_checkall_1(sql) datacheck = self.table1_checkall_1(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.error("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_int)) tdSql.error(
tdSql.query("describe `%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_int))
tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(2) tdSql.checkRows(2)
print("==============add==============") print("==============add==============")
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` bigint; " %(self.regular_table, self.col_bigint)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` bigint; " %
(self.regular_table, self.col_bigint))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` smallint; " %(self.regular_table, self.col_smallint)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` smallint; " %
(self.regular_table, self.col_smallint))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(4) tdSql.checkRows(4)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` tinyint; " %(self.regular_table, self.col_tinyint)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` tinyint; " %
(self.regular_table, self.col_tinyint))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(5) tdSql.checkRows(5)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` bool; " %(self.regular_table, self.col_bool)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` bool; " %
(self.regular_table, self.col_bool))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(6) tdSql.checkRows(6)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` binary(20); " %(self.regular_table, self.col_binary)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` binary(20); " %
(self.regular_table, self.col_binary))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(7) tdSql.checkRows(7)
tdSql.execute("insert into db2.`%s` values(now, 1 , 2, 3, 4, 5, 6)" %self.regular_table) tdSql.execute(
sql = "select * from db2.`%s` order by ts desc; " %self.regular_table "insert into db2.`%s` values(now, 1 , 2, 3, 4, 5, 6)" %
self.regular_table)
sql = "select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall_5(sql) datacheck = self.table1_checkall_5(sql)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` nchar(20); " %(self.regular_table, self.col_nchar)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` nchar(20); " %
(self.regular_table, self.col_nchar))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(8) tdSql.checkRows(8)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` float; " %(self.regular_table, self.col_float)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` float; " %
(self.regular_table, self.col_float))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(9) tdSql.checkRows(9)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` double; " %(self.regular_table, self.col_double)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` double; " %
(self.regular_table, self.col_double))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` timestamp; " %(self.regular_table, self.col_ts)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` timestamp; " %
(self.regular_table, self.col_ts))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(11) tdSql.checkRows(11)
tdSql.execute("insert into db2.`%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %self.regular_table) tdSql.execute(
sql = "select * from db2.`%s` order by ts desc; " %self.regular_table "insert into db2.`%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %
self.regular_table)
sql = "select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
print("==============change, regular not support==============") print("==============change, regular not support==============")
print("==============modify==============") print("==============modify==============")
# TD-10810 # TD-10810
tdSql.execute("ALTER TABLE db2.`%s` MODIFY COLUMN `%s` binary(30); ; " %(self.regular_table, self.col_binary)) tdSql.execute(
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table "ALTER TABLE db2.`%s` MODIFY COLUMN `%s` binary(30); ; " %
(self.regular_table, self.col_binary))
sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(11) tdSql.checkRows(11)
tdSql.execute("ALTER TABLE `%s` MODIFY COLUMN `%s` nchar(30); ; " %(self.regular_table, self.col_nchar)) tdSql.execute(
sql = " select * from `%s` order by ts desc; " %self.regular_table "ALTER TABLE `%s` MODIFY COLUMN `%s` nchar(30); ; " %
(self.regular_table, self.col_nchar))
sql = " select * from `%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe `%s` ; " %self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(11) tdSql.checkRows(11)
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % buildPath)
binPath = buildPath + "/build/bin/"
if not os.path.exists(self.tmpdir):
os.makedirs(self.tmpdir)
else:
print("directory exists")
os.system("rm -rf %s" % self.tmpdir)
os.makedirs(self.tmpdir)
print("==============step4,#taosdump out ; drop db ; taosdumo in") print("==============step4,#taosdump out ; drop db ; taosdumo in")
assert os.system("taosdump -D db2 ") == 0 assert os.system(
"%staosdump -D db2 -o %s" %
(binPath, self.tmpdir)) == 0
tdSql.execute('''drop database if exists db2 ;''') tdSql.execute('''drop database if exists db2 ;''')
assert os.system("taosdump -i . -g") == 0 assert os.system("%staosdump -i %s -g" % (binPath, self.tmpdir)) == 0
print("==============step5,#create regular_table; insert regular_table; show regular_table; select regular_table; drop regular_table") print("==============step5,#create regular_table; insert regular_table; show regular_table; select regular_table; drop regular_table")
self.regular_table = "regular_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" self.regular_table = "regular_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
self.regular_col_base = "123@#$%^&*()-_+=[]{};:,<.>/?~!$%^" self.regular_col_base = "123@#$%^&*()-_+=[]{};:,<.>/?~!$%^"
self.col_int = "regular_table_col_int%s" %self.regular_col_base self.col_int = "regular_table_col_int%s" % self.regular_col_base
print(self.col_int) print(self.col_int)
self.col_bigint = "regular_table_col_bigint%s" %self.regular_col_base self.col_bigint = "regular_table_col_bigint%s" % self.regular_col_base
self.col_smallint = "regular_table_col_smallint%s" %self.regular_col_base self.col_smallint = "regular_table_col_smallint%s" % self.regular_col_base
self.col_tinyint = "regular_table_col_tinyint%s" %self.regular_col_base self.col_tinyint = "regular_table_col_tinyint%s" % self.regular_col_base
self.col_bool = "regular_table_col_bool%s" %self.regular_col_base self.col_bool = "regular_table_col_bool%s" % self.regular_col_base
self.col_binary = "regular_table_col_binary%s" %self.regular_col_base self.col_binary = "regular_table_col_binary%s" % self.regular_col_base
self.col_nchar = "regular_table_col_nchar%s" %self.regular_col_base self.col_nchar = "regular_table_col_nchar%s" % self.regular_col_base
self.col_float = "regular_table_col_float%s" %self.regular_col_base self.col_float = "regular_table_col_float%s" % self.regular_col_base
self.col_double = "regular_table_col_double%s" %self.regular_col_base self.col_double = "regular_table_col_double%s" % self.regular_col_base
self.col_ts = "regular_table_col_ts%s" %self.regular_col_base self.col_ts = "regular_table_col_ts%s" % self.regular_col_base
tdSql.query("describe `%s` ; "%self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(11) tdSql.checkRows(11)
tdSql.query("select _block_dist() from `%s` ; " %self.regular_table) tdSql.query("select _block_dist() from `%s` ; " % self.regular_table)
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("show create table `%s` ; " %self.regular_table) tdSql.query("show create table `%s` ; " % self.regular_table)
tdSql.checkData(0, 0, self.regular_table) tdSql.checkData(0, 0, self.regular_table)
tdSql.checkData(0, 1, "create table `%s` (`ts` TIMESTAMP,`%s` INT,`%s` BIGINT,`%s` SMALLINT,`%s` TINYINT,`%s` BOOL,`%s` BINARY(30),`%s` NCHAR(30),`%s` FLOAT,`%s` DOUBLE,`%s` TIMESTAMP)" tdSql.checkData(0, 1, "create table `%s` (`ts` TIMESTAMP,`%s` INT,`%s` BIGINT,`%s` SMALLINT,`%s` TINYINT,`%s` BOOL,`%s` BINARY(30),`%s` NCHAR(30),`%s` FLOAT,`%s` DOUBLE,`%s` TIMESTAMP)"
%(self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, % (self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool,
self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)) self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts))
tdSql.execute("insert into `%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %self.regular_table) tdSql.execute(
sql = "select * from `%s` order by ts desc; " %self.regular_table "insert into `%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %
self.regular_table)
sql = "select * from `%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(5) tdSql.checkRows(5)
sql = '''select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db2.`%s` order by ts desc; '''\ sql = '''select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db2.`%s` order by ts desc; '''\
%(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.regular_table) % (self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.regular_table)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(5) tdSql.checkRows(5)
time.sleep(1) time.sleep(1)
tdSql.execute('''insert into db2.`%s` (ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`) values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)'''\ tdSql.execute('''insert into db2.`%s` (ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`) values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)'''
%(self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) ) % (self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts))
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(6) tdSql.checkRows(6)
sql = " select * from db2.`%s` where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10; " \ sql = " select * from db2.`%s` where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10; " \
%(self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) % (self.regular_table, self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(3) # CBD tdSql.checkRows(3)
tdSql.query("select count(*) from `%s` order by ts desc; " %self.regular_table) tdSql.query(
"select count(*) from `%s` order by ts desc; " %
self.regular_table)
tdSql.checkData(0, 0, 6) tdSql.checkData(0, 0, 6)
tdSql.query("select _block_dist() from `%s` ; " %self.regular_table) tdSql.query("select _block_dist() from `%s` ; " % self.regular_table)
tdSql.checkRows(1) tdSql.checkRows(1)
sql = "select * from (select * from `%s` order by ts desc) ; " %self.regular_table sql = "select * from (select * from `%s` order by ts desc) ; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(6) tdSql.checkRows(6)
sql = "select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db2.`%s`\ sql = "select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from (select ts ,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s`,`%s` from db2.`%s`\
where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10 ) ; " \ where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10 ) ; " \
%(self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,\ % (self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts,
self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.regular_table, \ self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts, self.regular_table,
self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts) self.col_int, self.col_bigint, self.col_smallint, self.col_tinyint, self.col_bool, self.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.checkRows(3) # CBD tdSql.checkRows(3)
tdSql.query("select count(*) from (select * from `%s` ); " %self.regular_table) tdSql.query(
"select count(*) from (select * from `%s` ); " %
self.regular_table)
tdSql.checkData(0, 0, 6) tdSql.checkData(0, 0, 6)
tdSql.query("show tables like 'regular_table%' ") tdSql.query("show tables like 'regular_table%' ")
...@@ -898,113 +1129,156 @@ class TDTestCase: ...@@ -898,113 +1129,156 @@ class TDTestCase:
tdSql.query("show db2.tables like 'create_r_table%' ") tdSql.query("show db2.tables like 'create_r_table%' ")
tdSql.checkRows(1) tdSql.checkRows(1)
print("==============drop\ add\ change\ modify column ") print(r"==============drop\ add\ change\ modify column ")
print("==============drop==============") print("==============drop==============")
tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_ts)) tdSql.execute(
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_ts))
sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall_9(sql) datacheck = self.table1_checkall_9(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_double)) tdSql.execute(
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table "ALTER TABLE `%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_double))
sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall_8(sql) datacheck = self.table1_checkall_8(sql)
tdSql.query("describe `%s` ; " %self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(9) tdSql.checkRows(9)
tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_float)) tdSql.execute(
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_float))
sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall_7(sql) datacheck = self.table1_checkall_7(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(8) tdSql.checkRows(8)
tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_nchar)) tdSql.execute(
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table "ALTER TABLE `%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_nchar))
sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall_6(sql) datacheck = self.table1_checkall_6(sql)
tdSql.query("describe `%s` ; " %self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(7) tdSql.checkRows(7)
tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_binary)) tdSql.execute(
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_binary))
sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall_5(sql) datacheck = self.table1_checkall_5(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(6) tdSql.checkRows(6)
tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_bool)) tdSql.execute(
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table "ALTER TABLE `%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_bool))
sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall_4(sql) datacheck = self.table1_checkall_4(sql)
tdSql.query("describe `%s` ; " %self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(5) tdSql.checkRows(5)
tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_tinyint)) tdSql.execute(
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_tinyint))
sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall_3(sql) datacheck = self.table1_checkall_3(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(4) tdSql.checkRows(4)
tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_smallint)) tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table (self.regular_table, self.col_smallint))
sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall_2(sql) datacheck = self.table1_checkall_2(sql)
tdSql.query("describe `%s` ; " %self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.execute("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_bigint)) tdSql.execute(
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_bigint))
sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall_1(sql) datacheck = self.table1_checkall_1(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.error("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_int)) tdSql.error(
tdSql.query("describe `%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %
(self.regular_table, self.col_int))
tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(2) tdSql.checkRows(2)
print("==============add==============") print("==============add==============")
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` bigint; " %(self.regular_table, self.col_bigint)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` bigint; " %
(self.regular_table, self.col_bigint))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` smallint; " %(self.regular_table, self.col_smallint)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` smallint; " %
(self.regular_table, self.col_smallint))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(4) tdSql.checkRows(4)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` tinyint; " %(self.regular_table, self.col_tinyint)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` tinyint; " %
(self.regular_table, self.col_tinyint))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(5) tdSql.checkRows(5)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` bool; " %(self.regular_table, self.col_bool)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` bool; " %
(self.regular_table, self.col_bool))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(6) tdSql.checkRows(6)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` binary(20); " %(self.regular_table, self.col_binary)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` binary(20); " %
(self.regular_table, self.col_binary))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(7) tdSql.checkRows(7)
tdSql.execute("insert into db2.`%s` values(now, 1 , 2, 3, 4, 5, 6)" %self.regular_table) tdSql.execute(
sql = "select * from db2.`%s` order by ts desc; " %self.regular_table "insert into db2.`%s` values(now, 1 , 2, 3, 4, 5, 6)" %
self.regular_table)
sql = "select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall_5(sql) datacheck = self.table1_checkall_5(sql)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` nchar(20); " %(self.regular_table, self.col_nchar)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` nchar(20); " %
(self.regular_table, self.col_nchar))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(8) tdSql.checkRows(8)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` float; " %(self.regular_table, self.col_float)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` float; " %
(self.regular_table, self.col_float))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(9) tdSql.checkRows(9)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` double; " %(self.regular_table, self.col_double)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` double; " %
(self.regular_table, self.col_double))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.execute("ALTER TABLE db2.`%s` ADD COLUMN `%s` timestamp; " %(self.regular_table, self.col_ts)) tdSql.execute(
tdSql.query("describe db2.`%s` ; " %self.regular_table) "ALTER TABLE db2.`%s` ADD COLUMN `%s` timestamp; " %
(self.regular_table, self.col_ts))
tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(11) tdSql.checkRows(11)
tdSql.execute("insert into db2.`%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %self.regular_table) tdSql.execute(
sql = "select * from db2.`%s` order by ts desc; " %self.regular_table "insert into db2.`%s` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)" %
self.regular_table)
sql = "select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
print("==============change, regular not support==============") print("==============change, regular not support==============")
print("==============modify==============") print("==============modify==============")
# TD-10810 # TD-10810
tdSql.execute("ALTER TABLE db2.`%s` MODIFY COLUMN `%s` binary(40); ; " %(self.regular_table, self.col_binary)) tdSql.execute(
sql = " select * from db2.`%s` order by ts desc; " %self.regular_table "ALTER TABLE db2.`%s` MODIFY COLUMN `%s` binary(40); ; " %
(self.regular_table, self.col_binary))
sql = " select * from db2.`%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe db2.`%s` ; " %self.regular_table) tdSql.query("describe db2.`%s` ; " % self.regular_table)
tdSql.checkRows(11) tdSql.checkRows(11)
tdSql.execute("ALTER TABLE `%s` MODIFY COLUMN `%s` nchar(40); ; " %(self.regular_table, self.col_nchar)) tdSql.execute(
sql = " select * from `%s` order by ts desc; " %self.regular_table "ALTER TABLE `%s` MODIFY COLUMN `%s` nchar(40); ; " %
(self.regular_table, self.col_nchar))
sql = " select * from `%s` order by ts desc; " % self.regular_table
datacheck = self.table1_checkall(sql) datacheck = self.table1_checkall(sql)
tdSql.query("describe `%s` ; " %self.regular_table) tdSql.query("describe `%s` ; " % self.regular_table)
tdSql.checkRows(11) tdSql.checkRows(11)
os.system("rm db*") os.system("rm %s/db*" % self.tmpdir)
os.system("rm dump_result.txt*") os.system("rm dump_result.txt*")
def stop(self): def stop(self):
......
...@@ -51,7 +51,52 @@ function dohavecore(){ ...@@ -51,7 +51,52 @@ function dohavecore(){
fi fi
fi fi
} }
function runSimCaseOneByOnefq {
end=`sed -n '$=' jenkins/basic.txt`
for ((i=1;i<=$end;i++)) ; do
if [[ $(($i%$1)) -eq $3 ]];then
line=`sed -n "$i"p jenkins/basic.txt`
if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then
case=`echo $line | grep sim$ |awk '{print $NF}'`
start_time=`date +%s`
date +%F\ %T | tee -a out.log
if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
echo -n $case
./test.sh -f $case > case.log 2>&1 && \
( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
( grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \
( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && cat case.log )
else
echo -n $case
./test.sh -f $case > ../../sim/case.log 2>&1 && \
( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
( grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \
( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && cat case.log )
fi
out_log=`tail -1 out.log `
if [[ $out_log =~ 'failed' ]];then
rm case.log
if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
cp -r ../../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S"`
else
cp -r ../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" `
fi
dohavecore $2 1
if [[ $2 == 1 ]];then
exit 8
fi
fi
end_time=`date +%s`
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a out.log
dohavecore $2 1
fi
fi
done
rm -rf ../../../sim/case.log
rm -rf ../../sim/case.log
}
function runPyCaseOneByOne { function runPyCaseOneByOne {
while read -r line; do while read -r line; do
...@@ -173,7 +218,6 @@ if [ "${OS}" == "Linux" ]; then ...@@ -173,7 +218,6 @@ if [ "${OS}" == "Linux" ]; then
fi fi
echo "### run Python test case ###"
cd $tests_dir cd $tests_dir
...@@ -204,6 +248,10 @@ if [ "$1" == "full" ]; then ...@@ -204,6 +248,10 @@ if [ "$1" == "full" ]; then
runPyCaseOneByOne fulltest-other.sh runPyCaseOneByOne fulltest-other.sh
runPyCaseOneByOne fulltest-insert.sh runPyCaseOneByOne fulltest-insert.sh
runPyCaseOneByOne fulltest-connector.sh runPyCaseOneByOne fulltest-connector.sh
elif [ "$1" == "sim" ]; then
echo "### run sim $2 test ###"
cd $tests_dir/script
runSimCaseOneByOnefq $2 1 $3
else else
echo "### run $1 $2 test ###" echo "### run $1 $2 test ###"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册