Merge branch 'develop' into feature/crash_gen

This commit is contained in:
Steven Li 2020-05-12 18:37:50 -07:00
commit bec47687f5
138 changed files with 1127 additions and 729 deletions

View File

@ -49,7 +49,7 @@ matrix:
./test-all.sh $TRAVIS_EVENT_TYPE || travis_terminate $? ./test-all.sh $TRAVIS_EVENT_TYPE || travis_terminate $?
cd ${TRAVIS_BUILD_DIR}/tests/pytest cd ${TRAVIS_BUILD_DIR}/tests/pytest
./smoketest.sh -g 2>&1 | tee mem-error-out.txt ./valgrind-test.sh -g 2>&1 | tee mem-error-out.txt
sleep 1 sleep 1
# Color setting # Color setting
@ -64,7 +64,7 @@ matrix:
for memError in `cat uniq-mem-error-out.txt | awk '{print $4}'` for memError in `cat uniq-mem-error-out.txt | awk '{print $4}'`
do do
if [ -n "$memError" ]; then if [ -n "$memError" ]; then
if [ "$memError" -gt 5 ]; then if [ "$memError" -gt 12 ]; then
echo -e "${RED} ## Memory errors number valgrind reports is $memError.\ echo -e "${RED} ## Memory errors number valgrind reports is $memError.\
More than our threshold! ## ${NC}" More than our threshold! ## ${NC}"
travis_terminate $memError travis_terminate $memError
@ -76,7 +76,7 @@ matrix:
for defiMemError in `cat uniq-definitely-lost-out.txt | awk '{print $7}'` for defiMemError in `cat uniq-definitely-lost-out.txt | awk '{print $7}'`
do do
if [ -n "$defiMemError" ]; then if [ -n "$defiMemError" ]; then
if [ "$defiMemError" -gt 3 ]; then if [ "$defiMemError" -gt 13 ]; then
echo -e "${RED} ## Memory errors number valgrind reports \ echo -e "${RED} ## Memory errors number valgrind reports \
Definitely lost is $defiMemError. More than our threshold! ## ${NC}" Definitely lost is $defiMemError. More than our threshold! ## ${NC}"
travis_terminate $defiMemError travis_terminate $defiMemError
@ -115,7 +115,7 @@ matrix:
# The command that will be added as an argument to "cov-build" to compile your project for analysis, # The command that will be added as an argument to "cov-build" to compile your project for analysis,
# ** likely specific to your build ** # ** likely specific to your build **
build_command: make > /dev/null build_command: make
# Pattern to match selecting branches that will run analysis. We recommend leaving this set to 'coverity_scan'. # Pattern to match selecting branches that will run analysis. We recommend leaving this set to 'coverity_scan'.
# Take care in resource usage, and consider the build frequency allowances per # Take care in resource usage, and consider the build frequency allowances per
@ -163,11 +163,9 @@ matrix:
cd ${TRAVIS_BUILD_DIR}/tests cd ${TRAVIS_BUILD_DIR}/tests
./test-all.sh ./test-all.sh $TRAVIS_EVENT_TYPE COVER
if [ "$?" -ne "0" ]; then TEST_RESULT=$?
travis_terminate $?
fi
pkill taosd pkill taosd
sleep 1 sleep 1
@ -199,6 +197,9 @@ matrix:
echo -e "${RED} ## Codecov did not collect coverage report! ## ${NC} " echo -e "${RED} ## Codecov did not collect coverage report! ## ${NC} "
fi fi
if [ "$TEST_RESULT" -ne "0" ]; then
travis_terminate $?
fi
;; ;;
esac esac

View File

@ -365,7 +365,7 @@ void tscInitMsgsFp();
int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion); int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion);
void tscProcessMsgFromServer(SRpcMsg *rpcMsg); void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet);
int tscProcessSql(SSqlObj *pSql); int tscProcessSql(SSqlObj *pSql);
int tscRenewMeterMeta(SSqlObj *pSql, char *tableId); int tscRenewMeterMeta(SSqlObj *pSql, char *tableId);

View File

@ -5563,8 +5563,8 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
} }
*(VarDataLenT*)tagVal = pList->a[i].pVar.nLen; ret = tVariantDump(&(pList->a[i].pVar), varDataVal(tagVal), pTagSchema[i].type);
ret = tVariantDump(&(pList->a[i].pVar), tagVal + VARSTR_HEADER_SIZE, pTagSchema[i].type); varDataSetLen(tagVal, pList->a[i].pVar.nLen);
} else { } else {
ret = tVariantDump(&(pList->a[i].pVar), tagVal, pTagSchema[i].type); ret = tVariantDump(&(pList->a[i].pVar), tagVal, pTagSchema[i].type);
} }

View File

@ -221,7 +221,7 @@ int tscSendMsgToServer(SSqlObj *pSql) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
void tscProcessMsgFromServer(SRpcMsg *rpcMsg) { void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
SSqlObj *pSql = (SSqlObj *)rpcMsg->handle; SSqlObj *pSql = (SSqlObj *)rpcMsg->handle;
if (pSql == NULL) { if (pSql == NULL) {
tscError("%p sql is already released", pSql->signature); tscError("%p sql is already released", pSql->signature);
@ -245,6 +245,12 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
return; return;
} }
if (pCmd->command < TSDB_SQL_MGMT) {
if (pIpSet) pSql->ipList = *pIpSet;
} else {
if (pIpSet) tscMgmtIpSet = *pIpSet;
}
if (rpcMsg->pCont == NULL) { if (rpcMsg->pCont == NULL) {
rpcMsg->code = TSDB_CODE_NETWORK_UNAVAIL; rpcMsg->code = TSDB_CODE_NETWORK_UNAVAIL;
} else { } else {
@ -556,15 +562,15 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo); size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo);
int32_t exprSize = sizeof(SSqlFuncMsg) * numOfExprs; int32_t exprSize = sizeof(SSqlFuncMsg) * numOfExprs;
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); //STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
// meter query without tags values // table query without tags values
if (!UTIL_TABLE_IS_SUPERTABLE(pTableMetaInfo)) { //if (!UTIL_TABLE_IS_SUPERTABLE(pTableMetaInfo)) {
return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + exprSize; return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + exprSize + 4096;
} //}
int32_t size = 4096; //int32_t size = 4096;
return size; //return size;
} }
static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char *pMsg) { static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char *pMsg) {

View File

@ -63,6 +63,7 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) {
rpcInit.user = (char*)user; rpcInit.user = (char*)user;
rpcInit.idleTime = 2000; rpcInit.idleTime = 2000;
rpcInit.ckey = "key"; rpcInit.ckey = "key";
rpcInit.spi = 1;
rpcInit.secret = secretEncrypt; rpcInit.secret = secretEncrypt;
*pDnodeConn = rpcOpen(&rpcInit); *pDnodeConn = rpcOpen(&rpcInit);

View File

@ -1144,23 +1144,21 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) {
} }
SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters) { SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters) {
SColumnFilterInfo* pFilter = NULL; if (numOfFilters == 0) {
if (numOfFilters > 0) {
pFilter = calloc(1, numOfFilters * sizeof(SColumnFilterInfo));
} else {
assert(src == NULL); assert(src == NULL);
return NULL; return NULL;
} }
SColumnFilterInfo* pFilter = calloc(1, numOfFilters * sizeof(SColumnFilterInfo));
memcpy(pFilter, src, sizeof(SColumnFilterInfo) * numOfFilters); memcpy(pFilter, src, sizeof(SColumnFilterInfo) * numOfFilters);
for (int32_t j = 0; j < numOfFilters; ++j) { for (int32_t j = 0; j < numOfFilters; ++j) {
if (pFilter[j].filterstr) { if (pFilter[j].filterstr) {
size_t len = (size_t) pFilter[j].len + 1; size_t len = (size_t) pFilter[j].len + 1;
pFilter[j].pz = (int64_t) calloc(1, len);
char* pTmp = calloc(1, len); memcpy((char*)pFilter[j].pz, (char*)src[j].pz, (size_t)len);
pFilter[j].pz = (int64_t) pTmp;
memcpy((char*)pFilter[j].pz, (char*)src->pz, (size_t)len);
} }
} }

View File

@ -266,9 +266,12 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) {
return taosCfgDynamicOptions(pCfg->config); return taosCfgDynamicOptions(pCfg->config);
} }
void dnodeUpdateIpSet(SRpcIpSet *pIpSet) {
dPrint("mnode IP list is changed, numOfIps:%d inUse:%d", pIpSet->numOfIps, pIpSet->inUse);
for (int i = 0; i < pIpSet->numOfIps; ++i) {
dPrint("mnode index:%d %s:%u", i, pIpSet->fqdn[i], pIpSet->port[i])
}
void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) {
dTrace("mgmt IP list is changed for ufp is called");
tsMnodeIpSet = *pIpSet; tsMnodeIpSet = *pIpSet;
} }

View File

@ -29,11 +29,11 @@
#include "dnodeVWrite.h" #include "dnodeVWrite.h"
#include "mnode.h" #include "mnode.h"
extern void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet); extern void dnodeUpdateIpSet(SRpcIpSet *pIpSet);
static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg); static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *);
static void (*dnodeProcessRspMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg); static void (*dnodeProcessRspMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg);
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg); static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet);
static void *tsDnodeServerRpc = NULL; static void *tsDnodeServerRpc = NULL;
static void *tsDnodeClientRpc = NULL; static void *tsDnodeClientRpc = NULL;
@ -52,6 +52,7 @@ int32_t dnodeInitServer() {
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = mgmtProcessReqMsgFromDnode; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = mgmtProcessReqMsgFromDnode;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = mgmtProcessReqMsgFromDnode; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = mgmtProcessReqMsgFromDnode;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = mgmtProcessReqMsgFromDnode; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = mgmtProcessReqMsgFromDnode;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_AUTH] = mgmtProcessReqMsgFromDnode;
SRpcInit rpcInit; SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit)); memset(&rpcInit, 0, sizeof(rpcInit));
@ -81,7 +82,7 @@ void dnodeCleanupServer() {
} }
} }
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg) { static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
SRpcMsg rspMsg; SRpcMsg rspMsg;
rspMsg.handle = pMsg->handle; rspMsg.handle = pMsg->handle;
rspMsg.pCont = NULL; rspMsg.pCont = NULL;
@ -119,7 +120,6 @@ int32_t dnodeInitClient() {
rpcInit.label = "DND-C"; rpcInit.label = "DND-C";
rpcInit.numOfThreads = 1; rpcInit.numOfThreads = 1;
rpcInit.cfp = dnodeProcessRspFromDnode; rpcInit.cfp = dnodeProcessRspFromDnode;
rpcInit.ufp = dnodeUpdateIpSet;
rpcInit.sessions = 100; rpcInit.sessions = 100;
rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.idleTime = tsShellActivityTimer * 1000; rpcInit.idleTime = tsShellActivityTimer * 1000;
@ -145,9 +145,10 @@ void dnodeCleanupClient() {
} }
} }
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg) { static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
if (dnodeProcessRspMsgFp[pMsg->msgType]) { if (dnodeProcessRspMsgFp[pMsg->msgType]) {
if (pMsg->msgType == TSDB_MSG_TYPE_DM_STATUS_RSP && pIpSet) dnodeUpdateIpSet(pIpSet);
(*dnodeProcessRspMsgFp[pMsg->msgType])(pMsg); (*dnodeProcessRspMsgFp[pMsg->msgType])(pMsg);
} else { } else {
dError("RPC %p, msg:%s is not processed", pMsg->handle, taosMsg[pMsg->msgType]); dError("RPC %p, msg:%s is not processed", pMsg->handle, taosMsg[pMsg->msgType]);
@ -163,3 +164,9 @@ void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) {
void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg) { void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg) {
rpcSendRequest(tsDnodeClientRpc, ipSet, rpcMsg); rpcSendRequest(tsDnodeClientRpc, ipSet, rpcMsg);
} }
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp) {
SRpcIpSet ipSet = {0};
dnodeGetMnodeDnodeIpSet(&ipSet);
rpcSendRecv(tsDnodeClientRpc, &ipSet, rpcMsg, rpcRsp);
}

View File

@ -21,6 +21,7 @@
#include "trpc.h" #include "trpc.h"
#include "tglobal.h" #include "tglobal.h"
#include "http.h" #include "http.h"
#include "mnode.h"
#include "dnode.h" #include "dnode.h"
#include "dnodeInt.h" #include "dnodeInt.h"
#include "dnodeVRead.h" #include "dnodeVRead.h"
@ -28,7 +29,7 @@
#include "dnodeShell.h" #include "dnodeShell.h"
static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
static void dnodeProcessMsgFromShell(SRpcMsg *pMsg); static void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcIpSet *);
static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey); static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
static void * tsDnodeShellRpc = NULL; static void * tsDnodeShellRpc = NULL;
static int32_t tsDnodeQueryReqNum = 0; static int32_t tsDnodeQueryReqNum = 0;
@ -106,7 +107,7 @@ void dnodeCleanupShell() {
} }
} }
void dnodeProcessMsgFromShell(SRpcMsg *pMsg) { void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
SRpcMsg rpcMsg; SRpcMsg rpcMsg;
rpcMsg.handle = pMsg->handle; rpcMsg.handle = pMsg->handle;
rpcMsg.pCont = NULL; rpcMsg.pCont = NULL;
@ -138,7 +139,34 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg) {
} }
static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey) { static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
return TSDB_CODE_SUCCESS; int code = mgmtRetriveAuth(user, spi, encrypt, secret, ckey);
if (code != TSDB_CODE_NOT_READY) return code;
SDMAuthMsg *pMsg = rpcMallocCont(sizeof(SDMAuthMsg));
strcpy(pMsg->user, user);
SRpcMsg rpcMsg = {0};
rpcMsg.pCont = pMsg;
rpcMsg.contLen = sizeof(SDMAuthMsg);
rpcMsg.msgType = TSDB_MSG_TYPE_DM_AUTH;
dTrace("user:%s, send auth msg to mnode", user);
SRpcMsg rpcRsp = {0};
dnodeSendMsgToDnodeRecv(&rpcMsg, &rpcRsp);
if (rpcRsp.code != 0) {
dError("user:%s, auth msg received from mnode, error:%s", user, tstrerror(rpcRsp.code));
} else {
dTrace("user:%s, auth msg received from mnode", user);
SDMAuthRsp *pRsp = rpcRsp.pCont;
memcpy(secret, pRsp->secret, TSDB_KEY_LEN);
memcpy(ckey, pRsp->ckey, TSDB_KEY_LEN);
*spi = pRsp->spi;
*encrypt = pRsp->encrypt;
}
rpcFreeCont(rpcRsp.pCont);
return rpcRsp.code;
} }
SDnodeStatisInfo dnodeGetStatisInfo() { SDnodeStatisInfo dnodeGetStatisInfo() {

View File

@ -52,6 +52,7 @@ int32_t dnodeGetDnodeId();
void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg));
void dnodeAddServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); void dnodeAddServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg));
void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg); void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg);
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -26,9 +26,11 @@ void mgmtCleanUpSystem();
void mgmtStopSystem(); void mgmtStopSystem();
void sdbUpdateSync(); void sdbUpdateSync();
int32_t mgmtRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg); void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg);
void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg); void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -74,6 +74,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_OPTION, 0, 26, "invalid option")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_CONFIGURED, 0, 27, "not configured") TAOS_DEFINE_ERROR(TSDB_CODE_NOT_CONFIGURED, 0, 27, "not configured")
TAOS_DEFINE_ERROR(TSDB_CODE_NODE_OFFLINE, 0, 28, "node offline") TAOS_DEFINE_ERROR(TSDB_CODE_NODE_OFFLINE, 0, 28, "node offline")
TAOS_DEFINE_ERROR(TSDB_CODE_NETWORK_UNAVAIL, 0, 29, "network unavailable") TAOS_DEFINE_ERROR(TSDB_CODE_NETWORK_UNAVAIL, 0, 29, "network unavailable")
TAOS_DEFINE_ERROR(TSDB_CODE_AUTH_REQUIRED, 0, 30, "auth required")
// db // db
TAOS_DEFINE_ERROR(TSDB_CODE_DB_NOT_SELECTED, 0, 100, "db not selected") TAOS_DEFINE_ERROR(TSDB_CODE_DB_NOT_SELECTED, 0, 100, "db not selected")

