Merge branch 'develop' into feature/2.0tsdb
This commit is contained in:
commit
678a7f4ea7
|
@ -4,6 +4,13 @@
|
||||||
#
|
#
|
||||||
# Build Matrix
|
# Build Matrix
|
||||||
#
|
#
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- coverity_scan
|
||||||
|
- /^.*ci-.*$/
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
- os: linux
|
- os: linux
|
||||||
dist: bionic
|
dist: bionic
|
||||||
|
|
|
@ -42,11 +42,13 @@ static void tscAsyncFetchSingleRowProxy(void *param, TAOS_RES *tres, int numOfRo
|
||||||
int doAsyncParseSql(SSqlObj* pSql) {
|
int doAsyncParseSql(SSqlObj* pSql) {
|
||||||
SSqlCmd* pCmd = &pSql->cmd;
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
SSqlRes* pRes = &pSql->res;
|
SSqlRes* pRes = &pSql->res;
|
||||||
|
|
||||||
int32_t code = tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE);
|
int32_t code = tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tscError("failed to malloc payload");
|
tscError("failed to malloc payload");
|
||||||
|
pSql->res.code = code;
|
||||||
|
|
||||||
tscQueueAsyncRes(pSql);
|
tscQueueAsyncRes(pSql);
|
||||||
// tscQueueAsyncRes(pSql->fp, pSql->param, TSDB_CODE_TSC_OUT_OF_MEMORY);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1482,6 +1482,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
|
||||||
const char* msg5 = "parameter is out of range [0, 100]";
|
const char* msg5 = "parameter is out of range [0, 100]";
|
||||||
const char* msg6 = "function applied to tags not allowed";
|
const char* msg6 = "function applied to tags not allowed";
|
||||||
const char* msg7 = "normal table can not apply this function";
|
const char* msg7 = "normal table can not apply this function";
|
||||||
|
const char* msg8 = "multi-columns selection does not support alias column name";
|
||||||
|
|
||||||
switch (optr) {
|
switch (optr) {
|
||||||
case TK_COUNT: {
|
case TK_COUNT: {
|
||||||
|
@ -1689,6 +1690,10 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
|
||||||
return invalidSqlErrMsg(pQueryInfo->msg, msg3);
|
return invalidSqlErrMsg(pQueryInfo->msg, msg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pItem->pNode->pParam->nExpr > 1 && strlen(pItem->aliasName) > 0) {
|
||||||
|
return invalidSqlErrMsg(pQueryInfo->msg, msg8);
|
||||||
|
}
|
||||||
|
|
||||||
/* in first/last function, multiple columns can be add to resultset */
|
/* in first/last function, multiple columns can be add to resultset */
|
||||||
for (int32_t i = 0; i < pItem->pNode->pParam->nExpr; ++i) {
|
for (int32_t i = 0; i < pItem->pNode->pParam->nExpr; ++i) {
|
||||||
tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[i]);
|
tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[i]);
|
||||||
|
@ -1755,6 +1760,11 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
|
||||||
} else { // select * from xxx
|
} else { // select * from xxx
|
||||||
int32_t numOfFields = 0;
|
int32_t numOfFields = 0;
|
||||||
|
|
||||||
|
// multicolumn selection does not support alias name
|
||||||
|
if (strlen(pItem->aliasName) != 0) {
|
||||||
|
return invalidSqlErrMsg(pQueryInfo->msg, msg8);
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t j = 0; j < pQueryInfo->numOfTables; ++j) {
|
for (int32_t j = 0; j < pQueryInfo->numOfTables; ++j) {
|
||||||
pTableMetaInfo = tscGetMetaInfo(pQueryInfo, j);
|
pTableMetaInfo = tscGetMetaInfo(pQueryInfo, j);
|
||||||
SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta);
|
SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta);
|
||||||
|
|
|
@ -1896,6 +1896,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
|
||||||
tscTrace("%p submit data to %d vnode(s)", pSql, pDataBlocks->nSize);
|
tscTrace("%p submit data to %d vnode(s)", pSql, pDataBlocks->nSize);
|
||||||
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
|
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
|
||||||
pState->numOfTotal = pSql->numOfSubs;
|
pState->numOfTotal = pSql->numOfSubs;
|
||||||
|
pState->numOfRemain = pState->numOfTotal;
|
||||||
|
|
||||||
pRes->code = TSDB_CODE_SUCCESS;
|
pRes->code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -1917,7 +1918,6 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
|
||||||
*/
|
*/
|
||||||
pNew->fetchFp = pNew->fp;
|
pNew->fetchFp = pNew->fp;
|
||||||
pSql->pSubs[i] = pNew;
|
pSql->pSubs[i] = pNew;
|
||||||
pNew->fetchFp = pNew->fp;
|
|
||||||
|
|
||||||
tscTrace("%p sub:%p create subObj success. orderOfSub:%d", pSql, pNew, i);
|
tscTrace("%p sub:%p create subObj success. orderOfSub:%d", pSql, pNew, i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1581,24 +1581,6 @@ void tscClearSubqueryInfo(SSqlCmd* pCmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void doRemoveTableMetaInfo(SQueryInfo* pQueryInfo, int32_t index, bool removeFromCache) {
|
|
||||||
if (index < 0 || index >= pQueryInfo->numOfTables) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index);
|
|
||||||
|
|
||||||
tscClearTableMetaInfo(pTableMetaInfo, removeFromCache);
|
|
||||||
free(pTableMetaInfo);
|
|
||||||
|
|
||||||
int32_t after = pQueryInfo->numOfTables - index - 1;
|
|
||||||
if (after > 0) {
|
|
||||||
memmove(&pQueryInfo->pTableMetaInfo[index], &pQueryInfo->pTableMetaInfo[index + 1], after * POINTER_BYTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
pQueryInfo->numOfTables -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool removeFromCache) {
|
void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool removeFromCache) {
|
||||||
tscTrace("%p deref the table meta in cache, numOfTables:%d", address, pQueryInfo->numOfTables);
|
tscTrace("%p deref the table meta in cache, numOfTables:%d", address, pQueryInfo->numOfTables);
|
||||||
|
|
||||||
|
|
|
@ -425,6 +425,7 @@ int taosGetTableRecordInfo(char *table, STableRecordInfo *pTableRecordInfo) {
|
||||||
|
|
||||||
int taosDumpOut(SDumpArguments *arguments) {
|
int taosDumpOut(SDumpArguments *arguments) {
|
||||||
TAOS_ROW row;
|
TAOS_ROW row;
|
||||||
|
TAOS_RES* result = NULL;
|
||||||
char *temp = NULL;
|
char *temp = NULL;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -464,7 +465,7 @@ int taosDumpOut(SDumpArguments *arguments) {
|
||||||
taosDumpCharset(fp);
|
taosDumpCharset(fp);
|
||||||
|
|
||||||
sprintf(command, "show databases");
|
sprintf(command, "show databases");
|
||||||
TAOS_RES* result = taos_query(taos, command);
|
result = taos_query(taos, command);
|
||||||
int32_t code = taos_errno(result);
|
int32_t code = taos_errno(result);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
fprintf(stderr, "failed to run command: %s, reason: %s\n", command, taos_errstr(result));
|
fprintf(stderr, "failed to run command: %s, reason: %s\n", command, taos_errstr(result));
|
||||||
|
@ -571,7 +572,7 @@ int taosDumpOut(SDumpArguments *arguments) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
taos_close(taos);
|
taos_close(taos);
|
||||||
taos_free_result(result);
|
taos_free_result(result);
|
||||||
free(temp);
|
tfree(temp);
|
||||||
taosFreeDbInfos();
|
taosFreeDbInfos();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -579,7 +580,7 @@ _exit_failure:
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
taos_close(taos);
|
taos_close(taos);
|
||||||
taos_free_result(result);
|
taos_free_result(result);
|
||||||
free(temp);
|
tfree(temp);
|
||||||
taosFreeDbInfos();
|
taosFreeDbInfos();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,8 +365,10 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
|
||||||
mnodeUpdateVgroupStatus(pVgroup, pDnode, pVload);
|
mnodeUpdateVgroupStatus(pVgroup, pDnode, pVload);
|
||||||
pAccess->vgId = htonl(pVload->vgId);
|
pAccess->vgId = htonl(pVload->vgId);
|
||||||
pAccess->accessState = pVgroup->accessState;
|
pAccess->accessState = pVgroup->accessState;
|
||||||
|
pAccess++;
|
||||||
mnodeDecVgroupRef(pVgroup);
|
mnodeDecVgroupRef(pVgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDnode->status == TAOS_DN_STATUS_OFFLINE) {
|
if (pDnode->status == TAOS_DN_STATUS_OFFLINE) {
|
||||||
|
|
|
@ -122,12 +122,11 @@ void mqttCleanUpSystem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mqtt_PublishCallback(void** unused, struct mqtt_response_publish* published) {
|
void mqtt_PublishCallback(void** unused, struct mqtt_response_publish* published) {
|
||||||
mqttPrint("mqtt_PublishCallback");
|
|
||||||
/* note that published->topic_name is NOT null-terminated (here we'll change it to a c-string) */
|
/* note that published->topic_name is NOT null-terminated (here we'll change it to a c-string) */
|
||||||
char* topic_name = (char*)malloc(published->topic_name_size + 1);
|
char* topic_name = (char*)malloc(published->topic_name_size + 1);
|
||||||
memcpy(topic_name, published->topic_name, published->topic_name_size);
|
memcpy(topic_name, published->topic_name, published->topic_name_size);
|
||||||
topic_name[published->topic_name_size] = '\0';
|
topic_name[published->topic_name_size] = '\0';
|
||||||
mqttPrint("Received publish('%s'): %s", topic_name, (const char*)published->application_message);
|
mqttPrint("received publish('%s'): %s", topic_name, (const char*)published->application_message);
|
||||||
char _token[128] = {0};
|
char _token[128] = {0};
|
||||||
char _dbname[128] = {0};
|
char _dbname[128] = {0};
|
||||||
char _tablename[128] = {0};
|
char _tablename[128] = {0};
|
||||||
|
@ -166,12 +165,12 @@ void* mqttClientRefresher(void* client) {
|
||||||
mqtt_sync((struct mqtt_client*)client);
|
mqtt_sync((struct mqtt_client*)client);
|
||||||
taosMsleep(100);
|
taosMsleep(100);
|
||||||
}
|
}
|
||||||
mqttPrint("Exit mqttClientRefresher");
|
mqttTrace("quit refresher");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mqttCleanup(int status, int sockfd, pthread_t* client_daemon) {
|
void mqttCleanup(int status, int sockfd, pthread_t* client_daemon) {
|
||||||
mqttPrint("mqttCleanup");
|
mqttPrint("clean up mqtt module");
|
||||||
if (sockfd != -1) close(sockfd);
|
if (sockfd != -1) close(sockfd);
|
||||||
if (client_daemon != NULL) pthread_cancel(*client_daemon);
|
if (client_daemon != NULL) pthread_cancel(*client_daemon);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +196,7 @@ void mqttQueryInsertCallback(void* param, TAOS_RES* result, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mqttReconnectClient(struct mqtt_client* client, void** reconnect_state_vptr) {
|
void mqttReconnectClient(struct mqtt_client* client, void** reconnect_state_vptr) {
|
||||||
mqttPrint("mqttReconnectClient");
|
mqttPrint("reconnect client");
|
||||||
struct reconnect_state_t* reconnect_state = *((struct reconnect_state_t**)reconnect_state_vptr);
|
struct reconnect_state_t* reconnect_state = *((struct reconnect_state_t**)reconnect_state_vptr);
|
||||||
|
|
||||||
/* Close the clients socket if this isn't the initial reconnect call */
|
/* Close the clients socket if this isn't the initial reconnect call */
|
||||||
|
@ -213,7 +212,7 @@ void mqttReconnectClient(struct mqtt_client* client, void** reconnect_state_vptr
|
||||||
/* Open a new socket. */
|
/* Open a new socket. */
|
||||||
int sockfd = open_nb_socket(reconnect_state->hostname, reconnect_state->port);
|
int sockfd = open_nb_socket(reconnect_state->hostname, reconnect_state->port);
|
||||||
if (sockfd == -1) {
|
if (sockfd == -1) {
|
||||||
mqttError("Failed to open socket: ");
|
mqttError("failed to open socket: ");
|
||||||
mqttCleanup(EXIT_FAILURE, sockfd, NULL);
|
mqttCleanup(EXIT_FAILURE, sockfd, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -577,15 +577,24 @@ static void rpcReleaseConn(SRpcConn *pConn) {
|
||||||
size_t size = snprintf(hashstr, sizeof(hashstr), "%x:%x:%x:%d", pConn->peerIp, pConn->linkUid, pConn->peerId, pConn->connType);
|
size_t size = snprintf(hashstr, sizeof(hashstr), "%x:%x:%x:%d", pConn->peerIp, pConn->linkUid, pConn->peerId, pConn->connType);
|
||||||
taosHashRemove(pRpc->hash, hashstr, size);
|
taosHashRemove(pRpc->hash, hashstr, size);
|
||||||
rpcFreeMsg(pConn->pRspMsg); // it may have a response msg saved, but not request msg
|
rpcFreeMsg(pConn->pRspMsg); // it may have a response msg saved, but not request msg
|
||||||
|
pConn->pRspMsg = NULL;
|
||||||
|
|
||||||
|
if (pConn->pReqMsg) rpcFreeCont(pConn->pReqMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// lockedBy can not be reset, since it maybe hold by a thread
|
// memset could not be used, since lockeBy can not be reset
|
||||||
int sid = pConn->sid;
|
pConn->inType = 0;
|
||||||
int64_t lockedBy = pConn->lockedBy;
|
pConn->outType = 0;
|
||||||
memset(pConn, 0, sizeof(SRpcConn));
|
pConn->inTranId = 0;
|
||||||
pConn->lockedBy = lockedBy;
|
pConn->outTranId = 0;
|
||||||
taosFreeId(pRpc->idPool, sid);
|
pConn->secured = 0;
|
||||||
|
pConn->peerIp = 0;
|
||||||
|
pConn->peerPort = 0;
|
||||||
|
pConn->pReqMsg = NULL;
|
||||||
|
pConn->reqMsgLen = 0;
|
||||||
|
pConn->pContext = NULL;
|
||||||
|
|
||||||
|
taosFreeId(pRpc->idPool, pConn->sid);
|
||||||
tTrace("%s, rpc connection is released", pConn->info);
|
tTrace("%s, rpc connection is released", pConn->info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,7 +653,6 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
|
||||||
terrno = TSDB_CODE_RPC_MAX_SESSIONS;
|
terrno = TSDB_CODE_RPC_MAX_SESSIONS;
|
||||||
} else {
|
} else {
|
||||||
pConn = pRpc->connList + sid;
|
pConn = pRpc->connList + sid;
|
||||||
memset(pConn, 0, sizeof(SRpcConn));
|
|
||||||
memcpy(pConn->user, pHead->user, tListLen(pConn->user));
|
memcpy(pConn->user, pHead->user, tListLen(pConn->user));
|
||||||
pConn->pRpc = pRpc;
|
pConn->pRpc = pRpc;
|
||||||
pConn->sid = sid;
|
pConn->sid = sid;
|
||||||
|
@ -885,6 +893,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) {
|
||||||
|
|
||||||
static void rpcReportBrokenLinkToServer(SRpcConn *pConn) {
|
static void rpcReportBrokenLinkToServer(SRpcConn *pConn) {
|
||||||
SRpcInfo *pRpc = pConn->pRpc;
|
SRpcInfo *pRpc = pConn->pRpc;
|
||||||
|
if (pConn->pReqMsg == NULL) return;
|
||||||
|
|
||||||
// if there are pending request, notify the app
|
// if there are pending request, notify the app
|
||||||
rpcAddRef(pRpc);
|
rpcAddRef(pRpc);
|
||||||
|
@ -897,6 +906,8 @@ static void rpcReportBrokenLinkToServer(SRpcConn *pConn) {
|
||||||
rpcMsg.handle = pConn;
|
rpcMsg.handle = pConn;
|
||||||
rpcMsg.msgType = pConn->inType;
|
rpcMsg.msgType = pConn->inType;
|
||||||
rpcMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
rpcMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||||
|
pConn->pReqMsg = NULL;
|
||||||
|
pConn->reqMsgLen = 0;
|
||||||
if (pRpc->cfp) (*(pRpc->cfp))(&rpcMsg, NULL);
|
if (pRpc->cfp) (*(pRpc->cfp))(&rpcMsg, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,9 +191,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
str++;
|
int32_t ret = WCSPatternMatch(&patterStr[i], ++str, size - n - 1, pInfo);
|
||||||
|
|
||||||
int32_t ret = WCSPatternMatch(&patterStr[i], str, wcslen(str), pInfo);
|
|
||||||
if (ret != TSDB_PATTERN_NOMATCH) {
|
if (ret != TSDB_PATTERN_NOMATCH) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +241,9 @@ static int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) {
|
||||||
SPatternCompareInfo pInfo = {'%', '_'};
|
SPatternCompareInfo pInfo = {'%', '_'};
|
||||||
|
|
||||||
wchar_t pattern[128] = {0};
|
wchar_t pattern[128] = {0};
|
||||||
memcpy(pattern, varDataVal(pRight), varDataLen(pRight)/TSDB_NCHAR_SIZE);
|
assert(TSDB_PATTERN_STRING_MAX_LEN < 128);
|
||||||
|
|
||||||
|
memcpy(pattern, varDataVal(pRight), varDataLen(pRight));
|
||||||
assert(varDataLen(pRight) < 128);
|
assert(varDataLen(pRight) < 128);
|
||||||
|
|
||||||
int32_t ret = WCSPatternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft)/TSDB_NCHAR_SIZE, &pInfo);
|
int32_t ret = WCSPatternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft)/TSDB_NCHAR_SIZE, &pInfo);
|
||||||
|
|
|
@ -36,6 +36,7 @@ uint32_t taosRand(void)
|
||||||
#else
|
#else
|
||||||
uint32_t taosRand(void)
|
uint32_t taosRand(void)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
int fd;
|
int fd;
|
||||||
int seed;
|
int seed;
|
||||||
|
|
||||||
|
@ -51,6 +52,8 @@ uint32_t taosRand(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint32_t)seed;
|
return (uint32_t)seed;
|
||||||
|
*/
|
||||||
|
return rand();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
###################################################################
|
||||||
|
# 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
|
||||||
|
from util.log import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.sql import *
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
print("======= Step 1 prepare data=========")
|
||||||
|
tdSql.execute(
|
||||||
|
"create table stb1 (ts timestamp, c1 int, c2 float) tags(t1 int, t2 binary(10), t3 nchar(10))")
|
||||||
|
tdSql.execute(
|
||||||
|
'''insert into tb1 using stb1 tags(1,'tb1', '表1') values ('2020-04-18 15:00:00.000', 1, 0.1)
|
||||||
|
('2020-04-18 15:00:01.000', 1,0.1) ('2020-04-18 15:00:03.000', 3, 0.3) ('2020-04-18 15:00:04.000', 4,0.4)''')
|
||||||
|
tdSql.execute(
|
||||||
|
'''insert into tb2 using stb1 tags(2,'tb2', '表2') values ('2020-04-18 15:00:00.000', 21, 2.1)
|
||||||
|
('2020-04-18 15:00:01.000', 22,2.2) ('2020-04-18 15:00:02.000', 22, 2.1) ('2020-04-18 15:00:03.000', 23,2.2)''')
|
||||||
|
|
||||||
|
tdSql.execute(
|
||||||
|
"create table stb_t (ts timestamp, temperature int, humidity float) tags(id int, name binary(10), dscrption nchar(10))")
|
||||||
|
tdSql.execute(
|
||||||
|
'''insert into tb_t1 using stb_t tags(1,'tb_t1', '温度表1') values ('2020-04-18 15:00:00.000', 25, 0.5)
|
||||||
|
('2020-04-18 15:00:01.000', 25, 0.5) ('2020-04-18 15:00:02.000', 26, 0.7) ('2020-04-18 15:00:03.000', 27, 0.8)''')
|
||||||
|
tdSql.execute(
|
||||||
|
'''insert into tb_t2 using stb_t tags(2,'tb_t2', '温度表2') values ('2020-04-18 15:00:00.000', 33, 0.9)
|
||||||
|
('2020-04-18 15:00:01.000', 35, 1.1) ('2020-04-18 15:00:03.000', 36, 1.3) ('2020-04-18 15:00:04.000', 37, 1.4)''')
|
||||||
|
|
||||||
|
tdSql.execute(
|
||||||
|
"create table stb_p (ts timestamp, pressure float) tags(id int, name binary(10), dscrption nchar(10), location binary(20))")
|
||||||
|
tdSql.execute(
|
||||||
|
'''insert into tb_p1 using stb_p tags(1,'tb_p1', '压力计1', 'beijing') values ('2020-04-18 15:00:00.000', 76.6)
|
||||||
|
('2020-04-18 15:00:01.000', 76.5) ('2020-04-18 15:00:01.500', 77.1) ('2020-04-18 15:00:02.000', 75.3)
|
||||||
|
('2020-04-18 15:00:03.000', 75.1) ('2020-04-18 15:00:04.500', 77.3)''')
|
||||||
|
tdSql.execute(
|
||||||
|
'''insert into tb_p2 using stb_p tags(2,'tb_p2', '压力计2', 'shenzhen') values ('2020-04-18 14:59:59.000', 74.6)
|
||||||
|
('2020-04-18 15:00:01.000', 74.5) ('2020-04-18 15:00:01.500', 73.6) ('2020-04-18 15:00:02.000', 74.5)
|
||||||
|
('2020-04-18 15:00:02.500', 73.9) ('2020-04-18 15:00:03.000', 73.5)''')
|
||||||
|
|
||||||
|
tdSql.execute(
|
||||||
|
"create table stb_v (ts timestamp, velocity float) tags(id int, name binary(10), dscrption nchar(10), location binary(20))")
|
||||||
|
tdSql.execute(
|
||||||
|
'''insert into tb_v1 using stb_v tags(1,'tb_v1', '速度计1', 'beijing ') values ('2020-04-18 15:00:00.000', 176.6)
|
||||||
|
('2020-04-18 15:00:01.000', 176.5)''')
|
||||||
|
tdSql.execute(
|
||||||
|
'''insert into tb_v2 using stb_v tags(2,'tb_v2', '速度计2', 'shenzhen') values ('2020-04-18 15:00:00.000', 171.6)
|
||||||
|
('2020-04-18 15:00:01.000', 171.5)''')
|
||||||
|
|
||||||
|
# explicit join should not work
|
||||||
|
tdSql.error("select * from stb_p join stb_t on (stb_p.id = stb_t.id)")
|
||||||
|
tdSql.error("select * from tb1 join tb2 on (tb1.ts=tb2.ts)")
|
||||||
|
tdSql.error(
|
||||||
|
"select * from stb_p join stb_t on (stb_p.ts=stb_t.ts and stb_p.id = stb_t.id)")
|
||||||
|
|
||||||
|
# alias should not work
|
||||||
|
tdSql.error("select * from stb_p p join stb_t t on (p.id = t.id)")
|
||||||
|
|
||||||
|
# join queries
|
||||||
|
tdSql.query(
|
||||||
|
"select * from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
||||||
|
tdSql.checkRows(6)
|
||||||
|
|
||||||
|
tdSql.query(
|
||||||
|
"select * from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id order by ts desc")
|
||||||
|
tdSql.checkColumnSorted(0, "desc")
|
||||||
|
|
||||||
|
tdSql.error(
|
||||||
|
"select ts, pressure, temperature, id, dscrption from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
||||||
|
|
||||||
|
tdSql.query("select stb_p.ts, pressure, stb_t.temperature, stb_p.id, stb_p.dscrption from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
||||||
|
tdSql.checkRows(6)
|
||||||
|
|
||||||
|
tdSql.query("select stb_t.ts, stb_p.pressure, stb_t.temperature,stb_p.id,stb_p.dscrption from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
||||||
|
tdSql.checkRows(6)
|
||||||
|
|
||||||
|
tdSql.error(
|
||||||
|
"select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id group by name")
|
||||||
|
tdSql.error(
|
||||||
|
"select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id group by stb_t.name")
|
||||||
|
tdSql.error(
|
||||||
|
"select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id group by stb_t.id")
|
||||||
|
tdSql.error(
|
||||||
|
"select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.name;")
|
||||||
|
tdSql.error(
|
||||||
|
"select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.location = stb_t.name")
|
||||||
|
|
||||||
|
tdSql.execute("alter table stb_t add tag pid int")
|
||||||
|
tdSql.execute("alter table tb_t1 set tag pid=2")
|
||||||
|
tdSql.execute("alter table tb_t2 set tag pid=1")
|
||||||
|
|
||||||
|
tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.pid")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
|
||||||
|
tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
||||||
|
tdSql.checkRows(6)
|
||||||
|
|
||||||
|
tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
||||||
|
tdSql.checkRows(6)
|
||||||
|
|
||||||
|
tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.pid, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -22,12 +22,12 @@ $i = 0
|
||||||
|
|
||||||
sql use $db
|
sql use $db
|
||||||
|
|
||||||
sql create table cpustrm as select count(*), avg(cpu_taosd), max(cpu_taosd), min(cpu_taosd), avg(cpu_system), max(cpu_cores), min(cpu_cores), last(cpu_cores) from log.dn_192_168_0_1 interval(4s) sliding(2s)
|
sql create table cpustrm as select count(*), avg(cpu_taosd), max(cpu_taosd), min(cpu_taosd), avg(cpu_system), max(cpu_cores), min(cpu_cores), last(cpu_cores) from log.dn1 interval(4s) sliding(2s)
|
||||||
sql create table memstrm as select count(*), avg(mem_taosd), max(mem_taosd), min(mem_taosd), avg(mem_system), first(mem_total), last(mem_total) from log.dn_192_168_0_1 interval(4s) sliding(2s)
|
sql create table memstrm as select count(*), avg(mem_taosd), max(mem_taosd), min(mem_taosd), avg(mem_system), first(mem_total), last(mem_total) from log.dn1 interval(4s) sliding(2s)
|
||||||
sql create table diskstrm as select count(*), avg(disk_used), last(disk_used), avg(disk_total), first(disk_total) from log.dn_192_168_0_1 interval(4s) sliding(2s)
|
sql create table diskstrm as select count(*), avg(disk_used), last(disk_used), avg(disk_total), first(disk_total) from log.dn1 interval(4s) sliding(2s)
|
||||||
sql create table bandstrm as select count(*), avg(band_speed), last(band_speed) from log.dn_192_168_0_1 interval(4s) sliding(2s)
|
sql create table bandstrm as select count(*), avg(band_speed), last(band_speed) from log.dn1 interval(4s) sliding(2s)
|
||||||
sql create table reqstrm as select count(*), avg(req_http), last(req_http), avg(req_select), last(req_select), avg(req_insert), last(req_insert) from log.dn_192_168_0_1 interval(4s) sliding(2s)
|
sql create table reqstrm as select count(*), avg(req_http), last(req_http), avg(req_select), last(req_select), avg(req_insert), last(req_insert) from log.dn1 interval(4s) sliding(2s)
|
||||||
sql create table iostrm as select count(*), avg(io_read), last(io_read), avg(io_write), last(io_write) from log.dn_192_168_0_1 interval(4s) sliding(2s)
|
sql create table iostrm as select count(*), avg(io_read), last(io_read), avg(io_write), last(io_write) from log.dn1 interval(4s) sliding(2s)
|
||||||
sleep 20000
|
sleep 20000
|
||||||
sql select * from cpustrm
|
sql select * from cpustrm
|
||||||
if $rows <= 0 then
|
if $rows <= 0 then
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
|
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
|
system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 10
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
#system sh/deploy.sh -n dnode1 -i 1
|
sleep 3000
|
||||||
#system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
|
||||||
#system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 10
|
|
||||||
#system sh/exec.sh -n dnode1 -s start
|
|
||||||
|
|
||||||
#sleep 3000
|
|
||||||
sql connect
|
sql connect
|
||||||
print ======================== dnode1 start
|
print ======================== dnode1 start
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue