Merge branch '3.0' of https://github.com/taosdata/TDengine into feature/3.0_mhli
This commit is contained in:
commit
bbd8c05181
|
@ -82,10 +82,12 @@ IF ("${CPUTYPE}" STREQUAL "")
|
|||
MESSAGE(STATUS "Current platform is amd64")
|
||||
SET(PLATFORM_ARCH_STR "amd64")
|
||||
SET(TD_INTEL_64 TRUE)
|
||||
ADD_DEFINITIONS("-D_TD_X86_")
|
||||
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)")
|
||||
MESSAGE(STATUS "Current platform is x86")
|
||||
SET(PLATFORM_ARCH_STR "i386")
|
||||
SET(TD_INTEL_32 TRUE)
|
||||
ADD_DEFINITIONS("-D_TD_X86_")
|
||||
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l")
|
||||
MESSAGE(STATUS "Current platform is aarch32")
|
||||
SET(PLATFORM_ARCH_STR "arm")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG 7e9ce09
|
||||
GIT_TAG d5df76d
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -69,7 +69,7 @@ TDengine 的主要功能如下:
|
|||
|
||||
- **[分析能力](https://www.taosdata.com/tdengine/easy_data_analytics)**:通过超级表、存储计算分离、分区分片、预计算和其它技术,TDengine 能够高效地浏览、格式化和访问数据。
|
||||
|
||||
- **[核心开源](https://www.taosdata.com/tdengine/open_source_time-series_database)**:TDengine 的核心代码包括集群功能全部在开源协议下公开。全球超过 140k 个运行实例,GitHub Star 19k,且拥有一个活跃的开发者社区。
|
||||
- **[核心开源](https://www.taosdata.com/tdengine/open_source_time-series_database)**:TDengine 的核心代码包括集群功能全部在开源协议下公开。全球超过 140k 个运行实例,GitHub Star 20k,且拥有一个活跃的开发者社区。
|
||||
|
||||
采用 TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。表现在几个方面:
|
||||
|
||||
|
|
|
@ -218,6 +218,9 @@ DLL_EXPORT int taos_get_db_route_info(TAOS *taos, const char *db, TAOS_DB_ROUTE_
|
|||
DLL_EXPORT int taos_get_table_vgId(TAOS *taos, const char *db, const char *table, int *vgId);
|
||||
|
||||
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char *tableNameList);
|
||||
|
||||
/* --------------------------schemaless INTERFACE------------------------------- */
|
||||
|
||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision);
|
||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert_with_reqid(TAOS *taos, char *lines[], int numLines, int protocol,
|
||||
int precision, int64_t reqid);
|
||||
|
@ -225,6 +228,13 @@ DLL_EXPORT TAOS_RES *taos_schemaless_insert_raw(TAOS *taos, char *lines, int len
|
|||
int precision);
|
||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert_raw_with_reqid(TAOS *taos, char *lines, int len, int32_t *totalRows,
|
||||
int protocol, int precision, int64_t reqid);
|
||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert_ttl(TAOS *taos, char *lines[], int numLines, int protocol, int precision, int32_t ttl);
|
||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert_ttl_with_reqid(TAOS *taos, char *lines[], int numLines, int protocol,
|
||||
int precision, int32_t ttl, int64_t reqid);
|
||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert_raw_ttl(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
|
||||
int precision, int32_t ttl);
|
||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert_raw_ttl_with_reqid(TAOS *taos, char *lines, int len, int32_t *totalRows,
|
||||
int protocol, int precision, int32_t ttl, int64_t reqid);
|
||||
|
||||
/* --------------------------TMQ INTERFACE------------------------------- */
|
||||
|
||||
|
@ -297,6 +307,7 @@ DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res);
|
|||
DLL_EXPORT int32_t tmq_get_raw(TAOS_RES *res, tmq_raw_data *raw);
|
||||
DLL_EXPORT int32_t tmq_write_raw(TAOS *taos, tmq_raw_data raw);
|
||||
DLL_EXPORT int taos_write_raw_block(TAOS *taos, int numOfRows, char *pData, const char *tbname);
|
||||
DLL_EXPORT int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const char* tbname, TAOS_FIELD *fields, int numFields);
|
||||
DLL_EXPORT void tmq_free_raw(tmq_raw_data raw);
|
||||
// Returning null means error. Returned result need to be freed by tmq_free_json_meta
|
||||
DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res);
|
||||
|
|
|
@ -47,6 +47,7 @@ extern "C" {
|
|||
#define TSDB_INS_TABLE_TOPICS "ins_topics"
|
||||
#define TSDB_INS_TABLE_STREAMS "ins_streams"
|
||||
#define TSDB_INS_TABLE_STREAM_TASKS "ins_stream_tasks"
|
||||
#define TSDB_INS_TABLE_USER_PRIVILEGES "ins_user_privileges"
|
||||
|
||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
||||
|
|
|
@ -92,6 +92,10 @@ extern int32_t tsQueryNodeChunkSize;
|
|||
extern bool tsQueryUseNodeAllocator;
|
||||
extern bool tsKeepColumnName;
|
||||
extern bool tsEnableQueryHb;
|
||||
extern int32_t tsRedirectPeriod;
|
||||
extern int32_t tsRedirectFactor;
|
||||
extern int32_t tsRedirectMaxPeriod;
|
||||
extern int32_t tsMaxRetryWaitTime;
|
||||
|
||||
// client
|
||||
extern int32_t tsMinSlidingTime;
|
||||
|
@ -125,6 +129,7 @@ extern char tsUdfdLdLibPath[];
|
|||
extern char tsSmlChildTableName[];
|
||||
extern char tsSmlTagName[];
|
||||
extern bool tsSmlDataFormat;
|
||||
extern int32_t tsSmlBatchSize;
|
||||
|
||||
// wal
|
||||
extern int64_t tsWalFsyncDataSizeLimit;
|
||||
|
|
|
@ -141,16 +141,18 @@ typedef enum _mgmt_table {
|
|||
#define TSDB_FILL_PREV 4
|
||||
#define TSDB_FILL_NEXT 5
|
||||
|
||||
#define TSDB_ALTER_USER_PASSWD 0x1
|
||||
#define TSDB_ALTER_USER_SUPERUSER 0x2
|
||||
#define TSDB_ALTER_USER_ADD_READ_DB 0x3
|
||||
#define TSDB_ALTER_USER_REMOVE_READ_DB 0x4
|
||||
#define TSDB_ALTER_USER_ADD_WRITE_DB 0x5
|
||||
#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x6
|
||||
#define TSDB_ALTER_USER_ADD_ALL_DB 0x7
|
||||
#define TSDB_ALTER_USER_REMOVE_ALL_DB 0x8
|
||||
#define TSDB_ALTER_USER_ENABLE 0x9
|
||||
#define TSDB_ALTER_USER_SYSINFO 0xA
|
||||
#define TSDB_ALTER_USER_PASSWD 0x1
|
||||
#define TSDB_ALTER_USER_SUPERUSER 0x2
|
||||
#define TSDB_ALTER_USER_ADD_READ_DB 0x3
|
||||
#define TSDB_ALTER_USER_REMOVE_READ_DB 0x4
|
||||
#define TSDB_ALTER_USER_ADD_WRITE_DB 0x5
|
||||
#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x6
|
||||
#define TSDB_ALTER_USER_ADD_ALL_DB 0x7
|
||||
#define TSDB_ALTER_USER_REMOVE_ALL_DB 0x8
|
||||
#define TSDB_ALTER_USER_ENABLE 0x9
|
||||
#define TSDB_ALTER_USER_SYSINFO 0xA
|
||||
#define TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC 0xB
|
||||
#define TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC 0xC
|
||||
|
||||
#define TSDB_ALTER_USER_PRIVILEGES 0x2
|
||||
|
||||
|
@ -620,7 +622,7 @@ typedef struct {
|
|||
int8_t enable;
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_USET_PASSWORD_LEN];
|
||||
char dbname[TSDB_DB_FNAME_LEN];
|
||||
char objname[TSDB_DB_FNAME_LEN]; // db or topic
|
||||
} SAlterUserReq;
|
||||
|
||||
int32_t tSerializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq);
|
||||
|
@ -1592,14 +1594,14 @@ typedef struct SSubQueryMsg {
|
|||
int8_t explain;
|
||||
int8_t needFetch;
|
||||
uint32_t sqlLen;
|
||||
char *sql;
|
||||
char* sql;
|
||||
uint32_t msgLen;
|
||||
char *msg;
|
||||
char* msg;
|
||||
} SSubQueryMsg;
|
||||
|
||||
int32_t tSerializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq);
|
||||
int32_t tDeserializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq);
|
||||
void tFreeSSubQueryMsg(SSubQueryMsg *pReq);
|
||||
int32_t tSerializeSSubQueryMsg(void* buf, int32_t bufLen, SSubQueryMsg* pReq);
|
||||
int32_t tDeserializeSSubQueryMsg(void* buf, int32_t bufLen, SSubQueryMsg* pReq);
|
||||
void tFreeSSubQueryMsg(SSubQueryMsg* pReq);
|
||||
|
||||
typedef struct {
|
||||
SMsgHead header;
|
||||
|
@ -1638,9 +1640,8 @@ typedef struct {
|
|||
int32_t execId;
|
||||
} SResFetchReq;
|
||||
|
||||
int32_t tSerializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq);
|
||||
int32_t tDeserializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq);
|
||||
|
||||
int32_t tSerializeSResFetchReq(void* buf, int32_t bufLen, SResFetchReq* pReq);
|
||||
int32_t tDeserializeSResFetchReq(void* buf, int32_t bufLen, SResFetchReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
SMsgHead header;
|
||||
|
@ -1713,12 +1714,11 @@ typedef struct {
|
|||
int32_t execId;
|
||||
} STaskDropReq;
|
||||
|
||||
int32_t tSerializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq);
|
||||
int32_t tDeserializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq);
|
||||
|
||||
int32_t tSerializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp);
|
||||
int32_t tDeserializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp);
|
||||
int32_t tSerializeSTaskDropReq(void* buf, int32_t bufLen, STaskDropReq* pReq);
|
||||
int32_t tDeserializeSTaskDropReq(void* buf, int32_t bufLen, STaskDropReq* pReq);
|
||||
|
||||
int32_t tSerializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
|
||||
int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
|
||||
|
||||
typedef struct {
|
||||
int32_t code;
|
||||
|
@ -2923,9 +2923,8 @@ typedef struct {
|
|||
STqOffsetVal reqOffset;
|
||||
} SMqPollReq;
|
||||
|
||||
int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq);
|
||||
int32_t tDeserializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq);
|
||||
|
||||
int32_t tSerializeSMqPollReq(void* buf, int32_t bufLen, SMqPollReq* pReq);
|
||||
int32_t tDeserializeSMqPollReq(void* buf, int32_t bufLen, SMqPollReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
|
@ -3138,7 +3137,8 @@ int32_t tDecodeDeleteRes(SDecoder* pCoder, SDeleteRes* pRes);
|
|||
typedef struct {
|
||||
// int64_t uid;
|
||||
char tbname[TSDB_TABLE_NAME_LEN];
|
||||
int64_t ts;
|
||||
int64_t startTs;
|
||||
int64_t endTs;
|
||||
} SSingleDeleteReq;
|
||||
|
||||
int32_t tEncodeSSingleDeleteReq(SEncoder* pCoder, const SSingleDeleteReq* pReq);
|
||||
|
@ -3160,8 +3160,8 @@ typedef struct {
|
|||
} SBatchMsg;
|
||||
|
||||
typedef struct {
|
||||
SMsgHead header;
|
||||
SArray* pMsgs; //SArray<SBatchMsg>
|
||||
SMsgHead header;
|
||||
SArray* pMsgs; // SArray<SBatchMsg>
|
||||
} SBatchReq;
|
||||
|
||||
typedef struct {
|
||||
|
@ -3173,11 +3173,11 @@ typedef struct {
|
|||
} SBatchRspMsg;
|
||||
|
||||
typedef struct {
|
||||
SArray* pRsps; //SArray<SBatchRspMsg>
|
||||
SArray* pRsps; // SArray<SBatchRspMsg>
|
||||
} SBatchRsp;
|
||||
|
||||
int32_t tSerializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq);
|
||||
int32_t tDeserializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq);
|
||||
int32_t tSerializeSBatchReq(void* buf, int32_t bufLen, SBatchReq* pReq);
|
||||
int32_t tDeserializeSBatchReq(void* buf, int32_t bufLen, SBatchReq* pReq);
|
||||
static FORCE_INLINE void tFreeSBatchReqMsg(void* msg) {
|
||||
if (NULL == msg) {
|
||||
return;
|
||||
|
@ -3186,8 +3186,8 @@ static FORCE_INLINE void tFreeSBatchReqMsg(void* msg) {
|
|||
taosMemoryFree(pMsg->msg);
|
||||
}
|
||||
|
||||
int32_t tSerializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp);
|
||||
int32_t tDeserializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp);
|
||||
int32_t tSerializeSBatchRsp(void* buf, int32_t bufLen, SBatchRsp* pRsp);
|
||||
int32_t tDeserializeSBatchRsp(void* buf, int32_t bufLen, SBatchRsp* pRsp);
|
||||
|
||||
static FORCE_INLINE void tFreeSBatchRspMsg(void* p) {
|
||||
if (NULL == p) {
|
||||
|
@ -3198,11 +3198,10 @@ static FORCE_INLINE void tFreeSBatchRspMsg(void* p) {
|
|||
taosMemoryFree(pRsp->msg);
|
||||
}
|
||||
|
||||
int32_t tSerializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq);
|
||||
int32_t tDeserializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq);
|
||||
int32_t tSerializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq);
|
||||
int32_t tDeserializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq);
|
||||
|
||||
int32_t tSerializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq);
|
||||
int32_t tDeserializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq);
|
||||
int32_t tSerializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
|
||||
int32_t tDeserializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
|
|
|
@ -280,8 +280,8 @@ enum {
|
|||
|
||||
TD_NEW_MSG_SEG(TDMT_VND_STREAM_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_RECOVER_STEP1, "vnode-stream-recover1", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_RECOVER_STEP2, "vnode-stream-recover2", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_RECOVER_NONBLOCKING_STAGE, "vnode-stream-recover1", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE, "vnode-stream-recover2", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_MAX_MSG, "vnd-stream-max", NULL, NULL)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_VND_TMQ_MSG)
|
||||
|
|
|
@ -58,282 +58,284 @@
|
|||
#define TK_TO 40
|
||||
#define TK_REVOKE 41
|
||||
#define TK_FROM 42
|
||||
#define TK_NK_COMMA 43
|
||||
#define TK_READ 44
|
||||
#define TK_WRITE 45
|
||||
#define TK_NK_DOT 46
|
||||
#define TK_DNODE 47
|
||||
#define TK_PORT 48
|
||||
#define TK_DNODES 49
|
||||
#define TK_NK_IPTOKEN 50
|
||||
#define TK_FORCE 51
|
||||
#define TK_LOCAL 52
|
||||
#define TK_QNODE 53
|
||||
#define TK_BNODE 54
|
||||
#define TK_SNODE 55
|
||||
#define TK_MNODE 56
|
||||
#define TK_DATABASE 57
|
||||
#define TK_USE 58
|
||||
#define TK_FLUSH 59
|
||||
#define TK_TRIM 60
|
||||
#define TK_IF 61
|
||||
#define TK_NOT 62
|
||||
#define TK_EXISTS 63
|
||||
#define TK_BUFFER 64
|
||||
#define TK_CACHEMODEL 65
|
||||
#define TK_CACHESIZE 66
|
||||
#define TK_COMP 67
|
||||
#define TK_DURATION 68
|
||||
#define TK_NK_VARIABLE 69
|
||||
#define TK_MAXROWS 70
|
||||
#define TK_MINROWS 71
|
||||
#define TK_KEEP 72
|
||||
#define TK_PAGES 73
|
||||
#define TK_PAGESIZE 74
|
||||
#define TK_TSDB_PAGESIZE 75
|
||||
#define TK_PRECISION 76
|
||||
#define TK_REPLICA 77
|
||||
#define TK_STRICT 78
|
||||
#define TK_VGROUPS 79
|
||||
#define TK_SINGLE_STABLE 80
|
||||
#define TK_RETENTIONS 81
|
||||
#define TK_SCHEMALESS 82
|
||||
#define TK_WAL_LEVEL 83
|
||||
#define TK_WAL_FSYNC_PERIOD 84
|
||||
#define TK_WAL_RETENTION_PERIOD 85
|
||||
#define TK_WAL_RETENTION_SIZE 86
|
||||
#define TK_WAL_ROLL_PERIOD 87
|
||||
#define TK_WAL_SEGMENT_SIZE 88
|
||||
#define TK_STT_TRIGGER 89
|
||||
#define TK_TABLE_PREFIX 90
|
||||
#define TK_TABLE_SUFFIX 91
|
||||
#define TK_NK_COLON 92
|
||||
#define TK_MAX_SPEED 93
|
||||
#define TK_TABLE 94
|
||||
#define TK_NK_LP 95
|
||||
#define TK_NK_RP 96
|
||||
#define TK_STABLE 97
|
||||
#define TK_ADD 98
|
||||
#define TK_COLUMN 99
|
||||
#define TK_MODIFY 100
|
||||
#define TK_RENAME 101
|
||||
#define TK_TAG 102
|
||||
#define TK_SET 103
|
||||
#define TK_NK_EQ 104
|
||||
#define TK_USING 105
|
||||
#define TK_TAGS 106
|
||||
#define TK_COMMENT 107
|
||||
#define TK_BOOL 108
|
||||
#define TK_TINYINT 109
|
||||
#define TK_SMALLINT 110
|
||||
#define TK_INT 111
|
||||
#define TK_INTEGER 112
|
||||
#define TK_BIGINT 113
|
||||
#define TK_FLOAT 114
|
||||
#define TK_DOUBLE 115
|
||||
#define TK_BINARY 116
|
||||
#define TK_TIMESTAMP 117
|
||||
#define TK_NCHAR 118
|
||||
#define TK_UNSIGNED 119
|
||||
#define TK_JSON 120
|
||||
#define TK_VARCHAR 121
|
||||
#define TK_MEDIUMBLOB 122
|
||||
#define TK_BLOB 123
|
||||
#define TK_VARBINARY 124
|
||||
#define TK_DECIMAL 125
|
||||
#define TK_MAX_DELAY 126
|
||||
#define TK_WATERMARK 127
|
||||
#define TK_ROLLUP 128
|
||||
#define TK_TTL 129
|
||||
#define TK_SMA 130
|
||||
#define TK_FIRST 131
|
||||
#define TK_LAST 132
|
||||
#define TK_SHOW 133
|
||||
#define TK_DATABASES 134
|
||||
#define TK_TABLES 135
|
||||
#define TK_STABLES 136
|
||||
#define TK_MNODES 137
|
||||
#define TK_QNODES 138
|
||||
#define TK_FUNCTIONS 139
|
||||
#define TK_INDEXES 140
|
||||
#define TK_ACCOUNTS 141
|
||||
#define TK_APPS 142
|
||||
#define TK_CONNECTIONS 143
|
||||
#define TK_LICENCES 144
|
||||
#define TK_GRANTS 145
|
||||
#define TK_QUERIES 146
|
||||
#define TK_SCORES 147
|
||||
#define TK_TOPICS 148
|
||||
#define TK_VARIABLES 149
|
||||
#define TK_CLUSTER 150
|
||||
#define TK_BNODES 151
|
||||
#define TK_SNODES 152
|
||||
#define TK_TRANSACTIONS 153
|
||||
#define TK_DISTRIBUTED 154
|
||||
#define TK_CONSUMERS 155
|
||||
#define TK_SUBSCRIPTIONS 156
|
||||
#define TK_VNODES 157
|
||||
#define TK_LIKE 158
|
||||
#define TK_TBNAME 159
|
||||
#define TK_QTAGS 160
|
||||
#define TK_AS 161
|
||||
#define TK_INDEX 162
|
||||
#define TK_FUNCTION 163
|
||||
#define TK_INTERVAL 164
|
||||
#define TK_TOPIC 165
|
||||
#define TK_WITH 166
|
||||
#define TK_META 167
|
||||
#define TK_CONSUMER 168
|
||||
#define TK_GROUP 169
|
||||
#define TK_DESC 170
|
||||
#define TK_DESCRIBE 171
|
||||
#define TK_RESET 172
|
||||
#define TK_QUERY 173
|
||||
#define TK_CACHE 174
|
||||
#define TK_EXPLAIN 175
|
||||
#define TK_ANALYZE 176
|
||||
#define TK_VERBOSE 177
|
||||
#define TK_NK_BOOL 178
|
||||
#define TK_RATIO 179
|
||||
#define TK_NK_FLOAT 180
|
||||
#define TK_OUTPUTTYPE 181
|
||||
#define TK_AGGREGATE 182
|
||||
#define TK_BUFSIZE 183
|
||||
#define TK_STREAM 184
|
||||
#define TK_INTO 185
|
||||
#define TK_TRIGGER 186
|
||||
#define TK_AT_ONCE 187
|
||||
#define TK_WINDOW_CLOSE 188
|
||||
#define TK_IGNORE 189
|
||||
#define TK_EXPIRED 190
|
||||
#define TK_FILL_HISTORY 191
|
||||
#define TK_SUBTABLE 192
|
||||
#define TK_KILL 193
|
||||
#define TK_CONNECTION 194
|
||||
#define TK_TRANSACTION 195
|
||||
#define TK_BALANCE 196
|
||||
#define TK_VGROUP 197
|
||||
#define TK_MERGE 198
|
||||
#define TK_REDISTRIBUTE 199
|
||||
#define TK_SPLIT 200
|
||||
#define TK_DELETE 201
|
||||
#define TK_INSERT 202
|
||||
#define TK_NULL 203
|
||||
#define TK_NK_QUESTION 204
|
||||
#define TK_NK_ARROW 205
|
||||
#define TK_ROWTS 206
|
||||
#define TK_QSTART 207
|
||||
#define TK_QEND 208
|
||||
#define TK_QDURATION 209
|
||||
#define TK_WSTART 210
|
||||
#define TK_WEND 211
|
||||
#define TK_WDURATION 212
|
||||
#define TK_IROWTS 213
|
||||
#define TK_CAST 214
|
||||
#define TK_NOW 215
|
||||
#define TK_TODAY 216
|
||||
#define TK_TIMEZONE 217
|
||||
#define TK_CLIENT_VERSION 218
|
||||
#define TK_SERVER_VERSION 219
|
||||
#define TK_SERVER_STATUS 220
|
||||
#define TK_CURRENT_USER 221
|
||||
#define TK_COUNT 222
|
||||
#define TK_LAST_ROW 223
|
||||
#define TK_CASE 224
|
||||
#define TK_END 225
|
||||
#define TK_WHEN 226
|
||||
#define TK_THEN 227
|
||||
#define TK_ELSE 228
|
||||
#define TK_BETWEEN 229
|
||||
#define TK_IS 230
|
||||
#define TK_NK_LT 231
|
||||
#define TK_NK_GT 232
|
||||
#define TK_NK_LE 233
|
||||
#define TK_NK_GE 234
|
||||
#define TK_NK_NE 235
|
||||
#define TK_MATCH 236
|
||||
#define TK_NMATCH 237
|
||||
#define TK_CONTAINS 238
|
||||
#define TK_IN 239
|
||||
#define TK_JOIN 240
|
||||
#define TK_INNER 241
|
||||
#define TK_SELECT 242
|
||||
#define TK_DISTINCT 243
|
||||
#define TK_WHERE 244
|
||||
#define TK_PARTITION 245
|
||||
#define TK_BY 246
|
||||
#define TK_SESSION 247
|
||||
#define TK_STATE_WINDOW 248
|
||||
#define TK_SLIDING 249
|
||||
#define TK_FILL 250
|
||||
#define TK_VALUE 251
|
||||
#define TK_NONE 252
|
||||
#define TK_PREV 253
|
||||
#define TK_LINEAR 254
|
||||
#define TK_NEXT 255
|
||||
#define TK_HAVING 256
|
||||
#define TK_RANGE 257
|
||||
#define TK_EVERY 258
|
||||
#define TK_ORDER 259
|
||||
#define TK_SLIMIT 260
|
||||
#define TK_SOFFSET 261
|
||||
#define TK_LIMIT 262
|
||||
#define TK_OFFSET 263
|
||||
#define TK_ASC 264
|
||||
#define TK_NULLS 265
|
||||
#define TK_ABORT 266
|
||||
#define TK_AFTER 267
|
||||
#define TK_ATTACH 268
|
||||
#define TK_BEFORE 269
|
||||
#define TK_BEGIN 270
|
||||
#define TK_BITAND 271
|
||||
#define TK_BITNOT 272
|
||||
#define TK_BITOR 273
|
||||
#define TK_BLOCKS 274
|
||||
#define TK_CHANGE 275
|
||||
#define TK_COMMA 276
|
||||
#define TK_COMPACT 277
|
||||
#define TK_CONCAT 278
|
||||
#define TK_CONFLICT 279
|
||||
#define TK_COPY 280
|
||||
#define TK_DEFERRED 281
|
||||
#define TK_DELIMITERS 282
|
||||
#define TK_DETACH 283
|
||||
#define TK_DIVIDE 284
|
||||
#define TK_DOT 285
|
||||
#define TK_EACH 286
|
||||
#define TK_FAIL 287
|
||||
#define TK_FILE 288
|
||||
#define TK_FOR 289
|
||||
#define TK_GLOB 290
|
||||
#define TK_ID 291
|
||||
#define TK_IMMEDIATE 292
|
||||
#define TK_IMPORT 293
|
||||
#define TK_INITIALLY 294
|
||||
#define TK_INSTEAD 295
|
||||
#define TK_ISNULL 296
|
||||
#define TK_KEY 297
|
||||
#define TK_MODULES 298
|
||||
#define TK_NK_BITNOT 299
|
||||
#define TK_NK_SEMI 300
|
||||
#define TK_NOTNULL 301
|
||||
#define TK_OF 302
|
||||
#define TK_PLUS 303
|
||||
#define TK_PRIVILEGE 304
|
||||
#define TK_RAISE 305
|
||||
#define TK_REPLACE 306
|
||||
#define TK_RESTRICT 307
|
||||
#define TK_ROW 308
|
||||
#define TK_SEMI 309
|
||||
#define TK_STAR 310
|
||||
#define TK_STATEMENT 311
|
||||
#define TK_STRING 312
|
||||
#define TK_TIMES 313
|
||||
#define TK_UPDATE 314
|
||||
#define TK_VALUES 315
|
||||
#define TK_VARIABLE 316
|
||||
#define TK_VIEW 317
|
||||
#define TK_WAL 318
|
||||
#define TK_SUBSCRIBE 43
|
||||
#define TK_NK_COMMA 44
|
||||
#define TK_READ 45
|
||||
#define TK_WRITE 46
|
||||
#define TK_NK_DOT 47
|
||||
#define TK_DNODE 48
|
||||
#define TK_PORT 49
|
||||
#define TK_DNODES 50
|
||||
#define TK_NK_IPTOKEN 51
|
||||
#define TK_FORCE 52
|
||||
#define TK_LOCAL 53
|
||||
#define TK_QNODE 54
|
||||
#define TK_BNODE 55
|
||||
#define TK_SNODE 56
|
||||
#define TK_MNODE 57
|
||||
#define TK_DATABASE 58
|
||||
#define TK_USE 59
|
||||
#define TK_FLUSH 60
|
||||
#define TK_TRIM 61
|
||||
#define TK_IF 62
|
||||
#define TK_NOT 63
|
||||
#define TK_EXISTS 64
|
||||
#define TK_BUFFER 65
|
||||
#define TK_CACHEMODEL 66
|
||||
#define TK_CACHESIZE 67
|
||||
#define TK_COMP 68
|
||||
#define TK_DURATION 69
|
||||
#define TK_NK_VARIABLE 70
|
||||
#define TK_MAXROWS 71
|
||||
#define TK_MINROWS 72
|
||||
#define TK_KEEP 73
|
||||
#define TK_PAGES 74
|
||||
#define TK_PAGESIZE 75
|
||||
#define TK_TSDB_PAGESIZE 76
|
||||
#define TK_PRECISION 77
|
||||
#define TK_REPLICA 78
|
||||
#define TK_STRICT 79
|
||||
#define TK_VGROUPS 80
|
||||
#define TK_SINGLE_STABLE 81
|
||||
#define TK_RETENTIONS 82
|
||||
#define TK_SCHEMALESS 83
|
||||
#define TK_WAL_LEVEL 84
|
||||
#define TK_WAL_FSYNC_PERIOD 85
|
||||
#define TK_WAL_RETENTION_PERIOD 86
|
||||
#define TK_WAL_RETENTION_SIZE 87
|
||||
#define TK_WAL_ROLL_PERIOD 88
|
||||
#define TK_WAL_SEGMENT_SIZE 89
|
||||
#define TK_STT_TRIGGER 90
|
||||
#define TK_TABLE_PREFIX 91
|
||||
#define TK_TABLE_SUFFIX 92
|
||||
#define TK_NK_COLON 93
|
||||
#define TK_MAX_SPEED 94
|
||||
#define TK_TABLE 95
|
||||
#define TK_NK_LP 96
|
||||
#define TK_NK_RP 97
|
||||
#define TK_STABLE 98
|
||||
#define TK_ADD 99
|
||||
#define TK_COLUMN 100
|
||||
#define TK_MODIFY 101
|
||||
#define TK_RENAME 102
|
||||
#define TK_TAG 103
|
||||
#define TK_SET 104
|
||||
#define TK_NK_EQ 105
|
||||
#define TK_USING 106
|
||||
#define TK_TAGS 107
|
||||
#define TK_COMMENT 108
|
||||
#define TK_BOOL 109
|
||||
#define TK_TINYINT 110
|
||||
#define TK_SMALLINT 111
|
||||
#define TK_INT 112
|
||||
#define TK_INTEGER 113
|
||||
#define TK_BIGINT 114
|
||||
#define TK_FLOAT 115
|
||||
#define TK_DOUBLE 116
|
||||
#define TK_BINARY 117
|
||||
#define TK_TIMESTAMP 118
|
||||
#define TK_NCHAR 119
|
||||
#define TK_UNSIGNED 120
|
||||
#define TK_JSON 121
|
||||
#define TK_VARCHAR 122
|
||||
#define TK_MEDIUMBLOB 123
|
||||
#define TK_BLOB 124
|
||||
#define TK_VARBINARY 125
|
||||
#define TK_DECIMAL 126
|
||||
#define TK_MAX_DELAY 127
|
||||
#define TK_WATERMARK 128
|
||||
#define TK_ROLLUP 129
|
||||
#define TK_TTL 130
|
||||
#define TK_SMA 131
|
||||
#define TK_FIRST 132
|
||||
#define TK_LAST 133
|
||||
#define TK_SHOW 134
|
||||
#define TK_PRIVILEGES 135
|
||||
#define TK_DATABASES 136
|
||||
#define TK_TABLES 137
|
||||
#define TK_STABLES 138
|
||||
#define TK_MNODES 139
|
||||
#define TK_QNODES 140
|
||||
#define TK_FUNCTIONS 141
|
||||
#define TK_INDEXES 142
|
||||
#define TK_ACCOUNTS 143
|
||||
#define TK_APPS 144
|
||||
#define TK_CONNECTIONS 145
|
||||
#define TK_LICENCES 146
|
||||
#define TK_GRANTS 147
|
||||
#define TK_QUERIES 148
|
||||
#define TK_SCORES 149
|
||||
#define TK_TOPICS 150
|
||||
#define TK_VARIABLES 151
|
||||
#define TK_CLUSTER 152
|
||||
#define TK_BNODES 153
|
||||
#define TK_SNODES 154
|
||||
#define TK_TRANSACTIONS 155
|
||||
#define TK_DISTRIBUTED 156
|
||||
#define TK_CONSUMERS 157
|
||||
#define TK_SUBSCRIPTIONS 158
|
||||
#define TK_VNODES 159
|
||||
#define TK_LIKE 160
|
||||
#define TK_TBNAME 161
|
||||
#define TK_QTAGS 162
|
||||
#define TK_AS 163
|
||||
#define TK_INDEX 164
|
||||
#define TK_FUNCTION 165
|
||||
#define TK_INTERVAL 166
|
||||
#define TK_TOPIC 167
|
||||
#define TK_WITH 168
|
||||
#define TK_META 169
|
||||
#define TK_CONSUMER 170
|
||||
#define TK_GROUP 171
|
||||
#define TK_DESC 172
|
||||
#define TK_DESCRIBE 173
|
||||
#define TK_RESET 174
|
||||
#define TK_QUERY 175
|
||||
#define TK_CACHE 176
|
||||
#define TK_EXPLAIN 177
|
||||
#define TK_ANALYZE 178
|
||||
#define TK_VERBOSE 179
|
||||
#define TK_NK_BOOL 180
|
||||
#define TK_RATIO 181
|
||||
#define TK_NK_FLOAT 182
|
||||
#define TK_OUTPUTTYPE 183
|
||||
#define TK_AGGREGATE 184
|
||||
#define TK_BUFSIZE 185
|
||||
#define TK_STREAM 186
|
||||
#define TK_INTO 187
|
||||
#define TK_TRIGGER 188
|
||||
#define TK_AT_ONCE 189
|
||||
#define TK_WINDOW_CLOSE 190
|
||||
#define TK_IGNORE 191
|
||||
#define TK_EXPIRED 192
|
||||
#define TK_FILL_HISTORY 193
|
||||
#define TK_SUBTABLE 194
|
||||
#define TK_KILL 195
|
||||
#define TK_CONNECTION 196
|
||||
#define TK_TRANSACTION 197
|
||||
#define TK_BALANCE 198
|
||||
#define TK_VGROUP 199
|
||||
#define TK_MERGE 200
|
||||
#define TK_REDISTRIBUTE 201
|
||||
#define TK_SPLIT 202
|
||||
#define TK_DELETE 203
|
||||
#define TK_INSERT 204
|
||||
#define TK_NULL 205
|
||||
#define TK_NK_QUESTION 206
|
||||
#define TK_NK_ARROW 207
|
||||
#define TK_ROWTS 208
|
||||
#define TK_QSTART 209
|
||||
#define TK_QEND 210
|
||||
#define TK_QDURATION 211
|
||||
#define TK_WSTART 212
|
||||
#define TK_WEND 213
|
||||
#define TK_WDURATION 214
|
||||
#define TK_IROWTS 215
|
||||
#define TK_CAST 216
|
||||
#define TK_NOW 217
|
||||
#define TK_TODAY 218
|
||||
#define TK_TIMEZONE 219
|
||||
#define TK_CLIENT_VERSION 220
|
||||
#define TK_SERVER_VERSION 221
|
||||
#define TK_SERVER_STATUS 222
|
||||
#define TK_CURRENT_USER 223
|
||||
#define TK_COUNT 224
|
||||
#define TK_LAST_ROW 225
|
||||
#define TK_CASE 226
|
||||
#define TK_END 227
|
||||
#define TK_WHEN 228
|
||||
#define TK_THEN 229
|
||||
#define TK_ELSE 230
|
||||
#define TK_BETWEEN 231
|
||||
#define TK_IS 232
|
||||
#define TK_NK_LT 233
|
||||
#define TK_NK_GT 234
|
||||
#define TK_NK_LE 235
|
||||
#define TK_NK_GE 236
|
||||
#define TK_NK_NE 237
|
||||
#define TK_MATCH 238
|
||||
#define TK_NMATCH 239
|
||||
#define TK_CONTAINS 240
|
||||
#define TK_IN 241
|
||||
#define TK_JOIN 242
|
||||
#define TK_INNER 243
|
||||
#define TK_SELECT 244
|
||||
#define TK_DISTINCT 245
|
||||
#define TK_WHERE 246
|
||||
#define TK_PARTITION 247
|
||||
#define TK_BY 248
|
||||
#define TK_SESSION 249
|
||||
#define TK_STATE_WINDOW 250
|
||||
#define TK_SLIDING 251
|
||||
#define TK_FILL 252
|
||||
#define TK_VALUE 253
|
||||
#define TK_NONE 254
|
||||
#define TK_PREV 255
|
||||
#define TK_LINEAR 256
|
||||
#define TK_NEXT 257
|
||||
#define TK_HAVING 258
|
||||
#define TK_RANGE 259
|
||||
#define TK_EVERY 260
|
||||
#define TK_ORDER 261
|
||||
#define TK_SLIMIT 262
|
||||
#define TK_SOFFSET 263
|
||||
#define TK_LIMIT 264
|
||||
#define TK_OFFSET 265
|
||||
#define TK_ASC 266
|
||||
#define TK_NULLS 267
|
||||
#define TK_ABORT 268
|
||||
#define TK_AFTER 269
|
||||
#define TK_ATTACH 270
|
||||
#define TK_BEFORE 271
|
||||
#define TK_BEGIN 272
|
||||
#define TK_BITAND 273
|
||||
#define TK_BITNOT 274
|
||||
#define TK_BITOR 275
|
||||
#define TK_BLOCKS 276
|
||||
#define TK_CHANGE 277
|
||||
#define TK_COMMA 278
|
||||
#define TK_COMPACT 279
|
||||
#define TK_CONCAT 280
|
||||
#define TK_CONFLICT 281
|
||||
#define TK_COPY 282
|
||||
#define TK_DEFERRED 283
|
||||
#define TK_DELIMITERS 284
|
||||
#define TK_DETACH 285
|
||||
#define TK_DIVIDE 286
|
||||
#define TK_DOT 287
|
||||
#define TK_EACH 288
|
||||
#define TK_FAIL 289
|
||||
#define TK_FILE 290
|
||||
#define TK_FOR 291
|
||||
#define TK_GLOB 292
|
||||
#define TK_ID 293
|
||||
#define TK_IMMEDIATE 294
|
||||
#define TK_IMPORT 295
|
||||
#define TK_INITIALLY 296
|
||||
#define TK_INSTEAD 297
|
||||
#define TK_ISNULL 298
|
||||
#define TK_KEY 299
|
||||
#define TK_MODULES 300
|
||||
#define TK_NK_BITNOT 301
|
||||
#define TK_NK_SEMI 302
|
||||
#define TK_NOTNULL 303
|
||||
#define TK_OF 304
|
||||
#define TK_PLUS 305
|
||||
#define TK_PRIVILEGE 306
|
||||
#define TK_RAISE 307
|
||||
#define TK_REPLACE 308
|
||||
#define TK_RESTRICT 309
|
||||
#define TK_ROW 310
|
||||
#define TK_SEMI 311
|
||||
#define TK_STAR 312
|
||||
#define TK_STATEMENT 313
|
||||
#define TK_STRING 314
|
||||
#define TK_TIMES 315
|
||||
#define TK_UPDATE 316
|
||||
#define TK_VALUES 317
|
||||
#define TK_VARIABLE 318
|
||||
#define TK_VIEW 319
|
||||
#define TK_WAL 320
|
||||
|
||||
#define TK_NK_SPACE 600
|
||||
#define TK_NK_COMMENT 601
|
||||
|
|
|
@ -160,13 +160,6 @@ int32_t qAsyncKillTask(qTaskInfo_t tinfo);
|
|||
*/
|
||||
void qDestroyTask(qTaskInfo_t tinfo);
|
||||
|
||||
/**
|
||||
* Get the queried table uid
|
||||
* @param qHandle
|
||||
* @return
|
||||
*/
|
||||
int64_t qGetQueriedTableUid(qTaskInfo_t tinfo);
|
||||
|
||||
/**
|
||||
* Extract the qualified table id list, and than pass them to the TSDB driver to load the required table data blocks.
|
||||
*
|
||||
|
|
|
@ -57,7 +57,7 @@ typedef struct SFuncExecFuncs {
|
|||
#define MAX_INTERVAL_TIME_WINDOW 10000000 // maximum allowed time windows in final results
|
||||
|
||||
#define TOP_BOTTOM_QUERY_LIMIT 100
|
||||
#define FUNCTIONS_NAME_MAX_LENGTH 16
|
||||
#define FUNCTIONS_NAME_MAX_LENGTH 32
|
||||
|
||||
typedef struct SResultRowEntryInfo {
|
||||
bool initialized : 1; // output buffer has been initialized
|
||||
|
|
|
@ -42,9 +42,10 @@ extern "C" {
|
|||
|
||||
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
|
||||
|
||||
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
|
||||
#define PRIVILEGE_TYPE_READ PRIVILEGE_TYPE_MASK(1)
|
||||
#define PRIVILEGE_TYPE_WRITE PRIVILEGE_TYPE_MASK(2)
|
||||
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
|
||||
#define PRIVILEGE_TYPE_READ PRIVILEGE_TYPE_MASK(1)
|
||||
#define PRIVILEGE_TYPE_WRITE PRIVILEGE_TYPE_MASK(2)
|
||||
#define PRIVILEGE_TYPE_SUBSCRIBE PRIVILEGE_TYPE_MASK(3)
|
||||
|
||||
#define PRIVILEGE_TYPE_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
||||
|
||||
|
@ -423,7 +424,7 @@ typedef struct SDropFunctionStmt {
|
|||
typedef struct SGrantStmt {
|
||||
ENodeType type;
|
||||
char userName[TSDB_USER_LEN];
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char objName[TSDB_DB_NAME_LEN]; // db or topic
|
||||
int64_t privileges;
|
||||
} SGrantStmt;
|
||||
|
||||
|
|
|
@ -187,6 +187,7 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_SHOW_TRANSACTIONS_STMT,
|
||||
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT,
|
||||
QUERY_NODE_SHOW_VNODES_STMT,
|
||||
QUERY_NODE_SHOW_USER_PRIVILEGES_STMT,
|
||||
QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
|
||||
QUERY_NODE_SHOW_CREATE_TABLE_STMT,
|
||||
QUERY_NODE_SHOW_CREATE_STABLE_STMT,
|
||||
|
|
|
@ -106,7 +106,7 @@ typedef struct SValueNode {
|
|||
char* p;
|
||||
} datum;
|
||||
int64_t typeData;
|
||||
char unit;
|
||||
int8_t unit;
|
||||
} SValueNode;
|
||||
|
||||
typedef struct SLeftValueNode {
|
||||
|
|
|
@ -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*, const char*);
|
||||
int32_t (*setInfoFn)(TAOS_STMT*, STableMeta*, void*, SName*, bool, SHashObj*, SHashObj*, const char*);
|
||||
int32_t (*getExecInfoFn)(TAOS_STMT*, SHashObj**, SHashObj**);
|
||||
} SStmtCallback;
|
||||
|
||||
|
@ -108,7 +108,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, const char* sTableName, int32_t sTableNameLen, char* msgBuf, int16_t msgBufLen);
|
||||
char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl, char* msgBuf, int16_t msgBufLen);
|
||||
int32_t smlBuildOutput(void* handle, SHashObj* pVgHash);
|
||||
|
||||
int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
|
||||
|
|
|
@ -259,9 +259,15 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
|||
#define NEED_CLIENT_HANDLE_ERROR(_code) \
|
||||
(NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \
|
||||
NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code))
|
||||
|
||||
#define SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
|
||||
#define SYNC_SELF_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
|
||||
#define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) (false) // used later
|
||||
|
||||
#define NEED_REDIRECT_ERROR(_code) \
|
||||
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \
|
||||
(_code) == TSDB_CODE_NODE_NOT_DEPLOYED || (_code) == TSDB_CODE_SYN_NOT_LEADER || \
|
||||
(_code) == TSDB_CODE_NODE_NOT_DEPLOYED || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
|
||||
SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) || \
|
||||
(_code) == TSDB_CODE_APP_NOT_READY || (_code) == TSDB_CODE_RPC_BROKEN_LINK)
|
||||
|
||||
#define NEED_CLIENT_RM_TBLMETA_REQ(_type) \
|
||||
|
@ -270,7 +276,8 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
|||
|
||||
#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \
|
||||
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || \
|
||||
(_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_APP_NOT_READY)
|
||||
SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || \
|
||||
SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) || (_code) == TSDB_CODE_APP_NOT_READY)
|
||||
|
||||
#define REQUEST_TOTAL_EXEC_TIMES 2
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ typedef struct SWal SWal;
|
|||
typedef struct SSyncRaftEntry SSyncRaftEntry;
|
||||
|
||||
typedef enum {
|
||||
TAOS_SYNC_STATE_OFFLINE = 0,
|
||||
TAOS_SYNC_STATE_FOLLOWER = 100,
|
||||
TAOS_SYNC_STATE_CANDIDATE = 101,
|
||||
TAOS_SYNC_STATE_LEADER = 102,
|
||||
|
|
|
@ -85,6 +85,11 @@ typedef struct SRpcInit {
|
|||
int32_t retryLimit; // retry limit
|
||||
int32_t retryInterval; // retry interval ms
|
||||
|
||||
int32_t retryMinInterval; // retry init interval
|
||||
int32_t retryStepFactor; // retry interval factor
|
||||
int32_t retryMaxInterval; // retry max interval
|
||||
int64_t retryMaxTimouet;
|
||||
|
||||
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
||||
int8_t encryption; // encrypt or not
|
||||
|
||||
|
|
|
@ -43,12 +43,14 @@ extern "C" {
|
|||
#include <sys/utsname.h>
|
||||
#include <sys/wait.h>
|
||||
#include <termios.h>
|
||||
#include <cpuid.h>
|
||||
|
||||
#if defined(DARWIN)
|
||||
#else
|
||||
#include <argp.h>
|
||||
#include <sys/prctl.h>
|
||||
#if defined(_TD_X86_)
|
||||
#include <cpuid.h>
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
|
||||
|
|
|
@ -169,6 +169,9 @@ void taosSetMaskSIGPIPE();
|
|||
uint32_t taosInetAddr(const char *ipAddr);
|
||||
const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len);
|
||||
|
||||
uint64_t taosHton64(uint64_t val);
|
||||
uint64_t taosNtoh64(uint64_t val);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -27,7 +27,8 @@ extern "C" {
|
|||
typedef int32_t (*__compar_fn_t)(const void *, const void *);
|
||||
#endif
|
||||
|
||||
typedef void *(*FCopy)(void *);
|
||||
typedef void *(*__array_item_dup_fn_t)(void *);
|
||||
|
||||
typedef void (*FDelete)(void *);
|
||||
typedef int32_t (*FEncode)(void **buf, const void *dst);
|
||||
typedef void *(*FDecode)(const void *buf, void *dst);
|
||||
|
@ -41,7 +42,6 @@ typedef void *(*FDecode)(const void *buf, void *dst);
|
|||
#define elePtrAt(base, size, idx) (void *)((char *)(base) + (size) * (idx))
|
||||
|
||||
typedef int32_t (*__ext_compar_fn_t)(const void *p1, const void *p2, const void *param);
|
||||
typedef void (*__ext_swap_fn_t)(void *p1, void *p2, const void *param);
|
||||
|
||||
/**
|
||||
* quick sort, with the compare function requiring additional parameters support
|
||||
|
|
|
@ -92,6 +92,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0129)
|
||||
#define TSDB_CODE_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x012A)
|
||||
#define TSDB_CODE_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x012B)
|
||||
#define TSDB_CODE_TIMEOUT_ERROR TAOS_DEF_ERROR_CODE(0, 0x012C)
|
||||
|
||||
//client
|
||||
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
||||
|
@ -415,6 +416,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_SYN_PROPOSE_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0911)
|
||||
#define TSDB_CODE_SYN_STANDBY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0912)
|
||||
#define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913)
|
||||
#define TSDB_CODE_SYN_RESTORING TAOS_DEF_ERROR_CODE(0, 0x0914)
|
||||
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
||||
|
||||
// tq
|
||||
|
|
|
@ -205,13 +205,7 @@ SArray* taosArrayFromList(const void* src, size_t size, size_t elemSize);
|
|||
* clone a new array
|
||||
* @param pSrc
|
||||
*/
|
||||
SArray* taosArrayDup(const SArray* pSrc);
|
||||
|
||||
/**
|
||||
* deep copy a new array
|
||||
* @param pSrc
|
||||
*/
|
||||
SArray* taosArrayDeepCopy(const SArray* pSrc, FCopy deepCopy);
|
||||
SArray* taosArrayDup(const SArray* pSrc, __array_item_dup_fn_t fn);
|
||||
|
||||
/**
|
||||
* clear the array (remove all element)
|
||||
|
@ -226,15 +220,10 @@ void taosArrayClear(SArray* pArray);
|
|||
*/
|
||||
void taosArrayClearEx(SArray* pArray, void (*fp)(void*));
|
||||
|
||||
/**
|
||||
* clear the array (remove all element)
|
||||
* @param pArray
|
||||
* @param fp
|
||||
*/
|
||||
void taosArrayClearP(SArray* pArray, FDelete fp);
|
||||
|
||||
void* taosArrayDestroy(SArray* pArray);
|
||||
|
||||
void taosArrayDestroyP(SArray* pArray, FDelete fp);
|
||||
|
||||
void taosArrayDestroyEx(SArray* pArray, FDelete fp);
|
||||
|
||||
/**
|
||||
|
@ -244,12 +233,6 @@ void taosArrayDestroyEx(SArray* pArray, FDelete fp);
|
|||
*/
|
||||
void taosArraySort(SArray* pArray, __compar_fn_t comparFn);
|
||||
|
||||
/**
|
||||
* sort string array
|
||||
* @param pArray
|
||||
*/
|
||||
void taosArraySortString(SArray* pArray, __compar_fn_t comparFn);
|
||||
|
||||
/**
|
||||
* search the array
|
||||
* @param pArray
|
||||
|
|
|
@ -406,7 +406,7 @@ typedef enum ELogicConditionType {
|
|||
#ifdef WINDOWS
|
||||
#define TSDB_MAX_RPC_THREADS 4 // windows pipe only support 4 connections.
|
||||
#else
|
||||
#define TSDB_MAX_RPC_THREADS 10
|
||||
#define TSDB_MAX_RPC_THREADS 20
|
||||
#endif
|
||||
|
||||
#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type
|
||||
|
|
|
@ -205,6 +205,7 @@ function set_hostname() {
|
|||
break
|
||||
else
|
||||
read -p "Please enter one hostname(must not be 'localhost'):" newHostname
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -324,7 +325,9 @@ function local_fqdn_check() {
|
|||
;;
|
||||
|
||||
*)
|
||||
set_ipAsFqdn
|
||||
echo "Invalid input..."
|
||||
break
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
|
|
@ -51,7 +51,7 @@ Source: taos.bat; DestDir: "{app}\include"; Flags: igNoreversion;
|
|||
;Source: taosdemo.png; DestDir: "{app}\include"; Flags: igNoreversion;
|
||||
;Source: taosShell.png; DestDir: "{app}\include"; Flags: igNoreversion;
|
||||
Source: favicon.ico; DestDir: "{app}\include"; Flags: igNoreversion;
|
||||
Source: {#MyAppSourceDir}{#MyAppDLLName}; DestDir: "{win}\System32"; Flags: 64bit;Check:IsWin64;
|
||||
Source: {#MyAppSourceDir}{#MyAppDLLName}; DestDir: "{win}\System32"; Flags: igNoreversion recursesubdirs createallsubdirs 64bit;Check:IsWin64;
|
||||
Source: {#MyAppSourceDir}{#MyAppCfgName}; DestDir: "{app}\cfg"; Flags: igNoreversion recursesubdirs createallsubdirs onlyifdoesntexist uninsneveruninstall
|
||||
Source: {#MyAppSourceDir}{#MyAppDriverName}; DestDir: "{app}\driver"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||
;Source: {#MyAppSourceDir}{#MyAppConnectorName}; DestDir: "{app}\connector"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||
|
|
|
@ -148,6 +148,10 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
|||
rpcInit.dfp = destroyAhandle;
|
||||
rpcInit.retryLimit = tsRpcRetryLimit;
|
||||
rpcInit.retryInterval = tsRpcRetryInterval;
|
||||
rpcInit.retryMinInterval = tsRedirectPeriod;
|
||||
rpcInit.retryStepFactor = tsRedirectFactor;
|
||||
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
||||
rpcInit.retryMaxTimouet = tsMaxRetryWaitTime;
|
||||
|
||||
void *pDnodeConn = rpcOpen(&rpcInit);
|
||||
if (pDnodeConn == NULL) {
|
||||
|
|
|
@ -131,7 +131,7 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
|
|||
p = taosMemoryCalloc(1, sizeof(struct SAppInstInfo));
|
||||
p->mgmtEp = epSet;
|
||||
taosThreadMutexInit(&p->qnodeMutex, NULL);
|
||||
p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores);
|
||||
p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores / 2);
|
||||
p->pAppHbMgr = appHbMgrInit(p, key);
|
||||
if (NULL == p->pAppHbMgr) {
|
||||
destroyAppInst(p);
|
||||
|
@ -373,7 +373,7 @@ int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList) {
|
|||
}
|
||||
|
||||
if (pNodeList) {
|
||||
pInfo->pQnodeList = taosArrayDup(pNodeList);
|
||||
pInfo->pQnodeList = taosArrayDup(pNodeList, NULL);
|
||||
taosArraySort(pInfo->pQnodeList, compareQueryNodeLoad);
|
||||
tscDebug("QnodeList updated in cluster 0x%" PRIx64 ", num:%ld", pInfo->clusterId,
|
||||
taosArrayGetSize(pInfo->pQnodeList));
|
||||
|
@ -404,7 +404,7 @@ int32_t getQnodeList(SRequestObj* pRequest, SArray** pNodeList) {
|
|||
|
||||
taosThreadMutexLock(&pInfo->qnodeMutex);
|
||||
if (pInfo->pQnodeList) {
|
||||
*pNodeList = taosArrayDup(pInfo->pQnodeList);
|
||||
*pNodeList = taosArrayDup(pInfo->pQnodeList, NULL);
|
||||
}
|
||||
taosThreadMutexUnlock(&pInfo->qnodeMutex);
|
||||
|
||||
|
@ -593,13 +593,13 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray
|
|||
if (pRes->code) {
|
||||
pQnodeList = NULL;
|
||||
} else {
|
||||
pQnodeList = taosArrayDup((SArray*)pRes->pRes);
|
||||
pQnodeList = taosArrayDup((SArray*)pRes->pRes, NULL);
|
||||
}
|
||||
} else {
|
||||
SAppInstInfo* pInst = pRequest->pTscObj->pAppInfo;
|
||||
taosThreadMutexLock(&pInst->qnodeMutex);
|
||||
if (pInst->pQnodeList) {
|
||||
pQnodeList = taosArrayDup(pInst->pQnodeList);
|
||||
pQnodeList = taosArrayDup(pInst->pQnodeList, NULL);
|
||||
}
|
||||
taosThreadMutexUnlock(&pInst->qnodeMutex);
|
||||
}
|
||||
|
@ -1645,7 +1645,7 @@ int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols) {
|
|||
static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, int32_t numOfRows) {
|
||||
char* p = (char*)pResultInfo->pData;
|
||||
|
||||
// version + length + numOfRows + numOfCol + groupId + flag_segment + column_info
|
||||
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length |
|
||||
int32_t len = getVersion1BlockMetaSize(p, numOfCols);
|
||||
int32_t* colLength = (int32_t*)(p + len);
|
||||
len += sizeof(int32_t) * numOfCols;
|
||||
|
@ -2293,10 +2293,16 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) {
|
|||
|
||||
taosAsyncQueryImpl(*(int64_t*)taos, sql, syncQueryFn, param, validateOnly);
|
||||
tsem_wait(¶m->sem);
|
||||
|
||||
SRequestObj *pRequest = NULL;
|
||||
if (param->pRequest != NULL) {
|
||||
param->pRequest->syncQuery = true;
|
||||
pRequest = param->pRequest;
|
||||
} else {
|
||||
taosMemoryFree(param);
|
||||
}
|
||||
return param->pRequest;
|
||||
|
||||
return pRequest;
|
||||
}
|
||||
|
||||
TAOS_RES* taosQueryImplWithReqid(TAOS* taos, const char* sql, bool validateOnly, int64_t reqid) {
|
||||
|
@ -2310,8 +2316,14 @@ TAOS_RES* taosQueryImplWithReqid(TAOS* taos, const char* sql, bool validateOnly,
|
|||
|
||||
taosAsyncQueryImplWithReqid(*(int64_t*)taos, sql, syncQueryFn, param, validateOnly, reqid);
|
||||
tsem_wait(¶m->sem);
|
||||
|
||||
SRequestObj *pRequest = NULL;
|
||||
if (param->pRequest != NULL) {
|
||||
param->pRequest->syncQuery = true;
|
||||
pRequest = param->pRequest;
|
||||
} else {
|
||||
taosMemoryFree(param);
|
||||
}
|
||||
return param->pRequest;
|
||||
|
||||
return pRequest;
|
||||
}
|
||||
|
|
|
@ -1211,6 +1211,208 @@ static void destroyVgHash(void* data) {
|
|||
taosMemoryFreeClear(vgData->data);
|
||||
}
|
||||
|
||||
int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const char* tbname, TAOS_FIELD *fields, int numFields){
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
STableMeta* pTableMeta = NULL;
|
||||
SQuery* pQuery = NULL;
|
||||
SSubmitReq* subReq = NULL;
|
||||
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
|
||||
if (!pRequest) {
|
||||
uError("WriteRaw:createRequest error request is null");
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
|
||||
pRequest->syncQuery = true;
|
||||
if (!pRequest->pDb) {
|
||||
uError("WriteRaw:not use db");
|
||||
code = TSDB_CODE_PAR_DB_NOT_SPECIFIED;
|
||||
goto end;
|
||||
}
|
||||
|
||||
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
||||
tstrncpy(pName.dbname, pRequest->pDb, sizeof(pName.dbname));
|
||||
tstrncpy(pName.tname, tbname, sizeof(pName.tname));
|
||||
|
||||
struct SCatalog* pCatalog = NULL;
|
||||
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("WriteRaw: get gatlog error");
|
||||
goto end;
|
||||
}
|
||||
|
||||
SRequestConnInfo conn = {0};
|
||||
conn.pTrans = pRequest->pTscObj->pAppInfo->pTransporter;
|
||||
conn.requestId = pRequest->requestId;
|
||||
conn.requestObjRefId = pRequest->self;
|
||||
conn.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp);
|
||||
|
||||
SVgroupInfo vgData = {0};
|
||||
code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vgData);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("WriteRaw:catalogGetTableHashVgroup failed. table name: %s", tbname);
|
||||
goto end;
|
||||
}
|
||||
|
||||
code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("WriteRaw:catalogGetTableMeta failed. table name: %s", tbname);
|
||||
goto end;
|
||||
}
|
||||
uint64_t suid = (TSDB_NORMAL_TABLE == pTableMeta->tableType ? 0 : pTableMeta->suid);
|
||||
uint64_t uid = pTableMeta->uid;
|
||||
int32_t numOfCols = pTableMeta->tableInfo.numOfColumns;
|
||||
|
||||
uint16_t fLen = 0;
|
||||
int32_t rowSize = 0;
|
||||
int16_t nVar = 0;
|
||||
for (int i = 0; i < pTableMeta->tableInfo.numOfColumns; i++) {
|
||||
SSchema* schema = pTableMeta->schema + i;
|
||||
fLen += TYPE_BYTES[schema->type];
|
||||
rowSize += schema->bytes;
|
||||
if (IS_VAR_DATA_TYPE(schema->type)) {
|
||||
nVar++;
|
||||
}
|
||||
}
|
||||
|
||||
fLen -= sizeof(TSKEY);
|
||||
|
||||
int32_t extendedRowSize = rowSize + TD_ROW_HEAD_LEN - sizeof(TSKEY) + nVar * sizeof(VarDataOffsetT) +
|
||||
(int32_t)TD_BITMAP_BYTES(numOfCols - 1);
|
||||
int32_t schemaLen = 0;
|
||||
int32_t submitLen = sizeof(SSubmitBlk) + schemaLen + rows * extendedRowSize;
|
||||
|
||||
int32_t totalLen = sizeof(SSubmitReq) + submitLen;
|
||||
subReq = taosMemoryCalloc(1, totalLen);
|
||||
SSubmitBlk* blk = POINTER_SHIFT(subReq, sizeof(SSubmitReq));
|
||||
void* blkSchema = POINTER_SHIFT(blk, sizeof(SSubmitBlk));
|
||||
STSRow* rowData = POINTER_SHIFT(blkSchema, schemaLen);
|
||||
|
||||
SRowBuilder rb = {0};
|
||||
tdSRowInit(&rb, pTableMeta->sversion);
|
||||
tdSRowSetTpInfo(&rb, numOfCols, fLen);
|
||||
int32_t dataLen = 0;
|
||||
|
||||
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length |
|
||||
char* pStart = pData + getVersion1BlockMetaSize(pData, numFields);
|
||||
int32_t* colLength = (int32_t*)pStart;
|
||||
pStart += sizeof(int32_t) * numFields;
|
||||
|
||||
SResultColumn* pCol = taosMemoryCalloc(numFields, sizeof(SResultColumn));
|
||||
|
||||
for (int32_t i = 0; i < numFields; ++i) {
|
||||
if (IS_VAR_DATA_TYPE(fields[i].type)) {
|
||||
pCol[i].offset = (int32_t*)pStart;
|
||||
pStart += rows * sizeof(int32_t);
|
||||
} else {
|
||||
pCol[i].nullbitmap = pStart;
|
||||
pStart += BitmapLen(rows);
|
||||
}
|
||||
|
||||
pCol[i].pData = pStart;
|
||||
pStart += colLength[i];
|
||||
}
|
||||
|
||||
SHashObj* schemaHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
for (int i = 0; i < numFields; i++) {
|
||||
TAOS_FIELD* schema = &fields[i];
|
||||
taosHashPut(schemaHash, schema->name, strlen(schema->name), &i, sizeof(int32_t));
|
||||
}
|
||||
|
||||
for (int32_t j = 0; j < rows; j++) {
|
||||
tdSRowResetBuf(&rb, rowData);
|
||||
int32_t offset = 0;
|
||||
for (int32_t k = 0; k < numOfCols; k++) {
|
||||
const SSchema* pColumn = &pTableMeta->schema[k];
|
||||
int32_t* index = taosHashGet(schemaHash, pColumn->name, strlen(pColumn->name));
|
||||
if (!index) { // add none
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NONE, NULL, false, offset, k);
|
||||
}else{
|
||||
if (IS_VAR_DATA_TYPE(pColumn->type)) {
|
||||
if (pCol[*index].offset[j] != -1) {
|
||||
char* data = pCol[*index].pData + pCol[*index].offset[j];
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, offset, k);
|
||||
} else {
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k);
|
||||
}
|
||||
} else {
|
||||
if (!colDataIsNull_f(pCol[*index].nullbitmap, j)) {
|
||||
char* data = pCol[*index].pData + pColumn->bytes * j;
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, offset, k);
|
||||
} else {
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pColumn->colId != PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
offset += TYPE_BYTES[pColumn->type];
|
||||
}
|
||||
}
|
||||
tdSRowEnd(&rb);
|
||||
int32_t rowLen = TD_ROW_LEN(rowData);
|
||||
rowData = POINTER_SHIFT(rowData, rowLen);
|
||||
dataLen += rowLen;
|
||||
}
|
||||
|
||||
taosHashCleanup(schemaHash);
|
||||
taosMemoryFree(pCol);
|
||||
|
||||
blk->uid = htobe64(uid);
|
||||
blk->suid = htobe64(suid);
|
||||
blk->sversion = htonl(pTableMeta->sversion);
|
||||
blk->schemaLen = htonl(schemaLen);
|
||||
blk->numOfRows = htonl(rows);
|
||||
blk->dataLen = htonl(dataLen);
|
||||
subReq->length = sizeof(SSubmitReq) + sizeof(SSubmitBlk) + schemaLen + dataLen;
|
||||
subReq->numOfBlocks = 1;
|
||||
|
||||
pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
if (NULL == pQuery) {
|
||||
uError("create SQuery error");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->haveResultSet = false;
|
||||
pQuery->msgType = TDMT_VND_SUBMIT;
|
||||
pQuery->pRoot = (SNode*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT);
|
||||
if (NULL == pQuery->pRoot) {
|
||||
uError("create pQuery->pRoot error");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
SVnodeModifOpStmt* nodeStmt = (SVnodeModifOpStmt*)(pQuery->pRoot);
|
||||
nodeStmt->pDataBlocks = taosArrayInit(1, POINTER_BYTES);
|
||||
|
||||
SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks));
|
||||
if (NULL == dst) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
dst->vg = vgData;
|
||||
dst->numOfTables = subReq->numOfBlocks;
|
||||
dst->size = subReq->length;
|
||||
dst->pData = (char*)subReq;
|
||||
subReq->header.vgId = htonl(dst->vg.vgId);
|
||||
subReq->version = htonl(1);
|
||||
subReq->header.contLen = htonl(subReq->length);
|
||||
subReq->length = htonl(subReq->length);
|
||||
subReq->numOfBlocks = htonl(subReq->numOfBlocks);
|
||||
subReq = NULL; // no need free
|
||||
taosArrayPush(nodeStmt->pDataBlocks, &dst);
|
||||
|
||||
launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
code = pRequest->code;
|
||||
|
||||
end:
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
qDestroyQuery(pQuery);
|
||||
taosMemoryFree(subReq);
|
||||
return code;
|
||||
}
|
||||
|
||||
int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
STableMeta* pTableMeta = NULL;
|
||||
|
@ -1293,6 +1495,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
tdSRowSetTpInfo(&rb, numOfCols, fLen);
|
||||
int32_t dataLen = 0;
|
||||
|
||||
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length |
|
||||
char* pStart = pData + getVersion1BlockMetaSize(pData, numOfCols);
|
||||
int32_t* colLength = (int32_t*)pStart;
|
||||
pStart += sizeof(int32_t) * numOfCols;
|
||||
|
@ -1577,7 +1780,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
const SSchema* pColumn = &pTableMeta->schema[k];
|
||||
int32_t* index = taosHashGet(schemaHash, pColumn->name, strlen(pColumn->name));
|
||||
if (!index) {
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k);
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NONE, NULL, false, offset, k);
|
||||
} else {
|
||||
char* colData = rspObj.resInfo.row[*index];
|
||||
if (!colData) {
|
||||
|
@ -1670,6 +1873,7 @@ end:
|
|||
return code;
|
||||
}
|
||||
|
||||
|
||||
static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SHashObj* pVgHash = NULL;
|
||||
|
@ -1882,7 +2086,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
const SSchema* pColumn = &pTableMeta->schema[k];
|
||||
int32_t* index = taosHashGet(schemaHash, pColumn->name, strlen(pColumn->name));
|
||||
if (!index) {
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k);
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NONE, NULL, false, offset, k);
|
||||
} else {
|
||||
char* colData = rspObj.resInfo.row[*index];
|
||||
if (!colData) {
|
||||
|
@ -1963,7 +2167,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
code = pRequest->code;
|
||||
|
||||
end:
|
||||
end:
|
||||
tDeleteSTaosxRsp(&rspObj.rsp);
|
||||
rspObj.resInfo.pRspMsg = NULL;
|
||||
doFreeReqResultInfo(&rspObj.resInfo);
|
||||
|
|
|
@ -79,7 +79,6 @@
|
|||
#define NCHAR_ADD_LEN 3 // L"nchar" 3 means L" "
|
||||
|
||||
#define MAX_RETRY_TIMES 5
|
||||
#define LINE_BATCH 2000
|
||||
//=================================================================================================
|
||||
typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType;
|
||||
|
||||
|
@ -162,7 +161,9 @@ typedef struct {
|
|||
|
||||
SMLProtocolType protocol;
|
||||
int8_t precision;
|
||||
bool dataFormat; // true means that the name and order of keys in each line are the same(only for influx protocol)
|
||||
bool dataFormat; // true means that the name and order of keys in each line are the same(only for influx protocol)
|
||||
bool isRawLine;
|
||||
int32_t ttl;
|
||||
|
||||
SHashObj *childTables;
|
||||
SHashObj *superTables;
|
||||
|
@ -465,6 +466,13 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
goto end;
|
||||
}
|
||||
info->cost.numOfCreateSTables++;
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
|
||||
code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " catalogGetSTableMeta failed. super table name %s", info->id, pName.tname);
|
||||
goto end;
|
||||
}
|
||||
} else if (code == TSDB_CODE_SUCCESS) {
|
||||
hashTmp = taosHashInit(pTableMeta->tableInfo.numOfTags, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true,
|
||||
HASH_NO_LOCK);
|
||||
|
@ -503,16 +511,16 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
code = catalogRefreshTableMeta(info->pCatalog, &conn, &pName, -1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
code = catalogRefreshTableMeta(info->pCatalog, &conn, &pName, -1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
taosHashClear(hashTmp);
|
||||
|
@ -550,12 +558,18 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
}
|
||||
|
||||
code = catalogRefreshTableMeta(info->pCatalog, &conn, &pName, -1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " catalogGetSTableMeta failed. super table name %s", info->id, pName.tname);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
code = catalogRefreshTableMeta(info->pCatalog, &conn, &pName, -1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
needCheckMeta = true;
|
||||
taosHashCleanup(hashTmp);
|
||||
hashTmp = NULL;
|
||||
|
@ -563,13 +577,6 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
uError("SML:0x%" PRIx64 " load table meta error: %s", info->id, tstrerror(code));
|
||||
goto end;
|
||||
}
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
|
||||
code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " catalogGetSTableMeta failed. super table name %s", info->id, pName.tname);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (needCheckMeta) {
|
||||
code = smlCheckMeta(&(pTableMeta->schema[pTableMeta->tableInfo.numOfColumns]), pTableMeta->tableInfo.numOfTags,
|
||||
|
@ -594,7 +601,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
end:
|
||||
taosHashCleanup(hashTmp);
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
catalogRefreshTableMeta(info->pCatalog, &conn, &pName, 1);
|
||||
// catalogRefreshTableMeta(info->pCatalog, &conn, &pName, 1);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -813,6 +820,11 @@ static int8_t smlGetTsTypeByPrecision(int8_t precision) {
|
|||
}
|
||||
|
||||
static int64_t smlParseInfluxTime(SSmlHandle *info, const char *data, int32_t len) {
|
||||
void *tmp = taosMemoryCalloc(1, len + 1);
|
||||
memcpy(tmp, data, len);
|
||||
uDebug("SML:0x%" PRIx64 " smlParseInfluxTime tslen:%d, ts:%s", info->id, len, (char*)tmp);
|
||||
taosMemoryFree(tmp);
|
||||
|
||||
if (len == 0 || (len == 1 && data[0] == '0')) {
|
||||
return taosGetTimestampNs();
|
||||
}
|
||||
|
@ -863,6 +875,7 @@ static int32_t smlParseTS(SSmlHandle *info, const char *data, int32_t len, SArra
|
|||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
uDebug("SML:0x%" PRIx64 " smlParseTS:%" PRId64, info->id, ts);
|
||||
|
||||
if (ts == -1) return TSDB_CODE_INVALID_TIMESTAMP;
|
||||
|
||||
|
@ -2063,7 +2076,10 @@ static int32_t smlParseJSONString(SSmlHandle *info, cJSON *root, SSmlTableInfo *
|
|||
|
||||
static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql, const int len) {
|
||||
SSmlLineInfo elements = {0};
|
||||
uDebug("SML:0x%" PRIx64 " smlParseInfluxLine sql", info->id);
|
||||
void *tmp = taosMemoryCalloc(1, len + 1);
|
||||
memcpy(tmp, sql, len);
|
||||
uDebug("SML:0x%" PRIx64 " smlParseInfluxLine raw:%d, len:%d, sql:%s", info->id, info->isRawLine, len, (info->isRawLine ? (char*)tmp : sql));
|
||||
taosMemoryFree(tmp);
|
||||
|
||||
int ret = smlParseInfluxString(sql, sql + len, &elements, &info->msgBuf);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
|
@ -2323,7 +2339,7 @@ static int32_t smlInsertData(SSmlHandle *info) {
|
|||
|
||||
code = smlBindData(info->exec, tableData->tags, (*pMeta)->cols, tableData->cols, info->dataFormat,
|
||||
(*pMeta)->tableMeta, tableData->childTableName, tableData->sTableName, tableData->sTableNameLen,
|
||||
info->msgBuf.buf, info->msgBuf.len);
|
||||
info->ttl, info->msgBuf.buf, info->msgBuf.len);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBindData failed", info->id);
|
||||
return code;
|
||||
|
@ -2514,7 +2530,7 @@ static void smlInsertCallback(void *param, void *res, int32_t code) {
|
|||
}
|
||||
|
||||
TAOS_RES *taos_schemaless_insert_inner(SRequestObj *request, char *lines[], char *rawLine, char *rawLineEnd,
|
||||
int numLines, int protocol, int precision) {
|
||||
int numLines, int protocol, int precision, int32_t ttl) {
|
||||
int batchs = 0;
|
||||
STscObj *pTscObj = request->pTscObj;
|
||||
|
||||
|
@ -2559,7 +2575,7 @@ TAOS_RES *taos_schemaless_insert_inner(SRequestObj *request, char *lines[], char
|
|||
goto end;
|
||||
}
|
||||
|
||||
batchs = ceil(((double)numLines) / LINE_BATCH);
|
||||
batchs = ceil(((double)numLines) / tsSmlBatchSize);
|
||||
params.total = batchs;
|
||||
for (int i = 0; i < batchs; ++i) {
|
||||
SRequestObj *req = (SRequestObj *)createRequest(pTscObj->id, TSDB_SQL_INSERT, 0);
|
||||
|
@ -2575,7 +2591,10 @@ TAOS_RES *taos_schemaless_insert_inner(SRequestObj *request, char *lines[], char
|
|||
goto end;
|
||||
}
|
||||
|
||||
int32_t perBatch = LINE_BATCH;
|
||||
info->isRawLine = (rawLine == NULL);
|
||||
info->ttl = ttl;
|
||||
|
||||
int32_t perBatch = tsSmlBatchSize;
|
||||
|
||||
if (numLines > perBatch) {
|
||||
numLines -= perBatch;
|
||||
|
@ -2637,88 +2656,43 @@ end:
|
|||
* @return TAOS_RES
|
||||
*/
|
||||
|
||||
TAOS_RES *taos_schemaless_insert_ttl_with_reqid(TAOS *taos, char *lines[], int numLines, int protocol, int precision,
|
||||
int32_t ttl, int64_t reqid) {
|
||||
if (NULL == taos) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SRequestObj *request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT, reqid);
|
||||
if (!request) {
|
||||
uError("SML:taos_schemaless_insert error request is null");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!lines) {
|
||||
SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf};
|
||||
request->code = TSDB_CODE_SML_INVALID_DATA;
|
||||
smlBuildInvalidDataMsg(&msg, "lines is null", NULL);
|
||||
return (TAOS_RES *)request;
|
||||
}
|
||||
|
||||
return taos_schemaless_insert_inner(request, lines, NULL, NULL, numLines, protocol, precision, ttl);
|
||||
}
|
||||
|
||||
TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) {
|
||||
if (NULL == taos) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SRequestObj *request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT, 0);
|
||||
if (!request) {
|
||||
uError("SML:taos_schemaless_insert error request is null");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!lines) {
|
||||
SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf};
|
||||
request->code = TSDB_CODE_SML_INVALID_DATA;
|
||||
smlBuildInvalidDataMsg(&msg, "lines is null", NULL);
|
||||
return (TAOS_RES *)request;
|
||||
}
|
||||
|
||||
return taos_schemaless_insert_inner(request, lines, NULL, NULL, numLines, protocol, precision);
|
||||
return taos_schemaless_insert_ttl_with_reqid(taos, lines, numLines, protocol, precision, TSDB_DEFAULT_TABLE_TTL, 0);
|
||||
}
|
||||
|
||||
TAOS_RES *taos_schemaless_insert_with_reqid(TAOS *taos, char *lines[], int numLines, int protocol, int precision,
|
||||
int64_t reqid) {
|
||||
if (NULL == taos) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SRequestObj *request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT, reqid);
|
||||
if (!request) {
|
||||
uError("SML:taos_schemaless_insert error request is null");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!lines) {
|
||||
SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf};
|
||||
request->code = TSDB_CODE_SML_INVALID_DATA;
|
||||
smlBuildInvalidDataMsg(&msg, "lines is null", NULL);
|
||||
return (TAOS_RES *)request;
|
||||
}
|
||||
|
||||
return taos_schemaless_insert_inner(request, lines, NULL, NULL, numLines, protocol, precision);
|
||||
TAOS_RES *taos_schemaless_insert_ttl(TAOS *taos, char *lines[], int numLines, int protocol, int precision, int32_t ttl) {
|
||||
return taos_schemaless_insert_ttl_with_reqid(taos, lines, numLines, protocol, precision, ttl, 0);
|
||||
}
|
||||
|
||||
TAOS_RES *taos_schemaless_insert_raw(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
|
||||
int precision) {
|
||||
if (NULL == taos) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SRequestObj *request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT, 0);
|
||||
if (!request) {
|
||||
uError("SML:taos_schemaless_insert error request is null");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!lines || len <= 0) {
|
||||
SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf};
|
||||
request->code = TSDB_CODE_SML_INVALID_DATA;
|
||||
smlBuildInvalidDataMsg(&msg, "lines is null", NULL);
|
||||
return (TAOS_RES *)request;
|
||||
}
|
||||
|
||||
int numLines = 0;
|
||||
*totalRows = 0;
|
||||
char *tmp = lines;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (lines[i] == '\n' || i == len - 1) {
|
||||
numLines++;
|
||||
if (tmp[0] != '#' || protocol != TSDB_SML_LINE_PROTOCOL) { // ignore comment
|
||||
(*totalRows)++;
|
||||
}
|
||||
tmp = lines + i + 1;
|
||||
}
|
||||
}
|
||||
return taos_schemaless_insert_inner(request, NULL, lines, lines + len, numLines, protocol, precision);
|
||||
TAOS_RES *taos_schemaless_insert_with_reqid(TAOS *taos, char *lines[], int numLines, int protocol, int precision, int64_t reqid) {
|
||||
return taos_schemaless_insert_ttl_with_reqid(taos, lines, numLines, protocol, precision, TSDB_DEFAULT_TABLE_TTL, reqid);
|
||||
}
|
||||
|
||||
TAOS_RES *taos_schemaless_insert_raw_with_reqid(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
|
||||
int precision, int64_t reqid) {
|
||||
TAOS_RES *taos_schemaless_insert_raw_ttl_with_reqid(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol,
|
||||
int precision, int32_t ttl, int64_t reqid) {
|
||||
if (NULL == taos) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return NULL;
|
||||
|
@ -2749,5 +2723,16 @@ TAOS_RES *taos_schemaless_insert_raw_with_reqid(TAOS *taos, char *lines, int len
|
|||
tmp = lines + i + 1;
|
||||
}
|
||||
}
|
||||
return taos_schemaless_insert_inner(request, NULL, lines, lines + len, numLines, protocol, precision);
|
||||
return taos_schemaless_insert_inner(request, NULL, lines, lines + len, numLines, protocol, precision, ttl);
|
||||
}
|
||||
|
||||
TAOS_RES *taos_schemaless_insert_raw_with_reqid(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol, int precision, int64_t reqid) {
|
||||
return taos_schemaless_insert_raw_ttl_with_reqid(taos, lines, len, totalRows, protocol, precision, TSDB_DEFAULT_TABLE_TTL, reqid);
|
||||
}
|
||||
TAOS_RES *taos_schemaless_insert_raw_ttl(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol, int precision, int32_t ttl) {
|
||||
return taos_schemaless_insert_raw_ttl_with_reqid(taos, lines, len, totalRows, protocol, precision, ttl, 0);
|
||||
}
|
||||
|
||||
TAOS_RES *taos_schemaless_insert_raw(TAOS *taos, char *lines, int len, int32_t *totalRows, int protocol, int precision) {
|
||||
return taos_schemaless_insert_raw_ttl_with_reqid(taos, lines, len, totalRows, protocol, precision, TSDB_DEFAULT_TABLE_TTL, 0);
|
||||
}
|
||||
|
|
|
@ -152,9 +152,12 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char* tbFName, const char* sTableName, bool autoCreateTbl) {
|
||||
int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, SName* tbName, const char* sTableName, bool autoCreateTbl) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(tbName, tbFName);
|
||||
|
||||
memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName));
|
||||
strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1);
|
||||
pStmt->bInfo.tbFName[sizeof(pStmt->bInfo.tbFName) - 1] = 0;
|
||||
|
||||
|
@ -178,11 +181,11 @@ int32_t stmtUpdateExecInfo(TAOS_STMT* stmt, SHashObj* pVgHash, SHashObj* pBlockH
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t stmtUpdateInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char* tbFName, bool autoCreateTbl,
|
||||
int32_t stmtUpdateInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, SName* tbName, bool autoCreateTbl,
|
||||
SHashObj* pVgHash, SHashObj* pBlockHash, const char* sTableName) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
STMT_ERR_RET(stmtUpdateBindInfo(stmt, pTableMeta, tags, tbFName, sTableName, autoCreateTbl));
|
||||
STMT_ERR_RET(stmtUpdateBindInfo(stmt, pTableMeta, tags, tbName, sTableName, autoCreateTbl));
|
||||
STMT_ERR_RET(stmtUpdateExecInfo(stmt, pVgHash, pBlockHash, autoCreateTbl));
|
||||
|
||||
pStmt->sql.autoCreateTbl = autoCreateTbl;
|
||||
|
@ -773,7 +776,9 @@ int stmtAddBatch(TAOS_STMT* stmt) {
|
|||
int stmtUpdateTableUid(STscStmt* pStmt, SSubmitRsp* pRsp) {
|
||||
tscDebug("stmt start to update tbUid, blockNum: %d", pRsp->nBlocks);
|
||||
|
||||
size_t keyLen = 0;
|
||||
int32_t code = 0;
|
||||
int32_t finalCode = 0;
|
||||
size_t keyLen = 0;
|
||||
STableDataBlocks** pIter = taosHashIterate(pStmt->exec.pBlockHash, NULL);
|
||||
while (pIter) {
|
||||
STableDataBlocks* pBlock = *pIter;
|
||||
|
@ -809,10 +814,20 @@ int stmtUpdateTableUid(STscStmt* pStmt, SSubmitRsp* pRsp) {
|
|||
} else {
|
||||
tscDebug("table %s not found in submit rsp, will update from catalog", pStmt->bInfo.tbFName);
|
||||
if (NULL == pStmt->pCatalog) {
|
||||
STMT_ERR_RET(catalogGetHandle(pStmt->taos->pAppInfo->clusterId, &pStmt->pCatalog));
|
||||
code = catalogGetHandle(pStmt->taos->pAppInfo->clusterId, &pStmt->pCatalog);
|
||||
if (code) {
|
||||
pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
|
||||
finalCode = code;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
STMT_ERR_RET(stmtCreateRequest(pStmt));
|
||||
code = stmtCreateRequest(pStmt);
|
||||
if (code) {
|
||||
pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
|
||||
finalCode = code;
|
||||
continue;
|
||||
}
|
||||
|
||||
STableMeta* pTableMeta = NULL;
|
||||
SRequestConnInfo conn = {.pTrans = pStmt->taos->pAppInfo->pTransporter,
|
||||
|
@ -823,20 +838,23 @@ int stmtUpdateTableUid(STscStmt* pStmt, SSubmitRsp* pRsp) {
|
|||
|
||||
taos_free_result(pStmt->exec.pRequest);
|
||||
pStmt->exec.pRequest = NULL;
|
||||
|
||||
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
|
||||
tscDebug("tb %s not exist", pStmt->bInfo.tbFName);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
if (code || NULL == pTableMeta) {
|
||||
pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
|
||||
finalCode = code;
|
||||
taosMemoryFree(pTableMeta);
|
||||
continue;
|
||||
}
|
||||
|
||||
pMeta->uid = pTableMeta->uid;
|
||||
pStmt->bInfo.tbUid = pTableMeta->uid;
|
||||
taosMemoryFree(pTableMeta);
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return finalCode;
|
||||
}
|
||||
|
||||
int stmtExec(TAOS_STMT* stmt) {
|
||||
|
|
|
@ -206,16 +206,15 @@ static const SSysDbTableSchema vgroupsSchema[] = {
|
|||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "v1_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "v1_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "v2_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "v2_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "v3_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "v1_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||
{.name = "v1_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "v2_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||
{.name = "v2_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "v3_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||
{.name = "v3_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "v4_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||
{.name = "v4_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "cacheload", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "nfiles", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "file_size", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "tsma", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
||||
};
|
||||
|
||||
|
@ -274,6 +273,12 @@ static const SSysDbTableSchema vnodesSchema[] = {
|
|||
{.name = "dnode_ep", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userUserPrivilegesSchema[] = {
|
||||
{.name = "user_name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "privilege", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "object_name", .bytes = TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysTableMeta infosMeta[] = {
|
||||
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true},
|
||||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
||||
|
@ -298,6 +303,7 @@ static const SSysTableMeta infosMeta[] = {
|
|||
{TSDB_INS_TABLE_STREAMS, streamSchema, tListLen(streamSchema), false},
|
||||
{TSDB_INS_TABLE_STREAM_TASKS, streamTaskSchema, tListLen(streamTaskSchema), false},
|
||||
{TSDB_INS_TABLE_VNODES, vnodesSchema, tListLen(vnodesSchema), true},
|
||||
{TSDB_INS_TABLE_USER_PRIVILEGES, userUserPrivilegesSchema, tListLen(userUserPrivilegesSchema), false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema connectionsSchema[] = {
|
||||
|
|
|
@ -2334,7 +2334,7 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
|
|||
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||
pColInfoData->info.type = *(int16_t*)pStart;
|
||||
pColInfoData->info.type = *(int8_t*)pStart;
|
||||
pStart += sizeof(int8_t);
|
||||
|
||||
pColInfoData->info.bytes = *(int32_t*)pStart;
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "tglobal.h"
|
||||
#include "tconfig.h"
|
||||
#include "tmisce.h"
|
||||
#include "tgrant.h"
|
||||
#include "tlog.h"
|
||||
#include "tmisce.h"
|
||||
|
||||
GRANT_CFG_DECLARE;
|
||||
|
||||
|
@ -75,6 +75,7 @@ char tsSmlChildTableName[TSDB_TABLE_NAME_LEN] = ""; // user defined child table
|
|||
// If set to empty system will generate table name using MD5 hash.
|
||||
// true means that the name and order of cols in each line are the same(only for influx protocol)
|
||||
bool tsSmlDataFormat = false;
|
||||
int32_t tsSmlBatchSize = 10000;
|
||||
|
||||
// query
|
||||
int32_t tsQueryPolicy = 1;
|
||||
|
@ -86,6 +87,10 @@ bool tsQueryPlannerTrace = false;
|
|||
int32_t tsQueryNodeChunkSize = 32 * 1024;
|
||||
bool tsQueryUseNodeAllocator = true;
|
||||
bool tsKeepColumnName = false;
|
||||
int32_t tsRedirectPeriod = 10;
|
||||
int32_t tsRedirectFactor = 2;
|
||||
int32_t tsRedirectMaxPeriod = 1000;
|
||||
int32_t tsMaxRetryWaitTime = 10000;
|
||||
|
||||
/*
|
||||
* denote if the server needs to compress response message at the application layer to client, including query rsp,
|
||||
|
@ -120,7 +125,7 @@ int32_t tsMinIntervalTime = 1;
|
|||
int32_t tsMaxMemUsedByInsert = 1024;
|
||||
|
||||
float tsSelectivityRatio = 1.0;
|
||||
int32_t tsTagFilterResCacheSize = 1024*10;
|
||||
int32_t tsTagFilterResCacheSize = 1024 * 10;
|
||||
|
||||
// the maximum allowed query buffer size during query processing for each data node.
|
||||
// -1 no limit (default)
|
||||
|
@ -302,12 +307,17 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
|||
if (cfgAddString(pCfg, "smlChildTableName", "", 1) != 0) return -1;
|
||||
if (cfgAddString(pCfg, "smlTagName", tsSmlTagName, 1) != 0) return -1;
|
||||
if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "smlBatchSize", tsSmlBatchSize, 1, INT32_MAX, true) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "maxMemUsedByInsert", tsMaxMemUsedByInsert, 1, INT32_MAX, true) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "rpcRetryLimit", tsRpcRetryLimit, 1, 100000, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "rpcRetryInterval", tsRpcRetryInterval, 1, 100000, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "maxRetryWaitTime", tsMaxRetryWaitTime, 0, 86400000, 0) != 0) return -1;
|
||||
|
||||
tsNumOfTaskQueueThreads = tsNumOfCores / 2;
|
||||
tsNumOfTaskQueueThreads = TMAX(tsNumOfTaskQueueThreads, 4);
|
||||
if (tsNumOfTaskQueueThreads >= 10) {
|
||||
tsNumOfTaskQueueThreads = 10;
|
||||
}
|
||||
if (cfgAddInt32(pCfg, "numOfTaskQueueThreads", tsNumOfTaskQueueThreads, 4, 1024, 0) != 0) return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -640,6 +650,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
|||
tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN);
|
||||
tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval;
|
||||
|
||||
tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32;
|
||||
tsMaxMemUsedByInsert = cfgGetItem(pCfg, "maxMemUsedByInsert")->i32;
|
||||
|
||||
tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
|
||||
|
@ -656,6 +667,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
|||
|
||||
tsRpcRetryLimit = cfgGetItem(pCfg, "rpcRetryLimit")->i32;
|
||||
tsRpcRetryInterval = cfgGetItem(pCfg, "rpcRetryInterval")->i32;
|
||||
tsMaxRetryWaitTime = cfgGetItem(pCfg, "maxRetryWaitTime")->i32;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -871,6 +883,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32;
|
||||
} else if (strcasecmp("maxMemUsedByInsert", name) == 0) {
|
||||
tsMaxMemUsedByInsert = cfgGetItem(pCfg, "maxMemUsedByInsert")->i32;
|
||||
} else if (strcasecmp("maxRetryWaitTime", name) == 0) {
|
||||
tsMaxRetryWaitTime = cfgGetItem(pCfg, "maxRetryWaitTime")->i32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1010,6 +1024,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN);
|
||||
} else if (strcasecmp("smlDataFormat", name) == 0) {
|
||||
tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval;
|
||||
} else if (strcasecmp("smlBatchSize", name) == 0) {
|
||||
tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32;
|
||||
} else if (strcasecmp("shellActivityTimer", name) == 0) {
|
||||
tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
|
||||
} else if (strcasecmp("supportVnodes", name) == 0) {
|
||||
|
|
|
@ -1288,7 +1288,7 @@ int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq)
|
|||
if (tEncodeI8(&encoder, pReq->enable) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->dbname) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->objname) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -1307,7 +1307,7 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq
|
|||
if (tDecodeI8(&decoder, &pReq->enable) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->dbname) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->objname) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -4496,7 +4496,7 @@ int32_t tDeserializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq) {
|
|||
if (num <= 0) {
|
||||
pReq->pMsgs = NULL;
|
||||
tEndDecode(&decoder);
|
||||
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
@ -4511,7 +4511,7 @@ int32_t tDeserializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq) {
|
|||
if (tDecodeBinaryAlloc(&decoder, &msg.msg, NULL) < 0) return -1;
|
||||
if (NULL == taosArrayPush(pReq->pMsgs, &msg)) return -1;
|
||||
}
|
||||
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -4553,7 +4553,7 @@ int32_t tDeserializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp) {
|
|||
if (num <= 0) {
|
||||
pRsp->pRsps = NULL;
|
||||
tEndDecode(&decoder);
|
||||
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
@ -4569,14 +4569,13 @@ int32_t tDeserializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp) {
|
|||
if (tDecodeBinaryAlloc(&decoder, &msg.msg, NULL) < 0) return -1;
|
||||
if (NULL == taosArrayPush(pRsp->pRsps, &msg)) return -1;
|
||||
}
|
||||
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq) {
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
|
@ -4603,7 +4602,7 @@ int32_t tDeserializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq) {
|
|||
if (tDecodeI64(&decoder, &pReq->consumerId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->epoch) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->cgroup) < 0) return -1;
|
||||
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -4634,7 +4633,7 @@ int32_t tDeserializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) {
|
|||
|
||||
if (tDecodeI64(&decoder, &pReq->consumerId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->epoch) < 0) return -1;
|
||||
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -4664,7 +4663,7 @@ int32_t tSerializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq) {
|
|||
if (tEncodeU32(&encoder, pReq->sqlLen) < 0) return -1;
|
||||
if (tEncodeCStrWithLen(&encoder, pReq->sql, pReq->sqlLen) < 0) return -1;
|
||||
if (tEncodeU32(&encoder, pReq->msgLen) < 0) return -1;
|
||||
if (tEncodeBinary(&encoder, (uint8_t*)pReq->msg, pReq->msgLen) < 0) return -1;
|
||||
if (tEncodeBinary(&encoder, (uint8_t *)pReq->msg, pReq->msgLen) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
|
@ -4704,8 +4703,8 @@ int32_t tDeserializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq)
|
|||
if (tDecodeU32(&decoder, &pReq->sqlLen) < 0) return -1;
|
||||
if (tDecodeCStrAlloc(&decoder, &pReq->sql) < 0) return -1;
|
||||
if (tDecodeU32(&decoder, &pReq->msgLen) < 0) return -1;
|
||||
if (tDecodeBinaryAlloc(&decoder, (void**)&pReq->msg, NULL) < 0) return -1;
|
||||
|
||||
if (tDecodeBinaryAlloc(&decoder, (void **)&pReq->msg, NULL) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -4721,7 +4720,6 @@ void tFreeSSubQueryMsg(SSubQueryMsg *pReq) {
|
|||
taosMemoryFreeClear(pReq->msg);
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
|
@ -4768,14 +4766,13 @@ int32_t tDeserializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq)
|
|||
if (tDecodeU64(&decoder, &pReq->queryId) < 0) return -1;
|
||||
if (tDecodeU64(&decoder, &pReq->taskId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->execId) < 0) return -1;
|
||||
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSTqOffsetVal(SEncoder *pEncoder, STqOffsetVal *pOffset) {
|
||||
if (tEncodeI8(pEncoder, pOffset->type) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pOffset->uid) < 0) return -1;
|
||||
|
@ -4846,14 +4843,13 @@ int32_t tDeserializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) {
|
|||
if (tDecodeI64(&decoder, &pReq->consumerId) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->timeout) < 0) return -1;
|
||||
if (tDerializeSTqOffsetVal(&decoder, &pReq->reqOffset) < 0) return -1;
|
||||
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
|
@ -4902,7 +4898,7 @@ int32_t tDeserializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq)
|
|||
if (tDecodeU64(&decoder, &pReq->taskId) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->refId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->execId) < 0) return -1;
|
||||
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -4939,14 +4935,13 @@ int32_t tDeserializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pR
|
|||
if (tDecodeI32(&decoder, &pRsp->sversion) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->tversion) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pRsp->affectedRows) < 0) return -1;
|
||||
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
|
@ -6645,13 +6640,15 @@ void tDeleteSTaosxRsp(STaosxRsp *pRsp) {
|
|||
|
||||
int32_t tEncodeSSingleDeleteReq(SEncoder *pEncoder, const SSingleDeleteReq *pReq) {
|
||||
if (tEncodeCStr(pEncoder, pReq->tbname) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pReq->ts) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pReq->startTs) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pReq->endTs) < 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tDecodeSSingleDeleteReq(SDecoder *pDecoder, SSingleDeleteReq *pReq) {
|
||||
if (tDecodeCStrTo(pDecoder, pReq->tbname) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pReq->ts) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pReq->startTs) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pReq->endTs) < 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ static void dmGetServerRunStatus(SDnodeMgmt *pMgmt, SServerStatusRsp *pStatus) {
|
|||
SServerStatusRsp statusRsp = {0};
|
||||
SMonMloadInfo minfo = {0};
|
||||
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
||||
if (minfo.isMnode && minfo.load.syncState == TAOS_SYNC_STATE_ERROR) {
|
||||
if (minfo.isMnode && (minfo.load.syncState == TAOS_SYNC_STATE_ERROR || minfo.load.syncState == TAOS_SYNC_STATE_OFFLINE)) {
|
||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
||||
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(minfo.load.syncState));
|
||||
return;
|
||||
|
@ -160,7 +160,7 @@ static void dmGetServerRunStatus(SDnodeMgmt *pMgmt, SServerStatusRsp *pStatus) {
|
|||
(*pMgmt->getVnodeLoadsFp)(&vinfo);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(vinfo.pVloads); ++i) {
|
||||
SVnodeLoad *pLoad = taosArrayGet(vinfo.pVloads, i);
|
||||
if (pLoad->syncState == TAOS_SYNC_STATE_ERROR) {
|
||||
if (pLoad->syncState == TAOS_SYNC_STATE_ERROR || pLoad->syncState == TAOS_SYNC_STATE_OFFLINE) {
|
||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
||||
snprintf(pStatus->details, sizeof(pStatus->details), "vnode:%d sync state is %s", pLoad->vgId,
|
||||
syncStr(pLoad->syncState));
|
||||
|
|
|
@ -250,7 +250,7 @@ int32_t dmInitClient(SDnode *pDnode) {
|
|||
|
||||
SRpcInit rpcInit = {0};
|
||||
rpcInit.label = "DND-C";
|
||||
rpcInit.numOfThreads = 4;
|
||||
rpcInit.numOfThreads = tsNumOfRpcThreads;
|
||||
rpcInit.cfp = (RpcCfp)dmProcessRpcMsg;
|
||||
rpcInit.sessions = 1024;
|
||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||
|
@ -258,8 +258,13 @@ int32_t dmInitClient(SDnode *pDnode) {
|
|||
rpcInit.parent = pDnode;
|
||||
rpcInit.rfp = rpcRfp;
|
||||
rpcInit.compressSize = tsCompressMsgSize;
|
||||
|
||||
rpcInit.retryLimit = tsRpcRetryLimit;
|
||||
rpcInit.retryInterval = tsRpcRetryInterval;
|
||||
rpcInit.retryMinInterval = tsRedirectPeriod;
|
||||
rpcInit.retryStepFactor = tsRedirectFactor;
|
||||
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
||||
rpcInit.retryMaxTimouet = tsMaxRetryWaitTime;
|
||||
|
||||
pTrans->clientRpc = rpcOpen(&rpcInit);
|
||||
if (pTrans->clientRpc == NULL) {
|
||||
|
|
|
@ -248,7 +248,7 @@ void dmUpdateEps(SDnodeData *pData, SArray *eps) {
|
|||
static void dmResetEps(SDnodeData *pData, SArray *dnodeEps) {
|
||||
if (pData->dnodeEps != dnodeEps) {
|
||||
SArray *tmp = pData->dnodeEps;
|
||||
pData->dnodeEps = taosArrayDup(dnodeEps);
|
||||
pData->dnodeEps = taosArrayDup(dnodeEps, NULL);
|
||||
taosArrayDestroy(tmp);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,6 @@ int64_t mndGetVgroupMemory(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup);
|
|||
SArray *mndBuildDnodesArray(SMnode *, int32_t exceptDnodeId);
|
||||
int32_t mndAllocSmaVgroup(SMnode *, SDbObj *pDb, SVgObj *pVgroup);
|
||||
int32_t mndAllocVgroup(SMnode *, SDbObj *pDb, SVgObj **ppVgroups);
|
||||
int32_t mndAddVnodeToVgroup(SMnode *, SVgObj *pVgroup, SArray *pArray);
|
||||
int32_t mndRemoveVnodeFromVgroup(SMnode *, SVgObj *pVgroup, SArray *pArray, SVnodeGid *pDelVgid);
|
||||
int32_t mndAddCreateVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid);
|
||||
int32_t mndAddAlterVnodeConfirmAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup);
|
||||
int32_t mndAddAlterVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, tmsg_t msgType);
|
||||
|
|
|
@ -538,7 +538,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
|||
|
||||
int32_t code = -1;
|
||||
SArray *newSub = subscribe.topicNames;
|
||||
taosArraySortString(newSub, taosArrayCompareString);
|
||||
taosArraySort(newSub, taosArrayCompareString);
|
||||
taosArrayRemoveDuplicateP(newSub, taosArrayCompareString, taosMemoryFree);
|
||||
|
||||
int32_t newTopicNum = taosArrayGetSize(newSub);
|
||||
|
@ -850,7 +850,8 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
|
|||
|
||||
// add to current topic
|
||||
taosArrayPush(pOldConsumer->currentTopics, &addedTopic);
|
||||
taosArraySortString(pOldConsumer->currentTopics, taosArrayCompareString);
|
||||
taosArraySort(pOldConsumer->currentTopics, taosArrayCompareString);
|
||||
|
||||
// set status
|
||||
if (taosArrayGetSize(pOldConsumer->rebNewTopics) == 0 && taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0) {
|
||||
if (pOldConsumer->status == MQ_CONSUMER_STATUS__MODIFY ||
|
||||
|
|
|
@ -219,12 +219,12 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
||||
taosInitRWLatch(&pDb->lock);
|
||||
|
||||
if (pDb->cfg.tsdbPageSize <= TSDB_MIN_TSDB_PAGESIZE) {
|
||||
if (pDb->cfg.tsdbPageSize != TSDB_MIN_TSDB_PAGESIZE) {
|
||||
mInfo("db:%s, tsdbPageSize set from %d to default %d", pDb->name, pDb->cfg.tsdbPageSize,
|
||||
TSDB_DEFAULT_TSDB_PAGESIZE);
|
||||
}
|
||||
|
||||
if (pDb->cfg.sstTrigger <= TSDB_MIN_STT_TRIGGER) {
|
||||
if (pDb->cfg.sstTrigger != TSDB_MIN_STT_TRIGGER) {
|
||||
mInfo("db:%s, sstTrigger set from %d to default %d", pDb->name, pDb->cfg.sstTrigger, TSDB_DEFAULT_SST_TRIGGER);
|
||||
}
|
||||
|
||||
|
@ -810,7 +810,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
|||
|
||||
memcpy(&dbObj, pDb, sizeof(SDbObj));
|
||||
if (dbObj.cfg.pRetensions != NULL) {
|
||||
dbObj.cfg.pRetensions = taosArrayDup(pDb->cfg.pRetensions);
|
||||
dbObj.cfg.pRetensions = taosArrayDup(pDb->cfg.pRetensions, NULL);
|
||||
if (dbObj.cfg.pRetensions == NULL) goto _OVER;
|
||||
}
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ SMqConsumerEp *tCloneSMqConsumerEp(const SMqConsumerEp *pConsumerEpOld) {
|
|||
SMqConsumerEp *pConsumerEpNew = taosMemoryMalloc(sizeof(SMqConsumerEp));
|
||||
if (pConsumerEpNew == NULL) return NULL;
|
||||
pConsumerEpNew->consumerId = pConsumerEpOld->consumerId;
|
||||
pConsumerEpNew->vgs = taosArrayDeepCopy(pConsumerEpOld->vgs, (FCopy)tCloneSMqVgEp);
|
||||
pConsumerEpNew->vgs = taosArrayDup(pConsumerEpOld->vgs, (__array_item_dup_fn_t)tCloneSMqVgEp);
|
||||
return pConsumerEpNew;
|
||||
}
|
||||
|
||||
|
@ -440,11 +440,11 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
|
|||
pConsumerEp = (SMqConsumerEp *)pIter;
|
||||
SMqConsumerEp newEp = {
|
||||
.consumerId = pConsumerEp->consumerId,
|
||||
.vgs = taosArrayDeepCopy(pConsumerEp->vgs, (FCopy)tCloneSMqVgEp),
|
||||
.vgs = taosArrayDup(pConsumerEp->vgs, (__array_item_dup_fn_t)tCloneSMqVgEp),
|
||||
};
|
||||
taosHashPut(pSubNew->consumerHash, &newEp.consumerId, sizeof(int64_t), &newEp, sizeof(SMqConsumerEp));
|
||||
}
|
||||
pSubNew->unassignedVgs = taosArrayDeepCopy(pSub->unassignedVgs, (FCopy)tCloneSMqVgEp);
|
||||
pSubNew->unassignedVgs = taosArrayDup(pSub->unassignedVgs, (__array_item_dup_fn_t)tCloneSMqVgEp);
|
||||
memcpy(pSubNew->dbName, pSub->dbName, TSDB_DB_FNAME_LEN);
|
||||
return pSubNew;
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ SMqSubActionLogEntry *tCloneSMqSubActionLogEntry(SMqSubActionLogEntry *pEntry) {
|
|||
SMqSubActionLogEntry *pEntryNew = taosMemoryMalloc(sizeof(SMqSubActionLogEntry));
|
||||
if (pEntryNew == NULL) return NULL;
|
||||
pEntryNew->epoch = pEntry->epoch;
|
||||
pEntryNew->consumers = taosArrayDeepCopy(pEntry->consumers, (FCopy)tCloneSMqConsumerEp);
|
||||
pEntryNew->consumers = taosArrayDup(pEntry->consumers, (__array_item_dup_fn_t)tCloneSMqConsumerEp);
|
||||
return pEntryNew;
|
||||
}
|
||||
|
||||
|
@ -541,7 +541,7 @@ SMqSubActionLogObj *tCloneSMqSubActionLogObj(SMqSubActionLogObj *pLog) {
|
|||
SMqSubActionLogObj *pLogNew = taosMemoryMalloc(sizeof(SMqSubActionLogObj));
|
||||
if (pLogNew == NULL) return pLogNew;
|
||||
memcpy(pLogNew->key, pLog->key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||
pLogNew->logs = taosArrayDeepCopy(pLog->logs, (FCopy)tCloneSMqConsumerEp);
|
||||
pLogNew->logs = taosArrayDup(pLog->logs, (__array_item_dup_fn_t)tCloneSMqConsumerEp);
|
||||
return pLogNew;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,10 +151,10 @@ static void mndSetVgroupOffline(SMnode *pMnode, int32_t dnodeId, int64_t curMs)
|
|||
bool roleChanged = false;
|
||||
for (int32_t vg = 0; vg < pVgroup->replica; ++vg) {
|
||||
if (pVgroup->vnodeGid[vg].dnodeId == dnodeId) {
|
||||
if (pVgroup->vnodeGid[vg].syncState != TAOS_SYNC_STATE_ERROR) {
|
||||
if (pVgroup->vnodeGid[vg].syncState != TAOS_SYNC_STATE_OFFLINE) {
|
||||
mInfo("vgId:%d, state changed by offline check, old state:%s restored:%d new state:error restored:0",
|
||||
pVgroup->vgId, syncStr(pVgroup->vnodeGid[vg].syncState), pVgroup->vnodeGid[vg].syncRestore);
|
||||
pVgroup->vnodeGid[vg].syncState = TAOS_SYNC_STATE_ERROR;
|
||||
pVgroup->vnodeGid[vg].syncState = TAOS_SYNC_STATE_OFFLINE;
|
||||
pVgroup->vnodeGid[vg].syncRestore = 0;
|
||||
roleChanged = true;
|
||||
}
|
||||
|
@ -491,6 +491,15 @@ void mndPreClose(SMnode *pMnode) {
|
|||
if (pMnode != NULL) {
|
||||
syncLeaderTransfer(pMnode->syncMgmt.sync);
|
||||
syncPreStop(pMnode->syncMgmt.sync);
|
||||
|
||||
while (syncSnapshotRecving(pMnode->syncMgmt.sync)) {
|
||||
mInfo("vgId:1, snapshot is recving");
|
||||
taosMsleep(300);
|
||||
}
|
||||
while (syncSnapshotSending(pMnode->syncMgmt.sync)) {
|
||||
mInfo("vgId:1, snapshot is sending");
|
||||
taosMsleep(300);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -747,7 +756,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
|||
tstrncpy(desc.status, "ready", sizeof(desc.status));
|
||||
pClusterInfo->vgroups_alive++;
|
||||
}
|
||||
if (pVgid->syncState != TAOS_SYNC_STATE_ERROR) {
|
||||
if (pVgid->syncState != TAOS_SYNC_STATE_ERROR && pVgid->syncState != TAOS_SYNC_STATE_OFFLINE) {
|
||||
pClusterInfo->vnodes_alive++;
|
||||
}
|
||||
pClusterInfo->vnodes_total++;
|
||||
|
@ -803,12 +812,12 @@ void mndSetRestored(SMnode *pMnode, bool restored) {
|
|||
taosThreadRwlockWrlock(&pMnode->lock);
|
||||
pMnode->restored = true;
|
||||
taosThreadRwlockUnlock(&pMnode->lock);
|
||||
mTrace("mnode set restored:%d", restored);
|
||||
mInfo("mnode set restored:%d", restored);
|
||||
} else {
|
||||
taosThreadRwlockWrlock(&pMnode->lock);
|
||||
pMnode->restored = false;
|
||||
taosThreadRwlockUnlock(&pMnode->lock);
|
||||
mTrace("mnode set restored:%d", restored);
|
||||
mInfo("mnode set restored:%d", restored);
|
||||
while (1) {
|
||||
if (pMnode->rpcRef <= 0) break;
|
||||
taosMsleep(3);
|
||||
|
@ -822,7 +831,7 @@ void mndSetStop(SMnode *pMnode) {
|
|||
taosThreadRwlockWrlock(&pMnode->lock);
|
||||
pMnode->stopped = true;
|
||||
taosThreadRwlockUnlock(&pMnode->lock);
|
||||
mTrace("mnode set stopped");
|
||||
mInfo("mnode set stopped");
|
||||
}
|
||||
|
||||
bool mndGetStop(SMnode *pMnode) { return pMnode->stopped; }
|
||||
|
|
|
@ -185,7 +185,7 @@ static int32_t mndMnodeActionInsert(SSdb *pSdb, SMnodeObj *pObj) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
pObj->syncState = TAOS_SYNC_STATE_ERROR;
|
||||
pObj->syncState = TAOS_SYNC_STATE_OFFLINE;
|
||||
mndReloadSyncConfig(pSdb->pMnode);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1684,7 +1684,7 @@ static int32_t mndBuildStbCfgImp(SDbObj *pDb, SStbObj *pStb, const char *tbName,
|
|||
}
|
||||
|
||||
if (pStb->numOfFuncs > 0) {
|
||||
pRsp->pFuncs = taosArrayDup(pStb->pFuncs);
|
||||
pRsp->pFuncs = taosArrayDup(pStb->pFuncs, NULL);
|
||||
}
|
||||
|
||||
taosRUnLockLatch(&pStb->lock);
|
||||
|
|
|
@ -507,14 +507,14 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
if (alterReq.alterType == TSDB_ALTER_USER_ADD_READ_DB || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB) {
|
||||
if (strcmp(alterReq.dbname, "1.*") != 0) {
|
||||
int32_t len = strlen(alterReq.dbname) + 1;
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname);
|
||||
if (strcmp(alterReq.objname, "1.*") != 0) {
|
||||
int32_t len = strlen(alterReq.objname) + 1;
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname);
|
||||
if (pDb == NULL) {
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
goto _OVER;
|
||||
}
|
||||
if (taosHashPut(newUser.readDbs, alterReq.dbname, len, alterReq.dbname, TSDB_DB_FNAME_LEN) != 0) {
|
||||
if (taosHashPut(newUser.readDbs, alterReq.objname, len, alterReq.objname, TSDB_DB_FNAME_LEN) != 0) {
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -531,14 +531,14 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
if (alterReq.alterType == TSDB_ALTER_USER_ADD_WRITE_DB || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB) {
|
||||
if (strcmp(alterReq.dbname, "1.*") != 0) {
|
||||
int32_t len = strlen(alterReq.dbname) + 1;
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname);
|
||||
if (strcmp(alterReq.objname, "1.*") != 0) {
|
||||
int32_t len = strlen(alterReq.objname) + 1;
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname);
|
||||
if (pDb == NULL) {
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
goto _OVER;
|
||||
}
|
||||
if (taosHashPut(newUser.writeDbs, alterReq.dbname, len, alterReq.dbname, TSDB_DB_FNAME_LEN) != 0) {
|
||||
if (taosHashPut(newUser.writeDbs, alterReq.objname, len, alterReq.objname, TSDB_DB_FNAME_LEN) != 0) {
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -555,28 +555,28 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_READ_DB || alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_DB) {
|
||||
if (strcmp(alterReq.dbname, "1.*") != 0) {
|
||||
int32_t len = strlen(alterReq.dbname) + 1;
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname);
|
||||
if (strcmp(alterReq.objname, "1.*") != 0) {
|
||||
int32_t len = strlen(alterReq.objname) + 1;
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname);
|
||||
if (pDb == NULL) {
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
goto _OVER;
|
||||
}
|
||||
taosHashRemove(newUser.readDbs, alterReq.dbname, len);
|
||||
taosHashRemove(newUser.readDbs, alterReq.objname, len);
|
||||
} else {
|
||||
taosHashClear(newUser.readDbs);
|
||||
}
|
||||
}
|
||||
|
||||
if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_WRITE_DB || alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_DB) {
|
||||
if (strcmp(alterReq.dbname, "1.*") != 0) {
|
||||
int32_t len = strlen(alterReq.dbname) + 1;
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname);
|
||||
if (strcmp(alterReq.objname, "1.*") != 0) {
|
||||
int32_t len = strlen(alterReq.objname) + 1;
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname);
|
||||
if (pDb == NULL) {
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
goto _OVER;
|
||||
}
|
||||
taosHashRemove(newUser.writeDbs, alterReq.dbname, len);
|
||||
taosHashRemove(newUser.writeDbs, alterReq.objname, len);
|
||||
} else {
|
||||
taosHashClear(newUser.writeDbs);
|
||||
}
|
||||
|
|
|
@ -179,6 +179,22 @@ static int32_t mndVgroupActionUpdate(SSdb *pSdb, SVgObj *pOld, SVgObj *pNew) {
|
|||
pOld->hashEnd = pNew->hashEnd;
|
||||
pOld->replica = pNew->replica;
|
||||
pOld->isTsma = pNew->isTsma;
|
||||
for (int32_t i = 0; i < pNew->replica; ++i) {
|
||||
SVnodeGid *pNewGid = &pNew->vnodeGid[i];
|
||||
for (int32_t j = 0; j < pOld->replica; ++j) {
|
||||
SVnodeGid *pOldGid = &pOld->vnodeGid[j];
|
||||
if (pNewGid->dnodeId == pOldGid->dnodeId) {
|
||||
pNewGid->syncState = pOldGid->syncState;
|
||||
pNewGid->syncRestore = pOldGid->syncRestore;
|
||||
}
|
||||
}
|
||||
}
|
||||
pNew->numOfTables = pOld->numOfTables;
|
||||
pNew->numOfTimeSeries = pOld->numOfTimeSeries;
|
||||
pNew->totalStorage = pOld->totalStorage;
|
||||
pNew->compStorage = pOld->compStorage;
|
||||
pNew->pointsWritten = pOld->pointsWritten;
|
||||
pNew->compact = pOld->compact;
|
||||
memcpy(pOld->vnodeGid, pNew->vnodeGid, TSDB_MAX_REPLICA * sizeof(SVnodeGid));
|
||||
return 0;
|
||||
}
|
||||
|
@ -659,24 +675,30 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->numOfTables, false);
|
||||
|
||||
// default 3 replica
|
||||
for (int32_t i = 0; i < 3; ++i) {
|
||||
// default 3 replica, add 1 replica if move vnode
|
||||
for (int32_t i = 0; i < 4; ++i) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
if (i < pVgroup->replica) {
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->vnodeGid[i].dnodeId, false);
|
||||
int16_t dnodeId = (int16_t)pVgroup->vnodeGid[i].dnodeId;
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&dnodeId, false);
|
||||
|
||||
bool exist = false;
|
||||
bool online = false;
|
||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgroup->vnodeGid[i].dnodeId);
|
||||
if (pDnode != NULL) {
|
||||
exist = true;
|
||||
online = mndIsDnodeOnline(pDnode, curMs);
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
}
|
||||
|
||||
char buf1[20] = {0};
|
||||
char role[20] = "offline";
|
||||
if (online) {
|
||||
if (!exist) {
|
||||
strcpy(role, "dropping");
|
||||
} else if (online) {
|
||||
bool show = (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER && !pVgroup->vnodeGid[i].syncRestore);
|
||||
snprintf(role, sizeof(role), "%s%s", syncStr(pVgroup->vnodeGid[i].syncState), show ? "*" : "");
|
||||
} else {
|
||||
}
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf1, role, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
|
@ -690,16 +712,8 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppendNULL(pColInfo, numOfRows);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->cacheUsage, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppendNULL(pColInfo, numOfRows);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppendNULL(pColInfo, numOfRows);
|
||||
int32_t cacheUsage = (int32_t)pVgroup->cacheUsage;
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&cacheUsage, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->isTsma, false);
|
||||
|
@ -846,7 +860,7 @@ static void mndCancelGetNextVnode(SMnode *pMnode, void *pIter) {
|
|||
sdbCancelFetch(pSdb, pIter);
|
||||
}
|
||||
|
||||
int32_t mndAddVnodeToVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) {
|
||||
static int32_t mndAddVnodeToVgroup(SMnode *pMnode, STrans *pTrans, SVgObj *pVgroup, SArray *pArray) {
|
||||
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||
|
@ -882,12 +896,21 @@ int32_t mndAddVnodeToVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) {
|
|||
}
|
||||
|
||||
pVgid->dnodeId = pDnode->id;
|
||||
pVgid->syncState = TAOS_SYNC_STATE_ERROR;
|
||||
pVgid->syncState = TAOS_SYNC_STATE_OFFLINE;
|
||||
mInfo("db:%s, vgId:%d, vn:%d is added, memory:%" PRId64 ", dnode:%d avail:%" PRId64 " used:%" PRId64,
|
||||
pVgroup->dbName, pVgroup->vgId, pVgroup->replica, vgMem, pVgid->dnodeId, pDnode->memAvail, pDnode->memUsed);
|
||||
|
||||
pVgroup->replica++;
|
||||
pDnode->numOfVnodes++;
|
||||
|
||||
SSdbRaw *pVgRaw = mndVgroupActionEncode(pVgroup);
|
||||
if (pVgRaw == NULL) return -1;
|
||||
if (mndTransAppendRedolog(pTrans, pVgRaw) != 0) {
|
||||
sdbFreeRaw(pVgRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -896,7 +919,8 @@ int32_t mndAddVnodeToVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t mndRemoveVnodeFromVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray, SVnodeGid *pDelVgid) {
|
||||
static int32_t mndRemoveVnodeFromVgroup(SMnode *pMnode, STrans *pTrans, SVgObj *pVgroup, SArray *pArray,
|
||||
SVnodeGid *pDelVgid) {
|
||||
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||
|
@ -936,6 +960,15 @@ _OVER:
|
|||
SVnodeGid *pVgid = &pVgroup->vnodeGid[vn];
|
||||
mInfo("db:%s, vgId:%d, vn:%d dnode:%d is reserved", pVgroup->dbName, pVgroup->vgId, vn, pVgid->dnodeId);
|
||||
}
|
||||
|
||||
SSdbRaw *pVgRaw = mndVgroupActionEncode(pVgroup);
|
||||
if (pVgRaw == NULL) return -1;
|
||||
if (mndTransAppendRedolog(pTrans, pVgRaw) != 0) {
|
||||
sdbFreeRaw(pVgRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1083,11 +1116,11 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
|||
|
||||
if (!force) {
|
||||
mInfo("vgId:%d, will add 1 vnode", pVgroup->vgId);
|
||||
if (mndAddVnodeToVgroup(pMnode, &newVg, pArray) != 0) return -1;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1]) != 0) return -1;
|
||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
||||
for (int32_t i = 0; i < newVg.replica - 1; ++i) {
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||
}
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1]) != 0) return -1;
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||
|
||||
mInfo("vgId:%d, will remove 1 vnode", pVgroup->vgId);
|
||||
|
@ -1095,6 +1128,16 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
|||
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
||||
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
||||
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
||||
{
|
||||
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
||||
if (pRaw == NULL) return -1;
|
||||
if (mndTransAppendRedolog(pTrans, pRaw) != 0) {
|
||||
sdbFreeRaw(pRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
}
|
||||
|
||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
|
||||
for (int32_t i = 0; i < newVg.replica; ++i) {
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||
|
@ -1102,18 +1145,27 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
|||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||
} else {
|
||||
mInfo("vgId:%d, will add 1 vnode and force remove 1 vnode", pVgroup->vgId);
|
||||
if (mndAddVnodeToVgroup(pMnode, &newVg, pArray) != 0) return -1;
|
||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
||||
newVg.replica--;
|
||||
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
||||
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
||||
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
||||
{
|
||||
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
||||
if (pRaw == NULL) return -1;
|
||||
if (mndTransAppendRedolog(pTrans, pRaw) != 0) {
|
||||
sdbFreeRaw(pRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
}
|
||||
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[vnIndex]) != 0) return -1;
|
||||
for (int32_t i = 0; i < newVg.replica; ++i) {
|
||||
if (i != vnIndex) {
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||
}
|
||||
}
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[vnIndex]) != 0) return -1;
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||
|
||||
if (newVg.replica == 1) {
|
||||
|
@ -1123,16 +1175,12 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
|||
|
||||
{
|
||||
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
||||
if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) return -1;
|
||||
if (pRaw == NULL) return -1;
|
||||
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) {
|
||||
sdbFreeRaw(pRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
pRaw = NULL;
|
||||
}
|
||||
|
||||
{
|
||||
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) return -1;
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
pRaw = NULL;
|
||||
}
|
||||
|
||||
mInfo("vgId:%d, vgroup info after move, replica:%d", newVg.vgId, newVg.replica);
|
||||
|
@ -1188,12 +1236,20 @@ static int32_t mndAddIncVgroupReplicaToTrans(SMnode *pMnode, STrans *pTrans, SDb
|
|||
SVnodeGid *pGid = &pVgroup->vnodeGid[pVgroup->replica];
|
||||
pVgroup->replica++;
|
||||
pGid->dnodeId = newDnodeId;
|
||||
pGid->syncState = TAOS_SYNC_STATE_ERROR;
|
||||
pGid->syncState = TAOS_SYNC_STATE_OFFLINE;
|
||||
|
||||
SSdbRaw *pVgRaw = mndVgroupActionEncode(pVgroup);
|
||||
if (pVgRaw == NULL) return -1;
|
||||
if (mndTransAppendRedolog(pTrans, pVgRaw) != 0) {
|
||||
sdbFreeRaw(pVgRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
|
||||
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, pVgroup, pGid) != 0) return -1;
|
||||
for (int32_t i = 0; i < pVgroup->replica - 1; ++i) {
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, pVgroup, pVgroup->vnodeGid[i].dnodeId) != 0) return -1;
|
||||
}
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, pVgroup, pGid) != 0) return -1;
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, pVgroup) != 0) return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -1219,6 +1275,14 @@ static int32_t mndAddDecVgroupReplicaFromTrans(SMnode *pMnode, STrans *pTrans, S
|
|||
memcpy(pGid, &pVgroup->vnodeGid[pVgroup->replica], sizeof(SVnodeGid));
|
||||
memset(&pVgroup->vnodeGid[pVgroup->replica], 0, sizeof(SVnodeGid));
|
||||
|
||||
SSdbRaw *pVgRaw = mndVgroupActionEncode(pVgroup);
|
||||
if (pVgRaw == NULL) return -1;
|
||||
if (mndTransAppendRedolog(pTrans, pVgRaw) != 0) {
|
||||
sdbFreeRaw(pVgRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
|
||||
|
||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, pVgroup, &delGid, true) != 0) return -1;
|
||||
for (int32_t i = 0; i < pVgroup->replica; ++i) {
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, pVgroup, pVgroup->vnodeGid[i].dnodeId) != 0) return -1;
|
||||
|
@ -1231,9 +1295,8 @@ static int32_t mndAddDecVgroupReplicaFromTrans(SMnode *pMnode, STrans *pTrans, S
|
|||
static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgroup, SDnodeObj *pNew1,
|
||||
SDnodeObj *pOld1, SDnodeObj *pNew2, SDnodeObj *pOld2, SDnodeObj *pNew3,
|
||||
SDnodeObj *pOld3) {
|
||||
int32_t code = -1;
|
||||
SSdbRaw *pRaw = NULL;
|
||||
STrans *pTrans = NULL;
|
||||
int32_t code = -1;
|
||||
STrans *pTrans = NULL;
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "red-vgroup");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
@ -1314,17 +1377,13 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb,
|
|||
}
|
||||
|
||||
{
|
||||
pRaw = mndVgroupActionEncode(&newVg);
|
||||
if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER;
|
||||
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
||||
if (pRaw == NULL) return -1;
|
||||
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) {
|
||||
sdbFreeRaw(pRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
pRaw = NULL;
|
||||
}
|
||||
|
||||
{
|
||||
pRaw = mndVgroupActionEncode(&newVg);
|
||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
pRaw = NULL;
|
||||
}
|
||||
|
||||
mInfo("vgId:%d, vgroup info after redistribute, replica:%d", newVg.vgId, newVg.replica);
|
||||
|
@ -1337,7 +1396,6 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb,
|
|||
|
||||
_OVER:
|
||||
mndTransDrop(pTrans);
|
||||
sdbFreeRaw(pRaw);
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
return code;
|
||||
}
|
||||
|
@ -1588,12 +1646,17 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
|
|||
mInfo("db:%s, vgId:%d, will add 2 vnodes, vn:0 dnode:%d", pVgroup->dbName, pVgroup->vgId,
|
||||
pVgroup->vnodeGid[0].dnodeId);
|
||||
|
||||
if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1;
|
||||
if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[1]) != 0) return -1;
|
||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVgroup, pArray) != 0) return -1;
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0)
|
||||
return -1;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[1]) != 0) return -1;
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1;
|
||||
|
||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVgroup, pArray) != 0) return -1;
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0)
|
||||
return -1;
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[1].dnodeId) != 0)
|
||||
return -1;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[2]) != 0) return -1;
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1;
|
||||
} else if (newVgroup.replica == 3 && pNewDb->cfg.replications == 1) {
|
||||
|
@ -1602,10 +1665,15 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
|
|||
|
||||
SVnodeGid del1 = {0};
|
||||
SVnodeGid del2 = {0};
|
||||
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del1) != 0) return -1;
|
||||
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del2) != 0) return -1;
|
||||
if (mndRemoveVnodeFromVgroup(pMnode, pTrans, &newVgroup, pArray, &del1) != 0) return -1;
|
||||
if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &del1, true) != 0) return -1;
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0)
|
||||
return -1;
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[1].dnodeId) != 0)
|
||||
return -1;
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1;
|
||||
|
||||
if (mndRemoveVnodeFromVgroup(pMnode, pTrans, &newVgroup, pArray, &del2) != 0) return -1;
|
||||
if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &del2, true) != 0) return -1;
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0)
|
||||
return -1;
|
||||
|
@ -1614,16 +1682,6 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
|
|||
return -1;
|
||||
}
|
||||
|
||||
{
|
||||
SSdbRaw *pVgRaw = mndVgroupActionEncode(&newVgroup);
|
||||
if (pVgRaw == NULL) return -1;
|
||||
if (mndTransAppendRedolog(pTrans, pVgRaw) != 0) {
|
||||
sdbFreeRaw(pVgRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
|
||||
}
|
||||
|
||||
{
|
||||
SSdbRaw *pVgRaw = mndVgroupActionEncode(&newVgroup);
|
||||
if (pVgRaw == NULL) return -1;
|
||||
|
@ -1642,10 +1700,9 @@ static int32_t mndAddAdjustVnodeHashRangeAction(SMnode *pMnode, STrans *pTrans,
|
|||
}
|
||||
|
||||
static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgroup) {
|
||||
int32_t code = -1;
|
||||
SSdbRaw *pRaw = NULL;
|
||||
STrans *pTrans = NULL;
|
||||
SArray *pArray = mndBuildDnodesArray(pMnode, 0);
|
||||
int32_t code = -1;
|
||||
STrans *pTrans = NULL;
|
||||
SArray *pArray = mndBuildDnodesArray(pMnode, 0);
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "split-vgroup");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
@ -1661,16 +1718,16 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
|
|||
}
|
||||
|
||||
if (newVg1.replica == 1) {
|
||||
if (mndAddVnodeToVgroup(pMnode, &newVg1, pArray) != 0) goto _OVER;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg1, &newVg1.vnodeGid[1]) != 0) goto _OVER;
|
||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg1, pArray) != 0) goto _OVER;
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg1, newVg1.vnodeGid[0].dnodeId) != 0) goto _OVER;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg1, &newVg1.vnodeGid[1]) != 0) goto _OVER;
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
|
||||
} else if (newVg1.replica == 3) {
|
||||
SVnodeGid del1 = {0};
|
||||
if (mndRemoveVnodeFromVgroup(pMnode, &newVg1, pArray, &del1) != 0) goto _OVER;
|
||||
if (mndRemoveVnodeFromVgroup(pMnode, pTrans, &newVg1, pArray, &del1) != 0) goto _OVER;
|
||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg1, &del1, true) != 0) goto _OVER;
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg1, newVg1.vnodeGid[0].dnodeId) != 0) goto _OVER;
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg1, newVg1.vnodeGid[1].dnodeId) != 0) goto _OVER;
|
||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg1, &del1, true) != 0) goto _OVER;
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
|
||||
} else {
|
||||
goto _OVER;
|
||||
|
@ -1712,17 +1769,23 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
|
|||
#endif
|
||||
|
||||
{
|
||||
pRaw = mndVgroupActionEncode(&newVg1);
|
||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
||||
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg1);
|
||||
if (pRaw == NULL) return -1;
|
||||
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) {
|
||||
sdbFreeRaw(pRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
pRaw = NULL;
|
||||
}
|
||||
|
||||
{
|
||||
pRaw = mndVgroupActionEncode(&newVg2);
|
||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
||||
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg2);
|
||||
if (pRaw == NULL) return -1;
|
||||
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) {
|
||||
sdbFreeRaw(pRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
pRaw = NULL;
|
||||
}
|
||||
|
||||
mInfo("vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d", newVg1.vgId,
|
||||
|
@ -1742,7 +1805,6 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
|
|||
_OVER:
|
||||
taosArrayDestroy(pArray);
|
||||
mndTransDrop(pTrans);
|
||||
sdbFreeRaw(pRaw);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1787,16 +1849,8 @@ static int32_t mndSetBalanceVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SD
|
|||
|
||||
{
|
||||
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
||||
if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) {
|
||||
sdbFreeRaw(pRaw);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
}
|
||||
|
||||
{
|
||||
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) {
|
||||
if (pRaw == NULL) return -1;
|
||||
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) {
|
||||
sdbFreeRaw(pRaw);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1127,7 +1127,7 @@ int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg) {
|
|||
SRpcMsg rpcMsg = {
|
||||
.code = 0,
|
||||
.contLen = len,
|
||||
.msgType = TDMT_VND_STREAM_RECOVER_STEP2,
|
||||
.msgType = TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE,
|
||||
.pCont = serializedReq,
|
||||
};
|
||||
|
||||
|
|
|
@ -21,14 +21,16 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl
|
|||
SBatchDeleteReq* deleteReq) {
|
||||
ASSERT(pDataBlock->info.type == STREAM_DELETE_RESULT);
|
||||
int32_t totRow = pDataBlock->info.rows;
|
||||
SColumnInfoData* pTsCol = taosArrayGet(pDataBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||
SColumnInfoData* pStartTsCol = taosArrayGet(pDataBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||
SColumnInfoData* pEndTsCol = taosArrayGet(pDataBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||
SColumnInfoData* pGidCol = taosArrayGet(pDataBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||
SColumnInfoData* pTbNameCol = taosArrayGet(pDataBlock->pDataBlock, TABLE_NAME_COLUMN_INDEX);
|
||||
|
||||
tqDebug("stream delete msg: row %d", totRow);
|
||||
|
||||
for (int32_t row = 0; row < totRow; row++) {
|
||||
int64_t ts = *(int64_t*)colDataGetData(pTsCol, row);
|
||||
int64_t startTs = *(int64_t*)colDataGetData(pStartTsCol, row);
|
||||
int64_t endTs = *(int64_t*)colDataGetData(pEndTsCol, row);
|
||||
int64_t groupId = *(int64_t*)colDataGetData(pGidCol, row);
|
||||
char* name;
|
||||
void* varTbName = NULL;
|
||||
|
@ -42,8 +44,8 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl
|
|||
} else {
|
||||
name = buildCtbNameByGroupId(stbFullName, groupId);
|
||||
}
|
||||
tqDebug("stream delete msg: vgId:%d, groupId :%" PRId64 ", name: %s, ts:%" PRId64, pVnode->config.vgId, groupId,
|
||||
name, ts);
|
||||
tqDebug("stream delete msg: vgId:%d, groupId :%" PRId64 ", name: %s, start ts:%" PRId64 "end ts:%" PRId64,
|
||||
pVnode->config.vgId, groupId, name, startTs, endTs);
|
||||
#if 0
|
||||
SMetaReader mr = {0};
|
||||
metaReaderInit(&mr, pVnode->pMeta, 0);
|
||||
|
@ -59,7 +61,8 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl
|
|||
taosMemoryFree(name);
|
||||
#endif
|
||||
SSingleDeleteReq req = {
|
||||
.ts = ts,
|
||||
.startTs = startTs,
|
||||
.endTs = endTs,
|
||||
};
|
||||
strncpy(req.tbname, name, TSDB_TABLE_NAME_LEN);
|
||||
taosMemoryFree(name);
|
||||
|
|
|
@ -775,7 +775,10 @@ static void doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_
|
|||
} else {
|
||||
varDataSetLen(pSup->buildBuf[colIndex], pColVal->value.nData);
|
||||
ASSERT(pColVal->value.nData <= pColInfoData->info.bytes);
|
||||
memcpy(varDataVal(pSup->buildBuf[colIndex]), pColVal->value.pData, pColVal->value.nData);
|
||||
if (pColVal->value.nData > 0) { // pData may be null, if nData is 0
|
||||
memcpy(varDataVal(pSup->buildBuf[colIndex]), pColVal->value.pData, pColVal->value.nData);
|
||||
}
|
||||
|
||||
colDataAppend(pColInfoData, rowIndex, pSup->buildBuf[colIndex], false);
|
||||
}
|
||||
} else {
|
||||
|
@ -2540,6 +2543,7 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
|||
goto _err;
|
||||
}
|
||||
|
||||
// TODO: opt the perf of read del index
|
||||
code = tsdbReadDelIdx(pDelFReader, aDelIdx);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(aDelIdx);
|
||||
|
|
|
@ -263,7 +263,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
goto _err;
|
||||
}
|
||||
} break;
|
||||
case TDMT_VND_STREAM_RECOVER_STEP2: {
|
||||
case TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE: {
|
||||
if (tqProcessTaskRecover2Req(pVnode->pTq, version, pMsg->pCont, pMsg->contLen) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
return tqProcessTaskRetrieveReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_RETRIEVE_RSP:
|
||||
return tqProcessTaskRetrieveRsp(pVnode->pTq, pMsg);
|
||||
case TDMT_VND_STREAM_RECOVER_STEP1:
|
||||
case TDMT_VND_STREAM_RECOVER_NONBLOCKING_STAGE:
|
||||
return tqProcessTaskRecover1Req(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_RECOVER_FINISH:
|
||||
return tqProcessTaskRecoverFinishReq(pVnode->pTq, pMsg);
|
||||
|
@ -1184,11 +1184,11 @@ static int32_t vnodeProcessBatchDeleteReq(SVnode *pVnode, int64_t version, void
|
|||
|
||||
int64_t uid = mr.me.uid;
|
||||
|
||||
int32_t code = tsdbDeleteTableData(pVnode->pTsdb, version, deleteReq.suid, uid, pOneReq->ts, pOneReq->ts);
|
||||
int32_t code = tsdbDeleteTableData(pVnode->pTsdb, version, deleteReq.suid, uid, pOneReq->startTs, pOneReq->endTs);
|
||||
if (code < 0) {
|
||||
terrno = code;
|
||||
vError("vgId:%d, delete error since %s, suid:%" PRId64 ", uid:%" PRId64 ", start ts:%" PRId64 ", end ts:%" PRId64,
|
||||
TD_VID(pVnode), terrstr(), deleteReq.suid, uid, pOneReq->ts, pOneReq->ts);
|
||||
TD_VID(pVnode), terrstr(), deleteReq.suid, uid, pOneReq->startTs, pOneReq->endTs);
|
||||
}
|
||||
|
||||
tDecoderClear(&mr.coder);
|
||||
|
|
|
@ -66,7 +66,7 @@ void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
}
|
||||
pMsg->info.hasEpSet = 1;
|
||||
|
||||
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info, .msgType = pMsg->msgType + 1};
|
||||
SRpcMsg rsp = {.code = TSDB_CODE_SYN_NOT_LEADER, .info = pMsg->info, .msgType = pMsg->msgType + 1};
|
||||
tmsgSendRedirectRsp(&rsp, &newEpSet);
|
||||
}
|
||||
|
||||
|
@ -515,6 +515,16 @@ void vnodeSyncPreClose(SVnode *pVnode) {
|
|||
vInfo("vgId:%d, pre close sync", pVnode->config.vgId);
|
||||
syncLeaderTransfer(pVnode->sync);
|
||||
syncPreStop(pVnode->sync);
|
||||
|
||||
while (syncSnapshotRecving(pVnode->sync)) {
|
||||
vInfo("vgId:%d, snapshot is recving", pVnode->config.vgId);
|
||||
taosMsleep(300);
|
||||
}
|
||||
while (syncSnapshotSending(pVnode->sync)) {
|
||||
vInfo("vgId:%d, snapshot is sending", pVnode->config.vgId);
|
||||
taosMsleep(300);
|
||||
}
|
||||
|
||||
taosThreadMutexLock(&pVnode->lock);
|
||||
if (pVnode->blocked) {
|
||||
vInfo("vgId:%d, post block after close sync", pVnode->config.vgId);
|
||||
|
|
|
@ -1205,7 +1205,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
|||
stbCtx.pName = &stbName;
|
||||
|
||||
STableMeta* stbMeta = NULL;
|
||||
ctgReadTbMetaFromCache(pCtg, &stbCtx, &stbMeta);
|
||||
(void)ctgReadTbMetaFromCache(pCtg, &stbCtx, &stbMeta);
|
||||
if (stbMeta && stbMeta->sversion >= pOut->tbMeta->sversion) {
|
||||
ctgDebug("use cached stb meta, tbName:%s", tNameGetTableName(pName));
|
||||
exist = 1;
|
||||
|
|
|
@ -1188,7 +1188,7 @@ SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch) {
|
|||
return (SName*)taosArrayGet(pReq->pTables, pFetch->tbIdx);
|
||||
}
|
||||
|
||||
static void* ctgCloneDbVgroup(void* pSrc) { return taosArrayDup((const SArray*)pSrc); }
|
||||
static void* ctgCloneDbVgroup(void* pSrc) { return taosArrayDup((const SArray*)pSrc, NULL); }
|
||||
|
||||
static void ctgFreeDbVgroup(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
||||
|
||||
|
@ -1238,7 +1238,7 @@ static void* ctgCloneVgroupInfo(void* pSrc) {
|
|||
|
||||
static void ctgFreeVgroupInfo(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); }
|
||||
|
||||
static void* ctgCloneTableIndices(void* pSrc) { return taosArrayDup((const SArray*)pSrc); }
|
||||
static void* ctgCloneTableIndices(void* pSrc) { return taosArrayDup((const SArray*)pSrc, NULL); }
|
||||
|
||||
static void ctgFreeTableIndices(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
||||
|
||||
|
@ -1275,7 +1275,7 @@ static void* ctgCloneUserAuth(void* pSrc) {
|
|||
|
||||
static void ctgFreeUserAuth(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); }
|
||||
|
||||
static void* ctgCloneQnodeList(void* pSrc) { return taosArrayDup((const SArray*)pSrc); }
|
||||
static void* ctgCloneQnodeList(void* pSrc) { return taosArrayDup((const SArray*)pSrc, NULL); }
|
||||
|
||||
static void ctgFreeQnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
||||
|
||||
|
@ -1290,11 +1290,11 @@ static void* ctgCloneTableCfg(void* pSrc) {
|
|||
|
||||
static void ctgFreeTableCfg(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); }
|
||||
|
||||
static void* ctgCloneDnodeList(void* pSrc) { return taosArrayDup((const SArray*)pSrc); }
|
||||
static void* ctgCloneDnodeList(void* pSrc) { return taosArrayDup((const SArray*)pSrc, NULL); }
|
||||
|
||||
static void ctgFreeDnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
||||
|
||||
static int32_t ctgCloneMetaDataArray(SArray* pSrc, FCopy copyFunc, SArray** pDst) {
|
||||
static int32_t ctgCloneMetaDataArray(SArray* pSrc, __array_item_dup_fn_t copyFunc, SArray** pDst) {
|
||||
if (NULL == pSrc) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -782,13 +782,18 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE: {
|
||||
SExchangePhysiNode *pExchNode = (SExchangePhysiNode *)pNode;
|
||||
SExplainGroup *group = taosHashGet(ctx->groupHash, &pExchNode->srcStartGroupId, sizeof(pExchNode->srcStartGroupId));
|
||||
if (NULL == group) {
|
||||
qError("exchange src group %d not in groupHash", pExchNode->srcStartGroupId);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
int32_t nodeNum = 0;
|
||||
for (int32_t i = pExchNode->srcStartGroupId; i <= pExchNode->srcEndGroupId; ++i) {
|
||||
SExplainGroup *group = taosHashGet(ctx->groupHash, &pExchNode->srcStartGroupId, sizeof(pExchNode->srcStartGroupId));
|
||||
if (NULL == group) {
|
||||
qError("exchange src group %d not in groupHash", pExchNode->srcStartGroupId);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
}
|
||||
|
||||
nodeNum += group->nodeNum;
|
||||
}
|
||||
|
||||
EXPLAIN_ROW_NEW(level, EXPLAIN_EXCHANGE_FORMAT, pExchNode->singleChannel ? 1 : group->nodeNum);
|
||||
EXPLAIN_ROW_NEW(level, EXPLAIN_EXCHANGE_FORMAT, pExchNode->singleChannel ? 1 : nodeNum);
|
||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||
if (pResNode->pExecInfo) {
|
||||
QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen));
|
||||
|
@ -819,7 +824,9 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
}
|
||||
}
|
||||
|
||||
QRY_ERR_RET(qExplainAppendGroupResRows(ctx, pExchNode->srcStartGroupId, level + 1, pExchNode->singleChannel));
|
||||
for (int32_t i = pExchNode->srcStartGroupId; i <= pExchNode->srcEndGroupId; ++i) {
|
||||
QRY_ERR_RET(qExplainAppendGroupResRows(ctx, i, level + 1, pExchNode->singleChannel));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_SORT: {
|
||||
|
|
|
@ -161,4 +161,6 @@ int32_t convertFillType(int32_t mode);
|
|||
int32_t resultrowComparAsc(const void* p1, const void* p2);
|
||||
int32_t isQualifiedTable(STableKeyInfo* info, SNode* pTagCond, void* metaHandle, bool* pQualified);
|
||||
|
||||
void printDataBlock(SSDataBlock* pBlock, const char* flag);
|
||||
|
||||
#endif // TDENGINE_QUERYUTIL_H
|
||||
|
|
|
@ -332,6 +332,7 @@ typedef struct STableScanInfo {
|
|||
int32_t currentTable;
|
||||
int8_t scanMode;
|
||||
int8_t assignBlockUid;
|
||||
bool hasGroupByTag;
|
||||
} STableScanInfo;
|
||||
|
||||
typedef struct STableMergeScanInfo {
|
||||
|
@ -537,23 +538,6 @@ typedef struct SStreamIntervalOperatorInfo {
|
|||
SWinKey delKey;
|
||||
} SStreamIntervalOperatorInfo;
|
||||
|
||||
typedef struct SFillOperatorInfo {
|
||||
struct SFillInfo* pFillInfo;
|
||||
SSDataBlock* pRes;
|
||||
SSDataBlock* pFinalRes;
|
||||
int64_t totalInputRows;
|
||||
void** p;
|
||||
SSDataBlock* existNewGroupBlock;
|
||||
STimeWindow win;
|
||||
SColMatchInfo matchInfo;
|
||||
int32_t primaryTsCol;
|
||||
int32_t primarySrcSlotId;
|
||||
uint64_t curGroupId; // current handled group id
|
||||
SExprInfo* pExprInfo;
|
||||
int32_t numOfExpr;
|
||||
SExprSupp noFillExprSupp;
|
||||
} SFillOperatorInfo;
|
||||
|
||||
typedef struct SDataGroupInfo {
|
||||
uint64_t groupId;
|
||||
int64_t numOfRows;
|
||||
|
@ -805,8 +789,6 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
|
|||
int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle);
|
||||
int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList);
|
||||
|
||||
void printTaskExecCostInLog(SExecTaskInfo* pTaskInfo);
|
||||
|
||||
int32_t getMaximumIdleDurationSec();
|
||||
|
||||
STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval,
|
||||
|
@ -824,9 +806,8 @@ bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup);
|
|||
bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, SStreamState* pState, STimeWindowAggSupp* pTwSup);
|
||||
void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid,
|
||||
uint64_t* pGp, void* pTbName);
|
||||
void printDataBlock(SSDataBlock* pBlock, const char* flag);
|
||||
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId);
|
||||
void calBlockTbName(SStreamScanInfo* pInfo, SSDataBlock* pBlock);
|
||||
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId);
|
||||
void calBlockTbName(SStreamScanInfo* pInfo, SSDataBlock* pBlock);
|
||||
|
||||
int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup,
|
||||
SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
||||
|
|
|
@ -25,6 +25,8 @@ extern "C" {
|
|||
#include "tcommon.h"
|
||||
#include "tsimplehash.h"
|
||||
|
||||
#define GET_DEST_SLOT_ID(_p) ((_p)->pExpr->base.resSchema.slotId)
|
||||
|
||||
struct SSDataBlock;
|
||||
|
||||
typedef struct SFillColInfo {
|
||||
|
@ -113,12 +115,12 @@ typedef struct SStreamFillInfo {
|
|||
|
||||
int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, int64_t ekey, int32_t maxNumOfRows);
|
||||
|
||||
void taosFillSetStartInfo(struct SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey);
|
||||
void taosResetFillInfo(struct SFillInfo* pFillInfo, TSKEY startTimestamp);
|
||||
void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struct SSDataBlock* pInput);
|
||||
struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprInfo* pNotFillExpr,
|
||||
int32_t numOfNotFillCols, const struct SNodeListNode* val);
|
||||
bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
|
||||
void taosFillSetStartInfo(struct SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey);
|
||||
void taosResetFillInfo(struct SFillInfo* pFillInfo, TSKEY startTimestamp);
|
||||
void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struct SSDataBlock* pInput);
|
||||
SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprInfo* pNotFillExpr,
|
||||
int32_t numOfNotFillCols, const struct SNodeListNode* val);
|
||||
bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
|
||||
|
||||
SFillInfo* taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillCols, int32_t capacity,
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t slotId,
|
||||
|
@ -128,6 +130,8 @@ void* taosDestroyFillInfo(struct SFillInfo* pFillInfo);
|
|||
int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, SSDataBlock* p, int32_t capacity);
|
||||
int64_t getFillInfoStart(struct SFillInfo* pFillInfo);
|
||||
|
||||
bool fillIfWindowPseudoColumn(SFillInfo* pFillInfo, SFillColInfo* pCol, SColumnInfoData* pDstColInfoData,
|
||||
int32_t rowIndex);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -15,26 +15,15 @@
|
|||
|
||||
#include "filter.h"
|
||||
#include "function.h"
|
||||
#include "functionMgt.h"
|
||||
#include "os.h"
|
||||
#include "querynodes.h"
|
||||
#include "tfill.h"
|
||||
#include "tname.h"
|
||||
#include "tref.h"
|
||||
|
||||
#include "tdatablock.h"
|
||||
#include "tglobal.h"
|
||||
#include "tmsg.h"
|
||||
#include "tsort.h"
|
||||
#include "ttime.h"
|
||||
|
||||
#include "executorimpl.h"
|
||||
#include "index.h"
|
||||
#include "query.h"
|
||||
#include "tcompare.h"
|
||||
#include "thash.h"
|
||||
#include "ttypes.h"
|
||||
#include "vnode.h"
|
||||
|
||||
typedef struct SFetchRspHandleWrapper {
|
||||
uint32_t exchangeId;
|
||||
|
|
|
@ -2002,3 +2002,13 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
|
|||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void printDataBlock(SSDataBlock* pBlock, const char* flag) {
|
||||
if (!pBlock || pBlock->info.rows == 0) {
|
||||
qDebug("===stream===printDataBlock: Block is Null or Empty");
|
||||
return;
|
||||
}
|
||||
char* pBuf = NULL;
|
||||
qDebug("%s", dumpBlockData(pBlock, flag, &pBuf));
|
||||
taosMemoryFree(pBuf);
|
||||
}
|
|
@ -704,6 +704,20 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void printTaskExecCostInLog(SExecTaskInfo* pTaskInfo) {
|
||||
STaskCostInfo* pSummary = &pTaskInfo->cost;
|
||||
|
||||
SFileBlockLoadRecorder* pRecorder = pSummary->pRecoder;
|
||||
if (pSummary->pRecoder != NULL) {
|
||||
qDebug(
|
||||
"%s :cost summary: elapsed time:%.2f ms, extract tableList:%.2f ms, createGroupIdMap:%.2f ms, total blocks:%d, "
|
||||
"load block SMA:%d, load data block:%d, total rows:%" PRId64 ", check rows:%" PRId64,
|
||||
GET_TASKID(pTaskInfo), pSummary->elapsedTime / 1000.0, pSummary->extractListTime, pSummary->groupIdMapTime,
|
||||
pRecorder->totalBlocks, pRecorder->loadBlockStatis, pRecorder->loadBlocks, pRecorder->totalRows,
|
||||
pRecorder->totalCheckedRows);
|
||||
}
|
||||
}
|
||||
|
||||
void qDestroyTask(qTaskInfo_t qTaskHandle) {
|
||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)qTaskHandle;
|
||||
if (pTaskInfo == NULL) {
|
||||
|
|
|
@ -91,7 +91,6 @@ static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock*
|
|||
|
||||
static void releaseQueryBuf(size_t numOfTables);
|
||||
|
||||
static void destroyFillOperatorInfo(void* param);
|
||||
static void destroyAggOperatorInfo(void* param);
|
||||
static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
|
||||
static void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId);
|
||||
|
@ -1157,20 +1156,6 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG
|
|||
}
|
||||
}
|
||||
|
||||
void printTaskExecCostInLog(SExecTaskInfo* pTaskInfo) {
|
||||
STaskCostInfo* pSummary = &pTaskInfo->cost;
|
||||
|
||||
SFileBlockLoadRecorder* pRecorder = pSummary->pRecoder;
|
||||
if (pSummary->pRecoder != NULL) {
|
||||
qDebug(
|
||||
"%s :cost summary: elapsed time:%.2f ms, extract tableList:%.2f ms, createGroupIdMap:%.2f ms, total blocks:%d, "
|
||||
"load block SMA:%d, load data block:%d, total rows:%" PRId64 ", check rows:%" PRId64,
|
||||
GET_TASKID(pTaskInfo), pSummary->elapsedTime / 1000.0, pSummary->extractListTime, pSummary->groupIdMapTime,
|
||||
pRecorder->totalBlocks, pRecorder->loadBlockStatis, pRecorder->loadBlocks, pRecorder->totalRows,
|
||||
pRecorder->totalCheckedRows);
|
||||
}
|
||||
}
|
||||
|
||||
// void skipBlocks(STaskRuntimeEnv *pRuntimeEnv) {
|
||||
// STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr;
|
||||
//
|
||||
|
@ -1419,6 +1404,78 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBlock **ppBlock) {
|
||||
if (!tsCountAlwaysReturnValue) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||
if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_PARTITION ||
|
||||
(downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN &&
|
||||
((STableScanInfo *)downstream->info)->hasGroupByTag == true)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx;
|
||||
bool hasCountFunc = false;
|
||||
for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) {
|
||||
if ((strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "count") == 0) ||
|
||||
(strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "hyperloglog") == 0) ||
|
||||
(strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "_hyperloglog_partial") == 0) ||
|
||||
(strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "_hyperloglog_merge") == 0)) {
|
||||
hasCountFunc = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasCountFunc) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SSDataBlock* pBlock = createDataBlock();
|
||||
pBlock->info.rows = 1;
|
||||
pBlock->info.capacity = 0;
|
||||
|
||||
for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) {
|
||||
SColumnInfoData colInfo = {0};
|
||||
colInfo.hasNull = true;
|
||||
colInfo.info.type = TSDB_DATA_TYPE_NULL;
|
||||
colInfo.info.bytes = 1;
|
||||
|
||||
SExprInfo* pOneExpr = &pOperator->exprSupp.pExprInfo[i];
|
||||
for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) {
|
||||
SFunctParam* pFuncParam = &pOneExpr->base.pParam[j];
|
||||
if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
|
||||
int32_t slotId = pFuncParam->pCol->slotId;
|
||||
int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
||||
if (slotId >= numOfCols) {
|
||||
taosArrayEnsureCap(pBlock->pDataBlock, slotId + 1);
|
||||
for (int32_t k = numOfCols; k < slotId + 1; ++k) {
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfo);
|
||||
}
|
||||
}
|
||||
} else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockDataEnsureCapacity(pBlock, pBlock->info.rows);
|
||||
*ppBlock = pBlock;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock **ppBlock) {
|
||||
if (!blockAllocated) {
|
||||
return;
|
||||
}
|
||||
|
||||
blockDataDestroy(*ppBlock);
|
||||
*ppBlock = NULL;
|
||||
}
|
||||
|
||||
|
||||
// this is a blocking operator
|
||||
static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
||||
if (OPTR_IS_OPENED(pOperator)) {
|
||||
|
@ -1436,22 +1493,36 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
|||
int32_t order = TSDB_ORDER_ASC;
|
||||
int32_t scanFlag = MAIN_SCAN;
|
||||
|
||||
bool hasValidBlock = false;
|
||||
bool blockAllocated = false;
|
||||
|
||||
while (1) {
|
||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||
if (pBlock == NULL) {
|
||||
break;
|
||||
if (!hasValidBlock) {
|
||||
createDataBlockForEmptyInput(pOperator, &pBlock);
|
||||
if (pBlock == NULL) {
|
||||
break;
|
||||
}
|
||||
blockAllocated = true;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
hasValidBlock = true;
|
||||
|
||||
int32_t code = getTableScanInfo(pOperator, &order, &scanFlag);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
destroyDataBlockForEmptyInput(blockAllocated, &pBlock);
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
|
||||
// there is an scalar expression that needs to be calculated before apply the group aggregation.
|
||||
if (pAggInfo->scalarExprSup.pExprInfo != NULL) {
|
||||
if (pAggInfo->scalarExprSup.pExprInfo != NULL && !blockAllocated) {
|
||||
SExprSupp* pSup1 = &pAggInfo->scalarExprSup;
|
||||
code = projectApplyFunctions(pSup1->pExprInfo, pBlock, pBlock, pSup1->pCtx, pSup1->numOfExprs, NULL);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
destroyDataBlockForEmptyInput(blockAllocated, &pBlock);
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
}
|
||||
|
@ -1461,8 +1532,12 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
|||
setInputDataBlock(pSup, pBlock, order, scanFlag, true);
|
||||
code = doAggregateImpl(pOperator, pSup->pCtx);
|
||||
if (code != 0) {
|
||||
destroyDataBlockForEmptyInput(blockAllocated, &pBlock);
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
|
||||
destroyDataBlockForEmptyInput(blockAllocated, &pBlock);
|
||||
|
||||
}
|
||||
|
||||
// the downstream operator may return with error code, so let's check the code before generating results.
|
||||
|
@ -1513,179 +1588,6 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) {
|
|||
return (rows == 0) ? NULL : pInfo->pRes;
|
||||
}
|
||||
|
||||
static void doHandleRemainBlockForNewGroupImpl(SOperatorInfo* pOperator, SFillOperatorInfo* pInfo,
|
||||
SResultInfo* pResultInfo, SExecTaskInfo* pTaskInfo) {
|
||||
pInfo->totalInputRows = pInfo->existNewGroupBlock->info.rows;
|
||||
SSDataBlock* pResBlock = pInfo->pFinalRes;
|
||||
|
||||
int32_t order = TSDB_ORDER_ASC;
|
||||
int32_t scanFlag = MAIN_SCAN;
|
||||
getTableScanInfo(pOperator, &order, &scanFlag);
|
||||
|
||||
int64_t ekey = pInfo->existNewGroupBlock->info.window.ekey;
|
||||
taosResetFillInfo(pInfo->pFillInfo, getFillInfoStart(pInfo->pFillInfo));
|
||||
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
doApplyScalarCalculation(pOperator, pInfo->existNewGroupBlock, order, scanFlag);
|
||||
|
||||
taosFillSetStartInfo(pInfo->pFillInfo, pInfo->pRes->info.rows, ekey);
|
||||
taosFillSetInputDataBlock(pInfo->pFillInfo, pInfo->pRes);
|
||||
|
||||
int32_t numOfResultRows = pResultInfo->capacity - pResBlock->info.rows;
|
||||
taosFillResultDataBlock(pInfo->pFillInfo, pResBlock, numOfResultRows);
|
||||
|
||||
pInfo->curGroupId = pInfo->existNewGroupBlock->info.id.groupId;
|
||||
pInfo->existNewGroupBlock = NULL;
|
||||
}
|
||||
|
||||
static void doHandleRemainBlockFromNewGroup(SOperatorInfo* pOperator, SFillOperatorInfo* pInfo,
|
||||
SResultInfo* pResultInfo, SExecTaskInfo* pTaskInfo) {
|
||||
if (taosFillHasMoreResults(pInfo->pFillInfo)) {
|
||||
int32_t numOfResultRows = pResultInfo->capacity - pInfo->pFinalRes->info.rows;
|
||||
taosFillResultDataBlock(pInfo->pFillInfo, pInfo->pFinalRes, numOfResultRows);
|
||||
pInfo->pRes->info.id.groupId = pInfo->curGroupId;
|
||||
return;
|
||||
}
|
||||
|
||||
// handle the cached new group data block
|
||||
if (pInfo->existNewGroupBlock) {
|
||||
doHandleRemainBlockForNewGroupImpl(pOperator, pInfo, pResultInfo, pTaskInfo);
|
||||
}
|
||||
}
|
||||
|
||||
static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag) {
|
||||
SFillOperatorInfo* pInfo = pOperator->info;
|
||||
SExprSupp* pSup = &pOperator->exprSupp;
|
||||
setInputDataBlock(pSup, pBlock, order, scanFlag, false);
|
||||
projectApplyFunctions(pSup->pExprInfo, pInfo->pRes, pBlock, pSup->pCtx, pSup->numOfExprs, NULL);
|
||||
|
||||
// reset the row value before applying the no-fill functions to the input data block, which is "pBlock" in this case.
|
||||
pInfo->pRes->info.rows = 0;
|
||||
SExprSupp* pNoFillSupp = &pInfo->noFillExprSupp;
|
||||
setInputDataBlock(pNoFillSupp, pBlock, order, scanFlag, false);
|
||||
|
||||
projectApplyFunctions(pNoFillSupp->pExprInfo, pInfo->pRes, pBlock, pNoFillSupp->pCtx, pNoFillSupp->numOfExprs, NULL);
|
||||
pInfo->pRes->info.id.groupId = pBlock->info.id.groupId;
|
||||
}
|
||||
|
||||
static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
|
||||
SFillOperatorInfo* pInfo = pOperator->info;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
|
||||
SResultInfo* pResultInfo = &pOperator->resultInfo;
|
||||
SSDataBlock* pResBlock = pInfo->pFinalRes;
|
||||
|
||||
blockDataCleanup(pResBlock);
|
||||
|
||||
int32_t order = TSDB_ORDER_ASC;
|
||||
int32_t scanFlag = MAIN_SCAN;
|
||||
getTableScanInfo(pOperator, &order, &scanFlag);
|
||||
|
||||
doHandleRemainBlockFromNewGroup(pOperator, pInfo, pResultInfo, pTaskInfo);
|
||||
if (pResBlock->info.rows > 0) {
|
||||
pResBlock->info.id.groupId = pInfo->curGroupId;
|
||||
return pResBlock;
|
||||
}
|
||||
|
||||
SOperatorInfo* pDownstream = pOperator->pDownstream[0];
|
||||
while (1) {
|
||||
SSDataBlock* pBlock = pDownstream->fpSet.getNextFn(pDownstream);
|
||||
if (pBlock == NULL) {
|
||||
if (pInfo->totalInputRows == 0) {
|
||||
setOperatorCompleted(pOperator);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey);
|
||||
} else {
|
||||
blockDataUpdateTsWindow(pBlock, pInfo->primarySrcSlotId);
|
||||
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
blockDataEnsureCapacity(pInfo->pRes, pBlock->info.rows);
|
||||
blockDataEnsureCapacity(pInfo->pFinalRes, pBlock->info.rows);
|
||||
doApplyScalarCalculation(pOperator, pBlock, order, scanFlag);
|
||||
|
||||
if (pInfo->curGroupId == 0 || pInfo->curGroupId == pInfo->pRes->info.id.groupId) {
|
||||
pInfo->curGroupId = pInfo->pRes->info.id.groupId; // the first data block
|
||||
pInfo->totalInputRows += pInfo->pRes->info.rows;
|
||||
|
||||
if (order == pInfo->pFillInfo->order) {
|
||||
taosFillSetStartInfo(pInfo->pFillInfo, pInfo->pRes->info.rows, pBlock->info.window.ekey);
|
||||
} else {
|
||||
taosFillSetStartInfo(pInfo->pFillInfo, pInfo->pRes->info.rows, pBlock->info.window.skey);
|
||||
}
|
||||
taosFillSetInputDataBlock(pInfo->pFillInfo, pInfo->pRes);
|
||||
} else if (pInfo->curGroupId != pBlock->info.id.groupId) { // the new group data block
|
||||
pInfo->existNewGroupBlock = pBlock;
|
||||
|
||||
// Fill the previous group data block, before handle the data block of new group.
|
||||
// Close the fill operation for previous group data block
|
||||
taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t numOfResultRows = pOperator->resultInfo.capacity - pResBlock->info.rows;
|
||||
taosFillResultDataBlock(pInfo->pFillInfo, pResBlock, numOfResultRows);
|
||||
|
||||
// current group has no more result to return
|
||||
if (pResBlock->info.rows > 0) {
|
||||
// 1. The result in current group not reach the threshold of output result, continue
|
||||
// 2. If multiple group results existing in one SSDataBlock is not allowed, return immediately
|
||||
if (pResBlock->info.rows > pResultInfo->threshold || pBlock == NULL || pInfo->existNewGroupBlock != NULL) {
|
||||
pResBlock->info.id.groupId = pInfo->curGroupId;
|
||||
return pResBlock;
|
||||
}
|
||||
|
||||
doHandleRemainBlockFromNewGroup(pOperator, pInfo, pResultInfo, pTaskInfo);
|
||||
if (pResBlock->info.rows >= pOperator->resultInfo.threshold || pBlock == NULL) {
|
||||
pResBlock->info.id.groupId = pInfo->curGroupId;
|
||||
return pResBlock;
|
||||
}
|
||||
} else if (pInfo->existNewGroupBlock) { // try next group
|
||||
assert(pBlock != NULL);
|
||||
|
||||
blockDataCleanup(pResBlock);
|
||||
|
||||
doHandleRemainBlockForNewGroupImpl(pOperator, pInfo, pResultInfo, pTaskInfo);
|
||||
if (pResBlock->info.rows > pResultInfo->threshold) {
|
||||
pResBlock->info.id.groupId = pInfo->curGroupId;
|
||||
return pResBlock;
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static SSDataBlock* doFill(SOperatorInfo* pOperator) {
|
||||
SFillOperatorInfo* pInfo = pOperator->info;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SSDataBlock* fillResult = NULL;
|
||||
while (true) {
|
||||
fillResult = doFillImpl(pOperator);
|
||||
if (fillResult == NULL) {
|
||||
setOperatorCompleted(pOperator);
|
||||
break;
|
||||
}
|
||||
|
||||
doFilter(fillResult, pOperator->exprSupp.pFilterInfo, &pInfo->matchInfo);
|
||||
if (fillResult->info.rows > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fillResult != NULL) {
|
||||
pOperator->resultInfo.totalRows += fillResult->info.rows;
|
||||
}
|
||||
|
||||
return fillResult;
|
||||
}
|
||||
|
||||
void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) {
|
||||
for (int32_t i = 0; i < numOfExprs; ++i) {
|
||||
SExprInfo* pExprInfo = &pExpr[i];
|
||||
|
@ -1955,167 +1857,6 @@ void destroyAggOperatorInfo(void* param) {
|
|||
taosMemoryFreeClear(param);
|
||||
}
|
||||
|
||||
void destroyFillOperatorInfo(void* param) {
|
||||
SFillOperatorInfo* pInfo = (SFillOperatorInfo*)param;
|
||||
pInfo->pFillInfo = taosDestroyFillInfo(pInfo->pFillInfo);
|
||||
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
||||
pInfo->pFinalRes = blockDataDestroy(pInfo->pFinalRes);
|
||||
|
||||
cleanupExprSupp(&pInfo->noFillExprSupp);
|
||||
|
||||
taosMemoryFreeClear(pInfo->p);
|
||||
taosArrayDestroy(pInfo->matchInfo.pList);
|
||||
taosMemoryFreeClear(param);
|
||||
}
|
||||
|
||||
static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t numOfCols, SExprInfo* pNotFillExpr,
|
||||
int32_t numOfNotFillCols, SNodeListNode* pValNode, STimeWindow win, int32_t capacity,
|
||||
const char* id, SInterval* pInterval, int32_t fillType, int32_t order) {
|
||||
SFillColInfo* pColInfo = createFillColInfo(pExpr, numOfCols, pNotFillExpr, numOfNotFillCols, pValNode);
|
||||
|
||||
int64_t startKey = (order == TSDB_ORDER_ASC) ? win.skey : win.ekey;
|
||||
STimeWindow w = getAlignQueryTimeWindow(pInterval, pInterval->precision, startKey);
|
||||
w = getFirstQualifiedTimeWindow(startKey, &w, pInterval, order);
|
||||
|
||||
pInfo->pFillInfo = taosCreateFillInfo(w.skey, numOfCols, numOfNotFillCols, capacity, pInterval, fillType, pColInfo,
|
||||
pInfo->primaryTsCol, order, id);
|
||||
|
||||
if (order == TSDB_ORDER_ASC) {
|
||||
pInfo->win.skey = win.skey;
|
||||
pInfo->win.ekey = win.ekey;
|
||||
} else {
|
||||
pInfo->win.skey = win.ekey;
|
||||
pInfo->win.ekey = win.skey;
|
||||
}
|
||||
pInfo->p = taosMemoryCalloc(numOfCols, POINTER_BYTES);
|
||||
|
||||
if (pInfo->pFillInfo == NULL || pInfo->p == NULL) {
|
||||
taosMemoryFree(pInfo->pFillInfo);
|
||||
taosMemoryFree(pInfo->p);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static bool isWstartColumnExist(SFillOperatorInfo* pInfo) {
|
||||
if (pInfo->noFillExprSupp.numOfExprs == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < pInfo->noFillExprSupp.numOfExprs; ++i) {
|
||||
SExprInfo* exprInfo = pInfo->noFillExprSupp.pExprInfo + i;
|
||||
if (exprInfo->pExpr->nodeType == QUERY_NODE_COLUMN && exprInfo->base.numOfParams == 1 &&
|
||||
exprInfo->base.pParam[0].pCol->colType == COLUMN_TYPE_WINDOW_START) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int32_t createPrimaryTsExprIfNeeded(SFillOperatorInfo* pInfo, SFillPhysiNode* pPhyFillNode, SExprSupp* pExprSupp,
|
||||
const char* idStr) {
|
||||
bool wstartExist = isWstartColumnExist(pInfo);
|
||||
|
||||
if (wstartExist == false) {
|
||||
if (pPhyFillNode->pWStartTs->type != QUERY_NODE_TARGET) {
|
||||
qError("pWStartTs of fill physical node is not a target node, %s", idStr);
|
||||
return TSDB_CODE_QRY_SYS_ERROR;
|
||||
}
|
||||
|
||||
SExprInfo* pExpr = taosMemoryRealloc(pExprSupp->pExprInfo, (pExprSupp->numOfExprs + 1) * sizeof(SExprInfo));
|
||||
if (pExpr == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
createExprFromTargetNode(&pExpr[pExprSupp->numOfExprs], (STargetNode*)pPhyFillNode->pWStartTs);
|
||||
pExprSupp->numOfExprs += 1;
|
||||
pExprSupp->pExprInfo = pExpr;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode,
|
||||
SExecTaskInfo* pTaskInfo) {
|
||||
SFillOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SFillOperatorInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pInfo->pRes = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc);
|
||||
SExprInfo* pExprInfo = createExprInfo(pPhyFillNode->pFillExprs, NULL, &pInfo->numOfExpr);
|
||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||
|
||||
SExprSupp* pNoFillSupp = &pInfo->noFillExprSupp;
|
||||
pNoFillSupp->pExprInfo = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &pNoFillSupp->numOfExprs);
|
||||
int32_t code = createPrimaryTsExprIfNeeded(pInfo, pPhyFillNode, pNoFillSupp, pTaskInfo->id.str);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
code = initExprSupp(pNoFillSupp, pNoFillSupp->pExprInfo, pNoFillSupp->numOfExprs);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
SInterval* pInterval =
|
||||
QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL == downstream->operatorType
|
||||
? &((SMergeAlignedIntervalAggOperatorInfo*)downstream->info)->intervalAggOperatorInfo->interval
|
||||
: &((SIntervalAggOperatorInfo*)downstream->info)->interval;
|
||||
|
||||
int32_t order = (pPhyFillNode->inputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||
int32_t type = convertFillType(pPhyFillNode->mode);
|
||||
|
||||
SResultInfo* pResultInfo = &pOperator->resultInfo;
|
||||
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||
code = initExprSupp(&pOperator->exprSupp, pExprInfo, pInfo->numOfExpr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pInfo->primaryTsCol = ((STargetNode*)pPhyFillNode->pWStartTs)->slotId;
|
||||
pInfo->primarySrcSlotId = ((SColumnNode*)((STargetNode*)pPhyFillNode->pWStartTs)->pExpr)->slotId;
|
||||
|
||||
int32_t numOfOutputCols = 0;
|
||||
code = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc, &numOfOutputCols,
|
||||
COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo);
|
||||
|
||||
code = initFillInfo(pInfo, pExprInfo, pInfo->numOfExpr, pNoFillSupp->pExprInfo, pNoFillSupp->numOfExprs,
|
||||
(SNodeListNode*)pPhyFillNode->pValues, pPhyFillNode->timeRange, pResultInfo->capacity,
|
||||
pTaskInfo->id.str, pInterval, type, order);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pInfo->pFinalRes = createOneDataBlock(pInfo->pRes, false);
|
||||
blockDataEnsureCapacity(pInfo->pFinalRes, pOperator->resultInfo.capacity);
|
||||
|
||||
code = filterInitFromNode((SNode*)pPhyFillNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
setOperatorInfo(pOperator, "FillOperator", QUERY_NODE_PHYSICAL_PLAN_FILL, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
pOperator->exprSupp.numOfExprs = pInfo->numOfExpr;
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, destroyFillOperatorInfo, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
if (pInfo != NULL) {
|
||||
destroyFillOperatorInfo(pInfo);
|
||||
}
|
||||
|
||||
pTaskInfo->code = code;
|
||||
taosMemoryFreeClear(pOperator);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPTR_EXEC_MODEL model, char* dbFName) {
|
||||
SExecTaskInfo* pTaskInfo = taosMemoryCalloc(1, sizeof(SExecTaskInfo));
|
||||
if (pTaskInfo == NULL) {
|
||||
|
@ -2355,10 +2096,12 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
return NULL;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < tableListGetSize(pTableListInfo); ++i) {
|
||||
size_t num = taosArrayGetSize(pList);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
STableKeyInfo* p = taosArrayGet(pList, i);
|
||||
tableListAddTableInfo(pTableListInfo, p->uid, 0);
|
||||
}
|
||||
|
||||
taosArrayDestroy(pList);
|
||||
} else { // Create group with only one table
|
||||
tableListAddTableInfo(pTableListInfo, pBlockNode->uid, 0);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -895,6 +895,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
|||
|
||||
pInfo->currentGroupId = -1;
|
||||
pInfo->assignBlockUid = pTableScanNode->assignBlockUid;
|
||||
pInfo->hasGroupByTag = pTableScanNode->pGroupTags ? true : false;
|
||||
|
||||
setOperatorInfo(pOperator, "TableScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, false, OP_NOT_OPENED, pInfo,
|
||||
pTaskInfo);
|
||||
|
@ -1051,6 +1052,9 @@ static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts,
|
|||
}
|
||||
|
||||
static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t* pRowIndex) {
|
||||
if (pBlock->info.rows == 0) {
|
||||
return false;
|
||||
}
|
||||
if ((*pRowIndex) == pBlock->info.rows) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1183,10 +1187,10 @@ static SSDataBlock* doRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32
|
|||
}
|
||||
|
||||
static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
|
||||
blockDataCleanup(pDestBlock);
|
||||
if (pSrcBlock->info.rows == 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
blockDataCleanup(pDestBlock);
|
||||
int32_t code = blockDataEnsureCapacity(pDestBlock, pSrcBlock->info.rows);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
|
@ -1335,30 +1339,6 @@ static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock,
|
|||
return code;
|
||||
}
|
||||
|
||||
static void calBlockTag(SExprSupp* pTagCalSup, SSDataBlock* pBlock, SSDataBlock* pResBlock) {
|
||||
if (pTagCalSup == NULL || pTagCalSup->numOfExprs == 0) return;
|
||||
if (pBlock == NULL || pBlock->info.rows == 0) return;
|
||||
|
||||
SSDataBlock* pSrcBlock = blockCopyOneRow(pBlock, 0);
|
||||
ASSERT(pSrcBlock->info.rows == 1);
|
||||
|
||||
blockDataEnsureCapacity(pResBlock, 1);
|
||||
|
||||
projectApplyFunctions(pTagCalSup->pExprInfo, pResBlock, pSrcBlock, pTagCalSup->pCtx, 1, NULL);
|
||||
ASSERT(pResBlock->info.rows == 1);
|
||||
|
||||
// build tagArray
|
||||
/*SArray* tagArray = taosArrayInit(0, sizeof(void*));*/
|
||||
/*STagVal tagVal = {*/
|
||||
/*.cid = 0,*/
|
||||
/*.type = 0,*/
|
||||
/*};*/
|
||||
// build STag
|
||||
// set STag
|
||||
|
||||
blockDataDestroy(pSrcBlock);
|
||||
}
|
||||
|
||||
void calBlockTbName(SStreamScanInfo* pInfo, SSDataBlock* pBlock) {
|
||||
SExprSupp* pTbNameCalSup = &pInfo->tbnameCalSup;
|
||||
SStreamState* pState = pInfo->pStreamScanOp->pTaskInfo->streamInfo.pState;
|
||||
|
@ -1836,6 +1816,12 @@ FETCH_NEXT_BLOCK:
|
|||
}
|
||||
setBlockGroupIdByUid(pInfo, pDelBlock);
|
||||
printDataBlock(pDelBlock, "stream scan delete recv filtered");
|
||||
if (pDelBlock->info.rows == 0) {
|
||||
if (pInfo->tqReader) {
|
||||
blockDataDestroy(pDelBlock);
|
||||
}
|
||||
goto FETCH_NEXT_BLOCK;
|
||||
}
|
||||
if (!isIntervalWindow(pInfo) && !isSessionWindow(pInfo) && !isStateWindow(pInfo)) {
|
||||
generateDeleteResultBlock(pInfo, pDelBlock, pInfo->pDeleteDataRes);
|
||||
pInfo->pDeleteDataRes->info.type = STREAM_DELETE_RESULT;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -467,11 +467,11 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
|||
// add current row if timestamp match
|
||||
if (ts == pSliceInfo->current && pSliceInfo->current <= pSliceInfo->win.ekey) {
|
||||
addCurrentRowToResult(pSliceInfo, &pOperator->exprSupp, pResBlock, pBlock, i);
|
||||
doKeepPrevRows(pSliceInfo, pBlock, i);
|
||||
|
||||
pSliceInfo->current =
|
||||
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
|
||||
}
|
||||
doKeepPrevRows(pSliceInfo, pBlock, i);
|
||||
|
||||
if (pSliceInfo->current > pSliceInfo->win.ekey) {
|
||||
setOperatorCompleted(pOperator);
|
||||
|
|
|
@ -677,16 +677,6 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
|
|||
}
|
||||
}
|
||||
|
||||
void printDataBlock(SSDataBlock* pBlock, const char* flag) {
|
||||
if (!pBlock || pBlock->info.rows == 0) {
|
||||
qDebug("===stream===printDataBlock: Block is Null or Empty");
|
||||
return;
|
||||
}
|
||||
char* pBuf = NULL;
|
||||
qDebug("%s", dumpBlockData(pBlock, flag, &pBuf));
|
||||
taosMemoryFree(pBuf);
|
||||
}
|
||||
|
||||
typedef int32_t (*__compare_fn_t)(void* pKey, void* data, int32_t index);
|
||||
|
||||
int32_t binarySearchCom(void* keyList, int num, void* pKey, int order, __compare_fn_t comparefn) {
|
||||
|
@ -3117,7 +3107,7 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
|
|||
if (!winInfo.pOutputBuf) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
|
||||
code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &winInfo, &pResult, i, winRows, rows, numOfOutput,
|
||||
pOperator);
|
||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
|
@ -3242,8 +3232,8 @@ void doBuildDeleteDataBlock(SOperatorInfo* pOp, SSHashObj* pStDeleted, SSDataBlo
|
|||
char parTbName[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN];
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(parTbName, tbname, sizeof(parTbName));
|
||||
colDataAppend(pTableCol, pBlock->info.rows, (const char*)parTbName, false);
|
||||
tdbFree(tbname);
|
||||
}
|
||||
tdbFree(tbname);
|
||||
pBlock->info.rows += 1;
|
||||
}
|
||||
if ((*Ite) == NULL) {
|
||||
|
@ -3854,7 +3844,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
|||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SStreamStateAggOperatorInfo* pInfo = pOperator->info;
|
||||
int32_t numOfOutput = pOperator->exprSupp.numOfExprs;
|
||||
int64_t groupId = pSDataBlock->info.id.groupId;
|
||||
uint64_t groupId = pSDataBlock->info.id.groupId;
|
||||
int64_t code = TSDB_CODE_SUCCESS;
|
||||
TSKEY* tsCols = NULL;
|
||||
SResultRow* pResult = NULL;
|
||||
|
|
|
@ -116,9 +116,12 @@ void tsortClearOrderdSource(SArray *pOrderedSource) {
|
|||
if (NULL == *pSource) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// release pageIdList
|
||||
if ((*pSource)->pageIdList) {
|
||||
taosArrayDestroy((*pSource)->pageIdList);
|
||||
}
|
||||
if ((*pSource)->param && !(*pSource)->onlyRef) {
|
||||
taosMemoryFree((*pSource)->param);
|
||||
taosMemoryFree((*pSource)->param);
|
||||
}
|
||||
taosMemoryFreeClear(*pSource);
|
||||
}
|
||||
|
|
|
@ -526,7 +526,7 @@ static int32_t getNumOfElems(SqlFunctionCtx* pCtx) {
|
|||
* count function does not use the pCtx->interResBuf to keep the intermediate buffer
|
||||
*/
|
||||
int32_t countFunction(SqlFunctionCtx* pCtx) {
|
||||
int32_t numOfElem = getNumOfElems(pCtx);
|
||||
int32_t numOfElem = 0;
|
||||
|
||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
|
@ -539,6 +539,7 @@ int32_t countFunction(SqlFunctionCtx* pCtx) {
|
|||
numOfElem = 1;
|
||||
*((int64_t*)buf) = 0;
|
||||
} else {
|
||||
numOfElem = getNumOfElems(pCtx);
|
||||
*((int64_t*)buf) += numOfElem;
|
||||
}
|
||||
|
||||
|
@ -1499,7 +1500,7 @@ int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
|
||||
param12 /= param[1][1];
|
||||
|
||||
char buf[64] = {0};
|
||||
char buf[512] = {0};
|
||||
size_t len =
|
||||
snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", param02, param12);
|
||||
varDataSetLen(buf, len);
|
||||
|
@ -2043,12 +2044,16 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
|||
|
||||
pInfo->bytes = pInputCol->info.bytes;
|
||||
|
||||
if (IS_NULL_TYPE(pInputCol->info.type)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// All null data column, return directly.
|
||||
if (pInput->colDataSMAIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows)) {
|
||||
ASSERT(pInputCol->hasNull == true);
|
||||
// save selectivity value for column consisted of all null values
|
||||
firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SColumnDataAgg* pColAgg = (pInput->colDataSMAIsSet) ? pInput->pColumnDataAgg[0] : NULL;
|
||||
|
@ -2147,12 +2152,16 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
|||
int32_t bytes = pInputCol->info.bytes;
|
||||
pInfo->bytes = bytes;
|
||||
|
||||
if (IS_NULL_TYPE(type)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// All null data column, return directly.
|
||||
if (pInput->colDataSMAIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows)) {
|
||||
ASSERT(pInputCol->hasNull == true);
|
||||
// save selectivity value for column consisted of all null values
|
||||
firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SColumnDataAgg* pColAgg = (pInput->colDataSMAIsSet) ? pInput->pColumnDataAgg[0] : NULL;
|
||||
|
@ -2417,9 +2426,14 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
|
|||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||
|
||||
int32_t type = pInputCol->info.type;
|
||||
int32_t bytes = pInputCol->info.bytes;
|
||||
pInfo->bytes = bytes;
|
||||
|
||||
if (IS_NULL_TYPE(type)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
TSKEY startKey = getRowPTs(pInput->pPTS, 0);
|
||||
TSKEY endKey = getRowPTs(pInput->pPTS, pInput->totalRows - 1);
|
||||
|
||||
|
@ -3613,6 +3627,7 @@ bool histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultIn
|
|||
char* binDesc = strndup(varDataVal(pCtx->param[2].param.pz), varDataLen(pCtx->param[2].param.pz));
|
||||
int64_t normalized = pCtx->param[3].param.i;
|
||||
if (normalized != 0 && normalized != 1) {
|
||||
taosMemoryFree(binDesc);
|
||||
return false;
|
||||
}
|
||||
if (!getHistogramBinDesc(pInfo, binDesc, binType, (bool)normalized)) {
|
||||
|
@ -3868,6 +3883,10 @@ int32_t hllFunction(SqlFunctionCtx* pCtx) {
|
|||
int32_t numOfRows = pInput->numOfRows;
|
||||
|
||||
int32_t numOfElems = 0;
|
||||
if (IS_NULL_TYPE(type)) {
|
||||
goto _hll_over;
|
||||
}
|
||||
|
||||
for (int32_t i = start; i < numOfRows + start; ++i) {
|
||||
if (pCol->hasNull && colDataIsNull_s(pCol, i)) {
|
||||
continue;
|
||||
|
@ -3889,6 +3908,7 @@ int32_t hllFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
}
|
||||
|
||||
_hll_over:
|
||||
pInfo->totalCount += numOfElems;
|
||||
|
||||
if (pInfo->totalCount == 0 && !tsCountAlwaysReturnValue) {
|
||||
|
@ -3912,12 +3932,16 @@ static void hllTransferInfo(SHLLInfo* pInput, SHLLInfo* pOutput) {
|
|||
int32_t hllFunctionMerge(SqlFunctionCtx* pCtx) {
|
||||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
SColumnInfoData* pCol = pInput->pData[0];
|
||||
ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY);
|
||||
|
||||
if (pCol->info.type != TSDB_DATA_TYPE_BINARY) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SHLLInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
|
||||
int32_t start = pInput->startRowIndex;
|
||||
|
||||
|
||||
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
||||
char* data = colDataGetData(pCol, i);
|
||||
SHLLInfo* pInputInfo = (SHLLInfo*)varDataVal(data);
|
||||
|
|
|
@ -133,6 +133,14 @@ static void i8VectorSumAVX2(const int8_t* plist, int32_t numOfRows, int32_t type
|
|||
sum = _mm256_add_epi64(sum, extVal);
|
||||
p += width;
|
||||
}
|
||||
|
||||
// let sum up the final results
|
||||
const int64_t* q = (const int64_t*)∑
|
||||
pRes->sum.isum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.isum += plist[j + rounds * width];
|
||||
}
|
||||
} else {
|
||||
const uint8_t* p = (const uint8_t*)plist;
|
||||
|
||||
|
@ -142,16 +150,16 @@ static void i8VectorSumAVX2(const int8_t* plist, int32_t numOfRows, int32_t type
|
|||
sum = _mm256_add_epi64(sum, extVal);
|
||||
p += width;
|
||||
}
|
||||
|
||||
// let sum up the final results
|
||||
const uint64_t* q = (const uint64_t*)∑
|
||||
pRes->sum.usum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.usum += (uint8_t)plist[j + rounds * width];
|
||||
}
|
||||
}
|
||||
|
||||
// let sum up the final results
|
||||
const int64_t* q = (const int64_t*)∑
|
||||
pRes->sum.isum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
int32_t startIndex = rounds * width;
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.isum += plist[j + startIndex];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -176,8 +184,16 @@ static void i16VectorSumAVX2(const int16_t* plist, int32_t numOfRows, int32_t ty
|
|||
sum = _mm256_add_epi64(sum, extVal);
|
||||
p += width;
|
||||
}
|
||||
|
||||
// let sum up the final results
|
||||
const int64_t* q = (const int64_t*)∑
|
||||
pRes->sum.isum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.isum += plist[j + rounds * width];
|
||||
}
|
||||
} else {
|
||||
const uint8_t* p = (const uint8_t*)plist;
|
||||
const uint16_t* p = (const uint16_t*)plist;
|
||||
|
||||
for(int32_t i = 0; i < rounds; ++i) {
|
||||
__m128i val = _mm_lddqu_si128((__m128i*)p);
|
||||
|
@ -185,16 +201,16 @@ static void i16VectorSumAVX2(const int16_t* plist, int32_t numOfRows, int32_t ty
|
|||
sum = _mm256_add_epi64(sum, extVal);
|
||||
p += width;
|
||||
}
|
||||
|
||||
// let sum up the final results
|
||||
const uint64_t* q = (const uint64_t*)∑
|
||||
pRes->sum.usum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.usum += (uint16_t)plist[j + rounds * width];
|
||||
}
|
||||
}
|
||||
|
||||
// let sum up the final results
|
||||
const int64_t* q = (const int64_t*)∑
|
||||
pRes->sum.isum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
int32_t startIndex = rounds * width;
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.isum += plist[j + startIndex];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -219,6 +235,14 @@ static void i32VectorSumAVX2(const int32_t* plist, int32_t numOfRows, int32_t ty
|
|||
sum = _mm256_add_epi64(sum, extVal);
|
||||
p += width;
|
||||
}
|
||||
|
||||
// let sum up the final results
|
||||
const int64_t* q = (const int64_t*)∑
|
||||
pRes->sum.isum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.isum += plist[j + rounds * width];
|
||||
}
|
||||
} else {
|
||||
const uint32_t* p = (const uint32_t*)plist;
|
||||
|
||||
|
@ -228,16 +252,16 @@ static void i32VectorSumAVX2(const int32_t* plist, int32_t numOfRows, int32_t ty
|
|||
sum = _mm256_add_epi64(sum, extVal);
|
||||
p += width;
|
||||
}
|
||||
|
||||
// let sum up the final results
|
||||
const uint64_t* q = (const uint64_t*)∑
|
||||
pRes->sum.usum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.usum += (uint32_t)plist[j + rounds * width];
|
||||
}
|
||||
}
|
||||
|
||||
// let sum up the final results
|
||||
const int64_t* q = (const int64_t*)∑
|
||||
pRes->sum.isum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
int32_t startIndex = rounds * width;
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.isum += plist[j + startIndex];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -262,13 +286,22 @@ static void i64VectorSumAVX2(const int64_t* plist, int32_t numOfRows, SAvgRes* p
|
|||
}
|
||||
|
||||
// let sum up the final results
|
||||
const int64_t* q = (const int64_t*)∑
|
||||
pRes->sum.isum += q[0] + q[1] + q[2] + q[3];
|
||||
if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||
const int64_t* q = (const int64_t*)∑
|
||||
pRes->sum.isum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
int32_t startIndex = rounds * width;
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.isum += plist[j + startIndex];
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.isum += plist[j + rounds * width];
|
||||
}
|
||||
} else {
|
||||
const uint64_t* q = (const uint64_t*)∑
|
||||
pRes->sum.usum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.usum += (uint64_t)plist[j + rounds * width];
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -471,7 +504,6 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
int32_t type = pInput->pData[0]->info.type;
|
||||
|
||||
SAvgRes* pAvgRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
pAvgRes->type = type;
|
||||
|
||||
// computing based on the true data block
|
||||
SColumnInfoData* pCol = pInput->pData[0];
|
||||
|
@ -483,6 +515,8 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
goto _over;
|
||||
}
|
||||
|
||||
pAvgRes->type = type;
|
||||
|
||||
if (pInput->colDataSMAIsSet) { // try to use SMA if available
|
||||
numOfElem = calculateAvgBySMAInfo(pAvgRes, numOfRows, type, pAgg);
|
||||
} else if (!pCol->hasNull) { // try to employ the simd instructions to speed up the loop
|
||||
|
@ -501,7 +535,11 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
i8VectorSumAVX2(plist, numOfRows, type, pAvgRes);
|
||||
} else {
|
||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
pAvgRes->sum.usum += plist[i];
|
||||
if (type == TSDB_DATA_TYPE_TINYINT) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
} else {
|
||||
pAvgRes->sum.usum += (uint8_t)plist[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -516,7 +554,11 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
i16VectorSumAVX2(plist, numOfRows, type, pAvgRes);
|
||||
} else {
|
||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
if (type == TSDB_DATA_TYPE_SMALLINT) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
} else {
|
||||
pAvgRes->sum.usum += (uint16_t)plist[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -531,7 +573,11 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
i32VectorSumAVX2(plist, numOfRows, type, pAvgRes);
|
||||
} else {
|
||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
if (type == TSDB_DATA_TYPE_INT) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
} else {
|
||||
pAvgRes->sum.usum += (uint32_t)plist[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -546,7 +592,11 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
i64VectorSumAVX2(plist, numOfRows, pAvgRes);
|
||||
} else {
|
||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
} else {
|
||||
pAvgRes->sum.isum += (uint64_t)plist[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -592,6 +642,10 @@ _over:
|
|||
}
|
||||
|
||||
static void avgTransferInfo(SAvgRes* pInput, SAvgRes* pOutput) {
|
||||
if (IS_NULL_TYPE(pInput->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
pOutput->type = pInput->type;
|
||||
if (IS_SIGNED_NUMERIC_TYPE(pOutput->type)) {
|
||||
pOutput->sum.isum += pInput->sum.isum;
|
||||
|
@ -748,4 +802,4 @@ int32_t avgPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
|
||||
taosMemoryFree(res);
|
||||
return pResInfo->numOfRes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,8 +231,10 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
|||
SIF_ERR_RET(sifGetValueFromNode(node, ¶m->condValue));
|
||||
param->colId = -1;
|
||||
param->colValType = (uint8_t)(vn->node.resType.type);
|
||||
if (strlen(vn->literal) <= sizeof(param->colName)) {
|
||||
if (vn->literal != NULL && strlen(vn->literal) <= sizeof(param->colName)) {
|
||||
memcpy(param->colName, vn->literal, strlen(vn->literal));
|
||||
} else {
|
||||
param->status = SFLT_NOT_INDEX;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ void monRecordLog(int64_t ts, ELogLevel level, const char *content) {
|
|||
|
||||
int32_t monGetLogs(SMonLogs *logs) {
|
||||
taosThreadMutexLock(&tsMonitor.lock);
|
||||
logs->logs = taosArrayDup(tsMonitor.logs);
|
||||
logs->logs = taosArrayDup(tsMonitor.logs, NULL);
|
||||
logs->numOfInfoLogs = tsNumOfInfoLogs;
|
||||
logs->numOfErrorLogs = tsNumOfErrorLogs;
|
||||
logs->numOfDebugLogs = tsNumOfDebugLogs;
|
||||
|
|
|
@ -2952,6 +2952,7 @@ static const char* jkValueDuration = "Duration";
|
|||
static const char* jkValueTranslate = "Translate";
|
||||
static const char* jkValueNotReserved = "NotReserved";
|
||||
static const char* jkValueIsNull = "IsNull";
|
||||
static const char* jkValueUnit = "Unit";
|
||||
static const char* jkValueDatum = "Datum";
|
||||
|
||||
static int32_t datumToJson(const void* pObj, SJson* pJson) {
|
||||
|
@ -3041,6 +3042,9 @@ static int32_t valueNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddBoolToObject(pJson, jkValueIsNull, pNode->isNull);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkValueUnit, pNode->unit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && pNode->translate && !pNode->isNull) {
|
||||
code = datumToJson(pNode, pJson);
|
||||
}
|
||||
|
@ -3191,6 +3195,9 @@ static int32_t jsonToValueNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBoolValue(pJson, jkValueIsNull, &pNode->isNull);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetTinyIntValue(pJson, jkValueUnit, &pNode->unit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && pNode->translate && !pNode->isNull) {
|
||||
code = jsonToDatum(pJson, pNode);
|
||||
}
|
||||
|
|
|
@ -424,6 +424,7 @@ SNode* nodesMakeNode(ENodeType type) {
|
|||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
||||
return makeNode(type, sizeof(SShowStmt));
|
||||
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
||||
return makeNode(type, sizeof(SShowTableTagsStmt));
|
||||
|
@ -943,7 +944,8 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_TAGS_STMT: {
|
||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT: {
|
||||
SShowStmt* pStmt = (SShowStmt*)pNode;
|
||||
nodesDestroyNode(pStmt->pDbName);
|
||||
nodesDestroyNode(pStmt->pTbName);
|
||||
|
|
|
@ -135,7 +135,7 @@ int32_t insAllocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize);
|
|||
int32_t insCreateSName(SName *pName, struct SToken *pTableName, int32_t acctId, const char *dbName, SMsgBuf *pMsgBuf);
|
||||
int32_t insFindCol(struct SToken *pColname, int32_t start, int32_t end, SSchema *pSchema);
|
||||
void insBuildCreateTbReq(SVCreateTbReq *pTbReq, const char *tname, STag *pTag, int64_t suid, const char *sname,
|
||||
SArray *tagName, uint8_t tagNum);
|
||||
SArray *tagName, uint8_t tagNum, int32_t ttl);
|
||||
int32_t insMemRowAppend(SMsgBuf *pMsgBuf, const void *value, int32_t len, void *param);
|
||||
int32_t insCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start);
|
||||
int32_t insBuildOutput(SHashObj *pVgroupsHashObj, SArray *pVgDataBlocks, SArray **pDataBlocks);
|
||||
|
|
|
@ -101,6 +101,7 @@ cmd ::= REVOKE privileges(A) ON priv_level(B) FROM user_name(C).
|
|||
%destructor privileges { }
|
||||
privileges(A) ::= ALL. { A = PRIVILEGE_TYPE_ALL; }
|
||||
privileges(A) ::= priv_type_list(B). { A = B; }
|
||||
privileges(A) ::= SUBSCRIBE. { A = PRIVILEGE_TYPE_SUBSCRIBE; }
|
||||
|
||||
%type priv_type_list { int64_t }
|
||||
%destructor priv_type_list { }
|
||||
|
@ -116,6 +117,7 @@ priv_type(A) ::= WRITE.
|
|||
%destructor priv_level { }
|
||||
priv_level(A) ::= NK_STAR(B) NK_DOT NK_STAR. { A = B; }
|
||||
priv_level(A) ::= db_name(B) NK_DOT NK_STAR. { A = B; }
|
||||
priv_level(A) ::= topic_name(B). { A = B; }
|
||||
|
||||
/************************************************ create/drop/alter dnode *********************************************/
|
||||
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
||||
|
@ -393,6 +395,7 @@ col_name(A) ::= column_name(B).
|
|||
/************************************************ show ****************************************************************/
|
||||
cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); }
|
||||
cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); }
|
||||
cmd ::= SHOW USER PRIVILEGES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); }
|
||||
cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); }
|
||||
cmd ::= SHOW db_name_cond_opt(A) TABLES like_pattern_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, A, B, OP_TYPE_LIKE); }
|
||||
cmd ::= SHOW db_name_cond_opt(A) STABLES like_pattern_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, A, B, OP_TYPE_LIKE); }
|
||||
|
|
|
@ -1407,7 +1407,7 @@ SNode* createShowTableTagsStmt(SAstCreateContext* pCxt, SNode* pTbName, SNode* p
|
|||
|
||||
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
char password[TSDB_USET_PASSWORD_LEN] = {0};
|
||||
char password[TSDB_USET_PASSWORD_LEN + 3] = {0};
|
||||
if (!checkUserName(pCxt, pUserName) || !checkPassword(pCxt, pPassword, password)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1815,7 +1815,7 @@ SNode* createGrantStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbN
|
|||
SGrantStmt* pStmt = (SGrantStmt*)nodesMakeNode(QUERY_NODE_GRANT_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->privileges = privileges;
|
||||
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||
COPY_STRING_FORM_ID_TOKEN(pStmt->objName, pDbName);
|
||||
COPY_STRING_FORM_ID_TOKEN(pStmt->userName, pUserName);
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
@ -1828,7 +1828,7 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb
|
|||
SRevokeStmt* pStmt = (SRevokeStmt*)nodesMakeNode(QUERY_NODE_REVOKE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->privileges = privileges;
|
||||
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||
COPY_STRING_FORM_ID_TOKEN(pStmt->objName, pDbName);
|
||||
COPY_STRING_FORM_ID_TOKEN(pStmt->userName, pUserName);
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
|
|
@ -504,6 +504,11 @@ static int32_t collectMetaKeyFromShowVnodes(SCollectMetaKeyCxt* pCxt, SShowVnode
|
|||
pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowUserPrivileges(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_PRIVILEGES,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) {
|
||||
return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
||||
}
|
||||
|
@ -648,6 +653,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
|||
return collectMetaKeyFromShowDnodeVariables(pCxt, (SShowDnodeVariablesStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||
return collectMetaKeyFromShowVnodes(pCxt, (SShowVnodesStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
||||
return collectMetaKeyFromShowUserPrivileges(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||
return collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||
|
|
|
@ -169,7 +169,7 @@ static int32_t calcConstStmtCondition(SCalcConstContext* pCxt, SNode** pCond, bo
|
|||
static int32_t calcConstProject(SNode* pProject, bool dual, SNode** pNew) {
|
||||
SArray* pAssociation = NULL;
|
||||
if (NULL != ((SExprNode*)pProject)->pAssociation) {
|
||||
pAssociation = taosArrayDup(((SExprNode*)pProject)->pAssociation);
|
||||
pAssociation = taosArrayDup(((SExprNode*)pProject)->pAssociation, NULL);
|
||||
if (NULL == pAssociation) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ end:
|
|||
}
|
||||
|
||||
int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols, bool format, STableMeta* pTableMeta,
|
||||
char* tableName, const char* sTableName, int32_t sTableNameLen, char* msgBuf, int16_t msgBufLen) {
|
||||
char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl, char* msgBuf, int16_t msgBufLen) {
|
||||
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||
|
||||
SSmlExecHandle* smlHandle = (SSmlExecHandle*)handle;
|
||||
|
@ -229,7 +229,7 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
|
|||
}
|
||||
|
||||
insBuildCreateTbReq(&smlHandle->tableExecHandle.createTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName,
|
||||
pTableMeta->tableInfo.numOfTags);
|
||||
pTableMeta->tableInfo.numOfTags, ttl);
|
||||
taosArrayDestroy(tagName);
|
||||
|
||||
smlHandle->tableExecHandle.createTblReq.ctb.stbName = taosMemoryMalloc(sTableNameLen + 1);
|
||||
|
@ -303,9 +303,9 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
|
|||
if (kv) {
|
||||
int32_t colLen = kv->length;
|
||||
if (pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
// uError("SML:data before:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision);
|
||||
uDebug("SML:data before:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision);
|
||||
kv->i = convertTimePrecision(kv->i, TSDB_TIME_PRECISION_NANO, pTableMeta->tableInfo.precision);
|
||||
// uError("SML:data after:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision);
|
||||
uDebug("SML:data after:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision);
|
||||
}
|
||||
|
||||
if (IS_VAR_DATA_TYPE(kv->type)) {
|
||||
|
|
|
@ -562,7 +562,7 @@ static int32_t parseTagValue(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt
|
|||
|
||||
static void buildCreateTbReq(SVnodeModifOpStmt* pStmt, STag* pTag, SArray* pTagName) {
|
||||
insBuildCreateTbReq(&pStmt->createTblReq, pStmt->targetTableName.tname, pTag, pStmt->pTableMeta->suid,
|
||||
pStmt->usingTableName.tname, pTagName, pStmt->pTableMeta->tableInfo.numOfTags);
|
||||
pStmt->usingTableName.tname, pTagName, pStmt->pTableMeta->tableInfo.numOfTags, TSDB_DEFAULT_TABLE_TTL);
|
||||
}
|
||||
|
||||
static int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf) {
|
||||
|
@ -1529,9 +1529,7 @@ static int32_t setStmtInfo(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt)
|
|||
memcpy(tags, &pCxt->tags, sizeof(pCxt->tags));
|
||||
|
||||
SStmtCallback* pStmtCb = pCxt->pComCxt->pStmtCb;
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(&pStmt->targetTableName, tbFName);
|
||||
int32_t code = (*pStmtCb->setInfoFn)(pStmtCb->pStmt, pStmt->pTableMeta, tags, tbFName, pStmt->usingTableProcessing,
|
||||
int32_t code = (*pStmtCb->setInfoFn)(pStmtCb->pStmt, pStmt->pTableMeta, tags, &pStmt->targetTableName, pStmt->usingTableProcessing,
|
||||
pStmt->pVgroupsHashObj, pStmt->pTableBlockHashObj, pStmt->usingTableName.tname);
|
||||
|
||||
memset(&pCxt->tags, 0, sizeof(pCxt->tags));
|
||||
|
|
|
@ -137,7 +137,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch
|
|||
}
|
||||
|
||||
SVCreateTbReq tbReq = {0};
|
||||
insBuildCreateTbReq(&tbReq, tName, pTag, suid, sTableName, tagName, pDataBlock->pTableMeta->tableInfo.numOfTags);
|
||||
insBuildCreateTbReq(&tbReq, tName, pTag, suid, sTableName, tagName, pDataBlock->pTableMeta->tableInfo.numOfTags, TSDB_DEFAULT_TABLE_TTL);
|
||||
code = insBuildCreateTbMsg(pDataBlock, &tbReq);
|
||||
tdDestroySVCreateTbReq(&tbReq);
|
||||
|
||||
|
|
|
@ -850,15 +850,15 @@ int32_t insFindCol(SToken* pColname, int32_t start, int32_t end, SSchema* pSchem
|
|||
}
|
||||
|
||||
void insBuildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname,
|
||||
SArray* tagName, uint8_t tagNum) {
|
||||
SArray* tagName, uint8_t tagNum, int32_t ttl) {
|
||||
pTbReq->type = TD_CHILD_TABLE;
|
||||
pTbReq->name = strdup(tname);
|
||||
pTbReq->ctb.suid = suid;
|
||||
pTbReq->ctb.tagNum = tagNum;
|
||||
if (sname) pTbReq->ctb.stbName = strdup(sname);
|
||||
pTbReq->ctb.pTag = (uint8_t*)pTag;
|
||||
pTbReq->ctb.tagName = taosArrayDup(tagName);
|
||||
pTbReq->ttl = TSDB_DEFAULT_TABLE_TTL;
|
||||
pTbReq->ctb.tagName = taosArrayDup(tagName, NULL);
|
||||
pTbReq->ttl = ttl;
|
||||
pTbReq->commentLen = -1;
|
||||
|
||||
return;
|
||||
|
|
|
@ -161,6 +161,7 @@ static SKeyword keywordTable[] = {
|
|||
{"PPS", TK_PPS},
|
||||
{"PRECISION", TK_PRECISION},
|
||||
{"PREV", TK_PREV},
|
||||
{"PRIVILEGES", TK_PRIVILEGES},
|
||||
{"QNODE", TK_QNODE},
|
||||
{"QNODES", TK_QNODES},
|
||||
{"QTIME", TK_QTIME},
|
||||
|
@ -202,6 +203,7 @@ static SKeyword keywordTable[] = {
|
|||
{"STREAM", TK_STREAM},
|
||||
{"STREAMS", TK_STREAMS},
|
||||
{"STRICT", TK_STRICT},
|
||||
{"SUBSCRIBE", TK_SUBSCRIBE},
|
||||
{"SUBSCRIPTIONS", TK_SUBSCRIPTIONS},
|
||||
{"SUBTABLE", TK_SUBTABLE},
|
||||
{"SYSINFO", TK_SYSINFO},
|
||||
|
|
|
@ -251,6 +251,12 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
|||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{ .showType = QUERY_NODE_SHOW_USER_PRIVILEGES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_USER_PRIVILEGES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
|
@ -5031,7 +5037,7 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt
|
|||
alterReq.sysInfo = pStmt->sysinfo;
|
||||
snprintf(alterReq.pass, sizeof(alterReq.pass), "%s", pStmt->password);
|
||||
if (NULL != pCxt->pParseCxt->db) {
|
||||
snprintf(alterReq.dbname, sizeof(alterReq.dbname), "%s", pCxt->pParseCxt->db);
|
||||
snprintf(alterReq.objname, sizeof(alterReq.objname), "%s", pCxt->pParseCxt->db);
|
||||
}
|
||||
|
||||
return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &alterReq);
|
||||
|
@ -5710,9 +5716,11 @@ static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) {
|
|||
req.alterType = TSDB_ALTER_USER_ADD_READ_DB;
|
||||
} else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE)) {
|
||||
req.alterType = TSDB_ALTER_USER_ADD_WRITE_DB;
|
||||
} else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_SUBSCRIBE)) {
|
||||
req.alterType = TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC;
|
||||
}
|
||||
strcpy(req.user, pStmt->userName);
|
||||
sprintf(req.dbname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->dbName);
|
||||
sprintf(req.objname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->objName);
|
||||
return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req);
|
||||
}
|
||||
|
||||
|
@ -5726,9 +5734,11 @@ static int32_t translateRevoke(STranslateContext* pCxt, SRevokeStmt* pStmt) {
|
|||
req.alterType = TSDB_ALTER_USER_REMOVE_READ_DB;
|
||||
} else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE)) {
|
||||
req.alterType = TSDB_ALTER_USER_REMOVE_WRITE_DB;
|
||||
} else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_SUBSCRIBE)) {
|
||||
req.alterType = TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC;
|
||||
}
|
||||
strcpy(req.user, pStmt->userName);
|
||||
sprintf(req.dbname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->dbName);
|
||||
sprintf(req.objname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->objName);
|
||||
return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req);
|
||||
}
|
||||
|
||||
|
@ -6625,7 +6635,7 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S
|
|||
req.ctb.tagNum = tagNum;
|
||||
req.ctb.stbName = strdup(sTableNmae);
|
||||
req.ctb.pTag = (uint8_t*)pTag;
|
||||
req.ctb.tagName = taosArrayDup(tagName);
|
||||
req.ctb.tagName = taosArrayDup(tagName, NULL);
|
||||
if (pStmt->ignoreExists) {
|
||||
req.flags |= TD_CREATE_IF_NOT_EXISTS;
|
||||
}
|
||||
|
@ -7504,6 +7514,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
||||
code = rewriteShow(pCxt, pQuery);
|
||||
break;
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
|
|
|
@ -844,7 +844,7 @@ int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName,
|
|||
int32_t code = getMetaDataFromHash(pDbFName, strlen(pDbFName), pMetaCache->pDbVgroup, (void**)&pVgList);
|
||||
// pVgList is null, which is a legal value, indicating that the user DB has not been created
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pVgList) {
|
||||
*pVgInfo = taosArrayDup(pVgList);
|
||||
*pVgInfo = taosArrayDup(pVgList, NULL);
|
||||
if (NULL == *pVgInfo) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -961,7 +961,7 @@ int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFun
|
|||
static void destroySmaIndex(void* p) { taosMemoryFree(((STableIndexInfo*)p)->expr); }
|
||||
|
||||
static SArray* smaIndexesDup(SArray* pSrc) {
|
||||
SArray* pDst = taosArrayDup(pSrc);
|
||||
SArray* pDst = taosArrayDup(pSrc, NULL);
|
||||
if (NULL == pDst) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1011,7 +1011,7 @@ STableCfg* tableCfgDup(STableCfg* pCfg) {
|
|||
memcpy(pNew->pComment, pCfg->pComment, pNew->commentLen);
|
||||
}
|
||||
if (NULL != pNew->pFuncs) {
|
||||
pNew->pFuncs = taosArrayDup(pNew->pFuncs);
|
||||
pNew->pFuncs = taosArrayDup(pNew->pFuncs, NULL);
|
||||
}
|
||||
if (NULL != pNew->pTags) {
|
||||
pNew->pTags = taosMemoryCalloc(pNew->tagsLen + 1, 1);
|
||||
|
@ -1053,7 +1053,7 @@ int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) {
|
|||
return pRes->code;
|
||||
}
|
||||
|
||||
*pDnodes = taosArrayDup((SArray*)pRes->pRes);
|
||||
*pDnodes = taosArrayDup((SArray*)pRes->pRes, NULL);
|
||||
if (NULL == *pDnodes) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -101,6 +101,10 @@ void generateInformationSchema(MockCatalogService* mcs) {
|
|||
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN)
|
||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||
.done();
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_PRIVILEGES, TSDB_SYSTEM_TABLE, 2)
|
||||
.addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN)
|
||||
.addColumn("privilege", TSDB_DATA_TYPE_BINARY, 10)
|
||||
.done();
|
||||
}
|
||||
|
||||
void generatePerformanceSchema(MockCatalogService* mcs) {
|
||||
|
@ -248,8 +252,8 @@ int32_t __catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, con
|
|||
return g_mockCatalogService->catalogGetTableDistVgInfo(pTableName, pVgList);
|
||||
}
|
||||
|
||||
int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId,
|
||||
int32_t* tableNum, int64_t* stateTs) {
|
||||
int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId, int32_t* tableNum,
|
||||
int64_t* stateTs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -613,7 +613,7 @@ TEST_F(ParserInitialATest, alterUser) {
|
|||
if (nullptr != pPass) {
|
||||
strcpy(expect.pass, pPass);
|
||||
}
|
||||
strcpy(expect.dbname, "test");
|
||||
strcpy(expect.objname, "test");
|
||||
};
|
||||
|
||||
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||
|
@ -627,7 +627,7 @@ TEST_F(ParserInitialATest, alterUser) {
|
|||
ASSERT_EQ(req.enable, expect.enable);
|
||||
ASSERT_EQ(std::string(req.user), std::string(expect.user));
|
||||
ASSERT_EQ(std::string(req.pass), std::string(expect.pass));
|
||||
ASSERT_EQ(std::string(req.dbname), std::string(expect.dbname));
|
||||
ASSERT_EQ(std::string(req.objname), std::string(expect.objname));
|
||||
});
|
||||
|
||||
setAlterUserReq("wxy", TSDB_ALTER_USER_PASSWD, "123456");
|
||||
|
|
|
@ -34,10 +34,38 @@ TEST_F(ParserExplainToSyncdbTest, explain) {
|
|||
TEST_F(ParserExplainToSyncdbTest, grant) {
|
||||
useDb("root", "test");
|
||||
|
||||
SAlterUserReq expect = {0};
|
||||
|
||||
auto setAlterUserReq = [&](int8_t alterType, const string& user, const string& obj) {
|
||||
expect.alterType = alterType;
|
||||
snprintf(expect.user, sizeof(expect.user), "%s", user.c_str());
|
||||
snprintf(expect.objname, sizeof(expect.objname), "%s", obj.c_str());
|
||||
};
|
||||
|
||||
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_GRANT_STMT);
|
||||
ASSERT_EQ(pQuery->pCmdMsg->msgType, TDMT_MND_ALTER_USER);
|
||||
SAlterUserReq req = {0};
|
||||
ASSERT_EQ(tDeserializeSAlterUserReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
|
||||
ASSERT_EQ(req.alterType, expect.alterType);
|
||||
ASSERT_EQ(string(req.user), string(expect.user));
|
||||
ASSERT_EQ(string(req.objname), string(expect.objname));
|
||||
});
|
||||
|
||||
setAlterUserReq(TSDB_ALTER_USER_ADD_ALL_DB, "wxy", "0.test");
|
||||
run("GRANT ALL ON test.* TO wxy");
|
||||
|
||||
setAlterUserReq(TSDB_ALTER_USER_ADD_READ_DB, "wxy", "0.test");
|
||||
run("GRANT READ ON test.* TO wxy");
|
||||
|
||||
setAlterUserReq(TSDB_ALTER_USER_ADD_WRITE_DB, "wxy", "0.test");
|
||||
run("GRANT WRITE ON test.* TO wxy");
|
||||
|
||||
setAlterUserReq(TSDB_ALTER_USER_ADD_ALL_DB, "wxy", "0.test");
|
||||
run("GRANT READ, WRITE ON test.* TO wxy");
|
||||
|
||||
setAlterUserReq(TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC, "wxy", "0.tp1");
|
||||
run("GRANT SUBSCRIBE ON tp1 TO wxy");
|
||||
}
|
||||
|
||||
TEST_F(ParserExplainToSyncdbTest, insert) {
|
||||
|
|
|
@ -213,7 +213,13 @@ TEST_F(ParserShowToUseTest, showTags) {
|
|||
TEST_F(ParserShowToUseTest, showUsers) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SHOW users");
|
||||
run("SHOW USERS");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showUserPrivileges) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SHOW USER PRIVILEGES");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showVariables) {
|
||||
|
|
|
@ -580,15 +580,19 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
|
|||
}
|
||||
|
||||
// set the output
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pOutputGroupKeys) {
|
||||
code = createColumnByRewriteExprs(pOutputGroupKeys, &pAgg->node.pTargets);
|
||||
}
|
||||
nodesDestroyList(pOutputGroupKeys);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pAgg->pAggFuncs) {
|
||||
code = createColumnByRewriteExprs(pAgg->pAggFuncs, &pAgg->node.pTargets);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL != pOutputGroupKeys) {
|
||||
code = createColumnByRewriteExprs(pOutputGroupKeys, &pAgg->node.pTargets);
|
||||
} else if (NULL == pAgg->node.pTargets && NULL != pAgg->pGroupKeys) {
|
||||
code = createColumnByRewriteExprs(pAgg->pGroupKeys, &pAgg->node.pTargets);
|
||||
}
|
||||
}
|
||||
nodesDestroyList(pOutputGroupKeys);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pLogicNode = (SLogicNode*)pAgg;
|
||||
} else {
|
||||
|
|
|
@ -1543,51 +1543,73 @@ void vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut,
|
|||
int32_t doVectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t startIndex,
|
||||
int32_t numOfRows, int32_t step, __compar_fn_t fp, int32_t optr) {
|
||||
int32_t num = 0;
|
||||
bool * pRes = (bool *)pOut->columnData->pData;
|
||||
|
||||
for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) {
|
||||
int32_t leftIndex = (i >= pLeft->numOfRows) ? 0 : i;
|
||||
int32_t rightIndex = (i >= pRight->numOfRows) ? 0 : i;
|
||||
if (GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_JSON || GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_JSON) {
|
||||
for (int32_t i = startIndex; i < numOfRows && i >= startIndex; i += step) {
|
||||
int32_t leftIndex = (i >= pLeft->numOfRows) ? 0 : i;
|
||||
int32_t rightIndex = (i >= pRight->numOfRows) ? 0 : i;
|
||||
|
||||
if (IS_HELPER_NULL(pLeft->columnData, leftIndex) || IS_HELPER_NULL(pRight->columnData, rightIndex)) {
|
||||
bool res = false;
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&res);
|
||||
continue;
|
||||
}
|
||||
if (IS_HELPER_NULL(pLeft->columnData, leftIndex) || IS_HELPER_NULL(pRight->columnData, rightIndex)) {
|
||||
bool res = false;
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&res);
|
||||
continue;
|
||||
}
|
||||
|
||||
char *pLeftData = colDataGetData(pLeft->columnData, leftIndex);
|
||||
char *pRightData = colDataGetData(pRight->columnData, rightIndex);
|
||||
int64_t leftOut = 0;
|
||||
int64_t rightOut = 0;
|
||||
bool freeLeft = false;
|
||||
bool freeRight = false;
|
||||
bool isJsonnull = false;
|
||||
char * pLeftData = colDataGetData(pLeft->columnData, leftIndex);
|
||||
char * pRightData = colDataGetData(pRight->columnData, rightIndex);
|
||||
int64_t leftOut = 0;
|
||||
int64_t rightOut = 0;
|
||||
bool freeLeft = false;
|
||||
bool freeRight = false;
|
||||
bool isJsonnull = false;
|
||||
|
||||
bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData,
|
||||
&leftOut, &rightOut, &isJsonnull, &freeLeft, &freeRight);
|
||||
if (isJsonnull) {
|
||||
ASSERT(0);
|
||||
}
|
||||
bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData,
|
||||
&leftOut, &rightOut, &isJsonnull, &freeLeft, &freeRight);
|
||||
if (isJsonnull) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (!pLeftData || !pRightData) {
|
||||
result = false;
|
||||
}
|
||||
if (!pLeftData || !pRightData) {
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&result);
|
||||
} else {
|
||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&res);
|
||||
if (res) {
|
||||
++num;
|
||||
if (!result) {
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&result);
|
||||
} else {
|
||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&res);
|
||||
if (res) {
|
||||
++num;
|
||||
}
|
||||
}
|
||||
|
||||
if (freeLeft) {
|
||||
taosMemoryFreeClear(pLeftData);
|
||||
}
|
||||
|
||||
if (freeRight) {
|
||||
taosMemoryFreeClear(pRightData);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) {
|
||||
int32_t leftIndex = (i >= pLeft->numOfRows) ? 0 : i;
|
||||
int32_t rightIndex = (i >= pRight->numOfRows) ? 0 : i;
|
||||
|
||||
if (freeLeft) {
|
||||
taosMemoryFreeClear(pLeftData);
|
||||
}
|
||||
if (colDataIsNull_s(pLeft->columnData, leftIndex) ||
|
||||
colDataIsNull_s(pRight->columnData, rightIndex)) {
|
||||
pRes[i] = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (freeRight) {
|
||||
taosMemoryFreeClear(pRightData);
|
||||
char *pLeftData = colDataGetData(pLeft->columnData, leftIndex);
|
||||
char *pRightData = colDataGetData(pRight->columnData, rightIndex);
|
||||
|
||||
pRes[i] = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||
if (pRes[i]) {
|
||||
++num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ extern "C" {
|
|||
#include "tarray.h"
|
||||
#include "thash.h"
|
||||
#include "trpc.h"
|
||||
#include "ttimer.h"
|
||||
|
||||
enum {
|
||||
SCH_READ = 1,
|
||||
|
@ -146,6 +147,7 @@ typedef struct SSchedulerMgmt {
|
|||
int32_t jobRef;
|
||||
int32_t jobNum;
|
||||
SSchStat stat;
|
||||
void *timer;
|
||||
SRWLatch hbLock;
|
||||
SHashObj *hbConnections;
|
||||
void *queryMgmt;
|
||||
|
@ -202,12 +204,30 @@ typedef struct SSchTaskProfile {
|
|||
int64_t endTs;
|
||||
} SSchTaskProfile;
|
||||
|
||||
typedef struct SSchRedirectCtx {
|
||||
int32_t periodMs;
|
||||
bool inRedirect;
|
||||
int32_t totalTimes;
|
||||
int32_t roundTotal;
|
||||
int32_t roundTimes; // retry times in current round
|
||||
int64_t startTs;
|
||||
} SSchRedirectCtx;
|
||||
|
||||
typedef struct SSchTimerParam {
|
||||
int64_t rId;
|
||||
uint64_t queryId;
|
||||
uint64_t taskId;
|
||||
} SSchTimerParam;
|
||||
|
||||
typedef struct SSchTask {
|
||||
uint64_t taskId; // task id
|
||||
SRWLatch lock; // task reentrant lock
|
||||
int32_t maxExecTimes; // task max exec times
|
||||
int32_t maxRetryTimes; // task max retry times
|
||||
int32_t retryTimes; // task retry times
|
||||
int32_t delayExecMs; // task execution delay time
|
||||
tmr_h delayTimer; // task delay execution timer
|
||||
SSchRedirectCtx redirectCtx; // task redirect context
|
||||
bool waitRetry; // wait for retry
|
||||
int32_t execId; // task current execute index
|
||||
SSchLevel *level; // level
|
||||
|
@ -488,6 +508,7 @@ extern SSchedulerMgmt schMgmt;
|
|||
void schDeregisterTaskHb(SSchJob *pJob, SSchTask *pTask);
|
||||
void schCleanClusterHb(void *pTrans);
|
||||
int32_t schLaunchTask(SSchJob *job, SSchTask *task);
|
||||
int32_t schDelayLaunchTask(SSchJob *pJob, SSchTask *pTask);
|
||||
int32_t schBuildAndSendMsg(SSchJob *job, SSchTask *task, SQueryNodeAddr *addr, int32_t msgType);
|
||||
SSchJob *schAcquireJob(int64_t refId);
|
||||
int32_t schReleaseJob(int64_t refId);
|
||||
|
@ -529,6 +550,7 @@ int32_t schJobFetchRows(SSchJob *pJob);
|
|||
int32_t schJobFetchRowsA(SSchJob *pJob);
|
||||
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execId);
|
||||
int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId *pEpId, SArray *pStatusList);
|
||||
char *schDumpEpSet(SEpSet *pEpSet);
|
||||
char *schGetOpStr(SCH_OP_TYPE type);
|
||||
int32_t schBeginOperation(SSchJob *pJob, SCH_OP_TYPE type, bool sync);
|
||||
int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq);
|
||||
|
|
|
@ -721,7 +721,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) {
|
|||
if (pReq->pNodeList == NULL || taosArrayGetSize(pReq->pNodeList) <= 0) {
|
||||
qDebug("QID:0x%" PRIx64 " input exec nodeList is empty", pReq->pDag->queryId);
|
||||
} else {
|
||||
pJob->nodeList = taosArrayDup(pReq->pNodeList);
|
||||
pJob->nodeList = taosArrayDup(pReq->pNodeList, NULL);
|
||||
}
|
||||
|
||||
pJob->taskList = taosHashInit(pReq->pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false,
|
||||
|
|
|
@ -887,9 +887,14 @@ int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, SSchTrans *trans, SQuery
|
|||
SCH_ERR_JRET(schGenerateCallBackInfo(pJob, pTask, msg, msgSize, msgType, trans, isHb, &pMsgSendInfo));
|
||||
SCH_ERR_JRET(schUpdateSendTargetInfo(pMsgSendInfo, addr, pTask));
|
||||
|
||||
qDebug("start to send %s msg to node[%d,%s,%d], pTrans:%p, pHandle:%p", TMSG_INFO(msgType), addr->nodeId,
|
||||
epSet->eps[epSet->inUse].fqdn, epSet->eps[epSet->inUse].port, trans->pTrans, trans->pHandle);
|
||||
|
||||
if (pJob && pTask) {
|
||||
SCH_TASK_DLOG("start to send %s msg to node[%d,%s,%d], pTrans:%p, pHandle:%p", TMSG_INFO(msgType), addr->nodeId,
|
||||
epSet->eps[epSet->inUse].fqdn, epSet->eps[epSet->inUse].port, trans->pTrans, trans->pHandle);
|
||||
} else {
|
||||
qDebug("start to send %s msg to node[%d,%s,%d], pTrans:%p, pHandle:%p", TMSG_INFO(msgType), addr->nodeId,
|
||||
epSet->eps[epSet->inUse].fqdn, epSet->eps[epSet->inUse].port, trans->pTrans, trans->pHandle);
|
||||
}
|
||||
|
||||
if (pTask) {
|
||||
pTask->lastMsgType = msgType;
|
||||
}
|
||||
|
|
|
@ -340,6 +340,70 @@ int32_t schRescheduleTask(SSchJob *pJob, SSchTask *pTask) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t schChkUpdateRedirectCtx(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet) {
|
||||
SSchRedirectCtx *pCtx = &pTask->redirectCtx;
|
||||
if (!pCtx->inRedirect) {
|
||||
pCtx->inRedirect = true;
|
||||
pCtx->periodMs = tsRedirectPeriod;
|
||||
pCtx->startTs = taosGetTimestampMs();
|
||||
|
||||
if (SCH_IS_DATA_BIND_TASK(pTask)) {
|
||||
if (pEpSet) {
|
||||
pCtx->roundTotal = pEpSet->numOfEps;
|
||||
} else {
|
||||
SQueryNodeAddr *pAddr = taosArrayGet(pTask->candidateAddrs, 0);
|
||||
pCtx->roundTotal = pAddr->epSet.numOfEps;
|
||||
}
|
||||
} else {
|
||||
pCtx->roundTotal = 1;
|
||||
}
|
||||
|
||||
goto _return;
|
||||
}
|
||||
|
||||
pCtx->totalTimes++;
|
||||
|
||||
if (SCH_IS_DATA_BIND_TASK(pTask) && pEpSet) {
|
||||
pCtx->roundTotal = pEpSet->numOfEps;
|
||||
pCtx->roundTimes = 0;
|
||||
|
||||
pTask->delayExecMs = 0;
|
||||
|
||||
goto _return;
|
||||
}
|
||||
|
||||
pCtx->roundTimes++;
|
||||
|
||||
if (pCtx->roundTimes >= pCtx->roundTotal) {
|
||||
int64_t nowTs = taosGetTimestampMs();
|
||||
int64_t lastTime = nowTs - pCtx->startTs;
|
||||
if (lastTime > tsMaxRetryWaitTime) {
|
||||
SCH_TASK_DLOG("task no more redirect retry since timeout, now:%" PRId64 ", start:%" PRId64 ", max:%d, total:%d",
|
||||
nowTs, pCtx->startTs, tsMaxRetryWaitTime, pCtx->totalTimes);
|
||||
SCH_ERR_RET(TSDB_CODE_TIMEOUT_ERROR);
|
||||
}
|
||||
|
||||
pCtx->periodMs *= tsRedirectFactor;
|
||||
if (pCtx->periodMs > tsRedirectMaxPeriod) {
|
||||
pCtx->periodMs = tsRedirectMaxPeriod;
|
||||
}
|
||||
|
||||
int64_t leftTime = tsMaxRetryWaitTime - lastTime;
|
||||
pTask->delayExecMs = leftTime < pCtx->periodMs ? leftTime : pCtx->periodMs;
|
||||
|
||||
goto _return;
|
||||
}
|
||||
|
||||
pTask->delayExecMs = 0;
|
||||
|
||||
_return:
|
||||
|
||||
SCH_TASK_DLOG("task start %d/%d/%d redirect retry, delayExec:%d", pCtx->roundTimes, pCtx->roundTotal,
|
||||
pCtx->totalTimes, pTask->delayExecMs);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -349,14 +413,10 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32
|
|||
pTask->retryTimes = 0;
|
||||
}
|
||||
|
||||
if (((pTask->execId + 1) >= pTask->maxExecTimes) || ((pTask->retryTimes + 1) > pTask->maxRetryTimes)) {
|
||||
SCH_TASK_DLOG("task no more retry since reach max times %d:%d, execId %d", pTask->maxRetryTimes,
|
||||
pTask->maxExecTimes, pTask->execId);
|
||||
schHandleJobFailure(pJob, rspCode);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
SCH_ERR_JRET(schChkUpdateRedirectCtx(pJob, pTask, pData ? pData->pEpSet : NULL));
|
||||
|
||||
pTask->waitRetry = true;
|
||||
|
||||
schDropTaskOnExecNode(pJob, pTask);
|
||||
taosHashClear(pTask->execNodes);
|
||||
schRemoveTaskFromExecList(pJob, pTask);
|
||||
|
@ -368,8 +428,17 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32
|
|||
memset(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr));
|
||||
|
||||
if (SCH_IS_DATA_BIND_TASK(pTask)) {
|
||||
if (pData) {
|
||||
if (pData && pData->pEpSet) {
|
||||
SCH_ERR_JRET(schUpdateTaskCandidateAddr(pJob, pTask, pData->pEpSet));
|
||||
} else if (SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(rspCode)) {
|
||||
SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx);
|
||||
SCH_SWITCH_EPSET(addr);
|
||||
SCH_TASK_DLOG("switch task target node %d epset to %d/%d", addr->nodeId, addr->epSet.inUse, addr->epSet.numOfEps);
|
||||
} else {
|
||||
SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx);
|
||||
SEp *pEp = &addr->epSet.eps[addr->epSet.inUse];
|
||||
SCH_TASK_DLOG("task retry node %d current ep, idx:%d/%d,%s:%d", addr->nodeId, addr->epSet.inUse,
|
||||
addr->epSet.numOfEps, pEp->fqdn, pEp->port);
|
||||
}
|
||||
|
||||
if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) {
|
||||
|
@ -380,7 +449,7 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32
|
|||
|
||||
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_INIT);
|
||||
|
||||
SCH_ERR_JRET(schLaunchTask(pJob, pTask));
|
||||
SCH_ERR_JRET(schDelayLaunchTask(pJob, pTask));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -428,28 +497,24 @@ int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32
|
|||
schUpdateJobStatus(pJob, JOB_TASK_STATUS_EXEC);
|
||||
}
|
||||
|
||||
if (SCH_IS_DATA_BIND_TASK(pTask)) {
|
||||
if (SYNC_OTHER_LEADER_REDIRECT_ERROR(rspCode)) {
|
||||
if (NULL == pData->pEpSet) {
|
||||
SCH_TASK_ELOG("no epset updated while got error %s", tstrerror(rspCode));
|
||||
code = rspCode;
|
||||
SCH_TASK_ELOG("epset updating excepted, error:%s", tstrerror(rspCode));
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _return;
|
||||
}
|
||||
}
|
||||
|
||||
code = schDoTaskRedirect(pJob, pTask, pData, rspCode);
|
||||
taosMemoryFree(pData->pData);
|
||||
taosMemoryFree(pData->pEpSet);
|
||||
pData->pData = NULL;
|
||||
pData->pEpSet = NULL;
|
||||
taosMemoryFreeClear(pData->pData);
|
||||
taosMemoryFreeClear(pData->pEpSet);
|
||||
|
||||
SCH_RET(code);
|
||||
|
||||
_return:
|
||||
|
||||
taosMemoryFree(pData->pData);
|
||||
taosMemoryFree(pData->pEpSet);
|
||||
pData->pData = NULL;
|
||||
pData->pEpSet = NULL;
|
||||
taosMemoryFreeClear(pData->pData);
|
||||
taosMemoryFreeClear(pData->pEpSet);
|
||||
|
||||
SCH_RET(schProcessOnTaskFailure(pJob, pTask, code));
|
||||
}
|
||||
|
@ -715,10 +780,13 @@ int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSe
|
|||
|
||||
SQueryNodeAddr *pAddr = taosArrayGet(pTask->candidateAddrs, 0);
|
||||
|
||||
SEp *pOld = &pAddr->epSet.eps[pAddr->epSet.inUse];
|
||||
SEp *pNew = &pEpSet->eps[pEpSet->inUse];
|
||||
char *origEpset = schDumpEpSet(&pAddr->epSet);
|
||||
char *newEpset = schDumpEpSet(pEpSet);
|
||||
|
||||
SCH_TASK_DLOG("update task ep from %s:%d to %s:%d", pOld->fqdn, pOld->port, pNew->fqdn, pNew->port);
|
||||
SCH_TASK_DLOG("update task target node %d epset from %s to %s", pAddr->nodeId, origEpset, newEpset);
|
||||
|
||||
taosMemoryFree(origEpset);
|
||||
taosMemoryFree(newEpset);
|
||||
|
||||
memcpy(&pAddr->epSet, pEpSet, sizeof(pAddr->epSet));
|
||||
|
||||
|
@ -1078,6 +1146,56 @@ _return:
|
|||
SCH_RET(schProcessOnTaskFailure(pJob, pTask, code));
|
||||
}
|
||||
|
||||
void schHandleTimerEvent(void *param, void *tmrId) {
|
||||
SSchTimerParam *pTimerParam = (SSchTimerParam *)param;
|
||||
SSchTask *pTask = NULL;
|
||||
SSchJob *pJob = NULL;
|
||||
int32_t code = 0;
|
||||
|
||||
int64_t rId = pTimerParam->rId;
|
||||
uint64_t queryId = pTimerParam->queryId;
|
||||
uint64_t taskId = pTimerParam->taskId;
|
||||
taosMemoryFree(pTimerParam);
|
||||
|
||||
if (schProcessOnCbBegin(&pJob, &pTask, queryId, rId, taskId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
code = schLaunchTask(pJob, pTask);
|
||||
|
||||
schProcessOnCbEnd(pJob, pTask, code);
|
||||
}
|
||||
|
||||
int32_t schDelayLaunchTask(SSchJob *pJob, SSchTask *pTask) {
|
||||
if (pTask->delayExecMs > 0) {
|
||||
SSchTimerParam *param = taosMemoryMalloc(sizeof(SSchTimerParam));
|
||||
if (NULL == param) {
|
||||
SCH_TASK_ELOG("taosMemoryMalloc %d failed", (int)sizeof(SSchTimerParam));
|
||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
param->rId = pJob->refId;
|
||||
param->queryId = pJob->queryId;
|
||||
param->taskId = pTask->taskId;
|
||||
|
||||
if (NULL == pTask->delayTimer) {
|
||||
pTask->delayTimer = taosTmrStart(schHandleTimerEvent, pTask->delayExecMs, (void *)param, schMgmt.timer);
|
||||
if (NULL == pTask->delayTimer) {
|
||||
SCH_TASK_ELOG("start delay timer failed, handle:%p", schMgmt.timer);
|
||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
taosTmrReset(schHandleTimerEvent, pTask->delayExecMs, (void *)param, schMgmt.timer, &pTask->delayTimer);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCH_RET(schLaunchTask(pJob, pTask));
|
||||
}
|
||||
|
||||
int32_t schLaunchLevelTasks(SSchJob *pJob, SSchLevel *level) {
|
||||
SCH_ERR_RET(schChkJobNeedFlowCtrl(pJob, level));
|
||||
|
||||
|
@ -1099,7 +1217,12 @@ void schDropTaskInHashList(SSchJob *pJob, SHashObj *list) {
|
|||
while (pIter) {
|
||||
SSchTask *pTask = *(SSchTask **)pIter;
|
||||
|
||||
SCH_LOCK_TASK(pTask);
|
||||
if (pTask->delayTimer) {
|
||||
taosTmrStopA(&pTask->delayTimer);
|
||||
}
|
||||
schDropTaskOnExecNode(pJob, pTask);
|
||||
SCH_UNLOCK_TASK(pTask);
|
||||
|
||||
pIter = taosHashIterate(list, pIter);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,27 @@ FORCE_INLINE int32_t schReleaseJob(int64_t refId) {
|
|||
return taosReleaseRef(schMgmt.jobRef, refId);
|
||||
}
|
||||
|
||||
char *schDumpEpSet(SEpSet *pEpSet) {
|
||||
if (NULL == pEpSet) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t maxSize = 1024;
|
||||
char *str = taosMemoryMalloc(maxSize);
|
||||
if (NULL == str) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t n = 0;
|
||||
n += snprintf(str + n, maxSize - n, "numOfEps:%d, inUse:%d eps:", pEpSet->numOfEps, pEpSet->inUse);
|
||||
for (int32_t i = 0; i < pEpSet->numOfEps; ++i) {
|
||||
SEp *pEp = &pEpSet->eps[i];
|
||||
n += snprintf(str + n, maxSize - n, "[%s:%d]", pEp->fqdn, pEp->port);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char *schGetOpStr(SCH_OP_TYPE type) {
|
||||
switch (type) {
|
||||
case SCH_OP_NULL:
|
||||
|
|
|
@ -48,6 +48,12 @@ int32_t schedulerInit() {
|
|||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
schMgmt.timer = taosTmrInit(0, 0, 0, "scheduler");
|
||||
if (NULL == schMgmt.timer) {
|
||||
qError("init timer failed, error:%s", tstrerror(terrno));
|
||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
if (taosGetSystemUUID((char *)&schMgmt.sId, sizeof(schMgmt.sId))) {
|
||||
qError("generate schdulerId failed, errno:%d", errno);
|
||||
SCH_ERR_RET(TSDB_CODE_QRY_SYS_ERROR);
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
#include "streamInc.h"
|
||||
|
||||
static int32_t streamTaskExecImpl(SStreamTask* pTask, const void* data, SArray* pRes) {
|
||||
void* exec = pTask->exec.executor;
|
||||
int32_t code;
|
||||
void* exec = pTask->exec.executor;
|
||||
|
||||
// set input
|
||||
const SStreamQueueItem* pItem = (const SStreamQueueItem*)data;
|
||||
|
@ -49,8 +50,10 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, const void* data, SArray*
|
|||
while (1) {
|
||||
SSDataBlock* output = NULL;
|
||||
uint64_t ts = 0;
|
||||
if (qExecTask(exec, &output, &ts) < 0) {
|
||||
ASSERT(false);
|
||||
if ((code = qExecTask(exec, &output, &ts)) < 0) {
|
||||
/*ASSERT(false);*/
|
||||
qError("unexpected stream execution, stream %" PRId64 " task: %d, since %s", pTask->streamId, pTask->taskId,
|
||||
terrstr());
|
||||
}
|
||||
if (output == NULL) {
|
||||
if (pItem->type == STREAM_INPUT__DATA_RETRIEVE) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue