提交 787cc50c 编写于 作者: C cpwu

Merge branch '3.0' into cpwu/3.0

...@@ -78,11 +78,14 @@ int32_t create_stream() { ...@@ -78,11 +78,14 @@ int32_t create_stream() {
taos_free_result(pRes); taos_free_result(pRes);
/*const char* sql = "select min(k), max(k), sum(k) from tu1";*/ /*const char* sql = "select min(k), max(k), sum(k) from tu1";*/
const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1"; /*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/ /*const char* sql = "select sum(k) from tu1 interval(10m)";*/
pRes = tmq_create_stream(pConn, "stream1", "out1", sql); /*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
pRes = taos_query(
pConn,
"create stream stream1 trigger window_close as select min(k), max(k), sum(k) as sum_of_k from tu1 interval(10m)");
if (taos_errno(pRes) != 0) { if (taos_errno(pRes) != 0) {
printf("failed to create stream out1, reason:%s\n", taos_errstr(pRes)); printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes));
return -1; return -1;
} }
taos_free_result(pRes); taos_free_result(pRes);
......
...@@ -86,9 +86,9 @@ typedef struct taosField { ...@@ -86,9 +86,9 @@ typedef struct taosField {
} TAOS_FIELD; } TAOS_FIELD;
#ifdef WINDOWS #ifdef WINDOWS
#define DLL_EXPORT __declspec(dllexport) #define DLL_EXPORT __declspec(dllexport)
#else #else
#define DLL_EXPORT #define DLL_EXPORT
#endif #endif
typedef void (*__taos_async_fn_t)(void *param, TAOS_RES *, int code); typedef void (*__taos_async_fn_t)(void *param, TAOS_RES *, int code);
...@@ -123,42 +123,42 @@ DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...); ...@@ -123,42 +123,42 @@ DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...);
DLL_EXPORT setConfRet taos_set_config(const char *config); DLL_EXPORT setConfRet taos_set_config(const char *config);
DLL_EXPORT int taos_init(void); DLL_EXPORT int taos_init(void);
DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port); DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
DLL_EXPORT TAOS *taos_connect_l(const char *ip, int ipLen, const char *user, int userLen, const char *pass, int passLen, DLL_EXPORT TAOS *taos_connect_l(const char *ip, int ipLen, const char *user, int userLen, const char *pass, int passLen,
const char *db, int dbLen, uint16_t port); const char *db, int dbLen, uint16_t port);
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port); DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
DLL_EXPORT void taos_close(TAOS *taos); DLL_EXPORT void taos_close(TAOS *taos);
const char *taos_data_type(int type); const char *taos_data_type(int type);
DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos); DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos);
DLL_EXPORT int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length); DLL_EXPORT int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length);
DLL_EXPORT int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_MULTI_BIND *tags); DLL_EXPORT int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_MULTI_BIND *tags);
DLL_EXPORT int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name); DLL_EXPORT int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name);
DLL_EXPORT int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name); DLL_EXPORT int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name);
DLL_EXPORT int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert); DLL_EXPORT int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert);
DLL_EXPORT int taos_stmt_num_params(TAOS_STMT *stmt, int *nums); DLL_EXPORT int taos_stmt_num_params(TAOS_STMT *stmt, int *nums);
DLL_EXPORT int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes); DLL_EXPORT int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes);
DLL_EXPORT int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind); DLL_EXPORT int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind);
DLL_EXPORT int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind); DLL_EXPORT int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind);
DLL_EXPORT int taos_stmt_bind_single_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int colIdx); DLL_EXPORT int taos_stmt_bind_single_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int colIdx);
DLL_EXPORT int taos_stmt_add_batch(TAOS_STMT *stmt); DLL_EXPORT int taos_stmt_add_batch(TAOS_STMT *stmt);
DLL_EXPORT int taos_stmt_execute(TAOS_STMT *stmt); DLL_EXPORT int taos_stmt_execute(TAOS_STMT *stmt);
DLL_EXPORT TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt); DLL_EXPORT TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt);
DLL_EXPORT int taos_stmt_close(TAOS_STMT *stmt); DLL_EXPORT int taos_stmt_close(TAOS_STMT *stmt);
DLL_EXPORT char *taos_stmt_errstr(TAOS_STMT *stmt); DLL_EXPORT char *taos_stmt_errstr(TAOS_STMT *stmt);
DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT *stmt); DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT *stmt);
DLL_EXPORT int taos_stmt_affected_rows_once(TAOS_STMT *stmt); DLL_EXPORT int taos_stmt_affected_rows_once(TAOS_STMT *stmt);
DLL_EXPORT TAOS_RES *taos_query(TAOS *taos, const char *sql); DLL_EXPORT TAOS_RES *taos_query(TAOS *taos, const char *sql);
DLL_EXPORT TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen); DLL_EXPORT TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen);
DLL_EXPORT TAOS_ROW taos_fetch_row(TAOS_RES *res); DLL_EXPORT TAOS_ROW taos_fetch_row(TAOS_RES *res);
DLL_EXPORT int taos_result_precision(TAOS_RES *res); // get the time precision of result DLL_EXPORT int taos_result_precision(TAOS_RES *res); // get the time precision of result
DLL_EXPORT void taos_free_result(TAOS_RES *res); DLL_EXPORT void taos_free_result(TAOS_RES *res);
DLL_EXPORT int taos_field_count(TAOS_RES *res); DLL_EXPORT int taos_field_count(TAOS_RES *res);
DLL_EXPORT int taos_num_fields(TAOS_RES *res); DLL_EXPORT int taos_num_fields(TAOS_RES *res);
DLL_EXPORT int taos_affected_rows(TAOS_RES *res); DLL_EXPORT int taos_affected_rows(TAOS_RES *res);
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res); DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db); DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
...@@ -271,10 +271,8 @@ DLL_EXPORT int64_t tmq_get_response_offset(tmq_message_t *message); ...@@ -271,10 +271,8 @@ DLL_EXPORT int64_t tmq_get_response_offset(tmq_message_t *message);
/* --------------------TMPORARY INTERFACE FOR TESTING--------------------- */ /* --------------------TMPORARY INTERFACE FOR TESTING--------------------- */
#if 0 #if 0
DLL_EXPORT TAOS_RES *tmq_create_topic(TAOS *taos, const char *name, const char *sql, int sqlLen); DLL_EXPORT TAOS_RES *tmq_create_topic(TAOS *taos, const char *name, const char *sql, int sqlLen);
#endif
DLL_EXPORT TAOS_RES *tmq_create_stream(TAOS *taos, const char *streamName, const char *tbName, const char *sql); DLL_EXPORT TAOS_RES *tmq_create_stream(TAOS *taos, const char *streamName, const char *tbName, const char *sql);
#endif
/* ------------------------------ TMQ END -------------------------------- */ /* ------------------------------ TMQ END -------------------------------- */
#if 1 // Shuduo: temporary enable for app build #if 1 // Shuduo: temporary enable for app build
typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB *tsub, TAOS_RES *res, void *param, int code); typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB *tsub, TAOS_RES *res, void *param, int code);
......
...@@ -531,27 +531,24 @@ int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pR ...@@ -531,27 +531,24 @@ int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pR
typedef struct { typedef struct {
char db[TSDB_DB_FNAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int32_t numOfVgroups; int32_t numOfVgroups;
int32_t cacheBlockSize; // MB int32_t numOfStables; // single_stable
int32_t totalBlocks; int32_t buffer; // MB
int32_t pageSize;
int32_t pages;
int32_t daysPerFile; int32_t daysPerFile;
int32_t daysToKeep0; int32_t daysToKeep0;
int32_t daysToKeep1; int32_t daysToKeep1;
int32_t daysToKeep2; int32_t daysToKeep2;
int32_t minRows; int32_t minRows;
int32_t maxRows; int32_t maxRows;
int32_t commitTime;
int32_t fsyncPeriod; int32_t fsyncPeriod;
int32_t ttl;
int8_t walLevel; int8_t walLevel;
int8_t precision; // time resolution int8_t precision; // time resolution
int8_t compression; int8_t compression;
int8_t replications; int8_t replications;
int8_t strict; int8_t strict;
int8_t update;
int8_t cacheLastRow; int8_t cacheLastRow;
int8_t ignoreExist; int8_t ignoreExist;
int8_t streamMode;
int8_t singleSTable;
int32_t numOfRetensions; int32_t numOfRetensions;
SArray* pRetensions; // SRetention SArray* pRetensions; // SRetention
} SCreateDbReq; } SCreateDbReq;
...@@ -562,7 +559,10 @@ void tFreeSCreateDbReq(SCreateDbReq* pReq); ...@@ -562,7 +559,10 @@ void tFreeSCreateDbReq(SCreateDbReq* pReq);
typedef struct { typedef struct {
char db[TSDB_DB_FNAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int32_t totalBlocks; int32_t buffer;
int32_t pageSize;
int32_t pages;
int32_t daysPerFile;
int32_t daysToKeep0; int32_t daysToKeep0;
int32_t daysToKeep1; int32_t daysToKeep1;
int32_t daysToKeep2; int32_t daysToKeep2;
...@@ -626,26 +626,23 @@ int32_t tDeserializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq); ...@@ -626,26 +626,23 @@ int32_t tDeserializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq);
typedef struct { typedef struct {
int32_t numOfVgroups; int32_t numOfVgroups;
int32_t cacheBlockSize; int32_t numOfStables;
int32_t totalBlocks; int32_t buffer;
int32_t pageSize;
int32_t pages;
int32_t daysPerFile; int32_t daysPerFile;
int32_t daysToKeep0; int32_t daysToKeep0;
int32_t daysToKeep1; int32_t daysToKeep1;
int32_t daysToKeep2; int32_t daysToKeep2;
int32_t minRows; int32_t minRows;
int32_t maxRows; int32_t maxRows;
int32_t commitTime;
int32_t fsyncPeriod; int32_t fsyncPeriod;
int32_t ttl;
int8_t walLevel; int8_t walLevel;
int8_t precision; int8_t precision;
int8_t compression; int8_t compression;
int8_t replications; int8_t replications;
int8_t strict; int8_t strict;
int8_t update;
int8_t cacheLastRow; int8_t cacheLastRow;
int8_t streamMode;
int8_t singleSTable;
int32_t numOfRetensions; int32_t numOfRetensions;
SArray* pRetensions; SArray* pRetensions;
} SDbCfgRsp; } SDbCfgRsp;
...@@ -845,15 +842,16 @@ typedef struct { ...@@ -845,15 +842,16 @@ typedef struct {
char db[TSDB_DB_FNAME_LEN]; char db[TSDB_DB_FNAME_LEN];
int64_t dbUid; int64_t dbUid;
int32_t vgVersion; int32_t vgVersion;
int32_t cacheBlockSize; int32_t numOfStables;
int32_t totalBlocks; int32_t buffer;
int32_t pageSize;
int32_t pages;
int32_t daysPerFile; int32_t daysPerFile;
int32_t daysToKeep0; int32_t daysToKeep0;
int32_t daysToKeep1; int32_t daysToKeep1;
int32_t daysToKeep2; int32_t daysToKeep2;
int32_t minRows; int32_t minRows;
int32_t maxRows; int32_t maxRows;
int32_t commitTime;
int32_t fsyncPeriod; int32_t fsyncPeriod;
uint32_t hashBegin; uint32_t hashBegin;
uint32_t hashEnd; uint32_t hashEnd;
...@@ -862,11 +860,9 @@ typedef struct { ...@@ -862,11 +860,9 @@ typedef struct {
int8_t precision; int8_t precision;
int8_t compression; int8_t compression;
int8_t strict; int8_t strict;
int8_t update;
int8_t cacheLastRow; int8_t cacheLastRow;
int8_t replica; int8_t replica;
int8_t selfIndex; int8_t selfIndex;
int8_t streamMode;
SReplica replicas[TSDB_MAX_REPLICA]; SReplica replicas[TSDB_MAX_REPLICA];
int32_t numOfRetensions; int32_t numOfRetensions;
SArray* pRetensions; // SRetention SArray* pRetensions; // SRetention
...@@ -896,10 +892,14 @@ int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq ...@@ -896,10 +892,14 @@ int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq
typedef struct { typedef struct {
int32_t vgVersion; int32_t vgVersion;
int32_t totalBlocks; int32_t buffer;
int32_t pageSize;
int32_t pages;
int32_t daysPerFile;
int32_t daysToKeep0; int32_t daysToKeep0;
int32_t daysToKeep1; int32_t daysToKeep1;
int32_t daysToKeep2; int32_t daysToKeep2;
int32_t fsyncPeriod;
int8_t walLevel; int8_t walLevel;
int8_t strict; int8_t strict;
int8_t cacheLastRow; int8_t cacheLastRow;
...@@ -954,7 +954,6 @@ typedef struct { ...@@ -954,7 +954,6 @@ typedef struct {
int32_t numOfColumns; int32_t numOfColumns;
int8_t precision; int8_t precision;
int8_t tableType; int8_t tableType;
int8_t update;
int32_t sversion; int32_t sversion;
int32_t tversion; int32_t tversion;
uint64_t suid; uint64_t suid;
......
...@@ -595,6 +595,34 @@ static FORCE_INLINE int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols, ...@@ -595,6 +595,34 @@ static FORCE_INLINE int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols,
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
/**
* @brief
*
* @param pBuilder
* @param nCols
* @param nBoundCols use -1 if not available
* @param flen
* @return FORCE_INLINE
*/
static FORCE_INLINE int32_t tdSRowSetTpInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t flen) {
pBuilder->flen = flen;
pBuilder->nCols = nCols;
if (pBuilder->flen <= 0 || pBuilder->nCols <= 0) {
TASSERT(0);
terrno = TSDB_CODE_INVALID_PARA;
return terrno;
}
#ifdef TD_SUPPORT_BITMAP
// the primary TS key is stored separatedly
pBuilder->nBitmaps = (int16_t)TD_BITMAP_BYTES(pBuilder->nCols - 1);
#else
pBuilder->nBitmaps = 0;
pBuilder->nBoundBitmaps = 0;
#endif
return TSDB_CODE_SUCCESS;
}
/** /**
* @brief To judge row type: STpRow/SKvRow * @brief To judge row type: STpRow/SKvRow
* *
...@@ -1385,7 +1413,6 @@ static void tdSRowPrint(STSRow *row, STSchema *pSchema, const char* tag) { ...@@ -1385,7 +1413,6 @@ static void tdSRowPrint(STSRow *row, STSchema *pSchema, const char* tag) {
} }
printf("\n"); printf("\n");
} }
#ifdef TROW_ORIGIN_HZ #ifdef TROW_ORIGIN_HZ
typedef struct { typedef struct {
uint32_t nRows; uint32_t nRows;
......
...@@ -35,19 +35,6 @@ enum { ...@@ -35,19 +35,6 @@ enum {
STREAM_CREATED_BY__SMA, STREAM_CREATED_BY__SMA,
}; };
#if 0
// pipe -> fetch/pipe queue
// merge -> merge queue
// write -> write queue
enum {
TASK_DISPATCH_MSG__SND_PIPE = 1,
TASK_DISPATCH_MSG__SND_MERGE,
TASK_DISPATCH_MSG__VND_PIPE,
TASK_DISPATCH_MSG__VND_MERGE,
TASK_DISPATCH_MSG__VND_WRITE,
};
#endif
typedef struct { typedef struct {
int32_t nodeId; // 0 for snode int32_t nodeId; // 0 for snode
SEpSet epSet; SEpSet epSet;
...@@ -100,10 +87,6 @@ typedef struct { ...@@ -100,10 +87,6 @@ typedef struct {
int8_t reserved; int8_t reserved;
} STaskSinkFetch; } STaskSinkFetch;
typedef struct {
int8_t reserved;
} STaskSinkShow;
enum { enum {
TASK_SOURCE__SCAN = 1, TASK_SOURCE__SCAN = 1,
TASK_SOURCE__PIPE, TASK_SOURCE__PIPE,
...@@ -128,7 +111,6 @@ enum { ...@@ -128,7 +111,6 @@ enum {
TASK_SINK__TABLE, TASK_SINK__TABLE,
TASK_SINK__SMA, TASK_SINK__SMA,
TASK_SINK__FETCH, TASK_SINK__FETCH,
TASK_SINK__SHOW,
}; };
typedef struct { typedef struct {
...@@ -155,7 +137,6 @@ typedef struct { ...@@ -155,7 +137,6 @@ typedef struct {
STaskSinkTb tbSink; STaskSinkTb tbSink;
STaskSinkSma smaSink; STaskSinkSma smaSink;
STaskSinkFetch fetchSink; STaskSinkFetch fetchSink;
STaskSinkShow showSink;
}; };
// dispatch // dispatch
......
...@@ -244,9 +244,10 @@ int32_t* taosGetErrno(); ...@@ -244,9 +244,10 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x03AC) #define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x03AC)
#define TSDB_CODE_MND_COLUMN_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AD) #define TSDB_CODE_MND_COLUMN_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AD)
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE) #define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE)
#define TSDB_CODE_MND_SINGLE_STB_MODE_DB TAOS_DEF_ERROR_CODE(0, 0x03B0)
// mnode-infoSchema // mnode-infoSchema
#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x03B0) #define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x03BA)
// mnode-func // mnode-func
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0) #define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
......
...@@ -327,15 +327,21 @@ typedef enum ELogicConditionType { ...@@ -327,15 +327,21 @@ typedef enum ELogicConditionType {
#define TSDB_MIN_VNODES_PER_DB 1 #define TSDB_MIN_VNODES_PER_DB 1
#define TSDB_MAX_VNODES_PER_DB 4096 #define TSDB_MAX_VNODES_PER_DB 4096
#define TSDB_DEFAULT_VN_PER_DB 2 #define TSDB_DEFAULT_VN_PER_DB 2
#define TSDB_MIN_CACHE_BLOCK_SIZE 1 #define TSDB_MIN_BUFFER_PER_VNODE 3 // unit MB
#define TSDB_MAX_CACHE_BLOCK_SIZE 128 // 128MB for each vnode #define TSDB_MAX_BUFFER_PER_VNODE 16384 // unit MB
#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16 #define TSDB_DEFAULT_BUFFER_PER_VNODE 96
#define TSDB_MIN_TOTAL_BLOCKS 3 #define TSDB_MIN_PAGES_PER_VNODE 64
#define TSDB_MAX_TOTAL_BLOCKS 10000 #define TSDB_MAX_PAGES_PER_VNODE 16384
#define TSDB_DEFAULT_TOTAL_BLOCKS 6 #define TSDB_DEFAULT_PAGES_PER_VNODE 256
#define TSDB_MIN_PAGESIZE_PER_VNODE 1 // unit KB
#define TSDB_MAX_PAGESIZE_PER_VNODE 16384
#define TSDB_DEFAULT_PAGESIZE_PER_VNODE 4
#define TSDB_MIN_DAYS_PER_FILE 60 // unit minute #define TSDB_MIN_DAYS_PER_FILE 60 // unit minute
#define TSDB_MAX_DAYS_PER_FILE (3650 * 1440) #define TSDB_MAX_DAYS_PER_FILE (3650 * 1440)
#define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440) #define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440)
#define TSDB_MIN_DURATION_PER_FILE 60 // unit minute
#define TSDB_MAX_DURATION_PER_FILE (3650 * 1440)
#define TSDB_DEFAULT_DURATION_PER_FILE (10 * 1440)
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute #define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved. #define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years #define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
...@@ -345,9 +351,6 @@ typedef enum ELogicConditionType { ...@@ -345,9 +351,6 @@ typedef enum ELogicConditionType {
#define TSDB_MIN_MAXROWS_FBLOCK 200 #define TSDB_MIN_MAXROWS_FBLOCK 200
#define TSDB_MAX_MAXROWS_FBLOCK 10000 #define TSDB_MAX_MAXROWS_FBLOCK 10000
#define TSDB_DEFAULT_MAXROWS_FBLOCK 4096 #define TSDB_DEFAULT_MAXROWS_FBLOCK 4096
#define TSDB_MIN_COMMIT_TIME 30
#define TSDB_MAX_COMMIT_TIME 40960
#define TSDB_DEFAULT_COMMIT_TIME 3600
#define TSDB_MIN_FSYNC_PERIOD 0 #define TSDB_MIN_FSYNC_PERIOD 0
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond #define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second #define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
...@@ -366,9 +369,6 @@ typedef enum ELogicConditionType { ...@@ -366,9 +369,6 @@ typedef enum ELogicConditionType {
#define TSDB_DB_STRICT_OFF 0 #define TSDB_DB_STRICT_OFF 0
#define TSDB_DB_STRICT_ON 1 #define TSDB_DB_STRICT_ON 1
#define TSDB_DEFAULT_DB_STRICT 0 #define TSDB_DEFAULT_DB_STRICT 0
#define TSDB_MIN_DB_UPDATE 0
#define TSDB_MAX_DB_UPDATE 2
#define TSDB_DEFAULT_DB_UPDATE 0
#define TSDB_MIN_DB_CACHE_LAST_ROW 0 #define TSDB_MIN_DB_CACHE_LAST_ROW 0
#define TSDB_MAX_DB_CACHE_LAST_ROW 3 #define TSDB_MAX_DB_CACHE_LAST_ROW 3
#define TSDB_DEFAULT_CACHE_LAST_ROW 0 #define TSDB_DEFAULT_CACHE_LAST_ROW 0
...@@ -378,13 +378,6 @@ typedef enum ELogicConditionType { ...@@ -378,13 +378,6 @@ typedef enum ELogicConditionType {
#define TSDB_DB_SINGLE_STABLE_ON 0 #define TSDB_DB_SINGLE_STABLE_ON 0
#define TSDB_DB_SINGLE_STABLE_OFF 1 #define TSDB_DB_SINGLE_STABLE_OFF 1
#define TSDB_DEFAULT_DB_SINGLE_STABLE 0 #define TSDB_DEFAULT_DB_SINGLE_STABLE 0
#define TSDB_MIN_BUFFER_PER_VNODE 3 // unit MB
#define TSDB_DEFAULT_BUFFER_PER_VNODE 96
#define TSDB_MIN_PAGES_PER_VNODE 64
#define TSDB_DEFAULT_PAGES_PER_VNODE 256
#define TSDB_MIN_PAGESIZE_PER_VNODE 1 // unit KB
#define TSDB_MAX_PAGESIZE_PER_VNODE 16384
#define TSDB_DEFAULT_PAGESIZE_PER_VNODE 4
#define TSDB_MIN_ROLLUP_FILE_FACTOR 0 #define TSDB_MIN_ROLLUP_FILE_FACTOR 0
#define TSDB_MAX_ROLLUP_FILE_FACTOR 1 #define TSDB_MAX_ROLLUP_FILE_FACTOR 1
......
...@@ -667,7 +667,7 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) { ...@@ -667,7 +667,7 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
if (code != 0) goto FAIL; if (code != 0) goto FAIL;
while (TSDB_CODE_MND_CONSUMER_NOT_READY == tmqAskEp(tmq, false)) { while (TSDB_CODE_MND_CONSUMER_NOT_READY == tmqAskEp(tmq, false)) {
tscDebug("not ready, retry"); tscDebug("consumer not ready, retry");
taosMsleep(500); taosMsleep(500);
} }
...@@ -693,6 +693,7 @@ void tmq_conf_set_offset_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb) { ...@@ -693,6 +693,7 @@ void tmq_conf_set_offset_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb) {
conf->commitCb = cb; conf->commitCb = cb;
} }
#if 0
TAOS_RES* tmq_create_stream(TAOS* taos, const char* streamName, const char* tbName, const char* sql) { TAOS_RES* tmq_create_stream(TAOS* taos, const char* streamName, const char* tbName, const char* sql) {
STscObj* pTscObj = (STscObj*)taos; STscObj* pTscObj = (STscObj*)taos;
SRequestObj* pRequest = NULL; SRequestObj* pRequest = NULL;
...@@ -777,6 +778,7 @@ _return: ...@@ -777,6 +778,7 @@ _return:
return pRequest; return pRequest;
} }
#endif
#if 0 #if 0
int32_t tmqGetSkipLogNum(tmq_message_t* tmq_message) { int32_t tmqGetSkipLogNum(tmq_message_t* tmq_message) {
......
...@@ -1676,27 +1676,24 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) { ...@@ -1676,27 +1676,24 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
if (tStartEncode(&encoder) < 0) return -1; if (tStartEncode(&encoder) < 0) return -1;
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1; if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
if (tEncodeI32(&encoder, pReq->numOfVgroups) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfVgroups) < 0) return -1;
if (tEncodeI32(&encoder, pReq->cacheBlockSize) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfStables) < 0) return -1;
if (tEncodeI32(&encoder, pReq->totalBlocks) < 0) return -1; if (tEncodeI32(&encoder, pReq->buffer) < 0) return -1;
if (tEncodeI32(&encoder, pReq->pageSize) < 0) return -1;
if (tEncodeI32(&encoder, pReq->pages) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysPerFile) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysPerFile) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1;
if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1; if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1;
if (tEncodeI32(&encoder, pReq->maxRows) < 0) return -1; if (tEncodeI32(&encoder, pReq->maxRows) < 0) return -1;
if (tEncodeI32(&encoder, pReq->commitTime) < 0) return -1;
if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1; if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1;
if (tEncodeI32(&encoder, pReq->ttl) < 0) return -1;
if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1; if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1;
if (tEncodeI8(&encoder, pReq->precision) < 0) return -1; if (tEncodeI8(&encoder, pReq->precision) < 0) return -1;
if (tEncodeI8(&encoder, pReq->compression) < 0) return -1; if (tEncodeI8(&encoder, pReq->compression) < 0) return -1;
if (tEncodeI8(&encoder, pReq->replications) < 0) return -1; if (tEncodeI8(&encoder, pReq->replications) < 0) return -1;
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1; if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
if (tEncodeI8(&encoder, pReq->update) < 0) return -1;
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1; if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
if (tEncodeI8(&encoder, pReq->ignoreExist) < 0) return -1; if (tEncodeI8(&encoder, pReq->ignoreExist) < 0) return -1;
if (tEncodeI8(&encoder, pReq->streamMode) < 0) return -1;
if (tEncodeI8(&encoder, pReq->singleSTable) < 0) return -1;
if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1;
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) { for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
SRetention *pRetension = taosArrayGet(pReq->pRetensions, i); SRetention *pRetension = taosArrayGet(pReq->pRetensions, i);
...@@ -1719,27 +1716,24 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) ...@@ -1719,27 +1716,24 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
if (tStartDecode(&decoder) < 0) return -1; if (tStartDecode(&decoder) < 0) return -1;
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->numOfVgroups) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfVgroups) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->cacheBlockSize) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfStables) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->totalBlocks) < 0) return -1; if (tDecodeI32(&decoder, &pReq->buffer) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->pageSize) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->pages) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysPerFile) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysPerFile) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->minRows) < 0) return -1; if (tDecodeI32(&decoder, &pReq->minRows) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->maxRows) < 0) return -1; if (tDecodeI32(&decoder, &pReq->maxRows) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->commitTime) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1; if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->ttl) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1; if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->precision) < 0) return -1; if (tDecodeI8(&decoder, &pReq->precision) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->compression) < 0) return -1; if (tDecodeI8(&decoder, &pReq->compression) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1; if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1; if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->update) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1; if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->ignoreExist) < 0) return -1; if (tDecodeI8(&decoder, &pReq->ignoreExist) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->streamMode) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->singleSTable) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->numOfRetensions) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfRetensions) < 0) return -1;
pReq->pRetensions = taosArrayInit(pReq->numOfRetensions, sizeof(SRetention)); pReq->pRetensions = taosArrayInit(pReq->numOfRetensions, sizeof(SRetention));
if (pReq->pRetensions == NULL) { if (pReq->pRetensions == NULL) {
...@@ -1776,7 +1770,10 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { ...@@ -1776,7 +1770,10 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
if (tStartEncode(&encoder) < 0) return -1; if (tStartEncode(&encoder) < 0) return -1;
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1; if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
if (tEncodeI32(&encoder, pReq->totalBlocks) < 0) return -1; if (tEncodeI32(&encoder, pReq->buffer) < 0) return -1;
if (tEncodeI32(&encoder, pReq->pageSize) < 0) return -1;
if (tEncodeI32(&encoder, pReq->pages) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysPerFile) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1;
...@@ -1798,7 +1795,10 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { ...@@ -1798,7 +1795,10 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
if (tStartDecode(&decoder) < 0) return -1; if (tStartDecode(&decoder) < 0) return -1;
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->totalBlocks) < 0) return -1; if (tDecodeI32(&decoder, &pReq->buffer) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->pageSize) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->pages) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysPerFile) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1;
...@@ -2153,24 +2153,23 @@ int32_t tSerializeSDbCfgRsp(void *buf, int32_t bufLen, const SDbCfgRsp *pRsp) { ...@@ -2153,24 +2153,23 @@ int32_t tSerializeSDbCfgRsp(void *buf, int32_t bufLen, const SDbCfgRsp *pRsp) {
if (tStartEncode(&encoder) < 0) return -1; if (tStartEncode(&encoder) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->numOfVgroups) < 0) return -1; if (tEncodeI32(&encoder, pRsp->numOfVgroups) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->cacheBlockSize) < 0) return -1; if (tEncodeI32(&encoder, pRsp->numOfStables) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->totalBlocks) < 0) return -1; if (tEncodeI32(&encoder, pRsp->buffer) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->pageSize) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->pages) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->daysPerFile) < 0) return -1; if (tEncodeI32(&encoder, pRsp->daysPerFile) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->daysToKeep0) < 0) return -1; if (tEncodeI32(&encoder, pRsp->daysToKeep0) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->daysToKeep1) < 0) return -1; if (tEncodeI32(&encoder, pRsp->daysToKeep1) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->daysToKeep2) < 0) return -1; if (tEncodeI32(&encoder, pRsp->daysToKeep2) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->minRows) < 0) return -1; if (tEncodeI32(&encoder, pRsp->minRows) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->maxRows) < 0) return -1; if (tEncodeI32(&encoder, pRsp->maxRows) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->commitTime) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->fsyncPeriod) < 0) return -1; if (tEncodeI32(&encoder, pRsp->fsyncPeriod) < 0) return -1;
if (tEncodeI8(&encoder, pRsp->walLevel) < 0) return -1; if (tEncodeI8(&encoder, pRsp->walLevel) < 0) return -1;
if (tEncodeI8(&encoder, pRsp->precision) < 0) return -1; if (tEncodeI8(&encoder, pRsp->precision) < 0) return -1;
if (tEncodeI8(&encoder, pRsp->compression) < 0) return -1; if (tEncodeI8(&encoder, pRsp->compression) < 0) return -1;
if (tEncodeI8(&encoder, pRsp->replications) < 0) return -1; if (tEncodeI8(&encoder, pRsp->replications) < 0) return -1;
if (tEncodeI8(&encoder, pRsp->strict) < 0) return -1; if (tEncodeI8(&encoder, pRsp->strict) < 0) return -1;
if (tEncodeI8(&encoder, pRsp->update) < 0) return -1;
if (tEncodeI8(&encoder, pRsp->cacheLastRow) < 0) return -1; if (tEncodeI8(&encoder, pRsp->cacheLastRow) < 0) return -1;
if (tEncodeI8(&encoder, pRsp->streamMode) < 0) return -1;
if (tEncodeI32(&encoder, pRsp->numOfRetensions) < 0) return -1; if (tEncodeI32(&encoder, pRsp->numOfRetensions) < 0) return -1;
for (int32_t i = 0; i < pRsp->numOfRetensions; ++i) { for (int32_t i = 0; i < pRsp->numOfRetensions; ++i) {
SRetention *pRetension = taosArrayGet(pRsp->pRetensions, i); SRetention *pRetension = taosArrayGet(pRsp->pRetensions, i);
...@@ -2192,24 +2191,23 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) { ...@@ -2192,24 +2191,23 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) {
if (tStartDecode(&decoder) < 0) return -1; if (tStartDecode(&decoder) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->numOfVgroups) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->numOfVgroups) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->cacheBlockSize) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->numOfStables) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->totalBlocks) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->buffer) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->pageSize) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->pages) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->daysPerFile) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->daysPerFile) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->daysToKeep0) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->daysToKeep0) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->daysToKeep1) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->daysToKeep1) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->daysToKeep2) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->daysToKeep2) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->minRows) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->minRows) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->maxRows) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->maxRows) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->commitTime) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->fsyncPeriod) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->fsyncPeriod) < 0) return -1;
if (tDecodeI8(&decoder, &pRsp->walLevel) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->walLevel) < 0) return -1;
if (tDecodeI8(&decoder, &pRsp->precision) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->precision) < 0) return -1;
if (tDecodeI8(&decoder, &pRsp->compression) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->compression) < 0) return -1;
if (tDecodeI8(&decoder, &pRsp->replications) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->replications) < 0) return -1;
if (tDecodeI8(&decoder, &pRsp->strict) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->strict) < 0) return -1;
if (tDecodeI8(&decoder, &pRsp->update) < 0) return -1;
if (tDecodeI8(&decoder, &pRsp->cacheLastRow) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->cacheLastRow) < 0) return -1;
if (tDecodeI8(&decoder, &pRsp->streamMode) < 0) return -1;
if (tDecodeI32(&decoder, &pRsp->numOfRetensions) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->numOfRetensions) < 0) return -1;
pRsp->pRetensions = taosArrayInit(pRsp->numOfRetensions, sizeof(SRetention)); pRsp->pRetensions = taosArrayInit(pRsp->numOfRetensions, sizeof(SRetention));
if (pRsp->pRetensions == NULL) { if (pRsp->pRetensions == NULL) {
...@@ -2368,7 +2366,6 @@ static int32_t tEncodeSTableMetaRsp(SCoder *pEncoder, STableMetaRsp *pRsp) { ...@@ -2368,7 +2366,6 @@ static int32_t tEncodeSTableMetaRsp(SCoder *pEncoder, STableMetaRsp *pRsp) {
if (tEncodeI32(pEncoder, pRsp->numOfColumns) < 0) return -1; if (tEncodeI32(pEncoder, pRsp->numOfColumns) < 0) return -1;
if (tEncodeI8(pEncoder, pRsp->precision) < 0) return -1; if (tEncodeI8(pEncoder, pRsp->precision) < 0) return -1;
if (tEncodeI8(pEncoder, pRsp->tableType) < 0) return -1; if (tEncodeI8(pEncoder, pRsp->tableType) < 0) return -1;
if (tEncodeI8(pEncoder, pRsp->update) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->sversion) < 0) return -1; if (tEncodeI32(pEncoder, pRsp->sversion) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->tversion) < 0) return -1; if (tEncodeI32(pEncoder, pRsp->tversion) < 0) return -1;
if (tEncodeU64(pEncoder, pRsp->suid) < 0) return -1; if (tEncodeU64(pEncoder, pRsp->suid) < 0) return -1;
...@@ -2391,7 +2388,6 @@ static int32_t tDecodeSTableMetaRsp(SCoder *pDecoder, STableMetaRsp *pRsp) { ...@@ -2391,7 +2388,6 @@ static int32_t tDecodeSTableMetaRsp(SCoder *pDecoder, STableMetaRsp *pRsp) {
if (tDecodeI32(pDecoder, &pRsp->numOfColumns) < 0) return -1; if (tDecodeI32(pDecoder, &pRsp->numOfColumns) < 0) return -1;
if (tDecodeI8(pDecoder, &pRsp->precision) < 0) return -1; if (tDecodeI8(pDecoder, &pRsp->precision) < 0) return -1;
if (tDecodeI8(pDecoder, &pRsp->tableType) < 0) return -1; if (tDecodeI8(pDecoder, &pRsp->tableType) < 0) return -1;
if (tDecodeI8(pDecoder, &pRsp->update) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->sversion) < 0) return -1; if (tDecodeI32(pDecoder, &pRsp->sversion) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->tversion) < 0) return -1; if (tDecodeI32(pDecoder, &pRsp->tversion) < 0) return -1;
if (tDecodeU64(pDecoder, &pRsp->suid) < 0) return -1; if (tDecodeU64(pDecoder, &pRsp->suid) < 0) return -1;
...@@ -2811,15 +2807,16 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR ...@@ -2811,15 +2807,16 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1; if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1; if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1;
if (tEncodeI32(&encoder, pReq->vgVersion) < 0) return -1; if (tEncodeI32(&encoder, pReq->vgVersion) < 0) return -1;
if (tEncodeI32(&encoder, pReq->cacheBlockSize) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfStables) < 0) return -1;
if (tEncodeI32(&encoder, pReq->totalBlocks) < 0) return -1; if (tEncodeI32(&encoder, pReq->buffer) < 0) return -1;
if (tEncodeI32(&encoder, pReq->pageSize) < 0) return -1;
if (tEncodeI32(&encoder, pReq->pages) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysPerFile) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysPerFile) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1;
if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1; if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1;
if (tEncodeI32(&encoder, pReq->maxRows) < 0) return -1; if (tEncodeI32(&encoder, pReq->maxRows) < 0) return -1;
if (tEncodeI32(&encoder, pReq->commitTime) < 0) return -1;
if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1; if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1;
if (tEncodeU32(&encoder, pReq->hashBegin) < 0) return -1; if (tEncodeU32(&encoder, pReq->hashBegin) < 0) return -1;
if (tEncodeU32(&encoder, pReq->hashEnd) < 0) return -1; if (tEncodeU32(&encoder, pReq->hashEnd) < 0) return -1;
...@@ -2828,11 +2825,9 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR ...@@ -2828,11 +2825,9 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
if (tEncodeI8(&encoder, pReq->precision) < 0) return -1; if (tEncodeI8(&encoder, pReq->precision) < 0) return -1;
if (tEncodeI8(&encoder, pReq->compression) < 0) return -1; if (tEncodeI8(&encoder, pReq->compression) < 0) return -1;
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1; if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
if (tEncodeI8(&encoder, pReq->update) < 0) return -1;
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1; if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
if (tEncodeI8(&encoder, pReq->replica) < 0) return -1; if (tEncodeI8(&encoder, pReq->replica) < 0) return -1;
if (tEncodeI8(&encoder, pReq->selfIndex) < 0) return -1; if (tEncodeI8(&encoder, pReq->selfIndex) < 0) return -1;
if (tEncodeI8(&encoder, pReq->streamMode) < 0) return -1;
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
SReplica *pReplica = &pReq->replicas[i]; SReplica *pReplica = &pReq->replicas[i];
if (tEncodeSReplica(&encoder, pReplica) < 0) return -1; if (tEncodeSReplica(&encoder, pReplica) < 0) return -1;
...@@ -2862,15 +2857,16 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq * ...@@ -2862,15 +2857,16 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1; if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->vgVersion) < 0) return -1; if (tDecodeI32(&decoder, &pReq->vgVersion) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->cacheBlockSize) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfStables) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->totalBlocks) < 0) return -1; if (tDecodeI32(&decoder, &pReq->buffer) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->pageSize) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->pages) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysPerFile) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysPerFile) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->minRows) < 0) return -1; if (tDecodeI32(&decoder, &pReq->minRows) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->maxRows) < 0) return -1; if (tDecodeI32(&decoder, &pReq->maxRows) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->commitTime) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1; if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1;
if (tDecodeU32(&decoder, &pReq->hashBegin) < 0) return -1; if (tDecodeU32(&decoder, &pReq->hashBegin) < 0) return -1;
if (tDecodeU32(&decoder, &pReq->hashEnd) < 0) return -1; if (tDecodeU32(&decoder, &pReq->hashEnd) < 0) return -1;
...@@ -2879,11 +2875,9 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq * ...@@ -2879,11 +2875,9 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
if (tDecodeI8(&decoder, &pReq->precision) < 0) return -1; if (tDecodeI8(&decoder, &pReq->precision) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->compression) < 0) return -1; if (tDecodeI8(&decoder, &pReq->compression) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1; if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->update) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1; if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->replica) < 0) return -1; if (tDecodeI8(&decoder, &pReq->replica) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->selfIndex) < 0) return -1; if (tDecodeI8(&decoder, &pReq->selfIndex) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->streamMode) < 0) return -1;
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
SReplica *pReplica = &pReq->replicas[i]; SReplica *pReplica = &pReq->replicas[i];
if (tDecodeSReplica(&decoder, pReplica) < 0) return -1; if (tDecodeSReplica(&decoder, pReplica) < 0) return -1;
...@@ -2983,10 +2977,14 @@ int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq ...@@ -2983,10 +2977,14 @@ int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq
if (tStartEncode(&encoder) < 0) return -1; if (tStartEncode(&encoder) < 0) return -1;
if (tEncodeI32(&encoder, pReq->vgVersion) < 0) return -1; if (tEncodeI32(&encoder, pReq->vgVersion) < 0) return -1;
if (tEncodeI32(&encoder, pReq->totalBlocks) < 0) return -1; if (tEncodeI32(&encoder, pReq->buffer) < 0) return -1;
if (tEncodeI32(&encoder, pReq->pageSize) < 0) return -1;
if (tEncodeI32(&encoder, pReq->pages) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysPerFile) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1;
if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1; if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1;
if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1;
if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1; if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1;
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1; if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1; if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
...@@ -3010,10 +3008,14 @@ int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pR ...@@ -3010,10 +3008,14 @@ int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pR
if (tStartDecode(&decoder) < 0) return -1; if (tStartDecode(&decoder) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->vgVersion) < 0) return -1; if (tDecodeI32(&decoder, &pReq->vgVersion) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->totalBlocks) < 0) return -1; if (tDecodeI32(&decoder, &pReq->buffer) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->pageSize) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->pages) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysPerFile) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1; if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1; if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1; if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1; if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
......
...@@ -107,13 +107,11 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { ...@@ -107,13 +107,11 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pCfg->vgId = pCreate->vgId; pCfg->vgId = pCreate->vgId;
strcpy(pCfg->dbname, pCreate->db); strcpy(pCfg->dbname, pCreate->db);
// pCfg->szBuf = pCreate->cacheBlockSize * 1024 * 1024;
pCfg->streamMode = pCreate->streamMode;
pCfg->isWeak = true; pCfg->isWeak = true;
pCfg->tsdbCfg.days = 10; pCfg->tsdbCfg.days = 10;
pCfg->tsdbCfg.keep2 = 3650; // pCreate->daysToKeep0; pCfg->tsdbCfg.keep2 = 3650;
pCfg->tsdbCfg.keep0 = 3650; // pCreate->daysToKeep2; pCfg->tsdbCfg.keep0 = 3650;
pCfg->tsdbCfg.keep1 = 3650; // pCreate->daysToKeep0; pCfg->tsdbCfg.keep1 = 3650;
pCfg->tsdbCfg.retentions = pCreate->pRetensions; pCfg->tsdbCfg.retentions = pCreate->pRetensions;
pCfg->walCfg.vgId = pCreate->vgId; pCfg->walCfg.vgId = pCreate->vgId;
pCfg->hashBegin = pCreate->hashBegin; pCfg->hashBegin = pCreate->hashBegin;
......
...@@ -33,22 +33,18 @@ TEST_F(DndTestVnode, 01_Create_Vnode) { ...@@ -33,22 +33,18 @@ TEST_F(DndTestVnode, 01_Create_Vnode) {
strcpy(createReq.db, "1.d1"); strcpy(createReq.db, "1.d1");
createReq.dbUid = 9527; createReq.dbUid = 9527;
createReq.vgVersion = 1; createReq.vgVersion = 1;
createReq.cacheBlockSize = 16;
createReq.totalBlocks = 10;
createReq.daysPerFile = 10; createReq.daysPerFile = 10;
createReq.daysToKeep0 = 3650; createReq.daysToKeep0 = 3650;
createReq.daysToKeep1 = 3650; createReq.daysToKeep1 = 3650;
createReq.daysToKeep2 = 3650; createReq.daysToKeep2 = 3650;
createReq.minRows = 100; createReq.minRows = 100;
createReq.minRows = 4096; createReq.minRows = 4096;
createReq.commitTime = 3600;
createReq.fsyncPeriod = 3000; createReq.fsyncPeriod = 3000;
createReq.walLevel = 1; createReq.walLevel = 1;
createReq.precision = 0; createReq.precision = 0;
createReq.compression = 2; createReq.compression = 2;
createReq.replica = 1; createReq.replica = 1;
createReq.strict = 1; createReq.strict = 1;
createReq.update = 0;
createReq.cacheLastRow = 0; createReq.cacheLastRow = 0;
createReq.selfIndex = 0; createReq.selfIndex = 0;
for (int r = 0; r < createReq.replica; ++r) { for (int r = 0; r < createReq.replica; ++r) {
...@@ -75,27 +71,15 @@ TEST_F(DndTestVnode, 01_Create_Vnode) { ...@@ -75,27 +71,15 @@ TEST_F(DndTestVnode, 01_Create_Vnode) {
TEST_F(DndTestVnode, 02_Alter_Vnode) { TEST_F(DndTestVnode, 02_Alter_Vnode) {
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
SAlterVnodeReq alterReq = {0}; SAlterVnodeReq alterReq = {0};
alterReq.vgId = 2;
alterReq.dnodeId = 1;
strcpy(alterReq.db, "1.d1");
alterReq.dbUid = 9527;
alterReq.vgVersion = 2; alterReq.vgVersion = 2;
alterReq.cacheBlockSize = 16;
alterReq.totalBlocks = 10;
alterReq.daysPerFile = 10; alterReq.daysPerFile = 10;
alterReq.daysToKeep0 = 3650; alterReq.daysToKeep0 = 3650;
alterReq.daysToKeep1 = 3650; alterReq.daysToKeep1 = 3650;
alterReq.daysToKeep2 = 3650; alterReq.daysToKeep2 = 3650;
alterReq.minRows = 100;
alterReq.minRows = 4096;
alterReq.commitTime = 3600;
alterReq.fsyncPeriod = 3000; alterReq.fsyncPeriod = 3000;
alterReq.walLevel = 1; alterReq.walLevel = 1;
alterReq.precision = 0;
alterReq.compression = 2;
alterReq.replica = 1; alterReq.replica = 1;
alterReq.strict = 1; alterReq.strict = 1;
alterReq.update = 0;
alterReq.cacheLastRow = 0; alterReq.cacheLastRow = 0;
alterReq.selfIndex = 0; alterReq.selfIndex = 0;
for (int r = 0; r < alterReq.replica; ++r) { for (int r = 0; r < alterReq.replica; ++r) {
......
...@@ -257,26 +257,23 @@ typedef struct { ...@@ -257,26 +257,23 @@ typedef struct {
typedef struct { typedef struct {
int32_t numOfVgroups; int32_t numOfVgroups;
int32_t cacheBlockSize; int32_t numOfStables;
int32_t totalBlocks; int32_t buffer;
int32_t pageSize;
int32_t pages;
int32_t daysPerFile; int32_t daysPerFile;
int32_t daysToKeep0; int32_t daysToKeep0;
int32_t daysToKeep1; int32_t daysToKeep1;
int32_t daysToKeep2; int32_t daysToKeep2;
int32_t minRows; int32_t minRows;
int32_t maxRows; int32_t maxRows;
int32_t commitTime;
int32_t fsyncPeriod; int32_t fsyncPeriod;
int32_t ttl;
int8_t walLevel; int8_t walLevel;
int8_t precision; int8_t precision;
int8_t compression; int8_t compression;
int8_t replications; int8_t replications;
int8_t strict; int8_t strict;
int8_t update;
int8_t cacheLastRow; int8_t cacheLastRow;
int8_t streamMode;
int8_t singleSTable;
int8_t hashMethod; // default is 1 int8_t hashMethod; // default is 1
int32_t numOfRetensions; int32_t numOfRetensions;
SArray* pRetensions; SArray* pRetensions;
...@@ -316,7 +313,6 @@ typedef struct { ...@@ -316,7 +313,6 @@ typedef struct {
int64_t pointsWritten; int64_t pointsWritten;
int8_t compact; int8_t compact;
int8_t replica; int8_t replica;
int8_t streamMode;
SVnodeGid vnodeGid[TSDB_MAX_REPLICA]; SVnodeGid vnodeGid[TSDB_MAX_REPLICA];
} SVgObj; } SVgObj;
......
...@@ -29,6 +29,7 @@ void mndReleaseStb(SMnode *pMnode, SStbObj *pStb); ...@@ -29,6 +29,7 @@ void mndReleaseStb(SMnode *pMnode, SStbObj *pStb);
SSdbRaw *mndStbActionEncode(SStbObj *pStb); SSdbRaw *mndStbActionEncode(SStbObj *pStb);
int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *pStbs, int32_t numOfStbs, void **ppRsp, int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *pStbs, int32_t numOfStbs, void **ppRsp,
int32_t *pRspLen); int32_t *pRspLen);
int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -84,26 +84,23 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) { ...@@ -84,26 +84,23 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
SDB_SET_INT32(pRaw, dataPos, pDb->cfgVersion, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfgVersion, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->vgVersion, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->vgVersion, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfVgroups, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfVgroups, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.cacheBlockSize, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfStables, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.totalBlocks, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.buffer, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.pageSize, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.pages, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysPerFile, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysPerFile, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep0, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep0, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep1, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep1, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep2, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep2, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.minRows, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.minRows, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.maxRows, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.maxRows, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.commitTime, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.fsyncPeriod, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.fsyncPeriod, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.ttl, _OVER)
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.walLevel, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.walLevel, _OVER)
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.precision, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.precision, _OVER)
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.compression, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.compression, _OVER)
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.replications, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.replications, _OVER)
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.strict, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.strict, _OVER)
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.update, _OVER)
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.cacheLastRow, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.cacheLastRow, _OVER)
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.streamMode, _OVER)
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.singleSTable, _OVER)
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.hashMethod, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.hashMethod, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfRetensions, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfRetensions, _OVER)
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) { for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
...@@ -158,26 +155,23 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { ...@@ -158,26 +155,23 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32(pRaw, dataPos, &pDb->cfgVersion, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfgVersion, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->vgVersion, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->vgVersion, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfVgroups, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfVgroups, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.cacheBlockSize, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfStables, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.totalBlocks, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.buffer, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.pageSize, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.pages, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysPerFile, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysPerFile, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep0, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep0, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep1, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep1, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep2, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep2, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.minRows, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.minRows, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.maxRows, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.maxRows, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.commitTime, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.fsyncPeriod, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.fsyncPeriod, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.ttl, _OVER)
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.walLevel, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.walLevel, _OVER)
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.precision, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.precision, _OVER)
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.compression, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.compression, _OVER)
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.replications, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.replications, _OVER)
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.strict, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.strict, _OVER)
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.update, _OVER)
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.cacheLastRow, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.cacheLastRow, _OVER)
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.streamMode, _OVER)
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.singleSTable, _OVER)
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.hashMethod, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.hashMethod, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfRetensions, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfRetensions, _OVER)
if (pDb->cfg.numOfRetensions > 0) { if (pDb->cfg.numOfRetensions > 0) {
...@@ -268,10 +262,10 @@ static int32_t mndCheckDbName(const char *dbName, SUserObj *pUser) { ...@@ -268,10 +262,10 @@ static int32_t mndCheckDbName(const char *dbName, SUserObj *pUser) {
static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) { 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->numOfVgroups < TSDB_MIN_VNODES_PER_DB || pCfg->numOfVgroups > TSDB_MAX_VNODES_PER_DB) return -1;
/* if (pCfg->numOfStables < TSDB_DB_STREAM_MODE_OFF || pCfg->numOfStables > TSDB_DB_STREAM_MODE_ON) return -1;
if (pCfg->cacheBlockSize < TSDB_MIN_CACHE_BLOCK_SIZE || pCfg->cacheBlockSize > TSDB_MAX_CACHE_BLOCK_SIZE) return -1; if (pCfg->buffer < TSDB_MIN_BUFFER_PER_VNODE || pCfg->buffer > TSDB_MAX_BUFFER_PER_VNODE) return -1;
if (pCfg->totalBlocks < TSDB_MIN_TOTAL_BLOCKS || pCfg->totalBlocks > TSDB_MAX_TOTAL_BLOCKS) return -1; if (pCfg->pageSize < TSDB_MIN_PAGESIZE_PER_VNODE || pCfg->pageSize > TSDB_MAX_PAGESIZE_PER_VNODE) return -1;
*/ if (pCfg->pages < TSDB_MIN_PAGES_PER_VNODE || pCfg->pages > TSDB_MAX_PAGES_PER_VNODE) return -1;
if (pCfg->daysPerFile < TSDB_MIN_DAYS_PER_FILE || pCfg->daysPerFile > TSDB_MAX_DAYS_PER_FILE) return -1; if (pCfg->daysPerFile < TSDB_MIN_DAYS_PER_FILE || pCfg->daysPerFile > TSDB_MAX_DAYS_PER_FILE) return -1;
if (pCfg->daysToKeep0 < TSDB_MIN_KEEP || pCfg->daysToKeep0 > TSDB_MAX_KEEP) return -1; if (pCfg->daysToKeep0 < TSDB_MIN_KEEP || pCfg->daysToKeep0 > TSDB_MAX_KEEP) return -1;
if (pCfg->daysToKeep1 < TSDB_MIN_KEEP || pCfg->daysToKeep1 > TSDB_MAX_KEEP) return -1; if (pCfg->daysToKeep1 < TSDB_MIN_KEEP || pCfg->daysToKeep1 > TSDB_MAX_KEEP) return -1;
...@@ -282,9 +276,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) { ...@@ -282,9 +276,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
if (pCfg->minRows < TSDB_MIN_MINROWS_FBLOCK || pCfg->minRows > TSDB_MAX_MINROWS_FBLOCK) return -1; if (pCfg->minRows < TSDB_MIN_MINROWS_FBLOCK || pCfg->minRows > TSDB_MAX_MINROWS_FBLOCK) return -1;
if (pCfg->maxRows < TSDB_MIN_MAXROWS_FBLOCK || pCfg->maxRows > TSDB_MAX_MAXROWS_FBLOCK) return -1; if (pCfg->maxRows < TSDB_MIN_MAXROWS_FBLOCK || pCfg->maxRows > TSDB_MAX_MAXROWS_FBLOCK) return -1;
if (pCfg->minRows > pCfg->maxRows) return -1; if (pCfg->minRows > pCfg->maxRows) return -1;
if (pCfg->commitTime < TSDB_MIN_COMMIT_TIME || pCfg->commitTime > TSDB_MAX_COMMIT_TIME) return -1;
if (pCfg->fsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pCfg->fsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1; if (pCfg->fsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pCfg->fsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1;
// if (pCfg->ttl < TSDB_MIN_TABLE_TTL) return -1;
if (pCfg->walLevel < TSDB_MIN_WAL_LEVEL || pCfg->walLevel > TSDB_MAX_WAL_LEVEL) return -1; if (pCfg->walLevel < TSDB_MIN_WAL_LEVEL || pCfg->walLevel > TSDB_MAX_WAL_LEVEL) return -1;
if (pCfg->precision < TSDB_MIN_PRECISION && pCfg->precision > TSDB_MAX_PRECISION) return -1; if (pCfg->precision < TSDB_MIN_PRECISION && pCfg->precision > TSDB_MAX_PRECISION) return -1;
if (pCfg->compression < TSDB_MIN_COMP_LEVEL || pCfg->compression > TSDB_MAX_COMP_LEVEL) return -1; if (pCfg->compression < TSDB_MIN_COMP_LEVEL || pCfg->compression > TSDB_MAX_COMP_LEVEL) return -1;
...@@ -292,36 +284,30 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) { ...@@ -292,36 +284,30 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
if (pCfg->replications > mndGetDnodeSize(pMnode)) return -1; if (pCfg->replications > mndGetDnodeSize(pMnode)) return -1;
if (pCfg->strict < TSDB_DB_STRICT_OFF || pCfg->strict > TSDB_DB_STRICT_ON) return -1; if (pCfg->strict < TSDB_DB_STRICT_OFF || pCfg->strict > TSDB_DB_STRICT_ON) return -1;
if (pCfg->strict > pCfg->replications) return -1; if (pCfg->strict > pCfg->replications) return -1;
if (pCfg->update < TSDB_MIN_DB_UPDATE || pCfg->update > TSDB_MAX_DB_UPDATE) return -1;
if (pCfg->cacheLastRow < TSDB_MIN_DB_CACHE_LAST_ROW || pCfg->cacheLastRow > TSDB_MAX_DB_CACHE_LAST_ROW) return -1; if (pCfg->cacheLastRow < TSDB_MIN_DB_CACHE_LAST_ROW || pCfg->cacheLastRow > TSDB_MAX_DB_CACHE_LAST_ROW) return -1;
if (pCfg->streamMode < TSDB_DB_STREAM_MODE_OFF || pCfg->streamMode > TSDB_DB_STREAM_MODE_ON) return -1;
if (pCfg->singleSTable < TSDB_DB_SINGLE_STABLE_ON || pCfg->streamMode > TSDB_DB_SINGLE_STABLE_OFF) return -1;
if (pCfg->hashMethod != 1) return -1; if (pCfg->hashMethod != 1) return -1;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static void mndSetDefaultDbCfg(SDbCfg *pCfg) { static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
if (pCfg->numOfVgroups < 0) pCfg->numOfVgroups = TSDB_DEFAULT_VN_PER_DB; if (pCfg->numOfVgroups < 0) pCfg->numOfVgroups = TSDB_DEFAULT_VN_PER_DB;
if (pCfg->cacheBlockSize < 0) pCfg->cacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE; if (pCfg->numOfStables < 0) pCfg->numOfStables = TSDB_DEFAULT_DB_SINGLE_STABLE;
if (pCfg->totalBlocks < 0) pCfg->totalBlocks = TSDB_DEFAULT_TOTAL_BLOCKS; if (pCfg->buffer < 0) pCfg->buffer = TSDB_DEFAULT_BUFFER_PER_VNODE;
if (pCfg->daysPerFile < 0) pCfg->daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE; if (pCfg->pageSize < 0) pCfg->pageSize = TSDB_DEFAULT_PAGES_PER_VNODE;
if (pCfg->pages < 0) pCfg->pages = TSDB_MAX_PAGESIZE_PER_VNODE;
if (pCfg->daysPerFile < 0) pCfg->daysPerFile = TSDB_DEFAULT_DURATION_PER_FILE;
if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP; if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP;
if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep0; if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep0;
if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = pCfg->daysToKeep1; if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = pCfg->daysToKeep1;
if (pCfg->minRows < 0) pCfg->minRows = TSDB_DEFAULT_MINROWS_FBLOCK; if (pCfg->minRows < 0) pCfg->minRows = TSDB_DEFAULT_MINROWS_FBLOCK;
if (pCfg->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAXROWS_FBLOCK; if (pCfg->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAXROWS_FBLOCK;
if (pCfg->commitTime < 0) pCfg->commitTime = TSDB_DEFAULT_COMMIT_TIME;
if (pCfg->fsyncPeriod < 0) pCfg->fsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD; if (pCfg->fsyncPeriod < 0) pCfg->fsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD;
if (pCfg->ttl < 0) pCfg->ttl = TSDB_DEFAULT_TABLE_TTL;
if (pCfg->walLevel < 0) pCfg->walLevel = TSDB_DEFAULT_WAL_LEVEL; if (pCfg->walLevel < 0) pCfg->walLevel = TSDB_DEFAULT_WAL_LEVEL;
if (pCfg->precision < 0) pCfg->precision = TSDB_DEFAULT_PRECISION; if (pCfg->precision < 0) pCfg->precision = TSDB_DEFAULT_PRECISION;
if (pCfg->compression < 0) pCfg->compression = TSDB_DEFAULT_COMP_LEVEL; if (pCfg->compression < 0) pCfg->compression = TSDB_DEFAULT_COMP_LEVEL;
if (pCfg->replications < 0) pCfg->replications = TSDB_DEFAULT_DB_REPLICA; if (pCfg->replications < 0) pCfg->replications = TSDB_DEFAULT_DB_REPLICA;
if (pCfg->strict < 0) pCfg->strict = TSDB_DEFAULT_DB_STRICT; if (pCfg->strict < 0) pCfg->strict = TSDB_DEFAULT_DB_STRICT;
if (pCfg->update < 0) pCfg->update = TSDB_DEFAULT_DB_UPDATE;
if (pCfg->cacheLastRow < 0) pCfg->cacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW; if (pCfg->cacheLastRow < 0) pCfg->cacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW;
if (pCfg->streamMode < 0) pCfg->streamMode = TSDB_DEFAULT_DB_STREAM_MODE;
if (pCfg->singleSTable < 0) pCfg->singleSTable = TSDB_DEFAULT_DB_SINGLE_STABLE;
if (pCfg->numOfRetensions < 0) pCfg->numOfRetensions = 0; if (pCfg->numOfRetensions < 0) pCfg->numOfRetensions = 0;
} }
...@@ -447,26 +433,23 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate ...@@ -447,26 +433,23 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
memcpy(dbObj.createUser, pUser->user, TSDB_USER_LEN); memcpy(dbObj.createUser, pUser->user, TSDB_USER_LEN);
dbObj.cfg = (SDbCfg){ dbObj.cfg = (SDbCfg){
.numOfVgroups = pCreate->numOfVgroups, .numOfVgroups = pCreate->numOfVgroups,
.cacheBlockSize = pCreate->cacheBlockSize, .numOfStables = pCreate->numOfStables,
.totalBlocks = pCreate->totalBlocks, .buffer = pCreate->buffer,
.pageSize = pCreate->pageSize,
.pages = pCreate->pages,
.daysPerFile = pCreate->daysPerFile, .daysPerFile = pCreate->daysPerFile,
.daysToKeep0 = pCreate->daysToKeep0, .daysToKeep0 = pCreate->daysToKeep0,
.daysToKeep1 = pCreate->daysToKeep1, .daysToKeep1 = pCreate->daysToKeep1,
.daysToKeep2 = pCreate->daysToKeep2, .daysToKeep2 = pCreate->daysToKeep2,
.minRows = pCreate->minRows, .minRows = pCreate->minRows,
.maxRows = pCreate->maxRows, .maxRows = pCreate->maxRows,
.commitTime = pCreate->commitTime,
.fsyncPeriod = pCreate->fsyncPeriod, .fsyncPeriod = pCreate->fsyncPeriod,
.ttl = pCreate->ttl,
.walLevel = pCreate->walLevel, .walLevel = pCreate->walLevel,
.precision = pCreate->precision, .precision = pCreate->precision,
.compression = pCreate->compression, .compression = pCreate->compression,
.replications = pCreate->replications, .replications = pCreate->replications,
.strict = pCreate->strict, .strict = pCreate->strict,
.update = pCreate->update,
.cacheLastRow = pCreate->cacheLastRow, .cacheLastRow = pCreate->cacheLastRow,
.streamMode = pCreate->streamMode,
.singleSTable = pCreate->singleSTable,
.hashMethod = 1, .hashMethod = 1,
}; };
...@@ -570,8 +553,23 @@ _OVER: ...@@ -570,8 +553,23 @@ _OVER:
static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) { static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
terrno = TSDB_CODE_MND_DB_OPTION_UNCHANGED; terrno = TSDB_CODE_MND_DB_OPTION_UNCHANGED;
if (pAlter->totalBlocks >= 0 && pAlter->totalBlocks != pDb->cfg.totalBlocks) { if (pAlter->buffer >= 0 && pAlter->buffer != pDb->cfg.buffer) {
pDb->cfg.totalBlocks = pAlter->totalBlocks; pDb->cfg.buffer = pAlter->buffer;
terrno = 0;
}
if (pAlter->pages >= 0 && pAlter->pages != pDb->cfg.pages) {
pDb->cfg.pages = pAlter->pages;
terrno = 0;
}
if (pAlter->pageSize >= 0 && pAlter->pageSize != pDb->cfg.pageSize) {
pDb->cfg.pageSize = pAlter->pageSize;
terrno = 0;
}
if (pAlter->daysPerFile >= 0 && pAlter->daysPerFile != pDb->cfg.daysPerFile) {
pDb->cfg.daysPerFile = pAlter->daysPerFile;
terrno = 0; terrno = 0;
} }
...@@ -639,10 +637,14 @@ static int32_t mndSetAlterDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p ...@@ -639,10 +637,14 @@ static int32_t mndSetAlterDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
void *mndBuildAlterVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) { void *mndBuildAlterVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
SAlterVnodeReq alterReq = {0}; SAlterVnodeReq alterReq = {0};
alterReq.vgVersion = pVgroup->version; alterReq.vgVersion = pVgroup->version;
alterReq.totalBlocks = pDb->cfg.totalBlocks; alterReq.buffer = pDb->cfg.buffer;
alterReq.pages = pDb->cfg.pages;
alterReq.pageSize = pDb->cfg.pageSize;
alterReq.daysPerFile = pDb->cfg.daysPerFile;
alterReq.daysToKeep0 = pDb->cfg.daysToKeep0; alterReq.daysToKeep0 = pDb->cfg.daysToKeep0;
alterReq.daysToKeep1 = pDb->cfg.daysToKeep1; alterReq.daysToKeep1 = pDb->cfg.daysToKeep1;
alterReq.daysToKeep2 = pDb->cfg.daysToKeep2; alterReq.daysToKeep2 = pDb->cfg.daysToKeep2;
alterReq.fsyncPeriod = pDb->cfg.fsyncPeriod;
alterReq.walLevel = pDb->cfg.walLevel; alterReq.walLevel = pDb->cfg.walLevel;
alterReq.strict = pDb->cfg.strict; alterReq.strict = pDb->cfg.strict;
alterReq.cacheLastRow = pDb->cfg.cacheLastRow; alterReq.cacheLastRow = pDb->cfg.cacheLastRow;
...@@ -835,26 +837,23 @@ static int32_t mndProcessGetDbCfgReq(SNodeMsg *pReq) { ...@@ -835,26 +837,23 @@ static int32_t mndProcessGetDbCfgReq(SNodeMsg *pReq) {
} }
cfgRsp.numOfVgroups = pDb->cfg.numOfVgroups; cfgRsp.numOfVgroups = pDb->cfg.numOfVgroups;
cfgRsp.cacheBlockSize = pDb->cfg.cacheBlockSize; cfgRsp.numOfStables = pDb->cfg.numOfStables;
cfgRsp.totalBlocks = pDb->cfg.totalBlocks; cfgRsp.buffer = pDb->cfg.buffer;
cfgRsp.pageSize = pDb->cfg.pageSize;
cfgRsp.pages = pDb->cfg.pages;
cfgRsp.daysPerFile = pDb->cfg.daysPerFile; cfgRsp.daysPerFile = pDb->cfg.daysPerFile;
cfgRsp.daysToKeep0 = pDb->cfg.daysToKeep0; cfgRsp.daysToKeep0 = pDb->cfg.daysToKeep0;
cfgRsp.daysToKeep1 = pDb->cfg.daysToKeep1; cfgRsp.daysToKeep1 = pDb->cfg.daysToKeep1;
cfgRsp.daysToKeep2 = pDb->cfg.daysToKeep2; cfgRsp.daysToKeep2 = pDb->cfg.daysToKeep2;
cfgRsp.minRows = pDb->cfg.minRows; cfgRsp.minRows = pDb->cfg.minRows;
cfgRsp.maxRows = pDb->cfg.maxRows; cfgRsp.maxRows = pDb->cfg.maxRows;
cfgRsp.commitTime = pDb->cfg.commitTime;
cfgRsp.fsyncPeriod = pDb->cfg.fsyncPeriod; cfgRsp.fsyncPeriod = pDb->cfg.fsyncPeriod;
cfgRsp.ttl = pDb->cfg.ttl;
cfgRsp.walLevel = pDb->cfg.walLevel; cfgRsp.walLevel = pDb->cfg.walLevel;
cfgRsp.precision = pDb->cfg.precision; cfgRsp.precision = pDb->cfg.precision;
cfgRsp.compression = pDb->cfg.compression; cfgRsp.compression = pDb->cfg.compression;
cfgRsp.replications = pDb->cfg.replications; cfgRsp.replications = pDb->cfg.replications;
cfgRsp.strict = pDb->cfg.strict; cfgRsp.strict = pDb->cfg.strict;
cfgRsp.update = pDb->cfg.update;
cfgRsp.cacheLastRow = pDb->cfg.cacheLastRow; cfgRsp.cacheLastRow = pDb->cfg.cacheLastRow;
cfgRsp.streamMode = pDb->cfg.streamMode;
cfgRsp.singleSTable = pDb->cfg.singleSTable;
cfgRsp.numOfRetensions = pDb->cfg.numOfRetensions; cfgRsp.numOfRetensions = pDb->cfg.numOfRetensions;
cfgRsp.pRetensions = pDb->cfg.pRetensions; cfgRsp.pRetensions = pDb->cfg.pRetensions;
...@@ -1453,10 +1452,13 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in ...@@ -1453,10 +1452,13 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
colDataAppend(pColInfo, rows, (const char *)tmp, false); colDataAppend(pColInfo, rows, (const char *)tmp, false);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.cacheBlockSize, false); colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.buffer, false);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.pageSize, false);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.totalBlocks, false); colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.pages, false);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.minRows, false); colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.minRows, false);
...@@ -1498,13 +1500,7 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in ...@@ -1498,13 +1500,7 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
colDataAppend(pColInfo, rows, (const char *)t, false); colDataAppend(pColInfo, rows, (const char *)t, false);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.ttl, false); colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.numOfStables, false);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.singleSTable, false);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.streamMode, false);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
colDataAppend(pColInfo, rows, (const char *)b, false); colDataAppend(pColInfo, rows, (const char *)b, false);
...@@ -1522,7 +1518,6 @@ static void setInformationSchemaDbCfg(SDbObj *pDbObj) { ...@@ -1522,7 +1518,6 @@ static void setInformationSchemaDbCfg(SDbObj *pDbObj) {
pDbObj->cfg.numOfVgroups = 0; pDbObj->cfg.numOfVgroups = 0;
pDbObj->cfg.strict = 1; pDbObj->cfg.strict = 1;
pDbObj->cfg.replications = 1; pDbObj->cfg.replications = 1;
pDbObj->cfg.update = 1;
pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI; pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI;
} }
...@@ -1534,7 +1529,6 @@ static void setPerfSchemaDbCfg(SDbObj *pDbObj) { ...@@ -1534,7 +1529,6 @@ static void setPerfSchemaDbCfg(SDbObj *pDbObj) {
pDbObj->cfg.numOfVgroups = 0; pDbObj->cfg.numOfVgroups = 0;
pDbObj->cfg.strict = 1; pDbObj->cfg.strict = 1;
pDbObj->cfg.replications = 1; pDbObj->cfg.replications = 1;
pDbObj->cfg.update = 1;
pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI; pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI;
} }
......
...@@ -418,6 +418,9 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) { ...@@ -418,6 +418,9 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
if (tEncodeI32(pEncoder, pObj->version) < 0) return -1; if (tEncodeI32(pEncoder, pObj->version) < 0) return -1;
if (tEncodeI8(pEncoder, pObj->status) < 0) return -1; if (tEncodeI8(pEncoder, pObj->status) < 0) return -1;
if (tEncodeI8(pEncoder, pObj->createdBy) < 0) return -1; if (tEncodeI8(pEncoder, pObj->createdBy) < 0) return -1;
if (tEncodeI8(pEncoder, pObj->trigger) < 0) return -1;
if (tEncodeI32(pEncoder, pObj->triggerParam) < 0) return -1;
if (tEncodeI64(pEncoder, pObj->waterMark) < 0) return -1;
if (tEncodeI32(pEncoder, pObj->fixedSinkVgId) < 0) return -1; if (tEncodeI32(pEncoder, pObj->fixedSinkVgId) < 0) return -1;
if (tEncodeI64(pEncoder, pObj->smaId) < 0) return -1; if (tEncodeI64(pEncoder, pObj->smaId) < 0) return -1;
if (tEncodeCStr(pEncoder, pObj->sql) < 0) return -1; if (tEncodeCStr(pEncoder, pObj->sql) < 0) return -1;
...@@ -464,6 +467,9 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) { ...@@ -464,6 +467,9 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
if (tDecodeI32(pDecoder, &pObj->version) < 0) return -1; if (tDecodeI32(pDecoder, &pObj->version) < 0) return -1;
if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1; if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1;
if (tDecodeI8(pDecoder, &pObj->createdBy) < 0) return -1; if (tDecodeI8(pDecoder, &pObj->createdBy) < 0) return -1;
if (tDecodeI8(pDecoder, &pObj->trigger) < 0) return -1;
if (tDecodeI32(pDecoder, &pObj->triggerParam) < 0) return -1;
if (tDecodeI64(pDecoder, &pObj->waterMark) < 0) return -1;
if (tDecodeI32(pDecoder, &pObj->fixedSinkVgId) < 0) return -1; if (tDecodeI32(pDecoder, &pObj->fixedSinkVgId) < 0) return -1;
if (tDecodeI64(pDecoder, &pObj->smaId) < 0) return -1; if (tDecodeI64(pDecoder, &pObj->smaId) < 0) return -1;
if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1; if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1;
......
...@@ -76,10 +76,11 @@ static const SInfosTableSchema userDBSchema[] = { ...@@ -76,10 +76,11 @@ static const SInfosTableSchema userDBSchema[] = {
{.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, {.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
{.name = "replica", .bytes = 2, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "replica", .bytes = 2, .type = TSDB_DATA_TYPE_TINYINT},
{.name = "strict", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "strict", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "days", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "duration", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
{.name = "keep", .bytes = 24 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "keep", .bytes = 24 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "cache", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "buffer", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "pagesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
{.name = "pages", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
{.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
{.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
{.name = "wal", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "wal", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
...@@ -87,9 +88,7 @@ static const SInfosTableSchema userDBSchema[] = { ...@@ -87,9 +88,7 @@ static const SInfosTableSchema userDBSchema[] = {
{.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
{.name = "cachelast", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "cachelast", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
{.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "ttl", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
{.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
{.name = "stream_mode", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
// {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update // {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update
}; };
......
...@@ -774,6 +774,13 @@ static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) { ...@@ -774,6 +774,13 @@ static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) {
goto _OVER; goto _OVER;
} }
int32_t numOfStbs = -1;
mndGetNumOfStbs(pMnode, pDb->name, &numOfStbs);
if (pDb->cfg.numOfStables == 1 && numOfStbs != 0 ) {
terrno = TSDB_CODE_MND_SINGLE_STB_MODE_DB;
goto _OVER;
}
code = mndCreateStb(pMnode, pReq, &createReq, pDb); code = mndCreateStb(pMnode, pReq, &createReq, pDb);
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
...@@ -1427,7 +1434,6 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa ...@@ -1427,7 +1434,6 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
pRsp->numOfColumns = pStb->numOfColumns; pRsp->numOfColumns = pStb->numOfColumns;
pRsp->precision = pDb->cfg.precision; pRsp->precision = pDb->cfg.precision;
pRsp->tableType = TSDB_SUPER_TABLE; pRsp->tableType = TSDB_SUPER_TABLE;
pRsp->update = pDb->cfg.update;
pRsp->sversion = pStb->version; pRsp->sversion = pStb->version;
pRsp->suid = pStb->uid; pRsp->suid = pStb->uid;
pRsp->tuid = pStb->uid; pRsp->tuid = pStb->uid;
...@@ -1580,7 +1586,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *pStbVersions, int ...@@ -1580,7 +1586,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *pStbVersions, int
return 0; return 0;
} }
static int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs) { int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
SDbObj *pDb = mndAcquireDb(pMnode, dbName); SDbObj *pDb = mndAcquireDb(pMnode, dbName);
if (pDb == NULL) { if (pDb == NULL) {
......
...@@ -308,6 +308,8 @@ static int32_t mndCreateStream(SMnode *pMnode, SNodeMsg *pReq, SCMCreateStreamRe ...@@ -308,6 +308,8 @@ static int32_t mndCreateStream(SMnode *pMnode, SNodeMsg *pReq, SCMCreateStreamRe
streamObj.smaId = 0; streamObj.smaId = 0;
/*streamObj.physicalPlan = "";*/ /*streamObj.physicalPlan = "";*/
streamObj.logicalPlan = "not implemented"; streamObj.logicalPlan = "not implemented";
streamObj.trigger = pCreate->triggerType;
streamObj.waterMark = pCreate->watermark;
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_TYPE_CREATE_STREAM, &pReq->rpcMsg); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_TYPE_CREATE_STREAM, &pReq->rpcMsg);
if (pTrans == NULL) { if (pTrans == NULL) {
...@@ -431,7 +433,7 @@ static int32_t mndRetrieveStream(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p ...@@ -431,7 +433,7 @@ static int32_t mndRetrieveStream(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p
SStreamObj *pStream = NULL; SStreamObj *pStream = NULL;
while (numOfRows < rows) { while (numOfRows < rows) {
pShow->pIter = sdbFetch(pSdb, SDB_TOPIC, pShow->pIter, (void **)&pStream); pShow->pIter = sdbFetch(pSdb, SDB_STREAM, pShow->pIter, (void **)&pStream);
if (pShow->pIter == NULL) break; if (pShow->pIter == NULL) break;
SColumnInfoData *pColInfo; SColumnInfoData *pColInfo;
...@@ -471,8 +473,13 @@ static int32_t mndRetrieveStream(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p ...@@ -471,8 +473,13 @@ static int32_t mndRetrieveStream(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, numOfRows, (const char *)&pStream->trigger, false); colDataAppend(pColInfo, numOfRows, (const char *)&pStream->trigger, false);
numOfRows++;
sdbRelease(pSdb, pStream);
} }
return 0;
pShow->numOfRows += numOfRows;
return numOfRows;
} }
static void mndCancelGetNextStream(SMnode *pMnode, void *pIter) { static void mndCancelGetNextStream(SMnode *pMnode, void *pIter) {
......
...@@ -190,25 +190,24 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg ...@@ -190,25 +190,24 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
memcpy(createReq.db, pDb->name, TSDB_DB_FNAME_LEN); memcpy(createReq.db, pDb->name, TSDB_DB_FNAME_LEN);
createReq.dbUid = pDb->uid; createReq.dbUid = pDb->uid;
createReq.vgVersion = pVgroup->version; createReq.vgVersion = pVgroup->version;
createReq.cacheBlockSize = pDb->cfg.cacheBlockSize; createReq.numOfStables = pDb->cfg.numOfStables;
createReq.totalBlocks = pDb->cfg.totalBlocks; createReq.buffer = pDb->cfg.buffer;
createReq.pageSize = pDb->cfg.pageSize;
createReq.pages = pDb->cfg.pages;
createReq.daysPerFile = pDb->cfg.daysPerFile; createReq.daysPerFile = pDb->cfg.daysPerFile;
createReq.daysToKeep0 = pDb->cfg.daysToKeep0; createReq.daysToKeep0 = pDb->cfg.daysToKeep0;
createReq.daysToKeep1 = pDb->cfg.daysToKeep1; createReq.daysToKeep1 = pDb->cfg.daysToKeep1;
createReq.daysToKeep2 = pDb->cfg.daysToKeep2; createReq.daysToKeep2 = pDb->cfg.daysToKeep2;
createReq.minRows = pDb->cfg.minRows; createReq.minRows = pDb->cfg.minRows;
createReq.maxRows = pDb->cfg.maxRows; createReq.maxRows = pDb->cfg.maxRows;
createReq.commitTime = pDb->cfg.commitTime;
createReq.fsyncPeriod = pDb->cfg.fsyncPeriod; createReq.fsyncPeriod = pDb->cfg.fsyncPeriod;
createReq.walLevel = pDb->cfg.walLevel; createReq.walLevel = pDb->cfg.walLevel;
createReq.precision = pDb->cfg.precision; createReq.precision = pDb->cfg.precision;
createReq.compression = pDb->cfg.compression; createReq.compression = pDb->cfg.compression;
createReq.strict = pDb->cfg.strict; createReq.strict = pDb->cfg.strict;
createReq.update = pDb->cfg.update;
createReq.cacheLastRow = pDb->cfg.cacheLastRow; createReq.cacheLastRow = pDb->cfg.cacheLastRow;
createReq.replica = pVgroup->replica; createReq.replica = pVgroup->replica;
createReq.selfIndex = -1; createReq.selfIndex = -1;
createReq.streamMode = pVgroup->streamMode;
createReq.hashBegin = pVgroup->hashBegin; createReq.hashBegin = pVgroup->hashBegin;
createReq.hashEnd = pVgroup->hashEnd; createReq.hashEnd = pVgroup->hashEnd;
createReq.hashMethod = pDb->cfg.hashMethod; createReq.hashMethod = pDb->cfg.hashMethod;
...@@ -398,7 +397,6 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) { ...@@ -398,7 +397,6 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
pVgroup->createdTime = taosGetTimestampMs(); pVgroup->createdTime = taosGetTimestampMs();
pVgroup->updateTime = pVgroups->createdTime; pVgroup->updateTime = pVgroups->createdTime;
pVgroup->version = 1; pVgroup->version = 1;
pVgroup->streamMode = pDb->cfg.streamMode;
pVgroup->hashBegin = hashMin + hashInterval * v; pVgroup->hashBegin = hashMin + hashInterval * v;
if (v == pDb->cfg.numOfVgroups - 1) { if (v == pDb->cfg.numOfVgroups - 1) {
pVgroup->hashEnd = hashMax; pVgroup->hashEnd = hashMax;
......
...@@ -35,27 +35,24 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { ...@@ -35,27 +35,24 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
SCreateDbReq createReq = {0}; SCreateDbReq createReq = {0};
strcpy(createReq.db, "1.d1"); strcpy(createReq.db, "1.d1");
createReq.numOfVgroups = 2; createReq.numOfVgroups = 2;
createReq.cacheBlockSize = 16; createReq.buffer = -1;
createReq.totalBlocks = 10; createReq.pageSize = -1;
createReq.pages = -1;
createReq.daysPerFile = 1000; createReq.daysPerFile = 1000;
createReq.daysToKeep0 = 3650; createReq.daysToKeep0 = 3650;
createReq.daysToKeep1 = 3650; createReq.daysToKeep1 = 3650;
createReq.daysToKeep2 = 3650; createReq.daysToKeep2 = 3650;
createReq.minRows = 100; createReq.minRows = 100;
createReq.maxRows = 4096; createReq.maxRows = 4096;
createReq.commitTime = 3600;
createReq.fsyncPeriod = 3000; createReq.fsyncPeriod = 3000;
createReq.ttl = 1;
createReq.walLevel = 1; createReq.walLevel = 1;
createReq.precision = 0; createReq.precision = 0;
createReq.compression = 2; createReq.compression = 2;
createReq.replications = 1; createReq.replications = 1;
createReq.strict = 1; createReq.strict = 1;
createReq.update = 0;
createReq.cacheLastRow = 0; createReq.cacheLastRow = 0;
createReq.ignoreExist = 1; createReq.ignoreExist = 1;
createReq.streamMode = 0; createReq.numOfStables = 0;
createReq.singleSTable = 0;
createReq.numOfRetensions = 0; createReq.numOfRetensions = 0;
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
...@@ -76,7 +73,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { ...@@ -76,7 +73,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
{ {
SAlterDbReq alterdbReq = {0}; SAlterDbReq alterdbReq = {0};
strcpy(alterdbReq.db, "1.d1"); strcpy(alterdbReq.db, "1.d1");
alterdbReq.totalBlocks = 12; alterdbReq.buffer = 12;
alterdbReq.daysToKeep0 = 300; alterdbReq.daysToKeep0 = 300;
alterdbReq.daysToKeep1 = 400; alterdbReq.daysToKeep1 = 400;
alterdbReq.daysToKeep2 = 500; alterdbReq.daysToKeep2 = 500;
...@@ -129,27 +126,24 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { ...@@ -129,27 +126,24 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
SCreateDbReq createReq = {0}; SCreateDbReq createReq = {0};
strcpy(createReq.db, "1.d2"); strcpy(createReq.db, "1.d2");
createReq.numOfVgroups = 2; createReq.numOfVgroups = 2;
createReq.cacheBlockSize = 16; createReq.buffer = -1;
createReq.totalBlocks = 10; createReq.pageSize = -1;
createReq.pages = -1;
createReq.daysPerFile = 1000; createReq.daysPerFile = 1000;
createReq.daysToKeep0 = 3650; createReq.daysToKeep0 = 3650;
createReq.daysToKeep1 = 3650; createReq.daysToKeep1 = 3650;
createReq.daysToKeep2 = 3650; createReq.daysToKeep2 = 3650;
createReq.minRows = 100; createReq.minRows = 100;
createReq.maxRows = 4096; createReq.maxRows = 4096;
createReq.commitTime = 3600;
createReq.fsyncPeriod = 3000; createReq.fsyncPeriod = 3000;
createReq.ttl = 1;
createReq.walLevel = 1; createReq.walLevel = 1;
createReq.precision = 0; createReq.precision = 0;
createReq.compression = 2; createReq.compression = 2;
createReq.replications = 1; createReq.replications = 1;
createReq.strict = 1; createReq.strict = 1;
createReq.update = 0;
createReq.cacheLastRow = 0; createReq.cacheLastRow = 0;
createReq.ignoreExist = 1; createReq.ignoreExist = 1;
createReq.streamMode = 0; createReq.numOfStables = 0;
createReq.singleSTable = 0;
createReq.numOfRetensions = 0; createReq.numOfRetensions = 0;
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
......
...@@ -40,24 +40,22 @@ void* MndTestSma::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { ...@@ -40,24 +40,22 @@ void* MndTestSma::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
SCreateDbReq createReq = {0}; SCreateDbReq createReq = {0};
strcpy(createReq.db, dbname); strcpy(createReq.db, dbname);
createReq.numOfVgroups = 2; createReq.numOfVgroups = 2;
createReq.cacheBlockSize = 16; createReq.buffer = -1;
createReq.totalBlocks = 10; createReq.pageSize = -1;
createReq.pages = -1;
createReq.daysPerFile = 10 * 1440; createReq.daysPerFile = 10 * 1440;
createReq.daysToKeep0 = 3650 * 1440; createReq.daysToKeep0 = 3650 * 1440;
createReq.daysToKeep1 = 3650 * 1440; createReq.daysToKeep1 = 3650 * 1440;
createReq.daysToKeep2 = 3650 * 1440; createReq.daysToKeep2 = 3650 * 1440;
createReq.minRows = 100; createReq.minRows = 100;
createReq.maxRows = 4096; createReq.maxRows = 4096;
createReq.commitTime = 3600;
createReq.fsyncPeriod = 3000; createReq.fsyncPeriod = 3000;
createReq.walLevel = 1; createReq.walLevel = 1;
createReq.precision = 0; createReq.precision = 0;
createReq.compression = 2; createReq.compression = 2;
createReq.replications = 1; createReq.replications = 1;
createReq.strict = 1; createReq.strict = 1;
createReq.update = 0;
createReq.cacheLastRow = 0; createReq.cacheLastRow = 0;
createReq.ttl = 1;
createReq.ignoreExist = 1; createReq.ignoreExist = 1;
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
......
...@@ -41,24 +41,22 @@ void* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { ...@@ -41,24 +41,22 @@ void* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
SCreateDbReq createReq = {0}; SCreateDbReq createReq = {0};
strcpy(createReq.db, dbname); strcpy(createReq.db, dbname);
createReq.numOfVgroups = 2; createReq.numOfVgroups = 2;
createReq.cacheBlockSize = 16; createReq.buffer = -1;
createReq.totalBlocks = 10; createReq.pageSize = -1;
createReq.pages = -1;
createReq.daysPerFile = 1000; createReq.daysPerFile = 1000;
createReq.daysToKeep0 = 3650; createReq.daysToKeep0 = 3650;
createReq.daysToKeep1 = 3650; createReq.daysToKeep1 = 3650;
createReq.daysToKeep2 = 3650; createReq.daysToKeep2 = 3650;
createReq.minRows = 100; createReq.minRows = 100;
createReq.maxRows = 4096; createReq.maxRows = 4096;
createReq.commitTime = 3600;
createReq.fsyncPeriod = 3000; createReq.fsyncPeriod = 3000;
createReq.walLevel = 1; createReq.walLevel = 1;
createReq.precision = 0; createReq.precision = 0;
createReq.compression = 2; createReq.compression = 2;
createReq.replications = 1; createReq.replications = 1;
createReq.strict = 1; createReq.strict = 1;
createReq.update = 0;
createReq.cacheLastRow = 0; createReq.cacheLastRow = 0;
createReq.ttl = 1;
createReq.ignoreExist = 1; createReq.ignoreExist = 1;
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
...@@ -343,7 +341,6 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { ...@@ -343,7 +341,6 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
EXPECT_EQ(metaRsp.numOfTags, 3); EXPECT_EQ(metaRsp.numOfTags, 3);
EXPECT_EQ(metaRsp.precision, TSDB_TIME_PRECISION_MILLI); EXPECT_EQ(metaRsp.precision, TSDB_TIME_PRECISION_MILLI);
EXPECT_EQ(metaRsp.tableType, TSDB_SUPER_TABLE); EXPECT_EQ(metaRsp.tableType, TSDB_SUPER_TABLE);
EXPECT_EQ(metaRsp.update, 0);
EXPECT_EQ(metaRsp.sversion, 1); EXPECT_EQ(metaRsp.sversion, 1);
EXPECT_EQ(metaRsp.tversion, 0); EXPECT_EQ(metaRsp.tversion, 0);
EXPECT_GT(metaRsp.suid, 0); EXPECT_GT(metaRsp.suid, 0);
......
...@@ -33,24 +33,22 @@ void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { ...@@ -33,24 +33,22 @@ void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
SCreateDbReq createReq = {0}; SCreateDbReq createReq = {0};
strcpy(createReq.db, dbname); strcpy(createReq.db, dbname);
createReq.numOfVgroups = 2; createReq.numOfVgroups = 2;
createReq.cacheBlockSize = 16; createReq.buffer = -1;
createReq.totalBlocks = 10; createReq.pageSize = -1;
createReq.pages = -1;
createReq.daysPerFile = 10 * 1440; createReq.daysPerFile = 10 * 1440;
createReq.daysToKeep0 = 3650 * 1440; createReq.daysToKeep0 = 3650 * 1440;
createReq.daysToKeep1 = 3650 * 1440; createReq.daysToKeep1 = 3650 * 1440;
createReq.daysToKeep2 = 3650 * 1440; createReq.daysToKeep2 = 3650 * 1440;
createReq.minRows = 100; createReq.minRows = 100;
createReq.maxRows = 4096; createReq.maxRows = 4096;
createReq.commitTime = 3600;
createReq.fsyncPeriod = 3000; createReq.fsyncPeriod = 3000;
createReq.walLevel = 1; createReq.walLevel = 1;
createReq.precision = 0; createReq.precision = 0;
createReq.compression = 2; createReq.compression = 2;
createReq.replications = 1; createReq.replications = 1;
createReq.strict = 1; createReq.strict = 1;
createReq.update = 0;
createReq.cacheLastRow = 0; createReq.cacheLastRow = 0;
createReq.ttl = 1;
createReq.ignoreExist = 1; createReq.ignoreExist = 1;
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
......
...@@ -286,24 +286,22 @@ TEST_F(MndTestUser, 03_Alter_User) { ...@@ -286,24 +286,22 @@ TEST_F(MndTestUser, 03_Alter_User) {
SCreateDbReq createReq = {0}; SCreateDbReq createReq = {0};
strcpy(createReq.db, "1.d2"); strcpy(createReq.db, "1.d2");
createReq.numOfVgroups = 2; createReq.numOfVgroups = 2;
createReq.cacheBlockSize = 16; createReq.buffer = -1;
createReq.totalBlocks = 10; createReq.pageSize = -1;
createReq.pages = -1;
createReq.daysPerFile = 10 * 1440; createReq.daysPerFile = 10 * 1440;
createReq.daysToKeep0 = 3650 * 1440; createReq.daysToKeep0 = 3650 * 1440;
createReq.daysToKeep1 = 3650 * 1440; createReq.daysToKeep1 = 3650 * 1440;
createReq.daysToKeep2 = 3650 * 1440; createReq.daysToKeep2 = 3650 * 1440;
createReq.minRows = 100; createReq.minRows = 100;
createReq.maxRows = 4096; createReq.maxRows = 4096;
createReq.commitTime = 3600;
createReq.fsyncPeriod = 3000; createReq.fsyncPeriod = 3000;
createReq.walLevel = 1; createReq.walLevel = 1;
createReq.precision = 0; createReq.precision = 0;
createReq.compression = 2; createReq.compression = 2;
createReq.replications = 1; createReq.replications = 1;
createReq.strict = 1; createReq.strict = 1;
createReq.update = 0;
createReq.cacheLastRow = 0; createReq.cacheLastRow = 0;
createReq.ttl = 1;
createReq.ignoreExist = 1; createReq.ignoreExist = 1;
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
......
...@@ -157,7 +157,6 @@ struct SVnodeCfg { ...@@ -157,7 +157,6 @@ struct SVnodeCfg {
int32_t szCache; int32_t szCache;
uint64_t szBuf; uint64_t szBuf;
bool isHeap; bool isHeap;
int8_t streamMode;
bool isWeak; bool isWeak;
STsdbCfg tsdbCfg; STsdbCfg tsdbCfg;
SWalCfg walCfg; SWalCfg walCfg;
......
...@@ -159,7 +159,7 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo ...@@ -159,7 +159,7 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
// decode // decode
pBuf = pVal; pBuf = pVal;
pSW = taosMemoryMalloc(sizeof(pSW)); pSW = taosMemoryMalloc(sizeof(SSchemaWrapper));
tCoderInit(&coder, TD_LITTLE_ENDIAN, pVal, vLen, TD_DECODER); tCoderInit(&coder, TD_LITTLE_ENDIAN, pVal, vLen, TD_DECODER);
tDecodeSSchemaWrapper(&coder, pSW); tDecodeSSchemaWrapper(&coder, pSW);
...@@ -436,4 +436,4 @@ void *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid, bool isDecode) { ...@@ -436,4 +436,4 @@ void *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid, bool isDecode) {
return NULL; return NULL;
} }
#endif #endif
\ No newline at end of file
...@@ -864,7 +864,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int32_t parallel) { ...@@ -864,7 +864,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int32_t parallel) {
} }
int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) { int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
SStreamTask* pTask = taosMemoryMalloc(sizeof(SStreamTask)); SStreamTask* pTask = taosMemoryCalloc(1, sizeof(SStreamTask));
if (pTask == NULL) { if (pTask == NULL) {
return -1; return -1;
} }
......
...@@ -23,7 +23,6 @@ const SVnodeCfg vnodeCfgDefault = { ...@@ -23,7 +23,6 @@ const SVnodeCfg vnodeCfgDefault = {
.szCache = 256, .szCache = 256,
.szBuf = 96 * 1024 * 1024, .szBuf = 96 * 1024 * 1024,
.isHeap = false, .isHeap = false,
.streamMode = 0,
.isWeak = 0, .isWeak = 0,
.tsdbCfg = {.precision = TSDB_TIME_PRECISION_MILLI, .tsdbCfg = {.precision = TSDB_TIME_PRECISION_MILLI,
.update = 0, .update = 0,
...@@ -56,7 +55,6 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) { ...@@ -56,7 +55,6 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
if (tjsonAddIntegerToObject(pJson, "szCache", pCfg->szCache) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "szCache", pCfg->szCache) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "szBuf", pCfg->szBuf) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "szBuf", pCfg->szBuf) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "isHeap", pCfg->isHeap) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "isHeap", pCfg->isHeap) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "streamMode", pCfg->streamMode) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "isWeak", pCfg->isWeak) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "isWeak", pCfg->isWeak) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1;
...@@ -104,7 +102,6 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) { ...@@ -104,7 +102,6 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
if (tjsonGetNumberValue(pJson, "szCache", pCfg->szCache) < 0) return -1; if (tjsonGetNumberValue(pJson, "szCache", pCfg->szCache) < 0) return -1;
if (tjsonGetNumberValue(pJson, "szBuf", pCfg->szBuf) < 0) return -1; if (tjsonGetNumberValue(pJson, "szBuf", pCfg->szBuf) < 0) return -1;
if (tjsonGetNumberValue(pJson, "isHeap", pCfg->isHeap) < 0) return -1; if (tjsonGetNumberValue(pJson, "isHeap", pCfg->isHeap) < 0) return -1;
if (tjsonGetNumberValue(pJson, "streamMode", pCfg->streamMode) < 0) return -1;
if (tjsonGetNumberValue(pJson, "isWeak", pCfg->isWeak) < 0) return -1; if (tjsonGetNumberValue(pJson, "isWeak", pCfg->isWeak) < 0) return -1;
if (tjsonGetNumberValue(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1; if (tjsonGetNumberValue(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1;
if (tjsonGetNumberValue(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1; if (tjsonGetNumberValue(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1;
......
...@@ -97,24 +97,22 @@ void sendCreateDbMsg(void *shandle, SEpSet *pEpSet) { ...@@ -97,24 +97,22 @@ void sendCreateDbMsg(void *shandle, SEpSet *pEpSet) {
SCreateDbReq createReq = {0}; SCreateDbReq createReq = {0};
strcpy(createReq.db, "1.db1"); strcpy(createReq.db, "1.db1");
createReq.numOfVgroups = 2; createReq.numOfVgroups = 2;
createReq.cacheBlockSize = 16; createReq.buffer = -1;
createReq.totalBlocks = 10; createReq.pageSize = -1;
createReq.pages = -1;
createReq.daysPerFile = 10; createReq.daysPerFile = 10;
createReq.daysToKeep0 = 3650; createReq.daysToKeep0 = 3650;
createReq.daysToKeep1 = 3650; createReq.daysToKeep1 = 3650;
createReq.daysToKeep2 = 3650; createReq.daysToKeep2 = 3650;
createReq.minRows = 100; createReq.minRows = 100;
createReq.maxRows = 4096; createReq.maxRows = 4096;
createReq.commitTime = 3600;
createReq.fsyncPeriod = 3000; createReq.fsyncPeriod = 3000;
createReq.walLevel = 1; createReq.walLevel = 1;
createReq.precision = 0; createReq.precision = 0;
createReq.compression = 2; createReq.compression = 2;
createReq.replications = 1; createReq.replications = 1;
createReq.strict = 1; createReq.strict = 1;
createReq.update = 0;
createReq.cacheLastRow = 0; createReq.cacheLastRow = 0;
createReq.ttl = 1;
createReq.ignoreExist = 1; createReq.ignoreExist = 1;
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
...@@ -254,7 +252,6 @@ void ctgTestBuildSTableMetaRsp(STableMetaRsp *rspMsg) { ...@@ -254,7 +252,6 @@ void ctgTestBuildSTableMetaRsp(STableMetaRsp *rspMsg) {
rspMsg->numOfColumns = ctgTestColNum; rspMsg->numOfColumns = ctgTestColNum;
rspMsg->precision = 1 + 1; rspMsg->precision = 1 + 1;
rspMsg->tableType = TSDB_SUPER_TABLE; rspMsg->tableType = TSDB_SUPER_TABLE;
rspMsg->update = 1 + 1;
rspMsg->sversion = ctgTestSVersion + 1; rspMsg->sversion = ctgTestSVersion + 1;
rspMsg->tversion = ctgTestTVersion + 1; rspMsg->tversion = ctgTestTVersion + 1;
rspMsg->suid = ctgTestSuid + 1; rspMsg->suid = ctgTestSuid + 1;
...@@ -333,7 +330,6 @@ void ctgTestRspTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg * ...@@ -333,7 +330,6 @@ void ctgTestRspTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *
metaRsp.numOfColumns = ctgTestColNum; metaRsp.numOfColumns = ctgTestColNum;
metaRsp.precision = 1; metaRsp.precision = 1;
metaRsp.tableType = TSDB_NORMAL_TABLE; metaRsp.tableType = TSDB_NORMAL_TABLE;
metaRsp.update = 1;
metaRsp.sversion = ctgTestSVersion; metaRsp.sversion = ctgTestSVersion;
metaRsp.tversion = ctgTestTVersion; metaRsp.tversion = ctgTestTVersion;
metaRsp.suid = 0; metaRsp.suid = 0;
...@@ -379,7 +375,6 @@ void ctgTestRspCTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg ...@@ -379,7 +375,6 @@ void ctgTestRspCTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg
metaRsp.numOfColumns = ctgTestColNum; metaRsp.numOfColumns = ctgTestColNum;
metaRsp.precision = 1; metaRsp.precision = 1;
metaRsp.tableType = TSDB_CHILD_TABLE; metaRsp.tableType = TSDB_CHILD_TABLE;
metaRsp.update = 1;
metaRsp.sversion = ctgTestSVersion; metaRsp.sversion = ctgTestSVersion;
metaRsp.tversion = ctgTestTVersion; metaRsp.tversion = ctgTestTVersion;
metaRsp.suid = 0x0000000000000002; metaRsp.suid = 0x0000000000000002;
...@@ -426,7 +421,6 @@ void ctgTestRspSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg ...@@ -426,7 +421,6 @@ void ctgTestRspSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg
metaRsp.numOfColumns = ctgTestColNum; metaRsp.numOfColumns = ctgTestColNum;
metaRsp.precision = 1; metaRsp.precision = 1;
metaRsp.tableType = TSDB_SUPER_TABLE; metaRsp.tableType = TSDB_SUPER_TABLE;
metaRsp.update = 1;
metaRsp.sversion = ctgTestSVersion; metaRsp.sversion = ctgTestSVersion;
metaRsp.tversion = ctgTestTVersion; metaRsp.tversion = ctgTestTVersion;
metaRsp.suid = ctgTestSuid; metaRsp.suid = ctgTestSuid;
...@@ -475,7 +469,6 @@ void ctgTestRspMultiSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRp ...@@ -475,7 +469,6 @@ void ctgTestRspMultiSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRp
metaRsp.numOfColumns = ctgTestColNum; metaRsp.numOfColumns = ctgTestColNum;
metaRsp.precision = 1; metaRsp.precision = 1;
metaRsp.tableType = TSDB_SUPER_TABLE; metaRsp.tableType = TSDB_SUPER_TABLE;
metaRsp.update = 1;
metaRsp.sversion = ctgTestSVersion; metaRsp.sversion = ctgTestSVersion;
metaRsp.tversion = ctgTestTVersion; metaRsp.tversion = ctgTestTVersion;
metaRsp.suid = ctgTestSuid + idx; metaRsp.suid = ctgTestSuid + idx;
......
...@@ -227,8 +227,8 @@ int32_t operatorDummyOpenFn(SOperatorInfo* pOperator) { ...@@ -227,8 +227,8 @@ int32_t operatorDummyOpenFn(SOperatorInfo* pOperator) {
} }
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn, SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn,
__optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode, __optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode,
__optr_decode_fn_t decode, __optr_get_explain_fn_t explain) { __optr_decode_fn_t decode, __optr_get_explain_fn_t explain) {
SOperatorFpSet fpSet = { SOperatorFpSet fpSet = {
._openFn = openFn, ._openFn = openFn,
.getNextFn = nextFn, .getNextFn = nextFn,
...@@ -441,8 +441,8 @@ SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, ...@@ -441,8 +441,8 @@ SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId,
* +----------+---------------+ * +----------+---------------+
*/ */
static SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, int64_t uid, static SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, int64_t uid,
char* pData, int16_t bytes, bool masterscan, uint64_t groupId, char* pData, int16_t bytes, bool masterscan, uint64_t groupId,
SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup) { SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup) {
SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, groupId); SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, groupId);
SResultRowPosition* p1 = SResultRowPosition* p1 =
...@@ -463,9 +463,9 @@ static SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowI ...@@ -463,9 +463,9 @@ static SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowI
} }
} }
// 1. close current opened time window // 1. close current opened time window
if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId && if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId &&
pResult->offset != pResultRowInfo->cur.offset))) { pResult->offset != pResultRowInfo->cur.offset))) {
// todo extract function // todo extract function
SResultRowPosition pos = pResultRowInfo->cur; SResultRowPosition pos = pResultRowInfo->cur;
SFilePage* pPage = getBufPage(pResultBuf, pos.pageId); SFilePage* pPage = getBufPage(pResultBuf, pos.pageId);
...@@ -482,7 +482,8 @@ static SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowI ...@@ -482,7 +482,8 @@ static SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowI
// add a new result set for a new group // add a new result set for a new group
SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset}; SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset};
taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, sizeof(SResultRowPosition)); taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos,
sizeof(SResultRowPosition));
} }
// 2. set the new time window to be the new active time window // 2. set the new time window to be the new active time window
...@@ -646,7 +647,7 @@ static int32_t setResultOutputBufByKey_rv(SResultRowInfo* pResultRowInfo, int64_ ...@@ -646,7 +647,7 @@ static int32_t setResultOutputBufByKey_rv(SResultRowInfo* pResultRowInfo, int64_
SExecTaskInfo* pTaskInfo) { SExecTaskInfo* pTaskInfo) {
assert(win->skey <= win->ekey); assert(win->skey <= win->ekey);
SResultRow* pResultRow = doSetResultOutBufByKey(pAggSup->pResultBuf, pResultRowInfo, id, (char*)&win->skey, SResultRow* pResultRow = doSetResultOutBufByKey(pAggSup->pResultBuf, pResultRowInfo, id, (char*)&win->skey,
TSDB_KEYSIZE, masterscan, tableGroupId, pTaskInfo, true, pAggSup); TSDB_KEYSIZE, masterscan, tableGroupId, pTaskInfo, true, pAggSup);
if (pResultRow == NULL) { if (pResultRow == NULL) {
*pResult = NULL; *pResult = NULL;
...@@ -1034,8 +1035,8 @@ void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlo ...@@ -1034,8 +1035,8 @@ void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlo
} }
} }
static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t paramIndex,
int32_t paramIndex, int32_t numOfRows) { int32_t numOfRows) {
SColumnInfoData* pColInfo = NULL; SColumnInfoData* pColInfo = NULL;
if (pInput->pData[paramIndex] == NULL) { if (pInput->pData[paramIndex] == NULL) {
pColInfo = taosMemoryCalloc(1, sizeof(SColumnInfoData)); pColInfo = taosMemoryCalloc(1, sizeof(SColumnInfoData));
...@@ -1066,9 +1067,9 @@ static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunc ...@@ -1066,9 +1067,9 @@ static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunc
colDataAppendDouble(pColInfo, i, &v); colDataAppendDouble(pColInfo, i, &v);
} }
} else if (type == TSDB_DATA_TYPE_VARCHAR) { } else if (type == TSDB_DATA_TYPE_VARCHAR) {
char *tmp = taosMemoryMalloc(pFuncParam->param.nLen + VARSTR_HEADER_SIZE); char* tmp = taosMemoryMalloc(pFuncParam->param.nLen + VARSTR_HEADER_SIZE);
STR_WITH_SIZE_TO_VARSTR(tmp, pFuncParam->param.pz, pFuncParam->param.nLen); STR_WITH_SIZE_TO_VARSTR(tmp, pFuncParam->param.pz, pFuncParam->param.nLen);
for(int32_t i = 0; i < numOfRows; ++i) { for (int32_t i = 0; i < numOfRows; ++i) {
colDataAppend(pColInfo, i, tmp, false); colDataAppend(pColInfo, i, tmp, false);
} }
} }
...@@ -1081,9 +1082,9 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt ...@@ -1081,9 +1082,9 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
for (int32_t i = 0; i < pOperator->numOfOutput; ++i) { for (int32_t i = 0; i < pOperator->numOfOutput; ++i) {
pCtx[i].order = order; pCtx[i].order = order;
pCtx[i].size = pBlock->info.rows; pCtx[i].size = pBlock->info.rows;
pCtx[i].pSrcBlock = pBlock; pCtx[i].pSrcBlock = pBlock;
pCtx[i].currentStage = MAIN_SCAN; pCtx[i].currentStage = MAIN_SCAN;
SInputColumnInfoData* pInput = &pCtx[i].input; SInputColumnInfoData* pInput = &pCtx[i].input;
...@@ -1421,7 +1422,7 @@ static void doWindowBorderInterpolation(SOperatorInfo* pOperatorInfo, SSDataBloc ...@@ -1421,7 +1422,7 @@ static void doWindowBorderInterpolation(SOperatorInfo* pOperatorInfo, SSDataBloc
if (!done) { // it is not interpolated, now start to generated the interpolated value if (!done) { // it is not interpolated, now start to generated the interpolated value
int32_t startRowIndex = startPos; int32_t startRowIndex = startPos;
bool interp = setTimeWindowInterpolationStartTs(pOperatorInfo, pCtx, startRowIndex, pBlock->info.rows, bool interp = setTimeWindowInterpolationStartTs(pOperatorInfo, pCtx, startRowIndex, pBlock->info.rows,
pBlock->pDataBlock, tsCols, win); pBlock->pDataBlock, tsCols, win);
if (interp) { if (interp) {
setResultRowInterpo(pResult, RESULT_ROW_START_INTERP); setResultRowInterpo(pResult, RESULT_ROW_START_INTERP);
} }
...@@ -1482,8 +1483,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe ...@@ -1482,8 +1483,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
SResultRow* pResult = NULL; SResultRow* pResult = NULL;
int32_t ret = setResultOutputBufByKey_rv(pResultRowInfo, pSDataBlock->info.uid, &win, masterScan, &pResult, int32_t ret = setResultOutputBufByKey_rv(pResultRowInfo, pSDataBlock->info.uid, &win, masterScan, &pResult,
tableGroupId, pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset, tableGroupId, pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset,
&pInfo->aggSup, pTaskInfo); &pInfo->aggSup, pTaskInfo);
if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { if (ret != TSDB_CODE_SUCCESS || pResult == NULL) {
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
...@@ -1491,8 +1492,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe ...@@ -1491,8 +1492,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) { if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) {
SResKeyPos* pos = taosMemoryMalloc(sizeof(SResKeyPos) + sizeof(uint64_t)); SResKeyPos* pos = taosMemoryMalloc(sizeof(SResKeyPos) + sizeof(uint64_t));
pos->groupId = tableGroupId; pos->groupId = tableGroupId;
pos->pos = (SResultRowPosition) {.pageId = pResult->pageId, .offset = pResult->offset}; pos->pos = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset};
*(int64_t*) pos->key = pResult->win.skey; *(int64_t*)pos->key = pResult->win.skey;
taosArrayPush(pUpdated, &pos); taosArrayPush(pUpdated, &pos);
} }
...@@ -1569,8 +1570,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe ...@@ -1569,8 +1570,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) { if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) {
SResKeyPos* pos = taosMemoryMalloc(sizeof(SResKeyPos) + sizeof(uint64_t)); SResKeyPos* pos = taosMemoryMalloc(sizeof(SResKeyPos) + sizeof(uint64_t));
pos->groupId = tableGroupId; pos->groupId = tableGroupId;
pos->pos = (SResultRowPosition) {.pageId = pResult->pageId, .offset = pResult->offset}; pos->pos = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset};
*(int64_t*) pos->key = pResult->win.skey; *(int64_t*)pos->key = pResult->win.skey;
taosArrayPush(pUpdated, &pos); taosArrayPush(pUpdated, &pos);
} }
...@@ -1706,7 +1707,7 @@ int32_t setGroupResultOutputBuf(SOptrBasicInfo* binfo, int32_t numOfCols, char* ...@@ -1706,7 +1707,7 @@ int32_t setGroupResultOutputBuf(SOptrBasicInfo* binfo, int32_t numOfCols, char*
SqlFunctionCtx* pCtx = binfo->pCtx; SqlFunctionCtx* pCtx = binfo->pCtx;
SResultRow* pResultRow = doSetResultOutBufByKey(pBuf, pResultRowInfo, groupId, (char*)pData, bytes, true, groupId, SResultRow* pResultRow = doSetResultOutBufByKey(pBuf, pResultRowInfo, groupId, (char*)pData, bytes, true, groupId,
pTaskInfo, false, pAggSup); pTaskInfo, false, pAggSup);
assert(pResultRow != NULL); assert(pResultRow != NULL);
setResultRowKey(pResultRow, pData, type); setResultRowKey(pResultRow, pData, type);
...@@ -1890,7 +1891,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, ...@@ -1890,7 +1891,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
pCtx->functionId = -1; pCtx->functionId = -1;
pCtx->curBufPage = -1; pCtx->curBufPage = -1;
pCtx->pExpr = pExpr; pCtx->pExpr = pExpr;
if (pExpr->pExpr->nodeType == QUERY_NODE_FUNCTION) { if (pExpr->pExpr->nodeType == QUERY_NODE_FUNCTION) {
SFuncExecEnv env = {0}; SFuncExecEnv env = {0};
...@@ -1926,9 +1927,9 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, ...@@ -1926,9 +1927,9 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
pCtx->pTsOutput = NULL; pCtx->pTsOutput = NULL;
pCtx->resDataInfo.bytes = pFunct->resSchema.bytes; pCtx->resDataInfo.bytes = pFunct->resSchema.bytes;
pCtx->resDataInfo.type = pFunct->resSchema.type; pCtx->resDataInfo.type = pFunct->resSchema.type;
pCtx->order = TSDB_ORDER_ASC; pCtx->order = TSDB_ORDER_ASC;
pCtx->start.key = INT64_MIN; pCtx->start.key = INT64_MIN;
pCtx->end.key = INT64_MIN; pCtx->end.key = INT64_MIN;
pCtx->numOfParams = pExpr->base.numOfParams; pCtx->numOfParams = pExpr->base.numOfParams;
pCtx->param = pFunct->pParam; pCtx->param = pFunct->pParam;
...@@ -2719,7 +2720,7 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t ...@@ -2719,7 +2720,7 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t
int64_t tid = 0; int64_t tid = 0;
int64_t groupId = 0; int64_t groupId = 0;
SResultRow* pRow = doSetResultOutBufByKey(pSup->pResultBuf, pResultRowInfo, tid, (char*)&tid, sizeof(tid), true, SResultRow* pRow = doSetResultOutBufByKey(pSup->pResultBuf, pResultRowInfo, tid, (char*)&tid, sizeof(tid), true,
groupId, pTaskInfo, false, pSup); groupId, pTaskInfo, false, pSup);
for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) { for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) {
struct SResultRowEntryInfo* pEntry = getResultCell(pRow, i, rowCellInfoOffset); struct SResultRowEntryInfo* pEntry = getResultCell(pRow, i, rowCellInfoOffset);
...@@ -2866,24 +2867,24 @@ void finalizeUpdatedResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbased ...@@ -2866,24 +2867,24 @@ void finalizeUpdatedResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbased
size_t num = taosArrayGetSize(pUpdateList); size_t num = taosArrayGetSize(pUpdateList);
for (int32_t i = 0; i < num; ++i) { for (int32_t i = 0; i < num; ++i) {
SResKeyPos * pPos = taosArrayGetP(pUpdateList, i); SResKeyPos* pPos = taosArrayGetP(pUpdateList, i);
SFilePage* bufPage = getBufPage(pBuf, pPos->pos.pageId); SFilePage* bufPage = getBufPage(pBuf, pPos->pos.pageId);
SResultRow* pRow = (SResultRow*)((char*)bufPage + pPos->pos.offset); SResultRow* pRow = (SResultRow*)((char*)bufPage + pPos->pos.offset);
// //
for (int32_t j = 0; j < numOfOutput; ++j) { for (int32_t j = 0; j < numOfOutput; ++j) {
pCtx[j].resultInfo = getResultCell(pRow, j, rowCellInfoOffset); pCtx[j].resultInfo = getResultCell(pRow, j, rowCellInfoOffset);
// //
struct SResultRowEntryInfo* pResInfo = pCtx[j].resultInfo; struct SResultRowEntryInfo* pResInfo = pCtx[j].resultInfo;
// if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) { // if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) {
// continue; // continue;
// } // }
// //
// if (pCtx[j].fpSet.process) { // TODO set the dummy function. // if (pCtx[j].fpSet.process) { // TODO set the dummy function.
//// pCtx[j].fpSet.finalize(&pCtx[j]); //// pCtx[j].fpSet.finalize(&pCtx[j]);
// pResInfo->initialized = true; // pResInfo->initialized = true;
// } // }
// //
if (pRow->numOfRows < pResInfo->numOfRes) { if (pRow->numOfRows < pResInfo->numOfRes) {
pRow->numOfRows = pResInfo->numOfRes; pRow->numOfRows = pResInfo->numOfRes;
} }
...@@ -3005,9 +3006,8 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, u ...@@ -3005,9 +3006,8 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, u
SqlFunctionCtx* pCtx = pAggInfo->binfo.pCtx; SqlFunctionCtx* pCtx = pAggInfo->binfo.pCtx;
int32_t* rowCellInfoOffset = pAggInfo->binfo.rowCellInfoOffset; int32_t* rowCellInfoOffset = pAggInfo->binfo.rowCellInfoOffset;
SResultRow* pResultRow = SResultRow* pResultRow = doSetResultOutBufByKey(pAggInfo->aggSup.pResultBuf, pResultRowInfo, uid, (char*)&groupId,
doSetResultOutBufByKey(pAggInfo->aggSup.pResultBuf, pResultRowInfo, uid, (char*)&groupId, sizeof(groupId), sizeof(groupId), true, groupId, pTaskInfo, false, &pAggInfo->aggSup);
true, groupId, pTaskInfo, false, &pAggInfo->aggSup);
assert(pResultRow != NULL); assert(pResultRow != NULL);
/* /*
...@@ -3105,8 +3105,8 @@ int32_t doCopyToSDataBlock(SSDataBlock* pBlock, SExprInfo* pExprInfo, SDiskbased ...@@ -3105,8 +3105,8 @@ int32_t doCopyToSDataBlock(SSDataBlock* pBlock, SExprInfo* pExprInfo, SDiskbased
} }
for (int32_t i = start; (i < numOfRows) && (i >= 0); i += step) { for (int32_t i = start; (i < numOfRows) && (i >= 0); i += step) {
SResKeyPos *pPos = taosArrayGetP(pGroupResInfo->pRows, i); SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i);
SFilePage* page = getBufPage(pBuf, pPos->pos.pageId); SFilePage* page = getBufPage(pBuf, pPos->pos.pageId);
SResultRow* pRow = (SResultRow*)((char*)page + pPos->pos.offset); SResultRow* pRow = (SResultRow*)((char*)page + pPos->pos.offset);
if (pRow->numOfRows == 0) { if (pRow->numOfRows == 0) {
...@@ -3751,7 +3751,7 @@ static void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, ...@@ -3751,7 +3751,7 @@ static void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo,
ASSERT(numOfSrcCols >= pBlock->info.numOfCols); ASSERT(numOfSrcCols >= pBlock->info.numOfCols);
int32_t i = 0, j = 0; int32_t i = 0, j = 0;
while(i < numOfSrcCols && j < taosArrayGetSize(pColMatchInfo)) { while (i < numOfSrcCols && j < taosArrayGetSize(pColMatchInfo)) {
SColumnInfoData* p = taosArrayGet(pCols, i); SColumnInfoData* p = taosArrayGet(pCols, i);
SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, j); SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, j);
if (!pmInfo->output) { if (!pmInfo->output) {
...@@ -3777,10 +3777,10 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI ...@@ -3777,10 +3777,10 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
blockDataEnsureCapacity(pRes, numOfRows); blockDataEnsureCapacity(pRes, numOfRows);
if (pColList == NULL) { // data from other sources if (pColList == NULL) { // data from other sources
int32_t dataLen = *(int32_t*) pData; int32_t dataLen = *(int32_t*)pData;
pData += sizeof(int32_t); pData += sizeof(int32_t);
pRes->info.groupId = *(uint64_t*) pData; pRes->info.groupId = *(uint64_t*)pData;
pData += sizeof(uint64_t); pData += sizeof(uint64_t);
int32_t* colLen = (int32_t*)pData; int32_t* colLen = (int32_t*)pData;
...@@ -3810,8 +3810,8 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI ...@@ -3810,8 +3810,8 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
memcpy(pColInfoData->pData, pStart, colLen[i]); memcpy(pColInfoData->pData, pStart, colLen[i]);
} }
//TODO setting this flag to true temporarily so aggregate function on stable will // TODO setting this flag to true temporarily so aggregate function on stable will
//examine NULL value for non-primary key column // examine NULL value for non-primary key column
pColInfoData->hasNull = true; pColInfoData->hasNull = true;
pStart += colLen[i]; pStart += colLen[i];
} }
...@@ -3847,11 +3847,11 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI ...@@ -3847,11 +3847,11 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
blockDataEnsureCapacity(&block, numOfRows); blockDataEnsureCapacity(&block, numOfRows);
int32_t dataLen = *(int32_t*) pStart; int32_t dataLen = *(int32_t*)pStart;
uint64_t groupId = *(uint64_t*) (pStart + sizeof(int32_t)); uint64_t groupId = *(uint64_t*)(pStart + sizeof(int32_t));
pStart += sizeof(int32_t) + sizeof(uint64_t); pStart += sizeof(int32_t) + sizeof(uint64_t);
int32_t* colLen = (int32_t*) (pStart); int32_t* colLen = (int32_t*)(pStart);
pStart += sizeof(int32_t) * numOfCols; pStart += sizeof(int32_t) * numOfCols;
for (int32_t i = 0; i < numOfCols; ++i) { for (int32_t i = 0; i < numOfCols; ++i) {
...@@ -3877,7 +3877,7 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI ...@@ -3877,7 +3877,7 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
} }
// data from mnode // data from mnode
relocateColumnData(pRes, pColList, block.pDataBlock); relocateColumnData(pRes, pColList, block.pDataBlock);
} }
pRes->info.rows = numOfRows; pRes->info.rows = numOfRows;
...@@ -4226,8 +4226,8 @@ SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock ...@@ -4226,8 +4226,8 @@ SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock
pOperator->numOfOutput = pBlock->info.numOfCols; pOperator->numOfOutput = pBlock->info.numOfCols;
pOperator->pTaskInfo = pTaskInfo; pOperator->pTaskInfo = pTaskInfo;
pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL, destroyExchangeOperatorInfo, pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL,
NULL, NULL, NULL); destroyExchangeOperatorInfo, NULL, NULL, NULL);
#if 1 #if 1
{ // todo refactor { // todo refactor
...@@ -4716,8 +4716,8 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR ...@@ -4716,8 +4716,8 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR
pOperator->info = pInfo; pOperator->info = pInfo;
pOperator->pTaskInfo = pTaskInfo; pOperator->pTaskInfo = pTaskInfo;
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSort, NULL, NULL, destroyOrderOperatorInfo, pOperator->fpSet =
NULL, NULL, NULL); createOperatorFpSet(operatorDummyOpenFn, doSort, NULL, NULL, destroyOrderOperatorInfo, NULL, NULL, NULL);
int32_t code = appendDownstream(pOperator, &downstream, 1); int32_t code = appendDownstream(pOperator, &downstream, 1);
return pOperator; return pOperator;
...@@ -4933,8 +4933,8 @@ bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter* pSup, SOptrBasi ...@@ -4933,8 +4933,8 @@ bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter* pSup, SOptrBasi
initResultRow(resultRow); initResultRow(resultRow);
prepareResultListBuffer(&pInfo->resultRowInfo, pOperator->pTaskInfo->env); prepareResultListBuffer(&pInfo->resultRowInfo, pOperator->pTaskInfo->env);
// pInfo->resultRowInfo.cur = pInfo->resultRowInfo.size; // pInfo->resultRowInfo.cur = pInfo->resultRowInfo.size;
// pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] = // pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] =
// (SResultRowPosition){.pageId = resultRow->pageId, .offset = resultRow->offset}; // (SResultRowPosition){.pageId = resultRow->pageId, .offset = resultRow->offset};
pInfo->resultRowInfo.cur = (SResultRowPosition){.pageId = resultRow->pageId, .offset = resultRow->offset}; pInfo->resultRowInfo.cur = (SResultRowPosition){.pageId = resultRow->pageId, .offset = resultRow->offset};
} }
...@@ -4946,13 +4946,13 @@ bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter* pSup, SOptrBasi ...@@ -4946,13 +4946,13 @@ bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter* pSup, SOptrBasi
enum { enum {
PROJECT_RETRIEVE_CONTINUE = 0x1, PROJECT_RETRIEVE_CONTINUE = 0x1,
PROJECT_RETRIEVE_DONE = 0x2, PROJECT_RETRIEVE_DONE = 0x2,
}; };
static int32_t handleLimitOffset(SOperatorInfo* pOperator, SSDataBlock* pBlock) { static int32_t handleLimitOffset(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
SProjectOperatorInfo* pProjectInfo = pOperator->info; SProjectOperatorInfo* pProjectInfo = pOperator->info;
SOptrBasicInfo* pInfo = &pProjectInfo->binfo; SOptrBasicInfo* pInfo = &pProjectInfo->binfo;
SSDataBlock* pRes = pInfo->pRes; SSDataBlock* pRes = pInfo->pRes;
if (pProjectInfo->curSOffset > 0) { if (pProjectInfo->curSOffset > 0) {
if (pProjectInfo->groupId == 0) { // it is the first group if (pProjectInfo->groupId == 0) { // it is the first group
...@@ -5015,9 +5015,10 @@ static int32_t handleLimitOffset(SOperatorInfo* pOperator, SSDataBlock* pBlock) ...@@ -5015,9 +5015,10 @@ static int32_t handleLimitOffset(SOperatorInfo* pOperator, SSDataBlock* pBlock)
// todo optimize performance // todo optimize performance
// If there are slimit/soffset value exists, multi-round result can not be packed into one group, since the // If there are slimit/soffset value exists, multi-round result can not be packed into one group, since the
// they may not belong to the same group the limit/offset value is not valid in this case. // they may not belong to the same group the limit/offset value is not valid in this case.
if (pRes->info.rows >= pOperator->resultInfo.threshold || pProjectInfo->slimit.offset != -1 || pProjectInfo->slimit.limit != -1) { if (pRes->info.rows >= pOperator->resultInfo.threshold || pProjectInfo->slimit.offset != -1 ||
pProjectInfo->slimit.limit != -1) {
return PROJECT_RETRIEVE_DONE; return PROJECT_RETRIEVE_DONE;
} else { // not full enough, continue to accumulate the output data in the buffer. } else { // not full enough, continue to accumulate the output data in the buffer.
return PROJECT_RETRIEVE_CONTINUE; return PROJECT_RETRIEVE_CONTINUE;
} }
} }
...@@ -5101,7 +5102,7 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup) ...@@ -5101,7 +5102,7 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup)
int32_t status = handleLimitOffset(pOperator, pBlock); int32_t status = handleLimitOffset(pOperator, pBlock);
if (status == PROJECT_RETRIEVE_CONTINUE) { if (status == PROJECT_RETRIEVE_CONTINUE) {
continue; continue;
} else if (status == PROJECT_RETRIEVE_DONE) { } else if (status == PROJECT_RETRIEVE_DONE) {
break; break;
} }
} }
...@@ -5291,7 +5292,7 @@ static SSDataBlock* doAllIntervalAgg(SOperatorInfo* pOperator, bool* newgroup) { ...@@ -5291,7 +5292,7 @@ static SSDataBlock* doAllIntervalAgg(SOperatorInfo* pOperator, bool* newgroup) {
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
// finalizeQueryResult(pSliceInfo->binfo.pCtx, pOperator->numOfOutput); // finalizeQueryResult(pSliceInfo->binfo.pCtx, pOperator->numOfOutput);
// initGroupedResultInfo(&pSliceInfo->groupResInfo, &pSliceInfo->binfo.resultRowInfo); // initGroupedResultInfo(&pSliceInfo->groupResInfo, &pSliceInfo->binfo.resultRowInfo);
// doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pSliceInfo->pRes); // doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pSliceInfo->pRes);
if (pSliceInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pSliceInfo->groupResInfo)) { if (pSliceInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pSliceInfo->groupResInfo)) {
...@@ -5342,7 +5343,7 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup ...@@ -5342,7 +5343,7 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
finalizeMultiTupleQueryResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->aggSup.pResultBuf, finalizeMultiTupleQueryResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->aggSup.pResultBuf,
&pInfo->binfo.resultRowInfo, pInfo->binfo.rowCellInfoOffset); &pInfo->binfo.resultRowInfo, pInfo->binfo.rowCellInfoOffset);
// initGroupedResultInfo(&pInfo->groupResInfo, &pInfo->binfo.resultRowInfo); // initGroupedResultInfo(&pInfo->groupResInfo, &pInfo->binfo.resultRowInfo);
OPTR_SET_OPENED(pOperator); OPTR_SET_OPENED(pOperator);
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
...@@ -5684,8 +5685,8 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n ...@@ -5684,8 +5685,8 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n
pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput);
pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t)); pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t));
pAggSup->pResultRowHashTable = taosHashInit(10, hashFn, true, HASH_NO_LOCK); pAggSup->pResultRowHashTable = taosHashInit(10, hashFn, true, HASH_NO_LOCK);
// pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK); // pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK);
// pAggSup->pResultRowArrayList = taosArrayInit(10, sizeof(SResultRowCell)); // pAggSup->pResultRowArrayList = taosArrayInit(10, sizeof(SResultRowCell));
if (pAggSup->keyBuf == NULL /*|| pAggSup->pResultRowArrayList == NULL || pAggSup->pResultRowListSet == NULL*/ || if (pAggSup->keyBuf == NULL /*|| pAggSup->pResultRowArrayList == NULL || pAggSup->pResultRowListSet == NULL*/ ||
pAggSup->pResultRowHashTable == NULL) { pAggSup->pResultRowHashTable == NULL) {
...@@ -5703,8 +5704,8 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n ...@@ -5703,8 +5704,8 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n
static void cleanupAggSup(SAggSupporter* pAggSup) { static void cleanupAggSup(SAggSupporter* pAggSup) {
taosMemoryFreeClear(pAggSup->keyBuf); taosMemoryFreeClear(pAggSup->keyBuf);
taosHashCleanup(pAggSup->pResultRowHashTable); taosHashCleanup(pAggSup->pResultRowHashTable);
// taosHashCleanup(pAggSup->pResultRowListSet); // taosHashCleanup(pAggSup->pResultRowListSet);
// taosArrayDestroy(pAggSup->pResultRowArrayList); // taosArrayDestroy(pAggSup->pResultRowArrayList);
destroyDiskbasedBuf(pAggSup->pResultBuf); destroyDiskbasedBuf(pAggSup->pResultBuf);
} }
...@@ -5715,7 +5716,7 @@ int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInf ...@@ -5715,7 +5716,7 @@ int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInf
doInitAggInfoSup(pAggSup, pBasicInfo->pCtx, numOfCols, keyBufSize, pkey); doInitAggInfoSup(pAggSup, pBasicInfo->pCtx, numOfCols, keyBufSize, pkey);
for(int32_t i = 0; i < numOfCols; ++i) { for (int32_t i = 0; i < numOfCols; ++i) {
pBasicInfo->pCtx[i].pBuf = pAggSup->pResultBuf; pBasicInfo->pCtx[i].pBuf = pAggSup->pResultBuf;
} }
...@@ -5732,6 +5733,10 @@ void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows) { ...@@ -5732,6 +5733,10 @@ void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows) {
} }
static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInfo) { static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInfo) {
if (pTableGroupInfo->numOfTables == 0) {
return NULL;
}
STableQueryInfo* pTableQueryInfo = taosMemoryCalloc(pTableGroupInfo->numOfTables, sizeof(STableQueryInfo)); STableQueryInfo* pTableQueryInfo = taosMemoryCalloc(pTableGroupInfo->numOfTables, sizeof(STableQueryInfo));
if (pTableQueryInfo == NULL) { if (pTableQueryInfo == NULL) {
return NULL; return NULL;
...@@ -5757,7 +5762,8 @@ static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInf ...@@ -5757,7 +5762,8 @@ static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInf
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo, SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo,
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) { int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo,
const STableGroupInfo* pTableGroupInfo) {
SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo)); SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo));
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
if (pInfo == NULL || pOperator == NULL) { if (pInfo == NULL || pOperator == NULL) {
...@@ -5771,7 +5777,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* ...@@ -5771,7 +5777,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
int32_t code = int32_t code =
initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, pResultBlock, keyBufSize, pTaskInfo->id.str); initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, pResultBlock, keyBufSize, pTaskInfo->id.str);
pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo);
if (code != TSDB_CODE_SUCCESS || pInfo->pTableQueryInfo == NULL) { if (code != TSDB_CODE_SUCCESS) {
goto _error; goto _error;
} }
...@@ -5926,8 +5932,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p ...@@ -5926,8 +5932,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p
pOperator->pExpr = pExprInfo; pOperator->pExpr = pExprInfo;
pOperator->numOfOutput = num; pOperator->numOfOutput = num;
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doProjectOperation, NULL, NULL, destroyProjectOperatorInfo, pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doProjectOperation, NULL, NULL,
NULL, NULL, NULL); destroyProjectOperatorInfo, NULL, NULL, NULL);
pOperator->pTaskInfo = pTaskInfo; pOperator->pTaskInfo = pTaskInfo;
int32_t code = appendDownstream(pOperator, &downstream, 1); int32_t code = appendDownstream(pOperator, &downstream, 1);
...@@ -5952,12 +5958,12 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* ...@@ -5952,12 +5958,12 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
goto _error; goto _error;
} }
pInfo->order = TSDB_ORDER_ASC; pInfo->order = TSDB_ORDER_ASC;
pInfo->interval = *pInterval; pInfo->interval = *pInterval;
// pInfo->execModel = OPTR_EXEC_MODEL_STREAM; // pInfo->execModel = OPTR_EXEC_MODEL_STREAM;
pInfo->execModel = pTaskInfo->execModel; pInfo->execModel = pTaskInfo->execModel;
pInfo->win = pTaskInfo->window; pInfo->win = pTaskInfo->window;
pInfo->twAggSup = *pTwAggSupp; pInfo->twAggSup = *pTwAggSupp;
pInfo->primaryTsIndex = primaryTsSlotId; pInfo->primaryTsIndex = primaryTsSlotId;
int32_t numOfRows = 4096; int32_t numOfRows = 4096;
...@@ -5984,8 +5990,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* ...@@ -5984,8 +5990,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
pOperator->numOfOutput = numOfCols; pOperator->numOfOutput = numOfCols;
pOperator->info = pInfo; pOperator->info = pInfo;
pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, doStreamIntervalAgg, NULL, destroyIntervalOperatorInfo, pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, doStreamIntervalAgg, NULL,
aggEncodeResultRow, aggDecodeResultRow, NULL); destroyIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
code = appendDownstream(pOperator, &downstream, 1); code = appendDownstream(pOperator, &downstream, 1);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
...@@ -6004,18 +6010,19 @@ _error: ...@@ -6004,18 +6010,19 @@ _error:
SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId, SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
STimeWindowAggSupp *pTwAggSupp, const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo) { STimeWindowAggSupp* pTwAggSupp, const STableGroupInfo* pTableGroupInfo,
SExecTaskInfo* pTaskInfo) {
STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo)); STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo));
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
if (pInfo == NULL || pOperator == NULL) { if (pInfo == NULL || pOperator == NULL) {
goto _error; goto _error;
} }
pInfo->order = TSDB_ORDER_ASC; pInfo->order = TSDB_ORDER_ASC;
pInfo->interval = *pInterval; pInfo->interval = *pInterval;
pInfo->execModel = OPTR_EXEC_MODEL_STREAM; pInfo->execModel = OPTR_EXEC_MODEL_STREAM;
pInfo->win = pTaskInfo->window; pInfo->win = pTaskInfo->window;
pInfo->twAggSup = *pTwAggSupp; pInfo->twAggSup = *pTwAggSupp;
pInfo->primaryTsIndex = primaryTsSlotId; pInfo->primaryTsIndex = primaryTsSlotId;
int32_t numOfRows = 4096; int32_t numOfRows = 4096;
...@@ -6042,8 +6049,8 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr ...@@ -6042,8 +6049,8 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
pOperator->numOfOutput = numOfCols; pOperator->numOfOutput = numOfCols;
pOperator->info = pInfo; pOperator->info = pInfo;
pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doStreamIntervalAgg, doStreamIntervalAgg, NULL, destroyIntervalOperatorInfo, pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doStreamIntervalAgg, doStreamIntervalAgg, NULL,
aggEncodeResultRow, aggDecodeResultRow, NULL); destroyIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
code = appendDownstream(pOperator, &downstream, 1); code = appendDownstream(pOperator, &downstream, 1);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
...@@ -6052,13 +6059,12 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr ...@@ -6052,13 +6059,12 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
return pOperator; return pOperator;
_error: _error:
destroyIntervalOperatorInfo(pInfo, numOfCols); destroyIntervalOperatorInfo(pInfo, numOfCols);
taosMemoryFreeClear(pInfo); taosMemoryFreeClear(pInfo);
taosMemoryFreeClear(pOperator); taosMemoryFreeClear(pOperator);
pTaskInfo->code = code; pTaskInfo->code = code;
return NULL; return NULL;
} }
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
...@@ -6122,8 +6128,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf ...@@ -6122,8 +6128,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
pOperator->pTaskInfo = pTaskInfo; pOperator->pTaskInfo = pTaskInfo;
pOperator->info = pInfo; pOperator->info = pInfo;
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStateWindowAgg, NULL, NULL, destroyStateWindowOperatorInfo, pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStateWindowAgg, NULL, NULL,
aggEncodeResultRow, aggDecodeResultRow, NULL); destroyStateWindowOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
int32_t code = appendDownstream(pOperator, &downstream, 1); int32_t code = appendDownstream(pOperator, &downstream, 1);
return pOperator; return pOperator;
...@@ -6168,8 +6174,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo ...@@ -6168,8 +6174,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
pOperator->numOfOutput = numOfCols; pOperator->numOfOutput = numOfCols;
pOperator->info = pInfo; pOperator->info = pInfo;
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSessionWindowAgg, NULL, NULL, destroySWindowOperatorInfo, pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSessionWindowAgg, NULL, NULL,
aggEncodeResultRow, aggDecodeResultRow, NULL); destroySWindowOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
pOperator->pTaskInfo = pTaskInfo; pOperator->pTaskInfo = pTaskInfo;
code = appendDownstream(pOperator, &downstream, 1); code = appendDownstream(pOperator, &downstream, 1);
...@@ -6257,8 +6263,8 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp ...@@ -6257,8 +6263,8 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
pOperator->numOfOutput = numOfCols; pOperator->numOfOutput = numOfCols;
pOperator->info = pInfo; pOperator->info = pInfo;
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, NULL, destroySFillOperatorInfo, pOperator->fpSet =
NULL, NULL, NULL); createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, NULL, destroySFillOperatorInfo, NULL, NULL, NULL);
pOperator->pTaskInfo = pTaskInfo; pOperator->pTaskInfo = pTaskInfo;
code = appendDownstream(pOperator, &downstream, 1); code = appendDownstream(pOperator, &downstream, 1);
return pOperator; return pOperator;
...@@ -6269,7 +6275,6 @@ _error: ...@@ -6269,7 +6275,6 @@ _error:
return NULL; return NULL;
} }
static int32_t getColumnIndexInSource(SQueriedTableInfo* pTableInfo, SExprBasicInfo* pExpr, SColumnInfo* pTagCols) { static int32_t getColumnIndexInSource(SQueriedTableInfo* pTableInfo, SExprBasicInfo* pExpr, SColumnInfo* pTagCols) {
int32_t j = 0; int32_t j = 0;
...@@ -6467,11 +6472,11 @@ static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableSc ...@@ -6467,11 +6472,11 @@ static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableSc
static SInterval extractIntervalInfo(const STableScanPhysiNode* pTableScanNode) { static SInterval extractIntervalInfo(const STableScanPhysiNode* pTableScanNode) {
SInterval interval = { SInterval interval = {
.interval = pTableScanNode->interval, .interval = pTableScanNode->interval,
.sliding = pTableScanNode->sliding, .sliding = pTableScanNode->sliding,
.intervalUnit = pTableScanNode->intervalUnit, .intervalUnit = pTableScanNode->intervalUnit,
.slidingUnit = pTableScanNode->slidingUnit, .slidingUnit = pTableScanNode->slidingUnit,
.offset = pTableScanNode->offset, .offset = pTableScanNode->offset,
}; };
return interval; return interval;
...@@ -6486,7 +6491,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo ...@@ -6486,7 +6491,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode;
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode; STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
int32_t numOfCols = 0; int32_t numOfCols = 0;
tsdbReaderT pDataReader = doCreateDataReader(pTableScanNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId); tsdbReaderT pDataReader = doCreateDataReader(pTableScanNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId);
if (pDataReader == NULL && terrno != 0) { if (pDataReader == NULL && terrno != 0) {
return NULL; return NULL;
...@@ -6497,14 +6502,15 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo ...@@ -6497,14 +6502,15 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc); SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
SQueryTableDataCond cond = {0}; SQueryTableDataCond cond = {0};
int32_t code = initQueryTableDataCond(&cond, pTableScanNode); int32_t code = initQueryTableDataCond(&cond, pTableScanNode);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
return NULL; return NULL;
} }
SInterval interval = extractIntervalInfo(pTableScanNode); SInterval interval = extractIntervalInfo(pTableScanNode);
return createTableScanOperatorInfo(pDataReader, &cond, numOfCols, pTableScanNode->dataRequired, pTableScanNode->scanSeq, pColList, return createTableScanOperatorInfo(pDataReader, &cond, numOfCols, pTableScanNode->dataRequired,
pResBlock, pScanPhyNode->node.pConditions, &interval, pTableScanNode->ratio, pTaskInfo); pTableScanNode->scanSeq, pColList, pResBlock, pScanPhyNode->node.pConditions,
&interval, pTableScanNode->ratio, pTaskInfo);
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) { } else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode; SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode;
SSDataBlock* pResBlock = createResDataBlock(pExchange->node.pOutputDataBlockDesc); SSDataBlock* pResBlock = createResDataBlock(pExchange->node.pOutputDataBlockDesc);
...@@ -6512,27 +6518,30 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo ...@@ -6512,27 +6518,30 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) { } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; // simple child table. SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; // simple child table.
int32_t code = doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo, queryId, taskId); int32_t code = doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo,
queryId, taskId);
SArray* tableIdList = extractTableIdList(pTableGroupInfo); SArray* tableIdList = extractTableIdList(pTableGroupInfo);
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc); SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
int32_t numOfCols = 0; int32_t numOfCols = 0;
SArray* pCols = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); SArray* pCols = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle->reader, pResBlock, pCols, tableIdList, pTaskInfo); SOperatorInfo* pOperator =
createStreamScanOperatorInfo(pHandle->reader, pResBlock, pCols, tableIdList, pTaskInfo);
taosArrayDestroy(tableIdList); taosArrayDestroy(tableIdList);
return pOperator; return pOperator;
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) { } else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode; SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode;
SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan; SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan;
SSDataBlock* pResBlock = createResDataBlock(pScanNode->node.pOutputDataBlockDesc); SSDataBlock* pResBlock = createResDataBlock(pScanNode->node.pOutputDataBlockDesc);
int32_t numOfOutputCols = 0; int32_t numOfOutputCols = 0;
SArray* colList = extractColMatchInfo(pScanNode->pScanCols, pScanNode->node.pOutputDataBlockDesc, &numOfOutputCols); SArray* colList =
extractColMatchInfo(pScanNode->pScanCols, pScanNode->node.pOutputDataBlockDesc, &numOfOutputCols);
SOperatorInfo* pOperator = createSysTableScanOperatorInfo( SOperatorInfo* pOperator = createSysTableScanOperatorInfo(
pHandle, pResBlock, &pScanNode->tableName, pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet, pHandle, pResBlock, &pScanNode->tableName, pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet, colList,
colList, pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId); pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId);
return pOperator; return pOperator;
} else { } else {
ASSERT(0); ASSERT(0);
...@@ -6649,8 +6658,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo ...@@ -6649,8 +6658,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
return pOptr; return pOptr;
} }
static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode) {
static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode) {
pCond->loadExternalRows = false; pCond->loadExternalRows = false;
pCond->order = pTableScanNode->scanSeq[0] > 0 ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; pCond->order = pTableScanNode->scanSeq[0] > 0 ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
...@@ -6664,7 +6672,7 @@ static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableS ...@@ -6664,7 +6672,7 @@ static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableS
pCond->twindow = pTableScanNode->scanRange; pCond->twindow = pTableScanNode->scanRange;
#if 1 #if 1
//todo work around a problem, remove it later // todo work around a problem, remove it later
if ((pCond->order == TSDB_ORDER_ASC && pCond->twindow.skey > pCond->twindow.ekey) || if ((pCond->order == TSDB_ORDER_ASC && pCond->twindow.skey > pCond->twindow.ekey) ||
(pCond->order == TSDB_ORDER_DESC && pCond->twindow.skey < pCond->twindow.ekey)) { (pCond->order == TSDB_ORDER_DESC && pCond->twindow.skey < pCond->twindow.ekey)) {
TSWAP(pCond->twindow.skey, pCond->twindow.ekey); TSWAP(pCond->twindow.skey, pCond->twindow.ekey);
...@@ -6708,22 +6716,22 @@ SArray* extractColumnInfo(SNodeList* pNodeList) { ...@@ -6708,22 +6716,22 @@ SArray* extractColumnInfo(SNodeList* pNodeList) {
// todo extract method // todo extract method
SColumn c = {0}; SColumn c = {0};
c.slotId = pColNode->slotId; c.slotId = pColNode->slotId;
c.colId = pColNode->colId; c.colId = pColNode->colId;
c.type = pColNode->node.resType.type; c.type = pColNode->node.resType.type;
c.bytes = pColNode->node.resType.bytes; c.bytes = pColNode->node.resType.bytes;
c.scale = pColNode->node.resType.scale; c.scale = pColNode->node.resType.scale;
c.precision = pColNode->node.resType.precision; c.precision = pColNode->node.resType.precision;
taosArrayPush(pList, &c); taosArrayPush(pList, &c);
} else if (nodeType(pNode->pExpr) == QUERY_NODE_VALUE) { } else if (nodeType(pNode->pExpr) == QUERY_NODE_VALUE) {
SValueNode* pValNode = (SValueNode*) pNode->pExpr; SValueNode* pValNode = (SValueNode*)pNode->pExpr;
SColumn c = {0}; SColumn c = {0};
c.slotId = pNode->slotId; c.slotId = pNode->slotId;
c.colId = pNode->slotId; c.colId = pNode->slotId;
c.type = pValNode->node.type; c.type = pValNode->node.type;
c.bytes = pValNode->node.resType.bytes; c.bytes = pValNode->node.resType.bytes;
c.scale = pValNode->node.resType.scale; c.scale = pValNode->node.resType.scale;
c.precision = pValNode->node.resType.precision; c.precision = pValNode->node.resType.precision;
taosArrayPush(pList, &c); taosArrayPush(pList, &c);
...@@ -6925,7 +6933,8 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead ...@@ -6925,7 +6933,8 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
goto _complete; goto _complete;
} }
(*pTaskInfo)->pRoot = createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, queryId, taskId, &(*pTaskInfo)->tableqinfoGroupInfo); (*pTaskInfo)->pRoot =
createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, queryId, taskId, &(*pTaskInfo)->tableqinfoGroupInfo);
if (NULL == (*pTaskInfo)->pRoot) { if (NULL == (*pTaskInfo)->pRoot) {
code = terrno; code = terrno;
goto _complete; goto _complete;
...@@ -7263,8 +7272,8 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf ...@@ -7263,8 +7272,8 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
pOperator->info = pInfo; pOperator->info = pInfo;
pOperator->pTaskInfo = pTaskInfo; pOperator->pTaskInfo = pTaskInfo;
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, NULL, destroyBasicOperatorInfo, pOperator->fpSet =
NULL, NULL, NULL); createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, NULL, destroyBasicOperatorInfo, NULL, NULL, NULL);
int32_t code = appendDownstream(pOperator, pDownstream, numOfDownstream); int32_t code = appendDownstream(pOperator, pDownstream, numOfDownstream);
return pOperator; return pOperator;
......
...@@ -47,6 +47,7 @@ static SKeyword keywordTable[] = { ...@@ -47,6 +47,7 @@ static SKeyword keywordTable[] = {
{"BNODE", TK_BNODE}, {"BNODE", TK_BNODE},
{"BNODES", TK_BNODES}, {"BNODES", TK_BNODES},
{"BOOL", TK_BOOL}, {"BOOL", TK_BOOL},
{"BUFFER", TK_BUFFER},
{"BUFSIZE", TK_BUFSIZE}, {"BUFSIZE", TK_BUFSIZE},
{"BY", TK_BY}, {"BY", TK_BY},
{"CACHE", TK_CACHE}, {"CACHE", TK_CACHE},
...@@ -132,6 +133,8 @@ static SKeyword keywordTable[] = { ...@@ -132,6 +133,8 @@ static SKeyword keywordTable[] = {
{"OUTPUTTYPE", TK_OUTPUTTYPE}, {"OUTPUTTYPE", TK_OUTPUTTYPE},
{"PARTITION", TK_PARTITION}, {"PARTITION", TK_PARTITION},
{"PASS", TK_PASS}, {"PASS", TK_PASS},
{"PAGES", TK_PAGES},
{"PAGESIZE", TK_PAGESIZE},
{"PORT", TK_PORT}, {"PORT", TK_PORT},
{"PPS", TK_PPS}, {"PPS", TK_PPS},
{"PRECISION", TK_PRECISION}, {"PRECISION", TK_PRECISION},
......
...@@ -1539,26 +1539,24 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS ...@@ -1539,26 +1539,24 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
tNameGetFullDbName(&name, pReq->db); tNameGetFullDbName(&name, pReq->db);
pReq->numOfVgroups = pStmt->pOptions->numOfVgroups; pReq->numOfVgroups = pStmt->pOptions->numOfVgroups;
pReq->numOfStables = pStmt->pOptions->singleStable;
pReq->buffer = pStmt->pOptions->buffer;
pReq->pageSize = pStmt->pOptions->pagesize;
pReq->pages = pStmt->pOptions->pages;
pReq->daysPerFile = pStmt->pOptions->daysPerFile; pReq->daysPerFile = pStmt->pOptions->daysPerFile;
pReq->daysToKeep0 = pStmt->pOptions->keep[0]; pReq->daysToKeep0 = pStmt->pOptions->keep[0];
pReq->daysToKeep1 = pStmt->pOptions->keep[1]; pReq->daysToKeep1 = pStmt->pOptions->keep[1];
pReq->daysToKeep2 = pStmt->pOptions->keep[2]; pReq->daysToKeep2 = pStmt->pOptions->keep[2];
pReq->minRows = pStmt->pOptions->minRowsPerBlock; pReq->minRows = pStmt->pOptions->minRowsPerBlock;
pReq->maxRows = pStmt->pOptions->maxRowsPerBlock; pReq->maxRows = pStmt->pOptions->maxRowsPerBlock;
pReq->commitTime = -1;
pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod;
pReq->walLevel = pStmt->pOptions->walLevel; pReq->walLevel = pStmt->pOptions->walLevel;
pReq->precision = pStmt->pOptions->precision; pReq->precision = pStmt->pOptions->precision;
pReq->compression = pStmt->pOptions->compressionLevel; pReq->compression = pStmt->pOptions->compressionLevel;
pReq->replications = pStmt->pOptions->replica; pReq->replications = pStmt->pOptions->replica;
pReq->update = -1; pReq->strict = pStmt->pOptions->strict;
pReq->cacheLastRow = pStmt->pOptions->cachelast; pReq->cacheLastRow = pStmt->pOptions->cachelast;
pReq->ignoreExist = pStmt->ignoreExists; pReq->ignoreExist = pStmt->ignoreExists;
pReq->singleSTable = pStmt->pOptions->singleStable;
pReq->strict = pStmt->pOptions->strict;
// pStmt->pOptions->buffer;
// pStmt->pOptions->pages;
// pStmt->pOptions->pagesize;
return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq); return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq);
} }
...@@ -1698,7 +1696,8 @@ static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbNa ...@@ -1698,7 +1696,8 @@ static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbNa
static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions, static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions,
bool alter) { bool alter) {
int32_t code = checkRangeOption(pCxt, "buffer", pOptions->buffer, TSDB_MIN_BUFFER_PER_VNODE, INT32_MAX); int32_t code =
checkRangeOption(pCxt, "buffer", pOptions->buffer, TSDB_MIN_BUFFER_PER_VNODE, TSDB_MAX_BUFFER_PER_VNODE);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = checkRangeOption(pCxt, "cacheLast", pOptions->cachelast, TSDB_MIN_DB_CACHE_LAST_ROW, code = checkRangeOption(pCxt, "cacheLast", pOptions->cachelast, TSDB_MIN_DB_CACHE_LAST_ROW,
TSDB_MAX_DB_CACHE_LAST_ROW); TSDB_MAX_DB_CACHE_LAST_ROW);
...@@ -1724,7 +1723,7 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName ...@@ -1724,7 +1723,7 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
code = checkDbKeepOption(pCxt, pOptions); code = checkDbKeepOption(pCxt, pOptions);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = checkRangeOption(pCxt, "pages", pOptions->pages, TSDB_MIN_PAGES_PER_VNODE, INT32_MAX); code = checkRangeOption(pCxt, "pages", pOptions->pages, TSDB_MIN_PAGES_PER_VNODE, TSDB_MAX_PAGES_PER_VNODE);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = checkRangeOption(pCxt, "pagesize", pOptions->pagesize, TSDB_MIN_PAGESIZE_PER_VNODE, code = checkRangeOption(pCxt, "pagesize", pOptions->pagesize, TSDB_MIN_PAGESIZE_PER_VNODE,
...@@ -1810,16 +1809,18 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, ...@@ -1810,16 +1809,18 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
SName name = {0}; SName name = {0};
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
tNameGetFullDbName(&name, pReq->db); tNameGetFullDbName(&name, pReq->db);
// pStmt->pOptions->buffer pReq->buffer = pStmt->pOptions->buffer;
pReq->cacheLastRow = pStmt->pOptions->cachelast; pReq->pageSize = -1;
pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; pReq->pages = pStmt->pOptions->pages;
pReq->daysPerFile = -1;
pReq->daysToKeep0 = pStmt->pOptions->keep[0]; pReq->daysToKeep0 = pStmt->pOptions->keep[0];
pReq->daysToKeep1 = pStmt->pOptions->keep[1]; pReq->daysToKeep1 = pStmt->pOptions->keep[1];
pReq->daysToKeep2 = pStmt->pOptions->keep[2]; pReq->daysToKeep2 = pStmt->pOptions->keep[2];
// pStmt->pOptions->pages pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod;
pReq->replications = pStmt->pOptions->replica;
pReq->strict = pStmt->pOptions->strict;
pReq->walLevel = pStmt->pOptions->walLevel; pReq->walLevel = pStmt->pOptions->walLevel;
pReq->strict = pStmt->pOptions->strict;
pReq->cacheLastRow = pStmt->pOptions->cachelast;
pReq->replications = pStmt->pOptions->replica;
return; return;
} }
......
...@@ -15,7 +15,15 @@ typedef int16_t (*_len_fn)(char *, int32_t); ...@@ -15,7 +15,15 @@ typedef int16_t (*_len_fn)(char *, int32_t);
/** Math functions **/ /** Math functions **/
static double tlog(double v, double base) { static double tlog(double v, double base) {
return log(v) / log(base); double a = log(v);
double b = log(base);
if (isnan(a) || isinf(a)) {
return a;
} else if (isnan(b) || isinf(b)) {
return b;
} else {
return a / b;
}
} }
int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
...@@ -160,22 +168,64 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S ...@@ -160,22 +168,64 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
} }
double *out = (double *)pOutputData->pData; double *out = (double *)pOutputData->pData;
double result;
int32_t numOfRows = MAX(pInput[0].numOfRows, pInput[1].numOfRows);
if (pInput[0].numOfRows == pInput[1].numOfRows) {
for (int32_t i = 0; i < numOfRows; ++i) {
if (colDataIsNull_s(pInputData[0], i) ||
colDataIsNull_s(pInputData[1], i)) {
colDataAppendNULL(pOutputData, i);
continue;
}
result = valFn(getValueFn[0](pInputData[0]->pData, i), getValueFn[1](pInputData[1]->pData, i));
if (isinf(result) || isnan(result)) {
colDataAppendNULL(pOutputData, i);
} else {
out[i] = result;
}
}
} else if (pInput[0].numOfRows == 1) { //left operand is constant
if (colDataIsNull_s(pInputData[0], 0)) {
colDataAppendNNULL(pOutputData, 0, pInput[1].numOfRows);
} else {
for (int32_t i = 0; i < numOfRows; ++i) {
if (colDataIsNull_s(pInputData[1], i)) {
colDataAppendNULL(pOutputData, i);
continue;
}
for (int32_t i = 0; i < pInput->numOfRows; ++i) { result = valFn(getValueFn[0](pInputData[0]->pData, 0), getValueFn[1](pInputData[1]->pData, i));
if (colDataIsNull_s(pInputData[0], i) || if (isinf(result) || isnan(result)) {
colDataIsNull_s(pInputData[1], 0)) { colDataAppendNULL(pOutputData, i);
colDataAppendNULL(pOutputData, i); continue;
continue; }
out[i] = result;
}
} }
double result = valFn(getValueFn[0](pInputData[0]->pData, i), getValueFn[1](pInputData[1]->pData, 0)); } else if (pInput[1].numOfRows == 1) {
if (isinf(result) || isnan(result)) { if (colDataIsNull_s(pInputData[1], 0)) {
colDataAppendNULL(pOutputData, i); colDataAppendNNULL(pOutputData, 0, pInput[0].numOfRows);
} else { } else {
out[i] = result; for (int32_t i = 0; i < numOfRows; ++i) {
if (colDataIsNull_s(pInputData[0], i)) {
colDataAppendNULL(pOutputData, i);
continue;
}
result = valFn(getValueFn[0](pInputData[0]->pData, i), getValueFn[1](pInputData[1]->pData, 0));
if (isinf(result) || isnan(result)) {
colDataAppendNULL(pOutputData, i);
continue;
}
out[i] = result;
}
} }
} }
pOutput->numOfRows = pInput->numOfRows; pOutput->numOfRows = numOfRows;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -54,15 +54,28 @@ static int64_t adjustInterval(int64_t interval, int32_t precision) { ...@@ -54,15 +54,28 @@ static int64_t adjustInterval(int64_t interval, int32_t precision) {
if (precision != TSDB_TIME_PRECISION_MILLI) { if (precision != TSDB_TIME_PRECISION_MILLI) {
val = convertTimePrecision(interval, precision, TSDB_TIME_PRECISION_MILLI); val = convertTimePrecision(interval, precision, TSDB_TIME_PRECISION_MILLI);
} }
if (val < MIN_INTERVAL) {
val = MIN_INTERVAL; if (val <= 0 || val > MAX_INTERVAL) {
} else if (val > MAX_INTERVAL) {
val = MAX_INTERVAL; val = MAX_INTERVAL;
} else if (val < MIN_INTERVAL) {
val = MIN_INTERVAL;
}
if (precision != TSDB_TIME_PRECISION_MILLI) {
val = convertTimePrecision(val, TSDB_TIME_PRECISION_MILLI, precision);
} }
val = convertTimePrecision(val, TSDB_TIME_PRECISION_MILLI, precision);
return val; return val;
} }
static int64_t adjustWatermark(int64_t interval, int32_t watermark) {
if (watermark <= 0 || watermark > MAX_NUM_SCALABLE_BF * interval) {
watermark = MAX_NUM_SCALABLE_BF * interval;
} else if (watermark < MIN_NUM_SCALABLE_BF * interval) {
watermark = MIN_NUM_SCALABLE_BF * interval;
}
return watermark;
}
SUpdateInfo *updateInfoInitP(SInterval* pInterval, int64_t watermark) { SUpdateInfo *updateInfoInitP(SInterval* pInterval, int64_t watermark) {
return updateInfoInit(pInterval->interval, pInterval->precision, watermark); return updateInfoInit(pInterval->interval, pInterval->precision, watermark);
} }
...@@ -76,14 +89,9 @@ SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t waterma ...@@ -76,14 +89,9 @@ SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t waterma
pInfo->pTsSBFs = NULL; pInfo->pTsSBFs = NULL;
pInfo->minTS = -1; pInfo->minTS = -1;
pInfo->interval = adjustInterval(interval, precision); pInfo->interval = adjustInterval(interval, precision);
pInfo->watermark = watermark; pInfo->watermark = adjustWatermark(pInfo->interval, watermark);
uint64_t bfSize = (uint64_t)(watermark / pInfo->interval); uint64_t bfSize = (uint64_t)(pInfo->watermark / pInfo->interval);
if (bfSize < MIN_NUM_SCALABLE_BF) {
bfSize = MIN_NUM_SCALABLE_BF;
} else if (bfSize > MAX_NUM_SCALABLE_BF) {
bfSize = MAX_NUM_SCALABLE_BF;
}
pInfo->pTsSBFs = taosArrayInit(bfSize, sizeof(SScalableBf)); pInfo->pTsSBFs = taosArrayInit(bfSize, sizeof(SScalableBf));
if (pInfo->pTsSBFs == NULL) { if (pInfo->pTsSBFs == NULL) {
......
...@@ -90,11 +90,21 @@ TEST(TD_STREAM_UPDATE_TEST, update) { ...@@ -90,11 +90,21 @@ TEST(TD_STREAM_UPDATE_TEST, update) {
} }
} }
SUpdateInfo *pSU4 = updateInfoInit(-1, TSDB_TIME_PRECISION_MILLI, -1);
GTEST_ASSERT_EQ(pSU4->watermark, 120 * pSU4->interval);
GTEST_ASSERT_EQ(pSU4->interval, MILLISECOND_PER_MINUTE);
SUpdateInfo *pSU5 = updateInfoInit(0, TSDB_TIME_PRECISION_MILLI, 0);
GTEST_ASSERT_EQ(pSU5->watermark, 120 * pSU4->interval);
GTEST_ASSERT_EQ(pSU5->interval, MILLISECOND_PER_MINUTE);
updateInfoDestroy(pSU); updateInfoDestroy(pSU);
updateInfoDestroy(pSU1); updateInfoDestroy(pSU1);
updateInfoDestroy(pSU2); updateInfoDestroy(pSU2);
updateInfoDestroy(pSU3); updateInfoDestroy(pSU3);
updateInfoDestroy(pSU4);
updateInfoDestroy(pSU5);
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
......
...@@ -250,6 +250,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_NOT_EXIST, "Tag does not exist") ...@@ -250,6 +250,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_NOT_EXIST, "Tag does not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_COLUMNS, "Too many columns") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_COLUMNS, "Too many columns")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_ALREADY_EXIST, "Column already exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_ALREADY_EXIST, "Column already exists")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_NOT_EXIST, "Column does not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_NOT_EXIST, "Column does not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SINGLE_STB_MODE_DB, "Database is single stable mode")
// mnode-infoSchema // mnode-infoSchema
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SYS_TABLENAME, "Invalid system table name") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SYS_TABLENAME, "Invalid system table name")
......
...@@ -58,11 +58,11 @@ endi ...@@ -58,11 +58,11 @@ endi
print ============= create database print ============= create database
#database_option: { #database_option: {
# BLOCKS value [3~1000, default: 6] # | BUFFER value [3~16384, default: 96]
# | PAGES value [64~16384, default: 256]
# | CACHELAST value [0, 1, 2, 3] # | CACHELAST value [0, 1, 2, 3]
# | FSYNC value [0 ~ 180000 ms] # | FSYNC value [0 ~ 180000 ms]
# | KEEP value [days, 365000] # | KEEP value [days, 365000]
# | QUORUM value [1 | 2]
# | REPLICA value [1 | 3] # | REPLICA value [1 | 3]
# | WAL value [1 | 2] # | WAL value [1 | 2]
...@@ -98,31 +98,34 @@ endi ...@@ -98,31 +98,34 @@ endi
if $data7_db != 1440000,1440000,1440000 then # keep if $data7_db != 1440000,1440000,1440000 then # keep
return -1 return -1
endi endi
#if $data8_db != 3 then # cache if $data8_db != 96 then # buffer
# return -1 return -1
#endi endi
#if $data9_db != 7 then # blocks if $data9_db != 4 then # pagesize
# return -1 return -1
#endi endi
if $data10_db != 10 then # minrows if $data10_db != 256 then # pages
return -1
endi
if $data11_db != 10 then # minrows
return -1 return -1
endi endi
if $data11_db != 8000 then # maxrows if $data12_db != 8000 then # maxrows
return -1 return -1
endi endi
if $data12_db != 2 then # wal if $data13_db != 2 then # wal
return -1 return -1
endi endi
if $data13_db != 1000 then # fsync if $data14_db != 1000 then # fsync
return -1 return -1
endi endi
if $data14_db != 0 then # comp if $data15_db != 0 then # comp
return -1 return -1
endi endi
if $data15_db != 3 then # cachelast if $data16_db != 3 then # cachelast
return -1 return -1
endi endi
if $data16_db != ns then # precision if $data17_db != ns then # precision
return -1 return -1
endi endi
...@@ -302,14 +305,14 @@ sql_error alter database db maxrows 10 # little than minrows ...@@ -302,14 +305,14 @@ sql_error alter database db maxrows 10 # little than minrows
print ============== step wal print ============== step wal
sql alter database db wal 1 sql alter database db wal 1
sql show databases sql show databases
print wal $data12_db print wal $data13_db
if $data12_db != 1 then if $data13_db != 1 then
return -1 return -1
endi endi
sql alter database db wal 2 sql alter database db wal 2
sql show databases sql show databases
print wal $data12_db print wal $data13_db
if $data12_db != 2 then if $data13_db != 2 then
return -1 return -1
endi endi
...@@ -321,20 +324,20 @@ sql_error alter database db wal -1 ...@@ -321,20 +324,20 @@ sql_error alter database db wal -1
print ============== modify fsync print ============== modify fsync
sql alter database db fsync 2000 sql alter database db fsync 2000
sql show databases sql show databases
print fsync $data13_db print fsync $data14_db
if $data13_db != 2000 then if $data14_db != 2000 then
return -1 return -1
endi endi
sql alter database db fsync 500 sql alter database db fsync 500
sql show databases sql show databases
print fsync $data13_db print fsync $data14_db
if $data13_db != 500 then if $data14_db != 500 then
return -1 return -1
endi endi
sql alter database db fsync 0 sql alter database db fsync 0
sql show databases sql show databases
print fsync $data13_db print fsync $data14_db
if $data13_db != 0 then if $data14_db != 0 then
return -1 return -1
endi endi
sql_error alter database db fsync 180001 sql_error alter database db fsync 180001
...@@ -353,32 +356,32 @@ sql_error alter database db comp -1 ...@@ -353,32 +356,32 @@ sql_error alter database db comp -1
print ============== modify cachelast [0, 1, 2, 3] print ============== modify cachelast [0, 1, 2, 3]
sql alter database db cachelast 2 sql alter database db cachelast 2
sql show databases sql show databases
print cachelast $data15_db print cachelast $data16_db
if $data15_db != 2 then if $data16_db != 2 then
return -1 return -1
endi endi
sql alter database db cachelast 1 sql alter database db cachelast 1
sql show databases sql show databases
print cachelast $data15_db print cachelast $data16_db
if $data15_db != 1 then if $data16_db != 1 then
return -1 return -1
endi endi
sql alter database db cachelast 0 sql alter database db cachelast 0
sql show databases sql show databases
print cachelast $data15_db print cachelast $data16_db
if $data15_db != 0 then if $data16_db != 0 then
return -1 return -1
endi endi
sql alter database db cachelast 2 sql alter database db cachelast 2
sql show databases sql show databases
print cachelast $data15_db print cachelast $data16_db
if $data15_db != 2 then if $data16_db != 2 then
return -1 return -1
endi endi
sql alter database db cachelast 3 sql alter database db cachelast 3
sql show databases sql show databases
print cachelast $data15_db print cachelast $data16_db
if $data15_db != 3 then if $data16_db != 3 then
return -1 return -1
endi endi
......
...@@ -58,8 +58,9 @@ endi ...@@ -58,8 +58,9 @@ endi
print ============= create database with all options print ============= create database with all options
#database_option: { #database_option: {
# | BLOCKS value [3~1000, default: 6] # | BUFFER value [3~16384, default: 96]
# | CACHE value [default: 16] # | PAGES value [64~16384, default: 256]
# | PAGESIZE value [1~16384, default: 4]
# | CACHELAST value [0, 1, 2, 3, default: 0] # | CACHELAST value [0, 1, 2, 3, default: 0]
# | COMP [0 | 1 | 2, default: 2] # | COMP [0 | 1 | 2, default: 2]
# | DAYS value [60m ~ min(3650d,keep), default: 10d, unit may be minut/hour/day] # | DAYS value [60m ~ min(3650d,keep), default: 10d, unit may be minut/hour/day]
...@@ -68,24 +69,18 @@ print ============= create database with all options ...@@ -68,24 +69,18 @@ print ============= create database with all options
# | MINROWS value [10~1000, default: 100] # | MINROWS value [10~1000, default: 100]
# | KEEP value [max(1d ~ 365000d), default: 1d, unit may be minut/hour/day] # | KEEP value [max(1d ~ 365000d), default: 1d, unit may be minut/hour/day]
# | PRECISION ['ms' | 'us' | 'ns', default: ms] # | PRECISION ['ms' | 'us' | 'ns', default: ms]
# | QUORUM value [1 | 2, default: 1]
# | REPLICA value [1 | 3, default: 1] # | REPLICA value [1 | 3, default: 1]
# | TTL value [1d ~ , default: 1]
# | WAL value [1 | 2, default: 1] # | WAL value [1 | 2, default: 1]
# | VGROUPS value [default: 2] # | VGROUPS value [default: 2]
# | SINGLE_STABLE [0 | 1, default: ] # | SINGLE_STABLE [0 | 1, default: ]
# | STREAM_MODE [0 | 1, default: ]
# #
#$data0_db : name #$data0_db : name
#$data1_db : create_time #$data1_db : create_time
#$data2_db : vgroups #$data2_db : vgroups
#$data3_db : ntables #$data3_db : ntables
#$data4_db : replica #$data4_db : replica
#$data5_db : quorum
#$data6_db : days #$data6_db : days
#$data7_db : keep #$data7_db : keep
#$data8_db : cache
#$data9_db : blocks
#$data10_db : minrows #$data10_db : minrows
#$data11_db : maxrows #$data11_db : maxrows
#$data12_db : wal #$data12_db : wal
...@@ -124,31 +119,34 @@ endi ...@@ -124,31 +119,34 @@ endi
if $data7_db != 5256000,5256000,5256000 then # keep if $data7_db != 5256000,5256000,5256000 then # keep
return -1 return -1
endi endi
#if $data8_db != 16 then # cache if $data8_db != 96 then # buffer
# return -1 return -1
#endi endi
#if $data9_db != 6 then # blocks if $data9_db != 4 then # pagesize
# return -1 return -1
#endi endi
if $data10_db != 100 then # minrows if $data10_db != 256 then # pages
return -1
endi
if $data11_db != 100 then # minrows
return -1 return -1
endi endi
if $data11_db != 4096 then # maxrows if $data12_db != 4096 then # maxrows
return -1 return -1
endi endi
if $data12_db != 1 then # wal if $data13_db != 1 then # wal
return -1 return -1
endi endi
if $data13_db != 3000 then # fsync if $data14_db != 3000 then # fsync
return -1 return -1
endi endi
if $data14_db != 2 then # comp if $data15_db != 2 then # comp
return -1 return -1
endi endi
if $data15_db != 0 then # cachelast if $data16_db != 0 then # cachelast
return -1 return -1
endi endi
if $data16_db != ms then # precision if $data17_db != ms then # precision
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -194,7 +192,7 @@ print ====> CACHELAST value [0, 1, 2, 3, default: 0] ...@@ -194,7 +192,7 @@ print ====> CACHELAST value [0, 1, 2, 3, default: 0]
sql create database db CACHELAST 1 sql create database db CACHELAST 1
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data15_db != 1 then if $data16_db != 1 then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -202,7 +200,7 @@ sql drop database db ...@@ -202,7 +200,7 @@ sql drop database db
sql create database db CACHELAST 2 sql create database db CACHELAST 2
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data15_db != 2 then if $data16_db != 2 then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -210,7 +208,7 @@ sql drop database db ...@@ -210,7 +208,7 @@ sql drop database db
sql create database db CACHELAST 3 sql create database db CACHELAST 3
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data15_db != 3 then if $data16_db != 3 then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -221,7 +219,7 @@ print ====> COMP [0 | 1 | 2, default: 2] ...@@ -221,7 +219,7 @@ print ====> COMP [0 | 1 | 2, default: 2]
sql create database db COMP 1 sql create database db COMP 1
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data14_db != 1 then if $data15_db != 1 then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -229,7 +227,7 @@ sql drop database db ...@@ -229,7 +227,7 @@ sql drop database db
sql create database db COMP 0 sql create database db COMP 0
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data14_db != 0 then if $data15_db != 0 then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -280,7 +278,7 @@ print ====> FSYNC value [0 ~ 180000 ms, default: 3000] ...@@ -280,7 +278,7 @@ print ====> FSYNC value [0 ~ 180000 ms, default: 3000]
sql create database db FSYNC 0 sql create database db FSYNC 0
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data13_db != 0 then if $data14_db != 0 then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -288,7 +286,7 @@ sql drop database db ...@@ -288,7 +286,7 @@ sql drop database db
sql create database db FSYNC 180000 sql create database db FSYNC 180000
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data13_db != 180000 then if $data14_db != 180000 then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -299,10 +297,10 @@ print ====> MAXROWS value [200~10000, default: 4096], MINROWS value [10~1000, de ...@@ -299,10 +297,10 @@ print ====> MAXROWS value [200~10000, default: 4096], MINROWS value [10~1000, de
sql create database db MAXROWS 10000 MINROWS 1000 sql create database db MAXROWS 10000 MINROWS 1000
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data10_db != 1000 then if $data11_db != 1000 then
return -1 return -1
endi endi
if $data11_db != 10000 then if $data12_db != 10000 then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -310,10 +308,10 @@ sql drop database db ...@@ -310,10 +308,10 @@ sql drop database db
sql create database db MAXROWS 200 MINROWS 10 sql create database db MAXROWS 200 MINROWS 10
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data10_db != 10 then if $data11_db != 10 then
return -1 return -1
endi endi
if $data11_db != 200 then if $data12_db != 200 then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -331,7 +329,7 @@ print ====> PRECISION ['ms' | 'us' | 'ns', default: ms] ...@@ -331,7 +329,7 @@ print ====> PRECISION ['ms' | 'us' | 'ns', default: ms]
sql create database db PRECISION 'us' sql create database db PRECISION 'us'
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data16_db != us then if $data17_db != us then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -339,7 +337,7 @@ sql drop database db ...@@ -339,7 +337,7 @@ sql drop database db
sql create database db PRECISION 'ns' sql create database db PRECISION 'ns'
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data16_db != ns then if $data17_db != ns then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -412,7 +410,7 @@ print ====> WAL value [1 | 2, default: 1] ...@@ -412,7 +410,7 @@ print ====> WAL value [1 | 2, default: 1]
sql create database db WAL 2 sql create database db WAL 2
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data12_db != 2 then if $data13_db != 2 then
return -1 return -1
endi endi
sql drop database db sql drop database db
...@@ -420,7 +418,7 @@ sql drop database db ...@@ -420,7 +418,7 @@ sql drop database db
sql create database db WAL 1 sql create database db WAL 1
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data12_db != 1 then if $data13_db != 1 then
return -1 return -1
endi endi
sql drop database db sql drop database db
......
...@@ -83,7 +83,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat ...@@ -83,7 +83,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data(db)[20] != ready then if $data(db)[19] != ready then
goto check_db_ready goto check_db_ready
endi endi
......
...@@ -83,7 +83,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat ...@@ -83,7 +83,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data(db)[20] != ready then if $data(db)[19] != ready then
goto check_db_ready goto check_db_ready
endi endi
......
...@@ -83,7 +83,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat ...@@ -83,7 +83,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data(db)[20] != ready then if $data(db)[19] != ready then
goto check_db_ready goto check_db_ready
endi endi
......
...@@ -83,7 +83,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat ...@@ -83,7 +83,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data(db)[20] != ready then if $data(db)[19] != ready then
goto check_db_ready goto check_db_ready
endi endi
......
...@@ -39,7 +39,7 @@ sql show databases ...@@ -39,7 +39,7 @@ sql show databases
print ==> rows: $rows print ==> rows: $rows
print ==> $data(db)[0] $data(db)[1] $data(db)[2] $data(db)[3] $data(db)[4] $data(db)[5] $data(db)[6] $data(db)[7] $data(db)[8] $data(db)[9] $data(db)[10] $data(db)[11] $data(db)[12] print ==> $data(db)[0] $data(db)[1] $data(db)[2] $data(db)[3] $data(db)[4] $data(db)[5] $data(db)[6] $data(db)[7] $data(db)[8] $data(db)[9] $data(db)[10] $data(db)[11] $data(db)[12]
print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $data(db)[18] $data(db)[19] $data(db)[20] print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $data(db)[18] $data(db)[19] $data(db)[20]
if $data(db)[20] != nostrict then if $data(db)[19] != nostrict then
sleep 100 sleep 100
$loop_cnt = $loop_cnt + 1 $loop_cnt = $loop_cnt + 1
goto check_db_ready goto check_db_ready
......
...@@ -39,7 +39,7 @@ sql show databases ...@@ -39,7 +39,7 @@ sql show databases
print ==> rows: $rows print ==> rows: $rows
print ==> $data(db)[0] $data(db)[1] $data(db)[2] $data(db)[3] $data(db)[4] $data(db)[5] $data(db)[6] $data(db)[7] $data(db)[8] $data(db)[9] $data(db)[10] $data(db)[11] $data(db)[12] print ==> $data(db)[0] $data(db)[1] $data(db)[2] $data(db)[3] $data(db)[4] $data(db)[5] $data(db)[6] $data(db)[7] $data(db)[8] $data(db)[9] $data(db)[10] $data(db)[11] $data(db)[12]
print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $data(db)[18] $data(db)[19] $data(db)[20] print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $data(db)[18] $data(db)[19] $data(db)[20]
if $data(db)[20] != nostrict then if $data(db)[19] != nostrict then
sleep 100 sleep 100
$loop_cnt = $loop_cnt + 1 $loop_cnt = $loop_cnt + 1
goto check_db_ready goto check_db_ready
......
...@@ -73,17 +73,19 @@ class TDTestCase: ...@@ -73,17 +73,19 @@ class TDTestCase:
hostname = socket.gethostname() hostname = socket.gethostname()
serverPort = '7080' serverPort = '7080'
rpcDebugFlagVal = '143' rpcDebugFlagVal = '143'
clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135'} clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
clientCfgDict["serverPort"] = serverPort clientCfgDict["serverPort"] = serverPort
clientCfgDict["firstEp"] = hostname + ':' + serverPort clientCfgDict["firstEp"] = hostname + ':' + serverPort
clientCfgDict["secondEp"] = hostname + ':' + serverPort clientCfgDict["secondEp"] = hostname + ':' + serverPort
clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal
clientCfgDict["fqdn"] = hostname
updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':''} updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
updatecfgDict["clientCfg"] = clientCfgDict updatecfgDict["clientCfg"] = clientCfgDict
updatecfgDict["serverPort"] = serverPort updatecfgDict["serverPort"] = serverPort
updatecfgDict["firstEp"] = hostname + ':' + serverPort updatecfgDict["firstEp"] = hostname + ':' + serverPort
updatecfgDict["secondEp"] = hostname + ':' + serverPort updatecfgDict["secondEp"] = hostname + ':' + serverPort
updatecfgDict["fqdn"] = hostname
print ("===================: ", updatecfgDict) print ("===================: ", updatecfgDict)
...@@ -288,7 +290,7 @@ class TDTestCase: ...@@ -288,7 +290,7 @@ class TDTestCase:
retCode = taos_command(buildPath, "f", keyDict['f'], 'performance_schema', keyDict['c'], '', '', '') retCode = taos_command(buildPath, "f", keyDict['f'], 'performance_schema', keyDict['c'], '', '', '')
print("============ ret code: ", retCode) print("============ ret code: ", retCode)
if retCode != "TAOS_OK": if retCode != "TAOS_OK":
tdLog.exit("taos -s fail") tdLog.exit("taos -f fail")
print ("========== check new db ==========") print ("========== check new db ==========")
tdSql.query("show databases") tdSql.query("show databases")
......
import taos
import sys
import time
import socket
import pexpect
import os
from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import *
def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''):
if len(key) == 0:
tdLog.exit("taos test key is null!")
taosCmd = buildPath + '/build/bin/taos '
if len(cfgDir) != 0:
taosCmd = taosCmd + '-c ' + cfgDir
taosCmd = taosCmd + ' -' + key
if len(value) != 0:
if key == 'p':
taosCmd = taosCmd + value
else:
taosCmd = taosCmd + ' ' + value
if len(key1) != 0:
taosCmd = taosCmd + ' -' + key1
if key1 == 'p':
taosCmd = taosCmd + value1
else:
if len(value1) != 0:
taosCmd = taosCmd + ' ' + value1
tdLog.info ("taos cmd: %s" % taosCmd)
child = pexpect.spawn(taosCmd, timeout=3)
#output = child.readline()
#print (output.decode())
if len(expectString) != 0:
i = child.expect([expectString, pexpect.TIMEOUT, pexpect.EOF], timeout=6)
else:
i = child.expect([pexpect.TIMEOUT, pexpect.EOF], timeout=6)
retResult = child.before.decode()
print("cmd return result:\n%s\n"%retResult)
#print(child.after.decode())
if i == 0:
print ('taos login success! Here can run sql, taos> ')
if len(sqlString) != 0:
child.sendline (sqlString)
w = child.expect(["Query OK", pexpect.TIMEOUT, pexpect.EOF], timeout=1)
retResult = child.before.decode()
if w == 0:
return "TAOS_OK", retResult
else:
return "TAOS_FAIL", retResult
else:
if key == 'A' or key1 == 'A' or key == 'C' or key1 == 'C' or key == 'V' or key1 == 'V':
return "TAOS_OK", retResult
else:
return "TAOS_OK", retResult
else:
if key == 'A' or key1 == 'A' or key == 'C' or key1 == 'C' or key == 'V' or key1 == 'V':
return "TAOS_OK", retResult
else:
return "TAOS_FAIL", retResult
class TDTestCase:
#updatecfgDict = {'clientCfg': {'serverPort': 7080, 'firstEp': 'trd02:7080', 'secondEp':'trd02:7080'},\
# 'serverPort': 7080, 'firstEp': 'trd02:7080'}
hostname = socket.gethostname()
serverPort = '7080'
rpcDebugFlagVal = '143'
clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
clientCfgDict["serverPort"] = serverPort
clientCfgDict["firstEp"] = hostname + ':' + serverPort
clientCfgDict["secondEp"] = hostname + ':' + serverPort
clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal
clientCfgDict["fqdn"] = hostname
updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
updatecfgDict["clientCfg"] = clientCfgDict
updatecfgDict["serverPort"] = serverPort
updatecfgDict["firstEp"] = hostname + ':' + serverPort
updatecfgDict["secondEp"] = hostname + ':' + serverPort
clientCfgDict["fqdn"] = hostname
print ("===================: ", updatecfgDict)
def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor())
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosd" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql.prepare()
# time.sleep(2)
tdSql.query("create user testpy pass 'testpy'")
#hostname = socket.gethostname()
#tdLog.info ("hostname: %s" % hostname)
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosd not found!")
else:
tdLog.info("taosd found in %s" % buildPath)
cfgPath = buildPath + "/../sim/psim/cfg"
tdLog.info("cfgPath: %s" % cfgPath)
checkNetworkStatus = ['0: unavailable', '1: network ok', '2: service ok', '3: service degraded', '4: exiting']
netrole = ['client', 'server']
keyDict = {'h':'', 'P':'6030', 'p':'testpy', 'u':'testpy', 'a':'', 'A':'', 'c':'', 'C':'', 's':'', 'r':'', 'f':'', \
'k':'', 't':'', 'n':'', 'l':'1024', 'N':'100', 'V':'', 'd':'db', 'w':'30', '-help':'', '-usage':'', '?':''}
keyDict['h'] = self.hostname
keyDict['c'] = cfgPath
keyDict['P'] = self.serverPort
tdLog.printNoPrefix("================================ parameter: -h wiht error value")
#newDbName="dbh"
#sqlString = 'create database ' + newDbName + ';'
keyDict['h'] = 'abc'
retCode, retVal = taos_command(buildPath, "h", keyDict['h'], "taos>", keyDict['c'], '')
if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal):
tdLog.info("taos -h %s test suceess"%keyDict['h'])
else:
tdLog.exit("taos -h %s fail"%keyDict['h'])
keyDict['h'] = '\'abc\''
retCode, retVal = taos_command(buildPath, "h", keyDict['h'], "taos>", keyDict['c'], '')
if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal):
tdLog.info("taos -h %s test suceess"%keyDict['h'])
else:
tdLog.exit("taos -h %s fail"%keyDict['h'])
keyDict['h'] = '3'
retCode, retVal = taos_command(buildPath, "h", keyDict['h'], "taos>", keyDict['c'], '')
if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal):
tdLog.info("taos -h %s test suceess"%keyDict['h'])
else:
tdLog.exit("taos -h %s fail"%keyDict['h'])
keyDict['h'] = '\'3\''
retCode, retVal = taos_command(buildPath, "h", keyDict['h'], "taos>", keyDict['c'], '')
if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal):
tdLog.info("taos -h %s test suceess"%keyDict['h'])
else:
tdLog.exit("taos -h %s fail"%keyDict['h'])
tdLog.printNoPrefix("================================ parameter: -P wiht error value")
#newDbName="dbh"
#sqlString = 'create database ' + newDbName + ';'
keyDict['P'] = 'abc'
retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '')
if (retCode == "TAOS_FAIL") and ("Invalid port" in retVal):
tdLog.info("taos -P %s test suceess"%keyDict['P'])
else:
tdLog.exit("taos -P %s fail"%keyDict['P'])
keyDict['P'] = '\'abc\''
retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '')
if (retCode == "TAOS_FAIL") and ("Invalid port" in retVal):
tdLog.info("taos -P %s test suceess"%keyDict['P'])
else:
tdLog.exit("taos -P %s fail"%keyDict['P'])
keyDict['P'] = '3'
retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '')
if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal):
tdLog.info("taos -P %s test suceess"%keyDict['P'])
else:
tdLog.exit("taos -P %s fail"%keyDict['P'])
keyDict['P'] = '\'3\''
retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '')
if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal):
tdLog.info("taos -P %s test suceess"%keyDict['P'])
else:
tdLog.exit("taos -P %s fail"%keyDict['P'])
keyDict['P'] = '12ab'
retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '')
if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal):
tdLog.info("taos -P %s test suceess"%keyDict['P'])
else:
tdLog.exit("taos -P %s fail"%keyDict['P'])
keyDict['P'] = '\'12ab\''
retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '')
if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal):
tdLog.info("taos -P %s test suceess"%keyDict['P'])
else:
tdLog.exit("taos -P %s fail"%keyDict['P'])
tdLog.printNoPrefix("================================ parameter: -f with error sql ")
pwd=os.getcwd()
newDbName="dbf"
sqlFile = pwd + "/0-others/sql.txt"
sql1 = "echo 'create database " + newDbName + "' > " + sqlFile
sql2 = "echo 'use " + newDbName + "' >> " + sqlFile
sql3 = "echo 'create table ntbf (ts timestamp, c binary(40)) no this item' >> " + sqlFile
sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile
sql5 = "echo 'show databases' >> " + sqlFile
os.system(sql1)
os.system(sql2)
os.system(sql3)
os.system(sql4)
os.system(sql5)
keyDict['f'] = pwd + "/0-others/sql.txt"
retCode, retVal = taos_command(buildPath, "f", keyDict['f'], 'performance_schema', keyDict['c'], '', '', '')
#print("============ ret code: ", retCode)
if retCode != "TAOS_OK":
tdLog.exit("taos -f fail")
print ("========== check new db ==========")
tdSql.query("show databases")
for i in range(tdSql.queryRows):
#print ("dbseq: %d, dbname: %s"%(i, tdSql.getData(i, 0)))
if tdSql.getData(i, 0) == newDbName:
break
else:
tdLog.exit("create db fail after taos -f fail")
sqlString = "select * from " + newDbName + ".ntbf"
tdSql.error(sqlString)
shellCmd = "rm -f " + sqlFile
os.system(shellCmd)
keyDict['f'] = pwd + "/0-others/noexistfile.txt"
retCode, retVal = taos_command(buildPath, "f", keyDict['f'], 'failed to open file', keyDict['c'], '', '', '')
#print("============ ret code: ", retCode)
if retCode != "TAOS_OK":
tdLog.exit("taos -f fail")
tdSql.query('drop database %s'%newDbName)
tdLog.printNoPrefix("================================ parameter: -a with error value")
#newDbName="dba"
errorPassword = 'errorPassword'
sqlString = 'create database ' + newDbName + ';'
retCode, retVal = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'a', errorPassword)
if retCode != "TAOS_FAIL":
tdLog.exit("taos -u %s -a %s"%(keyDict['u'], errorPassword))
tdLog.printNoPrefix("================================ parameter: -p with error value")
#newDbName="dba"
keyDict['p'] = 'errorPassword'
retCode, retVal = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'p', keyDict['p'])
if retCode == "TAOS_FAIL" and "Authentication failure" in retVal:
tdLog.info("taos -p %s test suceess"%keyDict['p'])
else:
tdLog.exit("taos -u %s -p %s"%(keyDict['u'], keyDict['p']))
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())
#!/bin/bash #!/bin/bash
set -e set -e
set -x
python3 ./test.py -f 0-others/taosShell.py python3 ./test.py -f 0-others/taosShell.py
......
...@@ -93,6 +93,7 @@ function runSimCaseOneByOnefq { ...@@ -93,6 +93,7 @@ function runSimCaseOneByOnefq {
if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then
#case=`echo $line | grep sim$ |awk '{print $NF}'` #case=`echo $line | grep sim$ |awk '{print $NF}'`
case=`echo $line | grep -o ".*\.sim" |awk '{print $NF}'` case=`echo $line | grep -o ".*\.sim" |awk '{print $NF}'`
echo "$line running ..."
start_time=`date +%s` start_time=`date +%s`
date +%F\ %T | tee -a out.log date +%F\ %T | tee -a out.log
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册