merge from 3.0
This commit is contained in:
commit
d75e9b8f6a
|
@ -79,10 +79,16 @@ ENDIF ()
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_SANITIZER
|
BUILD_SANITIZER
|
||||||
"If build addr2line"
|
"If build sanitizer"
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(
|
||||||
|
TDENGINE_3
|
||||||
|
"TDengine 3.x"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_ADDR2LINE
|
BUILD_ADDR2LINE
|
||||||
"If build addr2line"
|
"If build addr2line"
|
||||||
|
|
|
@ -98,10 +98,10 @@ int32_t create_stream() {
|
||||||
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
|
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
|
||||||
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
|
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
|
||||||
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
|
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
|
||||||
pRes = taos_query(
|
pRes =
|
||||||
pConn,
|
taos_query(pConn,
|
||||||
"create stream stream1 trigger max_delay 10s into outstb as select _wstartts, sum(k) from st1 partition "
|
"create stream stream1 trigger max_delay 10s into outstb as select _wstart, sum(k) from st1 partition "
|
||||||
"by tbname session(ts, 10s) ");
|
"by tbname session(ts, 10s) ");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -30,21 +30,35 @@ static void msg_process(TAOS_RES* msg) {
|
||||||
if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) {
|
if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) {
|
||||||
tmq_raw_data *raw = tmq_get_raw_meta(msg);
|
tmq_raw_data *raw = tmq_get_raw_meta(msg);
|
||||||
if(raw){
|
if(raw){
|
||||||
TAOS* pConn = taos_connect("192.168.1.86", "root", "taosdata", "abc1", 0);
|
TAOS* pConn = taos_connect("192.168.1.86", "root", "taosdata", NULL, 0);
|
||||||
if (pConn == NULL) {
|
if (pConn == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 5");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "use abc1");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
int32_t ret = taos_write_raw_meta(pConn, raw);
|
int32_t ret = taos_write_raw_meta(pConn, raw);
|
||||||
printf("write raw data: %s\n", tmq_err2str(ret));
|
printf("write raw data: %s\n", tmq_err2str(ret));
|
||||||
free(raw);
|
|
||||||
taos_close(pConn);
|
taos_close(pConn);
|
||||||
}
|
}
|
||||||
|
tmq_free_raw_meta(raw);
|
||||||
char* result = tmq_get_json_meta(msg);
|
char* result = tmq_get_json_meta(msg);
|
||||||
if(result){
|
if(result){
|
||||||
printf("meta result: %s\n", result);
|
printf("meta result: %s\n", result);
|
||||||
free(result);
|
|
||||||
}
|
}
|
||||||
printf("meta:%p\n", raw);
|
tmq_free_json_meta(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -68,7 +82,7 @@ int32_t init_env() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1");
|
TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 5");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -82,15 +96,14 @@ int32_t init_env() {
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes =
|
pRes = taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 nchar(8), t4 bool)");
|
||||||
taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int)");
|
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000)");
|
pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000, \"ttt\", true)");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -104,13 +117,20 @@ int32_t init_env() {
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes = taos_query(pConn, "create table if not exists ct1 using st1 tags(2000)");
|
pRes = taos_query(pConn, "create table if not exists ct1 using st1(t1) tags(2000)");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create table if not exists ct2 using st1(t1) tags(NULL)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create child table ct2, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes = taos_query(pConn, "insert into ct1 values(now, 3, 4, 'b')");
|
pRes = taos_query(pConn, "insert into ct1 values(now, 3, 4, 'b')");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
@ -118,7 +138,7 @@ int32_t init_env() {
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes = taos_query(pConn, "create table if not exists ct3 using st1 tags(3000)");
|
pRes = taos_query(pConn, "create table if not exists ct3 using st1(t1) tags(3000)");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -202,6 +222,13 @@ int32_t init_env() {
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "alter table n1 comment 'hello'");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes = taos_query(pConn, "alter table n1 drop column c1");
|
pRes = taos_query(pConn, "alter table n1 drop column c1");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
@ -230,6 +257,27 @@ int32_t init_env() {
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create table jt2 using jt tags('')");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 nchar(8), t4 bool)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "drop table st1");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -265,7 +265,9 @@ typedef struct tmq_raw_data tmq_raw_data;
|
||||||
DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res);
|
DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res);
|
||||||
DLL_EXPORT tmq_raw_data *tmq_get_raw_meta(TAOS_RES *res);
|
DLL_EXPORT tmq_raw_data *tmq_get_raw_meta(TAOS_RES *res);
|
||||||
DLL_EXPORT int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data *raw_meta);
|
DLL_EXPORT int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data *raw_meta);
|
||||||
DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res); // Returning null means error. Returned result need to be freed.
|
DLL_EXPORT void tmq_free_raw_meta(tmq_raw_data *rawMeta);
|
||||||
|
DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res); // Returning null means error. Returned result need to be freed by tmq_free_json_meta
|
||||||
|
DLL_EXPORT void tmq_free_json_meta(char* jsonMeta);
|
||||||
DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res);
|
DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res);
|
||||||
DLL_EXPORT const char *tmq_get_db_name(TAOS_RES *res);
|
DLL_EXPORT const char *tmq_get_db_name(TAOS_RES *res);
|
||||||
DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res);
|
DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res);
|
||||||
|
|
|
@ -40,7 +40,6 @@ enum {
|
||||||
|| x == TDMT_VND_CREATE_TABLE \
|
|| x == TDMT_VND_CREATE_TABLE \
|
||||||
|| x == TDMT_VND_ALTER_TABLE \
|
|| x == TDMT_VND_ALTER_TABLE \
|
||||||
|| x == TDMT_VND_DROP_TABLE \
|
|| x == TDMT_VND_DROP_TABLE \
|
||||||
|| x == TDMT_VND_DROP_TTL_TABLE \
|
|
||||||
)
|
)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -162,7 +161,6 @@ typedef struct SQueryTableDataCond {
|
||||||
int64_t endVersion;
|
int64_t endVersion;
|
||||||
} SQueryTableDataCond;
|
} SQueryTableDataCond;
|
||||||
|
|
||||||
void* blockDataDestroy(SSDataBlock* pBlock);
|
|
||||||
int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock);
|
int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock);
|
||||||
void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock);
|
void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock);
|
||||||
|
|
||||||
|
@ -170,19 +168,6 @@ int32_t tEncodeDataBlocks(void** buf, const SArray* blocks);
|
||||||
void* tDecodeDataBlocks(const void* buf, SArray** blocks);
|
void* tDecodeDataBlocks(const void* buf, SArray** blocks);
|
||||||
void colDataDestroy(SColumnInfoData* pColData);
|
void colDataDestroy(SColumnInfoData* pColData);
|
||||||
|
|
||||||
static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
|
|
||||||
int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock);
|
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
|
||||||
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
|
||||||
colDataDestroy(pColInfoData);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayDestroy(pBlock->pDataBlock);
|
|
||||||
taosMemoryFreeClear(pBlock->pBlockAgg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void tDeleteSSDataBlock(SSDataBlock* pBlock) { blockDestroyInner(pBlock); }
|
|
||||||
|
|
||||||
//======================================================================================================================
|
//======================================================================================================================
|
||||||
// the following structure shared by parser and executor
|
// the following structure shared by parser and executor
|
||||||
typedef struct SColumn {
|
typedef struct SColumn {
|
||||||
|
|
|
@ -226,8 +226,12 @@ int32_t blockDataKeepFirstNRows(SSDataBlock* pBlock, size_t n);
|
||||||
|
|
||||||
int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src);
|
int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src);
|
||||||
int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src);
|
int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src);
|
||||||
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData);
|
|
||||||
SSDataBlock* createDataBlock();
|
SSDataBlock* createDataBlock();
|
||||||
|
void* blockDataDestroy(SSDataBlock* pBlock);
|
||||||
|
void blockDataFreeRes(SSDataBlock* pBlock);
|
||||||
|
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData);
|
||||||
|
|
||||||
int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData);
|
int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData);
|
||||||
|
|
||||||
SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId);
|
SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId);
|
||||||
|
|
|
@ -171,6 +171,7 @@ struct SColVal {
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct STagVal {
|
struct STagVal {
|
||||||
|
// char colName[TSDB_COL_NAME_LEN]; // only used for tmq_get_meta
|
||||||
union {
|
union {
|
||||||
int16_t cid;
|
int16_t cid;
|
||||||
char *pKey;
|
char *pKey;
|
||||||
|
|
|
@ -1939,6 +1939,8 @@ typedef struct SVCreateStbReq {
|
||||||
SSchemaWrapper schemaRow;
|
SSchemaWrapper schemaRow;
|
||||||
SSchemaWrapper schemaTag;
|
SSchemaWrapper schemaTag;
|
||||||
SRSmaParam rsmaParam;
|
SRSmaParam rsmaParam;
|
||||||
|
int32_t alterOriDataLen;
|
||||||
|
void* alterOriData;
|
||||||
} SVCreateStbReq;
|
} SVCreateStbReq;
|
||||||
|
|
||||||
int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq);
|
int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq);
|
||||||
|
@ -1966,7 +1968,9 @@ typedef struct SVCreateTbReq {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
char* name; // super table name
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
|
SArray* tagName;
|
||||||
uint8_t* pTag;
|
uint8_t* pTag;
|
||||||
} ctb;
|
} ctb;
|
||||||
struct {
|
struct {
|
||||||
|
@ -1983,6 +1987,9 @@ static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) {
|
||||||
taosMemoryFreeClear(req->comment);
|
taosMemoryFreeClear(req->comment);
|
||||||
if (req->type == TSDB_CHILD_TABLE) {
|
if (req->type == TSDB_CHILD_TABLE) {
|
||||||
taosMemoryFreeClear(req->ctb.pTag);
|
taosMemoryFreeClear(req->ctb.pTag);
|
||||||
|
taosMemoryFreeClear(req->ctb.name);
|
||||||
|
taosArrayDestroy(req->ctb.tagName);
|
||||||
|
req->ctb.tagName = NULL;
|
||||||
} else if (req->type == TSDB_NORMAL_TABLE) {
|
} else if (req->type == TSDB_NORMAL_TABLE) {
|
||||||
taosMemoryFreeClear(req->ntb.schemaRow.pSchema);
|
taosMemoryFreeClear(req->ntb.schemaRow.pSchema);
|
||||||
}
|
}
|
||||||
|
@ -2066,12 +2073,14 @@ typedef struct {
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
// TSDB_ALTER_TABLE_DROP_COLUMN
|
// TSDB_ALTER_TABLE_DROP_COLUMN
|
||||||
// TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
|
// TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
|
||||||
|
int8_t colModType;
|
||||||
int32_t colModBytes;
|
int32_t colModBytes;
|
||||||
// TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
|
// TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
|
||||||
char* colNewName;
|
char* colNewName;
|
||||||
// TSDB_ALTER_TABLE_UPDATE_TAG_VAL
|
// TSDB_ALTER_TABLE_UPDATE_TAG_VAL
|
||||||
char* tagName;
|
char* tagName;
|
||||||
int8_t isNull;
|
int8_t isNull;
|
||||||
|
int8_t tagType;
|
||||||
uint32_t nTagVal;
|
uint32_t nTagVal;
|
||||||
uint8_t* pTagVal;
|
uint8_t* pTagVal;
|
||||||
// TSDB_ALTER_TABLE_UPDATE_OPTIONS
|
// TSDB_ALTER_TABLE_UPDATE_OPTIONS
|
||||||
|
@ -2858,8 +2867,8 @@ typedef struct {
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSMqMetaRsp(void** buf, const SMqMetaRsp* pRsp) {
|
static FORCE_INLINE int32_t tEncodeSMqMetaRsp(void** buf, const SMqMetaRsp* pRsp) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
// tlen += taosEncodeFixedI64(buf, pRsp->reqOffset);
|
tlen += taosEncodeFixedI64(buf, pRsp->reqOffset);
|
||||||
// tlen += taosEncodeFixedI64(buf, pRsp->rspOffset);
|
tlen += taosEncodeFixedI64(buf, pRsp->rspOffset);
|
||||||
tlen += taosEncodeFixedI16(buf, pRsp->resMsgType);
|
tlen += taosEncodeFixedI16(buf, pRsp->resMsgType);
|
||||||
tlen += taosEncodeFixedI32(buf, pRsp->metaRspLen);
|
tlen += taosEncodeFixedI32(buf, pRsp->metaRspLen);
|
||||||
tlen += taosEncodeBinary(buf, pRsp->metaRsp, pRsp->metaRspLen);
|
tlen += taosEncodeBinary(buf, pRsp->metaRsp, pRsp->metaRspLen);
|
||||||
|
@ -2867,8 +2876,7 @@ static FORCE_INLINE int32_t tEncodeSMqMetaRsp(void** buf, const SMqMetaRsp* pRsp
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void* tDecodeSMqMetaRsp(const void* buf, SMqMetaRsp* pRsp) {
|
static FORCE_INLINE void* tDecodeSMqMetaRsp(const void* buf, SMqMetaRsp* pRsp) {
|
||||||
// buf = taosDecodeFixedI64(buf, &pRsp->reqOffset);
|
buf = taosDecodeFixedI64(buf, &pRsp->reqOffset);buf = taosDecodeFixedI64(buf, &pRsp->rspOffset);
|
||||||
// buf = taosDecodeFixedI64(buf, &pRsp->rspOffset);
|
|
||||||
buf = taosDecodeFixedI16(buf, &pRsp->resMsgType);
|
buf = taosDecodeFixedI16(buf, &pRsp->resMsgType);
|
||||||
buf = taosDecodeFixedI32(buf, &pRsp->metaRspLen);
|
buf = taosDecodeFixedI32(buf, &pRsp->metaRspLen);
|
||||||
buf = taosDecodeBinary(buf, &pRsp->metaRsp, pRsp->metaRspLen);
|
buf = taosDecodeBinary(buf, &pRsp->metaRsp, pRsp->metaRspLen);
|
||||||
|
|
|
@ -72,6 +72,8 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision);
|
int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision);
|
||||||
|
int64_t taosTimeSub(int64_t t, int64_t duration, char unit, int32_t precision);
|
||||||
|
|
||||||
int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision);
|
int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision);
|
||||||
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision);
|
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision);
|
||||||
|
|
||||||
|
|
|
@ -213,63 +213,64 @@
|
||||||
#define TK_NK_ARROW 195
|
#define TK_NK_ARROW 195
|
||||||
#define TK_ROWTS 196
|
#define TK_ROWTS 196
|
||||||
#define TK_TBNAME 197
|
#define TK_TBNAME 197
|
||||||
#define TK_QSTARTTS 198
|
#define TK_QSTART 198
|
||||||
#define TK_QENDTS 199
|
#define TK_QEND 199
|
||||||
#define TK_WSTARTTS 200
|
#define TK_QDURATION 200
|
||||||
#define TK_WENDTS 201
|
#define TK_WSTART 201
|
||||||
#define TK_WDURATION 202
|
#define TK_WEND 202
|
||||||
#define TK_CAST 203
|
#define TK_WDURATION 203
|
||||||
#define TK_NOW 204
|
#define TK_CAST 204
|
||||||
#define TK_TODAY 205
|
#define TK_NOW 205
|
||||||
#define TK_TIMEZONE 206
|
#define TK_TODAY 206
|
||||||
#define TK_CLIENT_VERSION 207
|
#define TK_TIMEZONE 207
|
||||||
#define TK_SERVER_VERSION 208
|
#define TK_CLIENT_VERSION 208
|
||||||
#define TK_SERVER_STATUS 209
|
#define TK_SERVER_VERSION 209
|
||||||
#define TK_CURRENT_USER 210
|
#define TK_SERVER_STATUS 210
|
||||||
#define TK_COUNT 211
|
#define TK_CURRENT_USER 211
|
||||||
#define TK_LAST_ROW 212
|
#define TK_COUNT 212
|
||||||
#define TK_BETWEEN 213
|
#define TK_LAST_ROW 213
|
||||||
#define TK_IS 214
|
#define TK_BETWEEN 214
|
||||||
#define TK_NK_LT 215
|
#define TK_IS 215
|
||||||
#define TK_NK_GT 216
|
#define TK_NK_LT 216
|
||||||
#define TK_NK_LE 217
|
#define TK_NK_GT 217
|
||||||
#define TK_NK_GE 218
|
#define TK_NK_LE 218
|
||||||
#define TK_NK_NE 219
|
#define TK_NK_GE 219
|
||||||
#define TK_MATCH 220
|
#define TK_NK_NE 220
|
||||||
#define TK_NMATCH 221
|
#define TK_MATCH 221
|
||||||
#define TK_CONTAINS 222
|
#define TK_NMATCH 222
|
||||||
#define TK_JOIN 223
|
#define TK_CONTAINS 223
|
||||||
#define TK_INNER 224
|
#define TK_JOIN 224
|
||||||
#define TK_SELECT 225
|
#define TK_INNER 225
|
||||||
#define TK_DISTINCT 226
|
#define TK_SELECT 226
|
||||||
#define TK_WHERE 227
|
#define TK_DISTINCT 227
|
||||||
#define TK_PARTITION 228
|
#define TK_WHERE 228
|
||||||
#define TK_BY 229
|
#define TK_PARTITION 229
|
||||||
#define TK_SESSION 230
|
#define TK_BY 230
|
||||||
#define TK_STATE_WINDOW 231
|
#define TK_SESSION 231
|
||||||
#define TK_SLIDING 232
|
#define TK_STATE_WINDOW 232
|
||||||
#define TK_FILL 233
|
#define TK_SLIDING 233
|
||||||
#define TK_VALUE 234
|
#define TK_FILL 234
|
||||||
#define TK_NONE 235
|
#define TK_VALUE 235
|
||||||
#define TK_PREV 236
|
#define TK_NONE 236
|
||||||
#define TK_LINEAR 237
|
#define TK_PREV 237
|
||||||
#define TK_NEXT 238
|
#define TK_LINEAR 238
|
||||||
#define TK_HAVING 239
|
#define TK_NEXT 239
|
||||||
#define TK_RANGE 240
|
#define TK_HAVING 240
|
||||||
#define TK_EVERY 241
|
#define TK_RANGE 241
|
||||||
#define TK_ORDER 242
|
#define TK_EVERY 242
|
||||||
#define TK_SLIMIT 243
|
#define TK_ORDER 243
|
||||||
#define TK_SOFFSET 244
|
#define TK_SLIMIT 244
|
||||||
#define TK_LIMIT 245
|
#define TK_SOFFSET 245
|
||||||
#define TK_OFFSET 246
|
#define TK_LIMIT 246
|
||||||
#define TK_ASC 247
|
#define TK_OFFSET 247
|
||||||
#define TK_NULLS 248
|
#define TK_ASC 248
|
||||||
#define TK_ID 249
|
#define TK_NULLS 249
|
||||||
#define TK_NK_BITNOT 250
|
#define TK_ID 250
|
||||||
#define TK_VALUES 251
|
#define TK_NK_BITNOT 251
|
||||||
#define TK_IMPORT 252
|
#define TK_VALUES 252
|
||||||
#define TK_NK_SEMI 253
|
#define TK_IMPORT 253
|
||||||
#define TK_FILE 254
|
#define TK_NK_SEMI 254
|
||||||
|
#define TK_FILE 255
|
||||||
|
|
||||||
#define TK_NK_SPACE 300
|
#define TK_NK_SPACE 300
|
||||||
#define TK_NK_COMMENT 301
|
#define TK_NK_COMMENT 301
|
||||||
|
|
|
@ -34,7 +34,7 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_ELAPSED,
|
FUNCTION_TYPE_ELAPSED,
|
||||||
FUNCTION_TYPE_IRATE,
|
FUNCTION_TYPE_IRATE,
|
||||||
FUNCTION_TYPE_LAST_ROW,
|
FUNCTION_TYPE_LAST_ROW,
|
||||||
FUNCTION_TYPE_LAST_ROWT, //TODO: removed
|
FUNCTION_TYPE_LAST_ROWT, // TODO: removed
|
||||||
FUNCTION_TYPE_MAX,
|
FUNCTION_TYPE_MAX,
|
||||||
FUNCTION_TYPE_MIN,
|
FUNCTION_TYPE_MIN,
|
||||||
FUNCTION_TYPE_MODE,
|
FUNCTION_TYPE_MODE,
|
||||||
|
@ -114,10 +114,11 @@ typedef enum EFunctionType {
|
||||||
// pseudo column function
|
// pseudo column function
|
||||||
FUNCTION_TYPE_ROWTS = 3500,
|
FUNCTION_TYPE_ROWTS = 3500,
|
||||||
FUNCTION_TYPE_TBNAME,
|
FUNCTION_TYPE_TBNAME,
|
||||||
FUNCTION_TYPE_QSTARTTS,
|
FUNCTION_TYPE_QSTART,
|
||||||
FUNCTION_TYPE_QENDTS,
|
FUNCTION_TYPE_QEND,
|
||||||
FUNCTION_TYPE_WSTARTTS,
|
FUNCTION_TYPE_QDURATION,
|
||||||
FUNCTION_TYPE_WENDTS,
|
FUNCTION_TYPE_WSTART,
|
||||||
|
FUNCTION_TYPE_WEND,
|
||||||
FUNCTION_TYPE_WDURATION,
|
FUNCTION_TYPE_WDURATION,
|
||||||
|
|
||||||
// internal function
|
// internal function
|
||||||
|
@ -197,6 +198,7 @@ bool fmIsInterpFunc(int32_t funcId);
|
||||||
bool fmIsLastRowFunc(int32_t funcId);
|
bool fmIsLastRowFunc(int32_t funcId);
|
||||||
bool fmIsSystemInfoFunc(int32_t funcId);
|
bool fmIsSystemInfoFunc(int32_t funcId);
|
||||||
bool fmIsImplicitTsFunc(int32_t funcId);
|
bool fmIsImplicitTsFunc(int32_t funcId);
|
||||||
|
bool fmIsClientPseudoColumnFunc(int32_t funcId);
|
||||||
|
|
||||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@ typedef struct SFillNode {
|
||||||
ENodeType type; // QUERY_NODE_FILL
|
ENodeType type; // QUERY_NODE_FILL
|
||||||
EFillMode mode;
|
EFillMode mode;
|
||||||
SNode* pValues; // SNodeListNode
|
SNode* pValues; // SNodeListNode
|
||||||
SNode* pWStartTs; // _wstartts pseudo column
|
SNode* pWStartTs; // _wstart pseudo column
|
||||||
STimeWindow timeRange;
|
STimeWindow timeRange;
|
||||||
} SFillNode;
|
} SFillNode;
|
||||||
|
|
||||||
|
@ -248,6 +248,7 @@ typedef struct SSelectStmt {
|
||||||
SNodeList* pOrderByList; // SOrderByExprNode
|
SNodeList* pOrderByList; // SOrderByExprNode
|
||||||
SLimitNode* pLimit;
|
SLimitNode* pLimit;
|
||||||
SLimitNode* pSlimit;
|
SLimitNode* pSlimit;
|
||||||
|
STimeWindow timeRange;
|
||||||
char stmtName[TSDB_TABLE_NAME_LEN];
|
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||||
uint8_t precision;
|
uint8_t precision;
|
||||||
int32_t selectFuncNum;
|
int32_t selectFuncNum;
|
||||||
|
|
|
@ -29,7 +29,7 @@ struct SMetaData;
|
||||||
typedef struct SStmtCallback {
|
typedef struct SStmtCallback {
|
||||||
TAOS_STMT* pStmt;
|
TAOS_STMT* pStmt;
|
||||||
int32_t (*getTbNameFn)(TAOS_STMT*, char**);
|
int32_t (*getTbNameFn)(TAOS_STMT*, char**);
|
||||||
int32_t (*setInfoFn)(TAOS_STMT*, STableMeta*, void*, char*, bool, SHashObj*, SHashObj*);
|
int32_t (*setInfoFn)(TAOS_STMT*, STableMeta*, void*, char*, bool, SHashObj*, SHashObj*, const char*);
|
||||||
int32_t (*getExecInfoFn)(TAOS_STMT*, SHashObj**, SHashObj**);
|
int32_t (*getExecInfoFn)(TAOS_STMT*, SHashObj**, SHashObj**);
|
||||||
} SStmtCallback;
|
} SStmtCallback;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ int32_t qBindStmtSingleColValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBu
|
||||||
int32_t rowNum);
|
int32_t rowNum);
|
||||||
int32_t qBuildStmtColFields(void* pDataBlock, int32_t* fieldNum, TAOS_FIELD_E** fields);
|
int32_t qBuildStmtColFields(void* pDataBlock, int32_t* fieldNum, TAOS_FIELD_E** fields);
|
||||||
int32_t qBuildStmtTagFields(void* pBlock, void* boundTags, int32_t* fieldNum, TAOS_FIELD_E** fields);
|
int32_t qBuildStmtTagFields(void* pBlock, void* boundTags, int32_t* fieldNum, TAOS_FIELD_E** fields);
|
||||||
int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tName, TAOS_MULTI_BIND* bind,
|
int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const char* sTableName, char* tName, TAOS_MULTI_BIND* bind,
|
||||||
char* msgBuf, int32_t msgBufLen);
|
char* msgBuf, int32_t msgBufLen);
|
||||||
void destroyBoundColumnInfo(void* pBoundInfo);
|
void destroyBoundColumnInfo(void* pBoundInfo);
|
||||||
int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf,
|
int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf,
|
||||||
|
@ -93,7 +93,7 @@ int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char*
|
||||||
void* smlInitHandle(SQuery* pQuery);
|
void* smlInitHandle(SQuery* pQuery);
|
||||||
void smlDestroyHandle(void* pHandle);
|
void smlDestroyHandle(void* pHandle);
|
||||||
int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols, bool format, STableMeta* pTableMeta,
|
int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols, bool format, STableMeta* pTableMeta,
|
||||||
char* tableName, char* msgBuf, int16_t msgBufLen);
|
char* tableName, const char* sTableName, int32_t sTableNameLen, char* msgBuf, int16_t msgBufLen);
|
||||||
int32_t smlBuildOutput(void* handle, SHashObj* pVgHash);
|
int32_t smlBuildOutput(void* handle, SHashObj* pVgHash);
|
||||||
|
|
||||||
int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
|
int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
|
||||||
|
|
|
@ -32,6 +32,7 @@ pNode will be freed in API;
|
||||||
*pRes need to freed in caller
|
*pRes need to freed in caller
|
||||||
*/
|
*/
|
||||||
int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes);
|
int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes);
|
||||||
|
int32_t scalarCalculateConstantsFromDual(SNode *pNode, SNode **pRes);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
pDst need to freed in caller
|
pDst need to freed in caller
|
||||||
|
|
|
@ -340,12 +340,12 @@ static FORCE_INLINE int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBloc
|
||||||
if (pTask->sinkType == TASK_SINK__TABLE) {
|
if (pTask->sinkType == TASK_SINK__TABLE) {
|
||||||
ASSERT(pTask->dispatchType == TASK_DISPATCH__NONE);
|
ASSERT(pTask->dispatchType == TASK_DISPATCH__NONE);
|
||||||
pTask->tbSink.tbSinkFunc(pTask, pTask->tbSink.vnode, 0, pBlock->blocks);
|
pTask->tbSink.tbSinkFunc(pTask, pTask->tbSink.vnode, 0, pBlock->blocks);
|
||||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)tDeleteSSDataBlock);
|
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
|
||||||
taosFreeQitem(pBlock);
|
taosFreeQitem(pBlock);
|
||||||
} else if (pTask->sinkType == TASK_SINK__SMA) {
|
} else if (pTask->sinkType == TASK_SINK__SMA) {
|
||||||
ASSERT(pTask->dispatchType == TASK_DISPATCH__NONE);
|
ASSERT(pTask->dispatchType == TASK_DISPATCH__NONE);
|
||||||
pTask->smaSink.smaSink(pTask->smaSink.vnode, pTask->smaSink.smaId, pBlock->blocks);
|
pTask->smaSink.smaSink(pTask->smaSink.vnode, pTask->smaSink.smaId, pBlock->blocks);
|
||||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)tDeleteSSDataBlock);
|
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
|
||||||
taosFreeQitem(pBlock);
|
taosFreeQitem(pBlock);
|
||||||
} else {
|
} else {
|
||||||
ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE);
|
ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE);
|
||||||
|
|
|
@ -26,6 +26,8 @@ extern "C" {
|
||||||
|
|
||||||
extern bool gRaftDetailLog;
|
extern bool gRaftDetailLog;
|
||||||
|
|
||||||
|
#define SYNC_RESP_TTL_MS 5000
|
||||||
|
|
||||||
#define SYNC_MAX_BATCH_SIZE 500
|
#define SYNC_MAX_BATCH_SIZE 500
|
||||||
#define SYNC_INDEX_BEGIN 0
|
#define SYNC_INDEX_BEGIN 0
|
||||||
#define SYNC_INDEX_INVALID -1
|
#define SYNC_INDEX_INVALID -1
|
||||||
|
|
|
@ -22,7 +22,10 @@ extern "C" {
|
||||||
|
|
||||||
#if defined(_TD_DARWIN_64)
|
#if defined(_TD_DARWIN_64)
|
||||||
// specific
|
// specific
|
||||||
|
#ifndef __COMPAR_FN_T
|
||||||
|
#define __COMPAR_FN_T
|
||||||
typedef int(*__compar_fn_t)(const void *, const void *);
|
typedef int(*__compar_fn_t)(const void *, const void *);
|
||||||
|
#endif
|
||||||
|
|
||||||
// for send function in tsocket.c
|
// for send function in tsocket.c
|
||||||
#if defined(MSG_NOSIGNAL)
|
#if defined(MSG_NOSIGNAL)
|
||||||
|
@ -41,7 +44,10 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_ALPINE)
|
#if defined(_ALPINE)
|
||||||
|
#ifndef __COMPAR_FN_T
|
||||||
|
#define __COMPAR_FN_T
|
||||||
typedef int(*__compar_fn_t)(const void *, const void *);
|
typedef int(*__compar_fn_t)(const void *, const void *);
|
||||||
|
#endif
|
||||||
void error (int, int, const char *);
|
void error (int, int, const char *);
|
||||||
#ifndef PTHREAD_MUTEX_RECURSIVE_NP
|
#ifndef PTHREAD_MUTEX_RECURSIVE_NP
|
||||||
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
||||||
|
@ -54,7 +60,10 @@ extern "C" {
|
||||||
char *stpncpy (char *dest, const char *src, size_t n);
|
char *stpncpy (char *dest, const char *src, size_t n);
|
||||||
|
|
||||||
// specific
|
// specific
|
||||||
|
#ifndef __COMPAR_FN_T
|
||||||
|
#define __COMPAR_FN_T
|
||||||
typedef int (*__compar_fn_t)(const void *, const void *);
|
typedef int (*__compar_fn_t)(const void *, const void *);
|
||||||
|
#endif
|
||||||
#define ssize_t int
|
#define ssize_t int
|
||||||
#define _SSIZE_T_
|
#define _SSIZE_T_
|
||||||
#define bzero(ptr, size) memset((ptr), 0, (size))
|
#define bzero(ptr, size) memset((ptr), 0, (size))
|
||||||
|
@ -69,7 +78,6 @@ extern "C" {
|
||||||
char * strsep(char **stringp, const char *delim);
|
char * strsep(char **stringp, const char *delim);
|
||||||
char * getpass(const char *prefix);
|
char * getpass(const char *prefix);
|
||||||
char * strndup(const char *s, size_t n);
|
char * strndup(const char *s, size_t n);
|
||||||
int gettimeofday(struct timeval *ptv, void *pTimeZone);
|
|
||||||
|
|
||||||
// for send function in tsocket.c
|
// for send function in tsocket.c
|
||||||
#define MSG_NOSIGNAL 0
|
#define MSG_NOSIGNAL 0
|
||||||
|
|
|
@ -584,7 +584,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_PAR_INVALID_INTERP_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x265D)
|
#define TSDB_CODE_PAR_INVALID_INTERP_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x265D)
|
||||||
#define TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN TAOS_DEF_ERROR_CODE(0, 0x265E)
|
#define TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN TAOS_DEF_ERROR_CODE(0, 0x265E)
|
||||||
#define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F)
|
#define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F)
|
||||||
#define TSDB_CODE_PAR_INVALID_SMA_INDEX TAOS_DEF_ERROR_CODE(0, 0x265C)
|
#define TSDB_CODE_PAR_INVALID_SMA_INDEX TAOS_DEF_ERROR_CODE(0, 0x2660)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_SELECTED_EXPR TAOS_DEF_ERROR_CODE(0, 0x2661)
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||||
|
|
|
@ -440,7 +440,7 @@ static FORCE_INLINE bool tDecodeIsEnd(SDecoder* pCoder) { return (pCoder->size =
|
||||||
|
|
||||||
static FORCE_INLINE void* tEncoderMalloc(SEncoder* pCoder, int32_t size) {
|
static FORCE_INLINE void* tEncoderMalloc(SEncoder* pCoder, int32_t size) {
|
||||||
void* p = NULL;
|
void* p = NULL;
|
||||||
SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size);
|
SCoderMem* pMem = (SCoderMem*)taosMemoryCalloc(1, sizeof(*pMem) + size);
|
||||||
if (pMem) {
|
if (pMem) {
|
||||||
pMem->next = pCoder->mList;
|
pMem->next = pCoder->mList;
|
||||||
pCoder->mList = pMem;
|
pCoder->mList = pMem;
|
||||||
|
@ -451,7 +451,7 @@ static FORCE_INLINE void* tEncoderMalloc(SEncoder* pCoder, int32_t size) {
|
||||||
|
|
||||||
static FORCE_INLINE void* tDecoderMalloc(SDecoder* pCoder, int32_t size) {
|
static FORCE_INLINE void* tDecoderMalloc(SDecoder* pCoder, int32_t size) {
|
||||||
void* p = NULL;
|
void* p = NULL;
|
||||||
SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size);
|
SCoderMem* pMem = (SCoderMem*)taosMemoryCalloc(1, sizeof(*pMem) + size);
|
||||||
if (pMem) {
|
if (pMem) {
|
||||||
pMem->next = pCoder->mList;
|
pMem->next = pCoder->mList;
|
||||||
pCoder->mList = pMem;
|
pCoder->mList = pMem;
|
||||||
|
|
|
@ -181,6 +181,7 @@ typedef struct SRequestSendRecvBody {
|
||||||
tsem_t rspSem; // not used now
|
tsem_t rspSem; // not used now
|
||||||
__taos_async_fn_t queryFp;
|
__taos_async_fn_t queryFp;
|
||||||
__taos_async_fn_t fetchFp;
|
__taos_async_fn_t fetchFp;
|
||||||
|
EQueryExecMode execMode;
|
||||||
void* param;
|
void* param;
|
||||||
SDataBuf requestMsg;
|
SDataBuf requestMsg;
|
||||||
int64_t queryJob; // query job, created according to sql query DAG.
|
int64_t queryJob; // query job, created according to sql query DAG.
|
||||||
|
|
|
@ -153,7 +153,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
||||||
*pRequest = createRequest(connId, TSDB_SQL_SELECT);
|
*pRequest = createRequest(connId, TSDB_SQL_SELECT);
|
||||||
if (*pRequest == NULL) {
|
if (*pRequest == NULL) {
|
||||||
tscError("failed to malloc sqlObj, %s", sql);
|
tscError("failed to malloc sqlObj, %s", sql);
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*pRequest)->sqlstr = taosMemoryMalloc(sqlLen + 1);
|
(*pRequest)->sqlstr = taosMemoryMalloc(sqlLen + 1);
|
||||||
|
@ -933,6 +933,8 @@ SRequestObj* launchQuery(uint64_t connId, const char* sql, int sqlLen, bool vali
|
||||||
void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultMeta) {
|
void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultMeta) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
pRequest->body.execMode = pQuery->execMode;
|
||||||
|
|
||||||
switch (pQuery->execMode) {
|
switch (pQuery->execMode) {
|
||||||
case QUERY_EXEC_MODE_LOCAL:
|
case QUERY_EXEC_MODE_LOCAL:
|
||||||
asyncExecLocalCmd(pRequest, pQuery);
|
asyncExecLocalCmd(pRequest, pQuery);
|
||||||
|
@ -1149,7 +1151,6 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
|
||||||
SRequestObj* pRequest = createRequest(pTscObj->id, TDMT_MND_CONNECT);
|
SRequestObj* pRequest = createRequest(pTscObj->id, TDMT_MND_CONNECT);
|
||||||
if (pRequest == NULL) {
|
if (pRequest == NULL) {
|
||||||
destroyTscObj(pTscObj);
|
destroyTscObj(pTscObj);
|
||||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
||||||
}
|
}
|
||||||
// this function may be called by user or system, or by both simultaneously.
|
// this function may be called by user or system, or by both simultaneously.
|
||||||
void taos_cleanup(void) {
|
void taos_cleanup(void) {
|
||||||
tscInfo("start to cleanup client environment");
|
tscDebug("start to cleanup client environment");
|
||||||
if (atomic_val_compare_exchange_32(&sentinel, TSC_VAR_NOT_RELEASE, TSC_VAR_RELEASED) != TSC_VAR_NOT_RELEASE) {
|
if (atomic_val_compare_exchange_32(&sentinel, TSC_VAR_NOT_RELEASE, TSC_VAR_RELEASED) != TSC_VAR_NOT_RELEASE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,10 @@ void taos_cleanup(void) {
|
||||||
clientReqRefPool = -1;
|
clientReqRefPool = -1;
|
||||||
taosCloseRef(id);
|
taosCloseRef(id);
|
||||||
|
|
||||||
cleanupTaskQueue();
|
hbMgrCleanUp();
|
||||||
|
|
||||||
|
catalogDestroy();
|
||||||
|
schedulerDestroy();
|
||||||
|
|
||||||
fmFuncMgtDestroy();
|
fmFuncMgtDestroy();
|
||||||
qCleanupKeywordsTable();
|
qCleanupKeywordsTable();
|
||||||
|
@ -67,12 +70,11 @@ void taos_cleanup(void) {
|
||||||
clientConnRefPool = -1;
|
clientConnRefPool = -1;
|
||||||
taosCloseRef(id);
|
taosCloseRef(id);
|
||||||
|
|
||||||
hbMgrCleanUp();
|
|
||||||
|
|
||||||
catalogDestroy();
|
|
||||||
schedulerDestroy();
|
|
||||||
|
|
||||||
rpcCleanup();
|
rpcCleanup();
|
||||||
|
tscDebug("rpc cleanup");
|
||||||
|
|
||||||
|
cleanupTaskQueue();
|
||||||
|
|
||||||
tscInfo("all local resources released");
|
tscInfo("all local resources released");
|
||||||
taosCleanupCfg();
|
taosCleanupCfg();
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
|
@ -852,27 +854,24 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// all data has returned to App already, no need to try again
|
// all data has returned to App already, no need to try again
|
||||||
if (pResultInfo->completed && (pRequest->body.queryJob != 0)) {
|
if (pResultInfo->completed) {
|
||||||
pResultInfo->numOfRows = 0;
|
// it is a local executed query, no need to do async fetch
|
||||||
|
if (QUERY_EXEC_MODE_LOCAL == pRequest->body.execMode) {
|
||||||
|
ASSERT(pResultInfo->numOfRows >= 0);
|
||||||
|
if (pResultInfo->localResultFetched) {
|
||||||
|
pResultInfo->numOfRows = 0;
|
||||||
|
pResultInfo->current = 0;
|
||||||
|
} else {
|
||||||
|
pResultInfo->localResultFetched = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pResultInfo->numOfRows = 0;
|
||||||
|
}
|
||||||
|
|
||||||
pRequest->body.fetchFp(param, pRequest, pResultInfo->numOfRows);
|
pRequest->body.fetchFp(param, pRequest, pResultInfo->numOfRows);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// it is a local executed query, no need to do async fetch
|
|
||||||
if (pRequest->body.queryJob == 0) {
|
|
||||||
ASSERT(pResultInfo->completed && pResultInfo->numOfRows >= 0);
|
|
||||||
if (pResultInfo->localResultFetched) {
|
|
||||||
pResultInfo->numOfRows = 0;
|
|
||||||
pResultInfo->current = 0;
|
|
||||||
pRequest->body.fetchFp(param, pRequest, pResultInfo->numOfRows);
|
|
||||||
} else {
|
|
||||||
pResultInfo->localResultFetched = true;
|
|
||||||
pRequest->body.fetchFp(param, pRequest, pResultInfo->numOfRows);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SSchedulerReq req = {
|
SSchedulerReq req = {
|
||||||
.syncReq = false,
|
.syncReq = false,
|
||||||
.fetchFp = fetchCallback,
|
.fetchFp = fetchCallback,
|
||||||
|
|
|
@ -2256,7 +2256,7 @@ static int32_t smlInsertData(SSmlHandle *info) {
|
||||||
(*pMeta)->tableMeta->uid = tableData->uid; // one table merge data block together according uid
|
(*pMeta)->tableMeta->uid = tableData->uid; // one table merge data block together according uid
|
||||||
|
|
||||||
code = smlBindData(info->exec, tableData->tags, (*pMeta)->cols, tableData->cols, info->dataFormat,
|
code = smlBindData(info->exec, tableData->tags, (*pMeta)->cols, tableData->cols, info->dataFormat,
|
||||||
(*pMeta)->tableMeta, tableData->childTableName, info->msgBuf.buf, info->msgBuf.len);
|
(*pMeta)->tableMeta, tableData->childTableName, tableData->sTableName, tableData->sTableNameLen, info->msgBuf.buf, info->msgBuf.len);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlBindData failed", info->id);
|
uError("SML:0x%" PRIx64 " smlBindData failed", info->id);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -136,7 +136,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char* tbFName) {
|
int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char* tbFName, const char* sTableName) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1);
|
strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1);
|
||||||
|
@ -147,6 +147,7 @@ int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags,
|
||||||
pStmt->bInfo.tbType = pTableMeta->tableType;
|
pStmt->bInfo.tbType = pTableMeta->tableType;
|
||||||
pStmt->bInfo.boundTags = tags;
|
pStmt->bInfo.boundTags = tags;
|
||||||
pStmt->bInfo.tagsCached = false;
|
pStmt->bInfo.tagsCached = false;
|
||||||
|
strcpy(pStmt->bInfo.stbFName, sTableName);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -162,10 +163,10 @@ int32_t stmtUpdateExecInfo(TAOS_STMT* stmt, SHashObj* pVgHash, SHashObj* pBlockH
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t stmtUpdateInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char* tbFName, bool autoCreateTbl,
|
int32_t stmtUpdateInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char* tbFName, bool autoCreateTbl,
|
||||||
SHashObj* pVgHash, SHashObj* pBlockHash) {
|
SHashObj* pVgHash, SHashObj* pBlockHash, const char* sTableName) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
STMT_ERR_RET(stmtUpdateBindInfo(stmt, pTableMeta, tags, tbFName));
|
STMT_ERR_RET(stmtUpdateBindInfo(stmt, pTableMeta, tags, tbFName, sTableName));
|
||||||
STMT_ERR_RET(stmtUpdateExecInfo(stmt, pVgHash, pBlockHash, autoCreateTbl));
|
STMT_ERR_RET(stmtUpdateExecInfo(stmt, pVgHash, pBlockHash, autoCreateTbl));
|
||||||
|
|
||||||
pStmt->sql.autoCreateTbl = autoCreateTbl;
|
pStmt->sql.autoCreateTbl = autoCreateTbl;
|
||||||
|
@ -253,7 +254,7 @@ int32_t stmtCleanBindInfo(STscStmt* pStmt) {
|
||||||
destroyBoundColumnInfo(pStmt->bInfo.boundTags);
|
destroyBoundColumnInfo(pStmt->bInfo.boundTags);
|
||||||
taosMemoryFreeClear(pStmt->bInfo.boundTags);
|
taosMemoryFreeClear(pStmt->bInfo.boundTags);
|
||||||
}
|
}
|
||||||
|
memset(pStmt->bInfo.stbFName, 0, TSDB_TABLE_FNAME_LEN);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,7 +593,7 @@ int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tscDebug("start to bind stmt tag values");
|
tscDebug("start to bind stmt tag values");
|
||||||
STMT_ERR_RET(qBindStmtTagsValue(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.sname.tname,
|
STMT_ERR_RET(qBindStmtTagsValue(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.stbFName, pStmt->bInfo.sname.tname,
|
||||||
tags, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen));
|
tags, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -542,8 +542,10 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
|
int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
|
||||||
pBlock->info.rows = *(int32_t*)buf;
|
int32_t numOfRows = *(int32_t*) buf;
|
||||||
|
blockDataEnsureCapacity(pBlock, numOfRows);
|
||||||
|
|
||||||
|
pBlock->info.rows = numOfRows;
|
||||||
size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
||||||
const char* pStart = buf + sizeof(uint32_t);
|
const char* pStart = buf + sizeof(uint32_t);
|
||||||
|
|
||||||
|
@ -589,6 +591,7 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo remove this
|
||||||
int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity) {
|
int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity) {
|
||||||
pBlock->info.rows = *(int32_t*)buf;
|
pBlock->info.rows = *(int32_t*)buf;
|
||||||
pBlock->info.groupId = *(uint64_t*)(buf + sizeof(int32_t));
|
pBlock->info.groupId = *(uint64_t*)(buf + sizeof(int32_t));
|
||||||
|
@ -1174,8 +1177,6 @@ int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows)
|
||||||
|
|
||||||
int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) {
|
int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
// ASSERT(numOfRows > 0);
|
|
||||||
|
|
||||||
if (numOfRows == 0) {
|
if (numOfRows == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1196,15 +1197,28 @@ int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void blockDataFreeRes(SSDataBlock* pBlock) {
|
||||||
|
int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock);
|
||||||
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
|
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
colDataDestroy(pColInfoData);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pBlock->pDataBlock);
|
||||||
|
taosMemoryFreeClear(pBlock->pBlockAgg);
|
||||||
|
memset(&pBlock->info, 0, sizeof(SDataBlockInfo));
|
||||||
|
}
|
||||||
|
|
||||||
void* blockDataDestroy(SSDataBlock* pBlock) {
|
void* blockDataDestroy(SSDataBlock* pBlock) {
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDestroyInner(pBlock);
|
blockDataFreeRes(pBlock);
|
||||||
taosMemoryFreeClear(pBlock);
|
taosMemoryFreeClear(pBlock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) {
|
int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) {
|
||||||
ASSERT(src != NULL);
|
ASSERT(src != NULL);
|
||||||
|
|
||||||
|
|
|
@ -1123,10 +1123,44 @@ void taosCfgDynamicOptions(const char *option, const char *value) {
|
||||||
if (strncasecmp(option, "debugFlag", 9) == 0) {
|
if (strncasecmp(option, "debugFlag", 9) == 0) {
|
||||||
int32_t flag = atoi(value);
|
int32_t flag = atoi(value);
|
||||||
taosSetAllDebugFlag(flag);
|
taosSetAllDebugFlag(flag);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp(option, "resetlog") == 0) {
|
if (strcasecmp(option, "resetlog") == 0) {
|
||||||
taosResetLog();
|
taosResetLog();
|
||||||
cfgDumpCfg(tsCfg, 0, false);
|
cfgDumpCfg(tsCfg, 0, false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcasecmp(option, "monitor") == 0) {
|
||||||
|
int32_t monitor = atoi(value);
|
||||||
|
uInfo("monitor set from %d to %d", tsEnableMonitor, monitor);
|
||||||
|
tsEnableMonitor = monitor;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *options[] = {
|
||||||
|
"dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag",
|
||||||
|
"tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tmrDebugFlag",
|
||||||
|
"uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag",
|
||||||
|
};
|
||||||
|
int32_t *optionVars[] = {
|
||||||
|
&dDebugFlag, &vDebugFlag, &mDebugFlag, &wDebugFlag, &sDebugFlag, &tsdbDebugFlag,
|
||||||
|
&tqDebugFlag, &fsDebugFlag, &udfDebugFlag, &smaDebugFlag, &idxDebugFlag, &tmrDebugFlag,
|
||||||
|
&uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag,
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t optionSize = tListLen(options);
|
||||||
|
for (int32_t d = 0; d < optionSize; ++d) {
|
||||||
|
const char *optName = options[d];
|
||||||
|
int32_t optLen = strlen(optName);
|
||||||
|
if (strncasecmp(option, optName, optLen) != 0) continue;
|
||||||
|
|
||||||
|
int32_t flag = atoi(value);
|
||||||
|
uInfo("%s set from %d to %d", optName, *optionVars[d], flag);
|
||||||
|
*optionVars[d] = flag;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uError("failed to cfg dynamic option:%s value:%s", option, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4871,6 +4871,11 @@ int tEncodeSVCreateStbReq(SEncoder *pCoder, const SVCreateStbReq *pReq) {
|
||||||
if (tEncodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1;
|
if (tEncodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tEncodeI32(pCoder, pReq->alterOriDataLen) < 0) return -1;
|
||||||
|
if (pReq->alterOriDataLen > 0) {
|
||||||
|
if (tEncodeBinary(pCoder, pReq->alterOriData, pReq->alterOriDataLen) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndEncode(pCoder);
|
tEndEncode(pCoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4887,6 +4892,11 @@ int tDecodeSVCreateStbReq(SDecoder *pCoder, SVCreateStbReq *pReq) {
|
||||||
if (tDecodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1;
|
if (tDecodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tDecodeI32(pCoder, &pReq->alterOriDataLen) < 0) return -1;
|
||||||
|
if (pReq->alterOriDataLen > 0) {
|
||||||
|
if (tDecodeBinary(pCoder, (uint8_t **)&pReq->alterOriData, NULL) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(pCoder);
|
tEndDecode(pCoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4930,8 +4940,15 @@ int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReq->type == TSDB_CHILD_TABLE) {
|
if (pReq->type == TSDB_CHILD_TABLE) {
|
||||||
|
if (tEncodeCStr(pCoder, pReq->ctb.name) < 0) return -1;
|
||||||
if (tEncodeI64(pCoder, pReq->ctb.suid) < 0) return -1;
|
if (tEncodeI64(pCoder, pReq->ctb.suid) < 0) return -1;
|
||||||
if (tEncodeTag(pCoder, (const STag *)pReq->ctb.pTag) < 0) return -1;
|
if (tEncodeTag(pCoder, (const STag *)pReq->ctb.pTag) < 0) return -1;
|
||||||
|
int32_t len = taosArrayGetSize(pReq->ctb.tagName);
|
||||||
|
if (tEncodeI32(pCoder, len) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < len; i++){
|
||||||
|
char* name = taosArrayGet(pReq->ctb.tagName, i);
|
||||||
|
if (tEncodeCStr(pCoder, name) < 0) return -1;
|
||||||
|
}
|
||||||
} else if (pReq->type == TSDB_NORMAL_TABLE) {
|
} else if (pReq->type == TSDB_NORMAL_TABLE) {
|
||||||
if (tEncodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1;
|
if (tEncodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4959,8 +4976,20 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReq->type == TSDB_CHILD_TABLE) {
|
if (pReq->type == TSDB_CHILD_TABLE) {
|
||||||
|
if (tDecodeCStr(pCoder, &pReq->ctb.name) < 0) return -1;
|
||||||
if (tDecodeI64(pCoder, &pReq->ctb.suid) < 0) return -1;
|
if (tDecodeI64(pCoder, &pReq->ctb.suid) < 0) return -1;
|
||||||
if (tDecodeTag(pCoder, (STag **)&pReq->ctb.pTag) < 0) return -1;
|
if (tDecodeTag(pCoder, (STag **)&pReq->ctb.pTag) < 0) return -1;
|
||||||
|
int32_t len = 0;
|
||||||
|
if (tDecodeI32(pCoder, &len) < 0) return -1;
|
||||||
|
pReq->ctb.tagName = taosArrayInit(len, TSDB_COL_NAME_LEN);
|
||||||
|
if(pReq->ctb.tagName == NULL) return -1;
|
||||||
|
for (int32_t i = 0; i < len; i++){
|
||||||
|
char name[TSDB_COL_NAME_LEN] = {0};
|
||||||
|
char *tmp = NULL;
|
||||||
|
if (tDecodeCStr(pCoder, &tmp) < 0) return -1;
|
||||||
|
strcpy(name, tmp);
|
||||||
|
taosArrayPush(pReq->ctb.tagName, name);
|
||||||
|
}
|
||||||
} else if (pReq->type == TSDB_NORMAL_TABLE) {
|
} else if (pReq->type == TSDB_NORMAL_TABLE) {
|
||||||
if (tDecodeSSchemaWrapperEx(pCoder, &pReq->ntb.schemaRow) < 0) return -1;
|
if (tDecodeSSchemaWrapperEx(pCoder, &pReq->ntb.schemaRow) < 0) return -1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -5292,6 +5321,7 @@ int32_t tEncodeSVAlterTbReq(SEncoder *pEncoder, const SVAlterTbReq *pReq) {
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||||
if (tEncodeCStr(pEncoder, pReq->colName) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pReq->colName) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pReq->colModType) < 0) return -1;
|
||||||
if (tEncodeI32v(pEncoder, pReq->colModBytes) < 0) return -1;
|
if (tEncodeI32v(pEncoder, pReq->colModBytes) < 0) return -1;
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME:
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME:
|
||||||
|
@ -5301,6 +5331,7 @@ int32_t tEncodeSVAlterTbReq(SEncoder *pEncoder, const SVAlterTbReq *pReq) {
|
||||||
case TSDB_ALTER_TABLE_UPDATE_TAG_VAL:
|
case TSDB_ALTER_TABLE_UPDATE_TAG_VAL:
|
||||||
if (tEncodeCStr(pEncoder, pReq->tagName) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pReq->tagName) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pReq->isNull) < 0) return -1;
|
if (tEncodeI8(pEncoder, pReq->isNull) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pReq->tagType) < 0) return -1;
|
||||||
if (!pReq->isNull) {
|
if (!pReq->isNull) {
|
||||||
if (tEncodeBinary(pEncoder, pReq->pTagVal, pReq->nTagVal) < 0) return -1;
|
if (tEncodeBinary(pEncoder, pReq->pTagVal, pReq->nTagVal) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
@ -5340,6 +5371,7 @@ int32_t tDecodeSVAlterTbReq(SDecoder *pDecoder, SVAlterTbReq *pReq) {
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||||
if (tDecodeCStr(pDecoder, &pReq->colName) < 0) return -1;
|
if (tDecodeCStr(pDecoder, &pReq->colName) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pReq->colModType) < 0) return -1;
|
||||||
if (tDecodeI32v(pDecoder, &pReq->colModBytes) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pReq->colModBytes) < 0) return -1;
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME:
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME:
|
||||||
|
@ -5349,6 +5381,7 @@ int32_t tDecodeSVAlterTbReq(SDecoder *pDecoder, SVAlterTbReq *pReq) {
|
||||||
case TSDB_ALTER_TABLE_UPDATE_TAG_VAL:
|
case TSDB_ALTER_TABLE_UPDATE_TAG_VAL:
|
||||||
if (tDecodeCStr(pDecoder, &pReq->tagName) < 0) return -1;
|
if (tDecodeCStr(pDecoder, &pReq->tagName) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pReq->isNull) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pReq->isNull) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pReq->tagType) < 0) return -1;
|
||||||
if (!pReq->isNull) {
|
if (!pReq->isNull) {
|
||||||
if (tDecodeBinary(pDecoder, &pReq->pTagVal, &pReq->nTagVal) < 0) return -1;
|
if (tDecodeBinary(pDecoder, &pReq->pTagVal, &pReq->nTagVal) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -710,6 +710,32 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
||||||
return (int64_t)(taosMktime(&tm) * TSDB_TICK_PER_SECOND(precision));
|
return (int64_t)(taosMktime(&tm) * TSDB_TICK_PER_SECOND(precision));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t taosTimeSub(int64_t t, int64_t duration, char unit, int32_t precision) {
|
||||||
|
if (duration == 0) {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unit != 'n' && unit != 'y') {
|
||||||
|
return t - duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The following code handles the y/n time duration
|
||||||
|
int64_t numOfMonth = duration;
|
||||||
|
if (unit == 'y') {
|
||||||
|
numOfMonth *= 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm tm;
|
||||||
|
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||||
|
taosLocalTime(&tt, &tm);
|
||||||
|
int32_t mon = tm.tm_year * 12 + tm.tm_mon - (int32_t)numOfMonth;
|
||||||
|
tm.tm_year = mon / 12;
|
||||||
|
tm.tm_mon = mon % 12;
|
||||||
|
|
||||||
|
return (int64_t)(taosMktime(&tm) * TSDB_TICK_PER_SECOND(precision));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision) {
|
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision) {
|
||||||
if (ekey < skey) {
|
if (ekey < skey) {
|
||||||
int64_t tmp = ekey;
|
int64_t tmp = ekey;
|
||||||
|
|
|
@ -168,7 +168,12 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
||||||
|
|
||||||
dTrace("msg:%p, is created and will put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType));
|
dTrace("msg:%p, is created and will put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType));
|
||||||
return mmPutMsgToWorker(pMgmt, pWorker, pMsg);
|
int32_t code = mmPutMsgToWorker(pMgmt, pWorker, pMsg);
|
||||||
|
if (code != 0) {
|
||||||
|
dTrace("msg:%p, is freed", pMsg);
|
||||||
|
taosFreeQitem(pMsg);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||||
|
|
|
@ -781,7 +781,13 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
const char *options[] = {
|
||||||
|
"debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag",
|
||||||
|
"tsdbDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag",
|
||||||
|
"tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag",
|
||||||
|
};
|
||||||
|
int32_t optionSize = tListLen(options);
|
||||||
|
|
||||||
SMCfgDnodeReq cfgReq = {0};
|
SMCfgDnodeReq cfgReq = {0};
|
||||||
if (tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq) != 0) {
|
if (tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq) != 0) {
|
||||||
|
@ -802,27 +808,52 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
SEpSet epSet = mndGetDnodeEpset(pDnode);
|
SEpSet epSet = mndGetDnodeEpset(pDnode);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
|
||||||
|
|
||||||
SDCfgDnodeReq dcfgReq = {0};
|
SDCfgDnodeReq dcfgReq = {0};
|
||||||
if (strncasecmp(cfgReq.config, "debugFlag", 9) == 0) {
|
if (strcasecmp(cfgReq.config, "resetlog") == 0) {
|
||||||
|
strcpy(dcfgReq.config, "resetlog");
|
||||||
|
} else if (strncasecmp(cfgReq.config, "monitor", 7) == 0) {
|
||||||
const char *value = cfgReq.value;
|
const char *value = cfgReq.value;
|
||||||
int32_t flag = atoi(value);
|
int32_t flag = atoi(value);
|
||||||
if (flag <= 0) {
|
if (flag <= 0) {
|
||||||
flag = atoi(cfgReq.config + 10);
|
flag = atoi(cfgReq.config + 8);
|
||||||
}
|
}
|
||||||
if (flag <= 0 || flag > 255) {
|
if (flag < 0 || flag > 2) {
|
||||||
mError("dnode:%d, failed to config debugFlag since value:%d", cfgReq.dnodeId, flag);
|
mError("dnode:%d, failed to config monitor since value:%d", cfgReq.dnodeId, flag);
|
||||||
terrno = TSDB_CODE_INVALID_CFG;
|
terrno = TSDB_CODE_INVALID_CFG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(dcfgReq.config, "debugFlag");
|
strcpy(dcfgReq.config, "monitor");
|
||||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
||||||
} else if (strcasecmp(cfgReq.config, "resetlog") == 0) {
|
|
||||||
strcpy(dcfgReq.config, "resetlog");
|
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_INVALID_CFG;
|
bool findOpt = false;
|
||||||
mError("dnode:%d, failed to config since %s", cfgReq.dnodeId, terrstr());
|
for (int32_t d = 0; d < optionSize; ++d) {
|
||||||
return -1;
|
const char *optName = options[d];
|
||||||
|
int32_t optLen = strlen(optName);
|
||||||
|
if (strncasecmp(cfgReq.config, optName, optLen) != 0) continue;
|
||||||
|
|
||||||
|
const char *value = cfgReq.value;
|
||||||
|
int32_t flag = atoi(value);
|
||||||
|
if (flag <= 0) {
|
||||||
|
flag = atoi(cfgReq.config + optLen + 1);
|
||||||
|
}
|
||||||
|
if (flag <= 0 || flag > 255) {
|
||||||
|
mError("dnode:%d, failed to config %s since value:%d", cfgReq.dnodeId, optName, flag);
|
||||||
|
terrno = TSDB_CODE_INVALID_CFG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tstrncpy(dcfgReq.config, optName, optLen + 1);
|
||||||
|
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
||||||
|
findOpt = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!findOpt) {
|
||||||
|
terrno = TSDB_CODE_INVALID_CFG;
|
||||||
|
mError("dnode:%d, failed to config since %s", cfgReq.dnodeId, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, &dcfgReq);
|
int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, &dcfgReq);
|
||||||
|
@ -831,13 +862,14 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
if (pBuf == NULL) return -1;
|
if (pBuf == NULL) return -1;
|
||||||
tSerializeSDCfgDnodeReq(pBuf, bufLen, &dcfgReq);
|
tSerializeSDCfgDnodeReq(pBuf, bufLen, &dcfgReq);
|
||||||
|
|
||||||
mDebug("dnode:%d, send config req to dnode, app:%p", cfgReq.dnodeId, pReq->info.ahandle);
|
mInfo("dnode:%d, send config req to dnode, app:%p config:%s value:%s", cfgReq.dnodeId, pReq->info.ahandle,
|
||||||
|
dcfgReq.config, dcfgReq.value);
|
||||||
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen};
|
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen};
|
||||||
return tmsgSendReq(&epSet, &rpcMsg);
|
return tmsgSendReq(&epSet, &rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) {
|
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) {
|
||||||
mDebug("config rsp from dnode, app:%p", pRsp->info.ahandle);
|
mInfo("config rsp from dnode, app:%p", pRsp->info.ahandle);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,7 @@ bool mndIsMnode(SMnode *pMnode, int32_t dnodeId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
|
void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
|
||||||
|
#if 0
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
int32_t totalMnodes = sdbGetSize(pSdb, SDB_MNODE);
|
int32_t totalMnodes = sdbGetSize(pSdb, SDB_MNODE);
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
|
@ -237,6 +238,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
|
||||||
addEpIntoEpSet(pEpSet, pObj->pDnode->fqdn, pObj->pDnode->port);
|
addEpIntoEpSet(pEpSet, pObj->pDnode->fqdn, pObj->pDnode->port);
|
||||||
sdbRelease(pSdb, pObj);
|
sdbRelease(pSdb, pObj);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
syncGetRetryEpSet(pMnode->syncMgmt.sync, pEpSet);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetCreateMnodeRedoLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
|
static int32_t mndSetCreateMnodeRedoLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextStb(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextStb(SMnode *pMnode, void *pIter);
|
||||||
static int32_t mndProcessTableCfgReq(SRpcMsg *pReq);
|
static int32_t mndProcessTableCfgReq(SRpcMsg *pReq);
|
||||||
static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp);
|
static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp, void* alterOriData, int32_t alterOriDataLen);
|
||||||
|
|
||||||
int32_t mndInitStb(SMnode *pMnode) {
|
int32_t mndInitStb(SMnode *pMnode) {
|
||||||
SSdbTable table = {
|
SSdbTable table = {
|
||||||
|
@ -409,7 +409,7 @@ static FORCE_INLINE int32_t schemaExColIdCompare(const void *colId, const void *
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int32_t *pContLen) {
|
static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int32_t *pContLen, void* alterOriData, int32_t alterOriDataLen) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
int32_t contLen;
|
int32_t contLen;
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
|
@ -422,6 +422,8 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
||||||
req.name = (char *)tNameGetTableName(&name);
|
req.name = (char *)tNameGetTableName(&name);
|
||||||
req.suid = pStb->uid;
|
req.suid = pStb->uid;
|
||||||
req.rollup = pStb->ast1Len > 0 ? 1 : 0;
|
req.rollup = pStb->ast1Len > 0 ? 1 : 0;
|
||||||
|
req.alterOriData = alterOriData;
|
||||||
|
req.alterOriDataLen = alterOriDataLen;
|
||||||
// todo
|
// todo
|
||||||
req.schemaRow.nCols = pStb->numOfColumns;
|
req.schemaRow.nCols = pStb->numOfColumns;
|
||||||
req.schemaRow.version = pStb->colVer;
|
req.schemaRow.version = pStb->colVer;
|
||||||
|
@ -626,7 +628,7 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen);
|
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen, NULL, 0);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
@ -706,10 +708,10 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
|
||||||
memcpy(pDst->db, pDb->name, TSDB_DB_FNAME_LEN);
|
memcpy(pDst->db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||||
pDst->createdTime = taosGetTimestampMs();
|
pDst->createdTime = taosGetTimestampMs();
|
||||||
pDst->updateTime = pDst->createdTime;
|
pDst->updateTime = pDst->createdTime;
|
||||||
pDst->uid = (pCreate->source == 1) ? pCreate->suid : mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
|
pDst->uid = (pCreate->source == TD_REQ_FROM_TAOX) ? pCreate->suid : mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
|
||||||
pDst->dbUid = pDb->uid;
|
pDst->dbUid = pDb->uid;
|
||||||
pDst->tagVer = (pCreate->source != TD_REQ_FROM_APP) ? pCreate->tagVer : 1;
|
pDst->tagVer = 1;
|
||||||
pDst->colVer = (pCreate->source != TD_REQ_FROM_APP) ? pCreate->colVer : 1;
|
pDst->colVer = 1;
|
||||||
pDst->smaVer = 1;
|
pDst->smaVer = 1;
|
||||||
pDst->nextColId = 1;
|
pDst->nextColId = 1;
|
||||||
pDst->maxdelay[0] = pCreate->delay1;
|
pDst->maxdelay[0] = pCreate->delay1;
|
||||||
|
@ -849,6 +851,75 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndFindSuperTableTagIndex(const SStbObj *pStb, const char *tagName) {
|
||||||
|
for (int32_t tag = 0; tag < pStb->numOfTags; tag++) {
|
||||||
|
if (strcasecmp(pStb->pTags[tag].name, tagName) == 0) {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndFindSuperTableColumnIndex(const SStbObj *pStb, const char *colName) {
|
||||||
|
for (int32_t col = 0; col < pStb->numOfColumns; col++) {
|
||||||
|
if (strcasecmp(pStb->pColumns[col].name, colName) == 0) {
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndBuildStbFromAlter(SStbObj *pStb, SStbObj *pDst, SMCreateStbReq *createReq) {
|
||||||
|
taosRLockLatch(&pStb->lock);
|
||||||
|
memcpy(pDst, pStb, sizeof(SStbObj));
|
||||||
|
taosRUnLockLatch(&pStb->lock);
|
||||||
|
|
||||||
|
pDst->updateTime = taosGetTimestampMs();
|
||||||
|
pDst->numOfColumns = createReq->numOfColumns;
|
||||||
|
pDst->numOfTags = createReq->numOfTags;
|
||||||
|
pDst->pColumns = taosMemoryCalloc(1, pDst->numOfColumns * sizeof(SSchema));
|
||||||
|
pDst->pTags = taosMemoryCalloc(1, pDst->numOfTags * sizeof(SSchema));
|
||||||
|
if (pDst->pColumns == NULL || pDst->pTags == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pDst->numOfColumns; ++i) {
|
||||||
|
SField *pField = taosArrayGet(createReq->pColumns, i);
|
||||||
|
SSchema *pSchema = &pDst->pColumns[i];
|
||||||
|
pSchema->type = pField->type;
|
||||||
|
pSchema->bytes = pField->bytes;
|
||||||
|
pSchema->flags = pField->flags;
|
||||||
|
memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN);
|
||||||
|
int32_t cIndex = mndFindSuperTableColumnIndex(pStb, pField->name);
|
||||||
|
if (cIndex >= 0){
|
||||||
|
pSchema->colId = pStb->pColumns[cIndex].colId;
|
||||||
|
}else{
|
||||||
|
pSchema->colId = pDst->nextColId++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pDst->numOfTags; ++i) {
|
||||||
|
SField *pField = taosArrayGet(createReq->pTags, i);
|
||||||
|
SSchema *pSchema = &pDst->pTags[i];
|
||||||
|
pSchema->type = pField->type;
|
||||||
|
pSchema->bytes = pField->bytes;
|
||||||
|
memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN);
|
||||||
|
int32_t cIndex = mndFindSuperTableTagIndex(pStb, pField->name);
|
||||||
|
if (cIndex >= 0){
|
||||||
|
pSchema->colId = pStb->pTags[cIndex].colId;
|
||||||
|
}else{
|
||||||
|
pSchema->colId = pDst->nextColId++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
pDst->tagVer = createReq->tagVer;
|
||||||
|
pDst->colVer = createReq->colVer;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -881,9 +952,9 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
||||||
terrno = TSDB_CODE_MND_STABLE_UID_NOT_MATCH;
|
terrno = TSDB_CODE_MND_STABLE_UID_NOT_MATCH;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
} else if (createReq.tagVer > 0 || createReq.colVer > 0) {
|
} else if (createReq.tagVer > 0 || createReq.colVer > 0) {
|
||||||
int32_t tagDelta = pStb->tagVer - createReq.tagVer;
|
int32_t tagDelta = createReq.tagVer - pStb->tagVer;
|
||||||
int32_t colDelta = pStb->colVer - createReq.colVer;
|
int32_t colDelta = createReq.colVer - pStb->colVer;
|
||||||
int32_t verDelta = tagDelta + verDelta;
|
int32_t verDelta = tagDelta + colDelta;
|
||||||
mInfo("stb:%s, already exist while create, input tagVer:%d colVer:%d, exist tagVer:%d colVer:%d",
|
mInfo("stb:%s, already exist while create, input tagVer:%d colVer:%d, exist tagVer:%d colVer:%d",
|
||||||
createReq.name, createReq.tagVer, createReq.colVer, pStb->tagVer, pStb->colVer);
|
createReq.name, createReq.tagVer, createReq.colVer, pStb->tagVer, pStb->colVer);
|
||||||
if (tagDelta <= 0 && colDelta <= 0) {
|
if (tagDelta <= 0 && colDelta <= 0) {
|
||||||
|
@ -910,6 +981,10 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
} else if (terrno != TSDB_CODE_MND_STB_NOT_EXIST) {
|
} else if (terrno != TSDB_CODE_MND_STB_NOT_EXIST) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
} else if (createReq.source == TD_REQ_FROM_TAOX && (createReq.tagVer != 1 || createReq.colVer != 1)){
|
||||||
|
mInfo("stb:%s, alter table does not need to be done, because table is deleted", createReq.name);
|
||||||
|
code = 0;
|
||||||
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDb = mndAcquireDbByStb(pMnode, createReq.name);
|
pDb = mndAcquireDbByStb(pMnode, createReq.name);
|
||||||
|
@ -934,7 +1009,16 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
if (isAlter) {
|
if (isAlter) {
|
||||||
bool needRsp = false;
|
bool needRsp = false;
|
||||||
code = mndAlterStbImp(pMnode, pReq, pDb, pStb, needRsp);
|
SStbObj pDst = {0};
|
||||||
|
if (mndBuildStbFromAlter(pStb, &pDst, &createReq) != 0) {
|
||||||
|
taosMemoryFreeClear(pDst.pTags);
|
||||||
|
taosMemoryFreeClear(pDst.pColumns);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndAlterStbImp(pMnode, pReq, pDb, &pDst, needRsp, NULL, 0);
|
||||||
|
taosMemoryFreeClear(pDst.pTags);
|
||||||
|
taosMemoryFreeClear(pDst.pColumns);
|
||||||
} else {
|
} else {
|
||||||
code = mndCreateStb(pMnode, pReq, &createReq, pDb);
|
code = mndCreateStb(pMnode, pReq, &createReq, pDb);
|
||||||
}
|
}
|
||||||
|
@ -972,26 +1056,6 @@ static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndFindSuperTableTagIndex(const SStbObj *pStb, const char *tagName) {
|
|
||||||
for (int32_t tag = 0; tag < pStb->numOfTags; tag++) {
|
|
||||||
if (strcasecmp(pStb->pTags[tag].name, tagName) == 0) {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndFindSuperTableColumnIndex(const SStbObj *pStb, const char *colName) {
|
|
||||||
for (int32_t col = 0; col < pStb->numOfColumns; col++) {
|
|
||||||
if (strcasecmp(pStb->pColumns[col].name, colName) == 0) {
|
|
||||||
return col;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
|
static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
|
||||||
pNew->pTags = taosMemoryCalloc(pNew->numOfTags, sizeof(SSchema));
|
pNew->pTags = taosMemoryCalloc(pNew->numOfTags, sizeof(SSchema));
|
||||||
pNew->pColumns = taosMemoryCalloc(pNew->numOfColumns, sizeof(SSchema));
|
pNew->pColumns = taosMemoryCalloc(pNew->numOfColumns, sizeof(SSchema));
|
||||||
|
@ -1315,7 +1379,7 @@ static int32_t mndSetAlterStbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb, void* alterOriData, int32_t alterOriDataLen) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SVgObj *pVgroup = NULL;
|
SVgObj *pVgroup = NULL;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
|
@ -1329,7 +1393,7 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen);
|
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen, alterOriData, alterOriDataLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
@ -1542,7 +1606,7 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, SStbObj *pObj, void **pCont, i
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp) {
|
static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp, void* alterOriData, int32_t alterOriDataLen) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq);
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
|
@ -1559,7 +1623,7 @@ static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbOb
|
||||||
|
|
||||||
if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) goto _OVER;
|
if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) goto _OVER;
|
||||||
if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, pStb) != 0) goto _OVER;
|
if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, pStb) != 0) goto _OVER;
|
||||||
if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, pStb) != 0) goto _OVER;
|
if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, pStb, alterOriData, alterOriDataLen) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
@ -1620,7 +1684,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != 0) goto _OVER;
|
if (code != 0) goto _OVER;
|
||||||
code = mndAlterStbImp(pMnode, pReq, pDb, &stbObj, needRsp);
|
code = mndAlterStbImp(pMnode, pReq, pDb, &stbObj, needRsp, pReq->pCont, pReq->contLen);
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
taosMemoryFreeClear(stbObj.pTags);
|
taosMemoryFreeClear(stbObj.pTags);
|
||||||
|
@ -1785,8 +1849,8 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropReq.source != TD_REQ_FROM_APP && pStb->uid != dropReq.suid) {
|
if (dropReq.source == TD_REQ_FROM_TAOX && pStb->uid != dropReq.suid) {
|
||||||
terrno = TSDB_CODE_MND_STB_NOT_EXIST;
|
code = 0;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@ typedef struct SSdbRow {
|
||||||
ESdbType type;
|
ESdbType type;
|
||||||
ESdbStatus status;
|
ESdbStatus status;
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
|
int64_t forAlign;
|
||||||
char pObj[];
|
char pObj[];
|
||||||
} SSdbRow;
|
} SSdbRow;
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ void *tsdbGetIdx(SMeta *pMeta);
|
||||||
void *tsdbGetIvtIdx(SMeta *pMeta);
|
void *tsdbGetIvtIdx(SMeta *pMeta);
|
||||||
|
|
||||||
int32_t tsdbLastRowReaderOpen(void *pVnode, int32_t type, SArray *pTableIdList, int32_t numOfCols, void **pReader);
|
int32_t tsdbLastRowReaderOpen(void *pVnode, int32_t type, SArray *pTableIdList, int32_t numOfCols, void **pReader);
|
||||||
int32_t tsdbRetrieveLastRow(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds);
|
int32_t tsdbRetrieveLastRow(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray* pTableUids);
|
||||||
int32_t tsdbLastrowReaderClose(void *pReader);
|
int32_t tsdbLastrowReaderClose(void *pReader);
|
||||||
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
||||||
|
|
||||||
|
|
|
@ -1125,6 +1125,11 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
skmDbKey.uid = pME->uid;
|
skmDbKey.uid = pME->uid;
|
||||||
skmDbKey.sver = pSW->version;
|
skmDbKey.sver = pSW->version;
|
||||||
|
|
||||||
|
// if receive tmq meta message is: create stable1 then delete stable1 then create stable1 with multi vgroups
|
||||||
|
if (tdbTbGet(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), NULL, NULL) == 0) {
|
||||||
|
return rcode;
|
||||||
|
}
|
||||||
|
|
||||||
// encode schema
|
// encode schema
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
tEncodeSize(tEncodeSSchemaWrapper, pSW, vLen, ret);
|
tEncodeSize(tEncodeSSchemaWrapper, pSW, vLen, ret);
|
||||||
|
|
|
@ -408,7 +408,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
tqDebug("fetch meta msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType);
|
tqDebug("fetch meta msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType);
|
||||||
SMqMetaRsp metaRsp = {0};
|
SMqMetaRsp metaRsp = {0};
|
||||||
/*metaRsp.reqOffset = pReq->reqOffset.version;*/
|
/*metaRsp.reqOffset = pReq->reqOffset.version;*/
|
||||||
/*metaRsp.rspOffset = fetchVer;*/
|
metaRsp.rspOffset = fetchVer;
|
||||||
/*metaRsp.rspOffsetNew.version = fetchVer;*/
|
/*metaRsp.rspOffsetNew.version = fetchVer;*/
|
||||||
tqOffsetResetToLog(&metaRsp.reqOffsetNew, pReq->reqOffset.version);
|
tqOffsetResetToLog(&metaRsp.reqOffsetNew, pReq->reqOffset.version);
|
||||||
tqOffsetResetToLog(&metaRsp.rspOffsetNew, fetchVer);
|
tqOffsetResetToLog(&metaRsp.rspOffsetNew, fetchVer);
|
||||||
|
|
|
@ -332,7 +332,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FAIL:
|
FAIL:
|
||||||
tDeleteSSDataBlock(pBlock);
|
blockDataFreeRes(pBlock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
|
||||||
|
|
||||||
SVCreateTbReq createTbReq = {0};
|
SVCreateTbReq createTbReq = {0};
|
||||||
createTbReq.name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId);
|
createTbReq.name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId);
|
||||||
|
createTbReq.ctb.name = strdup(stbFullName);
|
||||||
createTbReq.flags = 0;
|
createTbReq.flags = 0;
|
||||||
createTbReq.type = TSDB_CHILD_TABLE;
|
createTbReq.type = TSDB_CHILD_TABLE;
|
||||||
createTbReq.ctb.suid = suid;
|
createTbReq.ctb.suid = suid;
|
||||||
|
|
|
@ -22,11 +22,11 @@ typedef struct SLastrowReader {
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
STSchema* pSchema;
|
STSchema* pSchema;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
char** transferBuf; // todo remove it soon
|
char** transferBuf; // todo remove it soon
|
||||||
int32_t numOfCols;
|
int32_t numOfCols;
|
||||||
int32_t type;
|
int32_t type;
|
||||||
int32_t tableIndex; // currently returned result tables
|
int32_t tableIndex; // currently returned result tables
|
||||||
SArray* pTableList; // table id list
|
SArray* pTableList; // table id list
|
||||||
} SLastrowReader;
|
} SLastrowReader;
|
||||||
|
|
||||||
static void saveOneRow(STSRow* pRow, SSDataBlock* pBlock, SLastrowReader* pReader, const int32_t* slotIds) {
|
static void saveOneRow(STSRow* pRow, SSDataBlock* pBlock, SLastrowReader* pReader, const int32_t* slotIds) {
|
||||||
|
@ -94,17 +94,20 @@ int32_t tsdbLastRowReaderOpen(void* pVnode, int32_t type, SArray* pTableIdList,
|
||||||
int32_t tsdbLastrowReaderClose(void* pReader) {
|
int32_t tsdbLastrowReaderClose(void* pReader) {
|
||||||
SLastrowReader* p = pReader;
|
SLastrowReader* p = pReader;
|
||||||
|
|
||||||
for (int32_t i = 0; i < p->pSchema->numOfCols; ++i) {
|
if (p->pSchema != NULL) {
|
||||||
taosMemoryFreeClear(p->transferBuf[i]);
|
for (int32_t i = 0; i < p->pSchema->numOfCols; ++i) {
|
||||||
|
taosMemoryFreeClear(p->transferBuf[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(p->transferBuf);
|
||||||
|
taosMemoryFree(p->pSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(p->pSchema);
|
|
||||||
taosMemoryFree(p->transferBuf);
|
|
||||||
taosMemoryFree(pReader);
|
taosMemoryFree(pReader);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t* slotIds) {
|
int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t* slotIds, SArray* pTableUidList) {
|
||||||
if (pReader == NULL || pResBlock == NULL) {
|
if (pReader == NULL || pResBlock == NULL) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
@ -141,14 +144,15 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t
|
||||||
// appended or not.
|
// appended or not.
|
||||||
if (internalResult) {
|
if (internalResult) {
|
||||||
pResBlock->info.rows -= 1;
|
pResBlock->info.rows -= 1;
|
||||||
|
taosArrayClear(pTableUidList);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveOneRow(pRow, pResBlock, pr, slotIds);
|
saveOneRow(pRow, pResBlock, pr, slotIds);
|
||||||
|
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
||||||
internalResult = true;
|
internalResult = true;
|
||||||
lastKey = pRow->ts;
|
lastKey = pRow->ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
// taosMemoryFree(pRow);
|
|
||||||
tsdbCacheRelease(lruCache, h);
|
tsdbCacheRelease(lruCache, h);
|
||||||
}
|
}
|
||||||
} else if (pr->type == LASTROW_RETRIEVE_TYPE_ALL) {
|
} else if (pr->type == LASTROW_RETRIEVE_TYPE_ALL) {
|
||||||
|
@ -171,6 +175,7 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t
|
||||||
// tsdbCacheLastArray2Row(pLast, &pRow, pr->pSchema);
|
// tsdbCacheLastArray2Row(pLast, &pRow, pr->pSchema);
|
||||||
|
|
||||||
saveOneRow(pRow, pResBlock, pr, slotIds);
|
saveOneRow(pRow, pResBlock, pr, slotIds);
|
||||||
|
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
||||||
|
|
||||||
// taosMemoryFree(pRow);
|
// taosMemoryFree(pRow);
|
||||||
tsdbCacheRelease(lruCache, h);
|
tsdbCacheRelease(lruCache, h);
|
||||||
|
|
|
@ -209,10 +209,10 @@ static void resetDataBlockScanInfo(SHashObj* pTableMap) {
|
||||||
p->iterInit = false;
|
p->iterInit = false;
|
||||||
p->iiter.hasVal = false;
|
p->iiter.hasVal = false;
|
||||||
if (p->iter.iter != NULL) {
|
if (p->iter.iter != NULL) {
|
||||||
tsdbTbDataIterDestroy(p->iter.iter);
|
p->iter.iter = tsdbTbDataIterDestroy(p->iter.iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(p->delSkyline);
|
p->delSkyline = taosArrayDestroy(p->delSkyline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,17 +224,15 @@ static void destroyBlockScanInfo(SHashObj* pTableMap) {
|
||||||
p->iiter.hasVal = false;
|
p->iiter.hasVal = false;
|
||||||
|
|
||||||
if (p->iter.iter != NULL) {
|
if (p->iter.iter != NULL) {
|
||||||
tsdbTbDataIterDestroy(p->iter.iter);
|
p->iter.iter = tsdbTbDataIterDestroy(p->iter.iter);
|
||||||
p->iter.iter = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->iiter.iter != NULL) {
|
if (p->iiter.iter != NULL) {
|
||||||
tsdbTbDataIterDestroy(p->iiter.iter);
|
p->iiter.iter = tsdbTbDataIterDestroy(p->iiter.iter);
|
||||||
p->iiter.iter = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(p->delSkyline);
|
p->delSkyline = taosArrayDestroy(p->delSkyline);
|
||||||
p->delSkyline = NULL;
|
p->pBlockList = taosArrayDestroy(p->pBlockList);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashCleanup(pTableMap);
|
taosHashCleanup(pTableMap);
|
||||||
|
@ -302,9 +300,9 @@ static bool filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader) {
|
||||||
STimeWindow win = {0};
|
STimeWindow win = {0};
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// if (pReader->pFileReader != NULL) {
|
if (pReader->pFileReader != NULL) {
|
||||||
// tsdbDataFReaderClose(&pReader->pFileReader);
|
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||||
// }
|
}
|
||||||
|
|
||||||
pReader->status.pCurrentFileset = (SDFileSet*)taosArrayGet(pIter->pFileList, pIter->index);
|
pReader->status.pCurrentFileset = (SDFileSet*)taosArrayGet(pIter->pFileList, pIter->index);
|
||||||
|
|
||||||
|
@ -696,12 +694,14 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, uint32_
|
||||||
|
|
||||||
void* p = taosArrayPush(pScanInfo->pBlockList, &block);
|
void* p = taosArrayPush(pScanInfo->pBlockList, &block);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
|
tMapDataClear(&mapData);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*numOfBlocks) += 1;
|
(*numOfBlocks) += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tMapDataClear(&mapData);
|
||||||
if (pScanInfo->pBlockList != NULL && taosArrayGetSize(pScanInfo->pBlockList) > 0) {
|
if (pScanInfo->pBlockList != NULL && taosArrayGetSize(pScanInfo->pBlockList) > 0) {
|
||||||
(*numOfValidTables) += 1;
|
(*numOfValidTables) += 1;
|
||||||
}
|
}
|
||||||
|
@ -1308,6 +1308,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
||||||
pReader->idStr);
|
pReader->idStr);
|
||||||
|
|
||||||
pBlockIter->index = asc ? 0 : (numOfBlocks - 1);
|
pBlockIter->index = asc ? 0 : (numOfBlocks - 1);
|
||||||
|
|
||||||
|
cleanupBlockOrderSupporter(&sup);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1990,6 +1992,7 @@ static TSDBKEY getCurrentKeyInBuf(SDataBlockIter* pBlockIter, STsdbReader* pRead
|
||||||
|
|
||||||
static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) {
|
static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) {
|
||||||
SReaderStatus* pStatus = &pReader->status;
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
|
SArray* pIndexList = taosArrayInit(4, sizeof(SBlockIdx));
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
bool hasNext = filesetIteratorNext(&pStatus->fileIter, pReader);
|
bool hasNext = filesetIteratorNext(&pStatus->fileIter, pReader);
|
||||||
|
@ -1997,9 +2000,10 @@ static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* pIndexList = taosArrayInit(4, sizeof(SBlockIdx));
|
taosArrayClear(pIndexList);
|
||||||
int32_t code = doLoadBlockIndex(pReader, pReader->pFileReader, pIndexList);
|
int32_t code = doLoadBlockIndex(pReader, pReader->pFileReader, pIndexList);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosArrayDestroy(pIndexList);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2007,6 +2011,7 @@ static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) {
|
||||||
uint32_t numOfValidTable = 0;
|
uint32_t numOfValidTable = 0;
|
||||||
code = doLoadFileBlock(pReader, pIndexList, &numOfValidTable, numOfBlocks);
|
code = doLoadFileBlock(pReader, pIndexList, &numOfValidTable, numOfBlocks);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosArrayDestroy(pIndexList);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2014,10 +2019,10 @@ static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// no blocks in current file, try next files
|
// no blocks in current file, try next files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pIndexList);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3081,10 +3086,13 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
|
||||||
|
|
||||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||||
pTableBlockInfo->numOfFiles += pStatus->fileIter.numOfFiles;
|
pTableBlockInfo->numOfFiles += pStatus->fileIter.numOfFiles;
|
||||||
pTableBlockInfo->numOfBlocks += pBlockIter->numOfBlocks;
|
|
||||||
|
if (pBlockIter->numOfBlocks > 0) {
|
||||||
|
pTableBlockInfo->numOfBlocks += pBlockIter->numOfBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
pTableBlockInfo->numOfTables = numOfTables;
|
pTableBlockInfo->numOfTables = numOfTables;
|
||||||
bool hasNext = true;
|
bool hasNext = (pBlockIter->numOfBlocks > 0);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (hasNext) {
|
if (hasNext) {
|
||||||
|
|
|
@ -494,8 +494,6 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
|
||||||
taosArrayPush(rsp.pArray, &cRsp);
|
taosArrayPush(rsp.pArray, &cRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
|
||||||
|
|
||||||
tqUpdateTbUidList(pVnode->pTq, tbUids, true);
|
tqUpdateTbUidList(pVnode->pTq, tbUids, true);
|
||||||
tdUpdateTbUidList(pVnode->pSma, pStore);
|
tdUpdateTbUidList(pVnode->pSma, pStore);
|
||||||
tdUidStoreFree(pStore);
|
tdUidStoreFree(pStore);
|
||||||
|
@ -512,9 +510,12 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
|
||||||
}
|
}
|
||||||
tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen);
|
tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen);
|
||||||
tEncodeSVCreateTbBatchRsp(&encoder, &rsp);
|
tEncodeSVCreateTbBatchRsp(&encoder, &rsp);
|
||||||
tEncoderClear(&encoder);
|
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
|
pCreateReq = req.pReqs + iReq;
|
||||||
|
taosArrayDestroy(pCreateReq->ctb.tagName);
|
||||||
|
}
|
||||||
taosArrayDestroy(rsp.pArray);
|
taosArrayDestroy(rsp.pArray);
|
||||||
taosArrayDestroy(tbUids);
|
taosArrayDestroy(tbUids);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -611,7 +612,7 @@ static int32_t vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pRe
|
||||||
|
|
||||||
// process
|
// process
|
||||||
if (metaAlterTable(pVnode->pMeta, version, &vAlterTbReq, &vMetaRsp) < 0) {
|
if (metaAlterTable(pVnode->pMeta, version, &vAlterTbReq, &vMetaRsp) < 0) {
|
||||||
vAlterTbRsp.code = TSDB_CODE_INVALID_MSG;
|
vAlterTbRsp.code = terrno;
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
rcode = -1;
|
rcode = -1;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -795,6 +796,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
if (tDecodeSVCreateTbReq(&decoder, &createTbReq) < 0) {
|
if (tDecodeSVCreateTbReq(&decoder, &createTbReq) < 0) {
|
||||||
pRsp->code = TSDB_CODE_INVALID_MSG;
|
pRsp->code = TSDB_CODE_INVALID_MSG;
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
taosArrayDestroy(createTbReq.ctb.tagName);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,6 +804,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
||||||
submitBlkRsp.code = terrno;
|
submitBlkRsp.code = terrno;
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
taosArrayDestroy(createTbReq.ctb.tagName);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -822,6 +825,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
vnodeDebugPrintSingleSubmitMsg(pVnode->pMeta, pBlock, &msgIter, "real uid");
|
vnodeDebugPrintSingleSubmitMsg(pVnode->pMeta, pBlock, &msgIter, "real uid");
|
||||||
#endif
|
#endif
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
taosArrayDestroy(createTbReq.ctb.tagName);
|
||||||
} else {
|
} else {
|
||||||
submitBlkRsp.tblFName = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN);
|
submitBlkRsp.tblFName = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN);
|
||||||
sprintf(submitBlkRsp.tblFName, "%s.", pVnode->config.dbname);
|
sprintf(submitBlkRsp.tblFName, "%s.", pVnode->config.dbname);
|
||||||
|
|
|
@ -427,13 +427,22 @@ static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta c
|
||||||
syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state,
|
syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state,
|
||||||
syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType));
|
syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType));
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen};
|
if (cbMeta.code == 0) {
|
||||||
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen};
|
||||||
memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen);
|
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
||||||
syncGetAndDelRespRpc(pVnode->sync, cbMeta.seqNum, &rpcMsg.info);
|
memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen);
|
||||||
rpcMsg.info.conn.applyIndex = cbMeta.index;
|
syncGetAndDelRespRpc(pVnode->sync, cbMeta.seqNum, &rpcMsg.info);
|
||||||
rpcMsg.info.conn.applyTerm = cbMeta.term;
|
rpcMsg.info.conn.applyIndex = cbMeta.index;
|
||||||
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg);
|
rpcMsg.info.conn.applyTerm = cbMeta.term;
|
||||||
|
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg);
|
||||||
|
} else {
|
||||||
|
SRpcMsg rsp = {.code = cbMeta.code, .info = pMsg->info};
|
||||||
|
vError("vgId:%d, sync commit error, msgtype:%d,%s, error:0x%X, errmsg:%s", syncGetVgId(pVnode->sync), pMsg->msgType,
|
||||||
|
TMSG_INFO(pMsg->msgType), cbMeta.code, tstrerror(cbMeta.code));
|
||||||
|
if (rsp.info.handle != NULL) {
|
||||||
|
tmsgSendRsp(&rsp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vnodeSyncPreCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
static void vnodeSyncPreCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||||
|
|
|
@ -1293,7 +1293,7 @@ void catalogDestroy(void) {
|
||||||
|
|
||||||
if (!taosCheckCurrentInDll()) {
|
if (!taosCheckCurrentInDll()) {
|
||||||
ctgClearCacheEnqueue(NULL, true, true, true);
|
ctgClearCacheEnqueue(NULL, true, true, true);
|
||||||
taosThreadJoin(gCtgMgmt.updateThread, NULL);
|
taosThreadJoin(gCtgMgmt.updateThread, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashCleanup(gCtgMgmt.pCluster);
|
taosHashCleanup(gCtgMgmt.pCluster);
|
||||||
|
|
|
@ -570,10 +570,14 @@ int32_t buildSelectResultDataBlock(SNodeList* pProjects, SSDataBlock* pBlock) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
SNode* pProj = NULL;
|
SNode* pProj = NULL;
|
||||||
FOREACH(pProj, pProjects) {
|
FOREACH(pProj, pProjects) {
|
||||||
if (((SValueNode*)pProj)->isNull) {
|
if (QUERY_NODE_VALUE != nodeType(pProj)) {
|
||||||
colDataAppend(taosArrayGet(pBlock->pDataBlock, index++), 0, NULL, true);
|
return TSDB_CODE_PAR_INVALID_SELECTED_EXPR;
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(taosArrayGet(pBlock->pDataBlock, index++), 0, nodesGetValueFromNode((SValueNode*)pProj), false);
|
if (((SValueNode*)pProj)->isNull) {
|
||||||
|
colDataAppend(taosArrayGet(pBlock->pDataBlock, index++), 0, NULL, true);
|
||||||
|
} else {
|
||||||
|
colDataAppend(taosArrayGet(pBlock->pDataBlock, index++), 0, nodesGetValueFromNode((SValueNode*)pProj), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -321,6 +321,7 @@ typedef struct SLastrowScanInfo {
|
||||||
void *pLastrowReader;
|
void *pLastrowReader;
|
||||||
SArray *pColMatchInfo;
|
SArray *pColMatchInfo;
|
||||||
int32_t *pSlotIds;
|
int32_t *pSlotIds;
|
||||||
|
SExprSupp pseudoExprSup;
|
||||||
} SLastrowScanInfo;
|
} SLastrowScanInfo;
|
||||||
|
|
||||||
typedef enum EStreamScanMode {
|
typedef enum EStreamScanMode {
|
||||||
|
@ -789,6 +790,8 @@ int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaul
|
||||||
|
|
||||||
void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
||||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock);
|
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock);
|
||||||
|
int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr,
|
||||||
|
SSDataBlock* pBlock, const char* idStr);
|
||||||
|
|
||||||
void cleanupAggSup(SAggSupporter* pAggSup);
|
void cleanupAggSup(SAggSupporter* pAggSup);
|
||||||
void destroyBasicOperatorInfo(void* param, int32_t numOfOutput);
|
void destroyBasicOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
|
|
|
@ -45,20 +45,20 @@ SOperatorInfo* createLastrowScanOperator(SLastRowScanPhysiNode* pScanNode, SRead
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
pInfo->pColMatchInfo = extractColMatchInfo(pScanNode->pScanCols, pScanNode->node.pOutputDataBlockDesc, &numOfCols,
|
pInfo->pColMatchInfo = extractColMatchInfo(pScanNode->pScanCols, pScanNode->node.pOutputDataBlockDesc, &numOfCols,
|
||||||
COL_MATCH_FROM_COL_ID);
|
COL_MATCH_FROM_COL_ID);
|
||||||
int32_t* pCols = taosMemoryMalloc(numOfCols * sizeof(int32_t));
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->pColMatchInfo); ++i) {
|
|
||||||
SColMatchInfo* pColMatch = taosArrayGet(pInfo->pColMatchInfo, i);
|
|
||||||
pCols[i] = pColMatch->colId;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t code = extractTargetSlotId(pInfo->pColMatchInfo, pTaskInfo, &pInfo->pSlotIds);
|
int32_t code = extractTargetSlotId(pInfo->pColMatchInfo, pTaskInfo, &pInfo->pSlotIds);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbLastRowReaderOpen(readHandle->vnode, LASTROW_RETRIEVE_TYPE_ALL, pTableList, taosArrayGetSize(pInfo->pColMatchInfo),
|
tsdbLastRowReaderOpen(readHandle->vnode, LASTROW_RETRIEVE_TYPE_SINGLE, pTableList, taosArrayGetSize(pInfo->pColMatchInfo),
|
||||||
&pInfo->pLastrowReader);
|
&pInfo->pLastrowReader);
|
||||||
taosMemoryFree(pCols);
|
|
||||||
|
if (pScanNode->pScanPseudoCols != NULL) {
|
||||||
|
SExprSupp* pPseudoExpr = &pInfo->pseudoExprSup;
|
||||||
|
|
||||||
|
pPseudoExpr->pExprInfo = createExprInfo(pScanNode->pScanPseudoCols, NULL, &pPseudoExpr->numOfExprs);
|
||||||
|
pPseudoExpr->pCtx = createSqlFunctionCtx(pPseudoExpr->pExprInfo, pPseudoExpr->numOfExprs, &pPseudoExpr->rowEntryInfoOffset);
|
||||||
|
}
|
||||||
|
|
||||||
pOperator->name = "LastrowScanOperator";
|
pOperator->name = "LastrowScanOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN;
|
||||||
|
@ -100,7 +100,20 @@ SSDataBlock* doScanLastrow(SOperatorInfo* pOperator) {
|
||||||
// check if it is a group by tbname
|
// check if it is a group by tbname
|
||||||
if (size == taosArrayGetSize(pInfo->pTableList)) {
|
if (size == taosArrayGetSize(pInfo->pTableList)) {
|
||||||
blockDataCleanup(pInfo->pRes);
|
blockDataCleanup(pInfo->pRes);
|
||||||
tsdbRetrieveLastRow(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds);
|
SArray* pUidList = taosArrayInit(1, sizeof(tb_uid_t));
|
||||||
|
int32_t code = tsdbRetrieveLastRow(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pUidList);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
longjmp(pTaskInfo->env, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for tag values
|
||||||
|
if (pInfo->pRes->info.rows > 0 && pInfo->pseudoExprSup.numOfExprs > 0) {
|
||||||
|
SExprSupp* pSup = &pInfo->pseudoExprSup;
|
||||||
|
pInfo->pRes->info.uid = *(tb_uid_t*) taosArrayGet(pUidList, 0);
|
||||||
|
addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pInfo->pRes, GET_TASKID(pTaskInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||||
} else {
|
} else {
|
||||||
// todo fetch the result for each group
|
// todo fetch the result for each group
|
||||||
|
|
|
@ -307,7 +307,6 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
|
||||||
SNode* pTagIndexCond = (SNode*)pListInfo->pTagIndexCond;
|
SNode* pTagIndexCond = (SNode*)pListInfo->pTagIndexCond;
|
||||||
if (pScanNode->tableType == TSDB_SUPER_TABLE) {
|
if (pScanNode->tableType == TSDB_SUPER_TABLE) {
|
||||||
if (pTagIndexCond) {
|
if (pTagIndexCond) {
|
||||||
///<<<<<<< HEAD
|
|
||||||
SIndexMetaArg metaArg = {
|
SIndexMetaArg metaArg = {
|
||||||
.metaEx = metaHandle, .idx = tsdbGetIdx(metaHandle), .ivtIdx = tsdbGetIvtIdx(metaHandle), .suid = tableUid};
|
.metaEx = metaHandle, .idx = tsdbGetIdx(metaHandle), .ivtIdx = tsdbGetIvtIdx(metaHandle), .suid = tableUid};
|
||||||
|
|
||||||
|
@ -315,20 +314,9 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
|
||||||
SIdxFltStatus status = SFLT_NOT_INDEX;
|
SIdxFltStatus status = SFLT_NOT_INDEX;
|
||||||
code = doFilterTag(pTagIndexCond, &metaArg, res, &status);
|
code = doFilterTag(pTagIndexCond, &metaArg, res, &status);
|
||||||
if (code != 0 || status == SFLT_NOT_INDEX) {
|
if (code != 0 || status == SFLT_NOT_INDEX) {
|
||||||
code = TSDB_CODE_INDEX_REBUILDING;
|
qError("failed to get tableIds from index, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid);
|
||||||
}
|
// code = TSDB_CODE_INDEX_REBUILDING;
|
||||||
//=======
|
|
||||||
// SArray* res = taosArrayInit(8, sizeof(uint64_t));
|
|
||||||
// // code = doFilterTag(pTagIndexCond, &metaArg, res);
|
|
||||||
// code = TSDB_CODE_INDEX_REBUILDING;
|
|
||||||
//>>>>>>> dvv
|
|
||||||
if (code == TSDB_CODE_INDEX_REBUILDING) {
|
|
||||||
code = vnodeGetAllTableList(pVnode, tableUid, pListInfo->pTableList);
|
code = vnodeGetAllTableList(pVnode, tableUid, pListInfo->pTableList);
|
||||||
} else if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
qError("failed to get tableIds, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid);
|
|
||||||
taosArrayDestroy(res);
|
|
||||||
terrno = code;
|
|
||||||
return code;
|
|
||||||
} else {
|
} else {
|
||||||
qDebug("success to get tableIds, size:%d, suid:%" PRIu64, (int)taosArrayGetSize(res), tableUid);
|
qDebug("success to get tableIds, size:%d, suid:%" PRIu64, (int)taosArrayGetSize(res), tableUid);
|
||||||
}
|
}
|
||||||
|
@ -347,25 +335,25 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTagCond) {
|
|
||||||
int32_t i = 0;
|
|
||||||
while (i < taosArrayGetSize(pListInfo->pTableList)) {
|
|
||||||
STableKeyInfo* info = taosArrayGet(pListInfo->pTableList, i);
|
|
||||||
bool isOk = isTableOk(info, pTagCond, metaHandle);
|
|
||||||
if (terrno) return terrno;
|
|
||||||
if (!isOk) {
|
|
||||||
taosArrayRemove(pListInfo->pTableList, i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // Create one table group.
|
} else { // Create one table group.
|
||||||
STableKeyInfo info = {.lastKey = 0, .uid = tableUid, .groupId = 0};
|
STableKeyInfo info = {.lastKey = 0, .uid = tableUid, .groupId = 0};
|
||||||
taosArrayPush(pListInfo->pTableList, &info);
|
taosArrayPush(pListInfo->pTableList, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pTagCond) {
|
||||||
|
int32_t i = 0;
|
||||||
|
while (i < taosArrayGetSize(pListInfo->pTableList)) {
|
||||||
|
STableKeyInfo* info = taosArrayGet(pListInfo->pTableList, i);
|
||||||
|
bool isOk = isTableOk(info, pTagCond, metaHandle);
|
||||||
|
if (terrno) return terrno;
|
||||||
|
if (!isOk) {
|
||||||
|
taosArrayRemove(pListInfo->pTableList, i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pListInfo->pGroupList = taosArrayInit(4, POINTER_BYTES);
|
pListInfo->pGroupList = taosArrayInit(4, POINTER_BYTES);
|
||||||
if (pListInfo->pGroupList == NULL) {
|
if (pListInfo->pGroupList == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -853,6 +841,9 @@ static STimeWindow doCalculateTimeWindow(int64_t ts, SInterval* pInterval) {
|
||||||
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||||
} else {
|
} else {
|
||||||
int64_t st = w.skey;
|
int64_t st = w.skey;
|
||||||
|
if (pInterval->offset > 0) {
|
||||||
|
st = taosTimeAdd(st, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||||
|
}
|
||||||
|
|
||||||
if (st > ts) {
|
if (st > ts) {
|
||||||
st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
|
st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
|
||||||
|
|
|
@ -1483,8 +1483,8 @@ int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosi
|
||||||
} else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) {
|
} else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) {
|
||||||
// do nothing, todo refactor
|
// do nothing, todo refactor
|
||||||
} else {
|
} else {
|
||||||
// expand the result into multiple rows. E.g., _wstartts, top(k, 20)
|
// expand the result into multiple rows. E.g., _wstart, top(k, 20)
|
||||||
// the _wstartts needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
|
// the _wstart needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
|
char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
|
||||||
for (int32_t k = 0; k < pRow->numOfRows; ++k) {
|
for (int32_t k = 0; k < pRow->numOfRows; ++k) {
|
||||||
|
@ -1555,8 +1555,8 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprI
|
||||||
} else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) {
|
} else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) {
|
||||||
// do nothing, todo refactor
|
// do nothing, todo refactor
|
||||||
} else {
|
} else {
|
||||||
// expand the result into multiple rows. E.g., _wstartts, top(k, 20)
|
// expand the result into multiple rows. E.g., _wstart, top(k, 20)
|
||||||
// the _wstartts needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
|
// the _wstart needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
|
char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
|
||||||
if (pCtx[j].increase) {
|
if (pCtx[j].increase) {
|
||||||
|
@ -3475,9 +3475,12 @@ static SSDataBlock* doFill(SOperatorInfo* pOperator) {
|
||||||
static void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) {
|
static void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) {
|
||||||
for (int32_t i = 0; i < numOfExprs; ++i) {
|
for (int32_t i = 0; i < numOfExprs; ++i) {
|
||||||
SExprInfo* pExprInfo = &pExpr[i];
|
SExprInfo* pExprInfo = &pExpr[i];
|
||||||
if (pExprInfo->pExpr->nodeType == QUERY_NODE_COLUMN) {
|
for(int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
|
||||||
taosMemoryFree(pExprInfo->base.pParam[0].pCol);
|
if (pExprInfo->base.pParam[j].type == FUNC_PARAM_TYPE_COLUMN) {
|
||||||
|
taosMemoryFreeClear(pExprInfo->base.pParam[j].pCol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(pExprInfo->base.pParam);
|
taosMemoryFree(pExprInfo->base.pParam);
|
||||||
taosMemoryFree(pExprInfo->pExpr);
|
taosMemoryFree(pExprInfo->pExpr);
|
||||||
}
|
}
|
||||||
|
@ -3685,10 +3688,20 @@ void destroyBasicOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void freeItem(void* pItem) {
|
||||||
|
void** p = pItem;
|
||||||
|
if (*p != NULL) {
|
||||||
|
taosMemoryFreeClear(*p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void destroyAggOperatorInfo(void* param, int32_t numOfOutput) {
|
void destroyAggOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
SAggOperatorInfo* pInfo = (SAggOperatorInfo*)param;
|
SAggOperatorInfo* pInfo = (SAggOperatorInfo*)param;
|
||||||
cleanupBasicInfo(&pInfo->binfo);
|
cleanupBasicInfo(&pInfo->binfo);
|
||||||
|
|
||||||
|
cleanupAggSup(&pInfo->aggSup);
|
||||||
|
taosArrayDestroyEx(pInfo->groupResInfo.pRows, freeItem);
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4334,6 +4347,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = extractTableSchemaInfo(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
code = extractTableSchemaInfo(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
||||||
if (code) {
|
if (code) {
|
||||||
pTaskInfo->code = terrno;
|
pTaskInfo->code = terrno;
|
||||||
|
@ -4349,7 +4363,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
|
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
||||||
return createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, (SExchangePhysiNode*)pPhyNode, pTaskInfo);
|
return createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, (SExchangePhysiNode*)pPhyNode, pTaskInfo);
|
||||||
|
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
||||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
||||||
STimeWindowAggSupp twSup = {
|
STimeWindowAggSupp twSup = {
|
||||||
|
|
|
@ -39,8 +39,6 @@ static int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capac
|
||||||
static int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size,
|
static int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size,
|
||||||
const char* dbName);
|
const char* dbName);
|
||||||
|
|
||||||
static int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr,
|
|
||||||
SSDataBlock* pBlock, const char* idStr);
|
|
||||||
static bool processBlockWithProbability(const SSampleExecInfo* pInfo);
|
static bool processBlockWithProbability(const SSampleExecInfo* pInfo);
|
||||||
|
|
||||||
bool processBlockWithProbability(const SSampleExecInfo* pInfo) {
|
bool processBlockWithProbability(const SSampleExecInfo* pInfo) {
|
||||||
|
@ -198,12 +196,6 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
|
||||||
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
pCost->skipBlocks += 1;
|
pCost->skipBlocks += 1;
|
||||||
|
|
||||||
// clear all data in pBlock that are set when handing the previous block
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); ++i) {
|
|
||||||
SColumnInfoData* pcol = taosArrayGet(pBlock->pDataBlock, i);
|
|
||||||
pcol->pData = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else if (*status == FUNC_DATA_REQUIRED_STATIS_LOAD) {
|
} else if (*status == FUNC_DATA_REQUIRED_STATIS_LOAD) {
|
||||||
pCost->loadBlockStatis += 1;
|
pCost->loadBlockStatis += 1;
|
||||||
|
@ -320,8 +312,6 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int
|
||||||
int32_t dstSlotId = pExpr->base.resSchema.slotId;
|
int32_t dstSlotId = pExpr->base.resSchema.slotId;
|
||||||
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
||||||
|
|
||||||
colInfoDataEnsureCapacity(pColInfoData, pBlock->info.rows);
|
|
||||||
colInfoDataCleanup(pColInfoData, pBlock->info.rows);
|
colInfoDataCleanup(pColInfoData, pBlock->info.rows);
|
||||||
|
|
||||||
int32_t functionId = pExpr->pExpr->_function.functionId;
|
int32_t functionId = pExpr->pExpr->_function.functionId;
|
||||||
|
@ -1158,10 +1148,11 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
||||||
SOperatorInfo* pOperator = pInfo->pStreamScanOp;
|
SOperatorInfo* pOperator = pInfo->pStreamScanOp;
|
||||||
SExecTaskInfo* pTaskInfo = pInfo->pStreamScanOp->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pInfo->pStreamScanOp->pTaskInfo;
|
||||||
|
|
||||||
|
blockDataEnsureCapacity(pInfo->pRes, pBlock->info.rows);
|
||||||
|
|
||||||
pInfo->pRes->info.rows = pBlock->info.rows;
|
pInfo->pRes->info.rows = pBlock->info.rows;
|
||||||
pInfo->pRes->info.uid = pBlock->info.uid;
|
pInfo->pRes->info.uid = pBlock->info.uid;
|
||||||
pInfo->pRes->info.type = STREAM_NORMAL;
|
pInfo->pRes->info.type = STREAM_NORMAL;
|
||||||
pInfo->pRes->info.capacity = pBlock->info.rows;
|
|
||||||
|
|
||||||
uint64_t* groupIdPre = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t));
|
uint64_t* groupIdPre = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t));
|
||||||
if (groupIdPre) {
|
if (groupIdPre) {
|
||||||
|
@ -1187,7 +1178,10 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
||||||
for (int32_t j = 0; j < blockDataGetNumOfCols(pBlock); ++j) {
|
for (int32_t j = 0; j < blockDataGetNumOfCols(pBlock); ++j) {
|
||||||
SColumnInfoData* pResCol = bdGetColumnInfoData(pBlock, j);
|
SColumnInfoData* pResCol = bdGetColumnInfoData(pBlock, j);
|
||||||
if (pResCol->info.colId == pColMatchInfo->colId) {
|
if (pResCol->info.colId == pColMatchInfo->colId) {
|
||||||
taosArraySet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId, pResCol);
|
|
||||||
|
SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId);
|
||||||
|
colDataAssign(pDst, pResCol, pBlock->info.rows, &pInfo->pRes->info);
|
||||||
|
// taosArraySet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId, pResCol);
|
||||||
colExists = true;
|
colExists = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1200,8 +1194,6 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pBlock->pDataBlock);
|
|
||||||
|
|
||||||
ASSERT(pInfo->pRes->pDataBlock != NULL);
|
ASSERT(pInfo->pRes->pDataBlock != NULL);
|
||||||
|
|
||||||
// currently only the tbname pseudo column
|
// currently only the tbname pseudo column
|
||||||
|
@ -1209,12 +1201,14 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
||||||
int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes,
|
int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes,
|
||||||
GET_TASKID(pTaskInfo));
|
GET_TASKID(pTaskInfo));
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
blockDataFreeRes((SSDataBlock*) pBlock);
|
||||||
longjmp(pTaskInfo->env, code);
|
longjmp(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doFilter(pInfo->pCondition, pInfo->pRes);
|
doFilter(pInfo->pCondition, pInfo->pRes);
|
||||||
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
||||||
|
blockDataFreeRes((SSDataBlock*) pBlock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2419,6 +2413,7 @@ int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle
|
||||||
qDebug("no table qualified for query, TID:0x%" PRIx64 ", QID:0x%" PRIx64, taskId, queryId);
|
qDebug("no table qualified for query, TID:0x%" PRIx64 ", QID:0x%" PRIx64, taskId, queryId);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableListInfo->needSortTableByGroupId = pTableScanNode->groupSort;
|
pTableListInfo->needSortTableByGroupId = pTableScanNode->groupSort;
|
||||||
code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pGroupTags);
|
code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pGroupTags);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -2592,9 +2587,11 @@ static SSDataBlock* getTableDataBlock(void* param) {
|
||||||
SDataBlockInfo binfo = pBlock->info;
|
SDataBlockInfo binfo = pBlock->info;
|
||||||
tsdbRetrieveDataBlockInfo(reader, &binfo);
|
tsdbRetrieveDataBlockInfo(reader, &binfo);
|
||||||
|
|
||||||
binfo.capacity = binfo.rows;
|
blockDataEnsureCapacity(pBlock, binfo.rows);
|
||||||
blockDataEnsureCapacity(pBlock, binfo.capacity);
|
pBlock->info.type = binfo.type;
|
||||||
pBlock->info = binfo;
|
pBlock->info.uid = binfo.uid;
|
||||||
|
pBlock->info.window = binfo.window;
|
||||||
|
pBlock->info.rows = binfo.rows;
|
||||||
|
|
||||||
uint32_t status = 0;
|
uint32_t status = 0;
|
||||||
int32_t code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, readerIdx, pBlock, &status);
|
int32_t code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, readerIdx, pBlock, &status);
|
||||||
|
@ -2621,11 +2618,19 @@ static SSDataBlock* getTableDataBlock(void* param) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* generateSortByTsInfo(int32_t order) {
|
SArray* generateSortByTsInfo(SArray* colMatchInfo, int32_t order) {
|
||||||
|
int32_t tsTargetSlotId = 0;
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(colMatchInfo); ++i) {
|
||||||
|
SColMatchInfo* colInfo = taosArrayGet(colMatchInfo, i);
|
||||||
|
if (colInfo->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
|
tsTargetSlotId = colInfo->targetSlotId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SArray* pList = taosArrayInit(1, sizeof(SBlockOrderInfo));
|
SArray* pList = taosArrayInit(1, sizeof(SBlockOrderInfo));
|
||||||
SBlockOrderInfo bi = {0};
|
SBlockOrderInfo bi = {0};
|
||||||
bi.order = order;
|
bi.order = order;
|
||||||
bi.slotId = 0;
|
bi.slotId = tsTargetSlotId;
|
||||||
bi.nullFirst = NULL_ORDER_FIRST;
|
bi.nullFirst = NULL_ORDER_FIRST;
|
||||||
|
|
||||||
taosArrayPush(pList, &bi);
|
taosArrayPush(pList, &bi);
|
||||||
|
@ -2874,7 +2879,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
||||||
|
|
||||||
pInfo->sortSourceParams = taosArrayInit(64, sizeof(STableMergeScanSortSourceParam));
|
pInfo->sortSourceParams = taosArrayInit(64, sizeof(STableMergeScanSortSourceParam));
|
||||||
|
|
||||||
pInfo->pSortInfo = generateSortByTsInfo(pInfo->cond.order);
|
pInfo->pSortInfo = generateSortByTsInfo(pInfo->pColMatchInfo, pInfo->cond.order);
|
||||||
pInfo->pSortInputBlock = createOneDataBlock(pInfo->pResBlock, false);
|
pInfo->pSortInputBlock = createOneDataBlock(pInfo->pResBlock, false);
|
||||||
|
|
||||||
int32_t rowSize = pInfo->pResBlock->info.rowSize;
|
int32_t rowSize = pInfo->pResBlock->info.rowSize;
|
||||||
|
|
|
@ -621,7 +621,9 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (pInfo->groupSort) {
|
||||||
|
pInfo->hasGroupId = false;
|
||||||
|
}
|
||||||
if (p->info.rows > 0) { // todo extract method
|
if (p->info.rows > 0) { // todo extract method
|
||||||
blockDataEnsureCapacity(pDataBlock, p->info.rows);
|
blockDataEnsureCapacity(pDataBlock, p->info.rows);
|
||||||
int32_t numOfCols = taosArrayGetSize(pColMatchInfo);
|
int32_t numOfCols = taosArrayGetSize(pColMatchInfo);
|
||||||
|
|
|
@ -53,8 +53,8 @@ static void setNullRow(SSDataBlock* pBlock, int64_t ts, int32_t rowIndex) {
|
||||||
// the first are always the timestamp column, so start from the second column.
|
// the first are always the timestamp column, so start from the second column.
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); ++i) {
|
||||||
SColumnInfoData* p = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* p = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
if (p->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
if (p->info.type == TSDB_DATA_TYPE_TIMESTAMP) { // handle timestamp
|
||||||
colDataAppend(p, rowIndex, (const char*)&ts, false);
|
colDataAppend(p, rowIndex, (const char*)&ts, false);
|
||||||
} else {
|
} else {
|
||||||
colDataAppendNULL(p, rowIndex);
|
colDataAppendNULL(p, rowIndex);
|
||||||
}
|
}
|
||||||
|
@ -71,66 +71,76 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
||||||
SPoint point1, point2, point;
|
SPoint point1, point2, point;
|
||||||
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
||||||
|
|
||||||
// set the primary timestamp column value
|
// set the primary timestamp column value
|
||||||
int32_t index = pFillInfo->numOfCurrent;
|
int32_t index = pFillInfo->numOfCurrent;
|
||||||
SColumnInfoData* pCol0 = taosArrayGet(pBlock->pDataBlock, pFillInfo->tsSlotId);
|
|
||||||
char* val = colDataGetData(pCol0, index);
|
|
||||||
|
|
||||||
// set the primary timestamp value
|
|
||||||
*(TSKEY*)val = pFillInfo->currentKey;
|
|
||||||
|
|
||||||
// set the other values
|
// set the other values
|
||||||
if (pFillInfo->type == TSDB_FILL_PREV) {
|
if (pFillInfo->type == TSDB_FILL_PREV) {
|
||||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev : pFillInfo->next;
|
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev : pFillInfo->next;
|
||||||
|
|
||||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
|
||||||
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||||
doSetVal(pDstColInfoData, index, pKey);
|
|
||||||
|
if (pDstColInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
|
colDataAppend(pDstColInfoData, index, (const char*)&pFillInfo->currentKey, false);
|
||||||
|
} else {
|
||||||
|
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||||
|
doSetVal(pDstColInfoData, index, pKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
|
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
|
||||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next : pFillInfo->prev;
|
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next : pFillInfo->prev;
|
||||||
// todo refactor: start from 0 not 1
|
// todo refactor: start from 0 not 1
|
||||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
|
||||||
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||||
doSetVal(pDstColInfoData, index, pKey);
|
|
||||||
|
if (pDstColInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
|
colDataAppend(pDstColInfoData, index, (const char*)&pFillInfo->currentKey, false);
|
||||||
|
} else {
|
||||||
|
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||||
|
doSetVal(pDstColInfoData, index, pKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
||||||
// TODO : linear interpolation supports NULL value
|
// TODO : linear interpolation supports NULL value
|
||||||
if (outOfBound) {
|
if (outOfBound) {
|
||||||
setNullRow(pBlock, pFillInfo->currentKey, index);
|
setNullRow(pBlock, pFillInfo->currentKey, index);
|
||||||
} else {
|
} else {
|
||||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t srcSlotId = GET_SRC_SLOT_ID(pCol);
|
|
||||||
|
|
||||||
int32_t dstSlotId = GET_DEST_SLOT_ID(pCol);
|
int32_t dstSlotId = GET_DEST_SLOT_ID(pCol);
|
||||||
SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
||||||
|
|
||||||
int16_t type = pCol->pExpr->base.resSchema.type;
|
int16_t type = pDstCol->info.type;
|
||||||
|
if (type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
|
colDataAppend(pDstCol, index, (const char*)&pFillInfo->currentKey, false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
SGroupKeys* pKey = taosArrayGet(pFillInfo->prev, i);
|
SGroupKeys* pKey = taosArrayGet(pFillInfo->prev, i);
|
||||||
if (IS_VAR_DATA_TYPE(type) || type == TSDB_DATA_TYPE_BOOL || pKey->isNull) {
|
if (IS_VAR_DATA_TYPE(type) || type == TSDB_DATA_TYPE_BOOL || pKey->isNull) {
|
||||||
colDataAppendNULL(pDstCol, index);
|
colDataAppendNULL(pDstCol, index);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SGroupKeys* pKey1 = taosArrayGet(pFillInfo->prev, 0);
|
SGroupKeys* pKey1 = taosArrayGet(pFillInfo->prev, pFillInfo->tsSlotId);
|
||||||
int64_t prevTs = *(int64_t*)pKey1->pData;
|
|
||||||
|
int64_t prevTs = *(int64_t*)pKey1->pData;
|
||||||
|
int32_t srcSlotId = GET_SRC_SLOT_ID(pCol);
|
||||||
|
|
||||||
SColumnInfoData* pSrcCol = taosArrayGet(pSrcBlock->pDataBlock, srcSlotId);
|
SColumnInfoData* pSrcCol = taosArrayGet(pSrcBlock->pDataBlock, srcSlotId);
|
||||||
char* data = colDataGetData(pSrcCol, pFillInfo->index);
|
char* data = colDataGetData(pSrcCol, pFillInfo->index);
|
||||||
|
@ -148,7 +158,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
||||||
} else if (pFillInfo->type == TSDB_FILL_NULL) { // fill with NULL
|
} else if (pFillInfo->type == TSDB_FILL_NULL) { // fill with NULL
|
||||||
setNullRow(pBlock, pFillInfo->currentKey, index);
|
setNullRow(pBlock, pFillInfo->currentKey, index);
|
||||||
} else { // fill with user specified value for each column
|
} else { // fill with user specified value for each column
|
||||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
if (TSDB_COL_IS_TAG(pCol->flag) /* || IS_VAR_DATA_TYPE(pCol->schema.type)*/) {
|
if (TSDB_COL_IS_TAG(pCol->flag) /* || IS_VAR_DATA_TYPE(pCol->schema.type)*/) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -171,6 +181,8 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
||||||
colDataAppend(pDst, index, (char*)&v, false);
|
colDataAppend(pDst, index, (char*)&v, false);
|
||||||
} else if (pDst->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
} else if (pDst->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
colDataAppend(pDst, index, (const char*)&pFillInfo->currentKey, false);
|
colDataAppend(pDst, index, (const char*)&pFillInfo->currentKey, false);
|
||||||
|
} else { // varchar/nchar data
|
||||||
|
colDataAppendNULL(pDst, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,8 +241,7 @@ static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SArray
|
||||||
static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t outputRows) {
|
static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t outputRows) {
|
||||||
pFillInfo->numOfCurrent = 0;
|
pFillInfo->numOfCurrent = 0;
|
||||||
|
|
||||||
// todo make sure the first column is always the primary timestamp column?
|
SColumnInfoData* pTsCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, pFillInfo->tsSlotId);
|
||||||
SColumnInfoData* pTsCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, 0);
|
|
||||||
|
|
||||||
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
||||||
bool ascFill = FILL_IS_ASC_FILL(pFillInfo);
|
bool ascFill = FILL_IS_ASC_FILL(pFillInfo);
|
||||||
|
@ -264,9 +275,8 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
|
||||||
assert(pFillInfo->currentKey == ts);
|
assert(pFillInfo->currentKey == ts);
|
||||||
|
|
||||||
if (pFillInfo->type == TSDB_FILL_NEXT && (pFillInfo->index + 1) < pFillInfo->numOfRows) {
|
if (pFillInfo->type == TSDB_FILL_NEXT && (pFillInfo->index + 1) < pFillInfo->numOfRows) {
|
||||||
++pFillInfo->index;
|
int32_t nextRowIndex = pFillInfo->index + 1;
|
||||||
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pFillInfo->next);
|
copyCurrentRowIntoBuf(pFillInfo, nextRowIndex, pFillInfo->next);
|
||||||
--pFillInfo->index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign rows to dst buffer
|
// assign rows to dst buffer
|
||||||
|
|
|
@ -1341,9 +1341,9 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup,
|
||||||
uint64_t groupId = *(uint64_t*)key;
|
uint64_t groupId = *(uint64_t*)key;
|
||||||
ASSERT(keyLen == GET_RES_WINDOW_KEY_LEN(sizeof(TSKEY)));
|
ASSERT(keyLen == GET_RES_WINDOW_KEY_LEN(sizeof(TSKEY)));
|
||||||
TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t));
|
TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t));
|
||||||
SResultRowInfo dumyInfo;
|
STimeWindow win;
|
||||||
dumyInfo.cur.pageId = -1;
|
win.skey = ts;
|
||||||
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, ts, pInterval, TSDB_ORDER_ASC);
|
win.ekey = taosTimeAdd(win.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||||
SWinRes winRe = {
|
SWinRes winRe = {
|
||||||
.ts = win.skey,
|
.ts = win.skey,
|
||||||
.groupId = groupId,
|
.groupId = groupId,
|
||||||
|
@ -1600,7 +1600,7 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
|
||||||
}
|
}
|
||||||
|
|
||||||
void increaseTs(SqlFunctionCtx* pCtx) {
|
void increaseTs(SqlFunctionCtx* pCtx) {
|
||||||
if (pCtx[0].pExpr->pExpr->_function.pFunctNode->funcType == FUNCTION_TYPE_WSTARTTS) {
|
if (pCtx[0].pExpr->pExpr->_function.pFunctNode->funcType == FUNCTION_TYPE_WSTART) {
|
||||||
pCtx[0].increase = true;
|
pCtx[0].increase = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4507,13 +4507,14 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, iaInfo->order, scanFlag, true);
|
setInputDataBlock(pOperator, pSup->pCtx, pBlock, iaInfo->order, scanFlag, true);
|
||||||
doMergeAlignedIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes);
|
doMergeAlignedIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes);
|
||||||
doFilter(miaInfo->pCondition, pRes);
|
doFilter(miaInfo->pCondition, pRes);
|
||||||
if (pRes->info.rows > 0) {
|
if (pRes->info.rows >= pOperator->resultInfo.capacity) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pRes->info.groupId = miaInfo->groupId;
|
pRes->info.groupId = miaInfo->groupId;
|
||||||
}
|
}
|
||||||
|
miaInfo->hasGroupId = false;
|
||||||
|
|
||||||
if (miaInfo->inputBlocksFinished) {
|
if (miaInfo->inputBlocksFinished) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
|
|
|
@ -47,6 +47,7 @@ extern "C" {
|
||||||
#define FUNC_MGT_FORBID_WINDOW_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(18)
|
#define FUNC_MGT_FORBID_WINDOW_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(18)
|
||||||
#define FUNC_MGT_FORBID_GROUP_BY_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(19)
|
#define FUNC_MGT_FORBID_GROUP_BY_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(19)
|
||||||
#define FUNC_MGT_SYSTEM_INFO_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(20)
|
#define FUNC_MGT_SYSTEM_INFO_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(20)
|
||||||
|
#define FUNC_MGT_CLIENT_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(21)
|
||||||
|
|
||||||
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
||||||
|
|
||||||
|
|
|
@ -2784,28 +2784,38 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "_qstartts",
|
.name = "_qstart",
|
||||||
.type = FUNCTION_TYPE_QSTARTTS,
|
.type = FUNCTION_TYPE_QSTART,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_CLIENT_PC_FUNC,
|
||||||
.translateFunc = translateTimePseudoColumn,
|
.translateFunc = translateTimePseudoColumn,
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = qStartTsFunction,
|
.sprocessFunc = NULL,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "_qendts",
|
.name = "_qend",
|
||||||
.type = FUNCTION_TYPE_QENDTS,
|
.type = FUNCTION_TYPE_QEND,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_CLIENT_PC_FUNC,
|
||||||
.translateFunc = translateTimePseudoColumn,
|
.translateFunc = translateTimePseudoColumn,
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = qEndTsFunction,
|
.sprocessFunc = NULL,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "_wstartts",
|
.name = "_qduration",
|
||||||
.type = FUNCTION_TYPE_WSTARTTS,
|
.type = FUNCTION_TYPE_QDURATION,
|
||||||
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_CLIENT_PC_FUNC,
|
||||||
|
.translateFunc = translateWduration,
|
||||||
|
.getEnvFunc = NULL,
|
||||||
|
.initFunc = NULL,
|
||||||
|
.sprocessFunc = NULL,
|
||||||
|
.finalizeFunc = NULL
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "_wstart",
|
||||||
|
.type = FUNCTION_TYPE_WSTART,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||||
.translateFunc = translateTimePseudoColumn,
|
.translateFunc = translateTimePseudoColumn,
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
.getEnvFunc = getTimePseudoFuncEnv,
|
||||||
|
@ -2814,8 +2824,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "_wendts",
|
.name = "_wend",
|
||||||
.type = FUNCTION_TYPE_WENDTS,
|
.type = FUNCTION_TYPE_WEND,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||||
.translateFunc = translateTimePseudoColumn,
|
.translateFunc = translateTimePseudoColumn,
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
.getEnvFunc = getTimePseudoFuncEnv,
|
||||||
|
|
|
@ -80,11 +80,12 @@ typedef struct STopBotRes {
|
||||||
} STopBotRes;
|
} STopBotRes;
|
||||||
|
|
||||||
typedef struct SFirstLastRes {
|
typedef struct SFirstLastRes {
|
||||||
bool hasResult;
|
bool hasResult;
|
||||||
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
||||||
// this attribute is required
|
// this attribute is required
|
||||||
bool isNull;
|
bool isNull;
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
|
int64_t ts;
|
||||||
char buf[];
|
char buf[];
|
||||||
} SFirstLastRes;
|
} SFirstLastRes;
|
||||||
|
|
||||||
|
@ -2951,6 +2952,7 @@ int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
|
||||||
SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pResInfo);
|
SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
colDataAppend(pCol, pBlock->info.rows, pRes->buf, pRes->isNull||pResInfo->isNullRes);
|
colDataAppend(pCol, pBlock->info.rows, pRes->buf, pRes->isNull||pResInfo->isNullRes);
|
||||||
|
|
||||||
// handle selectivity
|
// handle selectivity
|
||||||
STuplePos* pTuplePos = (STuplePos*)(pRes->buf + pRes->bytes + sizeof(TSKEY));
|
STuplePos* pTuplePos = (STuplePos*)(pRes->buf + pRes->bytes + sizeof(TSKEY));
|
||||||
setSelectivityValue(pCtx, pBlock, pTuplePos, pBlock->info.rows);
|
setSelectivityValue(pCtx, pBlock, pTuplePos, pBlock->info.rows);
|
||||||
|
@ -3459,9 +3461,16 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* +------------------------------------+--------------+--------------+
|
||||||
|
* | null bitmap | | |
|
||||||
|
* |(n columns, one bit for each column)| src column #1| src column #2|
|
||||||
|
* +------------------------------------+--------------+--------------+
|
||||||
|
*/
|
||||||
void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos) {
|
void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos) {
|
||||||
SFilePage* pPage = NULL;
|
SFilePage* pPage = NULL;
|
||||||
|
|
||||||
|
// todo refactor: move away
|
||||||
int32_t completeRowSize = pCtx->subsidiaries.num * sizeof(bool);
|
int32_t completeRowSize = pCtx->subsidiaries.num * sizeof(bool);
|
||||||
for (int32_t j = 0; j < pCtx->subsidiaries.num; ++j) {
|
for (int32_t j = 0; j < pCtx->subsidiaries.num; ++j) {
|
||||||
SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j];
|
SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j];
|
||||||
|
@ -3474,12 +3483,15 @@ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS
|
||||||
} else {
|
} else {
|
||||||
pPage = getBufPage(pCtx->pBuf, pCtx->curBufPage);
|
pPage = getBufPage(pCtx->pBuf, pCtx->curBufPage);
|
||||||
if (pPage->num + completeRowSize > getBufPageSize(pCtx->pBuf)) {
|
if (pPage->num + completeRowSize > getBufPageSize(pCtx->pBuf)) {
|
||||||
|
// current page is all used, let's prepare a new buffer page
|
||||||
|
releaseBufPage(pCtx->pBuf, pPage);
|
||||||
pPage = getNewBufPage(pCtx->pBuf, 0, &pCtx->curBufPage);
|
pPage = getNewBufPage(pCtx->pBuf, 0, &pCtx->curBufPage);
|
||||||
pPage->num = sizeof(SFilePage);
|
pPage->num = sizeof(SFilePage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pPos->pageId = pCtx->curBufPage;
|
pPos->pageId = pCtx->curBufPage;
|
||||||
|
pPos->offset = pPage->num;
|
||||||
|
|
||||||
// keep the current row data, extract method
|
// keep the current row data, extract method
|
||||||
int32_t offset = 0;
|
int32_t offset = 0;
|
||||||
|
@ -3507,7 +3519,6 @@ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS
|
||||||
offset += pCol->info.bytes;
|
offset += pCol->info.bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
pPos->offset = pPage->num;
|
|
||||||
pPage->num += completeRowSize;
|
pPage->num += completeRowSize;
|
||||||
|
|
||||||
setBufPageDirty(pPage, true);
|
setBufPageDirty(pPage, true);
|
||||||
|
@ -4837,7 +4848,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da
|
||||||
if (pInfo->numSampled < pInfo->samples) {
|
if (pInfo->numSampled < pInfo->samples) {
|
||||||
sampleAssignResult(pInfo, data, pInfo->numSampled);
|
sampleAssignResult(pInfo, data, pInfo->numSampled);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
saveTupleData(pCtx, index, pCtx->pSrcBlock, pInfo->tuplePos + pInfo->numSampled * sizeof(STuplePos));
|
saveTupleData(pCtx, index, pCtx->pSrcBlock, &pInfo->tuplePos[pInfo->numSampled]);
|
||||||
}
|
}
|
||||||
pInfo->numSampled++;
|
pInfo->numSampled++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4845,7 +4856,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da
|
||||||
if (j < pInfo->samples) {
|
if (j < pInfo->samples) {
|
||||||
sampleAssignResult(pInfo, data, j);
|
sampleAssignResult(pInfo, data, j);
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
copyTupleData(pCtx, index, pCtx->pSrcBlock, pInfo->tuplePos + j * sizeof(STuplePos));
|
copyTupleData(pCtx, index, pCtx->pSrcBlock, &pInfo->tuplePos[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4883,7 +4894,7 @@ int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
int32_t currentRow = pBlock->info.rows;
|
int32_t currentRow = pBlock->info.rows;
|
||||||
for (int32_t i = 0; i < pInfo->numSampled; ++i) {
|
for (int32_t i = 0; i < pInfo->numSampled; ++i) {
|
||||||
colDataAppend(pCol, currentRow + i, pInfo->data + i * pInfo->colBytes, false);
|
colDataAppend(pCol, currentRow + i, pInfo->data + i * pInfo->colBytes, false);
|
||||||
setSelectivityValue(pCtx, pBlock, pInfo->tuplePos + i * sizeof(STuplePos), currentRow + i);
|
setSelectivityValue(pCtx, pBlock, &pInfo->tuplePos[i], currentRow + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pInfo->numSampled;
|
return pInfo->numSampled;
|
||||||
|
@ -5557,6 +5568,10 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
|
||||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
|
||||||
|
if (pData->totalRows == 0) {
|
||||||
|
pData->minRows = 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t row = 0;
|
int32_t row = 0;
|
||||||
char st[256] = {0};
|
char st[256] = {0};
|
||||||
double totalRawSize = pData->totalRows * pData->rowSize;
|
double totalRawSize = pData->totalRows * pData->rowSize;
|
||||||
|
@ -5568,10 +5583,14 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
varDataSetLen(st, len);
|
varDataSetLen(st, len);
|
||||||
colDataAppend(pColInfo, row++, st, false);
|
colDataAppend(pColInfo, row++, st, false);
|
||||||
|
|
||||||
|
int64_t avgRows = 0;
|
||||||
|
if (pData->numOfBlocks > 0) {
|
||||||
|
avgRows = pData->totalRows / pData->numOfBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
len = sprintf(st + VARSTR_HEADER_SIZE,
|
len = sprintf(st + VARSTR_HEADER_SIZE,
|
||||||
"Total_Rows=[%" PRId64 "] Inmem_Rows=[%d] MinRows=[%d] MaxRows=[%d] Average_Rows=[%" PRId64 "]",
|
"Total_Rows=[%" PRId64 "] Inmem_Rows=[%d] MinRows=[%d] MaxRows=[%d] Average_Rows=[%" PRId64 "]",
|
||||||
pData->totalRows, pData->numOfInmemRows, pData->minRows, pData->maxRows,
|
pData->totalRows, pData->numOfInmemRows, pData->minRows, pData->maxRows, avgRows);
|
||||||
pData->totalRows / pData->numOfBlocks);
|
|
||||||
|
|
||||||
varDataSetLen(st, len);
|
varDataSetLen(st, len);
|
||||||
colDataAppend(pColInfo, row++, st, false);
|
colDataAppend(pColInfo, row++, st, false);
|
||||||
|
@ -5988,7 +6007,7 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) {
|
||||||
SInputColumnInfoData* pInput = &pCtx->input;
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
|
|
||||||
int32_t type = pInputCol->info.type;
|
int32_t type = pInputCol->info.type;
|
||||||
int32_t bytes = pInputCol->info.bytes;
|
int32_t bytes = pInputCol->info.bytes;
|
||||||
|
|
||||||
pInfo->bytes = bytes;
|
pInfo->bytes = bytes;
|
||||||
|
@ -5999,7 +6018,7 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
char* data = colDataGetData(pInputCol, i);
|
char* data = colDataGetData(pInputCol, i);
|
||||||
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
||||||
if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) < cts) {
|
if (pResInfo->numOfRes == 0 || pInfo->ts < cts) {
|
||||||
|
|
||||||
if (colDataIsNull_s(pInputCol, i)) {
|
if (colDataIsNull_s(pInputCol, i)) {
|
||||||
pInfo->isNull = true;
|
pInfo->isNull = true;
|
||||||
|
@ -6012,8 +6031,7 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) {
|
||||||
memcpy(pInfo->buf, data, bytes);
|
memcpy(pInfo->buf, data, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
*(TSKEY*)(pInfo->buf + bytes) = cts;
|
pInfo->ts = cts;
|
||||||
|
|
||||||
pInfo->hasResult = true;
|
pInfo->hasResult = true;
|
||||||
pResInfo->numOfRes = 1;
|
pResInfo->numOfRes = 1;
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,8 @@ bool fmIsSystemInfoFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId,
|
||||||
|
|
||||||
bool fmIsImplicitTsFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_IMPLICIT_TS_FUNC); }
|
bool fmIsImplicitTsFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_IMPLICIT_TS_FUNC); }
|
||||||
|
|
||||||
|
bool fmIsClientPseudoColumnFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_CLIENT_PC_FUNC); }
|
||||||
|
|
||||||
bool fmIsInterpFunc(int32_t funcId) {
|
bool fmIsInterpFunc(int32_t funcId) {
|
||||||
if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -227,8 +229,8 @@ bool fmIsInvertible(int32_t funcId) {
|
||||||
case FUNCTION_TYPE_SUM:
|
case FUNCTION_TYPE_SUM:
|
||||||
case FUNCTION_TYPE_STDDEV:
|
case FUNCTION_TYPE_STDDEV:
|
||||||
case FUNCTION_TYPE_AVG:
|
case FUNCTION_TYPE_AVG:
|
||||||
case FUNCTION_TYPE_WSTARTTS:
|
case FUNCTION_TYPE_WSTART:
|
||||||
case FUNCTION_TYPE_WENDTS:
|
case FUNCTION_TYPE_WEND:
|
||||||
case FUNCTION_TYPE_WDURATION:
|
case FUNCTION_TYPE_WDURATION:
|
||||||
res = true;
|
res = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -296,8 +296,8 @@ void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
||||||
|
|
||||||
switch (call->callType) {
|
switch (call->callType) {
|
||||||
case TSDB_UDF_CALL_SCALA_PROC: {
|
case TSDB_UDF_CALL_SCALA_PROC: {
|
||||||
tDeleteSSDataBlock(&call->block);
|
blockDataFreeRes(&call->block);
|
||||||
tDeleteSSDataBlock(&subRsp->resultData);
|
blockDataFreeRes(&subRsp->resultData);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_UDF_CALL_AGG_INIT: {
|
case TSDB_UDF_CALL_AGG_INIT: {
|
||||||
|
@ -305,7 +305,7 @@ void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_UDF_CALL_AGG_PROC: {
|
case TSDB_UDF_CALL_AGG_PROC: {
|
||||||
tDeleteSSDataBlock(&call->block);
|
blockDataFreeRes(&call->block);
|
||||||
freeUdfInterBuf(&subRsp->resultBuf);
|
freeUdfInterBuf(&subRsp->resultBuf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(isDuration);
|
COPY_SCALAR_FIELD(isDuration);
|
||||||
COPY_SCALAR_FIELD(translate);
|
COPY_SCALAR_FIELD(translate);
|
||||||
COPY_SCALAR_FIELD(notReserved);
|
COPY_SCALAR_FIELD(notReserved);
|
||||||
|
COPY_SCALAR_FIELD(isNull);
|
||||||
COPY_SCALAR_FIELD(placeholderNo);
|
COPY_SCALAR_FIELD(placeholderNo);
|
||||||
COPY_SCALAR_FIELD(typeData);
|
COPY_SCALAR_FIELD(typeData);
|
||||||
COPY_SCALAR_FIELD(unit);
|
COPY_SCALAR_FIELD(unit);
|
||||||
|
|
|
@ -225,6 +225,8 @@ const char* nodesNodeName(ENodeType type) {
|
||||||
return "PhysiBlockDistScan";
|
return "PhysiBlockDistScan";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN:
|
||||||
return "PhysiLastRowScan";
|
return "PhysiLastRowScan";
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN:
|
||||||
|
return "PhysiTableMergeScan";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
|
case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
|
||||||
return "PhysiProject";
|
return "PhysiProject";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN:
|
case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN:
|
||||||
|
@ -2712,6 +2714,7 @@ static const char* jkValueLiteral = "Literal";
|
||||||
static const char* jkValueDuration = "Duration";
|
static const char* jkValueDuration = "Duration";
|
||||||
static const char* jkValueTranslate = "Translate";
|
static const char* jkValueTranslate = "Translate";
|
||||||
static const char* jkValueNotReserved = "NotReserved";
|
static const char* jkValueNotReserved = "NotReserved";
|
||||||
|
static const char* jkValueIsNull = "IsNull";
|
||||||
static const char* jkValueDatum = "Datum";
|
static const char* jkValueDatum = "Datum";
|
||||||
|
|
||||||
static int32_t datumToJson(const void* pObj, SJson* pJson) {
|
static int32_t datumToJson(const void* pObj, SJson* pJson) {
|
||||||
|
@ -2798,6 +2801,9 @@ static int32_t valueNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddBoolToObject(pJson, jkValueNotReserved, pNode->notReserved);
|
code = tjsonAddBoolToObject(pJson, jkValueNotReserved, pNode->notReserved);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddBoolToObject(pJson, jkValueIsNull, pNode->isNull);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && pNode->translate) {
|
if (TSDB_CODE_SUCCESS == code && pNode->translate) {
|
||||||
code = datumToJson(pNode, pJson);
|
code = datumToJson(pNode, pJson);
|
||||||
}
|
}
|
||||||
|
@ -2945,6 +2951,9 @@ static int32_t jsonToValueNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBoolValue(pJson, jkValueNotReserved, &pNode->notReserved);
|
code = tjsonGetBoolValue(pJson, jkValueNotReserved, &pNode->notReserved);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBoolValue(pJson, jkValueIsNull, &pNode->isNull);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && pNode->translate) {
|
if (TSDB_CODE_SUCCESS == code && pNode->translate) {
|
||||||
code = jsonToDatum(pJson, pNode);
|
code = jsonToDatum(pJson, pNode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -956,7 +956,6 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_SUBPLAN: {
|
case QUERY_NODE_PHYSICAL_SUBPLAN: {
|
||||||
SSubplan* pSubplan = (SSubplan*)pNode;
|
SSubplan* pSubplan = (SSubplan*)pNode;
|
||||||
// nodesDestroyList(pSubplan->pChildren);
|
|
||||||
nodesClearList(pSubplan->pChildren);
|
nodesClearList(pSubplan->pChildren);
|
||||||
nodesDestroyNode((SNode*)pSubplan->pNode);
|
nodesDestroyNode((SNode*)pSubplan->pNode);
|
||||||
nodesDestroyNode((SNode*)pSubplan->pDataSink);
|
nodesDestroyNode((SNode*)pSubplan->pDataSink);
|
||||||
|
@ -965,25 +964,9 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
nodesClearList(pSubplan->pParents);
|
nodesClearList(pSubplan->pParents);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN: {
|
case QUERY_NODE_PHYSICAL_PLAN:
|
||||||
SQueryPlan* pPlan = (SQueryPlan*)pNode;
|
nodesDestroyList(((SQueryPlan*)pNode)->pSubplans);
|
||||||
if (NULL != pPlan->pSubplans) {
|
|
||||||
// only need to destroy the top-level subplans, because they will recurse to all the subplans below
|
|
||||||
bool first = true;
|
|
||||||
SNode* pElement = NULL;
|
|
||||||
FOREACH(pElement, pPlan->pSubplans) {
|
|
||||||
if (first) {
|
|
||||||
// first = false;
|
|
||||||
nodesDestroyNode(pElement);
|
|
||||||
} else {
|
|
||||||
nodesClearList(((SNodeListNode*)pElement)->pNodeList);
|
|
||||||
taosMemoryFreeClear(pElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nodesClearList(pPlan->pSubplans);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1709,6 +1692,11 @@ int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
||||||
|
if (pNode->isNull) {
|
||||||
|
pVal->nType = TSDB_DATA_TYPE_NULL;
|
||||||
|
pVal->nLen = tDataTypes[TSDB_DATA_TYPE_NULL].bytes;
|
||||||
|
return;
|
||||||
|
}
|
||||||
pVal->nType = pNode->node.resType.type;
|
pVal->nType = pNode->node.resType.type;
|
||||||
pVal->nLen = pNode->node.resType.bytes;
|
pVal->nLen = pNode->node.resType.bytes;
|
||||||
switch (pNode->node.resType.type) {
|
switch (pNode->node.resType.type) {
|
||||||
|
@ -1789,7 +1777,7 @@ static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) {
|
||||||
SClassifyConditionCxt* pCxt = (SClassifyConditionCxt*)pContext;
|
SClassifyConditionCxt* pCxt = (SClassifyConditionCxt*)pContext;
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
if (PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId) {
|
if (PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId && TSDB_SYSTEM_TABLE != pCol->tableType) {
|
||||||
pCxt->hasPrimaryKey = true;
|
pCxt->hasPrimaryKey = true;
|
||||||
} else if (pCol->hasIndex) {
|
} else if (pCol->hasIndex) {
|
||||||
pCxt->hasTagIndexCol = true;
|
pCxt->hasTagIndexCol = true;
|
||||||
|
|
|
@ -520,7 +520,9 @@ cmd ::= DELETE FROM full_table_name(A) where_clause_opt(B).
|
||||||
cmd ::= query_expression(A). { pCxt->pRootNode = A; }
|
cmd ::= query_expression(A). { pCxt->pRootNode = A; }
|
||||||
|
|
||||||
/************************************************ insert **************************************************************/
|
/************************************************ insert **************************************************************/
|
||||||
cmd ::= INSERT INTO full_table_name(A) specific_cols_opt(B) query_expression(C). { pCxt->pRootNode = createInsertStmt(pCxt, A, B, C); }
|
cmd ::= INSERT INTO full_table_name(A)
|
||||||
|
NK_LP col_name_list(B) NK_RP query_expression(C). { pCxt->pRootNode = createInsertStmt(pCxt, A, B, C); }
|
||||||
|
cmd ::= INSERT INTO full_table_name(A) query_expression(B). { pCxt->pRootNode = createInsertStmt(pCxt, A, NULL, B); }
|
||||||
|
|
||||||
/************************************************ literal *************************************************************/
|
/************************************************ literal *************************************************************/
|
||||||
literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B)); }
|
literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B)); }
|
||||||
|
@ -675,10 +677,11 @@ column_reference(A) ::= table_name(B) NK_DOT column_name(C).
|
||||||
pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= table_name(B) NK_DOT TBNAME(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &C, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B)))); }
|
pseudo_column(A) ::= table_name(B) NK_DOT TBNAME(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &C, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B)))); }
|
||||||
pseudo_column(A) ::= QSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= QSTART(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= QENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= QEND(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= WSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= QDURATION(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= WENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= WSTART(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
|
pseudo_column(A) ::= WEND(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= WDURATION(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= WDURATION(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
|
|
||||||
function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||||
|
|
|
@ -598,7 +598,7 @@ SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues) {
|
||||||
nodesDestroyNode((SNode*)fill);
|
nodesDestroyNode((SNode*)fill);
|
||||||
CHECK_OUT_OF_MEM(fill->pWStartTs);
|
CHECK_OUT_OF_MEM(fill->pWStartTs);
|
||||||
}
|
}
|
||||||
strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstartts");
|
strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstart");
|
||||||
return (SNode*)fill;
|
return (SNode*)fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,6 +740,7 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr
|
||||||
select->pFromTable = pTable;
|
select->pFromTable = pTable;
|
||||||
sprintf(select->stmtName, "%p", select);
|
sprintf(select->stmtName, "%p", select);
|
||||||
select->isTimeLineResult = true;
|
select->isTimeLineResult = true;
|
||||||
|
select->timeRange = TSWINDOW_INITIALIZER;
|
||||||
return (SNode*)select;
|
return (SNode*)select;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ static int32_t calcConstStmtCondition(SCalcConstContext* pCxt, SNode** pCond, bo
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t calcConstProject(SNode* pProject, SNode** pNew) {
|
static int32_t calcConstProject(SNode* pProject, bool dual, SNode** pNew) {
|
||||||
SArray* pAssociation = NULL;
|
SArray* pAssociation = NULL;
|
||||||
if (NULL != ((SExprNode*)pProject)->pAssociation) {
|
if (NULL != ((SExprNode*)pProject)->pAssociation) {
|
||||||
pAssociation = taosArrayDup(((SExprNode*)pProject)->pAssociation);
|
pAssociation = taosArrayDup(((SExprNode*)pProject)->pAssociation);
|
||||||
|
@ -177,7 +177,12 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) {
|
||||||
|
|
||||||
char aliasName[TSDB_COL_NAME_LEN] = {0};
|
char aliasName[TSDB_COL_NAME_LEN] = {0};
|
||||||
strcpy(aliasName, ((SExprNode*)pProject)->aliasName);
|
strcpy(aliasName, ((SExprNode*)pProject)->aliasName);
|
||||||
int32_t code = scalarCalculateConstants(pProject, pNew);
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
if (dual) {
|
||||||
|
code = scalarCalculateConstantsFromDual(pProject, pNew);
|
||||||
|
} else {
|
||||||
|
code = scalarCalculateConstants(pProject, pNew);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_VALUE == nodeType(*pNew) && NULL != pAssociation) {
|
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_VALUE == nodeType(*pNew) && NULL != pAssociation) {
|
||||||
strcpy(((SExprNode*)*pNew)->aliasName, aliasName);
|
strcpy(((SExprNode*)*pNew)->aliasName, aliasName);
|
||||||
int32_t size = taosArrayGetSize(pAssociation);
|
int32_t size = taosArrayGetSize(pAssociation);
|
||||||
|
@ -223,7 +228,7 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SNode* pNew = NULL;
|
SNode* pNew = NULL;
|
||||||
int32_t code = calcConstProject(pProj, &pNew);
|
int32_t code = calcConstProject(pProj, (NULL == pSelect->pFromTable), &pNew);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
REPLACE_NODE(pNew);
|
REPLACE_NODE(pNew);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -71,6 +71,7 @@ typedef struct SInsertParseContext {
|
||||||
SVnodeModifOpStmt* pOutput;
|
SVnodeModifOpStmt* pOutput;
|
||||||
SStmtCallback* pStmtCb;
|
SStmtCallback* pStmtCb;
|
||||||
SParseMetaCache* pMetaCache;
|
SParseMetaCache* pMetaCache;
|
||||||
|
char sTableName[TSDB_TABLE_NAME_LEN];
|
||||||
} SInsertParseContext;
|
} SInsertParseContext;
|
||||||
|
|
||||||
typedef struct SInsertParseSyntaxCxt {
|
typedef struct SInsertParseSyntaxCxt {
|
||||||
|
@ -734,11 +735,13 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid) {
|
static void buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname, SArray* tagName) {
|
||||||
pTbReq->type = TD_CHILD_TABLE;
|
pTbReq->type = TD_CHILD_TABLE;
|
||||||
pTbReq->name = strdup(tname);
|
pTbReq->name = strdup(tname);
|
||||||
pTbReq->ctb.suid = suid;
|
pTbReq->ctb.suid = suid;
|
||||||
|
if(sname) pTbReq->ctb.name = strdup(sname);
|
||||||
pTbReq->ctb.pTag = (uint8_t*)pTag;
|
pTbReq->ctb.pTag = (uint8_t*)pTag;
|
||||||
|
pTbReq->ctb.tagName = taosArrayDup(tagName);
|
||||||
pTbReq->commentLen = -1;
|
pTbReq->commentLen = -1;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -758,6 +761,7 @@ static int32_t parseTagToken(char** end, SToken* pToken, SSchema* pSchema, int16
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// strcpy(val->colName, pSchema->name);
|
||||||
val->cid = pSchema->colId;
|
val->cid = pSchema->colId;
|
||||||
val->type = pSchema->type;
|
val->type = pSchema->type;
|
||||||
|
|
||||||
|
@ -936,6 +940,7 @@ static int32_t parseTagToken(char** end, SToken* pToken, SSchema* pSchema, int16
|
||||||
static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint8_t precision, const char* tName) {
|
static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint8_t precision, const char* tName) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SArray* pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal));
|
SArray* pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal));
|
||||||
|
SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||||
SToken sToken;
|
SToken sToken;
|
||||||
bool isParseBindParam = false;
|
bool isParseBindParam = false;
|
||||||
bool isJson = false;
|
bool isJson = false;
|
||||||
|
@ -965,6 +970,10 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
|
||||||
taosMemoryFree(tmpTokenBuf);
|
taosMemoryFree(tmpTokenBuf);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isNullStr(&sToken)) {
|
||||||
|
taosArrayPush(tagName, pTagSchema->name);
|
||||||
|
}
|
||||||
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
||||||
if (sToken.n > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
if (sToken.n > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
||||||
code = buildSyntaxErrMsg(&pCxt->msg, "json string too long than 4095", sToken.z);
|
code = buildSyntaxErrMsg(&pCxt->msg, "json string too long than 4095", sToken.z);
|
||||||
|
@ -1004,7 +1013,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid);
|
buildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid, pCxt->sTableName, tagName);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) {
|
for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) {
|
||||||
|
@ -1014,6 +1023,7 @@ end:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pTagVals);
|
taosArrayDestroy(pTagVals);
|
||||||
|
taosArrayDestroy(tagName);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1089,6 +1099,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SName* name, char* tb
|
||||||
createSName(&sname, &sToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg);
|
createSName(&sname, &sToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg);
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
tNameGetFullDbName(&sname, dbFName);
|
tNameGetFullDbName(&sname, dbFName);
|
||||||
|
strcpy(pCxt->sTableName, sname.tname);
|
||||||
|
|
||||||
CHECK_CODE(getSTableMeta(pCxt, &sname, dbFName));
|
CHECK_CODE(getSTableMeta(pCxt, &sname, dbFName));
|
||||||
if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) {
|
if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) {
|
||||||
|
@ -1325,15 +1336,10 @@ static int32_t parseDataFromFile(SInsertParseContext* pCxt, SToken filePath, STa
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyCreateSubTbReq(SVCreateTbReq* pReq) {
|
|
||||||
taosMemoryFreeClear(pReq->name);
|
|
||||||
taosMemoryFreeClear(pReq->ctb.pTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void destroyInsertParseContextForTable(SInsertParseContext* pCxt) {
|
static void destroyInsertParseContextForTable(SInsertParseContext* pCxt) {
|
||||||
taosMemoryFreeClear(pCxt->pTableMeta);
|
taosMemoryFreeClear(pCxt->pTableMeta);
|
||||||
destroyBoundColumnInfo(&pCxt->tags);
|
destroyBoundColumnInfo(&pCxt->tags);
|
||||||
destroyCreateSubTbReq(&pCxt->createTblReq);
|
tdDestroySVCreateTbReq(&pCxt->createTblReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroySubTableHashElem(void* p) { taosMemoryFree(*(STableMeta**)p); }
|
static void destroySubTableHashElem(void* p) { taosMemoryFree(*(STableMeta**)p); }
|
||||||
|
@ -1479,7 +1485,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
}
|
}
|
||||||
memcpy(tags, &pCxt->tags, sizeof(pCxt->tags));
|
memcpy(tags, &pCxt->tags, sizeof(pCxt->tags));
|
||||||
(*pCxt->pStmtCb->setInfoFn)(pCxt->pStmtCb->pStmt, pCxt->pTableMeta, tags, tbFName, autoCreateTbl,
|
(*pCxt->pStmtCb->setInfoFn)(pCxt->pStmtCb->pStmt, pCxt->pTableMeta, tags, tbFName, autoCreateTbl,
|
||||||
pCxt->pVgroupsHashObj, pCxt->pTableBlockHashObj);
|
pCxt->pVgroupsHashObj, pCxt->pTableBlockHashObj, pCxt->sTableName);
|
||||||
|
|
||||||
memset(&pCxt->tags, 0, sizeof(pCxt->tags));
|
memset(&pCxt->tags, 0, sizeof(pCxt->tags));
|
||||||
pCxt->pVgroupsHashObj = NULL;
|
pCxt->pVgroupsHashObj = NULL;
|
||||||
|
@ -1508,6 +1514,7 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache
|
||||||
.pSql = (char*)pContext->pSql,
|
.pSql = (char*)pContext->pSql,
|
||||||
.msg = {.buf = pContext->pMsg, .len = pContext->msgLen},
|
.msg = {.buf = pContext->pMsg, .len = pContext->msgLen},
|
||||||
.pTableMeta = NULL,
|
.pTableMeta = NULL,
|
||||||
|
.createTblReq = {0},
|
||||||
.pSubTableHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK),
|
.pSubTableHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK),
|
||||||
.pTableNameHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK),
|
.pTableNameHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK),
|
||||||
.pDbFNameHashObj = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK),
|
.pDbFNameHashObj = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK),
|
||||||
|
@ -1788,7 +1795,7 @@ int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tName, TAOS_MULTI_BIND* bind,
|
int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const char* sTableName, char* tName, TAOS_MULTI_BIND* bind,
|
||||||
char* msgBuf, int32_t msgBufLen) {
|
char* msgBuf, int32_t msgBufLen) {
|
||||||
STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock;
|
STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock;
|
||||||
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||||
|
@ -1802,6 +1809,11 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN
|
||||||
return buildInvalidOperationMsg(&pBuf, "out of memory");
|
return buildInvalidOperationMsg(&pBuf, "out of memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||||
|
if (!tagName) {
|
||||||
|
return buildInvalidOperationMsg(&pBuf, "out of memory");
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SSchema* pSchema = getTableTagSchema(pDataBlock->pTableMeta);
|
SSchema* pSchema = getTableTagSchema(pDataBlock->pTableMeta);
|
||||||
|
|
||||||
|
@ -1818,6 +1830,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN
|
||||||
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
||||||
colLen = bind[c].length[0];
|
colLen = bind[c].length[0];
|
||||||
}
|
}
|
||||||
|
taosArrayPush(tagName, pTagSchema->name);
|
||||||
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
||||||
if (colLen > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
if (colLen > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
||||||
code = buildSyntaxErrMsg(&pBuf, "json string too long than 4095", bind[c].buffer);
|
code = buildSyntaxErrMsg(&pBuf, "json string too long than 4095", bind[c].buffer);
|
||||||
|
@ -1834,6 +1847,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
||||||
|
// strcpy(val.colName, pTagSchema->name);
|
||||||
if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) {
|
if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) {
|
||||||
val.pData = (uint8_t*)bind[c].buffer;
|
val.pData = (uint8_t*)bind[c].buffer;
|
||||||
val.nData = colLen;
|
val.nData = colLen;
|
||||||
|
@ -1870,9 +1884,9 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN
|
||||||
}
|
}
|
||||||
|
|
||||||
SVCreateTbReq tbReq = {0};
|
SVCreateTbReq tbReq = {0};
|
||||||
buildCreateTbReq(&tbReq, tName, pTag, suid);
|
buildCreateTbReq(&tbReq, tName, pTag, suid, sTableName, tagName);
|
||||||
code = buildCreateTbMsg(pDataBlock, &tbReq);
|
code = buildCreateTbMsg(pDataBlock, &tbReq);
|
||||||
destroyCreateSubTbReq(&tbReq);
|
tdDestroySVCreateTbReq(&tbReq);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) {
|
for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) {
|
||||||
|
@ -1882,6 +1896,7 @@ end:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pTagArray);
|
taosArrayDestroy(pTagArray);
|
||||||
|
taosArrayDestroy(tagName);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2136,7 +2151,7 @@ typedef struct SmlExecHandle {
|
||||||
static void smlDestroyTableHandle(void* pHandle) {
|
static void smlDestroyTableHandle(void* pHandle) {
|
||||||
SmlExecTableHandle* handle = (SmlExecTableHandle*)pHandle;
|
SmlExecTableHandle* handle = (SmlExecTableHandle*)pHandle;
|
||||||
destroyBoundColumnInfo(&handle->tags);
|
destroyBoundColumnInfo(&handle->tags);
|
||||||
destroyCreateSubTbReq(&handle->createTblReq);
|
tdDestroySVCreateTbReq(&handle->createTblReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SSchema* pSchema) {
|
static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SSchema* pSchema) {
|
||||||
|
@ -2222,18 +2237,24 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS
|
||||||
* @param msg
|
* @param msg
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* pSchema, STag** ppTag, SMsgBuf* msg) {
|
static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* pSchema, STag** ppTag, SArray** tagName, SMsgBuf* msg) {
|
||||||
SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal));
|
SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal));
|
||||||
if (!pTagArray) {
|
if (!pTagArray) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
*tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||||
|
if (!*tagName) {
|
||||||
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
for (int i = 0; i < tags->numOfBound; ++i) {
|
for (int i = 0; i < tags->numOfBound; ++i) {
|
||||||
SSchema* pTagSchema = &pSchema[tags->boundColumns[i]];
|
SSchema* pTagSchema = &pSchema[tags->boundColumns[i]];
|
||||||
SSmlKv* kv = taosArrayGetP(cols, i);
|
SSmlKv* kv = taosArrayGetP(cols, i);
|
||||||
|
|
||||||
|
taosArrayPush(*tagName, pTagSchema->name);
|
||||||
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
||||||
|
// strcpy(val.colName, pTagSchema->name);
|
||||||
if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) {
|
if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) {
|
||||||
val.pData = (uint8_t*)kv->value;
|
val.pData = (uint8_t*)kv->value;
|
||||||
val.nData = kv->length;
|
val.nData = kv->length;
|
||||||
|
@ -2277,7 +2298,7 @@ end:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols, bool format, STableMeta* pTableMeta,
|
int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols, bool format, STableMeta* pTableMeta,
|
||||||
char* tableName, char* msgBuf, int16_t msgBufLen) {
|
char* tableName, const char* sTableName, int32_t sTableNameLen, char* msgBuf, int16_t msgBufLen) {
|
||||||
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||||
|
|
||||||
SSmlExecHandle* smlHandle = (SSmlExecHandle*)handle;
|
SSmlExecHandle* smlHandle = (SSmlExecHandle*)handle;
|
||||||
|
@ -2290,12 +2311,19 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
STag* pTag = NULL;
|
STag* pTag = NULL;
|
||||||
ret = smlBuildTagRow(tags, &smlHandle->tableExecHandle.tags, pTagsSchema, &pTag, &pBuf);
|
SArray* tagName = NULL;
|
||||||
|
ret = smlBuildTagRow(tags, &smlHandle->tableExecHandle.tags, pTagsSchema, &pTag, &tagName, &pBuf);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
|
taosArrayDestroy(tagName);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildCreateTbReq(&smlHandle->tableExecHandle.createTblReq, tableName, pTag, pTableMeta->suid);
|
buildCreateTbReq(&smlHandle->tableExecHandle.createTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName);
|
||||||
|
taosArrayDestroy(tagName);
|
||||||
|
|
||||||
|
smlHandle->tableExecHandle.createTblReq.ctb.name = taosMemoryMalloc(sTableNameLen + 1);
|
||||||
|
memcpy(smlHandle->tableExecHandle.createTblReq.ctb.name, sTableName, sTableNameLen);
|
||||||
|
smlHandle->tableExecHandle.createTblReq.ctb.name[sTableNameLen] = 0;
|
||||||
|
|
||||||
STableDataBlocks* pDataBlock = NULL;
|
STableDataBlocks* pDataBlock = NULL;
|
||||||
ret = getDataBlockFromList(smlHandle->pBlockHash, &pTableMeta->uid, sizeof(pTableMeta->uid),
|
ret = getDataBlockFromList(smlHandle->pBlockHash, &pTableMeta->uid, sizeof(pTableMeta->uid),
|
||||||
|
|
|
@ -240,12 +240,13 @@ static SKeyword keywordTable[] = {
|
||||||
{"WITH", TK_WITH},
|
{"WITH", TK_WITH},
|
||||||
{"WRITE", TK_WRITE},
|
{"WRITE", TK_WRITE},
|
||||||
{"_C0", TK_ROWTS},
|
{"_C0", TK_ROWTS},
|
||||||
{"_QENDTS", TK_QENDTS},
|
{"_QDURATION", TK_QDURATION},
|
||||||
{"_QSTARTTS", TK_QSTARTTS},
|
{"_QEND", TK_QEND},
|
||||||
|
{"_QSTART", TK_QSTART},
|
||||||
{"_ROWTS", TK_ROWTS},
|
{"_ROWTS", TK_ROWTS},
|
||||||
{"_WDURATION", TK_WDURATION},
|
{"_WDURATION", TK_WDURATION},
|
||||||
{"_WENDTS", TK_WENDTS},
|
{"_WEND", TK_WEND},
|
||||||
{"_WSTARTTS", TK_WSTARTTS},
|
{"_WSTART", TK_WSTART},
|
||||||
// {"ID", TK_ID},
|
// {"ID", TK_ID},
|
||||||
// {"STRING", TK_STRING},
|
// {"STRING", TK_STRING},
|
||||||
// {"EQ", TK_EQ},
|
// {"EQ", TK_EQ},
|
||||||
|
|
|
@ -496,7 +496,7 @@ static bool isPrimaryKeyImpl(SNode* pExpr) {
|
||||||
SFunctionNode* pFunc = (SFunctionNode*)pExpr;
|
SFunctionNode* pFunc = (SFunctionNode*)pExpr;
|
||||||
if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType) {
|
if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType) {
|
||||||
return isPrimaryKeyImpl(nodesListGetNode(pFunc->pParameterList, 0));
|
return isPrimaryKeyImpl(nodesListGetNode(pFunc->pParameterList, 0));
|
||||||
} else if (FUNCTION_TYPE_WSTARTTS == pFunc->funcType || FUNCTION_TYPE_WENDTS == pFunc->funcType) {
|
} else if (FUNCTION_TYPE_WSTART == pFunc->funcType || FUNCTION_TYPE_WEND == pFunc->funcType) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -916,8 +916,6 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_DATA_TYPE_NULL == pVal->node.resType.type) {
|
if (TSDB_DATA_TYPE_NULL == pVal->node.resType.type) {
|
||||||
// TODO
|
|
||||||
// pVal->node.resType = targetDt;
|
|
||||||
pVal->translate = true;
|
pVal->translate = true;
|
||||||
pVal->isNull = true;
|
pVal->isNull = true;
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
|
@ -932,6 +930,7 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
|
||||||
res = translateNormalValue(pCxt, pVal, targetDt, strict);
|
res = translateNormalValue(pCxt, pVal, targetDt, strict);
|
||||||
}
|
}
|
||||||
pVal->node.resType = targetDt;
|
pVal->node.resType = targetDt;
|
||||||
|
pVal->node.resType.scale = pVal->unit;
|
||||||
pVal->translate = true;
|
pVal->translate = true;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1198,7 +1197,7 @@ static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewriteSystemInfoFuncImpl(STranslateContext* pCxt, char* pLiteral, SNode** pNode) {
|
static int32_t rewriteFuncToValue(STranslateContext* pCxt, char* pLiteral, SNode** pNode) {
|
||||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||||
if (NULL == pVal) {
|
if (NULL == pVal) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -1229,7 +1228,7 @@ static int32_t rewriteDatabaseFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rewriteSystemInfoFuncImpl(pCxt, pCurrDb, pNode);
|
return rewriteFuncToValue(pCxt, pCurrDb, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) {
|
static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
|
@ -1237,7 +1236,7 @@ static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
if (NULL == pVer) {
|
if (NULL == pVer) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
return rewriteSystemInfoFuncImpl(pCxt, pVer, pNode);
|
return rewriteFuncToValue(pCxt, pVer, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewriteServerVersionFunc(STranslateContext* pCxt, SNode** pNode) {
|
static int32_t rewriteServerVersionFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
|
@ -1245,7 +1244,7 @@ static int32_t rewriteServerVersionFunc(STranslateContext* pCxt, SNode** pNode)
|
||||||
if (NULL == pVer) {
|
if (NULL == pVer) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
return rewriteSystemInfoFuncImpl(pCxt, pVer, pNode);
|
return rewriteFuncToValue(pCxt, pVer, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) {
|
static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
|
@ -1253,7 +1252,7 @@ static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
return TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
return TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||||
}
|
}
|
||||||
char* pStatus = taosMemoryStrDup((void*)"1");
|
char* pStatus = taosMemoryStrDup((void*)"1");
|
||||||
return rewriteSystemInfoFuncImpl(pCxt, pStatus, pNode);
|
return rewriteFuncToValue(pCxt, pStatus, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewriteUserFunc(STranslateContext* pCxt, SNode** pNode) {
|
static int32_t rewriteUserFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
|
@ -1264,7 +1263,7 @@ static int32_t rewriteUserFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
if (NULL == pUserConn) {
|
if (NULL == pUserConn) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
return rewriteSystemInfoFuncImpl(pCxt, pUserConn, pNode);
|
return rewriteFuncToValue(pCxt, pUserConn, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewriteSystemInfoFunc(STranslateContext* pCxt, SNode** pNode) {
|
static int32_t rewriteSystemInfoFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
|
@ -1318,10 +1317,60 @@ static int32_t translateNoramlFunction(STranslateContext* pCxt, SFunctionNode* p
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t rewriteQueryTimeFunc(STranslateContext* pCxt, int64_t val, SNode** pNode) {
|
||||||
|
if (INT64_MIN == val || INT64_MAX == val) {
|
||||||
|
return rewriteFuncToValue(pCxt, NULL, pNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* pStr = taosMemoryCalloc(1, 20);
|
||||||
|
if (NULL == pStr) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
snprintf(pStr, 20, "%" PRId64 "", val);
|
||||||
|
return rewriteFuncToValue(pCxt, pStr, pNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t rewriteQstartFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
|
return rewriteQueryTimeFunc(pCxt, ((SSelectStmt*)pCxt->pCurrStmt)->timeRange.skey, pNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t rewriteQendFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
|
return rewriteQueryTimeFunc(pCxt, ((SSelectStmt*)pCxt->pCurrStmt)->timeRange.ekey, pNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t rewriteQdurationFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
|
STimeWindow range = ((SSelectStmt*)pCxt->pCurrStmt)->timeRange;
|
||||||
|
if (INT64_MIN == range.skey || INT64_MAX == range.ekey) {
|
||||||
|
return rewriteQueryTimeFunc(pCxt, INT64_MIN, pNode);
|
||||||
|
}
|
||||||
|
return rewriteQueryTimeFunc(pCxt, range.ekey - range.skey + 1, pNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t rewriteClientPseudoColumnFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||||
|
if (NULL == pCxt->pCurrStmt || QUERY_NODE_SELECT_STMT != nodeType(pCxt->pCurrStmt) ||
|
||||||
|
pCxt->currClause <= SQL_CLAUSE_WHERE) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, "Illegal pseudo column");
|
||||||
|
}
|
||||||
|
switch (((SFunctionNode*)*pNode)->funcType) {
|
||||||
|
case FUNCTION_TYPE_QSTART:
|
||||||
|
return rewriteQstartFunc(pCxt, pNode);
|
||||||
|
case FUNCTION_TYPE_QEND:
|
||||||
|
return rewriteQendFunc(pCxt, pNode);
|
||||||
|
case FUNCTION_TYPE_QDURATION:
|
||||||
|
return rewriteQdurationFunc(pCxt, pNode);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateFunctionImpl(STranslateContext* pCxt, SFunctionNode** pFunc) {
|
static int32_t translateFunctionImpl(STranslateContext* pCxt, SFunctionNode** pFunc) {
|
||||||
if (fmIsSystemInfoFunc((*pFunc)->funcId)) {
|
if (fmIsSystemInfoFunc((*pFunc)->funcId)) {
|
||||||
return rewriteSystemInfoFunc(pCxt, (SNode**)pFunc);
|
return rewriteSystemInfoFunc(pCxt, (SNode**)pFunc);
|
||||||
}
|
}
|
||||||
|
if (fmIsClientPseudoColumnFunc((*pFunc)->funcId)) {
|
||||||
|
return rewriteClientPseudoColumnFunc(pCxt, (SNode**)pFunc);
|
||||||
|
}
|
||||||
return translateNoramlFunction(pCxt, *pFunc);
|
return translateNoramlFunction(pCxt, *pFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2078,7 +2127,7 @@ static int32_t getTimeRange(SNode** pPrimaryKeyCond, STimeWindow* pTimeRange, bo
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getFillTimeRange(STranslateContext* pCxt, SNode* pWhere, STimeWindow* pTimeRange) {
|
static int32_t getQueryTimeRange(STranslateContext* pCxt, SNode* pWhere, STimeWindow* pTimeRange) {
|
||||||
if (NULL == pWhere) {
|
if (NULL == pWhere) {
|
||||||
*pTimeRange = TSWINDOW_INITIALIZER;
|
*pTimeRange = TSWINDOW_INITIALIZER;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -2139,16 +2188,13 @@ static int32_t checkFill(STranslateContext* pCxt, SFillNode* pFill, SValueNode*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateFill(STranslateContext* pCxt, SNode* pWhere, SIntervalWindowNode* pInterval) {
|
static int32_t translateFill(STranslateContext* pCxt, SSelectStmt* pSelect, SIntervalWindowNode* pInterval) {
|
||||||
if (NULL == pInterval->pFill) {
|
if (NULL == pInterval->pFill) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = getFillTimeRange(pCxt, pWhere, &(((SFillNode*)pInterval->pFill)->timeRange));
|
((SFillNode*)pInterval->pFill)->timeRange = pSelect->timeRange;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
return checkFill(pCxt, (SFillNode*)pInterval->pFill, (SValueNode*)pInterval->pInterval);
|
||||||
code = checkFill(pCxt, (SFillNode*)pInterval->pFill, (SValueNode*)pInterval->pInterval);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t getMonthsFromTimeVal(int64_t val, int32_t fromPrecision, char unit) {
|
static int64_t getMonthsFromTimeVal(int64_t val, int32_t fromPrecision, char unit) {
|
||||||
|
@ -2235,7 +2281,7 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
|
||||||
static int32_t translateIntervalWindow(STranslateContext* pCxt, SSelectStmt* pSelect, SIntervalWindowNode* pInterval) {
|
static int32_t translateIntervalWindow(STranslateContext* pCxt, SSelectStmt* pSelect, SIntervalWindowNode* pInterval) {
|
||||||
int32_t code = checkIntervalWindow(pCxt, pInterval);
|
int32_t code = checkIntervalWindow(pCxt, pInterval);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateFill(pCxt, pSelect->pWhere, pInterval);
|
code = translateFill(pCxt, pSelect, pInterval);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2330,7 +2376,7 @@ static int32_t translateInterpFill(STranslateContext* pCxt, SSelectStmt* pSelect
|
||||||
code = translateExpr(pCxt, &pSelect->pFill);
|
code = translateExpr(pCxt, &pSelect->pFill);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = getFillTimeRange(pCxt, pSelect->pRange, &(((SFillNode*)pSelect->pFill)->timeRange));
|
code = getQueryTimeRange(pCxt, pSelect->pRange, &(((SFillNode*)pSelect->pFill)->timeRange));
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkFill(pCxt, (SFillNode*)pSelect->pFill, (SValueNode*)pSelect->pEvery);
|
code = checkFill(pCxt, (SFillNode*)pSelect->pFill, (SValueNode*)pSelect->pEvery);
|
||||||
|
@ -2362,9 +2408,13 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SNodeList* pPartiti
|
||||||
return translateExprList(pCxt, pPartitionByList);
|
return translateExprList(pCxt, pPartitionByList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateWhere(STranslateContext* pCxt, SNode** pWhere) {
|
static int32_t translateWhere(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
pCxt->currClause = SQL_CLAUSE_WHERE;
|
pCxt->currClause = SQL_CLAUSE_WHERE;
|
||||||
return translateExpr(pCxt, pWhere);
|
int32_t code = translateExpr(pCxt, &pSelect->pWhere);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = getQueryTimeRange(pCxt, pSelect->pWhere, &pSelect->timeRange);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateFrom(STranslateContext* pCxt, SNode* pTable) {
|
static int32_t translateFrom(STranslateContext* pCxt, SNode* pTable) {
|
||||||
|
@ -2495,7 +2545,7 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
|
||||||
int32_t code = translateFrom(pCxt, pSelect->pFromTable);
|
int32_t code = translateFrom(pCxt, pSelect->pFromTable);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pSelect->precision = ((STableNode*)pSelect->pFromTable)->precision;
|
pSelect->precision = ((STableNode*)pSelect->pFromTable)->precision;
|
||||||
code = translateWhere(pCxt, &pSelect->pWhere);
|
code = translateWhere(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translatePartitionBy(pCxt, pSelect->pPartitionByList);
|
code = translatePartitionBy(pCxt, pSelect->pPartitionByList);
|
||||||
|
@ -2681,7 +2731,8 @@ static int32_t partitionDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelet
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelete) {
|
static int32_t translateDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelete) {
|
||||||
int32_t code = translateWhere(pCxt, &pDelete->pWhere);
|
pCxt->currClause = SQL_CLAUSE_WHERE;
|
||||||
|
int32_t code = translateExpr(pCxt, &pDelete->pWhere);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = partitionDeleteWhere(pCxt, pDelete);
|
code = partitionDeleteWhere(pCxt, pDelete);
|
||||||
}
|
}
|
||||||
|
@ -3508,7 +3559,7 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch
|
||||||
nodesDestroyNode((SNode*)pSelect);
|
nodesDestroyNode((SNode*)pSelect);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
strcpy(pFunc->functionName, "_wstartts");
|
strcpy(pFunc->functionName, "_wstart");
|
||||||
nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
|
nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
|
||||||
SNode* pProject = NULL;
|
SNode* pProject = NULL;
|
||||||
FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); }
|
FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); }
|
||||||
|
@ -3703,6 +3754,9 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
|
||||||
pReq->delay2 = pStmt->pOptions->maxDelay2;
|
pReq->delay2 = pStmt->pOptions->maxDelay2;
|
||||||
pReq->watermark1 = pStmt->pOptions->watermark1;
|
pReq->watermark1 = pStmt->pOptions->watermark1;
|
||||||
pReq->watermark2 = pStmt->pOptions->watermark2;
|
pReq->watermark2 = pStmt->pOptions->watermark2;
|
||||||
|
pReq->colVer = 1;
|
||||||
|
pReq->tagVer = 1;
|
||||||
|
pReq->source = TD_REQ_FROM_APP;
|
||||||
columnDefNodeToField(pStmt->pCols, &pReq->pColumns);
|
columnDefNodeToField(pStmt->pCols, &pReq->pColumns);
|
||||||
columnDefNodeToField(pStmt->pTags, &pReq->pTags);
|
columnDefNodeToField(pStmt->pTags, &pReq->pTags);
|
||||||
pReq->numOfColumns = LIST_LENGTH(pStmt->pCols);
|
pReq->numOfColumns = LIST_LENGTH(pStmt->pCols);
|
||||||
|
@ -4334,14 +4388,14 @@ static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
||||||
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("_wstartts", ((SFunctionNode*)pProj)->functionName))) {
|
(QUERY_NODE_FUNCTION == nodeType(pProj) && 0 == strcmp("_wstart", ((SFunctionNode*)pProj)->functionName))) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
if (NULL == pFunc) {
|
if (NULL == pFunc) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
strcpy(pFunc->functionName, "_wstartts");
|
strcpy(pFunc->functionName, "_wstart");
|
||||||
strcpy(pFunc->node.aliasName, pFunc->functionName);
|
strcpy(pFunc->node.aliasName, pFunc->functionName);
|
||||||
int32_t code = nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
|
int32_t code = nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
@ -5286,6 +5340,8 @@ static void destroyCreateTbReqBatch(void* data) {
|
||||||
taosMemoryFreeClear(pTableReq->ntb.schemaRow.pSchema);
|
taosMemoryFreeClear(pTableReq->ntb.schemaRow.pSchema);
|
||||||
} else if (pTableReq->type == TSDB_CHILD_TABLE) {
|
} else if (pTableReq->type == TSDB_CHILD_TABLE) {
|
||||||
taosMemoryFreeClear(pTableReq->ctb.pTag);
|
taosMemoryFreeClear(pTableReq->ctb.pTag);
|
||||||
|
taosMemoryFreeClear(pTableReq->ctb.name);
|
||||||
|
taosArrayDestroy(pTableReq->ctb.tagName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5357,11 +5413,11 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, SCreateSubTableClause* pStmt,
|
static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, SCreateSubTableClause* pStmt,
|
||||||
const STag* pTag, uint64_t suid, SVgroupInfo* pVgInfo) {
|
const STag* pTag, uint64_t suid, const char* sTableNmae, SVgroupInfo* pVgInfo, SArray* tagName) {
|
||||||
// char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
// char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||||
// SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId};
|
// SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId};
|
||||||
// strcpy(name.dbname, pStmt->dbName);
|
// strcpy(name.dbname, pStmt->dbName);
|
||||||
// tNameGetFullDbName(&name, dbFName);
|
// tNameGetFullDbName(&name, dbFName);
|
||||||
|
|
||||||
struct SVCreateTbReq req = {0};
|
struct SVCreateTbReq req = {0};
|
||||||
req.type = TD_CHILD_TABLE;
|
req.type = TD_CHILD_TABLE;
|
||||||
|
@ -5374,7 +5430,9 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S
|
||||||
req.commentLen = -1;
|
req.commentLen = -1;
|
||||||
}
|
}
|
||||||
req.ctb.suid = suid;
|
req.ctb.suid = suid;
|
||||||
|
req.ctb.name = strdup(sTableNmae);
|
||||||
req.ctb.pTag = (uint8_t*)pTag;
|
req.ctb.pTag = (uint8_t*)pTag;
|
||||||
|
req.ctb.tagName = taosArrayDup(tagName);
|
||||||
if (pStmt->ignoreExists) {
|
if (pStmt->ignoreExists) {
|
||||||
req.flags |= TD_CREATE_IF_NOT_EXISTS;
|
req.flags |= TD_CREATE_IF_NOT_EXISTS;
|
||||||
}
|
}
|
||||||
|
@ -5466,6 +5524,7 @@ static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, S
|
||||||
if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) {
|
if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) {
|
||||||
void* nodeVal = nodesGetValueFromNode(pVal);
|
void* nodeVal = nodesGetValueFromNode(pVal);
|
||||||
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
||||||
|
// strcpy(val.colName, pTagSchema->name);
|
||||||
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
||||||
val.pData = varDataVal(nodeVal);
|
val.pData = varDataVal(nodeVal);
|
||||||
val.nData = varDataLen(nodeVal);
|
val.nData = varDataLen(nodeVal);
|
||||||
|
@ -5478,7 +5537,7 @@ static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, S
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta,
|
static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta,
|
||||||
STag** ppTag) {
|
STag** ppTag, SArray* tagName) {
|
||||||
int32_t numOfTags = getNumOfTags(pSuperTableMeta);
|
int32_t numOfTags = getNumOfTags(pSuperTableMeta);
|
||||||
if (LIST_LENGTH(pStmt->pValsOfTags) != LIST_LENGTH(pStmt->pSpecificTags) ||
|
if (LIST_LENGTH(pStmt->pValsOfTags) != LIST_LENGTH(pStmt->pSpecificTags) ||
|
||||||
numOfTags < LIST_LENGTH(pStmt->pValsOfTags)) {
|
numOfTags < LIST_LENGTH(pStmt->pValsOfTags)) {
|
||||||
|
@ -5509,8 +5568,10 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
|
||||||
if (pSchema->type == TSDB_DATA_TYPE_JSON) {
|
if (pSchema->type == TSDB_DATA_TYPE_JSON) {
|
||||||
isJson = true;
|
isJson = true;
|
||||||
code = buildJsonTagVal(pCxt, pSchema, pVal, pTagArray, ppTag);
|
code = buildJsonTagVal(pCxt, pSchema, pVal, pTagArray, ppTag);
|
||||||
|
taosArrayPush(tagName, pCol->colName);
|
||||||
} else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) {
|
} else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) {
|
||||||
code = buildNormalTagVal(pCxt, pSchema, pVal, pTagArray);
|
code = buildNormalTagVal(pCxt, pSchema, pVal, pTagArray);
|
||||||
|
taosArrayPush(tagName, pCol->colName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -5531,7 +5592,7 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta,
|
static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta,
|
||||||
STag** ppTag) {
|
STag** ppTag, SArray* tagName) {
|
||||||
if (getNumOfTags(pSuperTableMeta) != LIST_LENGTH(pStmt->pValsOfTags)) {
|
if (getNumOfTags(pSuperTableMeta) != LIST_LENGTH(pStmt->pValsOfTags)) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TAGS_NOT_MATCHED);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TAGS_NOT_MATCHED);
|
||||||
}
|
}
|
||||||
|
@ -5556,9 +5617,11 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
|
||||||
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
||||||
isJson = true;
|
isJson = true;
|
||||||
code = buildJsonTagVal(pCxt, pTagSchema, pVal, pTagArray, ppTag);
|
code = buildJsonTagVal(pCxt, pTagSchema, pVal, pTagArray, ppTag);
|
||||||
|
taosArrayPush(tagName, pTagSchema->name);
|
||||||
} else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) {
|
} else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) {
|
||||||
char* tmpVal = nodesGetValueFromNode(pVal);
|
char* tmpVal = nodesGetValueFromNode(pVal);
|
||||||
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
||||||
|
// strcpy(val.colName, pTagSchema->name);
|
||||||
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
||||||
val.pData = varDataVal(tmpVal);
|
val.pData = varDataVal(tmpVal);
|
||||||
val.nData = varDataLen(tmpVal);
|
val.nData = varDataLen(tmpVal);
|
||||||
|
@ -5566,6 +5629,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
|
||||||
memcpy(&val.i64, tmpVal, pTagSchema->bytes);
|
memcpy(&val.i64, tmpVal, pTagSchema->bytes);
|
||||||
}
|
}
|
||||||
taosArrayPush(pTagArray, &val);
|
taosArrayPush(pTagArray, &val);
|
||||||
|
taosArrayPush(tagName, pTagSchema->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -5601,12 +5665,13 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
|
||||||
}
|
}
|
||||||
|
|
||||||
STag* pTag = NULL;
|
STag* pTag = NULL;
|
||||||
|
SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (NULL != pStmt->pSpecificTags) {
|
if (NULL != pStmt->pSpecificTags) {
|
||||||
code = buildKVRowForBindTags(pCxt, pStmt, pSuperTableMeta, &pTag);
|
code = buildKVRowForBindTags(pCxt, pStmt, pSuperTableMeta, &pTag, tagName);
|
||||||
} else {
|
} else {
|
||||||
code = buildKVRowForAllTags(pCxt, pStmt, pSuperTableMeta, &pTag);
|
code = buildKVRowForAllTags(pCxt, pStmt, pSuperTableMeta, &pTag, tagName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5615,9 +5680,10 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
|
||||||
code = getTableHashVgroup(pCxt, pStmt->dbName, pStmt->tableName, &info);
|
code = getTableHashVgroup(pCxt, pStmt->dbName, pStmt->tableName, &info);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt, pTag, pSuperTableMeta->uid, &info);
|
addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt, pTag, pSuperTableMeta->uid, pStmt->useTableName, &info, tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(tagName);
|
||||||
taosMemoryFreeClear(pSuperTableMeta);
|
taosMemoryFreeClear(pSuperTableMeta);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -5832,9 +5898,8 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
||||||
return pCxt->errCode;
|
return pCxt->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type);
|
pReq->tagType = targetDt.type;
|
||||||
if (targetDt.type == TSDB_DATA_TYPE_JSON) {
|
if (targetDt.type == TSDB_DATA_TYPE_JSON) {
|
||||||
pReq->isNull = 0;
|
|
||||||
if (pStmt->pVal->literal &&
|
if (pStmt->pVal->literal &&
|
||||||
strlen(pStmt->pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
strlen(pStmt->pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
||||||
return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pStmt->pVal->literal);
|
return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pStmt->pVal->literal);
|
||||||
|
@ -5862,6 +5927,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
||||||
pReq->pTagVal = (uint8_t*)pTag;
|
pReq->pTagVal = (uint8_t*)pTag;
|
||||||
pStmt->pVal->datum.p = (char*)pTag; // for free
|
pStmt->pVal->datum.p = (char*)pTag; // for free
|
||||||
} else {
|
} else {
|
||||||
|
pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type);
|
||||||
pReq->nTagVal = pStmt->pVal->node.resType.bytes;
|
pReq->nTagVal = pStmt->pVal->node.resType.bytes;
|
||||||
pReq->pTagVal = nodesGetValueFromNode(pStmt->pVal);
|
pReq->pTagVal = nodesGetValueFromNode(pStmt->pVal);
|
||||||
|
|
||||||
|
@ -5888,7 +5954,8 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S
|
||||||
|
|
||||||
pReq->type = pStmt->dataType.type;
|
pReq->type = pStmt->dataType.type;
|
||||||
pReq->flags = COL_SMA_ON;
|
pReq->flags = COL_SMA_ON;
|
||||||
pReq->bytes = pStmt->dataType.bytes;
|
// pReq->bytes = pStmt->dataType.bytes;
|
||||||
|
pReq->bytes = calcTypeBytes(pStmt->dataType);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5915,7 +5982,7 @@ static int32_t buildDropColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt,
|
||||||
static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
|
static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
|
||||||
SVAlterTbReq* pReq) {
|
SVAlterTbReq* pReq) {
|
||||||
pReq->colModBytes = calcTypeBytes(pStmt->dataType);
|
pReq->colModBytes = calcTypeBytes(pStmt->dataType);
|
||||||
|
pReq->colModType = pStmt->dataType.type;
|
||||||
SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName);
|
SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName);
|
||||||
if (NULL == pSchema) {
|
if (NULL == pSchema) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pStmt->colName);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pStmt->colName);
|
||||||
|
|
|
@ -187,7 +187,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
case TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC:
|
case TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC:
|
||||||
return "%s function is not supported in fill query";
|
return "%s function is not supported in fill query";
|
||||||
case TSDB_CODE_PAR_INVALID_WINDOW_PC:
|
case TSDB_CODE_PAR_INVALID_WINDOW_PC:
|
||||||
return "_WSTARTTS, _WENDTS and _WDURATION can only be used in window query";
|
return "_WSTART, _WEND and _WDURATION can only be used in window query";
|
||||||
case TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC:
|
case TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC:
|
||||||
return "%s function is not supported in time window query";
|
return "%s function is not supported in time window query";
|
||||||
case TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC:
|
case TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC:
|
||||||
|
@ -389,6 +389,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
STagVal val = {0};
|
STagVal val = {0};
|
||||||
|
// strcpy(val.colName, colName);
|
||||||
val.pKey = jsonKey;
|
val.pKey = jsonKey;
|
||||||
taosHashPut(keyHash, jsonKey, keyLen, &keyLen,
|
taosHashPut(keyHash, jsonKey, keyLen, &keyLen,
|
||||||
CHAR_BYTES); // add key to hash to remove dumplicate, value is useless
|
CHAR_BYTES); // add key to hash to remove dumplicate, value is useless
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -75,7 +75,7 @@ TEST_F(ParserSelectTest, condition) {
|
||||||
TEST_F(ParserSelectTest, pseudoColumn) {
|
TEST_F(ParserSelectTest, pseudoColumn) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("SELECT _WSTARTTS, _WENDTS, COUNT(*) FROM t1 INTERVAL(10s)");
|
run("SELECT _WSTART, _WEND, COUNT(*) FROM t1 INTERVAL(10s)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserSelectTest, pseudoColumnSemanticCheck) {
|
TEST_F(ParserSelectTest, pseudoColumnSemanticCheck) {
|
||||||
|
@ -286,7 +286,7 @@ TEST_F(ParserSelectTest, intervalSemanticCheck) {
|
||||||
run("SELECT HISTOGRAM(c1, 'log_bin', '{\"start\": -33,\"factor\": 55,\"count\": 5,\"infinity\": false}', 1) FROM t1 "
|
run("SELECT HISTOGRAM(c1, 'log_bin', '{\"start\": -33,\"factor\": 55,\"count\": 5,\"infinity\": false}', 1) FROM t1 "
|
||||||
"WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59' INTERVAL(10s) FILL(NULL)",
|
"WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59' INTERVAL(10s) FILL(NULL)",
|
||||||
TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC);
|
TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC);
|
||||||
run("SELECT _WSTARTTS, _WENDTS, _WDURATION, sum(c1) FROM t1", TSDB_CODE_PAR_INVALID_WINDOW_PC);
|
run("SELECT _WSTART, _WEND, _WDURATION, sum(c1) FROM t1", TSDB_CODE_PAR_INVALID_WINDOW_PC);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserSelectTest, interp) {
|
TEST_F(ParserSelectTest, interp) {
|
||||||
|
@ -310,11 +310,11 @@ TEST_F(ParserSelectTest, subquery) {
|
||||||
|
|
||||||
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, ts FROM st1s1 INTERVAL(1m)) INTERVAL(1n)");
|
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, ts FROM st1s1 INTERVAL(1m)) INTERVAL(1n)");
|
||||||
|
|
||||||
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstartts FROM st1s1 INTERVAL(1m)) INTERVAL(1n)");
|
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstart FROM st1s1 INTERVAL(1m)) INTERVAL(1n)");
|
||||||
|
|
||||||
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, ts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)");
|
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, ts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)");
|
||||||
|
|
||||||
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstartts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)");
|
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstart FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)");
|
||||||
|
|
||||||
run("SELECT _C0 FROM (SELECT _ROWTS, ts FROM st1s1)");
|
run("SELECT _C0 FROM (SELECT _ROWTS, ts FROM st1s1)");
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) {
|
||||||
strcpy(pCol->node.aliasName, pToBeRewrittenExpr->aliasName);
|
strcpy(pCol->node.aliasName, pToBeRewrittenExpr->aliasName);
|
||||||
strcpy(pCol->colName, ((SExprNode*)pExpr)->aliasName);
|
strcpy(pCol->colName, ((SExprNode*)pExpr)->aliasName);
|
||||||
if (QUERY_NODE_FUNCTION == nodeType(pExpr)) {
|
if (QUERY_NODE_FUNCTION == nodeType(pExpr)) {
|
||||||
if (FUNCTION_TYPE_WSTARTTS == ((SFunctionNode*)pExpr)->funcType) {
|
if (FUNCTION_TYPE_WSTART == ((SFunctionNode*)pExpr)->funcType) {
|
||||||
pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||||
} else if (FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pExpr)->funcType) {
|
} else if (FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pExpr)->funcType) {
|
||||||
pCol->colType = COLUMN_TYPE_TBNAME;
|
pCol->colType = COLUMN_TYPE_TBNAME;
|
||||||
|
|
|
@ -124,12 +124,15 @@ static bool scanPathOptMayBeOptimized(SLogicNode* pNode) {
|
||||||
QUERY_NODE_LOGIC_PLAN_PARTITION != nodeType(pNode->pParent))) {
|
QUERY_NODE_LOGIC_PLAN_PARTITION != nodeType(pNode->pParent))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent) ||
|
if ((QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent) && WINDOW_TYPE_INTERVAL == ((SWindowLogicNode*)pNode->pParent)->winType) ||
|
||||||
(QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode->pParent) && pNode->pParent->pParent &&
|
(QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode->pParent) && pNode->pParent->pParent &&
|
||||||
QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent->pParent))) {
|
QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent->pParent) && WINDOW_TYPE_INTERVAL == ((SWindowLogicNode*)pNode->pParent)->winType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return !scanPathOptHaveNormalCol(((SAggLogicNode*)pNode->pParent)->pGroupKeys);
|
if (QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode->pParent)) {
|
||||||
|
return !scanPathOptHaveNormalCol(((SAggLogicNode*)pNode->pParent)->pGroupKeys);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNodeList* scanPathOptGetAllFuncs(SLogicNode* pNode) {
|
static SNodeList* scanPathOptGetAllFuncs(SLogicNode* pNode) {
|
||||||
|
@ -792,15 +795,15 @@ static EDealRes rewriteAggGroupKeyCondForPushDownImpl(SNode** pNode, void* pCont
|
||||||
if (0 == strcmp(((SExprNode*)pGroup)->aliasName, ((SColumnNode*)(*pNode))->colName)) {
|
if (0 == strcmp(((SExprNode*)pGroup)->aliasName, ((SColumnNode*)(*pNode))->colName)) {
|
||||||
SNode* pExpr = nodesCloneNode(pGroup);
|
SNode* pExpr = nodesCloneNode(pGroup);
|
||||||
if (pExpr == NULL) {
|
if (pExpr == NULL) {
|
||||||
pCxt->errCode = terrno;
|
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
nodesDestroyNode(*pNode);
|
nodesDestroyNode(*pNode);
|
||||||
*pNode = pExpr;
|
*pNode = pExpr;
|
||||||
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -861,16 +864,16 @@ static EDealRes rewriteProjectCondForPushDownImpl(SNode** ppNode, void* pContext
|
||||||
if (0 == strcmp(((SExprNode*)pProjection)->aliasName, ((SColumnNode*)(*ppNode))->colName)) {
|
if (0 == strcmp(((SExprNode*)pProjection)->aliasName, ((SColumnNode*)(*ppNode))->colName)) {
|
||||||
SNode* pExpr = nodesCloneNode(pProjection);
|
SNode* pExpr = nodesCloneNode(pProjection);
|
||||||
if (pExpr == NULL) {
|
if (pExpr == NULL) {
|
||||||
pCxt->errCode = terrno;
|
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
nodesDestroyNode(*ppNode);
|
nodesDestroyNode(*ppNode);
|
||||||
*ppNode = pExpr;
|
*ppNode = pExpr;
|
||||||
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
} // end if expr alias name equal column name
|
} // end if expr alias name equal column name
|
||||||
} // end for each project
|
} // end for each project
|
||||||
} // end if target node equals cond column node
|
} // end if target node equals cond column node
|
||||||
} // end for each targets
|
} // end for each targets
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -1208,7 +1211,7 @@ static int32_t smaIndexOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNo
|
||||||
int32_t smaFuncIndex = -1;
|
int32_t smaFuncIndex = -1;
|
||||||
*pWStrartIndex = -1;
|
*pWStrartIndex = -1;
|
||||||
FOREACH(pFunc, pFuncs) {
|
FOREACH(pFunc, pFuncs) {
|
||||||
if (FUNCTION_TYPE_WSTARTTS == ((SFunctionNode*)pFunc)->funcType) {
|
if (FUNCTION_TYPE_WSTART == ((SFunctionNode*)pFunc)->funcType) {
|
||||||
*pWStrartIndex = index;
|
*pWStrartIndex = index;
|
||||||
}
|
}
|
||||||
smaFuncIndex = smaIndexOptFindSmaFunc(pFunc, pSmaFuncs);
|
smaFuncIndex = smaIndexOptFindSmaFunc(pFunc, pSmaFuncs);
|
||||||
|
@ -1252,7 +1255,7 @@ static SNode* smaIndexOptCreateWStartTs() {
|
||||||
if (NULL == pWStart) {
|
if (NULL == pWStart) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpy(pWStart->functionName, "_wstartts");
|
strcpy(pWStart->functionName, "_wstart");
|
||||||
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart);
|
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart);
|
||||||
if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pWStart, NULL, 0)) {
|
if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pWStart, NULL, 0)) {
|
||||||
nodesDestroyNode((SNode*)pWStart);
|
nodesDestroyNode((SNode*)pWStart);
|
||||||
|
@ -2054,11 +2057,11 @@ static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) {
|
||||||
((SExprNode*)*pNode)->aliasName);
|
((SExprNode*)*pNode)->aliasName);
|
||||||
nodesDestroyNode(*pNode);
|
nodesDestroyNode(*pNode);
|
||||||
*pNode = pExpr;
|
*pNode = pExpr;
|
||||||
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -2100,11 +2103,12 @@ static bool tagScanMayBeOptimized(SLogicNode* pNode) {
|
||||||
if (QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(pNode) || (SCAN_TYPE_TAG == ((SScanLogicNode*)pNode)->scanType)) {
|
if (QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(pNode) || (SCAN_TYPE_TAG == ((SScanLogicNode*)pNode)->scanType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SScanLogicNode *pScan = (SScanLogicNode*)pNode;
|
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
||||||
if (NULL != pScan->pScanCols) {
|
if (NULL != pScan->pScanCols) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (NULL == pNode->pParent || QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent) || 1 != LIST_LENGTH(pNode->pParent->pChildren)) {
|
if (NULL == pNode->pParent || QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent) ||
|
||||||
|
1 != LIST_LENGTH(pNode->pParent->pChildren)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
SNode* pFunc = NULL;
|
SNode* pFunc = NULL;
|
||||||
FOREACH(pFunc, pFuncs) {
|
FOREACH(pFunc, pFuncs) {
|
||||||
if (FUNCTION_TYPE_WSTARTTS == ((SFunctionNode*)pFunc)->funcType) {
|
if (FUNCTION_TYPE_WSTART == ((SFunctionNode*)pFunc)->funcType) {
|
||||||
*pIndex = index;
|
*pIndex = index;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) {
|
||||||
if (NULL == pWStart) {
|
if (NULL == pWStart) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
strcpy(pWStart->functionName, "_wstartts");
|
strcpy(pWStart->functionName, "_wstart");
|
||||||
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart);
|
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart);
|
||||||
int32_t code = fmGetFuncInfo(pWStart, NULL, 0);
|
int32_t code = fmGetFuncInfo(pWStart, NULL, 0);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -333,7 +333,7 @@ static int32_t stbSplAppendWEnd(SWindowLogicNode* pWin, int32_t* pIndex) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
SNode* pFunc = NULL;
|
SNode* pFunc = NULL;
|
||||||
FOREACH(pFunc, pWin->pFuncs) {
|
FOREACH(pFunc, pWin->pFuncs) {
|
||||||
if (FUNCTION_TYPE_WENDTS == ((SFunctionNode*)pFunc)->funcType) {
|
if (FUNCTION_TYPE_WEND == ((SFunctionNode*)pFunc)->funcType) {
|
||||||
*pIndex = index;
|
*pIndex = index;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,7 @@ static int32_t stbSplAppendWEnd(SWindowLogicNode* pWin, int32_t* pIndex) {
|
||||||
if (NULL == pWEnd) {
|
if (NULL == pWEnd) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
strcpy(pWEnd->functionName, "_wendts");
|
strcpy(pWEnd->functionName, "_wend");
|
||||||
snprintf(pWEnd->node.aliasName, sizeof(pWEnd->node.aliasName), "%s.%p", pWEnd->functionName, pWEnd);
|
snprintf(pWEnd->node.aliasName, sizeof(pWEnd->node.aliasName), "%s.%p", pWEnd->functionName, pWEnd);
|
||||||
int32_t code = fmGetFuncInfo(pWEnd, NULL, 0);
|
int32_t code = fmGetFuncInfo(pWEnd, NULL, 0);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
|
|
@ -137,6 +137,17 @@ TEST_F(PlanBasicTest, sampleFunc) {
|
||||||
run("SELECT SAMPLE(c1, 10) FROM st1 PARTITION BY TBNAME");
|
run("SELECT SAMPLE(c1, 10) FROM st1 PARTITION BY TBNAME");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PlanBasicTest, pseudoColumn) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("SELECT _QSTART, _QEND, _QDURATION FROM t1");
|
||||||
|
|
||||||
|
run("SELECT _QSTART, _QEND, _QDURATION FROM t1 WHERE ts BETWEEN '2017-7-14 18:00:00' AND '2017-7-14 19:00:00'");
|
||||||
|
|
||||||
|
run("SELECT _QSTART, _QEND, _QDURATION, _WSTART, _WEND, _WDURATION, COUNT(*) FROM t1 "
|
||||||
|
"WHERE ts BETWEEN '2017-7-14 18:00:00' AND '2017-7-14 19:00:00' INTERVAL(10S)");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(PlanBasicTest, withoutFrom) {
|
TEST_F(PlanBasicTest, withoutFrom) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ TEST_F(PlanIntervalTest, basic) {
|
||||||
TEST_F(PlanIntervalTest, pseudoCol) {
|
TEST_F(PlanIntervalTest, pseudoCol) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("SELECT _WSTARTTS, _WDURATION, _WENDTS, COUNT(*) FROM t1 INTERVAL(10s)");
|
run("SELECT _WSTART, _WDURATION, _WEND, COUNT(*) FROM t1 INTERVAL(10s)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlanIntervalTest, fill) {
|
TEST_F(PlanIntervalTest, fill) {
|
||||||
|
@ -59,9 +59,9 @@ TEST_F(PlanIntervalTest, stable) {
|
||||||
|
|
||||||
run("SELECT COUNT(*) FROM st1 INTERVAL(10s)");
|
run("SELECT COUNT(*) FROM st1 INTERVAL(10s)");
|
||||||
|
|
||||||
run("SELECT _WSTARTTS, COUNT(*) FROM st1 INTERVAL(10s)");
|
run("SELECT _WSTART, COUNT(*) FROM st1 INTERVAL(10s)");
|
||||||
|
|
||||||
run("SELECT _WSTARTTS, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)");
|
run("SELECT _WSTART, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)");
|
||||||
|
|
||||||
run("SELECT TBNAME, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)");
|
run("SELECT TBNAME, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)");
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ TEST_F(PlanOptimizeTest, sortPrimaryKey) {
|
||||||
|
|
||||||
run("SELECT c1 FROM t1 ORDER BY ts DESC");
|
run("SELECT c1 FROM t1 ORDER BY ts DESC");
|
||||||
|
|
||||||
run("SELECT COUNT(*) FROM t1 INTERVAL(10S) ORDER BY _WSTARTTS DESC");
|
run("SELECT COUNT(*) FROM t1 INTERVAL(10S) ORDER BY _WSTART DESC");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlanOptimizeTest, PartitionTags) {
|
TEST_F(PlanOptimizeTest, PartitionTags) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ TEST_F(PlanOtherTest, createSmaIndex) {
|
||||||
|
|
||||||
run("SELECT SUM(c4) FROM t1 INTERVAL(10s)");
|
run("SELECT SUM(c4) FROM t1 INTERVAL(10s)");
|
||||||
|
|
||||||
run("SELECT _WSTARTTS, MIN(c3 + 10) FROM t1 "
|
run("SELECT _WSTART, MIN(c3 + 10) FROM t1 "
|
||||||
"WHERE ts BETWEEN TIMESTAMP '2022-04-01 00:00:00' AND TIMESTAMP '2022-04-30 23:59:59.999' INTERVAL(10s)");
|
"WHERE ts BETWEEN TIMESTAMP '2022-04-01 00:00:00' AND TIMESTAMP '2022-04-30 23:59:59.999' INTERVAL(10s)");
|
||||||
|
|
||||||
run("SELECT SUM(c4), MAX(c3) FROM t1 INTERVAL(10s)");
|
run("SELECT SUM(c4), MAX(c3) FROM t1 INTERVAL(10s)");
|
||||||
|
|
|
@ -30,6 +30,7 @@ typedef struct SOperatorValueType {
|
||||||
|
|
||||||
typedef struct SScalarCtx {
|
typedef struct SScalarCtx {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
bool dual;
|
||||||
SArray *pBlockList; /* element is SSDataBlock* */
|
SArray *pBlockList; /* element is SSDataBlock* */
|
||||||
SHashObj *pRes; /* element is SScalarParam */
|
SHashObj *pRes; /* element is SScalarParam */
|
||||||
void *param; // additional parameter (meta actually) for acquire value such as tbname/tags values
|
void *param; // additional parameter (meta actually) for acquire value such as tbname/tags values
|
||||||
|
|
|
@ -1010,13 +1010,14 @@ int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockL
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) {
|
int32_t sclCalcConstants(SNode *pNode, bool dual, SNode **pRes) {
|
||||||
if (NULL == pNode) {
|
if (NULL == pNode) {
|
||||||
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SScalarCtx ctx = {0};
|
SScalarCtx ctx = {0};
|
||||||
|
ctx.dual = dual;
|
||||||
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
if (NULL == ctx.pRes) {
|
if (NULL == ctx.pRes) {
|
||||||
sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM);
|
sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM);
|
||||||
|
@ -1028,10 +1029,88 @@ int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) {
|
||||||
*pRes = pNode;
|
*pRes = pNode;
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
sclFreeRes(ctx.pRes);
|
sclFreeRes(ctx.pRes);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t sclGetMinusOperatorResType(SOperatorNode* pOp) {
|
||||||
|
if (!IS_MATHABLE_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) {
|
||||||
|
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||||
|
}
|
||||||
|
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
||||||
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sclGetMathOperatorResType(SOperatorNode* pOp) {
|
||||||
|
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
||||||
|
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
|
||||||
|
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) ||
|
||||||
|
(TSDB_DATA_TYPE_TIMESTAMP == ldt.type && (IS_VAR_DATA_TYPE(rdt.type) || IS_FLOAT_TYPE(rdt.type))) ||
|
||||||
|
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && (IS_VAR_DATA_TYPE(ldt.type) || IS_FLOAT_TYPE(ldt.type)))) {
|
||||||
|
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && IS_INTEGER_TYPE(rdt.type)) ||
|
||||||
|
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && IS_INTEGER_TYPE(ldt.type)) ||
|
||||||
|
(TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_BOOL == rdt.type) ||
|
||||||
|
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && TSDB_DATA_TYPE_BOOL == ldt.type)) {
|
||||||
|
pOp->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes;
|
||||||
|
} else {
|
||||||
|
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
||||||
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sclGetCompOperatorResType(SOperatorNode* pOp) {
|
||||||
|
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
||||||
|
if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) {
|
||||||
|
((SExprNode*)(pOp->pRight))->resType = ldt;
|
||||||
|
} else if (nodesIsRegularOp(pOp)) {
|
||||||
|
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
|
||||||
|
if (!IS_VAR_DATA_TYPE(ldt.type) || QUERY_NODE_VALUE != nodeType(pOp->pRight) ||
|
||||||
|
(!IS_STR_DATA_TYPE(rdt.type) && (rdt.type != TSDB_DATA_TYPE_NULL))) {
|
||||||
|
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||||
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sclGetJsonOperatorResType(SOperatorNode* pOp) {
|
||||||
|
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
||||||
|
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
|
||||||
|
if (TSDB_DATA_TYPE_JSON != ldt.type || !IS_STR_DATA_TYPE(rdt.type)) {
|
||||||
|
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||||
|
}
|
||||||
|
if (pOp->opType == OP_TYPE_JSON_GET_VALUE) {
|
||||||
|
pOp->node.resType.type = TSDB_DATA_TYPE_JSON;
|
||||||
|
} else if (pOp->opType == OP_TYPE_JSON_CONTAINS) {
|
||||||
|
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||||
|
}
|
||||||
|
pOp->node.resType.bytes = tDataTypes[pOp->node.resType.type].bytes;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sclGetBitwiseOperatorResType(SOperatorNode* pOp) {
|
||||||
|
pOp->node.resType.type = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) {
|
||||||
|
return sclCalcConstants(pNode, false, pRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t scalarCalculateConstantsFromDual(SNode *pNode, SNode **pRes) {
|
||||||
|
return sclCalcConstants(pNode, true, pRes);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
||||||
if (NULL == pNode || NULL == pBlockList) {
|
if (NULL == pNode || NULL == pBlockList) {
|
||||||
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
@ -1075,74 +1154,6 @@ _return:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getMinusOperatorResultType(SOperatorNode* pOp) {
|
|
||||||
if (!IS_MATHABLE_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) {
|
|
||||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
|
||||||
}
|
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
|
||||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t getArithmeticOperatorResultType(SOperatorNode* pOp) {
|
|
||||||
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
|
||||||
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
|
|
||||||
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) ||
|
|
||||||
(TSDB_DATA_TYPE_TIMESTAMP == ldt.type && (IS_VAR_DATA_TYPE(rdt.type) || IS_FLOAT_TYPE(rdt.type))) ||
|
|
||||||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && (IS_VAR_DATA_TYPE(ldt.type) || IS_FLOAT_TYPE(ldt.type)))) {
|
|
||||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && IS_INTEGER_TYPE(rdt.type)) ||
|
|
||||||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && IS_INTEGER_TYPE(ldt.type)) ||
|
|
||||||
(TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_BOOL == rdt.type) ||
|
|
||||||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && TSDB_DATA_TYPE_BOOL == ldt.type)) {
|
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP;
|
|
||||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes;
|
|
||||||
} else {
|
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
|
||||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t getComparisonOperatorResultType(SOperatorNode* pOp) {
|
|
||||||
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
|
||||||
if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) {
|
|
||||||
((SExprNode*)(pOp->pRight))->resType = ldt;
|
|
||||||
} else if (nodesIsRegularOp(pOp)) {
|
|
||||||
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
|
|
||||||
if (!IS_VAR_DATA_TYPE(ldt.type) || QUERY_NODE_VALUE != nodeType(pOp->pRight) ||
|
|
||||||
(!IS_STR_DATA_TYPE(rdt.type) && (rdt.type != TSDB_DATA_TYPE_NULL))) {
|
|
||||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
|
||||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t getJsonOperatorResultType(SOperatorNode* pOp) {
|
|
||||||
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
|
||||||
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
|
|
||||||
if (TSDB_DATA_TYPE_JSON != ldt.type || !IS_STR_DATA_TYPE(rdt.type)) {
|
|
||||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
|
||||||
}
|
|
||||||
if (pOp->opType == OP_TYPE_JSON_GET_VALUE) {
|
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_JSON;
|
|
||||||
} else if (pOp->opType == OP_TYPE_JSON_CONTAINS) {
|
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
|
||||||
}
|
|
||||||
pOp->node.resType.bytes = tDataTypes[pOp->node.resType.type].bytes;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t getBitwiseOperatorResultType(SOperatorNode* pOp) {
|
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_BIGINT;
|
|
||||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t scalarGetOperatorResultType(SOperatorNode* pOp) {
|
int32_t scalarGetOperatorResultType(SOperatorNode* pOp) {
|
||||||
if (TSDB_DATA_TYPE_BLOB == ((SExprNode*)(pOp->pLeft))->resType.type ||
|
if (TSDB_DATA_TYPE_BLOB == ((SExprNode*)(pOp->pLeft))->resType.type ||
|
||||||
(NULL != pOp->pRight && TSDB_DATA_TYPE_BLOB == ((SExprNode*)(pOp->pRight))->resType.type)) {
|
(NULL != pOp->pRight && TSDB_DATA_TYPE_BLOB == ((SExprNode*)(pOp->pRight))->resType.type)) {
|
||||||
|
@ -1155,15 +1166,15 @@ int32_t scalarGetOperatorResultType(SOperatorNode* pOp) {
|
||||||
case OP_TYPE_MULTI:
|
case OP_TYPE_MULTI:
|
||||||
case OP_TYPE_DIV:
|
case OP_TYPE_DIV:
|
||||||
case OP_TYPE_REM:
|
case OP_TYPE_REM:
|
||||||
return getArithmeticOperatorResultType(pOp);
|
return sclGetMathOperatorResType(pOp);
|
||||||
case OP_TYPE_MINUS:
|
case OP_TYPE_MINUS:
|
||||||
return getMinusOperatorResultType(pOp);
|
return sclGetMinusOperatorResType(pOp);
|
||||||
case OP_TYPE_ASSIGN:
|
case OP_TYPE_ASSIGN:
|
||||||
pOp->node.resType = ((SExprNode*)(pOp->pLeft))->resType;
|
pOp->node.resType = ((SExprNode*)(pOp->pLeft))->resType;
|
||||||
break;
|
break;
|
||||||
case OP_TYPE_BIT_AND:
|
case OP_TYPE_BIT_AND:
|
||||||
case OP_TYPE_BIT_OR:
|
case OP_TYPE_BIT_OR:
|
||||||
return getBitwiseOperatorResultType(pOp);
|
return sclGetBitwiseOperatorResType(pOp);
|
||||||
case OP_TYPE_GREATER_THAN:
|
case OP_TYPE_GREATER_THAN:
|
||||||
case OP_TYPE_GREATER_EQUAL:
|
case OP_TYPE_GREATER_EQUAL:
|
||||||
case OP_TYPE_LOWER_THAN:
|
case OP_TYPE_LOWER_THAN:
|
||||||
|
@ -1184,10 +1195,10 @@ int32_t scalarGetOperatorResultType(SOperatorNode* pOp) {
|
||||||
case OP_TYPE_NMATCH:
|
case OP_TYPE_NMATCH:
|
||||||
case OP_TYPE_IN:
|
case OP_TYPE_IN:
|
||||||
case OP_TYPE_NOT_IN:
|
case OP_TYPE_NOT_IN:
|
||||||
return getComparisonOperatorResultType(pOp);
|
return sclGetCompOperatorResType(pOp);
|
||||||
case OP_TYPE_JSON_GET_VALUE:
|
case OP_TYPE_JSON_GET_VALUE:
|
||||||
case OP_TYPE_JSON_CONTAINS:
|
case OP_TYPE_JSON_CONTAINS:
|
||||||
return getJsonOperatorResultType(pOp);
|
return sclGetJsonOperatorResType(pOp);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1055,7 +1055,7 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vectorMathBigintAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) {
|
static void vectorMathTsAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) {
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||||
|
|
||||||
|
@ -1069,7 +1069,8 @@ static void vectorMathBigintAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue; // TODO set null or ignore
|
continue; // TODO set null or ignore
|
||||||
}
|
}
|
||||||
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, 0);
|
*output = taosTimeAdd(getVectorBigintValueFnLeft(pLeftCol->pData, i), getVectorBigintValueFnRight(pRightCol->pData, 0),
|
||||||
|
pRightCol->info.scale, pRightCol->info.precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1116,7 +1117,17 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||||
|
|
||||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
if (pLeft->numOfRows == 1 && pRight->numOfRows == 1) {
|
||||||
|
if (GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
|
vectorMathTsAddHelper(pLeftCol, pRightCol, pOutputCol, pRight->numOfRows, step, i);
|
||||||
|
} else {
|
||||||
|
vectorMathTsAddHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i);
|
||||||
|
}
|
||||||
|
} else if (pLeft->numOfRows == 1) {
|
||||||
|
vectorMathTsAddHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i);
|
||||||
|
} else if (pRight->numOfRows == 1) {
|
||||||
|
vectorMathTsAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i);
|
||||||
|
} else if (pLeft->numOfRows == pRight->numOfRows) {
|
||||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||||
if (IS_NULL) {
|
if (IS_NULL) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
|
@ -1124,11 +1135,7 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
||||||
}
|
}
|
||||||
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, i);
|
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, i);
|
||||||
}
|
}
|
||||||
} else if (pLeft->numOfRows == 1) {
|
}
|
||||||
vectorMathBigintAddHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i);
|
|
||||||
} else if (pRight->numOfRows == 1) {
|
|
||||||
vectorMathBigintAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
double *output = (double *)pOutputCol->pData;
|
double *output = (double *)pOutputCol->pData;
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
||||||
|
@ -1174,7 +1181,7 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vectorMathBigintSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t factor, int32_t i) {
|
static void vectorMathTsSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t factor, int32_t i) {
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||||
|
|
||||||
|
@ -1188,7 +1195,9 @@ static void vectorMathBigintSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue; // TODO set null or ignore
|
continue; // TODO set null or ignore
|
||||||
}
|
}
|
||||||
*output = (getVectorBigintValueFnLeft(pLeftCol->pData, i) - getVectorBigintValueFnRight(pRightCol->pData, 0)) * factor;
|
*output = taosTimeSub(getVectorBigintValueFnLeft(pLeftCol->pData, i), getVectorBigintValueFnRight(pRightCol->pData, 0),
|
||||||
|
pRightCol->info.scale, pRightCol->info.precision);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1211,7 +1220,13 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||||
|
|
||||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
if (pLeft->numOfRows == 1 && pRight->numOfRows == 1) {
|
||||||
|
vectorMathTsSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i);
|
||||||
|
} else if (pLeft->numOfRows == 1) {
|
||||||
|
vectorMathTsSubHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, -1, i);
|
||||||
|
} else if (pRight->numOfRows == 1) {
|
||||||
|
vectorMathTsSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i);
|
||||||
|
} else if (pLeft->numOfRows == pRight->numOfRows) {
|
||||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||||
if (IS_NULL) {
|
if (IS_NULL) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
|
@ -1219,10 +1234,6 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
||||||
}
|
}
|
||||||
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) - getVectorBigintValueFnRight(pRightCol->pData, i);
|
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) - getVectorBigintValueFnRight(pRightCol->pData, i);
|
||||||
}
|
}
|
||||||
} else if (pLeft->numOfRows == 1) {
|
|
||||||
vectorMathBigintSubHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, -1, i);
|
|
||||||
} else if (pRight->numOfRows == 1) {
|
|
||||||
vectorMathBigintSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
double *output = (double *)pOutputCol->pData;
|
double *output = (double *)pOutputCol->pData;
|
||||||
|
|
|
@ -223,6 +223,7 @@ typedef struct SSchJobAttr {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t op;
|
int32_t op;
|
||||||
|
SRWLatch lock;
|
||||||
bool syncReq;
|
bool syncReq;
|
||||||
} SSchOpStatus;
|
} SSchOpStatus;
|
||||||
|
|
||||||
|
@ -473,6 +474,7 @@ int32_t schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTas
|
||||||
int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel, int32_t levelNum);
|
int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel, int32_t levelNum);
|
||||||
int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask);
|
int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask);
|
||||||
void schDirectPostJobRes(SSchedulerReq* pReq, int32_t errCode);
|
void schDirectPostJobRes(SSchedulerReq* pReq, int32_t errCode);
|
||||||
|
bool schChkCurrentOp(SSchJob *pJob, int32_t op, bool sync);
|
||||||
|
|
||||||
extern SSchDebug gSCHDebug;
|
extern SSchDebug gSCHDebug;
|
||||||
|
|
||||||
|
|
|
@ -443,25 +443,37 @@ int32_t schNotifyUserFetchRes(SSchJob* pJob) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void schPostJobRes(SSchJob *pJob, SCH_OP_TYPE op) {
|
void schPostJobRes(SSchJob *pJob, SCH_OP_TYPE op) {
|
||||||
|
SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
|
|
||||||
if (SCH_OP_NULL == pJob->opStatus.op) {
|
if (SCH_OP_NULL == pJob->opStatus.op) {
|
||||||
SCH_JOB_DLOG("job not in any operation, no need to post job res, status:%s", jobTaskStatusStr(pJob->status));
|
SCH_JOB_DLOG("job not in any operation, no need to post job res, status:%s", jobTaskStatusStr(pJob->status));
|
||||||
return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op && pJob->opStatus.op != op) {
|
if (op && pJob->opStatus.op != op) {
|
||||||
SCH_JOB_ELOG("job in operation %s mis-match with expected %s", schGetOpStr(pJob->opStatus.op), schGetOpStr(op));
|
SCH_JOB_ELOG("job in operation %s mis-match with expected %s", schGetOpStr(pJob->opStatus.op), schGetOpStr(op));
|
||||||
return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SCH_JOB_IN_SYNC_OP(pJob)) {
|
if (SCH_JOB_IN_SYNC_OP(pJob)) {
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
tsem_post(&pJob->rspSem);
|
tsem_post(&pJob->rspSem);
|
||||||
} else if (SCH_JOB_IN_ASYNC_EXEC_OP(pJob)) {
|
} else if (SCH_JOB_IN_ASYNC_EXEC_OP(pJob)) {
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
schNotifyUserExecRes(pJob);
|
schNotifyUserExecRes(pJob);
|
||||||
} else if (SCH_JOB_IN_ASYNC_FETCH_OP(pJob)) {
|
} else if (SCH_JOB_IN_ASYNC_FETCH_OP(pJob)) {
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
schNotifyUserFetchRes(pJob);
|
schNotifyUserFetchRes(pJob);
|
||||||
} else {
|
} else {
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
SCH_JOB_ELOG("job not in any operation, status:%s", jobTaskStatusStr(pJob->status));
|
SCH_JOB_ELOG("job not in any operation, status:%s", jobTaskStatusStr(pJob->status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schProcessOnJobFailureImpl(SSchJob *pJob, int32_t status, int32_t errCode) {
|
int32_t schProcessOnJobFailureImpl(SSchJob *pJob, int32_t status, int32_t errCode) {
|
||||||
|
@ -658,13 +670,13 @@ int32_t schJobFetchRows(SSchJob *pJob) {
|
||||||
if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC)) {
|
if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC)) {
|
||||||
SCH_ERR_RET(schLaunchFetchTask(pJob));
|
SCH_ERR_RET(schLaunchFetchTask(pJob));
|
||||||
|
|
||||||
if (pJob->opStatus.syncReq) {
|
if (schChkCurrentOp(pJob, SCH_OP_FETCH, true)) {
|
||||||
SCH_JOB_DLOG("sync wait for rsp now, job status:%s", SCH_GET_JOB_STATUS_STR(pJob));
|
SCH_JOB_DLOG("sync wait for rsp now, job status:%s", SCH_GET_JOB_STATUS_STR(pJob));
|
||||||
tsem_wait(&pJob->rspSem);
|
tsem_wait(&pJob->rspSem);
|
||||||
SCH_RET(schDumpJobFetchRes(pJob, pJob->userRes.fetchRes));
|
SCH_RET(schDumpJobFetchRes(pJob, pJob->userRes.fetchRes));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pJob->opStatus.syncReq) {
|
if (schChkCurrentOp(pJob, SCH_OP_FETCH, true)) {
|
||||||
SCH_RET(schDumpJobFetchRes(pJob, pJob->userRes.fetchRes));
|
SCH_RET(schDumpJobFetchRes(pJob, pJob->userRes.fetchRes));
|
||||||
} else {
|
} else {
|
||||||
schPostJobRes(pJob, SCH_OP_FETCH);
|
schPostJobRes(pJob, SCH_OP_FETCH);
|
||||||
|
@ -775,25 +787,37 @@ void schDirectPostJobRes(SSchedulerReq* pReq, int32_t errCode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool schChkCurrentOp(SSchJob *pJob, int32_t op, bool sync) {
|
||||||
|
SCH_LOCK(SCH_READ, &pJob->opStatus.lock);
|
||||||
|
bool r = (pJob->opStatus.op == op) && (pJob->opStatus.syncReq == sync);
|
||||||
|
SCH_UNLOCK(SCH_READ, &pJob->opStatus.lock);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
void schProcessOnOpEnd(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq* pReq, int32_t errCode) {
|
void schProcessOnOpEnd(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq* pReq, int32_t errCode) {
|
||||||
int32_t op = 0;
|
int32_t op = 0;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SCH_OP_EXEC:
|
case SCH_OP_EXEC:
|
||||||
if (pReq && pReq->syncReq) {
|
if (pReq && pReq->syncReq) {
|
||||||
|
SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
op = atomic_val_compare_exchange_32(&pJob->opStatus.op, type, SCH_OP_NULL);
|
op = atomic_val_compare_exchange_32(&pJob->opStatus.op, type, SCH_OP_NULL);
|
||||||
if (SCH_OP_NULL == op || op != type) {
|
if (SCH_OP_NULL == op || op != type) {
|
||||||
SCH_JOB_ELOG("job not in %s operation, op:%s, status:%s", schGetOpStr(type), schGetOpStr(op), jobTaskStatusStr(pJob->status));
|
SCH_JOB_ELOG("job not in %s operation, op:%s, status:%s", schGetOpStr(type), schGetOpStr(op), jobTaskStatusStr(pJob->status));
|
||||||
}
|
}
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
schDumpJobExecRes(pJob, pReq->pExecRes);
|
schDumpJobExecRes(pJob, pReq->pExecRes);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCH_OP_FETCH:
|
case SCH_OP_FETCH:
|
||||||
if (pReq && pReq->syncReq) {
|
if (pReq && pReq->syncReq) {
|
||||||
|
SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
op = atomic_val_compare_exchange_32(&pJob->opStatus.op, type, SCH_OP_NULL);
|
op = atomic_val_compare_exchange_32(&pJob->opStatus.op, type, SCH_OP_NULL);
|
||||||
if (SCH_OP_NULL == op || op != type) {
|
if (SCH_OP_NULL == op || op != type) {
|
||||||
SCH_JOB_ELOG("job not in %s operation, op:%s, status:%s", schGetOpStr(type), schGetOpStr(op), jobTaskStatusStr(pJob->status));
|
SCH_JOB_ELOG("job not in %s operation, op:%s, status:%s", schGetOpStr(type), schGetOpStr(op), jobTaskStatusStr(pJob->status));
|
||||||
}
|
}
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCH_OP_GET_STATUS:
|
case SCH_OP_GET_STATUS:
|
||||||
|
@ -816,8 +840,10 @@ int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SCH_OP_EXEC:
|
case SCH_OP_EXEC:
|
||||||
|
SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
if (SCH_OP_NULL != atomic_val_compare_exchange_32(&pJob->opStatus.op, SCH_OP_NULL, type)) {
|
if (SCH_OP_NULL != atomic_val_compare_exchange_32(&pJob->opStatus.op, SCH_OP_NULL, type)) {
|
||||||
SCH_JOB_ELOG("job already in %s operation", schGetOpStr(pJob->opStatus.op));
|
SCH_JOB_ELOG("job already in %s operation", schGetOpStr(pJob->opStatus.op));
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
schDirectPostJobRes(pReq, TSDB_CODE_TSC_APP_ERROR);
|
schDirectPostJobRes(pReq, TSDB_CODE_TSC_APP_ERROR);
|
||||||
SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR);
|
SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -825,10 +851,13 @@ int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq
|
||||||
SCH_JOB_DLOG("job start %s operation", schGetOpStr(pJob->opStatus.op));
|
SCH_JOB_DLOG("job start %s operation", schGetOpStr(pJob->opStatus.op));
|
||||||
|
|
||||||
pJob->opStatus.syncReq = pReq->syncReq;
|
pJob->opStatus.syncReq = pReq->syncReq;
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
break;
|
break;
|
||||||
case SCH_OP_FETCH:
|
case SCH_OP_FETCH:
|
||||||
|
SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
if (SCH_OP_NULL != atomic_val_compare_exchange_32(&pJob->opStatus.op, SCH_OP_NULL, type)) {
|
if (SCH_OP_NULL != atomic_val_compare_exchange_32(&pJob->opStatus.op, SCH_OP_NULL, type)) {
|
||||||
SCH_JOB_ELOG("job already in %s operation", schGetOpStr(pJob->opStatus.op));
|
SCH_JOB_ELOG("job already in %s operation", schGetOpStr(pJob->opStatus.op));
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
schDirectPostJobRes(pReq, TSDB_CODE_TSC_APP_ERROR);
|
schDirectPostJobRes(pReq, TSDB_CODE_TSC_APP_ERROR);
|
||||||
SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR);
|
SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -840,6 +869,7 @@ int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq
|
||||||
pJob->userRes.cbParam = pReq->cbParam;
|
pJob->userRes.cbParam = pReq->cbParam;
|
||||||
|
|
||||||
pJob->opStatus.syncReq = pReq->syncReq;
|
pJob->opStatus.syncReq = pReq->syncReq;
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||||
|
|
||||||
if (!SCH_JOB_NEED_FETCH(pJob)) {
|
if (!SCH_JOB_NEED_FETCH(pJob)) {
|
||||||
SCH_JOB_ELOG("no need to fetch data, status:%s", SCH_GET_JOB_STATUS_STR(pJob));
|
SCH_JOB_ELOG("no need to fetch data, status:%s", SCH_GET_JOB_STATUS_STR(pJob));
|
||||||
|
|
|
@ -505,6 +505,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (SCH_IS_DATA_BIND_TASK(pTask)) {
|
if (SCH_IS_DATA_BIND_TASK(pTask)) {
|
||||||
if ((pTask->execId + 1) >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
|
if ((pTask->execId + 1) >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
|
||||||
*needRetry = false;
|
*needRetry = false;
|
||||||
|
@ -522,6 +523,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
*needRetry = true;
|
*needRetry = true;
|
||||||
SCH_TASK_DLOG("task need the %dth retry, errCode:%x - %s", pTask->execId + 1, errCode, tstrerror(errCode));
|
SCH_TASK_DLOG("task need the %dth retry, errCode:%x - %s", pTask->execId + 1, errCode, tstrerror(errCode));
|
||||||
|
|
|
@ -116,7 +116,7 @@ void streamFreeQitem(SStreamQueueItem* data) {
|
||||||
blockDataDestroy(((SStreamTrigger*)data)->pBlock);
|
blockDataDestroy(((SStreamTrigger*)data)->pBlock);
|
||||||
taosFreeQitem(data);
|
taosFreeQitem(data);
|
||||||
} else if (type == STREAM_INPUT__DATA_BLOCK || type == STREAM_INPUT__DATA_RETRIEVE) {
|
} else if (type == STREAM_INPUT__DATA_BLOCK || type == STREAM_INPUT__DATA_RETRIEVE) {
|
||||||
taosArrayDestroyEx(((SStreamDataBlock*)data)->blocks, (FDelete)tDeleteSSDataBlock);
|
taosArrayDestroyEx(((SStreamDataBlock*)data)->blocks, (FDelete)blockDataFreeRes);
|
||||||
taosFreeQitem(data);
|
taosFreeQitem(data);
|
||||||
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
streamDataSubmitRefDec((SStreamDataSubmit*)data);
|
streamDataSubmitRefDec((SStreamDataSubmit*)data);
|
||||||
|
|
|
@ -313,7 +313,7 @@ int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) {
|
||||||
atomic_store_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL);
|
atomic_store_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)tDeleteSSDataBlock);
|
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
|
||||||
taosFreeQitem(pBlock);
|
taosFreeQitem(pBlock);
|
||||||
|
|
||||||
tmsgSendReq(pEpSet, &dispatchMsg);
|
tmsgSendReq(pEpSet, &dispatchMsg);
|
||||||
|
|
|
@ -100,7 +100,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
|
||||||
}
|
}
|
||||||
if (pTask->taskStatus == TASK_STATUS__DROPPING) {
|
if (pTask->taskStatus == TASK_STATUS__DROPPING) {
|
||||||
if (data) streamFreeQitem(data);
|
if (data) streamFreeQitem(data);
|
||||||
taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock);
|
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
|
||||||
qRes->blocks = pRes;
|
qRes->blocks = pRes;
|
||||||
if (streamTaskOutput(pTask, qRes) < 0) {
|
if (streamTaskOutput(pTask, qRes) < 0) {
|
||||||
/*streamQueueProcessFail(pTask->inputQueue);*/
|
/*streamQueueProcessFail(pTask->inputQueue);*/
|
||||||
taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock);
|
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||||
taosFreeQitem(qRes);
|
taosFreeQitem(qRes);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
|
||||||
pRes = streamExecForQall(pTask, pRes);
|
pRes = streamExecForQall(pTask, pRes);
|
||||||
if (pRes == NULL) goto FAIL;
|
if (pRes == NULL) goto FAIL;
|
||||||
|
|
||||||
taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock);
|
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||||
atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE);
|
atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE);
|
||||||
qDebug("stream exec, return result");
|
qDebug("stream exec, return result");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -162,7 +162,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
|
||||||
continue;
|
continue;
|
||||||
} else if (execStatus == TASK_EXEC_STATUS__EXECUTING) {
|
} else if (execStatus == TASK_EXEC_STATUS__EXECUTING) {
|
||||||
ASSERT(taosArrayGetSize(pRes) == 0);
|
ASSERT(taosArrayGetSize(pRes) == 0);
|
||||||
taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock);
|
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
#define DEFAULT_FALSE_POSITIVE 0.01
|
#define DEFAULT_FALSE_POSITIVE 0.01
|
||||||
#define DEFAULT_BUCKET_SIZE 1024
|
#define DEFAULT_BUCKET_SIZE 131072
|
||||||
#define ROWS_PER_MILLISECOND 1
|
#define ROWS_PER_MILLISECOND 1
|
||||||
#define MAX_NUM_SCALABLE_BF 100000
|
#define MAX_NUM_SCALABLE_BF 100000
|
||||||
#define MIN_NUM_SCALABLE_BF 10
|
#define MIN_NUM_SCALABLE_BF 10
|
||||||
|
|
|
@ -26,6 +26,7 @@ extern "C" {
|
||||||
#include "syncInt.h"
|
#include "syncInt.h"
|
||||||
#include "syncMessage.h"
|
#include "syncMessage.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
|
#include "tskiplist.h"
|
||||||
|
|
||||||
typedef struct SSyncRaftEntry {
|
typedef struct SSyncRaftEntry {
|
||||||
uint32_t bytes;
|
uint32_t bytes;
|
||||||
|
@ -58,29 +59,52 @@ void syncEntryLog(const SSyncRaftEntry* pObj);
|
||||||
void syncEntryLog2(char* s, const SSyncRaftEntry* pObj);
|
void syncEntryLog2(char* s, const SSyncRaftEntry* pObj);
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
typedef struct SRaftEntryCache {
|
typedef struct SRaftEntryHashCache {
|
||||||
SHashObj* pEntryHash;
|
SHashObj* pEntryHash;
|
||||||
int32_t maxCount;
|
int32_t maxCount;
|
||||||
int32_t currentCount;
|
int32_t currentCount;
|
||||||
TdThreadMutex mutex;
|
TdThreadMutex mutex;
|
||||||
SSyncNode* pSyncNode;
|
SSyncNode* pSyncNode;
|
||||||
|
} SRaftEntryHashCache;
|
||||||
|
|
||||||
|
SRaftEntryHashCache* raftCacheCreate(SSyncNode* pSyncNode, int32_t maxCount);
|
||||||
|
void raftCacheDestroy(SRaftEntryHashCache* pCache);
|
||||||
|
int32_t raftCachePutEntry(struct SRaftEntryHashCache* pCache, SSyncRaftEntry* pEntry);
|
||||||
|
int32_t raftCacheGetEntry(struct SRaftEntryHashCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry);
|
||||||
|
int32_t raftCacheGetEntryP(struct SRaftEntryHashCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry);
|
||||||
|
int32_t raftCacheDelEntry(struct SRaftEntryHashCache* pCache, SyncIndex index);
|
||||||
|
int32_t raftCacheGetAndDel(struct SRaftEntryHashCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry);
|
||||||
|
int32_t raftCacheClear(struct SRaftEntryHashCache* pCache);
|
||||||
|
|
||||||
|
cJSON* raftCache2Json(SRaftEntryHashCache* pObj);
|
||||||
|
char* raftCache2Str(SRaftEntryHashCache* pObj);
|
||||||
|
void raftCachePrint(SRaftEntryHashCache* pObj);
|
||||||
|
void raftCachePrint2(char* s, SRaftEntryHashCache* pObj);
|
||||||
|
void raftCacheLog(SRaftEntryHashCache* pObj);
|
||||||
|
void raftCacheLog2(char* s, SRaftEntryHashCache* pObj);
|
||||||
|
|
||||||
|
//-----------------------------------
|
||||||
|
typedef struct SRaftEntryCache {
|
||||||
|
SSkipList* pSkipList;
|
||||||
|
int32_t maxCount;
|
||||||
|
int32_t currentCount;
|
||||||
|
TdThreadMutex mutex;
|
||||||
|
SSyncNode* pSyncNode;
|
||||||
} SRaftEntryCache;
|
} SRaftEntryCache;
|
||||||
|
|
||||||
SRaftEntryCache* raftCacheCreate(SSyncNode* pSyncNode, int32_t maxCount);
|
SRaftEntryCache* raftEntryCacheCreate(SSyncNode* pSyncNode, int32_t maxCount);
|
||||||
void raftCacheDestroy(SRaftEntryCache* pCache);
|
void raftEntryCacheDestroy(SRaftEntryCache* pCache);
|
||||||
int32_t raftCachePutEntry(struct SRaftEntryCache* pCache, SSyncRaftEntry* pEntry);
|
int32_t raftEntryCachePutEntry(struct SRaftEntryCache* pCache, SSyncRaftEntry* pEntry);
|
||||||
int32_t raftCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry);
|
int32_t raftEntryCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry);
|
||||||
int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry);
|
int32_t raftEntryCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry);
|
||||||
int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index);
|
int32_t raftEntryCacheClear(struct SRaftEntryCache* pCache, int32_t count);
|
||||||
int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry);
|
|
||||||
int32_t raftCacheClear(struct SRaftEntryCache* pCache);
|
|
||||||
|
|
||||||
cJSON* raftCache2Json(SRaftEntryCache* pObj);
|
cJSON* raftEntryCache2Json(SRaftEntryCache* pObj);
|
||||||
char* raftCache2Str(SRaftEntryCache* pObj);
|
char* raftEntryCache2Str(SRaftEntryCache* pObj);
|
||||||
void raftCachePrint(SRaftEntryCache* pObj);
|
void raftEntryCachePrint(SRaftEntryCache* pObj);
|
||||||
void raftCachePrint2(char* s, SRaftEntryCache* pObj);
|
void raftEntryCachePrint2(char* s, SRaftEntryCache* pObj);
|
||||||
void raftCacheLog(SRaftEntryCache* pObj);
|
void raftEntryCacheLog(SRaftEntryCache* pObj);
|
||||||
void raftCacheLog2(char* s, SRaftEntryCache* pObj);
|
void raftEntryCacheLog2(char* s, SRaftEntryCache* pObj);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,7 @@ int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader) {
|
||||||
|
|
||||||
int32_t syncNodeLeaderTransfer(SSyncNode* pSyncNode) {
|
int32_t syncNodeLeaderTransfer(SSyncNode* pSyncNode) {
|
||||||
if (pSyncNode->peersNum == 0) {
|
if (pSyncNode->peersNum == 0) {
|
||||||
sError("only one replica, cannot leader transfer");
|
sDebug("only one replica, cannot leader transfer");
|
||||||
terrno = TSDB_CODE_SYN_ONE_REPLICA;
|
terrno = TSDB_CODE_SYN_ONE_REPLICA;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeader) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
|
|
||||||
if (pSyncNode->replicaNum == 1) {
|
if (pSyncNode->replicaNum == 1) {
|
||||||
sError("only one replica, cannot leader transfer");
|
sDebug("only one replica, cannot leader transfer");
|
||||||
terrno = TSDB_CODE_SYN_ONE_REPLICA;
|
terrno = TSDB_CODE_SYN_ONE_REPLICA;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1055,19 +1055,12 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// tools
|
// tools
|
||||||
pSyncNode->pSyncRespMgr = syncRespMgrCreate(pSyncNode, 0);
|
pSyncNode->pSyncRespMgr = syncRespMgrCreate(pSyncNode, SYNC_RESP_TTL_MS);
|
||||||
ASSERT(pSyncNode->pSyncRespMgr != NULL);
|
ASSERT(pSyncNode->pSyncRespMgr != NULL);
|
||||||
|
|
||||||
// restore state
|
// restore state
|
||||||
pSyncNode->restoreFinish = false;
|
pSyncNode->restoreFinish = false;
|
||||||
|
|
||||||
// pSyncNode->pSnapshot = NULL;
|
|
||||||
// if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
|
||||||
// pSyncNode->pSnapshot = taosMemoryMalloc(sizeof(SSnapshot));
|
|
||||||
// pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, pSyncNode->pSnapshot);
|
|
||||||
// }
|
|
||||||
// tsem_init(&(pSyncNode->restoreSem), 0, 0);
|
|
||||||
|
|
||||||
// snapshot senders
|
// snapshot senders
|
||||||
for (int i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
for (int i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
||||||
SSyncSnapshotSender* pSender = snapshotSenderCreate(pSyncNode, i);
|
SSyncSnapshotSender* pSender = snapshotSenderCreate(pSyncNode, i);
|
||||||
|
|
|
@ -198,8 +198,8 @@ void syncEntryLog2(char* s, const SSyncRaftEntry* pObj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
SRaftEntryCache* raftCacheCreate(SSyncNode* pSyncNode, int32_t maxCount) {
|
SRaftEntryHashCache* raftCacheCreate(SSyncNode* pSyncNode, int32_t maxCount) {
|
||||||
SRaftEntryCache* pCache = taosMemoryMalloc(sizeof(SRaftEntryCache));
|
SRaftEntryHashCache* pCache = taosMemoryMalloc(sizeof(SRaftEntryHashCache));
|
||||||
if (pCache == NULL) {
|
if (pCache == NULL) {
|
||||||
sError("vgId:%d raft cache create error", pSyncNode->vgId);
|
sError("vgId:%d raft cache create error", pSyncNode->vgId);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -220,7 +220,7 @@ SRaftEntryCache* raftCacheCreate(SSyncNode* pSyncNode, int32_t maxCount) {
|
||||||
return pCache;
|
return pCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raftCacheDestroy(SRaftEntryCache* pCache) {
|
void raftCacheDestroy(SRaftEntryHashCache* pCache) {
|
||||||
if (pCache != NULL) {
|
if (pCache != NULL) {
|
||||||
taosThreadMutexLock(&(pCache->mutex));
|
taosThreadMutexLock(&(pCache->mutex));
|
||||||
taosHashCleanup(pCache->pEntryHash);
|
taosHashCleanup(pCache->pEntryHash);
|
||||||
|
@ -233,7 +233,7 @@ void raftCacheDestroy(SRaftEntryCache* pCache) {
|
||||||
// success, return 1
|
// success, return 1
|
||||||
// max count, return 0
|
// max count, return 0
|
||||||
// error, return -1
|
// error, return -1
|
||||||
int32_t raftCachePutEntry(struct SRaftEntryCache* pCache, SSyncRaftEntry* pEntry) {
|
int32_t raftCachePutEntry(struct SRaftEntryHashCache* pCache, SSyncRaftEntry* pEntry) {
|
||||||
taosThreadMutexLock(&(pCache->mutex));
|
taosThreadMutexLock(&(pCache->mutex));
|
||||||
|
|
||||||
if (pCache->currentCount >= pCache->maxCount) {
|
if (pCache->currentCount >= pCache->maxCount) {
|
||||||
|
@ -259,7 +259,7 @@ int32_t raftCachePutEntry(struct SRaftEntryCache* pCache, SSyncRaftEntry* pEntry
|
||||||
// success, return 0
|
// success, return 0
|
||||||
// error, return -1
|
// error, return -1
|
||||||
// not exist, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST
|
// not exist, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST
|
||||||
int32_t raftCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) {
|
int32_t raftCacheGetEntry(struct SRaftEntryHashCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) {
|
||||||
if (ppEntry == NULL) {
|
if (ppEntry == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ int32_t raftCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSync
|
||||||
// success, return 0
|
// success, return 0
|
||||||
// error, return -1
|
// error, return -1
|
||||||
// not exist, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST
|
// not exist, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST
|
||||||
int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) {
|
int32_t raftCacheGetEntryP(struct SRaftEntryHashCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) {
|
||||||
if (ppEntry == NULL) {
|
if (ppEntry == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyn
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index) {
|
int32_t raftCacheDelEntry(struct SRaftEntryHashCache* pCache, SyncIndex index) {
|
||||||
taosThreadMutexLock(&(pCache->mutex));
|
taosThreadMutexLock(&(pCache->mutex));
|
||||||
taosHashRemove(pCache->pEntryHash, &index, sizeof(index));
|
taosHashRemove(pCache->pEntryHash, &index, sizeof(index));
|
||||||
--(pCache->currentCount);
|
--(pCache->currentCount);
|
||||||
|
@ -329,7 +329,7 @@ int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) {
|
int32_t raftCacheGetAndDel(struct SRaftEntryHashCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) {
|
||||||
if (ppEntry == NULL) {
|
if (ppEntry == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyn
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t raftCacheClear(struct SRaftEntryCache* pCache) {
|
int32_t raftCacheClear(struct SRaftEntryHashCache* pCache) {
|
||||||
taosThreadMutexLock(&(pCache->mutex));
|
taosThreadMutexLock(&(pCache->mutex));
|
||||||
taosHashClear(pCache->pEntryHash);
|
taosHashClear(pCache->pEntryHash);
|
||||||
pCache->currentCount = 0;
|
pCache->currentCount = 0;
|
||||||
|
@ -371,7 +371,7 @@ int32_t raftCacheClear(struct SRaftEntryCache* pCache) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
cJSON* raftCache2Json(SRaftEntryCache* pCache) {
|
cJSON* raftCache2Json(SRaftEntryHashCache* pCache) {
|
||||||
char u64buf[128] = {0};
|
char u64buf[128] = {0};
|
||||||
cJSON* pRoot = cJSON_CreateObject();
|
cJSON* pRoot = cJSON_CreateObject();
|
||||||
|
|
||||||
|
@ -402,41 +402,283 @@ cJSON* raftCache2Json(SRaftEntryCache* pCache) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON* pJson = cJSON_CreateObject();
|
cJSON* pJson = cJSON_CreateObject();
|
||||||
cJSON_AddItemToObject(pJson, "SRaftEntryCache", pRoot);
|
cJSON_AddItemToObject(pJson, "SRaftEntryHashCache", pRoot);
|
||||||
return pJson;
|
return pJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* raftCache2Str(SRaftEntryCache* pCache) {
|
char* raftCache2Str(SRaftEntryHashCache* pCache) {
|
||||||
cJSON* pJson = raftCache2Json(pCache);
|
cJSON* pJson = raftCache2Json(pCache);
|
||||||
char* serialized = cJSON_Print(pJson);
|
char* serialized = cJSON_Print(pJson);
|
||||||
cJSON_Delete(pJson);
|
cJSON_Delete(pJson);
|
||||||
return serialized;
|
return serialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raftCachePrint(SRaftEntryCache* pCache) {
|
void raftCachePrint(SRaftEntryHashCache* pCache) {
|
||||||
char* serialized = raftCache2Str(pCache);
|
char* serialized = raftCache2Str(pCache);
|
||||||
printf("raftCachePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
|
printf("raftCachePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
taosMemoryFree(serialized);
|
taosMemoryFree(serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
void raftCachePrint2(char* s, SRaftEntryCache* pCache) {
|
void raftCachePrint2(char* s, SRaftEntryHashCache* pCache) {
|
||||||
char* serialized = raftCache2Str(pCache);
|
char* serialized = raftCache2Str(pCache);
|
||||||
printf("raftCachePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
|
printf("raftCachePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
taosMemoryFree(serialized);
|
taosMemoryFree(serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
void raftCacheLog(SRaftEntryCache* pCache) {
|
void raftCacheLog(SRaftEntryHashCache* pCache) {
|
||||||
char* serialized = raftCache2Str(pCache);
|
char* serialized = raftCache2Str(pCache);
|
||||||
sTrace("raftCacheLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
|
sTrace("raftCacheLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
|
||||||
taosMemoryFree(serialized);
|
taosMemoryFree(serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
void raftCacheLog2(char* s, SRaftEntryCache* pCache) {
|
void raftCacheLog2(char* s, SRaftEntryHashCache* pCache) {
|
||||||
if (gRaftDetailLog) {
|
if (gRaftDetailLog) {
|
||||||
char* serialized = raftCache2Str(pCache);
|
char* serialized = raftCache2Str(pCache);
|
||||||
sTraceLong("raftCacheLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
|
sTraceLong("raftCacheLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
|
||||||
taosMemoryFree(serialized);
|
taosMemoryFree(serialized);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------
|
||||||
|
static char* keyFn(const void* pData) {
|
||||||
|
SSyncRaftEntry* pEntry = (SSyncRaftEntry*)pData;
|
||||||
|
return (char*)(&(pEntry->index));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cmpFn(const void* p1, const void* p2) { return memcmp(p1, p2, sizeof(SyncIndex)); }
|
||||||
|
|
||||||
|
SRaftEntryCache* raftEntryCacheCreate(SSyncNode* pSyncNode, int32_t maxCount) {
|
||||||
|
SRaftEntryCache* pCache = taosMemoryMalloc(sizeof(SRaftEntryCache));
|
||||||
|
if (pCache == NULL) {
|
||||||
|
sError("vgId:%d raft cache create error", pSyncNode->vgId);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pCache->pSkipList =
|
||||||
|
tSkipListCreate(MAX_SKIP_LIST_LEVEL, TSDB_DATA_TYPE_BINARY, sizeof(SyncIndex), cmpFn, SL_ALLOW_DUP_KEY, keyFn);
|
||||||
|
if (pCache->pSkipList == NULL) {
|
||||||
|
sError("vgId:%d raft cache create hash error", pSyncNode->vgId);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosThreadMutexInit(&(pCache->mutex), NULL);
|
||||||
|
pCache->maxCount = maxCount;
|
||||||
|
pCache->currentCount = 0;
|
||||||
|
pCache->pSyncNode = pSyncNode;
|
||||||
|
|
||||||
|
return pCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
void raftEntryCacheDestroy(SRaftEntryCache* pCache) {
|
||||||
|
if (pCache != NULL) {
|
||||||
|
taosThreadMutexLock(&(pCache->mutex));
|
||||||
|
tSkipListDestroy(pCache->pSkipList);
|
||||||
|
taosThreadMutexUnlock(&(pCache->mutex));
|
||||||
|
taosThreadMutexDestroy(&(pCache->mutex));
|
||||||
|
taosMemoryFree(pCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// success, return 1
|
||||||
|
// max count, return 0
|
||||||
|
// error, return -1
|
||||||
|
int32_t raftEntryCachePutEntry(struct SRaftEntryCache* pCache, SSyncRaftEntry* pEntry) {
|
||||||
|
taosThreadMutexLock(&(pCache->mutex));
|
||||||
|
|
||||||
|
if (pCache->currentCount >= pCache->maxCount) {
|
||||||
|
taosThreadMutexUnlock(&(pCache->mutex));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSkipListNode* pSkipListNode = tSkipListPut(pCache->pSkipList, pEntry);
|
||||||
|
ASSERT(pSkipListNode != NULL);
|
||||||
|
++(pCache->currentCount);
|
||||||
|
|
||||||
|
do {
|
||||||
|
char eventLog[128];
|
||||||
|
snprintf(eventLog, sizeof(eventLog), "raft cache add, type:%s,%d, type2:%s,%d, index:%" PRId64 ", bytes:%d",
|
||||||
|
TMSG_INFO(pEntry->msgType), pEntry->msgType, TMSG_INFO(pEntry->originalRpcType), pEntry->originalRpcType,
|
||||||
|
pEntry->index, pEntry->bytes);
|
||||||
|
syncNodeEventLog(pCache->pSyncNode, eventLog);
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&(pCache->mutex));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find one, return 1
|
||||||
|
// not found, return 0
|
||||||
|
// error, return -1
|
||||||
|
int32_t raftEntryCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) {
|
||||||
|
ASSERT(ppEntry != NULL);
|
||||||
|
SSyncRaftEntry* pEntry = NULL;
|
||||||
|
int32_t code = raftEntryCacheGetEntryP(pCache, index, &pEntry);
|
||||||
|
if (code == 1) {
|
||||||
|
*ppEntry = taosMemoryMalloc(pEntry->bytes);
|
||||||
|
memcpy(*ppEntry, pEntry, pEntry->bytes);
|
||||||
|
} else {
|
||||||
|
*ppEntry = NULL;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find one, return 1
|
||||||
|
// not found, return 0
|
||||||
|
// error, return -1
|
||||||
|
int32_t raftEntryCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) {
|
||||||
|
taosThreadMutexLock(&(pCache->mutex));
|
||||||
|
|
||||||
|
SyncIndex index2 = index;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
SArray* entryPArray = tSkipListGet(pCache->pSkipList, (char*)(&index2));
|
||||||
|
int32_t arraySize = taosArrayGetSize(entryPArray);
|
||||||
|
if (arraySize == 1) {
|
||||||
|
SSkipListNode** ppNode = (SSkipListNode**)taosArrayGet(entryPArray, 0);
|
||||||
|
ASSERT(*ppNode != NULL);
|
||||||
|
*ppEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(*ppNode);
|
||||||
|
code = 1;
|
||||||
|
|
||||||
|
} else if (arraySize == 0) {
|
||||||
|
code = 0;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
|
||||||
|
code = -1;
|
||||||
|
}
|
||||||
|
taosArrayDestroy(entryPArray);
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&(pCache->mutex));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// count = -1, clear all
|
||||||
|
// count >= 0, clear count
|
||||||
|
// return -1, error
|
||||||
|
// return delete count
|
||||||
|
int32_t raftEntryCacheClear(struct SRaftEntryCache* pCache, int32_t count) {
|
||||||
|
taosThreadMutexLock(&(pCache->mutex));
|
||||||
|
int32_t returnCnt = 0;
|
||||||
|
|
||||||
|
if (count == -1) {
|
||||||
|
// clear all
|
||||||
|
SSkipListIterator* pIter = tSkipListCreateIter(pCache->pSkipList);
|
||||||
|
while (tSkipListIterNext(pIter)) {
|
||||||
|
SSkipListNode* pNode = tSkipListIterGet(pIter);
|
||||||
|
ASSERT(pNode != NULL);
|
||||||
|
SSyncRaftEntry* pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode);
|
||||||
|
syncEntryDestory(pEntry);
|
||||||
|
++returnCnt;
|
||||||
|
}
|
||||||
|
tSkipListDestroyIter(pIter);
|
||||||
|
|
||||||
|
tSkipListDestroy(pCache->pSkipList);
|
||||||
|
pCache->pSkipList =
|
||||||
|
tSkipListCreate(MAX_SKIP_LIST_LEVEL, TSDB_DATA_TYPE_BINARY, sizeof(SyncIndex), cmpFn, SL_ALLOW_DUP_KEY, keyFn);
|
||||||
|
ASSERT(pCache->pSkipList != NULL);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// clear count
|
||||||
|
int i = 0;
|
||||||
|
SSkipListIterator* pIter = tSkipListCreateIter(pCache->pSkipList);
|
||||||
|
SArray* delNodeArray = taosArrayInit(0, sizeof(SSkipListNode*));
|
||||||
|
|
||||||
|
// free entry
|
||||||
|
while (tSkipListIterNext(pIter)) {
|
||||||
|
SSkipListNode* pNode = tSkipListIterGet(pIter);
|
||||||
|
ASSERT(pNode != NULL);
|
||||||
|
if (i++ >= count) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sDebug("push pNode:%p", pNode);
|
||||||
|
taosArrayPush(delNodeArray, &pNode);
|
||||||
|
++returnCnt;
|
||||||
|
SSyncRaftEntry* pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode);
|
||||||
|
syncEntryDestory(pEntry);
|
||||||
|
}
|
||||||
|
tSkipListDestroyIter(pIter);
|
||||||
|
|
||||||
|
// delete skiplist node
|
||||||
|
int32_t arraySize = taosArrayGetSize(delNodeArray);
|
||||||
|
for (int32_t i = 0; i < arraySize; ++i) {
|
||||||
|
SSkipListNode** ppNode = taosArrayGet(delNodeArray, i);
|
||||||
|
// sDebug("get pNode:%p", *ppNode);
|
||||||
|
tSkipListRemoveNode(pCache->pSkipList, *ppNode);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(delNodeArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
pCache->currentCount -= returnCnt;
|
||||||
|
taosThreadMutexUnlock(&(pCache->mutex));
|
||||||
|
return returnCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON* raftEntryCache2Json(SRaftEntryCache* pCache) {
|
||||||
|
char u64buf[128] = {0};
|
||||||
|
cJSON* pRoot = cJSON_CreateObject();
|
||||||
|
|
||||||
|
if (pCache != NULL) {
|
||||||
|
taosThreadMutexLock(&(pCache->mutex));
|
||||||
|
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%p", pCache->pSyncNode);
|
||||||
|
cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf);
|
||||||
|
cJSON_AddNumberToObject(pRoot, "currentCount", pCache->currentCount);
|
||||||
|
cJSON_AddNumberToObject(pRoot, "maxCount", pCache->maxCount);
|
||||||
|
cJSON* pEntries = cJSON_CreateArray();
|
||||||
|
cJSON_AddItemToObject(pRoot, "entries", pEntries);
|
||||||
|
|
||||||
|
SSkipListIterator* pIter = tSkipListCreateIter(pCache->pSkipList);
|
||||||
|
while (tSkipListIterNext(pIter)) {
|
||||||
|
SSkipListNode* pNode = tSkipListIterGet(pIter);
|
||||||
|
ASSERT(pNode != NULL);
|
||||||
|
SSyncRaftEntry* pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode);
|
||||||
|
cJSON_AddItemToArray(pEntries, syncEntry2Json(pEntry));
|
||||||
|
}
|
||||||
|
tSkipListDestroyIter(pIter);
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&(pCache->mutex));
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON* pJson = cJSON_CreateObject();
|
||||||
|
cJSON_AddItemToObject(pJson, "SRaftEntryCache", pRoot);
|
||||||
|
return pJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* raftEntryCache2Str(SRaftEntryCache* pObj) {
|
||||||
|
cJSON* pJson = raftEntryCache2Json(pObj);
|
||||||
|
char* serialized = cJSON_Print(pJson);
|
||||||
|
cJSON_Delete(pJson);
|
||||||
|
return serialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
void raftEntryCachePrint(SRaftEntryCache* pObj) {
|
||||||
|
char* serialized = raftEntryCache2Str(pObj);
|
||||||
|
printf("raftEntryCachePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
|
||||||
|
fflush(NULL);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void raftEntryCachePrint2(char* s, SRaftEntryCache* pObj) {
|
||||||
|
char* serialized = raftEntryCache2Str(pObj);
|
||||||
|
printf("raftEntryCachePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
|
||||||
|
fflush(NULL);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void raftEntryCacheLog(SRaftEntryCache* pObj) {
|
||||||
|
char* serialized = raftEntryCache2Str(pObj);
|
||||||
|
sTrace("raftEntryCacheLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void raftEntryCacheLog2(char* s, SRaftEntryCache* pObj) {
|
||||||
|
if (gRaftDetailLog) {
|
||||||
|
char* serialized = raftEntryCache2Str(pObj);
|
||||||
|
sTraceLong("raftEntryCacheLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -122,54 +122,45 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl) {
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
SSyncNode *pSyncNode = pObj->data;
|
SSyncNode *pSyncNode = pObj->data;
|
||||||
|
|
||||||
SArray *delIndexArray = taosArrayInit(0, sizeof(SyncIndex));
|
SArray *delIndexArray = taosArrayInit(0, sizeof(uint64_t));
|
||||||
ASSERT(delIndexArray != NULL);
|
ASSERT(delIndexArray != NULL);
|
||||||
|
|
||||||
while (pStub) {
|
while (pStub) {
|
||||||
size_t len;
|
size_t len;
|
||||||
void * key = taosHashGetKey(pStub, &len);
|
void * key = taosHashGetKey(pStub, &len);
|
||||||
SyncIndex *pIndex = (SyncIndex *)key;
|
uint64_t *pSeqNum = (uint64_t *)key;
|
||||||
|
|
||||||
int64_t nowMS = taosGetTimestampMs();
|
int64_t nowMS = taosGetTimestampMs();
|
||||||
if (nowMS - pStub->createTime > ttl) {
|
if (nowMS - pStub->createTime > ttl) {
|
||||||
taosArrayPush(delIndexArray, pIndex);
|
taosArrayPush(delIndexArray, pSeqNum);
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
SSyncRaftEntry *pEntry = NULL;
|
SFsmCbMeta cbMeta = {0};
|
||||||
int32_t code = 0;
|
cbMeta.index = SYNC_INDEX_INVALID;
|
||||||
if (pSyncNode->pLogStore != NULL) {
|
cbMeta.lastConfigIndex = SYNC_INDEX_INVALID;
|
||||||
code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, *pIndex, &pEntry);
|
cbMeta.isWeak = false;
|
||||||
if (code == 0 && pEntry != NULL) {
|
cbMeta.code = TSDB_CODE_SYN_TIMEOUT;
|
||||||
SFsmCbMeta cbMeta = {0};
|
cbMeta.state = pSyncNode->state;
|
||||||
cbMeta.index = pEntry->index;
|
cbMeta.seqNum = *pSeqNum;
|
||||||
cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(pSyncNode, cbMeta.index);
|
cbMeta.term = SYNC_TERM_INVALID;
|
||||||
cbMeta.isWeak = pEntry->isWeak;
|
cbMeta.currentTerm = pSyncNode->pRaftStore->currentTerm;
|
||||||
cbMeta.code = TSDB_CODE_SYN_TIMEOUT;
|
cbMeta.flag = 0;
|
||||||
cbMeta.state = pSyncNode->state;
|
|
||||||
cbMeta.seqNum = pEntry->seqNum;
|
|
||||||
cbMeta.term = pEntry->term;
|
|
||||||
cbMeta.currentTerm = pSyncNode->pRaftStore->currentTerm;
|
|
||||||
cbMeta.flag = 0;
|
|
||||||
|
|
||||||
SRpcMsg rpcMsg = pStub->rpcMsg;
|
pStub->rpcMsg.pCont = NULL;
|
||||||
rpcMsg.pCont = rpcMallocCont(pEntry->dataLen);
|
pStub->rpcMsg.contLen = 0;
|
||||||
memcpy(rpcMsg.pCont, pEntry->data, pEntry->dataLen);
|
pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &(pStub->rpcMsg), cbMeta);
|
||||||
pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &rpcMsg, cbMeta);
|
|
||||||
|
|
||||||
syncEntryDestory(pEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pStub = (SRespStub *)taosHashIterate(pObj->pRespHash, pStub);
|
pStub = (SRespStub *)taosHashIterate(pObj->pRespHash, pStub);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t arraySize = taosArrayGetSize(delIndexArray);
|
int32_t arraySize = taosArrayGetSize(delIndexArray);
|
||||||
sDebug("vgId:%d, resp clean by ttl, cnt:%d, array-size:%d", pSyncNode->vgId, cnt, arraySize);
|
sDebug("vgId:%d, resp mgr clean by ttl, cnt:%d, array-size:%d", pSyncNode->vgId, cnt, arraySize);
|
||||||
|
|
||||||
for (int32_t i = 0; i < arraySize; ++i) {
|
for (int32_t i = 0; i < arraySize; ++i) {
|
||||||
SyncIndex *pIndex = taosArrayGet(delIndexArray, i);
|
uint64_t *pSeqNum = taosArrayGet(delIndexArray, i);
|
||||||
taosHashRemove(pObj->pRespHash, pIndex, sizeof(SyncIndex));
|
taosHashRemove(pObj->pRespHash, pSeqNum, sizeof(uint64_t));
|
||||||
|
sDebug("vgId:%d, resp mgr clean by ttl, seq:%d", pSyncNode->vgId, *pSeqNum);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(delIndexArray);
|
taosArrayDestroy(delIndexArray);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,14 @@
|
||||||
#include "syncTimeout.h"
|
#include "syncTimeout.h"
|
||||||
#include "syncElection.h"
|
#include "syncElection.h"
|
||||||
#include "syncReplication.h"
|
#include "syncReplication.h"
|
||||||
|
#include "syncRespMgr.h"
|
||||||
|
|
||||||
int32_t syncNodeTimerRoutine(SSyncNode* ths) {
|
int32_t syncNodeTimerRoutine(SSyncNode* ths) {
|
||||||
syncNodeEventLog(ths, "timer routines ... ");
|
syncNodeEventLog(ths, "timer routines ... ");
|
||||||
|
|
||||||
|
if (ths->vgId != 1) {
|
||||||
|
syncRespClean(ths->pSyncRespMgr);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ add_executable(syncIndexMgrTest "")
|
||||||
add_executable(syncLogStoreTest "")
|
add_executable(syncLogStoreTest "")
|
||||||
add_executable(syncEntryTest "")
|
add_executable(syncEntryTest "")
|
||||||
add_executable(syncEntryCacheTest "")
|
add_executable(syncEntryCacheTest "")
|
||||||
|
add_executable(syncHashCacheTest "")
|
||||||
add_executable(syncRequestVoteTest "")
|
add_executable(syncRequestVoteTest "")
|
||||||
add_executable(syncRequestVoteReplyTest "")
|
add_executable(syncRequestVoteReplyTest "")
|
||||||
add_executable(syncAppendEntriesTest "")
|
add_executable(syncAppendEntriesTest "")
|
||||||
|
@ -137,6 +138,10 @@ target_sources(syncEntryCacheTest
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"syncEntryCacheTest.cpp"
|
"syncEntryCacheTest.cpp"
|
||||||
)
|
)
|
||||||
|
target_sources(syncHashCacheTest
|
||||||
|
PRIVATE
|
||||||
|
"syncHashCacheTest.cpp"
|
||||||
|
)
|
||||||
target_sources(syncRequestVoteTest
|
target_sources(syncRequestVoteTest
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"syncRequestVoteTest.cpp"
|
"syncRequestVoteTest.cpp"
|
||||||
|
@ -387,6 +392,11 @@ target_include_directories(syncEntryCacheTest
|
||||||
"${TD_SOURCE_DIR}/include/libs/sync"
|
"${TD_SOURCE_DIR}/include/libs/sync"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
)
|
)
|
||||||
|
target_include_directories(syncHashCacheTest
|
||||||
|
PUBLIC
|
||||||
|
"${TD_SOURCE_DIR}/include/libs/sync"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
|
)
|
||||||
target_include_directories(syncRequestVoteTest
|
target_include_directories(syncRequestVoteTest
|
||||||
PUBLIC
|
PUBLIC
|
||||||
"${TD_SOURCE_DIR}/include/libs/sync"
|
"${TD_SOURCE_DIR}/include/libs/sync"
|
||||||
|
@ -654,6 +664,10 @@ target_link_libraries(syncEntryCacheTest
|
||||||
sync
|
sync
|
||||||
gtest_main
|
gtest_main
|
||||||
)
|
)
|
||||||
|
target_link_libraries(syncHashCacheTest
|
||||||
|
sync
|
||||||
|
gtest_main
|
||||||
|
)
|
||||||
target_link_libraries(syncRequestVoteTest
|
target_link_libraries(syncRequestVoteTest
|
||||||
sync
|
sync
|
||||||
gtest_main
|
gtest_main
|
||||||
|
|
|
@ -43,222 +43,82 @@ SRaftEntryCache* createCache(int maxCount) {
|
||||||
SSyncNode* pSyncNode = createFakeNode();
|
SSyncNode* pSyncNode = createFakeNode();
|
||||||
ASSERT(pSyncNode != NULL);
|
ASSERT(pSyncNode != NULL);
|
||||||
|
|
||||||
SRaftEntryCache* pCache = raftCacheCreate(pSyncNode, maxCount);
|
SRaftEntryCache* pCache = raftEntryCacheCreate(pSyncNode, maxCount);
|
||||||
ASSERT(pCache != NULL);
|
ASSERT(pCache != NULL);
|
||||||
|
|
||||||
return pCache;
|
return pCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void test1() {
|
void test1() {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SRaftEntryCache* pCache = createCache(5);
|
SRaftEntryCache* pCache = createCache(5);
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
SSyncRaftEntry* pEntry = createEntry(i);
|
SSyncRaftEntry* pEntry = createEntry(i);
|
||||||
code = raftCachePutEntry(pCache, pEntry);
|
code = raftEntryCachePutEntry(pCache, pEntry);
|
||||||
ASSERT(code == 1);
|
sTrace("put entry code:%d, pEntry:%p", code, pEntry);
|
||||||
syncEntryDestory(pEntry);
|
|
||||||
}
|
}
|
||||||
raftCacheLog2((char*)"==test1 write 5 entries==", pCache);
|
raftEntryCacheLog2((char*)"==test1 write 5 entries==", pCache);
|
||||||
|
|
||||||
SyncIndex index;
|
raftEntryCacheClear(pCache, 3);
|
||||||
index = 1;
|
raftEntryCacheLog2((char*)"==test1 evict 3 entries==", pCache);
|
||||||
code = raftCacheDelEntry(pCache, index);
|
|
||||||
ASSERT(code == 0);
|
|
||||||
index = 3;
|
|
||||||
code = raftCacheDelEntry(pCache, index);
|
|
||||||
ASSERT(code == 0);
|
|
||||||
raftCacheLog2((char*)"==test1 delete 1,3==", pCache);
|
|
||||||
|
|
||||||
code = raftCacheClear(pCache);
|
raftEntryCacheClear(pCache, -1);
|
||||||
ASSERT(code == 0);
|
raftEntryCacheLog2((char*)"==test1 evict -1(all) entries==", pCache);
|
||||||
raftCacheLog2((char*)"==clear all==", pCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test2() {
|
void test2() {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SRaftEntryCache* pCache = createCache(5);
|
SRaftEntryCache* pCache = createCache(5);
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
SSyncRaftEntry* pEntry = createEntry(i);
|
SSyncRaftEntry* pEntry = createEntry(i);
|
||||||
code = raftCachePutEntry(pCache, pEntry);
|
code = raftEntryCachePutEntry(pCache, pEntry);
|
||||||
ASSERT(code == 1);
|
sTrace("put entry code:%d, pEntry:%p", code, pEntry);
|
||||||
syncEntryDestory(pEntry);
|
|
||||||
}
|
}
|
||||||
raftCacheLog2((char*)"==test2 write 5 entries==", pCache);
|
raftEntryCacheLog2((char*)"==test1 write 5 entries==", pCache);
|
||||||
|
|
||||||
SyncIndex index;
|
SyncIndex index = 2;
|
||||||
index = 1;
|
SSyncRaftEntry* pEntry = NULL;
|
||||||
SSyncRaftEntry* pEntry;
|
|
||||||
code = raftCacheGetEntry(pCache, index, &pEntry);
|
|
||||||
ASSERT(code == 0);
|
|
||||||
syncEntryDestory(pEntry);
|
|
||||||
syncEntryLog2((char*)"==test2 get entry 1==", pEntry);
|
|
||||||
|
|
||||||
index = 2;
|
code = raftEntryCacheGetEntryP(pCache, index, &pEntry);
|
||||||
code = raftCacheGetEntryP(pCache, index, &pEntry);
|
ASSERT(code == 1 && index == pEntry->index);
|
||||||
ASSERT(code == 0);
|
sTrace("get entry:%p for %ld", pEntry, index);
|
||||||
syncEntryLog2((char*)"==test2 get entry pointer 2==", pEntry);
|
syncEntryLog2((char*)"==test2 get entry pointer 2==", pEntry);
|
||||||
|
|
||||||
|
code = raftEntryCacheGetEntry(pCache, index, &pEntry);
|
||||||
|
ASSERT(code == 1 && index == pEntry->index);
|
||||||
|
sTrace("get entry:%p for %ld", pEntry, index);
|
||||||
|
syncEntryLog2((char*)"==test2 get entry 2==", pEntry);
|
||||||
|
syncEntryDestory(pEntry);
|
||||||
|
|
||||||
// not found
|
// not found
|
||||||
index = 8;
|
index = 8;
|
||||||
code = raftCacheGetEntry(pCache, index, &pEntry);
|
code = raftEntryCacheGetEntry(pCache, index, &pEntry);
|
||||||
ASSERT(code == -1 && terrno == TSDB_CODE_WAL_LOG_NOT_EXIST);
|
ASSERT(code == 0);
|
||||||
|
sTrace("get entry:%p for %ld", pEntry, index);
|
||||||
sTrace("==test2 get entry 8 not found==");
|
sTrace("==test2 get entry 8 not found==");
|
||||||
|
|
||||||
// not found
|
// not found
|
||||||
index = 9;
|
index = 9;
|
||||||
code = raftCacheGetEntryP(pCache, index, &pEntry);
|
code = raftEntryCacheGetEntry(pCache, index, &pEntry);
|
||||||
ASSERT(code == -1 && terrno == TSDB_CODE_WAL_LOG_NOT_EXIST);
|
ASSERT(code == 0);
|
||||||
sTrace("==test2 get entry pointer 9 not found==");
|
sTrace("get entry:%p for %ld", pEntry, index);
|
||||||
|
sTrace("==test2 get entry 9 not found==");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test3() {
|
void test3() {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SRaftEntryCache* pCache = createCache(5);
|
SRaftEntryCache* pCache = createCache(20);
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i <= 4; ++i) {
|
||||||
SSyncRaftEntry* pEntry = createEntry(i);
|
SSyncRaftEntry* pEntry = createEntry(i);
|
||||||
code = raftCachePutEntry(pCache, pEntry);
|
code = raftEntryCachePutEntry(pCache, pEntry);
|
||||||
ASSERT(code == 1);
|
sTrace("put entry code:%d, pEntry:%p", code, pEntry);
|
||||||
syncEntryDestory(pEntry);
|
|
||||||
}
|
}
|
||||||
for (int i = 6; i < 10; ++i) {
|
|
||||||
SSyncRaftEntry* pEntry = createEntry(i);
|
|
||||||
code = raftCachePutEntry(pCache, pEntry);
|
|
||||||
ASSERT(code == 0);
|
|
||||||
syncEntryDestory(pEntry);
|
|
||||||
}
|
|
||||||
raftCacheLog2((char*)"==test3 write 10 entries, max count is 5==", pCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test4() {
|
|
||||||
int32_t code = 0;
|
|
||||||
SRaftEntryCache* pCache = createCache(5);
|
|
||||||
for (int i = 0; i < 5; ++i) {
|
|
||||||
SSyncRaftEntry* pEntry = createEntry(i);
|
|
||||||
code = raftCachePutEntry(pCache, pEntry);
|
|
||||||
ASSERT(code == 1);
|
|
||||||
syncEntryDestory(pEntry);
|
|
||||||
}
|
|
||||||
raftCacheLog2((char*)"==test4 write 5 entries==", pCache);
|
|
||||||
|
|
||||||
SyncIndex index;
|
|
||||||
index = 3;
|
|
||||||
SSyncRaftEntry* pEntry;
|
|
||||||
code = raftCacheGetAndDel(pCache, index, &pEntry);
|
|
||||||
ASSERT(code == 0);
|
|
||||||
syncEntryLog2((char*)"==test4 get-and-del entry 3==", pEntry);
|
|
||||||
raftCacheLog2((char*)"==test4 after get-and-del entry 3==", pCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char* keyFn(const void* pData) {
|
|
||||||
SSyncRaftEntry* pEntry = (SSyncRaftEntry*)pData;
|
|
||||||
return (char*)(&(pEntry->index));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int cmpFn(const void* p1, const void* p2) { return memcmp(p1, p2, sizeof(SyncIndex)); }
|
|
||||||
|
|
||||||
void printSkipList(SSkipList* pSkipList) {
|
|
||||||
ASSERT(pSkipList != NULL);
|
|
||||||
|
|
||||||
SSkipListIterator* pIter = tSkipListCreateIter(pSkipList);
|
|
||||||
while (tSkipListIterNext(pIter)) {
|
|
||||||
SSkipListNode* pNode = tSkipListIterGet(pIter);
|
|
||||||
ASSERT(pNode != NULL);
|
|
||||||
SSyncRaftEntry* pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode);
|
|
||||||
syncEntryPrint2((char*)"", pEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void delSkipListFirst(SSkipList* pSkipList, int n) {
|
|
||||||
ASSERT(pSkipList != NULL);
|
|
||||||
|
|
||||||
sTrace("delete first %d -------------", n);
|
|
||||||
SSkipListIterator* pIter = tSkipListCreateIter(pSkipList);
|
|
||||||
for (int i = 0; i < n; ++i) {
|
|
||||||
tSkipListIterNext(pIter);
|
|
||||||
SSkipListNode* pNode = tSkipListIterGet(pIter);
|
|
||||||
tSkipListRemoveNode(pSkipList, pNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SSyncRaftEntry* getLogEntry2(SSkipList* pSkipList, SyncIndex index) {
|
|
||||||
SyncIndex index2 = index;
|
|
||||||
SSyncRaftEntry *pEntry = NULL;
|
|
||||||
int arraySize = 0;
|
|
||||||
|
|
||||||
SArray* entryPArray = tSkipListGet(pSkipList, (char*)(&index2));
|
|
||||||
arraySize = taosArrayGetSize(entryPArray);
|
|
||||||
if (arraySize > 0) {
|
|
||||||
SSkipListNode** ppNode = (SSkipListNode**)taosArrayGet(entryPArray, 0);
|
|
||||||
ASSERT(*ppNode != NULL);
|
|
||||||
pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(*ppNode);
|
|
||||||
}
|
|
||||||
taosArrayDestroy(entryPArray);
|
|
||||||
|
|
||||||
sTrace("get index2: %ld, arraySize:%d -------------", index, arraySize);
|
|
||||||
syncEntryLog2((char*)"getLogEntry2", pEntry);
|
|
||||||
return pEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SSyncRaftEntry* getLogEntry(SSkipList* pSkipList, SyncIndex index) {
|
|
||||||
sTrace("get index: %ld -------------", index);
|
|
||||||
SyncIndex index2 = index;
|
|
||||||
SSyncRaftEntry *pEntry = NULL;
|
|
||||||
SSkipListIterator* pIter = tSkipListCreateIterFromVal(pSkipList, (const char *)&index2, TSDB_DATA_TYPE_BINARY, TSDB_ORDER_ASC);
|
|
||||||
if (tSkipListIterNext(pIter)) {
|
|
||||||
SSkipListNode* pNode = tSkipListIterGet(pIter);
|
|
||||||
ASSERT(pNode != NULL);
|
|
||||||
pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
syncEntryLog2((char*)"getLogEntry", pEntry);
|
|
||||||
return pEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
void test5() {
|
|
||||||
SSkipList* pSkipList =
|
|
||||||
tSkipListCreate(MAX_SKIP_LIST_LEVEL, TSDB_DATA_TYPE_BINARY, sizeof(SyncIndex), cmpFn, SL_ALLOW_DUP_KEY, keyFn);
|
|
||||||
ASSERT(pSkipList != NULL);
|
|
||||||
|
|
||||||
sTrace("insert 9 - 5");
|
|
||||||
for (int i = 9; i >= 5; --i) {
|
for (int i = 9; i >= 5; --i) {
|
||||||
SSyncRaftEntry* pEntry = createEntry(i);
|
SSyncRaftEntry* pEntry = createEntry(i);
|
||||||
SSkipListNode* pSkipListNode = tSkipListPut(pSkipList, pEntry);
|
code = raftEntryCachePutEntry(pCache, pEntry);
|
||||||
|
sTrace("put entry code:%d, pEntry:%p", code, pEntry);
|
||||||
}
|
}
|
||||||
|
raftEntryCacheLog2((char*)"==test3 write 10 entries==", pCache);
|
||||||
sTrace("insert 0 - 4");
|
|
||||||
for (int i = 0; i <= 4; ++i) {
|
|
||||||
SSyncRaftEntry* pEntry = createEntry(i);
|
|
||||||
SSkipListNode* pSkipListNode = tSkipListPut(pSkipList, pEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
sTrace("insert 7 7 7 7 7");
|
|
||||||
for (int i = 0; i <= 4; ++i) {
|
|
||||||
SSyncRaftEntry* pEntry = createEntry(7);
|
|
||||||
SSkipListNode* pSkipListNode = tSkipListPut(pSkipList, pEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
sTrace("print: -------------");
|
|
||||||
printSkipList(pSkipList);
|
|
||||||
|
|
||||||
delSkipListFirst(pSkipList, 3);
|
|
||||||
|
|
||||||
sTrace("print: -------------");
|
|
||||||
printSkipList(pSkipList);
|
|
||||||
|
|
||||||
getLogEntry(pSkipList, 2);
|
|
||||||
getLogEntry(pSkipList, 5);
|
|
||||||
getLogEntry(pSkipList, 7);
|
|
||||||
getLogEntry(pSkipList, 7);
|
|
||||||
|
|
||||||
getLogEntry2(pSkipList, 2);
|
|
||||||
getLogEntry2(pSkipList, 5);
|
|
||||||
getLogEntry2(pSkipList, 7);
|
|
||||||
getLogEntry2(pSkipList, 7);
|
|
||||||
|
|
||||||
|
|
||||||
tSkipListDestroy(pSkipList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
@ -266,14 +126,9 @@ int main(int argc, char** argv) {
|
||||||
tsAsyncLog = 0;
|
tsAsyncLog = 0;
|
||||||
sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE + DEBUG_DEBUG;
|
sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE + DEBUG_DEBUG;
|
||||||
|
|
||||||
/*
|
test1();
|
||||||
test1();
|
test2();
|
||||||
test2();
|
test3();
|
||||||
test3();
|
|
||||||
test4();
|
|
||||||
*/
|
|
||||||
|
|
||||||
test5();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,277 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "syncEnv.h"
|
||||||
|
#include "syncIO.h"
|
||||||
|
#include "syncInt.h"
|
||||||
|
#include "syncRaftLog.h"
|
||||||
|
#include "syncRaftStore.h"
|
||||||
|
#include "syncUtil.h"
|
||||||
|
#include "tskiplist.h"
|
||||||
|
|
||||||
|
void logTest() {
|
||||||
|
sTrace("--- sync log test: trace");
|
||||||
|
sDebug("--- sync log test: debug");
|
||||||
|
sInfo("--- sync log test: info");
|
||||||
|
sWarn("--- sync log test: warn");
|
||||||
|
sError("--- sync log test: error");
|
||||||
|
sFatal("--- sync log test: fatal");
|
||||||
|
}
|
||||||
|
|
||||||
|
SSyncRaftEntry* createEntry(int i) {
|
||||||
|
int32_t dataLen = 20;
|
||||||
|
SSyncRaftEntry* pEntry = syncEntryBuild(dataLen);
|
||||||
|
assert(pEntry != NULL);
|
||||||
|
pEntry->msgType = 88;
|
||||||
|
pEntry->originalRpcType = 99;
|
||||||
|
pEntry->seqNum = 3;
|
||||||
|
pEntry->isWeak = true;
|
||||||
|
pEntry->term = 100 + i;
|
||||||
|
pEntry->index = i;
|
||||||
|
snprintf(pEntry->data, dataLen, "value%d", i);
|
||||||
|
|
||||||
|
return pEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSyncNode* createFakeNode() {
|
||||||
|
SSyncNode* pSyncNode = (SSyncNode*)taosMemoryMalloc(sizeof(SSyncNode));
|
||||||
|
ASSERT(pSyncNode != NULL);
|
||||||
|
memset(pSyncNode, 0, sizeof(SSyncNode));
|
||||||
|
|
||||||
|
return pSyncNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRaftEntryHashCache* createCache(int maxCount) {
|
||||||
|
SSyncNode* pSyncNode = createFakeNode();
|
||||||
|
ASSERT(pSyncNode != NULL);
|
||||||
|
|
||||||
|
SRaftEntryHashCache* pCache = raftCacheCreate(pSyncNode, maxCount);
|
||||||
|
ASSERT(pCache != NULL);
|
||||||
|
|
||||||
|
return pCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test1() {
|
||||||
|
int32_t code = 0;
|
||||||
|
SRaftEntryHashCache* pCache = createCache(5);
|
||||||
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
SSyncRaftEntry* pEntry = createEntry(i);
|
||||||
|
code = raftCachePutEntry(pCache, pEntry);
|
||||||
|
ASSERT(code == 1);
|
||||||
|
syncEntryDestory(pEntry);
|
||||||
|
}
|
||||||
|
raftCacheLog2((char*)"==test1 write 5 entries==", pCache);
|
||||||
|
|
||||||
|
SyncIndex index;
|
||||||
|
index = 1;
|
||||||
|
code = raftCacheDelEntry(pCache, index);
|
||||||
|
ASSERT(code == 0);
|
||||||
|
index = 3;
|
||||||
|
code = raftCacheDelEntry(pCache, index);
|
||||||
|
ASSERT(code == 0);
|
||||||
|
raftCacheLog2((char*)"==test1 delete 1,3==", pCache);
|
||||||
|
|
||||||
|
code = raftCacheClear(pCache);
|
||||||
|
ASSERT(code == 0);
|
||||||
|
raftCacheLog2((char*)"==clear all==", pCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test2() {
|
||||||
|
int32_t code = 0;
|
||||||
|
SRaftEntryHashCache* pCache = createCache(5);
|
||||||
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
SSyncRaftEntry* pEntry = createEntry(i);
|
||||||
|
code = raftCachePutEntry(pCache, pEntry);
|
||||||
|
ASSERT(code == 1);
|
||||||
|
syncEntryDestory(pEntry);
|
||||||
|
}
|
||||||
|
raftCacheLog2((char*)"==test2 write 5 entries==", pCache);
|
||||||
|
|
||||||
|
SyncIndex index;
|
||||||
|
index = 1;
|
||||||
|
SSyncRaftEntry* pEntry;
|
||||||
|
code = raftCacheGetEntry(pCache, index, &pEntry);
|
||||||
|
ASSERT(code == 0);
|
||||||
|
syncEntryDestory(pEntry);
|
||||||
|
syncEntryLog2((char*)"==test2 get entry 1==", pEntry);
|
||||||
|
|
||||||
|
index = 2;
|
||||||
|
code = raftCacheGetEntryP(pCache, index, &pEntry);
|
||||||
|
ASSERT(code == 0);
|
||||||
|
syncEntryLog2((char*)"==test2 get entry pointer 2==", pEntry);
|
||||||
|
|
||||||
|
// not found
|
||||||
|
index = 8;
|
||||||
|
code = raftCacheGetEntry(pCache, index, &pEntry);
|
||||||
|
ASSERT(code == -1 && terrno == TSDB_CODE_WAL_LOG_NOT_EXIST);
|
||||||
|
sTrace("==test2 get entry 8 not found==");
|
||||||
|
|
||||||
|
// not found
|
||||||
|
index = 9;
|
||||||
|
code = raftCacheGetEntryP(pCache, index, &pEntry);
|
||||||
|
ASSERT(code == -1 && terrno == TSDB_CODE_WAL_LOG_NOT_EXIST);
|
||||||
|
sTrace("==test2 get entry pointer 9 not found==");
|
||||||
|
}
|
||||||
|
|
||||||
|
void test3() {
|
||||||
|
int32_t code = 0;
|
||||||
|
SRaftEntryHashCache* pCache = createCache(5);
|
||||||
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
SSyncRaftEntry* pEntry = createEntry(i);
|
||||||
|
code = raftCachePutEntry(pCache, pEntry);
|
||||||
|
ASSERT(code == 1);
|
||||||
|
syncEntryDestory(pEntry);
|
||||||
|
}
|
||||||
|
for (int i = 6; i < 10; ++i) {
|
||||||
|
SSyncRaftEntry* pEntry = createEntry(i);
|
||||||
|
code = raftCachePutEntry(pCache, pEntry);
|
||||||
|
ASSERT(code == 0);
|
||||||
|
syncEntryDestory(pEntry);
|
||||||
|
}
|
||||||
|
raftCacheLog2((char*)"==test3 write 10 entries, max count is 5==", pCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test4() {
|
||||||
|
int32_t code = 0;
|
||||||
|
SRaftEntryHashCache* pCache = createCache(5);
|
||||||
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
SSyncRaftEntry* pEntry = createEntry(i);
|
||||||
|
code = raftCachePutEntry(pCache, pEntry);
|
||||||
|
ASSERT(code == 1);
|
||||||
|
syncEntryDestory(pEntry);
|
||||||
|
}
|
||||||
|
raftCacheLog2((char*)"==test4 write 5 entries==", pCache);
|
||||||
|
|
||||||
|
SyncIndex index;
|
||||||
|
index = 3;
|
||||||
|
SSyncRaftEntry* pEntry;
|
||||||
|
code = raftCacheGetAndDel(pCache, index, &pEntry);
|
||||||
|
ASSERT(code == 0);
|
||||||
|
syncEntryLog2((char*)"==test4 get-and-del entry 3==", pEntry);
|
||||||
|
raftCacheLog2((char*)"==test4 after get-and-del entry 3==", pCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char* keyFn(const void* pData) {
|
||||||
|
SSyncRaftEntry* pEntry = (SSyncRaftEntry*)pData;
|
||||||
|
return (char*)(&(pEntry->index));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cmpFn(const void* p1, const void* p2) { return memcmp(p1, p2, sizeof(SyncIndex)); }
|
||||||
|
|
||||||
|
void printSkipList(SSkipList* pSkipList) {
|
||||||
|
ASSERT(pSkipList != NULL);
|
||||||
|
|
||||||
|
SSkipListIterator* pIter = tSkipListCreateIter(pSkipList);
|
||||||
|
while (tSkipListIterNext(pIter)) {
|
||||||
|
SSkipListNode* pNode = tSkipListIterGet(pIter);
|
||||||
|
ASSERT(pNode != NULL);
|
||||||
|
SSyncRaftEntry* pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode);
|
||||||
|
syncEntryPrint2((char*)"", pEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void delSkipListFirst(SSkipList* pSkipList, int n) {
|
||||||
|
ASSERT(pSkipList != NULL);
|
||||||
|
|
||||||
|
sTrace("delete first %d -------------", n);
|
||||||
|
SSkipListIterator* pIter = tSkipListCreateIter(pSkipList);
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
tSkipListIterNext(pIter);
|
||||||
|
SSkipListNode* pNode = tSkipListIterGet(pIter);
|
||||||
|
tSkipListRemoveNode(pSkipList, pNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SSyncRaftEntry* getLogEntry2(SSkipList* pSkipList, SyncIndex index) {
|
||||||
|
SyncIndex index2 = index;
|
||||||
|
SSyncRaftEntry* pEntry = NULL;
|
||||||
|
int arraySize = 0;
|
||||||
|
|
||||||
|
SArray* entryPArray = tSkipListGet(pSkipList, (char*)(&index2));
|
||||||
|
arraySize = taosArrayGetSize(entryPArray);
|
||||||
|
if (arraySize > 0) {
|
||||||
|
SSkipListNode** ppNode = (SSkipListNode**)taosArrayGet(entryPArray, 0);
|
||||||
|
ASSERT(*ppNode != NULL);
|
||||||
|
pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(*ppNode);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(entryPArray);
|
||||||
|
|
||||||
|
sTrace("get index2: %ld, arraySize:%d -------------", index, arraySize);
|
||||||
|
syncEntryLog2((char*)"getLogEntry2", pEntry);
|
||||||
|
return pEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSyncRaftEntry* getLogEntry(SSkipList* pSkipList, SyncIndex index) {
|
||||||
|
sTrace("get index: %ld -------------", index);
|
||||||
|
SyncIndex index2 = index;
|
||||||
|
SSyncRaftEntry* pEntry = NULL;
|
||||||
|
SSkipListIterator* pIter =
|
||||||
|
tSkipListCreateIterFromVal(pSkipList, (const char*)&index2, TSDB_DATA_TYPE_BINARY, TSDB_ORDER_ASC);
|
||||||
|
if (tSkipListIterNext(pIter)) {
|
||||||
|
SSkipListNode* pNode = tSkipListIterGet(pIter);
|
||||||
|
ASSERT(pNode != NULL);
|
||||||
|
pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
syncEntryLog2((char*)"getLogEntry", pEntry);
|
||||||
|
return pEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test5() {
|
||||||
|
SSkipList* pSkipList =
|
||||||
|
tSkipListCreate(MAX_SKIP_LIST_LEVEL, TSDB_DATA_TYPE_BINARY, sizeof(SyncIndex), cmpFn, SL_ALLOW_DUP_KEY, keyFn);
|
||||||
|
ASSERT(pSkipList != NULL);
|
||||||
|
|
||||||
|
sTrace("insert 9 - 5");
|
||||||
|
for (int i = 9; i >= 5; --i) {
|
||||||
|
SSyncRaftEntry* pEntry = createEntry(i);
|
||||||
|
SSkipListNode* pSkipListNode = tSkipListPut(pSkipList, pEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
sTrace("insert 0 - 4");
|
||||||
|
for (int i = 0; i <= 4; ++i) {
|
||||||
|
SSyncRaftEntry* pEntry = createEntry(i);
|
||||||
|
SSkipListNode* pSkipListNode = tSkipListPut(pSkipList, pEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
sTrace("insert 7 7 7 7 7");
|
||||||
|
for (int i = 0; i <= 4; ++i) {
|
||||||
|
SSyncRaftEntry* pEntry = createEntry(7);
|
||||||
|
SSkipListNode* pSkipListNode = tSkipListPut(pSkipList, pEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
sTrace("print: -------------");
|
||||||
|
printSkipList(pSkipList);
|
||||||
|
|
||||||
|
delSkipListFirst(pSkipList, 3);
|
||||||
|
|
||||||
|
sTrace("print: -------------");
|
||||||
|
printSkipList(pSkipList);
|
||||||
|
|
||||||
|
getLogEntry(pSkipList, 2);
|
||||||
|
getLogEntry(pSkipList, 5);
|
||||||
|
getLogEntry(pSkipList, 7);
|
||||||
|
getLogEntry(pSkipList, 7);
|
||||||
|
|
||||||
|
getLogEntry2(pSkipList, 2);
|
||||||
|
getLogEntry2(pSkipList, 5);
|
||||||
|
getLogEntry2(pSkipList, 7);
|
||||||
|
getLogEntry2(pSkipList, 7);
|
||||||
|
|
||||||
|
tSkipListDestroy(pSkipList);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
gRaftDetailLog = true;
|
||||||
|
tsAsyncLog = 0;
|
||||||
|
sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE + DEBUG_DEBUG;
|
||||||
|
|
||||||
|
/*
|
||||||
|
test1();
|
||||||
|
test2();
|
||||||
|
test3();
|
||||||
|
test4();
|
||||||
|
*/
|
||||||
|
|
||||||
|
test5();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -561,6 +561,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_COL_JSON, "Only tag can be jso
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_VALUE_TOO_LONG, "Value too long for column/tag")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_VALUE_TOO_LONG, "Value too long for column/tag")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_DELETE_WHERE, "The DELETE statement must have a definite time window range")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_DELETE_WHERE, "The DELETE statement must have a definite time window range")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG, "The REDISTRIBUTE VGROUP statement only support 1 to 3 dnodes")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG, "The REDISTRIBUTE VGROUP statement only support 1 to 3 dnodes")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_SELECTED_EXPR, "Invalid SELECTed expression")
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PLAN_INTERNAL_ERROR, "Planner internal error")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PLAN_INTERNAL_ERROR, "Planner internal error")
|
||||||
|
|
|
@ -431,7 +431,7 @@ static int32_t taosDecRefCount(int32_t rsetId, int64_t rid, int32_t remove) {
|
||||||
}
|
}
|
||||||
released = 1;
|
released = 1;
|
||||||
} else {
|
} else {
|
||||||
uTrace("rsetId:%d p:%p rid:%" PRId64 " is released", rsetId, pNode->p, rid);
|
uTrace("rsetId:%d p:%p rid:%" PRId64 " is released, remain count %d", rsetId, pNode->p, rid, pNode->count);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uTrace("rsetId:%d rid:%" PRId64 " is not there, failed to release/remove", rsetId, rid);
|
uTrace("rsetId:%d rid:%" PRId64 " is not there, failed to release/remove", rsetId, rid);
|
||||||
|
|
|
@ -129,7 +129,7 @@ void *taosProcessSchedQueue(void *scheduler) {
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((ret = tsem_wait(&pSched->fullSem)) != 0) {
|
if ((ret = tsem_wait(&pSched->fullSem)) != 0) {
|
||||||
uFatal("wait %s fullSem failed(%s)", pSched->label, strerror(errno));
|
uFatal("wait %s fullSem failed(%s)", pSched->label, strerror(errno));
|
||||||
exit(ret);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
if (pSched->stop) {
|
if (pSched->stop) {
|
||||||
break;
|
break;
|
||||||
|
@ -137,7 +137,7 @@ void *taosProcessSchedQueue(void *scheduler) {
|
||||||
|
|
||||||
if ((ret = taosThreadMutexLock(&pSched->queueMutex)) != 0) {
|
if ((ret = taosThreadMutexLock(&pSched->queueMutex)) != 0) {
|
||||||
uFatal("lock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
uFatal("lock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
||||||
exit(ret);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = pSched->queue[pSched->fullSlot];
|
msg = pSched->queue[pSched->fullSlot];
|
||||||
|
@ -146,12 +146,12 @@ void *taosProcessSchedQueue(void *scheduler) {
|
||||||
|
|
||||||
if ((ret = taosThreadMutexUnlock(&pSched->queueMutex)) != 0) {
|
if ((ret = taosThreadMutexUnlock(&pSched->queueMutex)) != 0) {
|
||||||
uFatal("unlock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
uFatal("unlock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
||||||
exit(ret);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = tsem_post(&pSched->emptySem)) != 0) {
|
if ((ret = tsem_post(&pSched->emptySem)) != 0) {
|
||||||
uFatal("post %s emptySem failed(%s)", pSched->label, strerror(errno));
|
uFatal("post %s emptySem failed(%s)", pSched->label, strerror(errno));
|
||||||
exit(ret);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.fp)
|
if (msg.fp)
|
||||||
|
@ -174,12 +174,12 @@ void taosScheduleTask(void *queueScheduler, SSchedMsg *pMsg) {
|
||||||
|
|
||||||
if ((ret = tsem_wait(&pSched->emptySem)) != 0) {
|
if ((ret = tsem_wait(&pSched->emptySem)) != 0) {
|
||||||
uFatal("wait %s emptySem failed(%s)", pSched->label, strerror(errno));
|
uFatal("wait %s emptySem failed(%s)", pSched->label, strerror(errno));
|
||||||
exit(ret);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = taosThreadMutexLock(&pSched->queueMutex)) != 0) {
|
if ((ret = taosThreadMutexLock(&pSched->queueMutex)) != 0) {
|
||||||
uFatal("lock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
uFatal("lock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
||||||
exit(ret);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pSched->queue[pSched->emptySlot] = *pMsg;
|
pSched->queue[pSched->emptySlot] = *pMsg;
|
||||||
|
@ -187,12 +187,12 @@ void taosScheduleTask(void *queueScheduler, SSchedMsg *pMsg) {
|
||||||
|
|
||||||
if ((ret = taosThreadMutexUnlock(&pSched->queueMutex)) != 0) {
|
if ((ret = taosThreadMutexUnlock(&pSched->queueMutex)) != 0) {
|
||||||
uFatal("unlock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
uFatal("unlock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
||||||
exit(ret);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = tsem_post(&pSched->fullSem)) != 0) {
|
if ((ret = tsem_post(&pSched->fullSem)) != 0) {
|
||||||
uFatal("post %s fullSem failed(%s)", pSched->label, strerror(errno));
|
uFatal("post %s fullSem failed(%s)", pSched->label, strerror(errno));
|
||||||
exit(ret);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,6 +200,8 @@ void taosCleanUpScheduler(void *param) {
|
||||||
SSchedQueue *pSched = (SSchedQueue *)param;
|
SSchedQueue *pSched = (SSchedQueue *)param;
|
||||||
if (pSched == NULL) return;
|
if (pSched == NULL) return;
|
||||||
|
|
||||||
|
uDebug("start to cleanup %s schedQsueue", pSched->label);
|
||||||
|
|
||||||
pSched->stop = true;
|
pSched->stop = true;
|
||||||
for (int32_t i = 0; i < pSched->numOfThreads; ++i) {
|
for (int32_t i = 0; i < pSched->numOfThreads; ++i) {
|
||||||
if (taosCheckPthreadValid(pSched->qthread[i])) {
|
if (taosCheckPthreadValid(pSched->qthread[i])) {
|
||||||
|
|
|
@ -65,6 +65,7 @@ ulimit -c unlimited
|
||||||
|
|
||||||
$TIMEOUT_CMD $cmd
|
$TIMEOUT_CMD $cmd
|
||||||
RET=$?
|
RET=$?
|
||||||
|
echo "cmd exit code: $RET"
|
||||||
|
|
||||||
if [ $RET -ne 0 ]; then
|
if [ $RET -ne 0 ]; then
|
||||||
pwd
|
pwd
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TDTestCase:
|
||||||
tdSql.execute('create table ownsampling_ct1 using downsampling_stb tags(10, 10.1, "beijing", True);')
|
tdSql.execute('create table ownsampling_ct1 using downsampling_stb tags(10, 10.1, "beijing", True);')
|
||||||
tdSql.execute('create table if not exists scalar_stb (ts timestamp, c1 int, c2 double, c3 binary(20)) tags (t1 int);')
|
tdSql.execute('create table if not exists scalar_stb (ts timestamp, c1 int, c2 double, c3 binary(20)) tags (t1 int);')
|
||||||
tdSql.execute('create table scalar_ct1 using scalar_stb tags(10);')
|
tdSql.execute('create table scalar_ct1 using scalar_stb tags(10);')
|
||||||
tdSql.execute('create stream downsampling_stream into output_downsampling_stb as select _wstartts AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
|
tdSql.execute('create stream downsampling_stream into output_downsampling_stb as select _wstart AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
|
||||||
tdSql.execute('create stream scalar_stream into output_scalar_stb as select ts, abs(c1) a1 , abs(c2) a2 from scalar_stb;')
|
tdSql.execute('create stream scalar_stream into output_scalar_stb as select ts, abs(c1) a1 , abs(c2) a2 from scalar_stb;')
|
||||||
tdSql.execute('insert into scalar_ct1 values (1653471881952, 100, 100.1, "beijing");')
|
tdSql.execute('insert into scalar_ct1 values (1653471881952, 100, 100.1, "beijing");')
|
||||||
tdSql.execute('insert into scalar_ct1 values (1653471881952+1s, -50, -50.1, "tianjin");')
|
tdSql.execute('insert into scalar_ct1 values (1653471881952+1s, -50, -50.1, "tianjin");')
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue