Merge remote-tracking branch 'origin/3.0' into feature/scheduler
This commit is contained in:
commit
97d7d3acc6
|
@ -25,8 +25,10 @@ if(${BUILD_TEST})
|
|||
enable_testing()
|
||||
endif(${BUILD_TEST})
|
||||
add_subdirectory(source)
|
||||
add_subdirectory(tools)
|
||||
add_subdirectory(tests)
|
||||
|
||||
# docs
|
||||
add_subdirectory(docs)
|
||||
|
||||
# tests (TODO)
|
||||
# tests (TODO)
|
||||
|
|
|
@ -76,44 +76,14 @@ def pre_test(){
|
|||
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
||||
git checkout -qf FETCH_HEAD
|
||||
git clean -dfx
|
||||
'''
|
||||
script {
|
||||
if (env.CHANGE_TARGET == 'master') {
|
||||
sh '''
|
||||
cd ${WK}
|
||||
git checkout master
|
||||
'''
|
||||
}
|
||||
else if(env.CHANGE_TARGET == '2.0'){
|
||||
sh '''
|
||||
cd ${WK}
|
||||
git checkout 2.0
|
||||
'''
|
||||
}
|
||||
else if(env.CHANGE_TARGET == '3.0'){
|
||||
sh '''
|
||||
cd ${WK}
|
||||
git checkout 3.0
|
||||
'''
|
||||
}
|
||||
else{
|
||||
sh '''
|
||||
cd ${WK}
|
||||
git checkout develop
|
||||
'''
|
||||
}
|
||||
}
|
||||
sh '''
|
||||
cd ${WK}
|
||||
git pull >/dev/null
|
||||
|
||||
git clean -dfx
|
||||
export TZ=Asia/Harbin
|
||||
date
|
||||
mkdir debug
|
||||
cd debug
|
||||
cmake .. > /dev/null
|
||||
make > /dev/null
|
||||
make install > /dev/null
|
||||
make -j4> /dev/null
|
||||
|
||||
'''
|
||||
return 1
|
||||
|
@ -124,11 +94,11 @@ pipeline {
|
|||
options { skipDefaultCheckout() }
|
||||
environment{
|
||||
WK = '/var/lib/jenkins/workspace/TDinternal'
|
||||
WKC= '/var/lib/jenkins/workspace/TDinternal/community'
|
||||
WKC= '/var/lib/jenkins/workspace/TDengine'
|
||||
}
|
||||
stages {
|
||||
stage('pre_build'){
|
||||
agent{label 'master'}
|
||||
agent{label 'slave3_0'}
|
||||
options { skipDefaultCheckout() }
|
||||
when {
|
||||
changeRequest()
|
||||
|
|
|
@ -80,8 +80,8 @@ typedef enum {
|
|||
|
||||
typedef struct taosField {
|
||||
char name[65];
|
||||
uint8_t type;
|
||||
int16_t bytes;
|
||||
int8_t type;
|
||||
int32_t bytes;
|
||||
} TAOS_FIELD;
|
||||
|
||||
#ifdef _TD_GO_DLL_
|
||||
|
|
|
@ -50,10 +50,9 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_CONSUME, "mq-consume" )
|
|||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_QUERY, "mq-query" )
|
||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_CONNECT, "mq-connect" )
|
||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_DISCONNECT, "mq-disconnect" )
|
||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_ACK, "mq-ack" )
|
||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_RESET, "mq-reset" )
|
||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_SET, "mq-set" )
|
||||
// message from client to mnode
|
||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CONNECT, "connect" )
|
||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CONNECT, "connect" )
|
||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_ACCT, "create-acct" )
|
||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_ALTER_ACCT, "alter-acct" )
|
||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_ACCT, "drop-acct" )
|
||||
|
@ -571,14 +570,13 @@ typedef struct {
|
|||
} SRetrieveTableMsg;
|
||||
|
||||
typedef struct SRetrieveTableRsp {
|
||||
int32_t numOfRows;
|
||||
int64_t offset; // updated offset value for multi-vnode projection query
|
||||
int64_t useconds;
|
||||
int8_t completed; // all results are returned to client
|
||||
int8_t precision;
|
||||
int8_t compressed;
|
||||
int8_t reserved;
|
||||
int32_t compLen;
|
||||
|
||||
int32_t numOfRows;
|
||||
char data[];
|
||||
} SRetrieveTableRsp;
|
||||
|
||||
|
@ -785,12 +783,8 @@ typedef struct {
|
|||
} SAuthVnodeMsg;
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_TABLE_FNAME_LEN];
|
||||
} SStbInfoMsg;
|
||||
|
||||
typedef struct {
|
||||
SMsgHead msgHead;
|
||||
char tableFname[TSDB_TABLE_FNAME_LEN];
|
||||
int32_t vgId;
|
||||
char tableFname[TSDB_TABLE_FNAME_LEN];
|
||||
} STableInfoMsg;
|
||||
|
||||
typedef struct {
|
||||
|
@ -801,10 +795,6 @@ typedef struct {
|
|||
char tableNames[];
|
||||
} SMultiTableInfoMsg;
|
||||
|
||||
typedef struct SSTableVgroupMsg {
|
||||
int32_t numOfTables;
|
||||
} SSTableVgroupMsg, SSTableVgroupRspMsg;
|
||||
|
||||
typedef struct SVgroupInfo {
|
||||
int32_t vgId;
|
||||
uint32_t hashBegin;
|
||||
|
@ -814,12 +804,6 @@ typedef struct SVgroupInfo {
|
|||
SEpAddrMsg epAddr[TSDB_MAX_REPLICA];
|
||||
} SVgroupInfo;
|
||||
|
||||
typedef struct SVgroupListRspMsg {
|
||||
int32_t vgroupNum;
|
||||
int32_t vgroupVersion;
|
||||
SVgroupInfo vgroupInfo[];
|
||||
} SVgroupListRspMsg;
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
int8_t numOfEps;
|
||||
|
@ -841,8 +825,8 @@ typedef struct {
|
|||
int8_t update;
|
||||
int32_t sversion;
|
||||
int32_t tversion;
|
||||
uint64_t tuid;
|
||||
uint64_t suid;
|
||||
uint64_t tuid;
|
||||
int32_t vgId;
|
||||
SSchema pSchema[];
|
||||
} STableMetaMsg;
|
||||
|
|
|
@ -62,7 +62,7 @@ enum {
|
|||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_CFG_DNODE, "cfg-dnode" )
|
||||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_CFG_MNODE, "cfg-mnode" )
|
||||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW, "show" )
|
||||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_RETRIEVE, "retrieve" )
|
||||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_RETRIEVE_MNODE, "retrieve" )
|
||||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_KILL_QUERY, "kill-query" )
|
||||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_KILL_STREAM, "kill-stream" )
|
||||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_KILL_CONNECTION, "kill-connection" )
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef TDENGINE_TNAME_H
|
||||
#define TDENGINE_TNAME_H
|
||||
|
||||
#include "taosmsg.h"
|
||||
//#include "taosmsg.h"
|
||||
|
||||
#define TSDB_DB_NAME_T 1
|
||||
#define TSDB_TABLE_NAME_T 2
|
||||
|
@ -27,7 +27,7 @@
|
|||
|
||||
typedef struct SName {
|
||||
uint8_t type; //db_name_t, table_name_t
|
||||
char acctId[TSDB_ACCT_ID_LEN];
|
||||
int32_t acctId;
|
||||
char dbname[TSDB_DB_NAME_LEN];
|
||||
char tname[TSDB_TABLE_NAME_LEN];
|
||||
} SName;
|
||||
|
@ -38,7 +38,7 @@ int32_t tNameLen(const SName* name);
|
|||
|
||||
SName* tNameDup(const SName* name);
|
||||
|
||||
bool tIsValidName(const SName* name);
|
||||
bool tNameIsValid(const SName* name);
|
||||
|
||||
const char* tNameGetTableName(const SName* name);
|
||||
|
||||
|
@ -50,14 +50,10 @@ bool tNameIsEmpty(const SName* name);
|
|||
|
||||
void tNameAssign(SName* dst, const SName* src);
|
||||
|
||||
int32_t tNameSetDbName(SName* dst, int32_t acctId, const char* dbName, size_t nameLen);
|
||||
|
||||
int32_t tNameFromString(SName* dst, const char* str, uint32_t type);
|
||||
|
||||
int32_t tNameSetAcctId(SName* dst, const char* acct);
|
||||
|
||||
SSchema* tGetTbnameColumnSchema();
|
||||
|
||||
#if 0
|
||||
int32_t tNameSetDbName(SName* dst, const char* acct, SToken* dbToken);
|
||||
#endif
|
||||
int32_t tNameSetAcctId(SName* dst, int32_t acctId);
|
||||
|
||||
#endif // TDENGINE_TNAME_H
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#ifndef _TD_META_H_
|
||||
#define _TD_META_H_
|
||||
|
||||
#include "mallocator.h"
|
||||
#include "os.h"
|
||||
#include "trow.h"
|
||||
|
||||
|
@ -71,7 +72,7 @@ typedef struct STbCfg {
|
|||
} STbCfg;
|
||||
|
||||
// SMeta operations
|
||||
SMeta *metaOpen(const char *path, const SMetaCfg *pOptions);
|
||||
SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF);
|
||||
void metaClose(SMeta *pMeta);
|
||||
void metaRemove(const char *path);
|
||||
int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg);
|
||||
|
@ -79,8 +80,8 @@ int metaDropTable(SMeta *pMeta, tb_uid_t uid);
|
|||
int metaCommit(SMeta *pMeta);
|
||||
|
||||
// Options
|
||||
void metaOptionsInit(SMetaCfg *pOptions);
|
||||
void metaOptionsClear(SMetaCfg *pOptions);
|
||||
void metaOptionsInit(SMetaCfg *pMetaCfg);
|
||||
void metaOptionsClear(SMetaCfg *pMetaCfg);
|
||||
|
||||
// STbCfg
|
||||
#define META_INIT_STB_CFG(NAME, TTL, KEEP, SUID, PSCHEMA, PTAGSCHEMA) \
|
||||
|
|
|
@ -62,10 +62,10 @@ typedef struct TmqDisconnectRsp {
|
|||
int8_t status;
|
||||
} TmqDisconnectRsp;
|
||||
|
||||
typedef struct TmqConsumeReq {
|
||||
typedef struct STqConsumeReq {
|
||||
TmqMsgHead head;
|
||||
TmqAcks acks;
|
||||
} TmqConsumeReq;
|
||||
} STqConsumeReq;
|
||||
|
||||
typedef struct TmqMsgContent {
|
||||
int64_t topicId;
|
||||
|
@ -73,11 +73,11 @@ typedef struct TmqMsgContent {
|
|||
char msg[];
|
||||
} TmqMsgContent;
|
||||
|
||||
typedef struct TmqConsumeRsp {
|
||||
typedef struct STqConsumeRsp {
|
||||
TmqMsgHead head;
|
||||
int64_t bodySize;
|
||||
TmqMsgContent msgs[];
|
||||
} TmqConsumeRsp;
|
||||
} STqConsumeRsp;
|
||||
|
||||
typedef struct TmqSubscribeReq {
|
||||
TmqMsgHead head;
|
||||
|
@ -261,13 +261,14 @@ typedef struct STQ {
|
|||
|
||||
// open in each vnode
|
||||
STQ* tqOpen(const char* path, STqCfg* tqConfig, STqLogReader* tqLogReader, SMemAllocatorFactory* allocFac);
|
||||
void tqDestroy(STQ*);
|
||||
void tqClose(STQ*);
|
||||
|
||||
// void* will be replace by a msg type
|
||||
int tqPushMsg(STQ*, void* msg, int64_t version);
|
||||
int tqCommit(STQ*);
|
||||
int tqSetCursor(STQ*, void* msg);
|
||||
|
||||
int tqConsume(STQ*, TmqConsumeReq*);
|
||||
int tqConsume(STQ*, STqConsumeReq*);
|
||||
|
||||
STqGroupHandle* tqGetGroupHandle(STQ*, int64_t cId);
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#ifndef _TD_TSDB_H_
|
||||
#define _TD_TSDB_H_
|
||||
|
||||
#include "mallocator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -25,7 +27,7 @@ typedef struct STsdb STsdb;
|
|||
typedef struct STsdbCfg STsdbCfg;
|
||||
|
||||
// STsdb
|
||||
STsdb *tsdbOpen(const char *path, const STsdbCfg *pTsdbCfg);
|
||||
STsdb *tsdbOpen(const char *path, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF);
|
||||
void tsdbClose(STsdb *);
|
||||
void tsdbRemove(const char *path);
|
||||
int tsdbInsertData(STsdb *pTsdb, SSubmitMsg *pMsg);
|
||||
|
|
|
@ -34,6 +34,13 @@ enum OPERATOR_TYPE_E {
|
|||
OP_TotalNum
|
||||
};
|
||||
|
||||
enum DATASINK_TYPE_E {
|
||||
DSINK_Unknown,
|
||||
DSINK_Dispatch,
|
||||
DSINK_Insert,
|
||||
DSINK_TotalNum
|
||||
};
|
||||
|
||||
struct SEpSet;
|
||||
struct SQueryStmtInfo;
|
||||
|
||||
|
@ -49,6 +56,22 @@ typedef struct SQueryNodeBasicInfo {
|
|||
const char *name; // operator name
|
||||
} SQueryNodeBasicInfo;
|
||||
|
||||
typedef struct SDataSink {
|
||||
SQueryNodeBasicInfo info;
|
||||
SDataBlockSchema schema;
|
||||
} SDataSink;
|
||||
|
||||
typedef struct SDataDispatcher {
|
||||
SDataSink sink;
|
||||
// todo
|
||||
} SDataDispatcher;
|
||||
|
||||
typedef struct SDataInserter {
|
||||
SDataSink sink;
|
||||
uint64_t uid; // unique id of the table
|
||||
// todo data field
|
||||
} SDataInserter;
|
||||
|
||||
typedef struct SPhyNode {
|
||||
SQueryNodeBasicInfo info;
|
||||
SArray *pTargets; // target list to be computed or scanned at this node
|
||||
|
@ -85,7 +108,7 @@ typedef struct SProjectPhyNode {
|
|||
typedef struct SExchangePhyNode {
|
||||
SPhyNode node;
|
||||
uint64_t srcTemplateId; // template id of datasource suplans
|
||||
SArray *pSourceEpSet; // SEpSet, scheduler fill by calling qSetSuplanExecutionNode
|
||||
SArray *pSrcEndPoints; // SEpAddrMsg, scheduler fill by calling qSetSuplanExecutionNode
|
||||
} SExchangePhyNode;
|
||||
|
||||
typedef struct SSubplanId {
|
||||
|
@ -115,22 +138,29 @@ typedef struct SQueryDag {
|
|||
*/
|
||||
int32_t qCreateQueryDag(const struct SQueryStmtInfo* pQueryInfo, struct SEpSet* pQnode, struct SQueryDag** pDag);
|
||||
|
||||
int32_t qSetSuplanExecutionNode(SArray* subplans, SArray* nodes);
|
||||
// Set datasource of this subplan, multiple calls may be made to a subplan.
|
||||
// @subplan subplan to be schedule
|
||||
// @templateId templateId of a group of datasource subplans of this @subplan
|
||||
// @eps Execution location of this group of datasource subplans, is an array of SEpAddr structures
|
||||
int32_t qSetSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SArray* eps);
|
||||
|
||||
int32_t qExplainQuery(const struct SQueryStmtInfo* pQueryInfo, struct SEpSet* pQnode, char** str);
|
||||
|
||||
|
||||
/**
|
||||
* Convert to subplan to string for the scheduler to send to the executor
|
||||
*/
|
||||
int32_t qSubPlanToString(struct SSubplan *pPhyNode, char** str);
|
||||
int32_t qSubPlanToString(const SSubplan* subplan, char** str);
|
||||
|
||||
int32_t qStringToSubplan(const char* str, SSubplan** subplan);
|
||||
|
||||
void qDestroySubplan(SSubplan* pSubplan);
|
||||
|
||||
/**
|
||||
* Destroy the physical plan.
|
||||
* @param pQueryPhyNode
|
||||
* @return
|
||||
*/
|
||||
void qDestroyQueryDag(struct SQueryDag* pDag);
|
||||
void qDestroyQueryDag(SQueryDag* pDag);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
*/
|
||||
|
||||
#if defined(INCLUDE_AS_ENUM) // enum define mode
|
||||
#undef OP_ENUM_MACRO
|
||||
#define OP_ENUM_MACRO(op) OP_##op,
|
||||
#undef OP_ENUM_MACRO
|
||||
#define OP_ENUM_MACRO(op) OP_##op,
|
||||
#elif defined(INCLUDE_AS_NAME) // comment define mode
|
||||
#undef OP_ENUM_MACRO
|
||||
#define OP_ENUM_MACRO(op) #op,
|
||||
#undef OP_ENUM_MACRO
|
||||
#define OP_ENUM_MACRO(op) #op,
|
||||
#else
|
||||
#error To use this include file, first define either INCLUDE_AS_ENUM or INCLUDE_AS_NAME
|
||||
#error To use this include file, first define either INCLUDE_AS_ENUM or INCLUDE_AS_NAME
|
||||
#endif
|
||||
|
||||
OP_ENUM_MACRO(TableScan)
|
||||
|
|
|
@ -24,8 +24,6 @@ extern "C" {
|
|||
#include "thash.h"
|
||||
#include "tlog.h"
|
||||
|
||||
typedef SVgroupListRspMsg SVgroupListInfo;
|
||||
|
||||
typedef struct STableComInfo {
|
||||
uint8_t numOfTags; // the number of tags in schema
|
||||
uint8_t precision; // the number of precision
|
||||
|
@ -83,12 +81,14 @@ typedef struct STableMetaOutput {
|
|||
STableMeta *tbMeta;
|
||||
} STableMetaOutput;
|
||||
|
||||
bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags);
|
||||
|
||||
extern int32_t (*queryBuildMsg[TSDB_MSG_TYPE_MAX])(void* input, char **msg, int32_t msgSize, int32_t *msgLen);
|
||||
extern int32_t (*queryProcessMsgRsp[TSDB_MSG_TYPE_MAX])(void* output, char *msg, int32_t msgSize);
|
||||
|
||||
SSchema* tGetTbnameColumnSchema();
|
||||
extern void msgInit();
|
||||
|
||||
|
||||
extern int32_t qDebugFlag;
|
||||
|
||||
#define qFatal(...) do { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", qDebugFlag, __VA_ARGS__); }} while(0)
|
|
@ -46,6 +46,7 @@ extern "C" {
|
|||
#include <math.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#define TSDB_LOCALE_LEN 64
|
||||
#define TSDB_TIMEZONE_LEN 96
|
||||
|
||||
|
@ -57,11 +59,11 @@ char * taosGetCmdlineByPID(int pid);
|
|||
void taosSetCoreDump(bool enable);
|
||||
|
||||
typedef struct {
|
||||
const char *sysname;
|
||||
const char *nodename;
|
||||
const char *release;
|
||||
const char *version;
|
||||
const char *machine;
|
||||
char sysname[_UTSNAME_MACHINE_LENGTH];
|
||||
char nodename[_UTSNAME_MACHINE_LENGTH];
|
||||
char release[_UTSNAME_MACHINE_LENGTH];
|
||||
char version[_UTSNAME_MACHINE_LENGTH];
|
||||
char machine[_UTSNAME_MACHINE_LENGTH];
|
||||
} SysNameInfo;
|
||||
|
||||
SysNameInfo taosGetSysNameInfo();
|
||||
|
|
|
@ -22,23 +22,28 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SMemAllocator SMemAllocator;
|
||||
typedef struct SMemAllocatorFactory SMemAllocatorFactory;
|
||||
// Memory allocator
|
||||
#define TD_MEM_ALCT(TYPE) \
|
||||
struct { \
|
||||
void *(*malloc_)(struct TYPE *, uint64_t size); \
|
||||
void (*free_)(struct TYPE *, void *ptr); \
|
||||
}
|
||||
#define TD_MA_MALLOC_FUNC(TMA) (TMA)->malloc_
|
||||
#define TD_MA_FREE_FUNC(TMA) (TMA)->free_
|
||||
|
||||
struct SMemAllocator {
|
||||
void *impl;
|
||||
void *(*malloc)(SMemAllocator *, uint64_t size);
|
||||
void *(*calloc)(SMemAllocator *, uint64_t nmemb, uint64_t size);
|
||||
void *(*realloc)(SMemAllocator *, void *ptr, uint64_t size);
|
||||
void (*free)(SMemAllocator *, void *ptr);
|
||||
uint64_t (*usage)(SMemAllocator *);
|
||||
};
|
||||
#define TD_MA_MALLOC(TMA, SIZE) (*((TMA)->malloc_))(TMA, (SIZE))
|
||||
#define TD_MA_FREE(TMA, PTR) (*((TMA)->free_))(TMA, (PTR))
|
||||
|
||||
struct SMemAllocatorFactory {
|
||||
typedef struct SMemAllocator {
|
||||
void *impl;
|
||||
SMemAllocator *(*create)(SMemAllocatorFactory *);
|
||||
void (*destroy)(SMemAllocatorFactory *, SMemAllocator *);
|
||||
};
|
||||
TD_MEM_ALCT(SMemAllocator);
|
||||
} SMemAllocator;
|
||||
|
||||
typedef struct SMemAllocatorFactory {
|
||||
void *impl;
|
||||
SMemAllocator *(*create)(struct SMemAllocatorFactory *);
|
||||
void (*destroy)(struct SMemAllocatorFactory *, SMemAllocator *);
|
||||
} SMemAllocatorFactory;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -206,44 +206,28 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0392)
|
||||
|
||||
// mnode-stable
|
||||
#define TSDB_CODE_MND_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
#define TSDB_CODE_MND_STB_INVALID_IGEXIST TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
#define TSDB_CODE_MND_STB_INVALID_COLS_NUM TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
#define TSDB_CODE_MND_STB_INVALID_TAGS_NUM TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
#define TSDB_CODE_MND_STB_INVALID_COL_TYPE TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
#define TSDB_CODE_MND_STB_INVALID_COL_ID TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
#define TSDB_CODE_MND_STB_INVALID_COL_BYTES TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
#define TSDB_CODE_MND_STB_INVALID_COL_NAME TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
|
||||
|
||||
#define TSDB_CODE_MND_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0361) //"Table name too long")
|
||||
#define TSDB_CODE_MND_INVALID_TABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x0362) //"Table does not exist")
|
||||
#define TSDB_CODE_MND_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0363) //"Invalid table type in tsdb")
|
||||
#define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x0364) //"Too many tags")
|
||||
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x0365) //"Too many columns")
|
||||
#define TSDB_CODE_MND_TOO_MANY_TIMESERIES TAOS_DEF_ERROR_CODE(0, 0x0366) //"Too many time series")
|
||||
#define TSDB_CODE_MND_NOT_SUPER_TABLE TAOS_DEF_ERROR_CODE(0, 0x0367) //"Not super table") // operation only available for super table
|
||||
#define TSDB_CODE_MND_COL_NAME_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x0368) //"Tag name too long")
|
||||
#define TSDB_CODE_MND_TAG_ALREAY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0369) //"Tag already exists")
|
||||
#define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x036A) //"Tag does not exist")
|
||||
#define TSDB_CODE_MND_FIELD_ALREAY_EXIST TAOS_DEF_ERROR_CODE(0, 0x036B) //"Field already exists")
|
||||
#define TSDB_CODE_MND_FIELD_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x036C) //"Field does not exist")
|
||||
#define TSDB_CODE_MND_INVALID_STABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x036D) //"Super table does not exist")
|
||||
#define TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG TAOS_DEF_ERROR_CODE(0, 0x036E) //"Invalid create table message")
|
||||
#define TSDB_CODE_MND_EXCEED_MAX_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x036F) //"Exceed max row bytes")
|
||||
|
||||
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0370)
|
||||
#define TSDB_CODE_MND_FUNC_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0371)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC TAOS_DEF_ERROR_CODE(0, 0x0372)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_NAME TAOS_DEF_ERROR_CODE(0, 0x0373)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_COMMENT TAOS_DEF_ERROR_CODE(0, 0x0374)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_CODE TAOS_DEF_ERROR_CODE(0, 0x0375)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x0376)
|
||||
|
||||
#define TSDB_CODE_MND_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0376) //"invalid tag length")
|
||||
#define TSDB_CODE_MND_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0377) //"invalid column length")
|
||||
#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
|
||||
#define TSDB_CODE_MND_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A1)
|
||||
#define TSDB_CODE_MND_TOO_MANY_STBS TAOS_DEF_ERROR_CODE(0, 0x03A2)
|
||||
#define TSDB_CODE_MND_INVALID_STB TAOS_DEF_ERROR_CODE(0, 0x03A3)
|
||||
#define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x03A4)
|
||||
#define TSDB_CODE_MND_STB_OPTION_UNCHNAGED TAOS_DEF_ERROR_CODE(0, 0x03A5)
|
||||
#define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x03A6)
|
||||
#define TSDB_CODE_MND_TAG_ALREAY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A7)
|
||||
#define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A8)
|
||||
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x03A9)
|
||||
#define TSDB_CODE_MND_COLUMN_ALREAY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AA)
|
||||
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AB)
|
||||
#define TSDB_CODE_MND_EXCEED_MAX_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x03AC)
|
||||
|
||||
// mnode-func
|
||||
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
|
||||
#define TSDB_CODE_MND_FUNC_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C1)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC TAOS_DEF_ERROR_CODE(0, 0x03C2)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_NAME TAOS_DEF_ERROR_CODE(0, 0x03C3)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_COMMENT TAOS_DEF_ERROR_CODE(0, 0x03C4)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_CODE TAOS_DEF_ERROR_CODE(0, 0x03C5)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x03C6)
|
||||
|
||||
// dnode
|
||||
#define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0400)
|
||||
|
|
|
@ -235,6 +235,7 @@ do { \
|
|||
#define TSDB_MAX_VNODES 512
|
||||
#define TSDB_MIN_VNODES_PER_DB 1
|
||||
#define TSDB_MAX_VNODES_PER_DB 4096
|
||||
#define TSDB_DEFAULT_VN_PER_DB 2
|
||||
|
||||
#define TSDB_DNODE_ROLE_ANY 0
|
||||
#define TSDB_DNODE_ROLE_MGMT 1
|
||||
|
|
|
@ -1,169 +0,0 @@
|
|||
/*
|
||||
* 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_UTIL_TDLIST_H_
|
||||
#define _TD_UTIL_TDLIST_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Single linked list
|
||||
#define TD_SLIST_NODE(TYPE) \
|
||||
struct { \
|
||||
struct TYPE *sl_next_; \
|
||||
}
|
||||
|
||||
#define TD_SLIST(TYPE) \
|
||||
struct { \
|
||||
struct TYPE *sl_head_; \
|
||||
int sl_neles_; \
|
||||
}
|
||||
|
||||
#define TD_SLIST_HEAD(sl) ((sl)->sl_head_)
|
||||
#define TD_SLIST_NELES(sl) ((sl)->sl_neles_)
|
||||
#define TD_SLIST_NODE_NEXT(sln) ((sln)->sl_next_)
|
||||
|
||||
#define tSListInit(sl) \
|
||||
do { \
|
||||
(sl)->sl_head_ = NULL; \
|
||||
(sl)->sl_neles_ = 0; \
|
||||
} while (0)
|
||||
|
||||
#define tSListPush(sl, sln) \
|
||||
do { \
|
||||
TD_SLIST_NODE_NEXT(sln) = TD_SLIST_HEAD(sl); \
|
||||
TD_SLIST_HEAD(sl) = (sln); \
|
||||
TD_SLIST_NELES(sl) += 1; \
|
||||
} while (0)
|
||||
|
||||
#define tSListPop(sl) \
|
||||
do { \
|
||||
TD_SLIST_HEAD(sl) = TD_SLIST_NODE_NEXT(TD_SLIST_HEAD(sl)); \
|
||||
TD_SLIST_NELES(sl) -= 1; \
|
||||
} while (0)
|
||||
|
||||
// Double linked list
|
||||
#define TD_DLIST_NODE(TYPE) \
|
||||
struct { \
|
||||
struct TYPE *dl_prev_; \
|
||||
struct TYPE *dl_next_; \
|
||||
}
|
||||
|
||||
#define TD_DLIST(TYPE) \
|
||||
struct { \
|
||||
struct TYPE *dl_head_; \
|
||||
struct TYPE *dl_tail_; \
|
||||
int dl_neles_; \
|
||||
}
|
||||
|
||||
#define TD_DLIST_NODE_PREV(dln) ((dln)->dl_prev_)
|
||||
#define TD_DLIST_NODE_NEXT(dln) ((dln)->dl_next_)
|
||||
#define TD_DLIST_HEAD(dl) ((dl)->dl_head_)
|
||||
#define TD_DLIST_TAIL(dl) ((dl)->dl_tail_)
|
||||
#define TD_DLIST_NELES(dl) ((dl)->dl_neles_)
|
||||
|
||||
#define tDListInit(dl) \
|
||||
do { \
|
||||
TD_DLIST_HEAD(dl) = TD_DLIST_TAIL(dl) = NULL; \
|
||||
TD_DLIST_NELES(dl) = 0; \
|
||||
} while (0)
|
||||
|
||||
#define tDListAppend(dl, dln) \
|
||||
do { \
|
||||
if (TD_DLIST_HEAD(dl) == NULL) { \
|
||||
TD_DLIST_NODE_PREV(dln) = TD_DLIST_NODE_NEXT(dln) = NULL; \
|
||||
TD_DLIST_HEAD(dl) = TD_DLIST_TAIL(dl) = (dln); \
|
||||
} else { \
|
||||
TD_DLIST_NODE_PREV(dln) = TD_DLIST_TAIL(dl); \
|
||||
TD_DLIST_NODE_NEXT(dln) = NULL; \
|
||||
TD_DLIST_NODE_NEXT(TD_DLIST_TAIL(dl)) = (dln); \
|
||||
TD_DLIST_TAIL(dl) = (dln); \
|
||||
} \
|
||||
TD_DLIST_NELES(dl) += 1; \
|
||||
} while (0)
|
||||
|
||||
#define tDListPrepend(dl, dln) \
|
||||
do { \
|
||||
if (TD_DLIST_HEAD(dl) == NULL) { \
|
||||
TD_DLIST_NODE_PREV(dln) = TD_DLIST_NODE_NEXT(dln) = NULL; \
|
||||
TD_DLIST_HEAD(dl) = TD_DLIST_TAIL(dl) = (dln); \
|
||||
} else { \
|
||||
TD_DLIST_NODE_PREV(dln) = NULL; \
|
||||
TD_DLIST_NODE_NEXT(dln) = TD_DLIST_HEAD(dl); \
|
||||
TD_DLIST_NODE_PREV(TD_DLIST_HEAD(dl)) = (dln); \
|
||||
TD_DLIST_HEAD(dl) = (dln); \
|
||||
} \
|
||||
TD_DLIST_NELES(dl) += 1; \
|
||||
} while (0)
|
||||
|
||||
#define tDListPop(dl, dln) \
|
||||
do { \
|
||||
if (TD_DLIST_HEAD(dl) == (dln)) { \
|
||||
TD_DLIST_HEAD(dl) = TD_DLIST_NODE_NEXT(dln); \
|
||||
} \
|
||||
if (TD_DLIST_TAIL(dl) == (dln)) { \
|
||||
TD_DLIST_TAIL(dl) = TD_DLIST_NODE_PREV(dln); \
|
||||
} \
|
||||
if (TD_DLIST_NODE_PREV(dln) != NULL) { \
|
||||
TD_DLIST_NODE_NEXT(TD_DLIST_NODE_PREV(dln)) = TD_DLIST_NODE_NEXT(dln); \
|
||||
} \
|
||||
if (TD_DLIST_NODE_NEXT(dln) != NULL) { \
|
||||
TD_DLIST_NODE_PREV(TD_DLIST_NODE_NEXT(dln)) = TD_DLIST_NODE_PREV(dln); \
|
||||
} \
|
||||
TD_DLIST_NELES(dl) -= 1; \
|
||||
TD_DLIST_NODE_PREV(dln) = TD_DLIST_NODE_NEXT(dln) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#if 0
|
||||
// List iterator
|
||||
#define TD_LIST_FITER 0
|
||||
#define TD_LIST_BITER 1
|
||||
#define TD_LIST_ITER(S) \
|
||||
struct { \
|
||||
int it_dir_; \
|
||||
S * it_next_; \
|
||||
S * it_ptr_; \
|
||||
TD_DLIST(S) * it_list_; \
|
||||
}
|
||||
|
||||
#define tlistIterInit(it, l, dir) \
|
||||
(it)->it_dir_ = (dir); \
|
||||
(it)->it_list_ = l; \
|
||||
if ((dir) == TD_LIST_FITER) { \
|
||||
(it)->it_next_ = (l)->dl_head_; \
|
||||
} else { \
|
||||
(it)->it_next_ = (l)->dl_tail_; \
|
||||
}
|
||||
|
||||
#define tlistIterNext(it) \
|
||||
({ \
|
||||
(it)->it_ptr_ = (it)->it_next_; \
|
||||
if ((it)->it_next_ != NULL) { \
|
||||
if ((it)->it_dir_ == TD_LIST_FITER) { \
|
||||
(it)->it_next_ = (it)->it_next_->next_; \
|
||||
} else { \
|
||||
(it)->it_next_ = (it)->it_next_->prev_; \
|
||||
} \
|
||||
} \
|
||||
(it)->it_ptr_; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_TDLIST_H_*/
|
|
@ -19,19 +19,124 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Single linked list ================
|
||||
#define TD_SLIST_NODE(TYPE) \
|
||||
struct { \
|
||||
struct TYPE *sl_next_; \
|
||||
}
|
||||
|
||||
#define TD_SLIST(TYPE) \
|
||||
struct { \
|
||||
struct TYPE *sl_head_; \
|
||||
int sl_neles_; \
|
||||
}
|
||||
|
||||
#define TD_SLIST_HEAD(sl) ((sl)->sl_head_)
|
||||
#define TD_SLIST_NELES(sl) ((sl)->sl_neles_)
|
||||
#define TD_SLIST_NODE_NEXT(sln) ((sln)->sl_next_)
|
||||
|
||||
#define TD_SLIST_INIT(sl) \
|
||||
do { \
|
||||
(sl)->sl_head_ = NULL; \
|
||||
(sl)->sl_neles_ = 0; \
|
||||
} while (0)
|
||||
|
||||
#define TD_SLIST_PUSH(sl, sln) \
|
||||
do { \
|
||||
TD_SLIST_NODE_NEXT(sln) = TD_SLIST_HEAD(sl); \
|
||||
TD_SLIST_HEAD(sl) = (sln); \
|
||||
TD_SLIST_NELES(sl) += 1; \
|
||||
} while (0)
|
||||
|
||||
#define TD_SLIST_POP(sl) \
|
||||
do { \
|
||||
TD_SLIST_HEAD(sl) = TD_SLIST_NODE_NEXT(TD_SLIST_HEAD(sl)); \
|
||||
TD_SLIST_NELES(sl) -= 1; \
|
||||
} while (0)
|
||||
|
||||
// Double linked list ================
|
||||
#define TD_DLIST_NODE(TYPE) \
|
||||
struct { \
|
||||
struct TYPE *dl_prev_; \
|
||||
struct TYPE *dl_next_; \
|
||||
}
|
||||
|
||||
#define TD_DLIST(TYPE) \
|
||||
struct { \
|
||||
struct TYPE *dl_head_; \
|
||||
struct TYPE *dl_tail_; \
|
||||
int dl_neles_; \
|
||||
}
|
||||
|
||||
#define TD_DLIST_NODE_PREV(dln) ((dln)->dl_prev_)
|
||||
#define TD_DLIST_NODE_NEXT(dln) ((dln)->dl_next_)
|
||||
#define TD_DLIST_HEAD(dl) ((dl)->dl_head_)
|
||||
#define TD_DLIST_TAIL(dl) ((dl)->dl_tail_)
|
||||
#define TD_DLIST_NELES(dl) ((dl)->dl_neles_)
|
||||
|
||||
#define TD_DLIST_INIT(dl) \
|
||||
do { \
|
||||
TD_DLIST_HEAD(dl) = TD_DLIST_TAIL(dl) = NULL; \
|
||||
TD_DLIST_NELES(dl) = 0; \
|
||||
} while (0)
|
||||
|
||||
#define TD_DLIST_APPEND(dl, dln) \
|
||||
do { \
|
||||
if (TD_DLIST_HEAD(dl) == NULL) { \
|
||||
TD_DLIST_NODE_PREV(dln) = TD_DLIST_NODE_NEXT(dln) = NULL; \
|
||||
TD_DLIST_HEAD(dl) = TD_DLIST_TAIL(dl) = (dln); \
|
||||
} else { \
|
||||
TD_DLIST_NODE_PREV(dln) = TD_DLIST_TAIL(dl); \
|
||||
TD_DLIST_NODE_NEXT(dln) = NULL; \
|
||||
TD_DLIST_NODE_NEXT(TD_DLIST_TAIL(dl)) = (dln); \
|
||||
TD_DLIST_TAIL(dl) = (dln); \
|
||||
} \
|
||||
TD_DLIST_NELES(dl) += 1; \
|
||||
} while (0)
|
||||
|
||||
#define TD_DLIST_PREPEND(dl, dln) \
|
||||
do { \
|
||||
if (TD_DLIST_HEAD(dl) == NULL) { \
|
||||
TD_DLIST_NODE_PREV(dln) = TD_DLIST_NODE_NEXT(dln) = NULL; \
|
||||
TD_DLIST_HEAD(dl) = TD_DLIST_TAIL(dl) = (dln); \
|
||||
} else { \
|
||||
TD_DLIST_NODE_PREV(dln) = NULL; \
|
||||
TD_DLIST_NODE_NEXT(dln) = TD_DLIST_HEAD(dl); \
|
||||
TD_DLIST_NODE_PREV(TD_DLIST_HEAD(dl)) = (dln); \
|
||||
TD_DLIST_HEAD(dl) = (dln); \
|
||||
} \
|
||||
TD_DLIST_NELES(dl) += 1; \
|
||||
} while (0)
|
||||
|
||||
#define TD_DLIST_POP(dl, dln) \
|
||||
do { \
|
||||
if (TD_DLIST_HEAD(dl) == (dln)) { \
|
||||
TD_DLIST_HEAD(dl) = TD_DLIST_NODE_NEXT(dln); \
|
||||
} \
|
||||
if (TD_DLIST_TAIL(dl) == (dln)) { \
|
||||
TD_DLIST_TAIL(dl) = TD_DLIST_NODE_PREV(dln); \
|
||||
} \
|
||||
if (TD_DLIST_NODE_PREV(dln) != NULL) { \
|
||||
TD_DLIST_NODE_NEXT(TD_DLIST_NODE_PREV(dln)) = TD_DLIST_NODE_NEXT(dln); \
|
||||
} \
|
||||
if (TD_DLIST_NODE_NEXT(dln) != NULL) { \
|
||||
TD_DLIST_NODE_PREV(TD_DLIST_NODE_NEXT(dln)) = TD_DLIST_NODE_PREV(dln); \
|
||||
} \
|
||||
TD_DLIST_NELES(dl) -= 1; \
|
||||
TD_DLIST_NODE_PREV(dln) = TD_DLIST_NODE_NEXT(dln) = NULL; \
|
||||
} while (0)
|
||||
|
||||
// General double linked list
|
||||
typedef enum { TD_LIST_FORWARD, TD_LIST_BACKWARD } TD_LIST_DIRECTION_T;
|
||||
|
||||
typedef struct _list_node {
|
||||
struct _list_node *next;
|
||||
struct _list_node *prev;
|
||||
char data[];
|
||||
typedef struct SListNode {
|
||||
TD_DLIST_NODE(SListNode);
|
||||
char data[];
|
||||
} SListNode;
|
||||
|
||||
typedef struct {
|
||||
struct _list_node *head;
|
||||
struct _list_node *tail;
|
||||
int numOfEles;
|
||||
int eleSize;
|
||||
TD_DLIST(SListNode);
|
||||
int eleSize;
|
||||
} SList;
|
||||
|
||||
typedef struct {
|
||||
|
@ -39,11 +144,11 @@ typedef struct {
|
|||
TD_LIST_DIRECTION_T direction;
|
||||
} SListIter;
|
||||
|
||||
#define listHead(l) (l)->head
|
||||
#define listTail(l) (l)->tail
|
||||
#define listNEles(l) (l)->numOfEles
|
||||
#define listEleSize(l) (l)->eleSize
|
||||
#define isListEmpty(l) ((l)->numOfEles == 0)
|
||||
#define listHead(l) TD_DLIST_HEAD(l)
|
||||
#define listTail(l) TD_DLIST_TAIL(l)
|
||||
#define listNEles(l) TD_DLIST_NELES(l)
|
||||
#define listEleSize(l) ((l)->eleSize)
|
||||
#define isListEmpty(l) (TD_DLIST_NELES(l) == 0)
|
||||
#define listNodeFree(n) free(n)
|
||||
|
||||
void tdListInit(SList *list, int eleSize);
|
||||
|
|
|
@ -2,14 +2,13 @@ aux_source_directory(src CLIENT_SRC)
|
|||
add_library(taos ${CLIENT_SRC})
|
||||
target_include_directories(
|
||||
taos
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/client"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/client"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_link_libraries(
|
||||
taos
|
||||
PRIVATE common
|
||||
INTERFACE api
|
||||
PRIVATE os util common transport parser catalog function query
|
||||
PRIVATE os util common transport parser catalog function qcom
|
||||
)
|
||||
|
||||
ADD_SUBDIRECTORY(test)
|
|
@ -20,8 +20,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <common.h>
|
||||
#include "taos.h"
|
||||
#include "common.h"
|
||||
#include "taosmsg.h"
|
||||
#include "tdef.h"
|
||||
#include "tep.h"
|
||||
|
@ -76,11 +76,10 @@ typedef struct SAppInfo {
|
|||
typedef struct STscObj {
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_PASSWORD_LEN];
|
||||
char acctId[TSDB_ACCT_ID_LEN];
|
||||
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
||||
int32_t acctId;
|
||||
uint32_t connId;
|
||||
uint64_t id; // ref ID returned by taosAddRef
|
||||
// struct SSqlObj *sqlList;
|
||||
void *pTransporter;
|
||||
pthread_mutex_t mutex; // used to protect the operation on db
|
||||
int32_t numOfReqs; // number of sqlObj from this tscObj
|
||||
|
@ -88,9 +87,15 @@ typedef struct STscObj {
|
|||
} STscObj;
|
||||
|
||||
typedef struct SClientResultInfo {
|
||||
SSDataBlock *pData;
|
||||
TAOS_FIELD *resultFields;
|
||||
const char *pMsg;
|
||||
const char *pData;
|
||||
TAOS_FIELD *fields;
|
||||
int32_t numOfCols;
|
||||
int32_t numOfRows;
|
||||
int32_t current;
|
||||
int32_t *length;
|
||||
TAOS_ROW row;
|
||||
char **pCol;
|
||||
} SClientResultInfo;
|
||||
|
||||
typedef struct SReqBody {
|
||||
|
@ -98,6 +103,7 @@ typedef struct SReqBody {
|
|||
void* fp;
|
||||
void* param;
|
||||
int32_t paramLen;
|
||||
int64_t execId; // showId/queryId
|
||||
SClientResultInfo* pResInfo;
|
||||
} SRequestBody;
|
||||
|
||||
|
@ -152,6 +158,7 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
|
|||
TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen);
|
||||
|
||||
void* doFetchRow(SRequestObj* pRequest);
|
||||
void setResultDataPtr(SClientResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
static int32_t initEpSetFromCfg(const char *firstEp, const char *secondEp, SCorEpSet *pEpSet);
|
||||
static int32_t buildConnectMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody);
|
||||
static void destroyConnectMsg(SRequestMsgBody* pMsgBody);
|
||||
static void destroyRequestMsgBody(SRequestMsgBody* pMsgBody);
|
||||
|
||||
static int32_t sendMsgToServer(void *pTransporter, SEpSet* epSet, const SRequestMsgBody *pBody, int64_t* pTransporterId);
|
||||
|
||||
|
@ -99,17 +99,19 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
|
|||
|
||||
char* key = getClusterKey(user, secretEncrypt, ip, port);
|
||||
|
||||
SAppInstInfo* pInst = taosHashGet(appInfo.pInstMap, key, strlen(key));
|
||||
SAppInstInfo** pInst = taosHashGet(appInfo.pInstMap, key, strlen(key));
|
||||
if (pInst == NULL) {
|
||||
pInst = calloc(1, sizeof(struct SAppInstInfo));
|
||||
SAppInstInfo* p = calloc(1, sizeof(struct SAppInstInfo));
|
||||
|
||||
pInst->mgmtEp = epSet;
|
||||
pInst->pTransporter = openTransporter(user, secretEncrypt);
|
||||
p->mgmtEp = epSet;
|
||||
p->pTransporter = openTransporter(user, secretEncrypt);
|
||||
taosHashPut(appInfo.pInstMap, key, strlen(key), &p, POINTER_BYTES);
|
||||
|
||||
taosHashPut(appInfo.pInstMap, key, strlen(key), &pInst, POINTER_BYTES);
|
||||
pInst = &p;
|
||||
}
|
||||
|
||||
return taosConnectImpl(ip, user, &secretEncrypt[0], db, port, NULL, NULL, pInst);
|
||||
tfree(key);
|
||||
return taosConnectImpl(ip, user, &secretEncrypt[0], db, port, NULL, NULL, *pInst);
|
||||
}
|
||||
|
||||
TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
|
||||
|
@ -151,7 +153,7 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
|
|||
void* output = NULL;
|
||||
int32_t outputLen = 0;
|
||||
code = qParseQuerySql(pRequest->sqlstr, sqlLen, pRequest->requestId, &type, &output, &outputLen, pRequest->msgBuf, ERROR_MSG_BUF_DEFAULT_SIZE);
|
||||
if (type == TSDB_SQL_CREATE_USER || type == TSDB_SQL_SHOW) {
|
||||
if (type == TSDB_SQL_CREATE_USER || type == TSDB_SQL_SHOW || type == TSDB_SQL_DROP_USER || type == TSDB_SQL_CREATE_DB) {
|
||||
pRequest->type = type;
|
||||
pRequest->body.param = output;
|
||||
pRequest->body.paramLen = outputLen;
|
||||
|
@ -163,7 +165,7 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
|
|||
sendMsgToServer(pTscObj->pTransporter, &pTscObj->pAppInfo->mgmtEp.epSet, &body, &transporterId);
|
||||
|
||||
tsem_wait(&pRequest->body.rspSem);
|
||||
destroyConnectMsg(&body);
|
||||
destroyRequestMsgBody(&body);
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
|
@ -234,7 +236,7 @@ STscObj* taosConnectImpl(const char *ip, const char *user, const char *auth, con
|
|||
sendMsgToServer(pTscObj->pTransporter, &pTscObj->pAppInfo->mgmtEp.epSet, &body, &transporterId);
|
||||
|
||||
tsem_wait(&pRequest->body.rspSem);
|
||||
destroyConnectMsg(&body);
|
||||
destroyRequestMsgBody(&body);
|
||||
|
||||
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
||||
const char *errorMsg = (pRequest->code == TSDB_CODE_RPC_FQDN_ERROR) ? taos_errstr(pRequest) : tstrerror(terrno);
|
||||
|
@ -281,7 +283,7 @@ static int32_t buildConnectMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void destroyConnectMsg(SRequestMsgBody* pMsgBody) {
|
||||
static void destroyRequestMsgBody(SRequestMsgBody* pMsgBody) {
|
||||
assert(pMsgBody != NULL);
|
||||
tfree(pMsgBody->pData);
|
||||
}
|
||||
|
@ -337,7 +339,14 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
|||
tscDebug("0x%" PRIx64 " message:%s, code:%s rspLen:%d, elapsed:%"PRId64 " ms", pRequest->requestId, taosMsg[pMsg->msgType],
|
||||
tstrerror(pMsg->code), pMsg->contLen, pRequest->metric.rsp - pRequest->metric.start);
|
||||
if (handleRequestRspFp[pRequest->type]) {
|
||||
pMsg->code = (*handleRequestRspFp[pRequest->type])(pRequest, pMsg->pCont, pMsg->contLen);
|
||||
char *p = malloc(pMsg->contLen);
|
||||
if (p == NULL) {
|
||||
pRequest->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = pRequest->code;
|
||||
} else {
|
||||
memcpy(p, pMsg->pCont, pMsg->contLen);
|
||||
pMsg->code = (*handleRequestRspFp[pRequest->type])(pRequest, p, pMsg->contLen);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tscError("0x%" PRIx64 " SQL cmd:%s, code:%s rspLen:%d, elapsed time:%"PRId64" ms", pRequest->requestId, taosMsg[pMsg->msgType],
|
||||
|
@ -381,15 +390,54 @@ void* doFetchRow(SRequestObj* pRequest) {
|
|||
assert(pRequest != NULL);
|
||||
SClientResultInfo* pResultInfo = pRequest->body.pResInfo;
|
||||
|
||||
if (pResultInfo == NULL || pResultInfo->current >= pResultInfo->pData->info.rows) {
|
||||
if (pResultInfo == NULL) {
|
||||
pRequest->body.pResInfo = calloc(1, sizeof(SClientResultInfo));
|
||||
// pRequest->body.pResInfo.
|
||||
if (pResultInfo->pData == NULL || pResultInfo->current >= pResultInfo->numOfRows) {
|
||||
pRequest->type = TSDB_SQL_RETRIEVE_MNODE;
|
||||
|
||||
SRequestMsgBody body = {0};
|
||||
buildRequestMsgFp[pRequest->type](pRequest, &body);
|
||||
|
||||
int64_t transporterId = 0;
|
||||
STscObj* pTscObj = pRequest->pTscObj;
|
||||
sendMsgToServer(pTscObj->pTransporter, &pTscObj->pAppInfo->mgmtEp.epSet, &body, &transporterId);
|
||||
|
||||
tsem_wait(&pRequest->body.rspSem);
|
||||
destroyRequestMsgBody(&body);
|
||||
|
||||
pResultInfo->current = 0;
|
||||
if (pResultInfo->numOfRows <= pResultInfo->current) {
|
||||
return NULL;
|
||||
}
|
||||
// current data set are exhausted, fetch more result from node
|
||||
// if (pRes->row >= pRes->numOfRows && needToFetchNewBlock(pSql)) {
|
||||
// taos_fetch_rows_a(res, waitForRetrieveRsp, pSql->pTscObj);
|
||||
// tsem_wait(&pSql->rspSem);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
for(int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
||||
pResultInfo->row[i] = pResultInfo->pCol[i] + pResultInfo->fields[i].bytes * pResultInfo->current;
|
||||
if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
||||
pResultInfo->length[i] = varDataLen(pResultInfo->row[i]);
|
||||
pResultInfo->row[i] = varDataVal(pResultInfo->row[i]);
|
||||
}
|
||||
}
|
||||
|
||||
pResultInfo->current += 1;
|
||||
return pResultInfo->row;
|
||||
}
|
||||
|
||||
void setResultDataPtr(SClientResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows) {
|
||||
assert(numOfCols > 0 && pFields != NULL && pResultInfo != NULL);
|
||||
if (numOfRows == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t offset = 0;
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
pResultInfo->length[i] = pResultInfo->fields[i].bytes;
|
||||
pResultInfo->row[i] = (char*) (pResultInfo->pData + offset * pResultInfo->numOfRows);
|
||||
pResultInfo->pCol[i] = pResultInfo->row[i];
|
||||
offset += pResultInfo->fields[i].bytes;
|
||||
}
|
||||
}
|
||||
|
||||
const char *taos_get_client_info() { return version; }
|
||||
|
||||
int taos_affected_rows(TAOS_RES *res) { return 1; }
|
||||
|
||||
int taos_result_precision(TAOS_RES *res) { return TSDB_TIME_PRECISION_MILLI; }
|
||||
|
|
|
@ -28,7 +28,6 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
|||
}
|
||||
|
||||
int ret = taos_options_imp(option, (const char*)arg);
|
||||
|
||||
atomic_store_32(&lock, 0);
|
||||
return ret;
|
||||
}
|
||||
|
@ -58,18 +57,18 @@ void taos_cleanup(void) {
|
|||
}
|
||||
|
||||
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
|
||||
int32_t p = (port != 0)? port:tsServerPort;
|
||||
int32_t p = (port != 0) ? port : tsServerPort;
|
||||
|
||||
tscDebug("try to connect to %s:%u, user:%s db:%s", ip, p, user, db);
|
||||
if (user == NULL) {
|
||||
user = TSDB_DEFAULT_USER;
|
||||
}
|
||||
tscDebug("try to connect to %s:%u, user:%s db:%s", ip, p, user, db);
|
||||
if (user == NULL) {
|
||||
user = TSDB_DEFAULT_USER;
|
||||
}
|
||||
|
||||
if (pass == NULL) {
|
||||
pass = TSDB_DEFAULT_PASS;
|
||||
}
|
||||
if (pass == NULL) {
|
||||
pass = TSDB_DEFAULT_PASS;
|
||||
}
|
||||
|
||||
return taos_connect_internal(ip, user, pass, NULL, db, p);
|
||||
return taos_connect_internal(ip, user, pass, NULL, db, p);
|
||||
}
|
||||
|
||||
void taos_close(TAOS* taos) {
|
||||
|
@ -110,6 +109,34 @@ void taos_free_result(TAOS_RES *res) {
|
|||
destroyRequest(pRequest);
|
||||
}
|
||||
|
||||
int taos_field_count(TAOS_RES *res) {
|
||||
if (res == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SRequestObj* pRequest = (SRequestObj*) res;
|
||||
|
||||
SClientResultInfo* pResInfo = pRequest->body.pResInfo;
|
||||
if (pResInfo == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return pResInfo->numOfCols;
|
||||
}
|
||||
|
||||
int taos_num_fields(TAOS_RES *res) {
|
||||
return taos_field_count(res);
|
||||
}
|
||||
|
||||
TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
||||
if (taos_num_fields(res) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SClientResultInfo* pResInfo = ((SRequestObj*) res)->body.pResInfo;
|
||||
return pResInfo->fields;
|
||||
}
|
||||
|
||||
TAOS_RES *taos_query(TAOS *taos, const char *sql) {
|
||||
if (taos == NULL || sql == NULL) {
|
||||
return NULL;
|
||||
|
@ -131,3 +158,112 @@ TAOS_ROW taos_fetch_row(TAOS_RES *pRes) {
|
|||
|
||||
return doFetchRow(pRequest);
|
||||
}
|
||||
|
||||
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
||||
int32_t len = 0;
|
||||
for (int i = 0; i < num_fields; ++i) {
|
||||
if (i > 0) {
|
||||
str[len++] = ' ';
|
||||
}
|
||||
|
||||
if (row[i] == NULL) {
|
||||
len += sprintf(str + len, "%s", TSDB_DATA_NULL_STR);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (fields[i].type) {
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
len += sprintf(str + len, "%d", *((int8_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
len += sprintf(str + len, "%u", *((uint8_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
len += sprintf(str + len, "%d", *((int16_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
len += sprintf(str + len, "%u", *((uint16_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
len += sprintf(str + len, "%d", *((int32_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
len += sprintf(str + len, "%u", *((uint32_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
len += sprintf(str + len, "%" PRIu64, *((uint64_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float fv = 0;
|
||||
fv = GET_FLOAT_VAL(row[i]);
|
||||
len += sprintf(str + len, "%f", fv);
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
double dv = 0;
|
||||
dv = GET_DOUBLE_VAL(row[i]);
|
||||
len += sprintf(str + len, "%lf", dv);
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
int32_t charLen = varDataLen((char*)row[i] - VARSTR_HEADER_SIZE);
|
||||
if (fields[i].type == TSDB_DATA_TYPE_BINARY) {
|
||||
assert(charLen <= fields[i].bytes && charLen >= 0);
|
||||
} else {
|
||||
assert(charLen <= fields[i].bytes * TSDB_NCHAR_SIZE && charLen >= 0);
|
||||
}
|
||||
|
||||
memcpy(str + len, row[i], charLen);
|
||||
len += charLen;
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
len += sprintf(str + len, "%d", *((int8_t *)row[i]));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int* taos_fetch_lengths(TAOS_RES *res) {
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ((SRequestObj*) res)->body.pResInfo->length;
|
||||
}
|
||||
|
||||
const char *taos_data_type(int type) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_NULL: return "TSDB_DATA_TYPE_NULL";
|
||||
case TSDB_DATA_TYPE_BOOL: return "TSDB_DATA_TYPE_BOOL";
|
||||
case TSDB_DATA_TYPE_TINYINT: return "TSDB_DATA_TYPE_TINYINT";
|
||||
case TSDB_DATA_TYPE_SMALLINT: return "TSDB_DATA_TYPE_SMALLINT";
|
||||
case TSDB_DATA_TYPE_INT: return "TSDB_DATA_TYPE_INT";
|
||||
case TSDB_DATA_TYPE_BIGINT: return "TSDB_DATA_TYPE_BIGINT";
|
||||
case TSDB_DATA_TYPE_FLOAT: return "TSDB_DATA_TYPE_FLOAT";
|
||||
case TSDB_DATA_TYPE_DOUBLE: return "TSDB_DATA_TYPE_DOUBLE";
|
||||
case TSDB_DATA_TYPE_BINARY: return "TSDB_DATA_TYPE_BINARY";
|
||||
case TSDB_DATA_TYPE_TIMESTAMP: return "TSDB_DATA_TYPE_TIMESTAMP";
|
||||
case TSDB_DATA_TYPE_NCHAR: return "TSDB_DATA_TYPE_NCHAR";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include <catalog.h>
|
||||
#include <tname.h>
|
||||
#include "clientInt.h"
|
||||
#include "clientLog.h"
|
||||
#include "os.h"
|
||||
|
@ -529,7 +530,7 @@ int doBuildAndSendMsg(SSqlObj *pSql) {
|
|||
|
||||
if (pCmd->command == TSDB_SQL_SELECT ||
|
||||
pCmd->command == TSDB_SQL_FETCH ||
|
||||
pCmd->command == TSDB_SQL_RETRIEVE ||
|
||||
pCmd->command == TSDB_SQL_RETRIEVE_MNODE ||
|
||||
pCmd->command == TSDB_SQL_INSERT ||
|
||||
pCmd->command == TSDB_SQL_CONNECT ||
|
||||
pCmd->command == TSDB_SQL_HB ||
|
||||
|
@ -2700,7 +2701,7 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
if ((pCmd->command == TSDB_SQL_RETRIEVE) ||
|
||||
if ((pCmd->command == TSDB_SQL_RETRIEVE_MNODE) ||
|
||||
((UTIL_TABLE_IS_CHILD_TABLE(pTableMetaInfo) || UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) &&
|
||||
!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_SUBQUERY)) ||
|
||||
(tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) &&
|
||||
|
@ -2885,7 +2886,7 @@ int32_t getMultiTableMetaFromMnode(SSqlObj *pSql, SArray* pNameList, SArray* pVg
|
|||
}
|
||||
|
||||
int32_t tscGetTableMetaImpl(SSqlObj* pSql, STableMetaInfo *pTableMetaInfo, bool autocreate, bool onlyLocal) {
|
||||
assert(tIsValidName(&pTableMetaInfo->name));
|
||||
assert(tNameIsValid(&pTableMetaInfo->name));
|
||||
|
||||
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
tNameExtractFullName(&pTableMetaInfo->name, name);
|
||||
|
@ -3138,7 +3139,7 @@ int processConnectRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) {
|
|||
// TODO refactor
|
||||
pthread_mutex_lock(&pTscObj->mutex);
|
||||
char temp[TSDB_TABLE_FNAME_LEN * 2] = {0};
|
||||
int32_t len = sprintf(temp, "%s%s%s", pTscObj->acctId, TS_PATH_DELIMITER, pTscObj->db);
|
||||
int32_t len = sprintf(temp, "%d%s%s", pTscObj->acctId, TS_PATH_DELIMITER, pTscObj->db);
|
||||
|
||||
assert(len <= sizeof(pTscObj->db));
|
||||
tstrncpy(pTscObj->db, temp, sizeof(pTscObj->db));
|
||||
|
@ -3153,28 +3154,46 @@ int processConnectRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) {
|
|||
}
|
||||
|
||||
pTscObj->connId = pConnect->connId;
|
||||
pTscObj->acctId = pConnect->acctId;
|
||||
|
||||
// update the appInstInfo
|
||||
pTscObj->pAppInfo->clusterId = pConnect->clusterId;
|
||||
atomic_add_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||
|
||||
pRequest->body.pResInfo = calloc(1, sizeof(SClientResultInfo));
|
||||
pRequest->body.pResInfo->pMsg = pMsg;
|
||||
|
||||
tscDebug("0x%" PRIx64 " clusterId:%d, totalConn:%"PRId64, pRequest->requestId, pConnect->clusterId, pTscObj->pAppInfo->numOfConns);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t buildCreateUserMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) {
|
||||
pMsgBody->msgType = TSDB_MSG_TYPE_CREATE_USER;
|
||||
pMsgBody->msgLen = sizeof(SCreateUserMsg);
|
||||
int32_t doBuildMsgSupp(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) {
|
||||
pMsgBody->requestObjRefId = pRequest->self;
|
||||
pMsgBody->pData = pRequest->body.param;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t buildShowMsg(SRequestObj* pRequest, SRequestMsgBody* pMsgBody) {
|
||||
pMsgBody->msgType = TSDB_MSG_TYPE_SHOW;
|
||||
pMsgBody->msgLen = pRequest->body.paramLen;
|
||||
pMsgBody->requestObjRefId = pRequest->self;
|
||||
pMsgBody->pData = pRequest->body.param;
|
||||
|
||||
switch(pRequest->type) {
|
||||
case TSDB_SQL_CREATE_USER:
|
||||
pMsgBody->msgType = TSDB_MSG_TYPE_CREATE_USER;
|
||||
break;
|
||||
case TSDB_SQL_CREATE_DB: {
|
||||
pMsgBody->msgType = TSDB_MSG_TYPE_CREATE_DB;
|
||||
|
||||
SCreateDbMsg* pCreateMsg = pRequest->body.param;
|
||||
SName name = {0};
|
||||
int32_t ret = tNameSetDbName(&name, pRequest->pTscObj->acctId, pCreateMsg->db, strnlen(pCreateMsg->db, tListLen(pCreateMsg->db)));
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
tNameGetFullDbName(&name, pCreateMsg->db);
|
||||
|
||||
break;
|
||||
}
|
||||
case TSDB_SQL_SHOW:
|
||||
pMsgBody->msgType = TSDB_MSG_TYPE_SHOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
STableMeta* createTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) {
|
||||
|
@ -3217,26 +3236,73 @@ int32_t processShowRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen)
|
|||
SSchema* pSchema = pMetaMsg->pSchema;
|
||||
pMetaMsg->tuid = htobe64(pMetaMsg->tuid);
|
||||
for (int i = 0; i < pMetaMsg->numOfColumns; ++i) {
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
pSchema++;
|
||||
}
|
||||
|
||||
STableMeta* pTableMeta = createTableMetaFromMsg(pMetaMsg);
|
||||
SSchema *pTableSchema = pTableMeta->schema;
|
||||
|
||||
TAOS_FIELD* pFields = calloc(1, pTableMeta->tableInfo.numOfColumns);
|
||||
for (int16_t i = 0; i < pTableMeta->tableInfo.numOfColumns; ++i, ++pSchema) {
|
||||
tstrncpy(pFields[i].name, pTableSchema[i].name, tListLen(pFields[i].name));
|
||||
pFields[i].type = pTableSchema[i].type;
|
||||
pFields[i].bytes = pTableSchema[i].bytes;
|
||||
pSchema = pMetaMsg->pSchema;
|
||||
TAOS_FIELD* pFields = calloc(pMetaMsg->numOfColumns, sizeof(TAOS_FIELD));
|
||||
for (int32_t i = 0; i < pMetaMsg->numOfColumns; ++i) {
|
||||
tstrncpy(pFields[i].name, pSchema[i].name, tListLen(pFields[i].name));
|
||||
pFields[i].type = pSchema[i].type;
|
||||
pFields[i].bytes = pSchema[i].bytes;
|
||||
}
|
||||
|
||||
// pRequest->body.resultFields = pFields;
|
||||
// pRequest->body.numOfFields = pTableMeta->tableInfo.numOfColumns;
|
||||
if (pRequest->body.pResInfo == NULL) {
|
||||
pRequest->body.pResInfo = calloc(1, sizeof(SClientResultInfo));
|
||||
}
|
||||
|
||||
pRequest->body.pResInfo->pMsg = pMsg;
|
||||
SClientResultInfo* pResInfo = pRequest->body.pResInfo;
|
||||
|
||||
pResInfo->fields = pFields;
|
||||
pResInfo->numOfCols = pMetaMsg->numOfColumns;
|
||||
pResInfo->row = calloc(pResInfo->numOfCols, POINTER_BYTES);
|
||||
pResInfo->pCol = calloc(pResInfo->numOfCols, POINTER_BYTES);
|
||||
pResInfo->length = calloc(pResInfo->numOfCols, sizeof(int32_t));
|
||||
|
||||
pRequest->body.execId = pShow->showId;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int buildRetrieveMnodeMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) {
|
||||
pMsgBody->msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
|
||||
pMsgBody->msgLen = sizeof(SRetrieveTableMsg);
|
||||
pMsgBody->requestObjRefId = pRequest->self;
|
||||
|
||||
SRetrieveTableMsg *pRetrieveMsg = calloc(1, sizeof(SRetrieveTableMsg));
|
||||
pRetrieveMsg->showId = htonl(pRequest->body.execId);
|
||||
|
||||
pMsgBody->pData = pRetrieveMsg;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t processRetrieveMnodeRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) {
|
||||
assert(msgLen >= sizeof(SRetrieveTableRsp));
|
||||
|
||||
tfree(pRequest->body.pResInfo->pMsg);
|
||||
pRequest->body.pResInfo->pMsg = pMsg;
|
||||
|
||||
SRetrieveTableRsp *pRetrieve = (SRetrieveTableRsp *) pMsg;
|
||||
pRetrieve->numOfRows = htonl(pRetrieve->numOfRows);
|
||||
pRetrieve->precision = htons(pRetrieve->precision);
|
||||
|
||||
SClientResultInfo* pResInfo = pRequest->body.pResInfo;
|
||||
pResInfo->numOfRows = pRetrieve->numOfRows;
|
||||
pResInfo->pData = pRetrieve->data; // todo fix this in async model
|
||||
|
||||
pResInfo->current = 0;
|
||||
setResultDataPtr(pResInfo, pResInfo->fields, pResInfo->numOfCols, pResInfo->numOfRows);
|
||||
|
||||
tscDebug("0x%"PRIx64" numOfRows:%d, complete:%d, qId:0x%"PRIx64, pRequest->self, pRetrieve->numOfRows,
|
||||
pRetrieve->completed, pRequest->body.execId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t processCreateDbRsp(SRequestObj *pRequest, const char* pMsg, int32_t msgLen) {
|
||||
// todo rsp with the vnode id list
|
||||
}
|
||||
|
||||
void initMsgHandleFp() {
|
||||
#if 0
|
||||
tscBuildMsg[TSDB_SQL_SELECT] = tscBuildQueryMsg;
|
||||
|
@ -3273,7 +3339,7 @@ void initMsgHandleFp() {
|
|||
|
||||
tscBuildMsg[TSDB_SQL_HB] = tscBuildHeartBeatMsg;
|
||||
tscBuildMsg[TSDB_SQL_SHOW] = tscBuildShowMsg;
|
||||
tscBuildMsg[TSDB_SQL_RETRIEVE] = tscBuildRetrieveFromMgmtMsg;
|
||||
tscBuildMsg[TSDB_SQL_RETRIEVE_MNODE] = tscBuildRetrieveFromMgmtMsg;
|
||||
tscBuildMsg[TSDB_SQL_KILL_QUERY] = tscBuildKillMsg;
|
||||
tscBuildMsg[TSDB_SQL_KILL_STREAM] = tscBuildKillMsg;
|
||||
tscBuildMsg[TSDB_SQL_KILL_CONNECTION] = tscBuildKillMsg;
|
||||
|
@ -3291,7 +3357,7 @@ void initMsgHandleFp() {
|
|||
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_FUNC] = tscProcessRetrieveFuncRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_SHOW] = tscProcessShowRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_RETRIEVE] = tscProcessRetrieveRspFromNode; // rsp handled by same function.
|
||||
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_MNODE] = tscProcessRetrieveRspFromNode; // rsp handled by same function.
|
||||
tscProcessMsgRsp[TSDB_SQL_DESCRIBE_TABLE] = tscProcessDescribeTableRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_CURRENT_DB] = tscProcessLocalRetrieveRsp;
|
||||
|
@ -3316,9 +3382,14 @@ void initMsgHandleFp() {
|
|||
buildRequestMsgFp[TSDB_SQL_CONNECT] = buildConnectMsg;
|
||||
handleRequestRspFp[TSDB_SQL_CONNECT] = processConnectRsp;
|
||||
|
||||
buildRequestMsgFp[TSDB_SQL_CREATE_USER] = buildCreateUserMsg;
|
||||
buildRequestMsgFp[TSDB_SQL_CREATE_USER] = doBuildMsgSupp;
|
||||
|
||||
buildRequestMsgFp[TSDB_SQL_SHOW] = buildShowMsg;
|
||||
buildRequestMsgFp[TSDB_SQL_SHOW] = doBuildMsgSupp;
|
||||
handleRequestRspFp[TSDB_SQL_SHOW] = processShowRsp;
|
||||
|
||||
buildRequestMsgFp[TSDB_SQL_RETRIEVE_MNODE] = buildRetrieveMnodeMsg;
|
||||
handleRequestRspFp[TSDB_SQL_RETRIEVE_MNODE]= processRetrieveMnodeRsp;
|
||||
|
||||
buildRequestMsgFp[TSDB_SQL_CREATE_DB] = doBuildMsgSupp;
|
||||
handleRequestRspFp[TSDB_SQL_CREATE_DB] = processCreateDbRsp;
|
||||
}
|
|
@ -127,8 +127,6 @@ void destroyTscObj(void *pObj) {
|
|||
|
||||
atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||
tscDebug("connObj 0x%"PRIx64" destroyed, totalConn:%"PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns);
|
||||
|
||||
closeTransporter(pTscObj);
|
||||
pthread_mutex_destroy(&pTscObj->mutex);
|
||||
tfree(pTscObj);
|
||||
}
|
||||
|
@ -190,6 +188,12 @@ static void doDestroyRequest(void* p) {
|
|||
tfree(pRequest->sqlstr);
|
||||
tfree(pRequest->pInfo);
|
||||
|
||||
if (pRequest->body.pResInfo != NULL) {
|
||||
tfree(pRequest->body.pResInfo->pData);
|
||||
tfree(pRequest->body.pResInfo->pMsg);
|
||||
tfree(pRequest->body.pResInfo);
|
||||
}
|
||||
|
||||
deregisterRequest(pRequest);
|
||||
tfree(pRequest);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
|
||||
#include "../inc/clientInt.h"
|
||||
#include "taos.h"
|
||||
|
||||
namespace {
|
||||
|
@ -34,19 +35,90 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
TEST(testCase, driverInit_Test) {
|
||||
taos_init();
|
||||
}
|
||||
|
||||
TEST(testCase, connect_Test) {
|
||||
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||
assert(pConn != NULL);
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
TEST(testCase, create_user_Test) {
|
||||
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||
assert(pConn != NULL);
|
||||
|
||||
// TAOS_RES* pRes = taos_query(pConn, "create user abc pass 'abc'");
|
||||
TAOS_RES* pRes = taos_query(pConn, "create user abc pass 'abc'");
|
||||
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||
printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
//TEST(testCase, drop_user_Test) {
|
||||
// TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||
// assert(pConn != NULL);
|
||||
//
|
||||
// TAOS_RES* pRes = taos_query(pConn, "drop user abc");
|
||||
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||
// printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
||||
// }
|
||||
//
|
||||
// taos_free_result(pRes);
|
||||
// taos_close(pConn);
|
||||
//}
|
||||
|
||||
TEST(testCase, show_user_Test) {
|
||||
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||
assert(pConn != NULL);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "show users");
|
||||
TAOS_ROW pRow = taos_fetch_row(pRes);
|
||||
assert(pRow != NULL);
|
||||
TAOS_ROW pRow = NULL;
|
||||
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
|
||||
char str[512] = {0};
|
||||
while((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||
printf("%s\n", str);
|
||||
}
|
||||
|
||||
taos_close(pConn);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(testCase, show_db_Test) {
|
||||
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||
assert(pConn != NULL);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "show databases");
|
||||
TAOS_ROW pRow = NULL;
|
||||
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
|
||||
char str[512] = {0};
|
||||
while((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||
printf("%s\n", str);
|
||||
}
|
||||
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
TEST(testCase, create_db_Test) {
|
||||
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||
assert(pConn != NULL);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "create database abc");
|
||||
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
ASSERT_TRUE(pFields == NULL);
|
||||
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
ASSERT_EQ(numOfFields, 0);
|
||||
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
#include "tname.h"
|
||||
#include "taosmsg.h"
|
||||
|
||||
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
|
||||
#define VALIDNUMOFTAGS(x) ((x) >= 0 && (x) <= TSDB_MAX_TAGS)
|
||||
|
||||
#define VALID_NAME_TYPE(x) ((x) == TSDB_DB_NAME_T || (x) == TSDB_TABLE_NAME_T)
|
||||
|
||||
char* extractDBName(const char* tableId, char* name) {
|
||||
|
@ -120,84 +117,11 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
|
|||
|
||||
#endif
|
||||
|
||||
static struct SSchema _s = {
|
||||
.colId = TSDB_TBNAME_COLUMN_INDEX,
|
||||
.type = TSDB_DATA_TYPE_BINARY,
|
||||
.bytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE,
|
||||
.name = "tbname",
|
||||
};
|
||||
|
||||
SSchema* tGetTbnameColumnSchema() {
|
||||
return &_s;
|
||||
}
|
||||
|
||||
static bool doValidateSchema(SSchema* pSchema, int32_t numOfCols, int32_t maxLen) {
|
||||
int32_t rowLen = 0;
|
||||
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
// 1. valid types
|
||||
if (!isValidDataType(pSchema[i].type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 2. valid length for each type
|
||||
if (pSchema[i].type == TSDB_DATA_TYPE_BINARY) {
|
||||
if (pSchema[i].bytes > TSDB_MAX_BINARY_LEN) {
|
||||
return false;
|
||||
}
|
||||
} else if (pSchema[i].type == TSDB_DATA_TYPE_NCHAR) {
|
||||
if (pSchema[i].bytes > TSDB_MAX_NCHAR_LEN) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (pSchema[i].bytes != tDataTypes[pSchema[i].type].bytes) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. valid column names
|
||||
for (int32_t j = i + 1; j < numOfCols; ++j) {
|
||||
if (strncasecmp(pSchema[i].name, pSchema[j].name, sizeof(pSchema[i].name) - 1) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
rowLen += pSchema[i].bytes;
|
||||
}
|
||||
|
||||
return rowLen <= maxLen;
|
||||
}
|
||||
|
||||
bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags) {
|
||||
if (!VALIDNUMOFCOLS(numOfCols)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!VALIDNUMOFTAGS(numOfTags)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* first column must be the timestamp, which is a primary key */
|
||||
if (pSchema[0].type != TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!doValidateSchema(pSchema, numOfCols, TSDB_MAX_BYTES_PER_ROW)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!doValidateSchema(&pSchema[numOfCols], numOfTags, TSDB_MAX_TAGS_LEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t tNameExtractFullName(const SName* name, char* dst) {
|
||||
assert(name != NULL && dst != NULL);
|
||||
|
||||
// invalid full name format, abort
|
||||
if (!tIsValidName(name)) {
|
||||
if (!tNameIsValid(name)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -230,7 +154,7 @@ int32_t tNameLen(const SName* name) {
|
|||
}
|
||||
}
|
||||
|
||||
bool tIsValidName(const SName* name) {
|
||||
bool tNameIsValid(const SName* name) {
|
||||
assert(name != NULL);
|
||||
|
||||
if (!VALID_NAME_TYPE(name->type)) {
|
||||
|
@ -265,13 +189,13 @@ int32_t tNameGetDbName(const SName* name, char* dst) {
|
|||
int32_t tNameGetFullDbName(const SName* name, char* dst) {
|
||||
assert(name != NULL && dst != NULL);
|
||||
snprintf(dst, TSDB_ACCT_ID_LEN + TS_PATH_DELIMITER_LEN + TSDB_DB_NAME_LEN, // there is a over write risk
|
||||
"%s.%s", name->acctId, name->dbname);
|
||||
"%d.%s", name->acctId, name->dbname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool tNameIsEmpty(const SName* name) {
|
||||
assert(name != NULL);
|
||||
return name->type == 0 || strlen(name->acctId) <= 0;
|
||||
return name->type == 0 || name->acctId == 0;
|
||||
}
|
||||
|
||||
const char* tNameGetTableName(const SName* name) {
|
||||
|
@ -283,32 +207,23 @@ void tNameAssign(SName* dst, const SName* src) {
|
|||
memcpy(dst, src, sizeof(SName));
|
||||
}
|
||||
|
||||
//int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken) {
|
||||
// assert(dst != NULL && dbToken != NULL && acct != NULL);
|
||||
//
|
||||
// // too long account id or too long db name
|
||||
// if (strlen(acct) >= tListLen(dst->acctId) || dbToken->n >= tListLen(dst->dbname)) {
|
||||
// return -1;
|
||||
// }
|
||||
//
|
||||
// dst->type = TSDB_DB_NAME_T;
|
||||
// tstrncpy(dst->acctId, acct, tListLen(dst->acctId));
|
||||
// tstrncpy(dst->dbname, dbToken->z, dbToken->n + 1);
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
int32_t tNameSetAcctId(SName* dst, const char* acct) {
|
||||
assert(dst != NULL && acct != NULL);
|
||||
int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t nameLen) {
|
||||
assert(dst != NULL && dbName != NULL && nameLen > 0);
|
||||
|
||||
// too long account id or too long db name
|
||||
if (strlen(acct) >= tListLen(dst->acctId)) {
|
||||
if (nameLen >= tListLen(dst->dbname)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
tstrncpy(dst->acctId, acct, tListLen(dst->acctId));
|
||||
dst->type = TSDB_DB_NAME_T;
|
||||
dst->acctId = acct;
|
||||
tstrncpy(dst->dbname, dbName, nameLen + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert(strlen(dst->acctId) > 0);
|
||||
|
||||
int32_t tNameSetAcctId(SName* dst, int32_t acctId) {
|
||||
assert(dst != NULL && acct != NULL);
|
||||
dst->acctId = acctId;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -325,14 +240,11 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) {
|
|||
int32_t len = (int32_t)(p - str);
|
||||
|
||||
// too long account id or too long db name
|
||||
if ((len >= tListLen(dst->acctId)) || (len <= 0)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy (dst->acctId, str, len);
|
||||
dst->acctId[len] = 0;
|
||||
|
||||
assert(strlen(dst->acctId) > 0);
|
||||
// if ((len >= tListLen(dst->acctId)) || (len <= 0)) {
|
||||
// return -1;
|
||||
// }
|
||||
// memcpy (dst->acctId, str, len);
|
||||
dst->acctId = strtoll(str, NULL, 10);
|
||||
}
|
||||
|
||||
if ((type & T_NAME_DB) == T_NAME_DB) {
|
||||
|
|
|
@ -92,6 +92,7 @@ void dmnPrintVersion() {
|
|||
}
|
||||
|
||||
int dmnReadConfig(const char *path) {
|
||||
tstrncpy(configDir, global.configDir, PATH_MAX);
|
||||
taosInitGlobalCfg();
|
||||
taosReadGlobalLogCfg();
|
||||
|
||||
|
|
|
@ -38,14 +38,13 @@ static void dndInitMsgFp(STransMgmt *pMgmt) {
|
|||
pMgmt->msgFp[TSDB_MSG_TYPE_DROP_TABLE] = dndProcessVnodeWriteMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_ALTER_TABLE] = dndProcessVnodeWriteMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_UPDATE_TAG_VAL] = dndProcessVnodeWriteMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_TABLE_META] = dndProcessVnodeQueryMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_TABLE_META] = dndProcessMnodeReadMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_TABLES_META] = dndProcessVnodeQueryMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_MQ_QUERY] = dndProcessVnodeQueryMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_MQ_CONSUME] = dndProcessVnodeQueryMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_MQ_CONNECT] = dndProcessVnodeWriteMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_MQ_DISCONNECT] = dndProcessVnodeWriteMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_MQ_ACK] = dndProcessVnodeWriteMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_MQ_RESET] = dndProcessVnodeWriteMsg;
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_MQ_SET] = dndProcessVnodeWriteMsg;
|
||||
|
||||
// msg from client to mnode
|
||||
pMgmt->msgFp[TSDB_MSG_TYPE_CONNECT] = dndProcessMnodeReadMsg;
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
enable_testing()
|
||||
|
||||
add_subdirectory(acct)
|
||||
# add_subdirectory(auth)
|
||||
# add_subdirectory(balance)
|
||||
# add_subdirectory(cluster)
|
||||
add_subdirectory(cluster)
|
||||
add_subdirectory(db)
|
||||
add_subdirectory(dnode)
|
||||
# add_subdirectory(func)
|
||||
# add_subdirectory(mnode)
|
||||
# add_subdirectory(profile)
|
||||
# add_subdirectory(show)
|
||||
# add_subdirectory(stb)
|
||||
add_subdirectory(stb)
|
||||
# add_subdirectory(sync)
|
||||
# add_subdirectory(telem)
|
||||
# add_subdirectory(trans)
|
||||
|
|
|
@ -21,8 +21,6 @@ target_include_directories(dnode_test_acct
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/../sut"
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(
|
||||
NAME dnode_test_acct
|
||||
COMMAND dnode_test_acct
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file vnodeApiTests.cpp
|
||||
* @file acct.cpp
|
||||
* @author slguan (slguan@taosdata.com)
|
||||
* @brief DNODE module acct-msg tests
|
||||
* @version 0.1
|
||||
|
|
|
@ -1,29 +1,27 @@
|
|||
add_executable(dndTestCluster "")
|
||||
add_executable(dnode_test_cluster "")
|
||||
|
||||
target_sources(dndTestCluster
|
||||
target_sources(dnode_test_cluster
|
||||
PRIVATE
|
||||
"cluster.cpp"
|
||||
"../sut/deploy.cpp"
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
dndTestCluster
|
||||
dnode_test_cluster
|
||||
PUBLIC dnode
|
||||
PUBLIC util
|
||||
PUBLIC os
|
||||
PUBLIC gtest_main
|
||||
)
|
||||
|
||||
target_include_directories(dndTestCluster
|
||||
target_include_directories(dnode_test_cluster
|
||||
PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/include/server/dnode/mgmt"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../inc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../sut"
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(
|
||||
NAME dndTestCluster
|
||||
COMMAND dndTestCluster
|
||||
NAME dnode_test_cluster
|
||||
COMMAND dnode_test_cluster
|
||||
)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file vnodeApiTests.cpp
|
||||
* @file cluster.cpp
|
||||
* @author slguan (slguan@taosdata.com)
|
||||
* @brief DNODE module cluster-msg tests
|
||||
* @version 0.1
|
||||
|
@ -13,154 +13,158 @@
|
|||
|
||||
class DndTestCluster : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {}
|
||||
void TearDown() override {}
|
||||
static SServer* CreateServer(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
||||
SServer* pServer = createServer(path, fqdn, port, firstEp);
|
||||
ASSERT(pServer);
|
||||
return pServer;
|
||||
}
|
||||
|
||||
static void SetUpTestSuite() {
|
||||
const char* user = "root";
|
||||
const char* pass = "taosdata";
|
||||
const char* path = "/tmp/dndTestCluster";
|
||||
const char* fqdn = "localhost";
|
||||
uint16_t port = 9521;
|
||||
initLog("/tmp/tdlog");
|
||||
|
||||
pServer = createServer(path, fqdn, port);
|
||||
ASSERT(pServer);
|
||||
pClient = createClient(user, pass, fqdn, port);
|
||||
const char* fqdn = "localhost";
|
||||
const char* firstEp = "localhost:9030";
|
||||
pServer = CreateServer("/tmp/dnode_test_cluster", fqdn, 9030, firstEp);
|
||||
pClient = createClient("root", "taosdata", fqdn, 9030);
|
||||
taosMsleep(1100);
|
||||
}
|
||||
|
||||
static void TearDownTestSuite() {
|
||||
stopServer(pServer);
|
||||
dropClient(pClient);
|
||||
pServer = NULL;
|
||||
pClient = NULL;
|
||||
}
|
||||
|
||||
static SServer* pServer;
|
||||
static SClient* pClient;
|
||||
static int32_t connId;
|
||||
|
||||
public:
|
||||
void SetUp() override {}
|
||||
void TearDown() override {}
|
||||
|
||||
void SendTheCheckShowMetaMsg(int8_t showType, const char* showName, int32_t columns, const char* db) {
|
||||
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
|
||||
pShow->type = showType;
|
||||
if (db != NULL) {
|
||||
strcpy(pShow->db, db);
|
||||
}
|
||||
SRpcMsg showRpcMsg = {0};
|
||||
showRpcMsg.pCont = pShow;
|
||||
showRpcMsg.contLen = sizeof(SShowMsg);
|
||||
showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW;
|
||||
|
||||
sendMsg(pClient, &showRpcMsg);
|
||||
ASSERT_NE(pClient->pRsp, nullptr);
|
||||
ASSERT_EQ(pClient->pRsp->code, 0);
|
||||
ASSERT_NE(pClient->pRsp->pCont, nullptr);
|
||||
|
||||
SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont;
|
||||
ASSERT_NE(pShowRsp, nullptr);
|
||||
pShowRsp->showId = htonl(pShowRsp->showId);
|
||||
pMeta = &pShowRsp->tableMeta;
|
||||
pMeta->numOfTags = htonl(pMeta->numOfTags);
|
||||
pMeta->numOfColumns = htonl(pMeta->numOfColumns);
|
||||
pMeta->sversion = htonl(pMeta->sversion);
|
||||
pMeta->tversion = htonl(pMeta->tversion);
|
||||
pMeta->tuid = htobe64(pMeta->tuid);
|
||||
pMeta->suid = htobe64(pMeta->suid);
|
||||
|
||||
showId = pShowRsp->showId;
|
||||
|
||||
EXPECT_NE(pShowRsp->showId, 0);
|
||||
EXPECT_STREQ(pMeta->tbFname, showName);
|
||||
EXPECT_EQ(pMeta->numOfTags, 0);
|
||||
EXPECT_EQ(pMeta->numOfColumns, columns);
|
||||
EXPECT_EQ(pMeta->precision, 0);
|
||||
EXPECT_EQ(pMeta->tableType, 0);
|
||||
EXPECT_EQ(pMeta->update, 0);
|
||||
EXPECT_EQ(pMeta->sversion, 0);
|
||||
EXPECT_EQ(pMeta->tversion, 0);
|
||||
EXPECT_EQ(pMeta->tuid, 0);
|
||||
EXPECT_EQ(pMeta->suid, 0);
|
||||
}
|
||||
|
||||
void CheckSchema(int32_t index, int8_t type, int32_t bytes, const char* name) {
|
||||
SSchema* pSchema = &pMeta->pSchema[index];
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, type);
|
||||
EXPECT_EQ(pSchema->bytes, bytes);
|
||||
EXPECT_STREQ(pSchema->name, name);
|
||||
}
|
||||
|
||||
void SendThenCheckShowRetrieveMsg(int32_t rows) {
|
||||
SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg));
|
||||
pRetrieve->showId = htonl(showId);
|
||||
pRetrieve->free = 0;
|
||||
|
||||
SRpcMsg retrieveRpcMsg = {0};
|
||||
retrieveRpcMsg.pCont = pRetrieve;
|
||||
retrieveRpcMsg.contLen = sizeof(SRetrieveTableMsg);
|
||||
retrieveRpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
|
||||
|
||||
sendMsg(pClient, &retrieveRpcMsg);
|
||||
|
||||
ASSERT_NE(pClient->pRsp, nullptr);
|
||||
ASSERT_EQ(pClient->pRsp->code, 0);
|
||||
ASSERT_NE(pClient->pRsp->pCont, nullptr);
|
||||
|
||||
pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
|
||||
ASSERT_NE(pRetrieveRsp, nullptr);
|
||||
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
|
||||
pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
|
||||
pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
|
||||
|
||||
EXPECT_EQ(pRetrieveRsp->numOfRows, rows);
|
||||
EXPECT_EQ(pRetrieveRsp->useconds, 0);
|
||||
// EXPECT_EQ(pRetrieveRsp->completed, completed);
|
||||
EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(pRetrieveRsp->compressed, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->compLen, 0);
|
||||
|
||||
pData = pRetrieveRsp->data;
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
void CheckInt32() {
|
||||
int32_t data = *((int32_t*)(pData + pos));
|
||||
pos += sizeof(int32_t);
|
||||
EXPECT_GT(data, 0);
|
||||
}
|
||||
|
||||
void CheckTimestamp() {
|
||||
int64_t data = *((int64_t*)(pData + pos));
|
||||
pos += sizeof(int64_t);
|
||||
EXPECT_GT(data, 0);
|
||||
}
|
||||
|
||||
void CheckBinary(int32_t len) {
|
||||
pos += sizeof(VarDataLenT);
|
||||
char* data = (char*)(pData + pos);
|
||||
pos += len;
|
||||
}
|
||||
|
||||
int32_t showId;
|
||||
STableMetaMsg* pMeta;
|
||||
SRetrieveTableRsp* pRetrieveRsp;
|
||||
char* pData;
|
||||
int32_t pos;
|
||||
};
|
||||
|
||||
SServer* DndTestCluster::pServer;
|
||||
SClient* DndTestCluster::pClient;
|
||||
int32_t DndTestCluster::connId;
|
||||
|
||||
TEST_F(DndTestCluster, ShowCluster) {
|
||||
ASSERT_NE(pClient, nullptr);
|
||||
int32_t showId = 0;
|
||||
TEST_F(DndTestCluster, 01_ShowCluster) {
|
||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_CLUSTER, "show cluster", 3, NULL);
|
||||
CheckSchema(0, TSDB_DATA_TYPE_INT, 4, "id");
|
||||
CheckSchema(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
CheckSchema(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
||||
{
|
||||
SShowMsg* pReq = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
|
||||
pReq->type = TSDB_MGMT_TABLE_CLUSTER;
|
||||
strcpy(pReq->db, "");
|
||||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
rpcMsg.pCont = pReq;
|
||||
rpcMsg.contLen = sizeof(SShowMsg);
|
||||
rpcMsg.msgType = TSDB_MSG_TYPE_SHOW;
|
||||
|
||||
sendMsg(pClient, &rpcMsg);
|
||||
SRpcMsg* pMsg = pClient->pRsp;
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
|
||||
SShowRsp* pRsp = (SShowRsp*)pMsg->pCont;
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
pRsp->showId = htonl(pRsp->showId);
|
||||
STableMetaMsg* pMeta = &pRsp->tableMeta;
|
||||
pMeta->contLen = htonl(pMeta->contLen);
|
||||
pMeta->numOfColumns = htons(pMeta->numOfColumns);
|
||||
pMeta->sversion = htons(pMeta->sversion);
|
||||
pMeta->tversion = htons(pMeta->tversion);
|
||||
pMeta->tid = htonl(pMeta->tid);
|
||||
pMeta->uid = htobe64(pMeta->uid);
|
||||
pMeta->suid = htobe64(pMeta->suid);
|
||||
|
||||
showId = pRsp->showId;
|
||||
|
||||
EXPECT_NE(pRsp->showId, 0);
|
||||
EXPECT_EQ(pMeta->contLen, 0);
|
||||
EXPECT_STREQ(pMeta->tbFname, "show cluster");
|
||||
EXPECT_EQ(pMeta->numOfTags, 0);
|
||||
EXPECT_EQ(pMeta->precision, 0);
|
||||
EXPECT_EQ(pMeta->tableType, 0);
|
||||
EXPECT_EQ(pMeta->numOfColumns, 3);
|
||||
EXPECT_EQ(pMeta->sversion, 0);
|
||||
EXPECT_EQ(pMeta->tversion, 0);
|
||||
EXPECT_EQ(pMeta->tid, 0);
|
||||
EXPECT_EQ(pMeta->uid, 0);
|
||||
EXPECT_STREQ(pMeta->sTableName, "");
|
||||
EXPECT_EQ(pMeta->suid, 0);
|
||||
|
||||
SSchema* pSchema = NULL;
|
||||
pSchema = &pMeta->pSchema[0];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT);
|
||||
EXPECT_EQ(pSchema->bytes, 4);
|
||||
EXPECT_STREQ(pSchema->name, "id");
|
||||
|
||||
pSchema = &pMeta->pSchema[1];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
|
||||
EXPECT_EQ(pSchema->bytes, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE);
|
||||
EXPECT_STREQ(pSchema->name, "name");
|
||||
|
||||
pSchema = &pMeta->pSchema[2];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
|
||||
EXPECT_EQ(pSchema->bytes, 8);
|
||||
EXPECT_STREQ(pSchema->name, "create_time");
|
||||
}
|
||||
|
||||
{
|
||||
SRetrieveTableMsg* pReq = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg));
|
||||
pReq->showId = htonl(showId);
|
||||
pReq->free = 0;
|
||||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
rpcMsg.pCont = pReq;
|
||||
rpcMsg.contLen = sizeof(SRetrieveTableMsg);
|
||||
rpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
|
||||
|
||||
sendMsg(pClient, &rpcMsg);
|
||||
SRpcMsg* pMsg = pClient->pRsp;
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
|
||||
SRetrieveTableRsp* pRsp = (SRetrieveTableRsp*)pMsg->pCont;
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
pRsp->numOfRows = htonl(pRsp->numOfRows);
|
||||
pRsp->offset = htobe64(pRsp->offset);
|
||||
pRsp->useconds = htobe64(pRsp->useconds);
|
||||
pRsp->compLen = htonl(pRsp->compLen);
|
||||
|
||||
EXPECT_EQ(pRsp->numOfRows, 1);
|
||||
EXPECT_EQ(pRsp->offset, 0);
|
||||
EXPECT_EQ(pRsp->useconds, 0);
|
||||
EXPECT_EQ(pRsp->completed, 1);
|
||||
EXPECT_EQ(pRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(pRsp->compressed, 0);
|
||||
EXPECT_EQ(pRsp->reserved, 0);
|
||||
EXPECT_EQ(pRsp->compLen, 0);
|
||||
|
||||
char* pData = pRsp->data;
|
||||
int32_t pos = 0;
|
||||
|
||||
int32_t id = *((int32_t*)(pData + pos));
|
||||
pos += sizeof(int32_t);
|
||||
|
||||
int32_t nameLen = varDataLen(pData + pos);
|
||||
pos += sizeof(VarDataLenT);
|
||||
|
||||
char* name = (char*)(pData + pos);
|
||||
pos += TSDB_CLUSTER_ID_LEN;
|
||||
|
||||
int64_t create_time = *((int64_t*)(pData + pos));
|
||||
pos += sizeof(int64_t);
|
||||
|
||||
EXPECT_NE(id, 0);
|
||||
EXPECT_EQ(nameLen, 36);
|
||||
EXPECT_STRNE(name, "");
|
||||
EXPECT_GT(create_time, 0);
|
||||
printf("--- id:%d nameLen:%d name:%s time:%" PRId64 " --- \n", id, nameLen, name, create_time);
|
||||
}
|
||||
SendThenCheckShowRetrieveMsg(1);
|
||||
CheckInt32();
|
||||
CheckBinary(TSDB_CLUSTER_ID_LEN);
|
||||
CheckTimestamp();
|
||||
}
|
|
@ -21,8 +21,6 @@ target_include_directories(dnode_test_db
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/../sut"
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(
|
||||
NAME dnode_test_db
|
||||
COMMAND dnode_test_db
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file vnodeApiTests.cpp
|
||||
* @file db.cpp
|
||||
* @author slguan (slguan@taosdata.com)
|
||||
* @brief DNODE module db-msg tests
|
||||
* @version 0.1
|
||||
|
@ -88,7 +88,7 @@ class DndTestDb : public ::testing::Test {
|
|||
|
||||
void CheckSchema(int32_t index, int8_t type, int32_t bytes, const char* name) {
|
||||
SSchema* pSchema = &pMeta->pSchema[index];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, type);
|
||||
EXPECT_EQ(pSchema->bytes, bytes);
|
||||
|
@ -114,17 +114,14 @@ class DndTestDb : public ::testing::Test {
|
|||
pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
|
||||
ASSERT_NE(pRetrieveRsp, nullptr);
|
||||
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
|
||||
pRetrieveRsp->offset = htobe64(pRetrieveRsp->offset);
|
||||
pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
|
||||
pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
|
||||
|
||||
EXPECT_EQ(pRetrieveRsp->numOfRows, rows);
|
||||
EXPECT_EQ(pRetrieveRsp->offset, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->useconds, 0);
|
||||
// EXPECT_EQ(pRetrieveRsp->completed, completed);
|
||||
EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(pRetrieveRsp->compressed, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->reserved, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->compLen, 0);
|
||||
|
||||
pData = pRetrieveRsp->data;
|
||||
|
@ -182,13 +179,13 @@ int32_t DndTestDb::connId;
|
|||
TEST_F(DndTestDb, 01_ShowDb) {
|
||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DB, "show databases", 17, NULL);
|
||||
CheckSchema(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name");
|
||||
CheckSchema(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create time");
|
||||
CheckSchema(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CheckSchema(2, TSDB_DATA_TYPE_SMALLINT, 2, "vgroups");
|
||||
CheckSchema(3, TSDB_DATA_TYPE_SMALLINT, 2, "replica");
|
||||
CheckSchema(4, TSDB_DATA_TYPE_SMALLINT, 2, "quorum");
|
||||
CheckSchema(5, TSDB_DATA_TYPE_SMALLINT, 2, "days");
|
||||
CheckSchema(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "keep0,keep1,keep2");
|
||||
CheckSchema(7, TSDB_DATA_TYPE_INT, 4, "cache(MB)");
|
||||
CheckSchema(7, TSDB_DATA_TYPE_INT, 4, "cache");
|
||||
CheckSchema(8, TSDB_DATA_TYPE_INT, 4, "blocks");
|
||||
CheckSchema(9, TSDB_DATA_TYPE_INT, 4, "minrows");
|
||||
CheckSchema(10, TSDB_DATA_TYPE_INT, 4, "maxrows");
|
||||
|
|
|
@ -21,8 +21,6 @@ target_include_directories(dnode_test_dnode
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/../sut"
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(
|
||||
NAME dnode_test_dnode
|
||||
COMMAND dnode_test_dnode
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file vnodeApiTests.cpp
|
||||
* @file dnode.cpp
|
||||
* @author slguan (slguan@taosdata.com)
|
||||
* @brief DNODE module dnode-msg tests
|
||||
* @version 0.1
|
||||
|
@ -81,8 +81,8 @@ class DndTestDnode : public ::testing::Test {
|
|||
pMeta->numOfTags = htonl(pMeta->numOfTags);
|
||||
pMeta->numOfColumns = htonl(pMeta->numOfColumns);
|
||||
pMeta->sversion = htonl(pMeta->sversion);
|
||||
pMeta->tversion = htons(pMeta->tversion);
|
||||
pMeta->tuid = htonl(pMeta->tuid);
|
||||
pMeta->tversion = htonl(pMeta->tversion);
|
||||
pMeta->tuid = htobe64(pMeta->tuid);
|
||||
pMeta->suid = htobe64(pMeta->suid);
|
||||
|
||||
showId = pShowRsp->showId;
|
||||
|
@ -102,7 +102,7 @@ class DndTestDnode : public ::testing::Test {
|
|||
|
||||
void CheckSchema(int32_t index, int8_t type, int32_t bytes, const char* name) {
|
||||
SSchema* pSchema = &pMeta->pSchema[index];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, type);
|
||||
EXPECT_EQ(pSchema->bytes, bytes);
|
||||
|
@ -128,17 +128,14 @@ class DndTestDnode : public ::testing::Test {
|
|||
pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
|
||||
ASSERT_NE(pRetrieveRsp, nullptr);
|
||||
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
|
||||
pRetrieveRsp->offset = htobe64(pRetrieveRsp->offset);
|
||||
pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
|
||||
pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
|
||||
|
||||
EXPECT_EQ(pRetrieveRsp->numOfRows, rows);
|
||||
EXPECT_EQ(pRetrieveRsp->offset, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->useconds, 0);
|
||||
// EXPECT_EQ(pRetrieveRsp->completed, completed);
|
||||
EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(pRetrieveRsp->compressed, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->reserved, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->compLen, 0);
|
||||
|
||||
pData = pRetrieveRsp->data;
|
||||
|
@ -187,12 +184,12 @@ SClient* DndTestDnode::pClient;
|
|||
TEST_F(DndTestDnode, 01_ShowDnode) {
|
||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "show dnodes", 7);
|
||||
CheckSchema(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||
CheckSchema(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "end point");
|
||||
CheckSchema(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
|
||||
CheckSchema(2, TSDB_DATA_TYPE_SMALLINT, 2, "vnodes");
|
||||
CheckSchema(3, TSDB_DATA_TYPE_SMALLINT, 2, "max vnodes");
|
||||
CheckSchema(3, TSDB_DATA_TYPE_SMALLINT, 2, "max_vnodes");
|
||||
CheckSchema(4, TSDB_DATA_TYPE_BINARY, 10 + VARSTR_HEADER_SIZE, "status");
|
||||
CheckSchema(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "create time");
|
||||
CheckSchema(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "offline reason");
|
||||
CheckSchema(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CheckSchema(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "offline_reason");
|
||||
|
||||
SendThenCheckShowRetrieveMsg(1);
|
||||
CheckInt16(1);
|
||||
|
|
|
@ -21,8 +21,6 @@ target_include_directories(dndTestProfile
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/../sut"
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(
|
||||
NAME dndTestProfile
|
||||
COMMAND dndTestProfile
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file vnodeApiTests.cpp
|
||||
* @file profile.cpp
|
||||
* @author slguan (slguan@taosdata.com)
|
||||
* @brief DNODE module profile-msg tests
|
||||
* @version 0.1
|
||||
|
@ -216,17 +216,14 @@ TEST_F(DndTestProfile, SConnectMsg_03) {
|
|||
SRetrieveTableRsp* pRsp = (SRetrieveTableRsp*)pMsg->pCont;
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
pRsp->numOfRows = htonl(pRsp->numOfRows);
|
||||
pRsp->offset = htobe64(pRsp->offset);
|
||||
pRsp->useconds = htobe64(pRsp->useconds);
|
||||
pRsp->compLen = htonl(pRsp->compLen);
|
||||
|
||||
EXPECT_EQ(pRsp->numOfRows, 1);
|
||||
EXPECT_EQ(pRsp->offset, 0);
|
||||
EXPECT_EQ(pRsp->useconds, 0);
|
||||
EXPECT_EQ(pRsp->completed, 1);
|
||||
EXPECT_EQ(pRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(pRsp->compressed, 0);
|
||||
EXPECT_EQ(pRsp->reserved, 0);
|
||||
EXPECT_EQ(pRsp->compLen, 0);
|
||||
}
|
||||
}
|
||||
|
@ -497,7 +494,7 @@ TEST_F(DndTestProfile, SKillQueryMsg_03) {
|
|||
EXPECT_STREQ(pSchema->name, "queryId");
|
||||
|
||||
pSchema = &pMeta->pSchema[1];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT);
|
||||
EXPECT_EQ(pSchema->bytes, 4);
|
||||
|
|
|
@ -1,29 +1,27 @@
|
|||
add_executable(dndTestShow "")
|
||||
add_executable(dnode_test_show "")
|
||||
|
||||
target_sources(dndTestShow
|
||||
target_sources(dnode_test_show
|
||||
PRIVATE
|
||||
"show.cpp"
|
||||
"../sut/deploy.cpp"
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
dndTestShow
|
||||
dnode_test_show
|
||||
PUBLIC dnode
|
||||
PUBLIC util
|
||||
PUBLIC os
|
||||
PUBLIC gtest_main
|
||||
)
|
||||
|
||||
target_include_directories(dndTestShow
|
||||
target_include_directories(dnode_test_show
|
||||
PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/include/server/dnode/mgmt"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../inc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../sut"
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(
|
||||
NAME dndTestShow
|
||||
COMMAND dndTestShow
|
||||
NAME dnode_test_show
|
||||
COMMAND dnode_test_show
|
||||
)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file vnodeApiTests.cpp
|
||||
* @file show.cpp
|
||||
* @author slguan (slguan@taosdata.com)
|
||||
* @brief DNODE module show-msg tests
|
||||
* @version 0.1
|
||||
|
@ -151,49 +151,49 @@ TEST_F(DndTestShow, SShowMsg_04) {
|
|||
|
||||
SSchema* pSchema = NULL;
|
||||
pSchema = &pMeta->pSchema[0];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT);
|
||||
EXPECT_EQ(pSchema->bytes, 4);
|
||||
EXPECT_STREQ(pSchema->name, "connId");
|
||||
|
||||
pSchema = &pMeta->pSchema[1];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
|
||||
EXPECT_EQ(pSchema->bytes, TSDB_USER_LEN + VARSTR_HEADER_SIZE);
|
||||
EXPECT_STREQ(pSchema->name, "user");
|
||||
|
||||
pSchema = &pMeta->pSchema[2];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
|
||||
EXPECT_EQ(pSchema->bytes, TSDB_USER_LEN + VARSTR_HEADER_SIZE);
|
||||
EXPECT_STREQ(pSchema->name, "program");
|
||||
|
||||
pSchema = &pMeta->pSchema[3];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT);
|
||||
EXPECT_EQ(pSchema->bytes, 4);
|
||||
EXPECT_STREQ(pSchema->name, "pid");
|
||||
|
||||
pSchema = &pMeta->pSchema[4];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
|
||||
EXPECT_EQ(pSchema->bytes, TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE);
|
||||
EXPECT_STREQ(pSchema->name, "ip:port");
|
||||
|
||||
pSchema = &pMeta->pSchema[5];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
|
||||
EXPECT_EQ(pSchema->bytes, 8);
|
||||
EXPECT_STREQ(pSchema->name, "login_time");
|
||||
|
||||
pSchema = &pMeta->pSchema[6];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
|
||||
EXPECT_EQ(pSchema->bytes, 8);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
add_executable(dnode_test_stb "")
|
||||
|
||||
target_sources(dnode_test_stb
|
||||
PRIVATE
|
||||
"stb.cpp"
|
||||
"../sut/deploy.cpp"
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
dnode_test_stb
|
||||
PUBLIC dnode
|
||||
PUBLIC util
|
||||
PUBLIC os
|
||||
PUBLIC gtest_main
|
||||
)
|
||||
|
||||
target_include_directories(dnode_test_stb
|
||||
PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/include/server/dnode/mgmt"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../inc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../sut"
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME dnode_test_stb
|
||||
COMMAND dnode_test_stb
|
||||
)
|
|
@ -0,0 +1,374 @@
|
|||
/**
|
||||
* @file stb.cpp
|
||||
* @author slguan (slguan@taosdata.com)
|
||||
* @brief DNODE module db-msg tests
|
||||
* @version 0.1
|
||||
* @date 2021-12-17
|
||||
*
|
||||
* @copyright Copyright (c) 2021
|
||||
*
|
||||
*/
|
||||
|
||||
#include "deploy.h"
|
||||
|
||||
class DndTestStb : public ::testing::Test {
|
||||
protected:
|
||||
static SServer* CreateServer(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
||||
SServer* pServer = createServer(path, fqdn, port, firstEp);
|
||||
ASSERT(pServer);
|
||||
return pServer;
|
||||
}
|
||||
|
||||
static void SetUpTestSuite() {
|
||||
initLog("/tmp/tdlog");
|
||||
|
||||
const char* fqdn = "localhost";
|
||||
const char* firstEp = "localhost:9101";
|
||||
pServer = CreateServer("/tmp/dnode_test_stb", fqdn, 9101, firstEp);
|
||||
pClient = createClient("root", "taosdata", fqdn, 9101);
|
||||
taosMsleep(1100);
|
||||
}
|
||||
|
||||
static void TearDownTestSuite() {
|
||||
stopServer(pServer);
|
||||
dropClient(pClient);
|
||||
pServer = NULL;
|
||||
pClient = NULL;
|
||||
}
|
||||
|
||||
static SServer* pServer;
|
||||
static SClient* pClient;
|
||||
static int32_t connId;
|
||||
|
||||
public:
|
||||
void SetUp() override {}
|
||||
void TearDown() override {}
|
||||
|
||||
void SendTheCheckShowMetaMsg(int8_t showType, const char* showName, int32_t columns, const char* db) {
|
||||
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
|
||||
pShow->type = showType;
|
||||
if (db != NULL) {
|
||||
strcpy(pShow->db, db);
|
||||
}
|
||||
SRpcMsg showRpcMsg = {0};
|
||||
showRpcMsg.pCont = pShow;
|
||||
showRpcMsg.contLen = sizeof(SShowMsg);
|
||||
showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW;
|
||||
|
||||
sendMsg(pClient, &showRpcMsg);
|
||||
ASSERT_NE(pClient->pRsp, nullptr);
|
||||
ASSERT_EQ(pClient->pRsp->code, 0);
|
||||
ASSERT_NE(pClient->pRsp->pCont, nullptr);
|
||||
|
||||
SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont;
|
||||
ASSERT_NE(pShowRsp, nullptr);
|
||||
pShowRsp->showId = htonl(pShowRsp->showId);
|
||||
pMeta = &pShowRsp->tableMeta;
|
||||
pMeta->numOfTags = htonl(pMeta->numOfTags);
|
||||
pMeta->numOfColumns = htonl(pMeta->numOfColumns);
|
||||
pMeta->sversion = htonl(pMeta->sversion);
|
||||
pMeta->tversion = htonl(pMeta->tversion);
|
||||
pMeta->tuid = htobe64(pMeta->tuid);
|
||||
pMeta->suid = htobe64(pMeta->suid);
|
||||
|
||||
showId = pShowRsp->showId;
|
||||
|
||||
EXPECT_NE(pShowRsp->showId, 0);
|
||||
EXPECT_STREQ(pMeta->tbFname, showName);
|
||||
EXPECT_EQ(pMeta->numOfTags, 0);
|
||||
EXPECT_EQ(pMeta->numOfColumns, columns);
|
||||
EXPECT_EQ(pMeta->precision, 0);
|
||||
EXPECT_EQ(pMeta->tableType, 0);
|
||||
EXPECT_EQ(pMeta->update, 0);
|
||||
EXPECT_EQ(pMeta->sversion, 0);
|
||||
EXPECT_EQ(pMeta->tversion, 0);
|
||||
EXPECT_EQ(pMeta->tuid, 0);
|
||||
EXPECT_EQ(pMeta->suid, 0);
|
||||
}
|
||||
|
||||
void CheckSchema(int32_t index, int8_t type, int32_t bytes, const char* name) {
|
||||
SSchema* pSchema = &pMeta->pSchema[index];
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, type);
|
||||
EXPECT_EQ(pSchema->bytes, bytes);
|
||||
EXPECT_STREQ(pSchema->name, name);
|
||||
}
|
||||
|
||||
void SendThenCheckShowRetrieveMsg(int32_t rows) {
|
||||
SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg));
|
||||
pRetrieve->showId = htonl(showId);
|
||||
pRetrieve->free = 0;
|
||||
|
||||
SRpcMsg retrieveRpcMsg = {0};
|
||||
retrieveRpcMsg.pCont = pRetrieve;
|
||||
retrieveRpcMsg.contLen = sizeof(SRetrieveTableMsg);
|
||||
retrieveRpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
|
||||
|
||||
sendMsg(pClient, &retrieveRpcMsg);
|
||||
|
||||
ASSERT_NE(pClient->pRsp, nullptr);
|
||||
ASSERT_EQ(pClient->pRsp->code, 0);
|
||||
ASSERT_NE(pClient->pRsp->pCont, nullptr);
|
||||
|
||||
pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
|
||||
ASSERT_NE(pRetrieveRsp, nullptr);
|
||||
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
|
||||
pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
|
||||
pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
|
||||
|
||||
EXPECT_EQ(pRetrieveRsp->numOfRows, rows);
|
||||
EXPECT_EQ(pRetrieveRsp->useconds, 0);
|
||||
// EXPECT_EQ(pRetrieveRsp->completed, completed);
|
||||
EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(pRetrieveRsp->compressed, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->compLen, 0);
|
||||
|
||||
pData = pRetrieveRsp->data;
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
void CheckInt8(int8_t val) {
|
||||
int8_t data = *((int8_t*)(pData + pos));
|
||||
pos += sizeof(int8_t);
|
||||
EXPECT_EQ(data, val);
|
||||
}
|
||||
|
||||
void CheckInt16(int16_t val) {
|
||||
int16_t data = *((int16_t*)(pData + pos));
|
||||
pos += sizeof(int16_t);
|
||||
EXPECT_EQ(data, val);
|
||||
}
|
||||
|
||||
void CheckInt32(int32_t val) {
|
||||
int32_t data = *((int32_t*)(pData + pos));
|
||||
pos += sizeof(int32_t);
|
||||
EXPECT_EQ(data, val);
|
||||
}
|
||||
|
||||
void CheckInt64(int64_t val) {
|
||||
int64_t data = *((int64_t*)(pData + pos));
|
||||
pos += sizeof(int64_t);
|
||||
EXPECT_EQ(data, val);
|
||||
}
|
||||
|
||||
void CheckTimestamp() {
|
||||
int64_t data = *((int64_t*)(pData + pos));
|
||||
pos += sizeof(int64_t);
|
||||
EXPECT_GT(data, 0);
|
||||
}
|
||||
|
||||
void CheckBinary(const char* val, int32_t len) {
|
||||
pos += sizeof(VarDataLenT);
|
||||
char* data = (char*)(pData + pos);
|
||||
pos += len;
|
||||
EXPECT_STREQ(data, val);
|
||||
}
|
||||
|
||||
int32_t showId;
|
||||
STableMetaMsg* pMeta;
|
||||
SRetrieveTableRsp* pRetrieveRsp;
|
||||
char* pData;
|
||||
int32_t pos;
|
||||
};
|
||||
|
||||
SServer* DndTestStb::pServer;
|
||||
SClient* DndTestStb::pClient;
|
||||
int32_t DndTestStb::connId;
|
||||
|
||||
TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
||||
{
|
||||
SCreateDbMsg* pReq = (SCreateDbMsg*)rpcMallocCont(sizeof(SCreateDbMsg));
|
||||
strcpy(pReq->db, "1.d1");
|
||||
pReq->numOfVgroups = htonl(2);
|
||||
pReq->cacheBlockSize = htonl(16);
|
||||
pReq->totalBlocks = htonl(10);
|
||||
pReq->daysPerFile = htonl(10);
|
||||
pReq->daysToKeep0 = htonl(3650);
|
||||
pReq->daysToKeep1 = htonl(3650);
|
||||
pReq->daysToKeep2 = htonl(3650);
|
||||
pReq->minRowsPerFileBlock = htonl(100);
|
||||
pReq->maxRowsPerFileBlock = htonl(4096);
|
||||
pReq->commitTime = htonl(3600);
|
||||
pReq->fsyncPeriod = htonl(3000);
|
||||
pReq->walLevel = 1;
|
||||
pReq->precision = 0;
|
||||
pReq->compression = 2;
|
||||
pReq->replications = 1;
|
||||
pReq->quorum = 1;
|
||||
pReq->update = 0;
|
||||
pReq->cacheLastRow = 0;
|
||||
pReq->ignoreExist = 1;
|
||||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
rpcMsg.pCont = pReq;
|
||||
rpcMsg.contLen = sizeof(SCreateDbMsg);
|
||||
rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_DB;
|
||||
|
||||
sendMsg(pClient, &rpcMsg);
|
||||
SRpcMsg* pMsg = pClient->pRsp;
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
}
|
||||
|
||||
{
|
||||
int32_t cols = 2;
|
||||
int32_t tags = 3;
|
||||
int32_t size = (tags + cols) * sizeof(SSchema) + sizeof(SCreateStbMsg);
|
||||
|
||||
SCreateStbMsg* pReq = (SCreateStbMsg*)rpcMallocCont(size);
|
||||
strcpy(pReq->name, "1.d1.stb");
|
||||
pReq->numOfTags = htonl(tags);
|
||||
pReq->numOfColumns = htonl(cols);
|
||||
|
||||
{
|
||||
SSchema* pSchema = &pReq->pSchema[0];
|
||||
pSchema->colId = htonl(0);
|
||||
pSchema->bytes = htonl(8);
|
||||
pSchema->type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema->name, "ts");
|
||||
}
|
||||
|
||||
{
|
||||
SSchema* pSchema = &pReq->pSchema[1];
|
||||
pSchema->colId = htonl(1);
|
||||
pSchema->bytes = htonl(4);
|
||||
pSchema->type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema->name, "col1");
|
||||
}
|
||||
|
||||
{
|
||||
SSchema* pSchema = &pReq->pSchema[2];
|
||||
pSchema->colId = htonl(2);
|
||||
pSchema->bytes = htonl(2);
|
||||
pSchema->type = TSDB_DATA_TYPE_TINYINT;
|
||||
strcpy(pSchema->name, "tag1");
|
||||
}
|
||||
|
||||
{
|
||||
SSchema* pSchema = &pReq->pSchema[3];
|
||||
pSchema->colId = htonl(3);
|
||||
pSchema->bytes = htonl(8);
|
||||
pSchema->type = TSDB_DATA_TYPE_BIGINT;
|
||||
strcpy(pSchema->name, "tag2");
|
||||
}
|
||||
|
||||
{
|
||||
SSchema* pSchema = &pReq->pSchema[4];
|
||||
pSchema->colId = htonl(4);
|
||||
pSchema->bytes = htonl(16);
|
||||
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema->name, "tag3");
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
rpcMsg.pCont = pReq;
|
||||
rpcMsg.contLen = size;
|
||||
rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_STB;
|
||||
|
||||
sendMsg(pClient, &rpcMsg);
|
||||
SRpcMsg* pMsg = pClient->pRsp;
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
}
|
||||
|
||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_STB, "show stables", 4, "1.d1");
|
||||
CheckSchema(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
CheckSchema(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CheckSchema(2, TSDB_DATA_TYPE_INT, 4, "columns");
|
||||
CheckSchema(3, TSDB_DATA_TYPE_INT, 4, "tags");
|
||||
|
||||
SendThenCheckShowRetrieveMsg(1);
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(2);
|
||||
CheckInt32(3);
|
||||
|
||||
// ----- meta ------
|
||||
{
|
||||
STableInfoMsg* pReq = (STableInfoMsg*)rpcMallocCont(sizeof(STableInfoMsg));
|
||||
strcpy(pReq->tableFname, "1.d1.stb");
|
||||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
rpcMsg.pCont = pReq;
|
||||
rpcMsg.contLen = sizeof(STableInfoMsg);
|
||||
rpcMsg.msgType = TSDB_MSG_TYPE_TABLE_META;
|
||||
|
||||
sendMsg(pClient, &rpcMsg);
|
||||
SRpcMsg* pMsg = pClient->pRsp;
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
|
||||
STableMetaMsg* pRsp = (STableMetaMsg*)pMsg->pCont;
|
||||
pRsp->numOfTags = htonl(pRsp->numOfTags);
|
||||
pRsp->numOfColumns = htonl(pRsp->numOfColumns);
|
||||
pRsp->sversion = htonl(pRsp->sversion);
|
||||
pRsp->tversion = htonl(pRsp->tversion);
|
||||
pRsp->suid = htobe64(pRsp->suid);
|
||||
pRsp->tuid = htobe64(pRsp->tuid);
|
||||
pRsp->vgId = htobe64(pRsp->vgId);
|
||||
for (int32_t i = 0; i < pRsp->numOfTags + pRsp->numOfColumns; ++i) {
|
||||
SSchema* pSchema = &pRsp->pSchema[i];
|
||||
pSchema->colId = htonl(pSchema->colId);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
}
|
||||
|
||||
EXPECT_STREQ(pRsp->tbFname, "");
|
||||
EXPECT_STREQ(pRsp->stbFname, "1.d1.stb");
|
||||
EXPECT_EQ(pRsp->numOfColumns, 2);
|
||||
EXPECT_EQ(pRsp->numOfTags, 3);
|
||||
EXPECT_EQ(pRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(pRsp->tableType, TSDB_SUPER_TABLE);
|
||||
EXPECT_EQ(pRsp->update, 0);
|
||||
EXPECT_EQ(pRsp->sversion, 1);
|
||||
EXPECT_EQ(pRsp->tversion, 0);
|
||||
EXPECT_GT(pRsp->suid, 0);
|
||||
EXPECT_EQ(pRsp->tuid, 0);
|
||||
EXPECT_EQ(pRsp->vgId, 0);
|
||||
|
||||
{
|
||||
SSchema* pSchema = &pRsp->pSchema[0];
|
||||
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->bytes, 8);
|
||||
EXPECT_STREQ(pSchema->name, "ts");
|
||||
}
|
||||
}
|
||||
|
||||
// restart
|
||||
stopServer(pServer);
|
||||
pServer = NULL;
|
||||
|
||||
uInfo("start all server");
|
||||
|
||||
const char* fqdn = "localhost";
|
||||
const char* firstEp = "localhost:9101";
|
||||
pServer = startServer("/tmp/dnode_test_stb", fqdn, 9101, firstEp);
|
||||
|
||||
uInfo("all server is running");
|
||||
|
||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_STB, "show stables", 4, "1.d1");
|
||||
SendThenCheckShowRetrieveMsg(1);
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(2);
|
||||
CheckInt32(3);
|
||||
|
||||
{
|
||||
SDropStbMsg* pReq = (SDropStbMsg*)rpcMallocCont(sizeof(SDropStbMsg));
|
||||
strcpy(pReq->name, "1.d1.stb");
|
||||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
rpcMsg.pCont = pReq;
|
||||
rpcMsg.contLen = sizeof(SDropStbMsg);
|
||||
rpcMsg.msgType = TSDB_MSG_TYPE_DROP_STB;
|
||||
|
||||
sendMsg(pClient, &rpcMsg);
|
||||
SRpcMsg* pMsg = pClient->pRsp;
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
ASSERT_EQ(pMsg->code, 0);
|
||||
}
|
||||
|
||||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_STB, "show stables", 4, "1.d1");
|
||||
SendThenCheckShowRetrieveMsg(0);
|
||||
}
|
|
@ -21,8 +21,6 @@ target_include_directories(dnode_test_user
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/../sut"
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(
|
||||
NAME dnode_test_user
|
||||
COMMAND dnode_test_user
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file vnodeApiTests.cpp
|
||||
* @file user.cpp
|
||||
* @author slguan (slguan@taosdata.com)
|
||||
* @brief DNODE module user-msg tests
|
||||
* @version 0.1
|
||||
|
@ -87,7 +87,7 @@ class DndTestUser : public ::testing::Test {
|
|||
|
||||
void CheckSchema(int32_t index, int8_t type, int32_t bytes, const char* name) {
|
||||
SSchema* pSchema = &pMeta->pSchema[index];
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
EXPECT_EQ(pSchema->colId, 0);
|
||||
EXPECT_EQ(pSchema->type, type);
|
||||
EXPECT_EQ(pSchema->bytes, bytes);
|
||||
|
@ -113,17 +113,14 @@ class DndTestUser : public ::testing::Test {
|
|||
pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
|
||||
ASSERT_NE(pRetrieveRsp, nullptr);
|
||||
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
|
||||
pRetrieveRsp->offset = htobe64(pRetrieveRsp->offset);
|
||||
pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
|
||||
pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
|
||||
|
||||
EXPECT_EQ(pRetrieveRsp->numOfRows, rows);
|
||||
EXPECT_EQ(pRetrieveRsp->offset, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->useconds, 0);
|
||||
// EXPECT_EQ(pRetrieveRsp->completed, completed);
|
||||
EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(pRetrieveRsp->compressed, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->reserved, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->compLen, 0);
|
||||
|
||||
pData = pRetrieveRsp->data;
|
||||
|
@ -170,7 +167,7 @@ TEST_F(DndTestUser, 01_ShowUser) {
|
|||
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_USER, "show users", 4);
|
||||
CheckSchema(0, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
CheckSchema(1, TSDB_DATA_TYPE_BINARY, 10 + VARSTR_HEADER_SIZE, "privilege");
|
||||
CheckSchema(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create time");
|
||||
CheckSchema(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CheckSchema(3, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "account");
|
||||
|
||||
SendThenCheckShowRetrieveMsg(1);
|
||||
|
|
|
@ -182,6 +182,7 @@ typedef struct {
|
|||
} SUserObj;
|
||||
|
||||
typedef struct {
|
||||
int32_t numOfVgroups;
|
||||
int32_t cacheBlockSize;
|
||||
int32_t totalBlocks;
|
||||
int32_t daysPerFile;
|
||||
|
@ -209,7 +210,6 @@ typedef struct {
|
|||
int64_t uid;
|
||||
int32_t cfgVersion;
|
||||
int32_t vgVersion;
|
||||
int32_t numOfVgroups;
|
||||
int8_t hashMethod; // default is 1
|
||||
SDbCfg cfg;
|
||||
} SDbObj;
|
||||
|
|
|
@ -143,22 +143,22 @@ static int32_t mndGetClusterMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
|
|||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "id");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "name");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htons(cols);
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
strcpy(pMeta->tbFname, mndShowStr(pShow->type));
|
||||
pShow->numOfColumns = cols;
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
|||
SDB_SET_INT64(pRaw, dataPos, pDb->uid)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfgVersion)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->vgVersion)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->numOfVgroups)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->hashMethod)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfVgroups)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.cacheBlockSize)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.totalBlocks)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysPerFile)
|
||||
|
@ -124,8 +124,8 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT64(pRaw, pRow, dataPos, &pDb->uid)
|
||||
SDB_GET_INT32(pRaw, pRow, dataPos, &pDb->cfgVersion)
|
||||
SDB_GET_INT32(pRaw, pRow, dataPos, &pDb->vgVersion)
|
||||
SDB_GET_INT32(pRaw, pRow, dataPos, &pDb->numOfVgroups)
|
||||
SDB_GET_INT8(pRaw, pRow, dataPos, &pDb->hashMethod)
|
||||
SDB_GET_INT32(pRaw, pRow, dataPos, &pDb->cfg.numOfVgroups)
|
||||
SDB_GET_INT32(pRaw, pRow, dataPos, &pDb->cfg.cacheBlockSize)
|
||||
SDB_GET_INT32(pRaw, pRow, dataPos, &pDb->cfg.totalBlocks)
|
||||
SDB_GET_INT32(pRaw, pRow, dataPos, &pDb->cfg.daysPerFile)
|
||||
|
@ -163,7 +163,6 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOldDb, SDbObj *pNewDb) {
|
|||
pOldDb->updateTime = pNewDb->createdTime;
|
||||
pOldDb->cfgVersion = pNewDb->cfgVersion;
|
||||
pOldDb->vgVersion = pNewDb->vgVersion;
|
||||
pOldDb->numOfVgroups = pNewDb->numOfVgroups;
|
||||
memcpy(&pOldDb->cfg, &pNewDb->cfg, sizeof(SDbCfg));
|
||||
return 0;
|
||||
}
|
||||
|
@ -195,6 +194,7 @@ static int32_t mndCheckDbName(char *dbName, SUserObj *pUser) {
|
|||
}
|
||||
|
||||
static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
||||
if (pCfg->numOfVgroups < TSDB_MIN_VNODES_PER_DB || pCfg->numOfVgroups > TSDB_MAX_VNODES_PER_DB) return -1;
|
||||
if (pCfg->cacheBlockSize < TSDB_MIN_CACHE_BLOCK_SIZE || pCfg->cacheBlockSize > TSDB_MAX_CACHE_BLOCK_SIZE) return -1;
|
||||
if (pCfg->totalBlocks < TSDB_MIN_TOTAL_BLOCKS || pCfg->totalBlocks > TSDB_MAX_TOTAL_BLOCKS) return -1;
|
||||
if (pCfg->daysPerFile < TSDB_MIN_DAYS_PER_FILE || pCfg->daysPerFile > TSDB_MAX_DAYS_PER_FILE) return -1;
|
||||
|
@ -222,6 +222,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
|||
}
|
||||
|
||||
static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
|
||||
if (pCfg->numOfVgroups < 0) pCfg->numOfVgroups = TSDB_DEFAULT_VN_PER_DB;
|
||||
if (pCfg->cacheBlockSize < 0) pCfg->cacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE;
|
||||
if (pCfg->totalBlocks < 0) pCfg->totalBlocks = TSDB_DEFAULT_TOTAL_BLOCKS;
|
||||
if (pCfg->daysPerFile < 0) pCfg->daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE;
|
||||
|
@ -246,7 +247,7 @@ static int32_t mndSetRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgOb
|
|||
if (pDbRaw == NULL || mndTransAppendRedolog(pTrans, pDbRaw) != 0) return -1;
|
||||
sdbSetRawStatus(pDbRaw, SDB_STATUS_CREATING);
|
||||
|
||||
for (int v = 0; v < pDb->numOfVgroups; ++v) {
|
||||
for (int v = 0; v < pDb->cfg.numOfVgroups; ++v) {
|
||||
SSdbRaw *pVgRaw = mndVgroupActionEncode(pVgroups + v);
|
||||
if (pVgRaw == NULL || mndTransAppendRedolog(pTrans, pVgRaw) != 0) return -1;
|
||||
sdbSetRawStatus(pVgRaw, SDB_STATUS_CREATING);
|
||||
|
@ -260,7 +261,7 @@ static int32_t mndSetUndoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgOb
|
|||
if (pDbRaw == NULL || mndTransAppendUndolog(pTrans, pDbRaw) != 0) return -1;
|
||||
sdbSetRawStatus(pDbRaw, SDB_STATUS_DROPPED);
|
||||
|
||||
for (int v = 0; v < pDb->numOfVgroups; ++v) {
|
||||
for (int v = 0; v < pDb->cfg.numOfVgroups; ++v) {
|
||||
SSdbRaw *pVgRaw = mndVgroupActionEncode(pVgroups + v);
|
||||
if (pVgRaw == NULL || mndTransAppendUndolog(pTrans, pVgRaw) != 0) return -1;
|
||||
sdbSetRawStatus(pVgRaw, SDB_STATUS_DROPPED);
|
||||
|
@ -274,7 +275,7 @@ static int32_t mndSetCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVg
|
|||
if (pDbRaw == NULL || mndTransAppendCommitlog(pTrans, pDbRaw) != 0) return -1;
|
||||
sdbSetRawStatus(pDbRaw, SDB_STATUS_READY);
|
||||
|
||||
for (int v = 0; v < pDb->numOfVgroups; ++v) {
|
||||
for (int v = 0; v < pDb->cfg.numOfVgroups; ++v) {
|
||||
SSdbRaw *pVgRaw = mndVgroupActionEncode(pVgroups + v);
|
||||
if (pVgRaw == NULL || mndTransAppendCommitlog(pTrans, pVgRaw) != 0) return -1;
|
||||
sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
|
||||
|
@ -298,11 +299,11 @@ static int32_t mndCreateDb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDbMsg *pCreat
|
|||
dbObj.createdTime = taosGetTimestampMs();
|
||||
dbObj.updateTime = dbObj.createdTime;
|
||||
dbObj.uid = mndGenerateUid(dbObj.name, TSDB_FULL_DB_NAME_LEN);
|
||||
dbObj.numOfVgroups = pCreate->numOfVgroups;
|
||||
dbObj.hashMethod = 1;
|
||||
dbObj.cfgVersion = 1;
|
||||
dbObj.vgVersion = 1;
|
||||
dbObj.cfg = (SDbCfg){.cacheBlockSize = pCreate->cacheBlockSize,
|
||||
dbObj.cfg = (SDbCfg){.numOfVgroups = pCreate->numOfVgroups,
|
||||
.cacheBlockSize = pCreate->cacheBlockSize,
|
||||
.totalBlocks = pCreate->totalBlocks,
|
||||
.daysPerFile = pCreate->daysPerFile,
|
||||
.daysToKeep0 = pCreate->daysToKeep0,
|
||||
|
@ -643,7 +644,7 @@ static int32_t mndProcessUseDbMsg(SMnodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t contLen = sizeof(SUseDbRsp) + pDb->numOfVgroups * sizeof(SVgroupInfo);
|
||||
int32_t contLen = sizeof(SUseDbRsp) + pDb->cfg.numOfVgroups * sizeof(SVgroupInfo);
|
||||
SUseDbRsp *pRsp = rpcMallocCont(contLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -654,7 +655,7 @@ static int32_t mndProcessUseDbMsg(SMnodeMsg *pMsg) {
|
|||
|
||||
if (pUse->vgVersion < pDb->vgVersion) {
|
||||
void *pIter = NULL;
|
||||
while (vindex < pDb->numOfVgroups) {
|
||||
while (vindex < pDb->cfg.numOfVgroups) {
|
||||
SVgObj *pVgroup = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
||||
if (pIter == NULL) break;
|
||||
|
@ -735,103 +736,103 @@ static int32_t mndGetDbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMe
|
|||
pShow->bytes[cols] = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "name");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "create time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
strcpy(pSchema[cols].name, "vgroups");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
strcpy(pSchema[cols].name, "replica");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
strcpy(pSchema[cols].name, "quorum");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
strcpy(pSchema[cols].name, "days");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 24 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "keep0,keep1,keep2");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "cache(MB)");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "cache");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "blocks");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "minrows");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "maxrows");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 1;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TINYINT;
|
||||
strcpy(pSchema[cols].name, "wallevel");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "fsync");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 1;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TINYINT;
|
||||
strcpy(pSchema[cols].name, "comp");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 1;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TINYINT;
|
||||
strcpy(pSchema[cols].name, "cachelast");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 3 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "precision");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 1;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TINYINT;
|
||||
strcpy(pSchema[cols].name, "update");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
|
@ -888,7 +889,7 @@ static int32_t mndRetrieveDbs(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int3
|
|||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
*(int16_t *)pWrite = pDb->numOfVgroups;
|
||||
*(int16_t *)pWrite = pDb->cfg.numOfVgroups;
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
|
|
|
@ -561,13 +561,13 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
|
|||
pShow->bytes[cols] = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
tstrncpy(pSchema[cols].name, "name", sizeof(pSchema[cols].name));
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_CONIIG_VALUE_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
tstrncpy(pSchema[cols].name, "value", sizeof(pSchema[cols].name));
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
|
@ -638,43 +638,43 @@ static int32_t mndGetDnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
|
|||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
strcpy(pSchema[cols].name, "id");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_EP_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "end point");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "endpoint");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
strcpy(pSchema[cols].name, "vnodes");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
strcpy(pSchema[cols].name, "max vnodes");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "max_vnodes");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 10 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "status");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "create time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 24 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "offline reason");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "offline_reason");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
|
|
|
@ -380,43 +380,43 @@ static int32_t mndGetFuncMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
|
|||
pShow->bytes[cols] = TSDB_FUNC_NAME_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "name");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = PATH_MAX + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "comment");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "aggregate");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_TYPE_STR_MAX_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "outputtype");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "code_len");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "bufsize");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
|
|
|
@ -368,31 +368,31 @@ static int32_t mndGetMnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
|
|||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
strcpy(pSchema[cols].name, "id");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_EP_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "end point");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "endpoint");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 12 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "role");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "role time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "role_time");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "create time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
|
|
|
@ -474,45 +474,45 @@ static int32_t mndGetConnsMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
|
|||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "connId");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_USER_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "user");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
// app name
|
||||
pShow->bytes[cols] = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "program");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
// app pid
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "pid");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "ip:port");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "login_time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "last_access");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
|
@ -602,85 +602,85 @@ static int32_t mndGetQueryMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
|
|||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "queryId");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "connId");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_USER_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "user");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "ip:port");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 24;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "qid");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "created_time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BIGINT;
|
||||
strcpy(pSchema[cols].name, "time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = QUERY_OBJ_ID_SIZE + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "sql_obj_id");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "pid");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_EP_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "ep");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 1;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BOOL;
|
||||
strcpy(pSchema[cols].name, "stable_query");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "sub_queries");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "sub_query_info");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "sql");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
|
@ -818,61 +818,61 @@ static int32_t mndGetStreamMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
|
|||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "streamId");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "connId");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_USER_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "user");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "dest table");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "destination");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "ip:port");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "created time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "exec time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "exec");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BIGINT;
|
||||
strcpy(pSchema[cols].name, "time(us)");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "sql");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "cycles");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
|
|
|
@ -291,7 +291,7 @@ char *mndShowStr(int32_t showType) {
|
|||
case TSDB_MGMT_TABLE_VNODES:
|
||||
return "show vnodes";
|
||||
case TSDB_MGMT_TABLE_CLUSTER:
|
||||
return "show clusters";
|
||||
return "show cluster";
|
||||
case TSDB_MGMT_TABLE_STREAMTABLES:
|
||||
return "show streamtables";
|
||||
case TSDB_MGMT_TABLE_TP:
|
||||
|
|
|
@ -80,7 +80,7 @@ static SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
|||
SDB_SET_INT64(pRaw, dataPos, pStb->updateTime)
|
||||
SDB_SET_INT64(pRaw, dataPos, pStb->uid)
|
||||
SDB_SET_INT64(pRaw, dataPos, pStb->dbUid)
|
||||
SDB_SET_INT64(pRaw, dataPos, pStb->version)
|
||||
SDB_SET_INT32(pRaw, dataPos, pStb->version)
|
||||
SDB_SET_INT32(pRaw, dataPos, pStb->numOfColumns)
|
||||
SDB_SET_INT32(pRaw, dataPos, pStb->numOfTags)
|
||||
|
||||
|
@ -157,11 +157,17 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOldStb, SStbObj *pNewStb
|
|||
atomic_exchange_32(&pOldStb->version, pNewStb->version);
|
||||
|
||||
taosWLockLatch(&pOldStb->lock);
|
||||
pOldStb->numOfColumns = pNewStb->numOfColumns;
|
||||
pOldStb->numOfTags = pNewStb->numOfTags;
|
||||
int32_t totalCols = pNewStb->numOfTags + pNewStb->numOfColumns;
|
||||
int32_t totalSize = totalCols * sizeof(SSchema);
|
||||
|
||||
if (pOldStb->numOfTags + pOldStb->numOfColumns < totalCols) {
|
||||
pOldStb->pSchema = malloc(totalSize);
|
||||
void *pSchema = malloc(totalSize);
|
||||
if (pSchema != NULL) {
|
||||
free(pOldStb->pSchema);
|
||||
pOldStb->pSchema = pSchema;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(pOldStb->pSchema, pNewStb->pSchema, totalSize);
|
||||
|
@ -200,37 +206,37 @@ static int32_t mndCheckStbMsg(SCreateStbMsg *pCreate) {
|
|||
}
|
||||
|
||||
if (pCreate->igExists < 0 || pCreate->igExists > 1) {
|
||||
terrno = TSDB_CODE_MND_STB_INVALID_IGEXIST;
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pCreate->numOfColumns < TSDB_MIN_COLUMNS || pCreate->numOfColumns > TSDB_MAX_COLUMNS) {
|
||||
terrno = TSDB_CODE_MND_STB_INVALID_COLS_NUM;
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pCreate->numOfTags <= 0 || pCreate->numOfTags > TSDB_MAX_TAGS) {
|
||||
terrno = TSDB_CODE_MND_STB_INVALID_TAGS_NUM;
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t maxColId = (TSDB_MAX_COLUMNS + TSDB_MAX_TAGS);
|
||||
for (int32_t i = 0; i < totalCols; ++i) {
|
||||
SSchema *pSchema = &pCreate->pSchema[i];
|
||||
if (pSchema->type <= 0) {
|
||||
terrno = TSDB_CODE_MND_STB_INVALID_COL_TYPE;
|
||||
if (pSchema->type < 0) {
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
if (pSchema->colId < 0 || pSchema->colId >= maxColId) {
|
||||
terrno = TSDB_CODE_MND_STB_INVALID_COL_ID;
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
if (pSchema->bytes <= 0) {
|
||||
terrno = TSDB_CODE_MND_STB_INVALID_COL_BYTES;
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
if (pSchema->name[0] == 0) {
|
||||
terrno = TSDB_CODE_MND_STB_INVALID_COL_NAME;
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -245,6 +251,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateStbMsg *pCre
|
|||
stbObj.createdTime = taosGetTimestampMs();
|
||||
stbObj.updateTime = stbObj.createdTime;
|
||||
stbObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
|
||||
stbObj.dbUid = pDb->uid;
|
||||
stbObj.version = 1;
|
||||
stbObj.numOfColumns = pCreate->numOfColumns;
|
||||
stbObj.numOfTags = pCreate->numOfTags;
|
||||
|
@ -350,19 +357,19 @@ static int32_t mndCheckAlterStbMsg(SAlterStbMsg *pAlter) {
|
|||
pSchema->bytes = htonl(pSchema->bytes);
|
||||
|
||||
if (pSchema->type <= 0) {
|
||||
terrno = TSDB_CODE_MND_STB_INVALID_COL_TYPE;
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
if (pSchema->colId < 0 || pSchema->colId >= (TSDB_MAX_COLUMNS + TSDB_MAX_TAGS)) {
|
||||
terrno = TSDB_CODE_MND_STB_INVALID_COL_ID;
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
if (pSchema->bytes <= 0) {
|
||||
terrno = TSDB_CODE_MND_STB_INVALID_COL_BYTES;
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
if (pSchema->name[0] == 0) {
|
||||
terrno = TSDB_CODE_MND_STB_INVALID_COL_NAME;
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -480,31 +487,37 @@ static int32_t mndProcessDropStbMsg(SMnodeMsg *pMsg) {
|
|||
static int32_t mndProcessDropStbInRsp(SMnodeMsg *pMsg) { return 0; }
|
||||
|
||||
static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SStbInfoMsg *pInfo = pMsg->rpcMsg.pCont;
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
STableInfoMsg *pInfo = pMsg->rpcMsg.pCont;
|
||||
|
||||
mDebug("stb:%s, start to retrieve meta", pInfo->name);
|
||||
mDebug("stb:%s, start to retrieve meta", pInfo->tableFname);
|
||||
|
||||
SDbObj *pDb = mndAcquireDbByStb(pMnode, pInfo->name);
|
||||
SDbObj *pDb = mndAcquireDbByStb(pMnode, pInfo->tableFname);
|
||||
if (pDb == NULL) {
|
||||
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||
mError("stb:%s, failed to retrieve meta since %s", pInfo->name, terrstr());
|
||||
mError("stb:%s, failed to retrieve meta since %s", pInfo->tableFname, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
SStbObj *pStb = mndAcquireStb(pMnode, pInfo->name);
|
||||
SStbObj *pStb = mndAcquireStb(pMnode, pInfo->tableFname);
|
||||
if (pStb == NULL) {
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
terrno = TSDB_CODE_MND_INVALID_TABLE_NAME;
|
||||
mError("stb:%s, failed to get meta since %s", pInfo->name, terrstr());
|
||||
terrno = TSDB_CODE_MND_INVALID_STB;
|
||||
mError("stb:%s, failed to get meta since %s", pInfo->tableFname, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t contLen = sizeof(STableMetaMsg) + (pStb->numOfColumns + pStb->numOfTags) * sizeof(SSchema);
|
||||
taosRLockLatch(&pStb->lock);
|
||||
int32_t totalCols = pStb->numOfColumns + pStb->numOfTags;
|
||||
int32_t contLen = sizeof(STableMetaMsg) + totalCols * sizeof(SSchema);
|
||||
|
||||
STableMetaMsg *pMeta = rpcMallocCont(contLen);
|
||||
if (pMeta == NULL) {
|
||||
taosRUnLockLatch(&pStb->lock);
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
mndReleaseStb(pMnode, pStb);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("stb:%s, failed to get meta since %s", pInfo->name, terrstr());
|
||||
mError("stb:%s, failed to get meta since %s", pInfo->tableFname, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -517,7 +530,7 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) {
|
|||
pMeta->sversion = htonl(pStb->version);
|
||||
pMeta->suid = htonl(pStb->uid);
|
||||
|
||||
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {
|
||||
for (int32_t i = 0; i < totalCols; ++i) {
|
||||
SSchema *pSchema = &pMeta->pSchema[i];
|
||||
SSchema *pSrcSchema = &pStb->pSchema[i];
|
||||
memcpy(pSchema->name, pSrcSchema->name, TSDB_COL_NAME_LEN);
|
||||
|
@ -525,11 +538,14 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) {
|
|||
pSchema->colId = htonl(pSrcSchema->colId);
|
||||
pSchema->bytes = htonl(pSrcSchema->bytes);
|
||||
}
|
||||
taosRUnLockLatch(&pStb->lock);
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
mndReleaseStb(pMnode, pStb);
|
||||
|
||||
pMsg->pCont = pMeta;
|
||||
pMsg->contLen = contLen;
|
||||
|
||||
mDebug("stb:%s, meta is retrieved, cols:%d tags:%d", pInfo->name, pStb->numOfColumns, pStb->numOfTags);
|
||||
mDebug("stb:%s, meta is retrieved, cols:%d tags:%d", pInfo->tableFname, pStb->numOfColumns, pStb->numOfTags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -546,7 +562,7 @@ static int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs
|
|||
void *pIter = NULL;
|
||||
while (1) {
|
||||
SStbObj *pStb = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pStb);
|
||||
pIter = sdbFetch(pSdb, SDB_STB, pIter, (void **)&pStb);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (strcmp(pStb->db, dbName) == 0) {
|
||||
|
@ -574,25 +590,25 @@ static int32_t mndGetStbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pM
|
|||
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "name");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "create time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "columns");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "tags");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
|
@ -603,6 +619,7 @@ static int32_t mndGetStbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pM
|
|||
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||
}
|
||||
|
||||
pShow->numOfRows = sdbGetSize(pSdb, SDB_STB);
|
||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||
strcpy(pMeta->tbFname, mndShowStr(pShow->type));
|
||||
|
||||
|
@ -646,8 +663,8 @@ static int32_t mndRetrieveStb(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int3
|
|||
|
||||
cols = 0;
|
||||
|
||||
char stbName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
memcpy(stbName, pStb->name + prefixLen, TSDB_TABLE_FNAME_LEN - prefixLen);
|
||||
char stbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
tstrncpy(stbName, pStb->name + prefixLen, TSDB_TABLE_NAME_LEN);
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_TO_VARSTR(pWrite, stbName);
|
||||
cols++;
|
||||
|
@ -657,11 +674,11 @@ static int32_t mndRetrieveStb(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int3
|
|||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
*(int16_t *)pWrite = pStb->numOfColumns;
|
||||
*(int32_t *)pWrite = pStb->numOfColumns;
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
*(int16_t *)pWrite = pStb->numOfTags;
|
||||
*(int32_t *)pWrite = pStb->numOfTags;
|
||||
cols++;
|
||||
|
||||
numOfRows++;
|
||||
|
|
|
@ -410,25 +410,25 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
|
|||
pShow->bytes[cols] = TSDB_USER_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "name");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 10 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "privilege");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "create time");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_USER_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "account");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
|
|
|
@ -156,11 +156,6 @@ void mndReleaseVgroup(SMnode *pMnode, SVgObj *pVgroup) {
|
|||
sdbRelease(pSdb, pVgroup);
|
||||
}
|
||||
|
||||
static int32_t mndGetDefaultVgroupSize(SMnode *pMnode) {
|
||||
// todo
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int32_t mndGetAvailableDnode(SMnode *pMnode, SVgObj *pVgroup) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t allocedVnodes = 0;
|
||||
|
@ -193,21 +188,7 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SVgObj *pVgroup) {
|
|||
}
|
||||
|
||||
int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
|
||||
if (pDb->numOfVgroups != -1 &&
|
||||
(pDb->numOfVgroups < TSDB_MIN_VNODES_PER_DB || pDb->numOfVgroups > TSDB_MAX_VNODES_PER_DB)) {
|
||||
terrno = TSDB_CODE_MND_INVALID_DB_OPTION;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pDb->numOfVgroups == -1) {
|
||||
pDb->numOfVgroups = mndGetDefaultVgroupSize(pMnode);
|
||||
if (pDb->numOfVgroups < 0) {
|
||||
terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
SVgObj *pVgroups = calloc(pDb->numOfVgroups, sizeof(SVgObj));
|
||||
SVgObj *pVgroups = calloc(pDb->cfg.numOfVgroups, sizeof(SVgObj));
|
||||
if (pVgroups == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
|
@ -217,9 +198,9 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
|
|||
int32_t maxVgId = sdbGetMaxId(pMnode->pSdb, SDB_VGROUP);
|
||||
uint32_t hashMin = 0;
|
||||
uint32_t hashMax = UINT32_MAX;
|
||||
uint32_t hashInterval = (hashMax - hashMin) / pDb->numOfVgroups;
|
||||
uint32_t hashInterval = (hashMax - hashMin) / pDb->cfg.numOfVgroups;
|
||||
|
||||
for (uint32_t v = 0; v < pDb->numOfVgroups; v++) {
|
||||
for (uint32_t v = 0; v < pDb->cfg.numOfVgroups; v++) {
|
||||
SVgObj *pVgroup = &pVgroups[v];
|
||||
pVgroup->vgId = maxVgId++;
|
||||
pVgroup->createdTime = taosGetTimestampMs();
|
||||
|
@ -227,7 +208,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
|
|||
pVgroup->version = 1;
|
||||
pVgroup->dbUid = pDb->uid;
|
||||
pVgroup->hashBegin = hashMin + hashInterval * v;
|
||||
if (v == pDb->numOfVgroups - 1) {
|
||||
if (v == pDb->cfg.numOfVgroups - 1) {
|
||||
pVgroup->hashEnd = hashMax;
|
||||
} else {
|
||||
pVgroup->hashEnd = hashMin + hashInterval * (v + 1) - 1;
|
||||
|
@ -300,26 +281,26 @@ static int32_t mndGetVgroupMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
|
|||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "vgId");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "tables");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
for (int32_t i = 0; i < pShow->replica; ++i) {
|
||||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
snprintf(pSchema[cols].name, TSDB_COL_NAME_LEN, "v%d_dnode", i + 1);
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 9 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
snprintf(pSchema[cols].name, TSDB_COL_NAME_LEN, "v%d_status", i + 1);
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
}
|
||||
|
||||
|
@ -402,13 +383,13 @@ static int32_t mndGetVnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
|
|||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "vgId");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 12 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "status");
|
||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||
pSchema[cols].bytes = htonl(pShow->bytes[cols]);
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = htonl(cols);
|
||||
|
|
|
@ -32,6 +32,8 @@ int vnodeBufPoolRecycle(SVnode *pVnode);
|
|||
void *vnodeMalloc(SVnode *pVnode, uint64_t size);
|
||||
bool vnodeBufPoolIsFull(SVnode *pVnode);
|
||||
|
||||
SMemAllocatorFactory *vBufPoolGetMAF(SVnode *pVnode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "mallocator.h"
|
||||
#include "sync.h"
|
||||
#include "tcoding.h"
|
||||
#include "tdlist.h"
|
||||
#include "tlist.h"
|
||||
#include "tlockfree.h"
|
||||
#include "tmacro.h"
|
||||
#include "wal.h"
|
||||
|
|
|
@ -13,19 +13,20 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_COMMON_INT_H_
|
||||
#define _TD_COMMON_INT_H_
|
||||
#ifndef _TD_VNODE_MAF_H_
|
||||
#define _TD_VNODE_MAF_H_
|
||||
|
||||
#include "vnode.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags);
|
||||
|
||||
|
||||
int vnodeOpenMAF(SVnode *pVnode);
|
||||
void vnodeCloseMAF(SVnode *pVnode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_COMMON_INT_H_*/
|
||||
#endif /*_TD_VNODE_MAF_H_*/
|
|
@ -21,13 +21,13 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint64_t processed;
|
||||
uint64_t committed;
|
||||
uint64_t applied;
|
||||
int64_t processed;
|
||||
int64_t committed;
|
||||
int64_t applied;
|
||||
} SVState;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_VNODE_STATE_MGR_H_*/
|
||||
#endif /*_TD_VNODE_STATE_MGR_H_*/
|
||||
|
|
|
@ -27,7 +27,7 @@ SVMemAllocator *vmaCreate(uint64_t capacity, uint64_t ssize, uint64_t lsize) {
|
|||
pVMA->capacity = capacity;
|
||||
pVMA->ssize = ssize;
|
||||
pVMA->lsize = lsize;
|
||||
tSListInit(&(pVMA->nlist));
|
||||
TD_SLIST_INIT(&(pVMA->nlist));
|
||||
|
||||
pVMA->pNode = vArenaNodeNew(capacity);
|
||||
if (pVMA->pNode == NULL) {
|
||||
|
@ -35,7 +35,7 @@ SVMemAllocator *vmaCreate(uint64_t capacity, uint64_t ssize, uint64_t lsize) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
tSListPush(&(pVMA->nlist), pVMA->pNode);
|
||||
TD_SLIST_PUSH(&(pVMA->nlist), pVMA->pNode);
|
||||
|
||||
return pVMA;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ void vmaDestroy(SVMemAllocator *pVMA) {
|
|||
if (pVMA) {
|
||||
while (TD_SLIST_NELES(&(pVMA->nlist)) > 1) {
|
||||
SVArenaNode *pNode = TD_SLIST_HEAD(&(pVMA->nlist));
|
||||
tSListPop(&(pVMA->nlist));
|
||||
TD_SLIST_POP(&(pVMA->nlist));
|
||||
vArenaNodeFree(pNode);
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ void vmaDestroy(SVMemAllocator *pVMA) {
|
|||
void vmaReset(SVMemAllocator *pVMA) {
|
||||
while (TD_SLIST_NELES(&(pVMA->nlist)) > 1) {
|
||||
SVArenaNode *pNode = TD_SLIST_HEAD(&(pVMA->nlist));
|
||||
tSListPop(&(pVMA->nlist));
|
||||
TD_SLIST_POP(&(pVMA->nlist));
|
||||
vArenaNodeFree(pNode);
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ void *vmaMalloc(SVMemAllocator *pVMA, uint64_t size) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
tSListPush(&(pVMA->nlist), pNode);
|
||||
TD_SLIST_PUSH(&(pVMA->nlist), pNode);
|
||||
}
|
||||
|
||||
ptr = pNode->ptr;
|
||||
|
|
|
@ -24,10 +24,13 @@ struct SVBufPool {
|
|||
TD_DLIST(SVMemAllocator) free;
|
||||
TD_DLIST(SVMemAllocator) incycle;
|
||||
SVMemAllocator *inuse;
|
||||
// MAF for submodules
|
||||
// SMemAllocatorFactory maf;
|
||||
// MAF for submodules to use
|
||||
SMemAllocatorFactory *pMAF;
|
||||
};
|
||||
|
||||
static SMemAllocator *vBufPoolCreateMA(SMemAllocatorFactory *pMAF);
|
||||
static void vBufPoolDestroyMA(SMemAllocatorFactory *pMAF, SMemAllocator *pMA);
|
||||
|
||||
int vnodeOpenBufPool(SVnode *pVnode) {
|
||||
uint64_t capacity;
|
||||
|
||||
|
@ -36,8 +39,8 @@ int vnodeOpenBufPool(SVnode *pVnode) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
tDListInit(&(pVnode->pBufPool->free));
|
||||
tDListInit(&(pVnode->pBufPool->incycle));
|
||||
TD_DLIST_INIT(&(pVnode->pBufPool->free));
|
||||
TD_DLIST_INIT(&(pVnode->pBufPool->incycle));
|
||||
|
||||
pVnode->pBufPool->inuse = NULL;
|
||||
|
||||
|
@ -51,9 +54,18 @@ int vnodeOpenBufPool(SVnode *pVnode) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
tDListAppend(&(pVnode->pBufPool->free), pVMA);
|
||||
TD_DLIST_APPEND(&(pVnode->pBufPool->free), pVMA);
|
||||
}
|
||||
|
||||
pVnode->pBufPool->pMAF = (SMemAllocatorFactory *)malloc(sizeof(SMemAllocatorFactory));
|
||||
if (pVnode->pBufPool->pMAF == NULL) {
|
||||
// TODO: handle error
|
||||
return -1;
|
||||
}
|
||||
pVnode->pBufPool->pMAF->impl = pVnode;
|
||||
pVnode->pBufPool->pMAF->create = vBufPoolCreateMA;
|
||||
pVnode->pBufPool->pMAF->destroy = vBufPoolDestroyMA;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -64,14 +76,14 @@ void vnodeCloseBufPool(SVnode *pVnode) {
|
|||
while (true) {
|
||||
SVMemAllocator *pVMA = TD_DLIST_HEAD(&(pVnode->pBufPool->incycle));
|
||||
if (pVMA == NULL) break;
|
||||
tDListPop(&(pVnode->pBufPool->incycle), pVMA);
|
||||
TD_DLIST_POP(&(pVnode->pBufPool->incycle), pVMA);
|
||||
vmaDestroy(pVMA);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
SVMemAllocator *pVMA = TD_DLIST_HEAD(&(pVnode->pBufPool->free));
|
||||
if (pVMA == NULL) break;
|
||||
tDListPop(&(pVnode->pBufPool->free), pVMA);
|
||||
TD_DLIST_POP(&(pVnode->pBufPool->free), pVMA);
|
||||
vmaDestroy(pVMA);
|
||||
}
|
||||
|
||||
|
@ -85,7 +97,7 @@ int vnodeBufPoolSwitch(SVnode *pVnode) {
|
|||
|
||||
pVnode->pBufPool->inuse = NULL;
|
||||
|
||||
tDListAppend(&(pVnode->pBufPool->incycle), pvma);
|
||||
TD_DLIST_APPEND(&(pVnode->pBufPool->incycle), pvma);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -94,9 +106,9 @@ int vnodeBufPoolRecycle(SVnode *pVnode) {
|
|||
SVMemAllocator *pvma = TD_DLIST_HEAD(&(pBufPool->incycle));
|
||||
ASSERT(pvma != NULL);
|
||||
|
||||
tDListPop(&(pBufPool->incycle), pvma);
|
||||
TD_DLIST_POP(&(pBufPool->incycle), pvma);
|
||||
vmaReset(pvma);
|
||||
tDListAppend(&(pBufPool->free), pvma);
|
||||
TD_DLIST_APPEND(&(pBufPool->free), pvma);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -109,7 +121,7 @@ void *vnodeMalloc(SVnode *pVnode, uint64_t size) {
|
|||
// TODO: add sem_wait and sem_post
|
||||
pBufPool->inuse = TD_DLIST_HEAD(&(pBufPool->free));
|
||||
if (pBufPool->inuse) {
|
||||
tDListPop(&(pBufPool->free), pBufPool->inuse);
|
||||
TD_DLIST_POP(&(pBufPool->free), pBufPool->inuse);
|
||||
break;
|
||||
} else {
|
||||
// tsem_wait(&(pBufPool->hasFree));
|
||||
|
@ -125,195 +137,50 @@ bool vnodeBufPoolIsFull(SVnode *pVnode) {
|
|||
return vmaIsFull(pVnode->pBufPool->inuse);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
typedef enum {
|
||||
// Heap allocator
|
||||
E_V_HEAP_ALLOCATOR = 0,
|
||||
// Arena allocator
|
||||
E_V_ARENA_ALLOCATOR
|
||||
} EVMemAllocatorT;
|
||||
|
||||
typedef struct {
|
||||
/* TODO */
|
||||
} SVHeapAllocator;
|
||||
|
||||
typedef struct SVArenaNode {
|
||||
struct SVArenaNode *prev;
|
||||
uint64_t size;
|
||||
void * ptr;
|
||||
char data[];
|
||||
} SVArenaNode;
|
||||
|
||||
typedef struct {
|
||||
uint64_t ssize; // step size
|
||||
uint64_t lsize; // limit size
|
||||
SVArenaNode *inuse;
|
||||
SVArenaNode node;
|
||||
} SVArenaAllocator;
|
||||
|
||||
typedef struct {
|
||||
SVnode * pVnode;
|
||||
SListNode *pNode;
|
||||
} SVMAWrapper;
|
||||
|
||||
|
||||
static SListNode * vBufPoolNewNode(uint64_t capacity, EVMemAllocatorT type);
|
||||
static void vBufPoolFreeNode(SListNode *pNode);
|
||||
static SMemAllocator *vBufPoolCreateMA(SMemAllocatorFactory *pmaf);
|
||||
static void vBufPoolDestroyMA(SMemAllocatorFactory *pmaf, SMemAllocator *pma);
|
||||
static void * vBufPoolMalloc(SVMemAllocator *pvma, uint64_t size);
|
||||
SMemAllocatorFactory *vBufPoolGetMAF(SVnode *pVnode) { return pVnode->pBufPool->pMAF; }
|
||||
|
||||
/* ------------------------ STATIC METHODS ------------------------ */
|
||||
static SListNode *vBufPoolNewNode(uint64_t capacity, EVMemAllocatorT type) {
|
||||
SListNode * pNode;
|
||||
SVMemAllocator *pvma;
|
||||
uint64_t msize;
|
||||
uint64_t ssize = 4096; // TODO
|
||||
uint64_t lsize = 1024; // TODO
|
||||
|
||||
msize = sizeof(SListNode) + sizeof(SVMemAllocator);
|
||||
if (type == E_V_ARENA_ALLOCATOR) {
|
||||
msize += capacity;
|
||||
}
|
||||
|
||||
pNode = (SListNode *)calloc(1, msize);
|
||||
if (pNode == NULL) {
|
||||
// TODO: handle error
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pvma = (SVMemAllocator *)(pNode->data);
|
||||
pvma->capacity = capacity;
|
||||
pvma->type = type;
|
||||
|
||||
switch (type) {
|
||||
case E_V_ARENA_ALLOCATOR:
|
||||
vArenaAllocatorInit(&(pvma->vaa), capacity, ssize, lsize);
|
||||
break;
|
||||
case E_V_HEAP_ALLOCATOR:
|
||||
// vHeapAllocatorInit(&(pvma->vha));
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
return pNode;
|
||||
}
|
||||
|
||||
static void vBufPoolFreeNode(SListNode *pNode) {
|
||||
SVMemAllocator *pvma = (SVMemAllocator *)(pNode->data);
|
||||
|
||||
switch (pvma->type) {
|
||||
case E_V_ARENA_ALLOCATOR:
|
||||
vArenaAllocatorClear(&(pvma->vaa));
|
||||
break;
|
||||
case E_V_HEAP_ALLOCATOR:
|
||||
// vHeapAllocatorClear(&(pvma->vha));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
free(pNode);
|
||||
}
|
||||
|
||||
static void *vBufPoolMalloc(SVMemAllocator *pvma, uint64_t size) {
|
||||
void *ptr = NULL;
|
||||
|
||||
if (pvma->type == E_V_ARENA_ALLOCATOR) {
|
||||
SVArenaAllocator *pvaa = &(pvma->vaa);
|
||||
|
||||
if (POINTER_DISTANCE(pvaa->inuse->ptr, pvaa->inuse->data) + size > pvaa->inuse->size) {
|
||||
SVArenaNode *pNode = (SVArenaNode *)malloc(sizeof(*pNode) + MAX(size, pvaa->ssize));
|
||||
if (pNode == NULL) {
|
||||
// TODO: handle error
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pNode->prev = pvaa->inuse;
|
||||
pNode->size = MAX(size, pvaa->ssize);
|
||||
pNode->ptr = pNode->data;
|
||||
|
||||
pvaa->inuse = pNode;
|
||||
}
|
||||
|
||||
ptr = pvaa->inuse->ptr;
|
||||
pvaa->inuse->ptr = POINTER_SHIFT(ptr, size);
|
||||
} else if (pvma->type == E_V_HEAP_ALLOCATOR) {
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static SMemAllocator *vBufPoolCreateMA(SMemAllocatorFactory *pmaf) {
|
||||
typedef struct {
|
||||
SVnode * pVnode;
|
||||
SMemAllocator * pma;
|
||||
SVMemAllocator *pvma;
|
||||
SVMAWrapper * pvmaw;
|
||||
SVMemAllocator *pVMA;
|
||||
} SVMAWrapper;
|
||||
|
||||
pVnode = (SVnode *)(pmaf->impl);
|
||||
pma = (SMemAllocator *)calloc(1, sizeof(*pma) + sizeof(SVMAWrapper));
|
||||
if (pma == NULL) {
|
||||
// TODO: handle error
|
||||
static FORCE_INLINE void *vmaMaloocCb(SMemAllocator *pMA, uint64_t size) {
|
||||
SVMAWrapper *pWrapper = (SVMAWrapper *)(pMA->impl);
|
||||
|
||||
return vmaMalloc(pWrapper->pVMA, size);
|
||||
}
|
||||
|
||||
// TODO: Add atomic operations here
|
||||
static SMemAllocator *vBufPoolCreateMA(SMemAllocatorFactory *pMAF) {
|
||||
SMemAllocator *pMA;
|
||||
SVnode * pVnode = (SVnode *)(pMAF->impl);
|
||||
SVMAWrapper * pWrapper;
|
||||
|
||||
pMA = (SMemAllocator *)calloc(1, sizeof(*pMA) + sizeof(SVMAWrapper));
|
||||
if (pMA == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
pvmaw = (SVMAWrapper *)POINTER_SHIFT(pma, sizeof(*pma));
|
||||
|
||||
// No allocator used currently
|
||||
if (pVnode->pBufPool->inuse == NULL) {
|
||||
while (listNEles(&(pVnode->pBufPool->free)) == 0) {
|
||||
// TODO: wait until all released ro kill query
|
||||
// tsem_wait();
|
||||
ASSERT(0);
|
||||
}
|
||||
pVnode->pBufPool->inuse->_ref.val++;
|
||||
pWrapper = POINTER_SHIFT(pMA, sizeof(*pMA));
|
||||
pWrapper->pVnode = pVnode;
|
||||
pWrapper->pVMA = pVnode->pBufPool->inuse;
|
||||
|
||||
pVnode->pBufPool->inuse = tdListPopHead(&(pVnode->pBufPool->free));
|
||||
pvma = (SVMemAllocator *)(pVnode->pBufPool->inuse->data);
|
||||
T_REF_INIT_VAL(pvma, 1);
|
||||
} else {
|
||||
pvma = (SVMemAllocator *)(pVnode->pBufPool->inuse->data);
|
||||
}
|
||||
pMA->impl = pWrapper;
|
||||
TD_MA_MALLOC_FUNC(pMA) = vmaMaloocCb;
|
||||
|
||||
T_REF_INC(pvma);
|
||||
|
||||
pvmaw->pVnode = pVnode;
|
||||
pvmaw->pNode = pVnode->pBufPool->inuse;
|
||||
|
||||
pma->impl = pvmaw;
|
||||
pma->malloc = NULL;
|
||||
pma->calloc = NULL; /* TODO */
|
||||
pma->realloc = NULL; /* TODO */
|
||||
pma->free = NULL; /* TODO */
|
||||
pma->usage = NULL; /* TODO */
|
||||
|
||||
return pma;
|
||||
return pMA;
|
||||
}
|
||||
|
||||
static void vBufPoolDestroyMA(SMemAllocatorFactory *pmaf, SMemAllocator *pma) { /* TODO */
|
||||
SVnode * pVnode = (SVnode *)(pmaf->impl);
|
||||
SListNode * pNode = ((SVMAWrapper *)(pma->impl))->pNode;
|
||||
SVMemAllocator *pvma = (SVMemAllocator *)(pNode->data);
|
||||
static void vBufPoolDestroyMA(SMemAllocatorFactory *pMAF, SMemAllocator *pMA) {
|
||||
SVMAWrapper * pWrapper = (SVMAWrapper *)(pMA->impl);
|
||||
SVnode * pVnode = pWrapper->pVnode;
|
||||
SVMemAllocator *pVMA = pWrapper->pVMA;
|
||||
|
||||
if (T_REF_DEC(pvma) == 0) {
|
||||
if (pvma->type == E_V_ARENA_ALLOCATOR) {
|
||||
SVArenaAllocator *pvaa = &(pvma->vaa);
|
||||
while (pvaa->inuse != &(pvaa->node)) {
|
||||
SVArenaNode *pNode = pvaa->inuse;
|
||||
pvaa->inuse = pNode->prev;
|
||||
/* code */
|
||||
}
|
||||
|
||||
pvaa->inuse->ptr = pvaa->inuse->data;
|
||||
} else if (pvma->type == E_V_HEAP_ALLOCATOR) {
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
// Move node from incycle to free
|
||||
tdListAppendNode(&(pVnode->pBufPool->free), tdListPopNode(&(pVnode->pBufPool->incycle), pNode));
|
||||
// tsem_post(); todo: sem_post
|
||||
free(pMA);
|
||||
if (--pVMA->_ref.val == 0) {
|
||||
TD_DLIST_POP(&(pVnode->pBufPool->incycle), pVMA);
|
||||
TD_DLIST_APPEND(&(pVnode->pBufPool->free), pVMA);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -94,7 +94,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
|
|||
|
||||
// Open meta
|
||||
sprintf(dir, "%s/meta", pVnode->path);
|
||||
pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaCfg));
|
||||
pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaCfg), vBufPoolGetMAF(pVnode));
|
||||
if (pVnode->pMeta == NULL) {
|
||||
// TODO: handle error
|
||||
return -1;
|
||||
|
@ -102,7 +102,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
|
|||
|
||||
// Open tsdb
|
||||
sprintf(dir, "%s/tsdb", pVnode->path);
|
||||
pVnode->pTsdb = tsdbOpen(dir, &(pVnode->config.tsdbCfg));
|
||||
pVnode->pTsdb = tsdbOpen(dir, &(pVnode->config.tsdbCfg), vBufPoolGetMAF(pVnode));
|
||||
if (pVnode->pTsdb == NULL) {
|
||||
// TODO: handle error
|
||||
return -1;
|
||||
|
@ -110,7 +110,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
|
|||
|
||||
// TODO: Open TQ
|
||||
sprintf(dir, "%s/tq", pVnode->path);
|
||||
pVnode->pTq = tqOpen(dir, &(pVnode->config.tqCfg), NULL, NULL);
|
||||
pVnode->pTq = tqOpen(dir, &(pVnode->config.tqCfg), NULL, vBufPoolGetMAF(pVnode));
|
||||
if (pVnode->pTq == NULL) {
|
||||
// TODO: handle error
|
||||
return -1;
|
||||
|
@ -131,7 +131,9 @@ static int vnodeOpenImpl(SVnode *pVnode) {
|
|||
static void vnodeCloseImpl(SVnode *pVnode) {
|
||||
if (pVnode) {
|
||||
vnodeCloseBufPool(pVnode);
|
||||
tsdbClose(pVnode->pTsdb);
|
||||
metaClose(pVnode->pMeta);
|
||||
tsdbClose(pVnode->pTsdb);
|
||||
tqClose(pVnode->pTq);
|
||||
walClose(pVnode->pWal);
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ int vnodeInit(uint16_t nthreads) {
|
|||
|
||||
pthread_mutex_init(&(vnodeMgr.mutex), NULL);
|
||||
pthread_cond_init(&(vnodeMgr.hasTask), NULL);
|
||||
tDListInit(&(vnodeMgr.queue));
|
||||
TD_DLIST_INIT(&(vnodeMgr.queue));
|
||||
|
||||
for (uint16_t i = 0; i < nthreads; i++) {
|
||||
pthread_create(&(vnodeMgr.threads[i]), NULL, loop, NULL);
|
||||
|
@ -77,7 +77,7 @@ void vnodeClear() {
|
|||
int vnodeScheduleTask(SVnodeTask* pTask) {
|
||||
pthread_mutex_lock(&(vnodeMgr.mutex));
|
||||
|
||||
tDListAppend(&(vnodeMgr.queue), pTask);
|
||||
TD_DLIST_APPEND(&(vnodeMgr.queue), pTask);
|
||||
|
||||
pthread_cond_signal(&(vnodeMgr.hasTask));
|
||||
|
||||
|
@ -101,7 +101,7 @@ static void* loop(void* arg) {
|
|||
pthread_cond_wait(&(vnodeMgr.hasTask), &(vnodeMgr.mutex));
|
||||
}
|
||||
} else {
|
||||
tDListPop(&(vnodeMgr.queue), pTask);
|
||||
TD_DLIST_POP(&(vnodeMgr.queue), pTask);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,10 @@ int vnodeBuildReq(void **buf, const SVnodeReq *pReq, uint8_t type) {
|
|||
switch (type) {
|
||||
case TSDB_MSG_TYPE_CREATE_TABLE:
|
||||
tsize += vnodeBuildCreateTableReq(buf, &(pReq->ctReq));
|
||||
break;
|
||||
case TSDB_MSG_TYPE_SUBMIT:
|
||||
/* code */
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -15,16 +15,31 @@
|
|||
|
||||
#include "vnodeDef.h"
|
||||
|
||||
int vnodeProcessNoWalWMsgs(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
SVnodeReq *pVnodeReq;
|
||||
|
||||
switch (pMsg->msgType) {
|
||||
case TSDB_MSG_TYPE_MQ_SET:
|
||||
if (tqSetCursor(pVnode->pTq, pMsg->pCont) < 0) {
|
||||
// TODO: handle error
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
void *pBuf = pMsg->pCont;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
|
||||
SRpcMsg * pMsg;
|
||||
SRpcMsg *pMsg;
|
||||
SVnodeReq *pVnodeReq;
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(pMsgs); i++) {
|
||||
pMsg = *(SRpcMsg **)taosArrayGet(pMsgs, i);
|
||||
|
||||
// ser request version
|
||||
void * pBuf = pMsg->pCont;
|
||||
uint64_t ver = pVnode->state.processed++;
|
||||
void *pBuf = pMsg->pCont;
|
||||
int64_t ver = pVnode->state.processed++;
|
||||
taosEncodeFixedU64(&pBuf, ver);
|
||||
|
||||
if (walWrite(pVnode->pWal, ver, pMsg->msgType, pMsg->pCont, pMsg->contLen) < 0) {
|
||||
|
@ -99,4 +114,4 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------ STATIC METHODS ------------------------ */
|
||||
/* ------------------------ STATIC METHODS ------------------------ */
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
// https://stackoverflow.com/questions/8565666/benchmarking-with-googletest
|
||||
// https://github.com/google/benchmark
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "vnode.h"
|
||||
|
||||
static STSchema *createBasicSchema() {
|
||||
static STSchema *vtCreateBasicSchema() {
|
||||
STSchemaBuilder sb;
|
||||
STSchema * pSchema = NULL;
|
||||
|
||||
|
@ -32,7 +32,7 @@ static STSchema *createBasicSchema() {
|
|||
return pSchema;
|
||||
}
|
||||
|
||||
static STSchema *createBasicTagSchema() {
|
||||
static STSchema *vtCreateBasicTagSchema() {
|
||||
STSchemaBuilder sb;
|
||||
STSchema * pSchema = NULL;
|
||||
|
||||
|
@ -50,7 +50,7 @@ static STSchema *createBasicTagSchema() {
|
|||
return pSchema;
|
||||
}
|
||||
|
||||
static SKVRow createBasicTag() {
|
||||
static SKVRow vtCreateBasicTag() {
|
||||
SKVRowBuilder rb;
|
||||
SKVRow pTag;
|
||||
|
||||
|
@ -71,118 +71,203 @@ static SKVRow createBasicTag() {
|
|||
return pTag;
|
||||
}
|
||||
|
||||
#if 0
|
||||
TEST(vnodeApiTest, test_create_table_encode_and_decode_function) {
|
||||
tb_uid_t suid = 1638166374163;
|
||||
STSchema *pSchema = createBasicSchema();
|
||||
STSchema *pTagSchema = createBasicTagSchema();
|
||||
char tbname[128] = "st";
|
||||
char * buffer = new char[1024];
|
||||
void * pBuf = (void *)buffer;
|
||||
static void vtBuildCreateStbReq(tb_uid_t suid, char *tbname, SRpcMsg **ppMsg) {
|
||||
SRpcMsg * pMsg;
|
||||
STSchema *pSchema;
|
||||
STSchema *pTagSchema;
|
||||
int zs;
|
||||
void * pBuf;
|
||||
|
||||
pSchema = vtCreateBasicSchema();
|
||||
pTagSchema = vtCreateBasicTagSchema();
|
||||
|
||||
SVnodeReq vCreateSTbReq = VNODE_INIT_CREATE_STB_REQ(tbname, UINT32_MAX, UINT32_MAX, suid, pSchema, pTagSchema);
|
||||
|
||||
zs = vnodeBuildReq(NULL, &vCreateSTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||
pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg) + zs);
|
||||
pMsg->msgType = TSDB_MSG_TYPE_CREATE_TABLE;
|
||||
pMsg->contLen = zs;
|
||||
pMsg->pCont = POINTER_SHIFT(pMsg, sizeof(SRpcMsg));
|
||||
|
||||
pBuf = pMsg->pCont;
|
||||
vnodeBuildReq(&pBuf, &vCreateSTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||
META_CLEAR_TB_CFG(&vCreateSTbReq);
|
||||
|
||||
SVnodeReq decoded_req;
|
||||
tdFreeSchema(pSchema);
|
||||
tdFreeSchema(pTagSchema);
|
||||
|
||||
vnodeParseReq(buffer, &decoded_req, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||
|
||||
int k = 10;
|
||||
*ppMsg = pMsg;
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
|
||||
static void vtBuildCreateCtbReq(tb_uid_t suid, char *tbname, SRpcMsg **ppMsg) {
|
||||
SRpcMsg *pMsg;
|
||||
int tz;
|
||||
SKVRow pTag = vtCreateBasicTag();
|
||||
|
||||
SVnodeReq vCreateCTbReq = VNODE_INIT_CREATE_CTB_REQ(tbname, UINT32_MAX, UINT32_MAX, suid, pTag);
|
||||
|
||||
tz = vnodeBuildReq(NULL, &vCreateCTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||
pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg) + tz);
|
||||
pMsg->msgType = TSDB_MSG_TYPE_CREATE_TABLE;
|
||||
pMsg->contLen = tz;
|
||||
pMsg->pCont = POINTER_SHIFT(pMsg, sizeof(*pMsg));
|
||||
void *pBuf = pMsg->pCont;
|
||||
|
||||
vnodeBuildReq(&pBuf, &vCreateCTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||
META_CLEAR_TB_CFG(&vCreateCTbReq);
|
||||
free(pTag);
|
||||
|
||||
*ppMsg = pMsg;
|
||||
}
|
||||
|
||||
static void vtBuildCreateNtbReq(char *tbname, SRpcMsg **ppMsg) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
static void vtBuildSubmitReq(SRpcMsg **ppMsg) {
|
||||
SRpcMsg * pMsg;
|
||||
SSubmitMsg *pSubmitMsg;
|
||||
SSubmitBlk *pSubmitBlk;
|
||||
int tz = 1024; // TODO
|
||||
|
||||
pMsg = (SRpcMsg *)malloc(sizeof(*pMsg) + tz);
|
||||
pMsg->msgType = TSDB_MSG_TYPE_SUBMIT;
|
||||
pMsg->contLen = tz;
|
||||
pMsg->pCont = POINTER_SHIFT(pMsg, sizeof(*pMsg));
|
||||
|
||||
// For submit msg header
|
||||
pSubmitMsg = (SSubmitMsg *)(pMsg->pCont);
|
||||
// pSubmitMsg->header.contLen = 0;
|
||||
// pSubmitMsg->header.vgId = 0;
|
||||
// pSubmitMsg->length = 0;
|
||||
pSubmitMsg->numOfBlocks = 1;
|
||||
|
||||
// For submit blk
|
||||
pSubmitBlk = (SSubmitBlk *)(pSubmitMsg->blocks);
|
||||
pSubmitBlk->uid = 0;
|
||||
pSubmitBlk->tid = 0;
|
||||
pSubmitBlk->padding = 0;
|
||||
pSubmitBlk->sversion = 0;
|
||||
pSubmitBlk->dataLen = 0;
|
||||
pSubmitBlk->numOfRows = 0;
|
||||
|
||||
// For row batch
|
||||
|
||||
*ppMsg = pMsg;
|
||||
}
|
||||
|
||||
static void vtClearMsgBatch(SArray *pMsgArr) {
|
||||
SRpcMsg *pMsg;
|
||||
for (size_t i = 0; i < taosArrayGetSize(pMsgArr); i++) {
|
||||
pMsg = *(SRpcMsg **)taosArrayGet(pMsgArr, i);
|
||||
free(pMsg);
|
||||
}
|
||||
|
||||
taosArrayClear(pMsgArr);
|
||||
}
|
||||
|
||||
TEST(vnodeApiTest, vnode_simple_create_table_test) {
|
||||
tb_uid_t suid = 1638166374163;
|
||||
SRpcMsg *pMsg;
|
||||
SArray * pMsgArr = NULL;
|
||||
SVnode * pVnode;
|
||||
int rcode;
|
||||
int ntables = 1000000;
|
||||
int batch = 10;
|
||||
char tbname[128];
|
||||
|
||||
pMsgArr = (SArray *)taosArrayInit(batch, sizeof(pMsg));
|
||||
|
||||
vnodeDestroy("vnode1");
|
||||
GTEST_ASSERT_GE(vnodeInit(2), 0);
|
||||
|
||||
// CREATE AND OPEN A VNODE
|
||||
pVnode = vnodeOpen("vnode1", NULL);
|
||||
ASSERT_NE(pVnode, nullptr);
|
||||
|
||||
// CREATE A SUPER TABLE
|
||||
sprintf(tbname, "st");
|
||||
vtBuildCreateStbReq(suid, tbname, &pMsg);
|
||||
taosArrayPush(pMsgArr, &pMsg);
|
||||
rcode = vnodeProcessWMsgs(pVnode, pMsgArr);
|
||||
ASSERT_EQ(rcode, 0);
|
||||
vtClearMsgBatch(pMsgArr);
|
||||
|
||||
// CREATE A LOT OF CHILD TABLES
|
||||
for (int i = 0; i < ntables / batch; i++) {
|
||||
// Build request batch
|
||||
for (int j = 0; j < batch; j++) {
|
||||
sprintf(tbname, "ct%d", i * batch + j + 1);
|
||||
vtBuildCreateCtbReq(suid, tbname, &pMsg);
|
||||
taosArrayPush(pMsgArr, &pMsg);
|
||||
}
|
||||
|
||||
// Process request batch
|
||||
rcode = vnodeProcessWMsgs(pVnode, pMsgArr);
|
||||
ASSERT_EQ(rcode, 0);
|
||||
|
||||
// Clear request batch
|
||||
vtClearMsgBatch(pMsgArr);
|
||||
}
|
||||
|
||||
// CLOSE THE VNODE
|
||||
vnodeClose(pVnode);
|
||||
vnodeClear();
|
||||
|
||||
taosArrayDestroy(pMsgArr);
|
||||
}
|
||||
|
||||
TEST(vnodeApiTest, vnode_simple_insert_test) {
|
||||
const char *vname = "vnode2";
|
||||
char tbname[128];
|
||||
tb_uid_t suid = 1638166374163;
|
||||
SRpcMsg * pMsg;
|
||||
SArray * pMsgArr;
|
||||
int rcode;
|
||||
SVnode * pVnode;
|
||||
int batch = 1;
|
||||
int loop = 1000000;
|
||||
|
||||
pMsgArr = (SArray *)taosArrayInit(0, sizeof(pMsg));
|
||||
|
||||
vnodeDestroy(vname);
|
||||
|
||||
GTEST_ASSERT_GE(vnodeInit(2), 0);
|
||||
|
||||
// Create and open a vnode
|
||||
SVnode *pVnode = vnodeOpen("vnode1", NULL);
|
||||
ASSERT_NE(pVnode, nullptr);
|
||||
// Open a vnode
|
||||
pVnode = vnodeOpen(vname, NULL);
|
||||
GTEST_ASSERT_NE(pVnode, nullptr);
|
||||
|
||||
tb_uid_t suid = 1638166374163;
|
||||
{
|
||||
// Create a super table
|
||||
STSchema *pSchema = createBasicSchema();
|
||||
STSchema *pTagSchema = createBasicTagSchema();
|
||||
char tbname[128] = "st";
|
||||
// 1. CREATE A SUPER TABLE
|
||||
sprintf(tbname, "st");
|
||||
vtBuildCreateStbReq(suid, tbname, &pMsg);
|
||||
taosArrayPush(pMsgArr, &pMsg);
|
||||
rcode = vnodeProcessWMsgs(pVnode, pMsgArr);
|
||||
GTEST_ASSERT_EQ(rcode, 0);
|
||||
vtClearMsgBatch(pMsgArr);
|
||||
|
||||
SArray * pMsgs = (SArray *)taosArrayInit(1, sizeof(SRpcMsg *));
|
||||
SVnodeReq vCreateSTbReq = VNODE_INIT_CREATE_STB_REQ(tbname, UINT32_MAX, UINT32_MAX, suid, pSchema, pTagSchema);
|
||||
// 2. CREATE A CHILD TABLE
|
||||
sprintf(tbname, "t0");
|
||||
vtBuildCreateCtbReq(suid, tbname, &pMsg);
|
||||
taosArrayPush(pMsgArr, &pMsg);
|
||||
rcode = vnodeProcessWMsgs(pVnode, pMsgArr);
|
||||
GTEST_ASSERT_EQ(rcode, 0);
|
||||
vtClearMsgBatch(pMsgArr);
|
||||
|
||||
int zs = vnodeBuildReq(NULL, &vCreateSTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||
SRpcMsg *pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg) + zs);
|
||||
pMsg->msgType = TSDB_MSG_TYPE_CREATE_TABLE;
|
||||
pMsg->contLen = zs;
|
||||
pMsg->pCont = POINTER_SHIFT(pMsg, sizeof(SRpcMsg));
|
||||
|
||||
void *pBuf = pMsg->pCont;
|
||||
|
||||
vnodeBuildReq(&pBuf, &vCreateSTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||
META_CLEAR_TB_CFG(&vCreateSTbReq);
|
||||
|
||||
taosArrayPush(pMsgs, &(pMsg));
|
||||
|
||||
vnodeProcessWMsgs(pVnode, pMsgs);
|
||||
|
||||
free(pMsg);
|
||||
taosArrayDestroy(pMsgs);
|
||||
tdFreeSchema(pSchema);
|
||||
tdFreeSchema(pTagSchema);
|
||||
}
|
||||
|
||||
{
|
||||
// Create some child tables
|
||||
int ntables = 1000000;
|
||||
int batch = 10;
|
||||
for (int i = 0; i < ntables / batch; i++) {
|
||||
SArray *pMsgs = (SArray *)taosArrayInit(batch, sizeof(SRpcMsg *));
|
||||
for (int j = 0; j < batch; j++) {
|
||||
SKVRow pTag = createBasicTag();
|
||||
char tbname[128];
|
||||
sprintf(tbname, "tb%d", i * batch + j);
|
||||
SVnodeReq vCreateCTbReq = VNODE_INIT_CREATE_CTB_REQ(tbname, UINT32_MAX, UINT32_MAX, suid, pTag);
|
||||
|
||||
int tz = vnodeBuildReq(NULL, &vCreateCTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||
SRpcMsg *pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg) + tz);
|
||||
pMsg->msgType = TSDB_MSG_TYPE_CREATE_TABLE;
|
||||
pMsg->contLen = tz;
|
||||
pMsg->pCont = POINTER_SHIFT(pMsg, sizeof(*pMsg));
|
||||
void *pBuf = pMsg->pCont;
|
||||
|
||||
vnodeBuildReq(&pBuf, &vCreateCTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||
META_CLEAR_TB_CFG(&vCreateCTbReq);
|
||||
free(pTag);
|
||||
|
||||
taosArrayPush(pMsgs, &(pMsg));
|
||||
}
|
||||
|
||||
vnodeProcessWMsgs(pVnode, pMsgs);
|
||||
|
||||
for (int j = 0; j < batch; j++) {
|
||||
SRpcMsg *pMsg = *(SRpcMsg **)taosArrayPop(pMsgs);
|
||||
free(pMsg);
|
||||
}
|
||||
|
||||
taosArrayDestroy(pMsgs);
|
||||
|
||||
// std::cout << "the " << i << "th batch is created" << std::endl;
|
||||
// 3. WRITE A LOT OF TIME-SERIES DATA
|
||||
for (int j = 0; j < loop; j++) {
|
||||
for (int i = 0; i < batch; i++) {
|
||||
vtBuildSubmitReq(&pMsg);
|
||||
taosArrayPush(pMsgArr, &pMsg);
|
||||
}
|
||||
rcode = vnodeProcessWMsgs(pVnode, pMsgArr);
|
||||
GTEST_ASSERT_EQ(rcode, 0);
|
||||
vtClearMsgBatch(pMsgArr);
|
||||
}
|
||||
|
||||
// Close the vnode
|
||||
vnodeClose(pVnode);
|
||||
|
||||
vnodeClear();
|
||||
}
|
||||
|
||||
TEST(vnodeApiTest, DISABLED_vnode_process_create_table) {
|
||||
STSchema * pSchema = NULL;
|
||||
STSchema * pTagSchema = NULL;
|
||||
char stname[15];
|
||||
SVCreateTableReq pReq = META_INIT_STB_CFG(stname, UINT32_MAX, UINT32_MAX, 0, pSchema, pTagSchema);
|
||||
|
||||
int k = 10;
|
||||
|
||||
META_CLEAR_TB_CFG(pReq);
|
||||
}
|
||||
taosArrayDestroy(pMsgArr);
|
||||
}
|
|
@ -34,7 +34,7 @@ extern "C" {
|
|||
struct SMeta {
|
||||
char* path;
|
||||
SMetaCfg options;
|
||||
SMetaDB* pDB;
|
||||
SMetaDB* pDB;
|
||||
SMetaIdx* pIdx;
|
||||
SMetaCache* pCache;
|
||||
STbUidGenerator uidGnrt;
|
||||
|
|
|
@ -17,27 +17,27 @@
|
|||
|
||||
#include "metaDef.h"
|
||||
|
||||
static SMeta *metaNew(const char *path, const SMetaCfg *pMetaOptions);
|
||||
static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF);
|
||||
static void metaFree(SMeta *pMeta);
|
||||
static int metaOpenImpl(SMeta *pMeta);
|
||||
static void metaCloseImpl(SMeta *pMeta);
|
||||
|
||||
SMeta *metaOpen(const char *path, const SMetaCfg *pMetaOptions) {
|
||||
SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF) {
|
||||
SMeta *pMeta = NULL;
|
||||
|
||||
// Set default options
|
||||
if (pMetaOptions == NULL) {
|
||||
pMetaOptions = &defaultMetaOptions;
|
||||
if (pMetaCfg == NULL) {
|
||||
pMetaCfg = &defaultMetaOptions;
|
||||
}
|
||||
|
||||
// Validate the options
|
||||
if (metaValidateOptions(pMetaOptions) < 0) {
|
||||
if (metaValidateOptions(pMetaCfg) < 0) {
|
||||
// TODO: deal with error
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Allocate handle
|
||||
pMeta = metaNew(path, pMetaOptions);
|
||||
pMeta = metaNew(path, pMetaCfg, pMAF);
|
||||
if (pMeta == NULL) {
|
||||
// TODO: handle error
|
||||
return NULL;
|
||||
|
@ -65,7 +65,7 @@ void metaClose(SMeta *pMeta) {
|
|||
void metaRemove(const char *path) { taosRemoveDir(path); }
|
||||
|
||||
/* ------------------------ STATIC METHODS ------------------------ */
|
||||
static SMeta *metaNew(const char *path, const SMetaCfg *pMetaOptions) {
|
||||
static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF) {
|
||||
SMeta *pMeta;
|
||||
size_t psize = strlen(path);
|
||||
|
||||
|
@ -80,7 +80,8 @@ static SMeta *metaNew(const char *path, const SMetaCfg *pMetaOptions) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
metaOptionsCopy(&(pMeta->options), pMetaOptions);
|
||||
metaOptionsCopy(&(pMeta->options), pMetaCfg);
|
||||
pMeta->pmaf = pMAF;
|
||||
|
||||
return pMeta;
|
||||
};
|
||||
|
|
|
@ -22,16 +22,16 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
//create persistent storage for meta info such as consuming offset
|
||||
//return value > 0: cgId
|
||||
//return value <= 0: error code
|
||||
//int tqCreateTCGroup(STQ*, const char* topic, int cgId, tqBufferHandle** handle);
|
||||
//create ring buffer in memory and load consuming offset
|
||||
//int tqOpenTCGroup(STQ*, const char* topic, int cgId);
|
||||
//destroy ring buffer and persist consuming offset
|
||||
//int tqCloseTCGroup(STQ*, const char* topic, int cgId);
|
||||
//delete persistent storage for meta info
|
||||
//int tqDropTCGroup(STQ*, const char* topic, int cgId);
|
||||
// create persistent storage for meta info such as consuming offset
|
||||
// return value > 0: cgId
|
||||
// return value <= 0: error code
|
||||
// int tqCreateTCGroup(STQ*, const char* topic, int cgId, tqBufferHandle** handle);
|
||||
// create ring buffer in memory and load consuming offset
|
||||
// int tqOpenTCGroup(STQ*, const char* topic, int cgId);
|
||||
// destroy ring buffer and persist consuming offset
|
||||
// int tqCloseTCGroup(STQ*, const char* topic, int cgId);
|
||||
// delete persistent storage for meta info
|
||||
// int tqDropTCGroup(STQ*, const char* topic, int cgId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -23,27 +23,22 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
STqMetaStore* tqStoreOpen(const char* path,
|
||||
FTqSerialize pSerializer,
|
||||
FTqDeserialize pDeserializer,
|
||||
FTqDelete pDeleter,
|
||||
int32_t tqConfigFlag
|
||||
);
|
||||
STqMetaStore* tqStoreOpen(const char* path, FTqSerialize pSerializer, FTqDeserialize pDeserializer, FTqDelete pDeleter,
|
||||
int32_t tqConfigFlag);
|
||||
int32_t tqStoreClose(STqMetaStore*);
|
||||
//int32_t tqStoreDelete(TqMetaStore*);
|
||||
//int32_t tqStoreCommitAll(TqMetaStore*);
|
||||
int32_t tqStorePersist(STqMetaStore*);
|
||||
//clean deleted idx and data from persistent file
|
||||
int32_t tqStoreCompact(STqMetaStore*);
|
||||
// int32_t tqStoreDelete(TqMetaStore*);
|
||||
// int32_t tqStoreCommitAll(TqMetaStore*);
|
||||
int32_t tqStorePersist(STqMetaStore*);
|
||||
// clean deleted idx and data from persistent file
|
||||
int32_t tqStoreCompact(STqMetaStore*);
|
||||
|
||||
void* tqHandleGet(STqMetaStore*, int64_t key);
|
||||
//make it unpersist
|
||||
void* tqHandleGet(STqMetaStore*, int64_t key);
|
||||
// make it unpersist
|
||||
void* tqHandleTouchGet(STqMetaStore*, int64_t key);
|
||||
int32_t tqHandleMovePut(STqMetaStore*, int64_t key, void* value);
|
||||
int32_t tqHandleCopyPut(STqMetaStore*, int64_t key, void* value, size_t vsize);
|
||||
//delete committed kv pair
|
||||
//notice that a delete action still needs to be committed
|
||||
// delete committed kv pair
|
||||
// notice that a delete action still needs to be committed
|
||||
int32_t tqHandleDel(STqMetaStore*, int64_t key);
|
||||
int32_t tqHandleCommit(STqMetaStore*, int64_t key);
|
||||
int32_t tqHandleAbort(STqMetaStore*, int64_t key);
|
||||
|
|
|
@ -63,7 +63,13 @@ STQ* tqOpen(const char* path, STqCfg* tqConfig, STqLogReader* tqLogReader, SMemA
|
|||
return pTq;
|
||||
}
|
||||
|
||||
static int tqProtoCheck(TmqMsgHead* pMsg) { return pMsg->protoVer == 0; }
|
||||
void tqClose(STQ*pTq) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
static int tqProtoCheck(TmqMsgHead *pMsg) {
|
||||
return pMsg->protoVer == 0;
|
||||
}
|
||||
|
||||
static int tqAckOneTopic(STqBufferHandle* bHandle, TmqOneAck* pAck, STqQueryMsg** ppQuery) {
|
||||
// clean old item and move forward
|
||||
|
@ -214,7 +220,11 @@ int tqCommit(STQ* pTq) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tqConsume(STQ* pTq, TmqConsumeReq* pMsg) {
|
||||
int tqSetCursor(STQ* pTq, void* msg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tqConsume(STQ* pTq, STqConsumeReq* pMsg) {
|
||||
if (!tqProtoCheck((TmqMsgHead*)pMsg)) {
|
||||
// proto version invalid
|
||||
return -1;
|
||||
|
@ -232,7 +242,7 @@ int tqConsume(STQ* pTq, TmqConsumeReq* pMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
TmqConsumeRsp* pRsp = (TmqConsumeRsp*)pMsg;
|
||||
STqConsumeRsp* pRsp = (STqConsumeRsp*)pMsg;
|
||||
|
||||
if (tqFetch(gHandle, (void**)&pRsp->msgs) <= 0) {
|
||||
// fetch error
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "mallocator.h"
|
||||
#include "taosmsg.h"
|
||||
#include "tdlist.h"
|
||||
#include "tlist.h"
|
||||
#include "thash.h"
|
||||
#include "tskiplist.h"
|
||||
|
||||
|
|
|
@ -15,27 +15,27 @@
|
|||
|
||||
#include "tsdbDef.h"
|
||||
|
||||
static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbOptions);
|
||||
static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF);
|
||||
static void tsdbFree(STsdb *pTsdb);
|
||||
static int tsdbOpenImpl(STsdb *pTsdb);
|
||||
static void tsdbCloseImpl(STsdb *pTsdb);
|
||||
|
||||
STsdb *tsdbOpen(const char *path, const STsdbCfg *pTsdbOptions) {
|
||||
STsdb *tsdbOpen(const char *path, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF) {
|
||||
STsdb *pTsdb = NULL;
|
||||
|
||||
// Set default TSDB Options
|
||||
if (pTsdbOptions == NULL) {
|
||||
pTsdbOptions = &defautlTsdbOptions;
|
||||
if (pTsdbCfg == NULL) {
|
||||
pTsdbCfg = &defautlTsdbOptions;
|
||||
}
|
||||
|
||||
// Validate the options
|
||||
if (tsdbValidateOptions(pTsdbOptions) < 0) {
|
||||
if (tsdbValidateOptions(pTsdbCfg) < 0) {
|
||||
// TODO: handle error
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Create the handle
|
||||
pTsdb = tsdbNew(path, pTsdbOptions);
|
||||
pTsdb = tsdbNew(path, pTsdbCfg, pMAF);
|
||||
if (pTsdb == NULL) {
|
||||
// TODO: handle error
|
||||
return NULL;
|
||||
|
@ -62,7 +62,7 @@ void tsdbClose(STsdb *pTsdb) {
|
|||
void tsdbRemove(const char *path) { taosRemoveDir(path); }
|
||||
|
||||
/* ------------------------ STATIC METHODS ------------------------ */
|
||||
static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbOptions) {
|
||||
static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF) {
|
||||
STsdb *pTsdb = NULL;
|
||||
|
||||
pTsdb = (STsdb *)calloc(1, sizeof(STsdb));
|
||||
|
@ -72,7 +72,8 @@ static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbOptions) {
|
|||
}
|
||||
|
||||
pTsdb->path = strdup(path);
|
||||
tsdbOptionsCopy(&(pTsdb->options), pTsdbOptions);
|
||||
tsdbOptionsCopy(&(pTsdb->options), pTsdbCfg);
|
||||
pTsdb->pmaf = pMAF;
|
||||
|
||||
return pTsdb;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ STsdbMemTable *tsdbNewMemTable(SMemAllocatorFactory *pMAF) {
|
|||
pMA = (*pMAF->create)(pMAF);
|
||||
ASSERT(pMA != NULL);
|
||||
|
||||
pMemTable = (STsdbMemTable *)((*pMA->malloc)(pMA, sizeof(*pMemTable)));
|
||||
pMemTable = (STsdbMemTable *)TD_MA_MALLOC(pMA, sizeof(*pMemTable));
|
||||
if (pMemTable == NULL) {
|
||||
(*pMAF->destroy)(pMAF, pMA);
|
||||
return NULL;
|
||||
|
@ -62,7 +62,7 @@ STsdbMemTable *tsdbNewMemTable(SMemAllocatorFactory *pMAF) {
|
|||
pMemTable->keyMax = TSKEY_MIN;
|
||||
pMemTable->nRow = 0;
|
||||
pMemTable->pMA = pMA;
|
||||
tSListInit(&(pMemTable->list));
|
||||
TD_SLIST_INIT(&(pMemTable->list));
|
||||
|
||||
// TODO
|
||||
return pMemTable;
|
||||
|
@ -71,7 +71,7 @@ STsdbMemTable *tsdbNewMemTable(SMemAllocatorFactory *pMAF) {
|
|||
void tsdbFreeMemTable(SMemAllocatorFactory *pMAF, STsdbMemTable *pMemTable) {
|
||||
SMemAllocator *pMA = pMemTable->pMA;
|
||||
|
||||
if (pMA->free) {
|
||||
if (TD_MA_FREE_FUNC(pMA) != NULL) {
|
||||
// TODO
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -81,12 +81,12 @@ void tsdbFreeMemTable(SMemAllocatorFactory *pMAF, STsdbMemTable *pMemTable) {
|
|||
|
||||
int tsdbInsertDataToMemTable(STsdbMemTable *pMemTable, SSubmitMsg *pMsg) {
|
||||
SMemAllocator *pMA = pMemTable->pMA;
|
||||
STbData * pTbData = (STbData *)((*pMA->malloc)(pMA, sizeof(*pTbData)));
|
||||
STbData * pTbData = (STbData *)TD_MA_MALLOC(pMA, sizeof(*pTbData));
|
||||
if (pTbData == NULL) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
tSListPush(&(pMemTable->list), pTbData);
|
||||
TD_SLIST_PUSH(&(pMemTable->list), pTbData);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -10,4 +10,4 @@ add_subdirectory(catalog)
|
|||
add_subdirectory(executor)
|
||||
add_subdirectory(planner)
|
||||
add_subdirectory(function)
|
||||
add_subdirectory(query)
|
||||
add_subdirectory(qcom)
|
||||
|
|
|
@ -8,7 +8,7 @@ target_include_directories(
|
|||
|
||||
target_link_libraries(
|
||||
catalog
|
||||
PRIVATE os util common transport query
|
||||
PRIVATE os util transport qcom
|
||||
)
|
||||
|
||||
ADD_SUBDIRECTORY(test)
|
|
@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
|||
ADD_EXECUTABLE(catalogTest ${SOURCE_LIST})
|
||||
TARGET_LINK_LIBRARIES(
|
||||
catalogTest
|
||||
PUBLIC os util common catalog transport gtest query taos
|
||||
PUBLIC os util common catalog transport gtest qcom taos
|
||||
)
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(
|
||||
|
|
|
@ -9,6 +9,7 @@ target_link_libraries(
|
|||
index
|
||||
PUBLIC os
|
||||
PUBLIC util
|
||||
PUBLIC common
|
||||
)
|
||||
|
||||
if (${BUILD_WITH_LUCENE})
|
||||
|
|
|
@ -37,9 +37,11 @@ struct SIndex {
|
|||
#endif
|
||||
void *cache;
|
||||
void *tindex;
|
||||
SHashObj *fieldObj; // <field name, field id>
|
||||
uint64_t suid;
|
||||
int fieldId;
|
||||
SHashObj *fieldObj;// < field name, field id>
|
||||
|
||||
int64_t suid; // current super table id, -1 is normal table
|
||||
int fieldId; // field id allocated to cache
|
||||
int32_t cVersion; // current version allocated to cache
|
||||
pthread_mutex_t mtx;
|
||||
};
|
||||
|
||||
|
@ -58,6 +60,7 @@ struct SIndexMultiTermQuery {
|
|||
|
||||
// field and key;
|
||||
typedef struct SIndexTerm {
|
||||
uint8_t type; // term data type, str/interger/json
|
||||
char *key;
|
||||
int32_t nKey;
|
||||
char *val;
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
|
||||
#include "index.h"
|
||||
#include "tlockfree.h"
|
||||
#include "tskiplist.h"
|
||||
// ----------------- row structure in skiplist ---------------------
|
||||
|
||||
/* A data row, the format is like below:
|
||||
* |<--totalLen-->|<-- fieldId-->|<-- value len--->|<-- value-->|<--version--->|<-- itermType -->|
|
||||
*
|
||||
* content: |<--totalLen-->|<-- fieldid-->|<--field type -->|<-- value len--->|<-- value -->|<-- uid -->|<--version--->|<-- itermType -->|
|
||||
* len : |<--int32_t -->|<-- int16_t-->|<-- int16_t --->|<--- int32_t --->|<--valuelen->|<--uint64_t->|<-- int32_t-->|<-- int8_t --->|
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -30,7 +31,7 @@ extern "C" {
|
|||
|
||||
typedef struct IndexCache {
|
||||
T_REF_DECLARE()
|
||||
int cVersion; //
|
||||
SSkipList *skiplist;
|
||||
} IndexCache;
|
||||
|
||||
|
||||
|
@ -39,7 +40,8 @@ IndexCache *indexCacheCreate();
|
|||
|
||||
void indexCacheDestroy(IndexCache *cache);
|
||||
|
||||
int indexCachePut(IndexCache *cache, int32_t fieldId, const char *fieldVale, int32_t fvlen, uint64_t uid, int8_t operaType);
|
||||
int indexCachePut(IndexCache *cache, int16_t fieldId, int16_t fieldType, const char *fieldValue, int32_t fvLen,
|
||||
uint32_t version, uint64_t uid, int8_t operType);
|
||||
|
||||
int indexCacheGet(IndexCache *cache, uint64_t *rst);
|
||||
int indexCacheSearch(IndexCache *cache, SIndexMultiTermQuery *query, SArray *result);
|
||||
|
|
|
@ -315,7 +315,6 @@ typedef struct StreamWithStateResult {
|
|||
FstSlice data;
|
||||
FstOutput out;
|
||||
void *state;
|
||||
|
||||
} StreamWithStateResult;
|
||||
|
||||
StreamWithStateResult *swsResultCreate(FstSlice *data, FstOutput fOut, void *state);
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
|
||||
|
||||
typedef struct SIdxFieldInfo {
|
||||
int id; // generated by index internal
|
||||
int fieldId; // generated by index internal
|
||||
int cVersion;
|
||||
int type; // field type
|
||||
} SIdxFieldInfo;
|
||||
|
||||
|
@ -39,7 +40,7 @@ static int indexMergeCacheIntoTindex(struct SIndex *sIdx) {
|
|||
}
|
||||
SIndex *indexOpen(SIndexOpts *opts, const char *path) {
|
||||
pthread_once(&isInit, indexInit);
|
||||
SIndex *sIdx = malloc(sizeof(SIndex));
|
||||
SIndex *sIdx = calloc(1, sizeof(SIndex));
|
||||
|
||||
#ifdef USE_LUCENE
|
||||
index_t *index = index_open(path);
|
||||
|
@ -49,6 +50,8 @@ SIndex *indexOpen(SIndexOpts *opts, const char *path) {
|
|||
sIdx->cache = (void*)indexCacheCreate();
|
||||
sIdx->tindex = NULL;
|
||||
sIdx->fieldObj = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
sIdx->fieldId = 1;
|
||||
sIdx->cVersion = 1;
|
||||
pthread_mutex_init(&sIdx->mtx, NULL);
|
||||
return sIdx;
|
||||
}
|
||||
|
@ -65,7 +68,7 @@ void indexClose(SIndex *sIdx) {
|
|||
return;
|
||||
}
|
||||
|
||||
int indexPut(SIndex *index, SArray* field_vals, int uid) {
|
||||
int indexPut(SIndex *index, SArray* fVals, int uid) {
|
||||
|
||||
#ifdef USE_LUCENE
|
||||
index_document_t *doc = index_document_create();
|
||||
|
@ -73,8 +76,8 @@ int indexPut(SIndex *index, SArray* field_vals, int uid) {
|
|||
char buf[16] = {0};
|
||||
sprintf(buf, "%d", uid);
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(field_vals); i++) {
|
||||
SIndexTerm *p = taosArrayGetP(field_vals, i);
|
||||
for (int i = 0; i < taosArrayGetSize(fVals); i++) {
|
||||
SIndexTerm *p = taosArrayGetP(fVals, i);
|
||||
index_document_add(doc, (const char *)(p->key), p->nKey, (const char *)(p->val), p->nVal, 1);
|
||||
}
|
||||
index_document_add(doc, NULL, 0, buf, strlen(buf), 0);
|
||||
|
@ -82,10 +85,33 @@ int indexPut(SIndex *index, SArray* field_vals, int uid) {
|
|||
index_put(index->index, doc);
|
||||
index_document_destroy(doc);
|
||||
#endif
|
||||
|
||||
//TODO(yihao): reduce the lock range
|
||||
pthread_mutex_lock(&index->mtx);
|
||||
for (int i = 0; i < taosArrayGetSize(fVals); i++) {
|
||||
SIndexTerm *p = taosArrayGetP(fVals, i);
|
||||
SIdxFieldInfo *fi = taosHashGet(index->fieldObj, p->key, p->nKey);
|
||||
if (fi == NULL) {
|
||||
SIdxFieldInfo tfi = {.fieldId = index->fieldId, .type = p->type};
|
||||
index->cVersion++;
|
||||
index->fieldId++;
|
||||
taosHashPut(index->fieldObj, p->key, p->nKey, &tfi, sizeof(tfi));
|
||||
} else {
|
||||
//TODO, del
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(fVals); i++) {
|
||||
SIndexTerm *p = taosArrayGetP(fVals, i);
|
||||
SIdxFieldInfo *fi = taosHashGet(index->fieldObj, p->key, p->nKey);
|
||||
assert(fi != NULL);
|
||||
int32_t fieldId = fi->fieldId;
|
||||
int32_t colType = fi->type;
|
||||
int32_t version = index->cVersion;
|
||||
|
||||
}
|
||||
pthread_mutex_unlock(&index->mtx);
|
||||
return 1;
|
||||
|
||||
}
|
||||
int indexSearch(SIndex *index, SIndexMultiTermQuery *multiQuerys, SArray *result) {
|
||||
#ifdef USE_LUCENE
|
||||
|
@ -152,7 +178,7 @@ SIndexMultiTermQuery *indexMultiTermQueryCreate(EIndexOperatorType opera) {
|
|||
SIndexMultiTermQuery *p = (SIndexMultiTermQuery *)malloc(sizeof(SIndexMultiTermQuery));
|
||||
if (p == NULL) { return NULL; }
|
||||
p->opera = opera;
|
||||
p->query = taosArrayInit(1, sizeof(SIndexTermQuery));
|
||||
p->query = taosArrayInit(4, sizeof(SIndexTermQuery));
|
||||
return p;
|
||||
}
|
||||
void indexMultiTermQueryDestroy(SIndexMultiTermQuery *pQuery) {
|
||||
|
|
|
@ -14,12 +14,18 @@
|
|||
*/
|
||||
|
||||
#include "index_cache.h"
|
||||
#include "tcompare.h"
|
||||
|
||||
#define MAX_INDEX_KEY_LEN 128 // test only, change later
|
||||
|
||||
static char* getIndexKey(const void *pData) {
|
||||
return NULL;
|
||||
}
|
||||
static int32_t compareKey(const void *l, const void *r) {
|
||||
char *lp = (char *)l;
|
||||
char *rp = (char *)r;
|
||||
|
||||
// skip total len
|
||||
// skip total len, not compare
|
||||
int32_t ll, rl; // len
|
||||
memcpy(&ll, lp, sizeof(int32_t));
|
||||
memcpy(&rl, rp, sizeof(int32_t));
|
||||
|
@ -27,7 +33,7 @@ static int32_t compareKey(const void *l, const void *r) {
|
|||
rp += sizeof(int32_t);
|
||||
|
||||
// compare field id
|
||||
int32_t lf, rf; // field id
|
||||
int16_t lf, rf; // field id
|
||||
memcpy(&lf, lp, sizeof(lf));
|
||||
memcpy(&rf, rp, sizeof(rf));
|
||||
if (lf != rf) {
|
||||
|
@ -36,14 +42,22 @@ static int32_t compareKey(const void *l, const void *r) {
|
|||
lp += sizeof(lf);
|
||||
rp += sizeof(rf);
|
||||
|
||||
// compare field value
|
||||
// compare field type
|
||||
int16_t lft, rft;
|
||||
memcpy(&lft, lp, sizeof(lft));
|
||||
memcpy(&rft, rp, sizeof(rft));
|
||||
lp += sizeof(lft);
|
||||
rp += sizeof(rft);
|
||||
assert(rft == rft);
|
||||
|
||||
// skip value len
|
||||
int32_t lfl, rfl;
|
||||
memcpy(&lfl, lp, sizeof(lfl));
|
||||
memcpy(&rfl, rp, sizeof(rfl));
|
||||
lp += sizeof(lfl);
|
||||
rp += sizeof(rfl);
|
||||
|
||||
//refator later
|
||||
// compare value
|
||||
int32_t i, j;
|
||||
for (i = 0, j = 0; i < lfl && j < rfl; i++, j++) {
|
||||
if (lp[i] == rp[j]) { continue; }
|
||||
|
@ -54,58 +68,79 @@ static int32_t compareKey(const void *l, const void *r) {
|
|||
lp += lfl;
|
||||
rp += rfl;
|
||||
|
||||
// compare version
|
||||
// skip uid
|
||||
uint64_t lu, ru;
|
||||
memcpy(&lu, lp, sizeof(lu));
|
||||
memcpy(&ru, rp, sizeof(ru));
|
||||
lp += sizeof(lu);
|
||||
rp += sizeof(ru);
|
||||
|
||||
// compare version, desc order
|
||||
int32_t lv, rv;
|
||||
memcpy(&lv, lp, sizeof(lv));
|
||||
memcpy(&rv, rp, sizeof(rv));
|
||||
if (lv != rv) {
|
||||
return lv > rv ? -1 : 1;
|
||||
}
|
||||
}
|
||||
lp += sizeof(lv);
|
||||
rp += sizeof(rv);
|
||||
// not care item type
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
IndexCache *indexCacheCreate() {
|
||||
IndexCache *cache = calloc(1, sizeof(IndexCache));
|
||||
cache->skiplist = tSkipListCreate(MAX_SKIP_LIST_LEVEL, TSDB_DATA_TYPE_BINARY, MAX_INDEX_KEY_LEN, compareKey, SL_ALLOW_DUP_KEY, getIndexKey);
|
||||
return cache;
|
||||
|
||||
}
|
||||
|
||||
void indexCacheDestroy(IndexCache *cache) {
|
||||
if (cache == NULL) { return; }
|
||||
tSkipListDestroy(cache->skiplist);
|
||||
free(cache);
|
||||
}
|
||||
|
||||
int indexCachePut(IndexCache *cache, int32_t fieldId, const char *fieldValue, int32_t fvlen, uint64_t uid, int8_t operType) {
|
||||
int indexCachePut(IndexCache *cache, int16_t fieldId, int16_t fieldType, const char *fieldValue, int32_t fvLen,
|
||||
uint32_t version, uint64_t uid, int8_t operType) {
|
||||
if (cache == NULL) { return -1;}
|
||||
int32_t version = T_REF_INC(cache);
|
||||
|
||||
int32_t total = sizeof(int32_t) + sizeof(fieldId) + 4 + fvlen + sizeof(version) + sizeof(uid) + sizeof(operType);
|
||||
// encode data
|
||||
int32_t total = sizeof(int32_t) + sizeof(fieldId) + sizeof(fieldType) + sizeof(fvLen) + fvLen + sizeof(version) + sizeof(uid) + sizeof(operType);
|
||||
|
||||
char *buf = calloc(1, total);
|
||||
char *p = buf;
|
||||
|
||||
memcpy(buf, &total, sizeof(total));
|
||||
total += total;
|
||||
memcpy(p, &total, sizeof(total));
|
||||
p += sizeof(total);
|
||||
|
||||
memcpy(buf, &fieldId, sizeof(fieldId));
|
||||
buf += sizeof(fieldId);
|
||||
memcpy(p, &fieldId, sizeof(fieldId));
|
||||
p += sizeof(fieldId);
|
||||
|
||||
memcpy(buf, &fvlen, sizeof(fvlen));
|
||||
buf += sizeof(fvlen);
|
||||
memcpy(buf, fieldValue, fvlen);
|
||||
buf += fvlen;
|
||||
memcpy(p, &fieldType, sizeof(fieldType));
|
||||
p += sizeof(fieldType);
|
||||
|
||||
memcpy(p, &fvLen, sizeof(fvLen));
|
||||
p += sizeof(fvLen);
|
||||
memcpy(p, fieldValue, fvLen);
|
||||
p += fvLen;
|
||||
|
||||
memcpy(buf, &version, sizeof(version));
|
||||
buf += sizeof(version);
|
||||
memcpy(p, &version, sizeof(version));
|
||||
p += sizeof(version);
|
||||
|
||||
memcpy(buf, &uid, sizeof(uid));
|
||||
buf += sizeof(uid);
|
||||
memcpy(p, &uid, sizeof(uid));
|
||||
p += sizeof(uid);
|
||||
|
||||
memcpy(buf, &operType, sizeof(operType));
|
||||
buf += sizeof(operType);
|
||||
memcpy(p, &operType, sizeof(operType));
|
||||
p += sizeof(operType);
|
||||
|
||||
tSkipListPut(cache->skiplist, (void *)buf);
|
||||
// encode end
|
||||
|
||||
|
||||
}
|
||||
int indexCacheDel(IndexCache *cache, int32_t fieldId, const char *fieldValue, int32_t fvlen, uint64_t uid, int8_t operType) {
|
||||
|
||||
}
|
||||
int indexCacheSearch(IndexCache *cache, SIndexMultiTermQuery *query, SArray *result) {
|
||||
|
|
|
@ -8,7 +8,7 @@ target_include_directories(
|
|||
|
||||
target_link_libraries(
|
||||
parser
|
||||
PRIVATE os util common catalog function transport query
|
||||
PRIVATE os util catalog function transport qcom
|
||||
)
|
||||
|
||||
ADD_SUBDIRECTORY(test)
|
||||
|
|
|
@ -171,8 +171,8 @@ typedef struct SCreateDbInfo {
|
|||
int8_t update;
|
||||
int8_t cachelast;
|
||||
SArray *keep;
|
||||
int8_t dbType;
|
||||
int16_t partitions;
|
||||
// int8_t dbType;
|
||||
// int16_t partitions;
|
||||
} SCreateDbInfo;
|
||||
|
||||
typedef struct SCreateFuncInfo {
|
||||
|
|
|
@ -5,5 +5,7 @@
|
|||
#include "taosmsg.h"
|
||||
|
||||
SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int64_t id, char* msgBuf, int32_t msgLen);
|
||||
SShowMsg* buildShowMsg(SShowInfo* pShowInfo, int64_t id, char* msgBuf, int32_t msgLen);
|
||||
SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, char* msgBuf, int32_t msgLen);
|
||||
|
||||
#endif // TDENGINE_ASTTOMSG_H
|
||||
|
|
|
@ -46,6 +46,7 @@ SInternalField* getInternalField(SFieldInfo* pFieldInfo, int32_t index);
|
|||
|
||||
int32_t parserValidateIdToken(SToken* pToken);
|
||||
int32_t parserValidatePassword(SToken* pToken, SMsgBuf* pMsgBuf);
|
||||
int32_t parserValidateNameToken(SToken* pToken);
|
||||
|
||||
int32_t buildInvalidOperationMsg(SMsgBuf* pMsgBuf, const char* msg);
|
||||
int32_t buildSyntaxErrMsg(SMsgBuf* pBuf, const char* additionalInfo, const char* sourceStr);
|
||||
|
|
|
@ -948,27 +948,24 @@ void setCompactVnodeSql(SSqlInfo *pInfo, int32_t type, SArray *pParam) {
|
|||
void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo) {
|
||||
pDBInfo->compressionLevel = -1;
|
||||
|
||||
pDBInfo->walLevel = -1;
|
||||
pDBInfo->walLevel = -1;
|
||||
pDBInfo->fsyncPeriod = -1;
|
||||
pDBInfo->commitTime = -1;
|
||||
pDBInfo->commitTime = -1;
|
||||
pDBInfo->maxTablesPerVnode = -1;
|
||||
|
||||
pDBInfo->cacheBlockSize = -1;
|
||||
pDBInfo->numOfBlocks = -1;
|
||||
pDBInfo->cacheBlockSize = -1;
|
||||
pDBInfo->numOfBlocks = -1;
|
||||
pDBInfo->maxRowsPerBlock = -1;
|
||||
pDBInfo->minRowsPerBlock = -1;
|
||||
pDBInfo->daysPerFile = -1;
|
||||
pDBInfo->daysPerFile = -1;
|
||||
|
||||
pDBInfo->replica = -1;
|
||||
pDBInfo->quorum = -1;
|
||||
pDBInfo->keep = NULL;
|
||||
pDBInfo->quorum = -1;
|
||||
pDBInfo->keep = NULL;
|
||||
|
||||
pDBInfo->update = -1;
|
||||
pDBInfo->update = -1;
|
||||
pDBInfo->cachelast = -1;
|
||||
|
||||
pDBInfo->dbType = -1;
|
||||
pDBInfo->partitions = -1;
|
||||
|
||||
memset(&pDBInfo->precision, 0, sizeof(SToken));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,160 @@
|
|||
#include "parserInt.h"
|
||||
#include "parserUtil.h"
|
||||
|
||||
SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int64_t id, char* msgBuf, int32_t msgLen) {
|
||||
SCreateUserMsg *pMsg = (SCreateUserMsg *)calloc(1, sizeof(SCreateUserMsg));
|
||||
SCreateUserMsg* pMsg = (SCreateUserMsg*)calloc(1, sizeof(SCreateUserMsg));
|
||||
if (pMsg == NULL) {
|
||||
// tscError("0x%" PRIx64 " failed to malloc for query msg", id);
|
||||
// tscError("0x%" PRIx64 " failed to malloc for query msg", id);
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SUserInfo *pUser = &pInfo->pMiscInfo->user;
|
||||
SUserInfo* pUser = &pInfo->pMiscInfo->user;
|
||||
strncpy(pMsg->user, pUser->user.z, pUser->user.n);
|
||||
pMsg->type = pUser->type;
|
||||
pMsg->superUser = (int8_t)pUser->type;
|
||||
|
||||
if (pUser->type == TSDB_ALTER_USER_PRIVILEGES) {
|
||||
// pMsg->privilege = (char)pCmd->count;
|
||||
// pMsg->privilege = (char)pCmd->count;
|
||||
} else {
|
||||
strncpy(pMsg->pass, pUser->passwd.z, pUser->passwd.n);
|
||||
}
|
||||
|
||||
return pMsg;
|
||||
}
|
||||
}
|
||||
|
||||
SShowMsg* buildShowMsg(SShowInfo* pShowInfo, int64_t id, char* msgBuf, int32_t msgLen) {
|
||||
SShowMsg* pShowMsg = calloc(1, sizeof(SShowMsg));
|
||||
|
||||
pShowMsg->type = pShowInfo->showType;
|
||||
|
||||
if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) {
|
||||
SToken* pPattern = &pShowInfo->pattern;
|
||||
if (pPattern->type > 0) { // only show tables support wildcard query
|
||||
strncpy(pShowMsg->payload, pPattern->z, pPattern->n);
|
||||
pShowMsg->payloadLen = htons(pPattern->n);
|
||||
}
|
||||
} else {
|
||||
SToken* pEpAddr = &pShowInfo->prefix;
|
||||
assert(pEpAddr->n > 0 && pEpAddr->type > 0);
|
||||
|
||||
strncpy(pShowMsg->payload, pEpAddr->z, pEpAddr->n);
|
||||
pShowMsg->payloadLen = htons(pEpAddr->n);
|
||||
}
|
||||
|
||||
return pShowMsg;
|
||||
}
|
||||
|
||||
static int32_t setKeepOption(SCreateDbMsg* pMsg, const SCreateDbInfo* pCreateDb, SMsgBuf* pMsgBuf) {
|
||||
const char* msg1 = "invalid number of keep options";
|
||||
const char* msg2 = "invalid keep value";
|
||||
const char* msg3 = "invalid keep value, should be keep0 <= keep1 <= keep2";
|
||||
|
||||
pMsg->daysToKeep0 = htonl(-1);
|
||||
pMsg->daysToKeep1 = htonl(-1);
|
||||
pMsg->daysToKeep2 = htonl(-1);
|
||||
|
||||
SArray* pKeep = pCreateDb->keep;
|
||||
if (pKeep != NULL) {
|
||||
size_t s = taosArrayGetSize(pKeep);
|
||||
#ifdef _STORAGE
|
||||
if (s >= 4 ||s <= 0) {
|
||||
#else
|
||||
if (s != 1) {
|
||||
#endif
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg1);
|
||||
}
|
||||
|
||||
// tListI* p0 = taosArrayGet(pKeep, 0);
|
||||
// tVariantListItem* p1 = (s > 1) ? taosArrayGet(pKeep, 1) : p0;
|
||||
// tVariantListItem* p2 = (s > 2) ? taosArrayGet(pKeep, 2) : p1;
|
||||
//
|
||||
// if ((int32_t)p0->pVar.i64 <= 0 || (int32_t)p1->pVar.i64 <= 0 || (int32_t)p2->pVar.i64 <= 0) {
|
||||
// return buildInvalidOperationMsg(pMsgBuf, msg2);
|
||||
// }
|
||||
// if (!(((int32_t)p0->pVar.i64 <= (int32_t)p1->pVar.i64) && ((int32_t)p1->pVar.i64 <= (int32_t)p2->pVar.i64))) {
|
||||
// return buildInvalidOperationMsg(pMsgBuf, msg3);
|
||||
// }
|
||||
//
|
||||
// pMsg->daysToKeep0 = htonl((int32_t)p0->pVar.i64);
|
||||
// pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64);
|
||||
// pMsg->daysToKeep2 = htonl((int32_t)p2->pVar.i64);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t setTimePrecision(SCreateDbMsg* pMsg, const SCreateDbInfo* pCreateDbInfo, SMsgBuf* pMsgBuf) {
|
||||
const char* msg = "invalid time precision";
|
||||
|
||||
pMsg->precision = TSDB_TIME_PRECISION_MILLI; // millisecond by default
|
||||
|
||||
SToken* pToken = &pCreateDbInfo->precision;
|
||||
if (pToken->n > 0) {
|
||||
pToken->n = strdequote(pToken->z);
|
||||
|
||||
if (strncmp(pToken->z, TSDB_TIME_PRECISION_MILLI_STR, pToken->n) == 0 &&
|
||||
strlen(TSDB_TIME_PRECISION_MILLI_STR) == pToken->n) {
|
||||
// time precision for this db: million second
|
||||
pMsg->precision = TSDB_TIME_PRECISION_MILLI;
|
||||
} else if (strncmp(pToken->z, TSDB_TIME_PRECISION_MICRO_STR, pToken->n) == 0 &&
|
||||
strlen(TSDB_TIME_PRECISION_MICRO_STR) == pToken->n) {
|
||||
pMsg->precision = TSDB_TIME_PRECISION_MICRO;
|
||||
} else if (strncmp(pToken->z, TSDB_TIME_PRECISION_NANO_STR, pToken->n) == 0 &&
|
||||
strlen(TSDB_TIME_PRECISION_NANO_STR) == pToken->n) {
|
||||
pMsg->precision = TSDB_TIME_PRECISION_NANO;
|
||||
} else {
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg);
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void doSetDbOptions(SCreateDbMsg* pMsg, const SCreateDbInfo* pCreateDb) {
|
||||
pMsg->cacheBlockSize = htonl(pCreateDb->cacheBlockSize);
|
||||
pMsg->totalBlocks = htonl(pCreateDb->numOfBlocks);
|
||||
pMsg->daysPerFile = htonl(pCreateDb->daysPerFile);
|
||||
pMsg->commitTime = htonl((int32_t)pCreateDb->commitTime);
|
||||
pMsg->minRowsPerFileBlock = htonl(pCreateDb->minRowsPerBlock);
|
||||
pMsg->maxRowsPerFileBlock = htonl(pCreateDb->maxRowsPerBlock);
|
||||
pMsg->fsyncPeriod = htonl(pCreateDb->fsyncPeriod);
|
||||
pMsg->compression = pCreateDb->compressionLevel;
|
||||
pMsg->walLevel = (char)pCreateDb->walLevel;
|
||||
pMsg->replications = pCreateDb->replica;
|
||||
pMsg->quorum = pCreateDb->quorum;
|
||||
pMsg->ignoreExist = pCreateDb->ignoreExists;
|
||||
pMsg->update = pCreateDb->update;
|
||||
pMsg->cacheLastRow = pCreateDb->cachelast;
|
||||
}
|
||||
|
||||
int32_t setDbOptions(SCreateDbMsg* pCreateDbMsg, const SCreateDbInfo* pCreateDbSql, SMsgBuf* pMsgBuf) {
|
||||
doSetDbOptions(pCreateDbMsg, pCreateDbSql);
|
||||
|
||||
if (setKeepOption(pCreateDbMsg, pCreateDbSql, pMsgBuf) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
if (setTimePrecision(pCreateDbMsg, pCreateDbSql, pMsgBuf) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
// todo configurable
|
||||
pCreateDbMsg->numOfVgroups = htonl(2);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, char* msgBuf, int32_t msgLen) {
|
||||
SCreateDbMsg* pCreateMsg = calloc(1, sizeof(SCreateDbMsg));
|
||||
|
||||
SMsgBuf msg = {.buf = msgBuf, .len = msgLen};
|
||||
if (setDbOptions(pCreateMsg, pCreateDbInfo, &msg) != TSDB_CODE_SUCCESS) {
|
||||
tfree(pCreateMsg);
|
||||
terrno = TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pCreateMsg;
|
||||
}
|
||||
|
|
|
@ -759,11 +759,6 @@ int32_t validateIntervalNode(SQueryStmtInfo *pQueryInfo, SSqlNode* pSqlNode, SMs
|
|||
// It is a time window query
|
||||
pQueryInfo->info.timewindow = true;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
// disable it temporarily
|
||||
// bool interpQuery = tscIsPointInterpQuery(pQueryInfo);
|
||||
// if ((pSqlNode->interval.token == TK_EVERY && (!interpQuery)) || (pSqlNode->interval.token == TK_INTERVAL && interpQuery)) {
|
||||
// return buildInvalidOperationMsg(pMsgBuf, msg4);
|
||||
// }
|
||||
}
|
||||
|
||||
int32_t validateSessionNode(SQueryStmtInfo *pQueryInfo, SSessionWindowVal* pSession, int32_t precision, SMsgBuf* pMsgBuf) {
|
||||
|
@ -3707,14 +3702,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
case TSDB_SQL_SHOW: {
|
||||
if (setShowInfo(pSql, pInfo) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_SQL_CREATE_FUNCTION:
|
||||
case TSDB_SQL_DROP_FUNCTION: {
|
||||
code = handleUserDefinedFunc(pSql, pInfo);
|
||||
|
@ -3725,35 +3712,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
|
|||
break;
|
||||
}
|
||||
|
||||
case TSDB_SQL_ALTER_DB:
|
||||
case TSDB_SQL_CREATE_DB: {
|
||||
const char* msg1 = "invalid db name";
|
||||
const char* msg2 = "name too long";
|
||||
|
||||
SCreateDbInfo* pCreateDB = &(pInfo->pMiscInfo->dbOpt);
|
||||
if (pCreateDB->dbname.n >= TSDB_DB_NAME_LEN) {
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg2);
|
||||
}
|
||||
|
||||
char buf[TSDB_DB_NAME_LEN] = {0};
|
||||
SToken token = taosTokenDup(&pCreateDB->dbname, buf, tListLen(buf));
|
||||
|
||||
if (tscValidateName(&token) != TSDB_CODE_SUCCESS) {
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg1);
|
||||
}
|
||||
|
||||
int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), &token);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg2);
|
||||
}
|
||||
|
||||
if (parseCreateDBOptions(pCmd, pCreateDB) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_SQL_CREATE_DNODE: {
|
||||
const char* msg = "invalid host name (ip address)";
|
||||
|
||||
|
@ -4133,25 +4091,83 @@ static int32_t setShowInfo(struct SSqlInfo* pInfo, void** output, int32_t* msgLe
|
|||
}
|
||||
}
|
||||
|
||||
SShowMsg* pShowMsg = calloc(1, sizeof(SShowMsg));
|
||||
pShowMsg->type = pShowInfo->showType;
|
||||
*output = buildShowMsg(pShowInfo, 0, pMsgBuf->buf, pMsgBuf->len);
|
||||
*msgLen = sizeof(SShowMsg)/* + htons(pShowMsg->payloadLen)*/;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) {
|
||||
SToken* pPattern = &pShowInfo->pattern;
|
||||
if (pPattern->type > 0) { // only show tables support wildcard query
|
||||
strncpy(pShowMsg->payload, pPattern->z, pPattern->n);
|
||||
pShowMsg->payloadLen = htons(pPattern->n);
|
||||
}
|
||||
} else {
|
||||
SToken* pEpAddr = &pShowInfo->prefix;
|
||||
assert(pEpAddr->n > 0 && pEpAddr->type > 0);
|
||||
// can only perform the parameters based on the macro definitation
|
||||
static int32_t doCheckDbOptions(SCreateDbMsg* pCreate, SMsgBuf* pMsgBuf) {
|
||||
char msg[512] = {0};
|
||||
|
||||
strncpy(pShowMsg->payload, pEpAddr->z, pEpAddr->n);
|
||||
pShowMsg->payloadLen = htons(pEpAddr->n);
|
||||
if (pCreate->walLevel != -1 && (pCreate->walLevel < TSDB_MIN_WAL_LEVEL || pCreate->walLevel > TSDB_MAX_WAL_LEVEL)) {
|
||||
snprintf(msg, tListLen(msg), "invalid db option walLevel: %d, only 1-2 allowed", pCreate->walLevel);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg);
|
||||
}
|
||||
|
||||
if (pCreate->replications != -1 &&
|
||||
(pCreate->replications < TSDB_MIN_DB_REPLICA_OPTION || pCreate->replications > TSDB_MAX_DB_REPLICA_OPTION)) {
|
||||
snprintf(msg, tListLen(msg), "invalid db option replications: %d valid range: [%d, %d]", pCreate->replications,
|
||||
TSDB_MIN_DB_REPLICA_OPTION, TSDB_MAX_DB_REPLICA_OPTION);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg);
|
||||
}
|
||||
|
||||
int32_t blocks = ntohl(pCreate->totalBlocks);
|
||||
if (blocks != -1 && (blocks < TSDB_MIN_TOTAL_BLOCKS || blocks > TSDB_MAX_TOTAL_BLOCKS)) {
|
||||
snprintf(msg, tListLen(msg), "invalid db option totalBlocks: %d valid range: [%d, %d]", blocks,
|
||||
TSDB_MIN_TOTAL_BLOCKS, TSDB_MAX_TOTAL_BLOCKS);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg);
|
||||
}
|
||||
|
||||
if (pCreate->quorum != -1 &&
|
||||
(pCreate->quorum < TSDB_MIN_DB_QUORUM_OPTION || pCreate->quorum > TSDB_MAX_DB_QUORUM_OPTION)) {
|
||||
snprintf(msg, tListLen(msg), "invalid db option quorum: %d valid range: [%d, %d]", pCreate->quorum,
|
||||
TSDB_MIN_DB_QUORUM_OPTION, TSDB_MAX_DB_QUORUM_OPTION);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg);
|
||||
}
|
||||
|
||||
int32_t val = htonl(pCreate->daysPerFile);
|
||||
if (val != -1 && (val < TSDB_MIN_DAYS_PER_FILE || val > TSDB_MAX_DAYS_PER_FILE)) {
|
||||
snprintf(msg, tListLen(msg), "invalid db option daysPerFile: %d valid range: [%d, %d]", val,
|
||||
TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg);
|
||||
}
|
||||
|
||||
val = htonl(pCreate->cacheBlockSize);
|
||||
if (val != -1 && (val < TSDB_MIN_CACHE_BLOCK_SIZE || val > TSDB_MAX_CACHE_BLOCK_SIZE)) {
|
||||
snprintf(msg, tListLen(msg), "invalid db option cacheBlockSize: %d valid range: [%d, %d]", val,
|
||||
TSDB_MIN_CACHE_BLOCK_SIZE, TSDB_MAX_CACHE_BLOCK_SIZE);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg);
|
||||
}
|
||||
|
||||
if (pCreate->precision != TSDB_TIME_PRECISION_MILLI && pCreate->precision != TSDB_TIME_PRECISION_MICRO &&
|
||||
pCreate->precision != TSDB_TIME_PRECISION_NANO) {
|
||||
snprintf(msg, tListLen(msg), "invalid db option timePrecision: %d valid value: [%d, %d, %d]", pCreate->precision,
|
||||
TSDB_TIME_PRECISION_MILLI, TSDB_TIME_PRECISION_MICRO, TSDB_TIME_PRECISION_NANO);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg);
|
||||
}
|
||||
|
||||
val = htonl(pCreate->commitTime);
|
||||
if (val != -1 && (val < TSDB_MIN_COMMIT_TIME || val > TSDB_MAX_COMMIT_TIME)) {
|
||||
snprintf(msg, tListLen(msg), "invalid db option commitTime: %d valid range: [%d, %d]", val,
|
||||
TSDB_MIN_COMMIT_TIME, TSDB_MAX_COMMIT_TIME);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg);
|
||||
}
|
||||
|
||||
val = htonl(pCreate->fsyncPeriod);
|
||||
if (val != -1 && (val < TSDB_MIN_FSYNC_PERIOD || val > TSDB_MAX_FSYNC_PERIOD)) {
|
||||
snprintf(msg, tListLen(msg), "invalid db option fsyncPeriod: %d valid range: [%d, %d]", val,
|
||||
TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg);
|
||||
}
|
||||
|
||||
if (pCreate->compression != -1 &&
|
||||
(pCreate->compression < TSDB_MIN_COMP_LEVEL || pCreate->compression > TSDB_MAX_COMP_LEVEL)) {
|
||||
snprintf(msg, tListLen(msg), "invalid db option compression: %d valid range: [%d, %d]", pCreate->compression,
|
||||
TSDB_MIN_COMP_LEVEL, TSDB_MAX_COMP_LEVEL);
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg);
|
||||
}
|
||||
|
||||
*output = pShowMsg;
|
||||
*msgLen = sizeof(SShowMsg) + htons(pShowMsg->payloadLen);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -4216,6 +4232,36 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, int64_t id, void** output, in
|
|||
code = setShowInfo(pInfo, output, outputLen, pMsgBuf);
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_SQL_ALTER_DB:
|
||||
case TSDB_SQL_CREATE_DB: {
|
||||
const char* msg1 = "invalid db name";
|
||||
const char* msg2 = "name too long";
|
||||
|
||||
SCreateDbInfo* pCreateDB = &(pInfo->pMiscInfo->dbOpt);
|
||||
if (pCreateDB->dbname.n >= TSDB_DB_NAME_LEN) {
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg2);
|
||||
}
|
||||
|
||||
char buf[TSDB_DB_NAME_LEN] = {0};
|
||||
SToken token = taosTokenDup(&pCreateDB->dbname, buf, tListLen(buf));
|
||||
|
||||
if (parserValidateNameToken(&token) != TSDB_CODE_SUCCESS) {
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg1);
|
||||
}
|
||||
|
||||
SCreateDbMsg* pCreateMsg = buildCreateDbMsg(pCreateDB, pMsgBuf->buf, pMsgBuf->len);
|
||||
if (doCheckDbOptions(pCreateMsg, pMsgBuf) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
strncpy(pCreateMsg->db, token.z, token.n);
|
||||
|
||||
*output = pCreateMsg;
|
||||
*outputLen = sizeof(SCreateDbMsg);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -77,6 +77,14 @@ typedef struct SInsertParseContext {
|
|||
SInsertStmtInfo* pOutput;
|
||||
} SInsertParseContext;
|
||||
|
||||
typedef int32_t (*FRowAppend)(const void *value, int32_t len, void *param);
|
||||
|
||||
typedef struct SKvParam {
|
||||
char buf[TSDB_MAX_TAGS_LEN];
|
||||
SKVRowBuilder* builder;
|
||||
SSchema* schema;
|
||||
} SKvParam;
|
||||
|
||||
static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE;
|
||||
static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE;
|
||||
|
||||
|
@ -300,14 +308,6 @@ static int parseTime(SInsertParseContext* pCxt, SToken *pToken, int16_t timePrec
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
typedef int32_t (*FRowAppend)(const void *value, int32_t len, void *param);
|
||||
|
||||
typedef struct SKvParam {
|
||||
char buf[TSDB_MAX_TAGS_LEN];
|
||||
SKVRowBuilder* builder;
|
||||
SSchema* schema;
|
||||
} SKvParam;
|
||||
|
||||
static FORCE_INLINE int32_t KvRowAppend(const void *value, int32_t len, void *param) {
|
||||
SKvParam* pa = (SKvParam*)param;
|
||||
if (TSDB_DATA_TYPE_BINARY == pa->schema->type) {
|
||||
|
|
|
@ -32,12 +32,6 @@ bool qIsInsertSql(const char* pStr, size_t length) {
|
|||
}
|
||||
|
||||
int32_t qParseQuerySql(const char* pStr, size_t length, int64_t id, int32_t *type, void** pOutput, int32_t* outputLen, char* msg, int32_t msgLen) {
|
||||
SQueryStmtInfo* pQueryInfo = calloc(1, sizeof(SQueryStmtInfo));
|
||||
if (pQueryInfo == NULL) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; // set correct error code.
|
||||
return terrno;
|
||||
}
|
||||
|
||||
SSqlInfo info = doGenerateAST(pStr);
|
||||
if (!info.valid) {
|
||||
strncpy(msg, info.msg, msgLen);
|
||||
|
@ -51,6 +45,12 @@ int32_t qParseQuerySql(const char* pStr, size_t length, int64_t id, int32_t *typ
|
|||
// do nothing
|
||||
}
|
||||
} else {
|
||||
SQueryStmtInfo* pQueryInfo = calloc(1, sizeof(SQueryStmtInfo));
|
||||
if (pQueryInfo == NULL) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; // set correct error code.
|
||||
return terrno;
|
||||
}
|
||||
|
||||
struct SCatalog* pCatalog = NULL;
|
||||
int32_t code = catalogGetHandle(NULL, &pCatalog);
|
||||
code = qParserValidateSqlNode(pCatalog, &info, pQueryInfo, id, msg, msgLen);
|
||||
|
@ -59,6 +59,7 @@ int32_t qParseQuerySql(const char* pStr, size_t length, int64_t id, int32_t *typ
|
|||
}
|
||||
}
|
||||
|
||||
destroySqlInfo(&info);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,7 @@ static int32_t tnameComparFn(const void* p1, const void* p2) {
|
|||
SName* pn1 = (SName*)p1;
|
||||
SName* pn2 = (SName*)p2;
|
||||
|
||||
int32_t ret = strncmp(pn1->acctId, pn2->acctId, tListLen(pn1->acctId));
|
||||
int32_t ret = pn1->acctId - pn2->acctId;
|
||||
if (ret != 0) {
|
||||
return ret > 0? 1:-1;
|
||||
} else {
|
||||
|
|
|
@ -122,6 +122,25 @@ int32_t parserValidatePassword(SToken* pToken, SMsgBuf* pMsgBuf) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t parserValidateNameToken(SToken* pToken) {
|
||||
if (pToken == NULL || pToken->z == NULL || pToken->type != TK_ID) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
// it is a token quoted with escape char '`'
|
||||
if (pToken->z[0] == TS_ESCAPE_CHAR && pToken->z[pToken->n - 1] == TS_ESCAPE_CHAR) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char* sep = strnchr(pToken->z, TS_PATH_DELIMITER[0], pToken->n, true);
|
||||
if (sep != NULL) { // It is a complex type, not allow
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
strntolower(pToken->z, pToken->z, pToken->n);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t buildInvalidOperationMsg(SMsgBuf* pBuf, const char* msg) {
|
||||
strncpy(pBuf->buf, msg, pBuf->len);
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
|
|
|
@ -2519,7 +2519,7 @@ static void yy_reduce(
|
|||
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
|
||||
break;
|
||||
case 105: /* db_optr ::= */
|
||||
{setDefaultCreateDbOption(&yymsp[1].minor.yy256); yymsp[1].minor.yy256.dbType = TSDB_DB_TYPE_DEFAULT;}
|
||||
{setDefaultCreateDbOption(&yymsp[1].minor.yy256);}
|
||||
break;
|
||||
case 106: /* db_optr ::= db_optr cache */
|
||||
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
|
||||
|
@ -2590,16 +2590,16 @@ static void yy_reduce(
|
|||
break;
|
||||
case 121: /* topic_optr ::= db_optr */
|
||||
case 131: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==131);
|
||||
{ yylhsminor.yy256 = yymsp[0].minor.yy256; yylhsminor.yy256.dbType = TSDB_DB_TYPE_TOPIC; }
|
||||
{ yylhsminor.yy256 = yymsp[0].minor.yy256;}
|
||||
yymsp[0].minor.yy256 = yylhsminor.yy256;
|
||||
break;
|
||||
case 122: /* topic_optr ::= topic_optr partitions */
|
||||
case 132: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==132);
|
||||
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
|
||||
{ yylhsminor.yy256 = yymsp[-1].minor.yy256; }
|
||||
yymsp[-1].minor.yy256 = yylhsminor.yy256;
|
||||
break;
|
||||
case 123: /* alter_db_optr ::= */
|
||||
{ setDefaultCreateDbOption(&yymsp[1].minor.yy256); yymsp[1].minor.yy256.dbType = TSDB_DB_TYPE_DEFAULT;}
|
||||
{ setDefaultCreateDbOption(&yymsp[1].minor.yy256); }
|
||||
break;
|
||||
case 133: /* typename ::= ids */
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ TARGET_INCLUDE_DIRECTORIES(
|
|||
|
||||
TARGET_LINK_LIBRARIES(
|
||||
parserTest
|
||||
PUBLIC os util common parser catalog transport gtest function planner query
|
||||
PUBLIC os util common parser catalog transport gtest function planner qcom
|
||||
)
|
||||
|
||||
TARGET_LINK_OPTIONS(parserTest PRIVATE -Wl,-wrap,malloc)
|
||||
|
|
|
@ -8,7 +8,7 @@ target_include_directories(
|
|||
|
||||
target_link_libraries(
|
||||
planner
|
||||
PRIVATE os util common catalog parser transport function query
|
||||
PRIVATE os util catalog cjson parser transport function qcom
|
||||
)
|
||||
|
||||
ADD_SUBDIRECTORY(test)
|
||||
|
|
|
@ -100,14 +100,9 @@ int32_t queryPlanToString(struct SQueryPlanNode* pQueryNode, char** str);
|
|||
int32_t queryPlanToSql(struct SQueryPlanNode* pQueryNode, char** sql);
|
||||
|
||||
int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryDag** pDag);
|
||||
|
||||
/**
|
||||
* Convert to physical plan to string to enable to print it out in the shell.
|
||||
* @param pPhyNode
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
int32_t phyPlanToString(struct SPhyNode *pPhyNode, char** str);
|
||||
int32_t setSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SArray* eps);
|
||||
int32_t subPlanToString(const SSubplan *pPhyNode, char** str);
|
||||
int32_t stringToSubplan(const char* str, SSubplan** subplan);
|
||||
|
||||
/**
|
||||
* Destroy the query plan object.
|
||||
|
@ -122,6 +117,8 @@ void destroyQueryPlan(struct SQueryPlanNode* pQueryNode);
|
|||
*/
|
||||
void* destroyQueryPhyPlan(struct SPhyNode* pQueryPhyNode);
|
||||
|
||||
int32_t opNameToOpType(const char* name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue