Merge branch 'feat/TS-4243-3.0' of github.com:taosdata/TDengine into TEST/3.0/TS-4243
This commit is contained in:
commit
cd6cff4485
|
@ -148,7 +148,7 @@ T = latest event time - watermark
|
||||||
|
|
||||||
The window closing time for each batch of data that arrives at the system is updated using the preceding formula, and all windows are closed whose closing time is less than T. If the triggering method is WINDOW_CLOSE or MAX_DELAY, the aggregate result for the window is pushed.
|
The window closing time for each batch of data that arrives at the system is updated using the preceding formula, and all windows are closed whose closing time is less than T. If the triggering method is WINDOW_CLOSE or MAX_DELAY, the aggregate result for the window is pushed.
|
||||||
|
|
||||||
Stream processing strategy for expired data
|
## Stream processing strategy for expired data
|
||||||
The data in expired windows is tagged as expired. TDengine stream processing provides two methods for handling such data:
|
The data in expired windows is tagged as expired. TDengine stream processing provides two methods for handling such data:
|
||||||
|
|
||||||
1. Drop the data. This is the default and often only handling method for most stream processing engines.
|
1. Drop the data. This is the default and often only handling method for most stream processing engines.
|
||||||
|
@ -157,6 +157,14 @@ The data in expired windows is tagged as expired. TDengine stream processing pro
|
||||||
|
|
||||||
In both of these methods, configuring the watermark is essential for obtaining accurate results (if expired data is dropped) and avoiding repeated triggers that affect system performance (if expired data is recalculated).
|
In both of these methods, configuring the watermark is essential for obtaining accurate results (if expired data is dropped) and avoiding repeated triggers that affect system performance (if expired data is recalculated).
|
||||||
|
|
||||||
|
## Stream processing strategy for modifying data
|
||||||
|
|
||||||
|
TDengine provides two ways to handle modified data, which are specified by the IGNORE UPDATE option:
|
||||||
|
|
||||||
|
1. Check whether the data has been modified, i.e. IGNORE UPDATE 0, and recalculate the corresponding window if the data has been modified.
|
||||||
|
|
||||||
|
2. Do not check whether the data has been modified, and calculate all the data as incremental data, i.e. IGNORE UPDATE 1, the default configuration.
|
||||||
|
|
||||||
## Supported functions
|
## Supported functions
|
||||||
|
|
||||||
All [scalar functions](../function/#scalar-functions) are available in stream processing. All [Aggregate functions](../function/#aggregate-functions) and [Selection functions](../function/#selection-functions) are available in stream processing, except the followings:
|
All [scalar functions](../function/#scalar-functions) are available in stream processing. All [Aggregate functions](../function/#aggregate-functions) and [Selection functions](../function/#selection-functions) are available in stream processing, except the followings:
|
||||||
|
|
|
@ -201,9 +201,9 @@ TDengine 对于过期数据提供两种处理方式,由 IGNORE EXPIRED 选项
|
||||||
|
|
||||||
TDengine 对于修改数据提供两种处理方式,由 IGNORE UPDATE 选项指定:
|
TDengine 对于修改数据提供两种处理方式,由 IGNORE UPDATE 选项指定:
|
||||||
|
|
||||||
1. 检查数据是否被修改,即 IGNORE UPDATE 0:默认配置,如果被修改,则重新计算对应窗口。
|
1. 检查数据是否被修改,即 IGNORE UPDATE 0,如果数据被修改,则重新计算对应窗口。
|
||||||
|
|
||||||
2. 不检查数据是否被修改,全部按增量数据计算,即 IGNORE UPDATE 1。
|
2. 不检查数据是否被修改,全部按增量数据计算,即 IGNORE UPDATE 1,默认配置。
|
||||||
|
|
||||||
|
|
||||||
## 写入已存在的超级表
|
## 写入已存在的超级表
|
||||||
|
|
|
@ -392,6 +392,7 @@ typedef struct STUidTagInfo {
|
||||||
#define CALCULATE_START_TS_COLUMN_INDEX 4
|
#define CALCULATE_START_TS_COLUMN_INDEX 4
|
||||||
#define CALCULATE_END_TS_COLUMN_INDEX 5
|
#define CALCULATE_END_TS_COLUMN_INDEX 5
|
||||||
#define TABLE_NAME_COLUMN_INDEX 6
|
#define TABLE_NAME_COLUMN_INDEX 6
|
||||||
|
#define PRIMARY_KEY_COLUMN_INDEX 7
|
||||||
|
|
||||||
// stream create table block column
|
// stream create table block column
|
||||||
#define UD_TABLE_NAME_COLUMN_INDEX 0
|
#define UD_TABLE_NAME_COLUMN_INDEX 0
|
||||||
|
|
|
@ -126,7 +126,7 @@ int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag);
|
||||||
int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag);
|
int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag);
|
||||||
void tRowGetKey(SRow *pRow, SRowKey *key);
|
void tRowGetKey(SRow *pRow, SRowKey *key);
|
||||||
int32_t tRowKeyCompare(const void *p1, const void *p2);
|
int32_t tRowKeyCompare(const void *p1, const void *p2);
|
||||||
int32_t tRowKeyAssign(SRowKey* pDst, SRowKey* pSrc);
|
int32_t tRowKeyAssign(SRowKey *pDst, SRowKey *pSrc);
|
||||||
|
|
||||||
// SRowIter ================================
|
// SRowIter ================================
|
||||||
int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter);
|
int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter);
|
||||||
|
@ -174,6 +174,7 @@ int32_t tColDataUpdateValue(SColData *pColData, SColVal *pColVal, bool forward);
|
||||||
void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal);
|
void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal);
|
||||||
uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal);
|
uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal);
|
||||||
int32_t tColDataCopy(SColData *pColDataFrom, SColData *pColData, xMallocFn xMalloc, void *arg);
|
int32_t tColDataCopy(SColData *pColDataFrom, SColData *pColData, xMallocFn xMalloc, void *arg);
|
||||||
|
void tColDataArrGetRowKey(SColData *aColData, int32_t nColData, int32_t iRow, SRowKey *key);
|
||||||
|
|
||||||
extern void (*tColDataCalcSMA[])(SColData *pColData, int64_t *sum, int64_t *max, int64_t *min, int16_t *numOfNull);
|
extern void (*tColDataCalcSMA[])(SColData *pColData, int64_t *sum, int64_t *max, int64_t *min, int16_t *numOfNull);
|
||||||
|
|
||||||
|
@ -188,8 +189,8 @@ void tColDataSortMerge(SArray *colDataArr);
|
||||||
int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t bytes, int32_t nRows, char *lengthOrbitmap,
|
int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t bytes, int32_t nRows, char *lengthOrbitmap,
|
||||||
char *data);
|
char *data);
|
||||||
// for encode/decode
|
// for encode/decode
|
||||||
int32_t tPutColData(uint8_t *pBuf, SColData *pColData);
|
int32_t tPutColData(uint8_t version, uint8_t *pBuf, SColData *pColData);
|
||||||
int32_t tGetColData(uint8_t *pBuf, SColData *pColData);
|
int32_t tGetColData(uint8_t version, uint8_t *pBuf, SColData *pColData);
|
||||||
|
|
||||||
// STRUCT ================================
|
// STRUCT ================================
|
||||||
struct STColumn {
|
struct STColumn {
|
||||||
|
|
|
@ -2566,6 +2566,8 @@ typedef struct {
|
||||||
int8_t igUpdate;
|
int8_t igUpdate;
|
||||||
int64_t lastTs;
|
int64_t lastTs;
|
||||||
SArray* pVgroupVerList;
|
SArray* pVgroupVerList;
|
||||||
|
// 3.3.0.0
|
||||||
|
SArray* pCols; // array of SField
|
||||||
} SCMCreateStreamReq;
|
} SCMCreateStreamReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -4035,6 +4037,7 @@ int32_t tDeserializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
|
||||||
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
|
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
|
||||||
#define SUBMIT_REQ_FROM_FILE 0x4
|
#define SUBMIT_REQ_FROM_FILE 0x4
|
||||||
#define TD_REQ_FROM_TAOX 0x8
|
#define TD_REQ_FROM_TAOX 0x8
|
||||||
|
#define SUBMIT_REQUEST_VERSION (1)
|
||||||
|
|
||||||
#define TD_REQ_FROM_TAOX_OLD 0x1 // for compatibility
|
#define TD_REQ_FROM_TAOX_OLD 0x1 // for compatibility
|
||||||
|
|
||||||
|
|
|
@ -578,6 +578,7 @@ typedef struct SWindowPhysiNode {
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
int64_t deleteMark;
|
int64_t deleteMark;
|
||||||
int8_t igExpired;
|
int8_t igExpired;
|
||||||
|
int8_t destHasPrimayKey;
|
||||||
bool mergeDataBlock;
|
bool mergeDataBlock;
|
||||||
} SWindowPhysiNode;
|
} SWindowPhysiNode;
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,8 @@ typedef struct SPlanContext {
|
||||||
const char* pUser;
|
const char* pUser;
|
||||||
bool sysInfo;
|
bool sysInfo;
|
||||||
int64_t allocatorId;
|
int64_t allocatorId;
|
||||||
|
bool destHasPrimaryKey;
|
||||||
|
bool sourceHasPrimaryKey;
|
||||||
} SPlanContext;
|
} SPlanContext;
|
||||||
|
|
||||||
// Create the physical plan for the query, according to the AST.
|
// Create the physical plan for the query, according to the AST.
|
||||||
|
|
|
@ -355,6 +355,8 @@ typedef struct SMetaHbInfo SMetaHbInfo;
|
||||||
typedef struct SDispatchMsgInfo {
|
typedef struct SDispatchMsgInfo {
|
||||||
SStreamDispatchReq* pData; // current dispatch data
|
SStreamDispatchReq* pData; // current dispatch data
|
||||||
int8_t dispatchMsgType;
|
int8_t dispatchMsgType;
|
||||||
|
int64_t checkpointId;// checkpoint id msg
|
||||||
|
int32_t transId; // transId for current checkpoint
|
||||||
int16_t msgType; // dispatch msg type
|
int16_t msgType; // dispatch msg type
|
||||||
int32_t retryCount; // retry send data count
|
int32_t retryCount; // retry send data count
|
||||||
int64_t startTs; // dispatch start time, record total elapsed time for dispatch
|
int64_t startTs; // dispatch start time, record total elapsed time for dispatch
|
||||||
|
|
|
@ -496,6 +496,11 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
pInst->onlineDnodes = pInst->totalDnodes ? 0 : -1;
|
pInst->onlineDnodes = pInst->totalDnodes ? 0 : -1;
|
||||||
tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), pInst->onlineDnodes, pInst->totalDnodes);
|
tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), pInst->onlineDnodes, pInst->totalDnodes);
|
||||||
|
taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
|
taosMemoryFree(pMsg->pEpSet);
|
||||||
|
tFreeClientHbBatchRsp(&pRsp);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspNum) {
|
if (rspNum) {
|
||||||
|
|
|
@ -1626,6 +1626,22 @@ void changeByteEndian(char* pData){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tmqGetRawDataRowsPrecisionFromRes(void *pRetrieve, void** rawData, int64_t *rows, int32_t *precision){
|
||||||
|
if(*(int64_t*)pRetrieve == 0){
|
||||||
|
*rawData = ((SRetrieveTableRsp*)pRetrieve)->data;
|
||||||
|
*rows = htobe64(((SRetrieveTableRsp*)pRetrieve)->numOfRows);
|
||||||
|
if(precision != NULL){
|
||||||
|
*precision = ((SRetrieveTableRsp*)pRetrieve)->precision;
|
||||||
|
}
|
||||||
|
}else if(*(int64_t*)pRetrieve == 1){
|
||||||
|
*rawData = ((SRetrieveTableRspForTmq*)pRetrieve)->data;
|
||||||
|
*rows = htobe64(((SRetrieveTableRspForTmq*)pRetrieve)->numOfRows);
|
||||||
|
if(precision != NULL){
|
||||||
|
*precision = ((SRetrieveTableRspForTmq*)pRetrieve)->precision;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows, SMqRspObj* pRspObj) {
|
static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows, SMqRspObj* pRspObj) {
|
||||||
(*numOfRows) = 0;
|
(*numOfRows) = 0;
|
||||||
tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN);
|
tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||||
|
@ -1648,13 +1664,7 @@ static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg
|
||||||
void* rawData = NULL;
|
void* rawData = NULL;
|
||||||
int64_t rows = 0;
|
int64_t rows = 0;
|
||||||
// deal with compatibility
|
// deal with compatibility
|
||||||
if(*(int64_t*)pRetrieve == 0){
|
tmqGetRawDataRowsPrecisionFromRes(pRetrieve, &rawData, &rows, NULL);
|
||||||
rawData = ((SRetrieveTableRsp*)pRetrieve)->data;
|
|
||||||
rows = htobe64(((SRetrieveTableRsp*)pRetrieve)->numOfRows);
|
|
||||||
}else if(*(int64_t*)pRetrieve == 1){
|
|
||||||
rawData = ((SRetrieveTableRspForTmq*)pRetrieve)->data;
|
|
||||||
rows = htobe64(((SRetrieveTableRspForTmq*)pRetrieve)->numOfRows);
|
|
||||||
}
|
|
||||||
|
|
||||||
pVg->numOfRows += rows;
|
pVg->numOfRows += rows;
|
||||||
(*numOfRows) += rows;
|
(*numOfRows) += rows;
|
||||||
|
@ -2625,18 +2635,22 @@ SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4) {
|
||||||
pRspObj->resIter++;
|
pRspObj->resIter++;
|
||||||
|
|
||||||
if (pRspObj->resIter < pRspObj->rsp.blockNum) {
|
if (pRspObj->resIter < pRspObj->rsp.blockNum) {
|
||||||
SRetrieveTableRspForTmq* pRetrieveTmq =
|
|
||||||
(SRetrieveTableRspForTmq*)taosArrayGetP(pRspObj->rsp.blockData, pRspObj->resIter);
|
|
||||||
if (pRspObj->rsp.withSchema) {
|
if (pRspObj->rsp.withSchema) {
|
||||||
doFreeReqResultInfo(&pRspObj->resInfo);
|
doFreeReqResultInfo(&pRspObj->resInfo);
|
||||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(pRspObj->rsp.blockSchema, pRspObj->resIter);
|
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(pRspObj->rsp.blockSchema, pRspObj->resIter);
|
||||||
setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols);
|
setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
pRspObj->resInfo.pData = (void*)pRetrieveTmq->data;
|
void* pRetrieve = taosArrayGetP(pRspObj->rsp.blockData, pRspObj->resIter);
|
||||||
pRspObj->resInfo.numOfRows = htobe64(pRetrieveTmq->numOfRows);
|
void* rawData = NULL;
|
||||||
|
int64_t rows = 0;
|
||||||
|
int32_t precision = 0;
|
||||||
|
tmqGetRawDataRowsPrecisionFromRes(pRetrieve, &rawData, &rows, &precision);
|
||||||
|
|
||||||
|
pRspObj->resInfo.pData = rawData;
|
||||||
|
pRspObj->resInfo.numOfRows = rows;
|
||||||
pRspObj->resInfo.current = 0;
|
pRspObj->resInfo.current = 0;
|
||||||
pRspObj->resInfo.precision = pRetrieveTmq->precision;
|
pRspObj->resInfo.precision = precision;
|
||||||
|
|
||||||
// TODO handle the compressed case
|
// TODO handle the compressed case
|
||||||
pRspObj->resInfo.totalRows += pRspObj->resInfo.numOfRows;
|
pRspObj->resInfo.totalRows += pRspObj->resInfo.numOfRows;
|
||||||
|
|
|
@ -3111,7 +3111,7 @@ static int32_t tColDataCopyRowAppend(SColData *aFromColData, int32_t iFromRow, S
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void tColDataArrGetRowKey(SColData *aColData, int32_t nColData, int32_t iRow, SRowKey *key) {
|
void tColDataArrGetRowKey(SColData *aColData, int32_t nColData, int32_t iRow, SRowKey *key) {
|
||||||
SColVal cv;
|
SColVal cv;
|
||||||
|
|
||||||
key->ts = ((TSKEY *)aColData[0].pData)[iRow];
|
key->ts = ((TSKEY *)aColData[0].pData)[iRow];
|
||||||
|
@ -3490,7 +3490,7 @@ _exit:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tPutColData(uint8_t *pBuf, SColData *pColData) {
|
static int32_t tPutColDataVersion0(uint8_t *pBuf, SColData *pColData) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
|
||||||
n += tPutI16v(pBuf ? pBuf + n : NULL, pColData->cid);
|
n += tPutI16v(pBuf ? pBuf + n : NULL, pColData->cid);
|
||||||
|
@ -3532,7 +3532,7 @@ int32_t tPutColData(uint8_t *pBuf, SColData *pColData) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tGetColData(uint8_t *pBuf, SColData *pColData) {
|
static int32_t tGetColDataVersion0(uint8_t *pBuf, SColData *pColData) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
|
||||||
n += tGetI16v(pBuf + n, &pColData->cid);
|
n += tGetI16v(pBuf + n, &pColData->cid);
|
||||||
|
@ -3571,10 +3571,45 @@ int32_t tGetColData(uint8_t *pBuf, SColData *pColData) {
|
||||||
n += pColData->nData;
|
n += pColData->nData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pColData->cflag = 0;
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t tPutColDataVersion1(uint8_t *pBuf, SColData *pColData) {
|
||||||
|
int32_t n = tPutColDataVersion0(pBuf, pColData);
|
||||||
|
n += tPutI8(pBuf ? pBuf + n : NULL, pColData->cflag);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tGetColDataVersion1(uint8_t *pBuf, SColData *pColData) {
|
||||||
|
int32_t n = tGetColDataVersion0(pBuf, pColData);
|
||||||
|
n += tGetI8(pBuf ? pBuf + n : NULL, &pColData->cflag);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tPutColData(uint8_t version, uint8_t *pBuf, SColData *pColData) {
|
||||||
|
if (version == 0) {
|
||||||
|
return tPutColDataVersion0(pBuf, pColData);
|
||||||
|
} else if (version == 1) {
|
||||||
|
return tPutColDataVersion1(pBuf, pColData);
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tGetColData(uint8_t version, uint8_t *pBuf, SColData *pColData) {
|
||||||
|
if (version == 0) {
|
||||||
|
return tGetColDataVersion0(pBuf, pColData);
|
||||||
|
} else if (version == 1) {
|
||||||
|
return tGetColDataVersion1(pBuf, pColData);
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define CALC_SUM_MAX_MIN(SUM, MAX, MIN, VAL) \
|
#define CALC_SUM_MAX_MIN(SUM, MAX, MIN, VAL) \
|
||||||
do { \
|
do { \
|
||||||
(SUM) += (VAL); \
|
(SUM) += (VAL); \
|
||||||
|
|
|
@ -7665,6 +7665,16 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
||||||
if (tEncodeI64(&encoder, p->ver) < 0) return -1;
|
if (tEncodeI64(&encoder, p->ver) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t colSize = taosArrayGetSize(pReq->pCols);
|
||||||
|
if (tEncodeI32(&encoder, colSize) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < colSize; ++i) {
|
||||||
|
SField *pField = taosArrayGet(pReq->pCols, i);
|
||||||
|
if (tEncodeI8(&encoder, pField->type) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pField->flags) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -7770,6 +7780,27 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int32_t colSize = 0;
|
||||||
|
if (tDecodeI32(&decoder, &colSize) < 0) return -1;
|
||||||
|
if (colSize > 0) {
|
||||||
|
pReq->pCols = taosArrayInit(colSize, sizeof(SField));
|
||||||
|
if (pReq->pCols == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < colSize; ++i) {
|
||||||
|
SField field = {0};
|
||||||
|
if (tDecodeI8(&decoder, &field.type) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &field.flags) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &field.bytes) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, field.name) < 0) return -1;
|
||||||
|
if (taosArrayPush(pReq->pCols, &field) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -7850,6 +7881,7 @@ void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) {
|
||||||
taosArrayDestroy(pReq->pTags);
|
taosArrayDestroy(pReq->pTags);
|
||||||
taosArrayDestroy(pReq->fillNullCols);
|
taosArrayDestroy(pReq->fillNullCols);
|
||||||
taosArrayDestroy(pReq->pVgroupVerList);
|
taosArrayDestroy(pReq->pVgroupVerList);
|
||||||
|
taosArrayDestroy(pReq->pCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSRSmaParam(SEncoder *pCoder, const SRSmaParam *pRSmaParam) {
|
int32_t tEncodeSRSmaParam(SEncoder *pCoder, const SRSmaParam *pRSmaParam) {
|
||||||
|
@ -9042,7 +9074,8 @@ int32_t tDecodeSBatchDeleteReqSetCtime(SDecoder *pDecoder, SBatchDeleteReq *pReq
|
||||||
static int32_t tEncodeSSubmitTbData(SEncoder *pCoder, const SSubmitTbData *pSubmitTbData) {
|
static int32_t tEncodeSSubmitTbData(SEncoder *pCoder, const SSubmitTbData *pSubmitTbData) {
|
||||||
if (tStartEncode(pCoder) < 0) return -1;
|
if (tStartEncode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
if (tEncodeI32v(pCoder, pSubmitTbData->flags) < 0) return -1;
|
int32_t flags = pSubmitTbData->flags | ((SUBMIT_REQUEST_VERSION) << 8);
|
||||||
|
if (tEncodeI32v(pCoder, flags) < 0) return -1;
|
||||||
|
|
||||||
// auto create table
|
// auto create table
|
||||||
if (pSubmitTbData->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
if (pSubmitTbData->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
||||||
|
@ -9062,7 +9095,8 @@ static int32_t tEncodeSSubmitTbData(SEncoder *pCoder, const SSubmitTbData *pSubm
|
||||||
if (tEncodeU64v(pCoder, nColData) < 0) return -1;
|
if (tEncodeU64v(pCoder, nColData) < 0) return -1;
|
||||||
|
|
||||||
for (uint64_t i = 0; i < nColData; i++) {
|
for (uint64_t i = 0; i < nColData; i++) {
|
||||||
pCoder->pos += tPutColData(pCoder->data ? pCoder->data + pCoder->pos : NULL, &aColData[i]);
|
pCoder->pos +=
|
||||||
|
tPutColData(SUBMIT_REQUEST_VERSION, pCoder->data ? pCoder->data + pCoder->pos : NULL, &aColData[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tEncodeU64v(pCoder, TARRAY_SIZE(pSubmitTbData->aRowP)) < 0) return -1;
|
if (tEncodeU64v(pCoder, TARRAY_SIZE(pSubmitTbData->aRowP)) < 0) return -1;
|
||||||
|
@ -9081,13 +9115,18 @@ static int32_t tEncodeSSubmitTbData(SEncoder *pCoder, const SSubmitTbData *pSubm
|
||||||
|
|
||||||
static int32_t tDecodeSSubmitTbData(SDecoder *pCoder, SSubmitTbData *pSubmitTbData) {
|
static int32_t tDecodeSSubmitTbData(SDecoder *pCoder, SSubmitTbData *pSubmitTbData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
int32_t flags;
|
||||||
|
uint8_t version;
|
||||||
|
|
||||||
if (tStartDecode(pCoder) < 0) {
|
if (tStartDecode(pCoder) < 0) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tDecodeI32v(pCoder, &pSubmitTbData->flags) < 0) return -1;
|
if (tDecodeI32v(pCoder, &flags) < 0) return -1;
|
||||||
|
|
||||||
|
pSubmitTbData->flags = flags & 0xff;
|
||||||
|
version = (flags >> 8) & 0xff;
|
||||||
|
|
||||||
if (pSubmitTbData->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
if (pSubmitTbData->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
||||||
pSubmitTbData->pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq));
|
pSubmitTbData->pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq));
|
||||||
|
@ -9131,7 +9170,7 @@ static int32_t tDecodeSSubmitTbData(SDecoder *pCoder, SSubmitTbData *pSubmitTbDa
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < nColData; ++i) {
|
for (int32_t i = 0; i < nColData; ++i) {
|
||||||
pCoder->pos += tGetColData(pCoder->data + pCoder->pos, taosArrayReserve(pSubmitTbData->aCol, 1));
|
pCoder->pos += tGetColData(version, pCoder->data + pCoder->pos, taosArrayReserve(pSubmitTbData->aCol, 1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint64_t nRow;
|
uint64_t nRow;
|
||||||
|
|
|
@ -160,6 +160,7 @@ typedef struct {
|
||||||
ETrnConflct conflict;
|
ETrnConflct conflict;
|
||||||
ETrnExec exec;
|
ETrnExec exec;
|
||||||
EOperType oper;
|
EOperType oper;
|
||||||
|
bool changeless;
|
||||||
int32_t code;
|
int32_t code;
|
||||||
int32_t failedTimes;
|
int32_t failedTimes;
|
||||||
void* rpcRsp;
|
void* rpcRsp;
|
||||||
|
|
|
@ -81,6 +81,7 @@ void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbnam
|
||||||
void mndTransSetArbGroupId(STrans *pTrans, int32_t groupId);
|
void mndTransSetArbGroupId(STrans *pTrans, int32_t groupId);
|
||||||
void mndTransSetSerial(STrans *pTrans);
|
void mndTransSetSerial(STrans *pTrans);
|
||||||
void mndTransSetParallel(STrans *pTrans);
|
void mndTransSetParallel(STrans *pTrans);
|
||||||
|
void mndTransSetChangeless(STrans *pTrans);
|
||||||
void mndTransSetOper(STrans *pTrans, EOperType oper);
|
void mndTransSetOper(STrans *pTrans, EOperType oper);
|
||||||
int32_t mndTransCheckConflict(SMnode *pMnode, STrans *pTrans);
|
int32_t mndTransCheckConflict(SMnode *pMnode, STrans *pTrans);
|
||||||
#ifndef BUILD_NO_CALL
|
#ifndef BUILD_NO_CALL
|
||||||
|
|
|
@ -822,7 +822,7 @@ _OVER:
|
||||||
"msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d "
|
"msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d "
|
||||||
"role:%s, redirect numOfEps:%d inUse:%d, type:%s",
|
"role:%s, redirect numOfEps:%d inUse:%d, type:%s",
|
||||||
pMsg, TMSG_INFO(pMsg->msgType), terrstr(), pMnode->restored, pMnode->stopped, state.restored,
|
pMsg, TMSG_INFO(pMsg->msgType), terrstr(), pMnode->restored, pMnode->stopped, state.restored,
|
||||||
syncStr(state.restored), epSet.numOfEps, epSet.inUse, TMSG_INFO(pMsg->msgType));
|
syncStr(state.state), epSet.numOfEps, epSet.inUse, TMSG_INFO(pMsg->msgType));
|
||||||
|
|
||||||
if (epSet.numOfEps <= 0) return -1;
|
if (epSet.numOfEps <= 0) return -1;
|
||||||
|
|
||||||
|
|
|
@ -287,6 +287,45 @@ static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t createSchemaByFields(const SArray* pFields, SSchemaWrapper* pWrapper) {
|
||||||
|
pWrapper->nCols = taosArrayGetSize(pFields);
|
||||||
|
pWrapper->pSchema = taosMemoryCalloc(pWrapper->nCols, sizeof(SSchema));
|
||||||
|
if (NULL == pWrapper->pSchema) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
SNode* pNode;
|
||||||
|
int32_t index = 0;
|
||||||
|
for(int32_t i = 0; i < pWrapper->nCols; i++) {
|
||||||
|
SField* pField = (SField*)taosArrayGet(pFields, i);
|
||||||
|
if (TSDB_DATA_TYPE_NULL == pField->type) {
|
||||||
|
pWrapper->pSchema[index].type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
|
pWrapper->pSchema[index].bytes = VARSTR_HEADER_SIZE;
|
||||||
|
} else {
|
||||||
|
pWrapper->pSchema[index].type = pField->type;
|
||||||
|
pWrapper->pSchema[index].bytes = pField->bytes;
|
||||||
|
}
|
||||||
|
pWrapper->pSchema[index].colId = index + 1;
|
||||||
|
strcpy(pWrapper->pSchema[index].name, pField->name);
|
||||||
|
pWrapper->pSchema[index].flags = pField->flags;
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool hasPrimaryKey(SSchemaWrapper* pWrapper) {
|
||||||
|
if (pWrapper->nCols < 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int32_t i = 1; i < pWrapper->nCols; i++) {
|
||||||
|
if(pWrapper->pSchema[i].flags & COL_IS_KEY) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, SCMCreateStreamReq *pCreate) {
|
static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, SCMCreateStreamReq *pCreate) {
|
||||||
SNode *pAst = NULL;
|
SNode *pAst = NULL;
|
||||||
SQueryPlan *pPlan = NULL;
|
SQueryPlan *pPlan = NULL;
|
||||||
|
@ -352,8 +391,8 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// extract output schema from ast
|
// create output schema
|
||||||
if (qExtractResultSchema(pAst, (int32_t *)&pObj->outputSchema.nCols, &pObj->outputSchema.pSchema) != 0) {
|
if (createSchemaByFields(pCreate->pCols, &pObj->outputSchema) != TSDB_CODE_SUCCESS) {
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,6 +428,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
||||||
pObj->outputSchema.pSchema = pFullSchema;
|
pObj->outputSchema.pSchema = pFullSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasKey = hasPrimaryKey(&pObj->outputSchema);
|
||||||
SPlanContext cxt = {
|
SPlanContext cxt = {
|
||||||
.pAstRoot = pAst,
|
.pAstRoot = pAst,
|
||||||
.topicQuery = false,
|
.topicQuery = false,
|
||||||
|
@ -398,6 +438,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
||||||
.igExpired = pObj->conf.igExpired,
|
.igExpired = pObj->conf.igExpired,
|
||||||
.deleteMark = pObj->deleteMark,
|
.deleteMark = pObj->deleteMark,
|
||||||
.igCheckUpdate = pObj->igCheckUpdate,
|
.igCheckUpdate = pObj->igCheckUpdate,
|
||||||
|
.destHasPrimaryKey = hasKey,
|
||||||
};
|
};
|
||||||
|
|
||||||
// using ast and param to build physical plan
|
// using ast and param to build physical plan
|
||||||
|
|
|
@ -739,6 +739,8 @@ void mndTransSetSerial(STrans *pTrans) { pTrans->exec = TRN_EXEC_SERIAL; }
|
||||||
|
|
||||||
void mndTransSetParallel(STrans *pTrans) { pTrans->exec = TRN_EXEC_PARALLEL; }
|
void mndTransSetParallel(STrans *pTrans) { pTrans->exec = TRN_EXEC_PARALLEL; }
|
||||||
|
|
||||||
|
void mndTransSetChangeless(STrans *pTrans) { pTrans->changeless = true; }
|
||||||
|
|
||||||
void mndTransSetOper(STrans *pTrans, EOperType oper) { pTrans->oper = oper; }
|
void mndTransSetOper(STrans *pTrans, EOperType oper) { pTrans->oper = oper; }
|
||||||
|
|
||||||
static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
|
static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
|
||||||
|
@ -855,6 +857,58 @@ int32_t mndTransCheckConflict(SMnode *pMnode, STrans *pTrans) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool mndTransActionsOfSameType(SArray *pActions) {
|
||||||
|
int32_t size = taosArrayGetSize(pActions);
|
||||||
|
ETrnAct lastActType = TRANS_ACTION_NULL;
|
||||||
|
bool same = true;
|
||||||
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
|
STransAction *pAction = taosArrayGet(pActions, i);
|
||||||
|
if (i > 0) {
|
||||||
|
if (lastActType != pAction->actionType) {
|
||||||
|
same = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastActType = pAction->actionType;
|
||||||
|
}
|
||||||
|
return same;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndTransCheckParallelActions(SMnode *pMnode, STrans *pTrans) {
|
||||||
|
if (pTrans->exec == TRN_EXEC_PARALLEL) {
|
||||||
|
if (mndTransActionsOfSameType(pTrans->redoActions) == false) {
|
||||||
|
terrno = TSDB_CODE_MND_TRANS_INVALID_STAGE;
|
||||||
|
mError("trans:%d, types of parallel redo actions are not the same", pTrans->id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTrans->policy == TRN_POLICY_ROLLBACK) {
|
||||||
|
if (mndTransActionsOfSameType(pTrans->undoActions) == false) {
|
||||||
|
terrno = TSDB_CODE_MND_TRANS_INVALID_STAGE;
|
||||||
|
mError("trans:%d, types of parallel undo actions are not the same", pTrans->id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndTransCheckCommitActions(SMnode *pMnode, STrans *pTrans) {
|
||||||
|
if (!pTrans->changeless && taosArrayGetSize(pTrans->commitActions) <= 0) {
|
||||||
|
terrno = TSDB_CODE_MND_TRANS_CLOG_IS_NULL;
|
||||||
|
mError("trans:%d, commit actions of non-changeless trans are empty", pTrans->id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (mndTransActionsOfSameType(pTrans->commitActions) == false) {
|
||||||
|
terrno = TSDB_CODE_MND_TRANS_INVALID_STAGE;
|
||||||
|
mError("trans:%d, types of commit actions are not the same", pTrans->id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
||||||
if (pTrans == NULL) return -1;
|
if (pTrans == NULL) return -1;
|
||||||
|
|
||||||
|
@ -862,9 +916,11 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(pTrans->commitActions) <= 0) {
|
if (mndTransCheckParallelActions(pMnode, pTrans) != 0) {
|
||||||
terrno = TSDB_CODE_MND_TRANS_CLOG_IS_NULL;
|
return -1;
|
||||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
}
|
||||||
|
|
||||||
|
if (mndTransCheckCommitActions(pMnode, pTrans) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1281,24 +1337,25 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
|
||||||
|
|
||||||
static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->redoActions, topHalf);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->redoActions, topHalf);
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
||||||
mError("failed to execute redoActions since:%s, code:0x%x", terrstr(), terrno);
|
mError("trans:%d, failed to execute redoActions since:%s, code:0x%x, topHalf:%d", pTrans->id, terrstr(), terrno,
|
||||||
|
topHalf);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTransExecuteUndoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static int32_t mndTransExecuteUndoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->undoActions, topHalf);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->undoActions, topHalf);
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
||||||
mError("failed to execute undoActions since %s", terrstr());
|
mError("trans:%d, failed to execute undoActions since %s. topHalf:%d", pTrans->id, terrstr(), topHalf);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTransExecuteCommitActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static int32_t mndTransExecuteCommitActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->commitActions, topHalf);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->commitActions, topHalf);
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
||||||
mError("failed to execute commitActions since %s", terrstr());
|
mError("trans:%d, failed to execute commitActions since %s. topHalf:%d", pTrans->id, terrstr(), topHalf);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2342,24 +2342,7 @@ int32_t mndAddVgroupBalanceToTrans(SMnode *pMnode, SVgObj *pVgroup, STrans *pTra
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, pVgroup) != 0) {
|
|
||||||
mError("trans:%d, vgid:%d failed to be balanced to dnode:%d", pTrans->id, vgid, dnodeId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
|
|
||||||
SSdbRaw *pRaw = mndVgroupActionEncode(pVgroup);
|
|
||||||
if (pRaw == NULL) {
|
|
||||||
mError("trans:%d, vgid:%d failed to encode action to dnode:%d", pTrans->id, vgid, dnodeId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) {
|
|
||||||
sdbFreeRaw(pRaw);
|
|
||||||
mError("trans:%d, vgid:%d failed to append commit log dnode:%d", pTrans->id, vgid, dnodeId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
|
||||||
} else {
|
} else {
|
||||||
mInfo("trans:%d, vgid:%d cant be balanced to dnode:%d, exist:%d, online:%d", pTrans->id, vgid, dnodeId, exist,
|
mInfo("trans:%d, vgid:%d cant be balanced to dnode:%d, exist:%d, online:%d", pTrans->id, vgid, dnodeId, exist,
|
||||||
online);
|
online);
|
||||||
|
|
|
@ -895,6 +895,7 @@ typedef enum {
|
||||||
} EExecMode;
|
} EExecMode;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
int64_t version;
|
||||||
SRowKey rowKey;
|
SRowKey rowKey;
|
||||||
int8_t dirty;
|
int8_t dirty;
|
||||||
SColVal colVal;
|
SColVal colVal;
|
||||||
|
|
|
@ -923,13 +923,14 @@ int32_t handleStep2Async(SStreamTask* pStreamTask, void* param) {
|
||||||
STaskId hId = pStreamTask->hTaskInfo.id;
|
STaskId hId = pStreamTask->hTaskInfo.id;
|
||||||
SStreamTask* pTask = streamMetaAcquireTask(pStreamTask->pMeta, hId.streamId, hId.taskId);
|
SStreamTask* pTask = streamMetaAcquireTask(pStreamTask->pMeta, hId.streamId, hId.taskId);
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
// todo handle error
|
tqWarn("s-task:0x%x failed to acquired it to exec step 2, scan wal quit", (int32_t) hId.taskId);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
doStartFillhistoryStep2(pTask, pStreamTask, pTq);
|
doStartFillhistoryStep2(pTask, pStreamTask, pTq);
|
||||||
|
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
return 0;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function should be executed by only one thread, so we set an sentinel to protect this function
|
// this function should be executed by only one thread, so we set an sentinel to protect this function
|
||||||
|
|
|
@ -311,7 +311,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
|
||||||
SSDataBlock* pBlock = taosArrayGet(pBlocks, i);
|
SSDataBlock* pBlock = taosArrayGet(pBlocks, i);
|
||||||
tqAddBlockDataToRsp(pBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlock->pDataBlock),
|
tqAddBlockDataToRsp(pBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlock->pDataBlock),
|
||||||
pTq->pVnode->config.tsdbCfg.precision);
|
pTq->pVnode->config.tsdbCfg.precision);
|
||||||
totalRows += pBlock->info.rows;
|
*totalRows += pBlock->info.rows;
|
||||||
blockDataFreeRes(pBlock);
|
blockDataFreeRes(pBlock);
|
||||||
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
||||||
taosArrayPush(pRsp->blockSchema, &pSW);
|
taosArrayPush(pRsp->blockSchema, &pSW);
|
||||||
|
|
|
@ -324,6 +324,7 @@ int32_t doBuildAndSendSubmitMsg(SVnode* pVnode, SStreamTask* pTask, SSubmitReq2*
|
||||||
int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, const char* id) {
|
int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, const char* id) {
|
||||||
int32_t oldLen = taosArrayGetSize(pExisted->aRowP);
|
int32_t oldLen = taosArrayGetSize(pExisted->aRowP);
|
||||||
int32_t newLen = taosArrayGetSize(pNew->aRowP);
|
int32_t newLen = taosArrayGetSize(pNew->aRowP);
|
||||||
|
int32_t numOfPk = 0;
|
||||||
|
|
||||||
int32_t j = 0, k = 0;
|
int32_t j = 0, k = 0;
|
||||||
SArray* pFinal = taosArrayInit(oldLen + newLen, POINTER_BYTES);
|
SArray* pFinal = taosArrayInit(oldLen + newLen, POINTER_BYTES);
|
||||||
|
@ -335,17 +336,40 @@ int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, c
|
||||||
while (j < newLen && k < oldLen) {
|
while (j < newLen && k < oldLen) {
|
||||||
SRow* pNewRow = taosArrayGetP(pNew->aRowP, j);
|
SRow* pNewRow = taosArrayGetP(pNew->aRowP, j);
|
||||||
SRow* pOldRow = taosArrayGetP(pExisted->aRowP, k);
|
SRow* pOldRow = taosArrayGetP(pExisted->aRowP, k);
|
||||||
if (pNewRow->ts <= pOldRow->ts) {
|
if (pNewRow->ts < pOldRow->ts) {
|
||||||
taosArrayPush(pFinal, &pNewRow);
|
taosArrayPush(pFinal, &pNewRow);
|
||||||
j += 1;
|
j += 1;
|
||||||
|
} else if (pNewRow->ts > pOldRow->ts) {
|
||||||
if (pNewRow->ts == pOldRow->ts) {
|
|
||||||
k += 1;
|
|
||||||
tRowDestroy(pOldRow);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
taosArrayPush(pFinal, &pOldRow);
|
taosArrayPush(pFinal, &pOldRow);
|
||||||
k += 1;
|
k += 1;
|
||||||
|
} else {
|
||||||
|
// check for the existance of primary key
|
||||||
|
if (pNewRow->numOfPKs == 0) {
|
||||||
|
taosArrayPush(pFinal, &pNewRow);
|
||||||
|
k += 1;
|
||||||
|
j += 1;
|
||||||
|
tRowDestroy(pOldRow);
|
||||||
|
} else {
|
||||||
|
numOfPk = pNewRow->numOfPKs;
|
||||||
|
|
||||||
|
SRowKey kNew, kOld;
|
||||||
|
tRowGetKey(pNewRow, &kNew);
|
||||||
|
tRowGetKey(pOldRow, &kOld);
|
||||||
|
|
||||||
|
int32_t ret = tRowKeyCompare(&kNew, &kOld);
|
||||||
|
if (ret <= 0) {
|
||||||
|
taosArrayPush(pFinal, &pNewRow);
|
||||||
|
j += 1;
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
k += 1;
|
||||||
|
tRowDestroy(pOldRow);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
taosArrayPush(pFinal, &pOldRow);
|
||||||
|
k += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,8 +387,8 @@ int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, c
|
||||||
taosArrayDestroy(pExisted->aRowP);
|
taosArrayDestroy(pExisted->aRowP);
|
||||||
pExisted->aRowP = pFinal;
|
pExisted->aRowP = pFinal;
|
||||||
|
|
||||||
tqTrace("s-task:%s rows merged, final rows:%d, uid:%" PRId64 ", existed auto-create table:%d, new-block:%d", id,
|
tqTrace("s-task:%s rows merged, final rows:%d, pk:%d uid:%" PRId64 ", existed auto-create table:%d, new-block:%d",
|
||||||
(int32_t)taosArrayGetSize(pFinal), pExisted->uid, (pExisted->pCreateTbReq != NULL),
|
id, (int32_t)taosArrayGetSize(pFinal), numOfPk, pExisted->uid, (pExisted->pCreateTbReq != NULL),
|
||||||
(pNew->pCreateTbReq != NULL));
|
(pNew->pCreateTbReq != NULL));
|
||||||
|
|
||||||
tdDestroySVCreateTbReq(pNew->pCreateTbReq);
|
tdDestroySVCreateTbReq(pNew->pCreateTbReq);
|
||||||
|
@ -546,20 +570,35 @@ int32_t doConvertRows(SSubmitTbData* pTableData, const STSchema* pTSchema, SSDat
|
||||||
taosArrayClear(pVals);
|
taosArrayClear(pVals);
|
||||||
|
|
||||||
int32_t dataIndex = 0;
|
int32_t dataIndex = 0;
|
||||||
|
int64_t ts = 0;
|
||||||
|
|
||||||
for (int32_t k = 0; k < pTSchema->numOfCols; k++) {
|
for (int32_t k = 0; k < pTSchema->numOfCols; k++) {
|
||||||
const STColumn* pCol = &pTSchema->columns[k];
|
const STColumn* pCol = &pTSchema->columns[k];
|
||||||
|
|
||||||
|
// primary timestamp column, for debug purpose
|
||||||
if (k == 0) {
|
if (k == 0) {
|
||||||
SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, dataIndex);
|
SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, dataIndex);
|
||||||
void* colData = colDataGetData(pColData, j);
|
ts = *(int64_t*)colDataGetData(pColData, j);
|
||||||
tqTrace("s-task:%s sink row %d, col %d ts %" PRId64, id, j, k, *(int64_t*)colData);
|
tqTrace("s-task:%s sink row %d, col %d ts %" PRId64, id, j, k, ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_SET_NULL(pCol)) {
|
if (IS_SET_NULL(pCol)) {
|
||||||
|
if (pCol->flags & COL_IS_KEY) {
|
||||||
|
qError("ts:%" PRId64 " Primary key column should not be null, colId:%" PRIi16 ", colType:%" PRIi8, ts,
|
||||||
|
pCol->colId, pCol->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type);
|
SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type);
|
||||||
taosArrayPush(pVals, &cv);
|
taosArrayPush(pVals, &cv);
|
||||||
} else {
|
} else {
|
||||||
SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, dataIndex);
|
SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, dataIndex);
|
||||||
if (colDataIsNull_s(pColData, j)) {
|
if (colDataIsNull_s(pColData, j)) {
|
||||||
|
if (pCol->flags & COL_IS_KEY) {
|
||||||
|
qError("ts:%" PRId64 "Primary key column should not be null, colId:%" PRIi16 ", colType:%" PRIi8,
|
||||||
|
ts, pCol->colId, pCol->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type);
|
SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type);
|
||||||
taosArrayPush(pVals, &cv);
|
taosArrayPush(pVals, &cv);
|
||||||
dataIndex++;
|
dataIndex++;
|
||||||
|
@ -583,6 +622,8 @@ int32_t doConvertRows(SSubmitTbData* pTableData, const STSchema* pTSchema, SSDat
|
||||||
}
|
}
|
||||||
|
|
||||||
SRow* pRow = NULL;
|
SRow* pRow = NULL;
|
||||||
|
tqInfo("result column flag:%d", pTSchema->columns[1].flags);
|
||||||
|
|
||||||
code = tRowBuild(pVals, (STSchema*)pTSchema, &pRow);
|
code = tRowBuild(pVals, (STSchema*)pTSchema, &pRow);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tDestroySubmitTbData(pTableData, TSDB_MSG_FLG_ENCODE);
|
tDestroySubmitTbData(pTableData, TSDB_MSG_FLG_ENCODE);
|
||||||
|
|
|
@ -850,12 +850,18 @@ int32_t tqStreamTaskProcessTaskResetReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
||||||
|
|
||||||
tqDebug("s-task:%s receive task-reset msg from mnode, reset status and ready for data processing", pTask->id.idStr);
|
tqDebug("s-task:%s receive task-reset msg from mnode, reset status and ready for data processing", pTask->id.idStr);
|
||||||
|
|
||||||
|
taosThreadMutexLock(&pTask->lock);
|
||||||
|
|
||||||
// clear flag set during do checkpoint, and open inputQ for all upstream tasks
|
// clear flag set during do checkpoint, and open inputQ for all upstream tasks
|
||||||
if (streamTaskGetStatus(pTask)->state == TASK_STATUS__CK) {
|
if (streamTaskGetStatus(pTask)->state == TASK_STATUS__CK) {
|
||||||
|
tqDebug("s-task:%s reset task status from checkpoint, current checkpointingId:%" PRId64 ", transId:%d",
|
||||||
|
pTask->id.idStr, pTask->chkInfo.checkpointingId, pTask->chkInfo.transId);
|
||||||
streamTaskClearCheckInfo(pTask, true);
|
streamTaskClearCheckInfo(pTask, true);
|
||||||
streamTaskSetStatusReady(pTask);
|
streamTaskSetStatusReady(pTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&pTask->lock);
|
||||||
|
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,6 +339,7 @@ static void rocksMayWrite(STsdb *pTsdb, bool force, bool read, bool lock) {
|
||||||
static SLastCol *tsdbCacheConvertLastColV1(SLastColV1 *pLastColV1) {
|
static SLastCol *tsdbCacheConvertLastColV1(SLastColV1 *pLastColV1) {
|
||||||
SLastCol *pLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
|
SLastCol *pLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
|
||||||
if (pLastCol == NULL) return NULL;
|
if (pLastCol == NULL) return NULL;
|
||||||
|
pLastCol->version = LAST_COL_VERSION;
|
||||||
pLastCol->rowKey.ts = pLastColV1->ts;
|
pLastCol->rowKey.ts = pLastColV1->ts;
|
||||||
pLastCol->rowKey.numOfPKs = 0;
|
pLastCol->rowKey.numOfPKs = 0;
|
||||||
pLastCol->dirty = pLastColV1->dirty;
|
pLastCol->dirty = pLastColV1->dirty;
|
||||||
|
@ -408,7 +409,7 @@ static SLastCol *tsdbCacheDeserialize(char const *value) {
|
||||||
if (!hasVersion) {
|
if (!hasVersion) {
|
||||||
return tsdbCacheDeserializeV1(value);
|
return tsdbCacheDeserializeV1(value);
|
||||||
}
|
}
|
||||||
return tsdbCacheDeserializeV2(value + sizeof(int64_t));
|
return tsdbCacheDeserializeV2(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t tsdbCacheCopyVarData(SValue *from, SValue *to) {
|
static uint32_t tsdbCacheCopyVarData(SValue *from, SValue *to) {
|
||||||
|
@ -423,7 +424,7 @@ static uint32_t tsdbCacheCopyVarData(SValue *from, SValue *to) {
|
||||||
|
|
||||||
static void tsdbCacheSerialize(SLastCol *pLastCol, char **value, size_t *size) {
|
static void tsdbCacheSerialize(SLastCol *pLastCol, char **value, size_t *size) {
|
||||||
SColVal *pColVal = &pLastCol->colVal;
|
SColVal *pColVal = &pLastCol->colVal;
|
||||||
size_t length = sizeof(int64_t) + sizeof(*pLastCol);
|
size_t length = sizeof(*pLastCol);
|
||||||
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
|
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
|
||||||
if (IS_VAR_DATA_TYPE(pLastCol->rowKey.pks[i].type)) {
|
if (IS_VAR_DATA_TYPE(pLastCol->rowKey.pks[i].type)) {
|
||||||
length += pLastCol->rowKey.pks[i].nData;
|
length += pLastCol->rowKey.pks[i].nData;
|
||||||
|
@ -435,14 +436,11 @@ static void tsdbCacheSerialize(SLastCol *pLastCol, char **value, size_t *size) {
|
||||||
|
|
||||||
// set version
|
// set version
|
||||||
*value = taosMemoryMalloc(length);
|
*value = taosMemoryMalloc(length);
|
||||||
char *currentPos = *value;
|
|
||||||
*(int64_t *)currentPos = LAST_COL_VERSION;
|
|
||||||
currentPos += sizeof(int64_t);
|
|
||||||
|
|
||||||
// copy last col
|
// copy last col
|
||||||
SLastCol* pToLastCol = (SLastCol *)currentPos;
|
SLastCol* pToLastCol = (SLastCol *)(*value);
|
||||||
*pToLastCol = *pLastCol;
|
*pToLastCol = *pLastCol;
|
||||||
currentPos += sizeof(*pLastCol);
|
char *currentPos = *value + sizeof(*pLastCol);
|
||||||
|
|
||||||
// copy var data pks
|
// copy var data pks
|
||||||
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
|
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
|
||||||
|
@ -535,18 +533,22 @@ int32_t tsdbCacheCommit(STsdb *pTsdb) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reallocVarData(SColVal *pColVal) {
|
static void reallocVarDataVal(SValue *pValue) {
|
||||||
if (IS_VAR_DATA_TYPE(pColVal->value.type)) {
|
if (IS_VAR_DATA_TYPE(pValue->type)) {
|
||||||
uint8_t *pVal = pColVal->value.pData;
|
uint8_t *pVal = pValue->pData;
|
||||||
if (pColVal->value.nData > 0) {
|
if (pValue->nData > 0) {
|
||||||
pColVal->value.pData = taosMemoryMalloc(pColVal->value.nData);
|
pValue->pData = taosMemoryMalloc(pValue->nData);
|
||||||
memcpy(pColVal->value.pData, pVal, pColVal->value.nData);
|
memcpy(pValue->pData, pVal, pValue->nData);
|
||||||
} else {
|
} else {
|
||||||
pColVal->value.pData = NULL;
|
pValue->pData = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void reallocVarData(SColVal *pColVal) {
|
||||||
|
reallocVarDataVal(&pColVal->value);
|
||||||
|
}
|
||||||
|
|
||||||
static void tsdbCacheDeleter(const void *key, size_t klen, void *value, void *ud) {
|
static void tsdbCacheDeleter(const void *key, size_t klen, void *value, void *ud) {
|
||||||
SLastCol *pLastCol = (SLastCol *)value;
|
SLastCol *pLastCol = (SLastCol *)value;
|
||||||
|
|
||||||
|
@ -569,16 +571,26 @@ static int32_t tsdbCacheNewTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, i
|
||||||
SRowKey noneRowKey = {0};
|
SRowKey noneRowKey = {0};
|
||||||
noneRowKey.ts = TSKEY_MIN;
|
noneRowKey.ts = TSKEY_MIN;
|
||||||
noneRowKey.numOfPKs = 0;
|
noneRowKey.numOfPKs = 0;
|
||||||
SLastCol noneCol = {.rowKey = noneRowKey, .colVal = COL_VAL_NONE(cid, col_type), .dirty = 1};
|
SLastCol noneCol = {
|
||||||
|
.version = LAST_COL_VERSION, .rowKey = noneRowKey, .colVal = COL_VAL_NONE(cid, col_type), .dirty = 1};
|
||||||
SLastCol *pLastCol = &noneCol;
|
SLastCol *pLastCol = &noneCol;
|
||||||
|
|
||||||
SLastCol *pTmpLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
|
SLastCol *pTmpLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
|
||||||
*pTmpLastCol = *pLastCol;
|
*pTmpLastCol = *pLastCol;
|
||||||
pLastCol = pTmpLastCol;
|
pLastCol = pTmpLastCol;
|
||||||
|
|
||||||
reallocVarData(&pLastCol->colVal);
|
|
||||||
size_t charge = sizeof(*pLastCol);
|
size_t charge = sizeof(*pLastCol);
|
||||||
|
|
||||||
|
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
|
||||||
|
SValue *pValue = &pLastCol->rowKey.pks[i];
|
||||||
|
if (IS_VAR_DATA_TYPE(pValue->type)) {
|
||||||
|
reallocVarDataVal(pValue);
|
||||||
|
charge += pValue->nData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
||||||
|
reallocVarData(&pLastCol->colVal);
|
||||||
charge += pLastCol->colVal.value.nData;
|
charge += pLastCol->colVal.value.nData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,6 +935,7 @@ static void tsdbCacheUpdateLastCol(SLastCol *pLastCol, SRowKey *pRowKey, SColVal
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
|
|
||||||
// update rowkey
|
// update rowkey
|
||||||
|
pLastCol->version = LAST_COL_VERSION;
|
||||||
pLastCol->rowKey.ts = pRowKey->ts;
|
pLastCol->rowKey.ts = pRowKey->ts;
|
||||||
pLastCol->rowKey.numOfPKs = pRowKey->numOfPKs;
|
pLastCol->rowKey.numOfPKs = pRowKey->numOfPKs;
|
||||||
for (int8_t i = 0; i < pRowKey->numOfPKs; i++) {
|
for (int8_t i = 0; i < pRowKey->numOfPKs; i++) {
|
||||||
|
@ -1015,7 +1028,6 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
|
||||||
LRUHandle *h = taosLRUCacheLookup(pCache, key, klen);
|
LRUHandle *h = taosLRUCacheLookup(pCache, key, klen);
|
||||||
if (h) {
|
if (h) {
|
||||||
SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h);
|
SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h);
|
||||||
|
|
||||||
if (tRowKeyCompare(&pLastCol->rowKey, pRowKey) != 1) {
|
if (tRowKeyCompare(&pLastCol->rowKey, pRowKey) != 1) {
|
||||||
tsdbCacheUpdateLastCol(pLastCol, pRowKey, pColVal);
|
tsdbCacheUpdateLastCol(pLastCol, pRowKey, pColVal);
|
||||||
}
|
}
|
||||||
|
@ -1032,7 +1044,6 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
|
||||||
LRUHandle *h = taosLRUCacheLookup(pCache, key, klen);
|
LRUHandle *h = taosLRUCacheLookup(pCache, key, klen);
|
||||||
if (h) {
|
if (h) {
|
||||||
SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h);
|
SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h);
|
||||||
|
|
||||||
if (tRowKeyCompare(&pLastCol->rowKey, pRowKey) != 1) {
|
if (tRowKeyCompare(&pLastCol->rowKey, pRowKey) != 1) {
|
||||||
tsdbCacheUpdateLastCol(pLastCol, pRowKey, pColVal);
|
tsdbCacheUpdateLastCol(pLastCol, pRowKey, pColVal);
|
||||||
}
|
}
|
||||||
|
@ -1078,6 +1089,7 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
|
||||||
// SColVal *pColVal = (SColVal *)taosArrayGet(aColVal, idxKey->idx);
|
// SColVal *pColVal = (SColVal *)taosArrayGet(aColVal, idxKey->idx);
|
||||||
|
|
||||||
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[i]);
|
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[i]);
|
||||||
|
SLastCol *PToFree = pLastCol;
|
||||||
|
|
||||||
if (IS_LAST_ROW_KEY(idxKey->key)) {
|
if (IS_LAST_ROW_KEY(idxKey->key)) {
|
||||||
if (NULL == pLastCol || (tRowKeyCompare(&pLastCol->rowKey, pRowKey) != 1)) {
|
if (NULL == pLastCol || (tRowKeyCompare(&pLastCol->rowKey, pRowKey) != 1)) {
|
||||||
|
@ -1096,9 +1108,17 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
|
||||||
*pTmpLastCol = *pLastCol;
|
*pTmpLastCol = *pLastCol;
|
||||||
pLastCol = pTmpLastCol;
|
pLastCol = pTmpLastCol;
|
||||||
|
|
||||||
reallocVarData(&pLastCol->colVal);
|
|
||||||
size_t charge = sizeof(*pLastCol);
|
size_t charge = sizeof(*pLastCol);
|
||||||
|
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
|
||||||
|
SValue *pValue = &pLastCol->rowKey.pks[i];
|
||||||
|
if (IS_VAR_DATA_TYPE(pValue->type)) {
|
||||||
|
reallocVarDataVal(pValue);
|
||||||
|
charge += pValue->nData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
||||||
|
reallocVarData(&pLastCol->colVal);
|
||||||
charge += pLastCol->colVal.value.nData;
|
charge += pLastCol->colVal.value.nData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1128,9 +1148,17 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
|
||||||
*pTmpLastCol = *pLastCol;
|
*pTmpLastCol = *pLastCol;
|
||||||
pLastCol = pTmpLastCol;
|
pLastCol = pTmpLastCol;
|
||||||
|
|
||||||
reallocVarData(&pLastCol->colVal);
|
|
||||||
size_t charge = sizeof(*pLastCol);
|
size_t charge = sizeof(*pLastCol);
|
||||||
|
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
|
||||||
|
SValue *pValue = &pLastCol->rowKey.pks[i];
|
||||||
|
if (IS_VAR_DATA_TYPE(pValue->type)) {
|
||||||
|
reallocVarDataVal(pValue);
|
||||||
|
charge += pValue->nData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
||||||
|
reallocVarData(&pLastCol->colVal);
|
||||||
charge += pLastCol->colVal.value.nData;
|
charge += pLastCol->colVal.value.nData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1143,10 +1171,9 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
|
||||||
taosMemoryFree(value);
|
taosMemoryFree(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(pLastCol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(PToFree);
|
||||||
rocksdb_free(values_list[i]);
|
rocksdb_free(values_list[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1428,7 +1455,8 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
|
||||||
}
|
}
|
||||||
|
|
||||||
// still null, then make up a none col value
|
// still null, then make up a none col value
|
||||||
SLastCol noneCol = {.rowKey.ts = TSKEY_MIN,
|
SLastCol noneCol = {.version = LAST_COL_VERSION,
|
||||||
|
.rowKey.ts = TSKEY_MIN,
|
||||||
.colVal = COL_VAL_NONE(idxKey->key.cid, pr->pSchema->columns[slotIds[i]].type)};
|
.colVal = COL_VAL_NONE(idxKey->key.cid, pr->pSchema->columns[slotIds[i]].type)};
|
||||||
if (!pLastCol) {
|
if (!pLastCol) {
|
||||||
pLastCol = &noneCol;
|
pLastCol = &noneCol;
|
||||||
|
@ -1446,9 +1474,16 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
|
||||||
*pTmpLastCol = *pLastCol;
|
*pTmpLastCol = *pLastCol;
|
||||||
pLastCol = pTmpLastCol;
|
pLastCol = pTmpLastCol;
|
||||||
|
|
||||||
reallocVarData(&pLastCol->colVal);
|
|
||||||
size_t charge = sizeof(*pLastCol);
|
size_t charge = sizeof(*pLastCol);
|
||||||
|
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
|
||||||
|
SValue *pValue = &pLastCol->rowKey.pks[i];
|
||||||
|
if (IS_VAR_DATA_TYPE(pValue->type)) {
|
||||||
|
reallocVarDataVal(pValue);
|
||||||
|
charge += pValue->nData;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
||||||
|
reallocVarData(&pLastCol->colVal);
|
||||||
charge += pLastCol->colVal.value.nData;
|
charge += pLastCol->colVal.value.nData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1524,15 +1559,23 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
|
||||||
SLRUCache *pCache = pTsdb->lruCache;
|
SLRUCache *pCache = pTsdb->lruCache;
|
||||||
for (int i = 0, j = 0; i < num_keys && j < TARRAY_SIZE(remainCols); ++i) {
|
for (int i = 0, j = 0; i < num_keys && j < TARRAY_SIZE(remainCols); ++i) {
|
||||||
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[i]);
|
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[i]);
|
||||||
|
SLastCol* PToFree = pLastCol;
|
||||||
SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j];
|
SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j];
|
||||||
if (pLastCol) {
|
if (pLastCol) {
|
||||||
SLastCol *pTmpLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
|
SLastCol *pTmpLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
|
||||||
*pTmpLastCol = *pLastCol;
|
*pTmpLastCol = *pLastCol;
|
||||||
pLastCol = pTmpLastCol;
|
pLastCol = pTmpLastCol;
|
||||||
|
|
||||||
reallocVarData(&pLastCol->colVal);
|
|
||||||
size_t charge = sizeof(*pLastCol);
|
size_t charge = sizeof(*pLastCol);
|
||||||
|
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
|
||||||
|
SValue *pValue = &pLastCol->rowKey.pks[i];
|
||||||
|
if (IS_VAR_DATA_TYPE(pValue->type)) {
|
||||||
|
reallocVarDataVal(pValue);
|
||||||
|
charge += pValue->nData;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
||||||
|
reallocVarData(&pLastCol->colVal);
|
||||||
charge += pLastCol->colVal.value.nData;
|
charge += pLastCol->colVal.value.nData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1543,11 +1586,14 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
|
||||||
}
|
}
|
||||||
|
|
||||||
SLastCol lastCol = *pLastCol;
|
SLastCol lastCol = *pLastCol;
|
||||||
|
for (int8_t i = 0; i < lastCol.rowKey.numOfPKs; i++) {
|
||||||
|
reallocVarDataVal(&lastCol.rowKey.pks[i]);
|
||||||
|
}
|
||||||
reallocVarData(&lastCol.colVal);
|
reallocVarData(&lastCol.colVal);
|
||||||
taosArraySet(pLastArray, idxKey->idx, &lastCol);
|
taosArraySet(pLastArray, idxKey->idx, &lastCol);
|
||||||
taosArrayRemove(remainCols, j);
|
taosArrayRemove(remainCols, j);
|
||||||
|
|
||||||
taosMemoryFree(pLastCol);
|
taosMemoryFreeClear(PToFree);
|
||||||
taosMemoryFree(values_list[i]);
|
taosMemoryFree(values_list[i]);
|
||||||
} else {
|
} else {
|
||||||
++j;
|
++j;
|
||||||
|
@ -1591,12 +1637,17 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
||||||
SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h);
|
SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h);
|
||||||
|
|
||||||
SLastCol lastCol = *pLastCol;
|
SLastCol lastCol = *pLastCol;
|
||||||
|
for (int8_t i = 0; i < lastCol.rowKey.numOfPKs; i++) {
|
||||||
|
reallocVarDataVal(&lastCol.rowKey.pks[i]);
|
||||||
|
}
|
||||||
reallocVarData(&lastCol.colVal);
|
reallocVarData(&lastCol.colVal);
|
||||||
taosArrayPush(pLastArray, &lastCol);
|
taosArrayPush(pLastArray, &lastCol);
|
||||||
|
|
||||||
taosLRUCacheRelease(pCache, h, false);
|
taosLRUCacheRelease(pCache, h, false);
|
||||||
} else {
|
} else {
|
||||||
SLastCol noneCol = {.rowKey.ts = TSKEY_MIN, .colVal = COL_VAL_NONE(cid, pr->pSchema->columns[pr->pSlotIds[i]].type)};
|
SLastCol noneCol = {.version = LAST_COL_VERSION,
|
||||||
|
.rowKey.ts = TSKEY_MIN,
|
||||||
|
.colVal = COL_VAL_NONE(cid, pr->pSchema->columns[pr->pSlotIds[i]].type)};
|
||||||
|
|
||||||
taosArrayPush(pLastArray, &noneCol);
|
taosArrayPush(pLastArray, &noneCol);
|
||||||
|
|
||||||
|
@ -1616,6 +1667,9 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
||||||
SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h);
|
SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h);
|
||||||
|
|
||||||
SLastCol lastCol = *pLastCol;
|
SLastCol lastCol = *pLastCol;
|
||||||
|
for (int8_t i = 0; i < lastCol.rowKey.numOfPKs; i++) {
|
||||||
|
reallocVarDataVal(&lastCol.rowKey.pks[i]);
|
||||||
|
}
|
||||||
reallocVarData(&lastCol.colVal);
|
reallocVarData(&lastCol.colVal);
|
||||||
taosArraySet(pLastArray, idxKey->idx, &lastCol);
|
taosArraySet(pLastArray, idxKey->idx, &lastCol);
|
||||||
|
|
||||||
|
@ -1702,7 +1756,6 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
|
||||||
if (NULL != pLastCol && (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey)) {
|
if (NULL != pLastCol && (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey)) {
|
||||||
rocksdb_writebatch_delete(wb, keys_list[i], klen);
|
rocksdb_writebatch_delete(wb, keys_list[i], klen);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pLastCol);
|
taosMemoryFreeClear(pLastCol);
|
||||||
|
|
||||||
pLastCol = tsdbCacheDeserialize(values_list[i + num_keys]);
|
pLastCol = tsdbCacheDeserialize(values_list[i + num_keys]);
|
||||||
|
@ -3232,7 +3285,9 @@ static int32_t initLastColArrayPartial(STSchema *pTSchema, SArray **ppColArray,
|
||||||
|
|
||||||
for (int32_t i = 0; i < nCols; ++i) {
|
for (int32_t i = 0; i < nCols; ++i) {
|
||||||
int16_t slotId = slotIds[i];
|
int16_t slotId = slotIds[i];
|
||||||
SLastCol col = {.rowKey.ts = 0, .colVal = COL_VAL_NULL(pTSchema->columns[slotId].colId, pTSchema->columns[slotId].type)};
|
SLastCol col = {.version = LAST_COL_VERSION,
|
||||||
|
.rowKey.ts = 0,
|
||||||
|
.colVal = COL_VAL_NULL(pTSchema->columns[slotId].colId, pTSchema->columns[slotId].type)};
|
||||||
taosArrayPush(pColArray, &col);
|
taosArrayPush(pColArray, &col);
|
||||||
}
|
}
|
||||||
*ppColArray = pColArray;
|
*ppColArray = pColArray;
|
||||||
|
@ -3337,12 +3392,12 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC
|
||||||
STColumn *pTColumn = &pTSchema->columns[0];
|
STColumn *pTColumn = &pTSchema->columns[0];
|
||||||
|
|
||||||
*pColVal = COL_VAL_VALUE(pTColumn->colId, ((SValue){.type = pTColumn->type, .val = rowTs}));
|
*pColVal = COL_VAL_VALUE(pTColumn->colId, ((SValue){.type = pTColumn->type, .val = rowTs}));
|
||||||
taosArraySet(pColArray, 0, &(SLastCol){.rowKey.ts = rowTs, .colVal = *pColVal});
|
taosArraySet(pColArray, 0, &(SLastCol){.version = LAST_COL_VERSION, .rowKey.ts = rowTs, .colVal = *pColVal});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal);
|
tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal);
|
||||||
|
|
||||||
*pCol = (SLastCol){.rowKey.ts = rowTs, .colVal = *pColVal};
|
*pCol = (SLastCol){.version = LAST_COL_VERSION, .rowKey.ts = rowTs, .colVal = *pColVal};
|
||||||
if (IS_VAR_DATA_TYPE(pColVal->value.type) /*&& pColVal->value.nData > 0*/) {
|
if (IS_VAR_DATA_TYPE(pColVal->value.type) /*&& pColVal->value.nData > 0*/) {
|
||||||
if (pColVal->value.nData > 0) {
|
if (pColVal->value.nData > 0) {
|
||||||
pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData);
|
pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData);
|
||||||
|
@ -3392,7 +3447,7 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC
|
||||||
|
|
||||||
tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal);
|
tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal);
|
||||||
if (!COL_VAL_IS_VALUE(tColVal) && COL_VAL_IS_VALUE(pColVal)) {
|
if (!COL_VAL_IS_VALUE(tColVal) && COL_VAL_IS_VALUE(pColVal)) {
|
||||||
SLastCol lastCol = {.rowKey.ts = rowTs, .colVal = *pColVal};
|
SLastCol lastCol = {.version = LAST_COL_VERSION, .rowKey.ts = rowTs, .colVal = *pColVal};
|
||||||
if (IS_VAR_DATA_TYPE(pColVal->value.type) /* && pColVal->value.nData > 0 */) {
|
if (IS_VAR_DATA_TYPE(pColVal->value.type) /* && pColVal->value.nData > 0 */) {
|
||||||
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pColArray, iCol);
|
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pColArray, iCol);
|
||||||
taosMemoryFree(pLastCol->colVal.value.pData);
|
taosMemoryFree(pLastCol->colVal.value.pData);
|
||||||
|
@ -3516,12 +3571,12 @@ static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray,
|
||||||
STColumn *pTColumn = &pTSchema->columns[0];
|
STColumn *pTColumn = &pTSchema->columns[0];
|
||||||
|
|
||||||
*pColVal = COL_VAL_VALUE(pTColumn->colId, ((SValue){.type = pTColumn->type, .val = rowTs}));
|
*pColVal = COL_VAL_VALUE(pTColumn->colId, ((SValue){.type = pTColumn->type, .val = rowTs}));
|
||||||
taosArraySet(pColArray, 0, &(SLastCol){.rowKey.ts = rowTs, .colVal = *pColVal});
|
taosArraySet(pColArray, 0, &(SLastCol){.version = LAST_COL_VERSION, .rowKey.ts = rowTs, .colVal = *pColVal});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal);
|
tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal);
|
||||||
|
|
||||||
*pCol = (SLastCol){.rowKey.ts = rowTs, .colVal = *pColVal};
|
*pCol = (SLastCol){.version = LAST_COL_VERSION, .rowKey.ts = rowTs, .colVal = *pColVal};
|
||||||
if (IS_VAR_DATA_TYPE(pColVal->value.type) /*&& pColVal->value.nData > 0*/) {
|
if (IS_VAR_DATA_TYPE(pColVal->value.type) /*&& pColVal->value.nData > 0*/) {
|
||||||
if (pColVal->value.nData > 0) {
|
if (pColVal->value.nData > 0) {
|
||||||
pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData);
|
pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData);
|
||||||
|
|
|
@ -240,10 +240,13 @@ static int32_t vnodePreProcessSubmitTbData(SVnode *pVnode, SDecoder *pCoder, int
|
||||||
}
|
}
|
||||||
|
|
||||||
SSubmitTbData submitTbData;
|
SSubmitTbData submitTbData;
|
||||||
|
uint8_t version;
|
||||||
if (tDecodeI32v(pCoder, &submitTbData.flags) < 0) {
|
if (tDecodeI32v(pCoder, &submitTbData.flags) < 0) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
version = (submitTbData.flags >> 8) & 0xff;
|
||||||
|
submitTbData.flags = submitTbData.flags & 0xff;
|
||||||
|
|
||||||
if (submitTbData.flags & SUBMIT_REQ_FROM_FILE) {
|
if (submitTbData.flags & SUBMIT_REQ_FROM_FILE) {
|
||||||
code = grantCheck(TSDB_GRANT_CSV);
|
code = grantCheck(TSDB_GRANT_CSV);
|
||||||
|
@ -307,7 +310,7 @@ static int32_t vnodePreProcessSubmitTbData(SVnode *pVnode, SDecoder *pCoder, int
|
||||||
}
|
}
|
||||||
|
|
||||||
SColData colData = {0};
|
SColData colData = {0};
|
||||||
pCoder->pos += tGetColData(pCoder->data + pCoder->pos, &colData);
|
pCoder->pos += tGetColData(version, pCoder->data + pCoder->pos, &colData);
|
||||||
if (colData.flag != HAS_VALUE) {
|
if (colData.flag != HAS_VALUE) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -321,7 +324,7 @@ static int32_t vnodePreProcessSubmitTbData(SVnode *pVnode, SDecoder *pCoder, int
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint64_t i = 1; i < nColData; i++) {
|
for (uint64_t i = 1; i < nColData; i++) {
|
||||||
pCoder->pos += tGetColData(pCoder->data + pCoder->pos, &colData);
|
pCoder->pos += tGetColData(version, pCoder->data + pCoder->pos, &colData);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint64_t nRow;
|
uint64_t nRow;
|
||||||
|
@ -1572,17 +1575,18 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, in
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
SColData *pColData = (SColData *)taosArrayGet(pSubmitTbData->aCol, 0);
|
SColData *colDataArr = TARRAY_DATA(pSubmitTbData->aCol);
|
||||||
TSKEY *aKey = (TSKEY *)(pColData->pData);
|
SRowKey lastKey;
|
||||||
|
tColDataArrGetRowKey(colDataArr, TARRAY_SIZE(pSubmitTbData->aCol), 0, &lastKey);
|
||||||
for (int32_t iRow = 0; iRow < pColData->nVal; iRow++) {
|
for (int32_t iRow = 1; iRow < colDataArr[0].nVal; iRow++) {
|
||||||
if (aKey[iRow] < minKey || aKey[iRow] > maxKey || (iRow > 0 && aKey[iRow] <= aKey[iRow - 1])) {
|
SRowKey key;
|
||||||
|
tColDataArrGetRowKey(TARRAY_DATA(pSubmitTbData->aCol), TARRAY_SIZE(pSubmitTbData->aCol), iRow, &key);
|
||||||
|
if (tRowKeyCompare(&lastKey, &key) >= 0) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
vError("vgId:%d %s failed since %s, version:%" PRId64, TD_VID(pVnode), __func__, tstrerror(terrno), ver);
|
vError("vgId:%d %s failed since %s, version:%" PRId64, TD_VID(pVnode), __func__, tstrerror(terrno), ver);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int32_t nRow = TARRAY_SIZE(pSubmitTbData->aRowP);
|
int32_t nRow = TARRAY_SIZE(pSubmitTbData->aRowP);
|
||||||
SRow **aRow = (SRow **)TARRAY_DATA(pSubmitTbData->aRowP);
|
SRow **aRow = (SRow **)TARRAY_DATA(pSubmitTbData->aRowP);
|
||||||
|
|
|
@ -451,8 +451,10 @@ typedef struct SStreamScanInfo {
|
||||||
SExprInfo* pPseudoExpr;
|
SExprInfo* pPseudoExpr;
|
||||||
int32_t numOfPseudoExpr;
|
int32_t numOfPseudoExpr;
|
||||||
SExprSupp tbnameCalSup;
|
SExprSupp tbnameCalSup;
|
||||||
|
SExprSupp* pPartTbnameSup;
|
||||||
SExprSupp tagCalSup;
|
SExprSupp tagCalSup;
|
||||||
int32_t primaryTsIndex; // primary time stamp slot id
|
int32_t primaryTsIndex; // primary time stamp slot id
|
||||||
|
int32_t primaryKeyIndex;
|
||||||
SReadHandle readHandle;
|
SReadHandle readHandle;
|
||||||
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here.
|
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here.
|
||||||
SColMatchInfo matchInfo;
|
SColMatchInfo matchInfo;
|
||||||
|
@ -606,6 +608,8 @@ typedef struct SStreamIntervalOperatorInfo {
|
||||||
bool clearState;
|
bool clearState;
|
||||||
SArray* pMidPullDatas;
|
SArray* pMidPullDatas;
|
||||||
int32_t midDelIndex;
|
int32_t midDelIndex;
|
||||||
|
SSHashObj* pDeletedMap;
|
||||||
|
bool destHasPrimaryKey;
|
||||||
} SStreamIntervalOperatorInfo;
|
} SStreamIntervalOperatorInfo;
|
||||||
|
|
||||||
typedef struct SDataGroupInfo {
|
typedef struct SDataGroupInfo {
|
||||||
|
@ -656,6 +660,8 @@ typedef struct SStreamSessionAggOperatorInfo {
|
||||||
SSDataBlock* pCheckpointRes;
|
SSDataBlock* pCheckpointRes;
|
||||||
bool clearState;
|
bool clearState;
|
||||||
bool recvGetAll;
|
bool recvGetAll;
|
||||||
|
bool destHasPrimaryKey;
|
||||||
|
SSHashObj* pPkDeleted;
|
||||||
} SStreamSessionAggOperatorInfo;
|
} SStreamSessionAggOperatorInfo;
|
||||||
|
|
||||||
typedef struct SStreamStateAggOperatorInfo {
|
typedef struct SStreamStateAggOperatorInfo {
|
||||||
|
@ -680,6 +686,8 @@ typedef struct SStreamStateAggOperatorInfo {
|
||||||
bool reCkBlock;
|
bool reCkBlock;
|
||||||
SSDataBlock* pCheckpointRes;
|
SSDataBlock* pCheckpointRes;
|
||||||
bool recvGetAll;
|
bool recvGetAll;
|
||||||
|
SSHashObj* pPkDeleted;
|
||||||
|
bool destHasPrimaryKey;
|
||||||
} SStreamStateAggOperatorInfo;
|
} SStreamStateAggOperatorInfo;
|
||||||
|
|
||||||
typedef struct SStreamEventAggOperatorInfo {
|
typedef struct SStreamEventAggOperatorInfo {
|
||||||
|
@ -706,6 +714,8 @@ typedef struct SStreamEventAggOperatorInfo {
|
||||||
SSDataBlock* pCheckpointRes;
|
SSDataBlock* pCheckpointRes;
|
||||||
SFilterInfo* pStartCondInfo;
|
SFilterInfo* pStartCondInfo;
|
||||||
SFilterInfo* pEndCondInfo;
|
SFilterInfo* pEndCondInfo;
|
||||||
|
SSHashObj* pPkDeleted;
|
||||||
|
bool destHasPrimaryKey;
|
||||||
} SStreamEventAggOperatorInfo;
|
} SStreamEventAggOperatorInfo;
|
||||||
|
|
||||||
typedef struct SStreamCountAggOperatorInfo {
|
typedef struct SStreamCountAggOperatorInfo {
|
||||||
|
@ -727,6 +737,8 @@ typedef struct SStreamCountAggOperatorInfo {
|
||||||
bool reCkBlock;
|
bool reCkBlock;
|
||||||
bool recvGetAll;
|
bool recvGetAll;
|
||||||
SSDataBlock* pCheckpointRes;
|
SSDataBlock* pCheckpointRes;
|
||||||
|
SSHashObj* pPkDeleted;
|
||||||
|
bool destHasPrimaryKey;
|
||||||
} SStreamCountAggOperatorInfo;
|
} SStreamCountAggOperatorInfo;
|
||||||
|
|
||||||
typedef struct SStreamPartitionOperatorInfo {
|
typedef struct SStreamPartitionOperatorInfo {
|
||||||
|
@ -863,10 +875,8 @@ bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup);
|
||||||
bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup);
|
bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup);
|
||||||
bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, void* pState, STimeWindowAggSupp* pTwSup,
|
bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, void* pState, STimeWindowAggSupp* pTwSup,
|
||||||
SStateStore* pStore);
|
SStateStore* pStore);
|
||||||
void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid,
|
void appendDataToSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid,
|
||||||
uint64_t* pGp, void* pTbName);
|
uint64_t* pGp, void* pTbName);
|
||||||
void appendAllColumnToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, TSKEY* pCalStartTs,
|
|
||||||
TSKEY* pCalEndTs, uint64_t* pUid, uint64_t* pGp, void* pTbName);
|
|
||||||
|
|
||||||
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId);
|
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId);
|
||||||
|
|
||||||
|
@ -905,7 +915,7 @@ void initDownStream(struct SOperatorInfo* downstream, SStreamAggSupporter* p
|
||||||
void getMaxTsWins(const SArray* pAllWins, SArray* pMaxWins);
|
void getMaxTsWins(const SArray* pAllWins, SArray* pMaxWins);
|
||||||
void initGroupResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList);
|
void initGroupResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList);
|
||||||
void getSessionHashKey(const SSessionKey* pKey, SSessionKey* pHashKey);
|
void getSessionHashKey(const SSessionKey* pKey, SSessionKey* pHashKey);
|
||||||
void deleteSessionWinState(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SSHashObj* pMapUpdate, SSHashObj* pMapDelete);
|
void deleteSessionWinState(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SSHashObj* pMapUpdate, SSHashObj* pMapDelete, SSHashObj* pPkDelete, bool needAdd);
|
||||||
int32_t getAllSessionWindow(SSHashObj* pHashMap, SSHashObj* pStUpdated);
|
int32_t getAllSessionWindow(SSHashObj* pHashMap, SSHashObj* pStUpdated);
|
||||||
int32_t closeSessionWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SSHashObj* pClosed);
|
int32_t closeSessionWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SSHashObj* pClosed);
|
||||||
int32_t copyUpdateResult(SSHashObj** ppWinUpdated, SArray* pUpdated, __compar_fn_t compar);
|
int32_t copyUpdateResult(SSHashObj** ppWinUpdated, SArray* pUpdated, __compar_fn_t compar);
|
||||||
|
@ -955,6 +965,7 @@ bool doDeleteSessionWindow(SStreamAggSupporter* pAggSup, SSessionKey* pK
|
||||||
void saveDeleteInfo(SArray* pWins, SSessionKey key);
|
void saveDeleteInfo(SArray* pWins, SSessionKey key);
|
||||||
void removeSessionResults(SStreamAggSupporter* pAggSup, SSHashObj* pHashMap, SArray* pWins);
|
void removeSessionResults(SStreamAggSupporter* pAggSup, SSHashObj* pHashMap, SArray* pWins);
|
||||||
void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted);
|
void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted);
|
||||||
|
void copyDeleteSessionKey(SSHashObj* source, SSHashObj* dest);
|
||||||
|
|
||||||
bool inSlidingWindow(SInterval* pInterval, STimeWindow* pWin, SDataBlockInfo* pBlockInfo);
|
bool inSlidingWindow(SInterval* pInterval, STimeWindow* pWin, SDataBlockInfo* pBlockInfo);
|
||||||
bool inCalSlidingWindow(SInterval* pInterval, STimeWindow* pWin, TSKEY calStart, TSKEY calEnd, EStreamType blockType);
|
bool inCalSlidingWindow(SInterval* pInterval, STimeWindow* pWin, TSKEY calStart, TSKEY calEnd, EStreamType blockType);
|
||||||
|
|
|
@ -45,8 +45,8 @@ static FilterCondType checkTagCond(SNode* cond);
|
||||||
static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond, SStorageAPI* pAPI);
|
static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond, SStorageAPI* pAPI);
|
||||||
static int32_t optimizeTbnameInCondImpl(void* metaHandle, SArray* list, SNode* pTagCond, SStorageAPI* pStoreAPI);
|
static int32_t optimizeTbnameInCondImpl(void* metaHandle, SArray* list, SNode* pTagCond, SStorageAPI* pStoreAPI);
|
||||||
|
|
||||||
static int32_t getTableList(void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, SNode* pTagIndexCond,
|
static int32_t getTableList(void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, SNode* pTagIndexCond,
|
||||||
STableListInfo* pListInfo, uint8_t* digest, const char* idstr, SStorageAPI* pStorageAPI);
|
STableListInfo* pListInfo, uint8_t* digest, const char* idstr, SStorageAPI* pStorageAPI);
|
||||||
|
|
||||||
static int64_t getLimit(const SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->limit; }
|
static int64_t getLimit(const SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->limit; }
|
||||||
static int64_t getOffset(const SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->offset; }
|
static int64_t getOffset(const SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->offset; }
|
||||||
|
@ -671,7 +671,8 @@ int32_t getColInfoResultForGroupby(void* pVnode, SNodeList* group, STableListInf
|
||||||
info->groupId = calcGroupId(keyBuf, len);
|
info->groupId = calcGroupId(keyBuf, len);
|
||||||
if (initRemainGroups) {
|
if (initRemainGroups) {
|
||||||
// groupId ~ table uid
|
// groupId ~ table uid
|
||||||
taosHashPut(pTableListInfo->remainGroups, &(info->groupId), sizeof(info->groupId), &(info->uid), sizeof(info->uid));
|
taosHashPut(pTableListInfo->remainGroups, &(info->groupId), sizeof(info->groupId), &(info->uid),
|
||||||
|
sizeof(info->uid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,7 +888,7 @@ static int32_t optimizeTbnameInCondImpl(void* pVnode, SArray* pExistedUidList, S
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock* createTagValBlockForFilter(SArray* pColList, int32_t numOfTables, SArray* pUidTagList, void* pVnode,
|
SSDataBlock* createTagValBlockForFilter(SArray* pColList, int32_t numOfTables, SArray* pUidTagList, void* pVnode,
|
||||||
SStorageAPI* pStorageAPI) {
|
SStorageAPI* pStorageAPI) {
|
||||||
SSDataBlock* pResBlock = createDataBlock();
|
SSDataBlock* pResBlock = createDataBlock();
|
||||||
if (pResBlock == NULL) {
|
if (pResBlock == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -968,11 +969,12 @@ SSDataBlock* createTagValBlockForFilter(SArray* pColList, int32_t numOfTables, S
|
||||||
return pResBlock;
|
return pResBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doSetQualifiedUid(STableListInfo* pListInfo, SArray* pUidList, const SArray* pUidTagList, bool* pResultList, bool addUid) {
|
static int32_t doSetQualifiedUid(STableListInfo* pListInfo, SArray* pUidList, const SArray* pUidTagList,
|
||||||
|
bool* pResultList, bool addUid) {
|
||||||
taosArrayClear(pUidList);
|
taosArrayClear(pUidList);
|
||||||
|
|
||||||
STableKeyInfo info = {.uid = 0, .groupId = 0};
|
STableKeyInfo info = {.uid = 0, .groupId = 0};
|
||||||
int32_t numOfTables = taosArrayGetSize(pUidTagList);
|
int32_t numOfTables = taosArrayGetSize(pUidTagList);
|
||||||
for (int32_t i = 0; i < numOfTables; ++i) {
|
for (int32_t i = 0; i < numOfTables; ++i) {
|
||||||
if (pResultList[i]) {
|
if (pResultList[i]) {
|
||||||
uint64_t uid = ((STUidTagInfo*)taosArrayGet(pUidTagList, i))->uid;
|
uint64_t uid = ((STUidTagInfo*)taosArrayGet(pUidTagList, i))->uid;
|
||||||
|
@ -1172,7 +1174,7 @@ int32_t getTableList(void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, S
|
||||||
if (code != 0 || status == SFLT_NOT_INDEX) { // temporarily disable it for performance sake
|
if (code != 0 || status == SFLT_NOT_INDEX) { // temporarily disable it for performance sake
|
||||||
qDebug("failed to get tableIds from index, suid:%" PRIu64, pScanNode->uid);
|
qDebug("failed to get tableIds from index, suid:%" PRIu64, pScanNode->uid);
|
||||||
} else {
|
} else {
|
||||||
qInfo("succ to get filter result, table num: %d", (int)taosArrayGetSize(pUidList));
|
qDebug("succ to get filter result, table num: %d", (int)taosArrayGetSize(pUidList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1194,7 +1196,8 @@ int32_t getTableList(void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, S
|
||||||
memcpy(pPayload + sizeof(int32_t), taosArrayGet(pUidList, 0), numOfTables * sizeof(uint64_t));
|
memcpy(pPayload + sizeof(int32_t), taosArrayGet(pUidList, 0), numOfTables * sizeof(uint64_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
pStorageAPI->metaFn.putCachedTableList(pVnode, pScanNode->suid, context.digest, tListLen(context.digest), pPayload, size, 1);
|
pStorageAPI->metaFn.putCachedTableList(pVnode, pScanNode->suid, context.digest, tListLen(context.digest),
|
||||||
|
pPayload, size, 1);
|
||||||
digest[0] = 1;
|
digest[0] = 1;
|
||||||
memcpy(digest + 1, context.digest, tListLen(context.digest));
|
memcpy(digest + 1, context.digest, tListLen(context.digest));
|
||||||
}
|
}
|
||||||
|
@ -1756,7 +1759,8 @@ SColumn extractColumnFromColumnNode(SColumnNode* pColNode) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode, const SReadHandle* readHandle) {
|
int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode,
|
||||||
|
const SReadHandle* readHandle) {
|
||||||
pCond->order = pTableScanNode->scanSeq[0] > 0 ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
pCond->order = pTableScanNode->scanSeq[0] > 0 ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||||
pCond->numOfCols = LIST_LENGTH(pTableScanNode->scan.pScanCols);
|
pCond->numOfCols = LIST_LENGTH(pTableScanNode->scan.pScanCols);
|
||||||
|
|
||||||
|
@ -1779,8 +1783,7 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
|
||||||
|
|
||||||
// allowed read stt file optimization mode
|
// allowed read stt file optimization mode
|
||||||
pCond->notLoadData = (pTableScanNode->dataRequired == FUNC_DATA_REQUIRED_NOT_LOAD) &&
|
pCond->notLoadData = (pTableScanNode->dataRequired == FUNC_DATA_REQUIRED_NOT_LOAD) &&
|
||||||
(pTableScanNode->scan.node.pConditions == NULL) &&
|
(pTableScanNode->scan.node.pConditions == NULL) && (pTableScanNode->interval == 0);
|
||||||
(pTableScanNode->interval == 0);
|
|
||||||
|
|
||||||
int32_t j = 0;
|
int32_t j = 0;
|
||||||
for (int32_t i = 0; i < pCond->numOfCols; ++i) {
|
for (int32_t i = 0; i < pCond->numOfCols; ++i) {
|
||||||
|
@ -1923,7 +1926,8 @@ void getNextTimeWindow(const SInterval* pInterval, STimeWindow* tw, int32_t orde
|
||||||
int32_t factor = GET_FORWARD_DIRECTION_FACTOR(order);
|
int32_t factor = GET_FORWARD_DIRECTION_FACTOR(order);
|
||||||
slidingStart = taosTimeAdd(slidingStart, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
|
slidingStart = taosTimeAdd(slidingStart, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
|
||||||
tw->skey = taosTimeAdd(slidingStart, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
tw->skey = taosTimeAdd(slidingStart, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||||
int64_t slidingEnd = taosTimeAdd(slidingStart, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
int64_t slidingEnd =
|
||||||
|
taosTimeAdd(slidingStart, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||||
tw->ekey = taosTimeAdd(slidingEnd, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
tw->ekey = taosTimeAdd(slidingEnd, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2164,11 +2168,14 @@ int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle*
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableListInfo->oneTableForEachGroup = groupByTbname;
|
pTableListInfo->oneTableForEachGroup = groupByTbname;
|
||||||
|
if (numOfTables == 1 && pTableListInfo->idInfo.tableType == TSDB_CHILD_TABLE) {
|
||||||
|
pTableListInfo->oneTableForEachGroup = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (groupSort && groupByTbname) {
|
if (groupSort && groupByTbname) {
|
||||||
taosArraySort(pTableListInfo->pTableList, orderbyGroupIdComparFn);
|
taosArraySort(pTableListInfo->pTableList, orderbyGroupIdComparFn);
|
||||||
pTableListInfo->numOfOuputGroups = numOfTables;
|
pTableListInfo->numOfOuputGroups = numOfTables;
|
||||||
} else if (groupByTbname && pScanNode->groupOrderScan){
|
} else if (groupByTbname && pScanNode->groupOrderScan) {
|
||||||
pTableListInfo->numOfOuputGroups = numOfTables;
|
pTableListInfo->numOfOuputGroups = numOfTables;
|
||||||
} else if (groupByTbname && tsCountAlwaysReturnValue && ((STableScanPhysiNode*)pScanNode)->needCountEmptyTable) {
|
} else if (groupByTbname && tsCountAlwaysReturnValue && ((STableScanPhysiNode*)pScanNode)->needCountEmptyTable) {
|
||||||
pTableListInfo->numOfOuputGroups = numOfTables;
|
pTableListInfo->numOfOuputGroups = numOfTables;
|
||||||
|
@ -2179,7 +2186,8 @@ int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle*
|
||||||
bool initRemainGroups = false;
|
bool initRemainGroups = false;
|
||||||
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == nodeType(pScanNode)) {
|
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == nodeType(pScanNode)) {
|
||||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pScanNode;
|
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pScanNode;
|
||||||
if (tsCountAlwaysReturnValue && pTableScanNode->needCountEmptyTable && !(groupSort || pScanNode->groupOrderScan)) {
|
if (tsCountAlwaysReturnValue && pTableScanNode->needCountEmptyTable &&
|
||||||
|
!(groupSort || pScanNode->groupOrderScan)) {
|
||||||
initRemainGroups = true;
|
initRemainGroups = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2303,7 +2311,7 @@ void printSpecDataBlock(SSDataBlock* pBlock, const char* flag, const char* opStr
|
||||||
}
|
}
|
||||||
if (qDebugFlag & DEBUG_DEBUG) {
|
if (qDebugFlag & DEBUG_DEBUG) {
|
||||||
char* pBuf = NULL;
|
char* pBuf = NULL;
|
||||||
char flagBuf[64];
|
char flagBuf[64];
|
||||||
snprintf(flagBuf, sizeof(flagBuf), "%s %s", flag, opStr);
|
snprintf(flagBuf, sizeof(flagBuf), "%s %s", flag, opStr);
|
||||||
qDebug("%s", dumpBlockData(pBlock, flagBuf, &pBuf, taskIdStr));
|
qDebug("%s", dumpBlockData(pBlock, flagBuf, &pBuf, taskIdStr));
|
||||||
taosMemoryFree(pBuf);
|
taosMemoryFree(pBuf);
|
||||||
|
@ -2312,7 +2320,7 @@ void printSpecDataBlock(SSDataBlock* pBlock, const char* flag, const char* opStr
|
||||||
|
|
||||||
TSKEY getStartTsKey(STimeWindow* win, const TSKEY* tsCols) { return tsCols == NULL ? win->skey : tsCols[0]; }
|
TSKEY getStartTsKey(STimeWindow* win, const TSKEY* tsCols) { return tsCols == NULL ? win->skey : tsCols[0]; }
|
||||||
|
|
||||||
void updateTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pWin, int64_t delta) {
|
void updateTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pWin, int64_t delta) {
|
||||||
int64_t* ts = (int64_t*)pColData->pData;
|
int64_t* ts = (int64_t*)pColData->pData;
|
||||||
|
|
||||||
int64_t duration = pWin->ekey - pWin->skey + delta;
|
int64_t duration = pWin->ekey - pWin->skey + delta;
|
||||||
|
@ -2321,13 +2329,14 @@ void updateTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pWin, int64_t
|
||||||
ts[4] = pWin->ekey + delta; // window end key
|
ts[4] = pWin->ekey + delta; // window end key
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t compKeys(const SArray* pSortGroupCols, const char* oldkeyBuf, int32_t oldKeysLen, const SSDataBlock* pBlock, int32_t rowIndex) {
|
int32_t compKeys(const SArray* pSortGroupCols, const char* oldkeyBuf, int32_t oldKeysLen, const SSDataBlock* pBlock,
|
||||||
|
int32_t rowIndex) {
|
||||||
SColumnDataAgg* pColAgg = NULL;
|
SColumnDataAgg* pColAgg = NULL;
|
||||||
const char* isNull = oldkeyBuf;
|
const char* isNull = oldkeyBuf;
|
||||||
const char* p = oldkeyBuf + sizeof(int8_t) * pSortGroupCols->size;
|
const char* p = oldkeyBuf + sizeof(int8_t) * pSortGroupCols->size;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pSortGroupCols->size; ++i) {
|
for (int32_t i = 0; i < pSortGroupCols->size; ++i) {
|
||||||
const SColumn* pCol = (SColumn*)TARRAY_GET_ELEM(pSortGroupCols, i);
|
const SColumn* pCol = (SColumn*)TARRAY_GET_ELEM(pSortGroupCols, i);
|
||||||
const SColumnInfoData* pColInfoData = TARRAY_GET_ELEM(pBlock->pDataBlock, pCol->slotId);
|
const SColumnInfoData* pColInfoData = TARRAY_GET_ELEM(pBlock->pDataBlock, pCol->slotId);
|
||||||
if (pBlock->pBlockAgg) pColAgg = pBlock->pBlockAgg[pCol->slotId];
|
if (pBlock->pBlockAgg) pColAgg = pBlock->pBlockAgg[pCol->slotId];
|
||||||
|
|
||||||
|
@ -2353,8 +2362,7 @@ int32_t compKeys(const SArray* pSortGroupCols, const char* oldkeyBuf, int32_t ol
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t buildKeys(char* keyBuf, const SArray* pSortGroupCols, const SSDataBlock* pBlock,
|
int32_t buildKeys(char* keyBuf, const SArray* pSortGroupCols, const SSDataBlock* pBlock, int32_t rowIndex) {
|
||||||
int32_t rowIndex) {
|
|
||||||
uint32_t colNum = pSortGroupCols->size;
|
uint32_t colNum = pSortGroupCols->size;
|
||||||
SColumnDataAgg* pColAgg = NULL;
|
SColumnDataAgg* pColAgg = NULL;
|
||||||
char* isNull = keyBuf;
|
char* isNull = keyBuf;
|
||||||
|
@ -2402,7 +2410,7 @@ uint64_t calcGroupId(char* pData, int32_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SNodeList* makeColsNodeArrFromSortKeys(SNodeList* pSortKeys) {
|
SNodeList* makeColsNodeArrFromSortKeys(SNodeList* pSortKeys) {
|
||||||
SNode* node;
|
SNode* node;
|
||||||
SNodeList* ret = NULL;
|
SNodeList* ret = NULL;
|
||||||
FOREACH(node, pSortKeys) {
|
FOREACH(node, pSortKeys) {
|
||||||
SOrderByExprNode* pSortKey = (SOrderByExprNode*)node;
|
SOrderByExprNode* pSortKey = (SOrderByExprNode*)node;
|
||||||
|
@ -2418,6 +2426,6 @@ int32_t extractKeysLen(const SArray* keys) {
|
||||||
SColumn* pCol = (SColumn*)taosArrayGet(keys, i);
|
SColumn* pCol = (SColumn*)taosArrayGet(keys, i);
|
||||||
len += pCol->bytes;
|
len += pCol->bytes;
|
||||||
}
|
}
|
||||||
len += sizeof(int8_t) * keyNum; //null flag
|
len += sizeof(int8_t) * keyNum; // null flag
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1255,7 +1255,7 @@ static void destroyStreamPartitionOperatorInfo(void* param) {
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initParDownStream(SOperatorInfo* downstream, SPartitionBySupporter* pParSup, SExprSupp* pExpr) {
|
void initParDownStream(SOperatorInfo* downstream, SPartitionBySupporter* pParSup, SExprSupp* pExpr, SExprSupp* pTbnameExpr) {
|
||||||
SStorageAPI* pAPI = &downstream->pTaskInfo->storageAPI;
|
SStorageAPI* pAPI = &downstream->pTaskInfo->storageAPI;
|
||||||
|
|
||||||
if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||||
|
@ -1265,6 +1265,7 @@ void initParDownStream(SOperatorInfo* downstream, SPartitionBySupporter* pParSup
|
||||||
SStreamScanInfo* pScanInfo = downstream->info;
|
SStreamScanInfo* pScanInfo = downstream->info;
|
||||||
pScanInfo->partitionSup = *pParSup;
|
pScanInfo->partitionSup = *pParSup;
|
||||||
pScanInfo->pPartScalarSup = pExpr;
|
pScanInfo->pPartScalarSup = pExpr;
|
||||||
|
pScanInfo->pPartTbnameSup = pTbnameExpr;
|
||||||
if (!pScanInfo->pUpdateInfo) {
|
if (!pScanInfo->pUpdateInfo) {
|
||||||
pScanInfo->pUpdateInfo = pAPI->stateStore.updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, 0, pScanInfo->igCheckUpdate);
|
pScanInfo->pUpdateInfo = pAPI->stateStore.updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, 0, pScanInfo->igCheckUpdate);
|
||||||
}
|
}
|
||||||
|
@ -1408,7 +1409,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
||||||
destroyStreamPartitionOperatorInfo, optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL);
|
destroyStreamPartitionOperatorInfo, optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL);
|
||||||
setOperatorStreamStateFn(pOperator, streamOpReleaseState, streamOpReloadState);
|
setOperatorStreamStateFn(pOperator, streamOpReleaseState, streamOpReloadState);
|
||||||
|
|
||||||
initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup);
|
initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup, &pInfo->tbnameCalSup);
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
|
|
|
@ -889,14 +889,15 @@ static SSDataBlock* doGroupedTableScan(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
if (pTableScanInfo->countState < TABLE_COUNT_STATE_END) {
|
if (pTableScanInfo->countState < TABLE_COUNT_STATE_END) {
|
||||||
STableListInfo* pTableListInfo = pTableScanInfo->base.pTableListInfo;
|
STableListInfo* pTableListInfo = pTableScanInfo->base.pTableListInfo;
|
||||||
if (pTableListInfo->oneTableForEachGroup || pTableListInfo->groupOffset) { // group by tbname, group by tag + sort
|
if (pTableListInfo->oneTableForEachGroup || pTableListInfo->groupOffset) { // group by tbname, group by tag + sort
|
||||||
if (pTableScanInfo->countState < TABLE_COUNT_STATE_PROCESSED) {
|
if (pTableScanInfo->countState < TABLE_COUNT_STATE_PROCESSED) {
|
||||||
pTableScanInfo->countState = TABLE_COUNT_STATE_PROCESSED;
|
pTableScanInfo->countState = TABLE_COUNT_STATE_PROCESSED;
|
||||||
STableKeyInfo* pStart =
|
STableKeyInfo* pStart =
|
||||||
(STableKeyInfo*)tableListGetInfo(pTableScanInfo->base.pTableListInfo, pTableScanInfo->tableStartIndex);
|
(STableKeyInfo*)tableListGetInfo(pTableScanInfo->base.pTableListInfo, pTableScanInfo->tableStartIndex);
|
||||||
|
if (NULL == pStart) return NULL;
|
||||||
return getBlockForEmptyTable(pOperator, pStart);
|
return getBlockForEmptyTable(pOperator, pStart);
|
||||||
}
|
}
|
||||||
} else { // group by tag + no sort
|
} else { // group by tag + no sort
|
||||||
int32_t numOfTables = tableListGetSize(pTableListInfo);
|
int32_t numOfTables = tableListGetSize(pTableListInfo);
|
||||||
if (pTableScanInfo->tableEndIndex + 1 >= numOfTables) {
|
if (pTableScanInfo->tableEndIndex + 1 >= numOfTables) {
|
||||||
// get empty group, mark processed & rm from hash
|
// get empty group, mark processed & rm from hash
|
||||||
|
@ -1357,13 +1358,51 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
|
||||||
return pBlock->info.rows > 0 ? pBlock : NULL;
|
return pBlock->info.rows > 0 ? pBlock : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) {
|
bool comparePrimaryKey(SColumnInfoData* pCol, int32_t rowId, void* pVal) {
|
||||||
|
void* pData = colDataGetData(pCol, rowId);
|
||||||
|
if (IS_VAR_DATA_TYPE(pCol->info.type)) {
|
||||||
|
int32_t colLen = varDataLen(pData);
|
||||||
|
int32_t keyLen = varDataLen(pVal);
|
||||||
|
if (pCol->info.type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
colLen = getJsonValueLen(pData);
|
||||||
|
keyLen = getJsonValueLen(pVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colLen == keyLen && memcmp(pData, pVal, colLen) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (memcmp(pData, pVal, pCol->info.bytes) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasPrimaryKey(SStreamScanInfo* pInfo) {
|
||||||
|
return pInfo->primaryKeyIndex != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion, void* pVal) {
|
||||||
SSDataBlock* pPreRes = readPreVersionData(pInfo->pTableScanOp, uid, ts, ts, maxVersion);
|
SSDataBlock* pPreRes = readPreVersionData(pInfo->pTableScanOp, uid, ts, ts, maxVersion);
|
||||||
if (!pPreRes || pPreRes->info.rows == 0) {
|
if (!pPreRes || pPreRes->info.rows == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ASSERT(pPreRes->info.rows == 1);
|
|
||||||
return calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pPreRes, 0);
|
int32_t rowId = 0;
|
||||||
|
if (hasPrimaryKey(pInfo)) {
|
||||||
|
SColumnInfoData* pPkCol = taosArrayGet(pPreRes->pDataBlock, pInfo->primaryKeyIndex);
|
||||||
|
for (; rowId < pPreRes->info.rows; rowId++) {
|
||||||
|
if (comparePrimaryKey(pPkCol, rowId, pVal)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rowId >= pPreRes->info.rows) {
|
||||||
|
qInfo("===stream===read preversion data of primary key failed. ts:%" PRId64 ",version:%" PRId64, ts, maxVersion);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pPreRes, rowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t getGroupIdByUid(SStreamScanInfo* pInfo, uint64_t uid) {
|
static uint64_t getGroupIdByUid(SStreamScanInfo* pInfo, uint64_t uid) {
|
||||||
|
@ -1371,9 +1410,9 @@ static uint64_t getGroupIdByUid(SStreamScanInfo* pInfo, uint64_t uid) {
|
||||||
return tableListGetTableGroupId(pTableScanInfo->base.pTableListInfo, uid);
|
return tableListGetTableGroupId(pTableScanInfo->base.pTableListInfo, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) {
|
static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion, void* pVal) {
|
||||||
if (pInfo->partitionSup.needCalc) {
|
if (pInfo->partitionSup.needCalc) {
|
||||||
return getGroupIdByCol(pInfo, uid, ts, maxVersion);
|
return getGroupIdByCol(pInfo, uid, ts, maxVersion, pVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getGroupIdByUid(pInfo, uid);
|
return getGroupIdByUid(pInfo, uid);
|
||||||
|
@ -1542,22 +1581,95 @@ static int32_t getPreSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs,
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void appendOneRowToSpecialBlockImpl(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, TSKEY* pCalStartTs,
|
||||||
|
TSKEY* pCalEndTs, uint64_t* pUid, uint64_t* pGp, void* pTbName, void* pPkData) {
|
||||||
|
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pCalStartCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pCalEndCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pTableCol = taosArrayGet(pBlock->pDataBlock, TABLE_NAME_COLUMN_INDEX);
|
||||||
|
colDataSetVal(pStartTsCol, pBlock->info.rows, (const char*)pStartTs, false);
|
||||||
|
colDataSetVal(pEndTsCol, pBlock->info.rows, (const char*)pEndTs, false);
|
||||||
|
colDataSetVal(pUidCol, pBlock->info.rows, (const char*)pUid, false);
|
||||||
|
colDataSetVal(pGpCol, pBlock->info.rows, (const char*)pGp, false);
|
||||||
|
colDataSetVal(pCalStartCol, pBlock->info.rows, (const char*)pCalStartTs, false);
|
||||||
|
colDataSetVal(pCalEndCol, pBlock->info.rows, (const char*)pCalEndTs, false);
|
||||||
|
colDataSetVal(pTableCol, pBlock->info.rows, (const char*)pTbName, pTbName == NULL);
|
||||||
|
if (taosArrayGetSize(pBlock->pDataBlock) > PRIMARY_KEY_COLUMN_INDEX) {
|
||||||
|
SColumnInfoData* pPkCol = taosArrayGet(pBlock->pDataBlock, PRIMARY_KEY_COLUMN_INDEX);
|
||||||
|
colDataSetVal(pPkCol, pBlock->info.rows, (const char*)pPkData, pPkData == NULL);
|
||||||
|
}
|
||||||
|
pBlock->info.rows++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void appendPkToSpecialBlock(SSDataBlock* pBlock, TSKEY* pTsArray, SColumnInfoData* pPkCol, int32_t rowId,
|
||||||
|
uint64_t* pUid, uint64_t* pGp, void* pTbName) {
|
||||||
|
void* pVal = NULL;
|
||||||
|
if (pPkCol) {
|
||||||
|
pVal = colDataGetData(pPkCol, rowId);
|
||||||
|
}
|
||||||
|
appendOneRowToSpecialBlockImpl(pBlock, pTsArray + rowId, pTsArray + rowId, pTsArray + rowId, pTsArray + rowId, pUid,
|
||||||
|
pGp, pTbName, pVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void getPreVersionDataBlock(uint64_t uid, TSKEY startTs, TSKEY endTs, int64_t version, char* taskIdStr,
|
||||||
|
SStreamScanInfo* pInfo, SSDataBlock* pBlock) {
|
||||||
|
SSDataBlock* pPreRes = readPreVersionData(pInfo->pTableScanOp, uid, startTs, endTs, version);
|
||||||
|
printDataBlock(pPreRes, "pre res", taskIdStr);
|
||||||
|
blockDataCleanup(pBlock);
|
||||||
|
if (!pPreRes) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
int32_t code = blockDataEnsureCapacity(pBlock, pPreRes->info.rows);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
SColumnInfoData* pTsCol = (SColumnInfoData*)taosArrayGet(pPreRes->pDataBlock, pInfo->primaryTsIndex);
|
||||||
|
SColumnInfoData* pPkCol = NULL;
|
||||||
|
if (hasPrimaryKey(pInfo)) {
|
||||||
|
pPkCol = (SColumnInfoData*)taosArrayGet(pPreRes->pDataBlock, pInfo->primaryKeyIndex);
|
||||||
|
}
|
||||||
|
for (int32_t i = 0; i < pPreRes->info.rows; i++) {
|
||||||
|
uint64_t groupId = calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pPreRes, i);
|
||||||
|
appendPkToSpecialBlock(pBlock, (TSKEY*)pTsCol->pData, pPkCol, i, &uid, &groupId, NULL);
|
||||||
|
}
|
||||||
|
printDataBlock(pBlock, "new delete", taskIdStr);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
|
static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
|
||||||
blockDataCleanup(pDestBlock);
|
|
||||||
if (pSrcBlock->info.rows == 0) {
|
if (pSrcBlock->info.rows == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
int32_t code = blockDataEnsureCapacity(pDestBlock, pSrcBlock->info.rows);
|
SExecTaskInfo* pTaskInfo = pInfo->pStreamScanOp->pTaskInfo;
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
ASSERT(taosArrayGetSize(pSrcBlock->pDataBlock) >= 3);
|
|
||||||
SColumnInfoData* pStartTsCol = taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
SColumnInfoData* pStartTsCol = taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
TSKEY* startData = (TSKEY*)pStartTsCol->pData;
|
TSKEY* startData = (TSKEY*)pStartTsCol->pData;
|
||||||
SColumnInfoData* pEndTsCol = taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
SColumnInfoData* pEndTsCol = taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
TSKEY* endData = (TSKEY*)pEndTsCol->pData;
|
TSKEY* endData = (TSKEY*)pEndTsCol->pData;
|
||||||
SColumnInfoData* pUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
|
SColumnInfoData* pUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
|
||||||
uint64_t* uidCol = (uint64_t*)pUidCol->pData;
|
uint64_t* uidCol = (uint64_t*)pUidCol->pData;
|
||||||
|
SColumnInfoData* pGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pSrcPkCol = NULL;
|
||||||
|
uint64_t* pSrcGp = (uint64_t*)pGpCol->pData;
|
||||||
|
if (taosArrayGetSize(pSrcBlock->pDataBlock) > PRIMARY_KEY_COLUMN_INDEX) {
|
||||||
|
pSrcPkCol = taosArrayGet(pSrcBlock->pDataBlock, PRIMARY_KEY_COLUMN_INDEX);
|
||||||
|
}
|
||||||
|
int64_t ver = pSrcBlock->info.version - 1;
|
||||||
|
|
||||||
|
if (pInfo->partitionSup.needCalc && (startData[0] != endData[0] || hasPrimaryKey(pInfo))) {
|
||||||
|
getPreVersionDataBlock(uidCol[0], startData[0], endData[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock);
|
||||||
|
startData = (TSKEY*)pStartTsCol->pData;
|
||||||
|
endData = (TSKEY*)pEndTsCol->pData;
|
||||||
|
uidCol = (uint64_t*)pUidCol->pData;
|
||||||
|
pSrcGp = (uint64_t*)pGpCol->pData;
|
||||||
|
}
|
||||||
|
blockDataCleanup(pDestBlock);
|
||||||
|
int32_t code = blockDataEnsureCapacity(pDestBlock, pSrcBlock->info.rows);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
SColumnInfoData* pDestStartCol = taosArrayGet(pDestBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
SColumnInfoData* pDestStartCol = taosArrayGet(pDestBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pDestEndCol = taosArrayGet(pDestBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
SColumnInfoData* pDestEndCol = taosArrayGet(pDestBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
|
@ -1565,9 +1677,15 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr
|
||||||
SColumnInfoData* pDestGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
SColumnInfoData* pDestGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
SColumnInfoData* pDestCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
SColumnInfoData* pDestCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pDestCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
SColumnInfoData* pDestCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
||||||
int64_t ver = pSrcBlock->info.version - 1;
|
|
||||||
for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
|
for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
|
||||||
uint64_t groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], ver);
|
uint64_t groupId = pSrcGp[i];
|
||||||
|
if (groupId == 0) {
|
||||||
|
void* pVal = NULL;
|
||||||
|
if (hasPrimaryKey(pInfo) && pSrcPkCol) {
|
||||||
|
pVal = colDataGetData(pSrcPkCol, i);
|
||||||
|
}
|
||||||
|
groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], ver, pVal);
|
||||||
|
}
|
||||||
// gap must be 0.
|
// gap must be 0.
|
||||||
SSessionKey startWin = {0};
|
SSessionKey startWin = {0};
|
||||||
getCurSessionWindow(pInfo->windowSup.pStreamAggSup, startData[i], startData[i], groupId, &startWin);
|
getCurSessionWindow(pInfo->windowSup.pStreamAggSup, startData[i], startData[i], groupId, &startWin);
|
||||||
|
@ -1602,17 +1720,33 @@ static int32_t generateCountScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcB
|
||||||
if (pSrcBlock->info.rows == 0) {
|
if (pSrcBlock->info.rows == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
int32_t code = blockDataEnsureCapacity(pDestBlock, pSrcBlock->info.rows);
|
SExecTaskInfo* pTaskInfo = pInfo->pStreamScanOp->pTaskInfo;
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
ASSERT(taosArrayGetSize(pSrcBlock->pDataBlock) >= 3);
|
|
||||||
SColumnInfoData* pStartTsCol = taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
SColumnInfoData* pStartTsCol = taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
TSKEY* startData = (TSKEY*)pStartTsCol->pData;
|
TSKEY* startData = (TSKEY*)pStartTsCol->pData;
|
||||||
SColumnInfoData* pEndTsCol = taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
SColumnInfoData* pEndTsCol = taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
TSKEY* endData = (TSKEY*)pEndTsCol->pData;
|
TSKEY* endData = (TSKEY*)pEndTsCol->pData;
|
||||||
SColumnInfoData* pUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
|
SColumnInfoData* pUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
|
||||||
uint64_t* uidCol = (uint64_t*)pUidCol->pData;
|
uint64_t* uidCol = (uint64_t*)pUidCol->pData;
|
||||||
|
SColumnInfoData* pGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
|
uint64_t* pSrcGp = (uint64_t*)pGpCol->pData;
|
||||||
|
SColumnInfoData* pSrcPkCol = NULL;
|
||||||
|
if (taosArrayGetSize(pSrcBlock->pDataBlock) > PRIMARY_KEY_COLUMN_INDEX ) {
|
||||||
|
pSrcPkCol = taosArrayGet(pSrcBlock->pDataBlock, PRIMARY_KEY_COLUMN_INDEX);
|
||||||
|
}
|
||||||
|
int64_t ver = pSrcBlock->info.version - 1;
|
||||||
|
|
||||||
|
if (pInfo->partitionSup.needCalc && (startData[0] != endData[0] || hasPrimaryKey(pInfo))) {
|
||||||
|
getPreVersionDataBlock(uidCol[0], startData[0], endData[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock);
|
||||||
|
startData = (TSKEY*)pStartTsCol->pData;
|
||||||
|
endData = (TSKEY*)pEndTsCol->pData;
|
||||||
|
uidCol = (uint64_t*)pUidCol->pData;
|
||||||
|
pSrcGp = (uint64_t*)pGpCol->pData;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code = blockDataEnsureCapacity(pDestBlock, pSrcBlock->info.rows);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
SColumnInfoData* pDestStartCol = taosArrayGet(pDestBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
SColumnInfoData* pDestStartCol = taosArrayGet(pDestBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pDestEndCol = taosArrayGet(pDestBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
SColumnInfoData* pDestEndCol = taosArrayGet(pDestBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
|
@ -1620,9 +1754,15 @@ static int32_t generateCountScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcB
|
||||||
SColumnInfoData* pDestGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
SColumnInfoData* pDestGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
SColumnInfoData* pDestCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
SColumnInfoData* pDestCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pDestCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
SColumnInfoData* pDestCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
||||||
int64_t ver = pSrcBlock->info.version - 1;
|
|
||||||
for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
|
for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
|
||||||
uint64_t groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], ver);
|
uint64_t groupId = pSrcGp[i];
|
||||||
|
if (groupId == 0) {
|
||||||
|
void* pVal = NULL;
|
||||||
|
if (hasPrimaryKey(pInfo) && pSrcPkCol) {
|
||||||
|
pVal = colDataGetData(pSrcPkCol, i);
|
||||||
|
}
|
||||||
|
groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], ver, pVal);
|
||||||
|
}
|
||||||
SSessionKey startWin = {.win.skey = startData[i], .win.ekey = endData[i], .groupId = groupId};
|
SSessionKey startWin = {.win.skey = startData[i], .win.ekey = endData[i], .groupId = groupId};
|
||||||
SSessionKey range = {0};
|
SSessionKey range = {0};
|
||||||
getCountWinRange(pInfo->windowSup.pStreamAggSup, &startWin, mode, &range);
|
getCountWinRange(pInfo->windowSup.pStreamAggSup, &startWin, mode, &range);
|
||||||
|
@ -1640,8 +1780,7 @@ static int32_t generateCountScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcB
|
||||||
|
|
||||||
static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
|
static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
|
||||||
blockDataCleanup(pDestBlock);
|
blockDataCleanup(pDestBlock);
|
||||||
int32_t rows = pSrcBlock->info.rows;
|
if (pSrcBlock->info.rows == 0) {
|
||||||
if (rows == 0) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
SExecTaskInfo* pTaskInfo = pInfo->pStreamScanOp->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pInfo->pStreamScanOp->pTaskInfo;
|
||||||
|
@ -1649,6 +1788,10 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS
|
||||||
SColumnInfoData* pSrcEndTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
SColumnInfoData* pSrcEndTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pSrcUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
|
SColumnInfoData* pSrcUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
|
||||||
SColumnInfoData* pSrcGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
SColumnInfoData* pSrcGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pSrcPkCol = NULL;
|
||||||
|
if (taosArrayGetSize(pSrcBlock->pDataBlock) > PRIMARY_KEY_COLUMN_INDEX ) {
|
||||||
|
pSrcPkCol = taosArrayGet(pSrcBlock->pDataBlock, PRIMARY_KEY_COLUMN_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData;
|
uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData;
|
||||||
ASSERT(pSrcStartTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
ASSERT(pSrcStartTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||||
|
@ -1656,34 +1799,15 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS
|
||||||
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
||||||
int64_t ver = pSrcBlock->info.version - 1;
|
int64_t ver = pSrcBlock->info.version - 1;
|
||||||
|
|
||||||
if (pInfo->partitionSup.needCalc && srcStartTsCol[0] != srcEndTsCol[0]) {
|
if (pInfo->partitionSup.needCalc && (srcStartTsCol[0] != srcEndTsCol[0] || hasPrimaryKey(pInfo))) {
|
||||||
uint64_t srcUid = srcUidData[0];
|
getPreVersionDataBlock(srcUidData[0], srcStartTsCol[0], srcEndTsCol[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock);
|
||||||
TSKEY startTs = srcStartTsCol[0];
|
srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
||||||
TSKEY endTs = srcEndTsCol[0];
|
srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
||||||
SSDataBlock* pPreRes = readPreVersionData(pInfo->pTableScanOp, srcUid, startTs, endTs, ver);
|
srcUidData = (uint64_t*)pSrcUidCol->pData;
|
||||||
printDataBlock(pPreRes, "pre res", GET_TASKID(pTaskInfo));
|
|
||||||
blockDataCleanup(pSrcBlock);
|
|
||||||
int32_t code = blockDataEnsureCapacity(pSrcBlock, pPreRes->info.rows);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
SColumnInfoData* pTsCol = (SColumnInfoData*)taosArrayGet(pPreRes->pDataBlock, pInfo->primaryTsIndex);
|
|
||||||
rows = pPreRes->info.rows;
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < rows; i++) {
|
|
||||||
uint64_t groupId = calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pPreRes, i);
|
|
||||||
appendOneRowToStreamSpecialBlock(pSrcBlock, ((TSKEY*)pTsCol->pData) + i, ((TSKEY*)pTsCol->pData) + i, &srcUid,
|
|
||||||
&groupId, NULL);
|
|
||||||
}
|
|
||||||
printDataBlock(pSrcBlock, "new delete", GET_TASKID(pTaskInfo));
|
|
||||||
}
|
}
|
||||||
uint64_t* srcGp = (uint64_t*)pSrcGpCol->pData;
|
|
||||||
srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
|
||||||
srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
|
||||||
srcUidData = (uint64_t*)pSrcUidCol->pData;
|
|
||||||
|
|
||||||
int32_t code = blockDataEnsureCapacity(pDestBlock, rows);
|
uint64_t* srcGp = (uint64_t*)pSrcGpCol->pData;
|
||||||
|
int32_t code = blockDataEnsureCapacity(pDestBlock, pSrcBlock->info.rows);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1694,11 +1818,15 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS
|
||||||
SColumnInfoData* pGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
SColumnInfoData* pGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
SColumnInfoData* pCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
SColumnInfoData* pCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
SColumnInfoData* pCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
||||||
for (int32_t i = 0; i < rows;) {
|
for (int32_t i = 0; i < pSrcBlock->info.rows;) {
|
||||||
uint64_t srcUid = srcUidData[i];
|
uint64_t srcUid = srcUidData[i];
|
||||||
uint64_t groupId = srcGp[i];
|
uint64_t groupId = srcGp[i];
|
||||||
if (groupId == 0) {
|
if (groupId == 0) {
|
||||||
groupId = getGroupIdByData(pInfo, srcUid, srcStartTsCol[i], ver);
|
void* pVal = NULL;
|
||||||
|
if (hasPrimaryKey(pInfo) && pSrcPkCol) {
|
||||||
|
pVal = colDataGetData(pSrcPkCol, i);
|
||||||
|
}
|
||||||
|
groupId = getGroupIdByData(pInfo, srcUid, srcStartTsCol[i], ver, pVal);
|
||||||
}
|
}
|
||||||
TSKEY calStartTs = srcStartTsCol[i];
|
TSKEY calStartTs = srcStartTsCol[i];
|
||||||
colDataSetVal(pCalStartTsCol, pDestBlock->info.rows, (const char*)(&calStartTs), false);
|
colDataSetVal(pCalStartTsCol, pDestBlock->info.rows, (const char*)(&calStartTs), false);
|
||||||
|
@ -1715,17 +1843,102 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calBlockTbName(SStreamScanInfo* pInfo, SSDataBlock* pBlock) {
|
static void calBlockTbName(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t rowId) {
|
||||||
SExprSupp* pTbNameCalSup = &pInfo->tbnameCalSup;
|
|
||||||
blockDataCleanup(pInfo->pCreateTbRes);
|
blockDataCleanup(pInfo->pCreateTbRes);
|
||||||
if (pInfo->tbnameCalSup.numOfExprs == 0 && pInfo->tagCalSup.numOfExprs == 0) {
|
if (pInfo->tbnameCalSup.numOfExprs == 0 && pInfo->tagCalSup.numOfExprs == 0) {
|
||||||
pBlock->info.parTbName[0] = 0;
|
pBlock->info.parTbName[0] = 0;
|
||||||
} else {
|
} else {
|
||||||
appendCreateTableRow(pInfo->pStreamScanOp->pTaskInfo->streamInfo.pState, &pInfo->tbnameCalSup, &pInfo->tagCalSup,
|
appendCreateTableRow(pInfo->pStreamScanOp->pTaskInfo->streamInfo.pState, &pInfo->tbnameCalSup, &pInfo->tagCalSup,
|
||||||
pBlock->info.id.groupId, pBlock, 0, pInfo->pCreateTbRes, &pInfo->stateStore);
|
pBlock->info.id.groupId, pBlock, rowId, pInfo->pCreateTbRes, &pInfo->stateStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t generatePartitionDelResBlock(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
|
||||||
|
SColumnInfoData* pSrcStartTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pSrcEndTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pSrcUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
|
||||||
|
uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData;
|
||||||
|
SColumnInfoData* pSrcGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
|
uint64_t* srcGp = (uint64_t*)pSrcGpCol->pData;
|
||||||
|
|
||||||
|
ASSERT(pSrcStartTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||||
|
TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
||||||
|
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
||||||
|
int64_t ver = pSrcBlock->info.version - 1;
|
||||||
|
for (int32_t delI = 0; delI < pSrcBlock->info.rows; delI++) {
|
||||||
|
uint64_t groupId = 0;
|
||||||
|
uint64_t srcUid = srcUidData[delI];
|
||||||
|
char tbname[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN] = {0};
|
||||||
|
SSDataBlock* pPreRes = readPreVersionData(pInfo->pTableScanOp, srcUid, srcStartTsCol[delI], srcEndTsCol[delI], ver);
|
||||||
|
blockDataEnsureCapacity(pDestBlock, pDestBlock->info.rows + pPreRes->info.rows);
|
||||||
|
for (int32_t preJ = 0; preJ < pPreRes->info.rows; preJ++) {
|
||||||
|
groupId = calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pPreRes, preJ);
|
||||||
|
if (pInfo->pPartTbnameSup) {
|
||||||
|
void* parTbname = NULL;
|
||||||
|
int32_t code = pInfo->stateStore.streamStateGetParName(pInfo->pStreamScanOp->pTaskInfo->streamInfo.pState, groupId, &parTbname);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
calBlockTbName(pInfo, pPreRes, preJ);
|
||||||
|
memcpy(varDataVal(tbname), pPreRes->info.parTbName, strlen(pPreRes->info.parTbName));
|
||||||
|
} else {
|
||||||
|
memcpy(varDataVal(tbname), parTbname, TSDB_TABLE_NAME_LEN);
|
||||||
|
}
|
||||||
|
varDataSetLen(tbname, strlen(varDataVal(tbname)));
|
||||||
|
pInfo->stateStore.streamStateFreeVal(parTbname);
|
||||||
|
}
|
||||||
|
appendDataToSpecialBlock(pDestBlock, srcStartTsCol + delI, srcEndTsCol + delI, srcUidData + delI, &groupId,
|
||||||
|
tbname[0] == 0 ? NULL : tbname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t generateDeleteResultBlockImpl(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
|
||||||
|
SColumnInfoData* pSrcStartTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pSrcEndTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pSrcUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
|
||||||
|
uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData;
|
||||||
|
SColumnInfoData* pSrcGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
|
uint64_t* srcGp = (uint64_t*)pSrcGpCol->pData;
|
||||||
|
SColumnInfoData* pSrcPkCol = NULL;
|
||||||
|
if (taosArrayGetSize(pSrcBlock->pDataBlock) > PRIMARY_KEY_COLUMN_INDEX ) {
|
||||||
|
pSrcPkCol = taosArrayGet(pSrcBlock->pDataBlock, PRIMARY_KEY_COLUMN_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(pSrcStartTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||||
|
TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
||||||
|
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
||||||
|
int64_t ver = pSrcBlock->info.version - 1;
|
||||||
|
for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
|
||||||
|
uint64_t srcUid = srcUidData[i];
|
||||||
|
uint64_t groupId = srcGp[i];
|
||||||
|
char tbname[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN] = {0};
|
||||||
|
if (groupId == 0) {
|
||||||
|
void* pVal = NULL;
|
||||||
|
if (hasPrimaryKey(pInfo) && pSrcPkCol) {
|
||||||
|
pVal = colDataGetData(pSrcPkCol, i);
|
||||||
|
}
|
||||||
|
groupId = getGroupIdByData(pInfo, srcUid, srcStartTsCol[i], ver, pVal);
|
||||||
|
}
|
||||||
|
if (pInfo->tbnameCalSup.pExprInfo) {
|
||||||
|
void* parTbname = NULL;
|
||||||
|
int32_t code = pInfo->stateStore.streamStateGetParName(pInfo->pStreamScanOp->pTaskInfo->streamInfo.pState, groupId, &parTbname);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
SSDataBlock* pPreRes = readPreVersionData(pInfo->pTableScanOp, srcUid, srcStartTsCol[i], srcStartTsCol[i], ver);
|
||||||
|
printDataBlock(pPreRes, "pre res", GET_TASKID(pInfo->pStreamScanOp->pTaskInfo));
|
||||||
|
calBlockTbName(pInfo, pPreRes, 0);
|
||||||
|
memcpy(varDataVal(tbname), pPreRes->info.parTbName, strlen(pPreRes->info.parTbName));
|
||||||
|
} else {
|
||||||
|
memcpy(varDataVal(tbname), parTbname, TSDB_TABLE_NAME_LEN);
|
||||||
|
}
|
||||||
|
varDataSetLen(tbname, strlen(varDataVal(tbname)));
|
||||||
|
pInfo->stateStore.streamStateFreeVal(parTbname);
|
||||||
|
}
|
||||||
|
appendDataToSpecialBlock(pDestBlock, srcStartTsCol + i, srcEndTsCol + i, srcUidData + i, &groupId,
|
||||||
|
tbname[0] == 0 ? NULL : tbname);
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t generateDeleteResultBlock(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
|
static int32_t generateDeleteResultBlock(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
|
||||||
blockDataCleanup(pDestBlock);
|
blockDataCleanup(pDestBlock);
|
||||||
int32_t rows = pSrcBlock->info.rows;
|
int32_t rows = pSrcBlock->info.rows;
|
||||||
|
@ -1736,42 +1949,10 @@ static int32_t generateDeleteResultBlock(SStreamScanInfo* pInfo, SSDataBlock* pS
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
if (pInfo->partitionSup.needCalc) {
|
||||||
SColumnInfoData* pSrcStartTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
return generatePartitionDelResBlock(pInfo, pSrcBlock, pDestBlock);
|
||||||
SColumnInfoData* pSrcEndTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
|
||||||
SColumnInfoData* pSrcUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
|
|
||||||
uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData;
|
|
||||||
SColumnInfoData* pSrcGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
|
||||||
uint64_t* srcGp = (uint64_t*)pSrcGpCol->pData;
|
|
||||||
ASSERT(pSrcStartTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
|
||||||
TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
|
||||||
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
|
||||||
int64_t ver = pSrcBlock->info.version - 1;
|
|
||||||
for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
|
|
||||||
uint64_t srcUid = srcUidData[i];
|
|
||||||
uint64_t groupId = srcGp[i];
|
|
||||||
char tbname[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN] = {0};
|
|
||||||
if (groupId == 0) {
|
|
||||||
groupId = getGroupIdByData(pInfo, srcUid, srcStartTsCol[i], ver);
|
|
||||||
}
|
|
||||||
if (pInfo->tbnameCalSup.pExprInfo) {
|
|
||||||
void* parTbname = NULL;
|
|
||||||
code = pInfo->stateStore.streamStateGetParName(pInfo->pStreamScanOp->pTaskInfo->streamInfo.pState, groupId, &parTbname);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
SSDataBlock* pPreRes = readPreVersionData(pInfo->pTableScanOp, srcUid, srcStartTsCol[i], srcStartTsCol[i], ver);
|
|
||||||
printDataBlock(pPreRes, "pre res", GET_TASKID(pInfo->pStreamScanOp->pTaskInfo));
|
|
||||||
calBlockTbName(pInfo, pPreRes);
|
|
||||||
memcpy(varDataVal(tbname), pPreRes->info.parTbName, strlen(pPreRes->info.parTbName));
|
|
||||||
} else {
|
|
||||||
memcpy(varDataVal(tbname), parTbname, TSDB_TABLE_NAME_LEN);
|
|
||||||
}
|
|
||||||
varDataSetLen(tbname, strlen(varDataVal(tbname)));
|
|
||||||
pInfo->stateStore.streamStateFreeVal(parTbname);
|
|
||||||
}
|
|
||||||
appendOneRowToStreamSpecialBlock(pDestBlock, srcStartTsCol + i, srcEndTsCol + i, srcUidData + i, &groupId,
|
|
||||||
tbname[0] == 0 ? NULL : tbname);
|
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return generateDeleteResultBlockImpl(pInfo, pSrcBlock, pDestBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock, EStreamType type) {
|
static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock, EStreamType type) {
|
||||||
|
@ -1792,28 +1973,9 @@ static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock,
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid,
|
void appendDataToSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid, uint64_t* pGp,
|
||||||
uint64_t* pGp, void* pTbName) {
|
void* pTbName) {
|
||||||
appendAllColumnToStreamSpecialBlock(pBlock, pStartTs, pEndTs, pStartTs, pEndTs, pUid, pGp, pTbName);
|
appendOneRowToSpecialBlockImpl(pBlock, pStartTs, pEndTs, pStartTs, pEndTs, pUid, pGp, pTbName, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
void appendAllColumnToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, TSKEY* pCalStartTs,
|
|
||||||
TSKEY* pCalEndTs, uint64_t* pUid, uint64_t* pGp, void* pTbName) {
|
|
||||||
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
|
||||||
SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
|
||||||
SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX);
|
|
||||||
SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
|
||||||
SColumnInfoData* pCalStartCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
|
||||||
SColumnInfoData* pCalEndCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
|
||||||
SColumnInfoData* pTableCol = taosArrayGet(pBlock->pDataBlock, TABLE_NAME_COLUMN_INDEX);
|
|
||||||
colDataSetVal(pStartTsCol, pBlock->info.rows, (const char*)pStartTs, false);
|
|
||||||
colDataSetVal(pEndTsCol, pBlock->info.rows, (const char*)pEndTs, false);
|
|
||||||
colDataSetVal(pUidCol, pBlock->info.rows, (const char*)pUid, false);
|
|
||||||
colDataSetVal(pGpCol, pBlock->info.rows, (const char*)pGp, false);
|
|
||||||
colDataSetVal(pCalStartCol, pBlock->info.rows, (const char*)pCalStartTs, false);
|
|
||||||
colDataSetVal(pCalEndCol, pBlock->info.rows, (const char*)pCalEndTs, false);
|
|
||||||
colDataSetVal(pTableCol, pBlock->info.rows, (const char*)pTbName, pTbName == NULL);
|
|
||||||
pBlock->info.rows++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkExpiredData(SStateStore* pAPI, SUpdateInfo* pUpdateInfo, STimeWindowAggSupp* pTwSup, uint64_t tableId, TSKEY ts) {
|
bool checkExpiredData(SStateStore* pAPI, SUpdateInfo* pUpdateInfo, STimeWindowAggSupp* pTwSup, uint64_t tableId, TSKEY ts) {
|
||||||
|
@ -1833,6 +1995,11 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock
|
||||||
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
|
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||||
ASSERT(pColDataInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
ASSERT(pColDataInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||||
TSKEY* tsCol = (TSKEY*)pColDataInfo->pData;
|
TSKEY* tsCol = (TSKEY*)pColDataInfo->pData;
|
||||||
|
SColumnInfoData* pPkColDataInfo = NULL;
|
||||||
|
if (hasPrimaryKey(pInfo)) {
|
||||||
|
pPkColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryKeyIndex);
|
||||||
|
}
|
||||||
|
|
||||||
bool tableInserted = pInfo->stateStore.updateInfoIsTableInserted(pInfo->pUpdateInfo, pBlock->info.id.uid);
|
bool tableInserted = pInfo->stateStore.updateInfoIsTableInserted(pInfo->pUpdateInfo, pBlock->info.id.uid);
|
||||||
for (int32_t rowId = 0; rowId < pBlock->info.rows; rowId++) {
|
for (int32_t rowId = 0; rowId < pBlock->info.rows; rowId++) {
|
||||||
SResultRowInfo dumyInfo;
|
SResultRowInfo dumyInfo;
|
||||||
|
@ -1850,17 +2017,15 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock
|
||||||
}
|
}
|
||||||
// must check update info first.
|
// must check update info first.
|
||||||
bool update = pInfo->stateStore.updateInfoIsUpdated(pInfo->pUpdateInfo, pBlock->info.id.uid, tsCol[rowId]);
|
bool update = pInfo->stateStore.updateInfoIsUpdated(pInfo->pUpdateInfo, pBlock->info.id.uid, tsCol[rowId]);
|
||||||
bool closedWin = isClosed && isSignleIntervalWindow(pInfo) &&
|
bool isDeleted = isClosed && isSignleIntervalWindow(pInfo) &&
|
||||||
isDeletedStreamWindow(&win, pBlock->info.id.groupId, pInfo->pState, &pInfo->twAggSup, &pInfo->stateStore);
|
isDeletedStreamWindow(&win, pBlock->info.id.groupId, pInfo->pState, &pInfo->twAggSup, &pInfo->stateStore);
|
||||||
if ((update || closedWin) && out) {
|
if ((update || isDeleted) && out) {
|
||||||
qDebug("stream update check not pass, update %d, closedWin %d", update, closedWin);
|
qDebug("stream update check not pass, update %d, deleted Win %d", update, isDeleted);
|
||||||
uint64_t gpId = 0;
|
uint64_t gpId = 0;
|
||||||
appendOneRowToStreamSpecialBlock(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.id.uid, &gpId,
|
appendPkToSpecialBlock(pInfo->pUpdateDataRes, tsCol, pPkColDataInfo, rowId, &pBlock->info.id.uid, &gpId, NULL);
|
||||||
NULL);
|
if (isDeleted && pInfo->partitionSup.needCalc) {
|
||||||
if (closedWin && pInfo->partitionSup.needCalc) {
|
|
||||||
gpId = calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pBlock, rowId);
|
gpId = calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pBlock, rowId);
|
||||||
appendOneRowToStreamSpecialBlock(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.id.uid,
|
appendPkToSpecialBlock(pInfo->pUpdateDataRes, tsCol, pPkColDataInfo, rowId, &pBlock->info.id.uid, &gpId, NULL);
|
||||||
&gpId, NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2028,7 +2193,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
calBlockTbName(pInfo, pInfo->pRes);
|
calBlockTbName(pInfo, pInfo->pRes, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2288,7 +2453,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
pInfo->pRecoverRes = doTableScan(pInfo->pTableScanOp);
|
pInfo->pRecoverRes = doTableScan(pInfo->pTableScanOp);
|
||||||
if (pInfo->pRecoverRes != NULL) {
|
if (pInfo->pRecoverRes != NULL) {
|
||||||
calBlockTbName(pInfo, pInfo->pRecoverRes);
|
calBlockTbName(pInfo, pInfo->pRecoverRes, 0);
|
||||||
if (!pInfo->igCheckUpdate && pInfo->pUpdateInfo) {
|
if (!pInfo->igCheckUpdate && pInfo->pUpdateInfo) {
|
||||||
TSKEY maxTs = pAPI->stateStore.updateInfoFillBlockData(pInfo->pUpdateInfo, pInfo->pRecoverRes, pInfo->primaryTsIndex);
|
TSKEY maxTs = pAPI->stateStore.updateInfoFillBlockData(pInfo->pUpdateInfo, pInfo->pRecoverRes, pInfo->primaryTsIndex);
|
||||||
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs);
|
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs);
|
||||||
|
@ -2346,6 +2511,7 @@ FETCH_NEXT_BLOCK:
|
||||||
switch (pBlock->info.type) {
|
switch (pBlock->info.type) {
|
||||||
case STREAM_NORMAL:
|
case STREAM_NORMAL:
|
||||||
case STREAM_GET_ALL:
|
case STREAM_GET_ALL:
|
||||||
|
printDataBlock(pBlock, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo));
|
||||||
return pBlock;
|
return pBlock;
|
||||||
case STREAM_RETRIEVE: {
|
case STREAM_RETRIEVE: {
|
||||||
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
||||||
|
@ -2377,11 +2543,15 @@ FETCH_NEXT_BLOCK:
|
||||||
|
|
||||||
if (!isStreamWindow(pInfo)) {
|
if (!isStreamWindow(pInfo)) {
|
||||||
generateDeleteResultBlock(pInfo, pDelBlock, pInfo->pDeleteDataRes);
|
generateDeleteResultBlock(pInfo, pDelBlock, pInfo->pDeleteDataRes);
|
||||||
pInfo->pDeleteDataRes->info.type = STREAM_DELETE_RESULT;
|
if (pInfo->partitionSup.needCalc) {
|
||||||
printSpecDataBlock(pDelBlock, getStreamOpName(pOperator->operatorType), "delete result", GET_TASKID(pTaskInfo));
|
pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA;
|
||||||
|
} else {
|
||||||
|
pInfo->pDeleteDataRes->info.type = STREAM_DELETE_RESULT;
|
||||||
|
}
|
||||||
blockDataDestroy(pDelBlock);
|
blockDataDestroy(pDelBlock);
|
||||||
|
|
||||||
if (pInfo->pDeleteDataRes->info.rows > 0) {
|
if (pInfo->pDeleteDataRes->info.rows > 0) {
|
||||||
|
printSpecDataBlock(pInfo->pDeleteDataRes, getStreamOpName(pOperator->operatorType), "delete result", GET_TASKID(pTaskInfo));
|
||||||
return pInfo->pDeleteDataRes;
|
return pInfo->pDeleteDataRes;
|
||||||
} else {
|
} else {
|
||||||
goto FETCH_NEXT_BLOCK;
|
goto FETCH_NEXT_BLOCK;
|
||||||
|
@ -2393,12 +2563,12 @@ FETCH_NEXT_BLOCK:
|
||||||
prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex);
|
prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex);
|
||||||
copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes);
|
copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes);
|
||||||
pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA;
|
pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA;
|
||||||
printSpecDataBlock(pDelBlock, getStreamOpName(pOperator->operatorType), "delete result", GET_TASKID(pTaskInfo));
|
|
||||||
if (pInfo->tqReader) {
|
if (pInfo->tqReader) {
|
||||||
blockDataDestroy(pDelBlock);
|
blockDataDestroy(pDelBlock);
|
||||||
}
|
}
|
||||||
if (pInfo->pDeleteDataRes->info.rows > 0) {
|
if (pInfo->pDeleteDataRes->info.rows > 0) {
|
||||||
pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE;
|
pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE;
|
||||||
|
printSpecDataBlock(pInfo->pDeleteDataRes, getStreamOpName(pOperator->operatorType), "delete result", GET_TASKID(pTaskInfo));
|
||||||
return pInfo->pDeleteDataRes;
|
return pInfo->pDeleteDataRes;
|
||||||
} else {
|
} else {
|
||||||
goto FETCH_NEXT_BLOCK;
|
goto FETCH_NEXT_BLOCK;
|
||||||
|
@ -2423,6 +2593,7 @@ FETCH_NEXT_BLOCK:
|
||||||
pInfo->pRes->info.dataLoad = 1;
|
pInfo->pRes->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
||||||
if (pInfo->pRes->info.rows > 0) {
|
if (pInfo->pRes->info.rows > 0) {
|
||||||
|
printDataBlock(pInfo->pRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo));
|
||||||
return pInfo->pRes;
|
return pInfo->pRes;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -2450,7 +2621,7 @@ FETCH_NEXT_BLOCK:
|
||||||
checkUpdateData(pInfo, true, pSDB, false);
|
checkUpdateData(pInfo, true, pSDB, false);
|
||||||
}
|
}
|
||||||
printSpecDataBlock(pSDB, getStreamOpName(pOperator->operatorType), "update", GET_TASKID(pTaskInfo));
|
printSpecDataBlock(pSDB, getStreamOpName(pOperator->operatorType), "update", GET_TASKID(pTaskInfo));
|
||||||
calBlockTbName(pInfo, pSDB);
|
calBlockTbName(pInfo, pSDB, 0);
|
||||||
return pSDB;
|
return pSDB;
|
||||||
}
|
}
|
||||||
blockDataCleanup(pInfo->pUpdateDataRes);
|
blockDataCleanup(pInfo->pUpdateDataRes);
|
||||||
|
@ -2544,6 +2715,7 @@ FETCH_NEXT_BLOCK:
|
||||||
|
|
||||||
qDebug("stream scan completed, and return source rows:%" PRId64", %s", pBlockInfo->rows, id);
|
qDebug("stream scan completed, and return source rows:%" PRId64", %s", pBlockInfo->rows, id);
|
||||||
if (pBlockInfo->rows > 0) {
|
if (pBlockInfo->rows > 0) {
|
||||||
|
printDataBlock(pInfo->pRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo));
|
||||||
return pInfo->pRes;
|
return pInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2567,7 +2739,7 @@ FETCH_NEXT_BLOCK:
|
||||||
if (pBlock->info.type == STREAM_CHECKPOINT) {
|
if (pBlock->info.type == STREAM_CHECKPOINT) {
|
||||||
streamScanOperatorSaveCheckpoint(pInfo);
|
streamScanOperatorSaveCheckpoint(pInfo);
|
||||||
}
|
}
|
||||||
// printDataBlock(pBlock, "stream scan ck");
|
// printDataBlock(pInfo->pCheckpointRes, "stream scan ck", GET_TASKID(pTaskInfo));
|
||||||
return pInfo->pCheckpointRes;
|
return pInfo->pCheckpointRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2794,6 +2966,14 @@ void streamScanReloadState(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addPrimaryKeyCol(SSDataBlock* pBlock, uint8_t type, int32_t bytes) {
|
||||||
|
pBlock->info.rowSize += bytes;
|
||||||
|
SColumnInfoData infoData = {0};
|
||||||
|
infoData.info.type = type;
|
||||||
|
infoData.info.bytes = bytes;
|
||||||
|
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||||
|
}
|
||||||
|
|
||||||
SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond,
|
SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond,
|
||||||
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) {
|
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) {
|
||||||
SArray* pColIds = NULL;
|
SArray* pColIds = NULL;
|
||||||
|
@ -2822,6 +3002,8 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDataType pkType = {0};
|
||||||
|
pInfo->primaryKeyIndex = -1;
|
||||||
int32_t numOfOutput = taosArrayGetSize(pInfo->matchInfo.pList);
|
int32_t numOfOutput = taosArrayGetSize(pInfo->matchInfo.pList);
|
||||||
pColIds = taosArrayInit(numOfOutput, sizeof(int16_t));
|
pColIds = taosArrayInit(numOfOutput, sizeof(int16_t));
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
|
@ -2832,8 +3014,13 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
if (id->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
if (id->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
pInfo->primaryTsIndex = id->dstSlotId;
|
pInfo->primaryTsIndex = id->dstSlotId;
|
||||||
}
|
}
|
||||||
|
if (id->isPk) {
|
||||||
|
pInfo->primaryKeyIndex = id->dstSlotId;
|
||||||
|
pkType = id->dataType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pInfo->pPartTbnameSup = NULL;
|
||||||
if (pTableScanNode->pSubtable != NULL) {
|
if (pTableScanNode->pSubtable != NULL) {
|
||||||
SExprInfo* pSubTableExpr = taosMemoryCalloc(1, sizeof(SExprInfo));
|
SExprInfo* pSubTableExpr = taosMemoryCalloc(1, sizeof(SExprInfo));
|
||||||
if (pSubTableExpr == NULL) {
|
if (pSubTableExpr == NULL) {
|
||||||
|
@ -2949,6 +3136,9 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
pInfo->pDeleteDataRes = createSpecialDataBlock(STREAM_DELETE_DATA);
|
pInfo->pDeleteDataRes = createSpecialDataBlock(STREAM_DELETE_DATA);
|
||||||
pInfo->updateWin = (STimeWindow){.skey = INT64_MAX, .ekey = INT64_MAX};
|
pInfo->updateWin = (STimeWindow){.skey = INT64_MAX, .ekey = INT64_MAX};
|
||||||
pInfo->pUpdateDataRes = createSpecialDataBlock(STREAM_CLEAR);
|
pInfo->pUpdateDataRes = createSpecialDataBlock(STREAM_CLEAR);
|
||||||
|
if (hasPrimaryKey(pInfo)) {
|
||||||
|
addPrimaryKeyCol(pInfo->pUpdateDataRes, pkType.type, pkType.bytes);
|
||||||
|
}
|
||||||
pInfo->assignBlockUid = pTableScanNode->assignBlockUid;
|
pInfo->assignBlockUid = pTableScanNode->assignBlockUid;
|
||||||
pInfo->partitionSup.needCalc = false;
|
pInfo->partitionSup.needCalc = false;
|
||||||
pInfo->igCheckUpdate = pTableScanNode->igCheckUpdate;
|
pInfo->igCheckUpdate = pTableScanNode->igCheckUpdate;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
#define IS_FINAL_COUNT_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_COUNT)
|
#define IS_NORMAL_COUNT_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT)
|
||||||
#define STREAM_COUNT_OP_STATE_NAME "StreamCountHistoryState"
|
#define STREAM_COUNT_OP_STATE_NAME "StreamCountHistoryState"
|
||||||
#define STREAM_COUNT_OP_CHECKPOINT_NAME "StreamCountOperator_Checkpoint"
|
#define STREAM_COUNT_OP_CHECKPOINT_NAME "StreamCountOperator_Checkpoint"
|
||||||
|
|
||||||
|
@ -61,6 +61,8 @@ void destroyStreamCountAggOperatorInfo(void* param) {
|
||||||
taosArrayDestroy(pInfo->historyWins);
|
taosArrayDestroy(pInfo->historyWins);
|
||||||
blockDataDestroy(pInfo->pCheckpointRes);
|
blockDataDestroy(pInfo->pCheckpointRes);
|
||||||
|
|
||||||
|
tSimpleHashCleanup(pInfo->pPkDeleted);
|
||||||
|
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,23 +269,27 @@ static void doStreamCountAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
range.win.skey = TMIN(startTsCols[i], range.win.skey);
|
range.win.skey = TMIN(startTsCols[i], range.win.skey);
|
||||||
range.win.ekey = TMAX(startTsCols[rows-1], range.win.ekey);
|
range.win.ekey = TMAX(startTsCols[rows-1], range.win.ekey);
|
||||||
uint64_t uid = 0;
|
uint64_t uid = 0;
|
||||||
appendOneRowToStreamSpecialBlock(pAggSup->pScanBlock, &range.win.skey, &range.win.ekey, &uid, &range.groupId, NULL);
|
appendDataToSpecialBlock(pAggSup->pScanBlock, &range.win.skey, &range.win.ekey, &uid, &range.groupId, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &curWin.winInfo, &pResult, i, winRows, rows, numOfOutput,
|
code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &curWin.winInfo, &pResult, i, winRows, rows, numOfOutput,
|
||||||
pOperator, 0);
|
pOperator, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||||
qError("%s do stream count aggregate impl error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
qError("%s do stream count aggregate impl error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
break;
|
||||||
}
|
}
|
||||||
saveSessionOutputBuf(pAggSup, &curWin.winInfo);
|
saveSessionOutputBuf(pAggSup, &curWin.winInfo);
|
||||||
|
|
||||||
|
if (pInfo->destHasPrimaryKey && curWin.winInfo.isOutput && IS_NORMAL_COUNT_OP(pOperator)) {
|
||||||
|
saveDeleteRes(pInfo->pPkDeleted, curWin.winInfo.sessionWin);
|
||||||
|
}
|
||||||
|
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pStUpdated) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pStUpdated) {
|
||||||
code = saveResult(curWin.winInfo, pStUpdated);
|
code = saveResult(curWin.winInfo, pStUpdated);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s do stream count aggregate impl, set result error, code %s", GET_TASKID(pTaskInfo),
|
qError("%s do stream count aggregate impl, set result error, code %s", GET_TASKID(pTaskInfo),
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||||
|
@ -484,7 +490,7 @@ void doDeleteCountWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SAr
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteCountWinState(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SSHashObj* pMapUpdate,
|
void deleteCountWinState(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SSHashObj* pMapUpdate,
|
||||||
SSHashObj* pMapDelete) {
|
SSHashObj* pMapDelete, SSHashObj* pPkDelete, bool needAdd) {
|
||||||
SArray* pWins = taosArrayInit(16, sizeof(SSessionKey));
|
SArray* pWins = taosArrayInit(16, sizeof(SSessionKey));
|
||||||
if (isSlidingCountWindow(pAggSup)) {
|
if (isSlidingCountWindow(pAggSup)) {
|
||||||
doDeleteCountWindows(pAggSup, pBlock, pWins);
|
doDeleteCountWindows(pAggSup, pBlock, pWins);
|
||||||
|
@ -493,6 +499,9 @@ void deleteCountWinState(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SSHa
|
||||||
}
|
}
|
||||||
removeSessionResults(pAggSup, pMapUpdate, pWins);
|
removeSessionResults(pAggSup, pMapUpdate, pWins);
|
||||||
copyDeleteWindowInfo(pWins, pMapDelete);
|
copyDeleteWindowInfo(pWins, pMapDelete);
|
||||||
|
if (needAdd) {
|
||||||
|
copyDeleteWindowInfo(pWins, pPkDelete);
|
||||||
|
}
|
||||||
taosArrayDestroy(pWins);
|
taosArrayDestroy(pWins);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,7 +551,8 @@ static SSDataBlock* doStreamCountAgg(SOperatorInfo* pOperator) {
|
||||||
printSpecDataBlock(pBlock, getStreamOpName(pOperator->operatorType), "recv", GET_TASKID(pTaskInfo));
|
printSpecDataBlock(pBlock, getStreamOpName(pOperator->operatorType), "recv", GET_TASKID(pTaskInfo));
|
||||||
|
|
||||||
if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) {
|
if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) {
|
||||||
deleteCountWinState(&pInfo->streamAggSup, pBlock, pInfo->pStUpdated, pInfo->pStDeleted);
|
bool add = pInfo->destHasPrimaryKey && IS_NORMAL_COUNT_OP(pOperator);
|
||||||
|
deleteCountWinState(&pInfo->streamAggSup, pBlock, pInfo->pStUpdated, pInfo->pStDeleted, pInfo->pPkDeleted, add);
|
||||||
continue;
|
continue;
|
||||||
} else if (pBlock->info.type == STREAM_CLEAR) {
|
} else if (pBlock->info.type == STREAM_CLEAR) {
|
||||||
doResetCountWindows(&pInfo->streamAggSup, pBlock);
|
doResetCountWindows(&pInfo->streamAggSup, pBlock);
|
||||||
|
@ -582,6 +592,10 @@ static SSDataBlock* doStreamCountAgg(SOperatorInfo* pOperator) {
|
||||||
pInfo->pUpdated = NULL;
|
pInfo->pUpdated = NULL;
|
||||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
|
if (pInfo->destHasPrimaryKey && IS_NORMAL_COUNT_OP(pOperator)) {
|
||||||
|
copyDeleteSessionKey(pInfo->pPkDeleted, pInfo->pStDeleted);
|
||||||
|
}
|
||||||
|
|
||||||
SSDataBlock* opRes = buildCountResult(pOperator);
|
SSDataBlock* opRes = buildCountResult(pOperator);
|
||||||
if (opRes) {
|
if (opRes) {
|
||||||
return opRes;
|
return opRes;
|
||||||
|
@ -694,6 +708,8 @@ SOperatorInfo* createStreamCountAggOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
|
|
||||||
pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT);
|
pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT);
|
||||||
pInfo->recvGetAll = false;
|
pInfo->recvGetAll = false;
|
||||||
|
pInfo->pPkDeleted = tSimpleHashInit(64, hashFn);
|
||||||
|
pInfo->destHasPrimaryKey = pCountNode->window.destHasPrimayKey;
|
||||||
|
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT;
|
||||||
setOperatorInfo(pOperator, getStreamOpName(pOperator->operatorType), QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT, true,
|
setOperatorInfo(pOperator, getStreamOpName(pOperator->operatorType), QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT, true,
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
#define IS_FINAL_EVENT_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_EVENT)
|
#define IS_NORMAL_EVENT_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT)
|
||||||
#define STREAM_EVENT_OP_STATE_NAME "StreamEventHistoryState"
|
#define STREAM_EVENT_OP_STATE_NAME "StreamEventHistoryState"
|
||||||
#define STREAM_EVENT_OP_CHECKPOINT_NAME "StreamEventOperator_Checkpoint"
|
#define STREAM_EVENT_OP_CHECKPOINT_NAME "StreamEventOperator_Checkpoint"
|
||||||
|
|
||||||
|
@ -66,6 +66,8 @@ void destroyStreamEventOperatorInfo(void* param) {
|
||||||
taosArrayDestroy(pInfo->historyWins);
|
taosArrayDestroy(pInfo->historyWins);
|
||||||
blockDataDestroy(pInfo->pCheckpointRes);
|
blockDataDestroy(pInfo->pCheckpointRes);
|
||||||
|
|
||||||
|
tSimpleHashCleanup(pInfo->pPkDeleted);
|
||||||
|
|
||||||
if (pInfo->pStartCondInfo != NULL) {
|
if (pInfo->pStartCondInfo != NULL) {
|
||||||
filterFreeInfo(pInfo->pStartCondInfo);
|
filterFreeInfo(pInfo->pStartCondInfo);
|
||||||
pInfo->pStartCondInfo = NULL;
|
pInfo->pStartCondInfo = NULL;
|
||||||
|
@ -99,17 +101,21 @@ int32_t getEndCondIndex(bool* pEnd, int32_t start, int32_t rows) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isWindowIncomplete(SEventWindowInfo* pWinInfo) {
|
||||||
|
return !(pWinInfo->pWinFlag->startFlag && pWinInfo->pWinFlag->endFlag);
|
||||||
|
}
|
||||||
int32_t reuseOutputBuf(void* pState, SRowBuffPos* pPos, SStateStore* pAPI) {
|
int32_t reuseOutputBuf(void* pState, SRowBuffPos* pPos, SStateStore* pAPI) {
|
||||||
pAPI->streamStateReleaseBuf(pState, pPos, true);
|
pAPI->streamStateReleaseBuf(pState, pPos, true);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEventOutputBuf(SStreamAggSupporter* pAggSup, TSKEY* pTs, uint64_t groupId, bool* pStart, bool* pEnd, int32_t index, int32_t rows, SEventWindowInfo* pCurWin, SSessionKey* pNextWinKey) {
|
void setEventOutputBuf(SStreamAggSupporter* pAggSup, TSKEY* pTs, uint64_t groupId, bool* pStart, bool* pEnd,
|
||||||
|
int32_t index, int32_t rows, SEventWindowInfo* pCurWin, SSessionKey* pNextWinKey) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t size = pAggSup->resultRowSize;
|
int32_t size = pAggSup->resultRowSize;
|
||||||
TSKEY ts = pTs [index];
|
TSKEY ts = pTs[index];
|
||||||
bool start = pStart[index];
|
bool start = pStart[index];
|
||||||
bool end = pEnd[index];
|
bool end = pEnd[index];
|
||||||
pCurWin->winInfo.sessionWin.groupId = groupId;
|
pCurWin->winInfo.sessionWin.groupId = groupId;
|
||||||
pCurWin->winInfo.sessionWin.win.skey = ts;
|
pCurWin->winInfo.sessionWin.win.skey = ts;
|
||||||
pCurWin->winInfo.sessionWin.win.ekey = ts;
|
pCurWin->winInfo.sessionWin.win.ekey = ts;
|
||||||
|
@ -122,7 +128,7 @@ void setEventOutputBuf(SStreamAggSupporter* pAggSup, TSKEY* pTs, uint64_t groupI
|
||||||
bool inWin = isInTimeWindow(&leftWinKey.win, ts, 0);
|
bool inWin = isInTimeWindow(&leftWinKey.win, ts, 0);
|
||||||
setEventWindowInfo(pAggSup, &leftWinKey, pVal, pCurWin);
|
setEventWindowInfo(pAggSup, &leftWinKey, pVal, pCurWin);
|
||||||
if(inWin || (pCurWin->pWinFlag->startFlag && !pCurWin->pWinFlag->endFlag) ) {
|
if(inWin || (pCurWin->pWinFlag->startFlag && !pCurWin->pWinFlag->endFlag) ) {
|
||||||
pCurWin->winInfo.isOutput = true;
|
pCurWin->winInfo.isOutput = !isWindowIncomplete(pCurWin);
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +141,7 @@ void setEventOutputBuf(SStreamAggSupporter* pAggSup, TSKEY* pTs, uint64_t groupI
|
||||||
int32_t endi = getEndCondIndex(pEnd, index, rows);
|
int32_t endi = getEndCondIndex(pEnd, index, rows);
|
||||||
if (endi < 0 || pTs[endi] >= rightWinKey.win.skey) {
|
if (endi < 0 || pTs[endi] >= rightWinKey.win.skey) {
|
||||||
setEventWindowInfo(pAggSup, &rightWinKey, pVal, pCurWin);
|
setEventWindowInfo(pAggSup, &rightWinKey, pVal, pCurWin);
|
||||||
pCurWin->winInfo.isOutput = true;
|
pCurWin->winInfo.isOutput = !isWindowIncomplete(pCurWin);
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,10 +253,6 @@ static int32_t compactEventWindow(SOperatorInfo* pOperator, SEventWindowInfo* pC
|
||||||
return winNum;
|
return winNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isWindowIncomplete(SEventWindowInfo* pWinInfo) {
|
|
||||||
return !(pWinInfo->pWinFlag->startFlag && pWinInfo->pWinFlag->endFlag);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool doDeleteEventWindow(SStreamAggSupporter* pAggSup, SSHashObj* pSeUpdated, SSessionKey* pKey) {
|
bool doDeleteEventWindow(SStreamAggSupporter* pAggSup, SSHashObj* pSeUpdated, SSessionKey* pKey) {
|
||||||
pAggSup->stateStore.streamStateSessionDel(pAggSup->pState, pKey);
|
pAggSup->stateStore.streamStateSessionDel(pAggSup->pState, pKey);
|
||||||
removeSessionResult(pAggSup, pSeUpdated, pAggSup->pResultRows, pKey);
|
removeSessionResult(pAggSup, pSeUpdated, pAggSup->pResultRows, pKey);
|
||||||
|
@ -324,10 +326,13 @@ static void doStreamEventAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
ASSERT(winRows >= 1);
|
ASSERT(winRows >= 1);
|
||||||
if (rebuild) {
|
if (rebuild) {
|
||||||
uint64_t uid = 0;
|
uint64_t uid = 0;
|
||||||
appendOneRowToStreamSpecialBlock(pAggSup->pScanBlock, &curWin.winInfo.sessionWin.win.skey,
|
appendDataToSpecialBlock(pAggSup->pScanBlock, &curWin.winInfo.sessionWin.win.skey,
|
||||||
&curWin.winInfo.sessionWin.win.ekey, &uid, &groupId, NULL);
|
&curWin.winInfo.sessionWin.win.ekey, &uid, &groupId, NULL);
|
||||||
tSimpleHashRemove(pSeUpdated, &curWin.winInfo.sessionWin, sizeof(SSessionKey));
|
tSimpleHashRemove(pSeUpdated, &curWin.winInfo.sessionWin, sizeof(SSessionKey));
|
||||||
doDeleteEventWindow(pAggSup, pSeUpdated, &curWin.winInfo.sessionWin);
|
doDeleteEventWindow(pAggSup, pSeUpdated, &curWin.winInfo.sessionWin);
|
||||||
|
if (pInfo->destHasPrimaryKey && curWin.winInfo.isOutput && IS_NORMAL_EVENT_OP(pOperator) && !isWindowIncomplete(&curWin)) {
|
||||||
|
saveDeleteRes(pInfo->pPkDeleted, curWin.winInfo.sessionWin);
|
||||||
|
}
|
||||||
releaseOutputBuf(pAggSup->pState, curWin.winInfo.pStatePos, &pAPI->stateStore);
|
releaseOutputBuf(pAggSup->pState, curWin.winInfo.pStatePos, &pAPI->stateStore);
|
||||||
SSessionKey tmpSeInfo = {0};
|
SSessionKey tmpSeInfo = {0};
|
||||||
getSessionHashKey(&curWin.winInfo.sessionWin, &tmpSeInfo);
|
getSessionHashKey(&curWin.winInfo.sessionWin, &tmpSeInfo);
|
||||||
|
@ -337,7 +342,7 @@ static void doStreamEventAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &curWin.winInfo, &pResult, i, winRows, rows, numOfOutput,
|
code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &curWin.winInfo, &pResult, i, winRows, rows, numOfOutput,
|
||||||
pOperator, 0);
|
pOperator, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
break;
|
||||||
}
|
}
|
||||||
compactEventWindow(pOperator, &curWin, pInfo->pSeUpdated, pInfo->pSeDeleted, false);
|
compactEventWindow(pOperator, &curWin, pInfo->pSeUpdated, pInfo->pSeDeleted, false);
|
||||||
saveSessionOutputBuf(pAggSup, &curWin.winInfo);
|
saveSessionOutputBuf(pAggSup, &curWin.winInfo);
|
||||||
|
@ -351,6 +356,10 @@ static void doStreamEventAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pInfo->destHasPrimaryKey && curWin.winInfo.isOutput && IS_NORMAL_EVENT_OP(pOperator)) {
|
||||||
|
saveDeleteRes(pInfo->pPkDeleted, curWin.winInfo.sessionWin);
|
||||||
|
}
|
||||||
|
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
|
||||||
code = saveResult(curWin.winInfo, pSeUpdated);
|
code = saveResult(curWin.winInfo, pSeUpdated);
|
||||||
}
|
}
|
||||||
|
@ -523,7 +532,8 @@ static SSDataBlock* doStreamEventAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT ||
|
if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT ||
|
||||||
pBlock->info.type == STREAM_CLEAR) {
|
pBlock->info.type == STREAM_CLEAR) {
|
||||||
deleteSessionWinState(&pInfo->streamAggSup, pBlock, pInfo->pSeUpdated, pInfo->pSeDeleted);
|
bool add = pInfo->destHasPrimaryKey && IS_NORMAL_EVENT_OP(pOperator);
|
||||||
|
deleteSessionWinState(&pInfo->streamAggSup, pBlock, pInfo->pSeUpdated, pInfo->pSeDeleted, pInfo->pPkDeleted, add);
|
||||||
continue;
|
continue;
|
||||||
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
||||||
pInfo->recvGetAll = true;
|
pInfo->recvGetAll = true;
|
||||||
|
@ -563,6 +573,9 @@ static SSDataBlock* doStreamEventAgg(SOperatorInfo* pOperator) {
|
||||||
getMaxTsWins(pHisWins, pInfo->historyWins);
|
getMaxTsWins(pHisWins, pInfo->historyWins);
|
||||||
taosArrayDestroy(pHisWins);
|
taosArrayDestroy(pHisWins);
|
||||||
}
|
}
|
||||||
|
if (pInfo->destHasPrimaryKey && IS_NORMAL_EVENT_OP(pOperator)) {
|
||||||
|
copyDeleteSessionKey(pInfo->pPkDeleted, pInfo->pSeDeleted);
|
||||||
|
}
|
||||||
|
|
||||||
initGroupResInfoFromArrayList(&pInfo->groupResInfo, pInfo->pUpdated);
|
initGroupResInfoFromArrayList(&pInfo->groupResInfo, pInfo->pUpdated);
|
||||||
pInfo->pUpdated = NULL;
|
pInfo->pUpdated = NULL;
|
||||||
|
@ -744,6 +757,8 @@ SOperatorInfo* createStreamEventAggOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT);
|
pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT);
|
||||||
pInfo->reCkBlock = false;
|
pInfo->reCkBlock = false;
|
||||||
pInfo->recvGetAll = false;
|
pInfo->recvGetAll = false;
|
||||||
|
pInfo->pPkDeleted = tSimpleHashInit(64, hashFn);
|
||||||
|
pInfo->destHasPrimaryKey = pEventNode->window.destHasPrimayKey;
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "StreamEventAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT, true, OP_NOT_OPENED,
|
setOperatorInfo(pOperator, "StreamEventAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT, true, OP_NOT_OPENED,
|
||||||
pInfo, pTaskInfo);
|
pInfo, pTaskInfo);
|
||||||
|
|
|
@ -29,7 +29,13 @@
|
||||||
|
|
||||||
#define IS_FINAL_INTERVAL_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL)
|
#define IS_FINAL_INTERVAL_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL)
|
||||||
#define IS_MID_INTERVAL_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL)
|
#define IS_MID_INTERVAL_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL)
|
||||||
|
#define IS_NORMAL_INTERVAL_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL || (op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL)
|
||||||
|
|
||||||
#define IS_FINAL_SESSION_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION)
|
#define IS_FINAL_SESSION_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION)
|
||||||
|
#define IS_NORMAL_SESSION_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION || (op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION)
|
||||||
|
|
||||||
|
#define IS_NORMAL_STATE_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE)
|
||||||
|
|
||||||
#define DEAULT_DELETE_MARK INT64_MAX
|
#define DEAULT_DELETE_MARK INT64_MAX
|
||||||
#define STREAM_INTERVAL_OP_STATE_NAME "StreamIntervalHistoryState"
|
#define STREAM_INTERVAL_OP_STATE_NAME "StreamIntervalHistoryState"
|
||||||
#define STREAM_SESSION_OP_STATE_NAME "StreamSessionHistoryState"
|
#define STREAM_SESSION_OP_STATE_NAME "StreamSessionHistoryState"
|
||||||
|
@ -371,11 +377,11 @@ static void doBuildDeleteResult(SStreamIntervalOperatorInfo* pInfo, SArray* pWin
|
||||||
void* tbname = NULL;
|
void* tbname = NULL;
|
||||||
pInfo->stateStore.streamStateGetParName(pInfo->pState, pWin->groupId, &tbname);
|
pInfo->stateStore.streamStateGetParName(pInfo->pState, pWin->groupId, &tbname);
|
||||||
if (tbname == NULL) {
|
if (tbname == NULL) {
|
||||||
appendOneRowToStreamSpecialBlock(pBlock, &pWin->ts, &pWin->ts, &uid, &pWin->groupId, NULL);
|
appendDataToSpecialBlock(pBlock, &pWin->ts, &pWin->ts, &uid, &pWin->groupId, NULL);
|
||||||
} else {
|
} else {
|
||||||
char parTbName[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN];
|
char parTbName[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN];
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(parTbName, tbname, sizeof(parTbName));
|
STR_WITH_MAXSIZE_TO_VARSTR(parTbName, tbname, sizeof(parTbName));
|
||||||
appendOneRowToStreamSpecialBlock(pBlock, &pWin->ts, &pWin->ts, &uid, &pWin->groupId, parTbName);
|
appendDataToSpecialBlock(pBlock, &pWin->ts, &pWin->ts, &uid, &pWin->groupId, parTbName);
|
||||||
}
|
}
|
||||||
pInfo->stateStore.streamStateFreeVal(tbname);
|
pInfo->stateStore.streamStateFreeVal(tbname);
|
||||||
(*index)++;
|
(*index)++;
|
||||||
|
@ -432,6 +438,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) {
|
||||||
tSimpleHashCleanup(pInfo->pUpdatedMap);
|
tSimpleHashCleanup(pInfo->pUpdatedMap);
|
||||||
pInfo->pUpdatedMap = NULL;
|
pInfo->pUpdatedMap = NULL;
|
||||||
pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated);
|
pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated);
|
||||||
|
tSimpleHashCleanup(pInfo->pDeletedMap);
|
||||||
|
|
||||||
blockDataDestroy(pInfo->pCheckpointRes);
|
blockDataDestroy(pInfo->pCheckpointRes);
|
||||||
|
|
||||||
|
@ -526,9 +533,7 @@ int32_t setIntervalOutputBuf(void* pState, STimeWindow* win, SRowBuffPos** pResu
|
||||||
char* value = NULL;
|
char* value = NULL;
|
||||||
int32_t size = pAggSup->resultRowSize;
|
int32_t size = pAggSup->resultRowSize;
|
||||||
|
|
||||||
if (pStore->streamStateAddIfNotExist(pState, &key, (void**)&value, &size) < 0) {
|
int32_t code = pStore->streamStateAddIfNotExist(pState, &key, (void**)&value, &size);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pResult = (SRowBuffPos*)value;
|
*pResult = (SRowBuffPos*)value;
|
||||||
SResultRow* res = (SResultRow*)((*pResult)->pRowBuff);
|
SResultRow* res = (SResultRow*)((*pResult)->pRowBuff);
|
||||||
|
@ -536,7 +541,7 @@ int32_t setIntervalOutputBuf(void* pState, STimeWindow* win, SRowBuffPos** pResu
|
||||||
// set time window for current result
|
// set time window for current result
|
||||||
res->win = (*win);
|
res->win = (*win);
|
||||||
setResultRowInitCtx(res, pCtx, numOfOutput, rowEntryInfoOffset);
|
setResultRowInitCtx(res, pCtx, numOfOutput, rowEntryInfoOffset);
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, void* pState, STimeWindowAggSupp* pTwSup,
|
bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, void* pState, STimeWindowAggSupp* pTwSup,
|
||||||
|
@ -612,6 +617,7 @@ static void doBuildPullDataBlock(SArray* array, int32_t* pIndex, SSDataBlock* pB
|
||||||
|
|
||||||
static bool processPullOver(SSDataBlock* pBlock, SHashObj* pMap, SHashObj* pFinalMap, SInterval* pInterval, SArray* pPullWins,
|
static bool processPullOver(SSDataBlock* pBlock, SHashObj* pMap, SHashObj* pFinalMap, SInterval* pInterval, SArray* pPullWins,
|
||||||
int32_t numOfCh, SOperatorInfo* pOperator) {
|
int32_t numOfCh, SOperatorInfo* pOperator) {
|
||||||
|
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
|
||||||
SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
||||||
TSKEY* tsData = (TSKEY*)pStartCol->pData;
|
TSKEY* tsData = (TSKEY*)pStartCol->pData;
|
||||||
SColumnInfoData* pEndCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
SColumnInfoData* pEndCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
||||||
|
@ -654,6 +660,10 @@ static bool processPullOver(SSDataBlock* pBlock, SHashObj* pMap, SHashObj* pFina
|
||||||
taosArrayPush(pInfo->pMidPullDatas, &winRes);
|
taosArrayPush(pInfo->pMidPullDatas, &winRes);
|
||||||
} else if (savePullWindow(&pull, pPullWins) == TSDB_CODE_SUCCESS) {
|
} else if (savePullWindow(&pull, pPullWins) == TSDB_CODE_SUCCESS) {
|
||||||
addPullWindow(pMap, &winRes, numOfCh);
|
addPullWindow(pMap, &winRes, numOfCh);
|
||||||
|
if (pInfo->destHasPrimaryKey) {
|
||||||
|
tSimpleHashPut(pInfo->pDeletedMap,&winRes, sizeof(SWinKey), NULL, 0);
|
||||||
|
}
|
||||||
|
qDebug("===stream===prepare final retrive for delete %" PRId64 ", size:%d", winRes.ts, numOfCh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -677,6 +687,9 @@ static void addRetriveWindow(SArray* wins, SStreamIntervalOperatorInfo* pInfo, i
|
||||||
// add pull data request
|
// add pull data request
|
||||||
if (savePullWindow(&pull, pInfo->pPullWins) == TSDB_CODE_SUCCESS) {
|
if (savePullWindow(&pull, pInfo->pPullWins) == TSDB_CODE_SUCCESS) {
|
||||||
addPullWindow(pInfo->pPullDataMap, winKey, pInfo->numOfChild);
|
addPullWindow(pInfo->pPullDataMap, winKey, pInfo->numOfChild);
|
||||||
|
if (pInfo->destHasPrimaryKey) {
|
||||||
|
tSimpleHashPut(pInfo->pDeletedMap,winKey, sizeof(SWinKey), NULL, 0);
|
||||||
|
}
|
||||||
qDebug("===stream===prepare retrive for delete %" PRId64 ", size:%d", winKey->ts, pInfo->numOfChild);
|
qDebug("===stream===prepare retrive for delete %" PRId64 ", size:%d", winKey->ts, pInfo->numOfChild);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -807,7 +820,7 @@ static int32_t getNextQualifiedFinalWindow(SInterval* pInterval, STimeWindow* pN
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doStreamIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBlock, uint64_t groupId,
|
static void doStreamIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBlock, uint64_t groupId,
|
||||||
SSHashObj* pUpdatedMap) {
|
SSHashObj* pUpdatedMap, SSHashObj* pDeletedMap) {
|
||||||
SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperator->info;
|
SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperator->info;
|
||||||
pInfo->dataVersion = TMAX(pInfo->dataVersion, pSDataBlock->info.version);
|
pInfo->dataVersion = TMAX(pInfo->dataVersion, pSDataBlock->info.version);
|
||||||
|
|
||||||
|
@ -875,6 +888,9 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDat
|
||||||
// add pull data request
|
// add pull data request
|
||||||
if (savePullWindow(&pull, pInfo->pPullWins) == TSDB_CODE_SUCCESS) {
|
if (savePullWindow(&pull, pInfo->pPullWins) == TSDB_CODE_SUCCESS) {
|
||||||
addPullWindow(pInfo->pPullDataMap, &winRes, pInfo->numOfChild);
|
addPullWindow(pInfo->pPullDataMap, &winRes, pInfo->numOfChild);
|
||||||
|
if (pInfo->destHasPrimaryKey) {
|
||||||
|
tSimpleHashPut(pInfo->pDeletedMap,&winRes, sizeof(SWinKey), NULL, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int32_t index = -1;
|
int32_t index = -1;
|
||||||
|
@ -902,9 +918,9 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDat
|
||||||
int32_t code = setIntervalOutputBuf(pInfo->pState, &nextWin, &pResPos, groupId, pSup->pCtx, numOfOutput,
|
int32_t code = setIntervalOutputBuf(pInfo->pState, &nextWin, &pResPos, groupId, pSup->pCtx, numOfOutput,
|
||||||
pSup->rowEntryInfoOffset, &pInfo->aggSup, &pInfo->stateStore);
|
pSup->rowEntryInfoOffset, &pInfo->aggSup, &pInfo->stateStore);
|
||||||
pResult = (SResultRow*)pResPos->pRowBuff;
|
pResult = (SResultRow*)pResPos->pRowBuff;
|
||||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
if (pResult == NULL) {
|
||||||
qError("%s set interval output buff error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
qError("%s set interval output buff error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
break;
|
||||||
}
|
}
|
||||||
if (IS_FINAL_INTERVAL_OP(pOperator)) {
|
if (IS_FINAL_INTERVAL_OP(pOperator)) {
|
||||||
forwardRows = 1;
|
forwardRows = 1;
|
||||||
|
@ -917,6 +933,11 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDat
|
||||||
.ts = pResult->win.skey,
|
.ts = pResult->win.skey,
|
||||||
.groupId = groupId,
|
.groupId = groupId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (pInfo->destHasPrimaryKey && code == TSDB_CODE_SUCCESS && IS_NORMAL_INTERVAL_OP(pOperator)) {
|
||||||
|
tSimpleHashPut(pDeletedMap,&key, sizeof(SWinKey), NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pUpdatedMap) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pUpdatedMap) {
|
||||||
saveWinResult(&key, pResPos, pUpdatedMap);
|
saveWinResult(&key, pResPos, pUpdatedMap);
|
||||||
}
|
}
|
||||||
|
@ -1174,6 +1195,16 @@ void doStreamIntervalSaveCheckpoint(SOperatorInfo* pOperator) {
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void copyIntervalDeleteKey(SSHashObj* pMap, SArray* pWins) {
|
||||||
|
void* pIte = NULL;
|
||||||
|
int32_t iter = 0;
|
||||||
|
while ((pIte = tSimpleHashIterate(pMap, pIte, &iter)) != NULL) {
|
||||||
|
void* pKey = tSimpleHashGetKey(pIte, NULL);
|
||||||
|
taosArrayPush(pWins, pKey);
|
||||||
|
}
|
||||||
|
tSimpleHashClear(pMap);
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* buildIntervalResult(SOperatorInfo* pOperator) {
|
static SSDataBlock* buildIntervalResult(SOperatorInfo* pOperator) {
|
||||||
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
|
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
@ -1359,7 +1390,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
|
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
|
||||||
}
|
}
|
||||||
setInputDataBlock(pSup, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
setInputDataBlock(pSup, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
||||||
doStreamIntervalAggImpl(pOperator, pBlock, pBlock->info.id.groupId, pInfo->pUpdatedMap);
|
doStreamIntervalAggImpl(pOperator, pBlock, pBlock->info.id.groupId, pInfo->pUpdatedMap, pInfo->pDeletedMap);
|
||||||
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
||||||
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.watermark);
|
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.watermark);
|
||||||
pInfo->twAggSup.minTs = TMIN(pInfo->twAggSup.minTs, pBlock->info.window.skey);
|
pInfo->twAggSup.minTs = TMIN(pInfo->twAggSup.minTs, pBlock->info.window.skey);
|
||||||
|
@ -1369,6 +1400,9 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
if (IS_FINAL_INTERVAL_OP(pOperator)) {
|
if (IS_FINAL_INTERVAL_OP(pOperator)) {
|
||||||
closeStreamIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval,
|
closeStreamIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval,
|
||||||
pInfo->pPullDataMap, pInfo->pUpdatedMap, pInfo->pDelWins, pOperator);
|
pInfo->pPullDataMap, pInfo->pUpdatedMap, pInfo->pDelWins, pOperator);
|
||||||
|
if (pInfo->destHasPrimaryKey) {
|
||||||
|
copyIntervalDeleteKey(pInfo->pDeletedMap, pInfo->pDelWins);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pInfo->binfo.pRes->info.watermark = pInfo->twAggSup.maxTs;
|
pInfo->binfo.pRes->info.watermark = pInfo->twAggSup.maxTs;
|
||||||
|
|
||||||
|
@ -1565,6 +1599,8 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
pInfo->pMidPulloverRes = createSpecialDataBlock(STREAM_MID_RETRIEVE);
|
pInfo->pMidPulloverRes = createSpecialDataBlock(STREAM_MID_RETRIEVE);
|
||||||
pInfo->clearState = false;
|
pInfo->clearState = false;
|
||||||
pInfo->pMidPullDatas = taosArrayInit(4, sizeof(SWinKey));
|
pInfo->pMidPullDatas = taosArrayInit(4, sizeof(SWinKey));
|
||||||
|
pInfo->pDeletedMap = tSimpleHashInit(4096, hashFn);
|
||||||
|
pInfo->destHasPrimaryKey = pIntervalPhyNode->window.destHasPrimayKey;
|
||||||
|
|
||||||
pOperator->operatorType = pPhyNode->type;
|
pOperator->operatorType = pPhyNode->type;
|
||||||
if (!IS_FINAL_INTERVAL_OP(pOperator) || numOfChild == 0) {
|
if (!IS_FINAL_INTERVAL_OP(pOperator) || numOfChild == 0) {
|
||||||
|
@ -1646,6 +1682,7 @@ void destroyStreamSessionAggOperatorInfo(void* param) {
|
||||||
|
|
||||||
taosArrayDestroy(pInfo->historyWins);
|
taosArrayDestroy(pInfo->historyWins);
|
||||||
blockDataDestroy(pInfo->pCheckpointRes);
|
blockDataDestroy(pInfo->pCheckpointRes);
|
||||||
|
tSimpleHashCleanup(pInfo->pPkDeleted);
|
||||||
|
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
@ -1865,10 +1902,10 @@ void removeSessionDeleteResults(SSHashObj* pHashMap, SArray* pWins) {
|
||||||
}
|
}
|
||||||
int32_t size = taosArrayGetSize(pWins);
|
int32_t size = taosArrayGetSize(pWins);
|
||||||
for (int32_t i = 0; i < size; i++) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
SSessionKey* pWin = taosArrayGet(pWins, i);
|
SResultWindowInfo* pWin = taosArrayGet(pWins, i);
|
||||||
if (!pWin) continue;
|
if (!pWin) continue;
|
||||||
SSessionKey key = {0};
|
SSessionKey key = {0};
|
||||||
getSessionHashKey(pWin, &key);
|
getSessionHashKey(&pWin->sessionWin, &key);
|
||||||
tSimpleHashRemove(pHashMap, &key, sizeof(SSessionKey));
|
tSimpleHashRemove(pHashMap, &key, sizeof(SSessionKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2109,17 +2146,20 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
|
||||||
pOperator, winDelta);
|
pOperator, winDelta);
|
||||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||||
qError("%s do stream session aggregate impl error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
qError("%s do stream session aggregate impl error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
break;
|
||||||
}
|
}
|
||||||
compactSessionWindow(pOperator, &winInfo, pStUpdated, pStDeleted, addGap);
|
compactSessionWindow(pOperator, &winInfo, pStUpdated, pStDeleted, addGap);
|
||||||
saveSessionOutputBuf(pAggSup, &winInfo);
|
saveSessionOutputBuf(pAggSup, &winInfo);
|
||||||
|
|
||||||
|
if (pInfo->destHasPrimaryKey && winInfo.isOutput && IS_NORMAL_SESSION_OP(pOperator)) {
|
||||||
|
saveDeleteRes(pInfo->pPkDeleted, winInfo.sessionWin);
|
||||||
|
}
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pStUpdated) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pStUpdated) {
|
||||||
code = saveResult(winInfo, pStUpdated);
|
code = saveResult(winInfo, pStUpdated);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s do stream session aggregate impl, set result error, code %s", GET_TASKID(pTaskInfo),
|
qError("%s do stream session aggregate impl, set result error, code %s", GET_TASKID(pTaskInfo),
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||||
|
@ -2645,6 +2685,20 @@ void resetUnCloseSessionWinInfo(SSHashObj* winMap) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void copyDeleteSessionKey(SSHashObj* source, SSHashObj* dest) {
|
||||||
|
if (tSimpleHashGetSize(source) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void* pIte = NULL;
|
||||||
|
int32_t iter = 0;
|
||||||
|
size_t keyLen = 0;
|
||||||
|
while ((pIte = tSimpleHashIterate(source, pIte, &iter)) != NULL) {
|
||||||
|
SSessionKey* pKey = tSimpleHashGetKey(pIte, &keyLen);
|
||||||
|
saveDeleteRes(dest, *pKey);
|
||||||
|
}
|
||||||
|
tSimpleHashClear(source);
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
SExprSupp* pSup = &pOperator->exprSupp;
|
SExprSupp* pSup = &pOperator->exprSupp;
|
||||||
SStreamSessionAggOperatorInfo* pInfo = pOperator->info;
|
SStreamSessionAggOperatorInfo* pInfo = pOperator->info;
|
||||||
|
@ -2705,6 +2759,9 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
rebuildSessionWindow(pOperator, pWins, pInfo->pStUpdated);
|
rebuildSessionWindow(pOperator, pWins, pInfo->pStUpdated);
|
||||||
}
|
}
|
||||||
copyDeleteWindowInfo(pWins, pInfo->pStDeleted);
|
copyDeleteWindowInfo(pWins, pInfo->pStDeleted);
|
||||||
|
if (pInfo->destHasPrimaryKey && IS_NORMAL_SESSION_OP(pOperator)) {
|
||||||
|
copyDeleteWindowInfo(pWins, pInfo->pPkDeleted);
|
||||||
|
}
|
||||||
taosArrayDestroy(pWins);
|
taosArrayDestroy(pWins);
|
||||||
continue;
|
continue;
|
||||||
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
||||||
|
@ -2760,6 +2817,9 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
if (pInfo->isHistoryOp) {
|
if (pInfo->isHistoryOp) {
|
||||||
getMaxTsWins(pInfo->pUpdated, pInfo->historyWins);
|
getMaxTsWins(pInfo->pUpdated, pInfo->historyWins);
|
||||||
}
|
}
|
||||||
|
if (pInfo->destHasPrimaryKey && IS_NORMAL_SESSION_OP(pOperator)) {
|
||||||
|
copyDeleteSessionKey(pInfo->pPkDeleted, pInfo->pStDeleted);
|
||||||
|
}
|
||||||
initGroupResInfoFromArrayList(&pInfo->groupResInfo, pInfo->pUpdated);
|
initGroupResInfoFromArrayList(&pInfo->groupResInfo, pInfo->pUpdated);
|
||||||
pInfo->pUpdated = NULL;
|
pInfo->pUpdated = NULL;
|
||||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||||
|
@ -2985,6 +3045,8 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
|
||||||
pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT);
|
pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT);
|
||||||
pInfo->clearState = false;
|
pInfo->clearState = false;
|
||||||
pInfo->recvGetAll = false;
|
pInfo->recvGetAll = false;
|
||||||
|
pInfo->destHasPrimaryKey = pSessionNode->window.destHasPrimayKey;
|
||||||
|
pInfo->pPkDeleted = tSimpleHashInit(64, hashFn);
|
||||||
|
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION;
|
||||||
setOperatorInfo(pOperator, getStreamOpName(pOperator->operatorType), QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION, true,
|
setOperatorInfo(pOperator, getStreamOpName(pOperator->operatorType), QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION, true,
|
||||||
|
@ -3025,11 +3087,14 @@ static void clearStreamSessionOperator(SStreamSessionAggOperatorInfo* pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteSessionWinState(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SSHashObj* pMapUpdate,
|
void deleteSessionWinState(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SSHashObj* pMapUpdate,
|
||||||
SSHashObj* pMapDelete) {
|
SSHashObj* pMapDelete, SSHashObj* pPkDelete, bool needAdd) {
|
||||||
SArray* pWins = taosArrayInit(16, sizeof(SSessionKey));
|
SArray* pWins = taosArrayInit(16, sizeof(SSessionKey));
|
||||||
doDeleteTimeWindows(pAggSup, pBlock, pWins);
|
doDeleteTimeWindows(pAggSup, pBlock, pWins);
|
||||||
removeSessionResults(pAggSup, pMapUpdate, pWins);
|
removeSessionResults(pAggSup, pMapUpdate, pWins);
|
||||||
copyDeleteWindowInfo(pWins, pMapDelete);
|
copyDeleteWindowInfo(pWins, pMapDelete);
|
||||||
|
if (needAdd) {
|
||||||
|
copyDeleteWindowInfo(pWins, pPkDelete);
|
||||||
|
}
|
||||||
taosArrayDestroy(pWins);
|
taosArrayDestroy(pWins);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3092,7 +3157,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
|
||||||
if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT ||
|
if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT ||
|
||||||
pBlock->info.type == STREAM_CLEAR) {
|
pBlock->info.type == STREAM_CLEAR) {
|
||||||
// gap must be 0
|
// gap must be 0
|
||||||
deleteSessionWinState(pAggSup, pBlock, pInfo->pStUpdated, pInfo->pStDeleted);
|
deleteSessionWinState(pAggSup, pBlock, pInfo->pStUpdated, pInfo->pStDeleted, NULL, false);
|
||||||
pInfo->clearState = true;
|
pInfo->clearState = true;
|
||||||
break;
|
break;
|
||||||
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
||||||
|
@ -3218,6 +3283,7 @@ void destroyStreamStateOperatorInfo(void* param) {
|
||||||
|
|
||||||
taosArrayDestroy(pInfo->historyWins);
|
taosArrayDestroy(pInfo->historyWins);
|
||||||
blockDataDestroy(pInfo->pCheckpointRes);
|
blockDataDestroy(pInfo->pCheckpointRes);
|
||||||
|
tSimpleHashCleanup(pInfo->pPkDeleted);
|
||||||
|
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
@ -3448,7 +3514,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
pAggSup->pResultRows, pSeUpdated, pStDeleted);
|
pAggSup->pResultRows, pSeUpdated, pStDeleted);
|
||||||
if (!allEqual) {
|
if (!allEqual) {
|
||||||
uint64_t uid = 0;
|
uint64_t uid = 0;
|
||||||
appendOneRowToStreamSpecialBlock(pAggSup->pScanBlock, &curWin.winInfo.sessionWin.win.skey,
|
appendDataToSpecialBlock(pAggSup->pScanBlock, &curWin.winInfo.sessionWin.win.skey,
|
||||||
&curWin.winInfo.sessionWin.win.ekey, &uid, &groupId, NULL);
|
&curWin.winInfo.sessionWin.win.ekey, &uid, &groupId, NULL);
|
||||||
tSimpleHashRemove(pSeUpdated, &curWin.winInfo.sessionWin, sizeof(SSessionKey));
|
tSimpleHashRemove(pSeUpdated, &curWin.winInfo.sessionWin, sizeof(SSessionKey));
|
||||||
doDeleteSessionWindow(pAggSup, &curWin.winInfo.sessionWin);
|
doDeleteSessionWindow(pAggSup, &curWin.winInfo.sessionWin);
|
||||||
|
@ -3459,15 +3525,19 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
pOperator, 0);
|
pOperator, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||||
qError("%s do one window aggregate impl error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
qError("%s do one window aggregate impl error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
break;
|
||||||
}
|
}
|
||||||
saveSessionOutputBuf(pAggSup, &curWin.winInfo);
|
saveSessionOutputBuf(pAggSup, &curWin.winInfo);
|
||||||
|
|
||||||
|
if (pInfo->destHasPrimaryKey && curWin.winInfo.isOutput && IS_NORMAL_STATE_OP(pOperator)) {
|
||||||
|
saveDeleteRes(pInfo->pPkDeleted, curWin.winInfo.sessionWin);
|
||||||
|
}
|
||||||
|
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
|
||||||
code = saveResult(curWin.winInfo, pSeUpdated);
|
code = saveResult(curWin.winInfo, pSeUpdated);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s do stream state aggregate impl, set result error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
qError("%s do stream state aggregate impl, set result error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3654,7 +3724,8 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT ||
|
if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT ||
|
||||||
pBlock->info.type == STREAM_CLEAR) {
|
pBlock->info.type == STREAM_CLEAR) {
|
||||||
deleteSessionWinState(&pInfo->streamAggSup, pBlock, pInfo->pSeUpdated, pInfo->pSeDeleted);
|
bool add = pInfo->destHasPrimaryKey && IS_NORMAL_STATE_OP(pOperator);
|
||||||
|
deleteSessionWinState(&pInfo->streamAggSup, pBlock, pInfo->pSeUpdated, pInfo->pSeDeleted, pInfo->pPkDeleted, add);
|
||||||
continue;
|
continue;
|
||||||
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
||||||
pInfo->recvGetAll = true;
|
pInfo->recvGetAll = true;
|
||||||
|
@ -3690,6 +3761,9 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
|
||||||
if (pInfo->isHistoryOp) {
|
if (pInfo->isHistoryOp) {
|
||||||
getMaxTsWins(pInfo->pUpdated, pInfo->historyWins);
|
getMaxTsWins(pInfo->pUpdated, pInfo->historyWins);
|
||||||
}
|
}
|
||||||
|
if (pInfo->destHasPrimaryKey && IS_NORMAL_STATE_OP(pOperator)) {
|
||||||
|
copyDeleteSessionKey(pInfo->pPkDeleted, pInfo->pSeDeleted);
|
||||||
|
}
|
||||||
|
|
||||||
initGroupResInfoFromArrayList(&pInfo->groupResInfo, pInfo->pUpdated);
|
initGroupResInfoFromArrayList(&pInfo->groupResInfo, pInfo->pUpdated);
|
||||||
pInfo->pUpdated = NULL;
|
pInfo->pUpdated = NULL;
|
||||||
|
@ -3871,6 +3945,8 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
|
|
||||||
pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT);
|
pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT);
|
||||||
pInfo->recvGetAll = false;
|
pInfo->recvGetAll = false;
|
||||||
|
pInfo->pPkDeleted = tSimpleHashInit(64, hashFn);
|
||||||
|
pInfo->destHasPrimaryKey = pStateNode->window.destHasPrimayKey;
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "StreamStateAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE, true, OP_NOT_OPENED,
|
setOperatorInfo(pOperator, "StreamStateAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE, true, OP_NOT_OPENED,
|
||||||
pInfo, pTaskInfo);
|
pInfo, pTaskInfo);
|
||||||
|
@ -4011,7 +4087,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
doStreamIntervalAggImpl(pOperator, pBlock, pBlock->info.id.groupId, pInfo->pUpdatedMap);
|
doStreamIntervalAggImpl(pOperator, pBlock, pBlock->info.id.groupId, pInfo->pUpdatedMap, pInfo->pDeletedMap);
|
||||||
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
||||||
pInfo->twAggSup.minTs = TMIN(pInfo->twAggSup.minTs, pBlock->info.window.skey);
|
pInfo->twAggSup.minTs = TMIN(pInfo->twAggSup.minTs, pBlock->info.window.skey);
|
||||||
}
|
}
|
||||||
|
@ -4019,6 +4095,9 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
removeDeleteResults(pInfo->pUpdatedMap, pInfo->pDelWins);
|
removeDeleteResults(pInfo->pUpdatedMap, pInfo->pDelWins);
|
||||||
closeStreamIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, NULL,
|
closeStreamIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, NULL,
|
||||||
pInfo->pUpdatedMap, pInfo->pDelWins, pOperator);
|
pInfo->pUpdatedMap, pInfo->pDelWins, pOperator);
|
||||||
|
if (pInfo->destHasPrimaryKey && IS_NORMAL_INTERVAL_OP(pOperator)) {
|
||||||
|
copyIntervalDeleteKey(pInfo->pDeletedMap, pInfo->pDelWins);
|
||||||
|
}
|
||||||
|
|
||||||
void* pIte = NULL;
|
void* pIte = NULL;
|
||||||
int32_t iter = 0;
|
int32_t iter = 0;
|
||||||
|
@ -4135,6 +4214,10 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
pInfo->recvGetAll = false;
|
pInfo->recvGetAll = false;
|
||||||
pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT);
|
pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT);
|
||||||
|
|
||||||
|
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
||||||
|
pInfo->pDeletedMap = tSimpleHashInit(4096, hashFn);
|
||||||
|
pInfo->destHasPrimaryKey = pIntervalPhyNode->window.destHasPrimayKey;
|
||||||
|
|
||||||
// for stream
|
// for stream
|
||||||
void* buff = NULL;
|
void* buff = NULL;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
|
@ -4213,8 +4296,9 @@ static void doStreamMidIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pS
|
||||||
int32_t code = setIntervalOutputBuf(pInfo->pState, &nextWin, &pResPos, groupId, pSup->pCtx, numOfOutput,
|
int32_t code = setIntervalOutputBuf(pInfo->pState, &nextWin, &pResPos, groupId, pSup->pCtx, numOfOutput,
|
||||||
pSup->rowEntryInfoOffset, &pInfo->aggSup, &pInfo->stateStore);
|
pSup->rowEntryInfoOffset, &pInfo->aggSup, &pInfo->stateStore);
|
||||||
pResult = (SResultRow*)pResPos->pRowBuff;
|
pResult = (SResultRow*)pResPos->pRowBuff;
|
||||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
if (pResult == NULL) {
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
qError("%s set interval output buff error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
|
||||||
|
|
|
@ -983,7 +983,10 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
|
||||||
: (3 + DBL_MANT_DIG - DBL_MIN_EXP + VARSTR_HEADER_SIZE);
|
: (3 + DBL_MANT_DIG - DBL_MIN_EXP + VARSTR_HEADER_SIZE);
|
||||||
tagVarChar = taosMemoryCalloc(1, bufSize + 1);
|
tagVarChar = taosMemoryCalloc(1, bufSize + 1);
|
||||||
int32_t len = -1;
|
int32_t len = -1;
|
||||||
convertTagDataToStr(varDataVal(tagVarChar), tagType, tagData, tagLen, &len);
|
if (tagLen > 0)
|
||||||
|
convertTagDataToStr(varDataVal(tagVarChar), tagType, tagData, tagLen, &len);
|
||||||
|
else
|
||||||
|
len = 0;
|
||||||
varDataSetLen(tagVarChar, len);
|
varDataSetLen(tagVarChar, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3598,15 +3598,15 @@ static int32_t doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf,
|
||||||
int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos) {
|
int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos) {
|
||||||
prepareBuf(pCtx);
|
prepareBuf(pCtx);
|
||||||
|
|
||||||
SWinKey key;
|
SWinKey key = {0};
|
||||||
if (pCtx->saveHandle.pBuf == NULL) {
|
if (pCtx->saveHandle.pBuf == NULL) {
|
||||||
SColumnInfoData* pColInfo = taosArrayGet(pSrcBlock->pDataBlock, 0);
|
SColumnInfoData* pColInfo = pCtx->input.pPTS;
|
||||||
if (pColInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
if (!pColInfo || pColInfo->info.type != TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
int64_t skey = *(int64_t*)colDataGetData(pColInfo, rowIndex);
|
pColInfo = taosArrayGet(pSrcBlock->pDataBlock, 0);
|
||||||
|
|
||||||
key.groupId = pSrcBlock->info.id.groupId;
|
|
||||||
key.ts = skey;
|
|
||||||
}
|
}
|
||||||
|
ASSERT(pColInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||||
|
key.groupId = pSrcBlock->info.id.groupId;
|
||||||
|
key.ts = *(int64_t*)colDataGetData(pColInfo, rowIndex);;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf);
|
char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "cmdnodes.h"
|
||||||
#include "nodesUtil.h"
|
#include "nodesUtil.h"
|
||||||
#include "plannodes.h"
|
#include "plannodes.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
|
@ -125,6 +126,15 @@ static int32_t columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t columnDefNodeCopy(const SColumnDefNode* pSrc, SColumnDefNode* pDst) {
|
||||||
|
COPY_CHAR_ARRAY_FIELD(colName);
|
||||||
|
COPY_OBJECT_FIELD(dataType, sizeof(SDataType));
|
||||||
|
COPY_CHAR_ARRAY_FIELD(comments);
|
||||||
|
COPY_SCALAR_FIELD(sma);
|
||||||
|
COPY_SCALAR_FIELD(is_pk);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||||
COPY_CHAR_POINT_FIELD(literal);
|
COPY_CHAR_POINT_FIELD(literal);
|
||||||
|
@ -718,6 +728,7 @@ static int32_t physiWindowCopy(const SWindowPhysiNode* pSrc, SWindowPhysiNode* p
|
||||||
COPY_SCALAR_FIELD(triggerType);
|
COPY_SCALAR_FIELD(triggerType);
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
COPY_SCALAR_FIELD(igExpired);
|
COPY_SCALAR_FIELD(igExpired);
|
||||||
|
COPY_SCALAR_FIELD(destHasPrimayKey);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -835,6 +846,9 @@ SNode* nodesCloneNode(const SNode* pNode) {
|
||||||
case QUERY_NODE_COLUMN:
|
case QUERY_NODE_COLUMN:
|
||||||
code = columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst);
|
code = columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_COLUMN_DEF:
|
||||||
|
code = columnDefNodeCopy((const SColumnDefNode*)pNode, (SColumnDefNode*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_VALUE:
|
case QUERY_NODE_VALUE:
|
||||||
code = valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst);
|
code = valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -514,6 +514,7 @@ static const char* jkSchemaType = "Type";
|
||||||
static const char* jkSchemaColId = "ColId";
|
static const char* jkSchemaColId = "ColId";
|
||||||
static const char* jkSchemaBytes = "bytes";
|
static const char* jkSchemaBytes = "bytes";
|
||||||
static const char* jkSchemaName = "Name";
|
static const char* jkSchemaName = "Name";
|
||||||
|
static const char* jkSchemaFlags = "Flags";
|
||||||
|
|
||||||
static int32_t schemaToJson(const void* pObj, SJson* pJson) {
|
static int32_t schemaToJson(const void* pObj, SJson* pJson) {
|
||||||
const SSchema* pNode = (const SSchema*)pObj;
|
const SSchema* pNode = (const SSchema*)pObj;
|
||||||
|
@ -528,6 +529,9 @@ static int32_t schemaToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddStringToObject(pJson, jkSchemaName, pNode->name);
|
code = tjsonAddStringToObject(pJson, jkSchemaName, pNode->name);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkSchemaFlags, pNode->flags);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -546,6 +550,9 @@ static int32_t jsonToSchema(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetStringValue(pJson, jkSchemaName, pNode->name);
|
code = tjsonGetStringValue(pJson, jkSchemaName, pNode->name);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
tjsonGetNumberValue(pJson, jkSchemaFlags, pNode->flags, code);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2513,6 +2520,7 @@ static const char* jkWindowPhysiPlanDeleteMark = "DeleteMark";
|
||||||
static const char* jkWindowPhysiPlanIgnoreExpired = "IgnoreExpired";
|
static const char* jkWindowPhysiPlanIgnoreExpired = "IgnoreExpired";
|
||||||
static const char* jkWindowPhysiPlanInputTsOrder = "InputTsOrder";
|
static const char* jkWindowPhysiPlanInputTsOrder = "InputTsOrder";
|
||||||
static const char* jkWindowPhysiPlanMergeDataBlock = "MergeDataBlock";
|
static const char* jkWindowPhysiPlanMergeDataBlock = "MergeDataBlock";
|
||||||
|
static const char* jkWindowPhysiPlanDestHasPrimaryKey = "DestHasPrimaryKey";
|
||||||
|
|
||||||
static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SWindowPhysiNode* pNode = (const SWindowPhysiNode*)pObj;
|
const SWindowPhysiNode* pNode = (const SWindowPhysiNode*)pObj;
|
||||||
|
@ -2545,6 +2553,9 @@ static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddBoolToObject(pJson, jkWindowPhysiPlanMergeDataBlock, pNode->mergeDataBlock);
|
code = tjsonAddBoolToObject(pJson, jkWindowPhysiPlanMergeDataBlock, pNode->mergeDataBlock);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanDestHasPrimaryKey, pNode->destHasPrimayKey);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2580,6 +2591,9 @@ static int32_t jsonToPhysiWindowNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBoolValue(pJson, jkWindowPhysiPlanMergeDataBlock, &pNode->mergeDataBlock);
|
code = tjsonGetBoolValue(pJson, jkWindowPhysiPlanMergeDataBlock, &pNode->mergeDataBlock);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetTinyIntValue(pJson, jkWindowPhysiPlanDestHasPrimaryKey, &pNode->destHasPrimayKey);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2913,7 +2913,8 @@ enum {
|
||||||
PHY_WINDOW_CODE_IG_EXPIRED,
|
PHY_WINDOW_CODE_IG_EXPIRED,
|
||||||
PHY_WINDOW_CODE_INPUT_TS_ORDER,
|
PHY_WINDOW_CODE_INPUT_TS_ORDER,
|
||||||
PHY_WINDOW_CODE_OUTPUT_TS_ORDER,
|
PHY_WINDOW_CODE_OUTPUT_TS_ORDER,
|
||||||
PHY_WINDOW_CODE_MERGE_DATA_BLOCK
|
PHY_WINDOW_CODE_MERGE_DATA_BLOCK,
|
||||||
|
PHY_WINDOW_CODE_DEST_HAS_PRIMARY_KEY,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int32_t physiWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
static int32_t physiWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||||
|
@ -2947,6 +2948,9 @@ static int32_t physiWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tlvEncodeBool(pEncoder, PHY_WINDOW_CODE_MERGE_DATA_BLOCK, pNode->mergeDataBlock);
|
code = tlvEncodeBool(pEncoder, PHY_WINDOW_CODE_MERGE_DATA_BLOCK, pNode->mergeDataBlock);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tlvEncodeI8(pEncoder, PHY_WINDOW_CODE_DEST_HAS_PRIMARY_KEY, pNode->destHasPrimayKey);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2988,6 +2992,9 @@ static int32_t msgToPhysiWindowNode(STlvDecoder* pDecoder, void* pObj) {
|
||||||
case PHY_WINDOW_CODE_MERGE_DATA_BLOCK:
|
case PHY_WINDOW_CODE_MERGE_DATA_BLOCK:
|
||||||
code = tlvDecodeBool(pTlv, &pNode->mergeDataBlock);
|
code = tlvDecodeBool(pTlv, &pNode->mergeDataBlock);
|
||||||
break;
|
break;
|
||||||
|
case PHY_WINDOW_CODE_DEST_HAS_PRIMARY_KEY:
|
||||||
|
code = tlvDecodeI8(pTlv, &pNode->destHasPrimayKey);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -681,13 +681,23 @@ cmd ::= RESUME STREAM exists_opt(A) ignore_opt(C) stream_name(B).
|
||||||
%type col_list_opt { SNodeList* }
|
%type col_list_opt { SNodeList* }
|
||||||
%destructor col_list_opt { nodesDestroyList($$); }
|
%destructor col_list_opt { nodesDestroyList($$); }
|
||||||
col_list_opt(A) ::= . { A = NULL; }
|
col_list_opt(A) ::= . { A = NULL; }
|
||||||
col_list_opt(A) ::= NK_LP col_name_list(B) NK_RP. { A = B; }
|
col_list_opt(A) ::= NK_LP column_stream_def_list(B) NK_RP. { A = B; }
|
||||||
|
|
||||||
|
%type column_stream_def_list { SNodeList* }
|
||||||
|
%destructor column_stream_def_list { nodesDestroyList($$); }
|
||||||
|
column_stream_def_list(A) ::= column_stream_def(B). { A = createNodeList(pCxt, B); }
|
||||||
|
column_stream_def_list(A) ::= column_stream_def_list(B)
|
||||||
|
NK_COMMA column_stream_def(C). { A = addNodeToList(pCxt, B, C); }
|
||||||
|
|
||||||
|
column_stream_def(A) ::= column_name(B). { A = createColumnDefNode(pCxt, &B, createDataType(TSDB_DATA_TYPE_NULL), NULL, false); }
|
||||||
|
column_stream_def(A) ::= column_name(B) PRIMARY KEY. { A = createColumnDefNode(pCxt, &B, createDataType(TSDB_DATA_TYPE_NULL), NULL, true); }
|
||||||
|
//column_stream_def(A) ::= column_def(B). { A = B; }
|
||||||
|
|
||||||
%type tag_def_or_ref_opt { SNodeList* }
|
%type tag_def_or_ref_opt { SNodeList* }
|
||||||
%destructor tag_def_or_ref_opt { nodesDestroyList($$); }
|
%destructor tag_def_or_ref_opt { nodesDestroyList($$); }
|
||||||
tag_def_or_ref_opt(A) ::= . { A = NULL; }
|
tag_def_or_ref_opt(A) ::= . { A = NULL; }
|
||||||
tag_def_or_ref_opt(A) ::= tags_def(B). { A = B; }
|
tag_def_or_ref_opt(A) ::= tags_def(B). { A = B; }
|
||||||
tag_def_or_ref_opt(A) ::= TAGS NK_LP col_name_list(B) NK_RP. { A = B; }
|
tag_def_or_ref_opt(A) ::= TAGS NK_LP column_stream_def_list(B) NK_RP. { A = B; }
|
||||||
|
|
||||||
stream_options(A) ::= . { A = createStreamOptions(pCxt); }
|
stream_options(A) ::= . { A = createStreamOptions(pCxt); }
|
||||||
stream_options(A) ::= stream_options(B) TRIGGER AT_ONCE(C). { A = setStreamOptions(pCxt, B, SOPT_TRIGGER_TYPE_SET, &C, NULL); }
|
stream_options(A) ::= stream_options(B) TRIGGER AT_ONCE(C). { A = setStreamOptions(pCxt, B, SOPT_TRIGGER_TYPE_SET, &C, NULL); }
|
||||||
|
|
|
@ -1576,11 +1576,13 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
// if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long'
|
// if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long'
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
char* pUcs4 = taosMemoryCalloc(1, pSchema->bytes - VARSTR_HEADER_SIZE);
|
int64_t realLen = pToken->n << 2;
|
||||||
|
if (realLen > pSchema->bytes - VARSTR_HEADER_SIZE) realLen = pSchema->bytes - VARSTR_HEADER_SIZE;
|
||||||
|
char* pUcs4 = taosMemoryMalloc(realLen);
|
||||||
if (NULL == pUcs4) {
|
if (NULL == pUcs4) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
if (!taosMbsToUcs4(pToken->z, pToken->n, (TdUcs4*)pUcs4, pSchema->bytes - VARSTR_HEADER_SIZE, &len)) {
|
if (!taosMbsToUcs4(pToken->z, pToken->n, (TdUcs4*)pUcs4, realLen, &len)) {
|
||||||
taosMemoryFree(pUcs4);
|
taosMemoryFree(pUcs4);
|
||||||
if (errno == E2BIG) {
|
if (errno == E2BIG) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
|
return generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
|
||||||
|
|
|
@ -2116,7 +2116,6 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu
|
||||||
}
|
}
|
||||||
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias && !pFunc->node.asParam) {
|
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias && !pFunc->node.asParam) {
|
||||||
strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias);
|
strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias);
|
||||||
strcpy(pFunc->node.aliasName, pFunc->node.userAlias);
|
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2708,6 +2707,29 @@ static EDealRes rewriteExprToGroupKeyFunc(STranslateContext* pCxt, SNode** pNode
|
||||||
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isTbnameFuction(SNode* pNode) {
|
||||||
|
return QUERY_NODE_FUNCTION == nodeType(pNode) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pNode)->funcType;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool hasTbnameFunction(SNodeList* pPartitionByList) {
|
||||||
|
SNode* pPartKey = NULL;
|
||||||
|
FOREACH(pPartKey, pPartitionByList) {
|
||||||
|
if (isTbnameFuction(pPartKey)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool fromSubtable(SNode* table) {
|
||||||
|
if (NULL == table) return false;
|
||||||
|
if (table->type == QUERY_NODE_REAL_TABLE && ((SRealTableNode*)table)->pMeta &&
|
||||||
|
((SRealTableNode*)table)->pMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
STranslateContext* pCxt = (STranslateContext*)pContext;
|
STranslateContext* pCxt = (STranslateContext*)pContext;
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
||||||
|
@ -2719,15 +2741,25 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
}
|
}
|
||||||
SNode* pGroupNode = NULL;
|
SNode* pGroupNode = NULL;
|
||||||
FOREACH(pGroupNode, getGroupByList(pCxt)) {
|
FOREACH(pGroupNode, getGroupByList(pCxt)) {
|
||||||
if (nodesEqualNode(getGroupByNode(pGroupNode), *pNode)) {
|
SNode* pActualNode = getGroupByNode(pGroupNode);
|
||||||
|
if (nodesEqualNode(pActualNode, *pNode)) {
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
|
if (isTbnameFuction(pActualNode) && QUERY_NODE_COLUMN == nodeType(*pNode) &&
|
||||||
|
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
||||||
|
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SNode* pPartKey = NULL;
|
SNode* pPartKey = NULL;
|
||||||
|
bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList);
|
||||||
FOREACH(pPartKey, pSelect->pPartitionByList) {
|
FOREACH(pPartKey, pSelect->pPartitionByList) {
|
||||||
if (nodesEqualNode(pPartKey, *pNode)) {
|
if (nodesEqualNode(pPartKey, *pNode)) {
|
||||||
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||||
}
|
}
|
||||||
|
if ((partionByTbname) && QUERY_NODE_COLUMN == nodeType(*pNode) &&
|
||||||
|
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
||||||
|
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (NULL != pSelect->pWindow && QUERY_NODE_STATE_WINDOW == nodeType(pSelect->pWindow)) {
|
if (NULL != pSelect->pWindow && QUERY_NODE_STATE_WINDOW == nodeType(pSelect->pWindow)) {
|
||||||
if (nodesEqualNode(((SStateWindowNode*)pSelect->pWindow)->pExpr, *pNode)) {
|
if (nodesEqualNode(((SStateWindowNode*)pSelect->pWindow)->pExpr, *pNode)) {
|
||||||
|
@ -2791,11 +2823,19 @@ static EDealRes doCheckAggColCoexist(SNode** pNode, void* pContext) {
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
SNode* pPartKey = NULL;
|
SNode* pPartKey = NULL;
|
||||||
|
bool partionByTbname = false;
|
||||||
|
if (fromSubtable(((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pFromTable) ||
|
||||||
|
hasTbnameFunction(((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList)) {
|
||||||
|
partionByTbname = true;
|
||||||
|
}
|
||||||
FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) {
|
FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) {
|
||||||
if (nodesEqualNode(pPartKey, *pNode)) {
|
if (nodesEqualNode(pPartKey, *pNode)) {
|
||||||
return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode);
|
return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (partionByTbname && QUERY_NODE_COLUMN == nodeType(*pNode) && ((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
||||||
|
return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode);
|
||||||
|
}
|
||||||
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
pCxt->existCol = true;
|
pCxt->existCol = true;
|
||||||
}
|
}
|
||||||
|
@ -3966,24 +4006,18 @@ static int32_t checkStateExpr(STranslateContext* pCxt, SNode* pNode) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasPartitionByTbname(SNodeList* pPartitionByList) {
|
|
||||||
SNode* pPartKey = NULL;
|
|
||||||
FOREACH(pPartKey, pPartitionByList) {
|
|
||||||
if (QUERY_NODE_FUNCTION == nodeType(pPartKey) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pPartKey)->funcType) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t checkStateWindowForStream(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t checkStateWindowForStream(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (!pCxt->createStream) {
|
if (!pCxt->createStream) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
if (TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
if (TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
||||||
!hasPartitionByTbname(pSelect->pPartitionByList)) {
|
!hasTbnameFunction(pSelect->pPartitionByList)) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query");
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query");
|
||||||
}
|
}
|
||||||
|
if ((SRealTableNode*)pSelect->pFromTable && hasPkInTable(((SRealTableNode*)pSelect->pFromTable)->pMeta)) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
|
"Source table of State window must not has primary key");
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5865,12 +5899,17 @@ static int32_t translateTrimDatabase(STranslateContext* pCxt, STrimDatabaseStmt*
|
||||||
return buildCmdMsg(pCxt, TDMT_MND_TRIM_DB, (FSerializeFunc)tSerializeSTrimDbReq, &req);
|
return buildCmdMsg(pCxt, TDMT_MND_TRIM_DB, (FSerializeFunc)tSerializeSTrimDbReq, &req);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) {
|
static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray, bool calBytes) {
|
||||||
*pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField));
|
*pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField));
|
||||||
SNode* pNode;
|
SNode* pNode;
|
||||||
FOREACH(pNode, pList) {
|
FOREACH(pNode, pList) {
|
||||||
SColumnDefNode* pCol = (SColumnDefNode*)pNode;
|
SColumnDefNode* pCol = (SColumnDefNode*)pNode;
|
||||||
SField field = {.type = pCol->dataType.type, .bytes = calcTypeBytes(pCol->dataType)};
|
SField field = {.type = pCol->dataType.type,};
|
||||||
|
if (calBytes) {
|
||||||
|
field.bytes = calcTypeBytes(pCol->dataType);
|
||||||
|
} else {
|
||||||
|
field.bytes = pCol->dataType.bytes;
|
||||||
|
}
|
||||||
strcpy(field.name, pCol->colName);
|
strcpy(field.name, pCol->colName);
|
||||||
if (pCol->sma) {
|
if (pCol->sma) {
|
||||||
field.flags |= COL_SMA_ON;
|
field.flags |= COL_SMA_ON;
|
||||||
|
@ -6090,22 +6129,26 @@ static int32_t checkTableColsSchema(STranslateContext* pCxt, SHashObj* pHash, in
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
|
static int32_t checkTableSchemaImpl(STranslateContext* pCxt, SNodeList* pTags, SNodeList* pCols, SNodeList* pRollupFuncs) {
|
||||||
SHashObj* pHash = taosHashInit(LIST_LENGTH(pStmt->pTags) + LIST_LENGTH(pStmt->pCols),
|
SHashObj* pHash = taosHashInit(LIST_LENGTH(pTags) + LIST_LENGTH(pCols),
|
||||||
taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
if (NULL == pHash) {
|
if (NULL == pHash) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = checkTableTagsSchema(pCxt, pHash, pStmt->pTags);
|
int32_t code = checkTableTagsSchema(pCxt, pHash, pTags);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkTableColsSchema(pCxt, pHash, LIST_LENGTH(pStmt->pTags), pStmt->pCols, pStmt->pOptions->pRollupFuncs);
|
code = checkTableColsSchema(pCxt, pHash, LIST_LENGTH(pTags), pCols, pRollupFuncs);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashCleanup(pHash);
|
taosHashCleanup(pHash);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
|
||||||
|
return checkTableSchemaImpl(pCxt, pStmt->pTags, pStmt->pCols, pStmt->pOptions->pRollupFuncs);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t getTableDelayOrWatermarkOption(STranslateContext* pCxt, const char* pName, int64_t minVal,
|
static int32_t getTableDelayOrWatermarkOption(STranslateContext* pCxt, const char* pName, int64_t minVal,
|
||||||
int64_t maxVal, SValueNode* pVal, int64_t* pMaxDelay) {
|
int64_t maxVal, SValueNode* pVal, int64_t* pMaxDelay) {
|
||||||
int32_t code = (DEAL_RES_ERROR == translateValue(pCxt, pVal) ? pCxt->errCode : TSDB_CODE_SUCCESS);
|
int32_t code = (DEAL_RES_ERROR == translateValue(pCxt, pVal) ? pCxt->errCode : TSDB_CODE_SUCCESS);
|
||||||
|
@ -6575,8 +6618,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
|
||||||
pReq->colVer = 1;
|
pReq->colVer = 1;
|
||||||
pReq->tagVer = 1;
|
pReq->tagVer = 1;
|
||||||
pReq->source = TD_REQ_FROM_APP;
|
pReq->source = TD_REQ_FROM_APP;
|
||||||
columnDefNodeToField(pStmt->pCols, &pReq->pColumns);
|
columnDefNodeToField(pStmt->pCols, &pReq->pColumns, true);
|
||||||
columnDefNodeToField(pStmt->pTags, &pReq->pTags);
|
columnDefNodeToField(pStmt->pTags, &pReq->pTags, true);
|
||||||
pReq->numOfColumns = LIST_LENGTH(pStmt->pCols);
|
pReq->numOfColumns = LIST_LENGTH(pStmt->pCols);
|
||||||
pReq->numOfTags = LIST_LENGTH(pStmt->pTags);
|
pReq->numOfTags = LIST_LENGTH(pStmt->pTags);
|
||||||
if (pStmt->pOptions->commentNull == false) {
|
if (pStmt->pOptions->commentNull == false) {
|
||||||
|
@ -7665,12 +7708,12 @@ static int32_t translateKillTransaction(STranslateContext* pCxt, SKillStmt* pStm
|
||||||
static bool crossTableWithoutAggOper(SSelectStmt* pSelect) {
|
static bool crossTableWithoutAggOper(SSelectStmt* pSelect) {
|
||||||
return NULL == pSelect->pWindow && !pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc &&
|
return NULL == pSelect->pWindow && !pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc &&
|
||||||
!pSelect->hasInterpFunc && TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
!pSelect->hasInterpFunc && TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
||||||
!hasPartitionByTbname(pSelect->pPartitionByList);
|
!hasTbnameFunction(pSelect->pPartitionByList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool crossTableWithUdaf(SSelectStmt* pSelect) {
|
static bool crossTableWithUdaf(SSelectStmt* pSelect) {
|
||||||
return pSelect->hasUdaf && TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
return pSelect->hasUdaf && TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
||||||
!hasPartitionByTbname(pSelect->pPartitionByList);
|
!hasTbnameFunction(pSelect->pPartitionByList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) {
|
static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) {
|
||||||
|
@ -7729,7 +7772,7 @@ static void getStreamQueryFirstProjectAliasName(SHashObj* pUserAliasSet, char* a
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t addWstartTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSelectStmt* pSelect,
|
static int32_t addWstartTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSelectStmt* pSelect,
|
||||||
SHashObj* pUserAliasSet) {
|
SHashObj* pUserAliasSet, SNodeList* pCols, SCMCreateStreamReq* pReq) {
|
||||||
SNode* pProj = nodesListGetNode(pSelect->pProjectionList, 0);
|
SNode* pProj = nodesListGetNode(pSelect->pProjectionList, 0);
|
||||||
if (NULL == pSelect->pWindow ||
|
if (NULL == pSelect->pWindow ||
|
||||||
(QUERY_NODE_FUNCTION == nodeType(pProj) && 0 == strcmp("_wstart", ((SFunctionNode*)pProj)->functionName))) {
|
(QUERY_NODE_FUNCTION == nodeType(pProj) && 0 == strcmp("_wstart", ((SFunctionNode*)pProj)->functionName))) {
|
||||||
|
@ -7745,18 +7788,27 @@ static int32_t addWstartTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSele
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
|
code = nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code && STREAM_CREATE_STABLE_TRUE == pReq->createStb) {
|
||||||
|
SColumnDefNode* pColDef = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF);
|
||||||
|
strcpy(pColDef->colName, pFunc->node.aliasName);
|
||||||
|
pColDef->dataType = pFunc->node.resType;
|
||||||
|
pColDef->sma = true;
|
||||||
|
pColDef->is_pk = false;
|
||||||
|
code = nodesListPushFront(pCols, (SNode*)pColDef);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
nodesDestroyNode((SNode*)pFunc);
|
nodesDestroyNode((SNode*)pFunc);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t addWstartTsToCreateStreamQuery(STranslateContext* pCxt, SNode* pStmt) {
|
static int32_t addWstartTsToCreateStreamQuery(STranslateContext* pCxt, SNode* pStmt, SNodeList* pCols, SCMCreateStreamReq* pReq) {
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
||||||
SHashObj* pUserAliasSet = NULL;
|
SHashObj* pUserAliasSet = NULL;
|
||||||
int32_t code = checkProjectAlias(pCxt, pSelect->pProjectionList, &pUserAliasSet);
|
int32_t code = checkProjectAlias(pCxt, pSelect->pProjectionList, &pUserAliasSet);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addWstartTsToCreateStreamQueryImpl(pCxt, pSelect, pUserAliasSet);
|
code = addWstartTsToCreateStreamQueryImpl(pCxt, pSelect, pUserAliasSet, pCols, pReq);
|
||||||
}
|
}
|
||||||
taosHashCleanup(pUserAliasSet);
|
taosHashCleanup(pUserAliasSet);
|
||||||
return code;
|
return code;
|
||||||
|
@ -7874,6 +7926,44 @@ static int32_t addNullTagsToCreateStreamQuery(STranslateContext* pCxt, STableMet
|
||||||
return addNullTagsForExistTable(pCxt, pMeta, (SSelectStmt*)pStmt->pQuery);
|
return addNullTagsForExistTable(pCxt, pMeta, (SSelectStmt*)pStmt->pQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t addColDefNodeByProj(SNodeList** ppCols, SNode* pProject, int8_t flags) {
|
||||||
|
SExprNode* pExpr = (SExprNode*)pProject;
|
||||||
|
SColumnDefNode* pColDef = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF);
|
||||||
|
strcpy(pColDef->colName, pExpr->userAlias);
|
||||||
|
pColDef->dataType = pExpr->resType;
|
||||||
|
pColDef->sma = flags & COL_SMA_ON;
|
||||||
|
pColDef->is_pk = flags & COL_IS_KEY;
|
||||||
|
return nodesListMakeAppend(ppCols, (SNode*)pColDef);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t addColsToCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) {
|
||||||
|
if ( STREAM_CREATE_STABLE_FALSE == pReq->createStb) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
||||||
|
SNode* pProject = NULL;
|
||||||
|
SNode* pNode = NULL;
|
||||||
|
if (0 != LIST_LENGTH(pStmt->pCols)) {
|
||||||
|
if (LIST_LENGTH(pStmt->pCols) != LIST_LENGTH(pSelect->pProjectionList)) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM);
|
||||||
|
}
|
||||||
|
FORBOTH(pNode, pStmt->pCols, pProject, pSelect->pProjectionList) {
|
||||||
|
SExprNode* pExpr = (SExprNode*)pProject;
|
||||||
|
SColumnDefNode* pColDef = (SColumnDefNode*)pNode;
|
||||||
|
pColDef->dataType = pExpr->resType;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
FOREACH(pProject, pSelect->pProjectionList) {
|
||||||
|
int32_t code = addColDefNodeByProj(&pStmt->pCols, pProject, 0);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t addSubtableInfoToCreateStreamQuery(STranslateContext* pCxt, STableMeta* pMeta,
|
static int32_t addSubtableInfoToCreateStreamQuery(STranslateContext* pCxt, STableMeta* pMeta,
|
||||||
SCreateStreamStmt* pStmt) {
|
SCreateStreamStmt* pStmt) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -7928,11 +8018,18 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
||||||
if ( (SRealTableNode*)pSelect->pFromTable && ((SRealTableNode*)pSelect->pFromTable)->pMeta
|
if ( (SRealTableNode*)pSelect->pFromTable && ((SRealTableNode*)pSelect->pFromTable)->pMeta
|
||||||
&& TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType
|
&& TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType
|
||||||
&& !hasPartitionByTbname(pSelect->pPartitionByList)
|
&& !hasTbnameFunction(pSelect->pPartitionByList)
|
||||||
&& pSelect->pWindow != NULL && pSelect->pWindow->type == QUERY_NODE_EVENT_WINDOW) {
|
&& pSelect->pWindow != NULL && pSelect->pWindow->type == QUERY_NODE_EVENT_WINDOW) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
"Event window for stream on super table must patitioned by table name");
|
"Event window for stream on super table must patitioned by table name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pSelect->pWindow != NULL && pSelect->pWindow->type == QUERY_NODE_EVENT_WINDOW &&
|
||||||
|
(SRealTableNode*)pSelect->pFromTable && hasPkInTable(((SRealTableNode*)pSelect->pFromTable)->pMeta)) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
|
"Source table of Event window must not has primary key");
|
||||||
|
}
|
||||||
|
|
||||||
if (TSDB_DATA_TYPE_TIMESTAMP != ((SExprNode*)nodesListGetNode(pSelect->pProjectionList, 0))->resType.type ||
|
if (TSDB_DATA_TYPE_TIMESTAMP != ((SExprNode*)nodesListGetNode(pSelect->pProjectionList, 0))->resType.type ||
|
||||||
!isTimeLineQuery(pStmt->pQuery) || crossTableWithoutAggOper(pSelect) || NULL != pSelect->pOrderByList ||
|
!isTimeLineQuery(pStmt->pQuery) || crossTableWithoutAggOper(pSelect) || NULL != pSelect->pOrderByList ||
|
||||||
crossTableWithUdaf(pSelect) || hasJsonTypeProjection(pSelect)) {
|
crossTableWithUdaf(pSelect) || hasJsonTypeProjection(pSelect)) {
|
||||||
|
@ -7956,7 +8053,7 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm
|
||||||
if (pSelect->pWindow != NULL && pSelect->pWindow->type == QUERY_NODE_COUNT_WINDOW) {
|
if (pSelect->pWindow != NULL && pSelect->pWindow->type == QUERY_NODE_COUNT_WINDOW) {
|
||||||
if ( (SRealTableNode*)pSelect->pFromTable && ((SRealTableNode*)pSelect->pFromTable)->pMeta
|
if ( (SRealTableNode*)pSelect->pFromTable && ((SRealTableNode*)pSelect->pFromTable)->pMeta
|
||||||
&& TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType
|
&& TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType
|
||||||
&& !hasPartitionByTbname(pSelect->pPartitionByList) ) {
|
&& !hasTbnameFunction(pSelect->pPartitionByList) ) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
"Count window for stream on super table must patitioned by table name");
|
"Count window for stream on super table must patitioned by table name");
|
||||||
}
|
}
|
||||||
|
@ -7975,12 +8072,18 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
"Ignore expired data of Count window must be 1.");
|
"Ignore expired data of Count window must be 1.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((SRealTableNode*)pSelect->pFromTable && hasPkInTable(((SRealTableNode*)pSelect->pFromTable)->pMeta)) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
|
"Source table of Count window must not has primary key");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t adjustDataTypeOfProjections(STranslateContext* pCxt, const STableMeta* pMeta, SNodeList* pProjections) {
|
static int32_t adjustDataTypeOfProjections(STranslateContext* pCxt, const STableMeta* pMeta, SNodeList* pProjections,
|
||||||
|
SNodeList** ppCols) {
|
||||||
if (getNumOfColumns(pMeta) != LIST_LENGTH(pProjections)) {
|
if (getNumOfColumns(pMeta) != LIST_LENGTH(pProjections)) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM, "Illegal number of columns");
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM, "Illegal number of columns");
|
||||||
}
|
}
|
||||||
|
@ -7999,6 +8102,15 @@ static int32_t adjustDataTypeOfProjections(STranslateContext* pCxt, const STable
|
||||||
}
|
}
|
||||||
REPLACE_NODE(pFunc);
|
REPLACE_NODE(pFunc);
|
||||||
}
|
}
|
||||||
|
SColumnDefNode* pColDef = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF);
|
||||||
|
strcpy(pColDef->colName, pSchema->name);
|
||||||
|
pColDef->dataType = dt;
|
||||||
|
pColDef->sma = pSchema->flags & COL_SMA_ON;
|
||||||
|
pColDef->is_pk = pSchema->flags & COL_IS_KEY;
|
||||||
|
int32_t code = nodesListMakeAppend(ppCols, (SNode*)pColDef);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -8006,6 +8118,7 @@ static int32_t adjustDataTypeOfProjections(STranslateContext* pCxt, const STable
|
||||||
|
|
||||||
typedef struct SProjColPos {
|
typedef struct SProjColPos {
|
||||||
int32_t colId;
|
int32_t colId;
|
||||||
|
int8_t flags;
|
||||||
SNode* pProj;
|
SNode* pProj;
|
||||||
} SProjColPos;
|
} SProjColPos;
|
||||||
|
|
||||||
|
@ -8029,10 +8142,11 @@ static int32_t addProjToProjColPos(STranslateContext* pCxt, const SSchema* pSche
|
||||||
if (!dataTypeEqual(&dt, &((SExprNode*)pNewProj)->resType)) {
|
if (!dataTypeEqual(&dt, &((SExprNode*)pNewProj)->resType)) {
|
||||||
SNode* pFunc = NULL;
|
SNode* pFunc = NULL;
|
||||||
code = createCastFunc(pCxt, pNewProj, dt, &pFunc);
|
code = createCastFunc(pCxt, pNewProj, dt, &pFunc);
|
||||||
|
strcpy(((SExprNode*)pFunc)->userAlias, ((SExprNode*)pNewProj)->userAlias);
|
||||||
pNewProj = pFunc;
|
pNewProj = pFunc;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SProjColPos pos = {.colId = pSchema->colId, .pProj = pNewProj};
|
SProjColPos pos = {.colId = pSchema->colId, .pProj = pNewProj, .flags = pSchema->flags};
|
||||||
code = (NULL == taosArrayPush(pProjColPos, &pos) ? TSDB_CODE_OUT_OF_MEMORY : TSDB_CODE_SUCCESS);
|
code = (NULL == taosArrayPush(pProjColPos, &pos) ? TSDB_CODE_OUT_OF_MEMORY : TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
@ -8064,25 +8178,26 @@ static int32_t setFillNullCols(SArray* pProjColPos, const STableMeta* pMeta, SCM
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t adjustOrderOfProjections(STranslateContext* pCxt, SNodeList* pCols, const STableMeta* pMeta,
|
static int32_t adjustOrderOfProjections(STranslateContext* pCxt, SNodeList** ppCols, const STableMeta* pMeta,
|
||||||
SNodeList** pProjections, SCMCreateStreamReq* pReq) {
|
SNodeList** pProjections, SCMCreateStreamReq* pReq) {
|
||||||
if (LIST_LENGTH(pCols) != LIST_LENGTH(*pProjections)) {
|
if (LIST_LENGTH((*ppCols)) != LIST_LENGTH(*pProjections)) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM, "Illegal number of columns");
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM, "Illegal number of columns");
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* pProjColPos = taosArrayInit(LIST_LENGTH(pCols), sizeof(SProjColPos));
|
SArray* pProjColPos = taosArrayInit(LIST_LENGTH((*ppCols)), sizeof(SProjColPos));
|
||||||
if (NULL == pProjColPos) {
|
if (NULL == pProjColPos) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
bool hasTsKey = false;
|
||||||
bool hasPrimaryKey = false;
|
bool hasPrimaryKey = false;
|
||||||
SNode* pCol = NULL;
|
SNode* pCol = NULL;
|
||||||
SNode* pProj = NULL;
|
SNode* pProj = NULL;
|
||||||
FORBOTH(pCol, pCols, pProj, *pProjections) {
|
FORBOTH(pCol, (*ppCols), pProj, *pProjections) {
|
||||||
const SSchema* pSchema = getNormalColSchema(pMeta, ((SColumnNode*)pCol)->colName);
|
const SSchema* pSchema = getNormalColSchema(pMeta, ((SColumnDefNode*)pCol)->colName);
|
||||||
if (NULL == pSchema) {
|
if (NULL == pSchema) {
|
||||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, ((SColumnNode*)pCol)->colName);
|
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, ((SColumnDefNode*)pCol)->colName);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addProjToProjColPos(pCxt, pSchema, pProj, pProjColPos);
|
code = addProjToProjColPos(pCxt, pSchema, pProj, pProjColPos);
|
||||||
|
@ -8091,41 +8206,56 @@ static int32_t adjustOrderOfProjections(STranslateContext* pCxt, SNodeList* pCol
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) {
|
if (PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) {
|
||||||
|
hasTsKey = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pSchema->flags & COL_IS_KEY) {
|
||||||
hasPrimaryKey = true;
|
hasPrimaryKey = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && !hasPrimaryKey) {
|
if (TSDB_CODE_SUCCESS == code && !hasTsKey) {
|
||||||
code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM,
|
code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM,
|
||||||
"primary timestamp column can not be null");
|
"Primary timestamp column of dest table can not be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code && !hasPrimaryKey && hasPkInTable(pMeta)) {
|
||||||
|
code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM,
|
||||||
|
"Primary key column of dest table can not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
SNodeList* pNewProjections = NULL;
|
SNodeList* pNewProjections = NULL;
|
||||||
|
SNodeList* pNewCols = NULL;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
taosArraySort(pProjColPos, projColPosCompar);
|
taosArraySort(pProjColPos, projColPosCompar);
|
||||||
int32_t num = taosArrayGetSize(pProjColPos);
|
int32_t num = taosArrayGetSize(pProjColPos);
|
||||||
pNewProjections = nodesMakeList();
|
pNewProjections = nodesMakeList();
|
||||||
|
pNewCols = nodesMakeList();
|
||||||
if (NULL == pNewProjections) {
|
if (NULL == pNewProjections) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
for (int32_t i = 0; TSDB_CODE_SUCCESS == code && i < num; ++i) {
|
for (int32_t i = 0; TSDB_CODE_SUCCESS == code && i < num; ++i) {
|
||||||
SProjColPos* pPos = taosArrayGet(pProjColPos, i);
|
SProjColPos* pPos = taosArrayGet(pProjColPos, i);
|
||||||
code = nodesListStrictAppend(pNewProjections, pPos->pProj);
|
code = nodesListStrictAppend(pNewProjections, pPos->pProj);
|
||||||
|
addColDefNodeByProj(&pNewCols, pPos->pProj, pPos->flags);
|
||||||
pPos->pProj = NULL;
|
pPos->pProj = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && pMeta->tableInfo.numOfColumns > LIST_LENGTH(pCols)) {
|
if (TSDB_CODE_SUCCESS == code && pMeta->tableInfo.numOfColumns > LIST_LENGTH((*ppCols)) ) {
|
||||||
code = setFillNullCols(pProjColPos, pMeta, pReq);
|
code = setFillNullCols(pProjColPos, pMeta, pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
taosArrayDestroy(pProjColPos);
|
taosArrayDestroy(pProjColPos);
|
||||||
nodesDestroyList(*pProjections);
|
nodesDestroyList(*pProjections);
|
||||||
|
nodesDestroyList(*ppCols);
|
||||||
*pProjections = pNewProjections;
|
*pProjections = pNewProjections;
|
||||||
|
*ppCols = pNewCols;
|
||||||
} else {
|
} else {
|
||||||
taosArrayDestroyEx(pProjColPos, projColPosDelete);
|
taosArrayDestroyEx(pProjColPos, projColPosDelete);
|
||||||
nodesDestroyList(pNewProjections);
|
nodesDestroyList(pNewProjections);
|
||||||
|
nodesDestroyList(pNewCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -8135,9 +8265,9 @@ static int32_t adjustProjectionsForExistTable(STranslateContext* pCxt, SCreateSt
|
||||||
const STableMeta* pMeta, SCMCreateStreamReq* pReq) {
|
const STableMeta* pMeta, SCMCreateStreamReq* pReq) {
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
||||||
if (NULL == pStmt->pCols) {
|
if (NULL == pStmt->pCols) {
|
||||||
return adjustDataTypeOfProjections(pCxt, pMeta, pSelect->pProjectionList);
|
return adjustDataTypeOfProjections(pCxt, pMeta, pSelect->pProjectionList, &pStmt->pCols);
|
||||||
}
|
}
|
||||||
return adjustOrderOfProjections(pCxt, pStmt->pCols, pMeta, &pSelect->pProjectionList, pReq);
|
return adjustOrderOfProjections(pCxt, &pStmt->pCols, pMeta, &pSelect->pProjectionList, pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isGroupIdTagStream(const STableMeta* pMeta, SNodeList* pTags) {
|
static bool isGroupIdTagStream(const STableMeta* pMeta, SNodeList* pTags) {
|
||||||
|
@ -8187,9 +8317,9 @@ static int32_t adjustOrderOfTags(STranslateContext* pCxt, SNodeList* pTags, cons
|
||||||
SNode* pTag = NULL;
|
SNode* pTag = NULL;
|
||||||
SNode* pTagExpr = NULL;
|
SNode* pTagExpr = NULL;
|
||||||
FORBOTH(pTag, pTags, pTagExpr, *pTagExprs) {
|
FORBOTH(pTag, pTags, pTagExpr, *pTagExprs) {
|
||||||
const SSchema* pSchema = getTagSchema(pMeta, ((SColumnNode*)pTag)->colName);
|
const SSchema* pSchema = getTagSchema(pMeta, ((SColumnDefNode*)pTag)->colName);
|
||||||
if (NULL == pSchema) {
|
if (NULL == pSchema) {
|
||||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, ((SColumnNode*)pTag)->colName);
|
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, ((SColumnDefNode*)pTag)->colName);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addProjToProjColPos(pCxt, pSchema, pTagExpr, pTagPos);
|
code = addProjToProjColPos(pCxt, pSchema, pTagExpr, pTagPos);
|
||||||
|
@ -8286,21 +8416,23 @@ static bool isTagDef(SNodeList* pTags) {
|
||||||
if (NULL == pTags) {
|
if (NULL == pTags) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return QUERY_NODE_COLUMN_DEF == nodeType(nodesListGetNode(pTags, 0));
|
SColumnDefNode* pColDef = (SColumnDefNode*)nodesListGetNode(pTags, 0);
|
||||||
|
return TSDB_DATA_TYPE_NULL != pColDef->dataType.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isTagBound(SNodeList* pTags) {
|
static bool isTagBound(SNodeList* pTags) {
|
||||||
if (NULL == pTags) {
|
if (NULL == pTags) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return QUERY_NODE_COLUMN == nodeType(nodesListGetNode(pTags, 0));
|
SColumnDefNode* pColDef = (SColumnDefNode*)nodesListGetNode(pTags, 0);
|
||||||
|
return TSDB_DATA_TYPE_NULL == pColDef->dataType.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateStreamTargetTable(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq,
|
static int32_t translateStreamTargetTable(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq,
|
||||||
STableMeta** pMeta) {
|
STableMeta** pMeta) {
|
||||||
int32_t code = getTableMeta(pCxt, pStmt->targetDbName, pStmt->targetTabName, pMeta);
|
int32_t code = getTableMeta(pCxt, pStmt->targetDbName, pStmt->targetTabName, pMeta);
|
||||||
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
|
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
|
||||||
if (NULL != pStmt->pCols || isTagBound(pStmt->pTags)) {
|
if (isTagBound(pStmt->pTags)) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, pStmt->targetTabName);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, pStmt->targetTabName);
|
||||||
}
|
}
|
||||||
pReq->createStb = STREAM_CREATE_STABLE_TRUE;
|
pReq->createStb = STREAM_CREATE_STABLE_TRUE;
|
||||||
|
@ -8441,6 +8573,42 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
|
||||||
return nodesListAppend((*pSelect1)->pGroupByList, (SNode*)pNode2);
|
return nodesListAppend((*pSelect1)->pGroupByList, (SNode*)pNode2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkAndAdjStreamDestTableSchema(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) {
|
||||||
|
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
||||||
|
SNode* pNode = nodesListGetNode(pStmt->pCols, 0);
|
||||||
|
SColumnDefNode* pCol = (SColumnDefNode*)pNode;
|
||||||
|
if (pCol && pCol->dataType.type != TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
|
pCol->dataType = (SDataType){.type = TSDB_DATA_TYPE_TIMESTAMP,
|
||||||
|
.precision = 0,
|
||||||
|
.scale = 0,
|
||||||
|
.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes};
|
||||||
|
}
|
||||||
|
int32_t code = checkTableSchemaImpl(pCxt, pStmt->pTags, pStmt->pCols, NULL);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL == pSelect->pWindow &&
|
||||||
|
((SRealTableNode*)pSelect->pFromTable && hasPkInTable(((SRealTableNode*)pSelect->pFromTable)->pMeta))) {
|
||||||
|
if (1 >= LIST_LENGTH(pStmt->pCols) || 1 >= LIST_LENGTH(pSelect->pProjectionList)) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY);
|
||||||
|
}
|
||||||
|
|
||||||
|
SNode* pProj = nodesListGetNode(pSelect->pProjectionList, 1);
|
||||||
|
if (QUERY_NODE_COLUMN != nodeType(pProj) ||
|
||||||
|
0 != strcmp(((SColumnNode*)pProj)->colName, ((SRealTableNode*)pSelect->pFromTable)->pMeta->schema[1].name)) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
|
"Source table has primary key, result must has primary key");
|
||||||
|
}
|
||||||
|
|
||||||
|
pNode = nodesListGetNode(pStmt->pCols, 1);
|
||||||
|
pCol = (SColumnDefNode*)pNode;
|
||||||
|
if (STREAM_CREATE_STABLE_TRUE == pReq->createStb) {
|
||||||
|
pCol->is_pk = true;
|
||||||
|
}
|
||||||
|
if (!pCol->is_pk) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Source table has primary key, dest table must has primary key");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) {
|
static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) {
|
||||||
pCxt->createStream = true;
|
pCxt->createStream = true;
|
||||||
STableMeta* pMeta = NULL;
|
STableMeta* pMeta = NULL;
|
||||||
|
@ -8452,7 +8620,10 @@ static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt
|
||||||
code = translateQuery(pCxt, pStmt->pQuery);
|
code = translateQuery(pCxt, pStmt->pQuery);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addWstartTsToCreateStreamQuery(pCxt, pStmt->pQuery);
|
code = addColsToCreateStreamQuery(pCxt, pStmt, pReq);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = addWstartTsToCreateStreamQuery(pCxt, pStmt->pQuery, pStmt->pCols, pReq);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkStreamQuery(pCxt, pStmt);
|
code = checkStreamQuery(pCxt, pStmt);
|
||||||
|
@ -8463,6 +8634,9 @@ static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = adjustTags(pCxt, pStmt, pMeta, pReq);
|
code = adjustTags(pCxt, pStmt, pMeta, pReq);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = checkAndAdjStreamDestTableSchema(pCxt, pStmt, pReq);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
getSourceDatabase(pStmt->pQuery, pCxt->pParseCxt->acctId, pReq->sourceDB);
|
getSourceDatabase(pStmt->pQuery, pCxt->pParseCxt->acctId, pReq->sourceDB);
|
||||||
code = nodesNodeToString(pStmt->pQuery, false, &pReq->ast, NULL);
|
code = nodesNodeToString(pStmt->pQuery, false, &pReq->ast, NULL);
|
||||||
|
@ -8528,9 +8702,10 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
|
||||||
pReq->fillHistory = pStmt->pOptions->fillHistory;
|
pReq->fillHistory = pStmt->pOptions->fillHistory;
|
||||||
pReq->igExpired = pStmt->pOptions->ignoreExpired;
|
pReq->igExpired = pStmt->pOptions->ignoreExpired;
|
||||||
if (pReq->createStb) {
|
if (pReq->createStb) {
|
||||||
columnDefNodeToField(pStmt->pTags, &pReq->pTags);
|
columnDefNodeToField(pStmt->pTags, &pReq->pTags, true);
|
||||||
pReq->numOfTags = LIST_LENGTH(pStmt->pTags);
|
pReq->numOfTags = LIST_LENGTH(pStmt->pTags);
|
||||||
}
|
}
|
||||||
|
columnDefNodeToField(pStmt->pCols, &pReq->pCols, false);
|
||||||
pReq->igUpdate = pStmt->pOptions->ignoreUpdate;
|
pReq->igUpdate = pStmt->pOptions->ignoreUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -522,6 +522,9 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
} else if (pSelect->pPartitionByList) {
|
} else if (pSelect->pPartitionByList) {
|
||||||
isCountByTag = !keysHasCol(pSelect->pPartitionByList);
|
isCountByTag = !keysHasCol(pSelect->pPartitionByList);
|
||||||
}
|
}
|
||||||
|
if (pScan->tableType == TSDB_CHILD_TABLE) {
|
||||||
|
isCountByTag = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pScan->isCountByTag = isCountByTag;
|
pScan->isCountByTag = isCountByTag;
|
||||||
|
|
||||||
|
|
|
@ -2997,6 +2997,15 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic
|
||||||
if (FUNCTION_TYPE_LAST == funcType) {
|
if (FUNCTION_TYPE_LAST == funcType) {
|
||||||
nodesWalkExpr(nodesListGetNode(pFunc->pParameterList, 0), lastRowScanOptSetColDataType, &cxt);
|
nodesWalkExpr(nodesListGetNode(pFunc->pParameterList, 0), lastRowScanOptSetColDataType, &cxt);
|
||||||
nodesListErase(pFunc->pParameterList, nodesListGetCell(pFunc->pParameterList, 1));
|
nodesListErase(pFunc->pParameterList, nodesListGetCell(pFunc->pParameterList, 1));
|
||||||
|
if (pFunc->hasPk) {
|
||||||
|
if (LIST_LENGTH(pFunc->pParameterList) != 2) {
|
||||||
|
planError("last func which has pk but its parameter list length is not %d", 2);
|
||||||
|
nodesClearList(cxt.pLastCols);
|
||||||
|
taosArrayDestroy(isDuplicateCol);
|
||||||
|
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
nodesWalkExpr(nodesListGetNode(pFunc->pParameterList, 1), lastRowScanOptSetColDataType, &cxt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pNode = nodesListGetNode(pFunc->pParameterList, 0);
|
pNode = nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
|
|
|
@ -1573,6 +1573,9 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList*
|
||||||
pWindow->watermark = pWindowLogicNode->watermark;
|
pWindow->watermark = pWindowLogicNode->watermark;
|
||||||
pWindow->deleteMark = pWindowLogicNode->deleteMark;
|
pWindow->deleteMark = pWindowLogicNode->deleteMark;
|
||||||
pWindow->igExpired = pWindowLogicNode->igExpired;
|
pWindow->igExpired = pWindowLogicNode->igExpired;
|
||||||
|
if (pCxt->pPlanCxt->streamQuery) {
|
||||||
|
pWindow->destHasPrimayKey = pCxt->pPlanCxt->destHasPrimaryKey;
|
||||||
|
}
|
||||||
pWindow->mergeDataBlock = (GROUP_ACTION_KEEP == pWindowLogicNode->node.groupAction ? false : true);
|
pWindow->mergeDataBlock = (GROUP_ACTION_KEEP == pWindowLogicNode->node.groupAction ? false : true);
|
||||||
pWindow->node.inputTsOrder = pWindowLogicNode->node.inputTsOrder;
|
pWindow->node.inputTsOrder = pWindowLogicNode->node.inputTsOrder;
|
||||||
pWindow->node.outputTsOrder = pWindowLogicNode->node.outputTsOrder;
|
pWindow->node.outputTsOrder = pWindowLogicNode->node.outputTsOrder;
|
||||||
|
|
|
@ -486,6 +486,7 @@ int32_t schHandleNotifyCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
||||||
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " task notify rsp received, code:0x%x", pParam->queryId, pParam->taskId,
|
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " task notify rsp received, code:0x%x", pParam->queryId, pParam->taskId,
|
||||||
code);
|
code);
|
||||||
|
rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT);
|
||||||
if (pMsg) {
|
if (pMsg) {
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
taosMemoryFree(pMsg->pEpSet);
|
taosMemoryFree(pMsg->pEpSet);
|
||||||
|
@ -526,6 +527,7 @@ int32_t schHandleHbCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
qError("hb rsp error:%s", tstrerror(code));
|
qError("hb rsp error:%s", tstrerror(code));
|
||||||
|
rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT);
|
||||||
SCH_ERR_JRET(code);
|
SCH_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1181,7 +1183,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
qMsg.queryId = pJob->queryId;
|
qMsg.queryId = pJob->queryId;
|
||||||
qMsg.taskId = pTask->taskId;
|
qMsg.taskId = pTask->taskId;
|
||||||
qMsg.refId = pJob->refId;
|
qMsg.refId = pJob->refId;
|
||||||
qMsg.execId = pTask->execId;
|
qMsg.execId = *(int32_t*)param;
|
||||||
|
|
||||||
msgSize = tSerializeSTaskDropReq(NULL, 0, &qMsg);
|
msgSize = tSerializeSTaskDropReq(NULL, 0, &qMsg);
|
||||||
if (msgSize < 0) {
|
if (msgSize < 0) {
|
||||||
|
|
|
@ -371,14 +371,13 @@ int32_t schChkUpdateRedirectCtx(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet,
|
||||||
pCtx->roundTotal = pEpSet->numOfEps;
|
pCtx->roundTotal = pEpSet->numOfEps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (pCtx->roundTimes >= pCtx->roundTotal) {
|
if (pCtx->roundTimes >= pCtx->roundTotal) {
|
||||||
int64_t nowTs = taosGetTimestampMs();
|
int64_t nowTs = taosGetTimestampMs();
|
||||||
int64_t lastTime = nowTs - pCtx->startTs;
|
int64_t lastTime = nowTs - pCtx->startTs;
|
||||||
if (lastTime > tsMaxRetryWaitTime) {
|
if (lastTime > tsMaxRetryWaitTime) {
|
||||||
SCH_TASK_DLOG("task no more redirect retry since timeout, now:%" PRId64 ", start:%" PRId64 ", max:%d, total:%d",
|
SCH_TASK_DLOG("task no more redirect retry since timeout, now:%" PRId64 ", start:%" PRId64 ", max:%d, total:%d",
|
||||||
nowTs, pCtx->startTs, tsMaxRetryWaitTime, pCtx->totalTimes);
|
nowTs, pCtx->startTs, tsMaxRetryWaitTime, pCtx->totalTimes);
|
||||||
pJob->noMoreRetry = true;
|
pJob->noMoreRetry = true;
|
||||||
SCH_ERR_RET(SCH_GET_REDIRECT_CODE(pJob, rspCode));
|
SCH_ERR_RET(SCH_GET_REDIRECT_CODE(pJob, rspCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +417,7 @@ void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask) {
|
||||||
taosMemoryFreeClear(pTask->msg);
|
taosMemoryFreeClear(pTask->msg);
|
||||||
pTask->msgLen = 0;
|
pTask->msgLen = 0;
|
||||||
pTask->lastMsgType = 0;
|
pTask->lastMsgType = 0;
|
||||||
pTask->childReady = 0;
|
pTask->childReady = 0;
|
||||||
memset(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr));
|
memset(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,11 +504,11 @@ int32_t schHandleTaskSetRetry(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, i
|
||||||
pLevel->taskExecDoneNum = 0;
|
pLevel->taskExecDoneNum = 0;
|
||||||
pLevel->taskLaunchedNum = 0;
|
pLevel->taskLaunchedNum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_RESET_JOB_LEVEL_IDX(pJob);
|
SCH_RESET_JOB_LEVEL_IDX(pJob);
|
||||||
|
|
||||||
code = schDoTaskRedirect(pJob, pTask, pData, rspCode);
|
code = schDoTaskRedirect(pJob, pTask, pData, rspCode);
|
||||||
|
|
||||||
taosMemoryFreeClear(pData->pData);
|
taosMemoryFreeClear(pData->pData);
|
||||||
taosMemoryFreeClear(pData->pEpSet);
|
taosMemoryFreeClear(pData->pEpSet);
|
||||||
|
|
||||||
|
@ -627,7 +626,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
||||||
pTask->maxRetryTimes);
|
pTask->maxRetryTimes);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SCH_TIMEOUT_ERROR == errCode) {
|
if (TSDB_CODE_SCH_TIMEOUT_ERROR == errCode) {
|
||||||
pTask->maxExecTimes++;
|
pTask->maxExecTimes++;
|
||||||
pTask->maxRetryTimes++;
|
pTask->maxRetryTimes++;
|
||||||
|
@ -862,7 +861,9 @@ void schDropTaskOnExecNode(SSchJob *pJob, SSchTask *pTask) {
|
||||||
while (nodeInfo) {
|
while (nodeInfo) {
|
||||||
if (nodeInfo->handle) {
|
if (nodeInfo->handle) {
|
||||||
SCH_SET_TASK_HANDLE(pTask, nodeInfo->handle);
|
SCH_SET_TASK_HANDLE(pTask, nodeInfo->handle);
|
||||||
schBuildAndSendMsg(pJob, pTask, &nodeInfo->addr, TDMT_SCH_DROP_TASK, NULL);
|
void *pExecId = taosHashGetKey(nodeInfo, NULL);
|
||||||
|
schBuildAndSendMsg(pJob, pTask, &nodeInfo->addr, TDMT_SCH_DROP_TASK, pExecId);
|
||||||
|
|
||||||
SCH_TASK_DLOG("start to drop task's %dth execNode", i);
|
SCH_TASK_DLOG("start to drop task's %dth execNode", i);
|
||||||
} else {
|
} else {
|
||||||
SCH_TASK_DLOG("no need to drop task %dth execNode", i);
|
SCH_TASK_DLOG("no need to drop task %dth execNode", i);
|
||||||
|
@ -901,7 +902,6 @@ int32_t schNotifyTaskOnExecNode(SSchJob *pJob, SSchTask *pTask, ETaskNotifyType
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId *pEpId, SArray *pStatusList) {
|
int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId *pEpId, SArray *pStatusList) {
|
||||||
int32_t taskNum = (int32_t)taosArrayGetSize(pStatusList);
|
int32_t taskNum = (int32_t)taosArrayGetSize(pStatusList);
|
||||||
SSchTask *pTask = NULL;
|
SSchTask *pTask = NULL;
|
||||||
|
@ -1269,7 +1269,7 @@ int32_t schNotifyTaskInHashList(SSchJob *pJob, SHashObj *list, ETaskNotifyType t
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
SCH_ERR_RET(schNotifyTaskOnExecNode(pJob, pCurrTask, type));
|
SCH_ERR_RET(schNotifyTaskOnExecNode(pJob, pCurrTask, type));
|
||||||
|
|
||||||
void *pIter = taosHashIterate(list, NULL);
|
void *pIter = taosHashIterate(list, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SSchTask *pTask = *(SSchTask **)pIter;
|
SSchTask *pTask = *(SSchTask **)pIter;
|
||||||
|
@ -1277,7 +1277,7 @@ int32_t schNotifyTaskInHashList(SSchJob *pJob, SHashObj *list, ETaskNotifyType t
|
||||||
SCH_LOCK_TASK(pTask);
|
SCH_LOCK_TASK(pTask);
|
||||||
code = schNotifyTaskOnExecNode(pJob, pTask, type);
|
code = schNotifyTaskOnExecNode(pJob, pTask, type);
|
||||||
SCH_UNLOCK_TASK(pTask);
|
SCH_UNLOCK_TASK(pTask);
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1289,7 +1289,6 @@ int32_t schNotifyTaskInHashList(SSchJob *pJob, SHashObj *list, ETaskNotifyType t
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t schExecRemoteFetch(SSchJob *pJob, SSchTask *pTask) {
|
int32_t schExecRemoteFetch(SSchJob *pJob, SSchTask *pTask) {
|
||||||
SCH_RET(schBuildAndSendMsg(pJob, pJob->fetchTask, &pJob->resNode, SCH_FETCH_TYPE(pJob->fetchTask), NULL));
|
SCH_RET(schBuildAndSendMsg(pJob, pJob->fetchTask, &pJob->resNode, SCH_FETCH_TYPE(pJob->fetchTask), NULL));
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,6 +321,8 @@ void clearBufferedDispatchMsg(SStreamTask* pTask) {
|
||||||
destroyDispatchMsg(pMsgInfo->pData, getNumOfDispatchBranch(pTask));
|
destroyDispatchMsg(pMsgInfo->pData, getNumOfDispatchBranch(pTask));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pMsgInfo->checkpointId = -1;
|
||||||
|
pMsgInfo->transId = -1;
|
||||||
pMsgInfo->pData = NULL;
|
pMsgInfo->pData = NULL;
|
||||||
pMsgInfo->dispatchMsgType = 0;
|
pMsgInfo->dispatchMsgType = 0;
|
||||||
}
|
}
|
||||||
|
@ -332,6 +334,12 @@ static int32_t doBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* pD
|
||||||
|
|
||||||
pTask->msgInfo.dispatchMsgType = pData->type;
|
pTask->msgInfo.dispatchMsgType = pData->type;
|
||||||
|
|
||||||
|
if (pData->type == STREAM_INPUT__CHECKPOINT_TRIGGER) {
|
||||||
|
SSDataBlock* p = taosArrayGet(pData->blocks, 0);
|
||||||
|
pTask->msgInfo.checkpointId = p->info.version;
|
||||||
|
pTask->msgInfo.transId = p->info.window.ekey;
|
||||||
|
}
|
||||||
|
|
||||||
if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
|
if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
|
||||||
SStreamDispatchReq* pReq = taosMemoryCalloc(1, sizeof(SStreamDispatchReq));
|
SStreamDispatchReq* pReq = taosMemoryCalloc(1, sizeof(SStreamDispatchReq));
|
||||||
|
|
||||||
|
@ -950,9 +958,21 @@ void streamClearChkptReadyMsg(SStreamTask* pTask) {
|
||||||
// this message has been sent successfully, let's try next one.
|
// this message has been sent successfully, let's try next one.
|
||||||
static int32_t handleDispatchSuccessRsp(SStreamTask* pTask, int32_t downstreamId) {
|
static int32_t handleDispatchSuccessRsp(SStreamTask* pTask, int32_t downstreamId) {
|
||||||
stDebug("s-task:%s destroy dispatch msg:%p", pTask->id.idStr, pTask->msgInfo.pData);
|
stDebug("s-task:%s destroy dispatch msg:%p", pTask->id.idStr, pTask->msgInfo.pData);
|
||||||
|
|
||||||
bool delayDispatch = (pTask->msgInfo.dispatchMsgType == STREAM_INPUT__CHECKPOINT_TRIGGER);
|
bool delayDispatch = (pTask->msgInfo.dispatchMsgType == STREAM_INPUT__CHECKPOINT_TRIGGER);
|
||||||
if (delayDispatch) {
|
if (delayDispatch) {
|
||||||
pTask->chkInfo.dispatchCheckpointTrigger = true;
|
taosThreadMutexLock(&pTask->lock);
|
||||||
|
// we only set the dispatch msg info for current checkpoint trans
|
||||||
|
if (streamTaskGetStatus(pTask)->state == TASK_STATUS__CK && pTask->chkInfo.checkpointingId == pTask->msgInfo.checkpointId) {
|
||||||
|
ASSERT(pTask->chkInfo.transId == pTask->msgInfo.transId);
|
||||||
|
pTask->chkInfo.dispatchCheckpointTrigger = true;
|
||||||
|
stDebug("s-task:%s checkpoint-trigger msg rsp for checkpointId:%" PRId64 " transId:%d confirmed",
|
||||||
|
pTask->id.idStr, pTask->msgInfo.checkpointId, pTask->msgInfo.transId);
|
||||||
|
} else {
|
||||||
|
stWarn("s-task:%s checkpoint-trigger msg rsp for checkpointId:%" PRId64 " transId:%d discard, since expired",
|
||||||
|
pTask->id.idStr, pTask->msgInfo.checkpointId, pTask->msgInfo.transId);
|
||||||
|
}
|
||||||
|
taosThreadMutexUnlock(&pTask->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearBufferedDispatchMsg(pTask);
|
clearBufferedDispatchMsg(pTask);
|
||||||
|
|
|
@ -119,7 +119,11 @@ int32_t streamReExecScanHistoryFuture(SStreamTask* pTask, int32_t idleDuration)
|
||||||
|
|
||||||
// add ref for task
|
// add ref for task
|
||||||
SStreamTask* p = streamMetaAcquireTask(pTask->pMeta, pTask->id.streamId, pTask->id.taskId);
|
SStreamTask* p = streamMetaAcquireTask(pTask->pMeta, pTask->id.streamId, pTask->id.taskId);
|
||||||
ASSERT(p != NULL);
|
if (p == NULL) {
|
||||||
|
stError("s-task:0x%x failed to acquire task, status:%s, not exec scan-history data", pTask->id.taskId,
|
||||||
|
streamTaskGetStatus(pTask)->name);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
pTask->schedHistoryInfo.numOfTicks = numOfTicks;
|
pTask->schedHistoryInfo.numOfTicks = numOfTicks;
|
||||||
|
|
||||||
|
|
|
@ -278,11 +278,11 @@ int32_t streamStateFuncPut(SStreamState* pState, const SWinKey* key, const void*
|
||||||
#ifdef USE_ROCKSDB
|
#ifdef USE_ROCKSDB
|
||||||
void* pVal = NULL;
|
void* pVal = NULL;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t code = getRowBuff(pState->pFileState, (void*)key, sizeof(SWinKey), &pVal, &len);
|
getRowBuff(pState->pFileState, (void*)key, sizeof(SWinKey), &pVal, &len);
|
||||||
char* buf = ((SRowBuffPos*)pVal)->pRowBuff;
|
char* buf = ((SRowBuffPos*)pVal)->pRowBuff;
|
||||||
uint32_t rowSize = streamFileStateGeSelectRowSize(pState->pFileState);
|
uint32_t rowSize = streamFileStateGeSelectRowSize(pState->pFileState);
|
||||||
memcpy(buf + len - rowSize, value, vLen);
|
memcpy(buf + len - rowSize, value, vLen);
|
||||||
return code;
|
return TSDB_CODE_SUCCESS;
|
||||||
#else
|
#else
|
||||||
return tdbTbUpsert(pState->pTdbState->pFuncStateDb, key, sizeof(STupleKey), value, vLen, pState->pTdbState->txn);
|
return tdbTbUpsert(pState->pTdbState->pFuncStateDb, key, sizeof(STupleKey), value, vLen, pState->pTdbState->txn);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -380,12 +380,12 @@ void tFreeStreamTask(SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTask->hTaskInfo.pTimer != NULL) {
|
if (pTask->hTaskInfo.pTimer != NULL) {
|
||||||
taosTmrStop(pTask->hTaskInfo.pTimer);
|
/*bool ret = */taosTmrStop(pTask->hTaskInfo.pTimer);
|
||||||
pTask->hTaskInfo.pTimer = NULL;
|
pTask->hTaskInfo.pTimer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTask->msgInfo.pTimer != NULL) {
|
if (pTask->msgInfo.pTimer != NULL) {
|
||||||
taosTmrStop(pTask->msgInfo.pTimer);
|
/*bool ret = */taosTmrStop(pTask->msgInfo.pTimer);
|
||||||
pTask->msgInfo.pTimer = NULL;
|
pTask->msgInfo.pTimer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -543,8 +543,6 @@ void streamTaskSetStatusReady(SStreamTask* pTask) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadMutexLock(&pTask->lock);
|
|
||||||
|
|
||||||
pSM->prev.state = pSM->current;
|
pSM->prev.state = pSM->current;
|
||||||
pSM->prev.evt = 0;
|
pSM->prev.evt = 0;
|
||||||
|
|
||||||
|
@ -552,8 +550,6 @@ void streamTaskSetStatusReady(SStreamTask* pTask) {
|
||||||
pSM->startTs = taosGetTimestampMs();
|
pSM->startTs = taosGetTimestampMs();
|
||||||
pSM->pActiveTrans = NULL;
|
pSM->pActiveTrans = NULL;
|
||||||
taosArrayClear(pSM->pWaitingEventList);
|
taosArrayClear(pSM->pWaitingEventList);
|
||||||
|
|
||||||
taosThreadMutexUnlock(&pTask->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STaskStateTrans createStateTransform(ETaskStatus current, ETaskStatus next, EStreamTaskEvent event, __state_trans_fn fn,
|
STaskStateTrans createStateTransform(ETaskStatus current, ETaskStatus next, EStreamTaskEvent event, __state_trans_fn fn,
|
||||||
|
|
|
@ -438,6 +438,7 @@ SRowBuffPos* getNewRowPosForWrite(SStreamFileState* pFileState) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal, int32_t* pVLen) {
|
int32_t getRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal, int32_t* pVLen) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
pFileState->maxTs = TMAX(pFileState->maxTs, pFileState->getTs(pKey));
|
pFileState->maxTs = TMAX(pFileState->maxTs, pFileState->getTs(pKey));
|
||||||
SRowBuffPos** pos = tSimpleHashGet(pFileState->rowStateBuff, pKey, keyLen);
|
SRowBuffPos** pos = tSimpleHashGet(pFileState->rowStateBuff, pKey, keyLen);
|
||||||
if (pos) {
|
if (pos) {
|
||||||
|
@ -445,17 +446,18 @@ int32_t getRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, voi
|
||||||
*pVal = *pos;
|
*pVal = *pos;
|
||||||
(*pos)->beUsed = true;
|
(*pos)->beUsed = true;
|
||||||
(*pos)->beFlushed = false;
|
(*pos)->beFlushed = false;
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
SRowBuffPos* pNewPos = getNewRowPosForWrite(pFileState);
|
SRowBuffPos* pNewPos = getNewRowPosForWrite(pFileState);
|
||||||
ASSERT(pNewPos->pRowBuff);
|
ASSERT(pNewPos->pRowBuff);
|
||||||
memcpy(pNewPos->pKey, pKey, keyLen);
|
memcpy(pNewPos->pKey, pKey, keyLen);
|
||||||
|
code = TSDB_CODE_FAILED;
|
||||||
|
|
||||||
TSKEY ts = pFileState->getTs(pKey);
|
TSKEY ts = pFileState->getTs(pKey);
|
||||||
if (!isDeteled(pFileState, ts) && isFlushedState(pFileState, ts, 0)) {
|
if (!isDeteled(pFileState, ts) && isFlushedState(pFileState, ts, 0)) {
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
void* p = NULL;
|
void* p = NULL;
|
||||||
int32_t code = streamStateGet_rocksdb(pFileState->pFileStore, pKey, &p, &len);
|
code = streamStateGet_rocksdb(pFileState->pFileStore, pKey, &p, &len);
|
||||||
qDebug("===stream===get %" PRId64 " from disc, res %d", ts, code);
|
qDebug("===stream===get %" PRId64 " from disc, res %d", ts, code);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
memcpy(pNewPos->pRowBuff, p, len);
|
memcpy(pNewPos->pRowBuff, p, len);
|
||||||
|
@ -468,7 +470,7 @@ int32_t getRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, voi
|
||||||
*pVLen = pFileState->rowSize;
|
*pVLen = pFileState->rowSize;
|
||||||
*pVal = pNewPos;
|
*pVal = pNewPos;
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t deleteRowBuff(SStreamFileState* pFileState, const void* pKey, int32_t keyLen) {
|
int32_t deleteRowBuff(SStreamFileState* pFileState, const void* pKey, int32_t keyLen) {
|
||||||
|
|
|
@ -276,16 +276,18 @@ int32_t syncForceBecomeFollower(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
||||||
|
|
||||||
int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) {
|
int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) {
|
||||||
int32_t ret = -1;
|
int32_t ret = -1;
|
||||||
|
int32_t errcode = TSDB_CODE_MND_ARB_TOKEN_MISMATCH;
|
||||||
|
void* pHead = NULL;
|
||||||
|
int32_t contLen = 0;
|
||||||
|
|
||||||
SVArbSetAssignedLeaderReq req = {0};
|
SVArbSetAssignedLeaderReq req = {0};
|
||||||
if (tDeserializeSVArbSetAssignedLeaderReq((char*)pRpcMsg->pCont + sizeof(SMsgHead), pRpcMsg->contLen, &req) != 0) {
|
if (tDeserializeSVArbSetAssignedLeaderReq((char*)pRpcMsg->pCont + sizeof(SMsgHead), pRpcMsg->contLen, &req) != 0) {
|
||||||
sError("vgId:%d, failed to deserialize SVArbSetAssignedLeaderReq", ths->vgId);
|
sError("vgId:%d, failed to deserialize SVArbSetAssignedLeaderReq", ths->vgId);
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
errcode = terrno;
|
||||||
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t errcode = TSDB_CODE_MND_ARB_TOKEN_MISMATCH;
|
|
||||||
|
|
||||||
if (ths->arbTerm > req.arbTerm) {
|
if (ths->arbTerm > req.arbTerm) {
|
||||||
sInfo("vgId:%d, skip to set assigned leader, msg with lower term, local:%" PRId64 "msg:%" PRId64, ths->vgId,
|
sInfo("vgId:%d, skip to set assigned leader, msg with lower term, local:%" PRId64 "msg:%" PRId64, ths->vgId,
|
||||||
ths->arbTerm, req.arbTerm);
|
ths->arbTerm, req.arbTerm);
|
||||||
|
@ -294,50 +296,58 @@ int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) {
|
||||||
|
|
||||||
ths->arbTerm = TMAX(req.arbTerm, ths->arbTerm);
|
ths->arbTerm = TMAX(req.arbTerm, ths->arbTerm);
|
||||||
|
|
||||||
if (strncmp(req.memberToken, ths->arbToken, TSDB_ARB_TOKEN_SIZE) == 0) {
|
if (strncmp(req.memberToken, ths->arbToken, TSDB_ARB_TOKEN_SIZE) != 0) {
|
||||||
if (ths->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) {
|
|
||||||
raftStoreNextTerm(ths);
|
|
||||||
if (terrno != TSDB_CODE_SUCCESS) {
|
|
||||||
sError("vgId:%d, failed to set next term since:%s", ths->vgId, terrstr());
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
syncNodeBecomeAssignedLeader(ths);
|
|
||||||
|
|
||||||
if (syncNodeAppendNoop(ths) < 0) {
|
|
||||||
sError("vgId:%d, assigned leader failed to append noop entry since %s", ths->vgId, terrstr());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
errcode = TSDB_CODE_SUCCESS;
|
|
||||||
} else {
|
|
||||||
sInfo("vgId:%d, skip to set assigned leader, token mismatch, local:%s, msg:%s", ths->vgId, ths->arbToken,
|
sInfo("vgId:%d, skip to set assigned leader, token mismatch, local:%s, msg:%s", ths->vgId, ths->arbToken,
|
||||||
req.memberToken);
|
req.memberToken);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ths->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) {
|
||||||
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
raftStoreNextTerm(ths);
|
||||||
|
if (terrno != TSDB_CODE_SUCCESS) {
|
||||||
|
sError("vgId:%d, failed to set next term since:%s", ths->vgId, terrstr());
|
||||||
|
errcode = terrno;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
syncNodeBecomeAssignedLeader(ths);
|
||||||
|
|
||||||
|
if (syncNodeAppendNoop(ths) < 0) {
|
||||||
|
sError("vgId:%d, assigned leader failed to append noop entry since %s", ths->vgId, terrstr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SVArbSetAssignedLeaderRsp rsp = {0};
|
SVArbSetAssignedLeaderRsp rsp = {0};
|
||||||
rsp.arbToken = req.arbToken;
|
rsp.arbToken = req.arbToken;
|
||||||
rsp.memberToken = req.memberToken;
|
rsp.memberToken = req.memberToken;
|
||||||
rsp.vgId = ths->vgId;
|
rsp.vgId = ths->vgId;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSVArbSetAssignedLeaderRsp(NULL, 0, &rsp);
|
contLen = tSerializeSVArbSetAssignedLeaderRsp(NULL, 0, &rsp);
|
||||||
if (contLen <= 0) {
|
if (contLen <= 0) {
|
||||||
sError("vgId:%d, failed to serialize SVArbSetAssignedLeaderRsp", ths->vgId);
|
sError("vgId:%d, failed to serialize SVArbSetAssignedLeaderRsp", ths->vgId);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
errcode = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
void* pHead = rpcMallocCont(contLen);
|
pHead = rpcMallocCont(contLen);
|
||||||
if (!pHead) {
|
if (!pHead) {
|
||||||
sError("vgId:%d, failed to malloc memory for SVArbSetAssignedLeaderRsp", ths->vgId);
|
sError("vgId:%d, failed to malloc memory for SVArbSetAssignedLeaderRsp", ths->vgId);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
errcode = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (tSerializeSVArbSetAssignedLeaderRsp(pHead, contLen, &rsp) <= 0) {
|
if (tSerializeSVArbSetAssignedLeaderRsp(pHead, contLen, &rsp) <= 0) {
|
||||||
sError("vgId:%d, failed to serialize SVArbSetAssignedLeaderRsp", ths->vgId);
|
sError("vgId:%d, failed to serialize SVArbSetAssignedLeaderRsp", ths->vgId);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
errcode = terrno;
|
||||||
rpcFreeCont(pHead);
|
rpcFreeCont(pHead);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errcode = TSDB_CODE_SUCCESS;
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
_OVER:;
|
||||||
SRpcMsg rspMsg = {
|
SRpcMsg rspMsg = {
|
||||||
.code = errcode,
|
.code = errcode,
|
||||||
.pCont = pHead,
|
.pCont = pHead,
|
||||||
|
@ -347,9 +357,6 @@ int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) {
|
||||||
|
|
||||||
tmsgSendRsp(&rspMsg);
|
tmsgSendRsp(&rspMsg);
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
_OVER:
|
|
||||||
tFreeSVArbSetAssignedLeaderReq(&req);
|
tFreeSVArbSetAssignedLeaderReq(&req);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,12 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
#include "os.h"
|
|
||||||
#include "taoserror.h"
|
|
||||||
#include "theap.h"
|
#include "theap.h"
|
||||||
#include "tmisce.h"
|
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "transLog.h"
|
#include "transLog.h"
|
||||||
#include "transportInt.h"
|
#include "transportInt.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "ttrace.h"
|
#include "ttrace.h"
|
||||||
#include "tutil.h"
|
|
||||||
|
|
||||||
typedef bool (*FilteFunc)(void* arg);
|
typedef bool (*FilteFunc)(void* arg);
|
||||||
|
|
||||||
|
@ -115,9 +111,12 @@ typedef SRpcConnInfo STransHandleInfo;
|
||||||
|
|
||||||
// ref mgt handle
|
// ref mgt handle
|
||||||
typedef struct SExHandle {
|
typedef struct SExHandle {
|
||||||
void* handle;
|
void* handle;
|
||||||
int64_t refId;
|
int64_t refId;
|
||||||
void* pThrd;
|
void* pThrd;
|
||||||
|
queue q;
|
||||||
|
int8_t inited;
|
||||||
|
SRWLatch latch;
|
||||||
} SExHandle;
|
} SExHandle;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -92,6 +92,7 @@ typedef struct SCliMsg {
|
||||||
int64_t refId;
|
int64_t refId;
|
||||||
uint64_t st;
|
uint64_t st;
|
||||||
int sent; //(0: no send, 1: alread sent)
|
int sent; //(0: no send, 1: alread sent)
|
||||||
|
queue seqq;
|
||||||
} SCliMsg;
|
} SCliMsg;
|
||||||
|
|
||||||
typedef struct SCliThrd {
|
typedef struct SCliThrd {
|
||||||
|
@ -121,11 +122,7 @@ typedef struct SCliThrd {
|
||||||
SHashObj* batchCache;
|
SHashObj* batchCache;
|
||||||
|
|
||||||
SCliMsg* stopMsg;
|
SCliMsg* stopMsg;
|
||||||
|
bool quit;
|
||||||
bool quit;
|
|
||||||
|
|
||||||
int newConnCount;
|
|
||||||
SHashObj* msgCount;
|
|
||||||
} SCliThrd;
|
} SCliThrd;
|
||||||
|
|
||||||
typedef struct SCliObj {
|
typedef struct SCliObj {
|
||||||
|
@ -262,10 +259,8 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
|
||||||
} \
|
} \
|
||||||
if (i == sz) { \
|
if (i == sz) { \
|
||||||
pMsg = NULL; \
|
pMsg = NULL; \
|
||||||
tDebug("msg not found, %" PRIu64 "", ahandle); \
|
|
||||||
} else { \
|
} else { \
|
||||||
pMsg = transQueueRm(&conn->cliMsgs, i); \
|
pMsg = transQueueRm(&conn->cliMsgs, i); \
|
||||||
tDebug("msg found, %" PRIu64 "", ahandle); \
|
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -343,6 +338,34 @@ bool cliMaySendCachedMsg(SCliConn* conn) {
|
||||||
_RETURN:
|
_RETURN:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool cliConnSendSeqMsg(int64_t refId, SCliConn* conn) {
|
||||||
|
if (refId == 0) return false;
|
||||||
|
SExHandle* exh = transAcquireExHandle(transGetRefMgt(), refId);
|
||||||
|
if (exh == NULL) {
|
||||||
|
tDebug("release conn %p, refId: %" PRId64 "", conn, refId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
taosWLockLatch(&exh->latch);
|
||||||
|
if (exh->handle == NULL) exh->handle = conn;
|
||||||
|
exh->inited = 1;
|
||||||
|
if (!QUEUE_IS_EMPTY(&exh->q)) {
|
||||||
|
queue* h = QUEUE_HEAD(&exh->q);
|
||||||
|
QUEUE_REMOVE(h);
|
||||||
|
taosWUnLockLatch(&exh->latch);
|
||||||
|
SCliMsg* t = QUEUE_DATA(h, SCliMsg, seqq);
|
||||||
|
transCtxMerge(&conn->ctx, &t->ctx->appCtx);
|
||||||
|
transQueuePush(&conn->cliMsgs, t);
|
||||||
|
tDebug("pop from conn %p, refId: %" PRId64 "", conn, refId);
|
||||||
|
transReleaseExHandle(transGetRefMgt(), refId);
|
||||||
|
cliSend(conn);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
taosWUnLockLatch(&exh->latch);
|
||||||
|
tDebug("empty conn %p, refId: %" PRId64 "", conn, refId);
|
||||||
|
transReleaseExHandle(transGetRefMgt(), refId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void cliHandleResp(SCliConn* conn) {
|
void cliHandleResp(SCliConn* conn) {
|
||||||
SCliThrd* pThrd = conn->hostThrd;
|
SCliThrd* pThrd = conn->hostThrd;
|
||||||
STrans* pTransInst = pThrd->pTransInst;
|
STrans* pTransInst = pThrd->pTransInst;
|
||||||
|
@ -439,8 +462,14 @@ void cliHandleResp(SCliConn* conn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int64_t refId = (pMsg == NULL ? 0 : (int64_t)(pMsg->msg.info.handle));
|
||||||
|
tDebug("conn %p msg refId: %" PRId64 "", conn, refId);
|
||||||
destroyCmsg(pMsg);
|
destroyCmsg(pMsg);
|
||||||
|
|
||||||
|
if (cliConnSendSeqMsg(refId, conn)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (cliMaySendCachedMsg(conn) == true) {
|
if (cliMaySendCachedMsg(conn) == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -451,6 +480,21 @@ void cliHandleResp(SCliConn* conn) {
|
||||||
|
|
||||||
uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb);
|
uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb);
|
||||||
}
|
}
|
||||||
|
static void cliDestroyMsgInExhandle(int64_t refId) {
|
||||||
|
if (refId == 0) return;
|
||||||
|
SExHandle* exh = transAcquireExHandle(transGetRefMgt(), refId);
|
||||||
|
if (exh) {
|
||||||
|
taosWLockLatch(&exh->latch);
|
||||||
|
while (!QUEUE_IS_EMPTY(&exh->q)) {
|
||||||
|
queue* h = QUEUE_HEAD(&exh->q);
|
||||||
|
QUEUE_REMOVE(h);
|
||||||
|
SCliMsg* t = QUEUE_DATA(h, SCliMsg, seqq);
|
||||||
|
destroyCmsg(t);
|
||||||
|
}
|
||||||
|
taosWUnLockLatch(&exh->latch);
|
||||||
|
transReleaseExHandle(transGetRefMgt(), refId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cliHandleExceptImpl(SCliConn* pConn, int32_t code) {
|
void cliHandleExceptImpl(SCliConn* pConn, int32_t code) {
|
||||||
if (transQueueEmpty(&pConn->cliMsgs)) {
|
if (transQueueEmpty(&pConn->cliMsgs)) {
|
||||||
|
@ -510,6 +554,8 @@ void cliHandleExceptImpl(SCliConn* pConn, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMsg == NULL || (pMsg && pMsg->type != Release)) {
|
if (pMsg == NULL || (pMsg && pMsg->type != Release)) {
|
||||||
|
int64_t refId = (pMsg == NULL ? 0 : (int64_t)(pMsg->msg.info.handle));
|
||||||
|
cliDestroyMsgInExhandle(refId);
|
||||||
if (cliAppCb(pConn, &transMsg, pMsg) != 0) {
|
if (cliAppCb(pConn, &transMsg, pMsg) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -678,7 +724,7 @@ static SCliConn* getConnFromPool2(SCliThrd* pThrd, char* key, SCliMsg** pMsg) {
|
||||||
}
|
}
|
||||||
list->numOfConn++;
|
list->numOfConn++;
|
||||||
}
|
}
|
||||||
tTrace("%s numOfConn: %d, limit: %d", pTransInst->label, list->numOfConn, pTransInst->connLimitNum);
|
tDebug("%s numOfConn: %d, limit: %d, dst:%s", pTransInst->label, list->numOfConn, pTransInst->connLimitNum, key);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,13 +788,13 @@ static void addConnToPool(void* pool, SCliConn* conn) {
|
||||||
QUEUE_PUSH(&conn->list->conns, &conn->q);
|
QUEUE_PUSH(&conn->list->conns, &conn->q);
|
||||||
conn->list->size += 1;
|
conn->list->size += 1;
|
||||||
|
|
||||||
if (conn->list->size >= 20) {
|
if (conn->list->size >= 10) {
|
||||||
STaskArg* arg = taosMemoryCalloc(1, sizeof(STaskArg));
|
STaskArg* arg = taosMemoryCalloc(1, sizeof(STaskArg));
|
||||||
arg->param1 = conn;
|
arg->param1 = conn;
|
||||||
arg->param2 = thrd;
|
arg->param2 = thrd;
|
||||||
|
|
||||||
STrans* pTransInst = thrd->pTransInst;
|
STrans* pTransInst = thrd->pTransInst;
|
||||||
conn->task = transDQSched(thrd->timeoutQueue, doCloseIdleConn, arg, CONN_PERSIST_TIME(pTransInst->idleTime));
|
conn->task = transDQSched(thrd->timeoutQueue, doCloseIdleConn, arg, 10 * CONN_PERSIST_TIME(pTransInst->idleTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static int32_t allocConnRef(SCliConn* conn, bool update) {
|
static int32_t allocConnRef(SCliConn* conn, bool update) {
|
||||||
|
@ -761,8 +807,10 @@ static int32_t allocConnRef(SCliConn* conn, bool update) {
|
||||||
exh->handle = conn;
|
exh->handle = conn;
|
||||||
exh->pThrd = conn->hostThrd;
|
exh->pThrd = conn->hostThrd;
|
||||||
exh->refId = transAddExHandle(transGetRefMgt(), exh);
|
exh->refId = transAddExHandle(transGetRefMgt(), exh);
|
||||||
conn->refId = exh->refId;
|
QUEUE_INIT(&exh->q);
|
||||||
|
taosInitRWLatch(&exh->latch);
|
||||||
|
|
||||||
|
conn->refId = exh->refId;
|
||||||
if (conn->refId == -1) {
|
if (conn->refId == -1) {
|
||||||
taosMemoryFree(exh);
|
taosMemoryFree(exh);
|
||||||
}
|
}
|
||||||
|
@ -779,9 +827,11 @@ static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) {
|
||||||
if (exh == NULL) {
|
if (exh == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
taosWLockLatch(&exh->latch);
|
||||||
exh->handle = conn;
|
exh->handle = conn;
|
||||||
exh->pThrd = conn->hostThrd;
|
exh->pThrd = conn->hostThrd;
|
||||||
conn->refId = exh->refId;
|
conn->refId = exh->refId;
|
||||||
|
taosWUnLockLatch(&exh->latch);
|
||||||
|
|
||||||
transReleaseExHandle(transGetRefMgt(), handle);
|
transReleaseExHandle(transGetRefMgt(), handle);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -882,7 +932,6 @@ static void cliDestroyConn(SCliConn* conn, bool clear) {
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->list = NULL;
|
conn->list = NULL;
|
||||||
pThrd->newConnCount--;
|
|
||||||
|
|
||||||
transReleaseExHandle(transGetRefMgt(), conn->refId);
|
transReleaseExHandle(transGetRefMgt(), conn->refId);
|
||||||
transRemoveExHandle(transGetRefMgt(), conn->refId);
|
transRemoveExHandle(transGetRefMgt(), conn->refId);
|
||||||
|
@ -1190,7 +1239,6 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) {
|
||||||
addr.sin_port = (uint16_t)htons(pList->port);
|
addr.sin_port = (uint16_t)htons(pList->port);
|
||||||
|
|
||||||
tTrace("%s conn %p try to connect to %s", pTransInst->label, conn, pList->dst);
|
tTrace("%s conn %p try to connect to %s", pTransInst->label, conn, pList->dst);
|
||||||
pThrd->newConnCount++;
|
|
||||||
int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 10);
|
int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 10);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
tError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn,
|
tError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn,
|
||||||
|
@ -1392,7 +1440,10 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosRLockLatch(&exh->latch);
|
||||||
SCliConn* conn = exh->handle;
|
SCliConn* conn = exh->handle;
|
||||||
|
taosRUnLockLatch(&exh->latch);
|
||||||
|
|
||||||
transReleaseExHandle(transGetRefMgt(), refId);
|
transReleaseExHandle(transGetRefMgt(), refId);
|
||||||
tDebug("%s conn %p start to release to inst", CONN_GET_INST_LABEL(conn), conn);
|
tDebug("%s conn %p start to release to inst", CONN_GET_INST_LABEL(conn), conn);
|
||||||
|
|
||||||
|
@ -1425,7 +1476,9 @@ SCliConn* cliGetConn(SCliMsg** pMsg, SCliThrd* pThrd, bool* ignore, char* addr)
|
||||||
*ignore = true;
|
*ignore = true;
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
|
taosRLockLatch(&exh->latch);
|
||||||
conn = exh->handle;
|
conn = exh->handle;
|
||||||
|
taosRUnLockLatch(&exh->latch);
|
||||||
if (conn == NULL) {
|
if (conn == NULL) {
|
||||||
conn = getConnFromPool2(pThrd, addr, pMsg);
|
conn = getConnFromPool2(pThrd, addr, pMsg);
|
||||||
if (conn != NULL) specifyConnRef(conn, true, refId);
|
if (conn != NULL) specifyConnRef(conn, true, refId);
|
||||||
|
@ -1439,7 +1492,7 @@ SCliConn* cliGetConn(SCliMsg** pMsg, SCliThrd* pThrd, bool* ignore, char* addr)
|
||||||
if (conn != NULL) {
|
if (conn != NULL) {
|
||||||
tTrace("%s conn %p get from conn pool:%p", CONN_GET_INST_LABEL(conn), conn, pThrd->pool);
|
tTrace("%s conn %p get from conn pool:%p", CONN_GET_INST_LABEL(conn), conn, pThrd->pool);
|
||||||
} else {
|
} else {
|
||||||
tTrace("%s not found conn in conn pool:%p", ((STrans*)pThrd->pTransInst)->label, pThrd->pool);
|
tTrace("%s not found conn in conn pool:%p, dst:%s", ((STrans*)pThrd->pTransInst)->label, pThrd->pool, addr);
|
||||||
}
|
}
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
@ -1598,7 +1651,6 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
||||||
addr.sin_port = (uint16_t)htons(port);
|
addr.sin_port = (uint16_t)htons(port);
|
||||||
|
|
||||||
tGTrace("%s conn %p try to connect to %s", pTransInst->label, conn, conn->dstAddr);
|
tGTrace("%s conn %p try to connect to %s", pTransInst->label, conn, conn->dstAddr);
|
||||||
pThrd->newConnCount++;
|
|
||||||
int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 10);
|
int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 10);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
tGError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn,
|
tGError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn,
|
||||||
|
@ -1858,9 +1910,10 @@ void cliIteraConnMsgs(SCliConn* conn) {
|
||||||
bool cliRecvReleaseReq(SCliConn* conn, STransMsgHead* pHead) {
|
bool cliRecvReleaseReq(SCliConn* conn, STransMsgHead* pHead) {
|
||||||
if (pHead->release == 1 && (pHead->msgLen) == sizeof(*pHead)) {
|
if (pHead->release == 1 && (pHead->msgLen) == sizeof(*pHead)) {
|
||||||
uint64_t ahandle = pHead->ahandle;
|
uint64_t ahandle = pHead->ahandle;
|
||||||
tDebug("ahandle = %" PRIu64 "", ahandle);
|
|
||||||
SCliMsg* pMsg = NULL;
|
SCliMsg* pMsg = NULL;
|
||||||
CONN_GET_MSGCTX_BY_AHANDLE(conn, ahandle);
|
CONN_GET_MSGCTX_BY_AHANDLE(conn, ahandle);
|
||||||
|
tDebug("%s conn %p receive release request, refId:%" PRId64 ", may ignore", CONN_GET_INST_LABEL(conn), conn,
|
||||||
|
conn->refId);
|
||||||
|
|
||||||
transClearBuffer(&conn->readBuf);
|
transClearBuffer(&conn->readBuf);
|
||||||
transFreeMsg(transContFromHead((char*)pHead));
|
transFreeMsg(transContFromHead((char*)pHead));
|
||||||
|
@ -1869,6 +1922,9 @@ bool cliRecvReleaseReq(SCliConn* conn, STransMsgHead* pHead) {
|
||||||
SCliMsg* cliMsg = transQueueGet(&conn->cliMsgs, i);
|
SCliMsg* cliMsg = transQueueGet(&conn->cliMsgs, i);
|
||||||
if (cliMsg->type == Release) {
|
if (cliMsg->type == Release) {
|
||||||
ASSERTS(pMsg == NULL, "trans-cli recv invaid release-req");
|
ASSERTS(pMsg == NULL, "trans-cli recv invaid release-req");
|
||||||
|
tDebug("%s conn %p receive release request, refId:%" PRId64 ", ignore msg", CONN_GET_INST_LABEL(conn), conn,
|
||||||
|
conn->refId);
|
||||||
|
cliDestroyConn(conn, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1984,11 +2040,9 @@ static SCliThrd* createThrdObj(void* trans) {
|
||||||
taosMemoryFree(pThrd);
|
taosMemoryFree(pThrd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (pTransInst->supportBatch) {
|
int32_t nSync = pTransInst->supportBatch ? 4 : 8;
|
||||||
pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, 4, pThrd, cliAsyncCb);
|
pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, nSync, pThrd, cliAsyncCb);
|
||||||
} else {
|
|
||||||
pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, 8, pThrd, cliAsyncCb);
|
|
||||||
}
|
|
||||||
if (pThrd->asyncPool == NULL) {
|
if (pThrd->asyncPool == NULL) {
|
||||||
tError("failed to init async pool");
|
tError("failed to init async pool");
|
||||||
uv_loop_close(pThrd->loop);
|
uv_loop_close(pThrd->loop);
|
||||||
|
@ -2029,8 +2083,6 @@ static SCliThrd* createThrdObj(void* trans) {
|
||||||
|
|
||||||
pThrd->quit = false;
|
pThrd->quit = false;
|
||||||
|
|
||||||
pThrd->newConnCount = 0;
|
|
||||||
pThrd->msgCount = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
|
||||||
return pThrd;
|
return pThrd;
|
||||||
}
|
}
|
||||||
static void destroyThrdObj(SCliThrd* pThrd) {
|
static void destroyThrdObj(SCliThrd* pThrd) {
|
||||||
|
@ -2076,7 +2128,6 @@ static void destroyThrdObj(SCliThrd* pThrd) {
|
||||||
pIter = (void**)taosHashIterate(pThrd->batchCache, pIter);
|
pIter = (void**)taosHashIterate(pThrd->batchCache, pIter);
|
||||||
}
|
}
|
||||||
taosHashCleanup(pThrd->batchCache);
|
taosHashCleanup(pThrd->batchCache);
|
||||||
taosHashCleanup(pThrd->msgCount);
|
|
||||||
taosMemoryFree(pThrd);
|
taosMemoryFree(pThrd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2095,14 +2146,7 @@ void cliSendQuit(SCliThrd* thrd) {
|
||||||
void cliWalkCb(uv_handle_t* handle, void* arg) {
|
void cliWalkCb(uv_handle_t* handle, void* arg) {
|
||||||
if (!uv_is_closing(handle)) {
|
if (!uv_is_closing(handle)) {
|
||||||
if (uv_handle_get_type(handle) == UV_TIMER) {
|
if (uv_handle_get_type(handle) == UV_TIMER) {
|
||||||
// SCliConn* pConn = handle->data;
|
// do nothing
|
||||||
// if (pConn != NULL && pConn->timer != NULL) {
|
|
||||||
// SCliThrd* pThrd = pConn->hostThrd;
|
|
||||||
// uv_timer_stop((uv_timer_t*)handle);
|
|
||||||
// handle->data = NULL;
|
|
||||||
// taosArrayPush(pThrd->timerList, &pConn->timer);
|
|
||||||
// pConn->timer = NULL;
|
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
uv_read_stop((uv_stream_t*)handle);
|
uv_read_stop((uv_stream_t*)handle);
|
||||||
}
|
}
|
||||||
|
@ -2137,18 +2181,23 @@ static void doCloseIdleConn(void* param) {
|
||||||
cliDestroyConn(conn, true);
|
cliDestroyConn(conn, true);
|
||||||
taosMemoryFree(arg);
|
taosMemoryFree(arg);
|
||||||
}
|
}
|
||||||
|
static void cliSchedMsgToDebug(SCliMsg* pMsg, char* label) {
|
||||||
|
if (!(rpcDebugFlag & DEBUG_DEBUG)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
STransConnCtx* pCtx = pMsg->ctx;
|
||||||
|
STraceId* trace = &pMsg->msg.info.traceId;
|
||||||
|
char tbuf[512] = {0};
|
||||||
|
EPSET_TO_STR(&pCtx->epSet, tbuf);
|
||||||
|
tGDebug("%s retry on next node,use:%s, step: %d,timeout:%" PRId64 "", label, tbuf, pCtx->retryStep,
|
||||||
|
pCtx->retryNextInterval);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static void cliSchedMsgToNextNode(SCliMsg* pMsg, SCliThrd* pThrd) {
|
static void cliSchedMsgToNextNode(SCliMsg* pMsg, SCliThrd* pThrd) {
|
||||||
STrans* pTransInst = pThrd->pTransInst;
|
STrans* pTransInst = pThrd->pTransInst;
|
||||||
STransConnCtx* pCtx = pMsg->ctx;
|
STransConnCtx* pCtx = pMsg->ctx;
|
||||||
|
cliSchedMsgToDebug(pMsg, transLabel(pThrd->pTransInst));
|
||||||
if (rpcDebugFlag & DEBUG_DEBUG) {
|
|
||||||
STraceId* trace = &pMsg->msg.info.traceId;
|
|
||||||
char tbuf[512] = {0};
|
|
||||||
EPSET_TO_STR(&pCtx->epSet, tbuf);
|
|
||||||
tGDebug("%s retry on next node,use:%s, step: %d,timeout:%" PRId64 "", transLabel(pThrd->pTransInst), tbuf,
|
|
||||||
pCtx->retryStep, pCtx->retryNextInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg));
|
STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg));
|
||||||
arg->param1 = pMsg;
|
arg->param1 = pMsg;
|
||||||
|
@ -2157,12 +2206,6 @@ static void cliSchedMsgToNextNode(SCliMsg* pMsg, SCliThrd* pThrd) {
|
||||||
transDQSched(pThrd->delayQueue, doDelayTask, arg, pCtx->retryNextInterval);
|
transDQSched(pThrd->delayQueue, doDelayTask, arg, pCtx->retryNextInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE void cliCompareAndSwap(int8_t* val, int8_t exp, int8_t newVal) {
|
|
||||||
if (*val != exp) {
|
|
||||||
*val = newVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCE_INLINE bool cliTryExtractEpSet(STransMsg* pResp, SEpSet* dst) {
|
FORCE_INLINE bool cliTryExtractEpSet(STransMsg* pResp, SEpSet* dst) {
|
||||||
if ((pResp == NULL || pResp->info.hasEpSet == 0)) {
|
if ((pResp == NULL || pResp->info.hasEpSet == 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2504,21 +2547,7 @@ int transReleaseCliHandle(void* handle) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static SCliMsg* transInitMsg(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* ctx) {
|
||||||
int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* ctx) {
|
|
||||||
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle);
|
|
||||||
if (pTransInst == NULL) {
|
|
||||||
transFreeMsg(pReq->pCont);
|
|
||||||
return TSDB_CODE_RPC_BROKEN_LINK;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle);
|
|
||||||
if (pThrd == NULL) {
|
|
||||||
transFreeMsg(pReq->pCont);
|
|
||||||
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
|
||||||
return TSDB_CODE_RPC_BROKEN_LINK;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64());
|
TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64());
|
||||||
STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
|
STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
|
||||||
epsetAssign(&pCtx->epSet, pEpSet);
|
epsetAssign(&pCtx->epSet, pEpSet);
|
||||||
|
@ -2535,12 +2564,48 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran
|
||||||
cliMsg->st = taosGetTimestampUs();
|
cliMsg->st = taosGetTimestampUs();
|
||||||
cliMsg->type = Normal;
|
cliMsg->type = Normal;
|
||||||
cliMsg->refId = (int64_t)shandle;
|
cliMsg->refId = (int64_t)shandle;
|
||||||
|
QUEUE_INIT(&cliMsg->seqq);
|
||||||
|
return cliMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* ctx) {
|
||||||
|
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||||
|
if (pTransInst == NULL) {
|
||||||
|
transFreeMsg(pReq->pCont);
|
||||||
|
return TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t handle = (int64_t)pReq->info.handle;
|
||||||
|
SCliThrd* pThrd = transGetWorkThrd(pTransInst, handle);
|
||||||
|
if (pThrd == NULL) {
|
||||||
|
transFreeMsg(pReq->pCont);
|
||||||
|
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||||
|
return TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
|
}
|
||||||
|
if (handle != 0) {
|
||||||
|
SExHandle* exh = transAcquireExHandle(transGetRefMgt(), handle);
|
||||||
|
if (exh != NULL) {
|
||||||
|
taosWLockLatch(&exh->latch);
|
||||||
|
if (exh->handle == NULL && exh->inited != 0) {
|
||||||
|
SCliMsg* pCliMsg = transInitMsg(shandle, pEpSet, pReq, ctx);
|
||||||
|
QUEUE_PUSH(&exh->q, &pCliMsg->seqq);
|
||||||
|
taosWUnLockLatch(&exh->latch);
|
||||||
|
tDebug("msg refId: %" PRId64 "", handle);
|
||||||
|
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
exh->inited = 1;
|
||||||
|
taosWUnLockLatch(&exh->latch);
|
||||||
|
transReleaseExHandle(transGetRefMgt(), handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SCliMsg* pCliMsg = transInitMsg(shandle, pEpSet, pReq, ctx);
|
||||||
|
|
||||||
STraceId* trace = &pReq->info.traceId;
|
STraceId* trace = &pReq->info.traceId;
|
||||||
tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid,
|
tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid,
|
||||||
EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle);
|
EPSET_GET_INUSE_IP(pEpSet), EPSET_GET_INUSE_PORT(pEpSet), pReq->info.ahandle);
|
||||||
if (0 != transAsyncSend(pThrd->asyncPool, &(cliMsg->q))) {
|
if (0 != transAsyncSend(pThrd->asyncPool, &(pCliMsg->q))) {
|
||||||
destroyCmsg(cliMsg);
|
destroyCmsg(pCliMsg);
|
||||||
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||||
return TSDB_CODE_RPC_BROKEN_LINK;
|
return TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
}
|
}
|
||||||
|
@ -2726,6 +2791,8 @@ int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) {
|
||||||
int64_t transAllocHandle() {
|
int64_t transAllocHandle() {
|
||||||
SExHandle* exh = taosMemoryCalloc(1, sizeof(SExHandle));
|
SExHandle* exh = taosMemoryCalloc(1, sizeof(SExHandle));
|
||||||
exh->refId = transAddExHandle(transGetRefMgt(), exh);
|
exh->refId = transAddExHandle(transGetRefMgt(), exh);
|
||||||
|
QUEUE_INIT(&exh->q);
|
||||||
|
taosInitRWLatch(&exh->latch);
|
||||||
tDebug("pre alloc refId %" PRId64 "", exh->refId);
|
tDebug("pre alloc refId %" PRId64 "", exh->refId);
|
||||||
|
|
||||||
return exh->refId;
|
return exh->refId;
|
||||||
|
|
|
@ -761,9 +761,12 @@ static bool uvRecvReleaseReq(SSvrConn* pConn, STransMsgHead* pHead) {
|
||||||
tTrace("conn %p received release request", pConn);
|
tTrace("conn %p received release request", pConn);
|
||||||
|
|
||||||
STraceId traceId = pHead->traceId;
|
STraceId traceId = pHead->traceId;
|
||||||
pConn->status = ConnRelease;
|
|
||||||
transClearBuffer(&pConn->readBuf);
|
transClearBuffer(&pConn->readBuf);
|
||||||
transFreeMsg(transContFromHead((char*)pHead));
|
transFreeMsg(transContFromHead((char*)pHead));
|
||||||
|
if (pConn->status != ConnAcquire) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
pConn->status = ConnRelease;
|
||||||
|
|
||||||
STransMsg tmsg = {.code = 0, .info.handle = (void*)pConn, .info.traceId = traceId, .info.ahandle = (void*)0x9527};
|
STransMsg tmsg = {.code = 0, .info.handle = (void*)pConn, .info.traceId = traceId, .info.ahandle = (void*)0x9527};
|
||||||
SSvrMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSvrMsg));
|
SSvrMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSvrMsg));
|
||||||
|
@ -1090,6 +1093,7 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd) {
|
||||||
|
|
||||||
STrans* pTransInst = pThrd->pTransInst;
|
STrans* pTransInst = pThrd->pTransInst;
|
||||||
pConn->refId = exh->refId;
|
pConn->refId = exh->refId;
|
||||||
|
QUEUE_INIT(&exh->q);
|
||||||
transRefSrvHandle(pConn);
|
transRefSrvHandle(pConn);
|
||||||
tTrace("%s handle %p, conn %p created, refId:%" PRId64, transLabel(pTransInst), exh, pConn, pConn->refId);
|
tTrace("%s handle %p, conn %p created, refId:%" PRId64, transLabel(pTransInst), exh, pConn, pConn->refId);
|
||||||
return pConn;
|
return pConn;
|
||||||
|
@ -1121,6 +1125,7 @@ static int reallocConnRef(SSvrConn* conn) {
|
||||||
exh->handle = conn;
|
exh->handle = conn;
|
||||||
exh->pThrd = conn->hostThrd;
|
exh->pThrd = conn->hostThrd;
|
||||||
exh->refId = transAddExHandle(transGetRefMgt(), exh);
|
exh->refId = transAddExHandle(transGetRefMgt(), exh);
|
||||||
|
QUEUE_INIT(&exh->q);
|
||||||
transAcquireExHandle(transGetRefMgt(), exh->refId);
|
transAcquireExHandle(transGetRefMgt(), exh->refId);
|
||||||
conn->refId = exh->refId;
|
conn->refId = exh->refId;
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_IN_DROPPING, "Dnode in dropping sta
|
||||||
// mnode-trans
|
// mnode-trans
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_ALREADY_EXIST, "Transaction already exists")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_ALREADY_EXIST, "Transaction already exists")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_NOT_EXIST, "Transaction not exists")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_NOT_EXIST, "Transaction not exists")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_INVALID_STAGE, "Invalid stage to kill")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_INVALID_STAGE, "Invalid transaction stage")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_CONFLICT, "Conflict transaction not completed")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_CONFLICT, "Conflict transaction not completed")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_CLOG_IS_NULL, "Transaction commitlog is null")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_CLOG_IS_NULL, "Transaction commitlog is null")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL, "Unable to establish connection While execute transaction and will continue in the background")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL, "Unable to establish connection While execute transaction and will continue in the background")
|
||||||
|
|
|
@ -66,10 +66,10 @@ class TDTestCase:
|
||||||
tdSql.query('select * from (select tbname, avg(f) from st partition by tbname) a partition by a.tbname order by a.tbname');
|
tdSql.query('select * from (select tbname, avg(f) from st partition by tbname) a partition by a.tbname order by a.tbname');
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkCols(2)
|
tdSql.checkCols(2)
|
||||||
tdSql.checkData(0, 0, 'ct1');
|
tdSql.checkData(0, 0, 'ct1')
|
||||||
tdSql.checkData(0, 1, 6.0);
|
tdSql.checkData(0, 1, 6.0)
|
||||||
tdSql.checkData(1, 0, 'ct2');
|
tdSql.checkData(1, 0, 'ct2')
|
||||||
tdSql.checkData(1, 1, 12.0);
|
tdSql.checkData(1, 1, 12.0)
|
||||||
|
|
||||||
tdSql.error('select tbname from (select * from st)')
|
tdSql.error('select tbname from (select * from st)')
|
||||||
tdSql.error('select st.tbname from (select st.tbname from st)')
|
tdSql.error('select st.tbname from (select st.tbname from st)')
|
||||||
|
|
|
@ -1225,6 +1225,7 @@
|
||||||
,,y,script,./test.sh -f tsim/stream/countSliding1.sim
|
,,y,script,./test.sh -f tsim/stream/countSliding1.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/countSliding2.sim
|
,,y,script,./test.sh -f tsim/stream/countSliding2.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/deleteInterval.sim
|
,,y,script,./test.sh -f tsim/stream/deleteInterval.sim
|
||||||
|
,,y,script,./test.sh -f tsim/stream/deleteScalar.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/deleteSession.sim
|
,,y,script,./test.sh -f tsim/stream/deleteSession.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/deleteState.sim
|
,,y,script,./test.sh -f tsim/stream/deleteState.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/distributeInterval0.sim
|
,,y,script,./test.sh -f tsim/stream/distributeInterval0.sim
|
||||||
|
@ -1250,6 +1251,7 @@
|
||||||
,,y,script,./test.sh -f tsim/stream/ignoreExpiredData.sim
|
,,y,script,./test.sh -f tsim/stream/ignoreExpiredData.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/partitionby1.sim
|
,,y,script,./test.sh -f tsim/stream/partitionby1.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/partitionbyColumnInterval.sim
|
,,y,script,./test.sh -f tsim/stream/partitionbyColumnInterval.sim
|
||||||
|
,,y,script,./test.sh -f tsim/stream/partitionbyColumnOther.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/partitionbyColumnSession.sim
|
,,y,script,./test.sh -f tsim/stream/partitionbyColumnSession.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/partitionbyColumnState.sim
|
,,y,script,./test.sh -f tsim/stream/partitionbyColumnState.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/partitionby.sim
|
,,y,script,./test.sh -f tsim/stream/partitionby.sim
|
||||||
|
@ -1260,8 +1262,13 @@
|
||||||
,,y,script,./test.sh -f tsim/stream/sliding.sim
|
,,y,script,./test.sh -f tsim/stream/sliding.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/state0.sim
|
,,y,script,./test.sh -f tsim/stream/state0.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/state1.sim
|
,,y,script,./test.sh -f tsim/stream/state1.sim
|
||||||
|
,,y,script,./test.sh -f tsim/stream/streamPrimaryKey0.sim
|
||||||
|
,,y,script,./test.sh -f tsim/stream/streamPrimaryKey1.sim
|
||||||
|
,,y,script,./test.sh -f tsim/stream/streamPrimaryKey2.sim
|
||||||
|
,,y,script,./test.sh -f tsim/stream/streamPrimaryKey3.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/triggerInterval0.sim
|
,,y,script,./test.sh -f tsim/stream/triggerInterval0.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/triggerSession0.sim
|
,,y,script,./test.sh -f tsim/stream/triggerSession0.sim
|
||||||
|
,,y,script,./test.sh -f tsim/stream/udTableAndCol0.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/udTableAndTag0.sim
|
,,y,script,./test.sh -f tsim/stream/udTableAndTag0.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/udTableAndTag1.sim
|
,,y,script,./test.sh -f tsim/stream/udTableAndTag1.sim
|
||||||
,,y,script,./test.sh -f tsim/stream/udTableAndTag2.sim
|
,,y,script,./test.sh -f tsim/stream/udTableAndTag2.sim
|
||||||
|
|
|
@ -870,7 +870,7 @@ sql_error select stddev(c2), tbname from select_tags_mt0;
|
||||||
sql_error select twa(c2), tbname from select_tags_mt0;
|
sql_error select twa(c2), tbname from select_tags_mt0;
|
||||||
sql_error select interp(c2), tbname from select_tags_mt0 where ts=100001;
|
sql_error select interp(c2), tbname from select_tags_mt0 where ts=100001;
|
||||||
|
|
||||||
sql_error select t1,t2,tbname from select_tags_mt0 group by tbname;
|
|
||||||
sql select count(tbname) from select_tags_mt0 interval(1d);
|
sql select count(tbname) from select_tags_mt0 interval(1d);
|
||||||
sql select count(tbname) from select_tags_mt0 group by t1;
|
sql select count(tbname) from select_tags_mt0 group by t1;
|
||||||
sql select count(tbname),SUM(T1) from select_tags_mt0 interval(1d);
|
sql select count(tbname),SUM(T1) from select_tags_mt0 interval(1d);
|
||||||
|
@ -888,16 +888,16 @@ sql_error select tbname, t1 from select_tags_mt0 interval(1y);
|
||||||
print ==================================>TD-4231
|
print ==================================>TD-4231
|
||||||
sql select t1,tbname from select_tags_mt0 where c1<0
|
sql select t1,tbname from select_tags_mt0 where c1<0
|
||||||
sql select t1,tbname from select_tags_mt0 where c1<0 and tbname in ('select_tags_tb12')
|
sql select t1,tbname from select_tags_mt0 where c1<0 and tbname in ('select_tags_tb12')
|
||||||
|
|
||||||
sql select tbname from select_tags_mt0 where tbname in ('select_tags_tb12');
|
sql select tbname from select_tags_mt0 where tbname in ('select_tags_tb12');
|
||||||
|
|
||||||
sql_error select first(c1), last(c2), t1 from select_tags_mt0 group by tbname;
|
sql select first(ts), tbname from select_tags_mt0 group by tbname;
|
||||||
sql_error select first(c1), last(c2), tbname, t2 from select_tags_mt0 group by tbname;
|
sql select count(c1) from select_tags_mt0 where c1=99 group by tbname;
|
||||||
sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group by tbname;
|
sql select count(*),tbname from select_tags_mt0 group by tbname
|
||||||
#valid sql: select first(c1), t2 from select_tags_mt0 group by tbname;
|
|
||||||
|
|
||||||
#sql select first(ts), tbname from select_tags_mt0 group by tbname;
|
print ==================================> tag supported in group
|
||||||
#sql select count(c1) from select_tags_mt0 where c1=99 group by tbname;
|
sql select t1,t2,tbname from select_tags_mt0 group by tbname;
|
||||||
#sql select count(*),tbname from select_tags_mt0 group by tbname
|
sql select first(c1), last(c2), t1 from select_tags_mt0 group by tbname;
|
||||||
|
sql select first(c1), last(c2), tbname, t2 from select_tags_mt0 group by tbname;
|
||||||
|
sql select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group by tbname;
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
|
|
@ -3,15 +3,24 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
sql create database test;
|
sql create database test KEEP 36500;
|
||||||
sql use test;
|
sql use test;
|
||||||
sql create table st(ts timestamp, f int) tags(t int);
|
sql create table st(ts timestamp, f int) tags(t int);
|
||||||
sql insert into ct1 using st tags(1) values(now, 0)(now+1s, 1)(now+2s, 10)(now+3s, 11)
|
|
||||||
sql insert into ct2 using st tags(2) values(now+2s, 2)(now+3s, 3)
|
|
||||||
sql insert into ct3 using st tags(3) values(now+4s, 4)(now+5s, 5)
|
|
||||||
sql insert into ct4 using st tags(4) values(now+6s, 6)(now+7s, 7)
|
|
||||||
|
|
||||||
sql select count(*), spread(ts) from st where tbname='ct1'
|
$ms = 1712135244502
|
||||||
|
$ms1 = $ms + 1000
|
||||||
|
$ms2 = $ms + 2000
|
||||||
|
$ms3 = $ms + 3000
|
||||||
|
$ms4 = $ms + 4000
|
||||||
|
$ms5 = $ms + 5000
|
||||||
|
$ms6 = $ms + 6000
|
||||||
|
$ms7 = $ms + 7000
|
||||||
|
sql insert into ct1 using st tags(1) values($ms , 0)($ms1 , 1)($ms2 , 10)($ms3 , 11)
|
||||||
|
sql insert into ct2 using st tags(2) values($ms2 , 2)($ms3 , 3)
|
||||||
|
sql insert into ct3 using st tags(3) values($ms4 , 4)($ms5 , 5)
|
||||||
|
sql insert into ct4 using st tags(4) values($ms6 , 6)($ms7 , 7)
|
||||||
|
|
||||||
|
sql select count(*), spread(ts) from st where tbname='ct1'
|
||||||
print $data00, $data01
|
print $data00, $data01
|
||||||
if $data00 != @4@ then
|
if $data00 != @4@ then
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -15,6 +15,8 @@ sql use test3;
|
||||||
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
sql create stream streams3 trigger at_once ignore expired 0 ignore update 0 into streamt3 as select _wstart, count(*) c1 from t1 state_window(a);
|
sql create stream streams3 trigger at_once ignore expired 0 ignore update 0 into streamt3 as select _wstart, count(*) c1 from t1 state_window(a);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
sql insert into t1 values(1648791211000,1,2,3,1.0);
|
sql insert into t1 values(1648791211000,1,2,3,1.0);
|
||||||
sql insert into t1 values(1648791213000,2,2,3,1.1);
|
sql insert into t1 values(1648791213000,2,2,3,1.1);
|
||||||
sql insert into t1 values(1648791215000,3,2,3,1.1);
|
sql insert into t1 values(1648791215000,3,2,3,1.1);
|
||||||
|
@ -214,4 +216,232 @@ if $data[29][1] != 2 then
|
||||||
goto loop11
|
goto loop11
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print step2=============
|
||||||
|
|
||||||
|
sql create database test4 vgroups 4;
|
||||||
|
sql use test4;
|
||||||
|
sql create stable st(ts timestamp,a int,b int,c int,d double) tags(ta int,tb int,tc int);
|
||||||
|
sql create table t1 using st tags(1,1,1);
|
||||||
|
sql create table t2 using st tags(2,2,2);
|
||||||
|
sql create stream streams4 trigger at_once ignore expired 0 ignore update 0 into streamt4 as select _wstart, first(a), b, c, ta, tb from st interval(1s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791211000,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213000,2,3,4,1.1);
|
||||||
|
sql insert into t2 values(1648791215000,3,4,5,1.1);
|
||||||
|
sql insert into t2 values(1648791217000,4,5,6,1.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop12:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt4 order by 1;
|
||||||
|
sql select * from streamt4 order by 1;
|
||||||
|
|
||||||
|
if $rows != 4 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop12
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 2 then
|
||||||
|
print ======data02=$data02
|
||||||
|
goto loop12
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data03 != 3 then
|
||||||
|
print ======data03=$data03
|
||||||
|
goto loop12
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data04 != 1 then
|
||||||
|
print ======data04=$data04
|
||||||
|
goto loop12
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data05 != 1 then
|
||||||
|
print ======data05=$data05
|
||||||
|
goto loop12
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
|
if $data22 != 4 then
|
||||||
|
print ======data22=$data22
|
||||||
|
goto loop12
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data23 != 5 then
|
||||||
|
print ======data23=$data23
|
||||||
|
goto loop12
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data24 != 2 then
|
||||||
|
print ======data24=$data24
|
||||||
|
goto loop12
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data25 != 2 then
|
||||||
|
print ======data25=$data25
|
||||||
|
goto loop12
|
||||||
|
endi
|
||||||
|
|
||||||
|
print step3=============
|
||||||
|
|
||||||
|
sql create database test5 vgroups 4;
|
||||||
|
sql use test5;
|
||||||
|
sql create stable st(ts timestamp,a int,b int,c int,d double) tags(ta int,tb int,tc int);
|
||||||
|
sql create table t1 using st tags(1,1,1);
|
||||||
|
sql create table t2 using st tags(2,2,2);
|
||||||
|
sql create stream streams5 trigger at_once ignore expired 0 ignore update 0 into streamt5 as select _wstart, b, c, ta, tb, max(b) from t1 interval(1s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791211000,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213000,2,3,4,1.1);
|
||||||
|
sql insert into t1 values(1648791215000,3,4,5,1.1);
|
||||||
|
sql insert into t1 values(1648791217000,4,5,6,1.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop13:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt5 order by 1;
|
||||||
|
sql select * from streamt5 order by 1;
|
||||||
|
|
||||||
|
if $rows != 4 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop13
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 2 then
|
||||||
|
print ======data02=$data02
|
||||||
|
goto loop13
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 3 then
|
||||||
|
print ======data03=$data03
|
||||||
|
goto loop13
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data03 != 1 then
|
||||||
|
print ======data04=$data04
|
||||||
|
goto loop13
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data04 != 1 then
|
||||||
|
print ======data05=$data05
|
||||||
|
goto loop13
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
|
if $data21 != 4 then
|
||||||
|
print ======data22=$data22
|
||||||
|
goto loop13
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data22 != 5 then
|
||||||
|
print ======data23=$data23
|
||||||
|
goto loop13
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data23 != 1 then
|
||||||
|
print ======data24=$data24
|
||||||
|
goto loop13
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data24 != 1 then
|
||||||
|
print ======data25=$data25
|
||||||
|
goto loop13
|
||||||
|
endi
|
||||||
|
|
||||||
|
print step4=============
|
||||||
|
|
||||||
|
sql create database test6 vgroups 4;
|
||||||
|
sql use test6;
|
||||||
|
sql create stable st(ts timestamp,a int,b int,c int,d double) tags(ta int,tb int,tc int);
|
||||||
|
sql create table t1 using st tags(1,1,1);
|
||||||
|
sql create table t2 using st tags(2,2,2);
|
||||||
|
sql create stream streams6 trigger at_once ignore expired 0 ignore update 0 into streamt6 as select _wstart, b, c,min(c), ta, tb from st interval(1s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791211000,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213000,2,3,4,1.1);
|
||||||
|
sql insert into t2 values(1648791215000,3,4,5,1.1);
|
||||||
|
sql insert into t2 values(1648791217000,4,5,6,1.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop14:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt6 order by 1;
|
||||||
|
sql select * from streamt6 order by 1;
|
||||||
|
|
||||||
|
if $rows != 4 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop14
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 2 then
|
||||||
|
print ======data02=$data02
|
||||||
|
goto loop14
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 3 then
|
||||||
|
print ======data03=$data03
|
||||||
|
goto loop14
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data04 != 1 then
|
||||||
|
print ======data04=$data04
|
||||||
|
goto loop14
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data05 != 1 then
|
||||||
|
print ======data05=$data05
|
||||||
|
goto loop14
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
|
if $data21 != 4 then
|
||||||
|
print ======data22=$data22
|
||||||
|
goto loop14
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data22 != 5 then
|
||||||
|
print ======data23=$data23
|
||||||
|
goto loop14
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data24 != 2 then
|
||||||
|
print ======data24=$data24
|
||||||
|
goto loop14
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data25 != 2 then
|
||||||
|
print ======data25=$data25
|
||||||
|
goto loop14
|
||||||
|
endi
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -15,6 +15,8 @@ sql create table t1 using st tags(1,1,1);
|
||||||
sql create table t2 using st tags(2,2,2);
|
sql create table t2 using st tags(2,2,2);
|
||||||
sql create stream streams0 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt as select _wstart, count(*) c1, sum(a) from st session(ts, 10s);
|
sql create stream streams0 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt as select _wstart, count(*) c1, sum(a) from st session(ts, 10s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
sql insert into t1 values(1648791213000,1,2,3,1.0);
|
sql insert into t1 values(1648791213000,1,2,3,1.0);
|
||||||
|
|
||||||
sql insert into t2 values(1648791213001,2,2,3,1.1);
|
sql insert into t2 values(1648791213001,2,2,3,1.1);
|
||||||
|
|
|
@ -0,0 +1,260 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sleep 1000
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
sql drop database if exists test;
|
||||||
|
sql create database test vgroups 4;
|
||||||
|
sql use test;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
sql create stream streams0 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt as select ts, a, b from t1 partition by a;
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213001,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213002,2,2,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213003,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213004,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213005,2,2,3,1.0);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop0:
|
||||||
|
sleep 300
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 6 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
print delete from t1 where ts <= 1648791213002;
|
||||||
|
sql delete from t1 where ts <= 1648791213002;
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop1:
|
||||||
|
sleep 300
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt order by 1;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 0 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 2 then
|
||||||
|
print ======data21=$data21
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ======================step 2
|
||||||
|
|
||||||
|
sql drop database if exists test1;
|
||||||
|
sql create database test1 vgroups 4;
|
||||||
|
sql use test1;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
sql create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt1 subtable(concat("aaa-", cast( a as varchar(10) ))) as select ts, a, b from t1 partition by a;
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213001,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213002,2,2,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213003,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213004,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213005,2,2,3,1.0);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop2:
|
||||||
|
sleep 300
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt1;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 6 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop2
|
||||||
|
endi
|
||||||
|
|
||||||
|
print delete from t1 where ts <= 1648791213002;
|
||||||
|
sql delete from t1 where ts <= 1648791213002;
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop3:
|
||||||
|
sleep 300
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt1 order by 1;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 0 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 2 then
|
||||||
|
print ======data21=$data21
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ======================step 3
|
||||||
|
|
||||||
|
sql drop database if exists test1;
|
||||||
|
sql create database test2 vgroups 4;
|
||||||
|
sql use test2;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
sql create stream streams2 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt2 subtable("aaa-a") as select ts, a, b from t1;
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213001,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213002,2,2,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213003,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213004,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213005,2,2,3,1.0);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop4:
|
||||||
|
sleep 300
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt2;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 6 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop4
|
||||||
|
endi
|
||||||
|
|
||||||
|
print delete from t1 where ts <= 1648791213002;
|
||||||
|
sql delete from t1 where ts <= 1648791213002;
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop5:
|
||||||
|
sleep 300
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt2 order by 1;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop5
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 0 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop5
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
goto loop5
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 2 then
|
||||||
|
print ======data21=$data21
|
||||||
|
goto loop5
|
||||||
|
endi
|
||||||
|
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
|
||||||
|
#goto looptest
|
|
@ -1,6 +1,3 @@
|
||||||
$loop_all = 0
|
|
||||||
looptest:
|
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
@ -660,8 +657,65 @@ if $rows != 4 then
|
||||||
#goto loop17
|
#goto loop17
|
||||||
endi
|
endi
|
||||||
|
|
||||||
$loop_all = $loop_all + 1
|
print ================step2
|
||||||
print ============loop_all=$loop_all
|
sql drop database if exists test1;
|
||||||
|
sql create database test6 vgroups 4;
|
||||||
|
sql use test6;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
sql create stream streams6 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt6 subtable("aaa-a") as select _wstart, count(*) from t1 partition by a interval(10s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213001,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213002,2,2,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213003,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213004,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213005,2,2,3,1.0);
|
||||||
|
|
||||||
|
print delete from t1 where ts <= 1648791213002;
|
||||||
|
sql delete from t1 where ts <= 1648791213002;
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop18:
|
||||||
|
sleep 300
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt6 order by 1;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop18
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop18
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
goto loop18
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 1 then
|
||||||
|
print ======data21=$data21
|
||||||
|
goto loop18
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ========over
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
$loop_all = 0
|
||||||
|
looptest:
|
||||||
|
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sleep 50
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print ================step1
|
||||||
|
sql drop database if exists test1;
|
||||||
|
sql create database test0 vgroups 4;
|
||||||
|
sql use test0;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
sql create stream streams0 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 watermark 100s into streamt0 subtable("aaa-a") as select _wstart, count(*) from t1 partition by a count_window(10);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213001,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213002,2,2,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213003,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213004,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213005,2,2,3,1.0);
|
||||||
|
|
||||||
|
print delete from t1 where ts <= 1648791213002;
|
||||||
|
sql delete from t1 where ts <= 1648791213002;
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop0:
|
||||||
|
sleep 300
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt0 order by 1;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 1 then
|
||||||
|
print ======data21=$data21
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ================step1
|
||||||
|
sql drop database if exists test1;
|
||||||
|
sql create database test1 vgroups 4;
|
||||||
|
sql use test1;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
sql create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt1 subtable("aaa-a") as select _wstart, count(*) from t1 partition by a event_window start with b = 2 end with b = 2;
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213001,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213002,2,2,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213003,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213004,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213005,2,2,3,1.0);
|
||||||
|
|
||||||
|
print delete from t1 where ts <= 1648791213002;
|
||||||
|
sql delete from t1 where ts <= 1648791213002;
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop1:
|
||||||
|
sleep 300
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt1 order by 1;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 1 then
|
||||||
|
print ======data21=$data21
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ========over
|
||||||
|
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
|
||||||
|
#goto looptest
|
|
@ -561,9 +561,66 @@ if $data21 != 1 then
|
||||||
goto loop14
|
goto loop14
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print ================step2
|
||||||
|
sql drop database if exists test5;
|
||||||
|
sql create database test5 vgroups 4;
|
||||||
|
sql use test5;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
sql create stream streams6 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt6 subtable("aaa-a") as select _wstart, count(*) from t1 partition by a session(ts, 10s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213001,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213002,2,2,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213003,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213004,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213005,2,2,3,1.0);
|
||||||
|
|
||||||
|
print delete from t1 where ts <= 1648791213002;
|
||||||
|
sql delete from t1 where ts <= 1648791213002;
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop15:
|
||||||
|
sleep 300
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt6 order by 1;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop15
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop15
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
goto loop15
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 1 then
|
||||||
|
print ======data21=$data21
|
||||||
|
goto loop15
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ========over
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
|
|
||||||
$loop_all = $loop_all + 1
|
|
||||||
print ============loop_all=$loop_all
|
|
||||||
|
|
||||||
#goto looptest
|
#goto looptest
|
|
@ -266,9 +266,66 @@ if $data32 != 8 then
|
||||||
goto loop6
|
goto loop6
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print ================step2
|
||||||
|
sql drop database if exists test2;
|
||||||
|
sql create database test2 vgroups 4;
|
||||||
|
sql use test2;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
sql create stream streams6 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt6 subtable("aaa-a") as select _wstart, count(*) from t1 partition by a session(ts, 10s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213001,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213002,2,2,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213003,0,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213004,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213005,2,2,3,1.0);
|
||||||
|
|
||||||
|
print delete from t1 where ts <= 1648791213002;
|
||||||
|
sql delete from t1 where ts <= 1648791213002;
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop7:
|
||||||
|
sleep 300
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt6 order by 1;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop7
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop7
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
goto loop7
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 1 then
|
||||||
|
print ======data21=$data21
|
||||||
|
goto loop7
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ========over
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
|
|
||||||
$loop_all = $loop_all + 1
|
|
||||||
print ============loop_all=$loop_all
|
|
||||||
|
|
||||||
#goto looptest
|
#goto looptest
|
||||||
|
|
|
@ -0,0 +1,245 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/cfg.sh -n dnode1 -c debugflag -v 135
|
||||||
|
system sh/cfg.sh -n dnode1 -c streamBufferSize -v 10
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print step1=============
|
||||||
|
|
||||||
|
sql create database test vgroups 4;
|
||||||
|
sql use test;
|
||||||
|
sql create table st(ts timestamp, a int, b int , c int, d double) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table t1 using st tags("aa", 1, 2);
|
||||||
|
sql create table streamt0(ts timestamp, a int primary key, b bigint ) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table streamt2(ts timestamp, a int primary key, b bigint ) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create stream streams0 trigger at_once ignore expired 0 ignore update 0 into streamt0 as select _wstart, count(*) c1, max(b) from t1 interval(1s);
|
||||||
|
sql create stream streams2 trigger at_once ignore expired 0 ignore update 0 into streamt2 tags(ta) as select _wstart, count(*) c1, max(b) from st partition by tbname ta interval(1s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,2,3,1.0);
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210001,4,2,3,4.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791220000,2,2,3,1.1);
|
||||||
|
sql insert into t1 values(1648791230000,3,2,3,2.1);
|
||||||
|
sql insert into t1 values(1648791240000,4,2,3,3.1);
|
||||||
|
sql insert into t1 values(1648791250000,4,2,3,3.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop0:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt0
|
||||||
|
sql select * from streamt0;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 5 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 2 then
|
||||||
|
print =====data01=$data01
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop2:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt2
|
||||||
|
sql select * from streamt2;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 5 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop2
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 2 then
|
||||||
|
print =====data01=$data01
|
||||||
|
goto loop2
|
||||||
|
endi
|
||||||
|
|
||||||
|
print step2=============
|
||||||
|
|
||||||
|
sql create database test1 vgroups 4;
|
||||||
|
sql use test1;
|
||||||
|
sql create table st(ts timestamp, a int, b int , c int, d double) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table t1 using st tags("aa", 1, 2);
|
||||||
|
sql create table streamt3(ts timestamp, a int primary key, b bigint ) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table streamt5(ts timestamp, a int primary key, b bigint ) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create stream streams3 trigger at_once ignore expired 0 ignore update 0 into streamt3 as select _wstart, count(*) c1, max(b) from t1 session(ts,1s);
|
||||||
|
sql create stream streams5 trigger at_once ignore expired 0 ignore update 0 into streamt5 tags(ta) as select _wstart, count(*) c1, max(b) from st partition by tbname ta session(ts,1s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,2,3,1.0);
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210001,4,2,3,4.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791220000,2,2,3,1.1);
|
||||||
|
sql insert into t1 values(1648791230000,3,2,3,2.1);
|
||||||
|
sql insert into t1 values(1648791240000,4,2,3,3.1);
|
||||||
|
sql insert into t1 values(1648791250000,4,2,3,3.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop3:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt3
|
||||||
|
sql select * from streamt3;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 5 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 2 then
|
||||||
|
print =====data01=$data01
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop5:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt5
|
||||||
|
sql select * from streamt5;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 5 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop5
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 2 then
|
||||||
|
print =====data01=$data01
|
||||||
|
goto loop5
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
|
sql create database test2 vgroups 4;
|
||||||
|
sql use test2;
|
||||||
|
sql create table st(ts timestamp, a int, b int , c int, d double) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table t1 using st tags("aa", 1, 2);
|
||||||
|
sql create table streamt6(ts timestamp, a int primary key, b bigint ) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create stream streams6 trigger at_once ignore expired 0 ignore update 0 into streamt6 tags(ta) as select _wstart, count(*) c1, max(b) from st partition by tbname ta state_window(a);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,2,3,1.0);
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210001,1,2,3,4.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791220000,2,2,3,1.1);
|
||||||
|
sql insert into t1 values(1648791230000,3,2,3,2.1);
|
||||||
|
sql insert into t1 values(1648791240000,4,2,3,3.1);
|
||||||
|
sql insert into t1 values(1648791250000,5,2,3,3.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop6:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt6
|
||||||
|
sql select * from streamt6;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 5 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop6
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 2 then
|
||||||
|
print =====data01=$data01
|
||||||
|
goto loop6
|
||||||
|
endi
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,123 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/cfg.sh -n dnode1 -c debugflag -v 135
|
||||||
|
system sh/cfg.sh -n dnode1 -c streamBufferSize -v 10
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print step1=============
|
||||||
|
|
||||||
|
sql create database test vgroups 4;
|
||||||
|
sql use test;
|
||||||
|
sql create table st(ts timestamp, a int, b int , c int, d double) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table t1 using st tags("aa", 1, 2);
|
||||||
|
sql create table streamt1(ts timestamp, a int primary key, b bigint ) tags(ta varchar(100),tb int,tc int);
|
||||||
|
|
||||||
|
sql create stream streams1 trigger at_once ignore expired 0 ignore update 0 into streamt1 as select _wstart, count(*) c1, max(b) from st interval(1s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,2,3,1.0);
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210001,4,2,3,4.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791220000,2,2,3,1.1);
|
||||||
|
sql insert into t1 values(1648791230000,3,2,3,2.1);
|
||||||
|
sql insert into t1 values(1648791240000,4,2,3,3.1);
|
||||||
|
sql insert into t1 values(1648791250000,4,2,3,3.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop1:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt1
|
||||||
|
sql select * from streamt1;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 5 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 2 then
|
||||||
|
print =====data00=$data00
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
|
print step2=============
|
||||||
|
|
||||||
|
sql create database test1 vgroups 4;
|
||||||
|
sql use test1;
|
||||||
|
sql create table st(ts timestamp, a int, b int , c int, d double) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table t1 using st tags("aa", 1, 2);
|
||||||
|
sql create table streamt3(ts timestamp, a int primary key, b bigint ) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create stream streams3 trigger at_once ignore expired 0 ignore update 0 into streamt3 as select _wstart, count(*) c1, max(b) from st session(ts,1s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,2,3,1.0);
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210001,4,2,3,4.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791220000,2,2,3,1.1);
|
||||||
|
sql insert into t1 values(1648791230000,3,2,3,2.1);
|
||||||
|
sql insert into t1 values(1648791240000,4,2,3,3.1);
|
||||||
|
sql insert into t1 values(1648791250000,4,2,3,3.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop3:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt3
|
||||||
|
sql select * from streamt3;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 5 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 2 then
|
||||||
|
print =====data00=$data00
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,141 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/cfg.sh -n dnode1 -c debugflag -v 135
|
||||||
|
system sh/cfg.sh -n dnode1 -c streamBufferSize -v 10
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print step1=============
|
||||||
|
|
||||||
|
sql create database test vgroups 4;
|
||||||
|
sql use test;
|
||||||
|
sql create table st(ts timestamp, a int, b int , c int, d double) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table t1 using st tags("aa", 1, 2);
|
||||||
|
sql create table streamt1(ts timestamp, a int primary key, b bigint ) tags(ta varchar(100),tb int,tc int);
|
||||||
|
|
||||||
|
sql create stream streams1 trigger at_once ignore expired 0 ignore update 0 into streamt1 tags(ta) as select _wstart, count(*) c1, max(b) from st partition by tbname ta EVENT_WINDOW start with a = 1 end with a = 3;
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791210010,3,2,3,1.0);
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210001,2,2,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791220000,1,2,3,1.1);
|
||||||
|
sql insert into t1 values(1648791220001,3,2,3,1.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791230000,1,2,3,2.1);
|
||||||
|
sql insert into t1 values(1648791230001,3,2,3,2.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791240000,1,2,3,3.1);
|
||||||
|
sql insert into t1 values(1648791240001,3,2,3,3.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791250000,1,2,3,3.1);
|
||||||
|
sql insert into t1 values(1648791250001,3,2,3,3.1);
|
||||||
|
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop1:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt1
|
||||||
|
sql select * from streamt1;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 5 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 3 then
|
||||||
|
print =====data01=$data01
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
|
print step2=============
|
||||||
|
|
||||||
|
sql create database test1 vgroups 4;
|
||||||
|
sql use test1;
|
||||||
|
sql create table st(ts timestamp, a int, b int , c int, d double) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table t1 using st tags("aa", 1, 2);
|
||||||
|
sql create table streamt3(ts timestamp, a int primary key, b bigint ) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create stream streams3 trigger at_once ignore expired 1 ignore update 0 WATERMARK 1000s into streamt3 tags(ta) as select _wstart, count(*) c1, max(b) from st partition by tbname ta COUNT_WINDOW(2);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,2,3,1.0);
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210001,4,2,3,4.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791220000,2,2,3,1.1);
|
||||||
|
sql insert into t1 values(1648791220001,2,2,3,1.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791230000,3,2,3,2.1);
|
||||||
|
sql insert into t1 values(1648791230001,3,2,3,2.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791240000,4,2,3,3.1);
|
||||||
|
sql insert into t1 values(1648791240001,4,2,3,3.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791250000,4,2,3,3.1);
|
||||||
|
sql insert into t1 values(1648791250001,4,2,3,3.1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop3:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt3
|
||||||
|
sql select * from streamt3;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
print $data50 $data51 $data52
|
||||||
|
print $data60 $data61 $data62
|
||||||
|
print $data70 $data71 $data72
|
||||||
|
|
||||||
|
if $rows != 5 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 2 then
|
||||||
|
print =====data01=$data01
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,368 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/cfg.sh -n dnode1 -c debugflag -v 135
|
||||||
|
system sh/cfg.sh -n dnode1 -c streamBufferSize -v 10
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print step1=============
|
||||||
|
|
||||||
|
sql create database test vgroups 4;
|
||||||
|
sql use test;
|
||||||
|
sql create table st(ts timestamp, a int primary key, b int , c int, d double) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table t1 using st tags("aa", 1, 2);
|
||||||
|
|
||||||
|
sql create stream streams1 trigger at_once ignore expired 0 ignore update 0 into streamt1(ts, a primary key, b) as select ts, a, b from t1 partition by b;
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791210000,2,4,3,1.0);
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,3,3,1.0);
|
||||||
|
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop0:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt1 order by 1,2
|
||||||
|
sql select * from streamt1 order by 1,2;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
|
||||||
|
if $rows != 2 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print =====data01=$data01
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 3 then
|
||||||
|
print =====data02=$data02
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 2 then
|
||||||
|
print =====data11=$data11
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 4 then
|
||||||
|
print =====data12=$data12
|
||||||
|
goto loop0
|
||||||
|
endi
|
||||||
|
|
||||||
|
print step2=============
|
||||||
|
|
||||||
|
sql create database test1 vgroups 4;
|
||||||
|
sql use test1;
|
||||||
|
sql create table st(ts timestamp, a int primary key, b int , c int, d double) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table t1 using st tags("aa", 1, 2);
|
||||||
|
|
||||||
|
sql create stream streams2 trigger at_once ignore expired 0 ignore update 0 into streamt2(ts, a primary key, b) as select _wstart, max(b), count(*) from t1 partition by b interval(10s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,2,1,1.0);
|
||||||
|
sql insert into t1 values(1648791210000,2,4,2,1.0);
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,3,3,1.0);
|
||||||
|
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop1:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt2 order by 1,2
|
||||||
|
sql select * from streamt2 order by 1,2;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
|
||||||
|
if $rows != 2 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 3 then
|
||||||
|
print =====data01=$data01
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 1 then
|
||||||
|
print =====data02=$data02
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 4 then
|
||||||
|
print =====data11=$data11
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 1 then
|
||||||
|
print =====data12=$data12
|
||||||
|
goto loop1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,3,5,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210001,1,3,3,1.0);
|
||||||
|
sql insert into t1 values(1648791210001,2,4,3,1.0);
|
||||||
|
sql insert into t1 values(1648791210001,3,5,3,1.0);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop2:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt2 order by 1,2
|
||||||
|
sql select * from streamt2 order by 1,2;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop2
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 2 then
|
||||||
|
print =====data02=$data02
|
||||||
|
goto loop2
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 2 then
|
||||||
|
print =====data12=$data12
|
||||||
|
goto loop2
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data22 != 2 then
|
||||||
|
print =====data22=$data22
|
||||||
|
goto loop2
|
||||||
|
endi
|
||||||
|
|
||||||
|
print delete from t1 where ts = 1648791210000;
|
||||||
|
sql delete from t1 where ts = 1648791210000;
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop3:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt2 order by 1,2
|
||||||
|
sql select * from streamt2 order by 1,2;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 1 then
|
||||||
|
print =====data02=$data02
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 1 then
|
||||||
|
print =====data12=$data12
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data22 != 1 then
|
||||||
|
print =====data22=$data22
|
||||||
|
goto loop3
|
||||||
|
endi
|
||||||
|
|
||||||
|
print step3=============
|
||||||
|
|
||||||
|
sql create database test2 vgroups 4;
|
||||||
|
sql use test2;
|
||||||
|
sql create table st(ts timestamp, a int primary key, b int , c int, d double) tags(ta varchar(100),tb int,tc int);
|
||||||
|
sql create table t1 using st tags("aa", 1, 2);
|
||||||
|
|
||||||
|
sql create stream streams3 trigger at_once ignore expired 0 ignore update 0 into streamt3(ts, a primary key, b) as select _wstart, max(b), count(*) from t1 partition by b session(ts, 10s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,2,1,1.0);
|
||||||
|
sql insert into t1 values(1648791210000,2,4,2,1.0);
|
||||||
|
|
||||||
|
sleep 500
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,1,3,3,1.0);
|
||||||
|
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop6:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt3 order by 1,2
|
||||||
|
sql select * from streamt3 order by 1,2;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
|
||||||
|
if $rows != 2 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop6
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 3 then
|
||||||
|
print =====data01=$data01
|
||||||
|
goto loop6
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 1 then
|
||||||
|
print =====data02=$data02
|
||||||
|
goto loop6
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 4 then
|
||||||
|
print =====data11=$data11
|
||||||
|
goto loop6
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 1 then
|
||||||
|
print =====data12=$data12
|
||||||
|
goto loop6
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210000,3,5,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791210001,1,3,3,1.0);
|
||||||
|
sql insert into t1 values(1648791210001,2,4,3,1.0);
|
||||||
|
sql insert into t1 values(1648791210001,3,5,3,1.0);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop7:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt3 order by 1,2
|
||||||
|
sql select * from streamt3 order by 1,2;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop7
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 2 then
|
||||||
|
print =====data02=$data02
|
||||||
|
goto loop7
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 2 then
|
||||||
|
print =====data12=$data12
|
||||||
|
goto loop7
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data22 != 2 then
|
||||||
|
print =====data22=$data22
|
||||||
|
goto loop7
|
||||||
|
endi
|
||||||
|
|
||||||
|
print delete from t1 where ts = 1648791210000;
|
||||||
|
sql delete from t1 where ts = 1648791210000;
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop8:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print 1 select * from streamt3 order by 1,2
|
||||||
|
sql select * from streamt3 order by 1,2;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
|
||||||
|
if $rows != 3 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop8
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 1 then
|
||||||
|
print =====data02=$data02
|
||||||
|
goto loop8
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 1 then
|
||||||
|
print =====data12=$data12
|
||||||
|
goto loop8
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data22 != 1 then
|
||||||
|
print =====data22=$data22
|
||||||
|
goto loop8
|
||||||
|
endi
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,111 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
|
||||||
|
print ===== step1
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sleep 50
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print ===== step2
|
||||||
|
print ===== table name
|
||||||
|
|
||||||
|
sql create database test vgroups 4;
|
||||||
|
sql use test;
|
||||||
|
|
||||||
|
|
||||||
|
sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
|
||||||
|
sql create table t1 using st tags(1,1,1);
|
||||||
|
sql create table t2 using st tags(2,2,2);
|
||||||
|
|
||||||
|
sql_error create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt1(a, b, c, d) as select _wstart, count(*) c1, max(a) from st interval(10s);
|
||||||
|
sql_error create stream streams2 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt2(a, b) as select _wstart, count(*) c1, max(a) from st interval(10s);
|
||||||
|
|
||||||
|
|
||||||
|
sql create stream streams3 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt3(a, b) as select count(*) c1, max(a) from st interval(10s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql desc streamt3;
|
||||||
|
|
||||||
|
print $data00
|
||||||
|
print $data10
|
||||||
|
print $data20
|
||||||
|
print $data30
|
||||||
|
print $data40
|
||||||
|
|
||||||
|
if $rows != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql create stream streams4 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt4(a, b, c) as select _wstart, count(*) c1, max(a) from st interval(10s);
|
||||||
|
sql create stream streams5 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt5(a, b, c) as select _wstart, count(*) c1, max(a) from st partition by tbname interval(10s);
|
||||||
|
sql create stream streams6 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt6(a, b, c) tags(tbn varchar(60)) as select _wstart, count(*) c1, max(a) from st partition by tbname tbn interval(10s);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql create stream streams7 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt7(a, b primary key, c) tags(tbn varchar(60)) as select _wstart, count(*) c1, max(a) from st partition by tbname tbn interval(10s);
|
||||||
|
sql_error create stream streams8 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt8(a, b, c primary key) as select _wstart, count(*) c1, max(a) from st interval(10s);
|
||||||
|
|
||||||
|
sql create stream streams9 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt9(a primary key, b) as select count(*) c1, max(a) from st interval(10s);
|
||||||
|
|
||||||
|
sql_error create stream streams10 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt10(a, b primary key, c) as select count(*) c1, max(a), max(b) from st interval(10s);
|
||||||
|
sql_error create stream streams11 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt11(a, b , a) as select count(*) c1, max(a), max(b) from st interval(10s);
|
||||||
|
sql_error create stream streams12 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt12(a, b , c) tags(c varchar(60)) as select count(*) c1, max(a), max(b) from st partition by tbname c interval(10s);
|
||||||
|
|
||||||
|
sql_error create stream streams13 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt13(a, b , c) tags(tc varchar(60)) as select count(*) c1, max(a) c1, max(b) from st partition by tbname tc interval(10s);
|
||||||
|
|
||||||
|
sql_error create stream streams14 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt14 tags(tc varchar(60)) as select count(*) tc, max(a) c1, max(b) from st partition by tbname tc interval(10s);
|
||||||
|
|
||||||
|
sql_error create stream streams15 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt15 tags(tc varchar(100) primary key) as select _wstart, count(*) c1, max(a) from st partition by tbname tc interval(10s);
|
||||||
|
|
||||||
|
|
||||||
|
sql create database test1 vgroups 4;
|
||||||
|
sql use test1;
|
||||||
|
|
||||||
|
|
||||||
|
sql create stable st(ts timestamp, a int primary key, b int, c int) tags(ta int,tb int,tc int);
|
||||||
|
sql create table t1 using st tags(1,1,1);
|
||||||
|
sql create table t2 using st tags(2,2,2);
|
||||||
|
|
||||||
|
sql_error create stream streams16 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt16 as select _wstart, count(*) c1, max(a) from st partition by tbname tc state_window(b);
|
||||||
|
sql_error create stream streams17 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt17 as select _wstart, count(*) c1, max(a) from st partition by tbname tc event_window start with a = 0 end with a = 9;
|
||||||
|
sql_error create stream streams18 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 watermark 10s into streamt18 as select _wstart, count(*) c1, max(a) from st partition by tbname tc count_window(2);
|
||||||
|
|
||||||
|
print ===== step2
|
||||||
|
print ===== scalar
|
||||||
|
|
||||||
|
sql create database test2 vgroups 4;
|
||||||
|
sql use test2;
|
||||||
|
|
||||||
|
sql create table t1 (ts timestamp, a int, b int);
|
||||||
|
|
||||||
|
sql create table rst(ts timestamp, a int primary key, b int) tags(ta varchar(100));
|
||||||
|
sql create table rct1 using rst tags("aa");
|
||||||
|
|
||||||
|
sql create table rst6(ts timestamp, a int primary key, b int) tags(ta varchar(100));
|
||||||
|
sql create table rst7(ts timestamp, a int primary key, b int) tags(ta varchar(100));
|
||||||
|
|
||||||
|
sql create stream streams19 trigger at_once ignore expired 0 ignore update 0 into streamt19 as select ts,a, b from t1;
|
||||||
|
|
||||||
|
sql create stream streams20 trigger at_once ignore expired 0 ignore update 0 into streamt20(ts, a primary key, b) as select ts,a, b from t1;
|
||||||
|
sql create stream streams21 trigger at_once ignore expired 0 ignore update 0 into rst as select ts,a, b from t1;
|
||||||
|
|
||||||
|
sql_error create stream streams22 trigger at_once ignore expired 0 ignore update 0 into streamt22 as select ts,1, b from rct1;
|
||||||
|
|
||||||
|
sql create stream streams23 trigger at_once ignore expired 0 ignore update 0 into streamt23 as select ts, a, b from rct1;
|
||||||
|
|
||||||
|
sql create stream streams24 trigger at_once ignore expired 0 ignore update 0 into streamt24(ts, a primary key, b) as select ts, a, b from rct1;
|
||||||
|
sql create stream streams25 trigger at_once ignore expired 0 ignore update 0 into rst6 as select ts, a, b from rct1;
|
||||||
|
|
||||||
|
sql_error create stream streams26 trigger at_once ignore expired 0 ignore update 0 into rst7 as select ts, 1,b from rct1;
|
||||||
|
|
||||||
|
sql_error create stream streams27 trigger at_once ignore expired 0 ignore update 0 into streamt27(ts, a primary key, b) as select ts, 1,b from rct1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print ======over
|
||||||
|
|
||||||
|
system sh/stop_dnodes.sh
|
|
@ -339,6 +339,65 @@ if $data22 != t3 then
|
||||||
goto loop8
|
goto loop8
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print ===== step6
|
||||||
|
|
||||||
|
sql create database test5 vgroups 4;
|
||||||
|
sql use test5;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
sql create stable streamt5(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
|
||||||
|
sql create stream streams5 trigger at_once ignore expired 0 ignore update 0 into streamt5(ts,b,a) as select _wstart, count(*), 1000 c1 from t1 interval(10s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791223001,2,2,3,1.1);
|
||||||
|
sql insert into t1 values(1648791233002,3,2,3,2.1);
|
||||||
|
sql insert into t1 values(1648791243003,4,2,3,3.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
loop9:
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt5;
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
print $data10 $data11 $data12
|
||||||
|
print $data20 $data21 $data22
|
||||||
|
print $data30 $data31 $data32
|
||||||
|
print $data40 $data41 $data42
|
||||||
|
|
||||||
|
if $rows != 4 then
|
||||||
|
print =====rows=$rows
|
||||||
|
goto loop9
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1000 then
|
||||||
|
print =====data01=$data01
|
||||||
|
goto loop9
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 1 then
|
||||||
|
print =====data02=$data02
|
||||||
|
goto loop9
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
|
if $data31 != 1000 then
|
||||||
|
print =====data31=$data31
|
||||||
|
goto loop9
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data32 != 1 then
|
||||||
|
print =====data32=$data32
|
||||||
|
goto loop9
|
||||||
|
endi
|
||||||
|
|
||||||
print ======over
|
print ======over
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
|
|
|
@ -50,10 +50,11 @@ class TDTestCase:
|
||||||
self.tbnum = 20
|
self.tbnum = 20
|
||||||
self.rowNum = 10
|
self.rowNum = 10
|
||||||
self.tag_dict = {
|
self.tag_dict = {
|
||||||
't0':'int'
|
't0':'int',
|
||||||
|
't1':f'nchar({self.nchar_length})'
|
||||||
}
|
}
|
||||||
self.tag_values = [
|
self.tag_values = [
|
||||||
f'1'
|
f'1', '""'
|
||||||
]
|
]
|
||||||
self.binary_str = 'taosdata'
|
self.binary_str = 'taosdata'
|
||||||
self.nchar_str = '涛思数据'
|
self.nchar_str = '涛思数据'
|
||||||
|
@ -72,7 +73,7 @@ class TDTestCase:
|
||||||
tdSql.execute(f'use {self.dbname}')
|
tdSql.execute(f'use {self.dbname}')
|
||||||
tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict))
|
tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict))
|
||||||
for i in range(self.tbnum):
|
for i in range(self.tbnum):
|
||||||
tdSql.execute(f"create table {self.stbname}_{i} using {self.stbname} tags({self.tag_values[0]})")
|
tdSql.execute(f"create table {self.stbname}_{i} using {self.stbname} tags({self.tag_values[0]}, {self.tag_values[1]})")
|
||||||
self.insert_data(self.column_dict,f'{self.stbname}_{i}',self.rowNum)
|
self.insert_data(self.column_dict,f'{self.stbname}_{i}',self.rowNum)
|
||||||
def count_check(self):
|
def count_check(self):
|
||||||
tdSql.query('select count(*) from information_schema.ins_tables')
|
tdSql.query('select count(*) from information_schema.ins_tables')
|
||||||
|
@ -313,6 +314,11 @@ class TDTestCase:
|
||||||
tdSql.error('alter cluster "activeCode" ""')
|
tdSql.error('alter cluster "activeCode" ""')
|
||||||
tdSql.execute('alter cluster "activeCode" "revoked"')
|
tdSql.execute('alter cluster "activeCode" "revoked"')
|
||||||
|
|
||||||
|
def test_query_ins_tags(self):
|
||||||
|
sql = f'select tag_name, tag_value from information_schema.ins_tags where table_name = "{self.stbname}_0"'
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.prepare_data()
|
self.prepare_data()
|
||||||
self.count_check()
|
self.count_check()
|
||||||
|
@ -322,6 +328,7 @@ class TDTestCase:
|
||||||
self.ins_stable_check2()
|
self.ins_stable_check2()
|
||||||
self.ins_dnodes_check()
|
self.ins_dnodes_check()
|
||||||
self.ins_grants_check()
|
self.ins_grants_check()
|
||||||
|
self.test_query_ins_tags()
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|
|
@ -103,6 +103,10 @@ class TDTestCase:
|
||||||
tdSql.checkRows(row)
|
tdSql.checkRows(row)
|
||||||
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by tbname')
|
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by tbname')
|
||||||
tdSql.checkRows(row)
|
tdSql.checkRows(row)
|
||||||
|
tdSql.query(f'select t0, {function_name}(c1),sum(c1) from {self.stbname} partition by tbname')
|
||||||
|
tdSql.checkRows(row)
|
||||||
|
tdSql.query(f'select cast(t0 as binary(12)), {function_name}(c1),sum(c1) from {self.stbname} partition by tbname')
|
||||||
|
tdSql.checkRows(row)
|
||||||
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by c1')
|
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by c1')
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by t0')
|
tdSql.query(f'select {function_name}(c1),sum(c1) from {self.stbname} partition by t0')
|
||||||
|
|
|
@ -470,7 +470,9 @@ class TDTestCase:
|
||||||
tdSql.checkRows(40)
|
tdSql.checkRows(40)
|
||||||
|
|
||||||
# bug need fix
|
# bug need fix
|
||||||
tdSql.query("select tbname , csum(c1), csum(c12) from db.stb1 partition by tbname")
|
tdSql.query("select tbname , st1, csum(c1), csum(c12) from db.stb1 partition by tbname")
|
||||||
|
tdSql.checkRows(40)
|
||||||
|
tdSql.query("select tbname , cast(st1 as binary(24)), csum(c1), csum(c12) from db.stb1 partition by tbname")
|
||||||
tdSql.checkRows(40)
|
tdSql.checkRows(40)
|
||||||
tdSql.query("select tbname , csum(st1) from db.stb1 partition by tbname")
|
tdSql.query("select tbname , csum(st1) from db.stb1 partition by tbname")
|
||||||
tdSql.checkRows(70)
|
tdSql.checkRows(70)
|
||||||
|
|
|
@ -91,15 +91,71 @@ class TDTestCase:
|
||||||
tdSql.query(f"select t2, t3, c1, count(*) from {self.dbname}.{self.stable} {keyword} by t2, t3, c1 ")
|
tdSql.query(f"select t2, t3, c1, count(*) from {self.dbname}.{self.stable} {keyword} by t2, t3, c1 ")
|
||||||
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
|
||||||
|
def test_groupby_sub_table(self):
|
||||||
|
for i in range(self.tb_nums):
|
||||||
|
tbname = f"{self.dbname}.sub_{self.stable}_{i}"
|
||||||
|
ts = self.ts + i*10000
|
||||||
|
tdSql.query(f"select t1, t2, t3,count(*) from {tbname}")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 1, i)
|
||||||
|
tdSql.checkData(0, 2, i*10)
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(t2 as binary(12)),count(*) from {tbname}")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, i)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2 + 1, count(*) from {tbname}")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, i + 1)
|
||||||
|
|
||||||
|
tdSql.query(f"select t1, t2, t3, count(*) from {tbname} group by tbname")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 1, i)
|
||||||
|
tdSql.checkData(0, 2, i*10)
|
||||||
|
|
||||||
|
tdSql.query(f"select t1, t2, t3, count(*) from {tbname} group by tbname, c1, t4")
|
||||||
|
tdSql.checkData(0, 1, i)
|
||||||
|
tdSql.checkData(0, 2, i*10)
|
||||||
|
|
||||||
|
tdSql.query(f"select t1, t2, t3, count(*) from {tbname} partition by tbname")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 1, i)
|
||||||
|
tdSql.checkData(0, 2, i*10)
|
||||||
|
|
||||||
|
tdSql.query(f"select t1, t2, t3, count(*) from {tbname} partition by c1, tbname")
|
||||||
|
tdSql.checkData(0, 1, i)
|
||||||
|
tdSql.checkData(0, 2, i*10)
|
||||||
|
|
||||||
|
tdSql.query(f"select t1, t2, t3, count(*) from {self.dbname}.{self.stable} partition by c1, tbname order by tbname desc")
|
||||||
|
tdSql.checkRows(50)
|
||||||
|
tdSql.checkData(0, 1, 4)
|
||||||
|
tdSql.checkData(0, 2, 40)
|
||||||
|
|
||||||
|
|
||||||
def test_multi_group_key(self, check_num, nonempty_tb_num):
|
def test_multi_group_key(self, check_num, nonempty_tb_num):
|
||||||
# multi tag/tbname
|
# multi tag/tbname
|
||||||
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} group by t2, t3, tbname")
|
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} group by t2, t3, tbname")
|
||||||
tdSql.checkRows(check_num)
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(t2 as binary(12)), count(*) from {self.dbname}.{self.stable} group by t2, t3, tbname")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} partition by t2, t3, tbname")
|
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} partition by t2, t3, tbname")
|
||||||
tdSql.checkRows(check_num)
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} group by tbname order by tbname asc")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
tdSql.checkData(0, 0, 0)
|
||||||
|
tdSql.checkData(1, 0, 1)
|
||||||
|
tdSql.checkData(2, 1, 20)
|
||||||
|
tdSql.checkData(3, 1, 30)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2, t3, tbname, count(*) from {self.dbname}.{self.stable} partition by tbname order by tbname asc")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
tdSql.checkData(0, 0, 0)
|
||||||
|
tdSql.checkData(2, 1, 20)
|
||||||
|
tdSql.checkData(3, 1, 30)
|
||||||
|
|
||||||
# multi tag + col
|
# multi tag + col
|
||||||
tdSql.query(f"select t1, t2, c1, count(*) from {self.dbname}.{self.stable} partition by t1, t2, c1 ")
|
tdSql.query(f"select t1, t2, c1, count(*) from {self.dbname}.{self.stable} partition by t1, t2, c1 ")
|
||||||
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
@ -222,12 +278,14 @@ class TDTestCase:
|
||||||
|
|
||||||
self.test_groupby('group', self.tb_nums, nonempty_tb_num)
|
self.test_groupby('group', self.tb_nums, nonempty_tb_num)
|
||||||
self.test_groupby('partition', self.tb_nums, nonempty_tb_num)
|
self.test_groupby('partition', self.tb_nums, nonempty_tb_num)
|
||||||
|
self.test_groupby_sub_table()
|
||||||
self.test_innerSelect(self.tb_nums)
|
self.test_innerSelect(self.tb_nums)
|
||||||
self.test_multi_group_key(self.tb_nums, nonempty_tb_num)
|
self.test_multi_group_key(self.tb_nums, nonempty_tb_num)
|
||||||
self.test_multi_agg(self.tb_nums, nonempty_tb_num)
|
self.test_multi_agg(self.tb_nums, nonempty_tb_num)
|
||||||
self.test_window(nonempty_tb_num)
|
self.test_window(nonempty_tb_num)
|
||||||
self.test_event_window(nonempty_tb_num)
|
self.test_event_window(nonempty_tb_num)
|
||||||
|
|
||||||
|
|
||||||
## test old version before changed
|
## test old version before changed
|
||||||
# self.test_groupby('group', 0, 0)
|
# self.test_groupby('group', 0, 0)
|
||||||
# self.insert_db(5, self.row_nums)
|
# self.insert_db(5, self.row_nums)
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
###################################################################
|
||||||
|
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This file is proprietary and confidential to TAOS Technologies.
|
||||||
|
# No part of this file may be reproduced, stored, transmitted,
|
||||||
|
# disclosed or used in any form or by any means other than as
|
||||||
|
# expressly provided by the written permission from Jianhui Tao
|
||||||
|
#
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
import sys
|
||||||
|
import taos
|
||||||
|
from util.common import *
|
||||||
|
from util.log import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.sql import *
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
|
self.rowNum = 10
|
||||||
|
self.tbnum = 20
|
||||||
|
self.ts = 1537146000000
|
||||||
|
self.binary_str = 'taosdata'
|
||||||
|
self.nchar_str = '涛思数据'
|
||||||
|
|
||||||
|
def first_check_base(self):
|
||||||
|
dbname = "db"
|
||||||
|
tdSql.prepare(dbname)
|
||||||
|
column_dict = {
|
||||||
|
'col1': 'tinyint',
|
||||||
|
'col2': 'smallint',
|
||||||
|
'col3': 'int',
|
||||||
|
'col4': 'bigint',
|
||||||
|
'col5': 'tinyint unsigned',
|
||||||
|
'col6': 'smallint unsigned',
|
||||||
|
'col7': 'int unsigned',
|
||||||
|
'col8': 'bigint unsigned',
|
||||||
|
'col9': 'float',
|
||||||
|
'col10': 'double',
|
||||||
|
'col11': 'bool',
|
||||||
|
'col12': 'binary(20)',
|
||||||
|
'col13': 'nchar(20)'
|
||||||
|
}
|
||||||
|
tdSql.execute(f"alter local \'keepColumnName\' \'1\'")
|
||||||
|
tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
|
||||||
|
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''')
|
||||||
|
tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')")
|
||||||
|
tdSql.execute(f"create table {dbname}.stb_2 using {dbname}.stb tags('beijing')")
|
||||||
|
|
||||||
|
column_list = ['col1','col2','col3','col4','col5','col6','col7','col8','col9','col10','col11','col12','col13']
|
||||||
|
for i in column_list:
|
||||||
|
for j in ['stb_1']:
|
||||||
|
tdSql.query(f"select first({i}) from {dbname}.{j}")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
for n in range(self.rowNum):
|
||||||
|
i = n
|
||||||
|
tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
|
||||||
|
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1))
|
||||||
|
|
||||||
|
for n in range(self.rowNum):
|
||||||
|
i = n + 10
|
||||||
|
tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
|
||||||
|
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1))
|
||||||
|
|
||||||
|
for n in range(self.rowNum):
|
||||||
|
i = n + 100
|
||||||
|
tdSql.execute(f"insert into {dbname}.stb_2 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
|
||||||
|
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1))
|
||||||
|
|
||||||
|
for k, v in column_dict.items():
|
||||||
|
|
||||||
|
if v == 'tinyint' or v == 'smallint' or v == 'int' or v == 'bigint' or v == 'tinyint unsigned' or v == 'smallint unsigned'\
|
||||||
|
or v == 'int unsigned' or v == 'bigint unsigned':
|
||||||
|
tdSql.query(f"select last({k})-first({k}) from {dbname}.stb")
|
||||||
|
tdSql.checkData(0, 0, 109)
|
||||||
|
tdSql.query(f"select first({k})+last({k}) from {dbname}.stb")
|
||||||
|
tdSql.checkData(0, 0, 111)
|
||||||
|
tdSql.query(f"select max({k})-first({k}) from {dbname}.stb")
|
||||||
|
tdSql.checkData(0, 0, 109)
|
||||||
|
tdSql.query(f"select max({k})-min({k}) from {dbname}.stb")
|
||||||
|
tdSql.checkData(0, 0, 109)
|
||||||
|
|
||||||
|
tdSql.query(f"select last({k})-first({k}) from {dbname}.stb_1")
|
||||||
|
tdSql.checkData(0, 0, 19)
|
||||||
|
tdSql.query(f"select first({k})+last({k}) from {dbname}.stb_1")
|
||||||
|
tdSql.checkData(0, 0, 21)
|
||||||
|
tdSql.query(f"select max({k})-first({k}) from {dbname}.stb_1")
|
||||||
|
tdSql.checkData(0, 0, 19)
|
||||||
|
tdSql.query(f"select max({k})-min({k}) from {dbname}.stb_1")
|
||||||
|
tdSql.checkData(0, 0, 19)
|
||||||
|
|
||||||
|
# float,double
|
||||||
|
elif v == 'float' or v == 'double':
|
||||||
|
tdSql.query(f"select first({k})+last({k}) from {dbname}.stb")
|
||||||
|
tdSql.checkData(0, 0, 109.2)
|
||||||
|
tdSql.query(f"select first({k})+last({k}) from {dbname}.stb_1")
|
||||||
|
tdSql.checkData(0, 0, 19.2)
|
||||||
|
# bool
|
||||||
|
elif v == 'bool':
|
||||||
|
continue
|
||||||
|
# binary
|
||||||
|
elif 'binary' in v:
|
||||||
|
continue
|
||||||
|
# nchar
|
||||||
|
elif 'nchar' in v:
|
||||||
|
continue
|
||||||
|
|
||||||
|
#tdSql.execute(f'drop database {dbname}')
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.first_check_base()
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -29,9 +29,11 @@ class TDTestCase:
|
||||||
tdSql.execute(f'use db_stmt')
|
tdSql.execute(f'use db_stmt')
|
||||||
|
|
||||||
tdSql.query("select ts,k from st")
|
tdSql.query("select ts,k from st")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(self.expected_affected_rows)
|
||||||
|
|
||||||
tdSql.execute(f'create topic t_unorder_data as select ts,k from st')
|
tdSql.execute(f'create topic t_unorder_data as select ts,k from st')
|
||||||
|
tdSql.execute(f'create topic t_unorder_data_none as select i,k from st')
|
||||||
|
|
||||||
consumer_dict = {
|
consumer_dict = {
|
||||||
"group.id": "g1",
|
"group.id": "g1",
|
||||||
"td.connect.user": "root",
|
"td.connect.user": "root",
|
||||||
|
@ -41,7 +43,7 @@ class TDTestCase:
|
||||||
consumer = Consumer(consumer_dict)
|
consumer = Consumer(consumer_dict)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
consumer.subscribe(["t_unorder_data"])
|
consumer.subscribe(["t_unorder_data", "t_unorder_data_none"])
|
||||||
except TmqError:
|
except TmqError:
|
||||||
tdLog.exit(f"subscribe error")
|
tdLog.exit(f"subscribe error")
|
||||||
|
|
||||||
|
@ -51,18 +53,15 @@ class TDTestCase:
|
||||||
res = consumer.poll(1)
|
res = consumer.poll(1)
|
||||||
print(res)
|
print(res)
|
||||||
if not res:
|
if not res:
|
||||||
if cnt == 0:
|
if cnt == 0 or cnt != 2*self.expected_affected_rows:
|
||||||
tdLog.exit("consume error")
|
tdLog.exit("consume error")
|
||||||
break
|
break
|
||||||
val = res.value()
|
val = res.value()
|
||||||
if val is None:
|
if val is None:
|
||||||
continue
|
continue
|
||||||
for block in val:
|
for block in val:
|
||||||
|
print(block.fetchall(),len(block.fetchall()))
|
||||||
cnt += len(block.fetchall())
|
cnt += len(block.fetchall())
|
||||||
|
|
||||||
if cnt != 2:
|
|
||||||
tdLog.exit("consume error")
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
consumer.close()
|
consumer.close()
|
||||||
|
|
||||||
|
@ -110,20 +109,32 @@ class TDTestCase:
|
||||||
params = new_multi_binds(2)
|
params = new_multi_binds(2)
|
||||||
params[0].timestamp((1626861392589, 1626861392590))
|
params[0].timestamp((1626861392589, 1626861392590))
|
||||||
params[1].int([3, None])
|
params[1].int([3, None])
|
||||||
|
|
||||||
# print(type(stmt))
|
# print(type(stmt))
|
||||||
tdLog.debug("bind_param_batch start")
|
tdLog.debug("bind_param_batch start")
|
||||||
stmt.bind_param_batch(params)
|
stmt.bind_param_batch(params)
|
||||||
|
|
||||||
tdLog.debug("bind_param_batch end")
|
tdLog.debug("bind_param_batch end")
|
||||||
stmt.execute()
|
stmt.execute()
|
||||||
tdLog.debug("execute end")
|
tdLog.debug("execute end")
|
||||||
|
conn.execute("flush database %s" % dbname)
|
||||||
|
|
||||||
|
params1 = new_multi_binds(2)
|
||||||
|
params1[0].timestamp((1626861392587,1626861392586))
|
||||||
|
params1[1].int([None,3])
|
||||||
|
stmt.bind_param_batch(params1)
|
||||||
|
stmt.execute()
|
||||||
|
|
||||||
end = datetime.now()
|
end = datetime.now()
|
||||||
print("elapsed time: ", end - start)
|
print("elapsed time: ", end - start)
|
||||||
assert stmt.affected_rows == 2
|
print(stmt.affected_rows)
|
||||||
|
self.expected_affected_rows = 4
|
||||||
|
if stmt.affected_rows != self.expected_affected_rows :
|
||||||
|
tdLog.exit("affected_rows error")
|
||||||
tdLog.debug("close start")
|
tdLog.debug("close start")
|
||||||
|
|
||||||
stmt.close()
|
stmt.close()
|
||||||
|
|
||||||
# conn.execute("drop database if exists %s" % dbname)
|
# conn.execute("drop database if exists %s" % dbname)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
|
@ -1923,6 +1923,9 @@ int sml_td29373_Test() {
|
||||||
ASSERT(code == TSDB_CODE_SML_NOT_SUPPORT_PK);
|
ASSERT(code == TSDB_CODE_SML_NOT_SUPPORT_PK);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
for (int i = 0; i < 1; i++) {
|
||||||
|
taosMemoryFree(sql3[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// case 4
|
// case 4
|
||||||
const char *sql4[] = {
|
const char *sql4[] = {
|
||||||
|
|
Loading…
Reference in New Issue