View File

@ -100,6 +100,7 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_TABLE, "config-table" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_VNODE, "config-vnode" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_VNODE, "config-vnode" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_STATUS, "status" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_STATUS, "status" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_GRANT, "grant" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_GRANT, "grant" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_AUTH, "auth" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY12, "dummy12" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY12, "dummy12" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY13, "dummy13" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY13, "dummy13" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY14, "dummy14" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY14, "dummy14" )
@ -737,6 +738,14 @@ typedef struct {
char tableId[TSDB_TABLE_ID_LEN + 1]; char tableId[TSDB_TABLE_ID_LEN + 1];
} SMDAlterStreamMsg; } SMDAlterStreamMsg;
typedef struct {
char user[TSDB_USER_LEN + 1];
char spi;
char encrypt;
char secret[TSDB_KEY_LEN + 1];
char ckey[TSDB_KEY_LEN + 1];
} SDMAuthMsg, SDMAuthRsp;
#pragma pack(pop) #pragma pack(pop)
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -66,10 +66,7 @@ typedef struct {
char *ckey; // ciphering key char *ckey; // ciphering key
// call back to process incoming msg, code shall be ignored by server app // call back to process incoming msg, code shall be ignored by server app
void (*cfp)(SRpcMsg *); void (*cfp)(SRpcMsg *, SRpcIpSet *);
// call back to process notify the ipSet changes, for client app only
void (*ufp)(void *ahandle, SRpcIpSet *pIpSet);
// call back to retrieve the client auth info, for server app only // call back to retrieve the client auth info, for server app only
int (*afp)(char *tableId, char *spi, char *encrypt, char *secret, char *ckey); int (*afp)(char *tableId, char *spi, char *encrypt, char *secret, char *ckey);

View File

@ -109,6 +109,8 @@ int tsdbDropTable(TsdbRepoT *pRepo, STableId tableId);
int tsdbAlterTable(TsdbRepoT *repo, STableCfg *pCfg); int tsdbAlterTable(TsdbRepoT *repo, STableCfg *pCfg);
TSKEY tsdbGetTableLastKey(TsdbRepoT *repo, int64_t uid); TSKEY tsdbGetTableLastKey(TsdbRepoT *repo, int64_t uid);
uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, int32_t *size);
// the TSDB repository info // the TSDB repository info
typedef struct STsdbRepoInfo { typedef struct STsdbRepoInfo {
STsdbCfg tsdbCfg; STsdbCfg tsdbCfg;

View File

@ -85,8 +85,7 @@ typedef struct SSuperTableObj {
int32_t numOfTables; int32_t numOfTables;
int16_t nextColId; int16_t nextColId;
SSchema * schema; SSchema * schema;
int32_t vgLen; void * vgHash;
int32_t * vgList;
} SSuperTableObj; } SSuperTableObj;
typedef struct { typedef struct {

View File

@ -297,8 +297,10 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
if (pDb != NULL) { if (pDb != NULL) {
mgmtDecDbRef(pDb); mgmtDecDbRef(pDb);
if (pCreate->ignoreExist) { if (pCreate->ignoreExist) {
mTrace("db:%s, already exist, ignore exist is set", pCreate->db);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else { } else {
mError("db:%s, is already exist, ignore exist not set", pCreate->db);
return TSDB_CODE_DB_ALREADY_EXIST; return TSDB_CODE_DB_ALREADY_EXIST;
} }
} }
@ -751,6 +753,8 @@ static void mgmtProcessCreateDbMsg(SQueuedMsg *pMsg) {
code = mgmtCreateDb(pMsg->pUser->pAcct, pCreate); code = mgmtCreateDb(pMsg->pUser->pAcct, pCreate);
if (code == TSDB_CODE_SUCCESS) { if (code == TSDB_CODE_SUCCESS) {
mLPrint("db:%s, is created by %s", pCreate->db, pMsg->pUser->user); mLPrint("db:%s, is created by %s", pCreate->db, pMsg->pUser->user);
} else {
mError("db:%s, failed to create, reason:%s", pCreate->db, tstrerror(code));
} }
} }

View File

@ -41,7 +41,6 @@
typedef int32_t (*SShowMetaFp)(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); typedef int32_t (*SShowMetaFp)(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
typedef int32_t (*SShowRetrieveFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn); typedef int32_t (*SShowRetrieveFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
//static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg); static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg);
static void mgmtProcessUnSupportMsg(SRpcMsg *rpcMsg); static void mgmtProcessUnSupportMsg(SRpcMsg *rpcMsg);
static void mgmtProcessShowMsg(SQueuedMsg *queuedMsg); static void mgmtProcessShowMsg(SQueuedMsg *queuedMsg);
@ -343,29 +342,6 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) {
rpcSendResponse(&rpcRsp); rpcSendResponse(&rpcRsp);
} }
/*
static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
*spi = 1;
*encrypt = 0;
*ckey = 0;
if (!sdbIsMaster()) {
*secret = 0;
return TSDB_CODE_NOT_READY;
}
SUserObj *pUser = mgmtGetUser(user);
if (pUser == NULL) {
*secret = 0;
return TSDB_CODE_INVALID_USER;
} else {
memcpy(secret, pUser->pass, TSDB_KEY_LEN);
mgmtDecUserRef(pUser);
return TSDB_CODE_SUCCESS;
}
}
*/
static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) { static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) {
SRpcMsg rpcRsp = {.handle = pMsg->thandle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0}; SRpcMsg rpcRsp = {.handle = pMsg->thandle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0};
SCMConnectMsg *pConnectMsg = pMsg->pCont; SCMConnectMsg *pConnectMsg = pMsg->pCont;

View File

@ -24,6 +24,7 @@
#include "tname.h" #include "tname.h"
#include "tidpool.h" #include "tidpool.h"
#include "tglobal.h" #include "tglobal.h"
#include "hash.h"
#include "dnode.h" #include "dnode.h"
#include "mgmtDef.h" #include "mgmtDef.h"
#include "mgmtInt.h" #include "mgmtInt.h"
@ -194,7 +195,7 @@ static int32_t mgmtChildTableActionUpdate(SSdbOper *pOper) {
} }
static int32_t mgmtChildTableActionEncode(SSdbOper *pOper) { static int32_t mgmtChildTableActionEncode(SSdbOper *pOper) {
const int32_t maxRowSize = sizeof(SChildTableObj) + sizeof(SSchema) * TSDB_MAX_COLUMNS; const int32_t maxRowSize = sizeof(SChildTableObj) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16);
SChildTableObj *pTable = pOper->pObj; SChildTableObj *pTable = pOper->pObj;
assert(pTable != NULL && pOper->rowData != NULL); assert(pTable != NULL && pOper->rowData != NULL);
@ -336,7 +337,7 @@ static int32_t mgmtInitChildTables() {
.tableId = SDB_TABLE_CTABLE, .tableId = SDB_TABLE_CTABLE,
.tableName = "ctables", .tableName = "ctables",
.hashSessions = tsMaxTables, .hashSessions = tsMaxTables,
.maxRowSize = sizeof(SChildTableObj) + sizeof(SSchema) * TSDB_MAX_COLUMNS, .maxRowSize = sizeof(SChildTableObj) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16),
.refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj, .refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj,
.keyType = SDB_KEY_STRING, .keyType = SDB_KEY_STRING,
.insertFp = mgmtChildTableActionInsert, .insertFp = mgmtChildTableActionInsert,
@ -363,39 +364,35 @@ static void mgmtCleanUpChildTables() {
} }
static void mgmtAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable) { static void mgmtAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable) {
if (pStable->vgLen == 0) {
pStable->vgLen = 8;
pStable->vgList = calloc(pStable->vgLen, sizeof(int32_t));
}
bool find = false;
int32_t pos = 0;
for (pos = 0; pos < pStable->vgLen; ++pos) {
if (pStable->vgList[pos] == 0) break;
if (pStable->vgList[pos] == pCtable->vgId) {
find = true;
break;
}
}
if (!find) {
if (pos >= pStable->vgLen) {
pStable->vgLen *= 2;
pStable->vgList = realloc(pStable->vgList, pStable->vgLen * sizeof(int32_t));
}
pStable->vgList[pos] = pCtable->vgId;
}
pStable->numOfTables++; pStable->numOfTables++;
if (pStable->vgHash == NULL) {
pStable->vgHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false);
}
if (pStable->vgHash != NULL) {
taosHashPut(pStable->vgHash, (char *)&pCtable->vgId, sizeof(pCtable->vgId), &pCtable->vgId, sizeof(pCtable->vgId));
}
} }
static void mgmtRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj *pCtable) { static void mgmtRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj *pCtable) {
pStable->numOfTables--; pStable->numOfTables--;
if (pStable->vgHash == NULL) return;
SVgObj *pVgroup = mgmtGetVgroup(pCtable->vgId);
if (pVgroup == NULL) {
taosHashRemove(pStable->vgHash, (char *)&pCtable->vgId, sizeof(pCtable->vgId));
}
mgmtDecVgroupRef(pVgroup);
} }
static void mgmtDestroySuperTable(SSuperTableObj *pStable) { static void mgmtDestroySuperTable(SSuperTableObj *pStable) {
if (pStable->vgHash != NULL) {
taosHashCleanup(pStable->vgHash);
pStable->vgHash = NULL;
}
tfree(pStable->schema); tfree(pStable->schema);
tfree(pStable->vgList)
tfree(pStable); tfree(pStable);
} }
@ -434,7 +431,7 @@ static int32_t mgmtSuperTableActionUpdate(SSdbOper *pOper) {
void *oldSchema = pTable->schema; void *oldSchema = pTable->schema;
memcpy(pTable, pNew, pOper->rowSize); memcpy(pTable, pNew, pOper->rowSize);
pTable->schema = pNew->schema; pTable->schema = pNew->schema;
free(pNew->vgList); free(pNew->vgHash);
free(pNew); free(pNew);
free(oldSchema); free(oldSchema);
} }
@ -443,7 +440,7 @@ static int32_t mgmtSuperTableActionUpdate(SSdbOper *pOper) {
} }
static int32_t mgmtSuperTableActionEncode(SSdbOper *pOper) { static int32_t mgmtSuperTableActionEncode(SSdbOper *pOper) {
const int32_t maxRowSize = sizeof(SChildTableObj) + sizeof(SSchema) * TSDB_MAX_COLUMNS; const int32_t maxRowSize = sizeof(SChildTableObj) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16);
SSuperTableObj *pStable = pOper->pObj; SSuperTableObj *pStable = pOper->pObj;
assert(pOper->pObj != NULL && pOper->rowData != NULL); assert(pOper->pObj != NULL && pOper->rowData != NULL);
@ -494,7 +491,7 @@ static int32_t mgmtInitSuperTables() {
.tableId = SDB_TABLE_STABLE, .tableId = SDB_TABLE_STABLE,
.tableName = "stables", .tableName = "stables",
.hashSessions = TSDB_MAX_SUPER_TABLES, .hashSessions = TSDB_MAX_SUPER_TABLES,
.maxRowSize = tsSuperTableUpdateSize + sizeof(SSchema) * TSDB_MAX_COLUMNS, .maxRowSize = tsSuperTableUpdateSize + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16),
.refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj, .refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj,
.keyType = SDB_KEY_STRING, .keyType = SDB_KEY_STRING,
.insertFp = mgmtSuperTableActionInsert, .insertFp = mgmtSuperTableActionInsert,
@ -797,26 +794,26 @@ static void mgmtProcessCreateSuperTableMsg(SQueuedMsg *pMsg) {
static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) { static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) {
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable; SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
if (pStable->numOfTables != 0) { if (pStable->numOfTables != 0) {
mgmtDropAllChildTablesInStable(pStable); SHashMutableIterator *pIter = taosHashCreateIter(pStable->vgHash);
for (int32_t vg = 0; vg < pStable->vgLen; ++vg) { while (taosHashIterNext(pIter)) {
int32_t vgId = pStable->vgList[vg]; int32_t *pVgId = taosHashIterGet(pIter);
if (vgId == 0) break; SVgObj *pVgroup = mgmtGetVgroup(*pVgId);
SVgObj *pVgroup = mgmtGetVgroup(vgId);
if (pVgroup == NULL) break; if (pVgroup == NULL) break;
SMDDropSTableMsg *pDrop = rpcMallocCont(sizeof(SMDDropSTableMsg)); SMDDropSTableMsg *pDrop = rpcMallocCont(sizeof(SMDDropSTableMsg));
pDrop->contLen = htonl(sizeof(SMDDropSTableMsg)); pDrop->contLen = htonl(sizeof(SMDDropSTableMsg));
pDrop->vgId = htonl(vgId); pDrop->vgId = htonl(pVgroup->vgId);
pDrop->uid = htobe64(pStable->uid); pDrop->uid = htobe64(pStable->uid);
mgmtExtractTableName(pStable->info.tableId, pDrop->tableId); mgmtExtractTableName(pStable->info.tableId, pDrop->tableId);
mPrint("stable:%s, send drop stable msg to vgId:%d", pStable->info.tableId, vgId); mPrint("stable:%s, send drop stable msg to vgId:%d", pStable->info.tableId, pVgroup->vgId);
SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup); SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup);
SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE}; SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE};
dnodeSendMsgToDnode(&ipSet, &rpcMsg); dnodeSendMsgToDnode(&ipSet, &rpcMsg);
mgmtDecVgroupRef(pVgroup); mgmtDecVgroupRef(pVgroup);
} }
mgmtDropAllChildTablesInStable(pStable);
} }
SSdbOper oper = { SSdbOper oper = {
@ -1219,7 +1216,7 @@ static int32_t mgmtSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTa
static void mgmtGetSuperTableMeta(SQueuedMsg *pMsg) { static void mgmtGetSuperTableMeta(SQueuedMsg *pMsg) {
SSuperTableObj *pTable = (SSuperTableObj *)pMsg->pTable; SSuperTableObj *pTable = (SSuperTableObj *)pMsg->pTable;
STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * TSDB_MAX_COLUMNS); STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16));
pMeta->uid = htobe64(pTable->uid); pMeta->uid = htobe64(pTable->uid);
pMeta->sversion = htons(pTable->sversion); pMeta->sversion = htons(pTable->sversion);
pMeta->precision = pMsg->pDb->cfg.precision; pMeta->precision = pMsg->pDb->cfg.precision;
@ -1244,13 +1241,18 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) {
SCMSTableVgroupMsg *pInfo = pMsg->pCont; SCMSTableVgroupMsg *pInfo = pMsg->pCont;
int32_t numOfTable = htonl(pInfo->numOfTables); int32_t numOfTable = htonl(pInfo->numOfTables);
char* name = (char*) pInfo + sizeof(struct SCMSTableVgroupMsg); // reserve space
SCMSTableVgroupRspMsg *pRsp = NULL; int32_t contLen = sizeof(SCMSTableVgroupRspMsg) + 32 * sizeof(SCMVgroupInfo) + sizeof(SVgroupsInfo);
for (int32_t i = 0; i < numOfTable; ++i) {
char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN) * i;
SSuperTableObj *pTable = mgmtGetSuperTable(stableName);
if (pTable->vgHash != NULL) {
contLen += (taosHashGetSize(pTable->vgHash) * sizeof(SCMVgroupInfo) + sizeof(SVgroupsInfo));
}
mgmtDecTableRef(pTable);
}
// todo set the initial size to be 10, fix me SCMSTableVgroupRspMsg *pRsp = rpcMallocCont(contLen);
int32_t contLen = sizeof(SCMSTableVgroupRspMsg) + (sizeof(SCMVgroupInfo) * 10 + sizeof(SVgroupsInfo))*numOfTable;
pRsp = rpcMallocCont(contLen);
if (pRsp == NULL) { if (pRsp == NULL) {
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY);
return; return;
@ -1260,42 +1262,36 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) {
char* msg = (char*) pRsp + sizeof(SCMSTableVgroupRspMsg); char* msg = (char*) pRsp + sizeof(SCMSTableVgroupRspMsg);
for (int32_t i = 0; i < numOfTable; ++i) { for (int32_t i = 0; i < numOfTable; ++i) {
SSuperTableObj *pTable = mgmtGetSuperTable(name); char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN) * i;
SSuperTableObj *pTable = mgmtGetSuperTable(stableName);
SVgroupsInfo *pVgroupInfo = (SVgroupsInfo *)msg;
pMsg->pTable = (STableObj *)pTable; SHashMutableIterator *pIter = taosHashCreateIter(pTable->vgHash);
if (pMsg->pTable == NULL) { int32_t vgSize = 0;
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_INVALID_TABLE); while (taosHashIterNext(pIter)) {
return; int32_t *pVgId = taosHashIterGet(pIter);
} SVgObj * pVgroup = mgmtGetVgroup(*pVgId);
if (pVgroup == NULL) continue;
SVgroupsInfo* pVgroup = (SVgroupsInfo*) msg; pVgroupInfo->vgroups[vgSize].vgId = htonl(pVgroup->vgId);
for (int32_t vn = 0; vn < pVgroup->numOfVnodes; ++vn) {
int32_t vg = 0; SDnodeObj *pDnode = pVgroup->vnodeGid[vn].pDnode;
for (; vg < pTable->vgLen; ++vg) {
int32_t vgId = pTable->vgList[vg];
if (vgId == 0) break;
SVgObj *vgItem = mgmtGetVgroup(vgId);
if (vgItem == NULL) break;
pVgroup->vgroups[vg].vgId = htonl(vgId);
for (int32_t vn = 0; vn < vgItem->numOfVnodes; ++vn) {
SDnodeObj *pDnode = vgItem->vnodeGid[vn].pDnode;
if (pDnode == NULL) break; if (pDnode == NULL) break;
strncpy(pVgroup->vgroups[vg].ipAddr[vn].fqdn, pDnode->dnodeFqdn, tListLen(pDnode->dnodeFqdn)); strncpy(pVgroupInfo->vgroups[vgSize].ipAddr[vn].fqdn, pDnode->dnodeFqdn, tListLen(pDnode->dnodeFqdn));
pVgroup->vgroups[vg].ipAddr[vn].port = htons(tsDnodeShellPort); pVgroupInfo->vgroups[vgSize].ipAddr[vn].port = htons(tsDnodeShellPort);
pVgroup->vgroups[vg].numOfIps++; pVgroupInfo->vgroups[vgSize].numOfIps++;
} }
mgmtDecVgroupRef(vgItem); vgSize++;
mgmtDecVgroupRef(pVgroup);
} }
pVgroup->numOfVgroups = htonl(vg); pVgroupInfo->numOfVgroups = htonl(vgSize);
// one table is done, try the next table // one table is done, try the next table
msg += sizeof(SVgroupsInfo) + vg * sizeof(SCMVgroupInfo); msg += sizeof(SVgroupsInfo) + vgSize * sizeof(SCMVgroupInfo);
} }
SRpcMsg rpcRsp = {0}; SRpcMsg rpcRsp = {0};
@ -1735,7 +1731,7 @@ static void mgmtAutoCreateChildTable(SQueuedMsg *pMsg) {
} }
static void mgmtGetChildTableMeta(SQueuedMsg *pMsg) { static void mgmtGetChildTableMeta(SQueuedMsg *pMsg) {
STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * TSDB_MAX_COLUMNS); STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16));
if (pMeta == NULL) { if (pMeta == NULL) {
mError("table:%s, failed to get table meta, no enough memory", pMsg->pTable->tableId); mError("table:%s, failed to get table meta, no enough memory", pMsg->pTable->tableId);
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY);
@ -1983,7 +1979,7 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) {
if (pMsg->pDb == NULL) continue; if (pMsg->pDb == NULL) continue;
int availLen = totalMallocLen - pMultiMeta->contLen; int availLen = totalMallocLen - pMultiMeta->contLen;
if (availLen <= sizeof(STableMetaMsg) + sizeof(SSchema) * TSDB_MAX_COLUMNS) { if (availLen <= sizeof(STableMetaMsg) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16)) {
//TODO realloc //TODO realloc
//totalMallocLen *= 2; //totalMallocLen *= 2;
//pMultiMeta = rpcReMalloc(pMultiMeta, totalMallocLen); //pMultiMeta = rpcReMalloc(pMultiMeta, totalMallocLen);

View File

@ -37,6 +37,7 @@ static int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void
static void mgmtProcessCreateUserMsg(SQueuedMsg *pMsg); static void mgmtProcessCreateUserMsg(SQueuedMsg *pMsg);
static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg); static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg);
static void mgmtProcessDropUserMsg(SQueuedMsg *pMsg); static void mgmtProcessDropUserMsg(SQueuedMsg *pMsg);
static void mgmtProcessAuthMsg(SRpcMsg *rpcMsg);
static int32_t mgmtUserActionDestroy(SSdbOper *pOper) { static int32_t mgmtUserActionDestroy(SSdbOper *pOper) {
tfree(pOper->pObj); tfree(pOper->pObj);
@ -140,6 +141,7 @@ int32_t mgmtInitUsers() {
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_DROP_USER, mgmtProcessDropUserMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_DROP_USER, mgmtProcessDropUserMsg);
mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_USER, mgmtGetUserMeta); mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_USER, mgmtGetUserMeta);
mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_USER, mgmtRetrieveUsers); mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_USER, mgmtRetrieveUsers);
dnodeAddServerMsgHandle(TSDB_MSG_TYPE_DM_AUTH, mgmtProcessAuthMsg);
mTrace("table:%s, hash is created", tableDesc.tableName); mTrace("table:%s, hash is created", tableDesc.tableName);
return 0; return 0;
@ -529,3 +531,40 @@ void mgmtDropAllUsers(SAcctObj *pAcct) {
mTrace("acct:%s, all users:%d is dropped from sdb", pAcct->user, numOfUsers); mTrace("acct:%s, all users:%d is dropped from sdb", pAcct->user, numOfUsers);
} }
int32_t mgmtRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
if (!sdbIsMaster()) {
*secret = 0;
mTrace("user:%s, failed to auth user, reason:%s", user, tstrerror(TSDB_CODE_NOT_READY));
return TSDB_CODE_NOT_READY;
}
SUserObj *pUser = mgmtGetUser(user);
if (pUser == NULL) {
*secret = 0;
mError("user:%s, failed to auth user, reason:%s", user, tstrerror(TSDB_CODE_INVALID_USER));
return TSDB_CODE_INVALID_USER;
} else {
*spi = 1;
*encrypt = 0;
*ckey = 0;
memcpy(secret, pUser->pass, TSDB_KEY_LEN);
mgmtDecUserRef(pUser);
mTrace("user:%s, auth info is returned", user);
return TSDB_CODE_SUCCESS;
}
}
static void mgmtProcessAuthMsg(SRpcMsg *rpcMsg) {
SRpcMsg rpcRsp = {.handle = rpcMsg->handle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0};
SDMAuthMsg *pAuthMsg = rpcMsg->pCont;
SDMAuthRsp *pAuthRsp = rpcMallocCont(sizeof(SDMAuthRsp));
rpcRsp.code = mgmtRetriveAuth(pAuthMsg->user, &pAuthRsp->spi, &pAuthRsp->encrypt, pAuthRsp->secret, pAuthRsp->ckey);
rpcRsp.pCont = pAuthRsp;
rpcRsp.contLen = sizeof(SDMAuthRsp);
rpcSendResponse(&rpcRsp);
}

