1.Merge branch 'develop' into filterComboTest
2.Add query error cases 3.Add normal query cases 3.Add query cases with multiple filters
This commit is contained in:
commit
47c63e89e6
|
@ -29,6 +29,7 @@ void extractTableName(const char* tableId, char* name) {
|
||||||
size_t s2 = strcspn(&tableId[s1 + 1], &TS_PATH_DELIMITER[0]);
|
size_t s2 = strcspn(&tableId[s1 + 1], &TS_PATH_DELIMITER[0]);
|
||||||
|
|
||||||
strncpy(name, &tableId[s1 + s2 + 2], TSDB_TABLE_NAME_LEN);
|
strncpy(name, &tableId[s1 + s2 + 2], TSDB_TABLE_NAME_LEN);
|
||||||
|
name[TSDB_TABLE_NAME_LEN] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* extractDBName(const char* tableId, char* name) {
|
char* extractDBName(const char* tableId, char* name) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <errno.h>
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
@ -64,7 +65,10 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj);
|
||||||
void *cqOpen(void *ahandle, const SCqCfg *pCfg) {
|
void *cqOpen(void *ahandle, const SCqCfg *pCfg) {
|
||||||
|
|
||||||
SCqContext *pContext = calloc(sizeof(SCqContext), 1);
|
SCqContext *pContext = calloc(sizeof(SCqContext), 1);
|
||||||
if (pContext == NULL) return NULL;
|
if (pContext == NULL) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(pContext->user, pCfg->user);
|
strcpy(pContext->user, pCfg->user);
|
||||||
strcpy(pContext->pass, pCfg->pass);
|
strcpy(pContext->pass, pCfg->pass);
|
||||||
|
@ -82,6 +86,7 @@ void *cqOpen(void *ahandle, const SCqCfg *pCfg) {
|
||||||
|
|
||||||
void cqClose(void *handle) {
|
void cqClose(void *handle) {
|
||||||
SCqContext *pContext = handle;
|
SCqContext *pContext = handle;
|
||||||
|
if (handle == NULL) return;
|
||||||
|
|
||||||
// stop all CQs
|
// stop all CQs
|
||||||
cqStop(pContext);
|
cqStop(pContext);
|
||||||
|
@ -106,9 +111,9 @@ void cqClose(void *handle) {
|
||||||
|
|
||||||
void cqStart(void *handle) {
|
void cqStart(void *handle) {
|
||||||
SCqContext *pContext = handle;
|
SCqContext *pContext = handle;
|
||||||
cTrace("vgId:%d, start all CQs", pContext->vgId);
|
|
||||||
if (pContext->dbConn || pContext->master) return;
|
if (pContext->dbConn || pContext->master) return;
|
||||||
|
|
||||||
|
cTrace("vgId:%d, start all CQs", pContext->vgId);
|
||||||
pthread_mutex_lock(&pContext->mutex);
|
pthread_mutex_lock(&pContext->mutex);
|
||||||
|
|
||||||
pContext->master = 1;
|
pContext->master = 1;
|
||||||
|
|
|
@ -94,8 +94,8 @@ typedef void* tsync_h;
|
||||||
|
|
||||||
tsync_h syncStart(const SSyncInfo *);
|
tsync_h syncStart(const SSyncInfo *);
|
||||||
void syncStop(tsync_h shandle);
|
void syncStop(tsync_h shandle);
|
||||||
int syncReconfig(tsync_h shandle, const SSyncCfg *);
|
int32_t syncReconfig(tsync_h shandle, const SSyncCfg *);
|
||||||
int syncForwardToPeer(tsync_h shandle, void *pHead, void *mhandle, int qtype);
|
int32_t syncForwardToPeer(tsync_h shandle, void *pHead, void *mhandle, int qtype);
|
||||||
void syncConfirmForward(tsync_h shandle, uint64_t version, int32_t code);
|
void syncConfirmForward(tsync_h shandle, uint64_t version, int32_t code);
|
||||||
void syncRecover(tsync_h shandle); // recover from other nodes:
|
void syncRecover(tsync_h shandle); // recover from other nodes:
|
||||||
int syncGetNodesRole(tsync_h shandle, SNodesRole *);
|
int syncGetNodesRole(tsync_h shandle, SNodesRole *);
|
||||||
|
|
|
@ -63,7 +63,6 @@ typedef struct SMnodeObj {
|
||||||
int8_t updateEnd[1];
|
int8_t updateEnd[1];
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
int8_t role;
|
int8_t role;
|
||||||
SDnodeObj *pDnode;
|
|
||||||
} SMnodeObj;
|
} SMnodeObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -65,7 +65,6 @@ static int32_t mgmtMnodeActionInsert(SSdbOper *pOper) {
|
||||||
SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId);
|
SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId);
|
||||||
if (pDnode == NULL) return TSDB_CODE_DNODE_NOT_EXIST;
|
if (pDnode == NULL) return TSDB_CODE_DNODE_NOT_EXIST;
|
||||||
|
|
||||||
pMnode->pDnode = pDnode;
|
|
||||||
pDnode->isMgmt = true;
|
pDnode->isMgmt = true;
|
||||||
mgmtDecDnodeRef(pDnode);
|
mgmtDecDnodeRef(pDnode);
|
||||||
|
|
||||||
|
@ -220,22 +219,27 @@ void mgmtUpdateMnodeIpSet() {
|
||||||
pIter = mgmtGetNextMnode(pIter, &pMnode);
|
pIter = mgmtGetNextMnode(pIter, &pMnode);
|
||||||
if (pMnode == NULL) break;
|
if (pMnode == NULL) break;
|
||||||
|
|
||||||
strcpy(ipSet->fqdn[ipSet->numOfIps], pMnode->pDnode->dnodeFqdn);
|
SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId);
|
||||||
ipSet->port[ipSet->numOfIps] = htons(pMnode->pDnode->dnodePort);
|
if (pDnode != NULL) {
|
||||||
|
strcpy(ipSet->fqdn[ipSet->numOfIps], pDnode->dnodeFqdn);
|
||||||
|
ipSet->port[ipSet->numOfIps] = htons(pDnode->dnodePort);
|
||||||
|
|
||||||
mnodes->nodeInfos[index].nodeId = htonl(pMnode->mnodeId);
|
mnodes->nodeInfos[index].nodeId = htonl(pMnode->mnodeId);
|
||||||
strcpy(mnodes->nodeInfos[index].nodeEp, pMnode->pDnode->dnodeEp);
|
strcpy(mnodes->nodeInfos[index].nodeEp, pDnode->dnodeEp);
|
||||||
|
|
||||||
if (pMnode->role == TAOS_SYNC_ROLE_MASTER) {
|
if (pMnode->role == TAOS_SYNC_ROLE_MASTER) {
|
||||||
ipSet->inUse = ipSet->numOfIps;
|
ipSet->inUse = ipSet->numOfIps;
|
||||||
mnodes->inUse = index;
|
mnodes->inUse = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPrint("mnode:%d, ep:%s %s", index, pMnode->pDnode->dnodeEp, pMnode->role == TAOS_SYNC_ROLE_MASTER ? "master" : "");
|
mPrint("mnode:%d, ep:%s %s", index, pDnode->dnodeEp,
|
||||||
|
pMnode->role == TAOS_SYNC_ROLE_MASTER ? "master" : "");
|
||||||
|
|
||||||
ipSet->numOfIps++;
|
ipSet->numOfIps++;
|
||||||
index++;
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mgmtDecDnodeRef(pDnode);
|
||||||
mgmtDecMnodeRef(pMnode);
|
mgmtDecMnodeRef(pMnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +389,15 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pMnode->pDnode->dnodeEp, pShow->bytes[cols] - VARSTR_HEADER_SIZE);
|
|
||||||
|
SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId);
|
||||||
|
if (pDnode != NULL) {
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDnode->dnodeEp, pShow->bytes[cols] - VARSTR_HEADER_SIZE);
|
||||||
|
} else {
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, "invalid ep", pShow->bytes[cols] - VARSTR_HEADER_SIZE);
|
||||||
|
}
|
||||||
|
mgmtDecDnodeRef(pDnode);
|
||||||
|
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "mgmtDef.h"
|
#include "mgmtDef.h"
|
||||||
#include "mgmtInt.h"
|
#include "mgmtInt.h"
|
||||||
#include "mgmtMnode.h"
|
#include "mgmtMnode.h"
|
||||||
|
#include "mgmtDnode.h"
|
||||||
#include "mgmtSdb.h"
|
#include "mgmtSdb.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -259,10 +260,15 @@ void sdbUpdateSync() {
|
||||||
if (pMnode == NULL) break;
|
if (pMnode == NULL) break;
|
||||||
|
|
||||||
syncCfg.nodeInfo[index].nodeId = pMnode->mnodeId;
|
syncCfg.nodeInfo[index].nodeId = pMnode->mnodeId;
|
||||||
syncCfg.nodeInfo[index].nodePort = pMnode->pDnode->dnodePort + TSDB_PORT_SYNC;
|
|
||||||
strcpy(syncCfg.nodeInfo[index].nodeFqdn, pMnode->pDnode->dnodeEp);
|
|
||||||
index++;
|
|
||||||
|
|
||||||
|
SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId);
|
||||||
|
if (pDnode != NULL) {
|
||||||
|
syncCfg.nodeInfo[index].nodePort = pDnode->dnodePort + TSDB_PORT_SYNC;
|
||||||
|
strcpy(syncCfg.nodeInfo[index].nodeFqdn, pDnode->dnodeEp);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mgmtDecDnodeRef(pDnode);
|
||||||
mgmtDecMnodeRef(pMnode);
|
mgmtDecMnodeRef(pMnode);
|
||||||
}
|
}
|
||||||
sdbFreeIter(pIter);
|
sdbFreeIter(pIter);
|
||||||
|
|
|
@ -1139,7 +1139,7 @@ int32_t mgmtRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, v
|
||||||
prefixLen = strlen(prefix);
|
prefixLen = strlen(prefix);
|
||||||
|
|
||||||
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
||||||
char stableName[TSDB_TABLE_NAME_LEN] = {0};
|
char stableName[TSDB_TABLE_NAME_LEN + 1] = {0};
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
pShow->pIter = mgmtGetNextSuperTable(pShow->pIter, &pTable);
|
pShow->pIter = mgmtGetNextSuperTable(pShow->pIter, &pTable);
|
||||||
|
@ -2154,7 +2154,7 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char tableName[TSDB_TABLE_NAME_LEN] = {0};
|
char tableName[TSDB_TABLE_NAME_LEN + 1] = {0};
|
||||||
|
|
||||||
// pattern compare for table name
|
// pattern compare for table name
|
||||||
mgmtExtractTableName(pTable->info.tableId, tableName);
|
mgmtExtractTableName(pTable->info.tableId, tableName);
|
||||||
|
|
|
@ -65,6 +65,7 @@ taos_queue taosOpenQueue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosCloseQueue(taos_queue param) {
|
void taosCloseQueue(taos_queue param) {
|
||||||
|
if (param == NULL) return;
|
||||||
STaosQueue *queue = (STaosQueue *)param;
|
STaosQueue *queue = (STaosQueue *)param;
|
||||||
STaosQnode *pTemp;
|
STaosQnode *pTemp;
|
||||||
STaosQnode *pNode = queue->head;
|
STaosQnode *pNode = queue->head;
|
||||||
|
@ -224,6 +225,7 @@ taos_qset taosOpenQset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosCloseQset(taos_qset param) {
|
void taosCloseQset(taos_qset param) {
|
||||||
|
if (param == NULL) return;
|
||||||
STaosQset *qset = (STaosQset *)param;
|
STaosQset *qset = (STaosQset *)param;
|
||||||
pthread_mutex_destroy(&qset->mutex);
|
pthread_mutex_destroy(&qset->mutex);
|
||||||
tsem_destroy(&qset->sem);
|
tsem_destroy(&qset->sem);
|
||||||
|
|
|
@ -305,7 +305,7 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
|
||||||
sockFd = -1;
|
sockFd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosKeepTcpAlive(sockFd);
|
// taosKeepTcpAlive(sockFd);
|
||||||
|
|
||||||
return sockFd;
|
return sockFd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -501,6 +501,7 @@ static void taosTmrModuleInit(void) {
|
||||||
tmr_ctrl_t* ctrl = tmrCtrls + i;
|
tmr_ctrl_t* ctrl = tmrCtrls + i;
|
||||||
ctrl->next = ctrl + 1;
|
ctrl->next = ctrl + 1;
|
||||||
}
|
}
|
||||||
|
(tmrCtrls + taosMaxTmrCtrl - 1)->next = NULL;
|
||||||
unusedTmrCtrl = tmrCtrls;
|
unusedTmrCtrl = tmrCtrls;
|
||||||
|
|
||||||
pthread_mutex_init(&tmrCtrlMutex, NULL);
|
pthread_mutex_init(&tmrCtrlMutex, NULL);
|
||||||
|
|
|
@ -35,7 +35,7 @@ static void vnodeCleanUp(SVnodeObj *pVnode);
|
||||||
static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg);
|
static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg);
|
||||||
static int32_t vnodeReadCfg(SVnodeObj *pVnode);
|
static int32_t vnodeReadCfg(SVnodeObj *pVnode);
|
||||||
static int32_t vnodeSaveVersion(SVnodeObj *pVnode);
|
static int32_t vnodeSaveVersion(SVnodeObj *pVnode);
|
||||||
static bool vnodeReadVersion(SVnodeObj *pVnode);
|
static int32_t vnodeReadVersion(SVnodeObj *pVnode);
|
||||||
static int vnodeProcessTsdbStatus(void *arg, int status);
|
static int vnodeProcessTsdbStatus(void *arg, int status);
|
||||||
static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size, uint64_t *fversion);
|
static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size, uint64_t *fversion);
|
||||||
static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index);
|
static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index);
|
||||||
|
@ -46,9 +46,9 @@ static pthread_once_t vnodeModuleInit = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
#ifndef _SYNC
|
#ifndef _SYNC
|
||||||
tsync_h syncStart(const SSyncInfo *info) { return NULL; }
|
tsync_h syncStart(const SSyncInfo *info) { return NULL; }
|
||||||
int syncForwardToPeer(tsync_h shandle, void *pHead, void *mhandle, int qtype) { return 0; }
|
int32_t syncForwardToPeer(tsync_h shandle, void *pHead, void *mhandle, int qtype) { return 0; }
|
||||||
void syncStop(tsync_h shandle) {}
|
void syncStop(tsync_h shandle) {}
|
||||||
int syncReconfig(tsync_h shandle, const SSyncCfg * cfg) { return 0; }
|
int32_t syncReconfig(tsync_h shandle, const SSyncCfg * cfg) { return 0; }
|
||||||
int syncGetNodesRole(tsync_h shandle, SNodesRole * cfg) { return 0; }
|
int syncGetNodesRole(tsync_h shandle, SNodesRole * cfg) { return 0; }
|
||||||
void syncConfirmForward(tsync_h shandle, uint64_t version, int32_t code) {}
|
void syncConfirmForward(tsync_h shandle, uint64_t version, int32_t code) {}
|
||||||
#endif
|
#endif
|
||||||
|
@ -148,35 +148,20 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) {
|
||||||
pVnode->status = TAOS_VN_STATUS_UPDATING;
|
pVnode->status = TAOS_VN_STATUS_UPDATING;
|
||||||
|
|
||||||
int32_t code = vnodeSaveCfg(pVnodeCfg);
|
int32_t code = vnodeSaveCfg(pVnodeCfg);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) return code;
|
||||||
vError("vgId:%d, failed to save vnode cfg, reason:%s", pVnodeCfg->cfg.vgId, tstrerror(code));
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = vnodeReadCfg(pVnode);
|
code = vnodeReadCfg(pVnode);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) return code;
|
||||||
vError("vgId:%d, failed to read cfg file", pVnode->vgId);
|
|
||||||
taosHashRemove(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t));
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = syncReconfig(pVnode->sync, &pVnode->syncCfg);
|
code = syncReconfig(pVnode->sync, &pVnode->syncCfg);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) return code;
|
||||||
vTrace("vgId:%d, failed to alter vnode, canot reconfig sync, result:%s", pVnode->vgId,
|
|
||||||
tstrerror(code));
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = tsdbConfigRepo(pVnode->tsdb, &pVnode->tsdbCfg);
|
code = tsdbConfigRepo(pVnode->tsdb, &pVnode->tsdbCfg);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) return code;
|
||||||
vTrace("vgId:%d, failed to alter vnode, canot reconfig tsdb, result:%s", pVnode->vgId,
|
|
||||||
tstrerror(code));
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
pVnode->status = TAOS_VN_STATUS_READY;
|
pVnode->status = TAOS_VN_STATUS_READY;
|
||||||
|
|
||||||
vTrace("vgId:%d, vnode is altered", pVnode->vgId);
|
vTrace("vgId:%d, vnode is altered", pVnode->vgId);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,26 +170,40 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
|
||||||
pthread_once(&vnodeModuleInit, vnodeInit);
|
pthread_once(&vnodeModuleInit, vnodeInit);
|
||||||
|
|
||||||
SVnodeObj *pVnode = calloc(sizeof(SVnodeObj), 1);
|
SVnodeObj *pVnode = calloc(sizeof(SVnodeObj), 1);
|
||||||
|
if (pVnode == NULL) {
|
||||||
|
vError("vgId:%d, failed to open vnode since no enough memory", vnode);
|
||||||
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
atomic_add_fetch_32(&tsOpennedVnodes, 1);
|
||||||
|
atomic_add_fetch_32(&pVnode->refCount, 1);
|
||||||
|
|
||||||
pVnode->vgId = vnode;
|
pVnode->vgId = vnode;
|
||||||
pVnode->status = TAOS_VN_STATUS_INIT;
|
pVnode->status = TAOS_VN_STATUS_INIT;
|
||||||
pVnode->refCount = 1;
|
|
||||||
pVnode->version = 0;
|
pVnode->version = 0;
|
||||||
pVnode->tsdbCfg.tsdbId = pVnode->vgId;
|
pVnode->tsdbCfg.tsdbId = pVnode->vgId;
|
||||||
pVnode->rootDir = strdup(rootDir);
|
pVnode->rootDir = strdup(rootDir);
|
||||||
taosHashPut(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t), (char *)(&pVnode), sizeof(SVnodeObj *));
|
|
||||||
|
|
||||||
int32_t code = vnodeReadCfg(pVnode);
|
int32_t code = vnodeReadCfg(pVnode);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
vError("vgId:%d, failed to read cfg file", pVnode->vgId);
|
vnodeCleanUp(pVnode);
|
||||||
taosHashRemove(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t));
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = vnodeReadVersion(pVnode);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
vnodeCleanUp(pVnode);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
vnodeReadVersion(pVnode);
|
|
||||||
pVnode->fversion = pVnode->version;
|
pVnode->fversion = pVnode->version;
|
||||||
|
|
||||||
pVnode->wqueue = dnodeAllocateWqueue(pVnode);
|
pVnode->wqueue = dnodeAllocateWqueue(pVnode);
|
||||||
pVnode->rqueue = dnodeAllocateRqueue(pVnode);
|
pVnode->rqueue = dnodeAllocateRqueue(pVnode);
|
||||||
|
if (pVnode->wqueue == NULL || pVnode->rqueue == NULL) {
|
||||||
|
vnodeCleanUp(pVnode);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
SCqCfg cqCfg = {0};
|
SCqCfg cqCfg = {0};
|
||||||
sprintf(cqCfg.user, "root");
|
sprintf(cqCfg.user, "root");
|
||||||
|
@ -212,22 +211,29 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
|
||||||
cqCfg.vgId = vnode;
|
cqCfg.vgId = vnode;
|
||||||
cqCfg.cqWrite = vnodeWriteToQueue;
|
cqCfg.cqWrite = vnodeWriteToQueue;
|
||||||
pVnode->cq = cqOpen(pVnode, &cqCfg);
|
pVnode->cq = cqOpen(pVnode, &cqCfg);
|
||||||
|
if (pVnode->cq == NULL) {
|
||||||
|
vnodeCleanUp(pVnode);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
STsdbAppH appH = {0};
|
STsdbAppH appH = {0};
|
||||||
appH.appH = (void *)pVnode;
|
appH.appH = (void *)pVnode;
|
||||||
appH.notifyStatus = vnodeProcessTsdbStatus;
|
appH.notifyStatus = vnodeProcessTsdbStatus;
|
||||||
appH.cqH = pVnode->cq;
|
appH.cqH = pVnode->cq;
|
||||||
|
|
||||||
sprintf(temp, "%s/tsdb", rootDir);
|
sprintf(temp, "%s/tsdb", rootDir);
|
||||||
pVnode->tsdb = tsdbOpenRepo(temp, &appH);
|
pVnode->tsdb = tsdbOpenRepo(temp, &appH);
|
||||||
if (pVnode->tsdb == NULL) {
|
if (pVnode->tsdb == NULL) {
|
||||||
vError("vgId:%d, failed to open tsdb at %s(%s)", pVnode->vgId, temp, tstrerror(terrno));
|
vnodeCleanUp(pVnode);
|
||||||
taosHashRemove(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t));
|
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(temp, "%s/wal", rootDir);
|
sprintf(temp, "%s/wal", rootDir);
|
||||||
pVnode->wal = walOpen(temp, &pVnode->walCfg);
|
pVnode->wal = walOpen(temp, &pVnode->walCfg);
|
||||||
|
if (pVnode->wal == NULL) {
|
||||||
|
vnodeCleanUp(pVnode);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
walRestore(pVnode->wal, pVnode, vnodeWriteToQueue);
|
walRestore(pVnode->wal, pVnode, vnodeWriteToQueue);
|
||||||
|
|
||||||
SSyncInfo syncInfo;
|
SSyncInfo syncInfo;
|
||||||
|
@ -246,6 +252,11 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
|
||||||
|
|
||||||
#ifndef _SYNC
|
#ifndef _SYNC
|
||||||
pVnode->role = TAOS_SYNC_ROLE_MASTER;
|
pVnode->role = TAOS_SYNC_ROLE_MASTER;
|
||||||
|
#else
|
||||||
|
if (pVnode->sync == NULL) {
|
||||||
|
vnodeCleanUp(pVnode);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// start continuous query
|
// start continuous query
|
||||||
|
@ -253,11 +264,11 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
|
||||||
cqStart(pVnode->cq);
|
cqStart(pVnode->cq);
|
||||||
|
|
||||||
pVnode->events = NULL;
|
pVnode->events = NULL;
|
||||||
|
|
||||||
pVnode->status = TAOS_VN_STATUS_READY;
|
pVnode->status = TAOS_VN_STATUS_READY;
|
||||||
vTrace("vgId:%d, vnode is opened in %s, pVnode:%p", pVnode->vgId, rootDir, pVnode);
|
vTrace("vgId:%d, vnode is opened in %s, pVnode:%p", pVnode->vgId, rootDir, pVnode);
|
||||||
|
|
||||||
atomic_add_fetch_32(&tsOpennedVnodes, 1);
|
taosHashPut(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t), (char *)(&pVnode), sizeof(SVnodeObj *));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,13 +297,6 @@ void vnodeRelease(void *pVnodeRaw) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pVnode->rootDir);
|
tfree(pVnode->rootDir);
|
||||||
// remove read queue
|
|
||||||
dnodeFreeRqueue(pVnode->rqueue);
|
|
||||||
pVnode->rqueue = NULL;
|
|
||||||
|
|
||||||
// remove write queue
|
|
||||||
dnodeFreeWqueue(pVnode->wqueue);
|
|
||||||
pVnode->wqueue = NULL;
|
|
||||||
|
|
||||||
if (pVnode->status == TAOS_VN_STATUS_DELETING) {
|
if (pVnode->status == TAOS_VN_STATUS_DELETING) {
|
||||||
char rootDir[TSDB_FILENAME_LEN] = {0};
|
char rootDir[TSDB_FILENAME_LEN] = {0};
|
||||||
|
@ -387,14 +391,25 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
|
||||||
pVnode->sync = NULL;
|
pVnode->sync = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cqClose(pVnode->cq);
|
if (pVnode->wal)
|
||||||
pVnode->cq = NULL;
|
walClose(pVnode->wal);
|
||||||
|
pVnode->wal = NULL;
|
||||||
|
|
||||||
|
if (pVnode->tsdb)
|
||||||
tsdbCloseRepo(pVnode->tsdb, 1);
|
tsdbCloseRepo(pVnode->tsdb, 1);
|
||||||
pVnode->tsdb = NULL;
|
pVnode->tsdb = NULL;
|
||||||
|
|
||||||
walClose(pVnode->wal);
|
if (pVnode->cq)
|
||||||
pVnode->wal = NULL;
|
cqClose(pVnode->cq);
|
||||||
|
pVnode->cq = NULL;
|
||||||
|
|
||||||
|
if (pVnode->wqueue)
|
||||||
|
dnodeFreeWqueue(pVnode->wqueue);
|
||||||
|
pVnode->wqueue = NULL;
|
||||||
|
|
||||||
|
if (pVnode->rqueue)
|
||||||
|
dnodeFreeRqueue(pVnode->rqueue);
|
||||||
|
pVnode->rqueue = NULL;
|
||||||
|
|
||||||
vnodeRelease(pVnode);
|
vnodeRelease(pVnode);
|
||||||
}
|
}
|
||||||
|
@ -462,7 +477,8 @@ static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) {
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
vError("vgId:%d, failed to open vnode cfg file for write, file:%s error:%s", pVnodeCfg->cfg.vgId, cfgFile,
|
vError("vgId:%d, failed to open vnode cfg file for write, file:%s error:%s", pVnodeCfg->cfg.vgId, cfgFile,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return errno;
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
|
@ -512,27 +528,30 @@ static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeReadCfg(SVnodeObj *pVnode) {
|
static int32_t vnodeReadCfg(SVnodeObj *pVnode) {
|
||||||
|
cJSON *root = NULL;
|
||||||
|
char *content = NULL;
|
||||||
char cfgFile[TSDB_FILENAME_LEN + 30] = {0};
|
char cfgFile[TSDB_FILENAME_LEN + 30] = {0};
|
||||||
|
int maxLen = 1000;
|
||||||
|
|
||||||
|
terrno = TSDB_CODE_OTHERS;
|
||||||
sprintf(cfgFile, "%s/vnode%d/config.json", tsVnodeDir, pVnode->vgId);
|
sprintf(cfgFile, "%s/vnode%d/config.json", tsVnodeDir, pVnode->vgId);
|
||||||
FILE *fp = fopen(cfgFile, "r");
|
FILE *fp = fopen(cfgFile, "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
vError("vgId:%d, failed to open vnode cfg file for read, file:%s, error:%s", pVnode->vgId,
|
vError("vgId:%d, failed to open vnode cfg file:%s to read, error:%s", pVnode->vgId,
|
||||||
cfgFile, strerror(errno));
|
cfgFile, strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
goto PARSE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
content = calloc(1, maxLen + 1);
|
||||||
|
if (content == NULL) goto PARSE_OVER;
|
||||||
|
int len = fread(content, 1, maxLen, fp);
|
||||||
|
if (len <= 0) {
|
||||||
|
vError("vgId:%d, failed to read vnode cfg, content is null", pVnode->vgId);
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = TSDB_CODE_OTHERS;
|
root = cJSON_Parse(content);
|
||||||
int maxLen = 1000;
|
|
||||||
char *content = calloc(1, maxLen + 1);
|
|
||||||
int len = fread(content, 1, maxLen, fp);
|
|
||||||
if (len <= 0) {
|
|
||||||
free(content);
|
|
||||||
fclose(fp);
|
|
||||||
vError("vgId:%d, failed to read vnode cfg, content is null", pVnode->vgId);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON *root = cJSON_Parse(content);
|
|
||||||
if (root == NULL) {
|
if (root == NULL) {
|
||||||
vError("vgId:%d, failed to read vnode cfg, invalid json format", pVnode->vgId);
|
vError("vgId:%d, failed to read vnode cfg, invalid json format", pVnode->vgId);
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
|
@ -691,19 +710,19 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) {
|
||||||
pVnode->syncCfg.nodeInfo[i].nodePort += TSDB_PORT_SYNC;
|
pVnode->syncCfg.nodeInfo[i].nodePort += TSDB_PORT_SYNC;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
vPrint("vgId:%d, read vnode cfg successed, replcia:%d", pVnode->vgId, pVnode->syncCfg.replica);
|
vPrint("vgId:%d, read vnode cfg successfully, replcia:%d", pVnode->vgId, pVnode->syncCfg.replica);
|
||||||
for (int32_t i = 0; i < pVnode->syncCfg.replica; i++) {
|
for (int32_t i = 0; i < pVnode->syncCfg.replica; i++) {
|
||||||
vPrint("vgId:%d, dnode:%d, %s:%d", pVnode->vgId, pVnode->syncCfg.nodeInfo[i].nodeId,
|
vPrint("vgId:%d, dnode:%d, %s:%d", pVnode->vgId, pVnode->syncCfg.nodeInfo[i].nodeId,
|
||||||
pVnode->syncCfg.nodeInfo[i].nodeFqdn, pVnode->syncCfg.nodeInfo[i].nodePort);
|
pVnode->syncCfg.nodeInfo[i].nodeFqdn, pVnode->syncCfg.nodeInfo[i].nodePort);
|
||||||
}
|
}
|
||||||
|
|
||||||
PARSE_OVER:
|
PARSE_OVER:
|
||||||
free(content);
|
tfree(content);
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
fclose(fp);
|
if (fp) fclose(fp);
|
||||||
return ret;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeSaveVersion(SVnodeObj *pVnode) {
|
static int32_t vnodeSaveVersion(SVnodeObj *pVnode) {
|
||||||
|
@ -713,7 +732,7 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) {
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
vError("vgId:%d, failed to open vnode version file for write, file:%s error:%s", pVnode->vgId,
|
vError("vgId:%d, failed to open vnode version file for write, file:%s error:%s", pVnode->vgId,
|
||||||
versionFile, strerror(errno));
|
versionFile, strerror(errno));
|
||||||
return errno;
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
|
@ -733,29 +752,33 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool vnodeReadVersion(SVnodeObj *pVnode) {
|
static int32_t vnodeReadVersion(SVnodeObj *pVnode) {
|
||||||
char versionFile[TSDB_FILENAME_LEN + 30] = {0};
|
char versionFile[TSDB_FILENAME_LEN + 30] = {0};
|
||||||
|
char *content = NULL;
|
||||||
|
cJSON *root = NULL;
|
||||||
|
int maxLen = 100;
|
||||||
|
|
||||||
|
terrno = TSDB_CODE_OTHERS;
|
||||||
sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId);
|
sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId);
|
||||||
FILE *fp = fopen(versionFile, "r");
|
FILE *fp = fopen(versionFile, "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
vError("vgId:%d, failed to open version file:%s error:%s", pVnode->vgId, versionFile, strerror(errno));
|
vError("vgId:%d, failed to open version file:%s error:%s", pVnode->vgId, versionFile, strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = false;
|
content = calloc(1, maxLen + 1);
|
||||||
int maxLen = 100;
|
|
||||||
char *content = calloc(1, maxLen + 1);
|
|
||||||
int len = fread(content, 1, maxLen, fp);
|
int len = fread(content, 1, maxLen, fp);
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
free(content);
|
vError("vgId:%d, failed to read vnode version, content is null", pVnode->vgId);
|
||||||
fclose(fp);
|
goto PARSE_OVER;
|
||||||
vPrint("vgId:%d, failed to read vnode version, content is null", pVnode->vgId);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON *root = cJSON_Parse(content);
|
root = cJSON_Parse(content);
|
||||||
if (root == NULL) {
|
if (root == NULL) {
|
||||||
vError("vgId:%d, failed to read vnode version, invalid json format", pVnode->vgId);
|
vError("vgId:%d, failed to read vnode version, invalid json format", pVnode->vgId);
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
|
@ -768,13 +791,12 @@ static bool vnodeReadVersion(SVnodeObj *pVnode) {
|
||||||
}
|
}
|
||||||
pVnode->version = version->valueint;
|
pVnode->version = version->valueint;
|
||||||
|
|
||||||
ret = true;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
vPrint("vgId:%d, read vnode version successfully, version:%" PRId64, pVnode->vgId, pVnode->version);
|
||||||
vPrint("vgId:%d, read vnode version succeed, version:%" PRId64, pVnode->vgId, pVnode->version);
|
|
||||||
|
|
||||||
PARSE_OVER:
|
PARSE_OVER:
|
||||||
free(content);
|
tfree(content);
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
fclose(fp);
|
if(fp) fclose(fp);
|
||||||
return ret;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "tchecksum.h"
|
#include "tchecksum.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
#include "taoserror.h"
|
||||||
#include "twal.h"
|
#include "twal.h"
|
||||||
#include "tqueue.h"
|
#include "tqueue.h"
|
||||||
|
|
||||||
|
@ -56,7 +57,10 @@ static int walRemoveWalFiles(const char *path);
|
||||||
|
|
||||||
void *walOpen(const char *path, const SWalCfg *pCfg) {
|
void *walOpen(const char *path, const SWalCfg *pCfg) {
|
||||||
SWal *pWal = calloc(sizeof(SWal), 1);
|
SWal *pWal = calloc(sizeof(SWal), 1);
|
||||||
if (pWal == NULL) return NULL;
|
if (pWal == NULL) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
pWal->fd = -1;
|
pWal->fd = -1;
|
||||||
pWal->max = pCfg->wals;
|
pWal->max = pCfg->wals;
|
||||||
|
@ -75,6 +79,7 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
|
||||||
walRenew(pWal);
|
walRenew(pWal);
|
||||||
|
|
||||||
if (pWal->fd <0) {
|
if (pWal->fd <0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
wError("wal:%s, failed to open", path);
|
wError("wal:%s, failed to open", path);
|
||||||
pthread_mutex_destroy(&pWal->mutex);
|
pthread_mutex_destroy(&pWal->mutex);
|
||||||
free(pWal);
|
free(pWal);
|
||||||
|
@ -112,6 +117,7 @@ void walClose(void *handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int walRenew(void *handle) {
|
int walRenew(void *handle) {
|
||||||
|
if (handle == NULL) return 0;
|
||||||
SWal *pWal = handle;
|
SWal *pWal = handle;
|
||||||
int code = 0;
|
int code = 0;
|
||||||
|
|
||||||
|
@ -156,6 +162,7 @@ int walRenew(void *handle) {
|
||||||
int walWrite(void *handle, SWalHead *pHead) {
|
int walWrite(void *handle, SWalHead *pHead) {
|
||||||
SWal *pWal = handle;
|
SWal *pWal = handle;
|
||||||
int code = 0;
|
int code = 0;
|
||||||
|
if (pWal == NULL) return -1;
|
||||||
|
|
||||||
// no wal
|
// no wal
|
||||||
if (pWal->level == TAOS_WAL_NOLOG) return 0;
|
if (pWal->level == TAOS_WAL_NOLOG) return 0;
|
||||||
|
@ -178,6 +185,7 @@ int walWrite(void *handle, SWalHead *pHead) {
|
||||||
void walFsync(void *handle) {
|
void walFsync(void *handle) {
|
||||||
|
|
||||||
SWal *pWal = handle;
|
SWal *pWal = handle;
|
||||||
|
if (pWal == NULL) return;
|
||||||
|
|
||||||
if (pWal->level == TAOS_WAL_FSYNC && pWal->fd >=0) {
|
if (pWal->level == TAOS_WAL_FSYNC && pWal->fd >=0) {
|
||||||
if (fsync(pWal->fd) < 0) {
|
if (fsync(pWal->fd) < 0) {
|
||||||
|
|
|
@ -129,4 +129,6 @@ python3 ./test.py -f user/pass_len.py
|
||||||
|
|
||||||
#query
|
#query
|
||||||
python3 ./test.py -f query/filter.py
|
python3 ./test.py -f query/filter.py
|
||||||
|
python3 ./test.py $1 -f query/filterCombo.py
|
||||||
|
python3 ./test.py $1 -f query/queryNormal.py
|
||||||
|
python3 ./test.py $1 -f query/queryError.py
|
||||||
|
|
|
@ -41,12 +41,15 @@ class TDTestCase:
|
||||||
('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'),
|
('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'),
|
||||||
('2020-05-13 10:00:00.005', 3, 'third')""")
|
('2020-05-13 10:00:00.005', 3, 'third')""")
|
||||||
|
|
||||||
|
# query with filter condition A OR condition B
|
||||||
tdSql.query("select * from db.st where ts > '2020-05-13 10:00:00.002' AND tagtype < 2")
|
tdSql.query("select * from db.st where ts > '2020-05-13 10:00:00.002' AND tagtype < 2")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
# query with filter condition A OR condition B, error expected
|
||||||
tdSql.error("select * from db.st where ts > '2020-05-13 10:00:00.002' OR tagtype < 2")
|
tdSql.error("select * from db.st where ts > '2020-05-13 10:00:00.002' OR tagtype < 2")
|
||||||
|
|
||||||
|
# illegal condition
|
||||||
|
tdSql.error("select * from db.st where ts != '2020-05-13 10:00:00.002' OR tagtype < 2")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
###################################################################
|
||||||
|
# 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(), logSql)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
print("==============step1")
|
||||||
|
tdSql.execute(
|
||||||
|
"create table if not exists st (ts timestamp, tagtype int, name nchar(16)) tags(dev nchar(50))")
|
||||||
|
tdSql.execute(
|
||||||
|
'CREATE TABLE if not exists dev_001 using st tags("dev_01")')
|
||||||
|
tdSql.execute(
|
||||||
|
'CREATE TABLE if not exists dev_002 using st tags("dev_02")')
|
||||||
|
|
||||||
|
print("==============step2")
|
||||||
|
|
||||||
|
tdSql.execute(
|
||||||
|
"""INSERT INTO dev_001(ts, tagtype, name) VALUES('2020-05-13 10:00:00.000', 1, 'first'),('2020-05-13 10:00:00.001', 2, 'second'),
|
||||||
|
('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'),
|
||||||
|
('2020-05-13 10:00:00.005', 3, 'third')""")
|
||||||
|
|
||||||
|
"""Error expected here, but no errors
|
||||||
|
# query first .. as ..
|
||||||
|
tdSql.error("select first(*) as one from st")
|
||||||
|
|
||||||
|
# query last .. as ..
|
||||||
|
tdSql.error("select last(*) as latest from st")
|
||||||
|
"""
|
||||||
|
|
||||||
|
# query last row .. as ..
|
||||||
|
tdSql.error("select last_row as latest from st")
|
||||||
|
|
||||||
|
# query distinct on normal colnum
|
||||||
|
tdSql.error("select distinct tagtype from st")
|
||||||
|
|
||||||
|
# query .. order by non-time field
|
||||||
|
tdSql.error("select * from st order by name")
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,84 @@
|
||||||
|
###################################################################
|
||||||
|
# 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(), logSql)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
print("==============step1")
|
||||||
|
|
||||||
|
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', 2, 0.1)")
|
||||||
|
tdSql.execute("insert into tb2 using stb1 tags(2,'tb2', '表2') values ('2020-04-18 15:00:02.000', 3, 2.1), ('2020-04-18 15:00:03.000', 4, 2.2)")
|
||||||
|
|
||||||
|
# join 2 tables -- bug exists
|
||||||
|
# tdSql.query("select * from tb1 a, tb2 b where a.ts = b.ts")
|
||||||
|
# tdSql.checkRows(1)
|
||||||
|
|
||||||
|
# join 3 tables -- bug exists
|
||||||
|
# tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, 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")
|
||||||
|
|
||||||
|
# query count
|
||||||
|
tdSql.query("select count(*) from stb1")
|
||||||
|
tdSql.checkData(0, 0, 4)
|
||||||
|
|
||||||
|
# query first
|
||||||
|
tdSql.query("select first(*) from stb1")
|
||||||
|
tdSql.checkData(0, 1, 1)
|
||||||
|
|
||||||
|
# query last
|
||||||
|
tdSql.query("select last(*) from stb1")
|
||||||
|
tdSql.checkData(0, 1, 4)
|
||||||
|
|
||||||
|
# query as
|
||||||
|
tdSql.query("select t2 as number from stb1")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
|
||||||
|
# query first ... as
|
||||||
|
tdSql.query("select first(*) as begin from stb1")
|
||||||
|
tdSql.checkData(0, 1, 1)
|
||||||
|
|
||||||
|
# query last ... as
|
||||||
|
tdSql.query("select last(*) as end from stb1")
|
||||||
|
tdSql.checkData(0, 1, 4)
|
||||||
|
|
||||||
|
# query group .. by
|
||||||
|
tdSql.query("select sum(c1), t2 from stb1 group by t2")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
|
||||||
|
# query ... limit
|
||||||
|
tdSql.query("select * from stb1 limit 2")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
|
||||||
|
# query ... limit offset
|
||||||
|
tdSql.query("select * from stb1 limit 2 offset 3")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -2,14 +2,10 @@
|
||||||
# insert
|
# insert
|
||||||
python3 ./test.py $1 -f insert/basic.py
|
python3 ./test.py $1 -f insert/basic.py
|
||||||
python3 ./test.py $1 -s && sleep 1
|
python3 ./test.py $1 -s && sleep 1
|
||||||
python3 ./test.py $1 -f query/filterCombo.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
|
|
||||||
:<<!
|
|
||||||
python3 ./test.py $1 -f insert/int.py
|
python3 ./test.py $1 -f insert/int.py
|
||||||
python3 ./test.py $1 -s && sleep 1
|
python3 ./test.py $1 -s && sleep 1
|
||||||
python3 ./test.py $1 -f insert/float.py
|
python3 ./test.py $1 -f insert/float.py
|
||||||
python3 ./test.py $1 -s && sleep 1sss
|
python3 ./test.py $1 -s && sleep 1
|
||||||
python3 ./test.py $1 -f insert/bigint.py
|
python3 ./test.py $1 -f insert/bigint.py
|
||||||
python3 ./test.py $1 -s && sleep 1
|
python3 ./test.py $1 -s && sleep 1
|
||||||
python3 ./test.py $1 -f insert/bool.py
|
python3 ./test.py $1 -f insert/bool.py
|
||||||
|
@ -60,4 +56,10 @@ python3 ./test.py $1 -s && sleep 1
|
||||||
#query
|
#query
|
||||||
python3 ./test.py $1 -f query/filter.py
|
python3 ./test.py $1 -f query/filter.py
|
||||||
python3 ./test.py $1 -s && sleep 1
|
python3 ./test.py $1 -s && sleep 1
|
||||||
!
|
python3 ./test.py $1 -f query/filterCombo.py
|
||||||
|
python3 ./test.py $1 -s && sleep 1
|
||||||
|
python3 ./test.py $1 -f query/queryNormal.py
|
||||||
|
python3 ./test.py $1 -s && sleep 1
|
||||||
|
python3 ./test.py $1 -f query/queryError.py
|
||||||
|
python3 ./test.py $1 -s && sleep 1
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from util.sql import *
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
def init(self, conn):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug("start to execute %s" % __file__)
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
tdSql.init(conn.cursor(), logSql)
|
tdSql.init(conn.cursor(), logSql)
|
||||||
|
|
||||||
|
@ -95,17 +95,42 @@ class TDTestCase:
|
||||||
maxTableNameLen = self.getLimitFromSourceCode('TSDB_TABLE_NAME_LEN')
|
maxTableNameLen = self.getLimitFromSourceCode('TSDB_TABLE_NAME_LEN')
|
||||||
tdLog.notice("table name max length is %d" % maxTableNameLen)
|
tdLog.notice("table name max length is %d" % maxTableNameLen)
|
||||||
|
|
||||||
name = self.generateString(maxTableNameLen - 1)
|
# create a super table with name exceed max length
|
||||||
tdLog.info("table name is '%s'" % name)
|
sname = self.generateString(maxTableNameLen + 1)
|
||||||
|
tdLog.info("create a super table with length %d" % len(sname))
|
||||||
|
tdSql.error("create table %s (ts timestamp, value int) tags(id int)" % sname)
|
||||||
|
|
||||||
tdSql.execute("create table %s (ts timestamp, value int)" % name)
|
# create a super table with name of max length
|
||||||
tdSql.execute("insert into %s values(now, 0)" % name)
|
sname = self.generateString(maxTableNameLen)
|
||||||
|
tdLog.info("create a super table with length %d" % len(sname))
|
||||||
|
tdSql.execute("create table %s (ts timestamp, value int) tags(id int)" % sname)
|
||||||
|
tdLog.info("check table count, should be one")
|
||||||
|
tdSql.query('show stables')
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
# create a child table with name exceed max length
|
||||||
|
name = self.generateString(maxTableNameLen + 1)
|
||||||
|
tdLog.info("create a child table with length %d" % len(name))
|
||||||
|
tdSql.error("create table %s using %s tags(0)" % (name, sname))
|
||||||
|
|
||||||
|
# create a child table with name of max length
|
||||||
|
name = self.generateString(maxTableNameLen)
|
||||||
|
tdLog.info("create a child table with length %d" % len(name))
|
||||||
|
tdSql.execute("create table %s using %s tags(0)" % (name, sname))
|
||||||
tdSql.query('show tables')
|
tdSql.query('show tables')
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
tdSql.query('select * from %s' % name)
|
# insert one row
|
||||||
|
tdLog.info("insert one row of data")
|
||||||
|
tdSql.execute("insert into %s values(now, 0)" % name)
|
||||||
|
tdSql.query("select * from " + name)
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
tdSql.query("select * from " + sname)
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
name = name[:len(name) - 1]
|
||||||
|
tdSql.error("select * from " + name)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
def checkRowBoundaries(self):
|
def checkRowBoundaries(self):
|
||||||
tdLog.debug("checking row boundaries")
|
tdLog.debug("checking row boundaries")
|
||||||
|
|
|
@ -58,6 +58,9 @@ class TDSql:
|
||||||
"%s failed: sql:%s, expect error not occured" %
|
"%s failed: sql:%s, expect error not occured" %
|
||||||
(callerFilename, sql))
|
(callerFilename, sql))
|
||||||
else:
|
else:
|
||||||
|
self.queryRows = 0
|
||||||
|
self.queryCols = 0
|
||||||
|
self.queryResult = None
|
||||||
tdLog.info("sql:%s, expect error occured" % (sql))
|
tdLog.info("sql:%s, expect error occured" % (sql))
|
||||||
|
|
||||||
def query(self, sql):
|
def query(self, sql):
|
||||||
|
|
|
@ -1,14 +1,4 @@
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
|
||||||
system sh/deploy.sh -n dnode2 -i 2
|
|
||||||
system sh/deploy.sh -n dnode3 -i 3
|
|
||||||
|
|
||||||
system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2
|
|
||||||
system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2
|
|
||||||
system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2
|
|
||||||
|
|
||||||
return
|
|
||||||
system sh/stop_dnodes.sh
|
|
||||||
|
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/deploy.sh -n dnode2 -i 2
|
system sh/deploy.sh -n dnode2 -i 2
|
||||||
|
@ -34,3 +24,7 @@ system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4
|
||||||
system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4
|
system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4
|
||||||
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4
|
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4
|
||||||
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
|
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
|
||||||
|
|
||||||
|
system sh/cfg.sh -n dnode1 -c http -v 1
|
||||||
|
system sh/cfg.sh -n dnode2 -c http -v 1
|
||||||
|
system sh/cfg.sh -n dnode3 -c http -v 1
|
Loading…
Reference in New Issue