Merge branch '3.0' of github.com:taosdata/TDengine into szhou/feature/multi-tb-merge-scan

This commit is contained in:
slzhou 2022-06-15 16:14:07 +08:00
commit e60425b4a4
112 changed files with 2435 additions and 958 deletions

3
.gitmodules vendored
View File

@ -16,3 +16,6 @@
[submodule "tools/taos-tools"] [submodule "tools/taos-tools"]
path = tools/taos-tools path = tools/taos-tools
url = https://github.com/taosdata/taos-tools url = https://github.com/taosdata/taos-tools
[submodule "tools/taosadapter"]
path = tools/taosadapter
url = https://github.com/taosdata/taosadapter.git

View File

@ -38,6 +38,7 @@ def pre_test(){
sh ''' sh '''
hostname hostname
date date
env
''' '''
sh ''' sh '''
cd ${WK} cd ${WK}
@ -82,23 +83,33 @@ def pre_test(){
sh ''' sh '''
cd ${WKC} cd ${WKC}
git pull >/dev/null git pull >/dev/null
git log -5
echo "`date "+%Y%m%d-%H%M%S"` ${JOB_NAME}:${BRANCH_NAME}:${BUILD_ID}:${CHANGE_TARGET}" >>${WKDIR}/jenkins.log
echo "community log: `git log -5`" >>${WKDIR}/jenkins.log
git fetch origin +refs/pull/${CHANGE_ID}/merge git fetch origin +refs/pull/${CHANGE_ID}/merge
git checkout -qf FETCH_HEAD git checkout -qf FETCH_HEAD
git log -5 git log -5
echo "community log merged: `git log -5`" >>${WKDIR}/jenkins.log
cd ${WK} cd ${WK}
git pull >/dev/null git pull >/dev/null
git log -5 git log -5
echo "tdinternal log: `git log -5`" >>${WKDIR}/jenkins.log
''' '''
} else if (env.CHANGE_URL =~ /\/TDinternal\//) { } else if (env.CHANGE_URL =~ /\/TDinternal\//) {
sh ''' sh '''
cd ${WK} cd ${WK}
git pull >/dev/null git pull >/dev/null
git log -5
echo "`date "+%Y%m%d-%H%M%S"` ${JOB_NAME}:${BRANCH_NAME}:${BUILD_ID}:${CHANGE_TARGET}" >>${WKDIR}/jenkins.log
echo "tdinternal log: `git log -5`" >>${WKDIR}/jenkins.log
git fetch origin +refs/pull/${CHANGE_ID}/merge git fetch origin +refs/pull/${CHANGE_ID}/merge
git checkout -qf FETCH_HEAD git checkout -qf FETCH_HEAD
git log -5 git log -5
echo "tdinternal log merged: `git log -5`" >>${WKDIR}/jenkins.log
cd ${WKC} cd ${WKC}
git pull >/dev/null git pull >/dev/null
git log -5 git log -5
echo "community log: `git log -5`" >>${WKDIR}/jenkins.log
''' '''
} else { } else {
sh ''' sh '''
@ -113,6 +124,9 @@ def pre_test(){
cd ${WKPY} cd ${WKPY}
git reset --hard git reset --hard
git pull git pull
git log -5
echo "python connector log: `git log -5`" >>${WKDIR}/jenkins.log
echo >>${WKDIR}/jenkins.log
''' '''
return 1 return 1
} }

View File

@ -18,6 +18,33 @@ if (NOT DEFINED TD_GRANT)
SET(TD_GRANT FALSE) SET(TD_GRANT FALSE)
endif() endif()
IF ("${BUILD_HTTP}" STREQUAL "")
IF (TD_LINUX)
IF (TD_ARM_32)
SET(TD_BUILD_HTTP TRUE)
ELSE ()
SET(TD_BUILD_HTTP TRUE)
ENDIF ()
ELSEIF (TD_DARWIN)
SET(TD_BUILD_HTTP TRUE)
ELSE ()
SET(TD_BUILD_HTTP TRUE)
ENDIF ()
ELSEIF (${BUILD_HTTP} MATCHES "false")
SET(TD_BUILD_HTTP FALSE)
ELSEIF (${BUILD_HTTP} MATCHES "true")
SET(TD_BUILD_HTTP TRUE)
ELSEIF (${BUILD_HTTP} MATCHES "internal")
SET(TD_BUILD_HTTP FALSE)
SET(TD_BUILD_TAOSA_INTERNAL TRUE)
ELSE ()
SET(TD_BUILD_HTTP TRUE)
ENDIF ()
IF (TD_BUILD_HTTP)
ADD_DEFINITIONS(-DHTTP_EMBEDDED)
ENDIF ()
IF ("${BUILD_TOOLS}" STREQUAL "") IF ("${BUILD_TOOLS}" STREQUAL "")
IF (TD_LINUX) IF (TD_LINUX)
IF (TD_ARM_32) IF (TD_ARM_32)

View File

@ -1134,11 +1134,11 @@ void tFreeSMAlterStbRsp(SMAlterStbRsp* pRsp);
int32_t tSerializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp); int32_t tSerializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
int32_t tDeserializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp); int32_t tDeserializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
void tFreeSTableMetaRsp(STableMetaRsp* pRsp); void tFreeSTableMetaRsp(STableMetaRsp* pRsp);
void tFreeSTableIndexRsp(void *info); void tFreeSTableIndexRsp(void* info);
typedef struct { typedef struct {
SArray* pMetaRsp; // Array of STableMetaRsp SArray* pMetaRsp; // Array of STableMetaRsp
SArray* pIndexRsp; // Array of STableIndexRsp; SArray* pIndexRsp; // Array of STableIndexRsp;
} SSTbHbRsp; } SSTbHbRsp;
int32_t tSerializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp); int32_t tSerializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp);
@ -1305,8 +1305,9 @@ int32_t tSerializeSSetStandbyReq(void* buf, int32_t bufLen, SSetStandbyReq* pReq
int32_t tDeserializeSSetStandbyReq(void* buf, int32_t bufLen, SSetStandbyReq* pReq); int32_t tDeserializeSSetStandbyReq(void* buf, int32_t bufLen, SSetStandbyReq* pReq);
typedef struct { typedef struct {
int32_t connId; int32_t connId; // todo remove
int32_t queryId; int32_t queryId; // todo remove
char queryStrId[TSDB_QUERY_ID_LEN];
} SKillQueryReq; } SKillQueryReq;
int32_t tSerializeSKillQueryReq(void* buf, int32_t bufLen, SKillQueryReq* pReq); int32_t tSerializeSKillQueryReq(void* buf, int32_t bufLen, SKillQueryReq* pReq);

View File

@ -78,7 +78,7 @@
#define TK_BUFFER 60 #define TK_BUFFER 60
#define TK_CACHELAST 61 #define TK_CACHELAST 61
#define TK_COMP 62 #define TK_COMP 62
#define TK_DAYS 63 #define TK_DURATION 63
#define TK_NK_VARIABLE 64 #define TK_NK_VARIABLE 64
#define TK_FSYNC 65 #define TK_FSYNC 65
#define TK_MAXROWS 66 #define TK_MAXROWS 66

View File

@ -89,6 +89,7 @@ typedef struct STableOptions {
ENodeType type; ENodeType type;
char comment[TSDB_TB_COMMENT_LEN]; char comment[TSDB_TB_COMMENT_LEN];
double filesFactor; double filesFactor;
int32_t delay;
SNodeList* pRollupFuncs; SNodeList* pRollupFuncs;
int32_t ttl; int32_t ttl;
SNodeList* pSma; SNodeList* pSma;
@ -286,6 +287,11 @@ typedef struct SKillStmt {
int32_t targetId; int32_t targetId;
} SKillStmt; } SKillStmt;
typedef struct SKillQueryStmt {
ENodeType type;
char queryId[TSDB_QUERY_ID_LEN];
} SKillQueryStmt;
typedef struct SStreamOptions { typedef struct SStreamOptions {
ENodeType type; ENodeType type;
int8_t triggerType; int8_t triggerType;

View File

@ -204,6 +204,7 @@ typedef enum ENodeType {
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN,
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN,
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN, QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN,
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN,
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN,
QUERY_NODE_PHYSICAL_PLAN_PROJECT, QUERY_NODE_PHYSICAL_PLAN_PROJECT,

View File

@ -34,7 +34,13 @@ typedef struct SLogicNode {
uint8_t precision; uint8_t precision;
} SLogicNode; } SLogicNode;
typedef enum EScanType { SCAN_TYPE_TAG = 1, SCAN_TYPE_TABLE, SCAN_TYPE_SYSTEM_TABLE, SCAN_TYPE_STREAM } EScanType; typedef enum EScanType {
SCAN_TYPE_TAG = 1,
SCAN_TYPE_TABLE,
SCAN_TYPE_SYSTEM_TABLE,
SCAN_TYPE_STREAM,
SCAN_TYPE_TABLE_MERGE
} EScanType;
typedef struct SScanLogicNode { typedef struct SScanLogicNode {
SLogicNode node; SLogicNode node;
@ -262,6 +268,7 @@ typedef struct STableScanPhysiNode {
} STableScanPhysiNode; } STableScanPhysiNode;
typedef STableScanPhysiNode STableSeqScanPhysiNode; typedef STableScanPhysiNode STableSeqScanPhysiNode;
typedef STableScanPhysiNode STableMergeScanPhysiNode;
typedef STableScanPhysiNode SStreamScanPhysiNode; typedef STableScanPhysiNode SStreamScanPhysiNode;
typedef struct SProjectPhysiNode { typedef struct SProjectPhysiNode {

View File

@ -702,6 +702,7 @@ int32_t* taosGetErrno();
//index //index
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200) #define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -222,6 +222,8 @@ typedef enum ELogicConditionType {
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN #define TSDB_APP_NAME_LEN TSDB_UNI_LEN
#define TSDB_TB_COMMENT_LEN 1025 #define TSDB_TB_COMMENT_LEN 1025
#define TSDB_QUERY_ID_LEN 26
/** /**
* In some scenarios uint16_t (0~65535) is used to store the row len. * In some scenarios uint16_t (0~65535) is used to store the row len.
* - Firstly, we use 65531(65535 - 4), as the SDataRow/SKVRow contains 4 bits header. * - Firstly, we use 65531(65535 - 4), as the SDataRow/SKVRow contains 4 bits header.
@ -341,6 +343,9 @@ typedef enum ELogicConditionType {
#define TSDB_DB_SCHEMALESS_OFF 0 #define TSDB_DB_SCHEMALESS_OFF 0
#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF #define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF
// #define TSDB_MIN_ROLLUP_DELAY 1
// #define TSDB_MAX_ROLLUP_DELAY 10
// #define TSDB_DEFAULT_ROLLUP_DELAY 1
#define TSDB_MIN_ROLLUP_FILE_FACTOR 0 #define TSDB_MIN_ROLLUP_FILE_FACTOR 0
#define TSDB_MAX_ROLLUP_FILE_FACTOR 10 #define TSDB_MAX_ROLLUP_FILE_FACTOR 10
#define TSDB_DEFAULT_ROLLUP_FILE_FACTOR 0.1 #define TSDB_DEFAULT_ROLLUP_FILE_FACTOR 0.1

View File

@ -2355,34 +2355,34 @@ static int smlProcess(SSmlHandle *info, char *lines[], int numLines) {
} }
static int32_t isSchemalessDb(STscObj *taos, SRequestObj *request) { static int32_t isSchemalessDb(STscObj *taos, SRequestObj *request) {
SCatalog *catalog = NULL; // SCatalog *catalog = NULL;
int32_t code = catalogGetHandle(((STscObj *)taos)->pAppInfo->clusterId, &catalog); // int32_t code = catalogGetHandle(((STscObj *)taos)->pAppInfo->clusterId, &catalog);
if (code != TSDB_CODE_SUCCESS) { // if (code != TSDB_CODE_SUCCESS) {
uError("SML get catalog error %d", code); // uError("SML get catalog error %d", code);
return code; // return code;
} // }
//
SName name; // SName name;
tNameSetDbName(&name, taos->acctId, taos->db, strlen(taos->db)); // tNameSetDbName(&name, taos->acctId, taos->db, strlen(taos->db));
char dbFname[TSDB_DB_FNAME_LEN] = {0}; // char dbFname[TSDB_DB_FNAME_LEN] = {0};
tNameGetFullDbName(&name, dbFname); // tNameGetFullDbName(&name, dbFname);
SDbCfgInfo pInfo = {0}; // SDbCfgInfo pInfo = {0};
//
SRequestConnInfo conn = {0}; // SRequestConnInfo conn = {0};
conn.pTrans = taos->pAppInfo->pTransporter; // conn.pTrans = taos->pAppInfo->pTransporter;
conn.requestId = request->requestId; // conn.requestId = request->requestId;
conn.requestObjRefId = request->self; // conn.requestObjRefId = request->self;
conn.mgmtEps = getEpSet_s(&taos->pAppInfo->mgmtEp); // conn.mgmtEps = getEpSet_s(&taos->pAppInfo->mgmtEp);
//
code = catalogGetDBCfg(catalog, &conn, dbFname, &pInfo); // code = catalogGetDBCfg(catalog, &conn, dbFname, &pInfo);
if (code != TSDB_CODE_SUCCESS) { // if (code != TSDB_CODE_SUCCESS) {
return code; // return code;
} // }
taosArrayDestroy(pInfo.pRetensions); // taosArrayDestroy(pInfo.pRetensions);
//
if (!pInfo.schemaless) { // if (!pInfo.schemaless) {
return TSDB_CODE_SML_INVALID_DB_CONF; // return TSDB_CODE_SML_INVALID_DB_CONF;
} // }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }

View File

@ -91,8 +91,8 @@ static const SSysDbTableSchema userDBSchema[] = {
{.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "single_stable_model", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, {.name = "single_stable_model", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
// {.name = "schemaless", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, // {.name = "schemaless", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
{.name = "retension", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "retention", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
// {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update // {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update
}; };
@ -137,7 +137,7 @@ static const SSysDbTableSchema streamSchema[] = {
{.name = "target_table", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "target_table", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "watermark", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, {.name = "watermark", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
{.name = "trigger", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "trigger", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
}; };
static const SSysDbTableSchema userTblsSchema[] = { static const SSysDbTableSchema userTblsSchema[] = {
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
@ -221,7 +221,9 @@ static const SSysDbTableSchema transSchema[] = {
{.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
{.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
{.name = "last_action_info", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "last_action_info",
.bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE,
.type = TSDB_DATA_TYPE_VARCHAR},
}; };
static const SSysDbTableSchema configSchema[] = { static const SSysDbTableSchema configSchema[] = {
@ -314,8 +316,6 @@ static const SSysDbTableSchema querySchema[] = {
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
}; };
static const SSysTableMeta perfsMeta[] = { static const SSysTableMeta perfsMeta[] = {
{TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)}, {TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)},
{TSDB_PERFS_TABLE_QUERIES, querySchema, tListLen(querySchema)}, {TSDB_PERFS_TABLE_QUERIES, querySchema, tListLen(querySchema)},

View File

@ -3369,8 +3369,7 @@ int32_t tSerializeSKillQueryReq(void *buf, int32_t bufLen, SKillQueryReq *pReq)
tEncoderInit(&encoder, buf, bufLen); tEncoderInit(&encoder, buf, bufLen);
if (tStartEncode(&encoder) < 0) return -1; if (tStartEncode(&encoder) < 0) return -1;
if (tEncodeI32(&encoder, pReq->connId) < 0) return -1; if (tEncodeCStr(&encoder, pReq->queryStrId) < 0) return -1;
if (tEncodeI32(&encoder, pReq->queryId) < 0) return -1;
tEndEncode(&encoder); tEndEncode(&encoder);
int32_t tlen = encoder.pos; int32_t tlen = encoder.pos;
@ -3383,8 +3382,7 @@ int32_t tDeserializeSKillQueryReq(void *buf, int32_t bufLen, SKillQueryReq *pReq
tDecoderInit(&decoder, buf, bufLen); tDecoderInit(&decoder, buf, bufLen);
if (tStartDecode(&decoder) < 0) return -1; if (tStartDecode(&decoder) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->connId) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->queryStrId) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->queryId) < 0) return -1;
tEndDecode(&decoder); tEndDecode(&decoder);
tDecoderClear(&decoder); tDecoderClear(&decoder);

View File

@ -183,12 +183,12 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
pDb->cfg.pRetensions = taosArrayInit(pDb->cfg.numOfRetensions, sizeof(SRetention)); pDb->cfg.pRetensions = taosArrayInit(pDb->cfg.numOfRetensions, sizeof(SRetention));
if (pDb->cfg.pRetensions == NULL) goto _OVER; if (pDb->cfg.pRetensions == NULL) goto _OVER;
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) { for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
SRetention retension = {0}; SRetention retention = {0};
SDB_GET_INT64(pRaw, dataPos, &retension.freq, _OVER) SDB_GET_INT64(pRaw, dataPos, &retention.freq, _OVER)
SDB_GET_INT64(pRaw, dataPos, &retension.keep, _OVER) SDB_GET_INT64(pRaw, dataPos, &retention.keep, _OVER)
SDB_GET_INT8(pRaw, dataPos, &retension.freqUnit, _OVER) SDB_GET_INT8(pRaw, dataPos, &retention.freqUnit, _OVER)
SDB_GET_INT8(pRaw, dataPos, &retension.keepUnit, _OVER) SDB_GET_INT8(pRaw, dataPos, &retention.keepUnit, _OVER)
if (taosArrayPush(pDb->cfg.pRetensions, &retension) == NULL) { if (taosArrayPush(pDb->cfg.pRetensions, &retention) == NULL) {
goto _OVER; goto _OVER;
} }
} }
@ -472,7 +472,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
} }
int32_t code = -1; int32_t code = -1;
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB, pReq); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq);
if (pTrans == NULL) goto _OVER; if (pTrans == NULL) goto _OVER;
mDebug("trans:%d, used to create db:%s", pTrans->id, pCreate->db); mDebug("trans:%d, used to create db:%s", pTrans->id, pCreate->db);
@ -1382,7 +1382,7 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
char *status = "ready"; char *status = "ready";
if (objStatus == SDB_STATUS_CREATING) status = "creating"; if (objStatus == SDB_STATUS_CREATING) status = "creating";
if (objStatus == SDB_STATUS_DROPPING) status = "dropping"; if (objStatus == SDB_STATUS_DROPPING) status = "dropping";
char statusB[24] = {0}; char statusB[24] = {0};
STR_WITH_SIZE_TO_VARSTR(statusB, status, strlen(status)); STR_WITH_SIZE_TO_VARSTR(statusB, status, strlen(status));
if (sysDb) { if (sysDb) {

View File

@ -44,6 +44,7 @@ static int32_t mndProcessGetSmaReq(SRpcMsg *pReq);
static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq); static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq);
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
static void mndCancelGetNextSma(SMnode *pMnode, void *pIter); static void mndCancelGetNextSma(SMnode *pMnode, void *pIter);
static void mndDestroySmaObj(SSmaObj *pSmaObj);
int32_t mndInitSma(SMnode *pMnode) { int32_t mndInitSma(SMnode *pMnode) {
SSdbTable table = { SSdbTable table = {
@ -390,7 +391,9 @@ static int32_t mndSetUpdateSmaStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb
taosRLockLatch(&pStb->lock); taosRLockLatch(&pStb->lock);
memcpy(&stbObj, pStb, sizeof(SStbObj)); memcpy(&stbObj, pStb, sizeof(SStbObj));
taosRUnLockLatch(&pStb->lock); taosRUnLockLatch(&pStb->lock);
stbObj.numOfColumns = 0;
stbObj.pColumns = NULL; stbObj.pColumns = NULL;
stbObj.numOfTags = 0;
stbObj.pTags = NULL; stbObj.pTags = NULL;
stbObj.updateTime = taosGetTimestampMs(); stbObj.updateTime = taosGetTimestampMs();
stbObj.lock = 0; stbObj.lock = 0;
@ -404,6 +407,7 @@ static int32_t mndSetUpdateSmaStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb
return 0; return 0;
} }
#if 0
static int32_t mndSetCreateSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) { static int32_t mndSetCreateSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
SVgObj *pVgroup = NULL; SVgObj *pVgroup = NULL;
@ -442,6 +446,7 @@ static int32_t mndSetCreateSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
return 0; return 0;
} }
#endif
static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup,
SSmaObj *pSma) { SSmaObj *pSma) {
@ -501,6 +506,13 @@ static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans,
return 0; return 0;
} }
static void mndDestroySmaObj(SSmaObj *pSmaObj) {
if (pSmaObj) {
taosMemoryFreeClear(pSmaObj->schemaRow.pSchema);
taosMemoryFreeClear(pSmaObj->schemaTag.pSchema);
}
}
static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCreate, SDbObj *pDb, SStbObj *pStb) { static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCreate, SDbObj *pDb, SStbObj *pStb) {
SSmaObj smaObj = {0}; SSmaObj smaObj = {0};
memcpy(smaObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN); memcpy(smaObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN);
@ -524,29 +536,17 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
smaObj.tagsFilterLen = pCreate->tagsFilterLen; smaObj.tagsFilterLen = pCreate->tagsFilterLen;
smaObj.sqlLen = pCreate->sqlLen; smaObj.sqlLen = pCreate->sqlLen;
smaObj.astLen = pCreate->astLen; smaObj.astLen = pCreate->astLen;
if (smaObj.exprLen > 0) { if (smaObj.exprLen > 0) {
smaObj.expr = taosMemoryMalloc(smaObj.exprLen); smaObj.expr = pCreate->expr;
if (smaObj.expr == NULL) goto _OVER;
memcpy(smaObj.expr, pCreate->expr, smaObj.exprLen);
} }
if (smaObj.tagsFilterLen > 0) { if (smaObj.tagsFilterLen > 0) {
smaObj.tagsFilter = taosMemoryMalloc(smaObj.tagsFilterLen); smaObj.tagsFilter = pCreate->tagsFilter;
if (smaObj.tagsFilter == NULL) goto _OVER;
memcpy(smaObj.tagsFilter, pCreate->tagsFilter, smaObj.tagsFilterLen);
} }
if (smaObj.sqlLen > 0) { if (smaObj.sqlLen > 0) {
smaObj.sql = taosMemoryMalloc(smaObj.sqlLen); smaObj.sql = pCreate->sql;
if (smaObj.sql == NULL) goto _OVER;
memcpy(smaObj.sql, pCreate->sql, smaObj.sqlLen);
} }
if (smaObj.astLen > 0) { if (smaObj.astLen > 0) {
smaObj.ast = taosMemoryMalloc(smaObj.astLen); smaObj.ast = pCreate->ast;
if (smaObj.ast == NULL) goto _OVER;
memcpy(smaObj.ast, pCreate->ast, smaObj.astLen);
} }
SStreamObj streamObj = {0}; SStreamObj streamObj = {0};
@ -581,7 +581,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
if (mndSetCreateSmaCommitLogs(pMnode, pTrans, &smaObj) != 0) goto _OVER; if (mndSetCreateSmaCommitLogs(pMnode, pTrans, &smaObj) != 0) goto _OVER;
if (mndSetCreateSmaVgroupCommitLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER; if (mndSetCreateSmaVgroupCommitLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER;
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER; if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER; // if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER;
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER; if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, STREAM_TRIGGER_AT_ONCE, 0, pTrans) != 0) goto _OVER; if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, STREAM_TRIGGER_AT_ONCE, 0, pTrans) != 0) goto _OVER;
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
@ -589,6 +589,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
code = 0; code = 0;
_OVER: _OVER:
mndDestroySmaObj(&smaObj);
mndTransDrop(pTrans); mndTransDrop(pTrans);
return code; return code;
} }
@ -735,6 +736,7 @@ static int32_t mndSetDropSmaVgroupCommitLogs(SMnode *pMnode, STrans *pTrans, SVg
return 0; return 0;
} }
#if 0
static int32_t mndSetDropSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) { static int32_t mndSetDropSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
SVgObj *pVgroup = NULL; SVgObj *pVgroup = NULL;
@ -775,6 +777,7 @@ static int32_t mndSetDropSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
return 0; return 0;
} }
#endif
static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) { static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) {
SVnodeGid *pVgid = pVgroup->vnodeGid + 0; SVnodeGid *pVgid = pVgroup->vnodeGid + 0;
@ -825,7 +828,7 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER; if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER;
if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER; if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER; if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER; // if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER;
if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER; if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER;
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
@ -855,7 +858,7 @@ int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *p
if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER; if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER; if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER;
if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER; if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER;
if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER; // if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER;
mndReleaseVgroup(pMnode, pVgroup); mndReleaseVgroup(pMnode, pVgroup);
pVgroup = NULL; pVgroup = NULL;
} }
@ -1012,7 +1015,6 @@ int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool
rsp->suid = pStb->uid; rsp->suid = pStb->uid;
rsp->version = pStb->smaVer; rsp->version = pStb->smaVer;
mndReleaseStb(pMnode, pStb); mndReleaseStb(pMnode, pStb);
while (1) { while (1) {
pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma); pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma);

View File

@ -323,10 +323,14 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
pOld->smaVer = pNew->smaVer; pOld->smaVer = pNew->smaVer;
pOld->nextColId = pNew->nextColId; pOld->nextColId = pNew->nextColId;
pOld->ttl = pNew->ttl; pOld->ttl = pNew->ttl;
pOld->numOfColumns = pNew->numOfColumns; if (pNew->numOfColumns > 0) {
pOld->numOfTags = pNew->numOfTags; pOld->numOfColumns = pNew->numOfColumns;
memcpy(pOld->pColumns, pNew->pColumns, pOld->numOfColumns * sizeof(SSchema)); memcpy(pOld->pColumns, pNew->pColumns, pOld->numOfColumns * sizeof(SSchema));
memcpy(pOld->pTags, pNew->pTags, pOld->numOfTags * sizeof(SSchema)); }
if (pNew->numOfTags > 0) {
pOld->numOfTags = pNew->numOfTags;
memcpy(pOld->pTags, pNew->pTags, pOld->numOfTags * sizeof(SSchema));
}
if (pNew->commentLen != 0) { if (pNew->commentLen != 0) {
memcpy(pOld->comment, pNew->comment, pNew->commentLen); memcpy(pOld->comment, pNew->comment, pNew->commentLen);
} }

View File

@ -1347,13 +1347,11 @@ int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans) {
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) { for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
STransAction *pAction = taosArrayGet(pArray, i); STransAction *pAction = taosArrayGet(pArray, i);
if (pAction->errCode != 0) { mInfo("trans:%d, %s:%d set processed for kill msg received, errCode from %s to success", pTrans->id,
mInfo("trans:%d, %s:%d set processed for kill msg received, errCode from %s to success", pTrans->id, mndTransStr(pAction->stage), i, tstrerror(pAction->errCode));
mndTransStr(pAction->stage), i, tstrerror(pAction->errCode)); pAction->msgSent = 1;
pAction->msgSent = 1; pAction->msgReceived = 1;
pAction->msgReceived = 1; pAction->errCode = 0;
pAction->errCode = 0;
}
} }
mndTransExecute(pMnode, pTrans); mndTransExecute(pMnode, pTrans);

View File

@ -940,7 +940,7 @@ static int32_t mndAddSetVnodeStandByAction(SMnode *pMnode, STrans *pTrans, SDbOb
action.pCont = pReq; action.pCont = pReq;
action.contLen = contLen; action.contLen = contLen;
action.msgType = TDMT_DND_DROP_VNODE; action.msgType = TDMT_SYNC_SET_VNODE_STANDBY;
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (isRedo) { if (isRedo) {

View File

@ -66,7 +66,13 @@ static int32_t vnodeProcessAlterReplicaReq(SVnode *pVnode, SRpcMsg *pMsg) {
vInfo("vgId:%d, replica:%d %s:%u", TD_VID(pVnode), r, pNode->nodeFqdn, pNode->nodePort); vInfo("vgId:%d, replica:%d %s:%u", TD_VID(pVnode), r, pNode->nodeFqdn, pNode->nodePort);
} }
return syncReconfig(pVnode->sync, &cfg); SRpcMsg rpcMsg = {.info = pMsg->info};
if (syncReconfigBuild(pVnode->sync, &cfg, &rpcMsg) != 0) {
vError("vgId:%d, failed to build reconfig msg since %s", TD_VID(pVnode), terrstr());
return -1;
}
return syncPropose(pVnode->sync, &rpcMsg, false);
} }
void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
@ -241,6 +247,30 @@ static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
} }
int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) {
return 0;
}
int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) {
return 0;
}
int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
return 0;
}
int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void **ppWriter) {
return 0;
}
int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) {
return 0;
}
int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
return 0;
}
static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM)); SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM));
pFsm->data = pVnode; pFsm->data = pVnode;
@ -250,6 +280,14 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
pFsm->FpGetSnapshot = vnodeSyncGetSnapshot; pFsm->FpGetSnapshot = vnodeSyncGetSnapshot;
pFsm->FpRestoreFinishCb = NULL; pFsm->FpRestoreFinishCb = NULL;
pFsm->FpReConfigCb = vnodeSyncReconfig; pFsm->FpReConfigCb = vnodeSyncReconfig;
pFsm->FpSnapshotStartRead = vnodeSnapshotStartRead;
pFsm->FpSnapshotStopRead = vnodeSnapshotStopRead;
pFsm->FpSnapshotDoRead = vnodeSnapshotDoRead;
pFsm->FpSnapshotStartWrite = vnodeSnapshotStartWrite;
pFsm->FpSnapshotStopWrite = vnodeSnapshotStopWrite;
pFsm->FpSnapshotDoWrite = vnodeSnapshotDoWrite;
return pFsm; return pFsm;
} }

View File

@ -1480,14 +1480,6 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
return code; return code;
} }
static int32_t physiStreamScanNodeToJson(const void* pObj, SJson* pJson) {
return physiTableScanNodeToJson(pObj, pJson);
}
static int32_t jsonToPhysiStreamScanNode(const SJson* pJson, void* pObj) {
return jsonToPhysiTableScanNode(pJson, pObj);
}
static const char* jkSysTableScanPhysiPlanMnodeEpSet = "MnodeEpSet"; static const char* jkSysTableScanPhysiPlanMnodeEpSet = "MnodeEpSet";
static const char* jkSysTableScanPhysiPlanShowRewrite = "ShowRewrite"; static const char* jkSysTableScanPhysiPlanShowRewrite = "ShowRewrite";
static const char* jkSysTableScanPhysiPlanAccountId = "AccountId"; static const char* jkSysTableScanPhysiPlanAccountId = "AccountId";
@ -3964,9 +3956,9 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
return physiTagScanNodeToJson(pObj, pJson); return physiTagScanNodeToJson(pObj, pJson);
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
return physiTableScanNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN:
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
return physiStreamScanNodeToJson(pObj, pJson); return physiTableScanNodeToJson(pObj, pJson);
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
return physiSysTableScanNodeToJson(pObj, pJson); return physiSysTableScanNodeToJson(pObj, pJson);
case QUERY_NODE_PHYSICAL_PLAN_PROJECT: case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
@ -4097,9 +4089,9 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
return jsonToPhysiTagScanNode(pJson, pObj); return jsonToPhysiTagScanNode(pJson, pObj);
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
return jsonToPhysiTableScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN:
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
return jsonToPhysiStreamScanNode(pJson, pObj); return jsonToPhysiTableScanNode(pJson, pObj);
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
return jsonToPhysiSysTableScanNode(pJson, pObj); return jsonToPhysiSysTableScanNode(pJson, pObj);
case QUERY_NODE_PHYSICAL_PLAN_PROJECT: case QUERY_NODE_PHYSICAL_PLAN_PROJECT:

View File

@ -209,9 +209,10 @@ SNode* nodesMakeNode(ENodeType type) {
case QUERY_NODE_SHOW_CREATE_STABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
case QUERY_NODE_SHOW_TRANSACTIONS_STMT: case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
return makeNode(type, sizeof(SShowStmt)); return makeNode(type, sizeof(SShowStmt));
case QUERY_NODE_KILL_CONNECTION_STMT:
case QUERY_NODE_KILL_QUERY_STMT: case QUERY_NODE_KILL_QUERY_STMT:
return makeNode(type, sizeof(SKillQueryStmt));
case QUERY_NODE_KILL_TRANSACTION_STMT: case QUERY_NODE_KILL_TRANSACTION_STMT:
case QUERY_NODE_KILL_CONNECTION_STMT:
return makeNode(type, sizeof(SKillStmt)); return makeNode(type, sizeof(SKillStmt));
case QUERY_NODE_DELETE_STMT: case QUERY_NODE_DELETE_STMT:
return makeNode(type, sizeof(SDeleteStmt)); return makeNode(type, sizeof(SDeleteStmt));
@ -251,6 +252,8 @@ SNode* nodesMakeNode(ENodeType type) {
return makeNode(type, sizeof(STableScanPhysiNode)); return makeNode(type, sizeof(STableScanPhysiNode));
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
return makeNode(type, sizeof(STableSeqScanPhysiNode)); return makeNode(type, sizeof(STableSeqScanPhysiNode));
case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN:
return makeNode(type, sizeof(STableMergeScanPhysiNode));
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
return makeNode(type, sizeof(SStreamScanPhysiNode)); return makeNode(type, sizeof(SStreamScanPhysiNode));
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:

View File

@ -60,6 +60,7 @@ typedef enum EDatabaseOptionType {
typedef enum ETableOptionType { typedef enum ETableOptionType {
TABLE_OPTION_COMMENT = 1, TABLE_OPTION_COMMENT = 1,
TABLE_OPTION_FILE_FACTOR, TABLE_OPTION_FILE_FACTOR,
TABLE_OPTION_DELAY,
TABLE_OPTION_ROLLUP, TABLE_OPTION_ROLLUP,
TABLE_OPTION_TTL, TABLE_OPTION_TTL,
TABLE_OPTION_SMA TABLE_OPTION_SMA
@ -187,6 +188,7 @@ SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const
SNode* pOptions, SNode* pQuery); SNode* pOptions, SNode* pQuery);
SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName); SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName);
SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId); SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId);
SNode* createKillQueryStmt(SAstCreateContext* pCxt, const SToken* pQueryId);
SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt); SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt);
SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2); SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2);
SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes); SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes);

View File

@ -168,8 +168,8 @@ db_options(A) ::= .
db_options(A) ::= db_options(B) BUFFER NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BUFFER, &C); } db_options(A) ::= db_options(B) BUFFER NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BUFFER, &C); }
db_options(A) ::= db_options(B) CACHELAST NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHELAST, &C); } db_options(A) ::= db_options(B) CACHELAST NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHELAST, &C); }
db_options(A) ::= db_options(B) COMP NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_COMP, &C); } db_options(A) ::= db_options(B) COMP NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_COMP, &C); }
db_options(A) ::= db_options(B) DAYS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); } db_options(A) ::= db_options(B) DURATION NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); }
db_options(A) ::= db_options(B) DAYS NK_VARIABLE(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); } db_options(A) ::= db_options(B) DURATION NK_VARIABLE(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); }
db_options(A) ::= db_options(B) FSYNC NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_FSYNC, &C); } db_options(A) ::= db_options(B) FSYNC NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_FSYNC, &C); }
db_options(A) ::= db_options(B) MAXROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MAXROWS, &C); } db_options(A) ::= db_options(B) MAXROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MAXROWS, &C); }
db_options(A) ::= db_options(B) MINROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MINROWS, &C); } db_options(A) ::= db_options(B) MINROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MINROWS, &C); }
@ -317,8 +317,9 @@ tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP.
table_options(A) ::= . { A = createDefaultTableOptions(pCxt); } table_options(A) ::= . { A = createDefaultTableOptions(pCxt); }
table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); } table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
//table_options(A) ::= table_options(B) DELAY NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_DELAY, &C); }
table_options(A) ::= table_options(B) FILE_FACTOR NK_FLOAT(C). { A = setTableOption(pCxt, B, TABLE_OPTION_FILE_FACTOR, &C); } table_options(A) ::= table_options(B) FILE_FACTOR NK_FLOAT(C). { A = setTableOption(pCxt, B, TABLE_OPTION_FILE_FACTOR, &C); }
table_options(A) ::= table_options(B) ROLLUP NK_LP func_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_ROLLUP, C); } table_options(A) ::= table_options(B) ROLLUP NK_LP rollup_func_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_ROLLUP, C); }
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); } table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_SMA, C); } table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_SMA, C); }
@ -330,6 +331,15 @@ alter_table_options(A) ::= alter_table_options(B) alter_table_option(C).
alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.val = B; } alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.val = B; }
alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.val = B; } alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.val = B; }
%type rollup_func_list { SNodeList* }
%destructor rollup_func_list { nodesDestroyList($$); }
rollup_func_list(A) ::= rollup_func_name(B). { A = createNodeList(pCxt, B); }
rollup_func_list(A) ::= rollup_func_list(B) NK_COMMA rollup_func_name(C). { A = addNodeToList(pCxt, B, C); }
rollup_func_name(A) ::= function_name(B). { A = createFunctionNode(pCxt, &B, NULL); }
rollup_func_name(A) ::= FIRST(B). { A = createFunctionNode(pCxt, &B, NULL); }
rollup_func_name(A) ::= LAST(B). { A = createFunctionNode(pCxt, &B, NULL); }
%type col_name_list { SNodeList* } %type col_name_list { SNodeList* }
%destructor col_name_list { nodesDestroyList($$); } %destructor col_name_list { nodesDestroyList($$); }
col_name_list(A) ::= col_name(B). { A = createNodeList(pCxt, B); } col_name_list(A) ::= col_name(B). { A = createNodeList(pCxt, B); }
@ -378,13 +388,6 @@ table_name_cond(A) ::= table_name(B).
from_db_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); } from_db_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
from_db_opt(A) ::= FROM db_name(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } from_db_opt(A) ::= FROM db_name(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
%type func_name_list { SNodeList* }
%destructor func_name_list { nodesDestroyList($$); }
func_name_list(A) ::= func_name(B). { A = createNodeList(pCxt, B); }
func_name_list(A) ::= func_name_list(B) NK_COMMA func_name(C). { A = addNodeToList(pCxt, B, C); }
func_name(A) ::= function_name(B). { A = createFunctionNode(pCxt, &B, NULL); }
/************************************************ create index ********************************************************/ /************************************************ create index ********************************************************/
cmd ::= CREATE SMA INDEX not_exists_opt(D) cmd ::= CREATE SMA INDEX not_exists_opt(D)
index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, &A, &B, NULL, C); } index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, &A, &B, NULL, C); }
@ -466,7 +469,7 @@ stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C).
/************************************************ kill connection/query ***********************************************/ /************************************************ kill connection/query ***********************************************/
cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); } cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); }
cmd ::= KILL QUERY NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &A); } cmd ::= KILL QUERY NK_STRING(A). { pCxt->pRootNode = createKillQueryStmt(pCxt, &A); }
cmd ::= KILL TRANSACTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &A); } cmd ::= KILL TRANSACTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &A); }
/************************************************ merge/redistribute/ vgroup ******************************************/ /************************************************ merge/redistribute/ vgroup ******************************************/

