Merge remote-tracking branch 'origin/3.0' into feature/dnode3
This commit is contained in:
commit
89d1c6f66f
|
@ -62,6 +62,12 @@ typedef struct SConstantItem {
|
||||||
SVariant value;
|
SVariant value;
|
||||||
} SConstantItem;
|
} SConstantItem;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t numOfTables;
|
||||||
|
SArray *pGroupList;
|
||||||
|
SHashObj *map; // speedup acquire the tableQueryInfo by table uid
|
||||||
|
} STableGroupInfo;
|
||||||
|
|
||||||
typedef struct SSDataBlock {
|
typedef struct SSDataBlock {
|
||||||
SColumnDataAgg *pBlockAgg;
|
SColumnDataAgg *pBlockAgg;
|
||||||
SArray *pDataBlock; // SArray<SColumnInfoData>
|
SArray *pDataBlock; // SArray<SColumnInfoData>
|
||||||
|
|
|
@ -986,6 +986,14 @@ typedef struct {
|
||||||
char msg[];
|
char msg[];
|
||||||
} SSubQueryMsg;
|
} SSubQueryMsg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SMsgHead header;
|
||||||
|
uint64_t sId;
|
||||||
|
uint64_t queryId;
|
||||||
|
uint64_t taskId;
|
||||||
|
} SSinkDataReq;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMsgHead header;
|
SMsgHead header;
|
||||||
uint64_t sId;
|
uint64_t sId;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "mallocator.h"
|
#include "mallocator.h"
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -39,6 +40,10 @@ typedef struct STable {
|
||||||
STSchema *pSchema;
|
STSchema *pSchema;
|
||||||
} STable;
|
} STable;
|
||||||
|
|
||||||
|
#define BLOCK_LOAD_OFFSET_SEQ_ORDER 1
|
||||||
|
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
|
||||||
|
#define BLOCK_LOAD_TABLE_RR_ORDER 3
|
||||||
|
|
||||||
#define TABLE_TID(t) (t)->tid
|
#define TABLE_TID(t) (t)->tid
|
||||||
#define TABLE_UID(t) (t)->uid
|
#define TABLE_UID(t) (t)->uid
|
||||||
|
|
||||||
|
@ -58,6 +63,22 @@ typedef struct STsdbCfg {
|
||||||
int8_t compression;
|
int8_t compression;
|
||||||
} STsdbCfg;
|
} STsdbCfg;
|
||||||
|
|
||||||
|
// query condition to build multi-table data block iterator
|
||||||
|
typedef struct STsdbQueryCond {
|
||||||
|
STimeWindow twindow;
|
||||||
|
int32_t order; // desc|asc order to iterate the data block
|
||||||
|
int32_t numOfCols;
|
||||||
|
SColumnInfo *colList;
|
||||||
|
bool loadExternalRows; // load external rows or not
|
||||||
|
int32_t type; // data block load type:
|
||||||
|
} STsdbQueryCond;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
void *pTable;
|
||||||
|
TSKEY lastKey;
|
||||||
|
uint64_t uid;
|
||||||
|
} STableKeyInfo;
|
||||||
|
|
||||||
// STsdb
|
// STsdb
|
||||||
STsdb *tsdbOpen(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF, SMeta *pMeta);
|
STsdb *tsdbOpen(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF, SMeta *pMeta);
|
||||||
void tsdbClose(STsdb *);
|
void tsdbClose(STsdb *);
|
||||||
|
@ -70,6 +91,119 @@ int tsdbCommit(STsdb *pTsdb);
|
||||||
int tsdbOptionsInit(STsdbCfg *);
|
int tsdbOptionsInit(STsdbCfg *);
|
||||||
void tsdbOptionsClear(STsdbCfg *);
|
void tsdbOptionsClear(STsdbCfg *);
|
||||||
|
|
||||||
|
typedef void* tsdbReadHandleT;
|
||||||
|
/**
|
||||||
|
* Get the data block iterator, starting from position according to the query condition
|
||||||
|
*
|
||||||
|
* @param tsdb tsdb handle
|
||||||
|
* @param pCond query condition, including time window, result set order, and basic required columns for each block
|
||||||
|
* @param tableInfoGroup table object list in the form of set, grouped into different sets according to the
|
||||||
|
* group by condition
|
||||||
|
* @param qinfo query info handle from query processor
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
tsdbReadHandleT *tsdbQueryTables(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupInfo *tableInfoGroup, uint64_t qId,
|
||||||
|
void *pRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the last row of the given query time window for all the tables in STableGroupInfo object.
|
||||||
|
* Note that only one data block with only row will be returned while invoking retrieve data block function for
|
||||||
|
* all tables in this group.
|
||||||
|
*
|
||||||
|
* @param tsdb tsdb handle
|
||||||
|
* @param pCond query condition, including time window, result set order, and basic required columns for each block
|
||||||
|
* @param tableInfo table list.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//tsdbReadHandleT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STableGroupInfo *tableInfo, uint64_t qId,
|
||||||
|
// SMemRef *pRef);
|
||||||
|
|
||||||
|
|
||||||
|
tsdbReadHandleT tsdbQueryCacheLast(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, uint64_t qId, void* pMemRef);
|
||||||
|
|
||||||
|
bool isTsdbCacheLastRow(tsdbReadHandleT* pTsdbReadHandle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get num of rows in mem table
|
||||||
|
*
|
||||||
|
* @param pHandle
|
||||||
|
* @return row size
|
||||||
|
*/
|
||||||
|
|
||||||
|
int64_t tsdbGetNumOfRowsInMemTable(tsdbReadHandleT* pHandle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* move to next block if exists
|
||||||
|
*
|
||||||
|
* @param pTsdbReadHandle
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool tsdbNextDataBlock(tsdbReadHandleT pTsdbReadHandle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current data block information
|
||||||
|
*
|
||||||
|
* @param pTsdbReadHandle
|
||||||
|
* @param pBlockInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void tsdbRetrieveDataBlockInfo(tsdbReadHandleT *pTsdbReadHandle, SDataBlockInfo *pBlockInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Get the pre-calculated information w.r.t. current data block.
|
||||||
|
*
|
||||||
|
* In case of data block in cache, the pBlockStatis will always be NULL.
|
||||||
|
* If a block is not completed loaded from disk, the pBlockStatis will be NULL.
|
||||||
|
|
||||||
|
* @pBlockStatis the pre-calculated value for current data blocks. if the block is a cache block, always return 0
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReadHandleT *pTsdbReadHandle, SDataStatis **pBlockStatis);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* The query condition with primary timestamp is passed to iterator during its constructor function,
|
||||||
|
* the returned data block must be satisfied with the time window condition in any cases,
|
||||||
|
* which means the SData data block is not actually the completed disk data blocks.
|
||||||
|
*
|
||||||
|
* @param pTsdbReadHandle query handle
|
||||||
|
* @param pColumnIdList required data columns id list
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SArray *tsdbRetrieveDataBlock(tsdbReadHandleT *pTsdbReadHandle, SArray *pColumnIdList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* destroy the created table group list, which is generated by tag query
|
||||||
|
* @param pGroupList
|
||||||
|
*/
|
||||||
|
void tsdbDestroyTableGroup(STableGroupInfo *pGroupList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create the table group result including only one table, used to handle the normal table query
|
||||||
|
*
|
||||||
|
* @param tsdb tsdbHandle
|
||||||
|
* @param uid table uid
|
||||||
|
* @param pGroupInfo the generated result
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int32_t tsdbGetOneTableGroup(STsdb *tsdb, uint64_t uid, TSKEY startKey, STableGroupInfo *pGroupInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param tsdb
|
||||||
|
* @param pTableIdList
|
||||||
|
* @param pGroupInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int32_t tsdbGetTableGroupFromIdList(STsdb *tsdb, SArray *pTableIdList, STableGroupInfo *pGroupInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clean up the query handle
|
||||||
|
* @param queryHandle
|
||||||
|
*/
|
||||||
|
void tsdbCleanupQueryHandle(tsdbReadHandleT queryHandle);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,36 +21,38 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "executorimpl.h"
|
#include "thash.h"
|
||||||
|
#include "executor.h"
|
||||||
|
|
||||||
#define DS_CAPACITY_ENOUGH 1
|
#define DS_BUF_LOW 1
|
||||||
#define DS_CAPACITY_FULL 2
|
#define DS_BUF_FULL 2
|
||||||
#define DS_NEED_SCHEDULE 3
|
#define DS_BUF_EMPTY 3
|
||||||
#define DS_END 4
|
|
||||||
#define DS_IN_PROCESS 5
|
|
||||||
|
|
||||||
struct SDataSink;
|
struct SDataSink;
|
||||||
struct SSDataBlock;
|
struct SSDataBlock;
|
||||||
|
|
||||||
typedef struct SDataSinkMgtCfg {
|
typedef struct SDataSinkMgtCfg {
|
||||||
uint32_t maxDataBlockNum;
|
uint32_t maxDataBlockNum; // todo: this should be numOfRows?
|
||||||
uint32_t maxDataBlockNumPerQuery;
|
uint32_t maxDataBlockNumPerQuery;
|
||||||
} SDataSinkMgtCfg;
|
} SDataSinkMgtCfg;
|
||||||
|
|
||||||
int32_t dsDataSinkMgtInit(SDataSinkMgtCfg *cfg);
|
int32_t dsDataSinkMgtInit(SDataSinkMgtCfg *cfg);
|
||||||
|
|
||||||
typedef void* DataSinkHandle;
|
|
||||||
|
|
||||||
typedef struct SInputData {
|
typedef struct SInputData {
|
||||||
const SSDataBlock* pData;
|
const struct SSDataBlock* pData;
|
||||||
SHashObj* pTableRetrieveTsMap;
|
SHashObj* pTableRetrieveTsMap;
|
||||||
} SInputData;
|
} SInputData;
|
||||||
|
|
||||||
typedef struct SOutPutData {
|
typedef struct SOutputData {
|
||||||
int32_t numOfRows;
|
int32_t numOfRows;
|
||||||
int8_t compressed;
|
int8_t compressed;
|
||||||
char* pData;
|
char* pData;
|
||||||
} SOutPutData;
|
bool queryEnd;
|
||||||
|
bool needSchedule;
|
||||||
|
int32_t bufStatus;
|
||||||
|
int64_t useconds;
|
||||||
|
int8_t precision;
|
||||||
|
} SOutputData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a subplan's datasinker handle for all later operations.
|
* Create a subplan's datasinker handle for all later operations.
|
||||||
|
@ -66,16 +68,16 @@ int32_t dsCreateDataSinker(const struct SDataSink *pDataSink, DataSinkHandle* pH
|
||||||
* @param pRes
|
* @param pRes
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
int32_t dsPutDataBlock(DataSinkHandle handle, const SInputData* pInput, int32_t* pStatus);
|
int32_t dsPutDataBlock(DataSinkHandle handle, const SInputData* pInput, bool* pContinue);
|
||||||
|
|
||||||
void dsEndPut(DataSinkHandle handle);
|
void dsEndPut(DataSinkHandle handle, int64_t useconds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the length of the data returned by the next call to dsGetDataBlock.
|
* Get the length of the data returned by the next call to dsGetDataBlock.
|
||||||
* @param handle
|
* @param handle
|
||||||
* @return data length
|
* @param pLen data length
|
||||||
*/
|
*/
|
||||||
int32_t dsGetDataLength(DataSinkHandle handle, int32_t* pStatus);
|
void dsGetDataLength(DataSinkHandle handle, int32_t* pLen, bool* pQueryEnd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data, the caller needs to allocate data memory.
|
* Get data, the caller needs to allocate data memory.
|
||||||
|
@ -84,7 +86,7 @@ int32_t dsGetDataLength(DataSinkHandle handle, int32_t* pStatus);
|
||||||
* @param pStatus output
|
* @param pStatus output
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
int32_t dsGetDataBlock(DataSinkHandle handle, SOutPutData* pOutput, int32_t* pStatus);
|
int32_t dsGetDataBlock(DataSinkHandle handle, SOutputData* pOutput);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After dsGetStatus returns DS_NEED_SCHEDULE, the caller need to put this into the work queue.
|
* After dsGetStatus returns DS_NEED_SCHEDULE, the caller need to put this into the work queue.
|
|
@ -21,24 +21,30 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void* qTaskInfo_t;
|
typedef void* qTaskInfo_t;
|
||||||
|
typedef void* DataSinkHandle;
|
||||||
|
struct SSubplan;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the exec task object according to task json
|
||||||
|
* @param tsdb
|
||||||
|
* @param vgId
|
||||||
|
* @param pTaskInfoMsg
|
||||||
|
* @param pTaskInfo
|
||||||
|
* @param qId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int32_t qCreateExecTask(void* tsdb, int32_t vgId, struct SSubplan* pPlan, qTaskInfo_t* pTaskInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create the qinfo object according to QueryTableMsg
|
* The main task execution function, including query on both table and multiple tables,
|
||||||
* @param tsdb
|
|
||||||
* @param pQueryTableMsg
|
|
||||||
* @param pTaskInfo
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int32_t qCreateTask(void* tsdb, int32_t vgId, void* pQueryTableMsg, qTaskInfo_t* pTaskInfo, uint64_t qId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the main query execution function, including query on both table and multiple tables,
|
|
||||||
* which are decided according to the tag or table name query conditions
|
* which are decided according to the tag or table name query conditions
|
||||||
*
|
*
|
||||||
* @param qinfo
|
* @param tinfo
|
||||||
|
* @param handle
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool qExecTask(qTaskInfo_t qinfo, uint64_t *qId);
|
int32_t qExecTask(qTaskInfo_t tinfo, DataSinkHandle* handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the produced results information, if current query is not paused or completed,
|
* Retrieve the produced results information, if current query is not paused or completed,
|
||||||
|
@ -60,7 +66,7 @@ int32_t qRetrieveQueryResultInfo(qTaskInfo_t qinfo, bool* buildRes, void* pRspCo
|
||||||
* @param contLen payload length
|
* @param contLen payload length
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t qDumpRetrieveResult(qTaskInfo_t qinfo, SRetrieveTableRsp** pRsp, int32_t* contLen, bool* continueExec);
|
//int32_t qDumpRetrieveResult(qTaskInfo_t qinfo, SRetrieveTableRsp** pRsp, int32_t* contLen, bool* continueExec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the transporter context (RPC)
|
* return the transporter context (RPC)
|
||||||
|
@ -81,7 +87,7 @@ int32_t qKillTask(qTaskInfo_t qinfo);
|
||||||
* @param qinfo
|
* @param qinfo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t qIsQueryCompleted(qTaskInfo_t qinfo);
|
int32_t qIsTaskCompleted(qTaskInfo_t qinfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* destroy query info structure
|
* destroy query info structure
|
||||||
|
@ -113,7 +119,7 @@ int32_t qGetQualifiedTableIdList(void* pTableList, const char* tagCond, int32_t
|
||||||
* @param numOfIndex
|
* @param numOfIndex
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t qCreateTableGroupByGroupExpr(SArray* pTableIdList, TSKEY skey, STableGroupInfo groupInfo, SColIndex* groupByIndex, int32_t numOfIndex);
|
//int32_t qCreateTableGroupByGroupExpr(SArray* pTableIdList, TSKEY skey, STableGroupInfo groupInfo, SColIndex* groupByIndex, int32_t numOfIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the table id list of a given query.
|
* Update the table id list of a given query.
|
||||||
|
|
|
@ -20,8 +20,10 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "planner.h"
|
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
|
#include "planner.h"
|
||||||
|
|
||||||
|
struct SSchJob;
|
||||||
|
|
||||||
typedef struct SSchedulerCfg {
|
typedef struct SSchedulerCfg {
|
||||||
uint32_t maxJobNum;
|
uint32_t maxJobNum;
|
||||||
|
@ -65,7 +67,7 @@ int32_t schedulerInit(SSchedulerCfg *cfg);
|
||||||
* @param nodeList Qnode/Vnode address list, element is SQueryNodeAddr
|
* @param nodeList Qnode/Vnode address list, element is SQueryNodeAddr
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t scheduleExecJob(void *transport, SArray *nodeList, SQueryDag* pDag, void** pJob, SQueryResult *pRes);
|
int32_t scheduleExecJob(void *transport, SArray *nodeList, SQueryDag* pDag, struct SSchJob** pJob, SQueryResult *pRes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the query job, generated according to the query physical plan.
|
* Process the query job, generated according to the query physical plan.
|
||||||
|
@ -73,7 +75,7 @@ int32_t scheduleExecJob(void *transport, SArray *nodeList, SQueryDag* pDag, void
|
||||||
* @param nodeList Qnode/Vnode address list, element is SQueryNodeAddr
|
* @param nodeList Qnode/Vnode address list, element is SQueryNodeAddr
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t scheduleAsyncExecJob(void *transport, SArray *nodeList, SQueryDag* pDag, void** pJob);
|
int32_t scheduleAsyncExecJob(void *transport, SArray *nodeList, SQueryDag* pDag, struct SSchJob** pJob);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch query result from the remote query executor
|
* Fetch query result from the remote query executor
|
||||||
|
@ -81,7 +83,7 @@ int32_t scheduleAsyncExecJob(void *transport, SArray *nodeList, SQueryDag* pDag,
|
||||||
* @param data
|
* @param data
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t scheduleFetchRows(void *pJob, void **data);
|
int32_t scheduleFetchRows(struct SSchJob *pJob, void **data);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,7 +91,7 @@ int32_t scheduleFetchRows(void *pJob, void **data);
|
||||||
* @param pJob
|
* @param pJob
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t scheduleCancelJob(void *pJob);
|
//int32_t scheduleCancelJob(void *pJob);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free the query job
|
* Free the query job
|
||||||
|
|
|
@ -113,6 +113,7 @@ typedef struct SRequestSendRecvBody {
|
||||||
tsem_t rspSem; // not used now
|
tsem_t rspSem; // not used now
|
||||||
void* fp;
|
void* fp;
|
||||||
SShowReqInfo showInfo; // todo this attribute will be removed after the query framework being completed.
|
SShowReqInfo showInfo; // todo this attribute will be removed after the query framework being completed.
|
||||||
|
struct SSchJob *pQueryJob; // query job, created according to sql query DAG.
|
||||||
SDataBuf requestMsg;
|
SDataBuf requestMsg;
|
||||||
SReqResultInfo resInfo;
|
SReqResultInfo resInfo;
|
||||||
} SRequestSendRecvBody;
|
} SRequestSendRecvBody;
|
||||||
|
@ -129,7 +130,7 @@ typedef struct SRequestObj {
|
||||||
char *msgBuf;
|
char *msgBuf;
|
||||||
void *pInfo; // sql parse info, generated by parser module
|
void *pInfo; // sql parse info, generated by parser module
|
||||||
int32_t code;
|
int32_t code;
|
||||||
uint64_t affectedRows;
|
uint64_t affectedRows; // todo remove it
|
||||||
SQueryExecMetric metric;
|
SQueryExecMetric metric;
|
||||||
SRequestSendRecvBody body;
|
SRequestSendRecvBody body;
|
||||||
} SRequestObj;
|
} SRequestObj;
|
||||||
|
@ -161,12 +162,13 @@ int taos_options_imp(TSDB_OPTION option, const char *str);
|
||||||
void* openTransporter(const char *user, const char *auth, int32_t numOfThreads);
|
void* openTransporter(const char *user, const char *auth, int32_t numOfThreads);
|
||||||
|
|
||||||
void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
|
void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
|
||||||
|
|
||||||
void initMsgHandleFp();
|
void initMsgHandleFp();
|
||||||
|
|
||||||
TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db, uint16_t port);
|
TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db, uint16_t port);
|
||||||
TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen);
|
|
||||||
|
|
||||||
void *doFetchRow(SRequestObj* pRequest);
|
void *doFetchRow(SRequestObj* pRequest);
|
||||||
|
|
||||||
void setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows);
|
void setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
|
|
||||||
|
#include "../../libs/scheduler/inc/schedulerInt.h"
|
||||||
#include "clientInt.h"
|
#include "clientInt.h"
|
||||||
#include "clientLog.h"
|
#include "clientLog.h"
|
||||||
|
#include "parser.h"
|
||||||
|
#include "planner.h"
|
||||||
|
#include "scheduler.h"
|
||||||
#include "tdef.h"
|
#include "tdef.h"
|
||||||
#include "tep.h"
|
#include "tep.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
@ -8,9 +12,6 @@
|
||||||
#include "tnote.h"
|
#include "tnote.h"
|
||||||
#include "tpagedfile.h"
|
#include "tpagedfile.h"
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
#include "parser.h"
|
|
||||||
#include "planner.h"
|
|
||||||
#include "scheduler.h"
|
|
||||||
|
|
||||||
#define CHECK_CODE_GOTO(expr, lable) \
|
#define CHECK_CODE_GOTO(expr, lable) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -57,6 +58,7 @@ static char* getClusterKey(const char* user, const char* auth, const char* ip, i
|
||||||
}
|
}
|
||||||
|
|
||||||
static STscObj* taosConnectImpl(const char *ip, const char *user, const char *auth, const char *db, uint16_t port, __taos_async_fn_t fp, void *param, SAppInstInfo* pAppInfo);
|
static STscObj* taosConnectImpl(const char *ip, const char *user, const char *auth, const char *db, uint16_t port, __taos_async_fn_t fp, void *param, SAppInstInfo* pAppInfo);
|
||||||
|
static void setResSchemaInfo(SReqResultInfo* pResInfo, const SDataBlockSchema* pDataBlockSchema);
|
||||||
|
|
||||||
TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db, uint16_t port) {
|
TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db, uint16_t port) {
|
||||||
if (taos_init() != TSDB_CODE_SUCCESS) {
|
if (taos_init() != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -197,19 +199,49 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQueryNode* pQuery) {
|
||||||
|
|
||||||
int32_t getPlan(SRequestObj* pRequest, SQueryNode* pQueryNode, SQueryDag** pDag) {
|
int32_t getPlan(SRequestObj* pRequest, SQueryNode* pQueryNode, SQueryDag** pDag) {
|
||||||
pRequest->type = pQueryNode->type;
|
pRequest->type = pQueryNode->type;
|
||||||
return qCreateQueryDag(pQueryNode, pDag, pRequest->requestId);
|
|
||||||
|
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
||||||
|
int32_t code = qCreateQueryDag(pQueryNode, pDag, pRequest->requestId);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pQueryNode->type == TSDB_SQL_SELECT) {
|
||||||
|
SArray* pa = taosArrayGetP((*pDag)->pSubplans, 0);
|
||||||
|
|
||||||
|
SSubplan* pPlan = taosArrayGetP(pa, 0);
|
||||||
|
SDataBlockSchema* pDataBlockSchema = &(pPlan->pDataSink->schema);
|
||||||
|
setResSchemaInfo(pResInfo, pDataBlockSchema);
|
||||||
|
pRequest->type = TDMT_VND_QUERY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag, void** pJob) {
|
void setResSchemaInfo(SReqResultInfo* pResInfo, const SDataBlockSchema* pDataBlockSchema) {
|
||||||
|
assert(pDataBlockSchema != NULL && pDataBlockSchema->numOfCols > 0);
|
||||||
|
|
||||||
|
pResInfo->numOfCols = pDataBlockSchema->numOfCols;
|
||||||
|
pResInfo->fields = calloc(pDataBlockSchema->numOfCols, sizeof(pDataBlockSchema->pSchema[0]));
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pResInfo->numOfCols; ++i) {
|
||||||
|
SSchema* pSchema = &pDataBlockSchema->pSchema[i];
|
||||||
|
pResInfo->fields[i].bytes = pSchema->bytes;
|
||||||
|
pResInfo->fields[i].type = pSchema->type;
|
||||||
|
tstrncpy(pResInfo->fields[i].name, pSchema[i].name, tListLen(pResInfo->fields[i].name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag) {
|
||||||
if (TSDB_SQL_INSERT == pRequest->type || TSDB_SQL_CREATE_TABLE == pRequest->type) {
|
if (TSDB_SQL_INSERT == pRequest->type || TSDB_SQL_CREATE_TABLE == pRequest->type) {
|
||||||
SQueryResult res = {.code = 0, .numOfRows = 0, .msgSize = ERROR_MSG_BUF_DEFAULT_SIZE, .msg = pRequest->msgBuf};
|
SQueryResult res = {.code = 0, .numOfRows = 0, .msgSize = ERROR_MSG_BUF_DEFAULT_SIZE, .msg = pRequest->msgBuf};
|
||||||
|
|
||||||
int32_t code = scheduleExecJob(pRequest->pTscObj->pTransporter, NULL, pDag, pJob, &res);
|
int32_t code = scheduleExecJob(pRequest->pTscObj->pTransporter, NULL, pDag, &pRequest->body.pQueryJob, &res);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
// handle error and retry
|
// handle error and retry
|
||||||
} else {
|
} else {
|
||||||
if (*pJob != NULL) {
|
if (pRequest->body.pQueryJob != NULL) {
|
||||||
scheduleFreeJob(*pJob);
|
scheduleFreeJob(pRequest->body.pQueryJob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +249,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag, void** pJob) {
|
||||||
return res.code;
|
return res.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
return scheduleAsyncExecJob(pRequest->pTscObj->pTransporter, NULL /*todo appInfo.xxx*/, pDag, pJob);
|
return scheduleAsyncExecJob(pRequest->pTscObj->pTransporter, NULL, pDag, &pRequest->body.pQueryJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RES *tmq_create_topic(TAOS* taos, const char* name, const char* sql, int sqlLen) {
|
TAOS_RES *tmq_create_topic(TAOS* taos, const char* name, const char* sql, int sqlLen) {
|
||||||
|
@ -294,7 +326,6 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
|
||||||
SRequestObj *pRequest = NULL;
|
SRequestObj *pRequest = NULL;
|
||||||
SQueryNode *pQuery = NULL;
|
SQueryNode *pQuery = NULL;
|
||||||
SQueryDag *pDag = NULL;
|
SQueryDag *pDag = NULL;
|
||||||
void *pJob = NULL;
|
|
||||||
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return);
|
CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return);
|
||||||
|
@ -304,9 +335,8 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
|
||||||
CHECK_CODE_GOTO(execDdlQuery(pRequest, pQuery), _return);
|
CHECK_CODE_GOTO(execDdlQuery(pRequest, pQuery), _return);
|
||||||
} else {
|
} else {
|
||||||
CHECK_CODE_GOTO(getPlan(pRequest, pQuery, &pDag), _return);
|
CHECK_CODE_GOTO(getPlan(pRequest, pQuery, &pDag), _return);
|
||||||
CHECK_CODE_GOTO(scheduleQuery(pRequest, pDag, &pJob), _return);
|
CHECK_CODE_GOTO(scheduleQuery(pRequest, pDag), _return);
|
||||||
pRequest->code = terrno;
|
pRequest->code = terrno;
|
||||||
return pRequest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
@ -315,6 +345,7 @@ _return:
|
||||||
if (NULL != pRequest && TSDB_CODE_SUCCESS != terrno) {
|
if (NULL != pRequest && TSDB_CODE_SUCCESS != terrno) {
|
||||||
pRequest->code = terrno;
|
pRequest->code = terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pRequest;
|
return pRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +544,17 @@ void* doFetchRow(SRequestObj* pRequest) {
|
||||||
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
||||||
|
|
||||||
if (pResultInfo->pData == NULL || pResultInfo->current >= pResultInfo->numOfRows) {
|
if (pResultInfo->pData == NULL || pResultInfo->current >= pResultInfo->numOfRows) {
|
||||||
if (pRequest->type == TDMT_MND_SHOW) {
|
if (pRequest->type == TDMT_VND_QUERY) {
|
||||||
|
pRequest->type = TDMT_VND_FETCH;
|
||||||
|
scheduleFetchRows(pRequest->body.pQueryJob, (void **)&pRequest->body.resInfo.pData);
|
||||||
|
|
||||||
|
pResultInfo->current = 0;
|
||||||
|
if (pResultInfo->numOfRows <= pResultInfo->current) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto _return;
|
||||||
|
} else if (pRequest->type == TDMT_MND_SHOW) {
|
||||||
pRequest->type = TDMT_MND_SHOW_RETRIEVE;
|
pRequest->type = TDMT_MND_SHOW_RETRIEVE;
|
||||||
} else if (pRequest->type == TDMT_VND_SHOW_TABLES) {
|
} else if (pRequest->type == TDMT_VND_SHOW_TABLES) {
|
||||||
pRequest->type = TDMT_VND_SHOW_TABLES_FETCH;
|
pRequest->type = TDMT_VND_SHOW_TABLES_FETCH;
|
||||||
|
@ -556,6 +597,8 @@ void* doFetchRow(SRequestObj* pRequest) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
for(int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
for(int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
||||||
pResultInfo->row[i] = pResultInfo->pCol[i] + pResultInfo->fields[i].bytes * pResultInfo->current;
|
pResultInfo->row[i] = pResultInfo->pCol[i] + pResultInfo->fields[i].bytes * pResultInfo->current;
|
||||||
if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include "../inc/clientInt.h"
|
#include "../inc/clientInt.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "tglobal.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void showDB(TAOS* pConn) {
|
void showDB(TAOS* pConn) {
|
||||||
|
@ -57,449 +56,449 @@ TEST(testCase, connect_Test) {
|
||||||
taos_close(pConn);
|
taos_close(pConn);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, create_user_Test) {
|
//TEST(testCase, create_user_Test) {
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
|
||||||
assert(pConn != NULL);
|
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "create user abc pass 'abc'");
|
|
||||||
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
|
||||||
printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
|
||||||
}
|
|
||||||
|
|
||||||
taos_free_result(pRes);
|
|
||||||
taos_close(pConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, create_account_Test) {
|
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
|
||||||
assert(pConn != NULL);
|
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "create account aabc pass 'abc'");
|
|
||||||
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
|
||||||
printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
|
||||||
}
|
|
||||||
|
|
||||||
taos_free_result(pRes);
|
|
||||||
taos_close(pConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, drop_account_Test) {
|
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
|
||||||
assert(pConn != NULL);
|
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "drop account aabc");
|
|
||||||
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
|
||||||
printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
|
||||||
}
|
|
||||||
|
|
||||||
taos_free_result(pRes);
|
|
||||||
taos_close(pConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, show_user_Test) {
|
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
|
||||||
assert(pConn != NULL);
|
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "show users");
|
|
||||||
TAOS_ROW pRow = NULL;
|
|
||||||
|
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
|
||||||
|
|
||||||
char str[512] = {0};
|
|
||||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
|
||||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
|
||||||
printf("%s\n", str);
|
|
||||||
}
|
|
||||||
|
|
||||||
taos_free_result(pRes);
|
|
||||||
taos_close(pConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, drop_user_Test) {
|
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
|
||||||
assert(pConn != NULL);
|
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "drop user abc");
|
|
||||||
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
|
||||||
printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
|
||||||
}
|
|
||||||
|
|
||||||
taos_free_result(pRes);
|
|
||||||
taos_close(pConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, show_db_Test) {
|
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
|
||||||
assert(pConn != NULL);
|
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "show databases");
|
|
||||||
TAOS_ROW pRow = NULL;
|
|
||||||
|
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
|
||||||
|
|
||||||
char str[512] = {0};
|
|
||||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
|
||||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
|
||||||
printf("%s\n", str);
|
|
||||||
}
|
|
||||||
|
|
||||||
taos_close(pConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, create_db_Test) {
|
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
|
||||||
assert(pConn != NULL);
|
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "create database abc1 vgroups 2");
|
|
||||||
if (taos_errno(pRes) != 0) {
|
|
||||||
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
|
||||||
}
|
|
||||||
|
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
|
||||||
ASSERT_TRUE(pFields == NULL);
|
|
||||||
|
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
|
||||||
ASSERT_EQ(numOfFields, 0);
|
|
||||||
|
|
||||||
taos_free_result(pRes);
|
|
||||||
|
|
||||||
pRes = taos_query(pConn, "create database abc1 vgroups 4");
|
|
||||||
if (taos_errno(pRes) != 0) {
|
|
||||||
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
|
||||||
}
|
|
||||||
taos_close(pConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, create_dnode_Test) {
|
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
|
||||||
assert(pConn != NULL);
|
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "create dnode abc1 port 7000");
|
|
||||||
if (taos_errno(pRes) != 0) {
|
|
||||||
printf("error in create dnode, reason:%s\n", taos_errstr(pRes));
|
|
||||||
}
|
|
||||||
taos_free_result(pRes);
|
|
||||||
|
|
||||||
pRes = taos_query(pConn, "create dnode 1.1.1.1 port 9000");
|
|
||||||
if (taos_errno(pRes) != 0) {
|
|
||||||
printf("failed to create dnode, reason:%s\n", taos_errstr(pRes));
|
|
||||||
}
|
|
||||||
taos_free_result(pRes);
|
|
||||||
|
|
||||||
taos_close(pConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, drop_dnode_Test) {
|
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
|
||||||
assert(pConn != NULL);
|
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "drop dnode 2");
|
|
||||||
if (taos_errno(pRes) != 0) {
|
|
||||||
printf("error in drop dnode, reason:%s\n", taos_errstr(pRes));
|
|
||||||
}
|
|
||||||
|
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
|
||||||
ASSERT_TRUE(pFields == NULL);
|
|
||||||
|
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
|
||||||
ASSERT_EQ(numOfFields, 0);
|
|
||||||
|
|
||||||
taos_free_result(pRes);
|
|
||||||
taos_close(pConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(testCase, use_db_test) {
|
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
|
||||||
assert(pConn != NULL);
|
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
|
||||||
if (taos_errno(pRes) != 0) {
|
|
||||||
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
|
||||||
}
|
|
||||||
|
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
|
||||||
ASSERT_TRUE(pFields == NULL);
|
|
||||||
|
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
|
||||||
ASSERT_EQ(numOfFields, 0);
|
|
||||||
|
|
||||||
taos_close(pConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TEST(testCase, drop_db_test) {
|
|
||||||
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
// assert(pConn != NULL);
|
// assert(pConn != NULL);
|
||||||
//
|
//
|
||||||
// showDB(pConn);
|
// TAOS_RES* pRes = taos_query(pConn, "create user abc pass 'abc'");
|
||||||
//
|
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||||
// TAOS_RES* pRes = taos_query(pConn, "drop database abc1");
|
// printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
||||||
// if (taos_errno(pRes) != 0) {
|
|
||||||
// printf("failed to drop db, reason:%s\n", taos_errstr(pRes));
|
|
||||||
// }
|
// }
|
||||||
// taos_free_result(pRes);
|
|
||||||
//
|
//
|
||||||
// showDB(pConn);
|
|
||||||
//
|
|
||||||
// pRes = taos_query(pConn, "create database abc1");
|
|
||||||
// if (taos_errno(pRes) != 0) {
|
|
||||||
// printf("create to drop db, reason:%s\n", taos_errstr(pRes));
|
|
||||||
// }
|
|
||||||
// taos_free_result(pRes);
|
// taos_free_result(pRes);
|
||||||
// taos_close(pConn);
|
// taos_close(pConn);
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
TEST(testCase, create_stable_Test) {
|
//TEST(testCase, create_account_Test) {
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
assert(pConn != NULL);
|
// assert(pConn != NULL);
|
||||||
|
//
|
||||||
TAOS_RES* pRes = taos_query(pConn, "create database abc1 vgroups 2");
|
// TAOS_RES* pRes = taos_query(pConn, "create account aabc pass 'abc'");
|
||||||
if (taos_errno(pRes) != 0) {
|
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||||
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
// printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
||||||
}
|
// }
|
||||||
taos_free_result(pRes);
|
//
|
||||||
|
// taos_free_result(pRes);
|
||||||
pRes = taos_query(pConn, "use abc1");
|
// taos_close(pConn);
|
||||||
if (taos_errno(pRes) != 0) {
|
//}
|
||||||
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
//
|
||||||
}
|
//TEST(testCase, drop_account_Test) {
|
||||||
taos_free_result(pRes);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
// assert(pConn != NULL);
|
||||||
pRes = taos_query(pConn, "create stable st1(ts timestamp, k int) tags(a int)");
|
//
|
||||||
if (taos_errno(pRes) != 0) {
|
// TAOS_RES* pRes = taos_query(pConn, "drop account aabc");
|
||||||
printf("error in create stable, reason:%s\n", taos_errstr(pRes));
|
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||||
}
|
// printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// }
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
//
|
||||||
ASSERT_TRUE(pFields == NULL);
|
// taos_free_result(pRes);
|
||||||
|
// taos_close(pConn);
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
//}
|
||||||
ASSERT_EQ(numOfFields, 0);
|
//
|
||||||
|
//TEST(testCase, show_user_Test) {
|
||||||
taos_free_result(pRes);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
taos_close(pConn);
|
// assert(pConn != NULL);
|
||||||
}
|
//
|
||||||
|
// TAOS_RES* pRes = taos_query(pConn, "show users");
|
||||||
TEST(testCase, create_table_Test) {
|
// TAOS_ROW pRow = NULL;
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
//
|
||||||
assert(pConn != NULL);
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
//
|
||||||
taos_free_result(pRes);
|
// char str[512] = {0};
|
||||||
|
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
pRes = taos_query(pConn, "create table tm0(ts timestamp, k int)");
|
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||||
taos_free_result(pRes);
|
// printf("%s\n", str);
|
||||||
|
// }
|
||||||
taos_close(pConn);
|
//
|
||||||
}
|
// taos_free_result(pRes);
|
||||||
|
// taos_close(pConn);
|
||||||
TEST(testCase, create_ctable_Test) {
|
//}
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
//
|
||||||
assert(pConn != NULL);
|
//TEST(testCase, drop_user_Test) {
|
||||||
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
// assert(pConn != NULL);
|
||||||
if (taos_errno(pRes) != 0) {
|
//
|
||||||
printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
// TAOS_RES* pRes = taos_query(pConn, "drop user abc");
|
||||||
}
|
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||||
taos_free_result(pRes);
|
// printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// }
|
||||||
pRes = taos_query(pConn, "create table tm0 using st1 tags(1)");
|
//
|
||||||
if (taos_errno(pRes) != 0) {
|
// taos_free_result(pRes);
|
||||||
printf("failed to create child table tm0, reason:%s\n", taos_errstr(pRes));
|
// taos_close(pConn);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
taos_free_result(pRes);
|
//TEST(testCase, show_db_Test) {
|
||||||
taos_close(pConn);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
}
|
// assert(pConn != NULL);
|
||||||
|
//
|
||||||
TEST(testCase, show_stable_Test) {
|
// TAOS_RES* pRes = taos_query(pConn, "show databases");
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
// TAOS_ROW pRow = NULL;
|
||||||
assert(pConn != NULL);
|
//
|
||||||
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
if (taos_errno(pRes) != 0) {
|
//
|
||||||
printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
// char str[512] = {0};
|
||||||
}
|
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
taos_free_result(pRes);
|
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||||
|
// printf("%s\n", str);
|
||||||
pRes = taos_query(pConn, "show stables");
|
// }
|
||||||
if (taos_errno(pRes) != 0) {
|
//
|
||||||
printf("failed to show stables, reason:%s\n", taos_errstr(pRes));
|
// taos_close(pConn);
|
||||||
taos_free_result(pRes);
|
//}
|
||||||
ASSERT_TRUE(false);
|
//
|
||||||
}
|
//TEST(testCase, create_db_Test) {
|
||||||
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
TAOS_ROW pRow = NULL;
|
// assert(pConn != NULL);
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
//
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
// TAOS_RES* pRes = taos_query(pConn, "create database abc1 vgroups 2");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
char str[512] = {0};
|
// printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
// }
|
||||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
//
|
||||||
printf("%s\n", str);
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
}
|
// ASSERT_TRUE(pFields == NULL);
|
||||||
|
//
|
||||||
taos_free_result(pRes);
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
taos_close(pConn);
|
// ASSERT_EQ(numOfFields, 0);
|
||||||
}
|
//
|
||||||
|
// taos_free_result(pRes);
|
||||||
TEST(testCase, show_vgroup_Test) {
|
//
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
// pRes = taos_query(pConn, "create database abc1 vgroups 4");
|
||||||
assert(pConn != NULL);
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
// }
|
||||||
if (taos_errno(pRes) != 0) {
|
// taos_close(pConn);
|
||||||
printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
//}
|
||||||
}
|
//
|
||||||
taos_free_result(pRes);
|
//TEST(testCase, create_dnode_Test) {
|
||||||
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
pRes = taos_query(pConn, "show vgroups");
|
// assert(pConn != NULL);
|
||||||
if (taos_errno(pRes) != 0) {
|
//
|
||||||
printf("failed to show vgroups, reason:%s\n", taos_errstr(pRes));
|
// TAOS_RES* pRes = taos_query(pConn, "create dnode abc1 port 7000");
|
||||||
taos_free_result(pRes);
|
// if (taos_errno(pRes) != 0) {
|
||||||
ASSERT_TRUE(false);
|
// printf("error in create dnode, reason:%s\n", taos_errstr(pRes));
|
||||||
}
|
// }
|
||||||
|
// taos_free_result(pRes);
|
||||||
TAOS_ROW pRow = NULL;
|
//
|
||||||
|
// pRes = taos_query(pConn, "create dnode 1.1.1.1 port 9000");
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
// if (taos_errno(pRes) != 0) {
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
// printf("failed to create dnode, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// }
|
||||||
char str[512] = {0};
|
// taos_free_result(pRes);
|
||||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
//
|
||||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
// taos_close(pConn);
|
||||||
printf("%s\n", str);
|
//}
|
||||||
}
|
//
|
||||||
|
//TEST(testCase, drop_dnode_Test) {
|
||||||
taos_free_result(pRes);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
taos_close(pConn);
|
// assert(pConn != NULL);
|
||||||
}
|
//
|
||||||
|
// TAOS_RES* pRes = taos_query(pConn, "drop dnode 2");
|
||||||
TEST(testCase, create_multiple_tables) {
|
// if (taos_errno(pRes) != 0) {
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
// printf("error in drop dnode, reason:%s\n", taos_errstr(pRes));
|
||||||
ASSERT_NE(pConn, nullptr);
|
// }
|
||||||
|
//
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
if (taos_errno(pRes) != 0) {
|
// ASSERT_TRUE(pFields == NULL);
|
||||||
printf("failed to use db, reason:%s", taos_errstr(pRes));
|
//
|
||||||
taos_free_result(pRes);
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
taos_close(pConn);
|
// ASSERT_EQ(numOfFields, 0);
|
||||||
return;
|
//
|
||||||
}
|
// taos_free_result(pRes);
|
||||||
|
// taos_close(pConn);
|
||||||
taos_free_result(pRes);
|
//}
|
||||||
|
//
|
||||||
pRes = taos_query(pConn, "create table t_2 using st1 tags(1)");
|
//TEST(testCase, use_db_test) {
|
||||||
if (taos_errno(pRes) != 0) {
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes));
|
// assert(pConn != NULL);
|
||||||
taos_free_result(pRes);
|
//
|
||||||
ASSERT_TRUE(false);
|
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
}
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||||
taos_free_result(pRes);
|
// }
|
||||||
pRes = taos_query(pConn, "create table t_3 using st1 tags(2)");
|
//
|
||||||
if (taos_errno(pRes) != 0) {
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes));
|
// ASSERT_TRUE(pFields == NULL);
|
||||||
taos_free_result(pRes);
|
//
|
||||||
ASSERT_TRUE(false);
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
}
|
// ASSERT_EQ(numOfFields, 0);
|
||||||
|
//
|
||||||
TAOS_ROW pRow = NULL;
|
// taos_close(pConn);
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
//}
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
//
|
||||||
|
//// TEST(testCase, drop_db_test) {
|
||||||
char str[512] = {0};
|
//// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
//// assert(pConn != NULL);
|
||||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
////
|
||||||
printf("%s\n", str);
|
//// showDB(pConn);
|
||||||
}
|
////
|
||||||
|
//// TAOS_RES* pRes = taos_query(pConn, "drop database abc1");
|
||||||
taos_free_result(pRes);
|
//// if (taos_errno(pRes) != 0) {
|
||||||
|
//// printf("failed to drop db, reason:%s\n", taos_errstr(pRes));
|
||||||
for (int32_t i = 0; i < 20; ++i) {
|
//// }
|
||||||
char sql[512] = {0};
|
//// taos_free_result(pRes);
|
||||||
snprintf(sql, tListLen(sql),
|
////
|
||||||
"create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5) t_x_%d using st1 tags(911)", i,
|
//// showDB(pConn);
|
||||||
(i + 1) * 30, (i + 2) * 40);
|
////
|
||||||
TAOS_RES* pres = taos_query(pConn, sql);
|
//// pRes = taos_query(pConn, "create database abc1");
|
||||||
if (taos_errno(pres) != 0) {
|
//// if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres));
|
//// printf("create to drop db, reason:%s\n", taos_errstr(pRes));
|
||||||
}
|
//// }
|
||||||
taos_free_result(pres);
|
//// taos_free_result(pRes);
|
||||||
}
|
//// taos_close(pConn);
|
||||||
|
////}
|
||||||
taos_close(pConn);
|
//
|
||||||
}
|
//TEST(testCase, create_stable_Test) {
|
||||||
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
TEST(testCase, show_table_Test) {
|
// assert(pConn != NULL);
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
//
|
||||||
assert(pConn != NULL);
|
// TAOS_RES* pRes = taos_query(pConn, "create database abc1 vgroups 2");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
// printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||||
taos_free_result(pRes);
|
// }
|
||||||
|
// taos_free_result(pRes);
|
||||||
pRes = taos_query(pConn, "show tables");
|
//
|
||||||
if (taos_errno(pRes) != 0) {
|
// pRes = taos_query(pConn, "use abc1");
|
||||||
printf("failed to show vgroups, reason:%s\n", taos_errstr(pRes));
|
// if (taos_errno(pRes) != 0) {
|
||||||
taos_free_result(pRes);
|
// printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||||
ASSERT_TRUE(false);
|
// }
|
||||||
}
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
TAOS_ROW pRow = NULL;
|
// pRes = taos_query(pConn, "create stable st1(ts timestamp, k int) tags(a int)");
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
// if (taos_errno(pRes) != 0) {
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
// printf("error in create stable, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// }
|
||||||
char str[512] = {0};
|
//
|
||||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
// ASSERT_TRUE(pFields == NULL);
|
||||||
printf("%s\n", str);
|
//
|
||||||
}
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
|
// ASSERT_EQ(numOfFields, 0);
|
||||||
taos_free_result(pRes);
|
//
|
||||||
taos_close(pConn);
|
// taos_free_result(pRes);
|
||||||
}
|
// taos_close(pConn);
|
||||||
|
//}
|
||||||
TEST(testCase, drop_stable_Test) {
|
//
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
//TEST(testCase, create_table_Test) {
|
||||||
assert(pConn != NULL);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
// assert(pConn != NULL);
|
||||||
TAOS_RES* pRes = taos_query(pConn, "create database abc1");
|
//
|
||||||
if (taos_errno(pRes) != 0) {
|
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
printf("error in creating db, reason:%s\n", taos_errstr(pRes));
|
// taos_free_result(pRes);
|
||||||
}
|
//
|
||||||
taos_free_result(pRes);
|
// pRes = taos_query(pConn, "create table tm0(ts timestamp, k int)");
|
||||||
|
// taos_free_result(pRes);
|
||||||
pRes = taos_query(pConn, "use abc1");
|
//
|
||||||
if (taos_errno(pRes) != 0) {
|
// taos_close(pConn);
|
||||||
printf("error in using db, reason:%s\n", taos_errstr(pRes));
|
//}
|
||||||
}
|
//
|
||||||
taos_free_result(pRes);
|
//TEST(testCase, create_ctable_Test) {
|
||||||
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
pRes = taos_query(pConn, "drop stable st1");
|
// assert(pConn != NULL);
|
||||||
if (taos_errno(pRes) != 0) {
|
//
|
||||||
printf("failed to drop stable, reason:%s\n", taos_errstr(pRes));
|
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
}
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
||||||
taos_free_result(pRes);
|
// }
|
||||||
taos_close(pConn);
|
// taos_free_result(pRes);
|
||||||
}
|
//
|
||||||
|
// pRes = taos_query(pConn, "create table tm0 using st1 tags(1)");
|
||||||
TEST(testCase, generated_request_id_test) {
|
// if (taos_errno(pRes) != 0) {
|
||||||
SHashObj* phash = taosHashInit(10000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
// printf("failed to create child table tm0, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// }
|
||||||
for (int32_t i = 0; i < 50000; ++i) {
|
//
|
||||||
uint64_t v = generateRequestId();
|
// taos_free_result(pRes);
|
||||||
void* result = taosHashGet(phash, &v, sizeof(v));
|
// taos_close(pConn);
|
||||||
if (result != nullptr) {
|
//}
|
||||||
printf("0x%lx, index:%d\n", v, i);
|
//
|
||||||
}
|
//TEST(testCase, show_stable_Test) {
|
||||||
assert(result == nullptr);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
taosHashPut(phash, &v, sizeof(v), NULL, 0);
|
// assert(pConn != NULL);
|
||||||
}
|
//
|
||||||
|
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
taosHashCleanup(phash);
|
// if (taos_errno(pRes) != 0) {
|
||||||
}
|
// printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// }
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
|
// pRes = taos_query(pConn, "show stables");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("failed to show stables, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// ASSERT_TRUE(false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// TAOS_ROW pRow = NULL;
|
||||||
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
|
//
|
||||||
|
// char str[512] = {0};
|
||||||
|
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
|
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||||
|
// printf("%s\n", str);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// taos_close(pConn);
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//TEST(testCase, show_vgroup_Test) {
|
||||||
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
// assert(pConn != NULL);
|
||||||
|
//
|
||||||
|
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// }
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
|
// pRes = taos_query(pConn, "show vgroups");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("failed to show vgroups, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// ASSERT_TRUE(false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// TAOS_ROW pRow = NULL;
|
||||||
|
//
|
||||||
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
|
//
|
||||||
|
// char str[512] = {0};
|
||||||
|
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
|
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||||
|
// printf("%s\n", str);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// taos_close(pConn);
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//TEST(testCase, create_multiple_tables) {
|
||||||
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
// ASSERT_NE(pConn, nullptr);
|
||||||
|
//
|
||||||
|
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// taos_close(pConn);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
|
// pRes = taos_query(pConn, "create table t_2 using st1 tags(1)");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// ASSERT_TRUE(false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// pRes = taos_query(pConn, "create table t_3 using st1 tags(2)");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// ASSERT_TRUE(false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// TAOS_ROW pRow = NULL;
|
||||||
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
|
//
|
||||||
|
// char str[512] = {0};
|
||||||
|
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
|
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||||
|
// printf("%s\n", str);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
|
// for (int32_t i = 0; i < 20; ++i) {
|
||||||
|
// char sql[512] = {0};
|
||||||
|
// snprintf(sql, tListLen(sql),
|
||||||
|
// "create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5) t_x_%d using st1 tags(911)", i,
|
||||||
|
// (i + 1) * 30, (i + 2) * 40);
|
||||||
|
// TAOS_RES* pres = taos_query(pConn, sql);
|
||||||
|
// if (taos_errno(pres) != 0) {
|
||||||
|
// printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres));
|
||||||
|
// }
|
||||||
|
// taos_free_result(pres);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// taos_close(pConn);
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//TEST(testCase, show_table_Test) {
|
||||||
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
// assert(pConn != NULL);
|
||||||
|
//
|
||||||
|
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
|
// pRes = taos_query(pConn, "show tables");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("failed to show vgroups, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// ASSERT_TRUE(false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// TAOS_ROW pRow = NULL;
|
||||||
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
|
//
|
||||||
|
// char str[512] = {0};
|
||||||
|
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
|
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||||
|
// printf("%s\n", str);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// taos_close(pConn);
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//TEST(testCase, drop_stable_Test) {
|
||||||
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
// assert(pConn != NULL);
|
||||||
|
//
|
||||||
|
// TAOS_RES* pRes = taos_query(pConn, "create database abc1");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("error in creating db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// }
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
|
// pRes = taos_query(pConn, "use abc1");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("error in using db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// }
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
|
// pRes = taos_query(pConn, "drop stable st1");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("failed to drop stable, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// taos_close(pConn);
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//TEST(testCase, generated_request_id_test) {
|
||||||
|
// SHashObj* phash = taosHashInit(10000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||||
|
//
|
||||||
|
// for (int32_t i = 0; i < 50000; ++i) {
|
||||||
|
// uint64_t v = generateRequestId();
|
||||||
|
// void* result = taosHashGet(phash, &v, sizeof(v));
|
||||||
|
// if (result != nullptr) {
|
||||||
|
// printf("0x%lx, index:%d\n", v, i);
|
||||||
|
// }
|
||||||
|
// assert(result == nullptr);
|
||||||
|
// taosHashPut(phash, &v, sizeof(v), NULL, 0);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// taosHashCleanup(phash);
|
||||||
|
//}
|
||||||
|
|
||||||
// TEST(testCase, create_topic_Test) {
|
// TEST(testCase, create_topic_Test) {
|
||||||
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
@ -557,18 +556,29 @@ TEST(testCase, projection_query_tables) {
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
ASSERT_NE(pConn, nullptr);
|
ASSERT_NE(pConn, nullptr);
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use test1");
|
// TAOS_RES* pRes = taos_query(pConn, "create database abc1 vgroups 2");
|
||||||
if (taos_errno(pRes) != 0) {
|
// if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to use db, reason:%s", taos_errstr(pRes));
|
// printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
||||||
taos_free_result(pRes);
|
// taos_free_result(pRes);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
|
|
||||||
|
// pRes = taos_query(pConn, "create table m1 (ts timestamp, k int) tags(a int)");
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
//
|
||||||
|
// pRes = taos_query(pConn, "create table tu using m1 tags(1)");
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
|
// pRes = taos_query(pConn, "insert into tu values(now, 1)");
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
|
||||||
pRes = taos_query(pConn, "select * from tm0");
|
pRes = taos_query(pConn, "select * from tu");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes));
|
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
ASSERT_TRUE(false);
|
ASSERT_TRUE(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ int vnodeQueryOpen(SVnode *pVnode) { return qWorkerInit(NULL, &pVnode->pQuery);
|
||||||
|
|
||||||
int vnodeProcessQueryReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
int vnodeProcessQueryReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
vTrace("query message is processed");
|
vTrace("query message is processed");
|
||||||
return qWorkerProcessQueryMsg(pVnode, pVnode->pQuery, pMsg);
|
return qWorkerProcessQueryMsg(pVnode->pTsdb, pVnode->pQuery, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ else(0)
|
||||||
"src/tsdbReadImpl.c"
|
"src/tsdbReadImpl.c"
|
||||||
"src/tsdbFile.c"
|
"src/tsdbFile.c"
|
||||||
"src/tsdbFS.c"
|
"src/tsdbFS.c"
|
||||||
|
"src/tsdbRead.c"
|
||||||
)
|
)
|
||||||
endif(0)
|
endif(0)
|
||||||
|
|
||||||
|
|
|
@ -1253,7 +1253,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDataCols *
|
||||||
pBlock->keyFirst = dataColsKeyFirst(pDataCols);
|
pBlock->keyFirst = dataColsKeyFirst(pDataCols);
|
||||||
pBlock->keyLast = dataColsKeyLast(pDataCols);
|
pBlock->keyLast = dataColsKeyLast(pDataCols);
|
||||||
|
|
||||||
tsdbDebug("vgId:%d tid:%d a block of data is written to file %s, offset %" PRId64
|
tsdbDebug("vgId:%d uid:%"PRId64" a block of data is written to file %s, offset %" PRId64
|
||||||
" numOfRows %d len %d numOfCols %" PRId16 " keyFirst %" PRId64 " keyLast %" PRId64,
|
" numOfRows %d len %d numOfCols %" PRId16 " keyFirst %" PRId64 " keyLast %" PRId64,
|
||||||
REPO_ID(pRepo), TABLE_TID(pTable), TSDB_FILE_FULL_NAME(pDFile), offset, rowsToWrite, pBlock->len,
|
REPO_ID(pRepo), TABLE_TID(pTable), TSDB_FILE_FULL_NAME(pDFile), offset, rowsToWrite, pBlock->len,
|
||||||
pBlock->numOfCols, pBlock->keyFirst, pBlock->keyLast);
|
pBlock->numOfCols, pBlock->keyFirst, pBlock->keyLast);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1322,3 +1322,4 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|