View File

@ -50,11 +50,11 @@ typedef struct tQueryInfo {
SSchema sch; // schema of tags SSchema sch; // schema of tags
char* q; char* q;
__compar_fn_t compare; // filter function __compar_fn_t compare; // filter function
void* param; // STSchema, void* param; // STSchema
} tQueryInfo; } tQueryInfo;
typedef struct SExprTraverseSupp { typedef struct SExprTraverseSupp {
__result_filter_fn_t fp; __result_filter_fn_t nodeFilterFn;
__do_filter_suppl_fn_t setupInfoFn; __do_filter_suppl_fn_t setupInfoFn;
void * pExtInfo; void * pExtInfo;
} SExprTraverseSupp; } SExprTraverseSupp;

View File

@ -540,8 +540,11 @@ static int32_t setQueryCond(tQueryInfo *queryColInfo, SQueryCond* pCond) {
static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* result) { static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* result) {
SSkipListIterator* iter = NULL; SSkipListIterator* iter = NULL;
SQueryCond cond = {0}; SQueryCond cond = {0};
setQueryCond(pQueryInfo, &cond); if (setQueryCond(pQueryInfo, &cond) != TSDB_CODE_SUCCESS) {
//todo handle error
}
if (cond.start != NULL) { if (cond.start != NULL) {
iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->keyInfo.type, TSDB_ORDER_ASC); iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->keyInfo.type, TSDB_ORDER_ASC);
@ -757,7 +760,7 @@ static bool filterItem(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *p
assert(pLeft->nodeType == TSQL_NODE_COL && pRight->nodeType == TSQL_NODE_VALUE); assert(pLeft->nodeType == TSQL_NODE_COL && pRight->nodeType == TSQL_NODE_VALUE);
param->setupInfoFn(pExpr, param->pExtInfo); param->setupInfoFn(pExpr, param->pExtInfo);
return param->fp(pItem, pExpr->_node.info); return param->nodeFilterFn(pItem, pExpr->_node.info);
} }
/** /**
@ -798,19 +801,19 @@ static void tSQLBinaryTraverseOnSkipList(tExprNode *pExpr, SArray *pResult, SSki
tSkipListDestroyIter(iter); tSkipListDestroyIter(iter);
} }
static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* result) { static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* res, __result_filter_fn_t filterFp) {
SSkipListIterator* iter = tSkipListCreateIter(pSkipList); SSkipListIterator* iter = tSkipListCreateIter(pSkipList);
while (tSkipListIterNext(iter)) { while (tSkipListIterNext(iter)) {
bool addToResult = false; bool addToResult = false;
SSkipListNode *pNode = tSkipListIterGet(iter); SSkipListNode *pNode = tSkipListIterGet(iter);
char* pTable = SL_GET_NODE_DATA(pNode); char * pData = SL_GET_NODE_DATA(pNode);
// todo refactor: // todo refactor:
tstr* name = ((STableIndexElem*) pTable)->pTable->name; tstr *name = ((STableIndexElem *)pData)->pTable->name;
// char* name = NULL; // char* name = NULL;
// tsdbGetTableName(tsdb, pTable, &name); // tsdbGetTableName(pQueryInfo->, pTable, &name);
// todo speed up by using hash // todo speed up by using hash
if (pQueryInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) { if (pQueryInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) {
@ -820,11 +823,11 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo,
addToResult = !pQueryInfo->compare(name, pQueryInfo->q); addToResult = !pQueryInfo->compare(name, pQueryInfo->q);
} }
} else { } else {
// TODO: other columns addToResult = filterFp(pNode, pQueryInfo);
} }
if (addToResult) { if (addToResult) {
taosArrayPush(result, pTable); taosArrayPush(res, pData);
} }
} }
@ -848,7 +851,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
param->setupInfoFn(pExpr, param->pExtInfo); param->setupInfoFn(pExpr, param->pExtInfo);
if (pSkipList == NULL) { if (pSkipList == NULL) {
tArrayTraverse(pExpr, param->fp, result); tArrayTraverse(pExpr, param->nodeFilterFn, result);
return; return;
} }
@ -856,7 +859,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
if (pQueryInfo->colIndex == 0 && pQueryInfo->optr != TSDB_RELATION_LIKE) { if (pQueryInfo->colIndex == 0 && pQueryInfo->optr != TSDB_RELATION_LIKE) {
tQueryIndexColumn(pSkipList, pQueryInfo, result); tQueryIndexColumn(pSkipList, pQueryInfo, result);
} else { } else {
tQueryIndexlessColumn(pSkipList, pQueryInfo, result); tQueryIndexlessColumn(pSkipList, pQueryInfo, result, param->nodeFilterFn);
} }
return; return;

View File

@ -820,7 +820,7 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBI
pInfo->pDCLInfo->dbOpt = *pDB; pInfo->pDCLInfo->dbOpt = *pDB;
pInfo->pDCLInfo->dbOpt.dbname = *pToken; pInfo->pDCLInfo->dbOpt.dbname = *pToken;
pInfo->pDCLInfo->dbOpt.ignoreExists = (pIgExists->z != NULL); pInfo->pDCLInfo->dbOpt.ignoreExists = pIgExists->n; // sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
} }
void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken *pPwd, SCreateAcctSQL *pAcctInfo) { void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken *pPwd, SCreateAcctSQL *pAcctInfo) {

View File

@ -2436,7 +2436,15 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
// set the pCtx output buffer position // set the pCtx output buffer position
pRuntimeEnv->pCtx[i].aOutputBuf = pQuery->sdata[i]->data + pRec->rows * bytes; pRuntimeEnv->pCtx[i].aOutputBuf = pQuery->sdata[i]->data + pRec->rows * bytes;
int32_t functionId = pQuery->pSelectExpr[i].base.functionId;
if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) {
pRuntimeEnv->pCtx[i].ptsOutputBuf = pRuntimeEnv->pCtx[0].aOutputBuf;
} }
}
qTrace("QInfo: %p realloc output buffer, new size: %d rows, old:%d, remain:%d", GET_QINFO_ADDR(pRuntimeEnv),
newSize, pRec->capacity, newSize - pRec->rows);
pRec->capacity = newSize; pRec->capacity = newSize;
} }
@ -2641,26 +2649,21 @@ static UNUSED_FUNC void printBinaryData(int32_t functionId, char *data, int32_t
} }
} }
void UNUSED_FUNC displayInterResult(SData **pdata, SQuery *pQuery, int32_t numOfRows) { void UNUSED_FUNC displayInterResult(SData **pdata, SQueryRuntimeEnv* pRuntimeEnv, int32_t numOfRows) {
#if 0 SQuery* pQuery = pRuntimeEnv->pQuery;
int32_t numOfCols = pQuery->numOfOutput; int32_t numOfCols = pQuery->numOfOutput;
printf("super table query intermediate result, total:%d\n", numOfRows); printf("super table query intermediate result, total:%d\n", numOfRows);
SQInfo * pQInfo = (SQInfo *)(GET_QINFO_ADDR(pQuery));
SMeterObj *pMeterObj = pQInfo->pObj;
for (int32_t j = 0; j < numOfRows; ++j) { for (int32_t j = 0; j < numOfRows; ++j) {
for (int32_t i = 0; i < numOfCols; ++i) { for (int32_t i = 0; i < numOfCols; ++i) {
switch (pQuery->pSelectExpr[i].type) { switch (pQuery->pSelectExpr[i].type) {
case TSDB_DATA_TYPE_BINARY: { case TSDB_DATA_TYPE_BINARY: {
int32_t colIndex = pQuery->pSelectExpr[i].base.colInfo.colIndex; // int32_t colIndex = pQuery->pSelectExpr[i].base.colInfo.colIndex;
int32_t type = 0; int32_t type = pQuery->pSelectExpr[i].type;
// } else {
if (TSDB_COL_IS_TAG(pQuery->pSelectExpr[i].base.colInfo.flag)) { // type = pMeterObj->schema[colIndex].type;
type = pQuery->pSelectExpr[i].type; // }
} else {
type = pMeterObj->schema[colIndex].type;
}
printBinaryData(pQuery->pSelectExpr[i].base.functionId, pdata[i]->data + pQuery->pSelectExpr[i].bytes * j, printBinaryData(pQuery->pSelectExpr[i].base.functionId, pdata[i]->data + pQuery->pSelectExpr[i].bytes * j,
type); type);
break; break;
@ -2682,7 +2685,6 @@ void UNUSED_FUNC displayInterResult(SData **pdata, SQuery *pQuery, int32_t numOf
} }
printf("\n"); printf("\n");
} }
#endif
} }
typedef struct SCompSupporter { typedef struct SCompSupporter {
@ -2950,7 +2952,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
int64_t endt = taosGetTimestampMs(); int64_t endt = taosGetTimestampMs();
#ifdef _DEBUG_VIEW #ifdef _DEBUG_VIEW
displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->num); displayInterResult(pQuery->sdata, pRuntimeEnv, pQuery->sdata[0]->num);
#endif #endif
qTrace("QInfo:%p result merge completed, elapsed time:%" PRId64 " ms", GET_QINFO_ADDR(pQuery), endt - startt); qTrace("QInfo:%p result merge completed, elapsed time:%" PRId64 " ms", GET_QINFO_ADDR(pQuery), endt - startt);
@ -3588,7 +3590,8 @@ void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
if (pTableQueryInfo->queryRangeSet) { if (pTableQueryInfo->queryRangeSet) {
pTableQueryInfo->lastKey = key; pTableQueryInfo->lastKey = key;
} else { } else {
pQuery->window.skey = key; // pQuery->window.skey = key;
pTableQueryInfo->win.skey = key;
STimeWindow win = {.skey = key, .ekey = pQuery->window.ekey}; STimeWindow win = {.skey = key, .ekey = pQuery->window.ekey};
// for too small query range, no data in this interval. // for too small query range, no data in this interval.
@ -3608,7 +3611,7 @@ void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
SWindowResInfo *pWindowResInfo = &pTableQueryInfo->windowResInfo; SWindowResInfo *pWindowResInfo = &pTableQueryInfo->windowResInfo;
getAlignQueryTimeWindow(pQuery, win.skey, win.skey, win.ekey, &skey1, &ekey1, &w); getAlignQueryTimeWindow(pQuery, win.skey, win.skey, win.ekey, &skey1, &ekey1, &w);
pWindowResInfo->startTime = pQuery->window.skey; // windowSKey may be 0 in case of 1970 timestamp pWindowResInfo->startTime = pTableQueryInfo->win.skey; // windowSKey may be 0 in case of 1970 timestamp
if (pWindowResInfo->prevSKey == 0) { if (pWindowResInfo->prevSKey == 0) {
if (QUERY_IS_ASC_QUERY(pQuery)) { if (QUERY_IS_ASC_QUERY(pQuery)) {
@ -3620,8 +3623,8 @@ void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
} }
pTableQueryInfo->queryRangeSet = 1; pTableQueryInfo->queryRangeSet = 1;
pTableQueryInfo->lastKey = pQuery->window.skey; pTableQueryInfo->lastKey = pTableQueryInfo->win.skey;
pTableQueryInfo->win.skey = pQuery->window.skey; pTableQueryInfo->win.skey = pTableQueryInfo->win.skey;
} }
} }
@ -3726,7 +3729,7 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResult *result, int32_t orde
qTrace("QInfo:%p copy data to query buf completed", pQInfo); qTrace("QInfo:%p copy data to query buf completed", pQInfo);
#ifdef _DEBUG_VIEW #ifdef _DEBUG_VIEW
displayInterResult(pQuery->sdata, pQuery, numOfResult); displayInterResult(pQuery->sdata, pRuntimeEnv, numOfResult);
#endif #endif
return numOfResult; return numOfResult;
} }
@ -4766,7 +4769,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
copyResToQueryResultBuf(pQInfo, pQuery); copyResToQueryResultBuf(pQInfo, pQuery);
#ifdef _DEBUG_VIEW #ifdef _DEBUG_VIEW
displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->num); displayInterResult(pQuery->sdata, pRuntimeEnv, pQuery->sdata[0]->num);
#endif #endif
} else { } else {
copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult); copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult);
@ -4819,7 +4822,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
copyResToQueryResultBuf(pQInfo, pQuery); copyResToQueryResultBuf(pQInfo, pQuery);
#ifdef _DEBUG_VIEW #ifdef _DEBUG_VIEW
displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->num); displayInterResult(pQuery->sdata, pRuntimeEnv, pQuery->sdata[0]->num);
#endif #endif
} }
} else { // not a interval query } else { // not a interval query
@ -5276,26 +5279,26 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
} }
for (int32_t f = 0; f < numOfFilters; ++f) { for (int32_t f = 0; f < numOfFilters; ++f) {
SColumnFilterInfo *pFilterInfo = (SColumnFilterInfo *)pMsg; SColumnFilterInfo *pFilterMsg = (SColumnFilterInfo *)pMsg;
SColumnFilterInfo *pDestFilterInfo = &pColInfo->filters[f];
pDestFilterInfo->filterstr = htons(pFilterInfo->filterstr); SColumnFilterInfo *pColFilter = &pColInfo->filters[f];
pColFilter->filterstr = htons(pFilterMsg->filterstr);
pMsg += sizeof(SColumnFilterInfo); pMsg += sizeof(SColumnFilterInfo);
if (pDestFilterInfo->filterstr) { if (pColFilter->filterstr) {
pDestFilterInfo->len = htobe64(pFilterInfo->len); pColFilter->len = htobe64(pFilterMsg->len);
pDestFilterInfo->pz = (int64_t) calloc(1, pDestFilterInfo->len); pColFilter->pz = (int64_t) calloc(1, pColFilter->len);
memcpy((void *)pDestFilterInfo->pz, pMsg, pDestFilterInfo->len); memcpy((void *)pColFilter->pz, pMsg, pColFilter->len);
pMsg += (pDestFilterInfo->len); pMsg += (pColFilter->len + 1);
} else { } else {
pDestFilterInfo->lowerBndi = htobe64(pFilterInfo->lowerBndi); pColFilter->lowerBndi = htobe64(pFilterMsg->lowerBndi);
pDestFilterInfo->upperBndi = htobe64(pFilterInfo->upperBndi); pColFilter->upperBndi = htobe64(pFilterMsg->upperBndi);
} }
pDestFilterInfo->lowerRelOptr = htons(pFilterInfo->lowerRelOptr); pColFilter->lowerRelOptr = htons(pFilterMsg->lowerRelOptr);
pDestFilterInfo->upperRelOptr = htons(pFilterInfo->upperRelOptr); pColFilter->upperRelOptr = htons(pFilterMsg->upperRelOptr);
} }
} }
@ -5692,9 +5695,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou
for (int16_t i = 0; i < numOfCols; ++i) { for (int16_t i = 0; i < numOfCols; ++i) {
pQuery->colList[i] = pQueryMsg->colList[i]; pQuery->colList[i] = pQueryMsg->colList[i];
pQuery->colList[i].filters = tscFilterInfoClone(pQueryMsg->colList[i].filters, pQuery->colList[i].numOfFilters);
SColumnInfo *pColInfo = &pQuery->colList[i];
pColInfo->filters = tscFilterInfoClone(pQueryMsg->colList[i].filters, pColInfo->numOfFilters);
} }
pQuery->tagColList = pTagCols; pQuery->tagColList = pTagCols;

View File

@ -183,33 +183,33 @@ bool equal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
bool equal_str(SColumnFilterElem *pFilter, char *minval, char *maxval) { bool equal_str(SColumnFilterElem *pFilter, char *minval, char *maxval) {
// query condition string is greater than the max length of string, not qualified data // query condition string is greater than the max length of string, not qualified data
if (pFilter->filterInfo.len > pFilter->bytes) { if (pFilter->filterInfo.len != varDataLen(minval)) {
return false; return false;
} }
return strncmp((char *)pFilter->filterInfo.pz, minval, pFilter->bytes) == 0; return strncmp((char *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)) == 0;
} }
bool equal_nchar(SColumnFilterElem *pFilter, char *minval, char *maxval) { bool equal_nchar(SColumnFilterElem *pFilter, char *minval, char *maxval) {
// query condition string is greater than the max length of string, not qualified data // query condition string is greater than the max length of string, not qualified data
if (pFilter->filterInfo.len > pFilter->bytes) { if (pFilter->filterInfo.len != varDataLen(minval)) {
return false; return false;
} }
return wcsncmp((wchar_t *)pFilter->filterInfo.pz, (wchar_t*) minval, pFilter->bytes/TSDB_NCHAR_SIZE) == 0; return wcsncmp((wchar_t *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE) == 0;
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
bool like_str(SColumnFilterElem *pFilter, char *minval, char *maxval) { bool like_str(SColumnFilterElem *pFilter, char *minval, char *maxval) {
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
return patternMatch((char *)pFilter->filterInfo.pz, minval, pFilter->bytes, &info) == TSDB_PATTERN_MATCH; return patternMatch((char *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval), &info) == TSDB_PATTERN_MATCH;
} }
bool like_nchar(SColumnFilterElem* pFilter, char* minval, char *maxval) { bool like_nchar(SColumnFilterElem* pFilter, char* minval, char *maxval) {
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
return WCSPatternMatch((wchar_t*) pFilter->filterInfo.pz, (wchar_t*) minval, pFilter->bytes/TSDB_NCHAR_SIZE, &info) == TSDB_PATTERN_MATCH; return WCSPatternMatch((wchar_t*) pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE, &info) == TSDB_PATTERN_MATCH;
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
@ -270,11 +270,11 @@ bool nequal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
} }
bool nequal_str(SColumnFilterElem *pFilter, char *minval, char *maxval) { bool nequal_str(SColumnFilterElem *pFilter, char *minval, char *maxval) {
if (pFilter->filterInfo.len > pFilter->bytes) { if (pFilter->filterInfo.len != varDataLen(minval)) {
return true; return true;
} }
return strncmp((char *)pFilter->filterInfo.pz, minval, pFilter->bytes) != 0; return strncmp((char *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)) != 0;
} }
bool nequal_nchar(SColumnFilterElem *pFilter, char* minval, char *maxval) { bool nequal_nchar(SColumnFilterElem *pFilter, char* minval, char *maxval) {
@ -282,7 +282,7 @@ bool nequal_nchar(SColumnFilterElem *pFilter, char* minval, char *maxval) {
return true; return true;
} }
return wcsncmp((wchar_t *)pFilter->filterInfo.pz, (wchar_t*)minval, pFilter->bytes/TSDB_NCHAR_SIZE) != 0; return wcsncmp((wchar_t *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE) != 0;
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////

View File

@ -389,6 +389,7 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
return 0; return 0;
} }
// todo handle the error
static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
char tmpBuf[40] = {0}; char tmpBuf[40] = {0};
@ -424,7 +425,12 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
pVariant->wpz = (wchar_t *)tmp; pVariant->wpz = (wchar_t *)tmp;
} else { } else {
taosMbsToUcs4(pDst, nLen, *pDest, (nLen + 1) * TSDB_NCHAR_SIZE, NULL); size_t output = -1;
taosMbsToUcs4(pDst, nLen, *pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output);
if (pDestSize != NULL) {
*pDestSize = output;
}
} }
return 0; return 0;

View File

@ -76,4 +76,8 @@ TEST(testCase, patternMatchTest) {
str = "carzero"; str = "carzero";
ret = patternMatch("%o", str, strlen(str), &info); ret = patternMatch("%o", str, strlen(str), &info);
EXPECT_EQ(ret, TSDB_PATTERN_MATCH); EXPECT_EQ(ret, TSDB_PATTERN_MATCH);
str = "19";
ret = patternMatch("%9", str, 2, &info);
EXPECT_EQ(ret, TSDB_PATTERN_MATCH);
} }

View File

@ -55,9 +55,8 @@ typedef struct {
char secret[TSDB_KEY_LEN]; // secret for the link char secret[TSDB_KEY_LEN]; // secret for the link
char ckey[TSDB_KEY_LEN]; // ciphering key char ckey[TSDB_KEY_LEN]; // ciphering key
void (*cfp)(SRpcMsg *); void (*cfp)(SRpcMsg *, SRpcIpSet *);
int (*afp)(char *user, char *spi, char *encrypt, char *secret, char *ckey); int (*afp)(char *user, char *spi, char *encrypt, char *secret, char *ckey);
void (*ufp)(void *ahandle, SRpcIpSet *pIpSet);
void *idPool; // handle to ID pool void *idPool; // handle to ID pool
void *tmrCtrl; // handle to timer void *tmrCtrl; // handle to timer
@ -222,7 +221,6 @@ void *rpcOpen(const SRpcInit *pInit) {
if (pInit->secret) strcpy(pRpc->secret, pInit->secret); if (pInit->secret) strcpy(pRpc->secret, pInit->secret);
if (pInit->ckey) strcpy(pRpc->ckey, pInit->ckey); if (pInit->ckey) strcpy(pRpc->ckey, pInit->ckey);
pRpc->spi = pInit->spi; pRpc->spi = pInit->spi;
pRpc->ufp = pInit->ufp;
pRpc->cfp = pInit->cfp; pRpc->cfp = pInit->cfp;
pRpc->afp = pInit->afp; pRpc->afp = pInit->afp;
@ -614,7 +612,12 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
pConn->ownId = htonl(pConn->sid); pConn->ownId = htonl(pConn->sid);
pConn->linkUid = pHead->linkUid; pConn->linkUid = pHead->linkUid;
if (pRpc->afp) { if (pRpc->afp) {
if (pConn->user[0] == 0) {
terrno = TSDB_CODE_AUTH_REQUIRED;
} else {
terrno = (*pRpc->afp)(pConn->user, &pConn->spi, &pConn->encrypt, pConn->secret, pConn->ckey); terrno = (*pRpc->afp)(pConn->user, &pConn->spi, &pConn->encrypt, pConn->secret, pConn->ckey);
}
if (terrno != 0) { if (terrno != 0) {
tWarn("%s %p, user not there or server not ready", pRpc->label, pConn); tWarn("%s %p, user not there or server not ready", pRpc->label, pConn);
taosFreeId(pRpc->idPool, sid); // sid shall be released taosFreeId(pRpc->idPool, sid); // sid shall be released
@ -900,10 +903,11 @@ static void rpcNotifyClient(SRpcReqContext *pContext, SRpcMsg *pMsg) {
memcpy(pContext->pRsp, pMsg, sizeof(SRpcMsg)); memcpy(pContext->pRsp, pMsg, sizeof(SRpcMsg));
} else { } else {
// for asynchronous API // for asynchronous API
if (pRpc->ufp && (pContext->ipSet.inUse != pContext->oldInUse || pContext->redirect)) SRpcIpSet *pIpSet = NULL;
(*pRpc->ufp)(pContext->ahandle, &pContext->ipSet); // notify the update of ipSet if (pContext->ipSet.inUse != pContext->oldInUse || pContext->redirect)
pIpSet = &pContext->ipSet;
(*pRpc->cfp)(pMsg); (*pRpc->cfp)(pMsg, pIpSet);
} }
// free the request message // free the request message
@ -924,13 +928,19 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
if ( rpcIsReq(pHead->msgType) ) { if ( rpcIsReq(pHead->msgType) ) {
rpcMsg.handle = pConn; rpcMsg.handle = pConn;
taosTmrReset(rpcProcessProgressTimer, tsRpcTimer/2, pConn, pRpc->tmrCtrl, &pConn->pTimer); taosTmrReset(rpcProcessProgressTimer, tsRpcTimer/2, pConn, pRpc->tmrCtrl, &pConn->pTimer);
(*(pRpc->cfp))(&rpcMsg); (*(pRpc->cfp))(&rpcMsg, NULL);
} else { } else {
// it's a response // it's a response
SRpcReqContext *pContext = pConn->pContext; SRpcReqContext *pContext = pConn->pContext;
rpcMsg.handle = pContext->ahandle; rpcMsg.handle = pContext->ahandle;
pConn->pContext = NULL; pConn->pContext = NULL;
if (pHead->code == TSDB_CODE_AUTH_REQUIRED) {
pConn->secured = 0;
rpcSendReqToServer(pRpc, pContext);
return;
}
// for UDP, port may be changed by server, the port in ipSet shall be used for cache // for UDP, port may be changed by server, the port in ipSet shall be used for cache
rpcAddConnIntoCache(pRpc->pCache, pConn, pConn->peerFqdn, pContext->ipSet.port[pContext->ipSet.inUse], pConn->connType); rpcAddConnIntoCache(pRpc->pCache, pConn, pConn->peerFqdn, pContext->ipSet.port[pContext->ipSet.inUse], pConn->connType);

View File

@ -31,22 +31,16 @@ typedef struct {
void *pRpc; void *pRpc;
} SInfo; } SInfo;
static void processResponse(SRpcMsg *pMsg) { static void processResponse(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
SInfo *pInfo = (SInfo *)pMsg->handle; SInfo *pInfo = (SInfo *)pMsg->handle;
tTrace("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, pMsg->code); tTrace("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, pMsg->code);
if (pIpSet) pInfo->ipSet = *pIpSet;
rpcFreeCont(pMsg->pCont); rpcFreeCont(pMsg->pCont);
sem_post(&pInfo->rspSem); sem_post(&pInfo->rspSem);
} }
static void processUpdateIpSet(void *handle, SRpcIpSet *pIpSet) {
SInfo *pInfo = (SInfo *)handle;
tTrace("thread:%d, ip set is changed, index:%d", pInfo->index, pIpSet->inUse);
pInfo->ipSet = *pIpSet;
}
static int tcount = 0; static int tcount = 0;
static void *sendRequest(void *param) { static void *sendRequest(void *param) {
@ -99,7 +93,6 @@ int main(int argc, char *argv[]) {
rpcInit.label = "APP"; rpcInit.label = "APP";
rpcInit.numOfThreads = 1; rpcInit.numOfThreads = 1;
rpcInit.cfp = processResponse; rpcInit.cfp = processResponse;
rpcInit.ufp = processUpdateIpSet;
rpcInit.sessions = 100; rpcInit.sessions = 100;
rpcInit.idleTime = tsShellActivityTimer*1000; rpcInit.idleTime = tsShellActivityTimer*1000;
rpcInit.user = "michael"; rpcInit.user = "michael";

View File

@ -32,12 +32,6 @@ typedef struct {
void *pRpc; void *pRpc;
} SInfo; } SInfo;
static void processUpdateIpSet(void *handle, SRpcIpSet *pIpSet) {
SInfo *pInfo = (SInfo *)handle;
tTrace("thread:%d, ip set is changed, index:%d", pInfo->index, pIpSet->inUse);
pInfo->ipSet = *pIpSet;
}
static int tcount = 0; static int tcount = 0;
static int terror = 0; static int terror = 0;
@ -100,8 +94,6 @@ int main(int argc, char *argv[]) {
rpcInit.localPort = 0; rpcInit.localPort = 0;
rpcInit.label = "APP"; rpcInit.label = "APP";
rpcInit.numOfThreads = 1; rpcInit.numOfThreads = 1;
// rpcInit.cfp = processResponse;
rpcInit.ufp = processUpdateIpSet;
rpcInit.sessions = 100; rpcInit.sessions = 100;
rpcInit.idleTime = tsShellActivityTimer*1000; rpcInit.idleTime = tsShellActivityTimer*1000;
rpcInit.user = "michael"; rpcInit.user = "michael";

View File

@ -113,7 +113,7 @@ int retrieveAuthInfo(char *meterId, char *spi, char *encrypt, char *secret, char
return ret; return ret;
} }
void processRequestMsg(SRpcMsg *pMsg) { void processRequestMsg(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
SRpcMsg *pTemp; SRpcMsg *pTemp;
pTemp = taosAllocateQitem(sizeof(SRpcMsg)); pTemp = taosAllocateQitem(sizeof(SRpcMsg));

View File

@ -151,8 +151,6 @@ STSchema * tsdbGetTableTagSchema(STsdbMeta *pMeta, STable *pTable);
STsdbMeta *tsdbGetMeta(TsdbRepoT *pRepo); STsdbMeta *tsdbGetMeta(TsdbRepoT *pRepo);
int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg);
int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId);
STable *tsdbIsValidTableToInsert(STsdbMeta *pMeta, STableId tableId); STable *tsdbIsValidTableToInsert(STsdbMeta *pMeta, STableId tableId);
// int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable); // int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable);
STable *tsdbGetTableByUid(STsdbMeta *pMeta, int64_t uid); STable *tsdbGetTableByUid(STsdbMeta *pMeta, int64_t uid);
@ -499,6 +497,7 @@ int tsdbWriteCompIdx(SRWHelper *pHelper);
void tsdbFitRetention(STsdbRepo *pRepo); void tsdbFitRetention(STsdbRepo *pRepo);
int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks); int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks);
void tsdbAdjustCacheBlocks(STsdbCache *pCache); void tsdbAdjustCacheBlocks(STsdbCache *pCache);
int32_t tsdbGetMetaFileName(char *rootDir, char *fname);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -164,7 +164,7 @@ int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks) {
} }
tsdbUnLockRepo((TsdbRepoT *)pRepo); tsdbUnLockRepo((TsdbRepoT *)pRepo);
tsdbTrace("tsdbId %d: tsdb total cache blocks changed from %d to %d", pRepo->config.tsdbId, oldNumOfBlocks, totalBlocks); tsdbTrace("vgId: %d tsdb total cache blocks changed from %d to %d", pRepo->config.tsdbId, oldNumOfBlocks, totalBlocks);
return 0; return 0;
} }

View File

@ -7,6 +7,7 @@
#include "tscompression.h" #include "tscompression.h"
#include "tchecksum.h" #include "tchecksum.h"
#include "ttime.h" #include "ttime.h"
#include <sys/stat.h>
int tsdbDebugFlag = 135; int tsdbDebugFlag = 135;
@ -133,6 +134,7 @@ int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg, void *limiter /* TODO */)
*/ */
int32_t tsdbDropRepo(TsdbRepoT *repo) { int32_t tsdbDropRepo(TsdbRepoT *repo) {
STsdbRepo *pRepo = (STsdbRepo *)repo; STsdbRepo *pRepo = (STsdbRepo *)repo;
int id = pRepo->config.tsdbId;
pRepo->state = TSDB_REPO_STATE_CLOSED; pRepo->state = TSDB_REPO_STATE_CLOSED;
@ -148,6 +150,8 @@ int32_t tsdbDropRepo(TsdbRepoT *repo) {
free(pRepo->rootDir); free(pRepo->rootDir);
free(pRepo); free(pRepo);
tsdbTrace("vgId: %d tsdb repository is dropped!", id);
return 0; return 0;
} }
@ -238,6 +242,7 @@ TsdbRepoT *tsdbOpenRepo(char *tsdbDir, STsdbAppH *pAppH) {
pRepo->state = TSDB_REPO_STATE_ACTIVE; pRepo->state = TSDB_REPO_STATE_ACTIVE;
tsdbTrace("vgId: %d open tsdb repository successfully!", pRepo->config.tsdbId);
return (TsdbRepoT *)pRepo; return (TsdbRepoT *)pRepo;
} }
@ -256,6 +261,7 @@ TsdbRepoT *tsdbOpenRepo(char *tsdbDir, STsdbAppH *pAppH) {
int32_t tsdbCloseRepo(TsdbRepoT *repo) { int32_t tsdbCloseRepo(TsdbRepoT *repo) {
STsdbRepo *pRepo = (STsdbRepo *)repo; STsdbRepo *pRepo = (STsdbRepo *)repo;
if (pRepo == NULL) return 0; if (pRepo == NULL) return 0;
int id = pRepo->config.tsdbId;
pRepo->state = TSDB_REPO_STATE_CLOSED; pRepo->state = TSDB_REPO_STATE_CLOSED;
tsdbLockRepo(repo); tsdbLockRepo(repo);
@ -289,6 +295,8 @@ int32_t tsdbCloseRepo(TsdbRepoT *repo) {
tfree(pRepo->rootDir); tfree(pRepo->rootDir);
tfree(pRepo); tfree(pRepo);
tsdbTrace("vgId: %d repository is closed!", id);
return 0; return 0;
} }
@ -349,6 +357,7 @@ int32_t tsdbTriggerCommit(TsdbRepoT *repo) {
pthread_attr_init(&thattr); pthread_attr_init(&thattr);
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_DETACHED);
pthread_create(&(pRepo->commitThread), &thattr, tsdbCommitData, (void *)repo); pthread_create(&(pRepo->commitThread), &thattr, tsdbCommitData, (void *)repo);
tsdbTrace("vgId: %d start to commit!", pRepo->config.tsdbId);
return 0; return 0;
} }
@ -376,11 +385,6 @@ STsdbRepoInfo *tsdbGetStatus(TsdbRepoT *pRepo) {
return NULL; return NULL;
} }
int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) {
STsdbRepo *pRepo = (STsdbRepo *)repo;
return tsdbCreateTableImpl(pRepo->tsdbMeta, pCfg);
}
int tsdbAlterTable(TsdbRepoT *pRepo, STableCfg *pCfg) { int tsdbAlterTable(TsdbRepoT *pRepo, STableCfg *pCfg) {
// TODO // TODO
return 0; return 0;
@ -395,13 +399,6 @@ TSKEY tsdbGetTableLastKey(TsdbRepoT *repo, int64_t uid) {
return TSDB_GET_TABLE_LAST_KEY(pTable); return TSDB_GET_TABLE_LAST_KEY(pTable);
} }
int tsdbDropTable(TsdbRepoT *repo, STableId tableId) {
if (repo == NULL) return -1;
STsdbRepo *pRepo = (STsdbRepo *)repo;
return tsdbDropTableImpl(pRepo->tsdbMeta, tableId);
}
STableInfo *tsdbGetTableInfo(TsdbRepoT *pRepo, STableId tableId) { STableInfo *tsdbGetTableInfo(TsdbRepoT *pRepo, STableId tableId) {
// TODO // TODO
return NULL; return NULL;
@ -756,12 +753,12 @@ static int32_t tsdbSetRepoEnv(STsdbRepo *pRepo) {
if (tsdbGetDataDirName(pRepo, dirName) < 0) return -1; if (tsdbGetDataDirName(pRepo, dirName) < 0) return -1;
if (mkdir(dirName, 0755) < 0) { if (mkdir(dirName, 0755) < 0) {
tsdbError("id %d: failed to create repository directory! reason %s", pRepo->config.tsdbId, strerror(errno)); tsdbError("vgId: %d failed to create repository directory! reason %s", pRepo->config.tsdbId, strerror(errno));
return -1; return -1;
} }
tsdbError( tsdbTrace(
"id %d: set up tsdb environment succeed! cacheBlockSize %d, totalBlocks %d, maxTables %d, daysPerFile %d, keep " "vgId: %d set up tsdb environment succeed! cacheBlockSize %d, totalBlocks %d, maxTables %d, daysPerFile %d, keep "
"%d, minRowsPerFileBlock %d, maxRowsPerFileBlock %d, precision %d, compression%d", "%d, minRowsPerFileBlock %d, maxRowsPerFileBlock %d, precision %d, compression%d",
pRepo->config.tsdbId, pCfg->cacheBlockSize, pCfg->totalBlocks, pCfg->maxTables, pCfg->daysPerFile, pCfg->keep, pRepo->config.tsdbId, pCfg->cacheBlockSize, pCfg->totalBlocks, pCfg->maxTables, pCfg->daysPerFile, pCfg->keep,
pCfg->minRowsPerFileBlock, pCfg->maxRowsPerFileBlock, pCfg->precision, pCfg->compression); pCfg->minRowsPerFileBlock, pCfg->maxRowsPerFileBlock, pCfg->precision, pCfg->compression);
@ -842,6 +839,9 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable
pTable->mem->numOfPoints = tSkipListGetSize(pTable->mem->pData); pTable->mem->numOfPoints = tSkipListGetSize(pTable->mem->pData);
tsdbTrace("vgId: %d, tid: %d, uid: " PRId64 "a row is inserted to table! key" PRId64,
pRepo->config.tsdbId, pTable->tableId.tid, pTable->tableId.uid, dataRowKey(row));
return 0; return 0;
} }
@ -1104,11 +1104,14 @@ static int tsdbHasDataToCommit(SSkipListIterator **iters, int nIters, TSKEY minK
} }
static void tsdbAlterCompression(STsdbRepo *pRepo, int8_t compression) { static void tsdbAlterCompression(STsdbRepo *pRepo, int8_t compression) {
int8_t oldCompRession = pRepo->config.compression;
pRepo->config.compression = compression; pRepo->config.compression = compression;
tsdbTrace("vgId: %d tsdb compression is changed from %d to %d", oldCompRession, compression);
} }
static void tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep) { static void tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep) {
STsdbCfg *pCfg = &pRepo->config; STsdbCfg *pCfg = &pRepo->config;
int oldKeep = pCfg->keep;
int maxFiles = keep / pCfg->maxTables + 3; int maxFiles = keep / pCfg->maxTables + 3;
if (pRepo->config.keep > keep) { if (pRepo->config.keep > keep) {
@ -1120,8 +1123,57 @@ static void tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep) {
} }
pRepo->tsdbFileH->maxFGroups = maxFiles; pRepo->tsdbFileH->maxFGroups = maxFiles;
} }
tsdbTrace("vgId: %d keep is changed from %d to %d", pRepo->config.tsdbId, oldKeep, keep);
} }
static void tsdbAlterMaxTables(STsdbRepo *pRepo, int32_t maxTables) { static void tsdbAlterMaxTables(STsdbRepo *pRepo, int32_t maxTables) {
// TODO // TODO
int oldMaxTables = pRepo->config.maxTables;
tsdbTrace("vgId: %d tsdb maxTables is changed from %d to %d!", pRepo->config.tsdbId, oldMaxTables, maxTables);
}
uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, int32_t *size) {
// TODO: need to refactor this function
STsdbRepo *pRepo = (STsdbRepo *)repo;
// STsdbMeta *pMeta = pRepo->tsdbMeta;
STsdbFileH *pFileH = pRepo->tsdbFileH;
uint32_t magic = 0;
char fname[256] = "\0";
struct stat fState;
char *spath = strdup(pRepo->rootDir);
char *prefixDir = dirname(spath);
if (name[0] == 0) {
// Map index to the file name
int fid = (*index) / 3;
if (fid > pFileH->numOfFGroups) {
// return meta data file
if ((*index) % 3 > 0) { // it is finished
tfree(spath);
return 0;
} else {
tsdbGetMetaFileName(pRepo->rootDir, fname);
}
} else {
// return data file name
strcpy(fname, pFileH->fGroup[fid].files[(*index) % 3].fname);
}
strcpy(name, fname + strlen(spath));
} else {
// Name is provided, need to get the file info
sprintf(fname, "%s/%s", prefixDir, name);
}
if (stat(fname, &fState) < 0) {
tfree(spath);
return 0;
}
*size = fState.st_size;
magic = *size;
return magic;
} }