View File

@ -804,10 +804,10 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti
case DB_OPTION_RETENTIONS: case DB_OPTION_RETENTIONS:
((SDatabaseOptions*)pOptions)->pRetentions = pVal; ((SDatabaseOptions*)pOptions)->pRetentions = pVal;
break; break;
case DB_OPTION_SCHEMALESS: // case DB_OPTION_SCHEMALESS:
// ((SDatabaseOptions*)pOptions)->schemaless = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); // ((SDatabaseOptions*)pOptions)->schemaless = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
((SDatabaseOptions*)pOptions)->schemaless = 1; // ((SDatabaseOptions*)pOptions)->schemaless = 0;
break; // break;
default: default:
break; break;
} }
@ -867,6 +867,7 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
CHECK_PARSER_STATUS(pCxt); CHECK_PARSER_STATUS(pCxt);
STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
CHECK_OUT_OF_MEM(pOptions); CHECK_OUT_OF_MEM(pOptions);
// pOptions->delay = TSDB_DEFAULT_ROLLUP_DELAY;
pOptions->filesFactor = TSDB_DEFAULT_ROLLUP_FILE_FACTOR; pOptions->filesFactor = TSDB_DEFAULT_ROLLUP_FILE_FACTOR;
pOptions->ttl = TSDB_DEFAULT_TABLE_TTL; pOptions->ttl = TSDB_DEFAULT_TABLE_TTL;
return (SNode*)pOptions; return (SNode*)pOptions;
@ -876,7 +877,7 @@ SNode* createAlterTableOptions(SAstCreateContext* pCxt) {
CHECK_PARSER_STATUS(pCxt); CHECK_PARSER_STATUS(pCxt);
STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
CHECK_OUT_OF_MEM(pOptions); CHECK_OUT_OF_MEM(pOptions);
pOptions->filesFactor = -1; pOptions->delay = -1;
pOptions->ttl = -1; pOptions->ttl = -1;
return (SNode*)pOptions; return (SNode*)pOptions;
} }
@ -890,8 +891,8 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType
sizeof(((STableOptions*)pOptions)->comment)); sizeof(((STableOptions*)pOptions)->comment));
} }
break; break;
case TABLE_OPTION_FILE_FACTOR: case TABLE_OPTION_DELAY:
((STableOptions*)pOptions)->filesFactor = taosStr2Double(((SToken*)pVal)->z, NULL); ((STableOptions*)pOptions)->delay = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
break; break;
case TABLE_OPTION_ROLLUP: case TABLE_OPTION_ROLLUP:
((STableOptions*)pOptions)->pRollupFuncs = pVal; ((STableOptions*)pOptions)->pRollupFuncs = pVal;
@ -1431,7 +1432,7 @@ SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const
CHECK_PARSER_STATUS(pCxt); CHECK_PARSER_STATUS(pCxt);
SDropStreamStmt* pStmt = (SDropStreamStmt*)nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT); SDropStreamStmt* pStmt = (SDropStreamStmt*)nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT);
CHECK_OUT_OF_MEM(pStmt); CHECK_OUT_OF_MEM(pStmt);
strncpy(pStmt->streamName, pStreamName->z, pStreamName->n); strncpy(pStmt->streamName, pStreamName->z, TMIN(pStreamName->n, sizeof(pStmt->streamName) - 1));
pStmt->ignoreNotExists = ignoreNotExists; pStmt->ignoreNotExists = ignoreNotExists;
return (SNode*)pStmt; return (SNode*)pStmt;
} }
@ -1444,6 +1445,14 @@ SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId
return (SNode*)pStmt; return (SNode*)pStmt;
} }
SNode* createKillQueryStmt(SAstCreateContext* pCxt, const SToken* pQueryId) {
CHECK_PARSER_STATUS(pCxt);
SKillQueryStmt* pStmt = (SKillQueryStmt*)nodesMakeNode(QUERY_NODE_KILL_QUERY_STMT);
CHECK_OUT_OF_MEM(pStmt);
strncpy(pStmt->queryId, pQueryId->z, TMIN(pQueryId->n, sizeof(pStmt->queryId) - 1));
return (SNode*)pStmt;
}
SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt) { SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt) {
CHECK_PARSER_STATUS(pCxt); CHECK_PARSER_STATUS(pCxt);
SBalanceVgroupStmt* pStmt = (SBalanceVgroupStmt*)nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_STMT); SBalanceVgroupStmt* pStmt = (SBalanceVgroupStmt*)nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_STMT);

View File

