Merge remote-tracking branch 'origin/3.0' into fix/dnode
This commit is contained in:
commit
f2caf11476
|
@ -79,10 +79,16 @@ ENDIF ()
|
|||
|
||||
option(
|
||||
BUILD_SANITIZER
|
||||
"If build addr2line"
|
||||
"If build sanitizer"
|
||||
OFF
|
||||
)
|
||||
|
||||
option(
|
||||
TDENGINE_3
|
||||
"TDengine 3.x"
|
||||
ON
|
||||
)
|
||||
|
||||
option(
|
||||
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 sum(k) from tu1 interval(10m)";*/
|
||||
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
|
||||
pRes = taos_query(
|
||||
pConn,
|
||||
"create stream stream1 trigger max_delay 10s into outstb as select _wstartts, sum(k) from st1 partition "
|
||||
"by tbname session(ts, 10s) ");
|
||||
pRes =
|
||||
taos_query(pConn,
|
||||
"create stream stream1 trigger max_delay 10s into outstb as select _wstart, sum(k) from st1 partition "
|
||||
"by tbname session(ts, 10s) ");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
|
|
|
@ -30,21 +30,35 @@ static void msg_process(TAOS_RES* msg) {
|
|||
if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) {
|
||||
tmq_raw_data *raw = tmq_get_raw_meta(msg);
|
||||
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) {
|
||||
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);
|
||||
printf("write raw data: %s\n", tmq_err2str(ret));
|
||||
free(raw);
|
||||
taos_close(pConn);
|
||||
}
|
||||
tmq_free_raw_meta(raw);
|
||||
char* result = tmq_get_json_meta(msg);
|
||||
if(result){
|
||||
printf("meta result: %s\n", result);
|
||||
free(result);
|
||||
}
|
||||
printf("meta:%p\n", raw);
|
||||
tmq_free_json_meta(result);
|
||||
return;
|
||||
}
|
||||
while (1) {
|
||||
|
@ -68,7 +82,7 @@ int32_t init_env() {
|
|||
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) {
|
||||
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
|
@ -82,15 +96,14 @@ int32_t init_env() {
|
|||
}
|
||||
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)");
|
||||
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, "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) {
|
||||
printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
|
@ -104,13 +117,20 @@ int32_t init_env() {
|
|||
}
|
||||
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) {
|
||||
printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
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')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes));
|
||||
|
@ -118,7 +138,7 @@ int32_t init_env() {
|
|||
}
|
||||
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) {
|
||||
printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
|
@ -202,6 +222,13 @@ int32_t init_env() {
|
|||
}
|
||||
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");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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_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 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_db_name(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_ALTER_TABLE \
|
||||
|| x == TDMT_VND_DROP_TABLE \
|
||||
|| x == TDMT_VND_DROP_TTL_TABLE \
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
|
@ -162,7 +161,6 @@ typedef struct SQueryTableDataCond {
|
|||
int64_t endVersion;
|
||||
} SQueryTableDataCond;
|
||||
|
||||
void* blockDataDestroy(SSDataBlock* pBlock);
|
||||
int32_t tEncodeDataBlock(void** buf, const 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 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
|
||||
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 copyDataBlock(SSDataBlock* dst, const SSDataBlock* src);
|
||||
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData);
|
||||
|
||||
SSDataBlock* createDataBlock();
|
||||
void* blockDataDestroy(SSDataBlock* pBlock);
|
||||
void blockDataFreeRes(SSDataBlock* pBlock);
|
||||
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData);
|
||||
|
||||
int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData);
|
||||
|
||||
SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId);
|
||||
|
|
|
@ -171,6 +171,7 @@ struct SColVal {
|
|||
|
||||
#pragma pack(push, 1)
|
||||
struct STagVal {
|
||||
// char colName[TSDB_COL_NAME_LEN]; // only used for tmq_get_meta
|
||||
union {
|
||||
int16_t cid;
|
||||
char *pKey;
|
||||
|
|
|
@ -1939,6 +1939,8 @@ typedef struct SVCreateStbReq {
|
|||
SSchemaWrapper schemaRow;
|
||||
SSchemaWrapper schemaTag;
|
||||
SRSmaParam rsmaParam;
|
||||
int32_t alterOriDataLen;
|
||||
void* alterOriData;
|
||||
} SVCreateStbReq;
|
||||
|
||||
int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq);
|
||||
|
@ -1966,7 +1968,9 @@ typedef struct SVCreateTbReq {
|
|||
int8_t type;
|
||||
union {
|
||||
struct {
|
||||
char* name; // super table name
|
||||
tb_uid_t suid;
|
||||
SArray* tagName;
|
||||
uint8_t* pTag;
|
||||
} ctb;
|
||||
struct {
|
||||
|
@ -1983,6 +1987,9 @@ static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) {
|
|||
taosMemoryFreeClear(req->comment);
|
||||
if (req->type == TSDB_CHILD_TABLE) {
|
||||
taosMemoryFreeClear(req->ctb.pTag);
|
||||
taosMemoryFreeClear(req->ctb.name);
|
||||
taosArrayDestroy(req->ctb.tagName);
|
||||
req->ctb.tagName = NULL;
|
||||
} else if (req->type == TSDB_NORMAL_TABLE) {
|
||||
taosMemoryFreeClear(req->ntb.schemaRow.pSchema);
|
||||
}
|
||||
|
@ -2066,12 +2073,14 @@ typedef struct {
|
|||
int32_t bytes;
|
||||
// TSDB_ALTER_TABLE_DROP_COLUMN
|
||||
// TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
|
||||
int8_t colModType;
|
||||
int32_t colModBytes;
|
||||
// TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
|
||||
char* colNewName;
|
||||
// TSDB_ALTER_TABLE_UPDATE_TAG_VAL
|
||||
char* tagName;
|
||||
int8_t isNull;
|
||||
int8_t tagType;
|
||||
uint32_t nTagVal;
|
||||
uint8_t* pTagVal;
|
||||
// TSDB_ALTER_TABLE_UPDATE_OPTIONS
|
||||
|
@ -2858,8 +2867,8 @@ typedef struct {
|
|||
|
||||
static FORCE_INLINE int32_t tEncodeSMqMetaRsp(void** buf, const SMqMetaRsp* pRsp) {
|
||||
int32_t tlen = 0;
|
||||
// tlen += taosEncodeFixedI64(buf, pRsp->reqOffset);
|
||||
// tlen += taosEncodeFixedI64(buf, pRsp->rspOffset);
|
||||
tlen += taosEncodeFixedI64(buf, pRsp->reqOffset);
|
||||
tlen += taosEncodeFixedI64(buf, pRsp->rspOffset);
|
||||
tlen += taosEncodeFixedI16(buf, pRsp->resMsgType);
|
||||
tlen += taosEncodeFixedI32(buf, 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) {
|
||||
// buf = taosDecodeFixedI64(buf, &pRsp->reqOffset);
|
||||
// buf = taosDecodeFixedI64(buf, &pRsp->rspOffset);
|
||||
buf = taosDecodeFixedI64(buf, &pRsp->reqOffset);buf = taosDecodeFixedI64(buf, &pRsp->rspOffset);
|
||||
buf = taosDecodeFixedI16(buf, &pRsp->resMsgType);
|
||||
buf = taosDecodeFixedI32(buf, &pRsp->metaRspLen);
|
||||
buf = taosDecodeBinary(buf, &pRsp->metaRsp, pRsp->metaRspLen);
|
||||
|
|
|
@ -213,63 +213,64 @@
|
|||
#define TK_NK_ARROW 195
|
||||
#define TK_ROWTS 196
|
||||
#define TK_TBNAME 197
|
||||
#define TK_QSTARTTS 198
|
||||
#define TK_QENDTS 199
|
||||
#define TK_WSTARTTS 200
|
||||
#define TK_WENDTS 201
|
||||
#define TK_WDURATION 202
|
||||
#define TK_CAST 203
|
||||
#define TK_NOW 204
|
||||
#define TK_TODAY 205
|
||||
#define TK_TIMEZONE 206
|
||||
#define TK_CLIENT_VERSION 207
|
||||
#define TK_SERVER_VERSION 208
|
||||
#define TK_SERVER_STATUS 209
|
||||
#define TK_CURRENT_USER 210
|
||||
#define TK_COUNT 211
|
||||
#define TK_LAST_ROW 212
|
||||
#define TK_BETWEEN 213
|
||||
#define TK_IS 214
|
||||
#define TK_NK_LT 215
|
||||
#define TK_NK_GT 216
|
||||
#define TK_NK_LE 217
|
||||
#define TK_NK_GE 218
|
||||
#define TK_NK_NE 219
|
||||
#define TK_MATCH 220
|
||||
#define TK_NMATCH 221
|
||||
#define TK_CONTAINS 222
|
||||
#define TK_JOIN 223
|
||||
#define TK_INNER 224
|
||||
#define TK_SELECT 225
|
||||
#define TK_DISTINCT 226
|
||||
#define TK_WHERE 227
|
||||
#define TK_PARTITION 228
|
||||
#define TK_BY 229
|
||||
#define TK_SESSION 230
|
||||
#define TK_STATE_WINDOW 231
|
||||
#define TK_SLIDING 232
|
||||
#define TK_FILL 233
|
||||
#define TK_VALUE 234
|
||||
#define TK_NONE 235
|
||||
#define TK_PREV 236
|
||||
#define TK_LINEAR 237
|
||||
#define TK_NEXT 238
|
||||
#define TK_HAVING 239
|
||||
#define TK_RANGE 240
|
||||
#define TK_EVERY 241
|
||||
#define TK_ORDER 242
|
||||
#define TK_SLIMIT 243
|
||||
#define TK_SOFFSET 244
|
||||
#define TK_LIMIT 245
|
||||
#define TK_OFFSET 246
|
||||
#define TK_ASC 247
|
||||
#define TK_NULLS 248
|
||||
#define TK_ID 249
|
||||
#define TK_NK_BITNOT 250
|
||||
#define TK_VALUES 251
|
||||
#define TK_IMPORT 252
|
||||
#define TK_NK_SEMI 253
|
||||
#define TK_FILE 254
|
||||
#define TK_QSTART 198
|
||||
#define TK_QEND 199
|
||||
#define TK_QDURATION 200
|
||||
#define TK_WSTART 201
|
||||
#define TK_WEND 202
|
||||
#define TK_WDURATION 203
|
||||
#define TK_CAST 204
|
||||
#define TK_NOW 205
|
||||
#define TK_TODAY 206
|
||||
#define TK_TIMEZONE 207
|
||||
#define TK_CLIENT_VERSION 208
|
||||
#define TK_SERVER_VERSION 209
|
||||
#define TK_SERVER_STATUS 210
|
||||
#define TK_CURRENT_USER 211
|
||||
#define TK_COUNT 212
|
||||
#define TK_LAST_ROW 213
|
||||
#define TK_BETWEEN 214
|
||||
#define TK_IS 215
|
||||
#define TK_NK_LT 216
|
||||
#define TK_NK_GT 217
|
||||
#define TK_NK_LE 218
|
||||
#define TK_NK_GE 219
|
||||
#define TK_NK_NE 220
|
||||
#define TK_MATCH 221
|
||||
#define TK_NMATCH 222
|
||||
#define TK_CONTAINS 223
|
||||
#define TK_JOIN 224
|
||||
#define TK_INNER 225
|
||||
#define TK_SELECT 226
|
||||
#define TK_DISTINCT 227
|
||||
#define TK_WHERE 228
|
||||
#define TK_PARTITION 229
|
||||
#define TK_BY 230
|
||||
#define TK_SESSION 231
|
||||
#define TK_STATE_WINDOW 232
|
||||
#define TK_SLIDING 233
|
||||
#define TK_FILL 234
|
||||
#define TK_VALUE 235
|
||||
#define TK_NONE 236
|
||||
#define TK_PREV 237
|
||||
#define TK_LINEAR 238
|
||||
#define TK_NEXT 239
|
||||
#define TK_HAVING 240
|
||||
#define TK_RANGE 241
|
||||
#define TK_EVERY 242
|
||||
#define TK_ORDER 243
|
||||
#define TK_SLIMIT 244
|
||||
#define TK_SOFFSET 245
|
||||
#define TK_LIMIT 246
|
||||
#define TK_OFFSET 247
|
||||
#define TK_ASC 248
|
||||
#define TK_NULLS 249
|
||||
#define TK_ID 250
|
||||
#define TK_NK_BITNOT 251
|
||||
#define TK_VALUES 252
|
||||
#define TK_IMPORT 253
|
||||
#define TK_NK_SEMI 254
|
||||
#define TK_FILE 255
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -34,7 +34,7 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_ELAPSED,
|
||||
FUNCTION_TYPE_IRATE,
|
||||
FUNCTION_TYPE_LAST_ROW,
|
||||
FUNCTION_TYPE_LAST_ROWT, //TODO: removed
|
||||
FUNCTION_TYPE_LAST_ROWT, // TODO: removed
|
||||
FUNCTION_TYPE_MAX,
|
||||
FUNCTION_TYPE_MIN,
|
||||
FUNCTION_TYPE_MODE,
|
||||
|
@ -114,10 +114,11 @@ typedef enum EFunctionType {
|
|||
// pseudo column function
|
||||
FUNCTION_TYPE_ROWTS = 3500,
|
||||
FUNCTION_TYPE_TBNAME,
|
||||
FUNCTION_TYPE_QSTARTTS,
|
||||
FUNCTION_TYPE_QENDTS,
|
||||
FUNCTION_TYPE_WSTARTTS,
|
||||
FUNCTION_TYPE_WENDTS,
|
||||
FUNCTION_TYPE_QSTART,
|
||||
FUNCTION_TYPE_QEND,
|
||||
FUNCTION_TYPE_QDURATION,
|
||||
FUNCTION_TYPE_WSTART,
|
||||
FUNCTION_TYPE_WEND,
|
||||
FUNCTION_TYPE_WDURATION,
|
||||
|
||||
// internal function
|
||||
|
@ -197,6 +198,7 @@ bool fmIsInterpFunc(int32_t funcId);
|
|||
bool fmIsLastRowFunc(int32_t funcId);
|
||||
bool fmIsSystemInfoFunc(int32_t funcId);
|
||||
bool fmIsImplicitTsFunc(int32_t funcId);
|
||||
bool fmIsClientPseudoColumnFunc(int32_t funcId);
|
||||
|
||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ typedef struct SFillNode {
|
|||
ENodeType type; // QUERY_NODE_FILL
|
||||
EFillMode mode;
|
||||
SNode* pValues; // SNodeListNode
|
||||
SNode* pWStartTs; // _wstartts pseudo column
|
||||
SNode* pWStartTs; // _wstart pseudo column
|
||||
STimeWindow timeRange;
|
||||
} SFillNode;
|
||||
|
||||
|
@ -248,6 +248,7 @@ typedef struct SSelectStmt {
|
|||
SNodeList* pOrderByList; // SOrderByExprNode
|
||||
SLimitNode* pLimit;
|
||||
SLimitNode* pSlimit;
|
||||
STimeWindow timeRange;
|
||||
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||
uint8_t precision;
|
||||
int32_t selectFuncNum;
|
||||
|
|
|
@ -29,7 +29,7 @@ struct SMetaData;
|
|||
typedef struct SStmtCallback {
|
||||
TAOS_STMT* pStmt;
|
||||
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**);
|
||||
} SStmtCallback;
|
||||
|
||||
|
@ -84,7 +84,7 @@ int32_t qBindStmtSingleColValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBu
|
|||
int32_t rowNum);
|
||||
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 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);
|
||||
void destroyBoundColumnInfo(void* pBoundInfo);
|
||||
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 smlDestroyHandle(void* pHandle);
|
||||
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 rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
|
||||
|
|
|
@ -340,12 +340,12 @@ static FORCE_INLINE int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBloc
|
|||
if (pTask->sinkType == TASK_SINK__TABLE) {
|
||||
ASSERT(pTask->dispatchType == TASK_DISPATCH__NONE);
|
||||
pTask->tbSink.tbSinkFunc(pTask, pTask->tbSink.vnode, 0, pBlock->blocks);
|
||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)tDeleteSSDataBlock);
|
||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
|
||||
taosFreeQitem(pBlock);
|
||||
} else if (pTask->sinkType == TASK_SINK__SMA) {
|
||||
ASSERT(pTask->dispatchType == TASK_DISPATCH__NONE);
|
||||
pTask->smaSink.smaSink(pTask->smaSink.vnode, pTask->smaSink.smaId, pBlock->blocks);
|
||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)tDeleteSSDataBlock);
|
||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
|
||||
taosFreeQitem(pBlock);
|
||||
} else {
|
||||
ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE);
|
||||
|
|
|
@ -22,7 +22,10 @@ extern "C" {
|
|||
|
||||
#if defined(_TD_DARWIN_64)
|
||||
// specific
|
||||
#ifndef __COMPAR_FN_T
|
||||
#define __COMPAR_FN_T
|
||||
typedef int(*__compar_fn_t)(const void *, const void *);
|
||||
#endif
|
||||
|
||||
// for send function in tsocket.c
|
||||
#if defined(MSG_NOSIGNAL)
|
||||
|
@ -41,7 +44,10 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#if defined(_ALPINE)
|
||||
#ifndef __COMPAR_FN_T
|
||||
#define __COMPAR_FN_T
|
||||
typedef int(*__compar_fn_t)(const void *, const void *);
|
||||
#endif
|
||||
void error (int, int, const char *);
|
||||
#ifndef PTHREAD_MUTEX_RECURSIVE_NP
|
||||
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
||||
|
@ -54,7 +60,10 @@ extern "C" {
|
|||
char *stpncpy (char *dest, const char *src, size_t n);
|
||||
|
||||
// specific
|
||||
#ifndef __COMPAR_FN_T
|
||||
#define __COMPAR_FN_T
|
||||
typedef int (*__compar_fn_t)(const void *, const void *);
|
||||
#endif
|
||||
#define ssize_t int
|
||||
#define _SSIZE_T_
|
||||
#define bzero(ptr, size) memset((ptr), 0, (size))
|
||||
|
@ -69,7 +78,6 @@ extern "C" {
|
|||
char * strsep(char **stringp, const char *delim);
|
||||
char * getpass(const char *prefix);
|
||||
char * strndup(const char *s, size_t n);
|
||||
int gettimeofday(struct timeval *ptv, void *pTimeZone);
|
||||
|
||||
// for send function in tsocket.c
|
||||
#define MSG_NOSIGNAL 0
|
||||
|
|
|
@ -440,7 +440,7 @@ static FORCE_INLINE bool tDecodeIsEnd(SDecoder* pCoder) { return (pCoder->size =
|
|||
|
||||
static FORCE_INLINE void* tEncoderMalloc(SEncoder* pCoder, int32_t size) {
|
||||
void* p = NULL;
|
||||
SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size);
|
||||
SCoderMem* pMem = (SCoderMem*)taosMemoryCalloc(1, sizeof(*pMem) + size);
|
||||
if (pMem) {
|
||||
pMem->next = pCoder->mList;
|
||||
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) {
|
||||
void* p = NULL;
|
||||
SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size);
|
||||
SCoderMem* pMem = (SCoderMem*)taosMemoryCalloc(1, sizeof(*pMem) + size);
|
||||
if (pMem) {
|
||||
pMem->next = pCoder->mList;
|
||||
pCoder->mList = pMem;
|
||||
|
|
|
@ -181,6 +181,7 @@ typedef struct SRequestSendRecvBody {
|
|||
tsem_t rspSem; // not used now
|
||||
__taos_async_fn_t queryFp;
|
||||
__taos_async_fn_t fetchFp;
|
||||
EQueryExecMode execMode;
|
||||
void* param;
|
||||
SDataBuf requestMsg;
|
||||
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);
|
||||
if (*pRequest == NULL) {
|
||||
tscError("failed to malloc sqlObj, %s", sql);
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
(*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) {
|
||||
int32_t code = 0;
|
||||
|
||||
pRequest->body.execMode = pQuery->execMode;
|
||||
|
||||
switch (pQuery->execMode) {
|
||||
case QUERY_EXEC_MODE_LOCAL:
|
||||
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);
|
||||
if (pRequest == NULL) {
|
||||
destroyTscObj(pTscObj);
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
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.
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
@ -58,7 +58,10 @@ void taos_cleanup(void) {
|
|||
clientReqRefPool = -1;
|
||||
taosCloseRef(id);
|
||||
|
||||
cleanupTaskQueue();
|
||||
hbMgrCleanUp();
|
||||
|
||||
catalogDestroy();
|
||||
schedulerDestroy();
|
||||
|
||||
fmFuncMgtDestroy();
|
||||
qCleanupKeywordsTable();
|
||||
|
@ -67,12 +70,11 @@ void taos_cleanup(void) {
|
|||
clientConnRefPool = -1;
|
||||
taosCloseRef(id);
|
||||
|
||||
hbMgrCleanUp();
|
||||
|
||||
catalogDestroy();
|
||||
schedulerDestroy();
|
||||
|
||||
rpcCleanup();
|
||||
tscDebug("rpc cleanup");
|
||||
|
||||
cleanupTaskQueue();
|
||||
|
||||
tscInfo("all local resources released");
|
||||
taosCleanupCfg();
|
||||
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
|
||||
if (pResultInfo->completed && (pRequest->body.queryJob != 0)) {
|
||||
pResultInfo->numOfRows = 0;
|
||||
if (pResultInfo->completed) {
|
||||
// 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);
|
||||
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 = {
|
||||
.syncReq = false,
|
||||
.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
|
||||
|
||||
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) {
|
||||
uError("SML:0x%" PRIx64 " smlBindData failed", info->id);
|
||||
return code;
|
||||
|
|
|
@ -136,7 +136,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
|||
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;
|
||||
|
||||
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.boundTags = tags;
|
||||
pStmt->bInfo.tagsCached = false;
|
||||
strcpy(pStmt->bInfo.stbFName, sTableName);
|
||||
|
||||
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,
|
||||
SHashObj* pVgHash, SHashObj* pBlockHash) {
|
||||
SHashObj* pVgHash, SHashObj* pBlockHash, const char* sTableName) {
|
||||
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));
|
||||
|
||||
pStmt->sql.autoCreateTbl = autoCreateTbl;
|
||||
|
@ -253,7 +254,7 @@ int32_t stmtCleanBindInfo(STscStmt* pStmt) {
|
|||
destroyBoundColumnInfo(pStmt->bInfo.boundTags);
|
||||
taosMemoryFreeClear(pStmt->bInfo.boundTags);
|
||||
}
|
||||
|
||||
memset(pStmt->bInfo.stbFName, 0, TSDB_TABLE_FNAME_LEN);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -592,7 +593,7 @@ int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) {
|
|||
}
|
||||
|
||||
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));
|
||||
|
||||
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) {
|
||||
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);
|
||||
const char* pStart = buf + sizeof(uint32_t);
|
||||
|
||||
|
@ -589,6 +591,7 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// todo remove this
|
||||
int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity) {
|
||||
pBlock->info.rows = *(int32_t*)buf;
|
||||
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 code = 0;
|
||||
// ASSERT(numOfRows > 0);
|
||||
|
||||
if (numOfRows == 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1196,15 +1197,28 @@ int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) {
|
|||
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) {
|
||||
if (pBlock == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
blockDestroyInner(pBlock);
|
||||
blockDataFreeRes(pBlock);
|
||||
taosMemoryFreeClear(pBlock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) {
|
||||
ASSERT(src != NULL);
|
||||
|
||||
|
|
|
@ -4871,6 +4871,11 @@ int tEncodeSVCreateStbReq(SEncoder *pCoder, const SVCreateStbReq *pReq) {
|
|||
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);
|
||||
return 0;
|
||||
}
|
||||
|
@ -4887,6 +4892,11 @@ int tDecodeSVCreateStbReq(SDecoder *pCoder, SVCreateStbReq *pReq) {
|
|||
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);
|
||||
return 0;
|
||||
}
|
||||
|
@ -4930,8 +4940,15 @@ int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) {
|
|||
}
|
||||
|
||||
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 (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) {
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1;
|
||||
} else {
|
||||
|
@ -4959,8 +4976,20 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
|
|||
}
|
||||
|
||||
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 (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) {
|
||||
if (tDecodeSSchemaWrapperEx(pCoder, &pReq->ntb.schemaRow) < 0) return -1;
|
||||
} else {
|
||||
|
@ -5292,6 +5321,7 @@ int32_t tEncodeSVAlterTbReq(SEncoder *pEncoder, const SVAlterTbReq *pReq) {
|
|||
break;
|
||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||
if (tEncodeCStr(pEncoder, pReq->colName) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pReq->colModType) < 0) return -1;
|
||||
if (tEncodeI32v(pEncoder, pReq->colModBytes) < 0) return -1;
|
||||
break;
|
||||
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:
|
||||
if (tEncodeCStr(pEncoder, pReq->tagName) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pReq->isNull) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pReq->tagType) < 0) return -1;
|
||||
if (!pReq->isNull) {
|
||||
if (tEncodeBinary(pEncoder, pReq->pTagVal, pReq->nTagVal) < 0) return -1;
|
||||
}
|
||||
|
@ -5340,6 +5371,7 @@ int32_t tDecodeSVAlterTbReq(SDecoder *pDecoder, SVAlterTbReq *pReq) {
|
|||
break;
|
||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||
if (tDecodeCStr(pDecoder, &pReq->colName) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pReq->colModType) < 0) return -1;
|
||||
if (tDecodeI32v(pDecoder, &pReq->colModBytes) < 0) return -1;
|
||||
break;
|
||||
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:
|
||||
if (tDecodeCStr(pDecoder, &pReq->tagName) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pReq->isNull) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pReq->tagType) < 0) return -1;
|
||||
if (!pReq->isNull) {
|
||||
if (tDecodeBinary(pDecoder, &pReq->pTagVal, &pReq->nTagVal) < 0) return -1;
|
||||
}
|
||||
|
|
|
@ -168,7 +168,12 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
|||
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));
|
||||
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) {
|
||||
|
|
|
@ -45,7 +45,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq);
|
|||
static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||
static void mndCancelGetNextStb(SMnode *pMnode, void *pIter);
|
||||
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) {
|
||||
SSdbTable table = {
|
||||
|
@ -409,7 +409,7 @@ static FORCE_INLINE int32_t schemaExColIdCompare(const void *colId, const void *
|
|||
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};
|
||||
int32_t contLen;
|
||||
SName name = {0};
|
||||
|
@ -422,6 +422,8 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
|||
req.name = (char *)tNameGetTableName(&name);
|
||||
req.suid = pStb->uid;
|
||||
req.rollup = pStb->ast1Len > 0 ? 1 : 0;
|
||||
req.alterOriData = alterOriData;
|
||||
req.alterOriDataLen = alterOriDataLen;
|
||||
// todo
|
||||
req.schemaRow.nCols = pStb->numOfColumns;
|
||||
req.schemaRow.version = pStb->colVer;
|
||||
|
@ -626,7 +628,7 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
|||
continue;
|
||||
}
|
||||
|
||||
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen);
|
||||
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen, NULL, 0);
|
||||
if (pReq == NULL) {
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
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);
|
||||
pDst->createdTime = taosGetTimestampMs();
|
||||
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->tagVer = (pCreate->source != TD_REQ_FROM_APP) ? pCreate->tagVer : 1;
|
||||
pDst->colVer = (pCreate->source != TD_REQ_FROM_APP) ? pCreate->colVer : 1;
|
||||
pDst->tagVer = 1;
|
||||
pDst->colVer = 1;
|
||||
pDst->smaVer = 1;
|
||||
pDst->nextColId = 1;
|
||||
pDst->maxdelay[0] = pCreate->delay1;
|
||||
|
@ -849,6 +851,75 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) {
|
|||
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) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
int32_t code = -1;
|
||||
|
@ -881,9 +952,9 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
|||
terrno = TSDB_CODE_MND_STABLE_UID_NOT_MATCH;
|
||||
goto _OVER;
|
||||
} else if (createReq.tagVer > 0 || createReq.colVer > 0) {
|
||||
int32_t tagDelta = pStb->tagVer - createReq.tagVer;
|
||||
int32_t colDelta = pStb->colVer - createReq.colVer;
|
||||
int32_t verDelta = tagDelta + verDelta;
|
||||
int32_t tagDelta = createReq.tagVer - pStb->tagVer;
|
||||
int32_t colDelta = createReq.colVer - pStb->colVer;
|
||||
int32_t verDelta = tagDelta + colDelta;
|
||||
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);
|
||||
if (tagDelta <= 0 && colDelta <= 0) {
|
||||
|
@ -910,6 +981,10 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
|||
}
|
||||
} else if (terrno != TSDB_CODE_MND_STB_NOT_EXIST) {
|
||||
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);
|
||||
|
@ -934,7 +1009,16 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
|||
|
||||
if (isAlter) {
|
||||
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 {
|
||||
code = mndCreateStb(pMnode, pReq, &createReq, pDb);
|
||||
}
|
||||
|
@ -972,26 +1056,6 @@ static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
|
|||
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) {
|
||||
pNew->pTags = taosMemoryCalloc(pNew->numOfTags, sizeof(SSchema));
|
||||
pNew->pColumns = taosMemoryCalloc(pNew->numOfColumns, sizeof(SSchema));
|
||||
|
@ -1315,7 +1379,7 @@ static int32_t mndSetAlterStbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *
|
|||
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;
|
||||
SVgObj *pVgroup = NULL;
|
||||
void *pIter = NULL;
|
||||
|
@ -1329,7 +1393,7 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
|||
continue;
|
||||
}
|
||||
|
||||
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen);
|
||||
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen, alterOriData, alterOriDataLen);
|
||||
if (pReq == NULL) {
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
|
@ -1542,7 +1606,7 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, SStbObj *pObj, void **pCont, i
|
|||
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;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq);
|
||||
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 (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;
|
||||
|
||||
code = 0;
|
||||
|
@ -1620,7 +1684,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
|
|||
}
|
||||
|
||||
if (code != 0) goto _OVER;
|
||||
code = mndAlterStbImp(pMnode, pReq, pDb, &stbObj, needRsp);
|
||||
code = mndAlterStbImp(pMnode, pReq, pDb, &stbObj, needRsp, pReq->pCont, pReq->contLen);
|
||||
|
||||
_OVER:
|
||||
taosMemoryFreeClear(stbObj.pTags);
|
||||
|
@ -1785,8 +1849,8 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
|
|||
}
|
||||
}
|
||||
|
||||
if (dropReq.source != TD_REQ_FROM_APP && pStb->uid != dropReq.suid) {
|
||||
terrno = TSDB_CODE_MND_STB_NOT_EXIST;
|
||||
if (dropReq.source == TD_REQ_FROM_TAOX && pStb->uid != dropReq.suid) {
|
||||
code = 0;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,7 @@ typedef struct SSdbRow {
|
|||
ESdbType type;
|
||||
ESdbStatus status;
|
||||
int32_t refCount;
|
||||
int64_t forAlign;
|
||||
char pObj[];
|
||||
} SSdbRow;
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ void *tsdbGetIdx(SMeta *pMeta);
|
|||
void *tsdbGetIvtIdx(SMeta *pMeta);
|
||||
|
||||
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 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.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
|
||||
int32_t ret = 0;
|
||||
tEncodeSize(tEncodeSSchemaWrapper, pSW, vLen, ret);
|
||||
|
|
|
@ -401,7 +401,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
|||
tqDebug("fetch meta msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType);
|
||||
SMqMetaRsp metaRsp = {0};
|
||||
/*metaRsp.reqOffset = pReq->reqOffset.version;*/
|
||||
/*metaRsp.rspOffset = fetchVer;*/
|
||||
metaRsp.rspOffset = fetchVer;
|
||||
/*metaRsp.rspOffsetNew.version = fetchVer;*/
|
||||
tqOffsetResetToLog(&metaRsp.reqOffsetNew, pReq->reqOffset.version);
|
||||
tqOffsetResetToLog(&metaRsp.rspOffsetNew, fetchVer);
|
||||
|
|
|
@ -319,7 +319,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
|
|||
return 0;
|
||||
|
||||
FAIL:
|
||||
tDeleteSSDataBlock(pBlock);
|
||||
blockDataFreeRes(pBlock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
|
|||
|
||||
SVCreateTbReq createTbReq = {0};
|
||||
createTbReq.name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId);
|
||||
createTbReq.ctb.name = strdup(stbFullName);
|
||||
createTbReq.flags = 0;
|
||||
createTbReq.type = TSDB_CHILD_TABLE;
|
||||
createTbReq.ctb.suid = suid;
|
||||
|
|
|
@ -107,7 +107,7 @@ int32_t tsdbLastrowReaderClose(void* pReader) {
|
|||
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) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
@ -144,14 +144,15 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t
|
|||
// appended or not.
|
||||
if (internalResult) {
|
||||
pResBlock->info.rows -= 1;
|
||||
taosArrayClear(pTableUidList);
|
||||
}
|
||||
|
||||
saveOneRow(pRow, pResBlock, pr, slotIds);
|
||||
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
||||
internalResult = true;
|
||||
lastKey = pRow->ts;
|
||||
}
|
||||
|
||||
// taosMemoryFree(pRow);
|
||||
tsdbCacheRelease(lruCache, h);
|
||||
}
|
||||
} else if (pr->type == LASTROW_RETRIEVE_TYPE_ALL) {
|
||||
|
@ -174,6 +175,7 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t
|
|||
// tsdbCacheLastArray2Row(pLast, &pRow, pr->pSchema);
|
||||
|
||||
saveOneRow(pRow, pResBlock, pr, slotIds);
|
||||
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
||||
|
||||
// taosMemoryFree(pRow);
|
||||
tsdbCacheRelease(lruCache, h);
|
||||
|
|
|
@ -209,10 +209,10 @@ static void resetDataBlockScanInfo(SHashObj* pTableMap) {
|
|||
p->iterInit = false;
|
||||
p->iiter.hasVal = false;
|
||||
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;
|
||||
|
||||
if (p->iter.iter != NULL) {
|
||||
tsdbTbDataIterDestroy(p->iter.iter);
|
||||
p->iter.iter = NULL;
|
||||
p->iter.iter = tsdbTbDataIterDestroy(p->iter.iter);
|
||||
}
|
||||
|
||||
if (p->iiter.iter != NULL) {
|
||||
tsdbTbDataIterDestroy(p->iiter.iter);
|
||||
p->iiter.iter = NULL;
|
||||
p->iiter.iter = tsdbTbDataIterDestroy(p->iiter.iter);
|
||||
}
|
||||
|
||||
taosArrayDestroy(p->delSkyline);
|
||||
p->delSkyline = NULL;
|
||||
p->delSkyline = taosArrayDestroy(p->delSkyline);
|
||||
p->pBlockList = taosArrayDestroy(p->pBlockList);
|
||||
}
|
||||
|
||||
taosHashCleanup(pTableMap);
|
||||
|
@ -302,9 +300,9 @@ static bool filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader) {
|
|||
STimeWindow win = {0};
|
||||
|
||||
while (1) {
|
||||
// if (pReader->pFileReader != NULL) {
|
||||
// tsdbDataFReaderClose(&pReader->pFileReader);
|
||||
// }
|
||||
if (pReader->pFileReader != NULL) {
|
||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||
}
|
||||
|
||||
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);
|
||||
if (p == NULL) {
|
||||
tMapDataClear(&mapData);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
(*numOfBlocks) += 1;
|
||||
}
|
||||
|
||||
tMapDataClear(&mapData);
|
||||
if (pScanInfo->pBlockList != NULL && taosArrayGetSize(pScanInfo->pBlockList) > 0) {
|
||||
(*numOfValidTables) += 1;
|
||||
}
|
||||
|
@ -1308,6 +1308,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
|||
pReader->idStr);
|
||||
|
||||
pBlockIter->index = asc ? 0 : (numOfBlocks - 1);
|
||||
|
||||
cleanupBlockOrderSupporter(&sup);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1990,6 +1992,7 @@ static TSDBKEY getCurrentKeyInBuf(SDataBlockIter* pBlockIter, STsdbReader* pRead
|
|||
|
||||
static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) {
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
SArray* pIndexList = taosArrayInit(4, sizeof(SBlockIdx));
|
||||
|
||||
while (1) {
|
||||
bool hasNext = filesetIteratorNext(&pStatus->fileIter, pReader);
|
||||
|
@ -1997,9 +2000,10 @@ static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) {
|
|||
break;
|
||||
}
|
||||
|
||||
SArray* pIndexList = taosArrayInit(4, sizeof(SBlockIdx));
|
||||
taosArrayClear(pIndexList);
|
||||
int32_t code = doLoadBlockIndex(pReader, pReader->pFileReader, pIndexList);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(pIndexList);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -2007,6 +2011,7 @@ static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) {
|
|||
uint32_t numOfValidTable = 0;
|
||||
code = doLoadFileBlock(pReader, pIndexList, &numOfValidTable, numOfBlocks);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(pIndexList);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -2014,10 +2019,10 @@ static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// no blocks in current file, try next files
|
||||
}
|
||||
|
||||
taosArrayDestroy(pIndexList);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -3081,10 +3086,13 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
|
|||
|
||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||
pTableBlockInfo->numOfFiles += pStatus->fileIter.numOfFiles;
|
||||
pTableBlockInfo->numOfBlocks += pBlockIter->numOfBlocks;
|
||||
|
||||
if (pBlockIter->numOfBlocks > 0) {
|
||||
pTableBlockInfo->numOfBlocks += pBlockIter->numOfBlocks;
|
||||
}
|
||||
|
||||
pTableBlockInfo->numOfTables = numOfTables;
|
||||
bool hasNext = true;
|
||||
bool hasNext = (pBlockIter->numOfBlocks > 0);
|
||||
|
||||
while (true) {
|
||||
if (hasNext) {
|
||||
|
|
|
@ -494,8 +494,6 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
|
|||
taosArrayPush(rsp.pArray, &cRsp);
|
||||
}
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
tqUpdateTbUidList(pVnode->pTq, tbUids, true);
|
||||
tdUpdateTbUidList(pVnode->pSma, pStore);
|
||||
tdUidStoreFree(pStore);
|
||||
|
@ -512,9 +510,12 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
|
|||
}
|
||||
tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen);
|
||||
tEncodeSVCreateTbBatchRsp(&encoder, &rsp);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
_exit:
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pCreateReq = req.pReqs + iReq;
|
||||
taosArrayDestroy(pCreateReq->ctb.tagName);
|
||||
}
|
||||
taosArrayDestroy(rsp.pArray);
|
||||
taosArrayDestroy(tbUids);
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -611,7 +612,7 @@ static int32_t vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pRe
|
|||
|
||||
// process
|
||||
if (metaAlterTable(pVnode->pMeta, version, &vAlterTbReq, &vMetaRsp) < 0) {
|
||||
vAlterTbRsp.code = TSDB_CODE_INVALID_MSG;
|
||||
vAlterTbRsp.code = terrno;
|
||||
tDecoderClear(&dc);
|
||||
rcode = -1;
|
||||
goto _exit;
|
||||
|
@ -795,6 +796,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
|||
if (tDecodeSVCreateTbReq(&decoder, &createTbReq) < 0) {
|
||||
pRsp->code = TSDB_CODE_INVALID_MSG;
|
||||
tDecoderClear(&decoder);
|
||||
taosArrayDestroy(createTbReq.ctb.tagName);
|
||||
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) {
|
||||
submitBlkRsp.code = terrno;
|
||||
tDecoderClear(&decoder);
|
||||
taosArrayDestroy(createTbReq.ctb.tagName);
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
@ -822,6 +825,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
|||
vnodeDebugPrintSingleSubmitMsg(pVnode->pMeta, pBlock, &msgIter, "real uid");
|
||||
#endif
|
||||
tDecoderClear(&decoder);
|
||||
taosArrayDestroy(createTbReq.ctb.tagName);
|
||||
} else {
|
||||
submitBlkRsp.tblFName = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN);
|
||||
sprintf(submitBlkRsp.tblFName, "%s.", pVnode->config.dbname);
|
||||
|
|
|
@ -1293,7 +1293,7 @@ void catalogDestroy(void) {
|
|||
|
||||
if (!taosCheckCurrentInDll()) {
|
||||
ctgClearCacheEnqueue(NULL, true, true, true);
|
||||
taosThreadJoin(gCtgMgmt.updateThread, NULL);
|
||||
taosThreadJoin(gCtgMgmt.updateThread, NULL);
|
||||
}
|
||||
|
||||
taosHashCleanup(gCtgMgmt.pCluster);
|
||||
|
|
|
@ -322,6 +322,7 @@ typedef struct SLastrowScanInfo {
|
|||
void *pLastrowReader;
|
||||
SArray *pColMatchInfo;
|
||||
int32_t *pSlotIds;
|
||||
SExprSupp pseudoExprSup;
|
||||
} SLastrowScanInfo;
|
||||
|
||||
typedef enum EStreamScanMode {
|
||||
|
@ -790,6 +791,8 @@ int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaul
|
|||
|
||||
void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
||||
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 destroyBasicOperatorInfo(void* param, int32_t numOfOutput);
|
||||
|
|
|
@ -45,20 +45,20 @@ SOperatorInfo* createLastrowScanOperator(SLastRowScanPhysiNode* pScanNode, SRead
|
|||
int32_t numOfCols = 0;
|
||||
pInfo->pColMatchInfo = extractColMatchInfo(pScanNode->pScanCols, pScanNode->node.pOutputDataBlockDesc, &numOfCols,
|
||||
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);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
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);
|
||||
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->operatorType = QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN;
|
||||
|
@ -100,7 +100,20 @@ SSDataBlock* doScanLastrow(SOperatorInfo* pOperator) {
|
|||
// check if it is a group by tbname
|
||||
if (size == taosArrayGetSize(pInfo->pTableList)) {
|
||||
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;
|
||||
} else {
|
||||
// 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;
|
||||
if (pScanNode->tableType == TSDB_SUPER_TABLE) {
|
||||
if (pTagIndexCond) {
|
||||
///<<<<<<< HEAD
|
||||
SIndexMetaArg metaArg = {
|
||||
.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;
|
||||
code = doFilterTag(pTagIndexCond, &metaArg, res, &status);
|
||||
if (code != 0 || status == SFLT_NOT_INDEX) {
|
||||
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) {
|
||||
qError("failed to get tableIds from index, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid);
|
||||
// code = TSDB_CODE_INDEX_REBUILDING;
|
||||
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 {
|
||||
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;
|
||||
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.
|
||||
STableKeyInfo info = {.lastKey = 0, .uid = tableUid, .groupId = 0};
|
||||
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);
|
||||
if (pListInfo->pGroupList == NULL) {
|
||||
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;
|
||||
} else {
|
||||
int64_t st = w.skey;
|
||||
if (pInterval->offset > 0) {
|
||||
st = taosTimeAdd(st, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||
}
|
||||
|
||||
if (st > ts) {
|
||||
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) {
|
||||
// do nothing, todo refactor
|
||||
} else {
|
||||
// expand the result into multiple rows. E.g., _wstartts, top(k, 20)
|
||||
// the _wstartts needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
|
||||
// expand the result into multiple rows. E.g., _wstart, top(k, 20)
|
||||
// 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);
|
||||
char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
|
||||
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) {
|
||||
// do nothing, todo refactor
|
||||
} else {
|
||||
// expand the result into multiple rows. E.g., _wstartts, top(k, 20)
|
||||
// the _wstartts needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
|
||||
// expand the result into multiple rows. E.g., _wstart, top(k, 20)
|
||||
// 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);
|
||||
char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
|
||||
if (pCtx[j].increase) {
|
||||
|
@ -3475,9 +3475,12 @@ static SSDataBlock* doFill(SOperatorInfo* pOperator) {
|
|||
static void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) {
|
||||
for (int32_t i = 0; i < numOfExprs; ++i) {
|
||||
SExprInfo* pExprInfo = &pExpr[i];
|
||||
if (pExprInfo->pExpr->nodeType == QUERY_NODE_COLUMN) {
|
||||
taosMemoryFree(pExprInfo->base.pParam[0].pCol);
|
||||
for(int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
|
||||
if (pExprInfo->base.pParam[j].type == FUNC_PARAM_TYPE_COLUMN) {
|
||||
taosMemoryFreeClear(pExprInfo->base.pParam[j].pCol);
|
||||
}
|
||||
}
|
||||
|
||||
taosMemoryFree(pExprInfo->base.pParam);
|
||||
taosMemoryFree(pExprInfo->pExpr);
|
||||
}
|
||||
|
@ -3685,10 +3688,20 @@ void destroyBasicOperatorInfo(void* param, int32_t numOfOutput) {
|
|||
taosMemoryFreeClear(param);
|
||||
}
|
||||
|
||||
|
||||
static void freeItem(void* pItem) {
|
||||
void** p = pItem;
|
||||
if (*p != NULL) {
|
||||
taosMemoryFreeClear(*p);
|
||||
}
|
||||
}
|
||||
|
||||
void destroyAggOperatorInfo(void* param, int32_t numOfOutput) {
|
||||
SAggOperatorInfo* pInfo = (SAggOperatorInfo*)param;
|
||||
cleanupBasicInfo(&pInfo->binfo);
|
||||
|
||||
cleanupAggSup(&pInfo->aggSup);
|
||||
taosArrayDestroyEx(pInfo->groupResInfo.pRows, freeItem);
|
||||
taosMemoryFreeClear(param);
|
||||
}
|
||||
|
||||
|
@ -4334,6 +4347,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
pTaskInfo->code = code;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
code = extractTableSchemaInfo(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
||||
if (code) {
|
||||
pTaskInfo->code = terrno;
|
||||
|
@ -4349,7 +4363,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
||||
return createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, (SExchangePhysiNode*)pPhyNode, pTaskInfo);
|
||||
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
||||
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,
|
||||
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);
|
||||
|
||||
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);
|
||||
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;
|
||||
} else if (*status == FUNC_DATA_REQUIRED_STATIS_LOAD) {
|
||||
pCost->loadBlockStatis += 1;
|
||||
|
@ -320,8 +312,6 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int
|
|||
int32_t dstSlotId = pExpr->base.resSchema.slotId;
|
||||
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
||||
|
||||
colInfoDataEnsureCapacity(pColInfoData, pBlock->info.rows);
|
||||
colInfoDataCleanup(pColInfoData, pBlock->info.rows);
|
||||
|
||||
int32_t functionId = pExpr->pExpr->_function.functionId;
|
||||
|
@ -1157,10 +1147,11 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
SOperatorInfo* pOperator = pInfo->pStreamScanOp;
|
||||
SExecTaskInfo* pTaskInfo = pInfo->pStreamScanOp->pTaskInfo;
|
||||
|
||||
blockDataEnsureCapacity(pInfo->pRes, pBlock->info.rows);
|
||||
|
||||
pInfo->pRes->info.rows = pBlock->info.rows;
|
||||
pInfo->pRes->info.uid = pBlock->info.uid;
|
||||
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));
|
||||
if (groupIdPre) {
|
||||
|
@ -1186,7 +1177,10 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
for (int32_t j = 0; j < blockDataGetNumOfCols(pBlock); ++j) {
|
||||
SColumnInfoData* pResCol = bdGetColumnInfoData(pBlock, j);
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -1199,8 +1193,6 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
}
|
||||
}
|
||||
|
||||
taosArrayDestroy(pBlock->pDataBlock);
|
||||
|
||||
ASSERT(pInfo->pRes->pDataBlock != NULL);
|
||||
|
||||
// currently only the tbname pseudo column
|
||||
|
@ -1208,12 +1200,14 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes,
|
||||
GET_TASKID(pTaskInfo));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
blockDataFreeRes((SSDataBlock*) pBlock);
|
||||
longjmp(pTaskInfo->env, code);
|
||||
}
|
||||
}
|
||||
|
||||
doFilter(pInfo->pCondition, pInfo->pRes);
|
||||
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
||||
blockDataFreeRes((SSDataBlock*) pBlock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2396,6 +2390,7 @@ int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle
|
|||
qDebug("no table qualified for query, TID:0x%" PRIx64 ", QID:0x%" PRIx64, taskId, queryId);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
pTableListInfo->needSortTableByGroupId = pTableScanNode->groupSort;
|
||||
code = generateGroupIdMap(pTableListInfo, pHandle, pTableScanNode->pGroupTags);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -2569,9 +2564,11 @@ static SSDataBlock* getTableDataBlock(void* param) {
|
|||
SDataBlockInfo binfo = pBlock->info;
|
||||
tsdbRetrieveDataBlockInfo(reader, &binfo);
|
||||
|
||||
binfo.capacity = binfo.rows;
|
||||
blockDataEnsureCapacity(pBlock, binfo.capacity);
|
||||
pBlock->info = binfo;
|
||||
blockDataEnsureCapacity(pBlock, binfo.rows);
|
||||
pBlock->info.type = binfo.type;
|
||||
pBlock->info.uid = binfo.uid;
|
||||
pBlock->info.window = binfo.window;
|
||||
pBlock->info.rows = binfo.rows;
|
||||
|
||||
uint32_t status = 0;
|
||||
int32_t code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, readerIdx, pBlock, &status);
|
||||
|
@ -2598,11 +2595,19 @@ static SSDataBlock* getTableDataBlock(void* param) {
|
|||
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));
|
||||
SBlockOrderInfo bi = {0};
|
||||
bi.order = order;
|
||||
bi.slotId = 0;
|
||||
bi.slotId = tsTargetSlotId;
|
||||
bi.nullFirst = NULL_ORDER_FIRST;
|
||||
|
||||
taosArrayPush(pList, &bi);
|
||||
|
@ -2851,7 +2856,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
|||
|
||||
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);
|
||||
|
||||
int32_t rowSize = pInfo->pResBlock->info.rowSize;
|
||||
|
|
|
@ -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.
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); ++i) {
|
||||
SColumnInfoData* p = taosArrayGet(pBlock->pDataBlock, i);
|
||||
if (p->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
colDataAppend(p, rowIndex, (const char*)&ts, false);
|
||||
if (p->info.type == TSDB_DATA_TYPE_TIMESTAMP) { // handle timestamp
|
||||
colDataAppend(p, rowIndex, (const char*)&ts, false);
|
||||
} else {
|
||||
colDataAppendNULL(p, rowIndex);
|
||||
}
|
||||
|
@ -71,66 +71,76 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
|||
SPoint point1, point2, point;
|
||||
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
||||
|
||||
// set the primary timestamp column value
|
||||
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 primary timestamp column value
|
||||
int32_t index = pFillInfo->numOfCurrent;
|
||||
|
||||
// set the other values
|
||||
if (pFillInfo->type == TSDB_FILL_PREV) {
|
||||
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];
|
||||
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
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) {
|
||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next : pFillInfo->prev;
|
||||
// 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];
|
||||
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
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) {
|
||||
// TODO : linear interpolation supports NULL value
|
||||
if (outOfBound) {
|
||||
setNullRow(pBlock, pFillInfo->currentKey, index);
|
||||
} else {
|
||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int32_t srcSlotId = GET_SRC_SLOT_ID(pCol);
|
||||
|
||||
int32_t dstSlotId = GET_DEST_SLOT_ID(pCol);
|
||||
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);
|
||||
if (IS_VAR_DATA_TYPE(type) || type == TSDB_DATA_TYPE_BOOL || pKey->isNull) {
|
||||
colDataAppendNULL(pDstCol, index);
|
||||
continue;
|
||||
}
|
||||
|
||||
SGroupKeys* pKey1 = taosArrayGet(pFillInfo->prev, 0);
|
||||
int64_t prevTs = *(int64_t*)pKey1->pData;
|
||||
SGroupKeys* pKey1 = taosArrayGet(pFillInfo->prev, pFillInfo->tsSlotId);
|
||||
|
||||
int64_t prevTs = *(int64_t*)pKey1->pData;
|
||||
int32_t srcSlotId = GET_SRC_SLOT_ID(pCol);
|
||||
|
||||
SColumnInfoData* pSrcCol = taosArrayGet(pSrcBlock->pDataBlock, srcSlotId);
|
||||
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
|
||||
setNullRow(pBlock, pFillInfo->currentKey, index);
|
||||
} 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];
|
||||
if (TSDB_COL_IS_TAG(pCol->flag) /* || IS_VAR_DATA_TYPE(pCol->schema.type)*/) {
|
||||
continue;
|
||||
|
@ -171,6 +181,8 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
|||
colDataAppend(pDst, index, (char*)&v, false);
|
||||
} else if (pDst->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
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) {
|
||||
pFillInfo->numOfCurrent = 0;
|
||||
|
||||
// todo make sure the first column is always the primary timestamp column?
|
||||
SColumnInfoData* pTsCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, 0);
|
||||
SColumnInfoData* pTsCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, pFillInfo->tsSlotId);
|
||||
|
||||
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
||||
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);
|
||||
|
||||
if (pFillInfo->type == TSDB_FILL_NEXT && (pFillInfo->index + 1) < pFillInfo->numOfRows) {
|
||||
++pFillInfo->index;
|
||||
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pFillInfo->next);
|
||||
--pFillInfo->index;
|
||||
int32_t nextRowIndex = pFillInfo->index + 1;
|
||||
copyCurrentRowIntoBuf(pFillInfo, nextRowIndex, pFillInfo->next);
|
||||
}
|
||||
|
||||
// assign rows to dst buffer
|
||||
|
|
|
@ -1600,7 +1600,7 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ extern "C" {
|
|||
#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_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)
|
||||
|
||||
|
|
|
@ -2784,28 +2784,38 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_qstartts",
|
||||
.type = FUNCTION_TYPE_QSTARTTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.name = "_qstart",
|
||||
.type = FUNCTION_TYPE_QSTART,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_CLIENT_PC_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = qStartTsFunction,
|
||||
.sprocessFunc = NULL,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_qendts",
|
||||
.type = FUNCTION_TYPE_QENDTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.name = "_qend",
|
||||
.type = FUNCTION_TYPE_QEND,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_CLIENT_PC_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = qEndTsFunction,
|
||||
.sprocessFunc = NULL,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_wstartts",
|
||||
.type = FUNCTION_TYPE_WSTARTTS,
|
||||
.name = "_qduration",
|
||||
.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,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
|
@ -2814,8 +2824,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_wendts",
|
||||
.type = FUNCTION_TYPE_WENDTS,
|
||||
.name = "_wend",
|
||||
.type = FUNCTION_TYPE_WEND,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
|
|
|
@ -80,11 +80,12 @@ typedef struct STopBotRes {
|
|||
} STopBotRes;
|
||||
|
||||
typedef struct SFirstLastRes {
|
||||
bool hasResult;
|
||||
bool hasResult;
|
||||
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
||||
// this attribute is required
|
||||
bool isNull;
|
||||
bool isNull;
|
||||
int32_t bytes;
|
||||
int64_t ts;
|
||||
char buf[];
|
||||
} SFirstLastRes;
|
||||
|
||||
|
@ -2951,6 +2952,7 @@ int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
|
||||
SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pResInfo);
|
||||
colDataAppend(pCol, pBlock->info.rows, pRes->buf, pRes->isNull||pResInfo->isNullRes);
|
||||
|
||||
// handle selectivity
|
||||
STuplePos* pTuplePos = (STuplePos*)(pRes->buf + pRes->bytes + sizeof(TSKEY));
|
||||
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) {
|
||||
SFilePage* pPage = NULL;
|
||||
|
||||
// todo refactor: move away
|
||||
int32_t completeRowSize = pCtx->subsidiaries.num * sizeof(bool);
|
||||
for (int32_t j = 0; j < pCtx->subsidiaries.num; ++j) {
|
||||
SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j];
|
||||
|
@ -3474,12 +3483,15 @@ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS
|
|||
} else {
|
||||
pPage = getBufPage(pCtx->pBuf, pCtx->curBufPage);
|
||||
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->num = sizeof(SFilePage);
|
||||
}
|
||||
}
|
||||
|
||||
pPos->pageId = pCtx->curBufPage;
|
||||
pPos->offset = pPage->num;
|
||||
|
||||
// keep the current row data, extract method
|
||||
int32_t offset = 0;
|
||||
|
@ -3507,7 +3519,6 @@ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS
|
|||
offset += pCol->info.bytes;
|
||||
}
|
||||
|
||||
pPos->offset = pPage->num;
|
||||
pPage->num += completeRowSize;
|
||||
|
||||
setBufPageDirty(pPage, true);
|
||||
|
@ -4837,7 +4848,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da
|
|||
if (pInfo->numSampled < pInfo->samples) {
|
||||
sampleAssignResult(pInfo, data, pInfo->numSampled);
|
||||
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++;
|
||||
} else {
|
||||
|
@ -4845,7 +4856,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da
|
|||
if (j < pInfo->samples) {
|
||||
sampleAssignResult(pInfo, data, j);
|
||||
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;
|
||||
for (int32_t i = 0; i < pInfo->numSampled; ++i) {
|
||||
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;
|
||||
|
@ -5557,6 +5568,10 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
|
||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
||||
|
||||
if (pData->totalRows == 0) {
|
||||
pData->minRows = 0;
|
||||
}
|
||||
|
||||
int32_t row = 0;
|
||||
char st[256] = {0};
|
||||
double totalRawSize = pData->totalRows * pData->rowSize;
|
||||
|
@ -5568,10 +5583,14 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
varDataSetLen(st, len);
|
||||
colDataAppend(pColInfo, row++, st, false);
|
||||
|
||||
int64_t avgRows = 0;
|
||||
if (pData->numOfBlocks > 0) {
|
||||
avgRows = pData->totalRows / pData->numOfBlocks;
|
||||
}
|
||||
|
||||
len = sprintf(st + VARSTR_HEADER_SIZE,
|
||||
"Total_Rows=[%" PRId64 "] Inmem_Rows=[%d] MinRows=[%d] MaxRows=[%d] Average_Rows=[%" PRId64 "]",
|
||||
pData->totalRows, pData->numOfInmemRows, pData->minRows, pData->maxRows,
|
||||
pData->totalRows / pData->numOfBlocks);
|
||||
pData->totalRows, pData->numOfInmemRows, pData->minRows, pData->maxRows, avgRows);
|
||||
|
||||
varDataSetLen(st, len);
|
||||
colDataAppend(pColInfo, row++, st, false);
|
||||
|
@ -5988,7 +6007,7 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) {
|
|||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||
|
||||
int32_t type = pInputCol->info.type;
|
||||
int32_t type = pInputCol->info.type;
|
||||
int32_t bytes = pInputCol->info.bytes;
|
||||
|
||||
pInfo->bytes = bytes;
|
||||
|
@ -5999,7 +6018,7 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) {
|
|||
|
||||
char* data = colDataGetData(pInputCol, 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)) {
|
||||
pInfo->isNull = true;
|
||||
|
@ -6012,8 +6031,7 @@ int32_t lastrowFunction(SqlFunctionCtx* pCtx) {
|
|||
memcpy(pInfo->buf, data, bytes);
|
||||
}
|
||||
|
||||
*(TSKEY*)(pInfo->buf + bytes) = cts;
|
||||
|
||||
pInfo->ts = cts;
|
||||
pInfo->hasResult = true;
|
||||
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 fmIsClientPseudoColumnFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_CLIENT_PC_FUNC); }
|
||||
|
||||
bool fmIsInterpFunc(int32_t funcId) {
|
||||
if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
||||
return false;
|
||||
|
@ -227,8 +229,8 @@ bool fmIsInvertible(int32_t funcId) {
|
|||
case FUNCTION_TYPE_SUM:
|
||||
case FUNCTION_TYPE_STDDEV:
|
||||
case FUNCTION_TYPE_AVG:
|
||||
case FUNCTION_TYPE_WSTARTTS:
|
||||
case FUNCTION_TYPE_WENDTS:
|
||||
case FUNCTION_TYPE_WSTART:
|
||||
case FUNCTION_TYPE_WEND:
|
||||
case FUNCTION_TYPE_WDURATION:
|
||||
res = true;
|
||||
break;
|
||||
|
|
|
@ -296,8 +296,8 @@ void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
|||
|
||||
switch (call->callType) {
|
||||
case TSDB_UDF_CALL_SCALA_PROC: {
|
||||
tDeleteSSDataBlock(&call->block);
|
||||
tDeleteSSDataBlock(&subRsp->resultData);
|
||||
blockDataFreeRes(&call->block);
|
||||
blockDataFreeRes(&subRsp->resultData);
|
||||
break;
|
||||
}
|
||||
case TSDB_UDF_CALL_AGG_INIT: {
|
||||
|
@ -305,7 +305,7 @@ void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
|||
break;
|
||||
}
|
||||
case TSDB_UDF_CALL_AGG_PROC: {
|
||||
tDeleteSSDataBlock(&call->block);
|
||||
blockDataFreeRes(&call->block);
|
||||
freeUdfInterBuf(&subRsp->resultBuf);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -127,6 +127,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
|||
COPY_SCALAR_FIELD(isDuration);
|
||||
COPY_SCALAR_FIELD(translate);
|
||||
COPY_SCALAR_FIELD(notReserved);
|
||||
COPY_SCALAR_FIELD(isNull);
|
||||
COPY_SCALAR_FIELD(placeholderNo);
|
||||
COPY_SCALAR_FIELD(typeData);
|
||||
COPY_SCALAR_FIELD(unit);
|
||||
|
|
|
@ -225,6 +225,8 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "PhysiBlockDistScan";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN:
|
||||
return "PhysiLastRowScan";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN:
|
||||
return "PhysiTableMergeScan";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
|
||||
return "PhysiProject";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN:
|
||||
|
@ -2712,6 +2714,7 @@ static const char* jkValueLiteral = "Literal";
|
|||
static const char* jkValueDuration = "Duration";
|
||||
static const char* jkValueTranslate = "Translate";
|
||||
static const char* jkValueNotReserved = "NotReserved";
|
||||
static const char* jkValueIsNull = "IsNull";
|
||||
static const char* jkValueDatum = "Datum";
|
||||
|
||||
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) {
|
||||
code = tjsonAddBoolToObject(pJson, jkValueNotReserved, pNode->notReserved);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddBoolToObject(pJson, jkValueIsNull, pNode->isNull);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && pNode->translate) {
|
||||
code = datumToJson(pNode, pJson);
|
||||
}
|
||||
|
@ -2945,6 +2951,9 @@ static int32_t jsonToValueNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBoolValue(pJson, jkValueNotReserved, &pNode->notReserved);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBoolValue(pJson, jkValueIsNull, &pNode->isNull);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && pNode->translate) {
|
||||
code = jsonToDatum(pJson, pNode);
|
||||
}
|
||||
|
|
|
@ -956,7 +956,6 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
}
|
||||
case QUERY_NODE_PHYSICAL_SUBPLAN: {
|
||||
SSubplan* pSubplan = (SSubplan*)pNode;
|
||||
// nodesDestroyList(pSubplan->pChildren);
|
||||
nodesClearList(pSubplan->pChildren);
|
||||
nodesDestroyNode((SNode*)pSubplan->pNode);
|
||||
nodesDestroyNode((SNode*)pSubplan->pDataSink);
|
||||
|
@ -965,25 +964,9 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
nodesClearList(pSubplan->pParents);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN: {
|
||||
SQueryPlan* pPlan = (SQueryPlan*)pNode;
|
||||
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);
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN:
|
||||
nodesDestroyList(((SQueryPlan*)pNode)->pSubplans);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1709,6 +1692,11 @@ int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots) {
|
|||
}
|
||||
|
||||
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->nLen = pNode->node.resType.bytes;
|
||||
switch (pNode->node.resType.type) {
|
||||
|
@ -1789,7 +1777,7 @@ static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) {
|
|||
SClassifyConditionCxt* pCxt = (SClassifyConditionCxt*)pContext;
|
||||
if (QUERY_NODE_COLUMN == nodeType(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;
|
||||
} else if (pCol->hasIndex) {
|
||||
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; }
|
||||
|
||||
/************************************************ 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(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) ::= 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) ::= QSTARTTS(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) ::= WSTARTTS(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) ::= QSTART(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) ::= QDURATION(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)); }
|
||||
|
||||
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);
|
||||
CHECK_OUT_OF_MEM(fill->pWStartTs);
|
||||
}
|
||||
strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstartts");
|
||||
strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstart");
|
||||
return (SNode*)fill;
|
||||
}
|
||||
|
||||
|
@ -740,6 +740,7 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr
|
|||
select->pFromTable = pTable;
|
||||
sprintf(select->stmtName, "%p", select);
|
||||
select->isTimeLineResult = true;
|
||||
select->timeRange = TSWINDOW_INITIALIZER;
|
||||
return (SNode*)select;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ typedef struct SInsertParseContext {
|
|||
SVnodeModifOpStmt* pOutput;
|
||||
SStmtCallback* pStmtCb;
|
||||
SParseMetaCache* pMetaCache;
|
||||
char sTableName[TSDB_TABLE_NAME_LEN];
|
||||
} SInsertParseContext;
|
||||
|
||||
typedef struct SInsertParseSyntaxCxt {
|
||||
|
@ -734,11 +735,13 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
|
|||
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->name = strdup(tname);
|
||||
pTbReq->ctb.suid = suid;
|
||||
if(sname) pTbReq->ctb.name = strdup(sname);
|
||||
pTbReq->ctb.pTag = (uint8_t*)pTag;
|
||||
pTbReq->ctb.tagName = taosArrayDup(tagName);
|
||||
pTbReq->commentLen = -1;
|
||||
|
||||
return;
|
||||
|
@ -758,6 +761,7 @@ static int32_t parseTagToken(char** end, SToken* pToken, SSchema* pSchema, int16
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// strcpy(val->colName, pSchema->name);
|
||||
val->cid = pSchema->colId;
|
||||
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) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SArray* pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal));
|
||||
SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||
SToken sToken;
|
||||
bool isParseBindParam = false;
|
||||
bool isJson = false;
|
||||
|
@ -965,6 +970,10 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
|
|||
taosMemoryFree(tmpTokenBuf);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!isNullStr(&sToken)) {
|
||||
taosArrayPush(tagName, pTagSchema->name);
|
||||
}
|
||||
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
||||
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);
|
||||
|
@ -1004,7 +1013,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
|
|||
goto end;
|
||||
}
|
||||
|
||||
buildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid);
|
||||
buildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid, pCxt->sTableName, tagName);
|
||||
|
||||
end:
|
||||
for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) {
|
||||
|
@ -1014,6 +1023,7 @@ end:
|
|||
}
|
||||
}
|
||||
taosArrayDestroy(pTagVals);
|
||||
taosArrayDestroy(tagName);
|
||||
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);
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(&sname, dbFName);
|
||||
strcpy(pCxt->sTableName, sname.tname);
|
||||
|
||||
CHECK_CODE(getSTableMeta(pCxt, &sname, dbFName));
|
||||
if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) {
|
||||
|
@ -1325,15 +1336,10 @@ static int32_t parseDataFromFile(SInsertParseContext* pCxt, SToken filePath, STa
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void destroyCreateSubTbReq(SVCreateTbReq* pReq) {
|
||||
taosMemoryFreeClear(pReq->name);
|
||||
taosMemoryFreeClear(pReq->ctb.pTag);
|
||||
}
|
||||
|
||||
static void destroyInsertParseContextForTable(SInsertParseContext* pCxt) {
|
||||
taosMemoryFreeClear(pCxt->pTableMeta);
|
||||
destroyBoundColumnInfo(&pCxt->tags);
|
||||
destroyCreateSubTbReq(&pCxt->createTblReq);
|
||||
tdDestroySVCreateTbReq(&pCxt->createTblReq);
|
||||
}
|
||||
|
||||
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));
|
||||
(*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));
|
||||
pCxt->pVgroupsHashObj = NULL;
|
||||
|
@ -1508,6 +1514,7 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache
|
|||
.pSql = (char*)pContext->pSql,
|
||||
.msg = {.buf = pContext->pMsg, .len = pContext->msgLen},
|
||||
.pTableMeta = NULL,
|
||||
.createTblReq = {0},
|
||||
.pSubTableHashObj = 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),
|
||||
|
@ -1788,7 +1795,7 @@ int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash
|
|||
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) {
|
||||
STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock;
|
||||
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");
|
||||
}
|
||||
|
||||
SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||
if (!tagName) {
|
||||
return buildInvalidOperationMsg(&pBuf, "out of memory");
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
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)) {
|
||||
colLen = bind[c].length[0];
|
||||
}
|
||||
taosArrayPush(tagName, pTagSchema->name);
|
||||
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
||||
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);
|
||||
|
@ -1834,6 +1847,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN
|
|||
}
|
||||
} else {
|
||||
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
||||
// strcpy(val.colName, pTagSchema->name);
|
||||
if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) {
|
||||
val.pData = (uint8_t*)bind[c].buffer;
|
||||
val.nData = colLen;
|
||||
|
@ -1870,9 +1884,9 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN
|
|||
}
|
||||
|
||||
SVCreateTbReq tbReq = {0};
|
||||
buildCreateTbReq(&tbReq, tName, pTag, suid);
|
||||
buildCreateTbReq(&tbReq, tName, pTag, suid, sTableName, tagName);
|
||||
code = buildCreateTbMsg(pDataBlock, &tbReq);
|
||||
destroyCreateSubTbReq(&tbReq);
|
||||
tdDestroySVCreateTbReq(&tbReq);
|
||||
|
||||
end:
|
||||
for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) {
|
||||
|
@ -1882,6 +1896,7 @@ end:
|
|||
}
|
||||
}
|
||||
taosArrayDestroy(pTagArray);
|
||||
taosArrayDestroy(tagName);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -2136,7 +2151,7 @@ typedef struct SmlExecHandle {
|
|||
static void smlDestroyTableHandle(void* pHandle) {
|
||||
SmlExecTableHandle* handle = (SmlExecTableHandle*)pHandle;
|
||||
destroyBoundColumnInfo(&handle->tags);
|
||||
destroyCreateSubTbReq(&handle->createTblReq);
|
||||
tdDestroySVCreateTbReq(&handle->createTblReq);
|
||||
}
|
||||
|
||||
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
|
||||
* @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));
|
||||
if (!pTagArray) {
|
||||
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;
|
||||
for (int i = 0; i < tags->numOfBound; ++i) {
|
||||
SSchema* pTagSchema = &pSchema[tags->boundColumns[i]];
|
||||
SSmlKv* kv = taosArrayGetP(cols, i);
|
||||
|
||||
taosArrayPush(*tagName, pTagSchema->name);
|
||||
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
||||
// strcpy(val.colName, pTagSchema->name);
|
||||
if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) {
|
||||
val.pData = (uint8_t*)kv->value;
|
||||
val.nData = kv->length;
|
||||
|
@ -2277,7 +2298,7 @@ end:
|
|||
}
|
||||
|
||||
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};
|
||||
|
||||
SSmlExecHandle* smlHandle = (SSmlExecHandle*)handle;
|
||||
|
@ -2290,12 +2311,19 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
|
|||
return ret;
|
||||
}
|
||||
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) {
|
||||
taosArrayDestroy(tagName);
|
||||
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;
|
||||
ret = getDataBlockFromList(smlHandle->pBlockHash, &pTableMeta->uid, sizeof(pTableMeta->uid),
|
||||
|
|
|
@ -240,12 +240,13 @@ static SKeyword keywordTable[] = {
|
|||
{"WITH", TK_WITH},
|
||||
{"WRITE", TK_WRITE},
|
||||
{"_C0", TK_ROWTS},
|
||||
{"_QENDTS", TK_QENDTS},
|
||||
{"_QSTARTTS", TK_QSTARTTS},
|
||||
{"_QDURATION", TK_QDURATION},
|
||||
{"_QEND", TK_QEND},
|
||||
{"_QSTART", TK_QSTART},
|
||||
{"_ROWTS", TK_ROWTS},
|
||||
{"_WDURATION", TK_WDURATION},
|
||||
{"_WENDTS", TK_WENDTS},
|
||||
{"_WSTARTTS", TK_WSTARTTS},
|
||||
{"_WEND", TK_WEND},
|
||||
{"_WSTART", TK_WSTART},
|
||||
// {"ID", TK_ID},
|
||||
// {"STRING", TK_STRING},
|
||||
// {"EQ", TK_EQ},
|
||||
|
|
|
@ -496,7 +496,7 @@ static bool isPrimaryKeyImpl(SNode* pExpr) {
|
|||
SFunctionNode* pFunc = (SFunctionNode*)pExpr;
|
||||
if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1197,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);
|
||||
if (NULL == pVal) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1228,7 +1228,7 @@ static int32_t rewriteDatabaseFunc(STranslateContext* pCxt, SNode** pNode) {
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
return rewriteSystemInfoFuncImpl(pCxt, pCurrDb, pNode);
|
||||
return rewriteFuncToValue(pCxt, pCurrDb, pNode);
|
||||
}
|
||||
|
||||
static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||
|
@ -1236,7 +1236,7 @@ static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) {
|
|||
if (NULL == pVer) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
return rewriteSystemInfoFuncImpl(pCxt, pVer, pNode);
|
||||
return rewriteFuncToValue(pCxt, pVer, pNode);
|
||||
}
|
||||
|
||||
static int32_t rewriteServerVersionFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||
|
@ -1244,7 +1244,7 @@ static int32_t rewriteServerVersionFunc(STranslateContext* pCxt, SNode** pNode)
|
|||
if (NULL == pVer) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
return rewriteSystemInfoFuncImpl(pCxt, pVer, pNode);
|
||||
return rewriteFuncToValue(pCxt, pVer, pNode);
|
||||
}
|
||||
|
||||
static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||
|
@ -1252,7 +1252,7 @@ static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) {
|
|||
return TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||
}
|
||||
char* pStatus = taosMemoryStrDup((void*)"1");
|
||||
return rewriteSystemInfoFuncImpl(pCxt, pStatus, pNode);
|
||||
return rewriteFuncToValue(pCxt, pStatus, pNode);
|
||||
}
|
||||
|
||||
static int32_t rewriteUserFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||
|
@ -1263,7 +1263,7 @@ static int32_t rewriteUserFunc(STranslateContext* pCxt, SNode** pNode) {
|
|||
if (NULL == pUserConn) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
return rewriteSystemInfoFuncImpl(pCxt, pUserConn, pNode);
|
||||
return rewriteFuncToValue(pCxt, pUserConn, pNode);
|
||||
}
|
||||
|
||||
static int32_t rewriteSystemInfoFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||
|
@ -1317,10 +1317,60 @@ static int32_t translateNoramlFunction(STranslateContext* pCxt, SFunctionNode* p
|
|||
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) {
|
||||
if (fmIsSystemInfoFunc((*pFunc)->funcId)) {
|
||||
return rewriteSystemInfoFunc(pCxt, (SNode**)pFunc);
|
||||
}
|
||||
if (fmIsClientPseudoColumnFunc((*pFunc)->funcId)) {
|
||||
return rewriteClientPseudoColumnFunc(pCxt, (SNode**)pFunc);
|
||||
}
|
||||
return translateNoramlFunction(pCxt, *pFunc);
|
||||
}
|
||||
|
||||
|
@ -2077,7 +2127,7 @@ static int32_t getTimeRange(SNode** pPrimaryKeyCond, STimeWindow* pTimeRange, bo
|
|||
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) {
|
||||
*pTimeRange = TSWINDOW_INITIALIZER;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -2138,16 +2188,13 @@ static int32_t checkFill(STranslateContext* pCxt, SFillNode* pFill, SValueNode*
|
|||
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) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t code = getFillTimeRange(pCxt, pWhere, &(((SFillNode*)pInterval->pFill)->timeRange));
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkFill(pCxt, (SFillNode*)pInterval->pFill, (SValueNode*)pInterval->pInterval);
|
||||
}
|
||||
return code;
|
||||
((SFillNode*)pInterval->pFill)->timeRange = pSelect->timeRange;
|
||||
return checkFill(pCxt, (SFillNode*)pInterval->pFill, (SValueNode*)pInterval->pInterval);
|
||||
}
|
||||
|
||||
static int64_t getMonthsFromTimeVal(int64_t val, int32_t fromPrecision, char unit) {
|
||||
|
@ -2234,7 +2281,7 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
|
|||
static int32_t translateIntervalWindow(STranslateContext* pCxt, SSelectStmt* pSelect, SIntervalWindowNode* pInterval) {
|
||||
int32_t code = checkIntervalWindow(pCxt, pInterval);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateFill(pCxt, pSelect->pWhere, pInterval);
|
||||
code = translateFill(pCxt, pSelect, pInterval);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -2329,7 +2376,7 @@ static int32_t translateInterpFill(STranslateContext* pCxt, SSelectStmt* pSelect
|
|||
code = translateExpr(pCxt, &pSelect->pFill);
|
||||
}
|
||||
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) {
|
||||
code = checkFill(pCxt, (SFillNode*)pSelect->pFill, (SValueNode*)pSelect->pEvery);
|
||||
|
@ -2361,9 +2408,13 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SNodeList* pPartiti
|
|||
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;
|
||||
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) {
|
||||
|
@ -2494,7 +2545,7 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
|
|||
int32_t code = translateFrom(pCxt, pSelect->pFromTable);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pSelect->precision = ((STableNode*)pSelect->pFromTable)->precision;
|
||||
code = translateWhere(pCxt, &pSelect->pWhere);
|
||||
code = translateWhere(pCxt, pSelect);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translatePartitionBy(pCxt, pSelect->pPartitionByList);
|
||||
|
@ -2680,7 +2731,8 @@ static int32_t partitionDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelet
|
|||
}
|
||||
|
||||
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) {
|
||||
code = partitionDeleteWhere(pCxt, pDelete);
|
||||
}
|
||||
|
@ -3507,7 +3559,7 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch
|
|||
nodesDestroyNode((SNode*)pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(pFunc->functionName, "_wstartts");
|
||||
strcpy(pFunc->functionName, "_wstart");
|
||||
nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
|
||||
SNode* pProject = NULL;
|
||||
FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); }
|
||||
|
@ -3702,6 +3754,9 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
|
|||
pReq->delay2 = pStmt->pOptions->maxDelay2;
|
||||
pReq->watermark1 = pStmt->pOptions->watermark1;
|
||||
pReq->watermark2 = pStmt->pOptions->watermark2;
|
||||
pReq->colVer = 1;
|
||||
pReq->tagVer = 1;
|
||||
pReq->source = TD_REQ_FROM_APP;
|
||||
columnDefNodeToField(pStmt->pCols, &pReq->pColumns);
|
||||
columnDefNodeToField(pStmt->pTags, &pReq->pTags);
|
||||
pReq->numOfColumns = LIST_LENGTH(pStmt->pCols);
|
||||
|
@ -4333,14 +4388,14 @@ static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
|
|||
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
||||
SNode* pProj = nodesListGetNode(pSelect->pProjectionList, 0);
|
||||
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;
|
||||
}
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pFunc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(pFunc->functionName, "_wstartts");
|
||||
strcpy(pFunc->functionName, "_wstart");
|
||||
strcpy(pFunc->node.aliasName, pFunc->functionName);
|
||||
int32_t code = nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
|
@ -5285,6 +5340,8 @@ static void destroyCreateTbReqBatch(void* data) {
|
|||
taosMemoryFreeClear(pTableReq->ntb.schemaRow.pSchema);
|
||||
} else if (pTableReq->type == TSDB_CHILD_TABLE) {
|
||||
taosMemoryFreeClear(pTableReq->ctb.pTag);
|
||||
taosMemoryFreeClear(pTableReq->ctb.name);
|
||||
taosArrayDestroy(pTableReq->ctb.tagName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5356,11 +5413,11 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
}
|
||||
|
||||
static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, SCreateSubTableClause* pStmt,
|
||||
const STag* pTag, uint64_t suid, SVgroupInfo* pVgInfo) {
|
||||
// char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
// SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId};
|
||||
// strcpy(name.dbname, pStmt->dbName);
|
||||
// tNameGetFullDbName(&name, dbFName);
|
||||
const STag* pTag, uint64_t suid, const char* sTableNmae, SVgroupInfo* pVgInfo, SArray* tagName) {
|
||||
// char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
// SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId};
|
||||
// strcpy(name.dbname, pStmt->dbName);
|
||||
// tNameGetFullDbName(&name, dbFName);
|
||||
|
||||
struct SVCreateTbReq req = {0};
|
||||
req.type = TD_CHILD_TABLE;
|
||||
|
@ -5373,7 +5430,9 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S
|
|||
req.commentLen = -1;
|
||||
}
|
||||
req.ctb.suid = suid;
|
||||
req.ctb.name = strdup(sTableNmae);
|
||||
req.ctb.pTag = (uint8_t*)pTag;
|
||||
req.ctb.tagName = taosArrayDup(tagName);
|
||||
if (pStmt->ignoreExists) {
|
||||
req.flags |= TD_CREATE_IF_NOT_EXISTS;
|
||||
}
|
||||
|
@ -5465,6 +5524,7 @@ static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, S
|
|||
if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) {
|
||||
void* nodeVal = nodesGetValueFromNode(pVal);
|
||||
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
||||
// strcpy(val.colName, pTagSchema->name);
|
||||
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
||||
val.pData = varDataVal(nodeVal);
|
||||
val.nData = varDataLen(nodeVal);
|
||||
|
@ -5477,7 +5537,7 @@ static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, S
|
|||
}
|
||||
|
||||
static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta,
|
||||
STag** ppTag) {
|
||||
STag** ppTag, SArray* tagName) {
|
||||
int32_t numOfTags = getNumOfTags(pSuperTableMeta);
|
||||
if (LIST_LENGTH(pStmt->pValsOfTags) != LIST_LENGTH(pStmt->pSpecificTags) ||
|
||||
numOfTags < LIST_LENGTH(pStmt->pValsOfTags)) {
|
||||
|
@ -5508,8 +5568,10 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
|
|||
if (pSchema->type == TSDB_DATA_TYPE_JSON) {
|
||||
isJson = true;
|
||||
code = buildJsonTagVal(pCxt, pSchema, pVal, pTagArray, ppTag);
|
||||
taosArrayPush(tagName, pCol->colName);
|
||||
} else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) {
|
||||
code = buildNormalTagVal(pCxt, pSchema, pVal, pTagArray);
|
||||
taosArrayPush(tagName, pCol->colName);
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -5530,7 +5592,7 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
|
|||
}
|
||||
|
||||
static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta,
|
||||
STag** ppTag) {
|
||||
STag** ppTag, SArray* tagName) {
|
||||
if (getNumOfTags(pSuperTableMeta) != LIST_LENGTH(pStmt->pValsOfTags)) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TAGS_NOT_MATCHED);
|
||||
}
|
||||
|
@ -5555,9 +5617,11 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
|
|||
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
||||
isJson = true;
|
||||
code = buildJsonTagVal(pCxt, pTagSchema, pVal, pTagArray, ppTag);
|
||||
taosArrayPush(tagName, pTagSchema->name);
|
||||
} else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) {
|
||||
char* tmpVal = nodesGetValueFromNode(pVal);
|
||||
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
||||
// strcpy(val.colName, pTagSchema->name);
|
||||
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
||||
val.pData = varDataVal(tmpVal);
|
||||
val.nData = varDataLen(tmpVal);
|
||||
|
@ -5565,6 +5629,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
|
|||
memcpy(&val.i64, tmpVal, pTagSchema->bytes);
|
||||
}
|
||||
taosArrayPush(pTagArray, &val);
|
||||
taosArrayPush(tagName, pTagSchema->name);
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -5600,12 +5665,13 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
|
|||
}
|
||||
|
||||
STag* pTag = NULL;
|
||||
SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL != pStmt->pSpecificTags) {
|
||||
code = buildKVRowForBindTags(pCxt, pStmt, pSuperTableMeta, &pTag);
|
||||
code = buildKVRowForBindTags(pCxt, pStmt, pSuperTableMeta, &pTag, tagName);
|
||||
} else {
|
||||
code = buildKVRowForAllTags(pCxt, pStmt, pSuperTableMeta, &pTag);
|
||||
code = buildKVRowForAllTags(pCxt, pStmt, pSuperTableMeta, &pTag, tagName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5614,9 +5680,10 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
|
|||
code = getTableHashVgroup(pCxt, pStmt->dbName, pStmt->tableName, &info);
|
||||
}
|
||||
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);
|
||||
return code;
|
||||
}
|
||||
|
@ -5831,9 +5898,8 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
|||
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) {
|
||||
pReq->isNull = 0;
|
||||
if (pStmt->pVal->literal &&
|
||||
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);
|
||||
|
@ -5861,6 +5927,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
|||
pReq->pTagVal = (uint8_t*)pTag;
|
||||
pStmt->pVal->datum.p = (char*)pTag; // for free
|
||||
} else {
|
||||
pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type);
|
||||
pReq->nTagVal = pStmt->pVal->node.resType.bytes;
|
||||
pReq->pTagVal = nodesGetValueFromNode(pStmt->pVal);
|
||||
|
||||
|
@ -5887,7 +5954,8 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S
|
|||
|
||||
pReq->type = pStmt->dataType.type;
|
||||
pReq->flags = COL_SMA_ON;
|
||||
pReq->bytes = pStmt->dataType.bytes;
|
||||
// pReq->bytes = pStmt->dataType.bytes;
|
||||
pReq->bytes = calcTypeBytes(pStmt->dataType);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -5914,7 +5982,7 @@ static int32_t buildDropColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt,
|
|||
static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
|
||||
SVAlterTbReq* pReq) {
|
||||
pReq->colModBytes = calcTypeBytes(pStmt->dataType);
|
||||
|
||||
pReq->colModType = pStmt->dataType.type;
|
||||
SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName);
|
||||
if (NULL == pSchema) {
|
||||
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:
|
||||
return "%s function is not supported in fill query";
|
||||
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:
|
||||
return "%s function is not supported in time window query";
|
||||
case TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC:
|
||||
|
@ -389,6 +389,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
|
|||
continue;
|
||||
}
|
||||
STagVal val = {0};
|
||||
// strcpy(val.colName, colName);
|
||||
val.pKey = jsonKey;
|
||||
taosHashPut(keyHash, jsonKey, keyLen, &keyLen,
|
||||
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) {
|
||||
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) {
|
||||
|
@ -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 "
|
||||
"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);
|
||||
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) {
|
||||
|
@ -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, _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, _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)");
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) {
|
|||
strcpy(pCol->node.aliasName, pToBeRewrittenExpr->aliasName);
|
||||
strcpy(pCol->colName, ((SExprNode*)pExpr)->aliasName);
|
||||
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;
|
||||
} else if (FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pExpr)->funcType) {
|
||||
pCol->colType = COLUMN_TYPE_TBNAME;
|
||||
|
|
|
@ -795,15 +795,15 @@ static EDealRes rewriteAggGroupKeyCondForPushDownImpl(SNode** pNode, void* pCont
|
|||
if (0 == strcmp(((SExprNode*)pGroup)->aliasName, ((SColumnNode*)(*pNode))->colName)) {
|
||||
SNode* pExpr = nodesCloneNode(pGroup);
|
||||
if (pExpr == NULL) {
|
||||
pCxt->errCode = terrno;
|
||||
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = pExpr;
|
||||
return DEAL_RES_IGNORE_CHILD;
|
||||
}
|
||||
}
|
||||
}
|
||||
return DEAL_RES_IGNORE_CHILD;
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
@ -864,16 +864,16 @@ static EDealRes rewriteProjectCondForPushDownImpl(SNode** ppNode, void* pContext
|
|||
if (0 == strcmp(((SExprNode*)pProjection)->aliasName, ((SColumnNode*)(*ppNode))->colName)) {
|
||||
SNode* pExpr = nodesCloneNode(pProjection);
|
||||
if (pExpr == NULL) {
|
||||
pCxt->errCode = terrno;
|
||||
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
nodesDestroyNode(*ppNode);
|
||||
*ppNode = pExpr;
|
||||
return DEAL_RES_IGNORE_CHILD;
|
||||
} // end if expr alias name equal column name
|
||||
} // end for each project
|
||||
} // end if target node equals cond column node
|
||||
} // end for each targets
|
||||
return DEAL_RES_IGNORE_CHILD;
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
@ -1211,7 +1211,7 @@ static int32_t smaIndexOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNo
|
|||
int32_t smaFuncIndex = -1;
|
||||
*pWStrartIndex = -1;
|
||||
FOREACH(pFunc, pFuncs) {
|
||||
if (FUNCTION_TYPE_WSTARTTS == ((SFunctionNode*)pFunc)->funcType) {
|
||||
if (FUNCTION_TYPE_WSTART == ((SFunctionNode*)pFunc)->funcType) {
|
||||
*pWStrartIndex = index;
|
||||
}
|
||||
smaFuncIndex = smaIndexOptFindSmaFunc(pFunc, pSmaFuncs);
|
||||
|
@ -1255,7 +1255,7 @@ static SNode* smaIndexOptCreateWStartTs() {
|
|||
if (NULL == pWStart) {
|
||||
return NULL;
|
||||
}
|
||||
strcpy(pWStart->functionName, "_wstartts");
|
||||
strcpy(pWStart->functionName, "_wstart");
|
||||
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart);
|
||||
if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pWStart, NULL, 0)) {
|
||||
nodesDestroyNode((SNode*)pWStart);
|
||||
|
@ -2057,11 +2057,11 @@ static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) {
|
|||
((SExprNode*)*pNode)->aliasName);
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = pExpr;
|
||||
return DEAL_RES_IGNORE_CHILD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return DEAL_RES_IGNORE_CHILD;
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
@ -2103,11 +2103,12 @@ static bool tagScanMayBeOptimized(SLogicNode* pNode) {
|
|||
if (QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(pNode) || (SCAN_TYPE_TAG == ((SScanLogicNode*)pNode)->scanType)) {
|
||||
return false;
|
||||
}
|
||||
SScanLogicNode *pScan = (SScanLogicNode*)pNode;
|
||||
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
||||
if (NULL != pScan->pScanCols) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -308,7 +308,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) {
|
|||
int32_t index = 0;
|
||||
SNode* pFunc = NULL;
|
||||
FOREACH(pFunc, pFuncs) {
|
||||
if (FUNCTION_TYPE_WSTARTTS == ((SFunctionNode*)pFunc)->funcType) {
|
||||
if (FUNCTION_TYPE_WSTART == ((SFunctionNode*)pFunc)->funcType) {
|
||||
*pIndex = index;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) {
|
|||
if (NULL == pWStart) {
|
||||
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);
|
||||
int32_t code = fmGetFuncInfo(pWStart, NULL, 0);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -333,7 +333,7 @@ static int32_t stbSplAppendWEnd(SWindowLogicNode* pWin, int32_t* pIndex) {
|
|||
int32_t index = 0;
|
||||
SNode* pFunc = NULL;
|
||||
FOREACH(pFunc, pWin->pFuncs) {
|
||||
if (FUNCTION_TYPE_WENDTS == ((SFunctionNode*)pFunc)->funcType) {
|
||||
if (FUNCTION_TYPE_WEND == ((SFunctionNode*)pFunc)->funcType) {
|
||||
*pIndex = index;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ static int32_t stbSplAppendWEnd(SWindowLogicNode* pWin, int32_t* pIndex) {
|
|||
if (NULL == pWEnd) {
|
||||
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);
|
||||
int32_t code = fmGetFuncInfo(pWEnd, NULL, 0);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
|
|
@ -137,6 +137,17 @@ TEST_F(PlanBasicTest, sampleFunc) {
|
|||
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) {
|
||||
useDb("root", "test");
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ TEST_F(PlanIntervalTest, basic) {
|
|||
TEST_F(PlanIntervalTest, pseudoCol) {
|
||||
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) {
|
||||
|
@ -59,9 +59,9 @@ TEST_F(PlanIntervalTest, stable) {
|
|||
|
||||
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)");
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ TEST_F(PlanOptimizeTest, sortPrimaryKey) {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -49,7 +49,7 @@ TEST_F(PlanOtherTest, createSmaIndex) {
|
|||
|
||||
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)");
|
||||
|
||||
run("SELECT SUM(c4), MAX(c3) FROM t1 INTERVAL(10s)");
|
||||
|
|
|
@ -223,6 +223,7 @@ typedef struct SSchJobAttr {
|
|||
|
||||
typedef struct {
|
||||
int32_t op;
|
||||
SRWLatch lock;
|
||||
bool syncReq;
|
||||
} 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 schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask);
|
||||
void schDirectPostJobRes(SSchedulerReq* pReq, int32_t errCode);
|
||||
bool schChkCurrentOp(SSchJob *pJob, int32_t op, bool sync);
|
||||
|
||||
extern SSchDebug gSCHDebug;
|
||||
|
||||
|
|
|
@ -443,25 +443,37 @@ int32_t schNotifyUserFetchRes(SSchJob* pJob) {
|
|||
}
|
||||
|
||||
void schPostJobRes(SSchJob *pJob, SCH_OP_TYPE op) {
|
||||
SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||
|
||||
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));
|
||||
return;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
if (op && pJob->opStatus.op != 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)) {
|
||||
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||
tsem_post(&pJob->rspSem);
|
||||
} else if (SCH_JOB_IN_ASYNC_EXEC_OP(pJob)) {
|
||||
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||
schNotifyUserExecRes(pJob);
|
||||
} else if (SCH_JOB_IN_ASYNC_FETCH_OP(pJob)) {
|
||||
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||
schNotifyUserFetchRes(pJob);
|
||||
} else {
|
||||
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||
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) {
|
||||
|
@ -658,13 +670,13 @@ int32_t schJobFetchRows(SSchJob *pJob) {
|
|||
if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC)) {
|
||||
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));
|
||||
tsem_wait(&pJob->rspSem);
|
||||
SCH_RET(schDumpJobFetchRes(pJob, pJob->userRes.fetchRes));
|
||||
}
|
||||
} else {
|
||||
if (pJob->opStatus.syncReq) {
|
||||
if (schChkCurrentOp(pJob, SCH_OP_FETCH, true)) {
|
||||
SCH_RET(schDumpJobFetchRes(pJob, pJob->userRes.fetchRes));
|
||||
} else {
|
||||
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) {
|
||||
int32_t op = 0;
|
||||
|
||||
switch (type) {
|
||||
case SCH_OP_EXEC:
|
||||
if (pReq && pReq->syncReq) {
|
||||
SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||
op = atomic_val_compare_exchange_32(&pJob->opStatus.op, type, SCH_OP_NULL);
|
||||
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_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||
schDumpJobExecRes(pJob, pReq->pExecRes);
|
||||
}
|
||||
break;
|
||||
case SCH_OP_FETCH:
|
||||
if (pReq && pReq->syncReq) {
|
||||
SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||
op = atomic_val_compare_exchange_32(&pJob->opStatus.op, type, SCH_OP_NULL);
|
||||
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_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||
}
|
||||
break;
|
||||
case SCH_OP_GET_STATUS:
|
||||
|
@ -816,8 +840,10 @@ int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq
|
|||
|
||||
switch (type) {
|
||||
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)) {
|
||||
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);
|
||||
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));
|
||||
|
||||
pJob->opStatus.syncReq = pReq->syncReq;
|
||||
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||
break;
|
||||
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)) {
|
||||
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);
|
||||
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->opStatus.syncReq = pReq->syncReq;
|
||||
SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock);
|
||||
|
||||
if (!SCH_JOB_NEED_FETCH(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;
|
||||
}
|
||||
|
||||
/*
|
||||
if (SCH_IS_DATA_BIND_TASK(pTask)) {
|
||||
if ((pTask->execId + 1) >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
|
||||
*needRetry = false;
|
||||
|
@ -522,6 +523,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
*needRetry = true;
|
||||
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);
|
||||
taosFreeQitem(data);
|
||||
} 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);
|
||||
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
||||
streamDataSubmitRefDec((SStreamDataSubmit*)data);
|
||||
|
|
|
@ -313,7 +313,7 @@ int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) {
|
|||
atomic_store_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL);
|
||||
return -1;
|
||||
}
|
||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)tDeleteSSDataBlock);
|
||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
|
||||
taosFreeQitem(pBlock);
|
||||
|
||||
tmsgSendReq(pEpSet, &dispatchMsg);
|
||||
|
|
|
@ -106,7 +106,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
|
|||
qDebug("stream task %d exec end", pTask->taskId);
|
||||
|
||||
if (pTask->taskStatus == TASK_STATUS__DROPPING) {
|
||||
taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock);
|
||||
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
|
|||
qRes->blocks = pRes;
|
||||
if (streamTaskOutput(pTask, qRes) < 0) {
|
||||
/*streamQueueProcessFail(pTask->inputQueue);*/
|
||||
taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock);
|
||||
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||
taosFreeQitem(qRes);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
|
|||
pRes = streamExecForQall(pTask, pRes);
|
||||
if (pRes == NULL) goto FAIL;
|
||||
|
||||
taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock);
|
||||
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||
atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE);
|
||||
qDebug("stream exec, return result");
|
||||
return 0;
|
||||
|
@ -163,7 +163,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
|
|||
continue;
|
||||
} else if (execStatus == TASK_EXEC_STATUS__EXECUTING) {
|
||||
ASSERT(taosArrayGetSize(pRes) == 0);
|
||||
taosArrayDestroyEx(pRes, (FDelete)tDeleteSSDataBlock);
|
||||
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||
return 0;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "ttime.h"
|
||||
|
||||
#define DEFAULT_FALSE_POSITIVE 0.01
|
||||
#define DEFAULT_BUCKET_SIZE 1024
|
||||
#define DEFAULT_BUCKET_SIZE 131072
|
||||
#define ROWS_PER_MILLISECOND 1
|
||||
#define MAX_NUM_SCALABLE_BF 100000
|
||||
#define MIN_NUM_SCALABLE_BF 10
|
||||
|
|
|
@ -431,7 +431,7 @@ static int32_t taosDecRefCount(int32_t rsetId, int64_t rid, int32_t remove) {
|
|||
}
|
||||
released = 1;
|
||||
} 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 {
|
||||
uTrace("rsetId:%d rid:%" PRId64 " is not there, failed to release/remove", rsetId, rid);
|
||||
|
|
|
@ -129,7 +129,7 @@ void *taosProcessSchedQueue(void *scheduler) {
|
|||
while (1) {
|
||||
if ((ret = tsem_wait(&pSched->fullSem)) != 0) {
|
||||
uFatal("wait %s fullSem failed(%s)", pSched->label, strerror(errno));
|
||||
exit(ret);
|
||||
ASSERT(0);
|
||||
}
|
||||
if (pSched->stop) {
|
||||
break;
|
||||
|
@ -137,7 +137,7 @@ void *taosProcessSchedQueue(void *scheduler) {
|
|||
|
||||
if ((ret = taosThreadMutexLock(&pSched->queueMutex)) != 0) {
|
||||
uFatal("lock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
||||
exit(ret);
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
msg = pSched->queue[pSched->fullSlot];
|
||||
|
@ -146,12 +146,12 @@ void *taosProcessSchedQueue(void *scheduler) {
|
|||
|
||||
if ((ret = taosThreadMutexUnlock(&pSched->queueMutex)) != 0) {
|
||||
uFatal("unlock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
||||
exit(ret);
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if ((ret = tsem_post(&pSched->emptySem)) != 0) {
|
||||
uFatal("post %s emptySem failed(%s)", pSched->label, strerror(errno));
|
||||
exit(ret);
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (msg.fp)
|
||||
|
@ -174,12 +174,12 @@ void taosScheduleTask(void *queueScheduler, SSchedMsg *pMsg) {
|
|||
|
||||
if ((ret = tsem_wait(&pSched->emptySem)) != 0) {
|
||||
uFatal("wait %s emptySem failed(%s)", pSched->label, strerror(errno));
|
||||
exit(ret);
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if ((ret = taosThreadMutexLock(&pSched->queueMutex)) != 0) {
|
||||
uFatal("lock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
||||
exit(ret);
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
pSched->queue[pSched->emptySlot] = *pMsg;
|
||||
|
@ -187,12 +187,12 @@ void taosScheduleTask(void *queueScheduler, SSchedMsg *pMsg) {
|
|||
|
||||
if ((ret = taosThreadMutexUnlock(&pSched->queueMutex)) != 0) {
|
||||
uFatal("unlock %s queueMutex failed(%s)", pSched->label, strerror(errno));
|
||||
exit(ret);
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if ((ret = tsem_post(&pSched->fullSem)) != 0) {
|
||||
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;
|
||||
if (pSched == NULL) return;
|
||||
|
||||
uDebug("start to cleanup %s schedQsueue", pSched->label);
|
||||
|
||||
pSched->stop = true;
|
||||
for (int32_t i = 0; i < pSched->numOfThreads; ++i) {
|
||||
if (taosCheckPthreadValid(pSched->qthread[i])) {
|
||||
|
|
|
@ -65,6 +65,7 @@ ulimit -c unlimited
|
|||
|
||||
$TIMEOUT_CMD $cmd
|
||||
RET=$?
|
||||
echo "cmd exit code: $RET"
|
||||
|
||||
if [ $RET -ne 0 ]; then
|
||||
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 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 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('insert into scalar_ct1 values (1653471881952, 100, 100.1, "beijing");')
|
||||
tdSql.execute('insert into scalar_ct1 values (1653471881952+1s, -50, -50.1, "tianjin");')
|
||||
|
|
|
@ -22,23 +22,23 @@ class TDTestCase:
|
|||
tdSql.execute('create table downsampling_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), c4 nchar(20), c5 nchar(20)) tags (t1 int);')
|
||||
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('insert into downsampling_ct1 values (1653547828591, 100, 100.1, "Beijing", True);')
|
||||
tdSql.execute('insert into downsampling_ct1 values (1653547828591+1s, -100, -100.1, "Tianjin", False);')
|
||||
tdSql.execute('insert into downsampling_ct1 values (1653547828591+2s, 50, 50.3, "HeBei", False);')
|
||||
tdSql.execute('select * from output_downsampling_stb;')
|
||||
tdSql.execute('select start, `min(c1)`, `max(c2)`, `sum(c1)` from output_downsampling_stb;')
|
||||
tdSql.execute('select _wstartts AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
|
||||
tdSql.execute('select _wstart AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
|
||||
tdSql.execute('insert into downsampling_ct1 values (1653547828591+10m, 60, 60.3, "heilongjiang", True);')
|
||||
tdSql.execute('insert into downsampling_ct1 values (1653547828591+11m, 70, 70.3, "JiLin", True);')
|
||||
tdSql.execute('select * from output_downsampling_stb;')
|
||||
tdSql.execute('select start, `min(c1)`, `max(c2)`, `sum(c1)` from output_downsampling_stb;')
|
||||
tdSql.execute('select _wstartts AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
|
||||
tdSql.execute('select _wstart AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
|
||||
tdSql.execute('insert into downsampling_ct1 values (1653547828591+21m, 70, 70.3, "JiLin", True);')
|
||||
tdSql.execute('select * from output_downsampling_stb;')
|
||||
tdSql.execute('select * from output_downsampling_stb;')
|
||||
tdSql.execute('select start, `min(c1)`, `max(c2)`, `sum(c1)` from output_downsampling_stb;')
|
||||
tdSql.execute('select _wstartts AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
|
||||
tdSql.execute('select _wstart AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
|
||||
tdSql.execute('create stream abs_stream into output_abs_stb as select ts, abs(c1), abs(c2), c3 from scalar_stb;')
|
||||
tdSql.query('describe output_abs_stb')
|
||||
tdSql.execute('create stream acos_stream into output_acos_stb as select ts, acos(c1), acos(c2), c3 from scalar_stb;')
|
||||
|
|
|
@ -382,7 +382,7 @@ class TDDnode:
|
|||
|
||||
if self.valgrind == 0:
|
||||
if platform.system().lower() == 'windows':
|
||||
cmd = "mintty -h never -w hide %s -c %s" % (
|
||||
cmd = "mintty -h never %s -c %s" % (
|
||||
binPath, self.cfgDir)
|
||||
else:
|
||||
cmd = "nohup %s -c %s > /dev/null 2>&1 & " % (
|
||||
|
@ -391,7 +391,7 @@ class TDDnode:
|
|||
valgrindCmdline = "valgrind --log-file=\"%s/../log/valgrind.log\" --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes"%self.cfgDir
|
||||
|
||||
if platform.system().lower() == 'windows':
|
||||
cmd = "mintty -h never -w hide %s %s -c %s" % (
|
||||
cmd = "mintty -h never %s %s -c %s" % (
|
||||
valgrindCmdline, binPath, self.cfgDir)
|
||||
else:
|
||||
cmd = "nohup %s %s -c %s 2>&1 & " % (
|
||||
|
@ -518,20 +518,20 @@ class TDDnode:
|
|||
|
||||
if self.running != 0:
|
||||
if platform.system().lower() == 'windows':
|
||||
os.system("wmic process where \"name='taosd.exe' and CommandLine like '%%dnode%d%%'\" get processId | xargs echo | awk '{print $2}' | xargs taskkill -f -pid"%self.index)
|
||||
psCmd = "for /f %a in ('wmic process where \"name='taosd.exe' and CommandLine like '%%dnode%d%%'\" get processId ^| xargs echo ^| awk ^'{print $2}^'') do @(ps | grep %a | awk '{print $1}' | xargs kill -INT )" % (self.index)
|
||||
else:
|
||||
psCmd = "ps -ef|grep -w %s| grep dnode%d|grep -v grep | awk '{print $2}'" % (toBeKilled,self.index)
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
|
||||
while(processID):
|
||||
killCmd = "kill -INT %s > /dev/null 2>&1" % processID
|
||||
os.system(killCmd)
|
||||
time.sleep(1)
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
|
||||
while(processID):
|
||||
killCmd = "kill -INT %s > /dev/null 2>&1" % processID
|
||||
os.system(killCmd)
|
||||
time.sleep(1)
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
if self.valgrind:
|
||||
time.sleep(2)
|
||||
if self.valgrind:
|
||||
time.sleep(2)
|
||||
|
||||
self.running = 0
|
||||
tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index))
|
||||
|
|
|
@ -36,7 +36,7 @@ int64_t st, et;
|
|||
char hostName[128];
|
||||
char dbName[128];
|
||||
char tbName[128];
|
||||
int32_t runTimes = 10000;
|
||||
int32_t runTimes = 1000;
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
|
@ -85,9 +85,12 @@ static void sqExecSQLE(TAOS *taos, char *command) {
|
|||
taos_free_result(pSql);
|
||||
}
|
||||
|
||||
void sqError(char* prefix, const char* errMsg) {
|
||||
fprintf(stderr, "%s error: %s\n", prefix, errMsg);
|
||||
}
|
||||
|
||||
void sqExit(char* prefix, const char* errMsg) {
|
||||
fprintf(stderr, "%s error: %s\n", prefix, errMsg);
|
||||
sqError(prefix, errMsg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -141,16 +144,20 @@ void sqCloseFetchCb(void *param, TAOS_RES *pRes, int numOfRows) {
|
|||
taos_close(qParam->taos);
|
||||
|
||||
*qParam->end = 1;
|
||||
|
||||
taos_free_result(pRes);
|
||||
}
|
||||
|
||||
void sqCloseQueryCb(void *param, TAOS_RES *pRes, int code) {
|
||||
SSP_CB_PARAM *qParam = (SSP_CB_PARAM *)param;
|
||||
if (code == 0 && pRes) {
|
||||
if (qParam->fetch) {
|
||||
taos_fetch_rows_a(pRes, sqFreeFetchCb, param);
|
||||
taos_fetch_rows_a(pRes, sqCloseFetchCb, param);
|
||||
} else {
|
||||
taos_close(qParam->taos);
|
||||
*qParam->end = 1;
|
||||
|
||||
taos_free_result(pRes);
|
||||
}
|
||||
} else {
|
||||
sqExit("select", taos_errstr(pRes));
|
||||
|
@ -203,7 +210,9 @@ void sqAsyncQueryCb(void *param, TAOS_RES *pRes, int code) {
|
|||
*qParam->end = 1;
|
||||
}
|
||||
} else {
|
||||
sqExit("select", taos_errstr(pRes));
|
||||
sqError("select", taos_errstr(pRes));
|
||||
*qParam->end = 1;
|
||||
taos_free_result(pRes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -358,6 +367,7 @@ int sqCloseSyncQuery(bool fetch) {
|
|||
}
|
||||
|
||||
taos_close(taos);
|
||||
taos_free_result(pRes);
|
||||
}
|
||||
CASE_LEAVE();
|
||||
}
|
||||
|
@ -382,7 +392,7 @@ int sqCloseAsyncQuery(bool fetch) {
|
|||
SSP_CB_PARAM param = {0};
|
||||
param.fetch = fetch;
|
||||
param.end = &qEnd;
|
||||
taos_query_a(taos, sql, sqFreeQueryCb, ¶m);
|
||||
taos_query_a(taos, sql, sqCloseQueryCb, ¶m);
|
||||
while (0 == qEnd) {
|
||||
usleep(5000);
|
||||
}
|
||||
|
@ -457,8 +467,6 @@ void *closeThreadFp(void *arg) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *killThreadFp(void *arg) {
|
||||
SSP_CB_PARAM* qParam = (SSP_CB_PARAM*)arg;
|
||||
while (true) {
|
||||
|
@ -471,6 +479,19 @@ void *killThreadFp(void *arg) {
|
|||
}
|
||||
}
|
||||
|
||||
void *cleanupThreadFp(void *arg) {
|
||||
SSP_CB_PARAM* qParam = (SSP_CB_PARAM*)arg;
|
||||
while (true) {
|
||||
if (qParam->taos) {
|
||||
usleep(rand() % 10000);
|
||||
taos_cleanup();
|
||||
break;
|
||||
}
|
||||
usleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int sqConCloseSyncQuery(bool fetch) {
|
||||
|
@ -578,6 +599,8 @@ int sqConKillSyncQuery(bool fetch) {
|
|||
|
||||
pthread_join(qid, NULL);
|
||||
pthread_join(cid, NULL);
|
||||
|
||||
taos_close(param.taos);
|
||||
}
|
||||
CASE_LEAVE();
|
||||
}
|
||||
|
@ -593,6 +616,40 @@ int sqConKillAsyncQuery(bool fetch) {
|
|||
|
||||
pthread_join(qid, NULL);
|
||||
pthread_join(cid, NULL);
|
||||
|
||||
taos_close(param.taos);
|
||||
}
|
||||
CASE_LEAVE();
|
||||
}
|
||||
|
||||
int sqConCleanupSyncQuery(bool fetch) {
|
||||
CASE_ENTER();
|
||||
pthread_t qid, cid;
|
||||
for (int32_t i = 0; i < runTimes; ++i) {
|
||||
SSP_CB_PARAM param = {0};
|
||||
param.fetch = fetch;
|
||||
pthread_create(&qid, NULL, syncQueryThreadFp, (void*)¶m);
|
||||
pthread_create(&cid, NULL, cleanupThreadFp, (void*)¶m);
|
||||
|
||||
pthread_join(qid, NULL);
|
||||
pthread_join(cid, NULL);
|
||||
break;
|
||||
}
|
||||
CASE_LEAVE();
|
||||
}
|
||||
|
||||
int sqConCleanupAsyncQuery(bool fetch) {
|
||||
CASE_ENTER();
|
||||
pthread_t qid, cid;
|
||||
for (int32_t i = 0; i < runTimes; ++i) {
|
||||
SSP_CB_PARAM param = {0};
|
||||
param.fetch = fetch;
|
||||
pthread_create(&qid, NULL, asyncQueryThreadFp, (void*)¶m);
|
||||
pthread_create(&cid, NULL, cleanupThreadFp, (void*)¶m);
|
||||
|
||||
pthread_join(qid, NULL);
|
||||
pthread_join(cid, NULL);
|
||||
break;
|
||||
}
|
||||
CASE_LEAVE();
|
||||
}
|
||||
|
@ -600,7 +657,7 @@ int sqConKillAsyncQuery(bool fetch) {
|
|||
|
||||
|
||||
void sqRunAllCase(void) {
|
||||
/*
|
||||
#if 1
|
||||
sqStopSyncQuery(false);
|
||||
sqStopSyncQuery(true);
|
||||
sqStopAsyncQuery(false);
|
||||
|
@ -620,23 +677,26 @@ void sqRunAllCase(void) {
|
|||
sqConCloseSyncQuery(true);
|
||||
sqConCloseAsyncQuery(false);
|
||||
sqConCloseAsyncQuery(true);
|
||||
*/
|
||||
|
||||
#if 0
|
||||
|
||||
sqKillSyncQuery(false);
|
||||
sqKillSyncQuery(true);
|
||||
sqKillAsyncQuery(false);
|
||||
sqKillAsyncQuery(true);
|
||||
#endif
|
||||
|
||||
//sqConKillSyncQuery(false);
|
||||
sqConKillSyncQuery(false);
|
||||
sqConKillSyncQuery(true);
|
||||
#if 0
|
||||
sqConKillAsyncQuery(false);
|
||||
sqConKillAsyncQuery(true);
|
||||
#endif
|
||||
|
||||
/*
|
||||
sqConCleanupSyncQuery(false);
|
||||
sqConCleanupSyncQuery(true);
|
||||
sqConCleanupAsyncQuery(false);
|
||||
sqConCleanupAsyncQuery(true);
|
||||
*/
|
||||
|
||||
int32_t l = 5;
|
||||
while (l) {
|
||||
printf("%d\n", l--);
|
||||
|
|
|
@ -123,6 +123,7 @@
|
|||
# ./test.sh -f tsim/stream/schedSnode.sim
|
||||
./test.sh -f tsim/stream/windowClose.sim
|
||||
./test.sh -f tsim/stream/ignoreExpiredData.sim
|
||||
./test.sh -f tsim/stream/sliding.sim
|
||||
|
||||
# ---- transaction
|
||||
./test.sh -f tsim/trans/lossdata1.sim
|
||||
|
|
|
@ -127,8 +127,8 @@ echo "dataDir $DATA_DIR" >> $TAOS_CFG
|
|||
echo "logDir $LOG_DIR" >> $TAOS_CFG
|
||||
echo "debugFlag 0" >> $TAOS_CFG
|
||||
echo "tmrDebugFlag 131" >> $TAOS_CFG
|
||||
echo "uDebugFlag 131" >> $TAOS_CFG
|
||||
echo "rpcDebugFlag 131" >> $TAOS_CFG
|
||||
echo "uDebugFlag 143" >> $TAOS_CFG
|
||||
echo "rpcDebugFlag 143" >> $TAOS_CFG
|
||||
echo "jniDebugFlag 143" >> $TAOS_CFG
|
||||
echo "qDebugFlag 143" >> $TAOS_CFG
|
||||
echo "cDebugFlag 143" >> $TAOS_CFG
|
||||
|
|
|
@ -77,7 +77,10 @@ goto :eof
|
|||
:check_offline
|
||||
sleep 1
|
||||
for /f "tokens=2" %%C in ('wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" get processId ^| xargs echo') do (
|
||||
echo check taosd offline
|
||||
goto :check_offline
|
||||
for /f "tokens=1" %%D in ('ps ^| grep %%C') do (
|
||||
echo kill -INT %%D
|
||||
echo check taosd offline %NODE_NAME% %%C %%D
|
||||
goto :check_offline
|
||||
)
|
||||
)
|
||||
goto :eof
|
|
@ -24,7 +24,7 @@ for /F "usebackq tokens=*" %%i in (!caseFile!) do (
|
|||
)
|
||||
)
|
||||
)
|
||||
exit !exitNum!
|
||||
exit /b !exitNum!
|
||||
|
||||
:colorEcho
|
||||
set timeNow=%time%
|
||||
|
|
|
@ -660,8 +660,8 @@ endi
|
|||
print ======= over
|
||||
sql drop database d1
|
||||
sql show databases
|
||||
if $rows != 0 then
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -32,7 +32,6 @@ if $rows != 3 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
|
||||
print =============== insert data, mode1: one row one table in sql
|
||||
print =============== insert data, mode1: mulit rows one table in sql
|
||||
#print =============== insert data, mode1: one rows mulit table in sql
|
||||
|
@ -41,9 +40,6 @@ sql insert into ct1 values(now+0s, 10, 2.0, 3.0)
|
|||
sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3)
|
||||
sql insert into ct2 values(now+0s, 10, 2.0, 3.0)
|
||||
sql insert into ct2 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3)
|
||||
#sql insert into ct1 values(now+4s, -14, -2.4, -3.4) ct2 values(now+4s, -14, -2.4, -3.4)
|
||||
#sql insert into ct1 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) ct2 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6)
|
||||
|
||||
sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0)
|
||||
|
||||
#===================================================================
|
||||
|
@ -67,16 +63,6 @@ endi
|
|||
if $data03 != 3.000000000 then
|
||||
return -1
|
||||
endi
|
||||
#if $data41 != -14 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data42 != -2.40000 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data43 != -3.400000000 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
|
||||
print =============== select count(*) from child table
|
||||
sql select count(*) from ct1
|
||||
|
@ -107,10 +93,10 @@ if $data03 != 4 then
|
|||
endi
|
||||
|
||||
#print =============== select first(*)/first(column) from child table
|
||||
#sql select first(*) from ct1
|
||||
#print ====> select first(*) from ct1
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
sql select first(*) from ct1
|
||||
print ====> select first(*) from ct1
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
|
||||
sql select first(ts), first(c1), first(c2), first(c3) from ct1
|
||||
print ====> select first(ts), first(c1), first(c2), first(c3) from ct1
|
||||
|
@ -217,23 +203,23 @@ if $data32 != -3.300000000 then
|
|||
return -1
|
||||
endi
|
||||
#===================================================================
|
||||
#===================================================================
|
||||
|
||||
#print =============== query data from stb
|
||||
#sql select * from stb
|
||||
#if $rows != 4 then
|
||||
# return -1
|
||||
#endi
|
||||
sql select * from stb
|
||||
print $rows
|
||||
if $rows != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#print =============== select count(*) from supter table
|
||||
#sql select count(*) from stb
|
||||
#print $data00 $data01 $data02
|
||||
#if $rows != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 9 then
|
||||
# return -1
|
||||
#endi
|
||||
sql select count(*) from stb
|
||||
print $data00 $data01 $data02
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== select count(column) from supter table
|
||||
sql select ts, c1, c2, c3 from stb
|
||||
|
@ -264,27 +250,23 @@ if $data03 != 3.000000000 then
|
|||
endi
|
||||
|
||||
#print =============== select count(column) from supter table
|
||||
#sql select count(ts), count(c1), count(c2), count(c3) from stb
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
#print $data10 $data11 $data12 $data13
|
||||
#print $data20 $data21 $data22 $data23
|
||||
#print $data30 $data31 $data32 $data33
|
||||
#if $data00 != 9 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data01 != 8 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data02 != 8 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data03 != 8 then
|
||||
# return -1
|
||||
#endi
|
||||
sql select count(ts), count(c1), count(c2), count(c3) from stb
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
if $data00 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#===================================================================
|
||||
|
||||
print =============== stop and restart taosd, then again do query above
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
@ -308,16 +290,6 @@ endi
|
|||
if $data03 != 3.000000000 then
|
||||
return -1
|
||||
endi
|
||||
#if $data41 != -14 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data42 != -2.40000 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data43 != -3.400000000 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
|
||||
print =============== select count(*) from child table
|
||||
sql select count(*) from ct1
|
||||
|
@ -348,10 +320,10 @@ if $data03 != 4 then
|
|||
endi
|
||||
|
||||
#print =============== select first(*)/first(column) from child table
|
||||
#sql select first(*) from ct1
|
||||
#print ====> select first(*) from ct1
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
sql select first(*) from ct1
|
||||
print ====> select first(*) from ct1
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
|
||||
sql select first(ts), first(c1), first(c2), first(c3) from ct1
|
||||
print ====> select first(ts), first(c1), first(c2), first(c3) from ct1
|
||||
|
@ -456,24 +428,23 @@ endi
|
|||
if $data32 != -3.300000000 then
|
||||
return -1
|
||||
endi
|
||||
#===================================================================
|
||||
#===================================================================
|
||||
|
||||
#print =============== query data from stb
|
||||
#sql select * from stb
|
||||
#if $rows != 4 then
|
||||
# return -1
|
||||
#endi
|
||||
#===================================================================
|
||||
print =============== query data from stb
|
||||
sql select * from stb
|
||||
if $rows != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#print =============== select count(*) from supter table
|
||||
#sql select count(*) from stb
|
||||
#print $data00 $data01 $data02
|
||||
#if $rows != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 9 then
|
||||
# return -1
|
||||
#endi
|
||||
print =============== select count(*) from supter table
|
||||
sql select count(*) from stb
|
||||
print $data00 $data01 $data02
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== select count(column) from supter table
|
||||
sql select ts, c1, c2, c3 from stb
|
||||
|
@ -503,20 +474,19 @@ if $data03 != 3.000000000 then
|
|||
endi
|
||||
|
||||
#print =============== select count(column) from supter table
|
||||
#sql select count(ts), count(c1), count(c2), count(c3) from stb
|
||||
#print $data00 $data01 $data02 $data03
|
||||
#if $data00 != 8 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data01 != 8 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data02 != 8 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data03 != 8 then
|
||||
# return -1
|
||||
#endi
|
||||
sql select count(ts), count(c1), count(c2), count(c3) from stb
|
||||
print $data00 $data01 $data02 $data03
|
||||
if $data00 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -3,7 +3,6 @@ system sh/deploy.sh -n dnode1 -i 1
|
|||
system sh/exec.sh -n dnode1 -s start
|
||||
sql connect
|
||||
|
||||
|
||||
print =============== create database
|
||||
sql create database d1
|
||||
sql show databases
|
||||
|
@ -17,7 +16,6 @@ sql use d1
|
|||
|
||||
print =============== create super table, include all type
|
||||
sql create table if not exists stb (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(16), c9 nchar(16), c10 timestamp, c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned) tags (t1 bool, t2 tinyint, t3 smallint, t4 int, t5 bigint, t6 float, t7 double, t8 binary(16), t9 nchar(16), t10 timestamp, t11 tinyint unsigned, t12 smallint unsigned, t13 int unsigned, t14 bigint unsigned)
|
||||
|
||||
sql create stable if not exists stb_1 (ts timestamp, i int) tags (j int)
|
||||
sql create table stb_2 (ts timestamp, i int) tags (j int)
|
||||
sql create stable stb_3 (ts timestamp, i int) tags (j int)
|
||||
|
@ -36,11 +34,6 @@ if $rows != 2 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
|
||||
print =============== insert data, mode1: one row one table in sql
|
||||
print =============== insert data, mode1: mulit rows one table in sql
|
||||
print =============== insert data, mode1: one rows mulit table in sql
|
||||
print =============== insert data, mode1: mulit rows mulit table in sql
|
||||
sql insert into c1 values(now-1s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40)
|
||||
sql insert into c1 values(now+0s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+1s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+2s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40)
|
||||
|
||||
|
@ -69,10 +62,10 @@ if $data03 != -2 then
|
|||
endi
|
||||
|
||||
print =============== query data from st, but not support select * from super table, waiting fix
|
||||
#sql select * from st
|
||||
#if $rows != 4 then
|
||||
# return -1
|
||||
#endi
|
||||
sql select * from stb
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== stop and restart taosd
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
@ -102,9 +95,9 @@ if $data03 != -2 then
|
|||
endi
|
||||
|
||||
print =============== query data from st, but not support select * from super table, waiting fix
|
||||
#sql select * from st
|
||||
#if $rows != 4 then
|
||||
# return -1
|
||||
#endi
|
||||
sql select * from stb
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -68,8 +68,8 @@ sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8 )
|
|||
sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9 )
|
||||
|
||||
print ================ start query ======================
|
||||
sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s)
|
||||
print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s)
|
||||
sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from ct1 interval(10s, 2s)
|
||||
print ===> select _wstart, _wend, _wduration, _qstart, _qend, count(*) from ct1 interval(10s, 2s)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data05
|
||||
print ===> rows1: $data10 $data11 $data12 $data15
|
||||
|
@ -89,8 +89,8 @@ if $data45 != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) sliding(10s)
|
||||
print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) sliding(10s)
|
||||
sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from ct1 interval(10s, 2s) sliding(10s)
|
||||
print ===> select _wstart, _wend, _wduration, _qstart, _qend, count(*) from ct1 interval(10s, 2s) sliding(10s)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data05
|
||||
print ===> rows1: $data10 $data11 $data12 $data15
|
||||
|
@ -177,7 +177,7 @@ if $data70 != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w)
|
||||
sql select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct3 interval(1n, 1w)
|
||||
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
|
@ -200,11 +200,11 @@ if $data02 != 2678400000 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w)
|
||||
sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w)
|
||||
sql_error select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct3 interval(1n, 1w) sliding(2w)
|
||||
sql_error select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct3 interval(1n, 1w) sliding(4w)
|
||||
|
||||
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n)
|
||||
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n)
|
||||
sql select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct4 interval(1y, 6n)
|
||||
print ===> select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct4 interval(1y, 6n)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
||||
|
@ -220,7 +220,7 @@ if $data04 != 2 then
|
|||
endi
|
||||
|
||||
sql_error select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
|
||||
sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n)
|
||||
sql_error select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct4 interval(1y, 6n) sliding(12n)
|
||||
|
||||
#=================================================
|
||||
print =============== stop and restart taosd
|
||||
|
|
|
@ -82,8 +82,8 @@ print =============== step4
|
|||
#$cc = 1 * 60000
|
||||
#$ms2 = 1601481600000 - $cc
|
||||
|
||||
sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(tbcol) from $tb interval(1m)
|
||||
print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(tbcol) from $tb interval(1m)
|
||||
sql select _wstart, _wend, _wduration, _qstart, _qend, count(tbcol) from $tb interval(1m)
|
||||
print ===> select _wstart, _wend, _wduration, _qstart, _qend, count(tbcol) from $tb interval(1m)
|
||||
print ===> $rows $data01 $data05
|
||||
if $rows != $rowNum then
|
||||
return -1
|
||||
|
|
|
@ -81,7 +81,7 @@ sql use $dbNamme
|
|||
|
||||
# session(ts,5a)
|
||||
print ====> select count(*) from dev_001 session(ts,5a)
|
||||
sql select _wstartts, count(*) from dev_001 session(ts,5a)
|
||||
sql select _wstart, count(*) from dev_001 session(ts,5a)
|
||||
print ====> rows: $rows
|
||||
print ====> $data00 $data01 $data02 $data03 $data04 $data05
|
||||
print ====> $data10 $data11 $data12 $data13 $data14 $data15
|
||||
|
@ -102,7 +102,7 @@ endi
|
|||
|
||||
#
|
||||
#print ====> select count(*) from (select * from dev_001) session(ts,5a)
|
||||
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,5a)
|
||||
#sql select _wstart, count(*) from (select * from dev_001) session(ts,5a)
|
||||
#if $rows != 15 then
|
||||
# return -1
|
||||
#endi
|
||||
|
@ -111,7 +111,7 @@ endi
|
|||
#endi
|
||||
|
||||
print ====> select count(*) from dev_001 session(ts,1s)
|
||||
sql select _wstartts, count(*) from dev_001 session(ts,1s)
|
||||
sql select _wstart, count(*) from dev_001 session(ts,1s)
|
||||
if $rows != 12 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -120,7 +120,7 @@ if $data01 != 5 then
|
|||
endi
|
||||
|
||||
#print ====> select count(*) from (select * from dev_001) session(ts,1s)
|
||||
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1s)
|
||||
#sql select _wstart, count(*) from (select * from dev_001) session(ts,1s)
|
||||
#if $rows != 12 then
|
||||
# return -1
|
||||
#endi
|
||||
|
@ -129,7 +129,7 @@ endi
|
|||
#endi
|
||||
|
||||
print ====> select count(*) from dev_001 session(ts,1000a)
|
||||
sql select _wstartts, count(*) from dev_001 session(ts,1000a)
|
||||
sql select _wstart, count(*) from dev_001 session(ts,1000a)
|
||||
if $rows != 12 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -138,7 +138,7 @@ if $data01 != 5 then
|
|||
endi
|
||||
|
||||
#print ====> select count(*) from (select * from dev_001) session(ts,1000a)
|
||||
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1000a)
|
||||
#sql select _wstart, count(*) from (select * from dev_001) session(ts,1000a)
|
||||
#if $rows != 12 then
|
||||
# return -1
|
||||
#endi
|
||||
|
@ -147,7 +147,7 @@ endi
|
|||
#endi
|
||||
|
||||
print ====> select count(*) from dev_001 session(ts,1m)
|
||||
sql select _wstartts, count(*) from dev_001 session(ts,1m)
|
||||
sql select _wstart, count(*) from dev_001 session(ts,1m)
|
||||
if $rows != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -156,7 +156,7 @@ if $data01 != 8 then
|
|||
endi
|
||||
|
||||
#print ====> select count(*) from (select * from dev_001) session(ts,1m)
|
||||
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1m)
|
||||
#sql select _wstart, count(*) from (select * from dev_001) session(ts,1m)
|
||||
#if $rows != 9 then
|
||||
# return -1
|
||||
#endi
|
||||
|
@ -165,7 +165,7 @@ endi
|
|||
#endi
|
||||
|
||||
print ====> select count(*) from dev_001 session(ts,1h)
|
||||
sql select _wstartts, count(*) from dev_001 session(ts,1h)
|
||||
sql select _wstart, count(*) from dev_001 session(ts,1h)
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -174,7 +174,7 @@ if $data01 != 11 then
|
|||
endi
|
||||
|
||||
#print ====> select count(*) from (select * from dev_001) session(ts,1h)
|
||||
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1h)
|
||||
#sql select _wstart, count(*) from (select * from dev_001) session(ts,1h)
|
||||
#if $rows != 6 then
|
||||
# return -1
|
||||
#endi
|
||||
|
@ -183,7 +183,7 @@ endi
|
|||
#endi
|
||||
|
||||
print ====> select count(*) from dev_001 session(ts,1d)
|
||||
sql select _wstartts, count(*) from dev_001 session(ts,1d)
|
||||
sql select _wstart, count(*) from dev_001 session(ts,1d)
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -192,7 +192,7 @@ if $data01 != 13 then
|
|||
endi
|
||||
|
||||
#print ====> select count(*) from (select * from dev_001) session(ts,1d)
|
||||
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1d)
|
||||
#sql select _wstart, count(*) from (select * from dev_001) session(ts,1d)
|
||||
#if $rows != 4 then
|
||||
# return -1
|
||||
#endi
|
||||
|
@ -201,7 +201,7 @@ endi
|
|||
#endi
|
||||
|
||||
print ====> select count(*) from dev_001 session(ts,1w)
|
||||
sql select _wstartts, count(*) from dev_001 session(ts,1w)
|
||||
sql select _wstart, count(*) from dev_001 session(ts,1w)
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -210,7 +210,7 @@ if $data01 != 15 then
|
|||
endi
|
||||
|
||||
#print ====> select count(*) from (select * from dev_001) session(ts,1w)
|
||||
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1w)
|
||||
#sql select _wstart, count(*) from (select * from dev_001) session(ts,1w)
|
||||
#if $rows != 2 then
|
||||
# return -1
|
||||
#endi
|
||||
|
@ -298,7 +298,7 @@ sql_error select count(*) from dev_001 session(i,1y)
|
|||
sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0'
|
||||
|
||||
#print ====> select count(*) from dev_001 session(ts,1u)
|
||||
#sql select _wstartts, count(*) from dev_001 session(ts,1u)
|
||||
#sql select _wstart, count(*) from dev_001 session(ts,1u)
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
#print $data10 $data11 $data12 $data13
|
||||
|
|
|
@ -103,29 +103,29 @@ if $rows != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
print =====sql : select _wstartts, stddev(c1) as b from ct4 interval(1y)
|
||||
sql select _wstartts, stddev(c1) as b from ct4 interval(1y)
|
||||
print =====sql : select _wstart, stddev(c1) as b from ct4 interval(1y)
|
||||
sql select _wstart, stddev(c1) as b from ct4 interval(1y)
|
||||
print ===> $rows
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =====sql : select _wstartts, stddev(c1) as b from t1 interval(1y)
|
||||
sql select _wstartts, stddev(c1) as b from t1 interval(1y)
|
||||
print =====sql : select _wstart, stddev(c1) as b from t1 interval(1y)
|
||||
sql select _wstart, stddev(c1) as b from t1 interval(1y)
|
||||
print ===> $rows
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =====select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
|
||||
sql select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
|
||||
print =====select _wstart, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
|
||||
sql select _wstart, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
|
||||
# print ===> $rows
|
||||
# if $rows != 3 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =====select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
|
||||
sql select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
|
||||
print =====select _wstart, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
|
||||
sql select _wstart, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
|
||||
# print ===> $rows
|
||||
# if $rows != 3 then
|
||||
# return -1
|
||||
|
@ -281,29 +281,29 @@ if $rows != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
print =====sql : select _wstartts, stddev(c1) as b from ct4 interval(1y)
|
||||
sql select _wstartts, stddev(c1) as b from ct4 interval(1y)
|
||||
print =====sql : select _wstart, stddev(c1) as b from ct4 interval(1y)
|
||||
sql select _wstart, stddev(c1) as b from ct4 interval(1y)
|
||||
print ===> $rows
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =====sql : select _wstartts, stddev(c1) as b from t1 interval(1y)
|
||||
sql select _wstartts, stddev(c1) as b from t1 interval(1y)
|
||||
print =====sql : select _wstart, stddev(c1) as b from t1 interval(1y)
|
||||
sql select _wstart, stddev(c1) as b from t1 interval(1y)
|
||||
print ===> $rows
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =====select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
|
||||
sql select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
|
||||
print =====select _wstart, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
|
||||
sql select _wstart, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
|
||||
print ===> $rows
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =====select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
|
||||
sql select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
|
||||
print =====select _wstart, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
|
||||
sql select _wstart, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
|
||||
print ===> $rows
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
|
|
|
@ -58,7 +58,7 @@ if $rows != 5 then
|
|||
endi
|
||||
|
||||
print =============== select * from stb from memory in designated vgroup
|
||||
sql select _wstartts, _wendts, min(c1),max(c2),max(c1) from stb interval(5m,10s) sliding(5m);
|
||||
sql select _wstart, _wend, min(c1),max(c2),max(c1) from stb interval(5m,10s) sliding(5m);
|
||||
print $data00 $data01 $data02 $data03 $data04
|
||||
if $rows != 1 then
|
||||
print rows $rows != 1
|
||||
|
@ -81,7 +81,7 @@ if $data04 != 20 then
|
|||
endi
|
||||
|
||||
print =============== select * from stb from memory in common vgroups
|
||||
sql select _wstartts, _wendts, min(c1),max(c2),max(c1),max(c3) from stb interval(5m,10s) sliding(5m);
|
||||
sql select _wstart, _wend, min(c1),max(c2),max(c1),max(c3) from stb interval(5m,10s) sliding(5m);
|
||||
print $data00 $data01 $data02 $data03 $data04 $data05
|
||||
if $rows != 1 then
|
||||
print rows $rows != 1
|
||||
|
@ -128,7 +128,7 @@ if $rows != 5 then
|
|||
endi
|
||||
|
||||
print =============== select * from stb from file in designated vgroup
|
||||
sql select _wstartts, _wendts, min(c1),max(c2),max(c1) from stb interval(5m,10s) sliding(5m);
|
||||
sql select _wstart, _wend, min(c1),max(c2),max(c1) from stb interval(5m,10s) sliding(5m);
|
||||
print $data00 $data01 $data02 $data03 $data04
|
||||
if $rows != 1 then
|
||||
print rows $rows != 1
|
||||
|
@ -151,7 +151,7 @@ if $data04 != 20 then
|
|||
endi
|
||||
|
||||
print =============== select * from stb from file in common vgroups
|
||||
sql select _wstartts, _wendts, min(c1),max(c2),max(c1),max(c3) from stb interval(5m,10s) sliding(5m);
|
||||
sql select _wstart, _wend, min(c1),max(c2),max(c1),max(c3) from stb interval(5m,10s) sliding(5m);
|
||||
print $data00 $data01 $data02 $data03 $data04 $data05
|
||||
if $rows != 1 then
|
||||
print rows $rows != 1
|
||||
|
|
|
@ -33,7 +33,7 @@ if $rows != 3 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql create stream s1 trigger at_once into outstb as select _wstartts, min(k), max(k), sum(k) as sum_alias from ct1 interval(10m)
|
||||
sql create stream s1 trigger at_once into outstb as select _wstart, min(k), max(k), sum(k) as sum_alias from ct1 interval(10m)
|
||||
|
||||
sql show stables
|
||||
if $rows != 2 then
|
||||
|
@ -48,7 +48,7 @@ sleep 100
|
|||
#===================================================================
|
||||
print =============== query data from child table
|
||||
|
||||
sql select `_wstartts`,`min(k)`,`max(k)`,sum_alias from outstb
|
||||
sql select `_wstart`,`min(k)`,`max(k)`,sum_alias from outstb
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
if $rows != 1 then
|
||||
|
@ -77,7 +77,7 @@ sleep 100
|
|||
#===================================================================
|
||||
print =============== query data from child table
|
||||
|
||||
sql select `_wstartts`,`min(k)`,`max(k)`,sum_alias from outstb
|
||||
sql select `_wstart`,`min(k)`,`max(k)`,sum_alias from outstb
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
if $rows != 1 then
|
||||
|
@ -105,7 +105,7 @@ sleep 100
|
|||
#===================================================================
|
||||
print =============== query data from child table
|
||||
|
||||
sql select `_wstartts`,`min(k)`,`max(k)`,sum_alias from outstb
|
||||
sql select `_wstart`,`min(k)`,`max(k)`,sum_alias from outstb
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
print $data10 $data11 $data12 $data13
|
||||
|
|
|
@ -17,14 +17,14 @@ sql use test
|
|||
|
||||
|
||||
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||
sql create stream streams1 trigger at_once into streamt as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s);
|
||||
sql create stream streams1 trigger at_once into streamt as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s);
|
||||
sql insert into t1 values(1648791213000,1,2,3,1.0);
|
||||
sql insert into t1 values(1648791223001,2,2,3,1.1);
|
||||
sql insert into t1 values(1648791233002,3,2,3,2.1);
|
||||
sql insert into t1 values(1648791243003,4,2,3,3.1);
|
||||
sql insert into t1 values(1648791213004,4,2,3,4.1);
|
||||
sleep 1000
|
||||
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
|
||||
if $rows != 4 then
|
||||
print ======$rows
|
||||
|
@ -254,7 +254,7 @@ endi
|
|||
|
||||
sql insert into t1 values(1648791223002,12,14,13,11.1);
|
||||
sleep 100
|
||||
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
|
||||
# row 1
|
||||
if $data11 != 2 then
|
||||
|
@ -284,7 +284,7 @@ endi
|
|||
|
||||
sql insert into t1 values(1648791223003,12,14,13,11.1);
|
||||
sleep 100
|
||||
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
|
||||
# row 1
|
||||
if $data11 != 3 then
|
||||
|
@ -316,7 +316,7 @@ sql insert into t1 values(1648791223001,1,1,1,1.1);
|
|||
sql insert into t1 values(1648791223002,2,2,2,2.1);
|
||||
sql insert into t1 values(1648791223003,3,3,3,3.1);
|
||||
sleep 100
|
||||
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
|
||||
# row 1
|
||||
if $data11 != 3 then
|
||||
|
@ -348,7 +348,7 @@ sql insert into t1 values(1648791233003,3,2,3,2.1);
|
|||
sql insert into t1 values(1648791233002,5,6,7,8.1);
|
||||
sql insert into t1 values(1648791233002,3,2,3,2.1);
|
||||
sleep 100
|
||||
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
|
||||
# row 2
|
||||
if $data21 != 2 then
|
||||
|
@ -378,7 +378,7 @@ endi
|
|||
|
||||
sql insert into t1 values(1648791213004,4,2,3,4.1) (1648791213006,5,4,7,9.1) (1648791213004,40,20,30,40.1) (1648791213005,4,2,3,4.1);
|
||||
sleep 100
|
||||
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
|
||||
# row 0
|
||||
if $data01 != 4 then
|
||||
|
@ -408,7 +408,7 @@ endi
|
|||
|
||||
sql insert into t1 values(1648791223004,4,2,3,4.1) (1648791233006,5,4,7,9.1) (1648791223004,40,20,30,40.1) (1648791233005,4,2,3,4.1);
|
||||
sleep 100
|
||||
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||
|
||||
# row 1
|
||||
if $data11 != 4 then
|
||||
|
|
|
@ -33,7 +33,7 @@ if $rows != 3 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql create stream s1 trigger at_once into outstb as select _wstartts, min(k), max(k), sum(k) as sum_alias from ct1 interval(10m)
|
||||
sql create stream s1 trigger at_once into outstb as select _wstart, min(k), max(k), sum(k) as sum_alias from ct1 interval(10m)
|
||||
|
||||
sql show stables
|
||||
if $rows != 2 then
|
||||
|
@ -48,7 +48,7 @@ sleep 100
|
|||
#===================================================================
|
||||
print =============== query data from child table
|
||||
|
||||
sql select `_wstartts`,`min(k)`,`max(k)`,sum_alias from outstb
|
||||
sql select `_wstart`,`min(k)`,`max(k)`,sum_alias from outstb
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
if $rows != 1 then
|
||||
|
@ -77,7 +77,7 @@ sleep 100
|
|||
#===================================================================
|
||||
print =============== query data from child table
|
||||
|
||||
sql select `_wstartts`,`min(k)`,`max(k)`,sum_alias from outstb
|
||||
sql select `_wstart`,`min(k)`,`max(k)`,sum_alias from outstb
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
print $data10 $data11 $data12 $data13
|
||||
|
|
|
@ -41,7 +41,7 @@ sql create table ts1 using st tags(1,1,1);
|
|||
sql create table ts2 using st tags(2,2,2);
|
||||
sql create table ts3 using st tags(3,2,2);
|
||||
sql create table ts4 using st tags(4,2,2);
|
||||
sql create stream stream_t1 trigger at_once watermark 1d into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s);
|
||||
sql create stream stream_t1 trigger at_once watermark 1d into streamtST1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s);
|
||||
|
||||
sleep 1000
|
||||
|
||||
|
@ -195,7 +195,7 @@ if $data35 != 3 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5, avg(d) from st interval(10s);
|
||||
sql select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5, avg(d) from st interval(10s);
|
||||
|
||||
|
||||
sql create database test1 vgroups 1;
|
||||
|
@ -203,7 +203,7 @@ sql use test1;
|
|||
sql create stable st(ts timestamp, a int, b int , c int) tags(ta int,tb int,tc int);
|
||||
sql create table ts1 using st tags(1,1,1);
|
||||
sql create table ts2 using st tags(2,2,2);
|
||||
sql create stream stream_t2 trigger at_once watermark 20s into streamtST1 as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st interval(10s) ;
|
||||
sql create stream stream_t2 trigger at_once watermark 20s into streamtST1 as select _wstart, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st interval(10s) ;
|
||||
|
||||
sql insert into ts1 values(1648791211000,1,2,3);
|
||||
sql insert into ts1 values(1648791222001,2,2,3);
|
||||
|
|
|
@ -41,7 +41,7 @@ sql create table ts1 using st tags(1,1,1);
|
|||
sql create table ts2 using st tags(2,2,2);
|
||||
sql create table ts3 using st tags(3,2,2);
|
||||
sql create table ts4 using st tags(4,2,2);
|
||||
sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s);
|
||||
sql create stream stream_t1 trigger at_once into streamtST1 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s);
|
||||
|
||||
sleep 1000
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ sql use test;
|
|||
sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
|
||||
sql create table ts1 using st tags(1,1,1);
|
||||
sql create table ts2 using st tags(2,2,2);
|
||||
sql create stream stream_t1 trigger at_once into streamtST as select _wstartts, count(*) c1, sum(a) c2 , max(b) c3 from st session(ts, 10s) ;
|
||||
sql create stream stream_t1 trigger at_once into streamtST as select _wstart, count(*) c1, sum(a) c2 , max(b) c3 from st session(ts, 10s) ;
|
||||
|
||||
sleep 1000
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ print $data00 $data01 $data02
|
|||
|
||||
sql use test
|
||||
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||
sql create stream streams1 trigger at_once IGNORE EXPIRED into streamt1 as select _wstartts, count(*) c1, sum(a) c3 from t1 interval(10s);
|
||||
sql create stream streams2 trigger at_once IGNORE EXPIRED into streamt2 as select _wstartts, count(*) c1, sum(a) c3 from t1 session(ts,10s);
|
||||
sql create stream streams3 trigger at_once IGNORE EXPIRED into streamt3 as select _wstartts, count(*) c1, sum(a) c3 from t1 state_window(a);
|
||||
sql create stream streams1 trigger at_once IGNORE EXPIRED into streamt1 as select _wstart, count(*) c1, sum(a) c3 from t1 interval(10s);
|
||||
sql create stream streams2 trigger at_once IGNORE EXPIRED into streamt2 as select _wstart, count(*) c1, sum(a) c3 from t1 session(ts,10s);
|
||||
sql create stream streams3 trigger at_once IGNORE EXPIRED into streamt3 as select _wstart, count(*) c1, sum(a) c3 from t1 state_window(a);
|
||||
sql insert into t1 values(1648791213000,1,2,3,1.0);
|
||||
sql insert into t1 values(1648791223001,1,2,3,1.1);
|
||||
sql insert into t1 values(1648791233002,2,2,3,2.1);
|
||||
|
@ -111,8 +111,8 @@ sql use test1
|
|||
sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
|
||||
sql create table ts1 using st tags(1,1,1);
|
||||
sql create table ts2 using st tags(2,2,2);
|
||||
sql create stream stream_t1 trigger at_once IGNORE EXPIRED into streamtST1 as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st interval(10s) ;
|
||||
sql create stream stream_t2 trigger at_once IGNORE EXPIRED into streamtST2 as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st session(ts, 10s) ;
|
||||
sql create stream stream_t1 trigger at_once IGNORE EXPIRED into streamtST1 as select _wstart, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st interval(10s) ;
|
||||
sql create stream stream_t2 trigger at_once IGNORE EXPIRED into streamtST2 as select _wstart, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st session(ts, 10s) ;
|
||||
sql insert into ts1 values(1648791211000,1,2,3);
|
||||
sql insert into ts1 values(1648791222001,2,2,3);
|
||||
sql insert into ts2 values(1648791211000,1,2,3);
|
||||
|
|
|
@ -11,7 +11,7 @@ sql create table ts1 using st tags(1,1,1);
|
|||
sql create table ts2 using st tags(2,2,2);
|
||||
sql create table ts3 using st tags(3,2,2);
|
||||
sql create table ts4 using st tags(4,2,2);
|
||||
sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by ta,tb,tc interval(10s);
|
||||
sql create stream stream_t1 trigger at_once into streamtST1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by ta,tb,tc interval(10s);
|
||||
|
||||
sql insert into ts1 values(1648791213001,1,12,3,1.0);
|
||||
sql insert into ts2 values(1648791213001,1,12,3,1.0);
|
||||
|
@ -43,7 +43,7 @@ sql create table ts1 using st tags(1,2,3);
|
|||
sql create table ts2 using st tags(1,3,4);
|
||||
sql create table ts3 using st tags(1,4,5);
|
||||
|
||||
sql create stream streams1 trigger at_once into streamt as select _wstartts, count(*) c1, count(a) c2 from st partition by ta,tb,tc interval(10s);
|
||||
sql create stream streams1 trigger at_once into streamt as select _wstart, count(*) c1, count(a) c2 from st partition by ta,tb,tc interval(10s);
|
||||
|
||||
|
||||
sql insert into ts1 values(1648791211000,1,2,3);
|
||||
|
@ -74,7 +74,7 @@ sql create stable st(ts timestamp,a int,b int,c int,id int) tags(ta int,tb int,t
|
|||
sql create table ts1 using st tags(1,1,1);
|
||||
sql create table ts2 using st tags(2,2,2);
|
||||
|
||||
sql create stream stream_t2 trigger at_once watermark 20s into streamtST as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6, max(id) c7 from st partition by ta interval(10s) ;
|
||||
sql create stream stream_t2 trigger at_once watermark 20s into streamtST as select _wstart, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6, max(id) c7 from st partition by ta interval(10s) ;
|
||||
sql insert into ts1 values(1648791211000,1,2,3,1);
|
||||
sql insert into ts1 values(1648791222001,2,2,3,2);
|
||||
sql insert into ts2 values(1648791211000,1,2,3,3);
|
||||
|
|
|
@ -11,7 +11,7 @@ sql create table ts1 using st tags(1,1,1);
|
|||
sql create table ts2 using st tags(2,2,2);
|
||||
sql create table ts3 using st tags(3,2,2);
|
||||
sql create table ts4 using st tags(4,2,2);
|
||||
sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by tbname interval(10s);
|
||||
sql create stream stream_t1 trigger at_once into streamtST1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by tbname interval(10s);
|
||||
|
||||
sql insert into ts1 values(1648791213001,1,12,3,1.0);
|
||||
sql insert into ts2 values(1648791213001,1,12,3,1.0);
|
||||
|
@ -43,7 +43,7 @@ sql create table ts1 using st tags(1,2,3);
|
|||
sql create table ts2 using st tags(1,3,4);
|
||||
sql create table ts3 using st tags(1,4,5);
|
||||
|
||||
sql create stream streams1 trigger at_once into streamt as select _wstartts, count(*) c1, count(a) c2 from st partition by tbname interval(10s);
|
||||
sql create stream streams1 trigger at_once into streamt as select _wstart, count(*) c1, count(a) c2 from st partition by tbname interval(10s);
|
||||
|
||||
|
||||
sql insert into ts1 values(1648791211000,1,2,3);
|
||||
|
@ -74,7 +74,7 @@ sql create stable st(ts timestamp,a int,b int,c int,id int) tags(ta int,tb int,t
|
|||
sql create table ts1 using st tags(1,1,1);
|
||||
sql create table ts2 using st tags(2,2,2);
|
||||
|
||||
sql create stream stream_t2 trigger at_once into streamtST as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6, max(id) c7 from st partition by tbname interval(10s) ;
|
||||
sql create stream stream_t2 trigger at_once into streamtST as select _wstart, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6, max(id) c7 from st partition by tbname interval(10s) ;
|
||||
sql insert into ts1 values(1648791211000,1,2,3,1);
|
||||
sql insert into ts1 values(1648791222001,2,2,3,2);
|
||||
sql insert into ts2 values(1648791211000,1,2,3,3);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue