TDengine/include/common/tmsg.h

2625 lines
74 KiB
C
Raw Normal View History

2021-10-08 05:53:49 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_COMMON_TAOS_MSG_H_
#define _TD_COMMON_TAOS_MSG_H_
#include "taosdef.h"
#include "taoserror.h"
2021-12-31 03:45:44 +00:00
#include "tarray.h"
2021-12-25 06:35:39 +00:00
#include "tcoding.h"
2022-02-28 09:39:07 +00:00
#include "tencode.h"
2022-01-07 02:36:42 +00:00
#include "thash.h"
2021-12-29 09:20:10 +00:00
#include "tlist.h"
2022-03-10 11:05:58 +00:00
#include "tname.h"
2022-03-23 02:44:32 +00:00
#include "trow.h"
2022-03-16 10:29:31 +00:00
#include "tuuid.h"
2021-10-08 05:53:49 +00:00
2022-02-28 09:39:07 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2021-12-29 09:20:10 +00:00
/* ------------------------ MESSAGE DEFINITIONS ------------------------ */
2021-12-24 07:00:51 +00:00
#define TD_MSG_NUMBER_
#undef TD_MSG_DICT_
#undef TD_MSG_INFO_
#undef TD_MSG_SEG_CODE_
#include "tmsgdef.h"
#undef TD_MSG_NUMBER_
#undef TD_MSG_DICT_
#undef TD_MSG_INFO_
#define TD_MSG_SEG_CODE_
#include "tmsgdef.h"
#undef TD_MSG_NUMBER_
#undef TD_MSG_DICT_
#undef TD_MSG_INFO_
#undef TD_MSG_SEG_CODE_
#include "tmsgdef.h"
2022-02-28 09:39:07 +00:00
extern char* tMsgInfo[];
extern int32_t tMsgDict[];
2021-12-24 07:00:51 +00:00
#define TMSG_SEG_CODE(TYPE) (((TYPE)&0xff00) >> 8)
2022-02-17 11:07:39 +00:00
#define TMSG_SEG_SEQ(TYPE) ((TYPE)&0xff)
#define TMSG_INFO(TYPE) tMsgInfo[tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE)]
#define TMSG_INDEX(TYPE) (tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE))
2021-10-08 05:53:49 +00:00
2021-12-24 07:40:15 +00:00
typedef uint16_t tmsg_t;
2021-12-29 09:20:10 +00:00
/* ------------------------ OTHER DEFINITIONS ------------------------ */
2021-10-08 05:53:49 +00:00
// IE type
2022-02-17 11:07:39 +00:00
#define TSDB_IE_TYPE_SEC 1
#define TSDB_IE_TYPE_META 2
#define TSDB_IE_TYPE_MGMT_IP 3
#define TSDB_IE_TYPE_DNODE_CFG 4
2021-10-08 05:53:49 +00:00
#define TSDB_IE_TYPE_NEW_VERSION 5
2022-02-17 11:07:39 +00:00
#define TSDB_IE_TYPE_DNODE_EXT 6
2021-10-08 05:53:49 +00:00
#define TSDB_IE_TYPE_DNODE_STATE 7
enum { CONN_TYPE__QUERY = 1, CONN_TYPE__TMQ, CONN_TYPE__MAX };
2022-01-14 02:48:05 +00:00
2022-01-26 00:50:32 +00:00
enum {
2022-05-06 06:13:56 +00:00
HEARTBEAT_KEY_USER_AUTHINFO = 1,
HEARTBEAT_KEY_DBINFO,
2022-01-25 10:29:26 +00:00
HEARTBEAT_KEY_STBINFO,
2022-01-26 00:50:32 +00:00
HEARTBEAT_KEY_MQ_TMP,
2022-01-25 10:29:26 +00:00
};
2021-12-02 11:56:43 +00:00
typedef enum _mgmt_table {
TSDB_MGMT_TABLE_START,
2021-10-08 05:53:49 +00:00
TSDB_MGMT_TABLE_DNODE,
TSDB_MGMT_TABLE_MNODE,
2022-04-14 12:54:43 +00:00
TSDB_MGMT_TABLE_MODULE,
2021-12-29 12:05:10 +00:00
TSDB_MGMT_TABLE_QNODE,
TSDB_MGMT_TABLE_SNODE,
TSDB_MGMT_TABLE_BNODE,
2022-04-14 12:54:43 +00:00
TSDB_MGMT_TABLE_CLUSTER,
TSDB_MGMT_TABLE_DB,
TSDB_MGMT_TABLE_FUNC,
TSDB_MGMT_TABLE_INDEX,
2021-12-10 07:20:04 +00:00
TSDB_MGMT_TABLE_STB,
2021-10-08 05:53:49 +00:00
TSDB_MGMT_TABLE_STREAMS,
2022-04-14 12:54:43 +00:00
TSDB_MGMT_TABLE_TABLE,
TSDB_MGMT_TABLE_USER,
2021-10-08 05:53:49 +00:00
TSDB_MGMT_TABLE_GRANTS,
2022-04-14 12:54:43 +00:00
TSDB_MGMT_TABLE_VGROUP,
TSDB_MGMT_TABLE_TOPICS,
TSDB_MGMT_TABLE_CONSUMERS,
2022-05-09 10:09:55 +00:00
TSDB_MGMT_TABLE_SUBSCRIPTIONS,
2022-04-14 12:54:43 +00:00
TSDB_MGMT_TABLE_TRANS,
TSDB_MGMT_TABLE_SMAS,
TSDB_MGMT_TABLE_CONFIGS,
TSDB_MGMT_TABLE_CONNS,
TSDB_MGMT_TABLE_QUERIES,
2021-10-08 05:53:49 +00:00
TSDB_MGMT_TABLE_VNODES,
TSDB_MGMT_TABLE_MAX,
2021-12-02 11:56:43 +00:00
} EShowType;
2021-10-08 05:53:49 +00:00
#define TSDB_ALTER_TABLE_ADD_TAG 1
#define TSDB_ALTER_TABLE_DROP_TAG 2
#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4
2022-02-17 11:07:39 +00:00
#define TSDB_ALTER_TABLE_ADD_COLUMN 5
#define TSDB_ALTER_TABLE_DROP_COLUMN 6
2022-02-08 09:13:43 +00:00
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES 7
2022-02-17 11:07:39 +00:00
#define TSDB_ALTER_TABLE_UPDATE_TAG_BYTES 8
#define TSDB_ALTER_TABLE_UPDATE_OPTIONS 9
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME 10
2021-10-08 05:53:49 +00:00
2022-02-17 11:07:39 +00:00
#define TSDB_FILL_NONE 0
#define TSDB_FILL_NULL 1
2021-12-24 07:00:51 +00:00
#define TSDB_FILL_SET_VALUE 2
2022-02-17 11:07:39 +00:00
#define TSDB_FILL_LINEAR 3
#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
2022-05-09 08:03:31 +00:00
#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
2022-02-11 05:13:32 +00:00
2021-10-08 05:53:49 +00:00
#define TSDB_ALTER_USER_PRIVILEGES 0x2
2021-12-24 07:00:51 +00:00
#define TSDB_KILL_MSG_LEN 30
2021-10-08 05:53:49 +00:00
2022-03-04 11:36:03 +00:00
#define TSDB_TABLE_NUM_UNIT 100000
2022-02-17 11:07:39 +00:00
#define TSDB_VN_READ_ACCCESS ((char)0x1)
2021-12-24 07:00:51 +00:00
#define TSDB_VN_WRITE_ACCCESS ((char)0x2)
2022-02-17 11:07:39 +00:00
#define TSDB_VN_ALL_ACCCESS (TSDB_VN_READ_ACCCESS | TSDB_VN_WRITE_ACCCESS)
2021-10-08 05:53:49 +00:00
2021-12-24 07:00:51 +00:00
#define TSDB_COL_NORMAL 0x0u // the normal column of the table
2022-02-17 11:07:39 +00:00
#define TSDB_COL_TAG 0x1u // the tag column type
#define TSDB_COL_UDC 0x2u // the user specified normal string column, it is a dummy column
#define TSDB_COL_TMP 0x4u // internal column generated by the previous operators
#define TSDB_COL_NULL 0x8u // the column filter NULL or not
2021-10-08 05:53:49 +00:00
2022-02-17 11:07:39 +00:00
#define TSDB_COL_IS_TAG(f) (((f & (~(TSDB_COL_NULL))) & TSDB_COL_TAG) != 0)
2021-12-24 07:00:51 +00:00
#define TSDB_COL_IS_NORMAL_COL(f) ((f & (~(TSDB_COL_NULL))) == TSDB_COL_NORMAL)
2022-02-17 11:07:39 +00:00
#define TSDB_COL_IS_UD_COL(f) ((f & (~(TSDB_COL_NULL))) == TSDB_COL_UDC)
#define TSDB_COL_REQ_NULL(f) (((f)&TSDB_COL_NULL) != 0)
2022-01-28 02:54:50 +00:00
2022-02-17 11:07:39 +00:00
#define TD_SUPER_TABLE TSDB_SUPER_TABLE
#define TD_CHILD_TABLE TSDB_CHILD_TABLE
2022-01-28 02:54:50 +00:00
#define TD_NORMAL_TABLE TSDB_NORMAL_TABLE
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-16 09:05:13 +00:00
int32_t vgId;
2022-01-28 09:50:16 +00:00
char* dbFName;
char* tbName;
2021-12-13 09:10:31 +00:00
} SBuildTableMetaInput;
2022-01-10 12:44:11 +00:00
typedef struct {
2022-01-24 06:31:57 +00:00
char db[TSDB_DB_FNAME_LEN];
2022-03-01 11:48:21 +00:00
int64_t dbId;
int32_t vgVersion;
2022-03-16 10:29:31 +00:00
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
2021-12-15 01:52:37 +00:00
} SBuildUseDBInput;
2022-02-09 10:55:16 +00:00
typedef struct SField {
char name[TSDB_COL_NAME_LEN];
uint8_t type;
int32_t bytes;
int8_t flags;
2022-02-09 10:55:16 +00:00
} SField;
2022-03-24 06:25:37 +00:00
typedef struct SRetention {
2022-05-01 04:18:54 +00:00
int64_t freq;
int64_t keep;
2022-03-24 06:54:10 +00:00
int8_t freqUnit;
int8_t keepUnit;
2022-03-24 06:25:37 +00:00
} SRetention;
2022-05-08 09:04:19 +00:00
#define RETENTION_VALID(r) (((r)->freq > 0) && ((r)->keep > 0))
2021-10-08 05:53:49 +00:00
#pragma pack(push, 1)
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
2022-01-26 06:00:15 +00:00
typedef struct SEp {
2021-12-17 12:58:45 +00:00
char fqdn[TSDB_FQDN_LEN];
2021-10-08 05:53:49 +00:00
uint16_t port;
2022-01-26 06:00:15 +00:00
} SEp;
2021-10-08 05:53:49 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
2021-10-08 05:53:49 +00:00
int32_t contLen;
2022-03-25 12:19:09 +00:00
int32_t vgId;
2021-10-08 05:53:49 +00:00
} SMsgHead;
// Submit message for one table
typedef struct SSubmitBlk {
2022-02-15 06:57:42 +00:00
int64_t uid; // table unique id
2022-03-25 13:03:12 +00:00
int64_t suid; // stable id
2022-02-15 06:57:42 +00:00
int32_t sversion; // data schema version
int32_t dataLen; // data part length, not including the SSubmitBlk head
int32_t schemaLen; // schema length, if length is 0, no schema exists
int16_t numOfRows; // total number of rows in current submit block
2022-03-27 15:26:21 +00:00
int16_t padding; // TODO just for padding here
2022-02-15 06:57:42 +00:00
char data[];
2021-10-08 05:53:49 +00:00
} SSubmitBlk;
// Submit message for this TSDB
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-16 09:05:13 +00:00
SMsgHead header;
2022-01-05 08:25:14 +00:00
int64_t version;
2021-12-16 09:05:13 +00:00
int32_t length;
int32_t numOfBlocks;
char blocks[];
2022-02-16 07:27:19 +00:00
} SSubmitReq;
2021-10-08 05:53:49 +00:00
2022-01-05 07:26:49 +00:00
typedef struct {
int32_t totalLen;
int32_t len;
2022-02-15 06:57:42 +00:00
STSRow* row;
2022-01-05 07:26:49 +00:00
} SSubmitBlkIter;
typedef struct {
2022-04-24 13:00:05 +00:00
int32_t totalLen;
int32_t len;
// head of SSubmitBlk
2022-04-25 13:08:11 +00:00
int64_t uid; // table unique id
int64_t suid; // stable id
int32_t sversion; // data schema version
int32_t dataLen; // data part length, not including the SSubmitBlk head
int32_t schemaLen; // schema length, if length is 0, no schema exists
int16_t numOfRows; // total number of rows in current submit block
2022-04-24 13:00:05 +00:00
// head of SSubmitBlk
2022-03-24 23:50:28 +00:00
const void* pMsg;
2022-01-05 07:26:49 +00:00
} SSubmitMsgIter;
2022-05-01 04:18:54 +00:00
2022-03-24 23:50:28 +00:00
int32_t tInitSubmitMsgIter(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
2022-02-16 03:45:44 +00:00
int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
2022-05-01 02:50:23 +00:00
int32_t tInitSubmitBlkIter(SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
2022-02-09 12:34:11 +00:00
STSRow* tGetSubmitBlkNext(SSubmitBlkIter* pIter);
2022-05-05 10:57:09 +00:00
// for debug
int32_t tPrintFixedSchemaSubmitReq(const SSubmitReq* pReq, STSchema* pSchema);
2022-01-05 07:26:49 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
int32_t index; // index of failed block in submit blocks
int32_t vnode; // vnode index of failed block
int32_t sid; // table index of failed block
int32_t code; // errorcode while write data to vnode, such as not created, dropped, no space, invalid table
2022-02-16 07:27:19 +00:00
} SSubmitRspBlock;
2021-10-08 05:53:49 +00:00
typedef struct {
2022-02-16 07:27:19 +00:00
int32_t code; // 0-success, > 0 error code
int32_t numOfRows; // number of records the client is trying to write
int32_t affectedRows; // number of records actually written
int32_t failedRows; // number of failed records (exclude duplicate records)
int32_t numOfFailedBlocks;
SSubmitRspBlock failedBlocks[];
} SSubmitRsp;
2021-10-08 05:53:49 +00:00
2022-04-18 13:23:22 +00:00
#define SCHEMA_SMA_ON 0x1
#define SCHEMA_IDX_ON 0x2
2021-10-08 05:53:49 +00:00
typedef struct SSchema {
int8_t type;
2022-04-18 13:23:22 +00:00
int8_t flags;
col_id_t colId;
int32_t bytes;
char name[TSDB_COL_NAME_LEN];
2021-10-08 05:53:49 +00:00
} SSchema;
2022-04-29 13:32:54 +00:00
#define IS_BSMA_ON(s) (((s)->flags & 0x01) == SCHEMA_SMA_ON)
2022-04-07 09:41:16 +00:00
#define SSCHMEA_TYPE(s) ((s)->type)
2022-04-29 13:32:54 +00:00
#define SSCHMEA_FLAGS(s) ((s)->flags)
2022-04-01 09:43:50 +00:00
#define SSCHMEA_COLID(s) ((s)->colId)
#define SSCHMEA_BYTES(s) ((s)->bytes)
2022-04-07 09:41:16 +00:00
#define SSCHMEA_NAME(s) ((s)->name)
2022-04-01 09:43:50 +00:00
2022-04-22 12:34:37 +00:00
typedef struct {
int32_t nCols;
int32_t sver;
SSchema* pSchema;
} SSchemaWrapper;
2022-04-20 09:56:45 +00:00
STSchema* tdGetSTSChemaFromSSChema(SSchema** pSchema, int32_t nCols);
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-10 07:20:04 +00:00
char name[TSDB_TABLE_FNAME_LEN];
int8_t igExists;
2022-03-24 02:50:16 +00:00
float xFilesFactor;
int32_t delay;
2022-03-24 05:57:33 +00:00
int32_t ttl;
2021-12-10 07:20:04 +00:00
int32_t numOfColumns;
2022-02-09 10:28:11 +00:00
int32_t numOfTags;
2022-03-23 09:53:00 +00:00
int32_t commentLen;
int32_t ast1Len;
int32_t ast2Len;
2022-03-24 05:57:33 +00:00
SArray* pColumns; // array of SField
SArray* pTags; // array of SField
2022-03-24 02:50:16 +00:00
char* comment;
char* pAst1;
char* pAst2;
2022-01-10 12:44:11 +00:00
} SMCreateStbReq;
2021-10-08 05:53:49 +00:00
2022-02-15 10:17:18 +00:00
int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
int32_t tDeserializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
2022-02-14 10:42:42 +00:00
void tFreeSMCreateStbReq(SMCreateStbReq* pReq);
2022-02-09 10:28:11 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
char name[TSDB_TABLE_FNAME_LEN];
int8_t igNotExists;
2022-01-10 12:44:11 +00:00
} SMDropStbReq;
2021-12-12 02:46:49 +00:00
2022-02-15 10:17:18 +00:00
int32_t tSerializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq);
int32_t tDeserializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq);
2022-02-09 11:41:14 +00:00
2021-12-12 02:46:49 +00:00
typedef struct {
char name[TSDB_TABLE_FNAME_LEN];
int8_t alterType;
2022-02-09 12:29:42 +00:00
int32_t numOfFields;
SArray* pFields;
2022-05-07 05:06:23 +00:00
} SMAlterStbReq;
2021-10-08 05:53:49 +00:00
2022-05-07 05:06:23 +00:00
int32_t tSerializeSMAlterStbReq(void* buf, int32_t bufLen, SMAlterStbReq* pReq);
int32_t tDeserializeSMAlterStbReq(void* buf, int32_t bufLen, SMAlterStbReq* pReq);
void tFreeSMAltertbReq(SMAlterStbReq* pReq);
2021-10-08 05:53:49 +00:00
typedef struct SEpSet {
2022-02-15 06:57:42 +00:00
int8_t inUse;
int8_t numOfEps;
SEp eps[TSDB_MAX_REPLICA];
2021-10-08 05:53:49 +00:00
} SEpSet;
2022-05-07 10:03:06 +00:00
int32_t tEncodeSEpSet(SEncoder* pEncoder, const SEpSet* pEp);
int32_t tDecodeSEpSet(SDecoder* pDecoder, SEpSet* pEp);
2022-02-16 03:45:44 +00:00
int32_t taosEncodeSEpSet(void** buf, const SEpSet* pEp);
void* taosDecodeSEpSet(const void* buf, SEpSet* pEp);
2021-12-29 09:53:43 +00:00
2022-04-21 09:51:33 +00:00
typedef struct {
SEpSet epSet;
} SMEpSet;
int32_t tSerializeSMEpSet(void* buf, int32_t bufLen, SMEpSet* pReq);
int32_t tDeserializeSMEpSet(void* buf, int32_t buflen, SMEpSet* pReq);
2021-10-08 05:53:49 +00:00
typedef struct {
2022-04-14 06:42:51 +00:00
int8_t connType;
2021-10-08 05:53:49 +00:00
int32_t pid;
2021-12-03 06:36:41 +00:00
char app[TSDB_APP_NAME_LEN];
char db[TSDB_DB_NAME_LEN];
2022-04-21 06:29:22 +00:00
char user[TSDB_USER_LEN];
char passwd[TSDB_PASSWORD_LEN];
int64_t startTime;
2022-01-06 08:13:49 +00:00
} SConnectReq;
2022-02-15 07:08:46 +00:00
2022-02-16 03:45:44 +00:00
int32_t tSerializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq);
int32_t tDeserializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq);
2022-01-19 09:35:06 +00:00
typedef struct {
int32_t acctId;
int64_t clusterId;
2022-04-12 11:10:52 +00:00
uint32_t connId;
int8_t superUser;
int8_t connType;
SEpSet epSet;
char sVersion[128];
2022-01-19 09:35:06 +00:00
} SConnectRsp;
2021-12-29 09:53:43 +00:00
2022-02-16 03:45:44 +00:00
int32_t tSerializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp);
int32_t tDeserializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp);
2022-01-19 09:35:06 +00:00
typedef struct {
char user[TSDB_USER_LEN];
char pass[TSDB_PASSWORD_LEN];
int32_t maxUsers;
int32_t maxDbs;
int32_t maxTimeSeries;
int32_t maxStreams;
int32_t accessState; // Configured only by command
int64_t maxStorage;
2022-01-19 09:35:06 +00:00
} SCreateAcctReq, SAlterAcctReq;
2022-01-14 02:48:05 +00:00
2022-02-11 09:48:26 +00:00
int32_t tSerializeSCreateAcctReq(void* buf, int32_t bufLen, SCreateAcctReq* pReq);
int32_t tDeserializeSCreateAcctReq(void* buf, int32_t bufLen, SCreateAcctReq* pReq);
2022-02-11 05:13:32 +00:00
2022-01-19 09:35:06 +00:00
typedef struct {
char user[TSDB_USER_LEN];
} SDropUserReq, SDropAcctReq;
2021-10-08 05:53:49 +00:00
2022-02-11 09:48:26 +00:00
int32_t tSerializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
int32_t tDeserializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
2022-02-11 05:13:32 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
2022-02-11 05:13:32 +00:00
int8_t createType;
int8_t superUser; // denote if it is a super user or not
2021-12-31 10:40:49 +00:00
char user[TSDB_USER_LEN];
2022-03-28 05:35:36 +00:00
char pass[TSDB_USET_PASSWORD_LEN];
2022-02-11 05:13:32 +00:00
} SCreateUserReq;
2022-02-11 09:48:26 +00:00
int32_t tSerializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq);
int32_t tDeserializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq);
2022-02-11 05:13:32 +00:00
typedef struct {
int8_t alterType;
2022-02-11 07:20:27 +00:00
int8_t superUser;
2022-02-11 05:13:32 +00:00
char user[TSDB_USER_LEN];
2022-03-28 05:35:36 +00:00
char pass[TSDB_USET_PASSWORD_LEN];
2022-02-11 05:13:32 +00:00
char dbname[TSDB_DB_FNAME_LEN];
} SAlterUserReq;
2022-02-11 09:48:26 +00:00
int32_t tSerializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq);
int32_t tDeserializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq);
2021-10-08 05:53:49 +00:00
2022-02-11 07:20:27 +00:00
typedef struct {
char user[TSDB_USER_LEN];
} SGetUserAuthReq;
2022-02-11 09:48:26 +00:00
int32_t tSerializeSGetUserAuthReq(void* buf, int32_t bufLen, SGetUserAuthReq* pReq);
int32_t tDeserializeSGetUserAuthReq(void* buf, int32_t bufLen, SGetUserAuthReq* pReq);
2022-02-11 07:20:27 +00:00
typedef struct {
char user[TSDB_USER_LEN];
2022-05-05 13:36:33 +00:00
int32_t version;
2022-02-11 07:20:27 +00:00
int8_t superAuth;
2022-05-05 13:36:33 +00:00
SHashObj* createdDbs;
2022-02-11 07:20:27 +00:00
SHashObj* readDbs;
SHashObj* writeDbs;
} SGetUserAuthRsp;
2022-02-12 08:28:50 +00:00
int32_t tSerializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pRsp);
int32_t tDeserializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pRsp);
2022-04-27 07:08:51 +00:00
void tFreeSGetUserAuthRsp(SGetUserAuthRsp* pRsp);
2022-02-11 07:20:27 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-06 07:06:29 +00:00
int16_t colId; // column id
int16_t colIndex; // column index in colList if it is a normal column or index in tagColList if a tag
int16_t flag; // denote if it is a tag or a normal column
2021-12-28 08:06:01 +00:00
char name[TSDB_DB_FNAME_LEN];
2021-10-08 05:53:49 +00:00
} SColIndex;
2022-01-10 12:44:11 +00:00
typedef struct {
2021-10-08 05:53:49 +00:00
int16_t lowerRelOptr;
int16_t upperRelOptr;
2021-12-16 09:05:13 +00:00
int16_t filterstr; // denote if current column is char(binary/nchar)
2021-10-08 05:53:49 +00:00
union {
struct {
int64_t lowerBndi;
int64_t upperBndi;
};
struct {
double lowerBndd;
double upperBndd;
};
struct {
int64_t pz;
int64_t len;
};
};
} SColumnFilterInfo;
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-16 09:05:13 +00:00
int16_t numOfFilters;
union {
int64_t placeholder;
2021-12-24 07:40:15 +00:00
SColumnFilterInfo* filterInfo;
2021-10-08 05:53:49 +00:00
};
} SColumnFilterList;
/*
2022-03-17 09:48:21 +00:00
* for client side struct, only column id, type, bytes are necessary
2021-10-08 05:53:49 +00:00
* But for data in vnode side, we need all the following information.
*/
2022-01-10 12:44:11 +00:00
typedef struct {
2022-03-04 11:21:30 +00:00
union {
col_id_t colId;
int16_t slotId;
2022-03-04 11:21:30 +00:00
};
2022-03-16 10:29:31 +00:00
int16_t type;
int32_t bytes;
uint8_t precision;
uint8_t scale;
2021-10-08 05:53:49 +00:00
} SColumnInfo;
2022-01-10 12:44:11 +00:00
typedef struct {
2022-02-23 08:04:06 +00:00
int64_t uid;
TSKEY key; // last accessed ts, for subscription
2021-10-08 05:53:49 +00:00
} STableIdInfo;
typedef struct STimeWindow {
TSKEY skey;
TSKEY ekey;
} STimeWindow;
typedef struct {
2021-12-16 09:05:13 +00:00
int32_t tsOffset; // offset value in current msg body, NOTE: ts list is compressed
int32_t tsLen; // total length of ts comp block
int32_t tsNumOfBlocks; // ts comp block numbers
int32_t tsOrder; // ts comp block order
2021-10-08 05:53:49 +00:00
} STsBufInfo;
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-16 09:05:13 +00:00
int32_t tz; // query client timezone
2021-10-08 05:53:49 +00:00
char intervalUnit;
char slidingUnit;
2022-04-07 10:20:54 +00:00
char
2022-04-24 05:42:54 +00:00
offsetUnit; // TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration.
2022-03-24 03:15:05 +00:00
int8_t precision;
2021-10-08 05:53:49 +00:00
int64_t interval;
int64_t sliding;
int64_t offset;
} SInterval;
typedef struct {
2021-12-06 07:06:29 +00:00
int32_t code;
2021-10-08 05:53:49 +00:00
} SQueryTableRsp;
2022-03-23 02:44:32 +00:00
int32_t tSerializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
2022-03-10 11:05:58 +00:00
2022-03-23 02:44:32 +00:00
int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
2022-03-10 11:05:58 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-28 08:06:01 +00:00
char db[TSDB_DB_FNAME_LEN];
2021-12-15 10:29:21 +00:00
int32_t numOfVgroups;
2022-04-25 13:12:03 +00:00
int32_t numOfStables; // single_stable
int32_t buffer; // MB
int32_t pageSize;
int32_t pages;
2021-12-06 06:38:37 +00:00
int32_t daysPerFile;
int32_t daysToKeep0;
int32_t daysToKeep1;
int32_t daysToKeep2;
2021-12-20 03:51:18 +00:00
int32_t minRows;
int32_t maxRows;
2021-12-06 06:38:37 +00:00
int32_t fsyncPeriod;
2021-12-09 05:07:00 +00:00
int8_t walLevel;
2021-12-06 06:38:37 +00:00
int8_t precision; // time resolution
int8_t compression;
int8_t replications;
2022-04-20 01:47:38 +00:00
int8_t strict;
2021-12-06 06:38:37 +00:00
int8_t cacheLastRow;
2021-12-09 05:07:00 +00:00
int8_t ignoreExist;
2022-03-24 06:25:37 +00:00
int32_t numOfRetensions;
SArray* pRetensions; // SRetention
2022-01-10 12:44:11 +00:00
} SCreateDbReq;
2021-12-09 05:07:00 +00:00
2022-02-12 09:00:40 +00:00
int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
int32_t tDeserializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
2022-03-24 06:25:37 +00:00
void tFreeSCreateDbReq(SCreateDbReq* pReq);
2022-02-12 09:00:40 +00:00
2021-12-09 05:07:00 +00:00
typedef struct {
2021-12-28 08:06:01 +00:00
char db[TSDB_DB_FNAME_LEN];
2022-04-25 13:12:03 +00:00
int32_t buffer;
int32_t pageSize;
int32_t pages;
2022-04-28 07:30:23 +00:00
int32_t daysPerFile;
2021-12-09 05:07:00 +00:00
int32_t daysToKeep0;
int32_t daysToKeep1;
int32_t daysToKeep2;
int32_t fsyncPeriod;
int8_t walLevel;
2022-04-20 01:47:38 +00:00
int8_t strict;
2021-12-09 05:07:00 +00:00
int8_t cacheLastRow;
2022-03-31 09:20:26 +00:00
int8_t replications;
2022-01-10 08:55:56 +00:00
} SAlterDbReq;
2021-12-09 05:07:00 +00:00
2022-02-12 09:00:40 +00:00
int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
int32_t tDeserializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
2021-12-09 05:07:00 +00:00
typedef struct {
2022-01-27 01:33:44 +00:00
char db[TSDB_DB_FNAME_LEN];
2021-12-31 10:40:49 +00:00
int8_t ignoreNotExists;
2022-01-10 08:55:56 +00:00
} SDropDbReq;
2021-12-09 05:07:00 +00:00
2022-02-12 09:00:40 +00:00
int32_t tSerializeSDropDbReq(void* buf, int32_t bufLen, SDropDbReq* pReq);
int32_t tDeserializeSDropDbReq(void* buf, int32_t bufLen, SDropDbReq* pReq);
2021-12-09 05:07:00 +00:00
typedef struct {
2022-02-23 08:04:06 +00:00
char db[TSDB_DB_FNAME_LEN];
int64_t uid;
2022-01-27 01:33:44 +00:00
} SDropDbRsp;
2022-02-12 09:00:40 +00:00
int32_t tSerializeSDropDbRsp(void* buf, int32_t bufLen, SDropDbRsp* pRsp);
int32_t tDeserializeSDropDbRsp(void* buf, int32_t bufLen, SDropDbRsp* pRsp);
2022-01-27 01:33:44 +00:00
typedef struct {
char db[TSDB_DB_FNAME_LEN];
2022-03-01 11:48:21 +00:00
int64_t dbId;
int32_t vgVersion;
2022-03-16 10:29:31 +00:00
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
2022-01-10 08:55:56 +00:00
} SUseDbReq;
2021-12-09 05:07:00 +00:00
2022-02-12 09:00:40 +00:00
int32_t tSerializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq);
int32_t tDeserializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq);
2021-12-09 05:07:00 +00:00
typedef struct {
2022-02-23 08:04:06 +00:00
char db[TSDB_DB_FNAME_LEN];
int64_t uid;
int32_t vgVersion;
int32_t vgNum;
int8_t hashMethod;
SArray* pVgroupInfos; // Array of SVgroupInfo
2022-02-14 07:27:38 +00:00
} SUseDbRsp;
2022-03-28 09:22:18 +00:00
int32_t tSerializeSUseDbRsp(void* buf, int32_t bufLen, const SUseDbRsp* pRsp);
2022-02-14 07:27:38 +00:00
int32_t tDeserializeSUseDbRsp(void* buf, int32_t bufLen, SUseDbRsp* pRsp);
2022-05-07 10:03:06 +00:00
int32_t tSerializeSUseDbRspImp(SEncoder* pEncoder, const SUseDbRsp* pRsp);
int32_t tDeserializeSUseDbRspImp(SDecoder* pDecoder, SUseDbRsp* pRsp);
2022-02-14 07:27:38 +00:00
void tFreeSUsedbRsp(SUseDbRsp* pRsp);
2022-04-08 08:05:30 +00:00
typedef struct {
2022-04-10 02:13:22 +00:00
char db[TSDB_DB_FNAME_LEN];
2022-04-08 08:05:30 +00:00
} SDbCfgReq;
int32_t tSerializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq);
int32_t tDeserializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq);
typedef struct {
int32_t numOfVgroups;
2022-04-25 13:12:03 +00:00
int32_t numOfStables;
int32_t buffer;
int32_t pageSize;
int32_t pages;
2022-04-08 08:05:30 +00:00
int32_t daysPerFile;
int32_t daysToKeep0;
int32_t daysToKeep1;
int32_t daysToKeep2;
int32_t minRows;
int32_t maxRows;
int32_t fsyncPeriod;
int8_t walLevel;
int8_t precision;
int8_t compression;
int8_t replications;
2022-04-20 01:47:38 +00:00
int8_t strict;
2022-04-08 08:05:30 +00:00
int8_t cacheLastRow;
int32_t numOfRetensions;
SArray* pRetensions;
2022-04-08 08:05:30 +00:00
} SDbCfgRsp;
int32_t tSerializeSDbCfgRsp(void* buf, int32_t bufLen, const SDbCfgRsp* pRsp);
int32_t tDeserializeSDbCfgRsp(void* buf, int32_t bufLen, SDbCfgRsp* pRsp);
2022-03-07 11:37:17 +00:00
typedef struct {
int32_t rowNum;
} SQnodeListReq;
int32_t tSerializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq);
int32_t tDeserializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq);
typedef struct {
2022-04-22 11:28:27 +00:00
SArray* addrsList; // SArray<SQueryNodeAddr>
2022-03-07 11:37:17 +00:00
} SQnodeListRsp;
int32_t tSerializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp);
int32_t tDeserializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp);
void tFreeSQnodeListRsp(SQnodeListRsp* pRsp);
2022-04-22 11:28:27 +00:00
typedef struct SQueryNodeAddr {
int32_t nodeId; // vgId or qnodeId
SEpSet epSet;
} SQueryNodeAddr;
2022-02-14 07:27:38 +00:00
typedef struct {
SArray* pArray; // Array of SUseDbRsp
} SUseDbBatchRsp;
int32_t tSerializeSUseDbBatchRsp(void* buf, int32_t bufLen, SUseDbBatchRsp* pRsp);
int32_t tDeserializeSUseDbBatchRsp(void* buf, int32_t bufLen, SUseDbBatchRsp* pRsp);
void tFreeSUseDbBatchRsp(SUseDbBatchRsp* pRsp);
2021-12-09 05:07:00 +00:00
2022-05-06 06:13:56 +00:00
typedef struct {
SArray* pArray; // Array of SGetUserAuthRsp
} SUserAuthBatchRsp;
int32_t tSerializeSUserAuthBatchRsp(void* buf, int32_t bufLen, SUserAuthBatchRsp* pRsp);
int32_t tDeserializeSUserAuthBatchRsp(void* buf, int32_t bufLen, SUserAuthBatchRsp* pRsp);
void tFreeSUserAuthBatchRsp(SUserAuthBatchRsp* pRsp);
2021-12-09 05:07:00 +00:00
typedef struct {
2022-01-27 01:33:44 +00:00
char db[TSDB_DB_FNAME_LEN];
2022-04-20 01:47:38 +00:00
} SCompactDbReq;
2022-02-12 09:00:40 +00:00
2022-04-20 01:47:38 +00:00
int32_t tSerializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
int32_t tDeserializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-06 06:38:37 +00:00
char name[TSDB_FUNC_NAME_LEN];
2022-01-24 05:59:09 +00:00
int8_t igExists;
2021-12-08 05:48:18 +00:00
int8_t funcType;
int8_t scriptType;
2021-12-06 06:38:37 +00:00
int8_t outputType;
2021-12-08 05:48:18 +00:00
int32_t outputLen;
2021-12-06 06:38:37 +00:00
int32_t bufSize;
2022-04-20 09:43:02 +00:00
int32_t codeLen;
2022-01-24 02:38:49 +00:00
int64_t signature;
char* pComment;
char* pCode;
2022-01-10 08:55:56 +00:00
} SCreateFuncReq;
2021-10-08 05:53:49 +00:00
2022-02-12 08:28:50 +00:00
int32_t tSerializeSCreateFuncReq(void* buf, int32_t bufLen, SCreateFuncReq* pReq);
int32_t tDeserializeSCreateFuncReq(void* buf, int32_t bufLen, SCreateFuncReq* pReq);
void tFreeSCreateFuncReq(SCreateFuncReq* pReq);
2022-02-12 08:28:50 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
2022-01-24 09:55:37 +00:00
char name[TSDB_FUNC_NAME_LEN];
int8_t igNotExists;
2022-01-10 08:55:56 +00:00
} SDropFuncReq;
2021-12-08 05:48:18 +00:00
2022-02-12 08:28:50 +00:00
int32_t tSerializeSDropFuncReq(void* buf, int32_t bufLen, SDropFuncReq* pReq);
int32_t tDeserializeSDropFuncReq(void* buf, int32_t bufLen, SDropFuncReq* pReq);
2021-12-08 05:48:18 +00:00
typedef struct {
int32_t numOfFuncs;
2022-04-21 07:33:07 +00:00
bool ignoreCodeComment;
2022-02-12 08:28:50 +00:00
SArray* pFuncNames;
2022-01-10 08:55:56 +00:00
} SRetrieveFuncReq;
2021-10-08 05:53:49 +00:00
2022-02-12 08:28:50 +00:00
int32_t tSerializeSRetrieveFuncReq(void* buf, int32_t bufLen, SRetrieveFuncReq* pReq);
int32_t tDeserializeSRetrieveFuncReq(void* buf, int32_t bufLen, SRetrieveFuncReq* pReq);
void tFreeSRetrieveFuncReq(SRetrieveFuncReq* pReq);
2022-02-12 08:28:50 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
char name[TSDB_FUNC_NAME_LEN];
2021-12-08 05:48:18 +00:00
int8_t funcType;
int8_t scriptType;
int8_t outputType;
int32_t outputLen;
2021-10-08 05:53:49 +00:00
int32_t bufSize;
2022-01-24 02:38:49 +00:00
int64_t signature;
2021-12-08 05:48:18 +00:00
int32_t commentSize;
int32_t codeSize;
char* pComment;
char* pCode;
2021-12-08 05:48:18 +00:00
} SFuncInfo;
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-08 05:48:18 +00:00
int32_t numOfFuncs;
2022-02-12 08:28:50 +00:00
SArray* pFuncInfos;
2021-12-08 05:48:18 +00:00
} SRetrieveFuncRsp;
2021-10-08 05:53:49 +00:00
2022-02-12 08:28:50 +00:00
int32_t tSerializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp);
int32_t tDeserializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp);
2022-04-24 05:42:54 +00:00
void tFreeSFuncInfo(SFuncInfo* pInfo);
void tFreeSRetrieveFuncRsp(SRetrieveFuncRsp* pRsp);
2022-02-12 08:28:50 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
2021-11-02 06:27:20 +00:00
int32_t statusInterval;
2022-02-28 09:39:07 +00:00
int64_t checkTime; // 1970-01-01 00:00:00.000
2022-02-24 04:19:51 +00:00
char timezone[TD_TIMEZONE_LEN]; // tsTimezone
char locale[TD_LOCALE_LEN]; // tsLocale
char charset[TD_LOCALE_LEN]; // tsCharset
2021-11-02 06:27:20 +00:00
} SClusterCfg;
2021-10-08 05:53:49 +00:00
typedef struct {
int32_t openVnodes;
int32_t totalVnodes;
int32_t masterNum;
int64_t numOfSelectReqs;
int64_t numOfInsertReqs;
int64_t numOfInsertSuccessReqs;
int64_t numOfBatchInsertReqs;
int64_t numOfBatchInsertSuccessReqs;
int64_t errors;
} SVnodesStat;
2021-11-02 06:27:20 +00:00
typedef struct {
int32_t vgId;
2022-04-19 13:39:42 +00:00
int32_t syncState;
2022-02-10 08:26:56 +00:00
int64_t numOfTables;
int64_t numOfTimeSeries;
2021-11-02 06:27:20 +00:00
int64_t totalStorage;
int64_t compStorage;
int64_t pointsWritten;
2022-03-05 07:05:13 +00:00
int64_t numOfSelectReqs;
int64_t numOfInsertReqs;
int64_t numOfInsertSuccessReqs;
int64_t numOfBatchInsertReqs;
int64_t numOfBatchInsertSuccessReqs;
2021-11-02 06:27:20 +00:00
} SVnodeLoad;
2022-04-19 13:39:42 +00:00
typedef struct {
int32_t syncState;
} SMnodeLoad;
2021-11-02 06:27:20 +00:00
typedef struct {
2022-04-12 07:49:21 +00:00
int32_t sver; // software version
int64_t dnodeVer; // dnode table version in sdb
2021-11-02 06:27:20 +00:00
int32_t dnodeId;
2021-12-27 02:57:31 +00:00
int64_t clusterId;
2021-12-27 02:47:14 +00:00
int64_t rebootTime;
int64_t updateTime;
2021-12-30 03:35:46 +00:00
int32_t numOfCores;
int32_t numOfSupportVnodes;
2021-11-02 06:27:20 +00:00
char dnodeEp[TSDB_EP_LEN];
SClusterCfg clusterCfg;
2022-02-10 03:40:16 +00:00
SArray* pVloads; // array of SVnodeLoad
2022-01-06 09:04:48 +00:00
} SStatusReq;
2021-10-08 05:53:49 +00:00
2022-02-16 05:36:03 +00:00
int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
2022-04-13 06:00:56 +00:00
void tFreeSStatusReq(SStatusReq* pReq);
2021-12-26 15:46:22 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
2021-10-25 09:39:21 +00:00
int32_t dnodeId;
2021-12-27 02:57:31 +00:00
int64_t clusterId;
2021-10-08 05:53:49 +00:00
} SDnodeCfg;
typedef struct {
2022-02-15 06:57:42 +00:00
int32_t id;
int8_t isMnode;
SEp ep;
2021-10-08 05:53:49 +00:00
} SDnodeEp;
typedef struct {
2022-04-12 07:49:21 +00:00
int64_t dnodeVer;
2021-11-02 06:27:20 +00:00
SDnodeCfg dnodeCfg;
2022-02-10 07:06:01 +00:00
SArray* pDnodeEps; // Array of SDnodeEp
2021-10-08 05:53:49 +00:00
} SStatusRsp;
2022-02-16 05:36:03 +00:00
int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
int32_t tDeserializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
2022-03-18 03:23:50 +00:00
void tFreeSStatusRsp(SStatusRsp* pRsp);
2022-02-10 07:06:01 +00:00
typedef struct {
2022-02-16 05:44:43 +00:00
int32_t reserved;
} SMTimerReq;
int32_t tSerializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq);
int32_t tDeserializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq);
2022-02-10 07:06:01 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
2021-11-05 08:04:02 +00:00
int32_t id;
uint16_t port; // node sync Port
char fqdn[TSDB_FQDN_LEN]; // node FQDN
2021-11-05 07:42:19 +00:00
} SReplica;
typedef struct {
2021-12-06 07:06:29 +00:00
int32_t vgId;
2021-12-18 12:56:05 +00:00
int32_t dnodeId;
2021-12-28 08:06:01 +00:00
char db[TSDB_DB_FNAME_LEN];
2022-02-23 08:04:06 +00:00
int64_t dbUid;
2021-12-19 06:43:58 +00:00
int32_t vgVersion;
2022-04-29 13:01:13 +00:00
int32_t numOfStables;
2022-04-25 13:12:03 +00:00
int32_t buffer;
int32_t pageSize;
int32_t pages;
2021-11-05 07:42:19 +00:00
int32_t daysPerFile;
int32_t daysToKeep0;
int32_t daysToKeep1;
int32_t daysToKeep2;
2021-12-18 12:56:05 +00:00
int32_t minRows;
int32_t maxRows;
2021-11-05 07:42:19 +00:00
int32_t fsyncPeriod;
2022-03-03 01:09:11 +00:00
uint32_t hashBegin;
uint32_t hashEnd;
2022-03-07 09:53:02 +00:00
int8_t hashMethod;
2021-12-18 12:56:05 +00:00
int8_t walLevel;
2021-11-05 07:42:19 +00:00
int8_t precision;
int8_t compression;
2022-04-20 01:47:38 +00:00
int8_t strict;
2021-12-18 12:56:05 +00:00
int8_t cacheLastRow;
2021-11-05 08:04:02 +00:00
int8_t replica;
2021-11-05 07:42:19 +00:00
int8_t selfIndex;
SReplica replicas[TSDB_MAX_REPLICA];
2022-03-24 06:54:10 +00:00
int32_t numOfRetensions;
SArray* pRetensions; // SRetention
2022-04-20 06:21:44 +00:00
} SCreateVnodeReq;
2021-10-08 05:53:49 +00:00
2022-02-16 05:55:37 +00:00
int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
int32_t tDeserializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
2022-03-24 06:54:10 +00:00
int32_t tFreeSCreateVnodeReq(SCreateVnodeReq* pReq);
2022-02-16 05:55:37 +00:00
2021-11-04 01:28:55 +00:00
typedef struct {
2022-02-23 08:04:06 +00:00
int32_t vgId;
int32_t dnodeId;
int64_t dbUid;
char db[TSDB_DB_FNAME_LEN];
2022-04-20 06:21:44 +00:00
} SDropVnodeReq;
2021-11-04 01:28:55 +00:00
2022-02-16 05:55:37 +00:00
int32_t tSerializeSDropVnodeReq(void* buf, int32_t bufLen, SDropVnodeReq* pReq);
int32_t tDeserializeSDropVnodeReq(void* buf, int32_t bufLen, SDropVnodeReq* pReq);
2021-11-04 01:28:55 +00:00
2022-04-20 06:21:44 +00:00
typedef struct {
int64_t dbUid;
char db[TSDB_DB_FNAME_LEN];
} SCompactVnodeReq;
int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
typedef struct {
int32_t vgVersion;
2022-04-25 13:12:03 +00:00
int32_t buffer;
int32_t pageSize;
int32_t pages;
2022-04-28 07:30:23 +00:00
int32_t daysPerFile;
2022-04-20 06:21:44 +00:00
int32_t daysToKeep0;
int32_t daysToKeep1;
int32_t daysToKeep2;
2022-04-25 13:12:03 +00:00
int32_t fsyncPeriod;
2022-04-20 06:21:44 +00:00
int8_t walLevel;
int8_t strict;
int8_t cacheLastRow;
int8_t replica;
int8_t selfIndex;
SReplica replicas[TSDB_MAX_REPLICA];
} SAlterVnodeReq;
int32_t tSerializeSAlterVnodeReq(void* buf, int32_t bufLen, SAlterVnodeReq* pReq);
int32_t tDeserializeSAlterVnodeReq(void* buf, int32_t bufLen, SAlterVnodeReq* pReq);
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-31 05:34:38 +00:00
SMsgHead header;
2022-01-28 09:50:16 +00:00
char dbFName[TSDB_DB_FNAME_LEN];
char tbName[TSDB_TABLE_NAME_LEN];
2022-01-10 12:44:11 +00:00
} STableInfoReq;
2021-10-08 05:53:49 +00:00
2022-02-15 07:24:27 +00:00
int32_t tSerializeSTableInfoReq(void* buf, int32_t bufLen, STableInfoReq* pReq);
int32_t tDeserializeSTableInfoReq(void* buf, int32_t bufLen, STableInfoReq* pReq);
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-10 06:12:11 +00:00
int8_t metaClone; // create local clone of the cached table meta
2021-10-08 05:53:49 +00:00
int32_t numOfVgroups;
int32_t numOfTables;
int32_t numOfUdfs;
char tableNames[];
2022-01-10 12:44:11 +00:00
} SMultiTableInfoReq;
2021-10-08 05:53:49 +00:00
2022-01-26 06:00:15 +00:00
// todo refactor
2021-12-14 07:24:21 +00:00
typedef struct SVgroupInfo {
2022-02-15 06:57:42 +00:00
int32_t vgId;
uint32_t hashBegin;
uint32_t hashEnd;
2022-03-08 09:22:21 +00:00
SEpSet epSet;
2022-03-28 12:31:05 +00:00
union {
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
int32_t taskId; // used in stream
};
2021-12-14 07:24:21 +00:00
} SVgroupInfo;
2021-10-08 05:53:49 +00:00
typedef struct {
2022-01-26 06:00:15 +00:00
int32_t numOfVgroups;
SVgroupInfo vgroups[];
2022-01-10 12:44:11 +00:00
} SVgroupsInfo;
2021-10-08 05:53:49 +00:00
2021-12-10 06:12:11 +00:00
typedef struct {
2022-01-28 09:50:16 +00:00
char tbName[TSDB_TABLE_NAME_LEN];
char stbName[TSDB_TABLE_NAME_LEN];
char dbFName[TSDB_DB_FNAME_LEN];
2022-02-23 08:04:06 +00:00
int64_t dbId;
2021-12-16 09:05:13 +00:00
int32_t numOfTags;
int32_t numOfColumns;
int8_t precision;
int8_t tableType;
int32_t sversion;
int32_t tversion;
2022-02-23 08:27:04 +00:00
uint64_t suid;
uint64_t tuid;
2021-12-16 09:05:13 +00:00
int32_t vgId;
2022-02-15 07:24:27 +00:00
SSchema* pSchemas;
2022-01-10 12:44:11 +00:00
} STableMetaRsp;
2021-10-08 05:53:49 +00:00
2022-02-15 07:24:27 +00:00
int32_t tSerializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
int32_t tDeserializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
void tFreeSTableMetaRsp(STableMetaRsp* pRsp);
typedef struct {
SArray* pArray; // Array of STableMetaRsp
} STableMetaBatchRsp;
int32_t tSerializeSTableMetaBatchRsp(void* buf, int32_t bufLen, STableMetaBatchRsp* pRsp);
int32_t tDeserializeSTableMetaBatchRsp(void* buf, int32_t bufLen, STableMetaBatchRsp* pRsp);
void tFreeSTableMetaBatchRsp(STableMetaBatchRsp* pRsp);
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-06 07:06:29 +00:00
int32_t numOfTables;
int32_t numOfVgroup;
int32_t numOfUdf;
int32_t contLen;
int8_t compressed; // denote if compressed or not
int32_t rawLen; // size before compress
uint8_t metaClone; // make meta clone after retrieve meta from mnode
char meta[];
2021-10-08 05:53:49 +00:00
} SMultiTableMeta;
typedef struct {
int32_t dataLen;
char name[TSDB_TABLE_FNAME_LEN];
2021-12-24 07:40:15 +00:00
char* data;
2021-10-08 05:53:49 +00:00
} STagData;
/*
* sql: show tables like '%a_%'
* payload is the query condition, e.g., '%a_%'
* payloadLen is the length of payload
*/
typedef struct {
2022-02-15 07:08:46 +00:00
int32_t type;
2021-12-28 08:06:01 +00:00
char db[TSDB_DB_FNAME_LEN];
2022-02-14 10:42:42 +00:00
int32_t payloadLen;
char* payload;
2022-01-05 12:18:56 +00:00
} SShowReq;
2021-10-08 05:53:49 +00:00
2022-02-14 10:42:42 +00:00
int32_t tSerializeSShowReq(void* buf, int32_t bufLen, SShowReq* pReq);
int32_t tDeserializeSShowReq(void* buf, int32_t bufLen, SShowReq* pReq);
void tFreeSShowReq(SShowReq* pReq);
2022-01-10 12:44:11 +00:00
typedef struct {
int64_t showId;
2022-01-10 12:44:11 +00:00
STableMetaRsp tableMeta;
2022-02-15 08:46:21 +00:00
} SShowRsp, SVShowTablesRsp;
2021-10-08 05:53:49 +00:00
2022-02-15 07:24:27 +00:00
int32_t tSerializeSShowRsp(void* buf, int32_t bufLen, SShowRsp* pRsp);
int32_t tDeserializeSShowRsp(void* buf, int32_t bufLen, SShowRsp* pRsp);
void tFreeSShowRsp(SShowRsp* pRsp);
2021-10-08 05:53:49 +00:00
typedef struct {
2022-03-09 06:58:15 +00:00
char db[TSDB_DB_FNAME_LEN];
2022-03-16 09:52:44 +00:00
char tb[TSDB_TABLE_NAME_LEN];
int64_t showId;
} SRetrieveTableReq;
typedef struct SSysTableSchema {
int8_t type;
col_id_t colId;
int32_t bytes;
} SSysTableSchema;
int32_t tSerializeSRetrieveTableReq(void* buf, int32_t bufLen, SRetrieveTableReq* pReq);
int32_t tDeserializeSRetrieveTableReq(void* buf, int32_t bufLen, SRetrieveTableReq* pReq);
typedef struct {
int64_t useconds;
int8_t completed; // all results are returned to client
int8_t precision;
int8_t compressed;
int32_t compLen;
int32_t numOfRows;
int32_t numOfCols;
char data[];
} SRetrieveTableRsp;
2022-03-11 11:29:43 +00:00
typedef struct {
2022-03-23 02:44:32 +00:00
int64_t handle;
int64_t useconds;
int8_t completed; // all results are returned to client
int8_t precision;
int8_t compressed;
int32_t compLen;
int32_t numOfRows;
char data[];
2022-03-11 11:29:43 +00:00
} SRetrieveMetaTableRsp;
2022-04-02 11:31:52 +00:00
typedef struct SExplainExecInfo {
uint64_t startupCost;
uint64_t totalCost;
uint64_t numOfRows;
2022-04-07 09:41:16 +00:00
void* verboseInfo;
2022-04-02 11:31:52 +00:00
} SExplainExecInfo;
2022-04-01 11:45:45 +00:00
typedef struct {
2022-04-02 11:31:52 +00:00
int32_t numOfPlans;
2022-04-07 09:41:16 +00:00
SExplainExecInfo* subplanInfo;
2022-04-01 11:45:45 +00:00
} SExplainRsp;
2022-04-02 11:31:52 +00:00
int32_t tSerializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp);
int32_t tDeserializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp);
2022-04-01 11:45:45 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-28 05:43:11 +00:00
char fqdn[TSDB_FQDN_LEN]; // end point, hostname:port
int32_t port;
2022-01-06 09:04:48 +00:00
} SCreateDnodeReq;
2021-12-08 10:50:52 +00:00
2022-02-12 03:58:40 +00:00
int32_t tSerializeSCreateDnodeReq(void* buf, int32_t bufLen, SCreateDnodeReq* pReq);
int32_t tDeserializeSCreateDnodeReq(void* buf, int32_t bufLen, SCreateDnodeReq* pReq);
2021-12-08 10:50:52 +00:00
typedef struct {
int32_t dnodeId;
char fqdn[TSDB_FQDN_LEN];
int32_t port;
2022-01-06 09:04:48 +00:00
} SDropDnodeReq;
2021-12-08 10:50:52 +00:00
2022-02-12 03:58:40 +00:00
int32_t tSerializeSDropDnodeReq(void* buf, int32_t bufLen, SDropDnodeReq* pReq);
int32_t tDeserializeSDropDnodeReq(void* buf, int32_t bufLen, SDropDnodeReq* pReq);
2021-12-08 10:50:52 +00:00
typedef struct {
int32_t dnodeId;
2021-12-12 04:14:26 +00:00
char config[TSDB_DNODE_CONFIG_LEN];
2022-02-12 03:58:40 +00:00
char value[TSDB_DNODE_VALUE_LEN];
2022-01-06 09:04:48 +00:00
} SMCfgDnodeReq, SDCfgDnodeReq;
2021-10-08 05:53:49 +00:00
2022-02-12 03:58:40 +00:00
int32_t tSerializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq);
int32_t tDeserializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq);
2021-12-08 11:34:54 +00:00
typedef struct {
int32_t dnodeId;
2022-04-10 02:13:22 +00:00
} SMCreateMnodeReq, SMDropMnodeReq, SDDropMnodeReq, SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq,
SMCreateSnodeReq, SMDropSnodeReq, SDCreateSnodeReq, SDDropSnodeReq, SMCreateBnodeReq, SMDropBnodeReq,
SDCreateBnodeReq, SDDropBnodeReq;
2021-12-08 11:34:54 +00:00
2022-04-09 06:59:41 +00:00
int32_t tSerializeSCreateDropMQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
int32_t tDeserializeSCreateDropMQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
2022-02-12 03:58:40 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
2021-11-22 02:03:41 +00:00
int32_t dnodeId;
int8_t replica;
2021-11-05 07:42:19 +00:00
SReplica replicas[TSDB_MAX_REPLICA];
2022-01-07 10:03:28 +00:00
} SDCreateMnodeReq, SDAlterMnodeReq;
2021-10-08 05:53:49 +00:00
2022-02-16 08:36:05 +00:00
int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
2021-12-05 15:28:11 +00:00
typedef struct {
int32_t connId;
int32_t queryId;
2022-01-06 08:13:49 +00:00
} SKillQueryReq;
2021-12-05 15:28:11 +00:00
2022-02-16 07:44:20 +00:00
int32_t tSerializeSKillQueryReq(void* buf, int32_t bufLen, SKillQueryReq* pReq);
int32_t tDeserializeSKillQueryReq(void* buf, int32_t bufLen, SKillQueryReq* pReq);
2021-12-05 15:28:11 +00:00
typedef struct {
int32_t connId;
2022-01-06 08:13:49 +00:00
} SKillConnReq;
2021-10-08 05:53:49 +00:00
2022-02-16 07:44:20 +00:00
int32_t tSerializeSKillConnReq(void* buf, int32_t bufLen, SKillConnReq* pReq);
int32_t tDeserializeSKillConnReq(void* buf, int32_t bufLen, SKillConnReq* pReq);
2022-02-17 16:26:43 +00:00
typedef struct {
int32_t transId;
} SKillTransReq;
int32_t tSerializeSKillTransReq(void* buf, int32_t bufLen, SKillTransReq* pReq);
int32_t tDeserializeSKillTransReq(void* buf, int32_t bufLen, SKillTransReq* pReq);
2021-10-08 05:53:49 +00:00
typedef struct {
char user[TSDB_USER_LEN];
char spi;
char encrypt;
char secret[TSDB_PASSWORD_LEN];
char ckey[TSDB_PASSWORD_LEN];
2022-01-06 12:17:25 +00:00
} SAuthReq, SAuthRsp;
2021-10-08 05:53:49 +00:00
2022-02-16 08:36:05 +00:00
int32_t tSerializeSAuthReq(void* buf, int32_t bufLen, SAuthReq* pReq);
int32_t tDeserializeSAuthReq(void* buf, int32_t bufLen, SAuthReq* pReq);
2021-10-08 05:53:49 +00:00
typedef struct {
2022-04-19 06:23:02 +00:00
int32_t statusCode;
2022-04-19 13:39:42 +00:00
char details[1024];
2022-04-19 06:23:02 +00:00
} SServerStatusRsp;
int32_t tSerializeSServerStatusRsp(void* buf, int32_t bufLen, SServerStatusRsp* pRsp);
int32_t tDeserializeSServerStatusRsp(void* buf, int32_t bufLen, SServerStatusRsp* pRsp);
2021-10-08 05:53:49 +00:00
/**
* The layout of the query message payload is as following:
* +--------------------+---------------------------------+
* |Sql statement | Physical plan |
* |(denoted by sqlLen) |(In JSON, denoted by contentLen) |
* +--------------------+---------------------------------+
*/
2022-01-19 09:35:06 +00:00
typedef struct SSubQueryMsg {
2021-12-31 05:34:38 +00:00
SMsgHead header;
2021-12-27 10:42:33 +00:00
uint64_t sId;
2021-12-24 07:00:51 +00:00
uint64_t queryId;
uint64_t taskId;
2022-03-09 08:13:46 +00:00
int64_t refId;
2022-01-20 11:34:46 +00:00
int8_t taskType;
2022-04-01 11:45:45 +00:00
int8_t explain;
2022-02-15 06:57:42 +00:00
uint32_t sqlLen; // the query sql,
uint32_t phyLen;
2021-12-24 07:00:51 +00:00
char msg[];
2021-12-23 09:42:40 +00:00
} SSubQueryMsg;
2021-12-19 08:27:50 +00:00
typedef struct {
SMsgHead header;
uint64_t sId;
uint64_t queryId;
uint64_t taskId;
} SSinkDataReq;
2022-01-12 10:40:22 +00:00
typedef struct {
SMsgHead header;
uint64_t sId;
uint64_t queryId;
uint64_t taskId;
} SQueryContinueReq;
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-31 05:34:38 +00:00
SMsgHead header;
2021-12-27 10:42:33 +00:00
uint64_t sId;
2021-12-24 07:00:51 +00:00
uint64_t queryId;
uint64_t taskId;
2022-01-10 12:44:11 +00:00
} SResReadyReq;
2021-12-19 08:27:50 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-24 01:41:09 +00:00
int32_t code;
} SResReadyRsp;
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-31 05:34:38 +00:00
SMsgHead header;
2021-12-27 10:42:33 +00:00
uint64_t sId;
2021-12-24 07:00:51 +00:00
uint64_t queryId;
uint64_t taskId;
2022-01-10 12:44:11 +00:00
} SResFetchReq;
2021-12-19 08:27:50 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-31 11:31:35 +00:00
SMsgHead header;
2021-12-27 10:42:33 +00:00
uint64_t sId;
2022-01-10 12:44:11 +00:00
} SSchTasksStatusReq;
2021-12-20 10:48:15 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-24 07:00:51 +00:00
uint64_t queryId;
uint64_t taskId;
2022-03-09 08:13:46 +00:00
int64_t refId;
2021-12-24 07:00:51 +00:00
int8_t status;
2021-12-21 10:28:28 +00:00
} STaskStatus;
2022-01-10 12:44:11 +00:00
typedef struct {
2022-03-16 10:29:31 +00:00
int64_t refId;
SArray* taskStatus; // SArray<STaskStatus>
2021-12-21 10:28:28 +00:00
} SSchedulerStatusRsp;
2022-03-09 08:13:46 +00:00
typedef struct {
uint64_t queryId;
uint64_t taskId;
int8_t action;
} STaskAction;
typedef struct SQueryNodeEpId {
int32_t nodeId; // vgId or qnodeId
SEp ep;
} SQueryNodeEpId;
typedef struct {
SMsgHead header;
uint64_t sId;
SQueryNodeEpId epId;
2022-03-16 10:29:31 +00:00
SArray* taskAction; // SArray<STaskAction>
2022-03-09 08:13:46 +00:00
} SSchedulerHbReq;
2022-03-16 10:29:31 +00:00
int32_t tSerializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq);
int32_t tDeserializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq);
void tFreeSSchedulerHbReq(SSchedulerHbReq* pReq);
2022-03-09 08:13:46 +00:00
typedef struct {
SQueryNodeEpId epId;
2022-03-16 10:29:31 +00:00
SArray* taskStatus; // SArray<STaskStatus>
2022-03-09 08:13:46 +00:00
} SSchedulerHbRsp;
2022-03-16 10:29:31 +00:00
int32_t tSerializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp);
int32_t tDeserializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp);
void tFreeSSchedulerHbRsp(SSchedulerHbRsp* pRsp);
2022-03-09 08:13:46 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-31 11:31:35 +00:00
SMsgHead header;
2021-12-27 10:42:33 +00:00
uint64_t sId;
2021-12-24 07:00:51 +00:00
uint64_t queryId;
uint64_t taskId;
2022-03-09 08:13:46 +00:00
int64_t refId;
2022-01-10 12:44:11 +00:00
} STaskCancelReq;
2021-12-23 09:42:40 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-24 01:41:09 +00:00
int32_t code;
} STaskCancelRsp;
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-31 11:31:35 +00:00
SMsgHead header;
2021-12-27 10:42:33 +00:00
uint64_t sId;
2021-12-24 07:00:51 +00:00
uint64_t queryId;
uint64_t taskId;
2022-03-09 08:13:46 +00:00
int64_t refId;
2022-01-10 12:44:11 +00:00
} STaskDropReq;
2021-12-21 10:28:28 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-24 01:41:09 +00:00
int32_t code;
} STaskDropRsp;
2022-04-16 05:15:14 +00:00
#define STREAM_TRIGGER_AT_ONCE 1
#define STREAM_TRIGGER_WINDOW_CLOSE 2
2021-12-28 09:01:09 +00:00
typedef struct {
2022-04-28 06:20:32 +00:00
char name[TSDB_TABLE_FNAME_LEN];
char sourceDB[TSDB_DB_FNAME_LEN];
char targetStbFullName[TSDB_TABLE_FNAME_LEN];
int8_t igExists;
char* sql;
char* ast;
int8_t triggerType;
2022-04-16 05:15:14 +00:00
int64_t watermark;
2022-03-10 09:15:45 +00:00
} SCMCreateStreamReq;
2021-12-28 09:01:09 +00:00
2022-03-10 09:15:45 +00:00
typedef struct {
int64_t streamId;
} SCMCreateStreamRsp;
int32_t tSerializeSCMCreateStreamReq(void* buf, int32_t bufLen, const SCMCreateStreamReq* pReq);
int32_t tDeserializeSCMCreateStreamReq(void* buf, int32_t bufLen, SCMCreateStreamReq* pReq);
void tFreeSCMCreateStreamReq(SCMCreateStreamReq* pReq);
2022-03-14 12:32:19 +00:00
typedef struct {
char name[TSDB_TOPIC_FNAME_LEN];
int64_t streamId;
char* sql;
char* executorMsg;
} SMVCreateStreamReq, SMSCreateStreamReq;
typedef struct {
int64_t streamId;
} SMVCreateStreamRsp, SMSCreateStreamRsp;
2022-03-10 09:15:45 +00:00
typedef struct {
2022-04-24 05:42:54 +00:00
char name[TSDB_TOPIC_FNAME_LEN]; // accout.topic
int8_t igExists;
int8_t withTbName;
int8_t withSchema;
int8_t withTag;
char* sql;
char* ast;
char subscribeDbName[TSDB_DB_NAME_LEN];
2022-03-10 09:15:45 +00:00
} SCMCreateTopicReq;
int32_t tSerializeSCMCreateTopicReq(void* buf, int32_t bufLen, const SCMCreateTopicReq* pReq);
int32_t tDeserializeSCMCreateTopicReq(void* buf, int32_t bufLen, SCMCreateTopicReq* pReq);
void tFreeSCMCreateTopicReq(SCMCreateTopicReq* pReq);
2021-12-29 09:53:43 +00:00
typedef struct {
int64_t topicId;
2022-03-10 09:15:45 +00:00
} SCMCreateTopicRsp;
2021-12-29 09:53:43 +00:00
2022-03-10 09:15:45 +00:00
int32_t tSerializeSCMCreateTopicRsp(void* buf, int32_t bufLen, const SCMCreateTopicRsp* pRsp);
int32_t tDeserializeSCMCreateTopicRsp(void* buf, int32_t bufLen, SCMCreateTopicRsp* pRsp);
2021-12-29 09:53:43 +00:00
typedef struct {
int64_t consumerId;
2022-04-27 09:15:02 +00:00
} SMqConsumerLostMsg, SMqConsumerRecoverMsg;
2021-12-29 09:53:43 +00:00
typedef struct {
int64_t consumerId;
char cgroup[TSDB_CGROUP_LEN];
2022-04-25 13:48:52 +00:00
SArray* topicNames; // SArray<char**>
2021-12-29 09:53:43 +00:00
} SCMSubscribeReq;
2022-02-28 09:39:07 +00:00
static FORCE_INLINE int32_t tSerializeSCMSubscribeReq(void** buf, const SCMSubscribeReq* pReq) {
int32_t tlen = 0;
2021-12-29 09:53:43 +00:00
tlen += taosEncodeFixedI64(buf, pReq->consumerId);
tlen += taosEncodeString(buf, pReq->cgroup);
2022-01-06 10:17:08 +00:00
2022-04-25 02:42:17 +00:00
int32_t topicNum = taosArrayGetSize(pReq->topicNames);
tlen += taosEncodeFixedI32(buf, topicNum);
for (int32_t i = 0; i < topicNum; i++) {
2022-01-06 10:17:08 +00:00
tlen += taosEncodeString(buf, (char*)taosArrayGetP(pReq->topicNames, i));
2022-01-04 02:40:34 +00:00
}
2021-12-29 09:53:43 +00:00
return tlen;
}
static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq* pReq) {
buf = taosDecodeFixedI64(buf, &pReq->consumerId);
buf = taosDecodeStringTo(buf, pReq->cgroup);
2022-04-25 02:42:17 +00:00
int32_t topicNum;
buf = taosDecodeFixedI32(buf, &topicNum);
pReq->topicNames = taosArrayInit(topicNum, sizeof(void*));
for (int32_t i = 0; i < topicNum; i++) {
2022-02-11 08:24:38 +00:00
char* name;
2022-01-06 10:17:08 +00:00
buf = taosDecodeString(buf, &name);
taosArrayPush(pReq->topicNames, &name);
2022-01-04 02:40:34 +00:00
}
2021-12-28 09:01:09 +00:00
return buf;
}
2022-01-04 02:40:34 +00:00
typedef struct SMqSubTopic {
2021-12-29 09:53:43 +00:00
int32_t vgId;
2022-01-04 02:40:34 +00:00
int64_t topicId;
SEpSet epSet;
} SMqSubTopic;
typedef struct {
2022-01-07 02:36:42 +00:00
int32_t topicNum;
2022-01-04 02:40:34 +00:00
SMqSubTopic topics[];
2021-12-29 09:53:43 +00:00
} SCMSubscribeRsp;
2022-02-28 09:39:07 +00:00
static FORCE_INLINE int32_t tSerializeSCMSubscribeRsp(void** buf, const SCMSubscribeRsp* pRsp) {
int32_t tlen = 0;
2022-01-04 02:40:34 +00:00
tlen += taosEncodeFixedI32(buf, pRsp->topicNum);
2022-02-28 09:39:07 +00:00
for (int32_t i = 0; i < pRsp->topicNum; i++) {
2022-01-04 02:40:34 +00:00
tlen += taosEncodeFixedI32(buf, pRsp->topics[i].vgId);
tlen += taosEncodeFixedI64(buf, pRsp->topics[i].topicId);
tlen += taosEncodeSEpSet(buf, &pRsp->topics[i].epSet);
}
2021-12-29 09:53:43 +00:00
return tlen;
}
static FORCE_INLINE void* tDeserializeSCMSubscribeRsp(void* buf, SCMSubscribeRsp* pRsp) {
2022-01-04 02:40:34 +00:00
buf = taosDecodeFixedI32(buf, &pRsp->topicNum);
2022-02-28 09:39:07 +00:00
for (int32_t i = 0; i < pRsp->topicNum; i++) {
2022-01-04 02:40:34 +00:00
buf = taosDecodeFixedI32(buf, &pRsp->topics[i].vgId);
buf = taosDecodeFixedI64(buf, &pRsp->topics[i].topicId);
buf = taosDecodeSEpSet(buf, &pRsp->topics[i].epSet);
}
2021-12-29 09:53:43 +00:00
return buf;
}
typedef struct {
int64_t topicId;
int64_t consumerId;
int64_t consumerGroupId;
int64_t offset;
2022-01-04 02:40:34 +00:00
char* sql;
char* logicalPlan;
char* physicalPlan;
2021-12-29 09:53:43 +00:00
} SMVSubscribeReq;
2022-02-28 09:39:07 +00:00
static FORCE_INLINE int32_t tSerializeSMVSubscribeReq(void** buf, SMVSubscribeReq* pReq) {
int32_t tlen = 0;
2022-01-04 02:40:34 +00:00
tlen += taosEncodeFixedI64(buf, pReq->topicId);
tlen += taosEncodeFixedI64(buf, pReq->consumerId);
tlen += taosEncodeFixedI64(buf, pReq->consumerGroupId);
tlen += taosEncodeFixedI64(buf, pReq->offset);
tlen += taosEncodeString(buf, pReq->sql);
tlen += taosEncodeString(buf, pReq->logicalPlan);
tlen += taosEncodeString(buf, pReq->physicalPlan);
return tlen;
}
static FORCE_INLINE void* tDeserializeSMVSubscribeReq(void* buf, SMVSubscribeReq* pReq) {
buf = taosDecodeFixedI64(buf, &pReq->topicId);
buf = taosDecodeFixedI64(buf, &pReq->consumerId);
buf = taosDecodeFixedI64(buf, &pReq->consumerGroupId);
buf = taosDecodeFixedI64(buf, &pReq->offset);
buf = taosDecodeString(buf, &pReq->sql);
buf = taosDecodeString(buf, &pReq->logicalPlan);
buf = taosDecodeString(buf, &pReq->physicalPlan);
return buf;
}
2022-02-10 03:22:50 +00:00
typedef struct {
char key[TSDB_SUBSCRIBE_KEY_LEN];
SArray* lostConsumers; // SArray<int64_t>
SArray* removedConsumers; // SArray<int64_t>
SArray* newConsumers; // SArray<int64_t>
2022-04-29 13:01:13 +00:00
} SMqRebInfo;
2022-02-11 08:24:38 +00:00
2022-04-29 13:01:13 +00:00
static FORCE_INLINE SMqRebInfo* tNewSMqRebSubscribe(const char* key) {
SMqRebInfo* pRebInfo = (SMqRebInfo*)taosMemoryCalloc(1, sizeof(SMqRebInfo));
if (pRebInfo == NULL) {
2022-05-10 09:12:11 +00:00
return NULL;
2022-02-11 08:24:38 +00:00
}
2022-04-29 13:01:13 +00:00
strcpy(pRebInfo->key, key);
pRebInfo->lostConsumers = taosArrayInit(0, sizeof(int64_t));
if (pRebInfo->lostConsumers == NULL) {
2022-02-11 08:24:38 +00:00
goto _err;
}
2022-04-29 13:01:13 +00:00
pRebInfo->removedConsumers = taosArrayInit(0, sizeof(int64_t));
if (pRebInfo->removedConsumers == NULL) {
2022-02-11 08:24:38 +00:00
goto _err;
}
2022-04-29 13:01:13 +00:00
pRebInfo->newConsumers = taosArrayInit(0, sizeof(int64_t));
if (pRebInfo->newConsumers == NULL) {
2022-02-11 08:24:38 +00:00
goto _err;
}
2022-04-29 13:01:13 +00:00
return pRebInfo;
2022-02-11 08:24:38 +00:00
_err:
2022-04-29 13:01:13 +00:00
taosArrayDestroy(pRebInfo->lostConsumers);
taosArrayDestroy(pRebInfo->removedConsumers);
taosArrayDestroy(pRebInfo->newConsumers);
taosMemoryFreeClear(pRebInfo);
2022-02-11 08:24:38 +00:00
return NULL;
}
2022-02-16 06:36:19 +00:00
// this message is sent from mnode to mnode(read thread to write thread), so there is no need for serialization or
2022-02-15 06:57:42 +00:00
// deserialization
2022-02-11 08:24:38 +00:00
typedef struct {
2022-02-15 06:57:42 +00:00
SHashObj* rebSubHash; // SHashObj<key, SMqRebSubscribe>
2022-02-10 03:22:50 +00:00
} SMqDoRebalanceMsg;
2021-12-29 09:53:43 +00:00
typedef struct {
2022-01-04 02:40:34 +00:00
int64_t status;
2021-12-29 09:53:43 +00:00
} SMVSubscribeRsp;
2021-12-23 12:28:08 +00:00
typedef struct {
char name[TSDB_TABLE_FNAME_LEN];
int8_t igNotExists;
2022-02-16 02:25:14 +00:00
} SMDropTopicReq;
2022-02-16 12:18:18 +00:00
int32_t tSerializeSMDropTopicReq(void* buf, int32_t bufLen, SMDropTopicReq* pReq);
2022-02-16 02:25:14 +00:00
int32_t tDeserializeSMDropTopicReq(void* buf, int32_t bufLen, SMDropTopicReq* pReq);
2021-12-23 12:28:08 +00:00
typedef struct {
char name[TSDB_TABLE_FNAME_LEN];
int8_t alterType;
SSchema schema;
2022-01-10 12:44:11 +00:00
} SAlterTopicReq;
2021-12-23 12:28:08 +00:00
typedef struct {
SMsgHead head;
char name[TSDB_TABLE_FNAME_LEN];
2022-02-23 08:04:06 +00:00
int64_t tuid;
2021-12-23 12:28:08 +00:00
int32_t sverson;
int32_t execLen;
char* executor;
int32_t sqlLen;
char* sql;
2022-01-10 12:44:11 +00:00
} SDCreateTopicReq;
2021-12-23 12:28:08 +00:00
typedef struct {
SMsgHead head;
char name[TSDB_TABLE_FNAME_LEN];
2022-02-23 08:04:06 +00:00
int64_t tuid;
2022-01-10 12:44:11 +00:00
} SDDropTopicReq;
2021-11-04 01:28:55 +00:00
2022-03-22 23:58:07 +00:00
typedef struct {
float xFilesFactor;
int32_t delay;
int32_t qmsg1Len;
int32_t qmsg2Len;
char* qmsg1; // pAst1:qmsg1:SRetention1 => trigger aggr task1
char* qmsg2; // pAst2:qmsg2:SRetention2 => trigger aggr task2
2022-03-22 23:58:07 +00:00
} SRSmaParam;
2022-05-07 10:03:06 +00:00
int32_t tEncodeSRSmaParam(SEncoder* pCoder, const SRSmaParam* pRSmaParam);
int32_t tDecodeSRSmaParam(SDecoder* pCoder, SRSmaParam* pRSmaParam);
2022-04-20 08:50:45 +00:00
2022-04-28 04:09:31 +00:00
// TDMT_VND_CREATE_STB ==============
2022-04-20 08:50:45 +00:00
typedef struct SVCreateStbReq {
2022-04-22 12:34:37 +00:00
const char* name;
tb_uid_t suid;
int8_t rollup;
SSchemaWrapper schema;
SSchemaWrapper schemaTag;
SRSmaParam pRSmaParam;
2022-04-20 08:50:45 +00:00
} SVCreateStbReq;
2022-05-07 10:03:06 +00:00
int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq);
int tDecodeSVCreateStbReq(SDecoder* pCoder, SVCreateStbReq* pReq);
2022-04-20 08:50:45 +00:00
2022-04-28 04:09:31 +00:00
// TDMT_VND_DROP_STB ==============
2022-04-21 14:01:58 +00:00
typedef struct SVDropStbReq {
2022-04-28 04:09:31 +00:00
const char* name;
tb_uid_t suid;
2022-04-21 14:01:58 +00:00
} SVDropStbReq;
2022-05-07 10:03:06 +00:00
int32_t tEncodeSVDropStbReq(SEncoder* pCoder, const SVDropStbReq* pReq);
int32_t tDecodeSVDropStbReq(SDecoder* pCoder, SVDropStbReq* pReq);
2022-04-20 08:50:45 +00:00
2022-05-06 13:06:10 +00:00
#define TD_CREATE_IF_NOT_EXISTS 0x1
2021-12-25 06:35:39 +00:00
typedef struct SVCreateTbReq {
2022-05-06 13:06:10 +00:00
int32_t flags;
2022-04-22 07:01:48 +00:00
tb_uid_t uid;
int64_t ctime;
const char* name;
int32_t ttl;
int8_t type;
2022-03-22 23:58:07 +00:00
union {
struct {
2022-05-07 06:57:31 +00:00
tb_uid_t suid;
const uint8_t* pTag;
2022-04-22 07:01:48 +00:00
} ctb;
2021-12-25 06:35:39 +00:00
struct {
2022-04-22 12:34:37 +00:00
SSchemaWrapper schema;
2022-04-22 07:01:48 +00:00
} ntb;
2021-12-25 06:35:39 +00:00
};
2022-04-22 08:23:55 +00:00
} SVCreateTbReq;
2022-04-22 07:01:48 +00:00
2022-05-07 10:03:06 +00:00
int tEncodeSVCreateTbReq(SEncoder* pCoder, const SVCreateTbReq* pReq);
int tDecodeSVCreateTbReq(SDecoder* pCoder, SVCreateTbReq* pReq);
2022-04-22 07:01:48 +00:00
2021-12-31 03:39:51 +00:00
typedef struct {
2022-04-22 08:23:55 +00:00
int32_t nReqs;
union {
SVCreateTbReq* pReqs;
SArray* pArray;
};
2021-12-31 03:39:51 +00:00
} SVCreateTbBatchReq;
2021-12-25 06:35:39 +00:00
2022-05-07 10:03:06 +00:00
int tEncodeSVCreateTbBatchReq(SEncoder* pCoder, const SVCreateTbBatchReq* pReq);
int tDecodeSVCreateTbBatchReq(SDecoder* pCoder, SVCreateTbBatchReq* pReq);
2021-12-25 06:35:39 +00:00
2021-12-31 03:39:51 +00:00
typedef struct {
2022-03-11 10:21:28 +00:00
int32_t code;
2022-02-08 09:44:58 +00:00
} SVCreateTbRsp, SVUpdateTbRsp;
2021-12-25 06:35:39 +00:00
2022-05-07 10:03:06 +00:00
int tEncodeSVCreateTbRsp(SEncoder* pCoder, const SVCreateTbRsp* pRsp);
int tDecodeSVCreateTbRsp(SDecoder* pCoder, SVCreateTbRsp* pRsp);
2022-04-23 10:50:26 +00:00
2022-02-08 09:44:58 +00:00
int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq);
void* tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pReq);
2021-12-25 06:35:39 +00:00
2021-12-31 03:39:51 +00:00
typedef struct {
2022-04-23 10:50:26 +00:00
int32_t nRsps;
union {
SVCreateTbRsp* pRsps;
SArray* pArray;
};
2022-02-08 09:44:58 +00:00
} SVCreateTbBatchRsp;
2021-12-25 06:35:39 +00:00
2022-05-07 10:03:06 +00:00
int tEncodeSVCreateTbBatchRsp(SEncoder* pCoder, const SVCreateTbBatchRsp* pRsp);
int tDecodeSVCreateTbBatchRsp(SDecoder* pCoder, SVCreateTbBatchRsp* pRsp);
2022-04-23 10:50:26 +00:00
2022-03-23 02:44:32 +00:00
int32_t tSerializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
2022-01-10 12:44:11 +00:00
2022-04-28 04:09:31 +00:00
// TDMT_VND_DROP_TABLE =================
2022-01-10 12:44:11 +00:00
typedef struct {
2022-04-28 04:09:31 +00:00
const char* name;
2022-04-29 07:05:37 +00:00
int8_t igNotExists;
2022-01-10 12:44:11 +00:00
} SVDropTbReq;
typedef struct {
2022-04-28 04:09:31 +00:00
int32_t code;
2022-01-10 12:44:11 +00:00
} SVDropTbRsp;
2022-04-28 04:09:31 +00:00
typedef struct {
int32_t nReqs;
union {
SVDropTbReq* pReqs;
SArray* pArray;
};
} SVDropTbBatchReq;
2022-05-07 10:03:06 +00:00
int32_t tEncodeSVDropTbBatchReq(SEncoder* pCoder, const SVDropTbBatchReq* pReq);
int32_t tDecodeSVDropTbBatchReq(SDecoder* pCoder, SVDropTbBatchReq* pReq);
2022-04-28 04:09:31 +00:00
typedef struct {
int32_t nRsps;
union {
SVDropTbRsp* pRsps;
SArray* pArray;
};
} SVDropTbBatchRsp;
2022-05-07 10:03:06 +00:00
int32_t tEncodeSVDropTbBatchRsp(SEncoder* pCoder, const SVDropTbBatchRsp* pRsp);
int32_t tDecodeSVDropTbBatchRsp(SDecoder* pCoder, SVDropTbBatchRsp* pRsp);
2022-01-28 02:54:50 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
SMsgHead head;
int64_t uid;
int32_t tid;
int16_t tversion;
int16_t colId;
int8_t type;
int16_t bytes;
int32_t tagValLen;
int16_t numOfTags;
int32_t schemaLen;
char data[];
} SUpdateTagValReq;
typedef struct {
SMsgHead head;
} SUpdateTagValRsp;
typedef struct {
2021-12-29 07:47:45 +00:00
SMsgHead head;
} SVShowTablesReq;
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-29 07:47:45 +00:00
SMsgHead head;
2021-12-29 15:07:01 +00:00
int32_t id;
2021-12-29 07:47:45 +00:00
} SVShowTablesFetchReq;
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-29 07:47:45 +00:00
int64_t useconds;
int8_t completed; // all results are returned to client
int8_t precision;
int8_t compressed;
int32_t compLen;
int32_t numOfRows;
char data[];
} SVShowTablesFetchRsp;
2022-04-26 09:08:42 +00:00
typedef struct {
2022-01-25 07:17:02 +00:00
int64_t consumerId;
int32_t epoch;
2022-03-07 09:53:02 +00:00
char cgroup[TSDB_CGROUP_LEN];
2022-04-26 09:08:42 +00:00
} SMqAskEpReq;
2022-01-19 09:35:06 +00:00
typedef struct {
2022-01-25 10:29:26 +00:00
int32_t key;
2022-01-19 09:35:06 +00:00
int32_t valueLen;
void* value;
} SKv;
typedef struct {
2022-04-12 11:10:52 +00:00
int64_t tscRid;
2022-04-14 11:54:59 +00:00
int8_t connType;
2022-01-19 09:35:06 +00:00
} SClientHbKey;
typedef struct {
2022-04-12 11:10:52 +00:00
int64_t tid;
int32_t status;
} SQuerySubDesc;
typedef struct {
char sql[TSDB_SHOW_SQL_LEN];
uint64_t queryId;
int64_t useconds;
int64_t stime;
int64_t reqRid;
int32_t pid;
char fqdn[TSDB_FQDN_LEN];
int32_t subPlanNum;
SArray* subDesc; // SArray<SQuerySubDesc>
2022-04-12 11:10:52 +00:00
} SQueryDesc;
typedef struct {
uint32_t connId;
int32_t pid;
char app[TSDB_APP_NAME_LEN];
SArray* queryDesc; // SArray<SQueryDesc>
2022-04-12 11:10:52 +00:00
} SQueryHbReqBasic;
typedef struct {
uint32_t connId;
uint64_t killRid;
int32_t totalDnodes;
int32_t onlineDnodes;
int8_t killConnection;
int8_t align[3];
SEpSet epSet;
} SQueryHbRspBasic;
typedef struct {
SClientHbKey connKey;
SQueryHbReqBasic* query;
SHashObj* info; // hash<Skv.key, Skv>
2022-01-19 09:35:06 +00:00
} SClientHbReq;
typedef struct {
int64_t reqId;
SArray* reqs; // SArray<SClientHbReq>
} SClientHbBatchReq;
typedef struct {
2022-04-12 11:10:52 +00:00
SClientHbKey connKey;
int32_t status;
SQueryHbRspBasic* query;
SArray* info; // Array<Skv>
2022-01-19 09:35:06 +00:00
} SClientHbRsp;
typedef struct {
int64_t reqId;
int64_t rspId;
SArray* rsps; // SArray<SClientHbRsp>
} SClientHbBatchRsp;
2022-02-15 06:57:42 +00:00
static FORCE_INLINE uint32_t hbKeyHashFunc(const char* key, uint32_t keyLen) { return taosIntHash_64(key, keyLen); }
2022-01-19 09:35:06 +00:00
2022-02-15 06:57:42 +00:00
static FORCE_INLINE void tFreeReqKvHash(SHashObj* info) {
void* pIter = taosHashIterate(info, NULL);
2022-01-26 09:42:31 +00:00
while (pIter != NULL) {
SKv* kv = (SKv*)pIter;
2022-03-25 16:29:53 +00:00
taosMemoryFreeClear(kv->value);
2022-01-26 09:42:31 +00:00
pIter = taosHashIterate(info, pIter);
}
}
2022-04-12 11:10:52 +00:00
static FORCE_INLINE void tFreeClientHbQueryDesc(void* pDesc) {
SQueryDesc* desc = (SQueryDesc*)pDesc;
if (desc->subDesc) {
taosArrayDestroy(desc->subDesc);
desc->subDesc = NULL;
}
}
2022-02-15 06:57:42 +00:00
static FORCE_INLINE void tFreeClientHbReq(void* pReq) {
2022-01-19 09:35:06 +00:00
SClientHbReq* req = (SClientHbReq*)pReq;
2022-04-12 11:10:52 +00:00
if (req->query) {
if (req->query->queryDesc) {
taosArrayDestroyEx(req->query->queryDesc, tFreeClientHbQueryDesc);
}
taosMemoryFreeClear(req->query);
}
2022-01-26 09:42:31 +00:00
if (req->info) {
tFreeReqKvHash(req->info);
taosHashCleanup(req->info);
}
2022-01-19 09:35:06 +00:00
}
2022-02-14 07:27:38 +00:00
int32_t tSerializeSClientHbBatchReq(void* buf, int32_t bufLen, const SClientHbBatchReq* pReq);
int32_t tDeserializeSClientHbBatchReq(void* buf, int32_t bufLen, SClientHbBatchReq* pReq);
2022-01-19 09:35:06 +00:00
static FORCE_INLINE void tFreeClientHbBatchReq(void* pReq, bool deep) {
2022-02-15 06:57:42 +00:00
SClientHbBatchReq* req = (SClientHbBatchReq*)pReq;
2022-01-19 09:35:06 +00:00
if (deep) {
taosArrayDestroyEx(req->reqs, tFreeClientHbReq);
} else {
taosArrayDestroy(req->reqs);
}
2022-03-25 16:29:53 +00:00
taosMemoryFree(pReq);
2022-01-19 09:35:06 +00:00
}
2022-02-15 06:57:42 +00:00
static FORCE_INLINE void tFreeClientKv(void* pKv) {
SKv* kv = (SKv*)pKv;
2022-01-26 09:42:31 +00:00
if (kv) {
2022-03-25 16:29:53 +00:00
taosMemoryFreeClear(kv->value);
2022-01-26 09:42:31 +00:00
}
}
2022-02-15 06:57:42 +00:00
static FORCE_INLINE void tFreeClientHbRsp(void* pRsp) {
2022-01-26 09:42:31 +00:00
SClientHbRsp* rsp = (SClientHbRsp*)pRsp;
2022-04-12 11:10:52 +00:00
taosMemoryFreeClear(rsp->query);
2022-01-26 09:42:31 +00:00
if (rsp->info) taosArrayDestroyEx(rsp->info, tFreeClientKv);
}
static FORCE_INLINE void tFreeClientHbBatchRsp(void* pRsp) {
2022-02-15 06:57:42 +00:00
SClientHbBatchRsp* rsp = (SClientHbBatchRsp*)pRsp;
2022-01-26 09:42:31 +00:00
taosArrayDestroyEx(rsp->rsps, tFreeClientHbRsp);
}
2022-02-14 07:27:38 +00:00
int32_t tSerializeSClientHbBatchRsp(void* buf, int32_t bufLen, const SClientHbBatchRsp* pBatchRsp);
int32_t tDeserializeSClientHbBatchRsp(void* buf, int32_t bufLen, SClientHbBatchRsp* pBatchRsp);
2022-01-19 09:35:06 +00:00
2022-05-07 10:03:06 +00:00
static FORCE_INLINE int32_t tEncodeSKv(SEncoder* pEncoder, const SKv* pKv) {
2022-02-14 07:27:38 +00:00
if (tEncodeI32(pEncoder, pKv->key) < 0) return -1;
if (tEncodeI32(pEncoder, pKv->valueLen) < 0) return -1;
2022-05-07 10:13:55 +00:00
if (tEncodeBinary(pEncoder, (uint8_t*)pKv->value, pKv->valueLen) < 0) return -1;
2022-02-14 07:27:38 +00:00
return 0;
2022-01-19 09:35:06 +00:00
}
2022-05-07 10:03:06 +00:00
static FORCE_INLINE int32_t tDecodeSKv(SDecoder* pDecoder, SKv* pKv) {
2022-02-14 07:27:38 +00:00
if (tDecodeI32(pDecoder, &pKv->key) < 0) return -1;
if (tDecodeI32(pDecoder, &pKv->valueLen) < 0) return -1;
2022-03-25 16:29:53 +00:00
pKv->value = taosMemoryMalloc(pKv->valueLen + 1);
2022-02-14 07:27:38 +00:00
if (pKv->value == NULL) return -1;
if (tDecodeCStrTo(pDecoder, (char*)pKv->value) < 0) return -1;
return 0;
2022-01-19 09:35:06 +00:00
}
2022-05-07 10:03:06 +00:00
static FORCE_INLINE int32_t tEncodeSClientHbKey(SEncoder* pEncoder, const SClientHbKey* pKey) {
2022-04-12 11:10:52 +00:00
if (tEncodeI64(pEncoder, pKey->tscRid) < 0) return -1;
2022-04-14 11:54:59 +00:00
if (tEncodeI8(pEncoder, pKey->connType) < 0) return -1;
2022-02-14 07:27:38 +00:00
return 0;
2022-01-19 09:35:06 +00:00
}
2022-05-07 10:03:06 +00:00
static FORCE_INLINE int32_t tDecodeSClientHbKey(SDecoder* pDecoder, SClientHbKey* pKey) {
2022-04-12 11:10:52 +00:00
if (tDecodeI64(pDecoder, &pKey->tscRid) < 0) return -1;
2022-04-14 11:54:59 +00:00
if (tDecodeI8(pDecoder, &pKey->connType) < 0) return -1;
2022-02-14 07:27:38 +00:00
return 0;
2022-01-19 09:35:06 +00:00
}
typedef struct SMqHbVgInfo {
int32_t vgId;
} SMqHbVgInfo;
2022-02-28 09:39:07 +00:00
static FORCE_INLINE int32_t taosEncodeSMqVgInfo(void** buf, const SMqHbVgInfo* pVgInfo) {
int32_t tlen = 0;
2022-01-19 09:35:06 +00:00
tlen += taosEncodeFixedI32(buf, pVgInfo->vgId);
return tlen;
}
static FORCE_INLINE void* taosDecodeSMqVgInfo(void* buf, SMqHbVgInfo* pVgInfo) {
buf = taosDecodeFixedI32(buf, &pVgInfo->vgId);
return buf;
}
typedef struct SMqHbTopicInfo {
int32_t epoch;
int64_t topicUid;
char name[TSDB_TOPIC_FNAME_LEN];
SArray* pVgInfo;
} SMqHbTopicInfo;
2022-02-28 09:39:07 +00:00
static FORCE_INLINE int32_t taosEncodeSMqHbTopicInfoMsg(void** buf, const SMqHbTopicInfo* pTopicInfo) {
int32_t tlen = 0;
2022-01-19 09:35:06 +00:00
tlen += taosEncodeFixedI32(buf, pTopicInfo->epoch);
tlen += taosEncodeFixedI64(buf, pTopicInfo->topicUid);
tlen += taosEncodeString(buf, pTopicInfo->name);
int32_t sz = taosArrayGetSize(pTopicInfo->pVgInfo);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
SMqHbVgInfo* pVgInfo = (SMqHbVgInfo*)taosArrayGet(pTopicInfo->pVgInfo, i);
tlen += taosEncodeSMqVgInfo(buf, pVgInfo);
}
return tlen;
}
static FORCE_INLINE void* taosDecodeSMqHbTopicInfoMsg(void* buf, SMqHbTopicInfo* pTopicInfo) {
buf = taosDecodeFixedI32(buf, &pTopicInfo->epoch);
buf = taosDecodeFixedI64(buf, &pTopicInfo->topicUid);
buf = taosDecodeStringTo(buf, pTopicInfo->name);
int32_t sz;
buf = taosDecodeFixedI32(buf, &sz);
pTopicInfo->pVgInfo = taosArrayInit(sz, sizeof(SMqHbVgInfo));
for (int32_t i = 0; i < sz; i++) {
SMqHbVgInfo vgInfo;
buf = taosDecodeSMqVgInfo(buf, &vgInfo);
taosArrayPush(pTopicInfo->pVgInfo, &vgInfo);
}
return buf;
}
typedef struct SMqHbMsg {
2022-02-15 06:57:42 +00:00
int32_t status; // ask hb endpoint
int32_t epoch;
int64_t consumerId;
SArray* pTopics; // SArray<SMqHbTopicInfo>
2022-01-19 09:35:06 +00:00
} SMqHbMsg;
2022-02-28 09:39:07 +00:00
static FORCE_INLINE int32_t taosEncodeSMqMsg(void** buf, const SMqHbMsg* pMsg) {
int32_t tlen = 0;
2022-01-19 09:35:06 +00:00
tlen += taosEncodeFixedI32(buf, pMsg->status);
tlen += taosEncodeFixedI32(buf, pMsg->epoch);
tlen += taosEncodeFixedI64(buf, pMsg->consumerId);
int32_t sz = taosArrayGetSize(pMsg->pTopics);
tlen += taosEncodeFixedI32(buf, sz);
2022-02-28 09:39:07 +00:00
for (int32_t i = 0; i < sz; i++) {
2022-01-19 09:35:06 +00:00
SMqHbTopicInfo* topicInfo = (SMqHbTopicInfo*)taosArrayGet(pMsg->pTopics, i);
tlen += taosEncodeSMqHbTopicInfoMsg(buf, topicInfo);
}
return tlen;
}
static FORCE_INLINE void* taosDecodeSMqMsg(void* buf, SMqHbMsg* pMsg) {
buf = taosDecodeFixedI32(buf, &pMsg->status);
buf = taosDecodeFixedI32(buf, &pMsg->epoch);
buf = taosDecodeFixedI64(buf, &pMsg->consumerId);
int32_t sz;
buf = taosDecodeFixedI32(buf, &sz);
pMsg->pTopics = taosArrayInit(sz, sizeof(SMqHbTopicInfo));
2022-02-28 09:39:07 +00:00
for (int32_t i = 0; i < sz; i++) {
2022-01-19 09:35:06 +00:00
SMqHbTopicInfo topicInfo;
buf = taosDecodeSMqHbTopicInfoMsg(buf, &topicInfo);
taosArrayPush(pMsg->pTopics, &topicInfo);
}
return buf;
}
2022-04-21 08:37:55 +00:00
enum {
TOPIC_SUB_TYPE__DB = 1,
TOPIC_SUB_TYPE__TABLE,
};
typedef struct {
int64_t leftForVer;
int32_t vgId;
int64_t oldConsumerId;
int64_t newConsumerId;
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
2022-04-21 08:37:55 +00:00
int8_t subType;
int8_t withTbName;
int8_t withSchema;
int8_t withTag;
char* qmsg;
} SMqRebVgReq;
static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pReq) {
int32_t tlen = 0;
tlen += taosEncodeFixedI64(buf, pReq->leftForVer);
tlen += taosEncodeFixedI32(buf, pReq->vgId);
tlen += taosEncodeFixedI64(buf, pReq->oldConsumerId);
tlen += taosEncodeFixedI64(buf, pReq->newConsumerId);
tlen += taosEncodeString(buf, pReq->subKey);
2022-04-21 08:37:55 +00:00
tlen += taosEncodeFixedI8(buf, pReq->subType);
tlen += taosEncodeFixedI8(buf, pReq->withTbName);
tlen += taosEncodeFixedI8(buf, pReq->withSchema);
tlen += taosEncodeFixedI8(buf, pReq->withTag);
if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
tlen += taosEncodeString(buf, pReq->qmsg);
}
return tlen;
}
static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq) {
buf = taosDecodeFixedI64(buf, &pReq->leftForVer);
buf = taosDecodeFixedI32(buf, &pReq->vgId);
buf = taosDecodeFixedI64(buf, &pReq->oldConsumerId);
buf = taosDecodeFixedI64(buf, &pReq->newConsumerId);
buf = taosDecodeStringTo(buf, pReq->subKey);
2022-04-21 08:37:55 +00:00
buf = taosDecodeFixedI8(buf, &pReq->subType);
buf = taosDecodeFixedI8(buf, &pReq->withTbName);
buf = taosDecodeFixedI8(buf, &pReq->withSchema);
buf = taosDecodeFixedI8(buf, &pReq->withTag);
if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
buf = taosDecodeString(buf, &pReq->qmsg);
}
return (void*)buf;
}
typedef struct {
int8_t reserved;
} SMqRebVgRsp;
2022-02-11 10:09:25 +00:00
typedef struct {
2022-02-15 06:57:42 +00:00
int64_t leftForVer;
int32_t vgId;
2022-04-07 06:11:16 +00:00
int32_t epoch;
2022-02-15 06:57:42 +00:00
int64_t consumerId;
char topicName[TSDB_TOPIC_FNAME_LEN];
2022-03-07 09:53:02 +00:00
char cgroup[TSDB_CGROUP_LEN];
2022-02-15 06:57:42 +00:00
char* sql;
char* physicalPlan;
char* qmsg;
2022-01-19 09:35:06 +00:00
} SMqSetCVgReq;
static FORCE_INLINE int32_t tEncodeSMqSetCVgReq(void** buf, const SMqSetCVgReq* pReq) {
int32_t tlen = 0;
2022-01-28 20:45:01 +00:00
tlen += taosEncodeFixedI64(buf, pReq->leftForVer);
2022-01-19 09:35:06 +00:00
tlen += taosEncodeFixedI32(buf, pReq->vgId);
2022-04-07 06:11:16 +00:00
tlen += taosEncodeFixedI32(buf, pReq->epoch);
2022-02-12 06:19:12 +00:00
tlen += taosEncodeFixedI64(buf, pReq->consumerId);
2022-01-19 09:35:06 +00:00
tlen += taosEncodeString(buf, pReq->topicName);
2022-01-20 10:09:28 +00:00
tlen += taosEncodeString(buf, pReq->cgroup);
2022-01-19 09:35:06 +00:00
tlen += taosEncodeString(buf, pReq->sql);
tlen += taosEncodeString(buf, pReq->physicalPlan);
2022-01-28 20:45:01 +00:00
tlen += taosEncodeString(buf, pReq->qmsg);
2022-01-19 09:35:06 +00:00
return tlen;
}
static FORCE_INLINE void* tDecodeSMqSetCVgReq(void* buf, SMqSetCVgReq* pReq) {
2022-01-28 20:45:01 +00:00
buf = taosDecodeFixedI64(buf, &pReq->leftForVer);
2022-01-19 09:35:06 +00:00
buf = taosDecodeFixedI32(buf, &pReq->vgId);
2022-04-07 06:11:16 +00:00
buf = taosDecodeFixedI32(buf, &pReq->epoch);
2022-02-12 06:19:12 +00:00
buf = taosDecodeFixedI64(buf, &pReq->consumerId);
2022-01-19 09:35:06 +00:00
buf = taosDecodeStringTo(buf, pReq->topicName);
2022-01-20 10:09:28 +00:00
buf = taosDecodeStringTo(buf, pReq->cgroup);
2022-01-19 09:35:06 +00:00
buf = taosDecodeString(buf, &pReq->sql);
buf = taosDecodeString(buf, &pReq->physicalPlan);
2022-01-28 20:45:01 +00:00
buf = taosDecodeString(buf, &pReq->qmsg);
2022-01-19 09:35:06 +00:00
return buf;
}
2022-02-17 11:07:39 +00:00
typedef struct {
int32_t vgId;
int64_t offset;
char topicName[TSDB_TOPIC_FNAME_LEN];
2022-03-07 09:53:02 +00:00
char cgroup[TSDB_CGROUP_LEN];
2022-02-17 11:07:39 +00:00
} SMqOffset;
typedef struct {
int32_t num;
SMqOffset* offsets;
2022-02-23 08:04:06 +00:00
} SMqCMCommitOffsetReq;
2022-02-17 11:07:39 +00:00
typedef struct {
int32_t reserved;
2022-02-23 08:04:06 +00:00
} SMqCMCommitOffsetRsp;
2022-02-17 11:07:39 +00:00
2022-05-07 10:03:06 +00:00
int32_t tEncodeSMqOffset(SEncoder* encoder, const SMqOffset* pOffset);
int32_t tDecodeSMqOffset(SDecoder* decoder, SMqOffset* pOffset);
int32_t tEncodeSMqCMCommitOffsetReq(SEncoder* encoder, const SMqCMCommitOffsetReq* pReq);
int32_t tDecodeSMqCMCommitOffsetReq(SDecoder* decoder, SMqCMCommitOffsetReq* pReq);
2022-02-17 11:07:39 +00:00
2022-04-25 07:40:25 +00:00
static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* pSchemaWrapper) {
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
if (pSW == NULL) return pSW;
pSW->nCols = pSchemaWrapper->nCols;
pSW->sver = pSchemaWrapper->sver;
2022-04-25 07:40:25 +00:00
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
if (pSW->pSchema == NULL) {
taosMemoryFree(pSW);
return NULL;
}
memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
return pSW;
}
static FORCE_INLINE void tDeleteSSchemaWrapper(SSchemaWrapper* pSchemaWrapper) {
taosMemoryFree(pSchemaWrapper->pSchema);
taosMemoryFree(pSchemaWrapper);
}
2022-02-15 07:24:27 +00:00
static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) {
2022-01-26 09:03:29 +00:00
int32_t tlen = 0;
tlen += taosEncodeFixedI8(buf, pSchema->type);
2022-04-18 13:23:22 +00:00
tlen += taosEncodeFixedI8(buf, pSchema->flags);
2022-01-26 09:03:29 +00:00
tlen += taosEncodeFixedI32(buf, pSchema->bytes);
tlen += taosEncodeFixedI16(buf, pSchema->colId);
2022-01-26 09:03:29 +00:00
tlen += taosEncodeString(buf, pSchema->name);
return tlen;
}
2022-04-25 07:40:25 +00:00
static FORCE_INLINE void* taosDecodeSSchema(const void* buf, SSchema* pSchema) {
2022-01-26 09:03:29 +00:00
buf = taosDecodeFixedI8(buf, &pSchema->type);
2022-04-18 13:23:22 +00:00
buf = taosDecodeFixedI8(buf, &pSchema->flags);
2022-01-26 09:03:29 +00:00
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
buf = taosDecodeFixedI16(buf, &pSchema->colId);
2022-01-26 09:03:29 +00:00
buf = taosDecodeStringTo(buf, pSchema->name);
2022-04-25 07:40:25 +00:00
return (void*)buf;
2022-01-26 09:03:29 +00:00
}
2022-05-07 10:03:06 +00:00
static FORCE_INLINE int32_t tEncodeSSchema(SEncoder* pEncoder, const SSchema* pSchema) {
2022-02-15 07:24:27 +00:00
if (tEncodeI8(pEncoder, pSchema->type) < 0) return -1;
2022-04-18 13:23:22 +00:00
if (tEncodeI8(pEncoder, pSchema->flags) < 0) return -1;
2022-04-23 13:45:26 +00:00
if (tEncodeI32v(pEncoder, pSchema->bytes) < 0) return -1;
if (tEncodeI16v(pEncoder, pSchema->colId) < 0) return -1;
2022-02-15 07:24:27 +00:00
if (tEncodeCStr(pEncoder, pSchema->name) < 0) return -1;
return 0;
}
2022-05-07 10:03:06 +00:00
static FORCE_INLINE int32_t tDecodeSSchema(SDecoder* pDecoder, SSchema* pSchema) {
2022-02-15 07:24:27 +00:00
if (tDecodeI8(pDecoder, &pSchema->type) < 0) return -1;
2022-04-18 13:23:22 +00:00
if (tDecodeI8(pDecoder, &pSchema->flags) < 0) return -1;
2022-04-23 13:45:26 +00:00
if (tDecodeI32v(pDecoder, &pSchema->bytes) < 0) return -1;
if (tDecodeI16v(pDecoder, &pSchema->colId) < 0) return -1;
2022-02-15 07:24:27 +00:00
if (tDecodeCStrTo(pDecoder, pSchema->name) < 0) return -1;
return 0;
}
2022-03-26 08:48:14 +00:00
static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWrapper* pSW) {
2022-01-26 09:03:29 +00:00
int32_t tlen = 0;
2022-04-22 12:34:37 +00:00
tlen += taosEncodeVariantI32(buf, pSW->nCols);
tlen += taosEncodeVariantI32(buf, pSW->sver);
2022-02-15 06:57:42 +00:00
for (int32_t i = 0; i < pSW->nCols; i++) {
2022-02-15 07:24:27 +00:00
tlen += taosEncodeSSchema(buf, &pSW->pSchema[i]);
2022-01-26 09:03:29 +00:00
}
return tlen;
}
2022-04-25 07:40:25 +00:00
static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapper* pSW) {
2022-04-22 12:34:37 +00:00
buf = taosDecodeVariantI32(buf, &pSW->nCols);
buf = taosDecodeVariantI32(buf, &pSW->sver);
2022-03-25 16:29:53 +00:00
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
2022-01-26 09:03:29 +00:00
if (pSW->pSchema == NULL) {
return NULL;
}
2022-02-15 06:57:42 +00:00
for (int32_t i = 0; i < pSW->nCols; i++) {
2022-02-15 07:24:27 +00:00
buf = taosDecodeSSchema(buf, &pSW->pSchema[i]);
2022-01-26 09:03:29 +00:00
}
2022-04-25 07:40:25 +00:00
return (void*)buf;
2022-01-26 09:03:29 +00:00
}
2022-03-23 05:50:53 +00:00
2022-05-07 10:03:06 +00:00
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSchemaWrapper* pSW) {
2022-04-22 12:34:37 +00:00
if (tEncodeI32v(pEncoder, pSW->nCols) < 0) return -1;
if (tEncodeI32v(pEncoder, pSW->sver) < 0) return -1;
2022-03-26 08:48:14 +00:00
for (int32_t i = 0; i < pSW->nCols; i++) {
if (tEncodeSSchema(pEncoder, &pSW->pSchema[i]) < 0) return -1;
}
2022-04-22 12:34:37 +00:00
return 0;
2022-03-26 08:48:14 +00:00
}
2022-05-07 10:03:06 +00:00
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWrapper* pSW) {
2022-04-22 12:34:37 +00:00
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
if (tDecodeI32v(pDecoder, &pSW->sver) < 0) return -1;
2022-05-05 10:57:09 +00:00
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
2022-04-22 12:34:37 +00:00
if (pSW->pSchema == NULL) return -1;
2022-03-26 08:48:14 +00:00
for (int32_t i = 0; i < pSW->nCols; i++) {
if (tDecodeSSchema(pDecoder, &pSW->pSchema[i]) < 0) return -1;
}
2022-04-22 12:34:37 +00:00
2022-03-26 08:48:14 +00:00
return 0;
}
2022-03-23 05:50:53 +00:00
typedef struct {
char name[TSDB_TABLE_FNAME_LEN];
char stb[TSDB_TABLE_FNAME_LEN];
int8_t igExists;
int8_t intervalUnit;
int8_t slidingUnit;
int8_t timezone;
2022-03-23 09:53:00 +00:00
int32_t dstVgId; // for stream
2022-03-23 05:50:53 +00:00
int64_t interval;
int64_t offset;
int64_t sliding;
2022-03-23 09:53:00 +00:00
int32_t exprLen; // strlen + 1
int32_t tagsFilterLen; // strlen + 1
int32_t sqlLen; // strlen + 1
int32_t astLen; // strlen + 1
2022-03-24 08:18:08 +00:00
char* expr;
2022-03-23 05:50:53 +00:00
char* tagsFilter;
2022-03-23 09:53:00 +00:00
char* sql;
char* ast;
2022-03-23 05:50:53 +00:00
} SMCreateSmaReq;
int32_t tSerializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
int32_t tDeserializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
void tFreeSMCreateSmaReq(SMCreateSmaReq* pReq);
typedef struct {
char name[TSDB_TABLE_FNAME_LEN];
int8_t igNotExists;
} SMDropSmaReq;
int32_t tSerializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
int32_t tDeserializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
typedef struct {
2022-03-18 08:26:32 +00:00
int8_t version; // for compatibility(default 0)
int8_t intervalUnit; // MACRO: TIME_UNIT_XXX
int8_t slidingUnit; // MACRO: TIME_UNIT_XXX
2022-03-24 08:18:08 +00:00
int8_t timezoneInt; // sma data expired if timezone changes.
2022-03-11 11:38:13 +00:00
char indexName[TSDB_INDEX_NAME_LEN];
2022-03-15 08:00:09 +00:00
int32_t exprLen;
int32_t tagsFilterLen;
2022-03-11 11:38:13 +00:00
int64_t indexUid;
tb_uid_t tableUid; // super/child/common table uid
int64_t interval;
2022-03-18 08:26:32 +00:00
int64_t offset; // use unit by precision of DB
2022-03-11 11:38:13 +00:00
int64_t sliding;
char* expr; // sma expression
char* tagsFilter;
2022-03-10 07:34:15 +00:00
} STSma; // Time-range-wise SMA
typedef struct {
2022-03-07 12:14:01 +00:00
int64_t ver; // use a general definition
STSma tSma;
} SVCreateTSmaReq;
typedef struct {
2022-03-21 06:43:08 +00:00
int8_t type; // 0 status report, 1 update data
int64_t indexUid;
int64_t skey; // start TS key of interval/sliding window
2022-03-07 12:14:01 +00:00
} STSmaMsg;
typedef struct {
int64_t ver; // use a general definition
2022-03-21 06:43:08 +00:00
int64_t indexUid;
2022-03-10 07:34:15 +00:00
char indexName[TSDB_INDEX_NAME_LEN];
2022-03-07 12:14:01 +00:00
} SVDropTSmaReq;
2022-03-07 12:14:01 +00:00
typedef struct {
2022-03-16 10:29:31 +00:00
int tmp; // TODO: to avoid compile error
2022-03-07 12:14:01 +00:00
} SVCreateTSmaRsp, SVDropTSmaRsp;
int32_t tSerializeSVCreateTSmaReq(void** buf, SVCreateTSmaReq* pReq);
void* tDeserializeSVCreateTSmaReq(void* buf, SVCreateTSmaReq* pReq);
int32_t tSerializeSVDropTSmaReq(void** buf, SVDropTSmaReq* pReq);
void* tDeserializeSVDropTSmaReq(void* buf, SVDropTSmaReq* pReq);
2022-03-07 12:14:01 +00:00
// RSma: Rollup SMA
typedef struct {
int64_t interval;
int32_t retention; // unit: day
uint16_t days; // unit: day
int8_t intervalUnit;
} SSmaParams;
typedef struct {
STSma tsma;
float xFilesFactor;
SArray* smaParams; // SSmaParams
} SRSma;
typedef struct {
uint32_t number;
STSma* tSma;
} STSmaWrapper;
2022-03-07 10:27:31 +00:00
static FORCE_INLINE void tdDestroyTSma(STSma* pSma) {
if (pSma) {
2022-03-25 16:29:53 +00:00
taosMemoryFreeClear(pSma->expr);
taosMemoryFreeClear(pSma->tagsFilter);
}
}
2022-03-07 10:27:31 +00:00
static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
if (pSW) {
if (pSW->tSma) {
for (uint32_t i = 0; i < pSW->number; ++i) {
2022-03-07 10:27:31 +00:00
tdDestroyTSma(pSW->tSma + i);
}
2022-03-25 16:29:53 +00:00
taosMemoryFreeClear(pSW->tSma);
}
}
}
2022-04-21 07:58:52 +00:00
static FORCE_INLINE void* tdFreeTSmaWrapper(STSmaWrapper* pSW) {
2022-03-24 23:50:28 +00:00
tdDestroyTSmaWrapper(pSW);
2022-04-21 07:58:52 +00:00
taosMemoryFree(pSW);
return NULL;
2022-03-24 23:50:28 +00:00
}
static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
int32_t tlen = 0;
2022-03-11 11:38:13 +00:00
tlen += taosEncodeFixedI8(buf, pSma->version);
tlen += taosEncodeFixedI8(buf, pSma->intervalUnit);
tlen += taosEncodeFixedI8(buf, pSma->slidingUnit);
2022-03-23 08:45:59 +00:00
tlen += taosEncodeFixedI8(buf, pSma->timezoneInt);
tlen += taosEncodeString(buf, pSma->indexName);
2022-03-15 08:00:09 +00:00
tlen += taosEncodeFixedI32(buf, pSma->exprLen);
tlen += taosEncodeFixedI32(buf, pSma->tagsFilterLen);
2022-03-11 11:38:13 +00:00
tlen += taosEncodeFixedI64(buf, pSma->indexUid);
2022-03-10 07:34:15 +00:00
tlen += taosEncodeFixedI64(buf, pSma->tableUid);
tlen += taosEncodeFixedI64(buf, pSma->interval);
2022-03-15 08:00:09 +00:00
tlen += taosEncodeFixedI64(buf, pSma->offset);
tlen += taosEncodeFixedI64(buf, pSma->sliding);
2022-03-16 10:29:31 +00:00
2022-03-11 11:38:13 +00:00
if (pSma->exprLen > 0) {
tlen += taosEncodeString(buf, pSma->expr);
}
2022-03-10 07:34:15 +00:00
if (pSma->tagsFilterLen > 0) {
tlen += taosEncodeString(buf, pSma->tagsFilter);
}
return tlen;
}
static FORCE_INLINE int32_t tEncodeTSmaWrapper(void** buf, const STSmaWrapper* pSW) {
int32_t tlen = 0;
tlen += taosEncodeFixedU32(buf, pSW->number);
for (uint32_t i = 0; i < pSW->number; ++i) {
tlen += tEncodeTSma(buf, pSW->tSma + i);
}
return tlen;
}
static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) {
2022-03-11 11:38:13 +00:00
buf = taosDecodeFixedI8(buf, &pSma->version);
buf = taosDecodeFixedI8(buf, &pSma->intervalUnit);
buf = taosDecodeFixedI8(buf, &pSma->slidingUnit);
2022-03-23 08:45:59 +00:00
buf = taosDecodeFixedI8(buf, &pSma->timezoneInt);
buf = taosDecodeStringTo(buf, pSma->indexName);
2022-03-15 08:00:09 +00:00
buf = taosDecodeFixedI32(buf, &pSma->exprLen);
buf = taosDecodeFixedI32(buf, &pSma->tagsFilterLen);
2022-03-11 11:38:13 +00:00
buf = taosDecodeFixedI64(buf, &pSma->indexUid);
2022-03-10 07:34:15 +00:00
buf = taosDecodeFixedI64(buf, &pSma->tableUid);
buf = taosDecodeFixedI64(buf, &pSma->interval);
2022-03-15 08:00:09 +00:00
buf = taosDecodeFixedI64(buf, &pSma->offset);
buf = taosDecodeFixedI64(buf, &pSma->sliding);
2022-03-11 11:38:13 +00:00
if (pSma->exprLen > 0) {
if ((buf = taosDecodeString(buf, &pSma->expr)) == NULL) {
2022-03-10 07:34:15 +00:00
tdDestroyTSma(pSma);
return NULL;
}
} else {
2022-03-11 11:38:13 +00:00
pSma->expr = NULL;
}
2022-03-10 07:34:15 +00:00
if (pSma->tagsFilterLen > 0) {
if ((buf = taosDecodeString(buf, &pSma->tagsFilter)) == NULL) {
2022-03-10 07:34:15 +00:00
tdDestroyTSma(pSma);
return NULL;
}
} else {
2022-03-10 07:34:15 +00:00
pSma->tagsFilter = NULL;
}
return buf;
}
static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) {
buf = taosDecodeFixedU32(buf, &pSW->number);
2022-03-25 16:29:53 +00:00
pSW->tSma = (STSma*)taosMemoryCalloc(pSW->number, sizeof(STSma));
if (pSW->tSma == NULL) {
return NULL;
}
for (uint32_t i = 0; i < pSW->number; ++i) {
if ((buf = tDecodeTSma(buf, pSW->tSma + i)) == NULL) {
for (uint32_t j = i; j >= 0; --i) {
2022-03-07 10:27:31 +00:00
tdDestroyTSma(pSW->tSma + j);
}
2022-03-25 16:29:53 +00:00
taosMemoryFree(pSW->tSma);
return NULL;
}
}
return buf;
}
2022-01-21 15:19:54 +00:00
2022-04-07 09:41:16 +00:00
typedef struct {
2022-04-07 13:32:30 +00:00
int idx;
2022-04-07 09:41:16 +00:00
} SMCreateFullTextReq;
int32_t tSerializeSMCreateFullTextReq(void* buf, int32_t bufLen, SMCreateFullTextReq* pReq);
int32_t tDeserializeSMCreateFullTextReq(void* buf, int32_t bufLen, SMCreateFullTextReq* pReq);
void tFreeSMCreateFullTextReq(SMCreateFullTextReq* pReq);
2022-04-07 14:04:38 +00:00
typedef struct {
char name[TSDB_TABLE_FNAME_LEN];
int8_t igNotExists;
} SMDropFullTextReq;
int32_t tSerializeSMDropFullTextReq(void* buf, int32_t bufLen, SMDropFullTextReq* pReq);
int32_t tDeserializeSMDropFullTextReq(void* buf, int32_t bufLen, SMDropFullTextReq* pReq);
2022-04-08 10:34:11 +00:00
typedef struct {
char indexFName[TSDB_INDEX_FNAME_LEN];
} SUserIndexReq;
int32_t tSerializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq);
int32_t tDeserializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq);
typedef struct {
char dbFName[TSDB_DB_FNAME_LEN];
char tblFName[TSDB_TABLE_FNAME_LEN];
char colName[TSDB_COL_NAME_LEN];
char indexType[TSDB_INDEX_TYPE_LEN];
char indexExts[TSDB_INDEX_EXTS_LEN];
} SUserIndexRsp;
int32_t tSerializeSUserIndexRsp(void* buf, int32_t bufLen, const SUserIndexRsp* pRsp);
int32_t tDeserializeSUserIndexRsp(void* buf, int32_t bufLen, SUserIndexRsp* pRsp);
2022-02-28 12:46:23 +00:00
typedef struct {
int8_t mqMsgType;
int32_t code;
int32_t epoch;
2022-03-21 13:39:16 +00:00
int64_t consumerId;
2022-02-28 12:46:23 +00:00
} SMqRspHead;
2022-04-20 13:36:55 +00:00
typedef struct {
SMsgHead head;
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
int32_t epoch;
uint64_t reqId;
int64_t consumerId;
int64_t waitTime;
2022-04-20 13:36:55 +00:00
int64_t currentOffset;
2022-04-26 13:50:36 +00:00
} SMqPollReq;
2022-01-24 02:46:55 +00:00
2022-02-10 03:22:50 +00:00
typedef struct {
2022-01-25 07:17:02 +00:00
int32_t vgId;
2022-02-23 08:04:06 +00:00
int64_t offset;
2022-01-25 07:17:02 +00:00
SEpSet epSet;
} SMqSubVgEp;
2022-02-10 03:22:50 +00:00
typedef struct {
2022-04-13 12:37:51 +00:00
char topic[TSDB_TOPIC_FNAME_LEN];
int8_t isSchemaAdaptive;
SArray* vgs; // SArray<SMqSubVgEp>
SSchemaWrapper schema;
2022-01-25 07:17:02 +00:00
} SMqSubTopicEp;
2022-04-20 13:36:55 +00:00
typedef struct {
SMqRspHead head;
int64_t reqOffset;
int64_t rspOffset;
int32_t skipLogNum;
int32_t blockNum;
int8_t withTbName;
int8_t withSchema;
int8_t withTag;
SArray* blockDataLen; // SArray<int32_t>
SArray* blockData; // SArray<SRetrieveTableRsp*>
SArray* blockTbName; // SArray<char*>
SArray* blockSchema; // SArray<SSchemaWrapper>
SArray* blockTags; // SArray<kvrow>
SArray* blockTagSchema; // SArray<kvrow>
} SMqDataBlkRsp;
static FORCE_INLINE int32_t tEncodeSMqDataBlkRsp(void** buf, const SMqDataBlkRsp* pRsp) {
int32_t tlen = 0;
tlen += taosEncodeFixedI64(buf, pRsp->reqOffset);
tlen += taosEncodeFixedI64(buf, pRsp->rspOffset);
tlen += taosEncodeFixedI32(buf, pRsp->skipLogNum);
tlen += taosEncodeFixedI32(buf, pRsp->blockNum);
if (pRsp->blockNum != 0) {
tlen += taosEncodeFixedI8(buf, pRsp->withTbName);
tlen += taosEncodeFixedI8(buf, pRsp->withSchema);
tlen += taosEncodeFixedI8(buf, pRsp->withTag);
for (int32_t i = 0; i < pRsp->blockNum; i++) {
int32_t bLen = *(int32_t*)taosArrayGet(pRsp->blockDataLen, i);
void* data = taosArrayGetP(pRsp->blockData, i);
tlen += taosEncodeFixedI32(buf, bLen);
tlen += taosEncodeBinary(buf, data, bLen);
2022-04-25 07:40:25 +00:00
if (pRsp->withSchema) {
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(pRsp->blockSchema, i);
tlen += taosEncodeSSchemaWrapper(buf, pSW);
}
2022-04-20 13:36:55 +00:00
}
}
return tlen;
}
static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* pRsp) {
buf = taosDecodeFixedI64(buf, &pRsp->reqOffset);
buf = taosDecodeFixedI64(buf, &pRsp->rspOffset);
buf = taosDecodeFixedI32(buf, &pRsp->skipLogNum);
buf = taosDecodeFixedI32(buf, &pRsp->blockNum);
pRsp->blockData = taosArrayInit(pRsp->blockNum, sizeof(void*));
pRsp->blockDataLen = taosArrayInit(pRsp->blockNum, sizeof(void*));
2022-04-25 07:40:25 +00:00
pRsp->blockSchema = taosArrayInit(pRsp->blockNum, sizeof(void*));
2022-04-20 13:36:55 +00:00
if (pRsp->blockNum != 0) {
buf = taosDecodeFixedI8(buf, &pRsp->withTbName);
buf = taosDecodeFixedI8(buf, &pRsp->withSchema);
buf = taosDecodeFixedI8(buf, &pRsp->withTag);
for (int32_t i = 0; i < pRsp->blockNum; i++) {
int32_t bLen = 0;
void* data = NULL;
buf = taosDecodeFixedI32(buf, &bLen);
buf = taosDecodeBinary(buf, &data, bLen);
taosArrayPush(pRsp->blockDataLen, &bLen);
taosArrayPush(pRsp->blockData, &data);
2022-04-25 07:40:25 +00:00
if (pRsp->withSchema) {
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
buf = taosDecodeSSchemaWrapper(buf, pSW);
taosArrayPush(pRsp->blockSchema, &pSW);
}
2022-04-20 13:36:55 +00:00
}
}
return (void*)buf;
}
2022-03-17 09:48:21 +00:00
typedef struct {
2022-02-28 12:46:23 +00:00
SMqRspHead head;
2022-03-21 13:39:16 +00:00
char cgroup[TSDB_CGROUP_LEN];
SArray* topics; // SArray<SMqSubTopicEp>
2022-04-26 09:08:42 +00:00
} SMqAskEpRsp;
2022-03-17 09:48:21 +00:00
static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) {
2022-04-20 13:36:55 +00:00
// taosMemoryFree(pSubTopicEp->schema.pSchema);
taosArrayDestroy(pSubTopicEp->vgs);
}
2022-01-28 11:10:18 +00:00
2022-01-25 07:17:02 +00:00
static FORCE_INLINE int32_t tEncodeSMqSubVgEp(void** buf, const SMqSubVgEp* pVgEp) {
int32_t tlen = 0;
2022-01-26 01:56:32 +00:00
tlen += taosEncodeFixedI32(buf, pVgEp->vgId);
2022-02-23 08:04:06 +00:00
tlen += taosEncodeFixedI64(buf, pVgEp->offset);
2022-01-25 07:17:02 +00:00
tlen += taosEncodeSEpSet(buf, &pVgEp->epSet);
return tlen;
}
static FORCE_INLINE void* tDecodeSMqSubVgEp(void* buf, SMqSubVgEp* pVgEp) {
buf = taosDecodeFixedI32(buf, &pVgEp->vgId);
2022-02-23 08:04:06 +00:00
buf = taosDecodeFixedI64(buf, &pVgEp->offset);
2022-01-25 07:17:02 +00:00
buf = taosDecodeSEpSet(buf, &pVgEp->epSet);
return buf;
}
static FORCE_INLINE int32_t tEncodeSMqSubTopicEp(void** buf, const SMqSubTopicEp* pTopicEp) {
int32_t tlen = 0;
tlen += taosEncodeString(buf, pTopicEp->topic);
2022-03-29 07:24:25 +00:00
tlen += taosEncodeFixedI8(buf, pTopicEp->isSchemaAdaptive);
2022-01-25 07:17:02 +00:00
int32_t sz = taosArrayGetSize(pTopicEp->vgs);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
SMqSubVgEp* pVgEp = (SMqSubVgEp*)taosArrayGet(pTopicEp->vgs, i);
tlen += tEncodeSMqSubVgEp(buf, pVgEp);
}
2022-04-13 12:37:51 +00:00
tlen += taosEncodeSSchemaWrapper(buf, &pTopicEp->schema);
2022-01-25 07:17:02 +00:00
return tlen;
}
static FORCE_INLINE void* tDecodeSMqSubTopicEp(void* buf, SMqSubTopicEp* pTopicEp) {
buf = taosDecodeStringTo(buf, pTopicEp->topic);
2022-03-29 07:24:25 +00:00
buf = taosDecodeFixedI8(buf, &pTopicEp->isSchemaAdaptive);
2022-01-25 07:17:02 +00:00
int32_t sz;
buf = taosDecodeFixedI32(buf, &sz);
pTopicEp->vgs = taosArrayInit(sz, sizeof(SMqSubVgEp));
if (pTopicEp->vgs == NULL) {
return NULL;
}
for (int32_t i = 0; i < sz; i++) {
SMqSubVgEp vgEp;
buf = tDecodeSMqSubVgEp(buf, &vgEp);
taosArrayPush(pTopicEp->vgs, &vgEp);
}
2022-04-13 12:37:51 +00:00
buf = taosDecodeSSchemaWrapper(buf, &pTopicEp->schema);
2022-01-25 07:17:02 +00:00
return buf;
}
2022-04-26 09:08:42 +00:00
static FORCE_INLINE int32_t tEncodeSMqAskEpRsp(void** buf, const SMqAskEpRsp* pRsp) {
2022-01-25 07:17:02 +00:00
int32_t tlen = 0;
2022-03-21 13:39:16 +00:00
// tlen += taosEncodeString(buf, pRsp->cgroup);
2022-01-25 07:17:02 +00:00
int32_t sz = taosArrayGetSize(pRsp->topics);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
SMqSubTopicEp* pVgEp = (SMqSubTopicEp*)taosArrayGet(pRsp->topics, i);
tlen += tEncodeSMqSubTopicEp(buf, pVgEp);
}
return tlen;
}
2022-04-26 09:08:42 +00:00
static FORCE_INLINE void* tDecodeSMqAskEpRsp(void* buf, SMqAskEpRsp* pRsp) {
2022-03-21 13:39:16 +00:00
// buf = taosDecodeStringTo(buf, pRsp->cgroup);
2022-01-25 07:17:02 +00:00
int32_t sz;
buf = taosDecodeFixedI32(buf, &sz);
pRsp->topics = taosArrayInit(sz, sizeof(SMqSubTopicEp));
if (pRsp->topics == NULL) {
return NULL;
}
for (int32_t i = 0; i < sz; i++) {
SMqSubTopicEp topicEp;
buf = tDecodeSMqSubTopicEp(buf, &topicEp);
taosArrayPush(pRsp->topics, &topicEp);
}
return buf;
}
2022-04-21 09:51:33 +00:00
2022-04-26 09:08:42 +00:00
static FORCE_INLINE void tDeleteSMqAskEpRsp(SMqAskEpRsp* pRsp) {
taosArrayDestroyEx(pRsp->topics, (void (*)(void*))tDeleteSMqSubTopicEp);
}
2022-05-05 06:51:47 +00:00
#define TD_AUTO_CREATE_TABLE 0x1
typedef struct {
2022-05-07 06:57:31 +00:00
int64_t suid;
int64_t uid;
int32_t sver;
2022-05-07 07:29:54 +00:00
uint32_t nData;
2022-05-07 06:57:31 +00:00
const uint8_t* pData;
SVCreateTbReq cTbReq;
2022-05-05 06:51:47 +00:00
} SVSubmitBlk;
typedef struct {
int32_t flags;
int32_t nBlocks;
union {
SArray* pArray;
SVSubmitBlk* pBlocks;
};
} SVSubmitReq;
2022-05-07 10:03:06 +00:00
int32_t tEncodeSVSubmitReq(SEncoder* pCoder, const SVSubmitReq* pReq);
int32_t tDecodeSVSubmitReq(SDecoder* pCoder, SVSubmitReq* pReq);
2022-05-05 06:51:47 +00:00
2022-02-28 12:46:23 +00:00
#pragma pack(pop)
2021-10-08 05:53:49 +00:00
#ifdef __cplusplus
}
#endif
#endif /*_TD_COMMON_TAOS_MSG_H_*/