@ -68,7 +68,7 @@ static SKeyword keywordTable[] = {
{"CONTAINS", TK_CONTAINS}, {"CONTAINS", TK_CONTAINS},
{"DATABASE", TK_DATABASE}, {"DATABASE", TK_DATABASE},
{"DATABASES", TK_DATABASES}, {"DATABASES", TK_DATABASES},
{"DAYS", TK_DAYS}, // {"DAYS", TK_DAYS},
{"DBS", TK_DBS}, {"DBS", TK_DBS},
{"DELETE", TK_DELETE}, {"DELETE", TK_DELETE},
{"DESC", TK_DESC}, {"DESC", TK_DESC},
@ -78,6 +78,7 @@ static SKeyword keywordTable[] = {
{"DNODES", TK_DNODES}, {"DNODES", TK_DNODES},
{"DOUBLE", TK_DOUBLE}, {"DOUBLE", TK_DOUBLE},
{"DROP", TK_DROP}, {"DROP", TK_DROP},
{"DURATION", TK_DURATION},
{"EXISTS", TK_EXISTS}, {"EXISTS", TK_EXISTS},
{"EXPLAIN", TK_EXPLAIN}, {"EXPLAIN", TK_EXPLAIN},
{"FILE_FACTOR", TK_FILE_FACTOR}, {"FILE_FACTOR", TK_FILE_FACTOR},

View File

@ -2839,6 +2839,9 @@ static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = checTableFactorOption(pCxt, pStmt->pOptions->filesFactor); code = checTableFactorOption(pCxt, pStmt->pOptions->filesFactor);
} }
// if (TSDB_CODE_SUCCESS == code) {
// code = checkRangeOption(pCxt, "delay", pStmt->pOptions->delay, TSDB_MIN_ROLLUP_DELAY, TSDB_MAX_ROLLUP_DELAY);
// }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = checkTableRollupOption(pCxt, pStmt->pOptions->pRollupFuncs); code = checkTableRollupOption(pCxt, pStmt->pOptions->pRollupFuncs);
} }
@ -3081,6 +3084,7 @@ static int32_t buildRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt,
static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStmt, SMCreateStbReq* pReq) { static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStmt, SMCreateStbReq* pReq) {
pReq->igExists = pStmt->ignoreExists; pReq->igExists = pStmt->ignoreExists;
// pReq->delay = pStmt->pOptions->delay;
pReq->xFilesFactor = pStmt->pOptions->filesFactor; pReq->xFilesFactor = pStmt->pOptions->filesFactor;
pReq->ttl = pStmt->pOptions->ttl; pReq->ttl = pStmt->pOptions->ttl;
columnDefNodeToField(pStmt->pCols, &pReq->pColumns); columnDefNodeToField(pStmt->pCols, &pReq->pColumns);
@ -3626,9 +3630,9 @@ static int32_t translateKillConnection(STranslateContext* pCxt, SKillStmt* pStmt
return buildCmdMsg(pCxt, TDMT_MND_KILL_CONN, (FSerializeFunc)tSerializeSKillQueryReq, &killReq); return buildCmdMsg(pCxt, TDMT_MND_KILL_CONN, (FSerializeFunc)tSerializeSKillQueryReq, &killReq);
} }
static int32_t translateKillQuery(STranslateContext* pCxt, SKillStmt* pStmt) { static int32_t translateKillQuery(STranslateContext* pCxt, SKillQueryStmt* pStmt) {
SKillQueryReq killReq = {0}; SKillQueryReq killReq = {0};
killReq.queryId = pStmt->targetId; strcpy(killReq.queryStrId, pStmt->queryId);
return buildCmdMsg(pCxt, TDMT_MND_KILL_QUERY, (FSerializeFunc)tSerializeSKillQueryReq, &killReq); return buildCmdMsg(pCxt, TDMT_MND_KILL_QUERY, (FSerializeFunc)tSerializeSKillQueryReq, &killReq);
} }
@ -3970,7 +3974,7 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
code = translateKillConnection(pCxt, (SKillStmt*)pNode); code = translateKillConnection(pCxt, (SKillStmt*)pNode);
break; break;
case QUERY_NODE_KILL_QUERY_STMT: case QUERY_NODE_KILL_QUERY_STMT:
code = translateKillQuery(pCxt, (SKillStmt*)pNode); code = translateKillQuery(pCxt, (SKillQueryStmt*)pNode);
break; break;
case QUERY_NODE_KILL_TRANSACTION_STMT: case QUERY_NODE_KILL_TRANSACTION_STMT:
code = translateKillTransaction(pCxt, (SKillStmt*)pNode); code = translateKillTransaction(pCxt, (SKillStmt*)pNode);

View File

@ -564,7 +564,7 @@ static const YYCODETYPE yy_lookahead[] = {
/* 1260 */ 0, 0, 40, 0, 271, 72, 0, 47, 175, 175, /* 1260 */ 0, 0, 40, 0, 271, 72, 0, 47, 175, 175,
/* 1270 */ 47, 47, 279, 310, 47, 0, 313, 314, 315, 316, /* 1270 */ 47, 47, 279, 310, 47, 0, 313, 314, 315, 316,
/* 1280 */ 317, 318, 289, 320, 47, 47, 293, 243, 175, 0, /* 1280 */ 317, 318, 289, 320, 47, 47, 293, 243, 175, 0,
/* 1290 */ 175, 0, 47, 0, 47, 0, 243, 47, 0, 81, /* 1290 */ 175, 0, 47, 0, 22, 0, 243, 47, 0, 81,
/* 1300 */ 113, 160, 156, 310, 159, 0, 313, 314, 315, 316, /* 1300 */ 113, 160, 156, 310, 159, 0, 313, 314, 315, 316,
/* 1310 */ 317, 318, 0, 320, 152, 271, 323, 151, 0, 356, /* 1310 */ 317, 318, 0, 320, 152, 271, 323, 151, 0, 356,
/* 1320 */ 357, 328, 0, 279, 271, 44, 0, 0, 0, 0, /* 1320 */ 357, 328, 0, 279, 271, 44, 0, 0, 0, 0,
@ -693,7 +693,7 @@ static const unsigned short int yy_shift_ofst[] = {
/* 310 */ 929, 931, 826, 875, 934, 952, 962, 965, 974, 976, /* 310 */ 929, 931, 826, 875, 934, 952, 962, 965, 974, 976,
/* 320 */ 859, 935, 1260, 1261, 1222, 1263, 1193, 1266, 1220, 1093, /* 320 */ 859, 935, 1260, 1261, 1222, 1263, 1193, 1266, 1220, 1093,
/* 330 */ 1223, 1224, 1227, 1094, 1275, 1237, 1238, 1113, 1289, 1115, /* 330 */ 1223, 1224, 1227, 1094, 1275, 1237, 1238, 1113, 1289, 1115,
/* 340 */ 1291, 1245, 1293, 1247, 1295, 1250, 1298, 1218, 1141, 1145, /* 340 */ 1291, 1245, 1293, 1272, 1295, 1250, 1298, 1218, 1141, 1145,
/* 350 */ 1187, 1146, 1305, 1312, 1162, 1166, 1318, 1322, 1281, 1326, /* 350 */ 1187, 1146, 1305, 1312, 1162, 1166, 1318, 1322, 1281, 1326,
/* 360 */ 1327, 1328, 1329, 1330, 1331, 1334, 1335, 1336, 1338, 1339, /* 360 */ 1327, 1328, 1329, 1330, 1331, 1334, 1335, 1336, 1338, 1339,
/* 370 */ 1340, 1341, 1343, 1344, 1345, 1347, 1348, 1309, 1351, 1352, /* 370 */ 1340, 1341, 1343, 1344, 1345, 1347, 1348, 1309, 1351, 1352,
@ -898,7 +898,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* BUFFER => nothing */ 0, /* BUFFER => nothing */
0, /* CACHELAST => nothing */ 0, /* CACHELAST => nothing */
0, /* COMP => nothing */ 0, /* COMP => nothing */
0, /* DAYS => nothing */ 0, /* DURATION => nothing */
0, /* NK_VARIABLE => nothing */ 0, /* NK_VARIABLE => nothing */
0, /* FSYNC => nothing */ 0, /* FSYNC => nothing */
0, /* MAXROWS => nothing */ 0, /* MAXROWS => nothing */
@ -1225,7 +1225,7 @@ static const char *const yyTokenName[] = {
/* 60 */ "BUFFER", /* 60 */ "BUFFER",
/* 61 */ "CACHELAST", /* 61 */ "CACHELAST",
/* 62 */ "COMP", /* 62 */ "COMP",
/* 63 */ "DAYS", /* 63 */ "DURATION",
/* 64 */ "NK_VARIABLE", /* 64 */ "NK_VARIABLE",
/* 65 */ "FSYNC", /* 65 */ "FSYNC",
/* 66 */ "MAXROWS", /* 66 */ "MAXROWS",
@ -1600,8 +1600,8 @@ static const char *const yyRuleName[] = {
/* 68 */ "db_options ::= db_options BUFFER NK_INTEGER", /* 68 */ "db_options ::= db_options BUFFER NK_INTEGER",
/* 69 */ "db_options ::= db_options CACHELAST NK_INTEGER", /* 69 */ "db_options ::= db_options CACHELAST NK_INTEGER",
/* 70 */ "db_options ::= db_options COMP NK_INTEGER", /* 70 */ "db_options ::= db_options COMP NK_INTEGER",
/* 71 */ "db_options ::= db_options DAYS NK_INTEGER", /* 71 */ "db_options ::= db_options DURATION NK_INTEGER",
/* 72 */ "db_options ::= db_options DAYS NK_VARIABLE", /* 72 */ "db_options ::= db_options DURATION NK_VARIABLE",
/* 73 */ "db_options ::= db_options FSYNC NK_INTEGER", /* 73 */ "db_options ::= db_options FSYNC NK_INTEGER",
/* 74 */ "db_options ::= db_options MAXROWS NK_INTEGER", /* 74 */ "db_options ::= db_options MAXROWS NK_INTEGER",
/* 75 */ "db_options ::= db_options MINROWS NK_INTEGER", /* 75 */ "db_options ::= db_options MINROWS NK_INTEGER",
@ -1783,7 +1783,7 @@ static const char *const yyRuleName[] = {
/* 251 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", /* 251 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal",
/* 252 */ "stream_options ::= stream_options WATERMARK duration_literal", /* 252 */ "stream_options ::= stream_options WATERMARK duration_literal",
/* 253 */ "cmd ::= KILL CONNECTION NK_INTEGER", /* 253 */ "cmd ::= KILL CONNECTION NK_INTEGER",
/* 254 */ "cmd ::= KILL QUERY NK_INTEGER", /* 254 */ "cmd ::= KILL QUERY NK_STRING",
/* 255 */ "cmd ::= KILL TRANSACTION NK_INTEGER", /* 255 */ "cmd ::= KILL TRANSACTION NK_INTEGER",
/* 256 */ "cmd ::= BALANCE VGROUP", /* 256 */ "cmd ::= BALANCE VGROUP",
/* 257 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", /* 257 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER",
@ -2646,8 +2646,8 @@ static const struct {
{ 254, -3 }, /* (68) db_options ::= db_options BUFFER NK_INTEGER */ { 254, -3 }, /* (68) db_options ::= db_options BUFFER NK_INTEGER */
{ 254, -3 }, /* (69) db_options ::= db_options CACHELAST NK_INTEGER */ { 254, -3 }, /* (69) db_options ::= db_options CACHELAST NK_INTEGER */
{ 254, -3 }, /* (70) db_options ::= db_options COMP NK_INTEGER */ { 254, -3 }, /* (70) db_options ::= db_options COMP NK_INTEGER */
{ 254, -3 }, /* (71) db_options ::= db_options DAYS NK_INTEGER */ { 254, -3 }, /* (71) db_options ::= db_options DURATION NK_INTEGER */
{ 254, -3 }, /* (72) db_options ::= db_options DAYS NK_VARIABLE */ { 254, -3 }, /* (72) db_options ::= db_options DURATION NK_VARIABLE */
{ 254, -3 }, /* (73) db_options ::= db_options FSYNC NK_INTEGER */ { 254, -3 }, /* (73) db_options ::= db_options FSYNC NK_INTEGER */
{ 254, -3 }, /* (74) db_options ::= db_options MAXROWS NK_INTEGER */ { 254, -3 }, /* (74) db_options ::= db_options MAXROWS NK_INTEGER */
{ 254, -3 }, /* (75) db_options ::= db_options MINROWS NK_INTEGER */ { 254, -3 }, /* (75) db_options ::= db_options MINROWS NK_INTEGER */
@ -2829,7 +2829,7 @@ static const struct {
{ 305, -4 }, /* (251) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ { 305, -4 }, /* (251) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */
{ 305, -3 }, /* (252) stream_options ::= stream_options WATERMARK duration_literal */ { 305, -3 }, /* (252) stream_options ::= stream_options WATERMARK duration_literal */
{ 240, -3 }, /* (253) cmd ::= KILL CONNECTION NK_INTEGER */ { 240, -3 }, /* (253) cmd ::= KILL CONNECTION NK_INTEGER */
{ 240, -3 }, /* (254) cmd ::= KILL QUERY NK_INTEGER */ { 240, -3 }, /* (254) cmd ::= KILL QUERY NK_STRING */
{ 240, -3 }, /* (255) cmd ::= KILL TRANSACTION NK_INTEGER */ { 240, -3 }, /* (255) cmd ::= KILL TRANSACTION NK_INTEGER */
{ 240, -2 }, /* (256) cmd ::= BALANCE VGROUP */ { 240, -2 }, /* (256) cmd ::= BALANCE VGROUP */
{ 240, -4 }, /* (257) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { 240, -4 }, /* (257) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
@ -3326,8 +3326,8 @@ static YYACTIONTYPE yy_reduce(
{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_COMP, &yymsp[0].minor.yy0); } { yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_COMP, &yymsp[0].minor.yy0); }
yymsp[-2].minor.yy632 = yylhsminor.yy632; yymsp[-2].minor.yy632 = yylhsminor.yy632;
break; break;
case 71: /* db_options ::= db_options DAYS NK_INTEGER */ case 71: /* db_options ::= db_options DURATION NK_INTEGER */
case 72: /* db_options ::= db_options DAYS NK_VARIABLE */ yytestcase(yyruleno==72); case 72: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==72);
{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } { yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_DAYS, &yymsp[0].minor.yy0); }
yymsp[-2].minor.yy632 = yylhsminor.yy632; yymsp[-2].minor.yy632 = yylhsminor.yy632;
break; break;
@ -3907,8 +3907,8 @@ static YYACTIONTYPE yy_reduce(
case 253: /* cmd ::= KILL CONNECTION NK_INTEGER */ case 253: /* cmd ::= KILL CONNECTION NK_INTEGER */
{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); }
break; break;
case 254: /* cmd ::= KILL QUERY NK_INTEGER */ case 254: /* cmd ::= KILL QUERY NK_STRING */
{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &yymsp[0].minor.yy0); } { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); }
break; break;
case 255: /* cmd ::= KILL TRANSACTION NK_INTEGER */ case 255: /* cmd ::= KILL TRANSACTION NK_INTEGER */
{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); }

View File

@ -46,7 +46,7 @@ TEST_F(ParserInitialCTest, createBnode) {
* BUFFER value * BUFFER value
* | CACHELAST value * | CACHELAST value
* | COMP {0 | 1 | 2} * | COMP {0 | 1 | 2}
* | DAYS value * | DURATION value
* | FSYNC value * | FSYNC value
* | MAXROWS value * | MAXROWS value
* | MINROWS value * | MINROWS value
@ -155,7 +155,7 @@ TEST_F(ParserInitialCTest, createDatabase) {
ASSERT_EQ(req.replications, expect.replications); ASSERT_EQ(req.replications, expect.replications);
ASSERT_EQ(req.strict, expect.strict); ASSERT_EQ(req.strict, expect.strict);
ASSERT_EQ(req.cacheLastRow, expect.cacheLastRow); ASSERT_EQ(req.cacheLastRow, expect.cacheLastRow);
ASSERT_EQ(req.schemaless, expect.schemaless); // ASSERT_EQ(req.schemaless, expect.schemaless);
ASSERT_EQ(req.ignoreExist, expect.ignoreExist); ASSERT_EQ(req.ignoreExist, expect.ignoreExist);
ASSERT_EQ(req.numOfRetensions, expect.numOfRetensions); ASSERT_EQ(req.numOfRetensions, expect.numOfRetensions);
if (expect.numOfRetensions > 0) { if (expect.numOfRetensions > 0) {
@ -202,7 +202,7 @@ TEST_F(ParserInitialCTest, createDatabase) {
"BUFFER 64 " "BUFFER 64 "
"CACHELAST 2 " "CACHELAST 2 "
"COMP 1 " "COMP 1 "
"DAYS 100 " "DURATION 100 "
"FSYNC 100 " "FSYNC 100 "
"MAXROWS 1000 " "MAXROWS 1000 "
"MINROWS 100 " "MINROWS 100 "
@ -223,7 +223,7 @@ TEST_F(ParserInitialCTest, createDatabase) {
setDbDaysFunc(100); setDbDaysFunc(100);
setDbKeepFunc(1440, 300 * 60, 400 * 1440); setDbKeepFunc(1440, 300 * 60, 400 * 1440);
run("CREATE DATABASE IF NOT EXISTS wxy_db " run("CREATE DATABASE IF NOT EXISTS wxy_db "
"DAYS 100m " "DURATION 100m "
"KEEP 1440m,300h,400d "); "KEEP 1440m,300h,400d ");
clearCreateDbReq(); clearCreateDbReq();
} }

View File

@ -181,7 +181,7 @@ static int16_t getUnsetSlotId(const SArray* pSlotIdsInfo) {
} }
static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc, static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc,
const char* pStmtName, bool output, bool reserve) { const char* pStmtName, bool output, bool reserve) {
if (NULL == pList) { if (NULL == pList) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -463,10 +463,25 @@ static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubpla
return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pTagScan, pPhyNode); return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pTagScan, pPhyNode);
} }
static ENodeType getScanOperatorType(EScanType scanType) {
switch (scanType) {
case SCAN_TYPE_TABLE:
return QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
case SCAN_TYPE_STREAM:
return QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
case SCAN_TYPE_TABLE_MERGE:
return QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
// return QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN;
default:
break;
}
return QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
}
static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
SPhysiNode** pPhyNode) { SPhysiNode** pPhyNode) {
STableScanPhysiNode* pTableScan = STableScanPhysiNode* pTableScan = (STableScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode,
(STableScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN); getScanOperatorType(pScanLogicNode->scanType));
if (NULL == pTableScan) { if (NULL == pTableScan) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
@ -528,12 +543,12 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
static int32_t createStreamScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, static int32_t createStreamScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
SPhysiNode** pPhyNode) { SPhysiNode** pPhyNode) {
int32_t res = createTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); return createTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode);
if (res == TSDB_CODE_SUCCESS) { }
ENodeType type = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
setNodeType(*pPhyNode, type); static int32_t createTableMergeScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
} SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
return res; return createTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode);
} }
static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
@ -547,6 +562,8 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
return createSystemTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); return createSystemTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode);
case SCAN_TYPE_STREAM: case SCAN_TYPE_STREAM:
return createStreamScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); return createStreamScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode);
case SCAN_TYPE_TABLE_MERGE:
return createTableMergeScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode);
default: default:
break; break;
} }

View File