View File

@ -8,7 +8,7 @@
#define TSDB_SUPER_TABLE_SL_LEVEL 5 // TODO: may change here #define TSDB_SUPER_TABLE_SL_LEVEL 5 // TODO: may change here
#define TSDB_META_FILE_NAME "META" #define TSDB_META_FILE_NAME "META"
const int32_t DEFAULT_TAG_INDEX_COLUMN = 0; const int32_t DEFAULT_TAG_INDEX_COLUMN = 0; // skip list built based on the first column of tags
static int tsdbFreeTable(STable *pTable); static int tsdbFreeTable(STable *pTable);
static int32_t tsdbCheckTableCfg(STableCfg *pCfg); static int32_t tsdbCheckTableCfg(STableCfg *pCfg);
@ -234,7 +234,6 @@ STSchema * tsdbGetTableTagSchema(STsdbMeta *pMeta, STable *pTable) {
} }
} }
// todo refactor table name definition
int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId* id, int32_t colId, int16_t* type, int16_t* bytes, char** val) { int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId* id, int32_t colId, int16_t* type, int16_t* bytes, char** val) {
STsdbMeta* pMeta = tsdbGetMeta(repo); STsdbMeta* pMeta = tsdbGetMeta(repo);
STable* pTable = tsdbGetTableByUid(pMeta, id->uid); STable* pTable = tsdbGetTableByUid(pMeta, id->uid);
@ -242,6 +241,7 @@ int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId* id, int32_t colId, int16_t
STSchema* pSchema = tsdbGetTableTagSchema(pMeta, pTable); STSchema* pSchema = tsdbGetTableTagSchema(pMeta, pTable);
STColumn* pCol = NULL; STColumn* pCol = NULL;
// todo binary search
for(int32_t col = 0; col < schemaNCols(pSchema); ++col) { for(int32_t col = 0; col < schemaNCols(pSchema); ++col) {
STColumn* p = schemaColAt(pSchema, col); STColumn* p = schemaColAt(pSchema, col);
if (p->colId == colId) { if (p->colId == colId) {
@ -283,7 +283,10 @@ char* tsdbGetTableName(TsdbRepoT *repo, const STableId* id, int16_t* bytes) {
} }
} }
int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) { int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) {
STsdbRepo *pRepo = (STsdbRepo *)repo;
STsdbMeta *pMeta = pRepo->tsdbMeta;
if (tsdbCheckTableCfg(pCfg) < 0) return -1; if (tsdbCheckTableCfg(pCfg) < 0) return -1;
STable *super = NULL; STable *super = NULL;
@ -351,8 +354,14 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
} }
// Register to meta // Register to meta
if (newSuper) tsdbAddTableToMeta(pMeta, super, true); if (newSuper) {
tsdbAddTableToMeta(pMeta, super, true);
tsdbTrace("vgId: %d super table is created! uid " PRId64, pRepo->config.tsdbId,
super->tableId.uid);
}
tsdbAddTableToMeta(pMeta, table, true); tsdbAddTableToMeta(pMeta, table, true);
tsdbTrace("vgId: %d table is created! tid %d, uid " PRId64, pRepo->config.tsdbId, table->tableId.tid,
table->tableId.uid);
// Write to meta file // Write to meta file
int bufLen = 0; int bufLen = 0;
@ -385,13 +394,24 @@ STable *tsdbIsValidTableToInsert(STsdbMeta *pMeta, STableId tableId) {
return pTable; return pTable;
} }
int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) { // int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) {
int tsdbDropTable(TsdbRepoT *repo, STableId tableId) {
STsdbRepo *pRepo = (STsdbRepo *)repo;
if (pRepo == NULL) return -1;
STsdbMeta *pMeta = pRepo->tsdbMeta;
if (pMeta == NULL) return -1; if (pMeta == NULL) return -1;
STable *pTable = tsdbGetTableByUid(pMeta, tableId.uid); STable *pTable = tsdbGetTableByUid(pMeta, tableId.uid);
if (pTable == NULL) return -1; if (pTable == NULL) {
tsdbError("vgId %d: failed to drop table since table not exists! tid %d, uid " PRId64, pRepo->config.tsdbId,
tableId.tid, tableId.uid);
return -1;
}
tsdbTrace("vgId: %d table is dropped! tid %d, uid " PRId64, pRepo->config.tsdbId, tableId.tid, tableId.uid);
if (tsdbRemoveTableFromMeta(pMeta, pTable) < 0) return -1; if (tsdbRemoveTableFromMeta(pMeta, pTable) < 0) return -1;
return 0; return 0;
} }
@ -483,7 +503,9 @@ static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) {
if (pTable->type == TSDB_SUPER_TABLE) { if (pTable->type == TSDB_SUPER_TABLE) {
SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex); SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex);
while (tSkipListIterNext(pIter)) { while (tSkipListIterNext(pIter)) {
STable *tTable = *(STable **)SL_GET_NODE_DATA(tSkipListIterGet(pIter)); STableIndexElem *pEle = (STableIndexElem *)SL_GET_NODE_DATA(tSkipListIterGet(pIter));
STable *tTable = pEle->pTable;
ASSERT(tTable != NULL && tTable->type == TSDB_CHILD_TABLE); ASSERT(tTable != NULL && tTable->type == TSDB_CHILD_TABLE);
pMeta->tables[tTable->tableId.tid] = NULL; pMeta->tables[tTable->tableId.tid] = NULL;
@ -548,7 +570,10 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
STable* pSTable = tsdbGetTableByUid(pMeta, pTable->superUid); STable* pSTable = tsdbGetTableByUid(pMeta, pTable->superUid);
assert(pSTable != NULL); assert(pSTable != NULL);
char* key = dataRowTuple(pTable->tagVal); // key STSchema* pSchema = tsdbGetTableTagSchema(pMeta, pTable);
STColumn* pCol = &pSchema->columns[DEFAULT_TAG_INDEX_COLUMN];
char* key = tdGetRowDataOfCol(pTable->tagVal, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset);
bool ret = tSkipListRemove(pSTable->pIndex, key); bool ret = tSkipListRemove(pSTable->pIndex, key);
assert(ret); assert(ret);

View File

@ -28,7 +28,7 @@ typedef struct {
int64_t uid; int64_t uid;
} SRecordInfo; } SRecordInfo;
static int32_t tsdbGetMetaFileName(char *rootDir, char *fname); // static int32_t tsdbGetMetaFileName(char *rootDir, char *fname);
// static int32_t tsdbCheckMetaHeader(int fd); // static int32_t tsdbCheckMetaHeader(int fd);
static int32_t tsdbWriteMetaHeader(int fd); static int32_t tsdbWriteMetaHeader(int fd);
static int tsdbCreateMetaFile(char *fname); static int tsdbCreateMetaFile(char *fname);
@ -180,7 +180,7 @@ void tsdbCloseMetaFile(SMetaFile *mfh) {
tfree(mfh); tfree(mfh);
} }
static int32_t tsdbGetMetaFileName(char *rootDir, char *fname) { int32_t tsdbGetMetaFileName(char *rootDir, char *fname) {
if (rootDir == NULL) return -1; if (rootDir == NULL) return -1;
sprintf(fname, "%s/%s", rootDir, TSDB_META_FILE_NAME); sprintf(fname, "%s/%s", rootDir, TSDB_META_FILE_NAME);
return 0; return 0;

View File

@ -414,6 +414,7 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheck
static int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order); static int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo) { static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo) {
STsdbRepo *pRepo = pQueryHandle->pTsdb;
SCompData* data = calloc(1, sizeof(SCompData) + sizeof(SCompCol) * pBlock->numOfCols); SCompData* data = calloc(1, sizeof(SCompData) + sizeof(SCompCol) * pBlock->numOfCols);
data->numOfCols = pBlock->numOfCols; data->numOfCols = pBlock->numOfCols;
@ -423,7 +424,7 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
SArray* sa = getDefaultLoadColumns(pQueryHandle, true); SArray* sa = getDefaultLoadColumns(pQueryHandle, true);
if (pCheckInfo->pDataCols == NULL) { if (pCheckInfo->pDataCols == NULL) {
pCheckInfo->pDataCols = tdNewDataCols(1000, 100, 4096); //todo fix me pCheckInfo->pDataCols = tdNewDataCols(pRepo->tsdbMeta->maxRowBytes, pRepo->tsdbMeta->maxCols, pRepo->config.maxRowsPerFileBlock);
} }
tdInitDataCols(pCheckInfo->pDataCols, tsdbGetTableSchema(tsdbGetMeta(pQueryHandle->pTsdb), pCheckInfo->pTableObj)); tdInitDataCols(pCheckInfo->pDataCols, tsdbGetTableSchema(tsdbGetMeta(pQueryHandle->pTsdb), pCheckInfo->pTableObj));
@ -626,7 +627,7 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf
for(int32_t k = start; k < pQueryHandle->realNumOfRows + start; ++k) { for(int32_t k = start; k < pQueryHandle->realNumOfRows + start; ++k) {
char* p = tdGetColDataOfRow(src, k); char* p = tdGetColDataOfRow(src, k);
memcpy(dst, p, varDataTLen(p)); memcpy(dst, p, varDataTLen(p));
dst += varDataTLen(p); dst += bytes;
} }
} }
@ -1311,8 +1312,8 @@ void filterPrepare(void* expr, void* param) {
} else { } else {
pInfo->q = calloc(1, pSchema->bytes); pInfo->q = calloc(1, pSchema->bytes);
if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) {
varDataSetLen(pInfo->q, pCond->nLen);
tVariantDump(pCond, varDataVal(pInfo->q), pSchema->type); tVariantDump(pCond, varDataVal(pInfo->q), pSchema->type);
varDataSetLen(pInfo->q, pCond->nLen); // the length may be changed after dump, so assign its value after dump
} else { } else {
tVariantDump(pCond, pInfo->q, pSchema->type); tVariantDump(pCond, pInfo->q, pSchema->type);
} }
@ -1432,7 +1433,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
return pTableGroup; return pTableGroup;
} }
bool tSkipListNodeFilterCallback(const void* pNode, void* param) { bool indexedNodeFilterFp(const void* pNode, void* param) {
tQueryInfo* pInfo = (tQueryInfo*) param; tQueryInfo* pInfo = (tQueryInfo*) param;
STableIndexElem* elem = (STableIndexElem*)(SL_GET_NODE_DATA((SSkipListNode*)pNode)); STableIndexElem* elem = (STableIndexElem*)(SL_GET_NODE_DATA((SSkipListNode*)pNode));
@ -1497,7 +1498,7 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) {
static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr) { static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr) {
// query according to the expression tree // query according to the expression tree
SExprTraverseSupp supp = { SExprTraverseSupp supp = {
.fp = (__result_filter_fn_t) tSkipListNodeFilterCallback, .nodeFilterFn = (__result_filter_fn_t) indexedNodeFilterFp,
.setupInfoFn = filterPrepare, .setupInfoFn = filterPrepare,
.pExtInfo = pSTable->tagSchema, .pExtInfo = pSTable->tagSchema,
}; };

View File

@ -51,6 +51,15 @@ int32_t compareDoubleIntVal(const void *pLeft, const void *pRight) {
} }
} }
int32_t compareFloatVal(const void *pLeft, const void *pRight) {
float ret = GET_FLOAT_VAL(pLeft) - GET_FLOAT_VAL(pRight);
if (fabs(ret) < FLT_EPSILON) {
return 0;
} else {
return ret > 0? 1 : -1;
}
}
int32_t compareDoubleVal(const void *pLeft, const void *pRight) { int32_t compareDoubleVal(const void *pLeft, const void *pRight) {
double ret = GET_DOUBLE_VAL(pLeft) - GET_DOUBLE_VAL(pRight); double ret = GET_DOUBLE_VAL(pLeft) - GET_DOUBLE_VAL(pRight);
if (fabs(ret) < FLT_EPSILON) { if (fabs(ret) < FLT_EPSILON) {
@ -67,33 +76,29 @@ int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight) {
if (len1 != len2) { if (len1 != len2) {
return len1 > len2? 1:-1; return len1 > len2? 1:-1;
} else { } else {
return (int32_t) strncmp(varDataVal(pLeft), varDataVal(pRight), len1); int32_t ret = strncmp(varDataVal(pLeft), varDataVal(pRight), len1);
if (ret == 0) {
return 0;
} else {
return ret > 0 ? 1:-1;
}
} }
} }
int32_t compareWStrVal(const void *pLeft, const void *pRight) { int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) {
// SSkipListKey *pL = (SSkipListKey *)pLeft; int32_t len1 = varDataLen(pLeft);
// SSkipListKey *pR = (SSkipListKey *)pRight; int32_t len2 = varDataLen(pRight);
//
// if (pL->nLen == 0 && pR->nLen == 0) { if (len1 != len2) {
// return 0; return len1 > len2? 1:-1;
// } } else {
// int32_t ret = wcsncmp(varDataVal(pLeft), varDataVal(pRight), len1);
// // handle only one-side bound compare situation, there is only lower bound or only upper bound if (ret == 0) {
// if (pL->nLen == -1) {
// return 1; // no lower bound, lower bound is minimum, always return -1;
// } else if (pR->nLen == -1) {
// return -1; // no upper bound, upper bound is maximum situation, always return 1;
// }
//
// int32_t ret = wcscmp(((SSkipListKey *)pLeft)->wpz, ((SSkipListKey *)pRight)->wpz);
//
// if (ret == 0) {
// return 0;
// } else {
// return ret > 0 ? 1 : -1;
// }
return 0; return 0;
} else {
return ret > 0 ? 1 : -1;
}
}
} }
/* /*
@ -131,7 +136,7 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
size_t n = strcspn(str, next); size_t n = strcspn(str, next);
str += n; str += n;
if (str[0] == 0 || (n >= size - 1)) { if (str[0] == 0 || (n >= size)) {
break; break;
} }
@ -179,10 +184,10 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c
wchar_t accept[3] = {towupper(c), towlower(c), 0}; wchar_t accept[3] = {towupper(c), towlower(c), 0};
while (1) { while (1) {
size_t n = wcsspn(str, accept); size_t n = wcscspn(str, accept);
str += n; str += n;
if (str[0] == 0 || (n >= size - 1)) { if (str[0] == 0 || (n >= size)) {
break; break;
} }
@ -261,7 +266,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
} }
case TSDB_DATA_TYPE_FLOAT: { case TSDB_DATA_TYPE_FLOAT: {
comparFn = compareDoubleVal; break; comparFn = compareFloatVal; break;
} }
case TSDB_DATA_TYPE_DOUBLE: { case TSDB_DATA_TYPE_DOUBLE: {
@ -284,7 +289,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
if (optr == TSDB_RELATION_LIKE) { if (optr == TSDB_RELATION_LIKE) {
comparFn = compareWStrPatternComp; comparFn = compareWStrPatternComp;
} else { } else {
comparFn = compareWStrVal; comparFn = compareLenPrefixedWStr;
} }
break; break;
@ -317,6 +322,8 @@ __compar_fn_t getKeyComparFunc(int32_t keyType) {
comparFn = compareInt64Val; comparFn = compareInt64Val;
break; break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
comparFn = compareFloatVal;
break;
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
comparFn = compareDoubleVal; comparFn = compareDoubleVal;
break; break;
@ -326,7 +333,7 @@ __compar_fn_t getKeyComparFunc(int32_t keyType) {
break; break;
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
comparFn = compareWStrVal; comparFn = compareLenPrefixedWStr;
break; break;
default: default:

View File

@ -49,6 +49,7 @@ typedef struct {
STsdbCfg tsdbCfg; STsdbCfg tsdbCfg;
SSyncCfg syncCfg; SSyncCfg syncCfg;
SWalCfg walCfg; SWalCfg walCfg;
char * rootDir;
} SVnodeObj; } SVnodeObj;
int vnodeWriteToQueue(void *param, void *pHead, int type); int vnodeWriteToQueue(void *param, void *pHead, int type);

View File

@ -182,6 +182,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
pVnode->refCount = 1; pVnode->refCount = 1;
pVnode->version = 0; pVnode->version = 0;
pVnode->tsdbCfg.tsdbId = pVnode->vgId; pVnode->tsdbCfg.tsdbId = pVnode->vgId;
pVnode->rootDir = strdup(rootDir);
taosAddIntHash(tsDnodeVnodesHash, pVnode->vgId, (char *)(&pVnode)); taosAddIntHash(tsDnodeVnodesHash, pVnode->vgId, (char *)(&pVnode));
int32_t code = vnodeReadCfg(pVnode); int32_t code = vnodeReadCfg(pVnode);
@ -271,6 +272,7 @@ void vnodeRelease(void *pVnodeRaw) {
return; return;
} }
tfree(pVnode->rootDir);
// remove read queue // remove read queue
dnodeFreeRqueue(pVnode->rqueue); dnodeFreeRqueue(pVnode->rqueue);
pVnode->rqueue = NULL; pVnode->rqueue = NULL;
@ -288,7 +290,7 @@ void vnodeRelease(void *pVnodeRaw) {
free(pVnode); free(pVnode);
int32_t count = atomic_sub_fetch_32(&tsOpennedVnodes, 1); int32_t count = atomic_sub_fetch_32(&tsOpennedVnodes, 1);
vTrace("vgId:%d, vnode is released, vnodes:%d", pVnode, vgId, count); vTrace("vgId:%d, vnode is released, vnodes:%d", vgId, count);
if (count <= 0) { if (count <= 0) {
taosCleanUpIntHash(tsDnodeVnodesHash); taosCleanUpIntHash(tsDnodeVnodesHash);
@ -383,9 +385,8 @@ static int vnodeWalCallback(void *arg) {
} }
static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size) { static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size) {
// SVnodeObj *pVnode = ahandle; SVnodeObj *pVnode = ahandle;
//tsdbGetFileInfo(pVnode->tsdb, name, index, size); return tsdbGetFileInfo(pVnode->tsdb, name, index, size);
return 0;
} }
static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index) { static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index) {
@ -405,9 +406,17 @@ static void vnodeNotifyRole(void *ahandle, int8_t role) {
static void vnodeNotifyFileSynced(void *ahandle) { static void vnodeNotifyFileSynced(void *ahandle) {
SVnodeObj *pVnode = ahandle; SVnodeObj *pVnode = ahandle;
vTrace("pVnode:%p vgId:%d, data file is synced", pVnode, pVnode->vgId); vTrace("vgId:%d, data file is synced", pVnode->vgId);
char rootDir[128] = "\0";
sprintf(rootDir, "%s/tsdb", pVnode->rootDir);
// clsoe tsdb, then open tsdb // clsoe tsdb, then open tsdb
tsdbCloseRepo(pVnode->tsdb);
STsdbAppH appH = {0};
appH.appH = (void *)pVnode;
appH.walCallBack = vnodeWalCallback;
appH.cqH = pVnode->cq;
pVnode->tsdb = tsdbOpenRepo(rootDir, &appH);
} }
static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) { static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) {

View File

@ -65,7 +65,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont
pRet->len = sizeof(SQueryTableRsp); pRet->len = sizeof(SQueryTableRsp);
pRet->rsp = pRsp; pRet->rsp = pRsp;
vTrace("vgId:%d QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo); vTrace("vgId:%d, QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo);
} else { } else {
pQInfo = pCont; pQInfo = pCont;
code = TSDB_CODE_ACTION_IN_PROGRESS; code = TSDB_CODE_ACTION_IN_PROGRESS;
@ -83,7 +83,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t cont
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
vTrace("vgId:%d QInfo:%p, retrieve msg is received", pVnode->vgId, pQInfo); vTrace("vgId:%d, QInfo:%p, retrieve msg is received", pVnode->vgId, pQInfo);
pRet->code = qRetrieveQueryResultInfo(pQInfo); pRet->code = qRetrieveQueryResultInfo(pQInfo);
if (pRet->code != TSDB_CODE_SUCCESS) { if (pRet->code != TSDB_CODE_SUCCESS) {
@ -104,6 +104,6 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t cont
} }
} }
vTrace("vgId:%d QInfo:%p, retrieve msg is disposed", pVnode->vgId, pQInfo); vTrace("vgId:%d, QInfo:%p, retrieve msg is disposed", pVnode->vgId, pQInfo);
return code; return code;
} }

View File

@ -51,10 +51,7 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) {
if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL) if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL)
return TSDB_CODE_MSG_NOT_PROCESSED; return TSDB_CODE_MSG_NOT_PROCESSED;
if (pVnode->status != TAOS_VN_STATUS_READY && qtype == TAOS_QTYPE_RPC) if (pHead->version == 0) { // from client or CQ
return TSDB_CODE_NOT_ACTIVE_VNODE;
if (pHead->version == 0) { // from client
if (pVnode->status != TAOS_VN_STATUS_READY) if (pVnode->status != TAOS_VN_STATUS_READY)
return TSDB_CODE_NOT_ACTIVE_VNODE; return TSDB_CODE_NOT_ACTIVE_VNODE;
@ -64,22 +61,24 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) {
// assign version // assign version
pVnode->version++; pVnode->version++;
pHead->version = pVnode->version; pHead->version = pVnode->version;
} else { } else { // from wal or forward
// for data from WAL or forward, version may be smaller // for data from WAL or forward, version may be smaller
if (pHead->version <= pVnode->version) return 0; if (pHead->version <= pVnode->version) return 0;
} }
// more status and role checking here
pVnode->version = pHead->version; pVnode->version = pHead->version;
// write into WAL // write into WAL
code = walWrite(pVnode->wal, pHead); code = walWrite(pVnode->wal, pHead);
if (code < 0) return code; if (code < 0) return code;
int32_t syncCode = syncForwardToPeer(pVnode->sync, pHead, item); // forward to peers if data is from RPC or CQ
int32_t syncCode = 0;
if (qtype == TAOS_QTYPE_RPC || qtype == TAOS_QTYPE_CQ)
syncCode = syncForwardToPeer(pVnode->sync, pHead, item);
if (syncCode < 0) return syncCode; if (syncCode < 0) return syncCode;
// write data locally
code = (*vnodeProcessWriteMsgFp[pHead->msgType])(pVnode, pHead->cont, item); code = (*vnodeProcessWriteMsgFp[pHead->msgType])(pVnode, pHead->cont, item);
if (code < 0) return code; if (code < 0) return code;

View File

@ -85,3 +85,6 @@ python3 ./test.py $1 -f import_merge/importTRestart.py
# user # user
python3 ./test.py $1 -f user/user_create.py python3 ./test.py $1 -f user/user_create.py
python3 ./test.py $1 -f user/pass_len.py python3 ./test.py $1 -f user/pass_len.py
# table
#python3 ./test.py $1 -f table/del_stable.py

View File

@ -46,16 +46,16 @@ class TDTestCase:
self.maxrows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import %d sequential data" % (self.maxrows / 2)) tdLog.info("import %d sequential data" % (self.maxrows // 2))
startTime = self.startTime startTime = self.startTime
sqlcmd = ['import into tb1 values'] sqlcmd = ['import into tb1 values']
for rid in range(1, self.maxrows / 2 + 1): for rid in range(1, self.maxrows // 2 + 1):
sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) sqlcmd.append('(%ld, %d)' % (startTime + rid, rid))
tdSql.execute(" ".join(sqlcmd)) tdSql.execute(" ".join(sqlcmd))
tdLog.info("================= step3") tdLog.info("================= step3")
tdSql.query('select * from tb1') tdSql.query('select * from tb1')
tdSql.checkRows(self.maxrows / 2) tdSql.checkRows(self.maxrows // 2)
tdLog.info("================= step4") tdLog.info("================= step4")
tdDnodes.stop(1) tdDnodes.stop(1)
@ -70,7 +70,7 @@ class TDTestCase:
tdLog.info("================= step7") tdLog.info("================= step7")
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.query('select * from tb1 order by ts desc') tdSql.query('select * from tb1 order by ts desc')
tdSql.checkRows(self.maxrows / 2 + 1) tdSql.checkRows(self.maxrows // 2 + 1)
tdLog.info("================= step8") tdLog.info("================= step8")
tdLog.info("import 10 data in batch before") tdLog.info("import 10 data in batch before")
@ -83,7 +83,7 @@ class TDTestCase:
tdLog.info("================= step9") tdLog.info("================= step9")
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.query('select * from tb1 order by ts desc') tdSql.query('select * from tb1 order by ts desc')
tdSql.checkRows(self.maxrows / 2 + 11) tdSql.checkRows(self.maxrows // 2 + 11)
def stop(self): def stop(self):
tdSql.close() tdSql.close()

View File

@ -27,7 +27,7 @@ class TDTestCase:
def run(self): def run(self):
self.ntables = 1 self.ntables = 1
self.startTime = 1520000010000 self.startTime = 1520000010000
self.maxwrows = 200 self.maxrows = 200
self.rowsPerTable = 20 self.rowsPerTable = 20
tdDnodes.stop(1) tdDnodes.stop(1)

View File

@ -46,16 +46,17 @@ class TDTestCase:
self.maxrows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import %d sequential data" % (self.maxrows / 2)) tdLog.info("import %d sequential data" % (self.maxrows // 2))
startTime = self.startTime startTime = self.startTime
sqlcmd = ['import into tb1 values'] sqlcmd = ['import into tb1 values']
for rid in range(1, self.maxrows / 2 + 1): for rid in range(1, self.maxrows // 2 + 1):
sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) sqlcmd.append('(%ld, %d)' % (startTime + rid, rid))
tdSql.execute(" ".join(sqlcmd)) tdSql.execute(" ".join(sqlcmd))
tdLog.info("================= step3") tdLog.info("================= step3")
tdSql.query('select * from tb1') tdSql.query('select * from tb1')
tdSql.checkRows(self.maxrows / 2) tdSql.checkRows(self.maxrows // 2)
tdLog.info("================= step4") tdLog.info("================= step4")
tdDnodes.stop(1) tdDnodes.stop(1)
@ -73,7 +74,7 @@ class TDTestCase:
tdLog.info("================= step9") tdLog.info("================= step9")
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.query('select * from tb1 order by ts desc') tdSql.query('select * from tb1 order by ts desc')
tdSql.checkRows(self.maxrows / 2) tdSql.checkRows(self.maxrows // 2)
def stop(self): def stop(self):
tdSql.close() tdSql.close()

View File

@ -33,7 +33,7 @@ class TDTestCase:
tdDnodes.start(1) tdDnodes.start(1)
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db cache 512 tables 10') tdSql.execute('create database db cache 512 maxtables 10')
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")

View File

@ -29,88 +29,17 @@ python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f table/db_table.py python3 ./test.py $1 -f table/db_table.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataLastTO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataLastT.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataTO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataT.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHeadOverlap.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHeadPartOverlap.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHORestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHPORestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHRestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importLastSub.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1HO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1HPO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1H.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1S.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1Sub.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1TO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1TPO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1T.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2HO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2HPO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2H.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2S.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2Sub.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2TO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2TPO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2T.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlockbetween.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importCacheFileSub.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importCacheFileTO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importCacheFileT.py python3 ./test.py $1 -f import_merge/importCacheFileT.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataLastSub.py python3 ./test.py $1 -f import_merge/importDataLastSub.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHead.py python3 ./test.py $1 -f import_merge/importHead.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importLastTO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importLastT.py python3 ./test.py $1 -f import_merge/importLastT.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importSpan.py python3 ./test.py $1 -f import_merge/importSpan.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importSRestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importSubRestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTailOverlap.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTail.py python3 ./test.py $1 -f import_merge/importTail.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTORestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTPORestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTRestart.py python3 ./test.py $1 -f import_merge/importTRestart.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1

View File

@ -0,0 +1,50 @@
###################################################################
# 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 tdLog
from util.cases import tdCases
from util.sql import tdSql
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
def run(self):
tdSql.prepare()
tdSql.execute("drop database if exists db")
print("==============step1")
tdSql.execute("create database db")
tdSql.execute("create table db.st (ts timestamp, i int) tags(j int)")
tdSql.execute("create table db.tb using st tags(1)")
tdSql.execute("insert into db.tb values(now, 1)")
print("==============step2")
try:
tdSql.execute("drop table db.st")
except Exception as e:
tdLog.exit(e)
tdSql.execute("select * from db.st")
tdSql.checkRows(1)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -201,8 +201,8 @@ class TDDnode:
self.running = 1 self.running = 1
tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) tdLog.debug("dnode:%d is running with %s " % (self.index, cmd))
tdLog.debug("wait 2 seconds for the dnode:%d to start." % (self.index)) tdLog.debug("wait 4 seconds for the dnode:%d to start." % (self.index))
time.sleep(2) time.sleep(4)
def stop(self): def stop(self):
if self.valgrind == 0: if self.valgrind == 0:

35
tests/pytest/valgrind-test.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
python3 ./test.py $1 -f insert/basic.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/int.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/float.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/bigint.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/bool.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/double.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/smallint.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/tinyint.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/binary.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/date.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/nchar.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f table/column_name.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f table/column_num.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f table/db_table.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importCacheFileT.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataLastSub.py
python3 ./test.py $1 -s && sleep 1

View File

@ -1,26 +1,21 @@
#################################
run general/cache/new_metrics.sim run general/cache/new_metrics.sim
run general/compress/compress.sim run general/compress/compress.sim
run general/compute/avg.sim run general/compute/avg.sim
run general/compute/bottom.sim
run general/compute/count.sim run general/compute/count.sim
run general/db/len.sim run general/db/len.sim
run general/db/basic4.sim run general/db/basic4.sim
run general/http/restful_insert.sim run general/http/restful_insert.sim
run general/import/basic.sim run general/import/basic.sim
run general/import/commit.sim run general/import/commit.sim
run general/insert/basic.sim
run general/insert/query_file_memory.sim run general/insert/query_file_memory.sim
run general/parser/binary_escapeCharacter.sim run general/parser/binary_escapeCharacter.sim
run general/parser/columnValue_bigint.sim
run general/parser/select_from_cache_disk.sim run general/parser/select_from_cache_disk.sim
run general/table/autocreate.sim run general/table/autocreate.sim
run general/table/basic3.sim
run general/table/column_name.sim run general/table/column_name.sim
run general/table/int.sim run general/table/int.sim
run general/table/vgroup.sim run general/table/vgroup.sim
run general/user/basic1.sim run general/user/basic1.sim
run general/user/pass_alter.sim run general/user/pass_alter.sim
run general/user/user_len.sim
run general/vector/single.sim run general/vector/single.sim
################################## #run general/connection/connection.sim
run general/user/authority.sim

View File

@ -26,21 +26,16 @@ endi
print =============== step2 print =============== step2
sql insert into d3.t1 values (now -300d,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0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 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 )
print =============== step3 print =============== step3

View File

@ -81,7 +81,7 @@ sql_error select diff(c8) from $tb
sql_error select diff(c9) from $tb sql_error select diff(c9) from $tb
sql_error select diff(ts) from $tb sql_error select diff(ts) from $tb
sql_error select diff(c1), diff(c2) from $tb sql_error select diff(c1), diff(c2) from $tb
sql_error select 2+diff(c1) from $tb #sql_error select 2+diff(c1) from $tb
sql_error select diff(c1+2) from $tb sql_error select diff(c1+2) from $tb
sql_error select diff(c1) from $tb where ts > 0 and ts < now + 100m interval(10m) sql_error select diff(c1) from $tb where ts > 0 and ts < now + 100m interval(10m)
sql_error select diff(c1) from $mt sql_error select diff(c1) from $mt

View File

@ -0,0 +1,21 @@
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/exec.sh -n dnode1 -s start
sleep 3000
sql connect
print ============= step1
sql close
print close1
sql connect
print ============= step2
sql close
sql connect
print ============= step3
sql close
sql connect write
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -26,9 +26,11 @@ 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
print ========= start dnodes print ========= start dnodes
sleep 2000
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
sql connect sql connect
sql reset query cache
print ======== step1 print ======== step1
sql create database d1 replica 1 sql create database d1 replica 1

View File

@ -1,4 +1,4 @@
run general//db/basic.sim run general/db/basic.sim
run general/db/basic1.sim run general/db/basic1.sim
run general/db/basic2.sim run general/db/basic2.sim
run general/db/basic3.sim run general/db/basic3.sim
@ -13,3 +13,4 @@ run general/db/delete_writing2.sim
run general/db/len.sim run general/db/len.sim
run general/db/repeat.sim run general/db/repeat.sim
run general/db/tables.sim run general/db/tables.sim
run general/db/vnodes.sim

View File

@ -0,0 +1,45 @@
system sh/stop_dnodes.sh
$totalVnodes = 10
$maxTables = 4
$totalRows = $totalVnodes * $maxTables
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 maxtablesPerVnode -v $maxTables
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v $totalVnodes
system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 100000
system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 100000
system sh/cfg.sh -n dnode1 -c maxShellConns -v 100000
system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 100000
print ========== prepare data
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql connect
sql create database db blocks 2 cache 1 maxTables $maxTables
sql use db
print ========== step1
sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int)
$x = 0
while $x < $totalRows
$tb = t . $x
sql create table $tb using mt tags( $x )
sql insert into $tb values (now, $x )
$x = $x + 1
endw
print ========== step2
sql select * from mt
if $rows != $totalRows then
return -1
endi
sql select count(*) from mt
if $data00 != $totalRows then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -157,25 +157,25 @@ endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select count(i) from d1.mt group by a"},{"refId":"B","alias":"","sql":"select sum(i) from d1.mt group by b"}]' 127.0.0.1:6020/grafana/query system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select count(i) from d1.mt group by a"},{"refId":"B","alias":"","sql":"select sum(i) from d1.mt group by b"}]' 127.0.0.1:6020/grafana/query
print 16-> $system_content print 16-> $system_content
if $system_content != @[{"refId":"A","target":"1","datapoints":[[5,"-"]]},{"refId":"A","target":"2","datapoints":[[4,"-"]]},{"refId":"A","target":"3","datapoints":[[3,"-"]]},{"refId":"B","target":"a","datapoints":[[5,"-"]]},{"refId":"B","target":"b","datapoints":[[8,"-"]]},{"refId":"B","target":"c","datapoints":[[9,"-"]]}]@ then if $system_content != @[{"refId":"A","target":"{a:1,}","datapoints":[[5,"-"]]},{"refId":"A","target":"{a:2,}","datapoints":[[4,"-"]]},{"refId":"A","target":"{a:3,}","datapoints":[[3,"-"]]},{"refId":"B","target":"{b:a}","datapoints":[[5,"-"]]},{"refId":"B","target":"{b:b}","datapoints":[[8,"-"]]},{"refId":"B","target":"{b:c}","datapoints":[[9,"-"]]}]@ then
return -1 return -1
endi endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"count","sql":"select count(i) from d1.mt group by a"},{"refId":"B","alias":"sum-","sql":"select sum(i) from d1.mt group by b"}]' 127.0.0.1:6020/grafana/query system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"count","sql":"select count(i) from d1.mt group by a"},{"refId":"B","alias":"sum-","sql":"select sum(i) from d1.mt group by b"}]' 127.0.0.1:6020/grafana/query
print 17-> $system_content print 17-> $system_content
if $system_content != @[{"refId":"A","target":"count1","datapoints":[[5,"-"]]},{"refId":"A","target":"count2","datapoints":[[4,"-"]]},{"refId":"A","target":"count3","datapoints":[[3,"-"]]},{"refId":"B","target":"sum-a","datapoints":[[5,"-"]]},{"refId":"B","target":"sum-b","datapoints":[[8,"-"]]},{"refId":"B","target":"sum-c","datapoints":[[9,"-"]]}]@ then if $system_content != @[{"refId":"A","target":"count{a:1,}","datapoints":[[5,"-"]]},{"refId":"A","target":"count{a:2,}","datapoints":[[4,"-"]]},{"refId":"A","target":"count{a:3,}","datapoints":[[3,"-"]]},{"refId":"B","target":"sum-{b:a}","datapoints":[[5,"-"]]},{"refId":"B","target":"sum-{b:b}","datapoints":[[8,"-"]]},{"refId":"B","target":"sum-{b:c}","datapoints":[[9,"-"]]}]@ then
return -1 return -1
endi endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"count","sql":"select count(i) from d1.mt interval(1m) group by a "}]' 127.0.0.1:6020/grafana/query system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"count","sql":"select count(i) from d1.mt interval(1m) group by a "}]' 127.0.0.1:6020/grafana/query
print 18-> $system_content print 18-> $system_content
if $system_content != @[{"refId":"A","target":"count1","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000],[1,1514208480000],[1,1514208540000]]},{"refId":"A","target":"count2","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000],[1,1514208480000]]},{"refId":"A","target":"count3","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000]]}]@ then if $system_content != @[{"refId":"A","target":"count{a:1,}","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000],[1,1514208480000],[1,1514208540000]]},{"refId":"A","target":"count{a:2,}","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000],[1,1514208480000]]},{"refId":"A","target":"count{a:3,}","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000]]}]@ then
return -1 return -1
endi endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select sum(v2), count(v1) from d1.m1"},{"refId":"B","alias":"","sql":"select count(v2), sum(v2) from d1.m1"}]' 127.0.0.1:6020/grafana/query system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select sum(v2), count(v1) from d1.m1"},{"refId":"B","alias":"","sql":"select count(v2), sum(v2) from d1.m1"}]' 127.0.0.1:6020/grafana/query
print 19-> $system_content print 19-> $system_content
if $system_content != @[{"refId":"A","target":"3","datapoints":[[15.299999714,"-"]]},{"refId":"B","target":"15.299999714","datapoints":[[3,"-"]]}]@ then if $system_content != @[{"refId":"A","target":"{count(v1):3}","datapoints":[[15.299999714,"-"]]},{"refId":"B","target":"{sum(v2):15.299999714}","datapoints":[[3,"-"]]}]@ then
return -1 return -1
endi endi

View File

@ -43,7 +43,7 @@ print ====== tables created
print ================== restart server to commit data into disk print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 2000 sleep 3000
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
print ================== server restart completed print ================== server restart completed
@ -69,7 +69,7 @@ endw
print ================== restart server to commit data into disk print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 2000 sleep 4000
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
print ================== server restart completed print ================== server restart completed

View File

@ -238,3 +238,5 @@ sql show databases
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -39,4 +39,4 @@ sql alter table tb1 set tag len = 379
# test end # test end
sql drop database $db sql drop database $db
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -1,6 +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 dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c walLevel -v 0
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2
@ -96,25 +94,25 @@ $ts1 = $ts0 + 1000
$ts2 = $ts0 + 2000 $ts2 = $ts0 + 2000
sql insert into tb_1 using $stb tags (-1) values ( $ts1 , 1,1,1,1,'bin',1,1,1,'涛思数据') ( $ts2 , 2,2,2,2,'binar', 1,1,1,'nchar') sql insert into tb_1 using $stb tags (-1) values ( $ts1 , 1,1,1,1,'bin',1,1,1,'涛思数据') ( $ts2 , 2,2,2,2,'binar', 1,1,1,'nchar')
sql select * from $stb sql select * from $stb
if $rows != 3 then if $rows != 5 then
return -1 return -1
endi endi
if $data19 != 涛思数据 then if $data09 != 涛思数据 then
return -1 return -1
endi endi
if $data11 != 1 then if $data01 != 1 then
return -1 return -1
endi endi
if $data22 != 2 then if $data42 != 2 then
return -2 return -2
endi endi
if $data23 != 2.00000 then if $data43 != 2.00000 then
return -1 return -1
endi endi
if $data25 != binar then if $data45 != binar then
return -1 return -1
endi endi
if $data29 != nchar then if $data49 != nchar then
return -1 return -1
endi endi
sql drop table tb_1 sql drop table tb_1
@ -127,22 +125,22 @@ sql select * from $stb
if $rows != 5 then if $rows != 5 then
return -1 return -1
endi endi
if $data19 != 涛思数据 then if $data09 != 涛思数据 then
return -1 return -1
endi endi
if $data11 != 1 then if $data01 != 1 then
return -1 return -1
endi endi
if $data22 != 2 then if $data42 != 2 then
return -2 return -2
endi endi
if $data23 != 2.00000 then if $data43 != 2.00000 then
return -1 return -1
endi endi
if $data25 != binar then if $data45 != binar then
return -1 return -1
endi endi
if $data29 != nchar then if $data49 != nchar then
return -1 return -1
endi endi
@ -154,13 +152,13 @@ sql show tables
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data00 != tb3 then if $data00 != tb1 then
return -1 return -1
endi endi
if $data10 != tb2 then if $data10 != tb2 then
return -1 return -1
endi endi
if $data20 != tb1 then if $data20 != tb3 then
return -1 return -1
endi endi
@ -222,13 +220,13 @@ sql show tables
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data00 != tb3 then if $data00 != tb1 then
return -1 return -1
endi endi
if $data10 != tb2 then if $data10 != tb2 then
return -1 return -1
endi endi
if $data20 != tb1 then if $data20 != tb3 then
return -1 return -1
endi endi
@ -301,6 +299,9 @@ sql_error create table txu using tu tags(0) values(now, 1);
#[TBASE-675] #[TBASE-675]
sql insert into tu values(1565971200000, 1) (1565971200000,2) (1565971200001, 3)(1565971200001, 4) sql insert into tu values(1565971200000, 1) (1565971200000,2) (1565971200001, 3)(1565971200001, 4)
sql select * from tu
if $rows != 2 then if $rows != 2 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -1,8 +1,7 @@
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c commitTime -v 30 system sh/cfg.sh -n dnode1 -c ctime -v 30
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
sql connect sql connect
@ -22,7 +21,7 @@ $stb = $stbPrefix . $i
sql drop database $db -x step1 sql drop database $db -x step1
step1: step1:
sql create database $db maxrows 200 cache 2048 maxTables 4 sql create database $db maxrows 200 cache 2 maxTables 4
print ====== create tables print ====== create tables
sql use $db sql use $db
@ -81,3 +80,5 @@ while $x < 100
$x = $x + 1 $x = $x + 1
print loop $x print loop $x
endw endw
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -95,9 +95,4 @@ if $data41 != @udp005@ then
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -42,4 +42,3 @@ sql select st1.ts, st1.f1, st2.f2 from db.st1, db.st2 where st1.t1=st2.t2 and st
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select st1.ts, st1.f1, st2.f2 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts' 127.0.0.1:6020/restful/sql system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select st1.ts, st1.f1, st2.f2 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts' 127.0.0.1:6020/restful/sql
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -90,3 +90,5 @@ endi
#### illegal operations #### illegal operations
sql_error select max(c2*2) from $tb sql_error select max(c2*2) from $tb
sql_error select max(c1-c2) from $tb sql_error select max(c1-c2) from $tb
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -22,15 +22,5 @@ run general/parser/columnValue_bigint.sim
run general/parser/columnValue_float.sim run general/parser/columnValue_float.sim
run general/parser/columnValue_double.sim run general/parser/columnValue_double.sim
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -107,3 +107,5 @@ while $loop <= $loops
endi endi
$loop = $loop + 1 $loop = $loop + 1
endw endw
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -188,3 +188,5 @@ sql show databases
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -258,3 +258,5 @@ sql show databases
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -188,3 +188,5 @@ sql show databases
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -127,5 +127,4 @@ if $rows != 7 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -849,3 +849,5 @@ sql show databases
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -430,3 +430,5 @@ sql show databases
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -83,3 +83,4 @@ sleep 3000
run general/parser/first_last_query.sim run general/parser/first_last_query.sim
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -407,3 +407,5 @@ endi
if $data97 != @group_tb0@ then if $data97 != @group_tb0@ then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -2,7 +2,7 @@ system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c commitTime -v 30 system sh/cfg.sh -n dnode1 -c ctime -v 30
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
sql connect sql connect
@ -53,3 +53,4 @@ if $data00 != $res then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -2,7 +2,7 @@ system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c commitTime -v 30 system sh/cfg.sh -n dnode1 -c ctime -v 30
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
sql connect sql connect
@ -52,3 +52,4 @@ if $data00 != $res then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -2,7 +2,7 @@ system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c commitTime -v 30 system sh/cfg.sh -n dnode1 -c ctime -v 30
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
sql connect sql connect
@ -59,3 +59,4 @@ if $data00 != $res then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -35,3 +35,5 @@ endi
#system rm -f $inFileName # invalid shell #system rm -f $inFileName # invalid shell
system rm -f ~/data.csv system rm -f ~/data.csv
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -233,3 +233,4 @@ endi
#endi #endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -65,3 +65,5 @@ system sh/exec.sh -n dnode1 -s start
print ================== server restart completed print ================== server restart completed
run general/parser/interp_test.sim run general/parser/interp_test.sim
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -444,3 +444,5 @@ sql insert into um1 using m2 tags(1) values(1000001, 10)(2000000, 20);
sql insert into um2 using m2 tags(9) values(1000001, 10)(2000000, 20); sql insert into um2 using m2 tags(9) values(1000001, 10)(2000000, 20);
sql_error select count(*) from m1,m2 where m1.a=m2.a and m1.ts=m2.ts; sql_error select count(*) from m1,m2 where m1.a=m2.a and m1.ts=m2.ts;
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -128,3 +128,5 @@ sql select join_mt0.ts, join_mt1.t1 from join_mt0, join_mt1 where join_mt0.ts=jo
sql select join_mt0.ts, join_mt1.t1, join_mt0.t1, join_mt1.tbname, join_mt0.tbname from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1 sql select join_mt0.ts, join_mt1.t1, join_mt0.t1, join_mt1.tbname, join_mt0.tbname from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1
sql select join_mt0.ts, join_mt1.t1, join_mt0.t1, join_mt1.tbname, join_mt0.tbname from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1 limit 1 sql select join_mt0.ts, join_mt1.t1, join_mt0.t1, join_mt1.tbname, join_mt0.tbname from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1 limit 1
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -68,3 +68,5 @@ sql connect
sleep 3000 sleep 3000
run general/parser/lastrow_query.sim run general/parser/lastrow_query.sim
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -69,3 +69,5 @@ sleep 3000
run general/parser/limit_tb.sim run general/parser/limit_tb.sim
run general/parser/limit_stb.sim run general/parser/limit_stb.sim
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -67,3 +67,5 @@ print ================== server restart completed
run general/parser/limit1_tb.sim run general/parser/limit1_tb.sim
run general/parser/limit1_stb.sim run general/parser/limit1_stb.sim
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -67,3 +67,5 @@ print ================== server restart completed
run general/parser/limit1_tb.sim run general/parser/limit1_tb.sim
run general/parser/limit1_stb.sim run general/parser/limit1_stb.sim
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -74,3 +74,5 @@ system sh/exec.sh -n dnode1 -s start
print ================== server restart completed print ================== server restart completed
run general/parser/limit2_query.sim run general/parser/limit2_query.sim
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -142,3 +142,5 @@ endi
if $data03 != 319 then if $data03 != 319 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -194,8 +194,10 @@ sql reset query cache
sql select * from $mt where tgcol = '1' sql select * from $mt where tgcol = '1'
step2: step2:
if $rows != 100 then if $rows != 100 then
print expect 100, actual: $rows
return -1 return -1
endi endi
sql select * from $mt where tgcol > '0' sql select * from $mt where tgcol > '0'
#print rows = $rows #print rows = $rows
if $rows != 100 then if $rows != 100 then
@ -308,3 +310,5 @@ endi
# if $rows != 0 then # if $rows != 0 then
# return -1 # return -1
# endi # endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -488,3 +488,4 @@ sql_error alter table st51 set tag tag_tinyint = abc379
#sql drop database $db #sql drop database $db
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -375,4 +375,4 @@ sql_error select 'abc';
#=============================tbase-1205 #=============================tbase-1205
sql select count(*) from tm1 where ts<now and ts>= now -1d interval(1h) fill(NULL); sql select count(*) from tm1 where ts<now and ts>= now -1d interval(1h) fill(NULL);
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -5,3 +5,5 @@ while $i <= $loops
run general/parser/alter.sim run general/parser/alter.sim
$i = $i + 1 $i = $i + 1
endw endw
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -5,3 +5,5 @@ while $i <= $repeats
run general/parser/stream.sim run general/parser/stream.sim
$i = $i + 1 $i = $i + 1
endw endw
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -182,3 +182,5 @@ while $loop <= $loops
endw endw
$loop = $loop + 1 $loop = $loop + 1
endw endw
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -80,3 +80,5 @@ sql show databases
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -68,3 +68,5 @@ endi
if $data12 != 1 then if $data12 != 1 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -838,3 +838,5 @@ sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group
#sql select first(ts), tbname from select_tags_mt0 group by tbname; #sql select first(ts), tbname from select_tags_mt0 group by tbname;
#sql select count(c1) from select_tags_mt0 where c1=99 group by tbname; #sql select count(c1) from select_tags_mt0 where c1=99 group by tbname;
#sql select count(*),tbname from select_tags_mt0 group by tbname #sql select count(*),tbname from select_tags_mt0 group by tbname
system sh/exec.sh -n dnode1 -s stop -x SIGINT

Some files were not shown because too many files have changed in this diff Show More