TDengine/include/common/tmsg.h

1538 lines
38 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_
#ifdef __cplusplus
extern "C" {
#endif
2021-12-28 12:25:38 +00:00
#include "encode.h"
2021-10-08 05:53:49 +00:00
#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"
2021-10-08 05:53:49 +00:00
#include "tdataformat.h"
2022-01-07 02:36:42 +00:00
#include "thash.h"
2021-12-29 09:20:10 +00:00
#include "tlist.h"
2021-10-08 05:53:49 +00:00
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"
2021-12-24 07:40:15 +00:00
extern char* tMsgInfo[];
2021-12-24 07:00:51 +00:00
extern int tMsgDict[];
#define TMSG_SEG_CODE(TYPE) (((TYPE)&0xff00) >> 8)
#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
#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
#define TSDB_IE_TYPE_NEW_VERSION 5
#define TSDB_IE_TYPE_DNODE_EXT 6
#define TSDB_IE_TYPE_DNODE_STATE 7
2022-01-14 02:48:05 +00:00
typedef enum {
HEARTBEAT_TYPE_MQ = 0,
HEARTBEAT_TYPE_QUERY = 1,
// types can be added here
//
HEARTBEAT_TYPE_MAX
} EHbType;
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_ACCT,
TSDB_MGMT_TABLE_USER,
TSDB_MGMT_TABLE_DB,
TSDB_MGMT_TABLE_TABLE,
TSDB_MGMT_TABLE_DNODE,
TSDB_MGMT_TABLE_MNODE,
2021-12-29 12:05:10 +00:00
TSDB_MGMT_TABLE_QNODE,
TSDB_MGMT_TABLE_SNODE,
TSDB_MGMT_TABLE_BNODE,
2021-10-08 05:53:49 +00:00
TSDB_MGMT_TABLE_VGROUP,
2021-12-10 07:20:04 +00:00
TSDB_MGMT_TABLE_STB,
2021-10-08 05:53:49 +00:00
TSDB_MGMT_TABLE_MODULE,
TSDB_MGMT_TABLE_QUERIES,
TSDB_MGMT_TABLE_STREAMS,
TSDB_MGMT_TABLE_VARIABLES,
TSDB_MGMT_TABLE_CONNS,
TSDB_MGMT_TABLE_SCORES,
TSDB_MGMT_TABLE_GRANTS,
TSDB_MGMT_TABLE_VNODES,
TSDB_MGMT_TABLE_CLUSTER,
2021-12-15 06:54:54 +00:00
TSDB_MGMT_TABLE_STREAMTABLES,
2021-10-08 05:53:49 +00:00
TSDB_MGMT_TABLE_TP,
TSDB_MGMT_TABLE_FUNCTION,
TSDB_MGMT_TABLE_MAX,
2021-12-02 11:56:43 +00:00
} EShowType;
2021-10-08 05:53:49 +00:00
2021-12-24 07:00:51 +00:00
#define TSDB_ALTER_TABLE_ADD_TAG_COLUMN 1
#define TSDB_ALTER_TABLE_DROP_TAG_COLUMN 2
2021-10-08 05:53:49 +00:00
#define TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN 3
2021-12-24 07:00:51 +00:00
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4
2021-10-08 05:53:49 +00:00
2021-12-24 07:00:51 +00:00
#define TSDB_ALTER_TABLE_ADD_COLUMN 5
#define TSDB_ALTER_TABLE_DROP_COLUMN 6
#define TSDB_ALTER_TABLE_CHANGE_COLUMN 7
2021-10-08 05:53:49 +00:00
#define TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN 8
2021-12-24 07:00:51 +00:00
#define TSDB_FILL_NONE 0
#define TSDB_FILL_NULL 1
#define TSDB_FILL_SET_VALUE 2
#define TSDB_FILL_LINEAR 3
#define TSDB_FILL_PREV 4
#define TSDB_FILL_NEXT 5
2021-10-08 05:53:49 +00:00
2021-12-24 07:00:51 +00:00
#define TSDB_ALTER_USER_PASSWD 0x1
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
2021-12-24 07:00:51 +00:00
#define TSDB_VN_READ_ACCCESS ((char)0x1)
#define TSDB_VN_WRITE_ACCCESS ((char)0x2)
2021-10-08 05:53:49 +00:00
#define TSDB_VN_ALL_ACCCESS (TSDB_VN_READ_ACCCESS | TSDB_VN_WRITE_ACCCESS)
2021-12-24 07:00:51 +00:00
#define TSDB_COL_NORMAL 0x0u // the normal column of the table
#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
2021-12-24 07:00:51 +00:00
#define TSDB_COL_IS_TAG(f) (((f & (~(TSDB_COL_NULL))) & TSDB_COL_TAG) != 0)
#define TSDB_COL_IS_NORMAL_COL(f) ((f & (~(TSDB_COL_NULL))) == TSDB_COL_NORMAL)
#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)
2021-10-08 05:53:49 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
2022-01-07 02:36:42 +00:00
int32_t keyLen;
int32_t valueLen;
void* key;
void* value;
2022-01-07 08:48:35 +00:00
} SKv;
2022-01-07 02:36:42 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
2022-01-07 06:57:45 +00:00
int32_t connId;
int32_t hbType;
} SClientHbKey;
2022-01-10 12:44:11 +00:00
typedef struct {
2022-01-07 06:57:45 +00:00
SClientHbKey connKey;
2022-01-14 07:54:07 +00:00
SHashObj* info; // hash<Skv.key, Skv>
2022-01-07 06:57:45 +00:00
} SClientHbReq;
2022-01-10 12:44:11 +00:00
typedef struct {
2022-01-07 06:57:45 +00:00
int64_t reqId;
SArray* reqs; // SArray<SClientHbReq>
} SClientHbBatchReq;
2022-01-10 12:44:11 +00:00
typedef struct {
2022-01-07 06:57:45 +00:00
SClientHbKey connKey;
int32_t status;
int32_t bodyLen;
void* body;
} SClientHbRsp;
2022-01-10 12:44:11 +00:00
typedef struct {
2022-01-07 06:57:45 +00:00
int64_t reqId;
int64_t rspId;
SArray* rsps; // SArray<SClientHbRsp>
} SClientHbBatchRsp;
static FORCE_INLINE uint32_t hbKeyHashFunc(const char* key, uint32_t keyLen) {
return taosIntHash_64(key, keyLen);
}
int tSerializeSClientHbReq(void** buf, const SClientHbReq* pReq);
2022-01-14 07:54:07 +00:00
void* tDeserializeSClientHbReq(void* buf, SClientHbReq* pReq);
int tSerializeSClientHbRsp(void** buf, const SClientHbRsp* pRsp);
void* tDeserializeSClientHbRsp(void* buf, SClientHbRsp* pRsp);
2022-01-07 08:48:35 +00:00
2022-01-07 06:57:45 +00:00
static FORCE_INLINE void tFreeClientHbReq(void *pReq) {
2022-01-07 08:48:35 +00:00
SClientHbReq* req = (SClientHbReq*)pReq;
2022-01-07 06:57:45 +00:00
taosHashCleanup(req->info);
free(pReq);
}
2022-01-07 08:48:35 +00:00
int tSerializeSClientHbBatchReq(void** buf, const SClientHbBatchReq* pReq);
2022-01-14 07:54:07 +00:00
void* tDeserializeSClientHbBatchReq(void* buf, SClientHbBatchReq* pReq);
2022-01-07 08:48:35 +00:00
static FORCE_INLINE void tFreeClientHbBatchReq(void* pReq) {
SClientHbBatchReq *req = (SClientHbBatchReq*)pReq;
2022-01-14 09:30:57 +00:00
//taosArrayDestroyEx(req->reqs, tFreeClientHbReq);
2022-01-07 08:48:35 +00:00
free(pReq);
}
2022-01-14 07:54:07 +00:00
int tSerializeSClientHbBatchRsp(void** buf, const SClientHbBatchRsp* pBatchRsp);
void* tDeserializeSClientHbBatchRsp(void* buf, SClientHbBatchRsp* pBatchRsp);
2022-01-07 08:48:35 +00:00
static FORCE_INLINE int taosEncodeSKv(void** buf, const SKv* pKv) {
2022-01-07 02:36:42 +00:00
int tlen = 0;
2022-01-07 08:48:35 +00:00
tlen += taosEncodeFixedI32(buf, pKv->keyLen);
tlen += taosEncodeFixedI32(buf, pKv->valueLen);
tlen += taosEncodeBinary(buf, pKv->key, pKv->keyLen);
tlen += taosEncodeBinary(buf, pKv->value, pKv->valueLen);
2022-01-07 02:36:42 +00:00
return tlen;
}
2022-01-07 08:48:35 +00:00
static FORCE_INLINE void* taosDecodeSKv(void* buf, SKv* pKv) {
buf = taosDecodeFixedI32(buf, &pKv->keyLen);
buf = taosDecodeFixedI32(buf, &pKv->valueLen);
buf = taosDecodeBinary(buf, &pKv->key, pKv->keyLen);
buf = taosDecodeBinary(buf, &pKv->value, pKv->valueLen);
2022-01-07 02:36:42 +00:00
return buf;
}
static FORCE_INLINE int taosEncodeSClientHbKey(void** buf, const SClientHbKey* pKey) {
int tlen = 0;
tlen += taosEncodeFixedI32(buf, pKey->connId);
tlen += taosEncodeFixedI32(buf, pKey->hbType);
return tlen;
}
static FORCE_INLINE void* taosDecodeSClientHbKey(void* buf, SClientHbKey* pKey) {
buf = taosDecodeFixedI32(buf, &pKey->connId);
buf = taosDecodeFixedI32(buf, &pKey->hbType);
return buf;
}
2022-01-17 11:56:33 +00:00
typedef struct SMqHbVgInfo {
int32_t vgId;
} SMqHbVgInfo;
static FORCE_INLINE int taosEncodeSMqVgInfo(void** buf, const SMqHbVgInfo* pVgInfo) {
int tlen = 0;
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;
static FORCE_INLINE int taosEncodeSMqHbTopicInfoMsg(void** buf, const SMqHbTopicInfo* pTopicInfo) {
int tlen = 0;
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 {
int32_t status; // ask hb endpoint
int32_t epoch;
int64_t consumerId;
SArray* pTopics; // SArray<SMqHbTopicInfo>
} SMqHbMsg;
static FORCE_INLINE int taosEncodeSMqMsg(void** buf, const SMqHbMsg* pMsg) {
int tlen = 0;
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);
for (int i = 0; i < sz; i++) {
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));
for (int i = 0; i < sz; i++) {
SMqHbTopicInfo topicInfo;
buf = taosDecodeSMqHbTopicInfoMsg(buf, &topicInfo);
taosArrayPush(pMsg->pTopics, &topicInfo);
}
return buf;
}
2022-01-14 02:48:05 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-16 09:05:13 +00:00
int32_t vgId;
2021-12-31 06:26:05 +00:00
char* dbName;
2021-12-24 07:40:15 +00:00
char* tableFullName;
2021-12-13 09:10:31 +00:00
} SBuildTableMetaInput;
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-15 01:52:37 +00:00
char db[TSDB_TABLE_FNAME_LEN];
int32_t vgVersion;
2021-12-15 01:52:37 +00:00
} SBuildUseDBInput;
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
typedef struct {
2021-12-17 12:58:45 +00:00
char fqdn[TSDB_FQDN_LEN];
2021-10-08 05:53:49 +00:00
uint16_t port;
2021-12-17 12:58:45 +00:00
} SEpAddr;
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;
int32_t vgId;
} SMsgHead;
// Submit message for one table
typedef struct SSubmitBlk {
uint64_t uid; // table unique id
int32_t tid; // table id
int32_t padding; // TODO just for padding here
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
char data[];
} 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[];
2021-10-08 05:53:49 +00:00
} SSubmitMsg;
2022-01-05 07:26:49 +00:00
typedef struct {
int32_t totalLen;
int32_t len;
SMemRow row;
} SSubmitBlkIter;
typedef struct {
int32_t totalLen;
int32_t len;
void* pMsg;
} SSubmitMsgIter;
2022-01-05 09:51:00 +00:00
int tInitSubmitMsgIter(SSubmitMsg* pMsg, SSubmitMsgIter* pIter);
int tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
int tInitSubmitBlkIter(SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
SMemRow tGetSubmitBlkNext(SSubmitBlkIter* pIter);
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
} SShellSubmitRspBlock;
typedef struct {
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;
SShellSubmitRspBlock failedBlocks[];
2022-01-10 12:44:11 +00:00
} SShellSubmitRsp;
2021-10-08 05:53:49 +00:00
typedef struct SSchema {
2021-12-09 10:53:09 +00:00
int8_t type;
2021-12-10 06:12:11 +00:00
int32_t colId;
int32_t bytes;
2021-12-09 10:53:09 +00:00
char name[TSDB_COL_NAME_LEN];
2021-10-08 05:53:49 +00:00
} SSchema;
typedef struct {
2021-12-10 07:20:04 +00:00
char name[TSDB_TABLE_FNAME_LEN];
int8_t igExists;
int32_t numOfTags;
int32_t numOfColumns;
SSchema pSchema[];
2022-01-10 12:44:11 +00:00
} SMCreateStbReq;
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
typedef struct {
char name[TSDB_TABLE_FNAME_LEN];
int8_t alterType;
SSchema schema;
2022-01-10 12:44:11 +00:00
} SMAlterStbReq;
2021-10-08 05:53:49 +00:00
typedef struct {
int32_t pid;
2021-12-03 06:36:41 +00:00
char app[TSDB_APP_NAME_LEN];
char db[TSDB_DB_NAME_LEN];
int64_t startTime;
2022-01-06 08:13:49 +00:00
} SConnectReq;
2021-10-08 05:53:49 +00:00
typedef struct SEpSet {
2021-12-06 08:19:12 +00:00
int8_t inUse;
int8_t numOfEps;
uint16_t port[TSDB_MAX_REPLICA];
char fqdn[TSDB_MAX_REPLICA][TSDB_FQDN_LEN];
2021-10-08 05:53:49 +00:00
} SEpSet;
2021-12-29 09:53:43 +00:00
static FORCE_INLINE int taosEncodeSEpSet(void** buf, const SEpSet* pEp) {
2022-01-04 02:40:34 +00:00
int tlen = 0;
tlen += taosEncodeFixedI8(buf, pEp->inUse);
tlen += taosEncodeFixedI8(buf, pEp->numOfEps);
for (int i = 0; i < TSDB_MAX_REPLICA; i++) {
tlen += taosEncodeFixedU16(buf, pEp->port[i]);
tlen += taosEncodeString(buf, pEp->fqdn[i]);
}
return tlen;
2021-12-29 09:53:43 +00:00
}
2022-01-04 02:40:34 +00:00
static FORCE_INLINE void* taosDecodeSEpSet(void* buf, SEpSet* pEp) {
buf = taosDecodeFixedI8(buf, &pEp->inUse);
buf = taosDecodeFixedI8(buf, &pEp->numOfEps);
for (int i = 0; i < TSDB_MAX_REPLICA; i++) {
buf = taosDecodeFixedU16(buf, &pEp->port[i]);
buf = taosDecodeStringTo(buf, pEp->fqdn[i]);
}
2021-12-29 09:53:43 +00:00
return buf;
}
2022-01-14 02:48:05 +00:00
typedef struct SMqHbRsp {
int8_t status; //idle or not
int8_t vnodeChanged;
int8_t epChanged; // should use new epset
int8_t reserved;
SEpSet epSet;
} SMqHbRsp;
static FORCE_INLINE int taosEncodeSMqHbRsp(void** buf, const SMqHbRsp* pRsp) {
int tlen = 0;
tlen += taosEncodeFixedI8(buf, pRsp->status);
tlen += taosEncodeFixedI8(buf, pRsp->vnodeChanged);
tlen += taosEncodeFixedI8(buf, pRsp->epChanged);
tlen += taosEncodeSEpSet(buf, &pRsp->epSet);
return tlen;
}
static FORCE_INLINE void* taosDecodeSMqHbRsp(void* buf, SMqHbRsp* pRsp) {
buf = taosDecodeFixedI8(buf, &pRsp->status);
buf = taosDecodeFixedI8(buf, &pRsp->vnodeChanged);
buf = taosDecodeFixedI8(buf, &pRsp->epChanged);
buf = taosDecodeSEpSet(buf, &pRsp->epSet);
return buf;
}
2022-01-17 11:56:33 +00:00
typedef struct SMqHbOneTopicBatchRsp {
char topicName[TSDB_TOPIC_FNAME_LEN];
SArray* rsps; // SArray<SMqHbRsp>
} SMqHbOneTopicBatchRsp;
static FORCE_INLINE int taosEncodeSMqHbOneTopicBatchRsp(void** buf, const SMqHbOneTopicBatchRsp* pBatchRsp) {
int tlen = 0;
tlen += taosEncodeString(buf, pBatchRsp->topicName);
int32_t sz = taosArrayGetSize(pBatchRsp->rsps);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
SMqHbRsp* pRsp = (SMqHbRsp*)taosArrayGet(pBatchRsp->rsps, i);
tlen += taosEncodeSMqHbRsp(buf, pRsp);
}
return tlen;
}
static FORCE_INLINE void* taosDecodeSMqHbOneTopicBatchRsp(void* buf, SMqHbOneTopicBatchRsp* pBatchRsp) {
int32_t sz;
buf = taosDecodeStringTo(buf, pBatchRsp->topicName);
buf = taosDecodeFixedI32(buf, &sz);
pBatchRsp->rsps = taosArrayInit(sz, sizeof(SMqHbRsp));
for (int32_t i = 0; i < sz; i++) {
SMqHbRsp rsp;
buf = taosDecodeSMqHbRsp(buf, &rsp);
buf = taosArrayPush(pBatchRsp->rsps, &rsp);
}
return buf;
}
typedef struct SMqHbBatchRsp {
int64_t consumerId;
SArray* batchRsps; // SArray<SMqHbOneTopicBatchRsp>
} SMqHbBatchRsp;
static FORCE_INLINE int taosEncodeSMqHbBatchRsp(void** buf, const SMqHbBatchRsp* pBatchRsp) {
int tlen = 0;
tlen += taosEncodeFixedI64(buf, pBatchRsp->consumerId);
int32_t sz;
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
SMqHbOneTopicBatchRsp* pRsp = (SMqHbOneTopicBatchRsp*) taosArrayGet(pBatchRsp->batchRsps, i);
tlen += taosEncodeSMqHbOneTopicBatchRsp(buf, pRsp);
}
return tlen;
}
static FORCE_INLINE void* taosDecodeSMqHbBatchRsp(void* buf, SMqHbBatchRsp* pBatchRsp) {
buf = taosDecodeFixedI64(buf, &pBatchRsp->consumerId);
int32_t sz;
buf = taosDecodeFixedI32(buf, &sz);
pBatchRsp->batchRsps = taosArrayInit(sz, sizeof(SMqHbOneTopicBatchRsp));
for (int32_t i = 0; i < sz; i++) {
SMqHbOneTopicBatchRsp rsp;
buf = taosDecodeSMqHbOneTopicBatchRsp(buf, &rsp);
buf = taosArrayPush(pBatchRsp->batchRsps, &rsp);
}
return buf;
}
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-28 05:35:21 +00:00
int32_t acctId;
int64_t clusterId;
int32_t connId;
int8_t superUser;
2021-12-31 10:40:49 +00:00
int8_t align[3];
2021-12-28 05:35:21 +00:00
SEpSet epSet;
2021-10-08 05:53:49 +00:00
} SConnectRsp;
typedef struct {
2021-10-16 07:16:05 +00:00
char user[TSDB_USER_LEN];
char pass[TSDB_PASSWORD_LEN];
2021-10-08 05:53:49 +00:00
int32_t maxUsers;
int32_t maxDbs;
int32_t maxTimeSeries;
int32_t maxStreams;
2021-12-06 08:19:12 +00:00
int32_t accessState; // Configured only by command
2021-12-15 05:22:04 +00:00
int64_t maxStorage; // In unit of GB
2022-01-04 12:04:23 +00:00
} SCreateAcctReq, SAlterAcctReq;
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-31 10:40:49 +00:00
char user[TSDB_USER_LEN];
2022-01-04 12:04:23 +00:00
} SDropUserReq, SDropAcctReq;
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-31 10:40:49 +00:00
int8_t type;
char user[TSDB_USER_LEN];
char pass[TSDB_PASSWORD_LEN];
int8_t superUser; // denote if it is a super user or not
2022-01-04 12:04:23 +00:00
} SCreateUserReq, SAlterUserReq;
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;
/*
* for client side struct, we only need the column id, type, bytes are not necessary
* But for data in vnode side, we need all the following information.
*/
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-16 09:05:13 +00:00
int16_t colId;
int16_t type;
int16_t bytes;
SColumnFilterList flist;
2021-10-08 05:53:49 +00:00
} SColumnInfo;
2022-01-10 12:44:11 +00:00
typedef struct {
2021-10-08 05:53:49 +00:00
uint64_t uid;
TSKEY key; // last accessed ts, for subscription
} 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;
char offsetUnit;
int64_t interval;
int64_t sliding;
int64_t offset;
} SInterval;
typedef struct {
2021-12-16 09:05:13 +00:00
SMsgHead head;
char version[TSDB_VERSION_LEN];
2021-10-08 05:53:49 +00:00
2021-12-16 09:05:13 +00:00
bool stableQuery; // super table query or not
bool topBotQuery; // TODO used bitwise flag
bool interpQuery; // interp query or not
bool groupbyColumn; // denote if this is a groupby normal column query
bool hasTagResults; // if there are tag values in final result or not
bool timeWindowInterpo; // if the time window start/end required interpolation
bool queryBlockDist; // if query data block distribution
bool stabledev; // super table stddev query
bool tsCompQuery; // is tscomp query
bool simpleAgg;
bool pointInterpQuery; // point interpolation query
bool needReverseScan; // need reverse scan
bool stateWindow; // state window flag
2021-10-08 05:53:49 +00:00
STimeWindow window;
int32_t numOfTables;
int16_t order;
int16_t orderColId;
2021-12-16 09:05:13 +00:00
int16_t numOfCols; // the number of columns will be load from vnode
2021-10-08 05:53:49 +00:00
SInterval interval;
2021-12-16 09:05:13 +00:00
// SSessionWindow sw; // session window
int16_t tagCondLen; // tag length in current query
int16_t colCondLen; // column length in current query
int16_t numOfGroupCols; // num of group by columns
int16_t orderByIdx;
int16_t orderType; // used in group by xx order by xxx
int64_t vgroupLimit; // limit the number of rows for each table, used in order by + limit in stable projection query.
int16_t prjOrder; // global order in super table projection query.
int64_t limit;
int64_t offset;
int32_t queryType; // denote another query process
int16_t numOfOutput; // final output columns numbers
int16_t fillType; // interpolate type
int64_t fillVal; // default value array list
int32_t secondStageOutput;
STsBufInfo tsBuf; // tsBuf info
int32_t numOfTags; // number of tags columns involved
int32_t sqlstrLen; // sql query string
int32_t prevResultLen; // previous result length
2021-10-08 05:53:49 +00:00
int32_t numOfOperator;
2021-12-24 07:00:51 +00:00
int32_t tableScanOperator; // table scan operator. -1 means no scan operator
int32_t udfNum; // number of udf function
2021-10-08 05:53:49 +00:00
int32_t udfContentOffset;
int32_t udfContentLen;
SColumnInfo tableCols[];
2022-01-10 12:44:11 +00:00
} SQueryTableReq;
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-06 07:06:29 +00:00
int32_t code;
2021-10-08 05:53:49 +00:00
} SQueryTableRsp;
// todo: the show handle should be replaced with id
typedef struct {
SMsgHead header;
2021-12-06 06:38:37 +00:00
union {
int64_t showId;
2021-12-06 06:38:37 +00:00
int64_t qhandle;
int64_t qId;
}; // query handle
int8_t free;
2022-01-05 12:18:56 +00:00
} SRetrieveTableReq;
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
int64_t useconds;
2021-12-06 06:38:37 +00:00
int8_t completed; // all results are returned to client
int8_t precision;
2021-10-08 05:53:49 +00:00
int8_t compressed;
int32_t compLen;
2021-12-17 03:22:31 +00:00
int32_t numOfRows;
2021-10-08 05:53:49 +00:00
char data[];
} SRetrieveTableRsp;
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;
2021-12-06 06:38:37 +00:00
int32_t cacheBlockSize; // MB
int32_t totalBlocks;
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 commitTime;
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;
int8_t quorum;
int8_t update;
int8_t cacheLastRow;
2021-12-09 05:07:00 +00:00
int8_t ignoreExist;
2022-01-10 12:44:11 +00:00
} SCreateDbReq;
2021-12-09 05:07:00 +00:00
typedef struct {
2021-12-28 08:06:01 +00:00
char db[TSDB_DB_FNAME_LEN];
2021-12-09 05:07:00 +00:00
int32_t totalBlocks;
int32_t daysToKeep0;
int32_t daysToKeep1;
int32_t daysToKeep2;
int32_t fsyncPeriod;
int8_t walLevel;
int8_t quorum;
int8_t cacheLastRow;
2022-01-10 08:55:56 +00:00
} SAlterDbReq;
2021-12-09 05:07:00 +00:00
typedef struct {
2021-12-31 10:40:49 +00:00
char db[TSDB_TABLE_FNAME_LEN];
int8_t ignoreNotExists;
2022-01-10 08:55:56 +00:00
} SDropDbReq;
2021-12-09 05:07:00 +00:00
typedef struct {
char db[TSDB_TABLE_FNAME_LEN];
int32_t vgVersion;
2022-01-10 08:55:56 +00:00
} SUseDbReq;
2021-12-09 05:07:00 +00:00
typedef struct {
2021-12-31 10:40:49 +00:00
char db[TSDB_TABLE_FNAME_LEN];
2022-01-10 08:55:56 +00:00
} SSyncDbReq;
2021-12-09 05:07:00 +00:00
typedef struct {
2021-12-31 10:40:49 +00:00
char db[TSDB_TABLE_FNAME_LEN];
2022-01-10 08:55:56 +00:00
} SCompactDbReq;
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-06 06:38:37 +00:00
char name[TSDB_FUNC_NAME_LEN];
2021-12-08 05:48:18 +00:00
int8_t funcType;
int8_t scriptType;
int8_t align;
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;
2021-12-08 05:48:18 +00:00
int64_t sigature;
int32_t commentSize;
int32_t codeSize;
char pCont[];
2022-01-10 08:55:56 +00:00
} SCreateFuncReq;
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-08 05:48:18 +00:00
char name[TSDB_FUNC_NAME_LEN];
2022-01-10 08:55:56 +00:00
} SDropFuncReq;
2021-12-08 05:48:18 +00:00
typedef struct {
int32_t numOfFuncs;
char pFuncNames[];
2022-01-10 08:55:56 +00:00
} SRetrieveFuncReq;
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 align;
int8_t outputType;
int32_t outputLen;
2021-10-08 05:53:49 +00:00
int32_t bufSize;
2021-12-08 05:48:18 +00:00
int64_t sigature;
int32_t commentSize;
int32_t codeSize;
char pCont[];
} SFuncInfo;
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-08 05:48:18 +00:00
int32_t numOfFuncs;
char pFuncInfos[];
} SRetrieveFuncRsp;
2021-10-08 05:53:49 +00:00
typedef struct {
2021-11-02 06:27:20 +00:00
int32_t statusInterval;
int64_t checkTime; // 1970-01-01 00:00:00.000
char timezone[TSDB_TIMEZONE_LEN]; // tsTimezone
char locale[TSDB_LOCALE_LEN]; // tsLocale
char charset[TSDB_LOCALE_LEN]; // tsCharset
} SClusterCfg;
2021-10-08 05:53:49 +00:00
2021-11-02 06:27:20 +00:00
typedef struct {
int32_t vgId;
int8_t role;
2021-12-31 10:40:49 +00:00
int8_t align[3];
2021-11-02 06:27:20 +00:00
int64_t totalStorage;
int64_t compStorage;
int64_t pointsWritten;
int64_t tablesNum;
} SVnodeLoad;
typedef struct {
2021-11-04 06:06:29 +00:00
int32_t num;
SVnodeLoad data[];
2021-11-02 06:27:20 +00:00
} SVnodeLoads;
2021-12-20 06:41:12 +00:00
typedef struct {
2021-11-30 11:42:51 +00:00
int32_t sver;
2021-11-02 06:27:20 +00:00
int32_t dnodeId;
2021-12-27 02:57:31 +00:00
int64_t clusterId;
int64_t dver;
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;
SVnodeLoads vnodeLoads;
2022-01-06 09:04:48 +00:00
} SStatusReq;
2021-10-08 05:53:49 +00:00
2021-12-26 15:46:22 +00:00
typedef struct {
int32_t reserved;
2022-01-10 12:44:11 +00:00
} STransReq;
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 {
2021-11-22 02:03:41 +00:00
int32_t id;
2021-10-25 09:39:21 +00:00
int8_t isMnode;
2021-12-31 10:40:49 +00:00
int8_t align;
2021-11-22 02:03:41 +00:00
uint16_t port;
char fqdn[TSDB_FQDN_LEN];
2021-10-08 05:53:49 +00:00
} SDnodeEp;
typedef struct {
2021-11-22 02:03:41 +00:00
int32_t num;
SDnodeEp eps[];
2021-10-08 05:53:49 +00:00
} SDnodeEps;
typedef struct {
int64_t dver;
2021-11-02 06:27:20 +00:00
SDnodeCfg dnodeCfg;
SDnodeEps dnodeEps;
2021-10-08 05:53:49 +00:00
} SStatusRsp;
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];
2021-12-18 12:56:05 +00:00
uint64_t dbUid;
2021-12-19 06:43:58 +00:00
int32_t vgVersion;
2021-11-05 07:42:19 +00:00
int32_t cacheBlockSize;
int32_t totalBlocks;
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;
int32_t commitTime;
2021-11-05 07:42:19 +00:00
int32_t fsyncPeriod;
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;
int8_t quorum;
2021-12-18 12:56:05 +00:00
int8_t update;
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-01-08 07:20:18 +00:00
} SCreateVnodeReq, SAlterVnodeReq;
2021-10-08 05:53:49 +00:00
2021-11-04 01:28:55 +00:00
typedef struct {
2021-12-18 12:56:05 +00:00
int32_t vgId;
int32_t dnodeId;
uint64_t dbUid;
2022-01-08 07:20:18 +00:00
char db[TSDB_DB_FNAME_LEN];
} SDropVnodeReq, SSyncVnodeReq, SCompactVnodeReq;
2021-11-04 01:28:55 +00:00
typedef struct {
int32_t vgId;
int8_t accessState;
2022-01-08 07:20:18 +00:00
} SAuthVnodeReq;
2021-11-04 01:28:55 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-31 05:34:38 +00:00
SMsgHead header;
2021-12-31 06:26:05 +00:00
char dbFname[TSDB_DB_FNAME_LEN];
2021-12-31 05:34:38 +00:00
char tableFname[TSDB_TABLE_FNAME_LEN];
2022-01-10 12:44:11 +00:00
} STableInfoReq;
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
2021-12-14 07:24:21 +00:00
typedef struct SVgroupInfo {
int32_t vgId;
2021-12-16 10:04:07 +00:00
uint32_t hashBegin;
uint32_t hashEnd;
int8_t inUse;
2021-12-14 07:24:21 +00:00
int8_t numOfEps;
2022-01-10 12:44:11 +00:00
SEpAddr epAddr[TSDB_MAX_REPLICA];
2021-12-14 07:24:21 +00:00
} SVgroupInfo;
2021-10-08 05:53:49 +00:00
typedef struct {
int32_t vgId;
int8_t numOfEps;
2022-01-10 12:44:11 +00:00
SEpAddr epAddr[TSDB_MAX_REPLICA];
2021-10-08 05:53:49 +00:00
} SVgroupMsg;
typedef struct {
2021-12-10 06:12:11 +00:00
int32_t numOfVgroups;
2021-10-08 05:53:49 +00:00
SVgroupMsg 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 {
char tbFname[TSDB_TABLE_FNAME_LEN]; // table full name
2021-12-16 09:05:13 +00:00
char stbFname[TSDB_TABLE_FNAME_LEN];
2021-12-31 06:43:13 +00:00
char dbFname[TSDB_DB_FNAME_LEN];
2021-12-16 09:05:13 +00:00
int32_t numOfTags;
int32_t numOfColumns;
int8_t precision;
int8_t tableType;
int8_t update;
int32_t sversion;
int32_t tversion;
uint64_t suid;
2021-12-17 04:00:54 +00:00
uint64_t tuid;
2021-12-16 09:05:13 +00:00
int32_t vgId;
SSchema pSchema[];
2022-01-10 12:44:11 +00:00
} STableMetaRsp;
2021-10-08 05:53:49 +00:00
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;
2021-12-15 01:52:37 +00:00
typedef struct {
2021-12-28 08:06:01 +00:00
char db[TSDB_DB_FNAME_LEN];
2022-01-06 07:30:32 +00:00
int64_t uid;
int32_t vgVersion;
2021-12-16 09:05:13 +00:00
int32_t vgNum;
int8_t hashMethod;
2021-12-15 01:52:37 +00:00
SVgroupInfo vgroupInfo[];
} SUseDbRsp;
2021-12-15 01:52:37 +00:00
2021-10-08 05:53:49 +00:00
/*
* sql: show tables like '%a_%'
* payload is the query condition, e.g., '%a_%'
* payloadLen is the length of payload
*/
typedef struct {
2021-12-06 06:38:37 +00:00
int8_t type;
2021-12-28 08:06:01 +00:00
char db[TSDB_DB_FNAME_LEN];
2021-12-06 06:38:37 +00:00
int16_t payloadLen;
char payload[];
2022-01-05 12:18:56 +00:00
} SShowReq;
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-10-08 05:53:49 +00:00
int32_t numOfVgroup;
int32_t vgid[];
2022-01-10 08:55:56 +00:00
} SCompactReq;
2021-10-08 05:53:49 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
int64_t showId;
2022-01-10 12:44:11 +00:00
STableMetaRsp tableMeta;
2021-10-08 05:53:49 +00:00
} SShowRsp;
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
typedef struct {
int32_t dnodeId;
2022-01-06 09:04:48 +00:00
} SDropDnodeReq;
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-01-06 09:04:48 +00:00
} SMCfgDnodeReq, SDCfgDnodeReq;
2021-10-08 05:53:49 +00:00
2021-12-08 11:34:54 +00:00
typedef struct {
int32_t dnodeId;
2022-01-07 10:03:28 +00:00
} SMCreateMnodeReq, SMDropMnodeReq, SDDropMnodeReq;
2021-12-08 11:34:54 +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
2021-12-27 12:33:23 +00:00
typedef struct {
int32_t dnodeId;
2022-01-04 12:42:03 +00:00
} SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq;
2021-12-27 12:33:23 +00:00
typedef struct {
int32_t dnodeId;
2022-01-04 12:42:03 +00:00
} SMCreateSnodeReq, SMDropSnodeReq, SDCreateSnodeReq, SDDropSnodeReq;
2021-12-27 12:33:23 +00:00
typedef struct {
int32_t dnodeId;
2022-01-04 12:42:03 +00:00
} SMCreateBnodeReq, SMDropBnodeReq, SDCreateBnodeReq, SDDropBnodeReq;
2021-12-27 12:33:23 +00:00
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-06 07:06:29 +00:00
char sql[TSDB_SHOW_SQL_LEN];
int32_t queryId;
int64_t useconds;
int64_t stime;
int64_t qId;
int64_t sqlObjId;
int32_t pid;
char fqdn[TSDB_FQDN_LEN];
int8_t stableQuery;
int32_t numOfSub;
char subSqlInfo[TSDB_SHOW_SUBQUERY_LEN]; // include subqueries' index, Obj IDs and states(C-complete/I-imcomplete)
2021-10-08 05:53:49 +00:00
} SQueryDesc;
typedef struct {
2021-12-03 06:36:41 +00:00
int32_t connId;
int32_t pid;
int32_t numOfQueries;
int32_t numOfStreams;
char app[TSDB_APP_NAME_LEN];
char pData[];
2022-01-06 08:13:49 +00:00
} SHeartBeatReq;
2021-10-08 05:53:49 +00:00
typedef struct {
2021-12-03 06:36:41 +00:00
int32_t connId;
int32_t queryId;
int32_t streamId;
int32_t totalDnodes;
int32_t onlineDnodes;
int8_t killConnection;
2021-12-31 10:40:49 +00:00
int8_t align[3];
2021-12-03 06:36:41 +00:00
SEpSet epSet;
2021-10-08 05:53:49 +00:00
} SHeartBeatRsp;
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
typedef struct {
int32_t connId;
2022-01-06 08:13:49 +00:00
} SKillConnReq;
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
typedef struct {
2021-12-16 09:05:13 +00:00
int8_t finished;
2021-12-31 10:40:49 +00:00
int8_t align[7];
2021-12-16 09:05:13 +00:00
char name[TSDB_STEP_NAME_LEN];
char desc[TSDB_STEP_DESC_LEN];
2022-01-10 08:55:56 +00:00
} SStartupReq;
2021-10-08 05:53:49 +00:00
// mq related
typedef struct {
} SMqConnectReq;
typedef struct {
} SMqConnectRsp;
typedef struct {
} SMqDisconnectReq;
typedef struct {
} SMqDisconnectRsp;
typedef struct {
} SMqAckReq;
typedef struct {
} SMqAckRsp;
typedef struct {
} SMqResetReq;
typedef struct {
} SMqResetRsp;
2021-12-16 09:05:13 +00:00
// mq related end
2021-10-08 05:53:49 +00:00
typedef struct {
/* data */
} SSubmitReq;
typedef struct {
/* data */
} SSubmitRsp;
typedef struct {
/* data */
} SSubmitReqReader;
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;
uint32_t contentLen;
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;
int8_t status;
2021-12-21 10:28:28 +00:00
} STaskStatus;
2022-01-10 12:44:11 +00:00
typedef struct {
2021-12-21 10:28:28 +00:00
uint32_t num;
STaskStatus status[];
} SSchedulerStatusRsp;
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-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-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;
2021-12-28 09:01:09 +00:00
typedef struct {
2022-01-04 02:40:34 +00:00
int8_t igExists;
char* name;
2022-01-14 10:35:57 +00:00
char* sql;
2022-01-04 02:40:34 +00:00
char* physicalPlan;
char* logicalPlan;
2021-12-28 09:01:09 +00:00
} SCMCreateTopicReq;
static FORCE_INLINE int tSerializeSCMCreateTopicReq(void** buf, const SCMCreateTopicReq* pReq) {
int tlen = 0;
tlen += taosEncodeFixedI8(buf, pReq->igExists);
2022-01-04 02:40:34 +00:00
tlen += taosEncodeString(buf, pReq->name);
2022-01-14 10:35:57 +00:00
tlen += taosEncodeString(buf, pReq->sql);
2021-12-29 09:53:43 +00:00
tlen += taosEncodeString(buf, pReq->physicalPlan);
tlen += taosEncodeString(buf, pReq->logicalPlan);
2021-12-28 09:01:09 +00:00
return tlen;
}
static FORCE_INLINE void* tDeserializeSCMCreateTopicReq(void* buf, SCMCreateTopicReq* pReq) {
buf = taosDecodeFixedI8(buf, &(pReq->igExists));
buf = taosDecodeString(buf, &(pReq->name));
2022-01-14 10:35:57 +00:00
buf = taosDecodeString(buf, &(pReq->sql));
2021-12-29 10:00:42 +00:00
buf = taosDecodeString(buf, &(pReq->physicalPlan));
buf = taosDecodeString(buf, &(pReq->logicalPlan));
2021-12-29 09:53:43 +00:00
return buf;
}
typedef struct {
int64_t topicId;
} SCMCreateTopicRsp;
static FORCE_INLINE int tSerializeSCMCreateTopicRsp(void** buf, const SCMCreateTopicRsp* pRsp) {
int tlen = 0;
tlen += taosEncodeFixedI64(buf, pRsp->topicId);
return tlen;
}
static FORCE_INLINE void* tDeserializeSCMCreateTopicRsp(void* buf, SCMCreateTopicRsp* pRsp) {
buf = taosDecodeFixedI64(buf, &pRsp->topicId);
return buf;
}
typedef struct {
2022-01-04 02:40:34 +00:00
int32_t topicNum;
2021-12-29 09:53:43 +00:00
int64_t consumerId;
2022-01-04 02:40:34 +00:00
char* consumerGroup;
2022-01-07 02:36:42 +00:00
SArray* topicNames; // SArray<char*>
2021-12-29 09:53:43 +00:00
} SCMSubscribeReq;
static FORCE_INLINE int tSerializeSCMSubscribeReq(void** buf, const SCMSubscribeReq* pReq) {
int tlen = 0;
2022-01-04 02:40:34 +00:00
tlen += taosEncodeFixedI32(buf, pReq->topicNum);
2021-12-29 09:53:43 +00:00
tlen += taosEncodeFixedI64(buf, pReq->consumerId);
2022-01-04 02:40:34 +00:00
tlen += taosEncodeString(buf, pReq->consumerGroup);
2022-01-06 10:17:08 +00:00
2022-01-07 02:36:42 +00:00
for (int i = 0; i < pReq->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) {
2022-01-04 02:40:34 +00:00
buf = taosDecodeFixedI32(buf, &pReq->topicNum);
2021-12-29 09:53:43 +00:00
buf = taosDecodeFixedI64(buf, &pReq->consumerId);
2022-01-04 02:40:34 +00:00
buf = taosDecodeString(buf, &pReq->consumerGroup);
2022-01-06 10:17:08 +00:00
pReq->topicNames = taosArrayInit(pReq->topicNum, sizeof(void*));
2022-01-07 02:36:42 +00:00
for (int i = 0; i < pReq->topicNum; i++) {
2022-01-06 10:17:08 +00:00
char* name = NULL;
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;
static FORCE_INLINE int tSerializeSCMSubscribeRsp(void** buf, const SCMSubscribeRsp* pRsp) {
int tlen = 0;
2022-01-04 02:40:34 +00:00
tlen += taosEncodeFixedI32(buf, pRsp->topicNum);
2022-01-07 02:36:42 +00:00
for (int 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-01-07 02:36:42 +00:00
for (int 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-01-06 02:56:25 +00:00
static FORCE_INLINE int tSerializeSMVSubscribeReq(void** buf, SMVSubscribeReq* pReq) {
2022-01-04 02:40:34 +00:00
int tlen = 0;
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;
}
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 {
2022-01-14 10:35:57 +00:00
char name[TSDB_TOPIC_NAME_LEN];
2021-12-23 12:28:08 +00:00
int8_t igExists;
2021-12-24 06:08:40 +00:00
int32_t execLen;
2021-12-23 12:28:08 +00:00
void* executor;
2021-12-24 06:08:40 +00:00
int32_t sqlLen;
2021-12-23 12:28:08 +00:00
char* sql;
2022-01-10 12:44:11 +00:00
} SCreateTopicReq;
2021-12-23 12:28:08 +00:00
typedef struct {
char name[TSDB_TABLE_FNAME_LEN];
int8_t igNotExists;
2022-01-10 12:44:11 +00:00
} SDropTopicReq;
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];
uint64_t tuid;
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];
uint64_t tuid;
2022-01-10 12:44:11 +00:00
} SDDropTopicReq;
2021-11-04 01:28:55 +00:00
2021-12-25 06:35:39 +00:00
typedef struct SVCreateTbReq {
uint64_t ver; // use a general definition
char* name;
uint32_t ttl;
uint32_t keep;
2021-12-31 07:48:21 +00:00
#define TD_SUPER_TABLE TSDB_SUPER_TABLE
#define TD_CHILD_TABLE TSDB_CHILD_TABLE
#define TD_NORMAL_TABLE TSDB_NORMAL_TABLE
2021-12-25 06:35:39 +00:00
uint8_t type;
union {
struct {
tb_uid_t suid;
uint32_t nCols;
SSchema* pSchema;
uint32_t nTagCols;
SSchema* pTagSchema;
} stbCfg;
struct {
tb_uid_t suid;
SKVRow pTag;
} ctbCfg;
struct {
uint32_t nCols;
SSchema* pSchema;
} ntbCfg;
};
} SVCreateTbReq;
2021-12-31 03:39:51 +00:00
typedef struct {
uint64_t ver; // use a general definition
SArray* pArray;
} SVCreateTbBatchReq;
2021-12-25 06:35:39 +00:00
2021-12-31 08:30:40 +00:00
int tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq);
2021-12-29 09:20:10 +00:00
void* tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pReq);
2021-12-31 08:30:40 +00:00
int tSVCreateTbBatchReqSerialize(void** buf, SVCreateTbBatchReq* pReq);
void* tSVCreateTbBatchReqDeserialize(void* buf, SVCreateTbBatchReq* pReq);
2021-12-25 06:35:39 +00:00
2022-01-10 12:44:11 +00:00
typedef struct {
SMsgHead head;
2021-12-25 06:35:39 +00:00
} SVCreateTbRsp;
2022-01-10 12:44:11 +00:00
typedef struct {
SMsgHead head;
char name[TSDB_TABLE_FNAME_LEN];
int8_t ignoreNotExists;
} SVAlterTbReq;
typedef struct {
SMsgHead head;
} SVAlterTbRsp;
typedef struct {
SMsgHead head;
char name[TSDB_TABLE_FNAME_LEN];
2022-01-17 07:38:50 +00:00
int64_t suid;
2022-01-10 12:44:11 +00:00
} SVDropTbReq;
typedef struct {
SMsgHead head;
} SVDropTbRsp;
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
int64_t id;
2022-01-10 12:44:11 +00:00
STableMetaRsp metaInfo;
2021-12-29 07:47:45 +00:00
} SVShowTablesRsp;
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;
2021-10-08 05:53:49 +00:00
#pragma pack(pop)
#ifdef __cplusplus
}
#endif
#endif /*_TD_COMMON_TAOS_MSG_H_*/