@ -15,6 +15,7 @@
#include "functionMgt.h" #include "functionMgt.h"
#include "planInt.h" #include "planInt.h"
#include "tglobal.h"
#define SPLIT_FLAG_MASK(n) (1 << n) #define SPLIT_FLAG_MASK(n) (1 << n)
@ -37,7 +38,8 @@ typedef struct SSplitRule {
FSplit splitFunc; FSplit splitFunc;
} SSplitRule; } SSplitRule;
typedef bool (*FSplFindSplitNode)(SSplitContext* pCxt, SLogicSubplan* pSubplan, void* pInfo); // typedef bool (*FSplFindSplitNode)(SSplitContext* pCxt, SLogicSubplan* pSubplan, void* pInfo);
typedef bool (*FSplFindSplitNode)(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, void* pInfo);
static void splSetSubplanVgroups(SLogicSubplan* pSubplan, SLogicNode* pNode) { static void splSetSubplanVgroups(SLogicSubplan* pSubplan, SLogicNode* pNode) {
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) {
@ -95,9 +97,23 @@ static int32_t splCreateExchangeNodeForSubplan(SSplitContext* pCxt, SLogicSubpla
return code; return code;
} }
static bool splMatchByNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, FSplFindSplitNode func,
void* pInfo) {
if (func(pCxt, pSubplan, pNode, pInfo)) {
return true;
}
SNode* pChild;
FOREACH(pChild, pNode->pChildren) {
if (splMatchByNode(pCxt, pSubplan, (SLogicNode*)pChild, func, pInfo)) {
return true;
}
}
return NULL;
}
static bool splMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan, int32_t flag, FSplFindSplitNode func, void* pInfo) { static bool splMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan, int32_t flag, FSplFindSplitNode func, void* pInfo) {
if (!SPLIT_FLAG_TEST_MASK(pSubplan->splitFlag, flag)) { if (!SPLIT_FLAG_TEST_MASK(pSubplan->splitFlag, flag)) {
if (func(pCxt, pSubplan, pInfo)) { if (splMatchByNode(pCxt, pSubplan, pSubplan->pNode, func, pInfo)) {
return true; return true;
} }
} }
@ -110,6 +126,11 @@ static bool splMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan, int32_t flag,
return false; return false;
} }
static void splSetParent(SLogicNode* pNode) {
SNode* pChild = NULL;
FOREACH(pChild, pNode->pChildren) { ((SLogicNode*)pChild)->pParent = pNode; }
}
typedef struct SStableSplitInfo { typedef struct SStableSplitInfo {
SLogicNode* pSplitNode; SLogicNode* pSplitNode;
SLogicSubplan* pSubplan; SLogicSubplan* pSubplan;
@ -136,11 +157,21 @@ static bool stbSplHasMultiTbScan(bool streamQuery, SLogicNode* pNode) {
return false; return false;
} }
SNode* pChild = nodesListGetNode(pNode->pChildren, 0); SNode* pChild = nodesListGetNode(pNode->pChildren, 0);
if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pChild)) {
if (1 != LIST_LENGTH(((SLogicNode*)pChild)->pChildren)) {
return false;
}
pChild = nodesListGetNode(((SLogicNode*)pChild)->pChildren, 0);
}
return (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pChild) && stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pChild)); return (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pChild) && stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pChild));
} }
static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) { static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) {
switch (nodeType(pNode)) { switch (nodeType(pNode)) {
case QUERY_NODE_LOGIC_PLAN_SCAN:
return stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pNode);
case QUERY_NODE_LOGIC_PLAN_JOIN:
return !(((SJoinLogicNode*)pNode)->isSingleTableJoin);
case QUERY_NODE_LOGIC_PLAN_AGG: case QUERY_NODE_LOGIC_PLAN_AGG:
return !stbSplHasGatherExecFunc(((SAggLogicNode*)pNode)->pAggFuncs) && stbSplHasMultiTbScan(streamQuery, pNode); return !stbSplHasGatherExecFunc(((SAggLogicNode*)pNode)->pAggFuncs) && stbSplHasMultiTbScan(streamQuery, pNode);
case QUERY_NODE_LOGIC_PLAN_WINDOW: { case QUERY_NODE_LOGIC_PLAN_WINDOW: {
@ -152,35 +183,20 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) {
} }
case QUERY_NODE_LOGIC_PLAN_SORT: case QUERY_NODE_LOGIC_PLAN_SORT:
return stbSplHasMultiTbScan(streamQuery, pNode); return stbSplHasMultiTbScan(streamQuery, pNode);
case QUERY_NODE_LOGIC_PLAN_SCAN:
return stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pNode);
default: default:
break; break;
} }
return false; return false;
} }
static SLogicNode* stbSplMatchByNode(bool streamQuery, SLogicNode* pNode) { static bool stbSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode,
if (stbSplNeedSplit(streamQuery, pNode)) { SStableSplitInfo* pInfo) {
return pNode; if (stbSplNeedSplit(pCxt->pPlanCxt->streamQuery, pNode)) {
} pInfo->pSplitNode = pNode;
SNode* pChild;
FOREACH(pChild, pNode->pChildren) {
SLogicNode* pSplitNode = stbSplMatchByNode(streamQuery, (SLogicNode*)pChild);
if (NULL != pSplitNode) {
return pSplitNode;
}
}
return NULL;
}
static bool stbSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SStableSplitInfo* pInfo) {
SLogicNode* pSplitNode = stbSplMatchByNode(pCxt->pPlanCxt->streamQuery, pSubplan->pNode);
if (NULL != pSplitNode) {
pInfo->pSplitNode = pSplitNode;
pInfo->pSubplan = pSubplan; pInfo->pSubplan = pSubplan;
return true;
} }
return NULL != pSplitNode; return false;
} }
static int32_t stbSplRewriteFuns(const SNodeList* pFuncs, SNodeList** pPartialFuncs, SNodeList** pMergeFuncs) { static int32_t stbSplRewriteFuns(const SNodeList* pFuncs, SNodeList** pPartialFuncs, SNodeList** pMergeFuncs) {
@ -258,6 +274,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
pMergeWindow->node.pTargets = pTargets; pMergeWindow->node.pTargets = pTargets;
pPartWin->node.pChildren = pChildren; pPartWin->node.pChildren = pChildren;
splSetParent((SLogicNode*)pPartWin);
code = stbSplRewriteFuns(pFunc, &pPartWin->pFuncs, &pMergeWindow->pFuncs); code = stbSplRewriteFuns(pFunc, &pPartWin->pFuncs, &pMergeWindow->pFuncs);
} }
int32_t index = 0; int32_t index = 0;
@ -285,13 +302,24 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
return code; return code;
} }
static int32_t stbSplGetNumOfVgroups(SLogicNode* pNode) {
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) {
return ((SScanLogicNode*)pNode)->pVgroupList->numOfVgroups;
} else {
if (1 == LIST_LENGTH(pNode->pChildren)) {
return stbSplGetNumOfVgroups((SLogicNode*)nodesListGetNode(pNode->pChildren, 0));
}
}
return 0;
}
static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pSplitNode, static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pSplitNode,
SNodeList* pMergeKeys, SLogicNode* pPartChild) { SNodeList* pMergeKeys, SLogicNode* pPartChild) {
SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE);
if (NULL == pMerge) { if (NULL == pMerge) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
pMerge->numOfChannels = ((SScanLogicNode*)nodesListGetNode(pPartChild->pChildren, 0))->pVgroupList->numOfVgroups; pMerge->numOfChannels = stbSplGetNumOfVgroups(pPartChild);
pMerge->srcGroupId = pCxt->groupId; pMerge->srcGroupId = pCxt->groupId;
pMerge->node.precision = pPartChild->precision; pMerge->node.precision = pPartChild->precision;
pMerge->pMergeKeys = pMergeKeys; pMerge->pMergeKeys = pMergeKeys;
@ -329,12 +357,12 @@ static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent
return code; return code;
} }
static int32_t stbSplCreateMergeKeysForInterval(SNode* pWStartTs, SNodeList** pMergeKeys) { static int32_t stbSplCreateMergeKeysByPrimaryKey(SNode* pPrimaryKey, SNodeList** pMergeKeys) {
SOrderByExprNode* pMergeKey = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); SOrderByExprNode* pMergeKey = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
if (NULL == pMergeKey) { if (NULL == pMergeKey) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
pMergeKey->pExpr = nodesCloneNode(pWStartTs); pMergeKey->pExpr = nodesCloneNode(pPrimaryKey);
if (NULL == pMergeKey->pExpr) { if (NULL == pMergeKey->pExpr) {
nodesDestroyNode((SNode*)pMergeKey); nodesDestroyNode((SNode*)pMergeKey);
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
@ -351,7 +379,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo
((SWindowLogicNode*)pPartWindow)->intervalAlgo = INTERVAL_ALGO_HASH; ((SWindowLogicNode*)pPartWindow)->intervalAlgo = INTERVAL_ALGO_HASH;
((SWindowLogicNode*)pInfo->pSplitNode)->intervalAlgo = INTERVAL_ALGO_MERGE; ((SWindowLogicNode*)pInfo->pSplitNode)->intervalAlgo = INTERVAL_ALGO_MERGE;
SNodeList* pMergeKeys = NULL; SNodeList* pMergeKeys = NULL;
code = stbSplCreateMergeKeysForInterval(((SWindowLogicNode*)pInfo->pSplitNode)->pTspk, &pMergeKeys); code = stbSplCreateMergeKeysByPrimaryKey(((SWindowLogicNode*)pInfo->pSplitNode)->pTspk, &pMergeKeys);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = stbSplCreateMergeNode(pCxt, NULL, pInfo->pSplitNode, pMergeKeys, pPartWindow); code = stbSplCreateMergeNode(pCxt, NULL, pInfo->pSplitNode, pMergeKeys, pPartWindow);
} }
@ -364,6 +392,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo
(SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); (SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT));
} }
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
++(pCxt->groupId);
return code; return code;
} }
@ -380,6 +409,7 @@ static int32_t stbSplSplitIntervalForStream(SSplitContext* pCxt, SStableSplitInf
(SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); (SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT));
} }
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
++(pCxt->groupId);
return code; return code;
} }
@ -439,6 +469,7 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO
pMergeAgg->node.pConditions = pConditions; pMergeAgg->node.pConditions = pConditions;
pMergeAgg->node.pTargets = pTargets; pMergeAgg->node.pTargets = pTargets;
pPartAgg->node.pChildren = pChildren; pPartAgg->node.pChildren = pChildren;
splSetParent((SLogicNode*)pPartAgg);
code = stbSplRewriteFuns(pFunc, &pPartAgg->pAggFuncs, &pMergeAgg->pAggFuncs); code = stbSplRewriteFuns(pFunc, &pPartAgg->pAggFuncs, &pMergeAgg->pAggFuncs);
} }
@ -467,6 +498,7 @@ static int32_t stbSplSplitAggNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
(SNode*)splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT)); (SNode*)splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT));
} }
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
++(pCxt->groupId);
return code; return code;
} }
@ -553,6 +585,7 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut
SNodeList* pMergeKeys = NULL; SNodeList* pMergeKeys = NULL;
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
pPartSort->node.pChildren = pChildren; pPartSort->node.pChildren = pChildren;
splSetParent((SLogicNode*)pPartSort);
pPartSort->pSortKeys = pSortKeys; pPartSort->pSortKeys = pSortKeys;
code = stbSplCreateMergeKeys(pPartSort->pSortKeys, pPartSort->node.pTargets, &pMergeKeys); code = stbSplCreateMergeKeys(pPartSort->pSortKeys, pPartSort->node.pTargets, &pMergeKeys);
} }
@ -580,6 +613,7 @@ static int32_t stbSplSplitSortNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
(SNode*)splCreateScanSubplan(pCxt, pPartSort, SPLIT_FLAG_STABLE_SPLIT)); (SNode*)splCreateScanSubplan(pCxt, pPartSort, SPLIT_FLAG_STABLE_SPLIT));
} }
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
++(pCxt->groupId);
return code; return code;
} }
@ -589,6 +623,59 @@ static int32_t stbSplSplitScanNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
(SNode*)splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); (SNode*)splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT));
} }
++(pCxt->groupId);
return code;
}
static SNode* stbSplFindPrimaryKeyFromScan(SScanLogicNode* pScan) {
SNode* pCol = NULL;
FOREACH(pCol, pScan->pScanCols) {
if (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pCol)->colId) {
return pCol;
}
}
return NULL;
}
static int32_t stbSplSplitScanNodeForJoin(SSplitContext* pCxt, SLogicSubplan* pSubplan, SScanLogicNode* pScan) {
SNodeList* pMergeKeys = NULL;
int32_t code = stbSplCreateMergeKeysByPrimaryKey(stbSplFindPrimaryKeyFromScan(pScan), &pMergeKeys);
if (TSDB_CODE_SUCCESS == code) {
code = stbSplCreateMergeNode(pCxt, pSubplan, (SLogicNode*)pScan, pMergeKeys, (SLogicNode*)pScan);
}
if (TSDB_CODE_SUCCESS == code) {
code = nodesListMakeStrictAppend(&pSubplan->pChildren,
(SNode*)splCreateScanSubplan(pCxt, (SLogicNode*)pScan, SPLIT_FLAG_STABLE_SPLIT));
}
pScan->scanType = SCAN_TYPE_TABLE_MERGE;
++(pCxt->groupId);
return code;
}
static int32_t stbSplSplitJoinNodeImpl(SSplitContext* pCxt, SLogicSubplan* pSubplan, SJoinLogicNode* pJoin) {
int32_t code = TSDB_CODE_SUCCESS;
SNode* pChild = NULL;
FOREACH(pChild, pJoin->node.pChildren) {
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pChild)) {
code = stbSplSplitScanNodeForJoin(pCxt, pSubplan, (SScanLogicNode*)pChild);
} else if (QUERY_NODE_LOGIC_PLAN_JOIN == nodeType(pChild)) {
code = stbSplSplitJoinNodeImpl(pCxt, pSubplan, (SJoinLogicNode*)pChild);
} else {
code = TSDB_CODE_PLAN_INTERNAL_ERROR;
}
if (TSDB_CODE_SUCCESS != code) {
break;
}
}
return code;
}
static int32_t stbSplSplitJoinNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
int32_t code = stbSplSplitJoinNodeImpl(pCxt, pInfo->pSubplan, (SJoinLogicNode*)pInfo->pSplitNode);
if (TSDB_CODE_SUCCESS == code) {
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
SPLIT_FLAG_SET_MASK(pInfo->pSubplan->splitFlag, SPLIT_FLAG_STABLE_SPLIT);
}
return code; return code;
} }
@ -604,6 +691,12 @@ static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
switch (nodeType(info.pSplitNode)) { switch (nodeType(info.pSplitNode)) {
case QUERY_NODE_LOGIC_PLAN_SCAN:
code = stbSplSplitScanNode(pCxt, &info);
break;
case QUERY_NODE_LOGIC_PLAN_JOIN:
code = stbSplSplitJoinNode(pCxt, &info);
break;
case QUERY_NODE_LOGIC_PLAN_AGG: case QUERY_NODE_LOGIC_PLAN_AGG:
code = stbSplSplitAggNode(pCxt, &info); code = stbSplSplitAggNode(pCxt, &info);
break; break;
@ -613,14 +706,10 @@ static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
case QUERY_NODE_LOGIC_PLAN_SORT: case QUERY_NODE_LOGIC_PLAN_SORT:
code = stbSplSplitSortNode(pCxt, &info); code = stbSplSplitSortNode(pCxt, &info);
break; break;
case QUERY_NODE_LOGIC_PLAN_SCAN:
code = stbSplSplitScanNode(pCxt, &info);
break;
default: default:
break; break;
} }
++(pCxt->groupId);
pCxt->split = true; pCxt->split = true;
return code; return code;
} }
@ -631,7 +720,12 @@ typedef struct SSigTbJoinSplitInfo {
SLogicSubplan* pSubplan; SLogicSubplan* pSubplan;
} SSigTbJoinSplitInfo; } SSigTbJoinSplitInfo;
static bool sigTbJoinSplNeedSplit(SJoinLogicNode* pJoin) { static bool sigTbJoinSplNeedSplit(SLogicNode* pNode) {
if (QUERY_NODE_LOGIC_PLAN_JOIN != nodeType(pNode)) {
return false;
}
SJoinLogicNode* pJoin = (SJoinLogicNode*)pNode;
if (!pJoin->isSingleTableJoin) { if (!pJoin->isSingleTableJoin) {
return false; return false;
} }
@ -639,28 +733,15 @@ static bool sigTbJoinSplNeedSplit(SJoinLogicNode* pJoin) {
QUERY_NODE_LOGIC_PLAN_EXCHANGE != nodeType(nodesListGetNode(pJoin->node.pChildren, 1)); QUERY_NODE_LOGIC_PLAN_EXCHANGE != nodeType(nodesListGetNode(pJoin->node.pChildren, 1));
} }
static SJoinLogicNode* sigTbJoinSplMatchByNode(SLogicNode* pNode) { static bool sigTbJoinSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode,
if (QUERY_NODE_LOGIC_PLAN_JOIN == nodeType(pNode) && sigTbJoinSplNeedSplit((SJoinLogicNode*)pNode)) { SSigTbJoinSplitInfo* pInfo) {
return (SJoinLogicNode*)pNode; if (sigTbJoinSplNeedSplit(pNode)) {
} pInfo->pJoin = (SJoinLogicNode*)pNode;
SNode* pChild; pInfo->pSplitNode = (SLogicNode*)nodesListGetNode(pNode->pChildren, 1);
FOREACH(pChild, pNode->pChildren) {
SJoinLogicNode* pSplitNode = sigTbJoinSplMatchByNode((SLogicNode*)pChild);
if (NULL != pSplitNode) {
return pSplitNode;
}
}
return NULL;
}
static bool sigTbJoinSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SSigTbJoinSplitInfo* pInfo) {
SJoinLogicNode* pJoin = sigTbJoinSplMatchByNode(pSubplan->pNode);
if (NULL != pJoin) {
pInfo->pJoin = pJoin;
pInfo->pSplitNode = (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1);
pInfo->pSubplan = pSubplan; pInfo->pSubplan = pSubplan;
return true;
} }
return NULL != pJoin; return false;
} }
static int32_t singleTableJoinSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { static int32_t singleTableJoinSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
@ -753,27 +834,14 @@ typedef struct SUnionAllSplitInfo {
SLogicSubplan* pSubplan; SLogicSubplan* pSubplan;
} SUnionAllSplitInfo; } SUnionAllSplitInfo;
static SLogicNode* unAllSplMatchByNode(SLogicNode* pNode) { static bool unAllSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode,
SUnionAllSplitInfo* pInfo) {
if (QUERY_NODE_LOGIC_PLAN_PROJECT == nodeType(pNode) && LIST_LENGTH(pNode->pChildren) > 1) { if (QUERY_NODE_LOGIC_PLAN_PROJECT == nodeType(pNode) && LIST_LENGTH(pNode->pChildren) > 1) {
return pNode; pInfo->pProject = (SProjectLogicNode*)pNode;
}
SNode* pChild;
FOREACH(pChild, pNode->pChildren) {
SLogicNode* pSplitNode = unAllSplMatchByNode((SLogicNode*)pChild);
if (NULL != pSplitNode) {
return pSplitNode;
}
}
return NULL;
}
static bool unAllSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SUnionAllSplitInfo* pInfo) {
SLogicNode* pSplitNode = unAllSplMatchByNode(pSubplan->pNode);
if (NULL != pSplitNode) {
pInfo->pProject = (SProjectLogicNode*)pSplitNode;
pInfo->pSubplan = pSubplan; pInfo->pSubplan = pSubplan;
return true;
} }
return NULL != pSplitNode; return false;
} }
static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SProjectLogicNode* pProject) { static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SProjectLogicNode* pProject) {
@ -828,20 +896,6 @@ typedef struct SUnionDistinctSplitInfo {
SLogicSubplan* pSubplan; SLogicSubplan* pSubplan;
} SUnionDistinctSplitInfo; } SUnionDistinctSplitInfo;
static SLogicNode* unDistSplMatchByNode(SLogicNode* pNode) {
if (QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) && LIST_LENGTH(pNode->pChildren) > 1) {
return pNode;
}
SNode* pChild;
FOREACH(pChild, pNode->pChildren) {
SLogicNode* pSplitNode = unDistSplMatchByNode((SLogicNode*)pChild);
if (NULL != pSplitNode) {
return pSplitNode;
}
}
return NULL;
}
static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SAggLogicNode* pAgg) { static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SAggLogicNode* pAgg) {
SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
if (NULL == pExchange) { if (NULL == pExchange) {
@ -859,13 +913,14 @@ static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* p
return nodesListMakeAppend(&pAgg->node.pChildren, (SNode*)pExchange); return nodesListMakeAppend(&pAgg->node.pChildren, (SNode*)pExchange);
} }
static bool unDistSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SUnionDistinctSplitInfo* pInfo) { static bool unDistSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode,
SLogicNode* pSplitNode = unDistSplMatchByNode(pSubplan->pNode); SUnionDistinctSplitInfo* pInfo) {
if (NULL != pSplitNode) { if (QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) && LIST_LENGTH(pNode->pChildren) > 1) {
pInfo->pAgg = (SAggLogicNode*)pSplitNode; pInfo->pAgg = (SAggLogicNode*)pNode;
pInfo->pSubplan = pSubplan; pInfo->pSubplan = pSubplan;
return true;
} }
return NULL != pSplitNode; return false;
} }
static int32_t unionDistinctSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { static int32_t unionDistinctSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
@ -888,27 +943,14 @@ typedef struct SSmaIndexSplitInfo {
SLogicSubplan* pSubplan; SLogicSubplan* pSubplan;
} SSmaIndexSplitInfo; } SSmaIndexSplitInfo;
static SLogicNode* smaIdxSplMatchByNode(SLogicNode* pNode) { static bool smaIdxSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode,
SSmaIndexSplitInfo* pInfo) {
if (QUERY_NODE_LOGIC_PLAN_MERGE == nodeType(pNode) && LIST_LENGTH(pNode->pChildren) > 1) { if (QUERY_NODE_LOGIC_PLAN_MERGE == nodeType(pNode) && LIST_LENGTH(pNode->pChildren) > 1) {
return pNode; pInfo->pMerge = (SMergeLogicNode*)pNode;
}
SNode* pChild;
FOREACH(pChild, pNode->pChildren) {
SLogicNode* pSplitNode = smaIdxSplMatchByNode((SLogicNode*)pChild);
if (NULL != pSplitNode) {
return pSplitNode;
}
}
return NULL;
}
static bool smaIdxSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SSmaIndexSplitInfo* pInfo) {
SLogicNode* pSplitNode = smaIdxSplMatchByNode(pSubplan->pNode);
if (NULL != pSplitNode) {
pInfo->pMerge = (SMergeLogicNode*)pSplitNode;
pInfo->pSubplan = pSubplan; pInfo->pSubplan = pSubplan;
return true;
} }
return NULL != pSplitNode; return false;
} }
static int32_t smaIndexSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { static int32_t smaIndexSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
@ -926,13 +968,47 @@ static int32_t smaIndexSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
return code; return code;
} }
typedef struct SQnodeSplitInfo {
SLogicNode* pSplitNode;
SLogicSubplan* pSubplan;
} SQnodeSplitInfo;
static bool qndSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode,
SQnodeSplitInfo* pInfo) {
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode) && NULL != pNode->pParent) {
pInfo->pSplitNode = pNode;
pInfo->pSubplan = pSubplan;
return true;
}
return false;
}
static int32_t qnodeSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
if (QUERY_POLICY_QNODE != tsQueryPolicy) {
return TSDB_CODE_SUCCESS;
}
SQnodeSplitInfo info = {0};
if (!splMatch(pCxt, pSubplan, 0, (FSplFindSplitNode)qndSplFindSplitNode, &info)) {
return TSDB_CODE_SUCCESS;
}
int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pSplitNode, info.pSubplan->subplanType);
if (TSDB_CODE_SUCCESS == code) {
code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)splCreateScanSubplan(pCxt, info.pSplitNode, 0));
}
++(pCxt->groupId);
pCxt->split = true;
return code;
}
// clang-format off // clang-format off
static const SSplitRule splitRuleSet[] = { static const SSplitRule splitRuleSet[] = {
{.pName = "SuperTableSplit", .splitFunc = stableSplit}, {.pName = "SuperTableSplit", .splitFunc = stableSplit},
{.pName = "SingleTableJoinSplit", .splitFunc = singleTableJoinSplit}, {.pName = "SingleTableJoinSplit", .splitFunc = singleTableJoinSplit},
{.pName = "UnionAllSplit", .splitFunc = unionAllSplit}, {.pName = "UnionAllSplit", .splitFunc = unionAllSplit},
{.pName = "UnionDistinctSplit", .splitFunc = unionDistinctSplit}, {.pName = "UnionDistinctSplit", .splitFunc = unionDistinctSplit},
{.pName = "SmaIndexSplit", .splitFunc = smaIndexSplit} {.pName = "SmaIndexSplit", .splitFunc = smaIndexSplit},
{.pName = "QnodeSplit", .splitFunc = qnodeSplit}
}; };
// clang-format on // clang-format on

View File

@ -83,5 +83,7 @@ TEST_F(PlanGroupByTest, stable) {
run("SELECT COUNT(*) FROM st1 GROUP BY c1"); run("SELECT COUNT(*) FROM st1 GROUP BY c1");
run("SELECT COUNT(*) FROM st1 PARTITION BY c2 GROUP BY c1");
run("SELECT SUM(c1) FROM st1 GROUP BY c2 HAVING SUM(c1) IS NOT NULL"); run("SELECT SUM(c1) FROM st1 GROUP BY c2 HAVING SUM(c1) IS NOT NULL");
} }

View File

