diff --git a/Jenkinsfile b/Jenkinsfile index d606479006c50afc976361208175762899c87e5e..491e70742825fb9d655ca76321085a133c4aea63 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -456,23 +456,42 @@ pipeline { nohup taosd >/dev/null & sleep 10 ''' + sh ''' - cd ${WKC}/tests/examples/nodejs - npm install td2.0-connector > /dev/null 2>&1 - node nodejsChecker.js host=localhost - node test1970.js - cd ${WKC}/tests/connectorTest/nodejsTest/nanosupport - npm install td2.0-connector > /dev/null 2>&1 - node nanosecondTest.js + cd ${WKC}/src/connector/python + export PYTHONPATH=$PWD/ + export LD_LIBRARY_PATH=${WKC}/debug/build/lib + pip3 install pytest + pytest tests/ + python3 examples/bind-multi.py + python3 examples/bind-row.py + python3 examples/demo.py + python3 examples/insert-lines.py + python3 examples/pep-249.py + python3 examples/query-async.py + python3 examples/query-objectively.py + python3 examples/subscribe-sync.py + python3 examples/subscribe-async.py + ''' + + sh ''' + cd ${WKC}/tests/examples/nodejs + npm install td2.0-connector > /dev/null 2>&1 + node nodejsChecker.js host=localhost + node test1970.js + cd ${WKC}/tests/connectorTest/nodejsTest/nanosupport + npm install td2.0-connector > /dev/null 2>&1 + node nanosecondTest.js ''' catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { sh ''' cd ${WKC}/tests/examples/C#/taosdemo - mcs -out:taosdemo *.cs > /dev/null 2>&1 - echo '' |./taosdemo -c /etc/taos + dotnet build -c Release + tree | true + ./bin/Release/net5.0/taosdemo -c /etc/taos -y ''' - } + } sh ''' cd ${WKC}/tests/gotest bash batchtest.sh diff --git a/packaging/cfg/taosd.service b/packaging/cfg/taosd.service index fff4b74e62a6da8f2bda9a6306a79132d7585e42..452488b4e951e36c043c823e17cca5ab7dbfd21b 100644 --- a/packaging/cfg/taosd.service +++ b/packaging/cfg/taosd.service @@ -1,7 +1,7 @@ [Unit] Description=TDengine server service -After=network-online.target -Wants=network-online.target +After=network-online.target taosadapter.service +Wants=network-online.target taosadapter.service [Service] Type=simple diff --git a/packaging/release.sh b/packaging/release.sh index 8eaf18774232e10c0435d1bf9e78ed42e16bdac6..ca8715f68430fc08b86f008936ddfc9409ae58a8 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -3,7 +3,7 @@ # Generate the deb package for ubuntu, or rpm package for centos, or tar.gz package for other linux os set -e -#set -x +set -x # release.sh -v [cluster | edge] # -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] @@ -414,10 +414,14 @@ fi if [[ "$httpdBuild" == "true" ]]; then BUILD_HTTP=true - BUILD_TOOLS=false else BUILD_HTTP=false +fi + +if [[ "$pagMode" == "full" ]]; then BUILD_TOOLS=true +else + BUILD_TOOLS=false fi # check support cpu type @@ -514,15 +518,17 @@ if [ "$osType" != "Darwin" ]; then cd ${script_dir}/deb ${csudo} ./makedeb.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType} - if [ -d ${top_dir}/src/kit/taos-tools/packaging/deb ]; then - cd ${top_dir}/src/kit/taos-tools/packaging/deb - [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" + if [[ "$pagMode" == "full" ]]; then + if [ -d ${top_dir}/src/kit/taos-tools/packaging/deb ]; then + cd ${top_dir}/src/kit/taos-tools/packaging/deb + [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" - taos_tools_ver=$(git describe --tags|sed -e 's/ver-//g'|awk -F '-' '{print $1}') - ${csudo} ./make-taos-tools-deb.sh ${top_dir} \ - ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType} + taos_tools_ver=$(git describe --tags|sed -e 's/ver-//g'|awk -F '-' '{print $1}') + ${csudo} ./make-taos-tools-deb.sh ${top_dir} \ + ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType} + fi fi - else + else echo "==========dpkg command not exist, so not release deb package!!!" fi ret='0' @@ -537,15 +543,17 @@ if [ "$osType" != "Darwin" ]; then cd ${script_dir}/rpm ${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType} - if [ -d ${top_dir}/src/kit/taos-tools/packaging/rpm ]; then - cd ${top_dir}/src/kit/taos-tools/packaging/rpm - [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" + if [[ "$pagMode" == "full" ]]; then + if [ -d ${top_dir}/src/kit/taos-tools/packaging/rpm ]; then + cd ${top_dir}/src/kit/taos-tools/packaging/rpm + [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" - taos_tools_ver=$(git describe --tags|sed -e 's/ver-//g'|awk -F '-' '{print $1}'|sed -e 's/-/_/g') - ${csudo} ./make-taos-tools-rpm.sh ${top_dir} \ - ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType} + taos_tools_ver=$(git describe --tags|sed -e 's/ver-//g'|awk -F '-' '{print $1}'|sed -e 's/-/_/g') + ${csudo} ./make-taos-tools-rpm.sh ${top_dir} \ + ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType} + fi fi - else + else echo "==========rpmbuild command not exist, so not release rpm package!!!" fi fi diff --git a/packaging/tools/install_client_jh.sh b/packaging/tools/install_client_jh.sh index cccf0a97be053796099d5b5f4a2c3db018c24955..a8599812feaea06120aa3391771e7c94523a53c2 100755 --- a/packaging/tools/install_client_jh.sh +++ b/packaging/tools/install_client_jh.sh @@ -188,9 +188,6 @@ function update() { install_log install_header install_lib - if [ "$pagMode" != "lite" ]; then - install_connector - fi install_examples install_bin install_config @@ -215,9 +212,6 @@ function install() { install_log install_header install_lib - if [ "$pagMode" != "lite" ]; then - install_connector - fi install_examples install_bin install_config diff --git a/packaging/tools/install_client_kh.sh b/packaging/tools/install_client_kh.sh index 210fd27fb6978527d76f0c915d0293370b93cf3e..3e7df18486a20b9ea75dba3d2644d46bee6b423b 100755 --- a/packaging/tools/install_client_kh.sh +++ b/packaging/tools/install_client_kh.sh @@ -189,9 +189,6 @@ function update() { install_log install_header install_lib - if [ "$pagMode" != "lite" ]; then - install_connector - fi install_examples install_bin install_config @@ -216,9 +213,6 @@ function install() { install_log install_header install_lib - if [ "$pagMode" != "lite" ]; then - install_connector - fi install_examples install_bin install_config diff --git a/packaging/tools/install_client_power.sh b/packaging/tools/install_client_power.sh index f96b0134dc34f61425410360d0b0f935da7b39e5..3c9abddb09646ea54f44e28664afea49822055f6 100755 --- a/packaging/tools/install_client_power.sh +++ b/packaging/tools/install_client_power.sh @@ -247,9 +247,6 @@ function update_PowerDB() { install_log install_header install_lib - if [ "$pagMode" != "lite" ]; then - install_connector - fi install_examples install_bin install_config @@ -275,9 +272,6 @@ function install_PowerDB() { install_header install_lib install_jemalloc - if [ "$pagMode" != "lite" ]; then - install_connector - fi install_examples install_bin install_config diff --git a/packaging/tools/install_client_pro.sh b/packaging/tools/install_client_pro.sh index c21f9d2e6aa685096eb55dcc03924bf453906b8f..e34dc6d4ac1d1ef1715ff903b38b1a8735001985 100755 --- a/packaging/tools/install_client_pro.sh +++ b/packaging/tools/install_client_pro.sh @@ -189,9 +189,6 @@ function update_prodb() { install_log install_header install_lib - if [ "$pagMode" != "lite" ]; then - install_connector - fi install_examples install_bin install_config @@ -216,9 +213,6 @@ function install_prodb() { install_log install_header install_lib - if [ "$pagMode" != "lite" ]; then - install_connector - fi install_examples install_bin install_config diff --git a/packaging/tools/install_client_tq.sh b/packaging/tools/install_client_tq.sh index 31a75f4fe74fbb4c68942f226602fa2117e1a01c..b7f10324dcd1c62fee20fe11399fbb61d8a38577 100755 --- a/packaging/tools/install_client_tq.sh +++ b/packaging/tools/install_client_tq.sh @@ -193,9 +193,6 @@ function update_tq() { install_log install_header install_lib - if [ "$pagMode" != "lite" ]; then - install_connector - fi install_examples install_bin install_config @@ -220,9 +217,6 @@ function install_tq() { install_log install_header install_lib - if [ "$pagMode" != "lite" ]; then - install_connector - fi install_examples install_bin install_config diff --git a/packaging/tools/makeclient_jh.sh b/packaging/tools/makeclient_jh.sh index 267d78b953be33c567f8175a369b13f326ee3f5a..ed61cffaf793ede0f774fa1ba2c81d7645f714dc 100755 --- a/packaging/tools/makeclient_jh.sh +++ b/packaging/tools/makeclient_jh.sh @@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then if [ "$pagMode" == "lite" ]; then strip ${build_dir}/bin/taos cp ${build_dir}/bin/taos ${install_dir}/bin/jh_taos - cp ${script_dir}/remove_jh.sh ${install_dir}/bin + cp ${script_dir}/remove_client_jh.sh ${install_dir}/bin else cp ${build_dir}/bin/taos ${install_dir}/bin/jh_taos - cp ${script_dir}/remove_jh.sh ${install_dir}/bin + cp ${script_dir}/remove_client_jh.sh ${install_dir}/bin cp ${build_dir}/bin/taosdemo ${install_dir}/bin/jhdemo cp ${build_dir}/bin/taosdump ${install_dir}/bin/jh_taosdump cp ${script_dir}/set_core.sh ${install_dir}/bin diff --git a/packaging/tools/makeclient_kh.sh b/packaging/tools/makeclient_kh.sh index b991e2a6fae69a72d678cf5ff8751429a9f88fc6..86d37105a4acd3fcefbfa8d230804d7d2f820fb5 100755 --- a/packaging/tools/makeclient_kh.sh +++ b/packaging/tools/makeclient_kh.sh @@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then if [ "$pagMode" == "lite" ]; then strip ${build_dir}/bin/taos cp ${build_dir}/bin/taos ${install_dir}/bin/khclient - cp ${script_dir}/remove_kh.sh ${install_dir}/bin + cp ${script_dir}/remove_client_kh.sh ${install_dir}/bin else cp ${build_dir}/bin/taos ${install_dir}/bin/khclient - cp ${script_dir}/remove_kh.sh ${install_dir}/bin + cp ${script_dir}/remove_client_kh.sh ${install_dir}/bin cp ${build_dir}/bin/taosdemo ${install_dir}/bin/khdemo cp ${build_dir}/bin/taosdump ${install_dir}/bin/khdump cp ${script_dir}/set_core.sh ${install_dir}/bin diff --git a/packaging/tools/makeclient_power.sh b/packaging/tools/makeclient_power.sh index 07dc9d30d21e130aff15f1c84a3db7e209867f88..2f01748f5e40925b905a715b3c308692d46e71b0 100755 --- a/packaging/tools/makeclient_power.sh +++ b/packaging/tools/makeclient_power.sh @@ -109,10 +109,10 @@ if [ "$osType" != "Darwin" ]; then if [ "$pagMode" == "lite" ]; then strip ${build_dir}/bin/taos cp ${build_dir}/bin/taos ${install_dir}/bin/power - cp ${script_dir}/remove_power.sh ${install_dir}/bin + cp ${script_dir}/remove_client_power.sh ${install_dir}/bin else cp ${build_dir}/bin/taos ${install_dir}/bin/power - cp ${script_dir}/remove_power.sh ${install_dir}/bin + cp ${script_dir}/remove_client_power.sh ${install_dir}/bin cp ${build_dir}/bin/taosdemo ${install_dir}/bin/powerdemo cp ${build_dir}/bin/taosdump ${install_dir}/bin/powerdump cp ${script_dir}/set_core.sh ${install_dir}/bin diff --git a/packaging/tools/makeclient_pro.sh b/packaging/tools/makeclient_pro.sh index 0c5033d87dd5815e9e3ec309e6b1bb9abe98ca42..769d0274e5eb5198fedb6c6c3a7f1590fd2ff44a 100755 --- a/packaging/tools/makeclient_pro.sh +++ b/packaging/tools/makeclient_pro.sh @@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then if [ "$pagMode" == "lite" ]; then strip ${build_dir}/bin/taos cp ${build_dir}/bin/taos ${install_dir}/bin/prodbc - cp ${script_dir}/remove_pro.sh ${install_dir}/bin + cp ${script_dir}/remove_client_pro.sh ${install_dir}/bin else cp ${build_dir}/bin/taos ${install_dir}/bin/prodbc - cp ${script_dir}/remove_pro.sh ${install_dir}/bin + cp ${script_dir}/remove_client_pro.sh ${install_dir}/bin cp ${build_dir}/bin/taosdemo ${install_dir}/bin/prodemo cp ${build_dir}/bin/taosdump ${install_dir}/bin/prodump cp ${script_dir}/set_core.sh ${install_dir}/bin diff --git a/packaging/tools/makeclient_tq.sh b/packaging/tools/makeclient_tq.sh index 3ed97520939be51f2f634f8955f16ecf9a46821b..f8d87ba76a9ab32ea729d4999a05712976a32634 100755 --- a/packaging/tools/makeclient_tq.sh +++ b/packaging/tools/makeclient_tq.sh @@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then if [ "$pagMode" == "lite" ]; then strip ${build_dir}/bin/taos cp ${build_dir}/bin/taos ${install_dir}/bin/tq - cp ${script_dir}/remove_tq.sh ${install_dir}/bin + cp ${script_dir}/remove_client_tq.sh ${install_dir}/bin else cp ${build_dir}/bin/taos ${install_dir}/bin/tq - cp ${script_dir}/remove_tq.sh ${install_dir}/bin + cp ${script_dir}/remove_client_tq.sh ${install_dir}/bin cp ${build_dir}/bin/taosdemo ${install_dir}/bin/tqdemo cp ${build_dir}/bin/taosdump ${install_dir}/bin/tqdump cp ${script_dir}/set_core.sh ${install_dir}/bin diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index de3b7a4b3da6971b2c84bcaaaee2478787fc15cc..98d6ff8e4d6fe3cc4c08691ab027622b7410e32d 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -886,7 +886,7 @@ static int32_t applyChildTableDataPointsWithInsertSQL(TAOS* taos, char* cTableNa TAOS_RES* res = taos_query(taos, sql); free(sql); code = taos_errno(res); - info->affectedRows = taos_affected_rows(res); + info->affectedRows += taos_affected_rows(res); taos_free_result(res); return code; } @@ -1302,14 +1302,6 @@ clean_up: return code; } -int tsc_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { - SSmlLinesInfo* info = calloc(1, sizeof(SSmlLinesInfo)); - info->id = genLinesSmlId(); - int code = tscSmlInsert(taos, points, numPoint, info); - free(info); - return code; -} - //========================================================================= /* Field Escape charaters diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 215861295fa0ff94352956fa3fd740ace9e90766..8d1a79e734cabf6694daf30d8887265488bcf630 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -1533,6 +1533,41 @@ int stmtGenInsertStatement(SSqlObj* pSql, STscStmt* pStmt, const char* name, TAO return TSDB_CODE_SUCCESS; } +int32_t stmtValidateValuesFields(SSqlCmd *pCmd, char * sql) { + int32_t loopCont = 1, index0 = 0, values = 0; + SStrToken sToken; + + while (loopCont) { + sToken = tStrGetToken(sql, &index0, false); + if (sToken.n <= 0) { + return TSDB_CODE_SUCCESS; + } + + switch (sToken.type) { + case TK_RP: + if (values) { + return TSDB_CODE_SUCCESS; + } + break; + case TK_VALUES: + values = 1; + break; + case TK_QUESTION: + case TK_LP: + break; + default: + if (values) { + tscError("only ? allowed in values"); + return tscInvalidOperationMsg(pCmd->payload, "only ? allowed in values", NULL); + } + break; + } + } + + return TSDB_CODE_SUCCESS; +} + + //////////////////////////////////////////////////////////////////////////////// // interface functions @@ -1637,6 +1672,11 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { STMT_RET(ret); } + ret = stmtValidateValuesFields(&pSql->cmd, pSql->sqlstr); + if (ret != TSDB_CODE_SUCCESS) { + STMT_RET(ret); + } + if (pStmt->multiTbInsert) { STMT_RET(TSDB_CODE_SUCCESS); } diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index e799215ece7e505c8991dd1c19f426852e22c40a..a775f3982a64a63c1f9b1b4f1f84aad591ae6fa6 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3524,7 +3524,9 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) { return TSDB_CODE_TSC_INVALID_OPERATION; } - strncpy(pCmd->payload, idStr->z, idStr->n); + SKillQueryMsg* msg = (SKillQueryMsg*)pCmd->payload; + + strncpy(msg->queryId, idStr->z, idStr->n); const char delim = ':'; char* connIdStr = strtok(idStr->z, &delim); @@ -3532,7 +3534,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) { int32_t connId = (int32_t)strtol(connIdStr, NULL, 10); if (connId <= 0) { - memset(pCmd->payload, 0, strlen(pCmd->payload)); + memset(msg, 0, sizeof(*msg)); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -3542,7 +3544,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) { int32_t queryId = (int32_t)strtol(queryIdStr, NULL, 10); if (queryId <= 0) { - memset(pCmd->payload, 0, strlen(pCmd->payload)); + memset(msg, 0, sizeof(*msg)); if (killType == TSDB_SQL_KILL_QUERY) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } else { @@ -9821,6 +9823,9 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS assert(pSqlExpr->pRight == NULL); if (pSqlExpr->type == SQL_NODE_VALUE) { + if(pSqlExpr->value.nType == -1){ + return TSDB_CODE_TSC_INVALID_VALUE; + } int32_t ret = TSDB_CODE_SUCCESS; *pExpr = calloc(1, sizeof(tExprNode)); (*pExpr)->nodeType = TSQL_NODE_VALUE; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index b661f8918dd2a9ca6b3ac7abbd2b481953c08438..35582973c2af7b214d3054807d31a897c7256191 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -506,7 +506,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { } } - if (pRes->code == TSDB_CODE_SUCCESS && tscProcessMsgRsp[pCmd->command]) { + if (pRes->code == TSDB_CODE_SUCCESS && pCmd->command < TSDB_SQL_MAX && tscProcessMsgRsp[pCmd->command]) { rpcMsg->code = (*tscProcessMsgRsp[pCmd->command])(pSql); } @@ -906,6 +906,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SArray* queryOperator = createExecOperatorPlan(&query); SQueryTableMsg *pQueryMsg = (SQueryTableMsg *)pCmd->payload; + tstrncpy(pQueryMsg->version, version, tListLen(pQueryMsg->version)); int32_t numOfTags = query.numOfTags; @@ -1146,6 +1147,23 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { memcpy(pMsg, pSql->sqlstr, sqlLen); pMsg += sqlLen; + +/* + //MSG EXTEND DEMO + pQueryMsg->extend = 1; + + STLV *tlv = (STLV *)pMsg; + tlv->type = htons(TLV_TYPE_DUMMY); + tlv->len = htonl(sizeof(int16_t)); + *(int16_t *)tlv->value = htons(12345); + pMsg += sizeof(*tlv) + ntohl(tlv->len); + + tlv = (STLV *)pMsg; + tlv->len = 0; + pMsg += sizeof(*tlv); + +*/ + int32_t msgLen = (int32_t)(pMsg - pCmd->payload); tscDebug("0x%"PRIx64" msg built success, len:%d bytes", pSql->self, msgLen); @@ -2806,7 +2824,11 @@ static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaIn tscAddQueryInfo(&pNew->cmd); SQueryInfo *pNewQueryInfo = tscGetQueryInfoS(&pNew->cmd); - if (TSDB_CODE_SUCCESS != tscAllocPayload(&pNew->cmd, TSDB_DEFAULT_PAYLOAD_SIZE + pSql->cmd.payloadLen)) { + int payLoadLen = TSDB_DEFAULT_PAYLOAD_SIZE + pSql->cmd.payloadLen; + if (autocreate && pSql->cmd.insertParam.tagData.dataLen != 0) { + payLoadLen += pSql->cmd.insertParam.tagData.dataLen; + } + if (TSDB_CODE_SUCCESS != tscAllocPayload(&pNew->cmd, payLoadLen)) { tscError("0x%"PRIx64" malloc failed for payload to get table meta", pSql->self); tscFreeSqlObj(pNew); diff --git a/src/common/inc/tvariant.h b/src/common/inc/tvariant.h index 03b17bdc463d6b5d0f812eafa723c886964d35fc..31bc7a247ad9851aa48d99a3c6eec31e90313972 100644 --- a/src/common/inc/tvariant.h +++ b/src/common/inc/tvariant.h @@ -25,7 +25,7 @@ extern "C" { // variant, each number/string/field_id has a corresponding struct during parsing sql typedef struct tVariant { - uint32_t nType; + int32_t nType; // change uint to int, because in tVariantCreate() pVar->nType = -1; // -1 means error type int32_t nLen; // only used for string, for number, it is useless union { int64_t i64; diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c index 8af44cdf12c510f85a3dac16523ffe6a4c8e09f5..68ed5c5c109cdfacb5ffac50e4f424ec431b78a0 100644 --- a/src/common/src/tvariant.c +++ b/src/common/src/tvariant.c @@ -285,7 +285,7 @@ void tVariantAssign(tVariant *pDst, const tVariant *pSrc) { } } - if (pDst->nType != TSDB_DATA_TYPE_POINTER_ARRAY && pDst->nType != TSDB_DATA_TYPE_VALUE_ARRAY) { + if (pDst->nType != TSDB_DATA_TYPE_POINTER_ARRAY && pDst->nType != TSDB_DATA_TYPE_VALUE_ARRAY && isValidDataType(pDst->nType)) { // if pDst->nType=-1, core dump. eg: where intcolumn=999999999999999999999999999 pDst->nLen = tDataTypes[pDst->nType].bytes; } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java index e17548055c792e900a1e2fb5b510de8bf65de7a7..07553d7ef4e1ea0745d25523d0fd1612086c3826 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java @@ -11,6 +11,11 @@ import java.util.Map; public abstract class AbstractResultSet extends WrapperImpl implements ResultSet { private int fetchSize; protected boolean wasNull; + protected int timestampPrecision; + + public void setTimestampPrecision(int timestampPrecision) { + this.timestampPrecision = timestampPrecision; + } protected void checkAvailability(int columnIndex, int bounds) throws SQLException { if (isClosed()) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java index 3814186f779203741001943efe47b85c0be83acb..003324d27a57c3557f0bb3205fcee208aa776ed5 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java @@ -74,9 +74,8 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { public boolean next() throws SQLException { if (this.getBatchFetch()) { - if (this.blockData.forward()) { + if (this.blockData.forward()) return true; - } int code = this.jniConnector.fetchBlock(this.resultSetPointer, this.blockData); this.blockData.reset(); @@ -214,7 +213,18 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (!lastWasNull) { Object value = this.rowData.getObject(columnIndex); if (value instanceof Timestamp) { - res = ((Timestamp) value).getTime(); + Timestamp ts = (Timestamp) value; + long epochSec = ts.getTime() / 1000; + long nanoAdjustment = ts.getNanos(); + switch (this.timestampPrecision) { + case 0: + default: // ms + return ts.getTime(); + case 1: // us + return epochSec * 1000_000L + nanoAdjustment / 1000L; + case 2: // ns + return epochSec * 1000_000_000L + nanoAdjustment; + } } else { int nativeType = this.columnMetaDataList.get(columnIndex - 1).getColType(); res = this.rowData.getLong(columnIndex, nativeType); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java index 2c77df2981e18931d6cb56cca84bb2115716b349..ce877987e6e9073defbff62e283910ee34366c4d 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java @@ -47,6 +47,8 @@ public class TSDBStatement extends AbstractStatement { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY); } TSDBResultSet res = new TSDBResultSet(this, this.connection.getConnector(), pSql); + int timestampPrecision = this.connection.getConnector().getResultTimePrecision(pSql); + res.setTimestampPrecision(timestampPrecision); res.setBatchFetch(this.connection.getBatchFetch()); return res; } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/enums/TimestampPrecision.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/enums/TimestampPrecision.java index 79350076c7f4b31743ab9fb61226e506186f0f17..4558dfa84bfccacf9f0d4fa2d7991c8bd0546b30 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/enums/TimestampPrecision.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/enums/TimestampPrecision.java @@ -1,8 +1,7 @@ package com.taosdata.jdbc.enums; -public enum TimestampPrecision { - MS, - US, - NS, - UNKNOWN +public class TimestampPrecision { + public static final int MS = 0; + public static final int US = 1; + public static final int NS = 2; } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java index f3e3f138df8fc854817c0adf57c5f5453f52bf05..d4c30115f851aa0f8b6f80994bbece609649428d 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java @@ -168,11 +168,22 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { case TIMESTAMP: { Long value = row.getLong(colIndex); //TODO: this implementation has bug if the timestamp bigger than 9999_9999_9999_9 - if (value < 1_0000_0000_0000_0L) + if (value < 1_0000_0000_0000_0L) { + this.timestampPrecision = TimestampPrecision.MS; return new Timestamp(value); - long epochSec = value / 1000_000L; - long nanoAdjustment = value % 1000_000L * 1000L; - return Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); + } + if (value >= 1_0000_0000_0000_0L && value < 1_000_000_000_000_000_0l) { + this.timestampPrecision = TimestampPrecision.US; + long epochSec = value / 1000_000L; + long nanoAdjustment = value % 1000_000L * 1000L; + return Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); + } + if (value >= 1_000_000_000_000_000_0l) { + this.timestampPrecision = TimestampPrecision.NS; + long epochSec = value / 1000_000_000L; + long nanoAdjustment = value % 1000_000_000L; + return Timestamp.from(Instant.ofEpochSecond(epochSec, nanoAdjustment)); + } } case UTC: { String value = row.getString(colIndex); @@ -182,12 +193,15 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { if (value.length() > 31) { // ns timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSSSSS+0x00 nanoAdjustment = fractionalSec; + this.timestampPrecision = TimestampPrecision.NS; } else if (value.length() > 28) { // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSS+0x00 nanoAdjustment = fractionalSec * 1000L; + this.timestampPrecision = TimestampPrecision.US; } else { // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSS+0x00 nanoAdjustment = fractionalSec * 1000_000L; + this.timestampPrecision = TimestampPrecision.MS; } ZoneOffset zoneOffset = ZoneOffset.of(value.substring(value.length() - 5)); Instant instant = Instant.ofEpochSecond(epochSec, nanoAdjustment).atOffset(zoneOffset).toInstant(); @@ -196,7 +210,9 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { case STRING: default: { String value = row.getString(colIndex); - TimestampPrecision precision = Utils.guessTimestampPrecision(value); + int precision = Utils.guessTimestampPrecision(value); + this.timestampPrecision = precision; + if (precision == TimestampPrecision.MS) { // ms timestamp: yyyy-MM-dd HH:mm:ss.SSS return row.getTimestamp(colIndex); @@ -338,8 +354,18 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { wasNull = value == null; if (value == null) return 0; - if (value instanceof Timestamp) - return ((Timestamp) value).getTime(); + if (value instanceof Timestamp) { + Timestamp ts = (Timestamp) value; + switch (this.timestampPrecision) { + case TimestampPrecision.MS: + default: + return ts.getTime(); + case TimestampPrecision.US: + return ts.getTime() * 1000 + ts.getNanos() / 1000 % 1000; + case TimestampPrecision.NS: + return ts.getTime() * 1000_000 + ts.getNanos() % 1000_000; + } + } long valueAsLong = 0; try { valueAsLong = Long.parseLong(value.toString()); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java index 6cd1ff7200962b7347969e0b8b10443083505912..6ec76fffd93751b0cb57e116085de9da550f214e 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java @@ -194,14 +194,14 @@ public class Utils { return timestamp.toLocalDateTime().format(milliSecFormatter); } - public static TimestampPrecision guessTimestampPrecision(String value) { + public static int guessTimestampPrecision(String value) { if (isMilliSecFormat(value)) return TimestampPrecision.MS; if (isMicroSecFormat(value)) return TimestampPrecision.US; if (isNanoSecFormat(value)) return TimestampPrecision.NS; - return TimestampPrecision.UNKNOWN; + return TimestampPrecision.MS; } private static boolean isMilliSecFormat(String timestampStr) { diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/GetLongWithDifferentTimestampPrecision.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/GetLongWithDifferentTimestampPrecision.java new file mode 100644 index 0000000000000000000000000000000000000000..1ba7bdc4057e5c9e2977d3723fe329e761e7258c --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/GetLongWithDifferentTimestampPrecision.java @@ -0,0 +1,59 @@ +package com.taosdata.jdbc.cases; + +import org.junit.Assert; +import org.junit.Test; + +import java.sql.*; +import java.text.SimpleDateFormat; + +public class GetLongWithDifferentTimestampPrecision { + + private final String host = "127.0.0.1"; + + @Test + public void testRestful() throws SQLException { + // given + String url = "jdbc:TAOS-RS://" + host + ":6041/"; + Connection conn = DriverManager.getConnection(url, "root", "taosdata"); + long ts = System.currentTimeMillis(); + + // when and then + assertResultSet(conn, "ms", ts, ts); + assertResultSet(conn, "us", ts, ts * 1000); + assertResultSet(conn, "ns", ts, ts * 1000_000); + } + + @Test + public void testJni() throws SQLException { + // given + String url = "jdbc:TAOS://" + host + ":6030/"; + Connection conn = DriverManager.getConnection(url, "root", "taosdata"); + long ts = System.currentTimeMillis(); + + // when and then + assertResultSet(conn, "ms", ts, ts); + assertResultSet(conn, "us", ts, ts * 1000); + assertResultSet(conn, "ns", ts, ts * 1000_000); + } + + private void assertResultSet(Connection conn, String precision, long timestamp, long expect) throws SQLException { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + + try (Statement stmt = conn.createStatement()) { + stmt.execute("drop database if exists test"); + stmt.execute("create database if not exists test precision '" + precision + "'"); + stmt.execute("create table test.weather(ts timestamp, f1 int)"); + + String dateTimeStr = sdf.format(new Date(timestamp)); + stmt.execute("insert into test.weather values('" + dateTimeStr + "', 1)"); + + ResultSet rs = stmt.executeQuery("select * from test.weather"); + rs.next(); + long actual = rs.getLong("ts"); + Assert.assertEquals(expect, actual); + stmt.execute("drop database if exists test"); + } + } + + +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java index 5de1655ee48776b6798619814fe2729625282764..da30bbd568c7043af493baeecc118f256ad73b10 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java @@ -9,29 +9,29 @@ import java.util.Random; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class RestfulJDBCTest { - // private static final String host = "127.0.0.1"; - private static final String host = "master"; + private static final String host = "127.0.0.1"; private static final Random random = new Random(System.currentTimeMillis()); private static Connection connection; + private static final String dbname = "restful_test"; @Test public void testCase001() throws SQLException { // given - String sql = "drop database if exists restful_test"; + String sql = "drop database if exists " + dbname; // when boolean execute = execute(connection, sql); // then Assert.assertFalse(execute); // given - sql = "create database if not exists restful_test"; + sql = "create database if not exists " + dbname; // when execute = execute(connection, sql); // then Assert.assertFalse(execute); // given - sql = "use restful_test"; + sql = "use " + dbname; // when execute = execute(connection, sql); // then @@ -41,7 +41,7 @@ public class RestfulJDBCTest { @Test public void testCase002() throws SQLException { // given - String sql = "create table weather(ts timestamp, temperature float, humidity int) tags(location nchar(64), groupId int)"; + String sql = "create table " + dbname + ".weather(ts timestamp, temperature float, humidity int) tags(location nchar(64), groupId int)"; // when boolean execute = execute(connection, sql); // then @@ -52,7 +52,7 @@ public class RestfulJDBCTest { public void testCase004() throws SQLException { for (int i = 1; i <= 100; i++) { // given - String sql = "create table t" + i + " using weather tags('beijing', '" + i + "')"; + String sql = "create table " + dbname + ".t" + i + " using " + dbname + ".weather tags('beijing', '" + i + "')"; // when boolean execute = execute(connection, sql); // then @@ -68,7 +68,7 @@ public class RestfulJDBCTest { // given long currentTimeMillis = System.currentTimeMillis(); - String sql = "insert into t" + j + " values(" + currentTimeMillis + "," + (random.nextFloat() * 50) + "," + random.nextInt(100) + ")"; + String sql = "insert into " + dbname + ".t" + j + " values(" + currentTimeMillis + "," + (random.nextFloat() * 50) + "," + random.nextInt(100) + ")"; // when int affectRows = executeUpdate(connection, sql); // then @@ -83,7 +83,7 @@ public class RestfulJDBCTest { @Test public void testCase006() throws SQLException { // given - String sql = "select * from weather"; + String sql = "select * from " + dbname + ".weather"; // when ResultSet rs = executeQuery(connection, sql); ResultSetMetaData meta = rs.getMetaData(); @@ -102,7 +102,7 @@ public class RestfulJDBCTest { @Test public void testCase007() throws SQLException { // given - String sql = "drop database restful_test"; + String sql = "drop database " + dbname; // when boolean execute = execute(connection, sql); @@ -143,7 +143,7 @@ public class RestfulJDBCTest { public static void afterClass() throws SQLException { if (connection != null) { Statement stmt = connection.createStatement(); - stmt.execute("drop database if exists restful_test"); + stmt.execute("drop database if exists " + dbname); stmt.close(); connection.close(); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java index 4058dd8b550b6e9ac5553144de92d908d804dce1..c1ca31ae388f577a33cc6f3a6bc943ce52112507 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java @@ -17,12 +17,25 @@ import java.text.SimpleDateFormat; public class RestfulResultSetTest { - // private static final String host = "127.0.0.1"; - private static final String host = "master"; + private static final String host = "127.0.0.1"; private static Connection conn; private static Statement stmt; private static ResultSet rs; + @BeforeClass + public static void beforeClass() throws SQLException { + conn = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"); + stmt = conn.createStatement(); + stmt.execute("drop database if exists restful_test"); + stmt.execute("create database if not exists restful_test"); + stmt.execute("use restful_test"); + stmt.execute("drop table if exists weather"); + stmt.execute("create table if not exists weather(f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 binary(64), f7 smallint, f8 tinyint, f9 bool, f10 nchar(64))"); + stmt.execute("insert into restful_test.weather values('2021-01-01 00:00:00.000', 1, 100, 3.1415, 3.1415926, 'abc', 10, 10, true, '涛思数据')"); + rs = stmt.executeQuery("select * from restful_test.weather"); + rs.next(); + } + @Test public void wasNull() throws SQLException { Assert.assertFalse(rs.wasNull()); @@ -658,20 +671,6 @@ public class RestfulResultSetTest { Assert.assertTrue(rs.isWrapperFor(RestfulResultSet.class)); } - @BeforeClass - public static void beforeClass() throws SQLException { - conn = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"); - stmt = conn.createStatement(); - stmt.execute("drop database if exists restful_test"); - stmt.execute("create database if not exists restful_test"); - stmt.execute("use restful_test"); - stmt.execute("drop table if exists weather"); - stmt.execute("create table if not exists weather(f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 binary(64), f7 smallint, f8 tinyint, f9 bool, f10 nchar(64))"); - stmt.execute("insert into restful_test.weather values('2021-01-01 00:00:00.000', 1, 100, 3.1415, 3.1415926, 'abc', 10, 10, true, '涛思数据')"); - rs = stmt.executeQuery("select * from restful_test.weather"); - rs.next(); - } - @AfterClass public static void afterClass() throws SQLException { if (rs != null) diff --git a/src/connector/python/examples/subscribe-async.py b/src/connector/python/examples/subscribe-async.py index 3782ce5505152e78838406e313094eb911bea4a2..49156de7edfb4322d7888727c28b76868cf6a16a 100644 --- a/src/connector/python/examples/subscribe-async.py +++ b/src/connector/python/examples/subscribe-async.py @@ -7,7 +7,7 @@ import time def subscribe_callback(p_sub, p_result, p_param, errno): # type: (c_void_p, c_void_p, c_void_p, c_int) -> None print("# fetch in callback") - result = TaosResult(p_result) + result = TaosResult(c_void_p(p_result)) result.check_error(errno) for row in result.rows_iter(): ts, n = row() @@ -18,18 +18,21 @@ def test_subscribe_callback(conn): # type: (TaosConnection) -> None dbname = "pytest_taos_subscribe_callback" try: + print("drop if exists") conn.execute("drop database if exists %s" % dbname) + print("create database") conn.execute("create database if not exists %s" % dbname) - conn.select_db(dbname) - conn.execute("create table if not exists log(ts timestamp, n int)") + print("create table") + # conn.execute("use %s" % dbname) + conn.execute("create table if not exists %s.log(ts timestamp, n int)" % dbname) print("# subscribe with callback") - sub = conn.subscribe(False, "test", "select * from log", 1000, subscribe_callback) + sub = conn.subscribe(False, "test", "select * from %s.log" % dbname, 1000, subscribe_callback) for i in range(10): - conn.execute("insert into log values(now, %d)" % i) + conn.execute("insert into %s.log values(now, %d)" % (dbname, i)) time.sleep(0.7) - # sub.close() + sub.close() conn.execute("drop database if exists %s" % dbname) # conn.close() diff --git a/src/connector/python/taos/cinterface.py b/src/connector/python/taos/cinterface.py index 37bc90d4c63fe3f75b12d46bb1bf535441869938..740af5838235a6abc41ae27e7c6a462c30977616 100644 --- a/src/connector/python/taos/cinterface.py +++ b/src/connector/python/taos/cinterface.py @@ -110,7 +110,7 @@ _libtaos.taos_get_client_info.restype = c_char_p def taos_get_client_info(): # type: () -> str """Get client version info.""" - return _libtaos.taos_get_client_info().decode() + return _libtaos.taos_get_client_info().decode("utf-8") _libtaos.taos_get_server_info.restype = c_char_p @@ -120,7 +120,7 @@ _libtaos.taos_get_server_info.argtypes = (c_void_p,) def taos_get_server_info(connection): # type: (c_void_p) -> str """Get server version as string.""" - return _libtaos.taos_get_server_info(connection).decode() + return _libtaos.taos_get_server_info(connection).decode("utf-8") _libtaos.taos_close.restype = None @@ -308,16 +308,14 @@ def taos_subscribe(connection, restart, topic, sql, interval, callback=None, par """ if callback != None: callback = subscribe_callback_type(callback) - if param != None: - param = c_void_p(param) return c_void_p( _libtaos.taos_subscribe( connection, 1 if restart else 0, c_char_p(topic.encode("utf-8")), c_char_p(sql.encode("utf-8")), - callback or None, - param, + callback, + c_void_p(param), interval, ) ) diff --git a/src/connector/python/taos/field.py b/src/connector/python/taos/field.py index 9d1799d367185e28b69f3cd1fe0bc0d0d14aa7fd..a6d64422e238b46b096a5ae62c42566666f226ad 100644 --- a/src/connector/python/taos/field.py +++ b/src/connector/python/taos/field.py @@ -144,7 +144,7 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_ try: if num_of_rows >= 0: tmpstr = ctypes.c_char_p(data) - res.append(tmpstr.value.decode()) + res.append(tmpstr.value.decode("utf-8")) else: res.append( ( @@ -172,7 +172,7 @@ def _crow_binary_to_python_block(data, num_of_rows, nbytes=None, precision=Field if rbyte == 1 and buffer[0] == b'\xff': res.append(None) else: - res.append(cast(buffer, c_char_p).value.decode()) + res.append(cast(buffer, c_char_p).value.decode("utf-8")) return res @@ -188,7 +188,7 @@ def _crow_nchar_to_python_block(data, num_of_rows, nbytes=None, precision=FieldT if rbyte == 4 and buffer[:4] == b'\xff'*4: res.append(None) else: - res.append(cast(buffer, c_char_p).value.decode()) + res.append(cast(buffer, c_char_p).value.decode("utf-8")) return res diff --git a/src/connector/python/taos/result.py b/src/connector/python/taos/result.py index c9feb4d6502515cc6e3e2d4be688f2e7fcd895b2..8b8a0cf108cf7c941d0a6476d8a9c1e2c5a41b84 100644 --- a/src/connector/python/taos/result.py +++ b/src/connector/python/taos/result.py @@ -3,6 +3,8 @@ from .cinterface import * # from .connection import TaosConnection from .error import * +from ctypes import c_void_p + class TaosResult(object): """TDengine result interface""" @@ -12,7 +14,11 @@ class TaosResult(object): # to make the __del__ order right self._conn = conn self._close_after = close_after - self._result = result + if isinstance(result, c_void_p): + self._result = result + else: + self._result = c_void_p(result) + self._fields = None self._field_count = None self._precision = None diff --git a/src/connector/python/tests/test_stream.py b/src/connector/python/tests/test_stream.py index de6e20928b176e51bc6d350fb01268459f4e7f95..32ec4c5999c975be907cf69a42a04b5f4dd5d54c 100644 --- a/src/connector/python/tests/test_stream.py +++ b/src/connector/python/tests/test_stream.py @@ -20,7 +20,8 @@ def stream_callback(p_param, p_result, p_row): result = TaosResult(p_result) row = TaosRow(result, p_row) try: - ts, count = row() + ts, count = row.as_tuple() + print(ts, count) p = cast(p_param, POINTER(Counter)) p.contents.count += count print("[%s] inserted %d in 5s, total count: %d" % (ts.strftime("%Y-%m-%d %H:%M:%S"), count, p.contents.count)) diff --git a/src/connector/python/tests/test_subscribe.py b/src/connector/python/tests/test_subscribe.py index 99fe5b263625c63200f416ec98fcb561773becd8..d8acd60e4f3b32bb87a9663b3f7dc43a73f2877b 100644 --- a/src/connector/python/tests/test_subscribe.py +++ b/src/connector/python/tests/test_subscribe.py @@ -63,7 +63,7 @@ def test_subscribe(conn): def subscribe_callback(p_sub, p_result, p_param, errno): # type: (c_void_p, c_void_p, c_void_p, c_int) -> None print("callback") - result = TaosResult(p_result) + result = TaosResult(c_void_p(p_result)) result.check_error(errno) for row in result.rows_iter(): ts, n = row() @@ -76,7 +76,7 @@ def test_subscribe_callback(conn): try: conn.execute("drop database if exists %s" % dbname) conn.execute("create database if not exists %s" % dbname) - conn.select_db(dbname) + conn.execute("use %s" % dbname) conn.execute("create table if not exists log(ts timestamp, n int)") print("# subscribe with callback") diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index f62e0c0df41f2fe399d0f4c1c8e661fcd0ef91b9..7676343b37d242c1d174a31959ea4be25a9d5af2 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -120,6 +120,14 @@ static void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *pEpSet) { if (pMsg->pCont == NULL) return; + if (pMsg->msgType >= TSDB_MSG_TYPE_MAX) { + dError("RPC %p, shell msg type:%d is not processed", pMsg->handle, pMsg->msgType); + rpcMsg.code = TSDB_CODE_DND_MSG_NOT_PROCESSED; + rpcSendResponse(&rpcMsg); + rpcFreeCont(pMsg->pCont); + return; + } + SRunStatus dnodeStatus = dnodeGetRunStatus(); if (dnodeStatus == TSDB_RUN_STATUS_STOPPED) { dError("RPC %p, shell msg:%s is ignored since dnode exiting", pMsg->handle, taosMsg[pMsg->msgType]); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 2842a021746890cf6de7679522217c513162e4ab..9dc76466aadbe9781dbdd727a524a32f8103650f 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -230,6 +230,7 @@ typedef struct SSubmitBlk { // Submit message for this TSDB typedef struct SSubmitMsg { SMsgHead header; + int8_t extend; int32_t length; int32_t numOfBlocks; char blocks[]; @@ -243,6 +244,7 @@ typedef struct { } SShellSubmitRspBlock; typedef struct { + int8_t extend; int32_t code; // 0-success, > 0 error code int32_t numOfRows; // number of records the client is trying to write int32_t affectedRows; // number of records actually written @@ -278,6 +280,7 @@ typedef struct { } SMDCreateTableMsg; typedef struct { + int8_t extend; int32_t len; // one create table message char tableName[TSDB_TABLE_FNAME_LEN]; int8_t igExists; @@ -290,11 +293,13 @@ typedef struct { } SCreateTableMsg; typedef struct { + int8_t extend; int32_t numOfTables; int32_t contLen; } SCMCreateTableMsg; typedef struct { + int8_t extend; char name[TSDB_TABLE_FNAME_LEN]; // if user specify DROP STABLE, this flag will be set. And an error will be returned if it is not a super table int8_t supertable; @@ -302,6 +307,7 @@ typedef struct { } SCMDropTableMsg; typedef struct { + int8_t extend; char tableFname[TSDB_TABLE_FNAME_LEN]; char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; int16_t type; /* operation type */ @@ -314,6 +320,7 @@ typedef struct { typedef struct { SMsgHead head; + int8_t extend; int64_t uid; int32_t tid; int16_t tversion; @@ -327,6 +334,7 @@ typedef struct { } SUpdateTableTagValMsg; typedef struct { + int8_t extend; char clientVersion[TSDB_VERSION_LEN]; char msgVersion[TSDB_VERSION_LEN]; char db[TSDB_TABLE_FNAME_LEN]; @@ -335,6 +343,7 @@ typedef struct { } SConnectMsg; typedef struct { + int8_t extend; char acctId[TSDB_ACCT_ID_LEN]; char serverVersion[TSDB_VERSION_LEN]; char clusterId[TSDB_CLUSTER_ID_LEN]; @@ -361,16 +370,19 @@ typedef struct { } SAcctCfg; typedef struct { + int8_t extend; char user[TSDB_USER_LEN]; char pass[TSDB_KEY_LEN]; SAcctCfg cfg; } SCreateAcctMsg, SAlterAcctMsg; typedef struct { - char user[TSDB_USER_LEN]; + int8_t extend; + char user[TSDB_USER_LEN]; } SDropUserMsg, SDropAcctMsg; typedef struct { + int8_t extend; char user[TSDB_USER_LEN]; char pass[TSDB_KEY_LEN]; int8_t privilege; @@ -462,6 +474,7 @@ typedef struct { typedef struct { SMsgHead head; + int8_t extend; char version[TSDB_VERSION_LEN]; bool stableQuery; // super table query or not @@ -514,6 +527,7 @@ typedef struct { } SQueryTableMsg; typedef struct { + int8_t extend; int32_t code; union{uint64_t qhandle; uint64_t qId;}; // query handle } SQueryTableRsp; @@ -521,11 +535,13 @@ typedef struct { // todo: the show handle should be replaced with id typedef struct { SMsgHead header; + int8_t extend; union{uint64_t qhandle; uint64_t qId;}; // query handle uint16_t free; } SRetrieveTableMsg; typedef struct SRetrieveTableRsp { + int8_t extend; int32_t numOfRows; int8_t completed; // all results are returned to client int16_t precision; @@ -551,6 +567,7 @@ typedef struct { } SVnodeLoad; typedef struct { + int8_t extend; char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; int32_t cacheBlockSize; //MB int32_t totalBlocks; @@ -577,6 +594,7 @@ typedef struct { } SCreateDbMsg, SAlterDbMsg; typedef struct { + int8_t extend; char name[TSDB_FUNC_NAME_LEN]; char path[PATH_MAX]; int32_t funcType; @@ -588,11 +606,13 @@ typedef struct { } SCreateFuncMsg; typedef struct { + int8_t extend; int32_t num; char name[]; } SRetrieveFuncMsg; typedef struct { + int8_t extend; char name[TSDB_FUNC_NAME_LEN]; int32_t funcType; int8_t resType; @@ -603,15 +623,18 @@ typedef struct { } SFunctionInfoMsg; typedef struct { + int8_t extend; int32_t num; char content[]; } SUdfFuncMsg; typedef struct { + int8_t extend; char name[TSDB_FUNC_NAME_LEN]; } SDropFuncMsg; typedef struct { + int8_t extend; char db[TSDB_TABLE_FNAME_LEN]; uint8_t ignoreNotExists; } SDropDbMsg, SUseDbMsg, SSyncDbMsg; @@ -744,12 +767,14 @@ typedef struct { } SCreateVnodeMsg, SAlterVnodeMsg; typedef struct { + int8_t extend; char tableFname[TSDB_TABLE_FNAME_LEN]; int16_t createFlag; char tags[]; } STableInfoMsg; typedef struct { + int8_t extend; uint8_t metaClone; // create local clone of the cached table meta int32_t numOfVgroups; int32_t numOfTables; @@ -758,21 +783,25 @@ typedef struct { } SMultiTableInfoMsg; typedef struct SSTableVgroupMsg { + int8_t extend; int32_t numOfTables; } SSTableVgroupMsg, SSTableVgroupRspMsg; typedef struct { + int8_t extend; int32_t vgId; int8_t numOfEps; SEpAddrMsg epAddr[TSDB_MAX_REPLICA]; } SVgroupMsg, SVgroupInfo; typedef struct { + int8_t extend; int32_t numOfVgroups; SVgroupMsg vgroups[]; } SVgroupsMsg, SVgroupsInfo; typedef struct STableMetaMsg { + int8_t extend; int32_t contLen; char tableFname[TSDB_TABLE_FNAME_LEN]; // table id uint8_t numOfTags; @@ -792,6 +821,7 @@ typedef struct STableMetaMsg { } STableMetaMsg; typedef struct SMultiTableMeta { + int8_t extend; int32_t numOfTables; int32_t numOfVgroup; int32_t numOfUdf; @@ -814,6 +844,7 @@ typedef struct { * payloadLen is the length of payload */ typedef struct { + int8_t extend; int8_t type; char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; uint16_t payloadLen; @@ -821,17 +852,20 @@ typedef struct { } SShowMsg; typedef struct { + int8_t extend; char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; int32_t numOfVgroup; int32_t vgid[]; } SCompactMsg; typedef struct SShowRsp { + int8_t extend; uint64_t qhandle; STableMetaMsg tableMeta; } SShowRsp; typedef struct { + int8_t extend; char ep[TSDB_EP_LEN]; // end point, hostname:port } SCreateDnodeMsg, SDropDnodeMsg; @@ -853,6 +887,7 @@ typedef struct { } SConfigVnodeMsg; typedef struct { + int8_t extend; char ep[TSDB_EP_LEN]; // end point, hostname:port char config[64]; } SCfgDnodeMsg; @@ -884,6 +919,7 @@ typedef struct { } SStreamDesc; typedef struct { + int8_t extend; char clientVer[TSDB_VERSION_LEN]; uint32_t connId; int32_t pid; @@ -894,6 +930,7 @@ typedef struct { } SHeartBeatMsg; typedef struct { + int8_t extend; uint32_t queryId; uint32_t streamId; uint32_t totalDnodes; @@ -904,10 +941,12 @@ typedef struct { } SHeartBeatRsp; typedef struct { + int8_t extend; char queryId[TSDB_KILL_MSG_LEN + 1]; } SKillQueryMsg, SKillStreamMsg, SKillConnMsg; typedef struct { + int8_t extend; int32_t vnode; int32_t sid; uint64_t uid; @@ -932,6 +971,16 @@ typedef struct { char reserved2[64]; } SStartupStep; +typedef struct { + int16_t type; + int32_t len; + char value[]; +} STLV; + +enum { + TLV_TYPE_DUMMY = 1, +}; + #pragma pack(pop) #ifdef __cplusplus diff --git a/src/plugins/taosadapter b/src/plugins/taosadapter index f108f5240918d0eec90debd1ff469c98ff0f25ac..88346a2e4e2e9282d2ec8b8c5264ca1ec23698a1 160000 --- a/src/plugins/taosadapter +++ b/src/plugins/taosadapter @@ -1 +1 @@ -Subproject commit f108f5240918d0eec90debd1ff469c98ff0f25ac +Subproject commit 88346a2e4e2e9282d2ec8b8c5264ca1ec23698a1 diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 48e03ad1e32dbfdcc6cf101186251a275ae11485..6e0eb373ac96c84e3e5eecf6f1bcf9aabf336f09 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -148,7 +148,7 @@ if(exprInfo->base.numOfParams > 0){ \ uint64_t queryHandleId = 0; int32_t getMaximumIdleDurationSec() { - return tsShellActivityTimer * 2; + return tsShellActivityTimer * 10; } int64_t genQueryId(void) { int64_t uid = 0; @@ -8186,6 +8186,32 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { goto _cleanup; } + + +/* + //MSG EXTEND DEMO + if (pQueryMsg->extend) { + pMsg += pQueryMsg->sqlstrLen; + + STLV *tlv = NULL; + while (1) { + tlv = (STLV *)pMsg; + tlv->type = ntohs(tlv->type); + tlv->len = ntohl(tlv->len); + if (tlv->len > 0) { + *(int16_t *)tlv->value = ntohs(*(int16_t *)tlv->value); + qDebug("Got TLV,type:%d,len:%d,value:%d", tlv->type, tlv->len, *(int16_t*)tlv->value); + pMsg += sizeof(*tlv) + tlv->len; + continue; + } + + break; + } + } + +*/ + + qDebug("qmsg:%p query %d tables, type:%d, qrange:%" PRId64 "-%" PRId64 ", numOfGroupbyTagCols:%d, order:%d, " "outputCols:%d, numOfCols:%d, interval:%" PRId64 ", fillType:%d, comptsLen:%d, compNumOfBlocks:%d, limit:%" PRId64 ", offset:%" PRId64, pQueryMsg, pQueryMsg->numOfTables, pQueryMsg->queryType, pQueryMsg->window.skey, pQueryMsg->window.ekey, pQueryMsg->numOfGroupCols, diff --git a/src/query/src/queryMain.c b/src/query/src/queryMain.c index fce7f649892f87d075c8dd64e4d1160e5d05bf77..2a2ccf9cae0f9e2aab60bddca7c27a8ceb719239 100644 --- a/src/query/src/queryMain.c +++ b/src/query/src/queryMain.c @@ -279,6 +279,7 @@ bool qTableQuery(qinfo_t qinfo, uint64_t *qId) { if (isQueryKilled(pQInfo)) { qDebug("QInfo:0x%"PRIx64" it is already killed, abort", pQInfo->qId); + pQInfo->runtimeEnv.outputBuf = NULL; return doBuildResCheck(pQInfo); } diff --git a/tests/develop-test/0-management/3-tag/json_tag.py b/tests/develop-test/0-management/3-tag/json_tag.py index c18c88e8316b7a7dcf96a6c2ef25f8e1a9ef1ed1..4810ec8b4e2437f5aecbb67a10c8d2ce4e5c55c5 100644 --- a/tests/develop-test/0-management/3-tag/json_tag.py +++ b/tests/develop-test/0-management/3-tag/json_tag.py @@ -458,7 +458,52 @@ class TDTestCase: #show create table tdSql.query("show create table jsons1") - tdSql.checkData(0, 1, 'create table `jsons1` (ts TIMESTAMP,dataint INT,databool BOOL,datastr NCHAR(50),datastrbin BINARY(150)) TAGS (jtag JSON)') + tdSql.checkData(0, 1, 'create table `jsons1` (`ts` TIMESTAMP,`dataint` INT,`databool` BOOL,`datastr` NCHAR(50),`datastrbin` BINARY(150)) TAGS (`jtag` JSON)') + + #test aggregate function:count/avg/twa/irate/sum/stddev/leastsquares + tdSql.query("select count(*) from jsons1 where jtag is not null") + tdSql.checkData(0, 0, 10) + tdSql.query("select avg(dataint) from jsons1 where jtag is not null") + tdSql.checkData(0, 0, 5.3) + tdSql.error("select twa(dataint) from jsons1 where jtag is not null") + tdSql.error("select irate(dataint) from jsons1 where jtag is not null") + tdSql.query("select sum(dataint) from jsons1 where jtag->'tag1' is not null") + tdSql.checkData(0, 0, 49) + tdSql.query("select stddev(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 4.496912521) + tdSql.error("SELECT LEASTSQUARES(dataint, 1, 1) from jsons1 where jtag is not null") + + #test selection function:min/max/first/last/top/bottom/percentile/apercentile/last_row/interp + tdSql.query("select min(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 1) + tdSql.query("select max(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 11) + tdSql.query("select first(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 2) + tdSql.query("select last(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 11) + tdSql.query("select top(dataint,100) from jsons1 where jtag->'tag1'>1") + tdSql.checkRows(3) + tdSql.query("select bottom(dataint,100) from jsons1 where jtag->'tag1'>1") + tdSql.checkRows(3) + tdSql.error("select percentile(dataint,20) from jsons1 where jtag->'tag1'>1") + tdSql.query("select apercentile(dataint, 50) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 1.5) + tdSql.query("select last_row(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 11) + tdSql.error("select interp(dataint) from jsons1 where ts = '2020-06-02 09:17:08.000' and jtag->'tag1'>1") + + #test calculation function:diff/derivative/spread/ceil/floor/round/ + tdSql.error("select diff(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.error("select derivative(dataint, 10m, 0) from jsons1 where jtag->'tag1'>1") + tdSql.query("select spread(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 10) + tdSql.query("select ceil(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkRows(3) + tdSql.query("select floor(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkRows(3) + tdSql.query("select round(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkRows(3) def stop(self): tdSql.close() @@ -467,3 +512,4 @@ class TDTestCase: tdCases.addWindows(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase()) + diff --git a/tests/develop-test/1-insert/0-sql/basic.py b/tests/develop-test/1-insert/0-sql/basic.py index 86872eeaa20ce6c8f473342da3da1f17f19bc8cc..273ff8ba488db609cfa4aa5978c689288d14750b 100644 --- a/tests/develop-test/1-insert/0-sql/basic.py +++ b/tests/develop-test/1-insert/0-sql/basic.py @@ -20,9 +20,9 @@ from util.sql import * class TDTestCase: def caseDescription(self): ''' - insert 倒序插入 - 语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效 - insert语句在values之间加入多个逗号 + case1: insert 倒序插入 + case2: 语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效 + case3: [TD-XXXX]insert语句在values之间加入多个逗号 ''' return diff --git a/tests/pytest/stream/stream2.py b/tests/pytest/stream/stream2.py index 9b4eb8725c96f95196f251c55b0b773cd68e9ed5..95f5d233855bbb743eaf0390d6c145258fd8f84d 100644 --- a/tests/pytest/stream/stream2.py +++ b/tests/pytest/stream/stream2.py @@ -153,10 +153,14 @@ class TDTestCase: tdSql.checkRows(2) tdSql.checkData(0, 2, 's1') tdSql.checkData(1, 2, 's0') + tdSql.execute('kill stream %s ;' % tdSql.queryResult[0][0]) + time.sleep(5) + tdSql.query("show streams") + tdSql.checkRows(1) def stop(self): - tdSql.close() + #tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/script/api/batchprepare.c b/tests/script/api/batchprepare.c index 2cbee8eac91719a4cbff4d9c323f1f304e8e8684..8931f2021f16674140844a1d4bf76cb9d7168b45 100644 --- a/tests/script/api/batchprepare.c +++ b/tests/script/api/batchprepare.c @@ -2722,6 +2722,38 @@ int stmt_funcb_autoctb_e5(TAOS_STMT *stmt) { } +int stmt_funcb_autoctb_e6(TAOS_STMT *stmt) { + char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(now,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("case success:failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt)); + } + + return 0; +} + + +int stmt_funcb_autoctb_e7(TAOS_STMT *stmt) { + char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,true,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("case success:failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt)); + } + + return 0; +} + + +int stmt_funcb_autoctb_e8(TAOS_STMT *stmt) { + char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,1,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("case success:failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt)); + } + + return 0; +} + //300 tables 60 records int stmt_funcb1(TAOS_STMT *stmt) { @@ -4857,6 +4889,44 @@ void* runcase(void *par) { #endif + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("e6 start\n"); + stmt_funcb_autoctb_e6(stmt); + printf("e6 end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("e7 start\n"); + stmt_funcb_autoctb_e7(stmt); + printf("e7 end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1, 0); + + stmt = taos_stmt_init(taos); + + printf("e8 start\n"); + stmt_funcb_autoctb_e8(stmt); + printf("e8 end\n"); + taos_stmt_close(stmt); + +#endif + + #if 1 prepare(taos, 1, 0); diff --git a/tests/system-test/0-management/1-stable/create_col_tag.py b/tests/system-test/0-management/1-stable/create_col_tag.py new file mode 100644 index 0000000000000000000000000000000000000000..d195e73321ea24a8b9de1f2ca5f9c07f9182dd65 --- /dev/null +++ b/tests/system-test/0-management/1-stable/create_col_tag.py @@ -0,0 +1,853 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import time +import os +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def caseDescription(self): + ''' + case1:The escape char "`" can be used for both tag name and column name + case2:create stable(column&tag); insert data; show stable; show create table; add stable(column&tag);change stable(tag);drop stable(column&tag);modify stable(column&tag)(binary和nchar);drop stable; + case3:create stable_child; insert data; show stable_child; show create stable_child; drop stable_child; + case4:create regular_table(column); insert data; show regular_table; show create regular_table; add regular_table(column);drop regular_table(column);modify regular_table(column)(binary和nchar);drop regular_table; + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + now = time.time() + self.ts = int(round(now * 1000)) + + def table1_checkall(self,sql): + tdLog.info(sql) + tdSql.query(sql) + tdSql.checkData(0,1,1) + tdSql.checkData(0,2,2) + tdSql.checkData(0,3,3) + tdSql.checkData(0,4,4) + tdSql.checkData(0,5,'True') + tdSql.checkData(0,6,6) + tdSql.checkData(0,7,7) + tdSql.checkData(0,8,8) + tdSql.checkData(0,9,9) + tdSql.checkData(0,10,'1970-01-01 08:00:00.010') + + def table1_checkall_1(self,sql): + tdSql.query(sql) + tdSql.checkData(0,1,1) + + def table1_checkall_2(self,sql): + self.table1_checkall_1(sql) + tdSql.checkData(0,2,2) + + def table1_checkall_3(self,sql): + self.table1_checkall_2(sql) + tdSql.checkData(0,3,3) + + def table1_checkall_4(self,sql): + self.table1_checkall_3(sql) + tdSql.checkData(0,4,4) + + def table1_checkall_5(self,sql): + self.table1_checkall_4(sql) + tdSql.checkData(0,5,'True') + + def table1_checkall_6(self,sql): + self.table1_checkall_5(sql) + tdSql.checkData(0,6,6) + + def table1_checkall_7(self,sql): + self.table1_checkall_6(sql) + tdSql.checkData(0,7,7) + + def table1_checkall_8(self,sql): + self.table1_checkall_7(sql) + tdSql.checkData(0,8,8) + + def table1_checkall_9(self,sql): + self.table1_checkall_8(sql) + tdSql.checkData(0,9,9) + + def table1_checkall_10(self,sql): + self.table1_checkall_9(sql) + tdSql.checkData(0,10,'1970-01-01 08:00:00.010') + + def run(self): + + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf 0-management/1-stable/%s.sql" % testcaseFilename ) + tdSql.prepare() + + print("==============step1") + print("prepare data") + + # case for defect: https://jira.taosdata.com:18080/browse/TD-2693 + tdSql.execute("create database db2") + tdSql.execute("use db2") + + 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("prepare data") + + self.stb1 = "stable_1~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" + self.tb1 = "table_1~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" + + self.col_base = "123~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" + + self.col_int = "stable_col_int%s" %self.col_base + print(self.col_int) + self.col_bigint = "stable_col_bigint%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_bool = "stable_col_bool%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_float = "stable_col_float%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.tag_base = "abc~!@#$%^&*()-_+=[]{}':,<.>/?stST13579" + self.tag_int = "stable_tag_int%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_tinyint = "stable_tag_tinyint%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_nchar = "stable_tag_nchar%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_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 , + `%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.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)) + tdSql.query("describe db.`%s` ; " %self.stb1) + tdSql.checkRows(22) + + tdSql.query("select _block_dist() from db.`%s` ; " %self.stb1) + tdSql.checkRows(0) + + tdSql.query("show create stable db.`%s` ; " %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)\ + 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.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)) + + 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.checkRows(22) + + time.sleep(10) + tdSql.query("show create table db.`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.execute("insert into db.`table!1` values(now, 1 , 2, 3, 4, 5, 6 ,7 ,8 ,9 ,10)") + sql = " select * from db.`table!1`; " + datacheck = self.table1_checkall(sql) + tdSql.checkRows(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) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(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)'''\ + %(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`; " + datacheck = self.table1_checkall(sql) + tdSql.checkRows(2) + + tdSql.query("select count(*) from db.`table!1`; ") + tdSql.checkData(0, 0, 2) + tdSql.query("select _block_dist() from db.`%s` ; " %self.stb1) + 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.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.query("show create table db.`%s` ; " %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.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) + 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` ; '''\ + %(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) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(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)'''\ + %(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 + datacheck = self.table1_checkall(sql) + 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; " \ + %(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) + tdSql.checkRows(2) + + tdSql.query("select count(*) from db.`%s`; " %self.tb1) + tdSql.checkData(0, 0, 2) + sql = "select * from db.`%s` ; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.checkRows(4) + tdSql.query("select count(*) from db.`%s`; " %self.stb1) + tdSql.checkData(0, 0, 4) + + sql = "select * from (select * from db.`%s`) ; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.checkRows(4) + tdSql.query("select count(*) from (select * from db.`%s`) ; " %self.stb1) + tdSql.checkData(0, 0, 4) + + 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) + datacheck = self.table1_checkall(sql) + 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`) ; " \ + %(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) + datacheck = self.table1_checkall(sql) + 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`\ + 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.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) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(4) + + tdSql.query("show db.stables like 'stable_1%' ") + tdSql.checkRows(1) + tdSql.query("show db.tables like 'table%' ") + tdSql.checkRows(2) + + 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.query("show db.tables like 'create_table_%' ") + tdSql.checkRows(1) + + print("==============drop\ add\ change\ modify column or tag") + print("==============drop==============") + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_ts)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(21) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_double)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(20) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_float)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(19) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_nchar)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(18) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_binary)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(17) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_bool)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(16) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_tinyint)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(15) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_smallint)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(14) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_bigint)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(13) + tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; " %(self.stb1, self.tag_int)) + sql = " select * from db.`%s`; " %self.stb1 + datacheck = self.table1_checkall(sql) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(12) + + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(11) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(10) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(9) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(8) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(7) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(6) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(5) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(4) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(3) + tdSql.error("ALTER TABLE db.`%s` DROP COLUMN `%s`; " %(self.stb1, self.col_int)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(3) + + print("==============add==============") + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` bigint; " %(self.stb1, self.col_bigint)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(4) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` smallint; " %(self.stb1, self.col_smallint)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(5) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` tinyint; " %(self.stb1, self.col_tinyint)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(6) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` bool; " %(self.stb1, self.col_bool)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(7) + tdSql.execute("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.execute("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) + + tdSql.execute("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.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` float; " %(self.stb1, self.col_float)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(10) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` double; " %(self.stb1, self.col_double)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(11) + tdSql.execute("ALTER TABLE db.`%s` ADD COLUMN `%s` timestamp; " %(self.stb1, self.col_ts)) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(12) + + 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` order by ts desc; " %self.tb1 + datacheck = self.table1_checkall(sql) + + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(13) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(14) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(15) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(16) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(17) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(18) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(19) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(20) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(21) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + + print("==============change==============") + self.tag_base_change = "abcdas" + 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_smallint_change = "stable_tag_smallint%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_binary_change = "stable_tag_binary%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_double_change = "stable_tag_double%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)) + 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.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + + print("==============modify==============") + # TD-10810 + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + tdSql.execute("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) + tdSql.query("describe db.`%s` ; " %self.tb1) + tdSql.checkRows(22) + + print("==============drop table\stable") + try: + tdSql.execute("drop table db.`%s` " %self.tb1) + except Exception as e: + tdLog.exit(e) + + tdSql.error("select * from db.`%s`" %self.tb1) + tdSql.query("show db.stables like 'stable_1%' ") + tdSql.checkRows(1) + + try: + tdSql.execute("drop table db.`%s` " %self.stb1) + except Exception as e: + tdLog.exit(e) + + tdSql.error("select * from db.`%s`" %self.tb1) + tdSql.error("select * from db.`%s`" %self.stb1) + + + print("==============step2,#create stable,table; insert table; show table; select table; drop table") + + self.stb2 = "stable_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" + self.tb2 = "table_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" + + tdSql.execute("create stable `%s` (ts timestamp, i int) tags(j int);" %self.stb2) + tdSql.query("describe `%s` ; "%self.stb2) + tdSql.checkRows(3) + + tdSql.query("select _block_dist() from `%s` ; " %self.stb2) + tdSql.checkRows(0) + + tdSql.query("show create stable `%s` ; " %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.execute("create table `table!2` using `%s` tags(1)" %self.stb2) + tdSql.query("describe `table!2` ; ") + tdSql.checkRows(3) + + time.sleep(10) + + tdSql.query("show create table `table!2` ; ") + tdSql.checkData(0, 0, "table!2") + tdSql.checkData(0, 1, "CREATE TABLE `table!2` USING `%s` TAGS (1)" %self.stb2) + tdSql.execute("insert into `table!2` values(now, 1)") + tdSql.query("select * from `table!2`; ") + tdSql.checkRows(1) + tdSql.query("select count(*) from `table!2`; ") + tdSql.checkData(0, 0, 1) + tdSql.query("select _block_dist() from `%s` ; " %self.stb2) + tdSql.checkRows(1) + + tdSql.execute("create table `%s` using `%s` tags(1)" %(self.tb2,self.stb2)) + tdSql.query("describe `%s` ; " %self.tb2) + tdSql.checkRows(3) + tdSql.query("show create table `%s` ; " %self.tb2) + tdSql.checkData(0, 0, self.tb2) + tdSql.checkData(0, 1, "CREATE TABLE `%s` USING `%s` TAGS (1)" %(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.query("select count(*) from `%s`; " %self.tb2) + tdSql.checkData(0, 0, 1) + tdSql.query("select * from `%s` ; " %self.stb2) + tdSql.checkRows(2) + tdSql.query("select count(*) from `%s`; " %self.stb2) + tdSql.checkData(0, 0, 2) + + tdSql.query("select * from (select * from `%s`) ; " %self.stb2) + tdSql.checkRows(2) + tdSql.query("select count(*) from (select * from `%s` ); " %self.stb2) + tdSql.checkData(0, 0, 2) + + tdSql.query("show stables like 'stable_2%' ") + tdSql.checkRows(1) + tdSql.query("show tables like 'table%' ") + tdSql.checkRows(2) + + + #TD-10536 + self.cr_tb2 = "create_table_2~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" + tdSql.execute("create table `%s` as select * from `%s` ;" %(self.cr_tb2,self.stb2)) + tdSql.query("show db.tables like 'create_table_%' ") + tdSql.checkRows(1) + + print("==============drop table\stable") + try: + tdSql.execute("drop table `%s` " %self.tb2) + except Exception as e: + tdLog.exit(e) + + tdSql.error("select * from `%s`" %self.tb2) + tdSql.query("show stables like 'stable_2%' ") + tdSql.checkRows(1) + + try: + tdSql.execute("drop table `%s` " %self.stb2) + except Exception as e: + tdLog.exit(e) + + tdSql.error("select * from `%s`" %self.tb2) + tdSql.error("select * from `%s`" %self.stb2) + + + 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_col_base = "123@#$%^&*()-_+=[]{};:,<.>/?~!$%^" + + self.col_int = "regular_table_col_int%s" %self.regular_col_base + print(self.col_int) + 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_tinyint = "regular_table_col_tinyint%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_nchar = "regular_table_col_nchar%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_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 , \ + `%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.col_binary, self.col_nchar, self.col_float, self.col_double, self.col_ts)) + tdSql.query("describe `%s` ; "%self.regular_table) + tdSql.checkRows(11) + + tdSql.query("select _block_dist() from `%s` ; " %self.regular_table) + tdSql.checkRows(1) + + tdSql.query("show create table `%s` ; " %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)" + %(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)) + + tdSql.execute("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) + tdSql.checkRows(1) + 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) + datacheck = self.table1_checkall(sql) + tdSql.checkRows(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)'''\ + %(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 + datacheck = self.table1_checkall(sql) + 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; " \ + %(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) + tdSql.checkRows(2) + + tdSql.query("select count(*) from `%s`; " %self.regular_table) + tdSql.checkData(0, 0, 2) + tdSql.query("select _block_dist() from `%s` ; " %self.regular_table) + tdSql.checkRows(1) + + sql = "select * from (select * from `%s`) ; " %self.regular_table + datacheck = self.table1_checkall(sql) + 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`\ + 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.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) + tdSql.checkRows(2) + + tdSql.query("select count(*) from (select * from `%s` ); " %self.regular_table) + tdSql.checkData(0, 0, 2) + + tdSql.query("show tables like 'regular_table%' ") + tdSql.checkRows(1) + + self.crr_tb = "create_r_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}" + 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.checkRows(1) + + + print("==============drop\ add\ change\ modify column ") + print("==============drop==============") + tdSql.execute("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) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(10) + tdSql.execute("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) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(9) + tdSql.execute("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) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(8) + tdSql.execute("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) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(7) + tdSql.execute("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) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(6) + tdSql.execute("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) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(5) + tdSql.execute("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) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(4) + tdSql.execute("ALTER TABLE `%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_smallint)) + sql = " select * from `%s`; " %self.regular_table + datacheck = self.table1_checkall_2(sql) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(3) + tdSql.execute("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) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(2) + tdSql.error("ALTER TABLE db2.`%s` DROP COLUMN `%s`; " %(self.regular_table, self.col_int)) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(2) + + print("==============add==============") + tdSql.execute("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.execute("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.execute("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.execute("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.execute("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.execute("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) + + tdSql.execute("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.execute("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.execute("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.execute("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.execute("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) + + + print("==============change, regular not support==============") + + + print("==============modify==============") + # TD-10810 + tdSql.execute("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) + tdSql.query("describe db2.`%s` ; " %self.regular_table) + tdSql.checkRows(11) + tdSql.execute("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) + tdSql.query("describe `%s` ; " %self.regular_table) + tdSql.checkRows(11) + + + print("==============drop table\stable") + try: + tdSql.execute("drop table `%s` " %self.regular_table) + except Exception as e: + tdLog.exit(e) + + tdSql.error("select * from `%s`" %self.regular_table) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/0-sql/basic.py b/tests/system-test/1-insert/0-sql/basic.py index cddbc3dc9e9b49d0316105eff09c9684bcfd040d..3604224c512d4a9f85de30a9069136801d343503 100644 --- a/tests/system-test/1-insert/0-sql/basic.py +++ b/tests/system-test/1-insert/0-sql/basic.py @@ -20,9 +20,9 @@ from util.sql import * class TDTestCase: def caseDescription(self): ''' - insert 倒序插入 - 语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效 - insert语句在values之间加入多个逗号 + case1: insert 倒序插入 + case2: 语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效 + case3: [TD-XXXX]insert语句在values之间加入多个逗号 ''' return def init(self, conn, logSql): diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index e71a25659b1e5a2eed92e615f63eb18ace64de92..5040747d3ae4a21ec8fda32793bf06dae98e09e2 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -1 +1,2 @@ -python3 test.py -f 1-insert/0-sql/basic.py \ No newline at end of file +python3 test.py -f 1-insert/0-sql/basic.py +python3 test.py -f 0-management/1-stable/create_col_tag.py \ No newline at end of file