@ -60,4 +60,6 @@ TEST_F(PlanIntervalTest, stable) {
run("SELECT COUNT(*) FROM st1 INTERVAL(10s)"); run("SELECT COUNT(*) FROM st1 INTERVAL(10s)");
run("SELECT _WSTARTTS, COUNT(*) FROM st1 INTERVAL(10s)"); run("SELECT _WSTARTTS, COUNT(*) FROM st1 INTERVAL(10s)");
run("SELECT _WSTARTTS, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)");
} }

View File

@ -50,3 +50,9 @@ TEST_F(PlanJoinTest, multiJoin) {
run("SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts JOIN st1s3 t3 ON t1.ts = t3.ts"); run("SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts JOIN st1s3 t3 ON t1.ts = t3.ts");
} }
TEST_F(PlanJoinTest, stable) {
useDb("root", "test");
run("SELECT t1.c1, t2.c1 FROM st1 t1 JOIN st2 t2 ON t1.ts = t2.ts ");
}

View File

@ -49,4 +49,6 @@ TEST_F(PlanOrderByTest, stable) {
// ORDER BY key is not in the projection list // ORDER BY key is not in the projection list
run("SELECT c2 FROM st1 ORDER BY c1"); run("SELECT c2 FROM st1 ORDER BY c1");
run("SELECT c2 FROM st1 PARTITION BY c2 ORDER BY c1");
} }

View File

@ -83,3 +83,10 @@ TEST_F(PlanOtherTest, delete) {
run("DELETE FROM st1 WHERE ts > now - 2d and ts < now - 1d AND tag1 = 10"); run("DELETE FROM st1 WHERE ts > now - 2d and ts < now - 1d AND tag1 = 10");
} }
TEST_F(PlanOtherTest, queryPolicy) {
useDb("root", "test");
tsQueryPolicy = QUERY_POLICY_QNODE;
run("SELECT COUNT(*) FROM st1");
}

View File

@ -18,6 +18,10 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#define ALLOW_FORBID_FUNC
#include "planInt.h"
class PlannerTestBaseImpl; class PlannerTestBaseImpl;
struct TAOS_MULTI_BIND; struct TAOS_MULTI_BIND;

View File

@ -41,7 +41,7 @@ typedef struct SCliConn {
// debug and log info // debug and log info
struct sockaddr_in addr; struct sockaddr_in addr;
struct sockaddr_in locaddr; struct sockaddr_in localAddr;
} SCliConn; } SCliConn;
typedef struct SCliMsg { typedef struct SCliMsg {
@ -54,7 +54,8 @@ typedef struct SCliMsg {
} SCliMsg; } SCliMsg;
typedef struct SCliThrdObj { typedef struct SCliThrdObj {
TdThread thread; TdThread thread; // tid
int64_t pid; // pid
uv_loop_t* loop; uv_loop_t* loop;
SAsyncPool* asyncPool; SAsyncPool* asyncPool;
uv_timer_t timer; uv_timer_t timer;
@ -325,7 +326,7 @@ void cliHandleResp(SCliConn* conn) {
tDebug("%s cli conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pTransInst->label, conn, tDebug("%s cli conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pTransInst->label, conn,
TMSG_INFO(pHead->msgType), taosInetNtoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port), TMSG_INFO(pHead->msgType), taosInetNtoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port),
taosInetNtoa(conn->locaddr.sin_addr), ntohs(conn->locaddr.sin_port), transMsg.contLen); taosInetNtoa(conn->localAddr.sin_addr), ntohs(conn->localAddr.sin_port), transMsg.contLen);
if (pCtx == NULL && CONN_NO_PERSIST_BY_APP(conn)) { if (pCtx == NULL && CONN_NO_PERSIST_BY_APP(conn)) {
tTrace("except, server continue send while cli ignore it"); tTrace("except, server continue send while cli ignore it");
@ -643,7 +644,7 @@ void cliSend(SCliConn* pConn) {
uv_buf_t wb = uv_buf_init((char*)pHead, msgLen); uv_buf_t wb = uv_buf_init((char*)pHead, msgLen);
tDebug("%s cli conn %p %s is send to %s:%d, local info %s:%d", CONN_GET_INST_LABEL(pConn), pConn, tDebug("%s cli conn %p %s is send to %s:%d, local info %s:%d", CONN_GET_INST_LABEL(pConn), pConn,
TMSG_INFO(pHead->msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), TMSG_INFO(pHead->msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port),
taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port));
if (pHead->persist == 1) { if (pHead->persist == 1) {
CONN_SET_PERSIST_BY_APP(pConn); CONN_SET_PERSIST_BY_APP(pConn);
@ -668,8 +669,8 @@ void cliConnCb(uv_connect_t* req, int status) {
int addrlen = sizeof(pConn->addr); int addrlen = sizeof(pConn->addr);
uv_tcp_getpeername((uv_tcp_t*)pConn->stream, (struct sockaddr*)&pConn->addr, &addrlen); uv_tcp_getpeername((uv_tcp_t*)pConn->stream, (struct sockaddr*)&pConn->addr, &addrlen);
addrlen = sizeof(pConn->locaddr); addrlen = sizeof(pConn->localAddr);
uv_tcp_getsockname((uv_tcp_t*)pConn->stream, (struct sockaddr*)&pConn->locaddr, &addrlen); uv_tcp_getsockname((uv_tcp_t*)pConn->stream, (struct sockaddr*)&pConn->localAddr, &addrlen);
tTrace("%s cli conn %p connect to server successfully", CONN_GET_INST_LABEL(pConn), pConn); tTrace("%s cli conn %p connect to server successfully", CONN_GET_INST_LABEL(pConn), pConn);
assert(pConn->stream == req->handle); assert(pConn->stream == req->handle);
@ -742,8 +743,7 @@ void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr) {
void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) { void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
uint64_t et = taosGetTimestampUs(); uint64_t et = taosGetTimestampUs();
uint64_t el = et - pMsg->st; uint64_t el = et - pMsg->st;
tTrace("%s cli msg tran time cost: %" PRIu64 "us, threadID: %" PRId64 "", ((STrans*)pThrd->pTransInst)->label, el, // tTrace("%s cli msg tran time cost: %" PRIu64 "us", ((STrans*)pThrd->pTransInst)->label, el);
pThrd->thread);
STransConnCtx* pCtx = pMsg->ctx; STransConnCtx* pCtx = pMsg->ctx;
STrans* pTransInst = pThrd->pTransInst; STrans* pTransInst = pThrd->pTransInst;
@ -822,6 +822,7 @@ static void cliAsyncCb(uv_async_t* handle) {
static void* cliWorkThread(void* arg) { static void* cliWorkThread(void* arg) {
SCliThrdObj* pThrd = (SCliThrdObj*)arg; SCliThrdObj* pThrd = (SCliThrdObj*)arg;
pThrd->pid = taosGetSelfPthreadId();
setThreadName("trans-cli-work"); setThreadName("trans-cli-work");
uv_run(pThrd->loop, UV_RUN_DEFAULT); uv_run(pThrd->loop, UV_RUN_DEFAULT);
return NULL; return NULL;
@ -966,30 +967,31 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
pMsg->st = taosGetTimestampUs(); pMsg->st = taosGetTimestampUs();
pCtx->retryCount += 1; pCtx->retryCount += 1;
if (pResp->code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { if (pResp->code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
if (pCtx->retryCount < pEpSet->numOfEps) { if (pCtx->retryCount < pEpSet->numOfEps * 3) {
pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps; pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps;
STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg));
arg->param1 = pMsg; arg->param1 = pMsg;
arg->param2 = pThrd; arg->param2 = pThrd;
transDQSched(pThrd->delayQueue, doDelayTask, arg, TRANS_RETRY_INTERVAL); transDQSched(pThrd->delayQueue, doDelayTask, arg, TRANS_RETRY_INTERVAL);
tTrace("use local epset, current in use: %d, retry count:%d, limit: %d", pEpSet->inUse, pCtx->retryCount + 1,
pEpSet->numOfEps * 3);
transUnrefCliHandle(pConn); transUnrefCliHandle(pConn);
return -1; return -1;
} }
} else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) { } else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) {
if (pResp->contLen == 0) { if (pResp->contLen == 0) {
pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps; pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps;
tTrace("use local epset, current in use: %d, retry count:%d, limit: %d", pEpSet->inUse, pCtx->retryCount + 1,
TRANS_RETRY_COUNT_LIMIT);
} else { } else {
SEpSet epSet = {0}; SEpSet epSet = {0};
tDeserializeSEpSet(pResp->pCont, pResp->contLen, &epSet); tDeserializeSEpSet(pResp->pCont, pResp->contLen, &epSet);
pCtx->epSet = epSet; pCtx->epSet = epSet;
if (!transEpSetIsEqual(&epSet, &pCtx->epSet)) { tTrace("use remote epset, current in use: %d, retry count:%d, limit: %d", pEpSet->inUse, pCtx->retryCount + 1,
pCtx->retryCount = 0; TRANS_RETRY_COUNT_LIMIT);
}
} }
addConnToPool(pThrd->pool, pConn); addConnToPool(pThrd->pool, pConn);
tTrace("use remote epset, current in use: %d, retry count:%d, try limit: %d", pEpSet->inUse, pCtx->retryCount + 1,
TRANS_RETRY_COUNT_LIMIT);
STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg));
arg->param1 = pMsg; arg->param1 = pMsg;
@ -1089,7 +1091,7 @@ void transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra
SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[index]; SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[index];
tDebug("send request at thread:%d, threadID: %" PRId64 ", msg: %p, dst: %s:%d, app:%p", index, thrd->thread, pReq, tDebug("send request at thread:%d, threadID: %08" PRId64 ", msg: %p, dst: %s:%d, app:%p", index, thrd->pid, pReq,
EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle);
ASSERT(transSendAsync(thrd->asyncPool, &(cliMsg->q)) == 0); ASSERT(transSendAsync(thrd->asyncPool, &(cliMsg->q)) == 0);
} }
@ -1118,7 +1120,7 @@ void transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransM
cliMsg->type = Normal; cliMsg->type = Normal;
SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[index]; SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[index];
tDebug("send request at thread:%d, threadID:%" PRId64 ", msg: %p, dst: %s:%d, app:%p", index, thrd->thread, pReq, tDebug("send request at thread:%d, threadID:%08" PRId64 ", msg: %p, dst: %s:%d, app:%p", index, thrd->pid, pReq,
EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle);
transSendAsync(thrd->asyncPool, &(cliMsg->q)); transSendAsync(thrd->asyncPool, &(cliMsg->q));
@ -1149,7 +1151,7 @@ void transSetDefaultAddr(void* ahandle, const char* ip, const char* fqdn) {
cliMsg->type = Update; cliMsg->type = Update;
SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[i]; SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[i];
tDebug("update epset at thread:%d, threadID:%" PRId64 "", i, thrd->thread); tDebug("update epset at thread:%d, threadID:%08" PRId64 "", i, thrd->pid);
transSendAsync(thrd->asyncPool, &(cliMsg->q)); transSendAsync(thrd->asyncPool, &(cliMsg->q));
} }

View File

@ -48,7 +48,7 @@ typedef struct SSvrConn {
ConnStatus status; ConnStatus status;
struct sockaddr_in addr; struct sockaddr_in addr;
struct sockaddr_in locaddr; struct sockaddr_in localAddr;
int64_t refId; int64_t refId;
int spi; int spi;
@ -286,12 +286,12 @@ static void uvHandleReq(SSvrConn* pConn) {
if (pConn->status == ConnNormal && pHead->noResp == 0) { if (pConn->status == ConnNormal && pHead->noResp == 0) {
transRefSrvHandle(pConn); transRefSrvHandle(pConn);
tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pConn, TMSG_INFO(transMsg.msgType), tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pConn, TMSG_INFO(transMsg.msgType),
taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->locaddr.sin_addr), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr),
ntohs(pConn->locaddr.sin_port), transMsg.contLen); ntohs(pConn->localAddr.sin_port), transMsg.contLen);
} else { } else {
tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, resp:%d ", pConn, tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, resp:%d ", pConn,
TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port),
taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port), transMsg.contLen, pHead->noResp); taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), transMsg.contLen, pHead->noResp);
// no ref here // no ref here
} }
@ -454,8 +454,8 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) {
char* msg = (char*)pHead; char* msg = (char*)pHead;
int32_t len = transMsgLenFromCont(pMsg->contLen); int32_t len = transMsgLenFromCont(pMsg->contLen);
tDebug("server conn %p %s is sent to %s:%d, local info: %s:%d, msglen:%d", pConn, TMSG_INFO(pHead->msgType), tDebug("server conn %p %s is sent to %s:%d, local info: %s:%d, msglen:%d", pConn, TMSG_INFO(pHead->msgType),
taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->locaddr.sin_addr), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr),
ntohs(pConn->locaddr.sin_port), len); ntohs(pConn->localAddr.sin_port), len);
pHead->msgLen = htonl(len); pHead->msgLen = htonl(len);
wb->base = msg; wb->base = msg;
@ -686,8 +686,8 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
return; return;
} }
addrlen = sizeof(pConn->locaddr); addrlen = sizeof(pConn->localAddr);
if (0 != uv_tcp_getsockname(pConn->pTcp, (struct sockaddr*)&pConn->locaddr, &addrlen)) { if (0 != uv_tcp_getsockname(pConn->pTcp, (struct sockaddr*)&pConn->localAddr, &addrlen)) {
tError("server conn %p failed to get local info", pConn); tError("server conn %p failed to get local info", pConn);
transUnrefSrvHandle(pConn); transUnrefSrvHandle(pConn);
return; return;

View File

@ -381,28 +381,29 @@ TEST_F(TransEnv, srvReleaseHandle) {
} }
////////////////// //////////////////
} }
TEST_F(TransEnv, cliReleaseHandleExcept) { // reopen later
SRpcMsg resp = {0}; // TEST_F(TransEnv, cliReleaseHandleExcept) {
SRpcMsg req = {0}; // SRpcMsg resp = {0};
for (int i = 0; i < 3; i++) { // SRpcMsg req = {0};
memset(&req, 0, sizeof(req)); // for (int i = 0; i < 3; i++) {
req.info = resp.info; // memset(&req, 0, sizeof(req));
req.info.persistHandle = 1; // req.info = resp.info;
req.info.ahandle = (void *)1234; // req.info.persistHandle = 1;
req.msgType = 1; // req.info.ahandle = (void *)1234;
req.pCont = rpcMallocCont(10); // req.msgType = 1;
req.contLen = 10; // req.pCont = rpcMallocCont(10);
tr->cliSendAndRecv(&req, &resp); // req.contLen = 10;
if (i == 1) { // tr->cliSendAndRecv(&req, &resp);
std::cout << "stop server" << std::endl; // if (i == 1) {
tr->StopSrv(); // std::cout << "stop server" << std::endl;
} // tr->StopSrv();
if (i > 1) { // }
EXPECT_TRUE(resp.code != 0); // if (i > 1) {
} // EXPECT_TRUE(resp.code != 0);
} // }
////////////////// // }
} // //////////////////
//}
TEST_F(TransEnv, srvContinueSend) { TEST_F(TransEnv, srvContinueSend) {
tr->SetSrvContinueSend(processContinueSend); tr->SetSrvContinueSend(processContinueSend);
SRpcMsg req = {0}, resp = {0}; SRpcMsg req = {0}, resp = {0};

View File

@ -568,6 +568,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_NO_INDEX_IN_CACHE, "No tsma index in ca
TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_ENV, "Invalid rsma env") TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_ENV, "Invalid rsma env")
TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_STAT, "Invalid rsma state") TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_STAT, "Invalid rsma state")
TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_REBUILDING, "Index is rebuilding") TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_REBUILDING, "Index is rebuilding")
#ifdef TAOS_ERROR_C #ifdef TAOS_ERROR_C

View File

@ -41,5 +41,16 @@ fi
cat ../script/jenkins/basic.txt |grep -v "^#"|grep -v "^$"|sed "s/^/,,script,/" >>$case_file cat ../script/jenkins/basic.txt |grep -v "^#"|grep -v "^$"|sed "s/^/,,script,/" >>$case_file
grep "^python" ../system-test/fulltest.sh |sed "s/^/,,system-test,/" >>$case_file grep "^python" ../system-test/fulltest.sh |sed "s/^/,,system-test,/" >>$case_file
# tar source code for run.sh to use
# if [ $ent -eq 0 ]; then
# cd ../../../
# rm -rf TDengine.tar.gz
# tar --exclude=TDengine/debug --exclude=TDengine/sim --exclude=TDengine/release -czf TDengine.tar.gz TDengine taos-connector-python
# else
# cd ../../../../
# rm -rf TDinternal.tar.gz
# tar --exclude=TDinternal/debug --exclude=TDinternal/sim --exclude=TDinternal/community/debug --exclude=TDinternal/community/release --exclude=TDinternal/community/sim -czf TDinternal.tar.gz TDinternal taos-connector-python
# fi
exit 0 exit 0

View File

@ -255,7 +255,6 @@ function run_thread() {
$cmd # 2>/dev/null $cmd # 2>/dev/null
local case_info=`echo "$line"|cut -d, -f 3,4` local case_info=`echo "$line"|cut -d, -f 3,4`
local corefile=`ls $log_dir/${case_file}.coredump/` local corefile=`ls $log_dir/${case_file}.coredump/`
corefile=`find $log_dir/${case_file}.coredump/ -name "core.*"`
echo -e "$case_info \e[31m failed\e[0m" echo -e "$case_info \e[31m failed\e[0m"
echo "=========================log============================" echo "=========================log============================"
cat $log_dir/$case_file.log cat $log_dir/$case_file.log
@ -291,6 +290,19 @@ function run_thread() {
fi fi
cmd="$scpcmd:${remote_sim_tar} $log_dir/${case_file}.sim.tar.gz" cmd="$scpcmd:${remote_sim_tar} $log_dir/${case_file}.sim.tar.gz"
$cmd $cmd
# backup source code (disabled)
source_tar_dir=$log_dir/TDengine_${hosts[index]}
source_tar_file=TDengine.tar.gz
if [ $ent -ne 0 ]; then
source_tar_dir=$log_dir/TDinternal_${hosts[index]}
source_tar_file=TDinternal.tar.gz
fi
mkdir $source_tar_dir 2>/dev/null
if [ $? -eq 0 ]; then
cmd="$scpcmd:${workdirs[index]}/$source_tar_file $source_tar_dir"
# echo "$cmd"
# $cmd
fi
fi fi
done done
} }

View File

@ -42,7 +42,7 @@ class TDTestCase:
tdDnodes.start(3) tdDnodes.start(3)
def run(self): def run(self):
tdSql.execute('create database db replica 3 days 7') tdSql.execute('create database db replica 3 duration 7')
tdSql.execute('use db') tdSql.execute('use db')
for tid in range(1, 11): for tid in range(1, 11):
tdSql.execute('create table tb%d(ts timestamp, i int)' % tid) tdSql.execute('create table tb%d(ts timestamp, i int)' % tid)

View File

@ -83,7 +83,7 @@ class TDTestCase:
tdSql.checkData(0, 0, np.max(floatData)) tdSql.checkData(0, 0, np.max(floatData))
# test case: https://jira.taosdata.com:18080/browse/TD-2583 # test case: https://jira.taosdata.com:18080/browse/TD-2583
tdSql.execute("create database test days 2") tdSql.execute("create database test duration 2")
tdSql.execute("create table car(ts timestamp, speed int)") tdSql.execute("create table car(ts timestamp, speed int)")
tdSql.execute("insert into car values(now, -1)") tdSql.execute("insert into car values(now, -1)")
tdSql.execute("insert into car values(now-10d, null)") tdSql.execute("insert into car values(now-10d, null)")

View File

@ -83,7 +83,7 @@ class TDTestCase:
tdSql.checkData(0, 0, np.min(floatData)) tdSql.checkData(0, 0, np.min(floatData))
# test case: https://jira.taosdata.com:18080/browse/TD-2583 # test case: https://jira.taosdata.com:18080/browse/TD-2583
tdSql.execute("create database test days 2") tdSql.execute("create database test duration 2")
tdSql.execute("create table car(ts timestamp, speed int)") tdSql.execute("create table car(ts timestamp, speed int)")
tdSql.execute("insert into car values(now, 1)") tdSql.execute("insert into car values(now, 1)")
tdSql.execute("insert into car values(now-10d, null)") tdSql.execute("insert into car values(now-10d, null)")

View File

@ -264,7 +264,7 @@ class TDTestCase:
def td4288(self): def td4288(self):
tdLog.printNoPrefix("==========TD-4288==========") tdLog.printNoPrefix("==========TD-4288==========")
# keep ~ [days,365000] # keep ~ [duration,365000]
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
tdSql.execute("create database if not exists db") tdSql.execute("create database if not exists db")
tdSql.query("show variables") tdSql.query("show variables")

View File

@ -32,7 +32,7 @@ class TDTestCase:
print("==============step1") print("==============step1")
tdSql.execute("create database if not exists demo keep 36500;"); tdSql.execute("create database if not exists demo keep 36500;");
print("==============create db demo keep 365000 days") print("==============create db demo keep 365000 duration")
tdSql.execute("use demo;") tdSql.execute("use demo;")
tdSql.execute("CREATE table if not exists test (ts timestamp, f1 int);") tdSql.execute("CREATE table if not exists test (ts timestamp, f1 int);")
print("==============create table test") print("==============create table test")

View File

@ -51,7 +51,7 @@ class TDTestRetetion:
def run(self): def run(self):
tdLog.info("=============== step1") tdLog.info("=============== step1")
tdSql.execute('create database test keep 3 days 1;') tdSql.execute('create database test keep 3 duration 1;')
tdSql.execute('use test;') tdSql.execute('use test;')
tdSql.execute('create table test(ts timestamp,i int);') tdSql.execute('create table test(ts timestamp,i int);')

View File

@ -66,7 +66,7 @@ class TDTestCase:
tdDnodes.deploy(1,cfg) tdDnodes.deploy(1,cfg)
tdDnodes.startWithoutSleep(1) tdDnodes.startWithoutSleep(1)
tdSql.execute("create database test days 1") tdSql.execute("create database test duration 1")
tdSql.execute("use test") tdSql.execute("use test")
tdSql.execute("create table stb(ts timestamp, c int) tags(t int)") tdSql.execute("create table stb(ts timestamp, c int) tags(t int)")
@ -85,7 +85,7 @@ class TDTestCase:
tdLog.info("================= step3") tdLog.info("================= step3")
tdSql.execute('drop database test') tdSql.execute('drop database test')
for i in range(50): for i in range(50):
tdSql.execute("create database test%d days 1" %(i)) tdSql.execute("create database test%d duration 1" %(i))
tdSql.execute("use test%d" %(i)) tdSql.execute("use test%d" %(i))
tdSql.execute("create table tb (ts timestamp,i int)") tdSql.execute("create table tb (ts timestamp,i int)")
for j in range(10): for j in range(10):

View File

@ -56,7 +56,7 @@ class TDTestCase:
tdDnodes.deploy(1,cfg) tdDnodes.deploy(1,cfg)
tdDnodes.startWithoutSleep(1) tdDnodes.startWithoutSleep(1)
tdSql.execute("create database test days 1 keep 15,5,10") tdSql.execute("create database test duration 1 keep 15,5,10")
tdSql.execute("use test") tdSql.execute("use test")
tdSql.execute("create table tb(ts timestamp, c int)") tdSql.execute("create table tb(ts timestamp, c int)")

View File

@ -66,7 +66,7 @@ class TDTestCase:
"name": "db", "name": "db",
"drop": "yes", "drop": "yes",
"replica": 1, "replica": 1,
"days": 10, "duration": 10,
"cache": 16, "cache": 16,
"blocks": 8, "blocks": 8,
"precision": "ms", "precision": "ms",

View File

@ -81,7 +81,7 @@ class JoinPerf:
"name": self.dbname, "name": self.dbname,
"drop": self.drop, "drop": self.drop,
"replica": 1, "replica": 1,
"days": 10, "duration": 10,
"cache": 16, "cache": 16,
"blocks": 8, "blocks": 8,
"precision": "ms", "precision": "ms",

View File

@ -75,7 +75,7 @@ class Taosdemo:
"name": self.dbname, "name": self.dbname,
"drop": self.drop, "drop": self.drop,
"replica": 1, "replica": 1,
"days": 10, "duration": 10,
"cache": 16, "cache": 16,
"blocks": 8, "blocks": 8,
"precision": "ms", "precision": "ms",

View File

@ -57,7 +57,7 @@ class TDTestCase:
"name": "db", "name": "db",
"drop": "yes", "drop": "yes",
"replica": 1, "replica": 1,
"days": 10, "duration": 10,
"cache": 16, "cache": 16,
"blocks": 8, "blocks": 8,
"precision": "ms", "precision": "ms",

View File

@ -138,7 +138,7 @@ class TDTestCase:
sqls_ls = [ sqls_ls = [
'drop database if exists nsdbsql;', 'drop database if exists nsdbsql;',
'create database nsdbsql precision "ns" keep 3600 days 6 update 1;', 'create database nsdbsql precision "ns" keep 3600 duration 6 update 1;',
'use nsdbsql;', 'use nsdbsql;',
'CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupdId int);', 'CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupdId int);',
'CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2);', 'CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2);',

View File

@ -125,7 +125,7 @@ class TDTestCase:
tdSql.checkData(0, 0, 600) tdSql.checkData(0, 0, 600)
# check taosdemo -s # check taosdemo -s
sqls_ls = ['drop database if exists nsdbsql;','create database nsdbsql precision "ns" keep 36 days 6 update 1;', sqls_ls = ['drop database if exists nsdbsql;','create database nsdbsql precision "ns" keep 36 duration 6 update 1;',
'use nsdbsql;','CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupdId int);', 'use nsdbsql;','CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupdId int);',
'CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2);', 'CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2);',
'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 219, 0.32);', 'INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 219, 0.32);',

View File

@ -60,8 +60,8 @@ class TDTestCase:
if not os.path.exists("./taosdumptest/tmp2"): if not os.path.exists("./taosdumptest/tmp2"):
os.makedirs("./taosdumptest/tmp2") os.makedirs("./taosdumptest/tmp2")
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
tdSql.execute("create database db days 11 keep 3649 blocks 8 ") tdSql.execute("create database db duration 11 keep 3649 blocks 8 ")
tdSql.execute("create database db1 days 12 keep 3640 blocks 7 ") tdSql.execute("create database db1 duration 12 keep 3640 blocks 7 ")
tdSql.execute("use db") tdSql.execute("use db")
tdSql.execute( tdSql.execute(
"create table st(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))") "create table st(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int, t2 binary(10))")
@ -102,7 +102,7 @@ class TDTestCase:
tdSql.query("show databases") tdSql.query("show databases")
tdSql.checkRows(2) tdSql.checkRows(2)
dbresult = tdSql.queryResult dbresult = tdSql.queryResult
# 6--days,7--keep0,keep1,keep, 12--block, # 6--duration,7--keep0,keep1,keep, 12--block,
isCommunity = self.checkCommunity() isCommunity = self.checkCommunity()
print("iscommunity: %d" % isCommunity) print("iscommunity: %d" % isCommunity)

View File

@ -60,7 +60,7 @@ class TDTestCase:
def build_db(precision, start_time): def build_db(precision, start_time):
tdSql.execute("drop database if exists timedb1") tdSql.execute("drop database if exists timedb1")
tdSql.execute( tdSql.execute(
"create database timedb1 days 10 keep 365 blocks 8 precision "+"\""+precision+"\"") "create database timedb1 duration 10 keep 365 blocks 8 precision "+"\""+precision+"\"")
tdSql.execute("use timedb1") tdSql.execute("use timedb1")
tdSql.execute( tdSql.execute(

View File

@ -30,7 +30,7 @@ class TDTestCase:
tdSql.execute(s) tdSql.execute(s)
s = 'drop database if exists db' s = 'drop database if exists db'
tdSql.execute(s) tdSql.execute(s)
s = 'create database db days 30' s = 'create database db duration 30'
tdSql.execute(s) tdSql.execute(s)
s = 'use db' s = 'use db'
tdSql.execute(s) tdSql.execute(s)

View File

@ -30,7 +30,7 @@ class TDTestCase:
tdSql.execute(s) tdSql.execute(s)
s = 'drop database if exists db' s = 'drop database if exists db'
tdSql.execute(s) tdSql.execute(s)
s = 'create database db update 1 days 30' s = 'create database db update 1 duration 30'
tdSql.execute(s) tdSql.execute(s)
s = 'use db' s = 'use db'
tdSql.execute(s) tdSql.execute(s)

View File

@ -50,7 +50,7 @@ class TDTestCase:
tdSql.execute(sql) tdSql.execute(sql)
sql = 'drop database if exists db' sql = 'drop database if exists db'
tdSql.execute(sql) tdSql.execute(sql)
sql = 'create database db update 1 days 30;' sql = 'create database db update 1 duration 30;'
tdSql.execute(sql) tdSql.execute(sql)
sql = 'use db;' sql = 'use db;'
tdSql.execute(sql) tdSql.execute(sql)

View File

@ -49,7 +49,7 @@ class TDTestCase:
tdSql.execute(sql) tdSql.execute(sql)
sql = 'drop database if exists db' sql = 'drop database if exists db'
tdSql.execute(sql) tdSql.execute(sql)
sql = 'create database db update 0 days 30;' sql = 'create database db update 0 duration 30;'
tdSql.execute(sql) tdSql.execute(sql)
sql = 'use db;' sql = 'use db;'
tdSql.execute(sql) tdSql.execute(sql)

View File

@ -34,7 +34,7 @@ class TDTestCase:
def run(self): def run(self):
tdSql.prepare() tdSql.prepare()
tdSql.execute("create database udb update 1 days 30") tdSql.execute("create database udb update 1 duration 30")
tdSql.execute("use udb") tdSql.execute("use udb")
print("==============step 1: UPDATE THE LAST RECORD REPEATEDLY") print("==============step 1: UPDATE THE LAST RECORD REPEATEDLY")

View File

@ -57,7 +57,7 @@ class TDSql:
tdLog.notice("'reset query cache' is not supported") tdLog.notice("'reset query cache' is not supported")
s = 'drop database if exists db' s = 'drop database if exists db'
self.cursor.execute(s) self.cursor.execute(s)
s = 'create database db days 300' s = 'create database db duration 300'
self.cursor.execute(s) self.cursor.execute(s)
s = 'use db' s = 'use db'
self.cursor.execute(s) self.cursor.execute(s)

View File

@ -63,7 +63,7 @@ class TDTaosdemoCfg:
"name": 'db', "name": 'db',
"drop": 'yes', "drop": 'yes',
"replica": 1, "replica": 1,
"days": 10, "duration": 10,
"cache": 16, "cache": 16,
"blocks": 6, "blocks": 6,
"precision": "ms", "precision": "ms",

View File

@ -9,7 +9,7 @@ sleep 2000
sql connect sql connect
print ============= create database print ============= create database
sql create database db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 sql create database db cache 2 blocks 4 duration 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1
sql show databases sql show databases
if $data00 != db then if $data00 != db then
return -1 return -1
@ -87,13 +87,13 @@ sql_error alter database db quorum 4
sql_error alter database db quorum 5 sql_error alter database db quorum 5
sql_error alter database db quorum -1 sql_error alter database db quorum -1
print ============== step days print ============== step duration
sql_error alter database db days 0 sql_error alter database db duration 0
sql_error alter database db days 1 sql_error alter database db duration 1
sql_error alter database db days 2 sql_error alter database db duration 2
sql_error alter database db days 10 sql_error alter database db duration 10
sql_error alter database db days 50 sql_error alter database db duration 50
sql_error alter database db days 100 sql_error alter database db duration 100
print ============== step keep print ============== step keep
sql show databases sql show databases

View File

@ -26,7 +26,7 @@ system sh/exec.sh -n dnode2 -s start
sleep 2000 sleep 2000
print ======== step1 create db print ======== step1 create db
sql create database keepdb replica 1 keep 30 days 7 sql create database keepdb replica 1 keep 30 duration 7
sql use keepdb sql use keepdb
sql create table tb (ts timestamp, i int) sql create table tb (ts timestamp, i int)
@ -201,7 +201,7 @@ sql alter database keepdb keep 0 -x error2
return -1 return -1
error2: error2:
sql alter database keepdb days 1 -x error3 sql alter database keepdb duration 1 -x error3
return -1 return -1
error3: error3:

View File

@ -171,7 +171,7 @@ sql_error create topic t1 partitions -1;
sql_error create topic t1 partitions 10001; sql_error create topic t1 partitions 10001;
print =============step3 create with db para print =============step3 create with db para
sql create topic db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 sql create topic db cache 2 blocks 4 duration 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1
sql show databases sql show databases
if $data00 != db then if $data00 != db then
return -1 return -1
@ -199,7 +199,7 @@ if $data09 != 4 then
endi endi
sql drop topic db; sql drop topic db;
sql create topic db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 partitions 7 sql create topic db cache 2 blocks 4 duration 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 partitions 7
sql show databases sql show databases
if $data00 != db then if $data00 != db then
return -1 return -1
@ -334,19 +334,19 @@ sql_error alter topic db quorum 4
sql_error alter topic db quorum 5 sql_error alter topic db quorum 5
sql_error alter topic db quorum -1 sql_error alter topic db quorum -1
print ============== step days print ============== step duration
sql_error alter database db days 0 sql_error alter database db duration 0
sql_error alter database db days 1 sql_error alter database db duration 1
sql_error alter database db days 2 sql_error alter database db duration 2
sql_error alter database db days 10 sql_error alter database db duration 10
sql_error alter database db days 50 sql_error alter database db duration 50
sql_error alter database db days 100 sql_error alter database db duration 100
sql_error alter topic db days 0 sql_error alter topic db duration 0
sql_error alter topic db days 1 sql_error alter topic db duration 1
sql_error alter topic db days 2 sql_error alter topic db duration 2
sql_error alter topic db days 10 sql_error alter topic db duration 10
sql_error alter topic db days 50 sql_error alter topic db duration 50
sql_error alter topic db days 100 sql_error alter topic db duration 100
print ============== step keep print ============== step keep
sql show databases sql show databases

View File

@ -30,7 +30,7 @@ sleep 2000
sql connect sql connect
print ========= step1 print ========= step1
sql create database ic1db days 7; sql create database ic1db duration 7;
sql create table ic1db.tb(ts timestamp, s int); sql create table ic1db.tb(ts timestamp, s int);
sql insert into ic1db.tb values(now-30d, -30); sql insert into ic1db.tb values(now-30d, -30);
sql insert into ic1db.tb values(now-20d, -20); sql insert into ic1db.tb values(now-20d, -20);
@ -50,7 +50,7 @@ if $rows != 12 then
endi endi
print ========= step2 print ========= step2
sql create database ic2db days 7; sql create database ic2db duration 7;
sql create table ic2db.tb(ts timestamp, s int); sql create table ic2db.tb(ts timestamp, s int);
sql insert into ic2db.tb values(now, 0); sql insert into ic2db.tb values(now, 0);
sql import into ic2db.tb values(now-30d, -30); sql import into ic2db.tb values(now-30d, -30);

View File

@ -30,7 +30,7 @@ system sh/exec.sh -n dnode1 -s start
sleep 2000 sleep 2000
sql connect sql connect
sql create database ir1db days 7 sql create database ir1db duration 7
sql use ir1db sql use ir1db
sql create table tb(ts timestamp, i bigint) sql create table tb(ts timestamp, i bigint)

View File

@ -20,7 +20,7 @@ $db = $dbPrefix . $i
$mt = $mtPrefix . $i $mt = $mtPrefix . $i
sql drop database if exists $db sql drop database if exists $db
sql create database $db days 10 keep 20,20,20 sql create database $db duration 10 keep 20,20,20
sql use $db sql use $db
sql_error alter database $db keep "20" sql_error alter database $db keep "20"

View File

@ -20,7 +20,7 @@ $db = $dbPrefix . $i
$mt = $mtPrefix . $i $mt = $mtPrefix . $i
sql drop database if exists $db sql drop database if exists $db
sql create database $db days 10 keep 20 sql create database $db duration 10 keep 20
sql use $db sql use $db
sql show databases sql show databases
if $rows != 1 then if $rows != 1 then

View File

@ -101,7 +101,7 @@ print db_already_exists test passed
print create_db.sim case5: db_meta_data test print create_db.sim case5: db_meta_data test
# cfg params # cfg params
$replica = 1 # max=3 $replica = 1 # max=3
$days = 10 $duration = 10
$keep = 365,365,365 $keep = 365,365,365
$rows_db = 1000 $rows_db = 1000
$cache = 16 # 16MB $cache = 16 # 16MB
@ -111,7 +111,7 @@ $ctime = 36000 # 10 hours
$wal = 1 # valid value is 1, 2 $wal = 1 # valid value is 1, 2
$comp = 1 # max=32, automatically trimmed when exceeding $comp = 1 # max=32, automatically trimmed when exceeding
sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache blocks 4 ctime $ctime wal $wal comp $comp sql create database $db replica $replica duration $duration keep $keep maxrows $rows_db cache $cache blocks 4 ctime $ctime wal $wal comp $comp
sql show databases sql show databases
if $rows != 1 then if $rows != 1 then
return -1 return -1
@ -122,7 +122,7 @@ endi
if $data04 != $replica then if $data04 != $replica then
return -1 return -1
endi endi
if $data06 != $days then if $data06 != $duration then
return -1 return -1
endi endi
if $data07 != 365,365,365 then if $data07 != 365,365,365 then

View File

@ -101,7 +101,7 @@ print db_already_exists test passed
print create_db.sim case5: db_meta_data test print create_db.sim case5: db_meta_data test
# cfg params # cfg params
$replica = 1 # max=3 $replica = 1 # max=3
$days = 10 $duration = 10
$keep = 365 $keep = 365
$rows_db = 1000 $rows_db = 1000
$cache = 16 # 16MB $cache = 16 # 16MB
@ -111,7 +111,7 @@ $ctime = 36000 # 10 hours
$wal = 1 # valid value is 1, 2 $wal = 1 # valid value is 1, 2
$comp = 1 # max=32, automatically trimmed when exceeding $comp = 1 # max=32, automatically trimmed when exceeding
sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache blocks 4 ctime $ctime wal $wal comp $comp sql create database $db replica $replica duration $duration keep $keep maxrows $rows_db cache $cache blocks 4 ctime $ctime wal $wal comp $comp
sql show databases sql show databases
if $rows != 1 then if $rows != 1 then
return -1 return -1
@ -122,7 +122,7 @@ endi
if $data04 != $replica then if $data04 != $replica then
return -1 return -1
endi endi
if $data06 != $days then if $data06 != $duration then
return -1 return -1
endi endi
if $data07 != 365 then if $data07 != 365 then

View File

@ -58,7 +58,7 @@
# ---- mnode # ---- mnode
./test.sh -f tsim/mnode/basic1.sim ./test.sh -f tsim/mnode/basic1.sim
./test.sh -f tsim/mnode/basic2.sim ./test.sh -f tsim/mnode/basic2.sim
#./test.sh -f tsim/mnode/basic3.sim ./test.sh -f tsim/mnode/basic3.sim
./test.sh -f tsim/mnode/basic4.sim ./test.sh -f tsim/mnode/basic4.sim
./test.sh -f tsim/mnode/basic5.sim ./test.sh -f tsim/mnode/basic5.sim
@ -132,7 +132,7 @@
#./test.sh -f tsim/mnode/basic1.sim -m #./test.sh -f tsim/mnode/basic1.sim -m
# --- sma # --- sma
#./test.sh -f tsim/sma/tsmaCreateInsertData.sim ./test.sh -f tsim/sma/tsmaCreateInsertData.sim
./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim ./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim
# --- valgrind # --- valgrind

View File

@ -62,11 +62,11 @@ print ============= create database
# | PAGES value [64~16384, default: 256] # | PAGES value [64~16384, default: 256]
# | CACHELAST value [0, 1, 2, 3] # | CACHELAST value [0, 1, 2, 3]
# | FSYNC value [0 ~ 180000 ms] # | FSYNC value [0 ~ 180000 ms]
# | KEEP value [days, 365000] # | KEEP value [duration, 365000]
# | REPLICA value [1 | 3] # | REPLICA value [1 | 3]
# | WAL value [1 | 2] # | WAL value [1 | 2]
sql create database db CACHELAST 3 COMP 0 DAYS 240 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1000 PRECISION 'ns' REPLICA 3 WAL 2 VGROUPS 6 SINGLE_STABLE 1 sql create database db CACHELAST 3 COMP 0 DURATION 240 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1000 PRECISION 'ns' REPLICA 3 WAL 2 VGROUPS 6 SINGLE_STABLE 1
sql show databases sql show databases
print rows: $rows print rows: $rows
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
@ -92,7 +92,7 @@ endi
if $data5_db != no_strict then # strict if $data5_db != no_strict then # strict
return -1 return -1
endi endi
if $data6_db != 345600 then # days if $data6_db != 345600 then # duration
return -1 return -1
endi endi
if $data7_db != 1440000m,1440000m,1440000m then # keep if $data7_db != 1440000m,1440000m,1440000m then # keep
@ -222,11 +222,11 @@ sql_error alter database db replica 0
#sql_error alter database db quorum 4 #sql_error alter database db quorum 4
#sql_error alter database db quorum 5 #sql_error alter database db quorum 5
#print ============== modify days #print ============== modify duration
sql_error alter database db days 480 sql_error alter database db duration 480
sql_error alter database db days 360 sql_error alter database db duration 360
sql_error alter database db days 0 sql_error alter database db duration 0
sql_error alter database db days 14400 # set over than keep sql_error alter database db duration 14400 # set over than keep
print ============== modify keep print ============== modify keep
sql alter database db keep 2400 sql alter database db keep 2400

View File

@ -15,7 +15,7 @@ $tb = $tbPrefix . $i
print =============== step1 print =============== step1
# quorum presicion # quorum presicion
sql create database $db vgroups 8 replica 1 days 2 keep 10 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us' sql create database $db vgroups 8 replica 1 duration 2 keep 10 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us'
sql show databases sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
@ -66,7 +66,7 @@ print =============== step4
sql_error drop database $db sql_error drop database $db
print =============== step5 print =============== step5
sql create database $db replica 1 days 15 keep 1500 sql create database $db replica 1 duration 15 keep 1500
sql show databases sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07
if $data20 != $db then if $data20 != $db then

View File

@ -63,7 +63,7 @@ print ============= create database with all options
# | PAGESIZE value [1~16384, default: 4] # | PAGESIZE value [1~16384, default: 4]
# | CACHELAST value [0, 1, 2, 3, default: 0] # | CACHELAST value [0, 1, 2, 3, default: 0]
# | COMP [0 | 1 | 2, default: 2] # | COMP [0 | 1 | 2, default: 2]
# | DAYS value [60m ~ min(3650d,keep), default: 10d, unit may be minut/hour/day] # | DURATION value [60m ~ min(3650d,keep), default: 10d, unit may be minut/hour/day]
# | FSYNC value [0 ~ 180000 ms, default: 3000] # | FSYNC value [0 ~ 180000 ms, default: 3000]
# | MAXROWS value [200~10000, default: 4096] # | MAXROWS value [200~10000, default: 4096]
# | MINROWS value [10~1000, default: 100] # | MINROWS value [10~1000, default: 100]
@ -79,7 +79,7 @@ print ============= create database with all options
#$data2_db : vgroups #$data2_db : vgroups
#$data3_db : ntables #$data3_db : ntables
#$data4_db : replica #$data4_db : replica
#$data6_db : days #$data6_db : duration
#$data7_db : keep #$data7_db : keep
#$data10_db : minrows #$data10_db : minrows
#$data11_db : maxrows #$data11_db : maxrows
@ -113,7 +113,7 @@ endi
if $data5_db != no_strict then # strict if $data5_db != no_strict then # strict
return -1 return -1
endi endi
if $data6_db != 14400 then # days if $data6_db != 14400 then # duration
return -1 return -1
endi endi
if $data7_db != 5256000m,5256000m,5256000m then # keep if $data7_db != 5256000m,5256000m,5256000m then # keep
@ -234,9 +234,9 @@ sql drop database db
sql_error create database db COMP 3 sql_error create database db COMP 3
sql_error create database db COMP -1 sql_error create database db COMP -1
#print ====> DAYS value [60m ~ min(3650d,keep), default: 10d, unit may be minut/hour/day] #print ====> DURATION value [60m ~ min(3650d,keep), default: 10d, unit may be minut/hour/day]
#print ====> KEEP value [max(1d ~ 365000d), default: 1d, unit may be minut/hour/day] #print ====> KEEP value [max(1d ~ 365000d), default: 1d, unit may be minut/hour/day]
#sql create database db DAYS 60m KEEP 60m #sql create database db DURATION 60m KEEP 60m
#sql show databases #sql show databases
#print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db #print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#if $data6_db != 60 then #if $data6_db != 60 then
@ -246,7 +246,7 @@ sql_error create database db COMP -1
# return -1 # return -1
#endi #endi
#sql drop database db #sql drop database db
#sql create database db DAYS 60m KEEP 1d #sql create database db DURATION 60m KEEP 1d
#sql show databases #sql show databases
#print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db #print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#if $data6_db != 60 then #if $data6_db != 60 then
@ -255,7 +255,7 @@ sql_error create database db COMP -1
#if $data7_db != 1440,1440,1440 then #if $data7_db != 1440,1440,1440 then
# return -1 # return -1
#endi #endi
#sql create database db DAYS 3650d KEEP 365000d #sql create database db DURATION 3650d KEEP 365000d
#sql show databases #sql show databases
#print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db #print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
#if $data6_db != 5256000 then #if $data6_db != 5256000 then
@ -265,10 +265,10 @@ sql_error create database db COMP -1
# return -1 # return -1
#endi #endi
#sql drop database db #sql drop database db
#sql_error create database db DAYS -59m #sql_error create database db DURATION -59m
#sql_error create database db DAYS 59m #sql_error create database db DURATION 59m
#sql_error create database db DAYS 5256001m #sql_error create database db DURATION 5256001m
#sql_error create database db DAYS 3651d #sql_error create database db DURATION 3651d
#sql_error create database db KEEP -59m #sql_error create database db KEEP -59m
#sql_error create database db KEEP 14399m #sql_error create database db KEEP 14399m
#sql_error create database db KEEP 525600001m #sql_error create database db KEEP 525600001m

View File

@ -163,26 +163,22 @@ endi
print =============== step32: move follower2 print =============== step32: move follower2
print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
=======
sql show d1.vgroups sql show d1.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
sql show d1.tables sql show d1.tables
if $rows != 1 then if $rows != 1 then
return -1 return -1
endi endi
return
print =============== step33: move follower1 print =============== step33: move follower1
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
=======
sql show d1.vgroups sql show d1.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
sql show d1.tables sql show d1.tables
if $rows != 1 then if $rows != 1 then
return -1 return -1
@ -191,12 +187,9 @@ endi
print =============== step34: move follower2 print =============== step34: move follower2
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
=======
sql show d1.vgroups sql show d1.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
sql show d1.tables sql show d1.tables
if $rows != 1 then if $rows != 1 then
return -1 return -1
@ -205,15 +198,8 @@ endi
print =============== step35: move follower1 print =============== step35: move follower1
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
sql show d1.tables
if $rows != 1 then
return -1
endi
=======
sql show d1.vgroups sql show d1.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
sql show d1.tables sql show d1.tables
if $rows != 1 then if $rows != 1 then
@ -242,8 +228,6 @@ if $rows != 1 then
return -1 return -1
endi endi
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
=======
print =============== step38: move follower2 print =============== step38: move follower2
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
@ -254,7 +238,6 @@ sql show d1.tables
if $rows != 1 then if $rows != 1 then
return -1 return -1
endi endi
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
print =============== step39: move follower1 print =============== step39: move follower1
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1

View File

@ -5,7 +5,7 @@ sleep 50
sql connect sql connect
print =============== create database print =============== create database
sql create database db days 300 keep 365000d,365000d,365000d sql create database db duration 300 keep 365000d,365000d,365000d
sql show databases sql show databases
if $rows != 3 then if $rows != 3 then
return -1 return -1

View File

@ -5,7 +5,7 @@ sleep 500
sql connect sql connect
print =============== create database print =============== create database
sql create database d0 days 300 sql create database d0 duration 300
sql use d0 sql use d0
print =============== create super table and child table print =============== create super table and child table

View File

@ -37,6 +37,14 @@ print =============== trigger stream to execute sma aggr task and insert sma dat
sql insert into ct1 values(now+5s, 20, 20.0, 30.0) sql insert into ct1 values(now+5s, 20, 20.0, 30.0)
#=================================================================== #===================================================================
print =============== show streams ================================
sql show streams;
print $data00 $data01 $data02
if $data00 != d1 then
return -1
endi
print =============== select * from ct1 from memory print =============== select * from ct1 from memory
sql select * from ct1; sql select * from ct1;
print $data00 $data01 print $data00 $data01

View File

@ -6,7 +6,7 @@ system sh/exec.sh -n dnode1 -s start
sql connect sql connect
print ======== step1 print ======== step1
sql create database d1 replica 1 days 7 keep 50 sql create database d1 replica 1 duration 7 keep 50
sql use d1 sql use d1
sql create table tb (ts timestamp, a int) sql create table tb (ts timestamp, a int)
sql insert into tb values(now-28d, -28) sql insert into tb values(now-28d, -28)

View File

@ -6,7 +6,7 @@ system sh/exec.sh -n dnode1 -s start
sql connect sql connect
print ======== step1 print ======== step1
sql create database d1 replica 1 days 7 keep 50 sql create database d1 replica 1 duration 7 keep 50
sql use d1 sql use d1
sql create table tb (ts timestamp, a int) sql create table tb (ts timestamp, a int)
sql insert into tb values(now-30d, -28) sql insert into tb values(now-30d, -28)

View File

@ -37,7 +37,7 @@ run tsim/db/error1.sim
run tsim/db/taosdlog.sim run tsim/db/taosdlog.sim
run tsim/db/alter_option.sim run tsim/db/alter_option.sim
run tsim/mnode/basic1.sim run tsim/mnode/basic1.sim
run tsim/mnode/basic3.sim #run tsim/mnode/basic3.sim
run tsim/mnode/basic2.sim run tsim/mnode/basic2.sim
run tsim/parser/fourArithmetic-basic.sim run tsim/parser/fourArithmetic-basic.sim
run tsim/parser/groupby-basic.sim run tsim/parser/groupby-basic.sim

View File

@ -7,44 +7,28 @@ system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
sql connect sql connect
print =============== show dnodes
sql show dnodes;
if $rows != 1 then
return -1
endi
if $data00 != 1 then
return -1
endi
sql show mnodes;
if $rows != 1 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data02 != leader then
return -1
endi
print =============== create dnodes print =============== create dnodes
sql create dnode $hostname port 7200 sql create dnode $hostname port 7200
sleep 2000
sql show dnodes; $x = 0
if $rows != 2 then step1:
return -1 $x = $x + 1
endi sleep 1000
if $x == 10 then
if $data00 != 1 then print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
return -1 return -1
endi endi
if $data(1)[4] != ready then
if $data10 != 2 then goto step1
return -1 endi
if $data(2)[4] != ready then
goto step1
endi endi
print =============== kill dnode2 print =============== kill dnode2
@ -68,7 +52,7 @@ if $data[0][0] != 7 then
return -1 return -1
endi endi
if $data[0][2] != undoAction then if $data[0][2] != redoAction then
return -1 return -1
endi endi
@ -80,14 +64,34 @@ sql_error create database d1 vgroups 2;
print =============== start dnode2 print =============== start dnode2
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
sleep 3000
$x = 0
step2:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
return -1
endi
if $data(1)[4] != ready then
goto step2
endi
if $data(2)[4] != ready then
goto step2
endi
sql show transactions sql show transactions
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
sql create database d1 vgroups 2; sql_error create database d1 vgroups 2;
print =============== kill dnode2 print =============== kill dnode2
system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT
@ -106,22 +110,31 @@ if $rows != 1 then
return -1 return -1
endi endi
if $data[0][0] != 9 then if $data[0][0] != 8 then
return -1 return -1
endi endi
if $data[0][2] != undoAction then if $data[0][2] != redoAction then
return -1 return -1
endi endi
if $data[0][3] != d2 then if $data[0][3] != d2 then
return -1 return -1
endi endi
return
sql show databases ;
if $rows != 4 then
return -1
endi
print d2 ==> $data(d2)[19]
if $data(d2)[19] != creating then
return -1
endi
sql_error create database d2 vgroups 2; sql_error create database d2 vgroups 2;
print =============== kill transaction print =============== kill transaction
sql kill transaction 9; sql kill transaction 8;
sleep 2000 sleep 2000
sql show transactions sql show transactions
@ -131,7 +144,34 @@ endi
print =============== start dnode2 print =============== start dnode2
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
sleep 3000
$x = 0
step3:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
return -1
endi
if $data(1)[4] != ready then
goto step3
endi
if $data(2)[4] != ready then
goto step3
endi
sql show transactions
if $rows != 0 then
return -1
endi
sql drop database d2;
sql show transactions sql show transactions
if $rows != 0 then if $rows != 0 then
@ -145,6 +185,5 @@ sql_error kill transaction 3;
sql_error kill transaction 4; sql_error kill transaction 4;
sql_error kill transaction 5; sql_error kill transaction 5;
return
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT

View File

@ -24,7 +24,7 @@ system sh/exec.sh -n dnode2 -s start
sleep 2000 sleep 2000
print ======== step1 create db print ======== step1 create db
sql create database commitdb replica 1 days 7 keep 30 sql create database commitdb replica 1 duration 7 keep 30
sql use commitdb sql use commitdb
sql create table tb (ts timestamp, i int) sql create table tb (ts timestamp, i int)

View File

@ -52,7 +52,7 @@ if $data4_2 != ready then
goto step1 goto step1
endi endi
sql create database ir2db replica 2 days 7 sql create database ir2db replica 2 duration 7
sql use ir2db sql use ir2db
sql create table tb(ts timestamp, i bigint) sql create table tb(ts timestamp, i bigint)

View File

@ -58,7 +58,7 @@ if $data4_3 != ready then
goto step1 goto step1
endi endi
sql create database ir3db replica 3 days 7 sql create database ir3db replica 3 duration 7
sql use ir3db sql use ir3db
sql create table tb(ts timestamp, i bigint) sql create table tb(ts timestamp, i bigint)

View File

@ -17,7 +17,7 @@ $db = $dbPrefix . $i
$tb = $tbPrefix . $i $tb = $tbPrefix . $i
print =============== step1 print =============== step1
sql create database $db replica 1 days 20 keep 2000 cache 16 sql create database $db replica 1 duration 20 keep 2000 cache 16
sql show databases sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07
if $data00 != $db then if $data00 != $db then
@ -57,7 +57,7 @@ print =============== step4
sql_error drop database $db sql_error drop database $db
print =============== step5 print =============== step5
sql create database $db replica 1 days 15 keep 1500 sql create database $db replica 1 duration 15 keep 1500
sql show databases sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07
if $data00 != $db then if $data00 != $db then

View File

@ -48,21 +48,21 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key
#output = child.readline() #output = child.readline()
#print (output.decode()) #print (output.decode())
if len(expectString) != 0: if len(expectString) != 0:
i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=6) i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=20)
else: else:
i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=6) i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=20)
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
retResult = child.before retResult = child.before
else: else:
retResult = child.before.decode() retResult = child.before.decode()
print("cmd return result:\n%s\n"%retResult) print("cmd return result:\n%s\n"%retResult)
#print(child.after.decode()) # print(child.after.decode())
if i == 0: if i == 0:
print ('taos login success! Here can run sql, taos> ') print ('taos login success! Here can run sql, taos> ')
if len(sqlString) != 0: if len(sqlString) != 0:
child.sendline (sqlString) child.sendline (sqlString)
w = child.expect(["Query OK", taosExpect.TIMEOUT, taosExpect.EOF], timeout=1) w = child.expect(["Query OK", taosExpect.TIMEOUT, taosExpect.EOF], timeout=10)
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
retResult = child.before retResult = child.before
else: else:

View File

@ -60,7 +60,7 @@ class TDTestCase:
def prepare_data(self): def prepare_data(self):
tdSql.execute("drop database if exists db ") tdSql.execute("drop database if exists db ")
tdSql.execute("create database if not exists db days 300") tdSql.execute("create database if not exists db duration 300")
tdSql.execute("use db") tdSql.execute("use db")
tdSql.execute( tdSql.execute(
'''create table stb1 '''create table stb1

View File

@ -63,7 +63,7 @@ class TDTestCase:
def prepare_data(self): def prepare_data(self):
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
tdSql.execute("create database if not exists db replica 1 days 300") tdSql.execute("create database if not exists db replica 1 duration 300")
tdSql.execute("use db") tdSql.execute("use db")
tdSql.execute( tdSql.execute(
'''create table stb1 '''create table stb1

View File

@ -62,7 +62,7 @@ class TDTestCase:
def prepare_data(self): def prepare_data(self):
tdSql.execute("drop database if exists db ") tdSql.execute("drop database if exists db ")
tdSql.execute("create database if not exists db days 300") tdSql.execute("create database if not exists db duration 300")
tdSql.execute("use db") tdSql.execute("use db")
tdSql.execute( tdSql.execute(
'''create table stb1 '''create table stb1

View File

@ -59,7 +59,7 @@ class TDTestCase:
def prepare_data(self): def prepare_data(self):
tdSql.execute("drop database if exists db ") tdSql.execute("drop database if exists db ")
tdSql.execute("create database if not exists db days 300") tdSql.execute("create database if not exists db duration 300")
tdSql.execute("use db") tdSql.execute("use db")
tdSql.execute( tdSql.execute(
'''create table stb1 '''create table stb1

View File

@ -0,0 +1,254 @@
import datetime
from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import *
PRIMARY_COL = "ts"
INT_COL = "c_int"
BINT_COL = "c_bint"
SINT_COL = "c_sint"
TINT_COL = "c_tint"
FLOAT_COL = "c_float"
DOUBLE_COL = "c_double"
BOOL_COL = "c_bool"
TINT_UN_COL = "c_tint_un"
SINT_UN_COL = "c_sint_un"
BINT_UN_COL = "c_bint_un"
INT_UN_COL = "c_int_un"
BINARY_COL = "c8"
NCHAR_COL = "c9"
TS_COL = "c10"
NUM_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ]
CHAR_COL = [ BINARY_COL, NCHAR_COL, ]
BOOLEAN_COL = [ BOOL_COL, ]
TS_TYPE_COL = [ TS_COL, ]
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor(), True)
@property
def create_databases_sql_err(self):
return [
"create database if not exists db1 retentions 0s:1d",
"create database if not exists db1 retentions 1s:1y",
"create database if not exists db1 retentions 1s:1n",
"create database if not exists db1 retentions 1s:1n,2s:2d,3s:3d,4s:4d",
]
@property
def create_databases_sql_current(self):
return [
"create database db1 retentions 1s:1d",
"create database db2 retentions 1s:1d,2m:2d,3h:3d",
]
@property
def alter_database_sql(self):
return [
"alter database db1 retentions 99h:99d",
"alter database db2 retentions 97h:97d,98h:98d,99h:99d,",
]
@property
def create_stable_sql_err(self):
return [
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) delay 1",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) delay 1",
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) delay 1",
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) rollup(avg) delay 1",
]
@property
def create_stable_sql_current(self):
return [
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(avg) delay 5",
]
def test_create_stb(self):
tdSql.execute("use db2")
for err_sql in self.create_stable_sql_err:
tdSql.error(err_sql)
for cur_sql in self.create_stable_sql_current:
tdSql.execute(cur_sql)
tdSql.query("show stables")
tdSql.checkRows(len(self.create_stable_sql_current))
def test_create_databases(self):
for err_sql in self.create_databases_sql_err:
tdSql.error(err_sql)
for cur_sql in self.create_databases_sql_current:
tdSql.execute(cur_sql)
tdSql.query("show databases")
for alter_sql in self.alter_database_sql:
tdSql.error(alter_sql)
def all_test(self):
self.test_create_databases()
self.test_create_stb()
def __create_tb(self):
tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp,
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
) tags (t1 int)
'''
create_ntb_sql = f'''create table t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp,
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
)
'''
tdSql.execute(create_stb_sql)
tdSql.execute(create_ntb_sql)
for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
def __create_data_set(self, rows):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
pos_data = []
neg_data = []
spec_data = []
for i in range(rows):
pos_data.append(
(
now_time - i * 1000, i, 11111 * i, 111 * i % 32767 , 11 * i % 127, 1.11 * i, 1100.0011 * i,
i % 2, f'binary{i}', f'nchar_测试_{i}', now_time + 1 * i, 11 * i % 127, 111 * i % 32767, i, 11111 * i
)
)
neg_data.append(
(
now_time - i * 7776000000, -i, -11111 * i, -111 * i % 32767, -11 * i % 127, -1.11 * i, -1100.0011 * i,
i % 2, f'binary{i}', f'nchar_测试_{i}', now_time + 1 * i, 11 * i % 127, 111 * i % 32767, i, 11111 * i
)
)
def __insert_data(self, rows):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows):
tdSql.execute(
f'''insert into ct1 values (
{ now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i},
{i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i }, {11 * i % 127}, {111 * i % 32767}, {i}, {11111 * i} )'''
)
tdSql.execute(
f'''insert into ct4 values (
{ now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i},
{i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i }, {11 * i % 127}, {111 * i % 32767}, {i}, {11111 * i} )'''
)
tdSql.execute(
f'''insert into ct2 values (
{ now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i},
{i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i }, {11 * i % 127}, {111 * i % 32767}, {i}, {11111 * i} )'''
)
tdSql.execute(
f'''insert into ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 }, 0, 0, 0, 0)
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 }, 0, 0, 0, 0 )
'''
)
tdSql.execute(
f'''insert into ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{ now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127,
{ 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000},
254, 65534, {pow(2,32)-pow(2,16)}, {pow(2,64)-pow(2,31)}
)
(
{ now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126,
{ 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000},
255, 65535, {pow(2,32)-pow(2,15)}, {pow(2,64)-pow(2,30)}
)
'''
)
tdSql.execute(
f'''insert into ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{ now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126, { -1 * 3.2 * pow(10,38) },
{ -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }, 1, 1, 1, 1
)
(
{ now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127, { - 3.3 * pow(10,38) },
{ -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }, 1, 1, 1, 1
)
'''
)
for i in range(rows):
insert_data = f'''insert into t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i }, {i % 127}, {i % 32767}, {i}, {i * 11111})
'''
tdSql.execute(insert_data)
tdSql.execute(
f'''insert into t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{ now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127, { 3.3 * pow(10,38) },
{ 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 },
254, 65534, {pow(2,32)-pow(2,16)}, {pow(2,64)-pow(2,31)}
)
(
{ now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126, { 3.2 * pow(10,38) },
{ 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 },
255, 65535, {pow(2,32)-pow(2,15)}, {pow(2,64)-pow(2,30)}
)
'''
)
def run(self):
tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table")
self.__create_tb()
tdLog.printNoPrefix("==========step2:insert data")
self.rows = 10
self.__insert_data(self.rows)
tdLog.printNoPrefix("==========step3:all check")
self.all_test()
tdSql.execute("drop database if exists db1 ")
tdSql.execute("drop database if exists db2 ")
tdDnodes.stop(1)
tdDnodes.start(1)
tdSql.execute("use db")
tdLog.printNoPrefix("==========step4:after wal, all check again ")
self.all_test()
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -68,7 +68,7 @@ class TDTestCase:
def prepare_tag_datas(self): def prepare_tag_datas(self):
# prepare datas # prepare datas
tdSql.execute("create database if not exists testdb keep 3650 days 1000") tdSql.execute("create database if not exists testdb keep 3650 duration 1000")
tdSql.execute(" use testdb ") tdSql.execute(" use testdb ")
tdSql.execute( tdSql.execute(
'''create table stb1 '''create table stb1

View File

@ -0,0 +1,357 @@
import datetime
from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import *
PRIMARY_COL = "ts"
INT_COL = "c1"
BINT_COL = "c2"
SINT_COL = "c3"
TINT_COL = "c4"
FLOAT_COL = "c5"
DOUBLE_COL = "c6"
BOOL_COL = "c7"
BINARY_COL = "c8"
NCHAR_COL = "c9"
TS_COL = "c10"
NUM_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ]
CHAR_COL = [ BINARY_COL, NCHAR_COL, ]
BOOLEAN_COL = [ BOOL_COL, ]
TS_TYPE_COL = [ TS_COL, ]
ALL_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BOOL_COL, BINARY_COL, NCHAR_COL, TS_COL ]
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor())
def __query_condition(self,tbname):
query_condition = [f"{tbname}.{col}" for col in ALL_COL]
for num_col in NUM_COL:
query_condition.extend(
(
f"abs( {tbname}.{num_col} )",
f"acos( {tbname}.{num_col} )",
f"asin( {tbname}.{num_col} )",
f"atan( {tbname}.{num_col} )",
f"avg( {tbname}.{num_col} )",
f"ceil( {tbname}.{num_col} )",
f"cos( {tbname}.{num_col} )",
f"count( {tbname}.{num_col} )",
f"floor( {tbname}.{num_col} )",
f"log( {tbname}.{num_col}, {tbname}.{num_col})",
f"max( {tbname}.{num_col} )",
f"min( {tbname}.{num_col} )",
f"pow( {tbname}.{num_col}, 2)",
f"round( {tbname}.{num_col} )",
f"sum( {tbname}.{num_col} )",
f"sin( {tbname}.{num_col} )",
f"sqrt( {tbname}.{num_col} )",
f"tan( {tbname}.{num_col} )",
f"cast( {tbname}.{num_col} as timestamp)",
)
)
query_condition.extend((f"{num_col} + {any_col}" for any_col in ALL_COL))
for char_col in CHAR_COL:
query_condition.extend(
(
f"sum(cast({tbname}.{char_col} as bigint ))",
f"max(cast({tbname}.{char_col} as bigint ))",
f"min(cast({tbname}.{char_col} as bigint ))",
f"avg(cast({tbname}.{char_col} as bigint ))",
)
)
query_condition.extend(
(
1010,
''' "test1234!@#$%^&*():'><?/.,][}{" ''',
"null"
)
)
return query_condition
def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False):
table_reference = tb_list[0]
join_condition = table_reference
join = "inner join" if INNER else "join"
for i in range(len(tb_list[1:])):
join_condition += f" {join} {tb_list[i+1]} on {table_reference}.{filter}={tb_list[i+1]}.{filter}"
return join_condition
def __where_condition(self, col=None, tbname=None, query_conditon=None):
if query_conditon and isinstance(query_conditon, str):
if query_conditon.startswith("count"):
query_conditon = query_conditon[6:-1]
elif query_conditon.startswith("max"):
query_conditon = query_conditon[4:-1]
elif query_conditon.startswith("sum"):
query_conditon = query_conditon[4:-1]
elif query_conditon.startswith("min"):
query_conditon = query_conditon[4:-1]
elif query_conditon.startswith("avg"):
query_conditon = query_conditon[4:-1]
if query_conditon:
return f" where {query_conditon} is not null"
if col in NUM_COL:
return f" where abs( {tbname}.{col} ) >= 0"
if col in CHAR_COL:
return f" where lower( {tbname}.{col} ) like 'bina%' or lower( {tbname}.{col} ) like '_cha%' "
if col in BOOLEAN_COL:
return f" where {tbname}.{col} in (false, true) "
if col in TS_TYPE_COL or col in PRIMARY_COL:
return f" where cast( {tbname}.{col} as binary(16) ) is not null "
return ""
def __group_condition(self, col, having = None):
if isinstance(col, str):
if col.startswith("count"):
col = col[6:-1]
elif col.startswith("max"):
col = col[4:-1]
elif col.startswith("sum"):
col = col[4:-1]
elif col.startswith("min"):
col = col[4:-1]
elif col.startswith("avg"):
col = col[4:-1]
return f" group by {col} having {having}" if having else f" group by {col} "
def __single_sql(self, select_clause, from_clause, where_condition="", group_condition=""):
if isinstance(select_clause, str) and "on" not in from_clause and select_clause.split(".")[0].split("(")[-1] != from_clause.split(".")[0]:
return
return f"explain select {select_clause} from {from_clause} {where_condition} {group_condition}"
@property
def __tb_list(self):
return [
"ct1",
"ct4",
"t1",
"ct2",
"stb1",
]
def sql_list(self):
sqls = []
__no_join_tblist = self.__tb_list
for tb in __no_join_tblist:
select_claus_list = self.__query_condition(tb)
for select_claus in select_claus_list:
group_claus = self.__group_condition(col=select_claus)
where_claus = self.__where_condition(query_conditon=select_claus)
having_claus = self.__group_condition(col=select_claus, having=f"{select_claus} is not null")
sqls.extend(
(
self.__single_sql(select_claus, tb, where_claus, having_claus),
self.__single_sql(select_claus, tb,),
self.__single_sql(select_claus, tb, where_condition=where_claus),
self.__single_sql(select_claus, tb, group_condition=group_claus),
)
)
# return filter(None, sqls)
return list(filter(None, sqls))
def __get_type(self, col):
if tdSql.cursor.istype(col, "BOOL"):
return "BOOL"
if tdSql.cursor.istype(col, "INT"):
return "INT"
if tdSql.cursor.istype(col, "BIGINT"):
return "BIGINT"
if tdSql.cursor.istype(col, "TINYINT"):
return "TINYINT"
if tdSql.cursor.istype(col, "SMALLINT"):
return "SMALLINT"
if tdSql.cursor.istype(col, "FLOAT"):
return "FLOAT"
if tdSql.cursor.istype(col, "DOUBLE"):
return "DOUBLE"
if tdSql.cursor.istype(col, "BINARY"):
return "BINARY"
if tdSql.cursor.istype(col, "NCHAR"):
return "NCHAR"
if tdSql.cursor.istype(col, "TIMESTAMP"):
return "TIMESTAMP"
if tdSql.cursor.istype(col, "JSON"):
return "JSON"
if tdSql.cursor.istype(col, "TINYINT UNSIGNED"):
return "TINYINT UNSIGNED"
if tdSql.cursor.istype(col, "SMALLINT UNSIGNED"):
return "SMALLINT UNSIGNED"
if tdSql.cursor.istype(col, "INT UNSIGNED"):
return "INT UNSIGNED"
if tdSql.cursor.istype(col, "BIGINT UNSIGNED"):
return "BIGINT UNSIGNED"
def explain_check(self):
sqls = self.sql_list()
tdLog.printNoPrefix("===step 1: curent case, must return query OK")
for i in range(len(sqls)):
tdLog.info(f"sql: {sqls[i]}")
tdSql.query(sqls[i])
def __test_current(self):
tdSql.query("explain select c1 from ct1")
tdSql.query("explain select 1 from ct2")
tdSql.query("explain select cast(ceil(c6) as bigint) from ct4 group by c6")
tdSql.query("explain select count(c3) from ct4 group by c7 having count(c3) > 0")
tdSql.query("explain select ct2.c3 from ct4 join ct2 on ct4.ts=ct2.ts")
tdSql.query("explain select c1 from stb1 where c1 is not null and c1 in (0, 1, 2) or c1 between 2 and 100 ")
self.explain_check()
def __test_error(self):
tdLog.printNoPrefix("===step 0: err case, must return err")
tdSql.error( "explain select hyperloglog(c1) from ct8" )
tdSql.error( "explain show databases " )
tdSql.error( "explain show stables " )
tdSql.error( "explain show tables " )
tdSql.error( "explain show vgroups " )
tdSql.error( "explain show dnodes " )
tdSql.error( '''explain select hyperloglog(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'])
from ct1
where ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null
group by ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10']
having ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null ''' )
def all_test(self):
self.__test_error()
self.__test_current()
def __create_tb(self):
tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
) tags (t1 int)
'''
create_ntb_sql = f'''create table t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
)
'''
tdSql.execute(create_stb_sql)
tdSql.execute(create_ntb_sql)
for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
{ i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}
def __insert_data(self, rows):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows):
tdSql.execute(
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f'''insert into ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
'''
)
tdSql.execute(
f'''insert into ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{ now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127,
{ 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000}
)
(
{ now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126,
{ 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000}
)
'''
)
tdSql.execute(
f'''insert into ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{ now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126,
{ -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }
)
(
{ now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127,
{ - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }
)
'''
)
for i in range(rows):
insert_data = f'''insert into t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
'''
tdSql.execute(insert_data)
tdSql.execute(
f'''insert into t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127,
{ 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 },
"binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }
)
(
{ now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126,
{ 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 },
"binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }
)
'''
)
def run(self):
tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table")
self.__create_tb()
tdLog.printNoPrefix("==========step2:insert data")
self.rows = 10
self.__insert_data(self.rows)
tdLog.printNoPrefix("==========step3:all check")
self.all_test()
tdDnodes.stop(1)
tdDnodes.start(1)
tdSql.execute("use db")
tdLog.printNoPrefix("==========step4:after wal, all check again ")
self.all_test()
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -1,365 +1,3 @@
import datetime
from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import *
PRIMARY_COL = "ts"
INT_COL = "c1"
BINT_COL = "c2"
SINT_COL = "c3"
TINT_COL = "c4"
FLOAT_COL = "c5"
DOUBLE_COL = "c6"
BOOL_COL = "c7"
BINARY_COL = "c8"
NCHAR_COL = "c9"
TS_COL = "c10"
NUM_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ]
CHAR_COL = [ BINARY_COL, NCHAR_COL, ]
BOOLEAN_COL = [ BOOL_COL, ]
TS_TYPE_COL = [ TS_COL, ]
ALL_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BOOL_COL, BINARY_COL, NCHAR_COL, TS_COL ]
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor())
def __query_condition(self,tbname):
query_condition = [f"cast({col} as bigint)" for col in ALL_COL]
for num_col in NUM_COL:
query_condition.extend(
(
f"{tbname}.{num_col}",
f"abs( {tbname}.{num_col} )",
f"acos( {tbname}.{num_col} )",
f"asin( {tbname}.{num_col} )",
f"atan( {tbname}.{num_col} )",
f"avg( {tbname}.{num_col} )",
f"ceil( {tbname}.{num_col} )",
f"cos( {tbname}.{num_col} )",
f"count( {tbname}.{num_col} )",
f"floor( {tbname}.{num_col} )",
f"log( {tbname}.{num_col}, {tbname}.{num_col})",
f"max( {tbname}.{num_col} )",
f"min( {tbname}.{num_col} )",
f"pow( {tbname}.{num_col}, 2)",
f"round( {tbname}.{num_col} )",
f"sum( {tbname}.{num_col} )",
f"sin( {tbname}.{num_col} )",
f"sqrt( {tbname}.{num_col} )",
f"tan( {tbname}.{num_col} )",
f"cast( {tbname}.{num_col} as timestamp)",
)
)
[ query_condition.append(f"{num_col} + {any_col}") for any_col in ALL_COL ]
for char_col in CHAR_COL:
query_condition.extend(
(
f"count({tbname}.{char_col})",
f"sum(cast({tbname}.{char_col}) as bigint)",
f"max(cast({tbname}.{char_col}) as bigint)",
f"min(cast({tbname}.{char_col}) as bigint)",
f"avg(cast({tbname}.{char_col}) as bigint)",
)
)
query_condition.extend(
(
1010,
)
)
return query_condition
def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False):
table_reference = tb_list[0]
join_condition = table_reference
join = "inner join" if INNER else "join"
for i in range(len(tb_list[1:])):
join_condition += f" {join} {tb_list[i+1]} on {table_reference}.{filter}={tb_list[i+1]}.{filter}"
return join_condition
def __where_condition(self, col=None, tbname=None, query_conditon=None):
if query_conditon and isinstance(query_conditon, str):
if query_conditon.startswith("count"):
query_conditon = query_conditon[6:-1]
elif query_conditon.startswith("max"):
query_conditon = query_conditon[4:-1]
elif query_conditon.startswith("sum"):
query_conditon = query_conditon[4:-1]
elif query_conditon.startswith("min"):
query_conditon = query_conditon[4:-1]
if query_conditon:
return f" where {query_conditon} is not null"
if col in NUM_COL:
return f" where abs( {tbname}.{col} ) >= 0"
if col in CHAR_COL:
return f" where lower( {tbname}.{col} ) like 'bina%' or lower( {tbname}.{col} ) like '_cha%' "
if col in BOOLEAN_COL:
return f" where {tbname}.{col} in (false, true) "
if col in TS_TYPE_COL or col in PRIMARY_COL:
return f" where cast( {tbname}.{col} as binary(16) ) is not null "
return ""
def __group_condition(self, col, having = None):
if isinstance(col, str):
if col.startswith("count"):
col = col[6:-1]
elif col.startswith("max"):
col = col[4:-1]
elif col.startswith("sum"):
col = col[4:-1]
elif col.startswith("min"):
col = col[4:-1]
return f" group by {col} having {having}" if having else f" group by {col} "
def __single_sql(self, select_clause, from_clause, where_condition="", group_condition=""):
if isinstance(select_clause, str) and "on" not in from_clause and select_clause.split(".")[0] != from_clause.split(".")[0]:
return
return f"select spread({select_clause}) from {from_clause} {where_condition} {group_condition}"
@property
def __tb_list(self):
return [
"ct1",
"ct4",
"t1",
"ct2",
"stb1",
]
def sql_list(self):
sqls = []
__no_join_tblist = self.__tb_list
for tb in __no_join_tblist:
select_claus_list = self.__query_condition(tb)
for select_claus in select_claus_list:
group_claus = self.__group_condition(col=select_claus)
where_claus = self.__where_condition(query_conditon=select_claus)
having_claus = self.__group_condition(col=select_claus, having=f"{select_claus} is not null")
sqls.extend(
(
self.__single_sql(select_claus, tb, where_claus, having_claus),
self.__single_sql(select_claus, tb,),
self.__single_sql(select_claus, tb, where_condition=where_claus),
self.__single_sql(select_claus, tb, group_condition=group_claus),
)
)
# return filter(None, sqls)
return list(filter(None, sqls))
def __get_type(self, col):
if tdSql.cursor.istype(col, "BOOL"):
return "BOOL"
if tdSql.cursor.istype(col, "INT"):
return "INT"
if tdSql.cursor.istype(col, "BIGINT"):
return "BIGINT"
if tdSql.cursor.istype(col, "TINYINT"):
return "TINYINT"
if tdSql.cursor.istype(col, "SMALLINT"):
return "SMALLINT"
if tdSql.cursor.istype(col, "FLOAT"):
return "FLOAT"
if tdSql.cursor.istype(col, "DOUBLE"):
return "DOUBLE"
if tdSql.cursor.istype(col, "BINARY"):
return "BINARY"
if tdSql.cursor.istype(col, "NCHAR"):
return "NCHAR"
if tdSql.cursor.istype(col, "TIMESTAMP"):
return "TIMESTAMP"
if tdSql.cursor.istype(col, "JSON"):
return "JSON"
if tdSql.cursor.istype(col, "TINYINT UNSIGNED"):
return "TINYINT UNSIGNED"
if tdSql.cursor.istype(col, "SMALLINT UNSIGNED"):
return "SMALLINT UNSIGNED"
if tdSql.cursor.istype(col, "INT UNSIGNED"):
return "INT UNSIGNED"
if tdSql.cursor.istype(col, "BIGINT UNSIGNED"):
return "BIGINT UNSIGNED"
def spread_check(self):
sqls = self.sql_list()
tdLog.printNoPrefix("===step 1: curent case, must return query OK")
for i in range(len(sqls)):
tdLog.info(f"sql: {sqls[i]}")
tdSql.query(sqls[i])
def __test_current(self):
tdSql.query("select spread(ts) from ct1")
tdSql.checkRows(1)
tdSql.query("select spread(c1) from ct2")
tdSql.checkRows(1)
tdSql.query("select spread(c1) from ct4 group by c1")
tdSql.checkRows(self.rows + 3)
tdSql.query("select spread(c1) from ct4 group by c7")
tdSql.checkRows(3)
tdSql.query("select spread(ct2.c1) from ct4 join ct2 on ct4.ts=ct2.ts")
tdSql.checkRows(1)
self.spread_check()
def __test_error(self):
tdLog.printNoPrefix("===step 0: err case, must return err")
tdSql.error( "select spread() from ct1" )
tdSql.error( "select spread(1, 2) from ct2" )
tdSql.error( f"select spread({NUM_COL[0]}, {NUM_COL[1]}) from ct4" )
tdSql.error( f"select spread({BOOLEAN_COL[0]}) from t1" )
tdSql.error( f"select spread({CHAR_COL[0]}) from stb1" )
# tdSql.error( ''' select spread(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'])
# from ct1
# where ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null
# group by ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10']
# having ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null ''' )
# tdSql.error( "select c1 from ct1 union select c1 from ct2 union select c1 from ct4 ")
def all_test(self):
self.__test_error()
self.__test_current()
def __create_tb(self):
tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
) tags (t1 int)
'''
create_ntb_sql = f'''create table t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
)
'''
tdSql.execute(create_stb_sql)
tdSql.execute(create_ntb_sql)
for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
{ i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}
def __insert_data(self, rows):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows):
tdSql.execute(
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f'''insert into ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
'''
)
tdSql.execute(
f'''insert into ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{ now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127,
{ 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000}
)
(
{ now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126,
{ 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000}
)
'''
)
tdSql.execute(
f'''insert into ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{ now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126,
{ -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }
)
(
{ now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127,
{ - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }
)
'''
)
for i in range(rows):
insert_data = f'''insert into t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
'''
tdSql.execute(insert_data)
tdSql.execute(
f'''insert into t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127,
{ 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 },
"binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }
)
(
{ now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126,
{ 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 },
"binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }
)
'''
)
def run(self):
tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table")
self.__create_tb()
tdLog.printNoPrefix("==========step2:insert data")
self.rows = 10
self.__insert_data(self.rows)
tdLog.printNoPrefix("==========step3:all check")
self.all_test()
tdDnodes.stop(1)
tdDnodes.start(1)
tdSql.execute("use db")
tdLog.printNoPrefix("==========step4:after wal, all check again ")
self.all_test()
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())
################################################################### ###################################################################
# Copyright (c) 2021 by TAOS Technologies, Inc. # Copyright (c) 2021 by TAOS Technologies, Inc.
@ -532,21 +170,21 @@ class TDTestCase:
tdSql.error('select histogram(tag_smallint, "user_input", "[1,3,5,7]", 0) from ctb;') tdSql.error('select histogram(tag_smallint, "user_input", "[1,3,5,7]", 0) from ctb;')
tdSql.error('select histogram(tag_smallint, "user_input", "[1,3,5,7]", 0) from tb;') tdSql.error('select histogram(tag_smallint, "user_input", "[1,3,5,7]", 0) from tb;')
tdSql.error('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from stb;') tdSql.query('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from stb;')
tdSql.error('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from ctb;') tdSql.query('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from ctb;')
tdSql.error('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from tb;') tdSql.query('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from tb;')
tdSql.error('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from stb;') tdSql.query('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from stb;')
tdSql.error('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from ctb;') tdSql.query('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from ctb;')
tdSql.error('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from tb;') tdSql.query('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from tb;')
tdSql.error('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from stb;') tdSql.query('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from stb;')
tdSql.error('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from ctb;') tdSql.query('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from ctb;')
tdSql.error('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from tb;') tdSql.query('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from tb;')
tdSql.error('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from stb;') tdSql.query('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from stb;')
tdSql.error('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from ctb;') tdSql.query('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from ctb;')
tdSql.error('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from tb;') tdSql.query('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from tb;')
tdSql.error('select histogram(tag_bool, "user_input", "[1,3,5,7]", 0) from stb;') tdSql.error('select histogram(tag_bool, "user_input", "[1,3,5,7]", 0) from stb;')
tdSql.error('select histogram(tag_bool, "user_input", "[1,3,5,7]", 0) from ctb;') tdSql.error('select histogram(tag_bool, "user_input", "[1,3,5,7]", 0) from ctb;')

View File

@ -33,50 +33,7 @@ class TDTestCase:
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
def __query_condition(self,tbname): def __query_condition(self,tbname):
query_condition = [f"cast({col} as bigint)" for col in ALL_COL] return [ f"{any_col}" for any_col in ALL_COL ]
for num_col in NUM_COL:
query_condition.extend(
(
f"{tbname}.{num_col}",
f"abs( {tbname}.{num_col} )",
f"acos( {tbname}.{num_col} )",
f"asin( {tbname}.{num_col} )",
f"atan( {tbname}.{num_col} )",
f"avg( {tbname}.{num_col} )",
f"ceil( {tbname}.{num_col} )",
f"cos( {tbname}.{num_col} )",
f"count( {tbname}.{num_col} )",
f"floor( {tbname}.{num_col} )",
f"log( {tbname}.{num_col}, {tbname}.{num_col})",
f"max( {tbname}.{num_col} )",
f"min( {tbname}.{num_col} )",
f"pow( {tbname}.{num_col}, 2)",
f"round( {tbname}.{num_col} )",
f"sum( {tbname}.{num_col} )",
f"sin( {tbname}.{num_col} )",
f"sqrt( {tbname}.{num_col} )",
f"tan( {tbname}.{num_col} )",
f"cast( {tbname}.{num_col} as timestamp)",
)
)
query_condition.extend((f"{num_col} + {any_col}" for any_col in ALL_COL))
for char_col in CHAR_COL:
query_condition.extend(
(
f"count({tbname}.{char_col})",
f"sum(cast({tbname}.{char_col}) as bigint)",
f"max(cast({tbname}.{char_col}) as bigint)",
f"min(cast({tbname}.{char_col}) as bigint)",
f"avg(cast({tbname}.{char_col}) as bigint)",
)
)
# query_condition.extend(
# (
# 1010,
# )
# )
return query_condition
def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False): def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False):
table_reference = tb_list[0] table_reference = tb_list[0]
@ -124,7 +81,7 @@ class TDTestCase:
return f" group by {col} having {having}" if having else f" group by {col} " return f" group by {col} having {having}" if having else f" group by {col} "
def __single_sql(self, select_clause, from_clause, where_condition="", group_condition=""): def __single_sql(self, select_clause, from_clause, where_condition="", group_condition=""):
if isinstance(select_clause, str) and "on" not in from_clause and select_clause.split(".")[0] != from_clause.split(".")[0]: if isinstance(select_clause, str) and "on" not in from_clause and select_clause.split(".")[0].split("(")[-1] != from_clause.split(".")[0]:
return return
return f"select hyperloglog({select_clause}) from {from_clause} {where_condition} {group_condition}" return f"select hyperloglog({select_clause}) from {from_clause} {where_condition} {group_condition}"
@ -191,7 +148,7 @@ class TDTestCase:
if tdSql.cursor.istype(col, "BIGINT UNSIGNED"): if tdSql.cursor.istype(col, "BIGINT UNSIGNED"):
return "BIGINT UNSIGNED" return "BIGINT UNSIGNED"
def spread_check(self): def hyperloglog_check(self):
sqls = self.sql_list() sqls = self.sql_list()
tdLog.printNoPrefix("===step 1: curent case, must return query OK") tdLog.printNoPrefix("===step 1: curent case, must return query OK")
for i in range(len(sqls)): for i in range(len(sqls)):
@ -214,15 +171,16 @@ class TDTestCase:
for i in range(tdSql.queryRows): for i in range(tdSql.queryRows):
tdSql.checkData(i, 0, 1) if tdSql.queryResult[i][1] is not None else tdSql.checkData(i, 0, 0) tdSql.checkData(i, 0, 1) if tdSql.queryResult[i][1] is not None else tdSql.checkData(i, 0, 0)
self.hyperloglog_check()
self.spread_check()
def __test_error(self): def __test_error(self):
tdLog.printNoPrefix("===step 0: err case, must return err") tdLog.printNoPrefix("===step 0: err case, must return err")
tdSql.error( "select hyperloglog() from ct1" ) tdSql.error( "select hyperloglog() from ct1" )
tdSql.error( "select hyperloglog(c1, c2) from ct2" ) tdSql.error( "select hyperloglog(c1, c2) from ct2" )
# tdSql.error( "select hyperloglog(1) from stb1" )
# tdSql.error( "select hyperloglog(abs(c1)) from ct4" )
tdSql.error( "select hyperloglog(count(c1)) from t1" )
# tdSql.error( "select hyperloglog(1) from ct2" ) # tdSql.error( "select hyperloglog(1) from ct2" )
tdSql.error( f"select hyperloglog({NUM_COL[0]}, {NUM_COL[1]}) from ct4" ) tdSql.error( f"select hyperloglog({NUM_COL[0]}, {NUM_COL[1]}) from ct4" )
tdSql.error( ''' select hyperloglog(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10']) tdSql.error( ''' select hyperloglog(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'])

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