feat: CREATE STREAM statement implement, and syntax of JSON data type implement.
This commit is contained in:
commit
e2164bf8cb
|
@ -4,5 +4,5 @@ if [ "$lua_header_installed" = "0" ]; then
|
|||
sudo apt install -y liblua5.3-dev
|
||||
fi
|
||||
|
||||
gcc -std=c99 lua_connector.c -fPIC -shared -o luaconnector.so -Wall -ltaos -I/usr/include/lua5.3
|
||||
gcc -std=c99 lua_connector.c -fPIC -shared -o luaconnector.so -Wall -ltaos -I/usr/include/lua5.3 -I../../include/client
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include <lauxlib.h>
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../../../include/client/taos.h"
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
#include "taos.h"
|
||||
|
||||
struct cb_param{
|
||||
lua_State* state;
|
||||
|
@ -60,8 +60,6 @@ static int l_connect(lua_State *L){
|
|||
|
||||
lua_settop(L,0);
|
||||
|
||||
taos_init();
|
||||
|
||||
lua_newtable(L);
|
||||
int table_index = lua_gettop(L);
|
||||
|
||||
|
@ -102,7 +100,7 @@ static int l_query(lua_State *L){
|
|||
printf("failed, reason:%s\n", taos_errstr(result));
|
||||
lua_pushinteger(L, -1);
|
||||
lua_setfield(L, table_index, "code");
|
||||
lua_pushstring(L, taos_errstr(taos));
|
||||
lua_pushstring(L, taos_errstr(result));
|
||||
lua_setfield(L, table_index, "error");
|
||||
|
||||
return 1;
|
||||
|
@ -113,7 +111,6 @@ static int l_query(lua_State *L){
|
|||
int rows = 0;
|
||||
int num_fields = taos_field_count(result);
|
||||
const TAOS_FIELD *fields = taos_fetch_fields(result);
|
||||
//char temp[256];
|
||||
|
||||
const int affectRows = taos_affected_rows(result);
|
||||
// printf(" affect rows:%d\r\n", affectRows);
|
||||
|
@ -136,17 +133,21 @@ static int l_query(lua_State *L){
|
|||
}
|
||||
|
||||
lua_pushstring(L,fields[i].name);
|
||||
|
||||
int32_t* length = taos_fetch_lengths(result);
|
||||
switch (fields[i].type) {
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
lua_pushinteger(L,*((char *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
lua_pushinteger(L,*((short *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
lua_pushinteger(L,*((int *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
lua_pushinteger(L,*((int64_t *)row[i]));
|
||||
break;
|
||||
|
@ -156,9 +157,11 @@ static int l_query(lua_State *L){
|
|||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
lua_pushnumber(L,*((double *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_JSON:
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
lua_pushstring(L,(char *)row[i]);
|
||||
//printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]);
|
||||
lua_pushlstring(L,(char *)row[i], length[i]);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
lua_pushinteger(L,*((int64_t *)row[i]));
|
||||
|
@ -166,6 +169,7 @@ static int l_query(lua_State *L){
|
|||
case TSDB_DATA_TYPE_BOOL:
|
||||
lua_pushinteger(L,*((char *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_NULL:
|
||||
default:
|
||||
lua_pushnil(L);
|
||||
break;
|
||||
|
@ -235,112 +239,6 @@ static int l_async_query(lua_State *L){
|
|||
return 1;
|
||||
}
|
||||
|
||||
void stream_cb(void *param, TAOS_RES *result, TAOS_ROW row){
|
||||
struct cb_param* p = (struct cb_param*) param;
|
||||
TAOS_FIELD *fields = taos_fetch_fields(result);
|
||||
int numFields = taos_num_fields(result);
|
||||
|
||||
// printf("\nnumfields:%d\n", numFields);
|
||||
//printf("\n\r-----------------------------------------------------------------------------------\n");
|
||||
|
||||
lua_State *L = p->state;
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback);
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
for (int i = 0; i < numFields; ++i) {
|
||||
if (row[i] == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lua_pushstring(L,fields[i].name);
|
||||
|
||||
switch (fields[i].type) {
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
lua_pushinteger(L,*((char *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
lua_pushinteger(L,*((short *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
lua_pushinteger(L,*((int *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
lua_pushinteger(L,*((int64_t *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
lua_pushnumber(L,*((float *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
lua_pushnumber(L,*((double *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
lua_pushstring(L,(char *)row[i]);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
lua_pushinteger(L,*((int64_t *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
lua_pushinteger(L,*((char *)row[i]));
|
||||
break;
|
||||
default:
|
||||
lua_pushnil(L);
|
||||
break;
|
||||
}
|
||||
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
|
||||
lua_call(L, 1, 0);
|
||||
|
||||
// printf("-----------------------------------------------------------------------------------\n\r");
|
||||
}
|
||||
|
||||
static int l_open_stream(lua_State *L){
|
||||
int r = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
TAOS * taos = (TAOS*)lua_topointer(L,1);
|
||||
const char * sqlstr = lua_tostring(L,2);
|
||||
int stime = luaL_checknumber(L,3);
|
||||
|
||||
lua_newtable(L);
|
||||
int table_index = lua_gettop(L);
|
||||
|
||||
struct cb_param *p = malloc(sizeof(struct cb_param));
|
||||
p->state = L;
|
||||
p->callback=r;
|
||||
// printf("r:%d, L:%d\n",r,L);
|
||||
void * s = taos_open_stream(taos,sqlstr,stream_cb,stime,p,NULL);
|
||||
if (s == NULL) {
|
||||
printf("failed to open stream, reason:%s\n", taos_errstr(taos));
|
||||
free(p);
|
||||
lua_pushnumber(L, -1);
|
||||
lua_setfield(L, table_index, "code");
|
||||
lua_pushstring(L, taos_errstr(taos));
|
||||
lua_setfield(L, table_index, "error");
|
||||
lua_pushlightuserdata(L,NULL);
|
||||
lua_setfield(L, table_index, "stream");
|
||||
}else{
|
||||
// printf("success to open stream\n");
|
||||
lua_pushnumber(L, 0);
|
||||
lua_setfield(L, table_index, "code");
|
||||
lua_pushstring(L, taos_errstr(taos));
|
||||
lua_setfield(L, table_index, "error");
|
||||
p->stream = s;
|
||||
lua_pushlightuserdata(L,p);
|
||||
lua_setfield(L, table_index, "stream");//stream has different content in lua and c.
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_close_stream(lua_State *L){
|
||||
//TODO:get stream and free cb_param
|
||||
struct cb_param *p = lua_touserdata(L,1);
|
||||
taos_close_stream(p->stream);
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_close(lua_State *L){
|
||||
TAOS *taos= (TAOS*)lua_topointer(L,1);
|
||||
|
@ -367,8 +265,6 @@ static const struct luaL_Reg lib[] = {
|
|||
{"query", l_query},
|
||||
{"query_a",l_async_query},
|
||||
{"close", l_close},
|
||||
{"open_stream", l_open_stream},
|
||||
{"close_stream", l_close_stream},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -70,13 +70,11 @@ typedef uint16_t tmsg_t;
|
|||
#define TSDB_IE_TYPE_DNODE_EXT 6
|
||||
#define TSDB_IE_TYPE_DNODE_STATE 7
|
||||
|
||||
typedef enum {
|
||||
HEARTBEAT_TYPE_MQ = 0,
|
||||
HEARTBEAT_TYPE_QUERY,
|
||||
// types can be added here
|
||||
//
|
||||
HEARTBEAT_TYPE_MAX
|
||||
} EHbType;
|
||||
enum {
|
||||
CONN_TYPE__QUERY = 1,
|
||||
CONN_TYPE__TMQ,
|
||||
CONN_TYPE__MAX
|
||||
};
|
||||
|
||||
enum {
|
||||
HEARTBEAT_KEY_DBINFO = 1,
|
||||
|
@ -346,7 +344,7 @@ int32_t tDeserializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq);
|
|||
typedef struct {
|
||||
int32_t acctId;
|
||||
int64_t clusterId;
|
||||
int32_t connId;
|
||||
uint32_t connId;
|
||||
int8_t superUser;
|
||||
int8_t connType;
|
||||
SEpSet epSet;
|
||||
|
@ -1048,40 +1046,6 @@ typedef struct {
|
|||
int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
||||
int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
char sql[TSDB_SHOW_SQL_LEN];
|
||||
int32_t queryId;
|
||||
int64_t useconds;
|
||||
int64_t stime;
|
||||
int64_t qId;
|
||||
int64_t sqlObjId;
|
||||
int32_t pid;
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
int8_t stableQuery;
|
||||
int32_t numOfSub;
|
||||
char subSqlInfo[TSDB_SHOW_SUBQUERY_LEN]; // include subqueries' index, Obj IDs and states(C-complete/I-imcomplete)
|
||||
} SQueryDesc;
|
||||
|
||||
typedef struct {
|
||||
int32_t connId;
|
||||
int32_t pid;
|
||||
int32_t numOfQueries;
|
||||
int32_t numOfStreams;
|
||||
char app[TSDB_APP_NAME_LEN];
|
||||
char pData[];
|
||||
} SHeartBeatReq;
|
||||
|
||||
typedef struct {
|
||||
int32_t connId;
|
||||
int32_t queryId;
|
||||
int32_t streamId;
|
||||
int32_t totalDnodes;
|
||||
int32_t onlineDnodes;
|
||||
int8_t killConnection;
|
||||
int8_t align[3];
|
||||
SEpSet epSet;
|
||||
} SHeartBeatRsp;
|
||||
|
||||
typedef struct {
|
||||
int32_t connId;
|
||||
int32_t queryId;
|
||||
|
@ -1684,12 +1648,47 @@ typedef struct {
|
|||
} SKv;
|
||||
|
||||
typedef struct {
|
||||
int32_t connId;
|
||||
int32_t hbType;
|
||||
int64_t tscRid;
|
||||
int8_t connType;
|
||||
} SClientHbKey;
|
||||
|
||||
typedef struct {
|
||||
int64_t tid;
|
||||
int32_t status;
|
||||
} SQuerySubDesc;
|
||||
|
||||
typedef struct {
|
||||
char sql[TSDB_SHOW_SQL_LEN];
|
||||
uint64_t queryId;
|
||||
int64_t useconds;
|
||||
int64_t stime;
|
||||
int64_t reqRid;
|
||||
int32_t pid;
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
int32_t subPlanNum;
|
||||
SArray* subDesc; // SArray<SQuerySubDesc>
|
||||
} SQueryDesc;
|
||||
|
||||
typedef struct {
|
||||
uint32_t connId;
|
||||
int32_t pid;
|
||||
char app[TSDB_APP_NAME_LEN];
|
||||
SArray* queryDesc; // SArray<SQueryDesc>
|
||||
} SQueryHbReqBasic;
|
||||
|
||||
typedef struct {
|
||||
uint32_t connId;
|
||||
uint64_t killRid;
|
||||
int32_t totalDnodes;
|
||||
int32_t onlineDnodes;
|
||||
int8_t killConnection;
|
||||
int8_t align[3];
|
||||
SEpSet epSet;
|
||||
} SQueryHbRspBasic;
|
||||
|
||||
typedef struct {
|
||||
SClientHbKey connKey;
|
||||
SQueryHbReqBasic* query;
|
||||
SHashObj* info; // hash<Skv.key, Skv>
|
||||
} SClientHbReq;
|
||||
|
||||
|
@ -1701,6 +1700,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
SClientHbKey connKey;
|
||||
int32_t status;
|
||||
SQueryHbRspBasic* query;
|
||||
SArray* info; // Array<Skv>
|
||||
} SClientHbRsp;
|
||||
|
||||
|
@ -1721,8 +1721,23 @@ static FORCE_INLINE void tFreeReqKvHash(SHashObj* info) {
|
|||
}
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tFreeClientHbQueryDesc(void* pDesc) {
|
||||
SQueryDesc* desc = (SQueryDesc*)pDesc;
|
||||
if (desc->subDesc) {
|
||||
taosArrayDestroy(desc->subDesc);
|
||||
desc->subDesc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tFreeClientHbReq(void* pReq) {
|
||||
SClientHbReq* req = (SClientHbReq*)pReq;
|
||||
if (req->query) {
|
||||
if (req->query->queryDesc) {
|
||||
taosArrayDestroyEx(req->query->queryDesc, tFreeClientHbQueryDesc);
|
||||
}
|
||||
taosMemoryFreeClear(req->query);
|
||||
}
|
||||
|
||||
if (req->info) {
|
||||
tFreeReqKvHash(req->info);
|
||||
taosHashCleanup(req->info);
|
||||
|
@ -1751,6 +1766,7 @@ static FORCE_INLINE void tFreeClientKv(void* pKv) {
|
|||
|
||||
static FORCE_INLINE void tFreeClientHbRsp(void* pRsp) {
|
||||
SClientHbRsp* rsp = (SClientHbRsp*)pRsp;
|
||||
taosMemoryFreeClear(rsp->query);
|
||||
if (rsp->info) taosArrayDestroyEx(rsp->info, tFreeClientKv);
|
||||
}
|
||||
|
||||
|
@ -1779,14 +1795,14 @@ static FORCE_INLINE int32_t tDecodeSKv(SCoder* pDecoder, SKv* pKv) {
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSClientHbKey(SCoder* pEncoder, const SClientHbKey* pKey) {
|
||||
if (tEncodeI32(pEncoder, pKey->connId) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pKey->hbType) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pKey->tscRid) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pKey->connType) < 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeSClientHbKey(SCoder* pDecoder, SClientHbKey* pKey) {
|
||||
if (tDecodeI32(pDecoder, &pKey->connId) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pKey->hbType) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pKey->tscRid) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pKey->connType) < 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -185,16 +185,16 @@
|
|||
#define TK_NULL 167
|
||||
#define TK_NK_QUESTION 168
|
||||
#define TK_NK_ARROW 169
|
||||
#define TK_NOW 170
|
||||
#define TK_TODAY 171
|
||||
#define TK_ROWTS 172
|
||||
#define TK_TBNAME 173
|
||||
#define TK_QSTARTTS 174
|
||||
#define TK_QENDTS 175
|
||||
#define TK_WSTARTTS 176
|
||||
#define TK_WENDTS 177
|
||||
#define TK_WDURATION 178
|
||||
#define TK_CAST 179
|
||||
#define TK_ROWTS 170
|
||||
#define TK_TBNAME 171
|
||||
#define TK_QSTARTTS 172
|
||||
#define TK_QENDTS 173
|
||||
#define TK_WSTARTTS 174
|
||||
#define TK_WENDTS 175
|
||||
#define TK_WDURATION 176
|
||||
#define TK_CAST 177
|
||||
#define TK_NOW 178
|
||||
#define TK_TODAY 179
|
||||
#define TK_COUNT 180
|
||||
#define TK_FIRST 181
|
||||
#define TK_LAST 182
|
||||
|
|
|
@ -110,7 +110,6 @@ typedef struct SFileBlockInfo {
|
|||
#define FUNCTION_COV 38
|
||||
|
||||
typedef struct SResultRowEntryInfo {
|
||||
// int8_t hasResult:6; // result generated, not NULL value
|
||||
bool initialized:1; // output buffer has been initialized
|
||||
bool complete:1; // query has completed
|
||||
uint8_t isNullRes:6; // the result is null
|
||||
|
@ -119,10 +118,10 @@ typedef struct SResultRowEntryInfo {
|
|||
|
||||
// determine the real data need to calculated the result
|
||||
enum {
|
||||
BLK_DATA_NO_NEEDED = 0x0,
|
||||
BLK_DATA_STATIS_NEEDED = 0x1,
|
||||
BLK_DATA_ALL_NEEDED = 0x3,
|
||||
BLK_DATA_DISCARD = 0x4, // discard current data block since it is not qualified for filter
|
||||
BLK_DATA_NOT_LOAD = 0x0,
|
||||
BLK_DATA_SMA_LOAD = 0x1,
|
||||
BLK_DATA_DATA_LOAD = 0x3,
|
||||
BLK_DATA_FILTEROUT = 0x4, // discard current data block since it is not qualified for filter
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
|
@ -140,10 +140,10 @@ bool fmIsDynamicScanOptimizedFunc(int32_t funcId);
|
|||
bool fmIsMultiResFunc(int32_t funcId);
|
||||
|
||||
typedef enum EFuncDataRequired {
|
||||
FUNC_DATA_REQUIRED_ALL_NEEDED = 1,
|
||||
FUNC_DATA_REQUIRED_STATIS_NEEDED,
|
||||
FUNC_DATA_REQUIRED_NO_NEEDED,
|
||||
FUNC_DATA_REQUIRED_DISCARD
|
||||
FUNC_DATA_REQUIRED_DATA_LOAD = 1,
|
||||
FUNC_DATA_REQUIRED_STATIS_LOAD,
|
||||
FUNC_DATA_REQUIRED_NOT_LOAD,
|
||||
FUNC_DATA_REQUIRED_FILTEROUT,
|
||||
} EFuncDataRequired;
|
||||
|
||||
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||
|
|
|
@ -57,6 +57,7 @@ typedef struct SQuery {
|
|||
SNode* pRoot;
|
||||
int32_t numOfResCols;
|
||||
SSchema* pResSchema;
|
||||
int8_t precision;
|
||||
SCmdMsgInfo* pCmdMsg;
|
||||
int32_t msgType;
|
||||
SArray* pDbList;
|
||||
|
|
|
@ -78,6 +78,8 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
|
|||
int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
||||
bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
|
||||
|
|
|
@ -89,6 +89,8 @@ int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryPlan* pD
|
|||
*/
|
||||
int32_t schedulerFetchRows(int64_t job, void **data);
|
||||
|
||||
int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub);
|
||||
|
||||
|
||||
/**
|
||||
* Cancel query job
|
||||
|
|
|
@ -33,13 +33,13 @@ void *taosMemoryMalloc(int32_t size);
|
|||
void *taosMemoryCalloc(int32_t num, int32_t size);
|
||||
void *taosMemoryRealloc(void *ptr, int32_t size);
|
||||
void *taosMemoryStrDup(void *ptr);
|
||||
void taosMemoryFree(const void *ptr);
|
||||
void taosMemoryFree(void *ptr);
|
||||
int32_t taosMemorySize(void *ptr);
|
||||
|
||||
#define taosMemoryFreeClear(ptr) \
|
||||
do { \
|
||||
if (ptr) { \
|
||||
taosMemoryFree(ptr); \
|
||||
taosMemoryFree((void*)ptr); \
|
||||
(ptr) = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
|
|
@ -205,6 +205,14 @@ SArray* taosArrayDup(const SArray* pSrc);
|
|||
*/
|
||||
void taosArrayClear(SArray* pArray);
|
||||
|
||||
/**
|
||||
* clear the array (remove all element)
|
||||
* @param pArray
|
||||
* @param fp
|
||||
*/
|
||||
void taosArrayClearEx(SArray* pArray, void (*fp)(void*));
|
||||
|
||||
|
||||
/**
|
||||
* destroy array list
|
||||
* @param pArray
|
||||
|
|
|
@ -128,6 +128,13 @@ extern const int32_t TYPE_BYTES[15];
|
|||
#define TSDB_INS_TABLE_QUERIES "queries"
|
||||
#define TSDB_INS_TABLE_VNODES "vnodes"
|
||||
|
||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||
#define TSDB_PERFS_TABLE_CONNECTIONS "connections"
|
||||
#define TSDB_PERFS_TABLE_QUERIES "queries"
|
||||
#define TSDB_PERFS_TABLE_TOPICS "topics"
|
||||
#define TSDB_PERFS_TABLE_CONSUMERS "consumers"
|
||||
#define TSDB_PERFS_TABLE_SUBSCRIBES "subscribes"
|
||||
|
||||
#define TSDB_INDEX_TYPE_SMA "SMA"
|
||||
#define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT"
|
||||
|
||||
|
|
|
@ -43,13 +43,17 @@ extern "C" {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
|
||||
#define HEARTBEAT_INTERVAL 1500 // ms
|
||||
|
||||
enum {
|
||||
CONN_TYPE__QUERY = 1,
|
||||
CONN_TYPE__TMQ,
|
||||
RES_TYPE__QUERY = 1,
|
||||
RES_TYPE__TMQ,
|
||||
};
|
||||
|
||||
#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY)
|
||||
#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ)
|
||||
|
||||
typedef struct SAppInstInfo SAppInstInfo;
|
||||
|
||||
typedef struct {
|
||||
|
@ -84,8 +88,8 @@ typedef struct {
|
|||
TdThread thread;
|
||||
TdThreadMutex lock; // used when app init and cleanup
|
||||
SArray* appHbMgrs; // SArray<SAppHbMgr*> one for each cluster
|
||||
FHbReqHandle reqHandle[HEARTBEAT_TYPE_MAX];
|
||||
FHbRspHandle rspHandle[HEARTBEAT_TYPE_MAX];
|
||||
FHbReqHandle reqHandle[CONN_TYPE__MAX];
|
||||
FHbRspHandle rspHandle[CONN_TYPE__MAX];
|
||||
} SClientHbMgr;
|
||||
|
||||
typedef struct SQueryExecMetric {
|
||||
|
@ -144,6 +148,7 @@ typedef struct STscObj {
|
|||
TdThreadMutex mutex; // used to protect the operation on db
|
||||
int32_t numOfReqs; // number of sqlObj bound to this connection
|
||||
SAppInstInfo* pAppInfo;
|
||||
SHashObj* pRequests;
|
||||
} STscObj;
|
||||
|
||||
typedef struct SResultColumn {
|
||||
|
@ -172,33 +177,15 @@ typedef struct SReqResultInfo {
|
|||
int32_t payloadLen;
|
||||
} SReqResultInfo;
|
||||
|
||||
typedef struct SShowReqInfo {
|
||||
int64_t execId; // showId/queryId
|
||||
int32_t vgId;
|
||||
SArray* pArray; // SArray<SVgroupInfo>
|
||||
int32_t currentIndex; // current accessed vgroup index.
|
||||
} SShowReqInfo;
|
||||
|
||||
typedef struct SRequestSendRecvBody {
|
||||
tsem_t rspSem; // not used now
|
||||
void* fp;
|
||||
SShowReqInfo showInfo; // todo this attribute will be removed after the query framework being completed.
|
||||
SDataBuf requestMsg;
|
||||
int64_t queryJob; // query job, created according to sql query DAG.
|
||||
struct SQueryPlan* pDag; // the query dag, generated according to the sql statement.
|
||||
SReqResultInfo resInfo;
|
||||
} SRequestSendRecvBody;
|
||||
|
||||
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
|
||||
|
||||
enum {
|
||||
RES_TYPE__QUERY = 1,
|
||||
RES_TYPE__TMQ,
|
||||
};
|
||||
|
||||
#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY)
|
||||
#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ)
|
||||
|
||||
typedef struct {
|
||||
int8_t resType;
|
||||
char* topic;
|
||||
|
@ -212,12 +199,11 @@ typedef struct SRequestObj {
|
|||
uint64_t requestId;
|
||||
int32_t type; // request type
|
||||
STscObj* pTscObj;
|
||||
char* pDb;
|
||||
char* pDb; // current database string
|
||||
char* sqlstr; // sql string
|
||||
int32_t sqlLen;
|
||||
int64_t self;
|
||||
char* msgBuf;
|
||||
void* pInfo; // sql parse info, generated by parser module
|
||||
char* msgBuf; // error msg buffer
|
||||
int32_t code;
|
||||
SArray* dbList;
|
||||
SArray* tableList;
|
||||
|
@ -256,17 +242,20 @@ int taos_init();
|
|||
|
||||
void* createTscObj(const char* user, const char* auth, const char* db, SAppInstInfo* pAppInfo);
|
||||
void destroyTscObj(void* pObj);
|
||||
STscObj *acquireTscObj(int64_t rid);
|
||||
int32_t releaseTscObj(int64_t rid);
|
||||
|
||||
uint64_t generateRequestId();
|
||||
|
||||
void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t type);
|
||||
void destroyRequest(SRequestObj* pRequest);
|
||||
SRequestObj *acquireRequest(int64_t rid);
|
||||
int32_t releaseRequest(int64_t rid);
|
||||
|
||||
char* getDbOfConnection(STscObj* pObj);
|
||||
void setConnectionDB(STscObj* pTscObj, const char* db);
|
||||
void resetConnectDB(STscObj* pTscObj);
|
||||
|
||||
void taos_init_imp(void);
|
||||
int taos_options_imp(TSDB_OPTION option, const char* str);
|
||||
|
||||
void* openTransporter(const char* user, const char* auth, int32_t numOfThreads);
|
||||
|
@ -286,9 +275,8 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj*
|
|||
|
||||
void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4);
|
||||
void doSetOneRowPtr(SReqResultInfo* pResultInfo);
|
||||
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows,
|
||||
bool convertUcs4);
|
||||
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
||||
void setResPrecision(SReqResultInfo* pResInfo, int32_t precision);
|
||||
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4);
|
||||
|
||||
// --- heartbeat
|
||||
|
@ -302,7 +290,7 @@ SAppHbMgr* appHbMgrInit(SAppInstInfo* pAppInstInfo, char* key);
|
|||
void appHbMgrCleanup(void);
|
||||
|
||||
// conn level
|
||||
int hbRegisterConn(SAppHbMgr* pAppHbMgr, int32_t connId, int64_t clusterId, int32_t hbType);
|
||||
int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType);
|
||||
void hbDeregisterConn(SAppHbMgr* pAppHbMgr, SClientHbKey connKey);
|
||||
|
||||
int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* value, int32_t keyLen, int32_t valueLen);
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_CLIENTSTMT_H
|
||||
#define TDENGINE_CLIENTSTMT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
STMT_TYPE_INSERT = 1,
|
||||
STMT_TYPE_MULTI_INSERT,
|
||||
STMT_TYPE_QUERY,
|
||||
} STMT_TYPE;
|
||||
|
||||
typedef struct STscStmt {
|
||||
STMT_TYPE type;
|
||||
//int16_t last;
|
||||
//STscObj* taos;
|
||||
//SSqlObj* pSql;
|
||||
//SMultiTbStmt mtb;
|
||||
//SNormalStmt normal;
|
||||
|
||||
//int numOfRows;
|
||||
} STscStmt;
|
||||
|
||||
#define STMT_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
|
||||
#define STMT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
|
||||
#define STMT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
|
||||
|
||||
TAOS_STMT *stmtInit(TAOS *taos);
|
||||
int stmtClose(TAOS_STMT *stmt);
|
||||
int stmtExec(TAOS_STMT *stmt);
|
||||
char *stmtErrstr(TAOS_STMT *stmt);
|
||||
int stmtAffectedRows(TAOS_STMT *stmt);
|
||||
int stmtBind(TAOS_STMT *stmt, TAOS_BIND *bind);
|
||||
int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length);
|
||||
int stmtSetTbNameTags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags);
|
||||
int stmtIsInsert(TAOS_STMT *stmt, int *insert);
|
||||
int stmtGetParamNum(TAOS_STMT *stmt, int *nums);
|
||||
int stmtAddBatch(TAOS_STMT *stmt);
|
||||
TAOS_RES *stmtUseResult(TAOS_STMT *stmt);
|
||||
int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TDENGINE_CLIENTSTMT_H
|
|
@ -37,7 +37,8 @@ static TdThreadOnce tscinit = PTHREAD_ONCE_INIT;
|
|||
volatile int32_t tscInitRes = 0;
|
||||
|
||||
static void registerRequest(SRequestObj *pRequest) {
|
||||
STscObj *pTscObj = (STscObj *)taosAcquireRef(clientConnRefPool, pRequest->pTscObj->id);
|
||||
STscObj *pTscObj = acquireTscObj(pRequest->pTscObj->id);
|
||||
|
||||
assert(pTscObj != NULL);
|
||||
|
||||
// connection has been released already, abort creating request.
|
||||
|
@ -48,8 +49,8 @@ static void registerRequest(SRequestObj *pRequest) {
|
|||
if (pTscObj->pAppInfo) {
|
||||
SInstanceSummary *pSummary = &pTscObj->pAppInfo->summary;
|
||||
|
||||
int32_t total = atomic_add_fetch_64(&pSummary->totalRequests, 1);
|
||||
int32_t currentInst = atomic_add_fetch_64(&pSummary->currentRequests, 1);
|
||||
int32_t total = atomic_add_fetch_64((int64_t*)&pSummary->totalRequests, 1);
|
||||
int32_t currentInst = atomic_add_fetch_64((int64_t*)&pSummary->currentRequests, 1);
|
||||
tscDebug("0x%" PRIx64 " new Request from connObj:0x%" PRIx64
|
||||
", current:%d, app current:%d, total:%d, reqId:0x%" PRIx64,
|
||||
pRequest->self, pRequest->pTscObj->id, num, currentInst, total, pRequest->requestId);
|
||||
|
@ -62,14 +63,14 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
STscObj * pTscObj = pRequest->pTscObj;
|
||||
SInstanceSummary *pActivity = &pTscObj->pAppInfo->summary;
|
||||
|
||||
int32_t currentInst = atomic_sub_fetch_64(&pActivity->currentRequests, 1);
|
||||
int32_t currentInst = atomic_sub_fetch_64((int64_t*)&pActivity->currentRequests, 1);
|
||||
int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1);
|
||||
|
||||
int64_t duration = taosGetTimestampUs() - pRequest->metric.start;
|
||||
tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 " elapsed:%" PRIu64
|
||||
" ms, current:%d, app current:%d",
|
||||
pRequest->self, pTscObj->id, pRequest->requestId, duration/1000, num, currentInst);
|
||||
taosReleaseRef(clientConnRefPool, pTscObj->id);
|
||||
releaseTscObj(pTscObj->id);
|
||||
}
|
||||
|
||||
// todo close the transporter properly
|
||||
|
@ -107,12 +108,24 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
|||
return pDnodeConn;
|
||||
}
|
||||
|
||||
void closeAllRequests(SHashObj *pRequests) {
|
||||
void *pIter = taosHashIterate(pRequests, NULL);
|
||||
while (pIter != NULL) {
|
||||
int64_t *rid = pIter;
|
||||
|
||||
releaseRequest(*rid);
|
||||
|
||||
pIter = taosHashIterate(pRequests, pIter);
|
||||
}
|
||||
}
|
||||
|
||||
void destroyTscObj(void *pObj) {
|
||||
STscObj *pTscObj = pObj;
|
||||
|
||||
SClientHbKey connKey = {.connId = pTscObj->connId, .hbType = pTscObj->connType};
|
||||
SClientHbKey connKey = {.tscRid = pTscObj->id, .connType = pTscObj->connType};
|
||||
hbDeregisterConn(pTscObj->pAppInfo->pAppHbMgr, connKey);
|
||||
atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||
closeAllRequests(pTscObj->pRequests);
|
||||
tscDebug("connObj 0x%" PRIx64 " destroyed, totalConn:%" PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns);
|
||||
taosThreadMutexDestroy(&pTscObj->mutex);
|
||||
taosMemoryFreeClear(pTscObj);
|
||||
|
@ -125,6 +138,13 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pObj->pRequests = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (NULL == pObj->pRequests) {
|
||||
taosMemoryFree(pObj);
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pObj->pAppInfo = pAppInfo;
|
||||
tstrncpy(pObj->user, user, sizeof(pObj->user));
|
||||
memcpy(pObj->pass, auth, TSDB_PASSWORD_LEN);
|
||||
|
@ -140,6 +160,14 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI
|
|||
return pObj;
|
||||
}
|
||||
|
||||
STscObj *acquireTscObj(int64_t rid) {
|
||||
return (STscObj *)taosAcquireRef(clientConnRefPool, rid);
|
||||
}
|
||||
|
||||
int32_t releaseTscObj(int64_t rid) {
|
||||
return taosReleaseRef(clientConnRefPool, rid);
|
||||
}
|
||||
|
||||
void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t type) {
|
||||
assert(pObj != NULL);
|
||||
|
||||
|
@ -161,6 +189,7 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty
|
|||
tsem_init(&pRequest->body.rspSem, 0, 0);
|
||||
|
||||
registerRequest(pRequest);
|
||||
|
||||
return pRequest;
|
||||
}
|
||||
|
||||
|
@ -186,9 +215,10 @@ static void doDestroyRequest(void *p) {
|
|||
|
||||
assert(RID_VALID(pRequest->self));
|
||||
|
||||
taosHashRemove(pRequest->pTscObj->pRequests, &pRequest->self, sizeof(pRequest->self));
|
||||
|
||||
taosMemoryFreeClear(pRequest->msgBuf);
|
||||
taosMemoryFreeClear(pRequest->sqlstr);
|
||||
taosMemoryFreeClear(pRequest->pInfo);
|
||||
taosMemoryFreeClear(pRequest->pDb);
|
||||
|
||||
doFreeReqResultInfo(&pRequest->body.resInfo);
|
||||
|
@ -198,10 +228,6 @@ static void doDestroyRequest(void *p) {
|
|||
schedulerFreeJob(pRequest->body.queryJob);
|
||||
}
|
||||
|
||||
if (pRequest->body.showInfo.pArray != NULL) {
|
||||
taosArrayDestroy(pRequest->body.showInfo.pArray);
|
||||
}
|
||||
|
||||
taosArrayDestroy(pRequest->tableList);
|
||||
taosArrayDestroy(pRequest->dbList);
|
||||
|
||||
|
@ -214,9 +240,18 @@ void destroyRequest(SRequestObj *pRequest) {
|
|||
return;
|
||||
}
|
||||
|
||||
taosReleaseRef(clientReqRefPool, pRequest->self);
|
||||
taosRemoveRef(clientReqRefPool, pRequest->self);
|
||||
}
|
||||
|
||||
SRequestObj *acquireRequest(int64_t rid) {
|
||||
return (SRequestObj *)taosAcquireRef(clientReqRefPool, rid);
|
||||
}
|
||||
|
||||
int32_t releaseRequest(int64_t rid) {
|
||||
return taosReleaseRef(clientReqRefPool, rid);
|
||||
}
|
||||
|
||||
|
||||
void taos_init_imp(void) {
|
||||
// In the APIs of other program language, taos_cleanup is not available yet.
|
||||
// So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning.
|
||||
|
@ -457,11 +492,18 @@ uint64_t generateRequestId() {
|
|||
}
|
||||
}
|
||||
|
||||
uint64_t id = 0;
|
||||
|
||||
while (true) {
|
||||
int64_t ts = taosGetTimestampMs();
|
||||
uint64_t pid = taosGetPId();
|
||||
int32_t val = atomic_add_fetch_32(&requestSerialId, 1);
|
||||
|
||||
uint64_t id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF);
|
||||
id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF);
|
||||
if (id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "catalog.h"
|
||||
#include "scheduler.h"
|
||||
#include "clientInt.h"
|
||||
#include "clientLog.h"
|
||||
#include "trpc.h"
|
||||
|
@ -109,10 +110,36 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
|
|||
static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
||||
SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &pRsp->connKey, sizeof(SClientHbKey));
|
||||
if (NULL == info) {
|
||||
tscWarn("fail to get connInfo, may be dropped, connId:%d, type:%d", pRsp->connKey.connId, pRsp->connKey.hbType);
|
||||
tscWarn("fail to get connInfo, may be dropped, refId:%" PRIx64 ", type:%d", pRsp->connKey.tscRid, pRsp->connKey.connType);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (pRsp->query) {
|
||||
STscObj *pTscObj = (STscObj *)acquireTscObj(pRsp->connKey.tscRid);
|
||||
if (NULL == pTscObj) {
|
||||
tscDebug("tscObj rid %" PRIx64 " not exist", pRsp->connKey.tscRid);
|
||||
} else {
|
||||
updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &pRsp->query->epSet);
|
||||
pTscObj->connId = pRsp->query->connId;
|
||||
|
||||
if (pRsp->query->killRid) {
|
||||
SRequestObj *pRequest = acquireRequest(pRsp->query->killRid);
|
||||
if (NULL == pRequest) {
|
||||
tscDebug("request 0x%" PRIx64 " not exist to kill", pRsp->query->killRid);
|
||||
} else {
|
||||
taos_stop_query((TAOS_RES *)pRequest);
|
||||
releaseRequest(pRsp->query->killRid);
|
||||
}
|
||||
}
|
||||
|
||||
if (pRsp->query->killConnection) {
|
||||
taos_close(pTscObj);
|
||||
}
|
||||
|
||||
releaseTscObj(pRsp->connKey.tscRid);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t kvNum = pRsp->info ? taosArrayGetSize(pRsp->info) : 0;
|
||||
|
||||
tscDebug("hb got %d rsp kv", kvNum);
|
||||
|
@ -197,7 +224,7 @@ static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code)
|
|||
|
||||
for (int32_t i = 0; i < rspNum; ++i) {
|
||||
SClientHbRsp *rsp = taosArrayGet(pRsp.rsps, i);
|
||||
code = (*clientHbMgr.rspHandle[rsp->connKey.hbType])((*pInst)->pAppHbMgr, rsp);
|
||||
code = (*clientHbMgr.rspHandle[rsp->connKey.connType])((*pInst)->pAppHbMgr, rsp);
|
||||
if (code) {
|
||||
break;
|
||||
}
|
||||
|
@ -208,6 +235,97 @@ static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code)
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) {
|
||||
int64_t now = taosGetTimestampUs();
|
||||
SQueryDesc desc = {0};
|
||||
int32_t code = 0;
|
||||
|
||||
void *pIter = taosHashIterate(pObj->pRequests, NULL);
|
||||
while (pIter != NULL) {
|
||||
int64_t *rid = pIter;
|
||||
SRequestObj *pRequest = acquireRequest(*rid);
|
||||
if (NULL == pRequest) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tstrncpy(desc.sql, pRequest->sqlstr, sizeof(desc.sql));
|
||||
desc.stime = pRequest->metric.start;
|
||||
desc.queryId = pRequest->requestId;
|
||||
desc.useconds = now - pRequest->metric.start;
|
||||
desc.reqRid = pRequest->self;
|
||||
desc.pid = hbBasic->pid;
|
||||
taosGetFqdn(desc.fqdn);
|
||||
desc.subPlanNum = pRequest->body.pDag ? pRequest->body.pDag->numOfSubplans : 0;
|
||||
|
||||
if (desc.subPlanNum) {
|
||||
desc.subDesc = taosArrayInit(desc.subPlanNum, sizeof(SQuerySubDesc));
|
||||
if (NULL == desc.subDesc) {
|
||||
releaseRequest(*rid);
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
code = schedulerGetTasksStatus(pRequest->body.queryJob, desc.subDesc);
|
||||
if (code) {
|
||||
taosArrayDestroy(desc.subDesc);
|
||||
desc.subDesc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
releaseRequest(*rid);
|
||||
taosArrayPush(hbBasic->queryDesc, &desc);
|
||||
|
||||
pIter = taosHashIterate(pObj->pRequests, pIter);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
|
||||
STscObj *pTscObj = (STscObj *)acquireTscObj(connKey->tscRid);
|
||||
if (NULL == pTscObj) {
|
||||
tscWarn("tscObj rid %" PRIx64 " not exist", connKey->tscRid);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
}
|
||||
|
||||
int32_t numOfQueries = pTscObj->pRequests ? taosHashGetSize(pTscObj->pRequests) : 0;
|
||||
if (numOfQueries <= 0) {
|
||||
releaseTscObj(connKey->tscRid);
|
||||
tscDebug("no queries on connection");
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
}
|
||||
|
||||
SQueryHbReqBasic *hbBasic = (SQueryHbReqBasic *)taosMemoryCalloc(1, sizeof(SQueryHbReqBasic));
|
||||
if (NULL == hbBasic) {
|
||||
tscError("calloc %d failed", (int32_t)sizeof(SQueryHbReqBasic));
|
||||
releaseTscObj(connKey->tscRid);
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
hbBasic->queryDesc = taosArrayInit(numOfQueries, sizeof(SQueryDesc));
|
||||
if (NULL == hbBasic->queryDesc) {
|
||||
tscWarn("taosArrayInit %d queryDesc failed", numOfQueries);
|
||||
releaseTscObj(connKey->tscRid);
|
||||
taosMemoryFree(hbBasic);
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
hbBasic->connId = pTscObj->connId;
|
||||
hbBasic->pid = taosGetPId();
|
||||
taosGetAppName(hbBasic->app, NULL);
|
||||
|
||||
int32_t code = hbBuildQueryDesc(hbBasic, pTscObj);
|
||||
if (code) {
|
||||
releaseTscObj(connKey->tscRid);
|
||||
taosMemoryFree(hbBasic);
|
||||
return code;
|
||||
}
|
||||
|
||||
req->query = hbBasic;
|
||||
releaseTscObj(connKey->tscRid);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SClientHbReq *req) {
|
||||
SDbVgVersion *dbs = NULL;
|
||||
uint32_t dbNum = 0;
|
||||
|
@ -286,6 +404,8 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req
|
|||
return code;
|
||||
}
|
||||
|
||||
hbGetQueryBasicInfo(connKey, req);
|
||||
|
||||
code = hbGetExpiredDBInfo(connKey, pCatalog, req);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
|
@ -300,11 +420,11 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req
|
|||
}
|
||||
|
||||
void hbMgrInitMqHbHandle() {
|
||||
clientHbMgr.reqHandle[HEARTBEAT_TYPE_QUERY] = hbQueryHbReqHandle;
|
||||
clientHbMgr.reqHandle[HEARTBEAT_TYPE_MQ] = hbMqHbReqHandle;
|
||||
clientHbMgr.reqHandle[CONN_TYPE__QUERY] = hbQueryHbReqHandle;
|
||||
clientHbMgr.reqHandle[CONN_TYPE__TMQ] = hbMqHbReqHandle;
|
||||
|
||||
clientHbMgr.rspHandle[HEARTBEAT_TYPE_QUERY] = hbQueryHbRspHandle;
|
||||
clientHbMgr.rspHandle[HEARTBEAT_TYPE_MQ] = hbMqHbRspHandle;
|
||||
clientHbMgr.rspHandle[CONN_TYPE__QUERY] = hbQueryHbRspHandle;
|
||||
clientHbMgr.rspHandle[CONN_TYPE__TMQ] = hbMqHbRspHandle;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void hbMgrInitHandle() {
|
||||
|
@ -317,6 +437,11 @@ void hbFreeReq(void *req) {
|
|||
tFreeReqKvHash(pReq->info);
|
||||
}
|
||||
|
||||
void hbClearClientHbReq(SClientHbReq *pReq) {
|
||||
pReq->query = NULL;
|
||||
pReq->info = NULL;
|
||||
}
|
||||
|
||||
SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
|
||||
SClientHbBatchReq *pBatchReq = taosMemoryCalloc(1, sizeof(SClientHbBatchReq));
|
||||
if (pBatchReq == NULL) {
|
||||
|
@ -333,22 +458,23 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
|
|||
|
||||
SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &pOneReq->connKey, sizeof(SClientHbKey));
|
||||
if (info) {
|
||||
code = (*clientHbMgr.reqHandle[pOneReq->connKey.hbType])(&pOneReq->connKey, info->param, pOneReq);
|
||||
code = (*clientHbMgr.reqHandle[pOneReq->connKey.connType])(&pOneReq->connKey, info->param, pOneReq);
|
||||
if (code) {
|
||||
taosHashCancelIterate(pAppHbMgr->activeInfo, pIter);
|
||||
break;
|
||||
pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
taosArrayPush(pBatchReq->reqs, pOneReq);
|
||||
hbClearClientHbReq(pOneReq);
|
||||
|
||||
pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter);
|
||||
}
|
||||
|
||||
if (code) {
|
||||
taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq);
|
||||
taosMemoryFreeClear(pBatchReq);
|
||||
}
|
||||
// if (code) {
|
||||
// taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq);
|
||||
// taosMemoryFreeClear(pBatchReq);
|
||||
// }
|
||||
|
||||
return pBatchReq;
|
||||
}
|
||||
|
@ -523,13 +649,13 @@ int hbMgrInit() {
|
|||
hbMgrInitHandle();
|
||||
|
||||
// init backgroud thread
|
||||
hbCreateThread();
|
||||
//hbCreateThread();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hbMgrCleanUp() {
|
||||
hbStopThread();
|
||||
//hbStopThread();
|
||||
|
||||
// destroy all appHbMgr
|
||||
int8_t old = atomic_val_compare_exchange_8(&clientHbMgr.inited, 1, 0);
|
||||
|
@ -549,7 +675,7 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo *
|
|||
if (data != NULL) {
|
||||
return 0;
|
||||
}
|
||||
SClientHbReq hbReq;
|
||||
SClientHbReq hbReq = {0};
|
||||
hbReq.connKey = connKey;
|
||||
hbReq.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
|
||||
|
||||
|
@ -566,22 +692,22 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo *
|
|||
return 0;
|
||||
}
|
||||
|
||||
int hbRegisterConn(SAppHbMgr *pAppHbMgr, int32_t connId, int64_t clusterId, int32_t hbType) {
|
||||
int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType) {
|
||||
SClientHbKey connKey = {
|
||||
.connId = connId,
|
||||
.hbType = hbType,
|
||||
.tscRid = tscRefId,
|
||||
.connType = connType,
|
||||
};
|
||||
SHbConnInfo info = {0};
|
||||
|
||||
switch (hbType) {
|
||||
case HEARTBEAT_TYPE_QUERY: {
|
||||
switch (connType) {
|
||||
case CONN_TYPE__QUERY: {
|
||||
int64_t *pClusterId = taosMemoryMalloc(sizeof(int64_t));
|
||||
*pClusterId = clusterId;
|
||||
|
||||
info.param = pClusterId;
|
||||
return hbRegisterConnImpl(pAppHbMgr, connKey, &info);
|
||||
}
|
||||
case HEARTBEAT_TYPE_MQ: {
|
||||
case CONN_TYPE__TMQ: {
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "clientInt.h"
|
||||
#include "clientLog.h"
|
||||
|
@ -132,6 +146,13 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj*
|
|||
(*pRequest)->sqlstr[sqlLen] = 0;
|
||||
(*pRequest)->sqlLen = sqlLen;
|
||||
|
||||
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self, sizeof((*pRequest)->self))) {
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
tscError("put request to request hash failed");
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
tscDebugL("0x%" PRIx64 " SQL: %s, reqId:0x%" PRIx64, (*pRequest)->self, (*pRequest)->sqlstr, (*pRequest)->requestId);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -161,6 +182,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if ((*pQuery)->haveResultSet) {
|
||||
setResSchemaInfo(&pRequest->body.resInfo, (*pQuery)->pResSchema, (*pQuery)->numOfResCols);
|
||||
setResPrecision(&pRequest->body.resInfo, (*pQuery)->precision);
|
||||
}
|
||||
|
||||
TSWAP(pRequest->dbList, (*pQuery)->pDbList, SArray*);
|
||||
|
@ -215,7 +237,7 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
|
|||
}
|
||||
|
||||
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols) {
|
||||
assert(pSchema != NULL && numOfCols > 0);
|
||||
ASSERT(pSchema != NULL && numOfCols > 0);
|
||||
|
||||
pResInfo->numOfCols = numOfCols;
|
||||
pResInfo->fields = taosMemoryCalloc(numOfCols, sizeof(TAOS_FIELD));
|
||||
|
@ -239,6 +261,14 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
|
|||
}
|
||||
}
|
||||
|
||||
void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) {
|
||||
if (precision != TSDB_TIME_PRECISION_MILLI && precision != TSDB_TIME_PRECISION_MICRO && precision != TSDB_TIME_PRECISION_NANO) {
|
||||
return;
|
||||
}
|
||||
|
||||
pResInfo->precision = precision;
|
||||
}
|
||||
|
||||
int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
||||
void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter;
|
||||
|
||||
|
@ -447,7 +477,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
|
|||
taos_close(pTscObj);
|
||||
pTscObj = NULL;
|
||||
} else {
|
||||
tscDebug("0x%" PRIx64 " connection is opening, connId:%d, dnodeConn:%p, reqId:0x%" PRIx64, pTscObj->id,
|
||||
tscDebug("0x%" PRIx64 " connection is opening, connId:%u, dnodeConn:%p, reqId:0x%" PRIx64, pTscObj->id,
|
||||
pTscObj->connId, pTscObj->pAppInfo->pTransporter, pRequest->requestId);
|
||||
destroyRequest(pRequest);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
*/
|
||||
|
||||
#include "catalog.h"
|
||||
#include "scheduler.h"
|
||||
#include "clientInt.h"
|
||||
#include "clientStmt.h"
|
||||
#include "clientLog.h"
|
||||
#include "os.h"
|
||||
#include "query.h"
|
||||
|
@ -66,6 +68,7 @@ void taos_cleanup(void) {
|
|||
|
||||
rpcCleanup();
|
||||
catalogDestroy();
|
||||
schedulerDestroy();
|
||||
taosCloseLog();
|
||||
|
||||
tscInfo("all local resources released");
|
||||
|
@ -98,7 +101,7 @@ void taos_close(TAOS *taos) {
|
|||
STscObj *pTscObj = (STscObj *)taos;
|
||||
tscDebug("0x%" PRIx64 " try to close connection, numOfReq:%d", pTscObj->id, pTscObj->numOfReqs);
|
||||
|
||||
/*taosRemoveRef(clientConnRefPool, pTscObj->id);*/
|
||||
taosRemoveRef(clientConnRefPool, pTscObj->id);
|
||||
}
|
||||
|
||||
int taos_errno(TAOS_RES *tres) {
|
||||
|
@ -193,7 +196,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
}
|
||||
|
||||
} else {
|
||||
// assert to avoid uninitialization error
|
||||
// assert to avoid un-initialization error
|
||||
ASSERT(0);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -355,6 +358,7 @@ int taos_result_precision(TAOS_RES *res) {
|
|||
if (res == NULL) {
|
||||
return TSDB_TIME_PRECISION_MILLI;
|
||||
}
|
||||
|
||||
if (TD_RES_QUERY(res)) {
|
||||
SRequestObj *pRequest = (SRequestObj *)res;
|
||||
return pRequest->body.resInfo.precision;
|
||||
|
@ -400,7 +404,7 @@ void taos_stop_query(TAOS_RES *res) {
|
|||
return;
|
||||
}
|
||||
|
||||
// scheduleCancelJob(pRequest->body.pQueryJob);
|
||||
schedulerFreeJob(pRequest->body.queryJob);
|
||||
}
|
||||
|
||||
bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) {
|
||||
|
@ -467,6 +471,7 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
|
|||
if (res == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (TD_RES_TMQ(res)) {
|
||||
SReqResultInfo *pResultInfo = tmqGetNextResInfo(res);
|
||||
if (pResultInfo == NULL) {
|
||||
|
@ -565,76 +570,149 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
|||
}
|
||||
|
||||
TAOS_STMT *taos_stmt_init(TAOS *taos) {
|
||||
// TODO
|
||||
if (taos == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return stmtInit(taos);
|
||||
}
|
||||
|
||||
int taos_stmt_close(TAOS_STMT *stmt) {
|
||||
// TODO
|
||||
return -1;
|
||||
if (stmt == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return stmtClose(stmt);
|
||||
}
|
||||
|
||||
int taos_stmt_execute(TAOS_STMT *stmt) {
|
||||
// TODO
|
||||
return -1;
|
||||
if (stmt == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return stmtExec(stmt);
|
||||
}
|
||||
|
||||
char *taos_stmt_errstr(TAOS_STMT *stmt) {
|
||||
// TODO
|
||||
if (stmt == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int taos_stmt_affected_rows(TAOS_STMT *stmt) {
|
||||
// TODO
|
||||
return -1;
|
||||
return stmtErrstr(stmt);
|
||||
}
|
||||
|
||||
int taos_stmt_affected_rows(TAOS_STMT *stmt) {
|
||||
if (stmt == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return stmtAffectedRows(stmt);
|
||||
}
|
||||
|
||||
int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) {
|
||||
if (stmt == NULL || bind == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return stmtBind(stmt, bind);
|
||||
}
|
||||
|
||||
int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) {
|
||||
if (stmt == NULL || sql == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return stmtPrepare(stmt, sql, length);
|
||||
}
|
||||
|
||||
int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) {
|
||||
if (stmt == NULL || name == NULL || tags == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return stmtSetTbNameTags(stmt, name, tags);
|
||||
}
|
||||
|
||||
int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) {
|
||||
if (stmt == NULL || name == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return stmtSetTbNameTags(stmt, name, NULL);
|
||||
}
|
||||
|
||||
int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) {
|
||||
if (stmt == NULL || insert == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return stmtIsInsert(stmt, insert);
|
||||
}
|
||||
|
||||
int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) {
|
||||
if (stmt == NULL || nums == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return stmtGetParamNum(stmt, nums);
|
||||
}
|
||||
|
||||
int taos_stmt_add_batch(TAOS_STMT *stmt) {
|
||||
if (stmt == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return stmtAddBatch(stmt);
|
||||
}
|
||||
|
||||
TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) {
|
||||
if (stmt == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return stmtUseResult(stmt);
|
||||
}
|
||||
|
||||
int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
|
||||
if (stmt == NULL || bind == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return stmtBindBatch(stmt, bind);
|
||||
}
|
||||
|
||||
|
||||
TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) {
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) {
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) {
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) {
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) {
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) {
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) {
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
int taos_stmt_add_batch(TAOS_STMT *stmt) {
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) {
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
pTscObj->connType = connectRsp.connType;
|
||||
|
||||
hbRegisterConn(pTscObj->pAppInfo->pAppHbMgr, connectRsp.connId, connectRsp.clusterId, connectRsp.connType);
|
||||
hbRegisterConn(pTscObj->pAppInfo->pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType);
|
||||
|
||||
// pRequest->body.resInfo.pRspMsg = pMsg->pData;
|
||||
tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId,
|
||||
|
@ -117,10 +117,10 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
struct SCatalog *pCatalog = NULL;
|
||||
|
||||
if (usedbRsp.vgVersion >= 0) {
|
||||
int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
int32_t code1 = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if (code1 != TSDB_CODE_SUCCESS) {
|
||||
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId,
|
||||
tstrerror(code));
|
||||
tstrerror(code1));
|
||||
} else {
|
||||
catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid);
|
||||
}
|
||||
|
@ -154,10 +154,10 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
} else {
|
||||
struct SCatalog* pCatalog = NULL;
|
||||
|
||||
int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
int32_t code1 = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if (code1 != TSDB_CODE_SUCCESS) {
|
||||
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId,
|
||||
tstrerror(code));
|
||||
tstrerror(code1));
|
||||
} else {
|
||||
catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup);
|
||||
}
|
||||
|
@ -209,81 +209,6 @@ int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
|
||||
void initMsgHandleFp() {
|
||||
#if 0
|
||||
tscBuildMsg[TSDB_SQL_SELECT] = tscBuildQueryMsg;
|
||||
tscBuildMsg[TSDB_SQL_INSERT] = tscBuildSubmitMsg;
|
||||
tscBuildMsg[TSDB_SQL_FETCH] = tscBuildFetchMsg;
|
||||
|
||||
tscBuildMsg[TSDB_SQL_CREATE_DB] = tscBuildCreateDbMsg;
|
||||
tscBuildMsg[TSDB_SQL_CREATE_USER] = tscBuildUserMsg;
|
||||
tscBuildMsg[TSDB_SQL_CREATE_FUNCTION] = tscBuildCreateFuncMsg;
|
||||
|
||||
tscBuildMsg[TSDB_SQL_CREATE_ACCT] = tscBuildAcctMsg;
|
||||
tscBuildMsg[TSDB_SQL_ALTER_ACCT] = tscBuildAcctMsg;
|
||||
|
||||
tscBuildMsg[TSDB_SQL_CREATE_TABLE] = tscBuildCreateTableMsg;
|
||||
tscBuildMsg[TSDB_SQL_DROP_USER] = tscBuildDropUserAcctMsg;
|
||||
tscBuildMsg[TSDB_SQL_DROP_ACCT] = tscBuildDropUserAcctMsg;
|
||||
tscBuildMsg[TSDB_SQL_DROP_DB] = tscBuildDropDbMsg;
|
||||
tscBuildMsg[TSDB_SQL_DROP_FUNCTION] = tscBuildDropFuncMsg;
|
||||
tscBuildMsg[TSDB_SQL_SYNC_DB_REPLICA] = tscBuildSyncDbReplicaMsg;
|
||||
tscBuildMsg[TSDB_SQL_DROP_TABLE] = tscBuildDropTableMsg;
|
||||
tscBuildMsg[TSDB_SQL_ALTER_USER] = tscBuildUserMsg;
|
||||
tscBuildMsg[TSDB_SQL_CREATE_DNODE] = tscBuildCreateDnodeMsg;
|
||||
tscBuildMsg[TSDB_SQL_DROP_DNODE] = tscBuildDropDnodeMsg;
|
||||
tscBuildMsg[TSDB_SQL_CFG_DNODE] = tscBuildCfgDnodeMsg;
|
||||
tscBuildMsg[TSDB_SQL_ALTER_TABLE] = tscBuildAlterTableMsg;
|
||||
tscBuildMsg[TSDB_SQL_UPDATE_TAG_VAL] = tscBuildUpdateTagMsg;
|
||||
tscBuildMsg[TSDB_SQL_ALTER_DB] = tscAlterDbMsg;
|
||||
tscBuildMsg[TSDB_SQL_COMPACT_VNODE] = tscBuildCompactMsg;
|
||||
|
||||
|
||||
tscBuildMsg[TSDB_SQL_USE_DB] = tscBuildUseDbMsg;
|
||||
tscBuildMsg[TSDB_SQL_STABLEVGROUP] = tscBuildSTableVgroupMsg;
|
||||
tscBuildMsg[TSDB_SQL_RETRIEVE_FUNC] = tscBuildRetrieveFuncMsg;
|
||||
|
||||
tscBuildMsg[TSDB_SQL_HB] = tscBuildHeartBeatMsg;
|
||||
tscBuildMsg[TSDB_SQL_SHOW] = tscBuildShowMsg;
|
||||
tscBuildMsg[TSDB_SQL_RETRIEVE_MNODE] = tscBuildRetrieveFromMgmtMsg;
|
||||
tscBuildMsg[TSDB_SQL_KILL_QUERY] = tscBuildKillMsg;
|
||||
tscBuildMsg[TSDB_SQL_KILL_STREAM] = tscBuildKillMsg;
|
||||
tscBuildMsg[TSDB_SQL_KILL_CONNECTION] = tscBuildKillMsg;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_SELECT] = tscProcessQueryRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_FETCH] = tscProcessRetrieveRspFromNode;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_DROP_DB] = tscProcessDropDbRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_DROP_TABLE] = tscProcessDropTableRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_USE_DB] = tscProcessUseDbRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_META] = tscProcessTableMetaRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_STABLEVGROUP] = tscProcessSTableVgroupRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_MULTI_META] = tscProcessMultiTableMetaRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_FUNC] = tscProcessRetrieveFuncRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_SHOW] = tscProcessShowRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_MNODE] = tscProcessRetrieveRspFromNode; // rsp handled by same function.
|
||||
tscProcessMsgRsp[TSDB_SQL_DESCRIBE_TABLE] = tscProcessDescribeTableRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_CURRENT_DB] = tscProcessLocalRetrieveRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_CURRENT_USER] = tscProcessLocalRetrieveRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_SERV_VERSION] = tscProcessLocalRetrieveRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_CLI_VERSION] = tscProcessLocalRetrieveRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_SERV_STATUS] = tscProcessLocalRetrieveRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_EMPTY_RESULT] = tscProcessEmptyResultRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_GLOBALMERGE] = tscProcessRetrieveGlobalMergeRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_ALTER_TABLE] = tscProcessAlterTableMsgRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_ALTER_DB] = tscProcessAlterDbMsgRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_COMPACT_VNODE] = tscProcessCompactRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_TABLE] = tscProcessShowCreateRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_STABLE] = tscProcessShowCreateRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp;
|
||||
#endif
|
||||
|
||||
handleRequestRspFp[TMSG_INDEX(TDMT_MND_CONNECT)] = processConnectRsp;
|
||||
handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_DB)] = processCreateDbRsp;
|
||||
handleRequestRspFp[TMSG_INDEX(TDMT_MND_USE_DB)] = processUseDbRsp;
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
|
||||
#include "clientInt.h"
|
||||
#include "clientLog.h"
|
||||
#include "clientStmt.h"
|
||||
#include "tdef.h"
|
||||
|
||||
TAOS_STMT *stmtInit(TAOS *taos) {
|
||||
STscObj* pObj = (STscObj*)taos;
|
||||
STscStmt* pStmt = NULL;
|
||||
|
||||
#if 0
|
||||
pStmt = taosMemoryCalloc(1, sizeof(STscStmt));
|
||||
if (pStmt == NULL) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
tscError("failed to allocate memory for statement");
|
||||
return NULL;
|
||||
}
|
||||
pStmt->taos = pObj;
|
||||
|
||||
SSqlObj* pSql = calloc(1, sizeof(SSqlObj));
|
||||
|
||||
if (pSql == NULL) {
|
||||
free(pStmt);
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
tscError("failed to allocate memory for statement");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE)) {
|
||||
free(pSql);
|
||||
free(pStmt);
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
tscError("failed to malloc payload buffer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tsem_init(&pSql->rspSem, 0, 0);
|
||||
pSql->signature = pSql;
|
||||
pSql->pTscObj = pObj;
|
||||
pSql->maxRetry = TSDB_MAX_REPLICA;
|
||||
pStmt->pSql = pSql;
|
||||
pStmt->last = STMT_INIT;
|
||||
pStmt->numOfRows = 0;
|
||||
registerSqlObj(pSql);
|
||||
#endif
|
||||
|
||||
return pStmt;
|
||||
}
|
||||
|
||||
int stmtClose(TAOS_STMT *stmt) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int stmtExec(TAOS_STMT *stmt) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char *stmtErrstr(TAOS_STMT *stmt) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int stmtAffectedRows(TAOS_STMT *stmt) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int stmtBind(TAOS_STMT *stmt, TAOS_BIND *bind) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int stmtSetTbNameTags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int stmtIsInsert(TAOS_STMT *stmt, int *insert) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int stmtGetParamNum(TAOS_STMT *stmt, int *nums) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int stmtAddBatch(TAOS_STMT *stmt) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
TAOS_RES *stmtUseResult(TAOS_STMT *stmt) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -134,6 +134,42 @@ void *taosDecodeSEpSet(void *buf, SEpSet *pEp) {
|
|||
static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq) {
|
||||
if (tEncodeSClientHbKey(pEncoder, &pReq->connKey) < 0) return -1;
|
||||
|
||||
if (pReq->connKey.connType == CONN_TYPE__QUERY) {
|
||||
int32_t queryNum = 0;
|
||||
if (pReq->query) {
|
||||
queryNum = 1;
|
||||
if (tEncodeI32(pEncoder, queryNum) < 0) return -1;
|
||||
if (tEncodeU32(pEncoder, pReq->query->connId) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pReq->query->pid) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pReq->query->app) < 0) return -1;
|
||||
|
||||
int32_t num = taosArrayGetSize(pReq->query->queryDesc);
|
||||
if (tEncodeI32(pEncoder, num) < 0) return -1;
|
||||
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SQueryDesc *desc = taosArrayGet(pReq->query->queryDesc, i);
|
||||
if (tEncodeCStr(pEncoder, desc->sql) < 0) return -1;
|
||||
if (tEncodeU64(pEncoder, desc->queryId) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, desc->useconds) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, desc->stime) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, desc->reqRid) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, desc->pid) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, desc->fqdn) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, desc->subPlanNum) < 0) return -1;
|
||||
|
||||
int32_t snum = desc->subDesc ? taosArrayGetSize(desc->subDesc) : 0;
|
||||
if (tEncodeI32(pEncoder, snum) < 0) return -1;
|
||||
for (int32_t m = 0; m < snum; ++m) {
|
||||
SQuerySubDesc *sDesc = taosArrayGet(desc->subDesc, m);
|
||||
if (tEncodeI64(pEncoder, sDesc->tid) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, sDesc->status) < 0) return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (tEncodeI32(pEncoder, queryNum) < 0) return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t kvNum = taosHashGetSize(pReq->info);
|
||||
if (tEncodeI32(pEncoder, kvNum) < 0) return -1;
|
||||
void *pIter = taosHashIterate(pReq->info, NULL);
|
||||
|
@ -149,6 +185,53 @@ static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq
|
|||
static int32_t tDeserializeSClientHbReq(SCoder *pDecoder, SClientHbReq *pReq) {
|
||||
if (tDecodeSClientHbKey(pDecoder, &pReq->connKey) < 0) return -1;
|
||||
|
||||
if (pReq->connKey.connType == CONN_TYPE__QUERY) {
|
||||
int32_t queryNum = 0;
|
||||
if (tDecodeI32(pDecoder, &queryNum) < 0) return -1;
|
||||
if (queryNum) {
|
||||
pReq->query = taosMemoryCalloc(1, sizeof(*pReq->query));
|
||||
if (NULL == pReq->query) return -1;
|
||||
if (tDecodeU32(pDecoder, &pReq->query->connId) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pReq->query->pid) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pReq->query->app) < 0) return -1;
|
||||
|
||||
int32_t num = 0;
|
||||
if (tDecodeI32(pDecoder, &num) < 0) return -1;
|
||||
if (num > 0) {
|
||||
pReq->query->queryDesc = taosArrayInit(num, sizeof(SQueryDesc));
|
||||
if (NULL == pReq->query->queryDesc) return -1;
|
||||
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SQueryDesc desc = {0};
|
||||
if (tDecodeCStrTo(pDecoder, desc.sql) < 0) return -1;
|
||||
if (tDecodeU64(pDecoder, &desc.queryId) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &desc.useconds) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &desc.stime) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &desc.reqRid) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &desc.pid) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, desc.fqdn) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &desc.subPlanNum) < 0) return -1;
|
||||
|
||||
int32_t snum = 0;
|
||||
if (tDecodeI32(pDecoder, &snum) < 0) return -1;
|
||||
if (snum > 0) {
|
||||
desc.subDesc = taosArrayInit(snum, sizeof(SQuerySubDesc));
|
||||
if (NULL == desc.subDesc) return -1;
|
||||
|
||||
for (int32_t m = 0; m < snum; ++m) {
|
||||
SQuerySubDesc sDesc = {0};
|
||||
if (tDecodeI64(pDecoder, &sDesc.tid) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &sDesc.status) < 0) return -1;
|
||||
taosArrayPush(desc.subDesc, &sDesc);
|
||||
}
|
||||
}
|
||||
|
||||
taosArrayPush(pReq->query->queryDesc, &desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t kvNum = 0;
|
||||
if (tDecodeI32(pDecoder, &kvNum) < 0) return -1;
|
||||
if (pReq->info == NULL) {
|
||||
|
@ -168,6 +251,20 @@ static int32_t tSerializeSClientHbRsp(SCoder *pEncoder, const SClientHbRsp *pRsp
|
|||
if (tEncodeSClientHbKey(pEncoder, &pRsp->connKey) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pRsp->status) < 0) return -1;
|
||||
|
||||
int32_t queryNum = 0;
|
||||
if (pRsp->query) {
|
||||
queryNum = 1;
|
||||
if (tEncodeI32(pEncoder, queryNum) < 0) return -1;
|
||||
if (tEncodeU32(pEncoder, pRsp->query->connId) < 0) return -1;
|
||||
if (tEncodeU64(pEncoder, pRsp->query->killRid) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pRsp->query->totalDnodes) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pRsp->query->onlineDnodes) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pRsp->query->killConnection) < 0) return -1;
|
||||
if (tEncodeSEpSet(pEncoder, &pRsp->query->epSet) < 0) return -1;
|
||||
} else {
|
||||
if (tEncodeI32(pEncoder, queryNum) < 0) return -1;
|
||||
}
|
||||
|
||||
int32_t kvNum = taosArrayGetSize(pRsp->info);
|
||||
if (tEncodeI32(pEncoder, kvNum) < 0) return -1;
|
||||
for (int32_t i = 0; i < kvNum; i++) {
|
||||
|
@ -182,6 +279,19 @@ static int32_t tDeserializeSClientHbRsp(SCoder *pDecoder, SClientHbRsp *pRsp) {
|
|||
if (tDecodeSClientHbKey(pDecoder, &pRsp->connKey) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pRsp->status) < 0) return -1;
|
||||
|
||||
int32_t queryNum = 0;
|
||||
if (tDecodeI32(pDecoder, &queryNum) < 0) return -1;
|
||||
if (queryNum) {
|
||||
pRsp->query = taosMemoryCalloc(1, sizeof(*pRsp->query));
|
||||
if (NULL == pRsp->query) return -1;
|
||||
if (tDecodeU32(pDecoder, &pRsp->query->connId) < 0) return -1;
|
||||
if (tDecodeU64(pDecoder, &pRsp->query->killRid) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pRsp->query->totalDnodes) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pRsp->query->onlineDnodes) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pRsp->query->killConnection) < 0) return -1;
|
||||
if (tDecodeSEpSet(pDecoder, &pRsp->query->epSet) < 0) return -1;
|
||||
}
|
||||
|
||||
int32_t kvNum = 0;
|
||||
if (tDecodeI32(pDecoder, &kvNum) < 0) return -1;
|
||||
pRsp->info = taosArrayInit(kvNum, sizeof(SKv));
|
||||
|
@ -224,8 +334,9 @@ int32_t tDeserializeSClientHbBatchReq(void *buf, int32_t bufLen, SClientHbBatchR
|
|||
|
||||
int32_t reqNum = 0;
|
||||
if (tDecodeI32(&decoder, &reqNum) < 0) return -1;
|
||||
if (pBatchReq->reqs == NULL) {
|
||||
if (reqNum > 0) {
|
||||
pBatchReq->reqs = taosArrayInit(reqNum, sizeof(SClientHbReq));
|
||||
if (NULL == pBatchReq->reqs) return -1;
|
||||
}
|
||||
for (int32_t i = 0; i < reqNum; i++) {
|
||||
SClientHbReq req = {0};
|
||||
|
@ -2567,7 +2678,7 @@ int32_t tSerializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) {
|
|||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->acctId) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pRsp->clusterId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->connId) < 0) return -1;
|
||||
if (tEncodeU32(&encoder, pRsp->connId) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->superUser) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->connType) < 0) return -1;
|
||||
if (tEncodeSEpSet(&encoder, &pRsp->epSet) < 0) return -1;
|
||||
|
@ -2586,7 +2697,7 @@ int32_t tDeserializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) {
|
|||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->acctId) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pRsp->clusterId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->connId) < 0) return -1;
|
||||
if (tDecodeU32(&decoder, &pRsp->connId) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->superUser) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->connType) < 0) return -1;
|
||||
if (tDecodeSEpSet(&decoder, &pRsp->epSet) < 0) return -1;
|
||||
|
|
|
@ -91,9 +91,9 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
pCfg->keep = pCreate->daysToKeep0;
|
||||
pCfg->streamMode = pCreate->streamMode;
|
||||
pCfg->isWeak = true;
|
||||
pCfg->tsdbCfg.keep = pCreate->daysToKeep0;
|
||||
pCfg->tsdbCfg.keep1 = pCreate->daysToKeep2;
|
||||
pCfg->tsdbCfg.keep2 = pCreate->daysToKeep0;
|
||||
pCfg->tsdbCfg.keep0 = pCreate->daysToKeep2;
|
||||
pCfg->tsdbCfg.keep1 = pCreate->daysToKeep0;
|
||||
pCfg->tsdbCfg.lruCacheSize = pCreate->cacheBlockSize;
|
||||
pCfg->tsdbCfg.retentions = pCreate->pRetensions;
|
||||
pCfg->metaCfg.lruSize = pCreate->cacheBlockSize;
|
||||
|
@ -121,6 +121,8 @@ static void vmGenerateWrapperCfg(SVnodesMgmt *pMgmt, SCreateVnodeReq *pCreate, S
|
|||
int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||
SRpcMsg *pReq = &pMsg->rpcMsg;
|
||||
SCreateVnodeReq createReq = {0};
|
||||
char path[TSDB_FILENAME_LEN];
|
||||
|
||||
if (tDeserializeSCreateVnodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
|
@ -143,6 +145,14 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
// create vnode
|
||||
snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, vnodeCfg.vgId);
|
||||
if (vnodeCreate(path, &vnodeCfg, pMgmt->pTfs) < 0) {
|
||||
tFreeSCreateVnodeReq(&createReq);
|
||||
dError("vgId:%d, failed to create vnode since %s", createReq.vgId, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
SMsgCb msgCb = pMgmt->pDnode->data.msgCb;
|
||||
msgCb.pWrapper = pMgmt->pWrapper;
|
||||
msgCb.queueFps[QUERY_QUEUE] = vmPutMsgToQueryQueue;
|
||||
|
|
|
@ -27,7 +27,7 @@ void mndCleanupDb(SMnode *pMnode);
|
|||
SDbObj *mndAcquireDb(SMnode *pMnode, const char *db);
|
||||
void mndReleaseDb(SMnode *pMnode, SDbObj *pDb);
|
||||
int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs, void **ppRsp, int32_t *pRspLen);
|
||||
char *mnGetDbStr(char *src);
|
||||
char *mndGetDbStr(char *src);
|
||||
int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -38,6 +38,10 @@ extern "C" {
|
|||
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }}
|
||||
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
|
||||
|
||||
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
|
||||
typedef int32_t (*MndMsgFp)(SNodeMsg *pMsg);
|
||||
typedef int32_t (*MndInitFp)(SMnode *pMnode);
|
||||
typedef void (*MndCleanupFp)(SMnode *pMnode);
|
||||
|
@ -74,7 +78,6 @@ typedef struct {
|
|||
} SShowMgmt;
|
||||
|
||||
typedef struct {
|
||||
int32_t connId;
|
||||
SCacheObj *cache;
|
||||
} SProfileMgmt;
|
||||
|
||||
|
@ -118,6 +121,7 @@ struct SMnode {
|
|||
STelemMgmt telemMgmt;
|
||||
SSyncMgmt syncMgmt;
|
||||
SHashObj *infosMeta;
|
||||
SHashObj *perfsMeta;
|
||||
SGrantInfo grant;
|
||||
MndMsgFp msgFp[TDMT_MAX];
|
||||
SMsgCb msgCb;
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_MND_PERF_SCHEMA_H_
|
||||
#define _TD_MND_PERF_SCHEMA_H_
|
||||
|
||||
#include "mndInt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SPerfsTableSchema {
|
||||
char *name;
|
||||
int32_t type;
|
||||
int32_t bytes;
|
||||
} SPerfsTableSchema;
|
||||
|
||||
typedef struct SPerfsTableMeta {
|
||||
char *name;
|
||||
const SPerfsTableSchema *schema;
|
||||
int32_t colNum;
|
||||
} SPerfsTableMeta;
|
||||
|
||||
int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp);
|
||||
int32_t mndInitPerfs(SMnode *pMnode);
|
||||
void mndCleanupPerfs(SMnode *pMnode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_MND_PERF_SCHEMA_H_*/
|
|
@ -1128,6 +1128,8 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) {
|
|||
|
||||
if (taosArrayGetSize(usedbRsp.pVgroupInfos) <= 0) {
|
||||
terrno = TSDB_CODE_MND_DB_NOT_EXIST;
|
||||
} else {
|
||||
code = 0;
|
||||
}
|
||||
} else {
|
||||
usedbRsp.vgVersion = usedbReq.vgVersion;
|
||||
|
@ -1340,7 +1342,7 @@ SYNC_DB_OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
char *mnGetDbStr(char *src) {
|
||||
char *mndGetDbStr(char *src) {
|
||||
char *pos = strstr(src, TS_PATH_DELIMITER);
|
||||
if (pos != NULL) ++pos;
|
||||
|
||||
|
@ -1355,7 +1357,7 @@ static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
int32_t cols = 0;
|
||||
|
||||
char* buf = taosMemoryMalloc(pShow->bytes[cols]);
|
||||
char *name = mnGetDbStr(pDb->name);
|
||||
char *name = mndGetDbStr(pDb->name);
|
||||
if (name != NULL) {
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, name, pShow->bytes[cols]);
|
||||
} else {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndInfoSchema.h"
|
||||
#include "mndInt.h"
|
||||
|
||||
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
|
@ -94,11 +95,13 @@ static const SInfosTableSchema userDBSchema[] = {
|
|||
};
|
||||
|
||||
static const SInfosTableSchema userFuncSchema[] = {
|
||||
{.name = "name", .bytes = 32, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "name", .bytes = TSDB_FUNC_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "comment", .bytes = PATH_MAX - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "aggregate", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "comment", .bytes = TSDB_TYPE_STR_MAX_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "ntables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "precision", .bytes = 2, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "code_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "bufsize", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema userIdxSchema[] = {
|
||||
|
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndPerfSchema.h"
|
||||
#include "mndInt.h"
|
||||
|
||||
//!!!! Note: only APPEND columns in below tables, NO insert !!!!
|
||||
static const SPerfsTableSchema connectionsSchema[] = {
|
||||
{.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "program", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
static const SPerfsTableSchema queriesSchema[] = {
|
||||
{.name = "query_id", .bytes = 4, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "fqdn", .bytes = TSDB_FQDN_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sub_queries", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "sub_query_info", .bytes = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
};
|
||||
|
||||
static const SPerfsTableSchema topicSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "row_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
static const SPerfsTableSchema consumerSchema[] = {
|
||||
{.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "status", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
// ep
|
||||
// up time
|
||||
// topics
|
||||
};
|
||||
|
||||
static const SPerfsTableSchema subscribeSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
};
|
||||
|
||||
static const SPerfsTableMeta perfsMeta[] = {
|
||||
{TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)},
|
||||
{TSDB_PERFS_TABLE_QUERIES, queriesSchema, tListLen(queriesSchema)},
|
||||
{TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema)},
|
||||
{TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema)},
|
||||
{TSDB_PERFS_TABLE_SUBSCRIBES, subscribeSchema, tListLen(subscribeSchema)},
|
||||
};
|
||||
|
||||
// connection/application/
|
||||
int32_t mndInitPerfsTableSchema(const SPerfsTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
||||
SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
|
||||
if (NULL == schema) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < colNum; ++i) {
|
||||
strcpy(schema[i].name, pSrc[i].name);
|
||||
|
||||
schema[i].type = pSrc[i].type;
|
||||
schema[i].colId = i + 1;
|
||||
schema[i].bytes = pSrc[i].bytes;
|
||||
}
|
||||
|
||||
*pDst = schema;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t mndPerfsInitMeta(SHashObj *hash) {
|
||||
STableMetaRsp meta = {0};
|
||||
|
||||
strcpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB);
|
||||
meta.tableType = TSDB_SYSTEM_TABLE;
|
||||
meta.sversion = 1;
|
||||
meta.tversion = 1;
|
||||
|
||||
for (int32_t i = 0; i < tListLen(perfsMeta); ++i) {
|
||||
strcpy(meta.tbName, perfsMeta[i].name);
|
||||
meta.numOfColumns = perfsMeta[i].colNum;
|
||||
|
||||
if (mndInitPerfsTableSchema(perfsMeta[i].schema, perfsMeta[i].colNum, &meta.pSchemas)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) {
|
||||
if (NULL == pMnode->perfsMeta) {
|
||||
terrno = TSDB_CODE_MND_NOT_READY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName));
|
||||
if (NULL == meta) {
|
||||
mError("invalid performance schema table name:%s", tbName);
|
||||
terrno = TSDB_CODE_MND_INVALID_INFOS_TBL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pRsp = *meta;
|
||||
|
||||
pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema));
|
||||
if (pRsp->pSchemas == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
pRsp->pSchemas = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(pRsp->pSchemas, meta->pSchemas, meta->numOfColumns * sizeof(SSchema));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndInitPerfs(SMnode *pMnode) {
|
||||
pMnode->perfsMeta = taosHashInit(20, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
if (pMnode->perfsMeta == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return mndPerfsInitMeta(pMnode->perfsMeta);
|
||||
}
|
||||
|
||||
void mndCleanupPerfs(SMnode *pMnode) {
|
||||
if (NULL == pMnode->perfsMeta) {
|
||||
return;
|
||||
}
|
||||
|
||||
void *pIter = taosHashIterate(pMnode->perfsMeta, NULL);
|
||||
while (pIter) {
|
||||
STableMetaRsp *meta = (STableMetaRsp *)pIter;
|
||||
|
||||
taosMemoryFreeClear(meta->pSchemas);
|
||||
|
||||
pIter = taosHashIterate(pMnode->perfsMeta, pIter);
|
||||
}
|
||||
|
||||
taosHashCleanup(pMnode->perfsMeta);
|
||||
pMnode->perfsMeta = NULL;
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
#include "version.h"
|
||||
|
||||
typedef struct {
|
||||
int32_t id;
|
||||
uint32_t id;
|
||||
int8_t connType;
|
||||
char user[TSDB_USER_LEN];
|
||||
char app[TSDB_APP_NAME_LEN]; // app name that invokes taosc
|
||||
|
@ -35,15 +35,15 @@ typedef struct {
|
|||
int8_t killed;
|
||||
int64_t loginTimeMs;
|
||||
int64_t lastAccessTimeMs;
|
||||
int32_t queryId;
|
||||
uint64_t killId;
|
||||
int32_t numOfQueries;
|
||||
SQueryDesc *pQueries;
|
||||
SArray *pQueries; //SArray<SQueryDesc>
|
||||
} SConnObj;
|
||||
|
||||
static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType, uint32_t ip, uint16_t port,
|
||||
int32_t pid, const char *app, int64_t startTime);
|
||||
static void mndFreeConn(SConnObj *pConn);
|
||||
static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId);
|
||||
static SConnObj *mndAcquireConn(SMnode *pMnode, uint32_t connId);
|
||||
static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn);
|
||||
static void *mndGetNextConn(SMnode *pMnode, SCacheIter *pIter);
|
||||
static void mndCancelGetNextConn(SMnode *pMnode, void *pIter);
|
||||
|
@ -91,8 +91,9 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
|
|||
int32_t pid, const char *app, int64_t startTime) {
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
int32_t connId = atomic_add_fetch_32(&pMgmt->connId, 1);
|
||||
if (connId == 0) atomic_add_fetch_32(&pMgmt->connId, 1);
|
||||
char connStr[255] = {0};
|
||||
int32_t len = snprintf(connStr, sizeof(connStr), "%s%d%d%d%s", user, ip, port, pid, app);
|
||||
int32_t connId = mndGenerateUid(connStr, len);
|
||||
if (startTime == 0) startTime = taosGetTimestampMs();
|
||||
|
||||
SConnObj connObj = {.id = connId,
|
||||
|
@ -104,7 +105,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
|
|||
.killed = 0,
|
||||
.loginTimeMs = taosGetTimestampMs(),
|
||||
.lastAccessTimeMs = 0,
|
||||
.queryId = 0,
|
||||
.killId = 0,
|
||||
.numOfQueries = 0,
|
||||
.pQueries = NULL};
|
||||
|
||||
|
@ -119,35 +120,35 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
|
|||
mError("conn:%d, failed to put into cache since %s, user:%s", connId, user, terrstr());
|
||||
return NULL;
|
||||
} else {
|
||||
mTrace("conn:%d, is created, data:%p user:%s", pConn->id, pConn, user);
|
||||
mTrace("conn:%u, is created, data:%p user:%s", pConn->id, pConn, user);
|
||||
return pConn;
|
||||
}
|
||||
}
|
||||
|
||||
static void mndFreeConn(SConnObj *pConn) {
|
||||
taosMemoryFreeClear(pConn->pQueries);
|
||||
mTrace("conn:%d, is destroyed, data:%p", pConn->id, pConn);
|
||||
mTrace("conn:%u, is destroyed, data:%p", pConn->id, pConn);
|
||||
}
|
||||
|
||||
static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId) {
|
||||
static SConnObj *mndAcquireConn(SMnode *pMnode, uint32_t connId) {
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
SConnObj *pConn = taosCacheAcquireByKey(pMgmt->cache, &connId, sizeof(int32_t));
|
||||
SConnObj *pConn = taosCacheAcquireByKey(pMgmt->cache, &connId, sizeof(connId));
|
||||
if (pConn == NULL) {
|
||||
mDebug("conn:%d, already destroyed", connId);
|
||||
mDebug("conn:%u, already destroyed", connId);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t keepTime = tsShellActivityTimer * 3;
|
||||
pConn->lastAccessTimeMs = keepTime * 1000 + (uint64_t)taosGetTimestampMs();
|
||||
|
||||
mTrace("conn:%d, acquired from cache, data:%p", pConn->id, pConn);
|
||||
mTrace("conn:%u, acquired from cache, data:%p", pConn->id, pConn);
|
||||
return pConn;
|
||||
}
|
||||
|
||||
static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn) {
|
||||
if (pConn == NULL) return;
|
||||
mTrace("conn:%d, released from cache, data:%p", pConn->id, pConn);
|
||||
mTrace("conn:%u, released from cache, data:%p", pConn->id, pConn);
|
||||
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
taosCacheRelease(pMgmt->cache, (void **)&pConn, false);
|
||||
|
@ -212,6 +213,8 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) {
|
|||
goto CONN_OVER;
|
||||
}
|
||||
|
||||
mndAcquireConn(pMnode, pConn->id);
|
||||
|
||||
SConnectRsp connectRsp = {0};
|
||||
connectRsp.acctId = pUser->acctId;
|
||||
connectRsp.superUser = pUser->superUser;
|
||||
|
@ -232,7 +235,7 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) {
|
|||
pReq->rspLen = contLen;
|
||||
pReq->pRsp = pRsp;
|
||||
|
||||
mDebug("user:%s, login from %s, conn:%d, app:%s", pReq->user, ip, pConn->id, connReq.app);
|
||||
mDebug("user:%s, login from %s:%d, conn:%u, app:%s", pReq->user, ip, pConn->port, pConn->id, connReq.app);
|
||||
|
||||
code = 0;
|
||||
|
||||
|
@ -245,22 +248,13 @@ CONN_OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) {
|
||||
pConn->numOfQueries = 0;
|
||||
int32_t numOfQueries = htonl(pReq->numOfQueries);
|
||||
static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) {
|
||||
taosArrayDestroyEx(pConn->pQueries, tFreeClientHbQueryDesc);
|
||||
|
||||
if (numOfQueries > 0) {
|
||||
if (pConn->pQueries == NULL) {
|
||||
pConn->pQueries = taosMemoryCalloc(sizeof(SQueryDesc), QUERY_SAVE_SIZE);
|
||||
}
|
||||
pConn->pQueries = pBasic->queryDesc;
|
||||
pBasic->queryDesc = NULL;
|
||||
|
||||
pConn->numOfQueries = TMIN(QUERY_SAVE_SIZE, numOfQueries);
|
||||
|
||||
int32_t saveSize = pConn->numOfQueries * sizeof(SQueryDesc);
|
||||
if (saveSize > 0 && pConn->pQueries != NULL) {
|
||||
memcpy(pConn->pQueries, pReq->pData, saveSize);
|
||||
}
|
||||
}
|
||||
pConn->numOfQueries = pBasic->queryDesc ? taosArrayGetSize(pBasic->queryDesc) : 0;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -330,28 +324,71 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHbReq *pHbReq, SClientHbBatchRsp *pBatchRsp) {
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = NULL, .query = NULL};
|
||||
|
||||
SClientHbBatchReq batchReq = {0};
|
||||
if (tDeserializeSClientHbBatchReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &batchReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
if (pHbReq->query) {
|
||||
SQueryHbReqBasic *pBasic = pHbReq->query;
|
||||
|
||||
SRpcConnInfo connInfo = {0};
|
||||
rpcGetConnInfo(pMsg->handle, &connInfo);
|
||||
|
||||
SConnObj *pConn = mndAcquireConn(pMnode, pBasic->connId);
|
||||
if (pConn == NULL) {
|
||||
pConn = mndCreateConn(pMnode, connInfo.user, CONN_TYPE__QUERY, connInfo.clientIp, connInfo.clientPort, pBasic->pid, pBasic->app, 0);
|
||||
if (pConn == NULL) {
|
||||
mError("user:%s, conn:%u is freed and failed to create new since %s", connInfo.user, pBasic->connId, terrstr());
|
||||
return -1;
|
||||
} else {
|
||||
mDebug("user:%s, conn:%u is freed and create a new conn:%u", connInfo.user, pBasic->connId, pConn->id);
|
||||
}
|
||||
} else if (pConn->killed) {
|
||||
mError("user:%s, conn:%u is already killed", connInfo.user, pConn->id);
|
||||
mndReleaseConn(pMnode, pConn);
|
||||
terrno = TSDB_CODE_MND_INVALID_CONNECTION;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SClientHbBatchRsp batchRsp = {0};
|
||||
batchRsp.rsps = taosArrayInit(0, sizeof(SClientHbRsp));
|
||||
|
||||
int32_t sz = taosArrayGetSize(batchReq.reqs);
|
||||
for (int i = 0; i < sz; i++) {
|
||||
SClientHbReq *pHbReq = taosArrayGet(batchReq.reqs, i);
|
||||
if (pHbReq->connKey.hbType == HEARTBEAT_TYPE_QUERY) {
|
||||
int32_t kvNum = taosHashGetSize(pHbReq->info);
|
||||
if (NULL == pHbReq->info || kvNum <= 0) {
|
||||
continue;
|
||||
SQueryHbRspBasic *rspBasic = taosMemoryCalloc(1, sizeof(SQueryHbRspBasic));
|
||||
if (rspBasic == NULL) {
|
||||
mndReleaseConn(pMnode, pConn);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("user:%s, conn:%u failed to process hb while since %s", pConn->user, pBasic->connId, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = taosArrayInit(kvNum, sizeof(SKv))};
|
||||
mndSaveQueryList(pConn, pBasic);
|
||||
if (pConn->killed != 0) {
|
||||
rspBasic->killConnection = 1;
|
||||
}
|
||||
|
||||
if (pConn->killId != 0) {
|
||||
rspBasic->killRid = pConn->killId;
|
||||
pConn->killId = 0;
|
||||
}
|
||||
|
||||
rspBasic->connId = pConn->id;
|
||||
rspBasic->totalDnodes = 1; //TODO
|
||||
rspBasic->onlineDnodes = 1; //TODO
|
||||
mndGetMnodeEpSet(pMnode, &rspBasic->epSet);
|
||||
mndReleaseConn(pMnode, pConn);
|
||||
|
||||
hbRsp.query = rspBasic;
|
||||
}
|
||||
|
||||
int32_t kvNum = taosHashGetSize(pHbReq->info);
|
||||
if (NULL == pHbReq->info || kvNum <= 0) {
|
||||
taosArrayPush(pBatchRsp->rsps, &hbRsp);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
hbRsp.info = taosArrayInit(kvNum, sizeof(SKv));
|
||||
if (NULL == hbRsp.info) {
|
||||
mError("taosArrayInit %d rsp kv failed", kvNum);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *pIter = taosHashIterate(pHbReq->info, NULL);
|
||||
while (pIter != NULL) {
|
||||
|
@ -387,8 +424,29 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
|
|||
pIter = taosHashIterate(pHbReq->info, pIter);
|
||||
}
|
||||
|
||||
taosArrayPush(batchRsp.rsps, &hbRsp);
|
||||
} else if (pHbReq->connKey.hbType == HEARTBEAT_TYPE_MQ) {
|
||||
taosArrayPush(pBatchRsp->rsps, &hbRsp);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
|
||||
SClientHbBatchReq batchReq = {0};
|
||||
if (tDeserializeSClientHbBatchReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &batchReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SClientHbBatchRsp batchRsp = {0};
|
||||
batchRsp.rsps = taosArrayInit(0, sizeof(SClientHbRsp));
|
||||
|
||||
int32_t sz = taosArrayGetSize(batchReq.reqs);
|
||||
for (int i = 0; i < sz; i++) {
|
||||
SClientHbReq *pHbReq = taosArrayGet(batchReq.reqs, i);
|
||||
if (pHbReq->connKey.connType == CONN_TYPE__QUERY) {
|
||||
mndProcessQueryHeartBeat(pMnode, &pReq->rpcMsg, pHbReq, &batchRsp);
|
||||
} else if (pHbReq->connKey.connType == CONN_TYPE__TMQ) {
|
||||
SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq);
|
||||
if (pRsp != NULL) {
|
||||
taosArrayPush(batchRsp.rsps, pRsp);
|
||||
|
@ -416,73 +474,8 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
|
|||
taosArrayDestroy(batchRsp.rsps);
|
||||
pReq->rspLen = tlen;
|
||||
pReq->pRsp = buf;
|
||||
|
||||
return 0;
|
||||
|
||||
#if 0
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
SHeartBeatReq *pHeartbeat = pReq->rpcMsg.pCont;
|
||||
pHeartbeat->connId = htonl(pHeartbeat->connId);
|
||||
pHeartbeat->pid = htonl(pHeartbeat->pid);
|
||||
|
||||
SConnObj *pConn = mndAcquireConn(pMnode, pHeartbeat->connId);
|
||||
if (pConn == NULL) {
|
||||
pConn = mndCreateConn(pMnode, &info, pHeartbeat->pid, pHeartbeat->app, 0);
|
||||
if (pConn == NULL) {
|
||||
mError("user:%s, conn:%d is freed and failed to create new since %s", pReq->user, pHeartbeat->connId, terrstr());
|
||||
return -1;
|
||||
} else {
|
||||
mDebug("user:%s, conn:%d is freed and create a new conn:%d", pReq->user, pHeartbeat->connId, pConn->id);
|
||||
}
|
||||
} else if (pConn->killed) {
|
||||
mError("user:%s, conn:%d is already killed", pReq->user, pConn->id);
|
||||
terrno = TSDB_CODE_MND_INVALID_CONNECTION;
|
||||
return -1;
|
||||
} else {
|
||||
if (pConn->ip != info.clientIp || pConn->port != info.clientPort /* || strcmp(pConn->user, info.user) != 0 */) {
|
||||
char oldIpStr[40];
|
||||
char newIpStr[40];
|
||||
taosIpPort2String(pConn->ip, pConn->port, oldIpStr);
|
||||
taosIpPort2String(info.clientIp, info.clientPort, newIpStr);
|
||||
mError("conn:%d, incoming conn user:%s ip:%s, not match exist user:%s ip:%s", pConn->id, info.user, newIpStr,
|
||||
pConn->user, oldIpStr);
|
||||
|
||||
if (pMgmt->connId < pConn->id) pMgmt->connId = pConn->id + 1;
|
||||
taosCacheRelease(pMgmt->cache, (void **)&pConn, false);
|
||||
terrno = TSDB_CODE_MND_INVALID_CONNECTION;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
SHeartBeatRsp *pRsp = rpcMallocCont(sizeof(SHeartBeatRsp));
|
||||
if (pRsp == NULL) {
|
||||
mndReleaseConn(pMnode, pConn);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("user:%s, conn:%d failed to process hb while since %s", pReq->user, pHeartbeat->connId, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
mndSaveQueryStreamList(pConn, pHeartbeat);
|
||||
if (pConn->killed != 0) {
|
||||
pRsp->killConnection = 1;
|
||||
}
|
||||
|
||||
if (pConn->queryId != 0) {
|
||||
pRsp->queryId = htonl(pConn->queryId);
|
||||
pConn->queryId = 0;
|
||||
}
|
||||
|
||||
pRsp->connId = htonl(pConn->id);
|
||||
pRsp->totalDnodes = htonl(1);
|
||||
pRsp->onlineDnodes = htonl(1);
|
||||
mndGetMnodeEpSet(pMnode, &pRsp->epSet);
|
||||
mndReleaseConn(pMnode, pConn);
|
||||
|
||||
pReq->contLen = sizeof(SConnectRsp);
|
||||
pReq->pRsp = pRsp;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) {
|
||||
|
@ -513,7 +506,7 @@ static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) {
|
|||
return -1;
|
||||
} else {
|
||||
mInfo("connId:%d, queryId:%d is killed by user:%s", killReq.connId, killReq.queryId, pReq->user);
|
||||
pConn->queryId = killReq.queryId;
|
||||
pConn->killId = killReq.queryId;
|
||||
taosCacheRelease(pMgmt->cache, (void **)&pConn, false);
|
||||
return 0;
|
||||
}
|
||||
|
@ -571,7 +564,7 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int
|
|||
cols = 0;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
*(int32_t *)pWrite = pConn->id;
|
||||
*(uint32_t *)pWrite = pConn->id;
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
|
@ -613,6 +606,7 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int
|
|||
static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t numOfRows = 0;
|
||||
#if 0
|
||||
SConnObj *pConn = NULL;
|
||||
int32_t cols = 0;
|
||||
char *pWrite;
|
||||
|
@ -709,6 +703,7 @@ static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, i
|
|||
}
|
||||
|
||||
pShow->numOfRows += numOfRows;
|
||||
#endif
|
||||
return numOfRows;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,6 +131,13 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
req.type = retrieveReq.type;
|
||||
strncpy(req.db, retrieveReq.db, tListLen(req.db));
|
||||
|
||||
STableMetaRsp *pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb) + 1);
|
||||
if (pMeta == NULL) {
|
||||
terrno = TSDB_CODE_MND_INVALID_INFOS_TBL;
|
||||
mError("failed to process show-retrieve req:%p since %s", pShow, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
pShow = mndCreateShowObj(pMnode, &req);
|
||||
if (pShow == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -138,7 +145,7 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
pShow->pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb) + 1);
|
||||
pShow->pMeta = pMeta;
|
||||
pShow->numOfColumns = pShow->pMeta->numOfColumns;
|
||||
int32_t offset = 0;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "mndDb.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndInfoSchema.h"
|
||||
#include "mndPerfSchema.h"
|
||||
#include "mndMnode.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndTrans.h"
|
||||
|
@ -1516,6 +1517,11 @@ static int32_t mndProcessTableMetaReq(SNodeMsg *pReq) {
|
|||
if (mndBuildInsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) {
|
||||
goto RETRIEVE_META_OVER;
|
||||
}
|
||||
} else if (0 == strcmp(infoReq.dbFName, TSDB_PERFORMANCE_SCHEMA_DB)) {
|
||||
mDebug("performance_schema table:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName);
|
||||
if (mndBuildPerfsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) {
|
||||
goto RETRIEVE_META_OVER;
|
||||
}
|
||||
} else {
|
||||
mDebug("stb:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName);
|
||||
if (mndBuildStbSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) {
|
||||
|
|
|
@ -58,7 +58,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans);
|
|||
static int32_t mndProcessTransReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessKillTransReq(SNodeMsg *pReq);
|
||||
|
||||
static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
||||
static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||
static void mndCancelGetNextTrans(SMnode *pMnode, void *pIter);
|
||||
|
||||
int32_t mndInitTrans(SMnode *pMnode) {
|
||||
|
@ -73,7 +73,7 @@ int32_t mndInitTrans(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_MND_TRANS_TIMER, mndProcessTransReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_KILL_TRANS, mndProcessKillTransReq);
|
||||
|
||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndRetrieveTrans);
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndRetrieveTrans);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndCancelGetNextTrans);
|
||||
return sdbSetTable(pMnode->pSdb, table);
|
||||
}
|
||||
|
@ -1259,7 +1259,7 @@ void mndTransPullup(SMnode *pMnode) {
|
|||
sdbWriteFile(pMnode->pSdb);
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t numOfRows = 0;
|
||||
|
@ -1273,34 +1273,34 @@ static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int
|
|||
|
||||
cols = 0;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
*(int32_t *)pWrite = pTrans->id;
|
||||
cols++;
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->id, false);
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
*(int64_t *)pWrite = pTrans->createdTime;
|
||||
cols++;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false);
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_TO_VARSTR(pWrite, mndTransStr(pTrans->stage));
|
||||
cols++;
|
||||
char stage[TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(stage, mndTransStr(pTrans->stage), pShow->bytes[cols]);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)stage, false);
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
char *name = mnGetDbStr(pTrans->dbname);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, name, pShow->bytes[cols]);
|
||||
cols++;
|
||||
char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->bytes[cols]);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)dbname, false);
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_TO_VARSTR(pWrite, mndTransType(pTrans->transType));
|
||||
cols++;
|
||||
char transType[TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndTransType(pTrans->transType), pShow->bytes[cols]);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)transType, false);
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
*(int64_t *)pWrite = pTrans->lastExecTime;
|
||||
cols++;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false);
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_TO_VARSTR(pWrite, pTrans->lastError);
|
||||
cols++;
|
||||
char lastError[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, pTrans->lastError, pShow->bytes[cols]);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)lastError, false);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pTrans);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "mndDnode.h"
|
||||
#include "mndFunc.h"
|
||||
#include "mndInfoSchema.h"
|
||||
#include "mndPerfSchema.h"
|
||||
#include "mndMnode.h"
|
||||
#include "mndOffset.h"
|
||||
#include "mndProfile.h"
|
||||
|
@ -210,6 +211,7 @@ static int32_t mndInitSteps(SMnode *pMnode, bool deploy) {
|
|||
if (mndAllocStep(pMnode, "mnode-stb", mndInitStb, mndCleanupStb) != 0) return -1;
|
||||
if (mndAllocStep(pMnode, "mnode-stb", mndInitSma, mndCleanupSma) != 0) return -1;
|
||||
if (mndAllocStep(pMnode, "mnode-infos", mndInitInfos, mndCleanupInfos) != 0) return -1;
|
||||
if (mndAllocStep(pMnode, "mnode-perfs", mndInitPerfs, mndCleanupPerfs) != 0) return -1;
|
||||
if (mndAllocStep(pMnode, "mnode-db", mndInitDb, mndCleanupDb) != 0) return -1;
|
||||
if (mndAllocStep(pMnode, "mnode-func", mndInitFunc, mndCleanupFunc) != 0) return -1;
|
||||
if (deploy) {
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
enable_testing()
|
||||
|
||||
#add_subdirectory(user)
|
||||
add_subdirectory(acct)
|
||||
#add_subdirectory(trans)
|
||||
#add_subdirectory(qnode)
|
||||
#add_subdirectory(snode)
|
||||
add_subdirectory(bnode)
|
||||
#add_subdirectory(show)
|
||||
#add_subdirectory(profile)
|
||||
#add_subdirectory(dnode)
|
||||
#add_subdirectory(mnode)
|
||||
#add_subdirectory(db)
|
||||
#add_subdirectory(stb)
|
||||
#add_subdirectory(sma)
|
||||
#add_subdirectory(func)
|
||||
#add_subdirectory(topic)
|
||||
add_subdirectory(db)
|
||||
add_subdirectory(dnode)
|
||||
add_subdirectory(func)
|
||||
add_subdirectory(mnode)
|
||||
add_subdirectory(profile)
|
||||
add_subdirectory(qnode)
|
||||
add_subdirectory(show)
|
||||
add_subdirectory(sma)
|
||||
add_subdirectory(snode)
|
||||
add_subdirectory(stb)
|
||||
add_subdirectory(topic)
|
||||
add_subdirectory(trans)
|
||||
add_subdirectory(user)
|
||||
|
|
|
@ -5,7 +5,7 @@ target_link_libraries(
|
|||
PUBLIC sut
|
||||
)
|
||||
|
||||
#add_test(
|
||||
# NAME mnode_test_db
|
||||
# COMMAND mnode_test_db
|
||||
#)
|
||||
add_test(
|
||||
NAME dbTest
|
||||
COMMAND dbTest
|
||||
)
|
||||
|
|
|
@ -26,29 +26,8 @@ class MndTestDb : public ::testing::Test {
|
|||
Testbase MndTestDb::test;
|
||||
|
||||
TEST_F(MndTestDb, 01_ShowDb) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 17);
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "vgroups");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "ntables");
|
||||
CHECK_SCHEMA(4, TSDB_DATA_TYPE_SMALLINT, 2, "replica");
|
||||
CHECK_SCHEMA(5, TSDB_DATA_TYPE_SMALLINT, 2, "quorum");
|
||||
CHECK_SCHEMA(6, TSDB_DATA_TYPE_SMALLINT, 2, "days");
|
||||
CHECK_SCHEMA(7, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "keep0,keep1,keep2");
|
||||
CHECK_SCHEMA(8, TSDB_DATA_TYPE_INT, 4, "cache");
|
||||
CHECK_SCHEMA(9, TSDB_DATA_TYPE_INT, 4, "blocks");
|
||||
CHECK_SCHEMA(10, TSDB_DATA_TYPE_INT, 4, "minrows");
|
||||
CHECK_SCHEMA(11, TSDB_DATA_TYPE_INT, 4, "maxrows");
|
||||
CHECK_SCHEMA(12, TSDB_DATA_TYPE_TINYINT, 1, "wallevel");
|
||||
CHECK_SCHEMA(13, TSDB_DATA_TYPE_INT, 4, "fsync");
|
||||
CHECK_SCHEMA(14, TSDB_DATA_TYPE_TINYINT, 1, "comp");
|
||||
CHECK_SCHEMA(15, TSDB_DATA_TYPE_TINYINT, 1, "cachelast");
|
||||
CHECK_SCHEMA(16, TSDB_DATA_TYPE_BINARY, 3 + VARSTR_HEADER_SIZE, "precision");
|
||||
// CHECK_SCHEMA(17, TSDB_DATA_TYPE_TINYINT, 1, "update");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
||||
|
@ -58,7 +37,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
createReq.numOfVgroups = 2;
|
||||
createReq.cacheBlockSize = 16;
|
||||
createReq.totalBlocks = 10;
|
||||
createReq.daysPerFile = 10;
|
||||
createReq.daysPerFile = 1000;
|
||||
createReq.daysToKeep0 = 3650;
|
||||
createReq.daysToKeep1 = 3650;
|
||||
createReq.daysToKeep2 = 3650;
|
||||
|
@ -66,6 +45,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
createReq.maxRows = 4096;
|
||||
createReq.commitTime = 3600;
|
||||
createReq.fsyncPeriod = 3000;
|
||||
createReq.ttl = 0;
|
||||
createReq.walLevel = 1;
|
||||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
|
@ -74,6 +54,9 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ignoreExist = 1;
|
||||
createReq.streamMode = 0;
|
||||
createReq.singleSTable = 0;
|
||||
createReq.numOfRetensions = 0;
|
||||
|
||||
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
|
@ -84,47 +67,11 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 17);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 3);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
||||
CheckTimestamp();
|
||||
CheckInt16(2); // vgroups
|
||||
CheckInt32(0); // ntables
|
||||
CheckInt16(1); // replica
|
||||
CheckInt16(1); // quorum
|
||||
CheckInt16(10); // days
|
||||
CheckBinary("3650,3650,3650", 24); // days
|
||||
CheckInt32(16); // cache
|
||||
CheckInt32(10); // blocks
|
||||
CheckInt32(100); // minrows
|
||||
CheckInt32(4096); // maxrows
|
||||
CheckInt8(1); // wallevel
|
||||
CheckInt32(3000); // fsync
|
||||
CheckInt8(2); // comp
|
||||
CheckInt8(0); // cachelast
|
||||
CheckBinary("ms", 3); // precision
|
||||
CheckInt8(0); // update
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_VGROUP, "1.d1");
|
||||
CHECK_META("show vgroups", 4);
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "vgId");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_INT, 4, "tables");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "v1_dnode");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, 9 + VARSTR_HEADER_SIZE, "v1_status");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_VGROUP, "vgroups", "1.d1");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
CheckInt32(2);
|
||||
CheckInt32(3);
|
||||
IgnoreInt32();
|
||||
IgnoreInt32();
|
||||
CheckInt16(1);
|
||||
CheckInt16(1);
|
||||
CheckBinary("master", 9);
|
||||
CheckBinary("master", 9);
|
||||
|
||||
{
|
||||
SAlterDbReq alterdbReq = {0};
|
||||
|
@ -147,55 +94,14 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
||||
CheckTimestamp();
|
||||
CheckInt16(2); // vgroups
|
||||
CheckInt32(0); // tables
|
||||
CheckInt16(1); // replica
|
||||
CheckInt16(2); // quorum
|
||||
CheckInt16(10); // days
|
||||
CheckBinary("300,400,500", 24); // days
|
||||
CheckInt32(16); // cache
|
||||
CheckInt32(12); // blocks
|
||||
CheckInt32(100); // minrows
|
||||
CheckInt32(4096); // maxrows
|
||||
CheckInt8(2); // wallevel
|
||||
CheckInt32(4000); // fsync
|
||||
CheckInt8(2); // comp
|
||||
CheckInt8(1); // cachelast
|
||||
CheckBinary("ms", 3); // precision
|
||||
CheckInt8(0); // update
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 3);
|
||||
|
||||
// restart
|
||||
test.Restart();
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 17);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckBinary("d1", TSDB_DB_NAME_LEN - 1);
|
||||
CheckTimestamp();
|
||||
CheckInt16(2); // vgroups
|
||||
CheckInt32(0); // tables
|
||||
CheckInt16(1); // replica
|
||||
CheckInt16(2); // quorum
|
||||
CheckInt16(10); // days
|
||||
CheckBinary("300,400,500", 24); // days
|
||||
CheckInt32(16); // cache
|
||||
CheckInt32(12); // blocks
|
||||
CheckInt32(100); // minrows
|
||||
CheckInt32(4096); // maxrows
|
||||
CheckInt8(2); // wallevel
|
||||
CheckInt32(4000); // fsync
|
||||
CheckInt8(2); // comp
|
||||
CheckInt8(1); // cachelast
|
||||
CheckBinary("ms", 3); // precision
|
||||
CheckInt8(0); // update
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 3);
|
||||
|
||||
{
|
||||
SDropDbReq dropdbReq = {0};
|
||||
|
@ -214,11 +120,8 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
EXPECT_STREQ(dropdbRsp.db, "1.d1");
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 17);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
|
||||
|
@ -228,7 +131,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
|
|||
createReq.numOfVgroups = 2;
|
||||
createReq.cacheBlockSize = 16;
|
||||
createReq.totalBlocks = 10;
|
||||
createReq.daysPerFile = 10;
|
||||
createReq.daysPerFile = 1000;
|
||||
createReq.daysToKeep0 = 3650;
|
||||
createReq.daysToKeep1 = 3650;
|
||||
createReq.daysToKeep2 = 3650;
|
||||
|
@ -236,6 +139,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
|
|||
createReq.maxRows = 4096;
|
||||
createReq.commitTime = 3600;
|
||||
createReq.fsyncPeriod = 3000;
|
||||
createReq.ttl = 0;
|
||||
createReq.walLevel = 1;
|
||||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
|
@ -244,6 +148,9 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
|
|||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ignoreExist = 1;
|
||||
createReq.streamMode = 0;
|
||||
createReq.singleSTable = 0;
|
||||
createReq.numOfRetensions = 0;
|
||||
|
||||
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
|
@ -254,12 +161,8 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, "");
|
||||
CHECK_META("show databases", 17);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("d2", TSDB_DB_NAME_LEN - 1);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 3);
|
||||
|
||||
uint64_t d2_uid = 0;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ target_link_libraries(
|
|||
PUBLIC sut
|
||||
)
|
||||
|
||||
#add_test(
|
||||
# NAME mnode_test_dnode
|
||||
# COMMAND mnode_test_dnode
|
||||
#)
|
||||
add_test(
|
||||
NAME mdnodeTest
|
||||
COMMAND mdnodeTest
|
||||
)
|
||||
|
|
|
@ -51,27 +51,8 @@ TestServer MndTestDnode::server4;
|
|||
TestServer MndTestDnode::server5;
|
||||
|
||||
TEST_F(MndTestDnode, 01_ShowDnode) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
CHECK_META("show dnodes", 7);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "vnodes");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_SMALLINT, 2, "support_vnodes");
|
||||
CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, 10 + VARSTR_HEADER_SIZE, "status");
|
||||
CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CHECK_SCHEMA(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "offline_reason");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckBinary("localhost:9023", TSDB_EP_LEN);
|
||||
CheckInt16(0);
|
||||
CheckInt16(16);
|
||||
CheckBinary("ready", 10);
|
||||
CheckTimestamp();
|
||||
CheckBinary("", 24);
|
||||
}
|
||||
|
||||
TEST_F(MndTestDnode, 02_ConfigDnode) {
|
||||
|
@ -162,25 +143,8 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
|
|||
|
||||
taosMsleep(1300);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
CHECK_META("show dnodes", 7);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckInt16(2);
|
||||
CheckBinary("localhost:9023", TSDB_EP_LEN);
|
||||
CheckBinary("localhost:9024", TSDB_EP_LEN);
|
||||
CheckInt16(0);
|
||||
CheckInt16(0);
|
||||
CheckInt16(16);
|
||||
CheckInt16(16);
|
||||
CheckBinary("ready", 10);
|
||||
CheckBinary("ready", 10);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckBinary("", 24);
|
||||
CheckBinary("", 24);
|
||||
}
|
||||
|
||||
TEST_F(MndTestDnode, 04_Drop_Dnode) {
|
||||
|
@ -236,19 +200,9 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
|
|||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DNODE_NOT_EXIST);
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
CHECK_META("show dnodes", 7);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckBinary("localhost:9023", TSDB_EP_LEN);
|
||||
CheckInt16(0);
|
||||
CheckInt16(16);
|
||||
CheckBinary("ready", 10);
|
||||
CheckTimestamp();
|
||||
CheckBinary("", 24);
|
||||
|
||||
taosMsleep(2000);
|
||||
server2.Stop();
|
||||
server2.DoStart();
|
||||
|
@ -298,40 +252,9 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) {
|
|||
}
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
CHECK_META("show dnodes", 7);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 4);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckInt16(3);
|
||||
CheckInt16(4);
|
||||
CheckInt16(5);
|
||||
CheckBinary("localhost:9023", TSDB_EP_LEN);
|
||||
CheckBinary("localhost:9025", TSDB_EP_LEN);
|
||||
CheckBinary("localhost:9026", TSDB_EP_LEN);
|
||||
CheckBinary("localhost:9027", TSDB_EP_LEN);
|
||||
CheckInt16(0);
|
||||
CheckInt16(0);
|
||||
CheckInt16(0);
|
||||
CheckInt16(0);
|
||||
CheckInt16(16);
|
||||
CheckInt16(16);
|
||||
CheckInt16(16);
|
||||
CheckInt16(16);
|
||||
CheckBinary("ready", 10);
|
||||
CheckBinary("ready", 10);
|
||||
CheckBinary("ready", 10);
|
||||
CheckBinary("ready", 10);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckBinary("", 24);
|
||||
CheckBinary("", 24);
|
||||
CheckBinary("", 24);
|
||||
CheckBinary("", 24);
|
||||
|
||||
// restart
|
||||
uInfo("stop all server");
|
||||
test.Restart();
|
||||
|
@ -341,37 +264,6 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) {
|
|||
server5.Restart();
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
CHECK_META("show dnodes", 7);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 4);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckInt16(3);
|
||||
CheckInt16(4);
|
||||
CheckInt16(5);
|
||||
CheckBinary("localhost:9023", TSDB_EP_LEN);
|
||||
CheckBinary("localhost:9025", TSDB_EP_LEN);
|
||||
CheckBinary("localhost:9026", TSDB_EP_LEN);
|
||||
CheckBinary("localhost:9027", TSDB_EP_LEN);
|
||||
CheckInt16(0);
|
||||
CheckInt16(0);
|
||||
CheckInt16(0);
|
||||
CheckInt16(0);
|
||||
CheckInt16(16);
|
||||
CheckInt16(16);
|
||||
CheckInt16(16);
|
||||
CheckInt16(16);
|
||||
CheckBinary("ready", 10);
|
||||
CheckBinary("ready", 10);
|
||||
CheckBinary("ready", 10);
|
||||
CheckBinary("ready", 10);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckBinary("", 24);
|
||||
CheckBinary("", 24);
|
||||
CheckBinary("", 24);
|
||||
CheckBinary("", 24);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. FUNC_SRC)
|
||||
add_executable(mnode_test_func ${FUNC_SRC})
|
||||
aux_source_directory(. MNODE_FUNC_TEST_SRC)
|
||||
add_executable(funcTest ${MNODE_FUNC_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_func
|
||||
funcTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_func
|
||||
COMMAND mnode_test_func
|
||||
NAME funcTest
|
||||
COMMAND funcTest
|
||||
)
|
||||
|
|
|
@ -26,18 +26,7 @@ class MndTestFunc : public ::testing::Test {
|
|||
Testbase MndTestFunc::test;
|
||||
|
||||
TEST_F(MndTestFunc, 01_Show_Func) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, "");
|
||||
CHECK_META("show functions", 7);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, PATH_MAX + VARSTR_HEADER_SIZE, "comment");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_INT, 4, "aggregate");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_TYPE_STR_MAX_LEN + VARSTR_HEADER_SIZE, "outputtype");
|
||||
CHECK_SCHEMA(4, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CHECK_SCHEMA(5, TSDB_DATA_TYPE_INT, 4, "code_len");
|
||||
CHECK_SCHEMA(6, TSDB_DATA_TYPE_INT, 4, "bufsize");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -194,19 +183,8 @@ TEST_F(MndTestFunc, 02_Create_Func) {
|
|||
}
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, "");
|
||||
CHECK_META("show functions", 7);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckBinary("f1", TSDB_FUNC_NAME_LEN);
|
||||
CheckBinaryByte('m', TSDB_FUNC_COMMENT_LEN);
|
||||
CheckInt32(0);
|
||||
CheckBinary("SMALLINT", TSDB_TYPE_STR_MAX_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(TSDB_FUNC_CODE_LEN);
|
||||
CheckInt32(4);
|
||||
}
|
||||
|
||||
TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
||||
|
@ -331,10 +309,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, "");
|
||||
CHECK_META("show functions", 7);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -529,20 +504,12 @@ TEST_F(MndTestFunc, 04_Drop_Func) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, "");
|
||||
CHECK_META("show functions", 7);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
// restart
|
||||
test.Restart();
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, "");
|
||||
CHECK_META("show functions", 7);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckBinary("f2", TSDB_FUNC_NAME_LEN);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. MTEST_SRC)
|
||||
add_executable(mnode_test_mnode ${MTEST_SRC})
|
||||
aux_source_directory(. MNODE_MNODE_TEST_SRC)
|
||||
add_executable(mmnodeTest ${MNODE_MNODE_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_mnode
|
||||
mmnodeTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_mnode
|
||||
COMMAND mnode_test_mnode
|
||||
NAME mmnodeTest
|
||||
COMMAND mmnodeTest
|
||||
)
|
||||
|
|
|
@ -39,23 +39,8 @@ Testbase MndTestMnode::test;
|
|||
TestServer MndTestMnode::server2;
|
||||
|
||||
TEST_F(MndTestMnode, 01_ShowDnode) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, "");
|
||||
CHECK_META("show mnodes", 5);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, 12 + VARSTR_HEADER_SIZE, "role");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CHECK_SCHEMA(4, TSDB_DATA_TYPE_TIMESTAMP, 8, "role_time");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckBinary("localhost:9028", TSDB_EP_LEN);
|
||||
CheckBinary("master", 12);
|
||||
CheckTimestamp();
|
||||
IgnoreTimestamp();
|
||||
}
|
||||
|
||||
TEST_F(MndTestMnode, 02_Create_Mnode_Invalid_Id) {
|
||||
|
@ -104,8 +89,7 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -122,20 +106,8 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckInt16(2);
|
||||
CheckBinary("localhost:9028", TSDB_EP_LEN);
|
||||
CheckBinary("localhost:9029", TSDB_EP_LEN);
|
||||
CheckBinary("master", 12);
|
||||
CheckBinary("slave", 12);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
IgnoreTimestamp();
|
||||
IgnoreTimestamp();
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -151,15 +123,8 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckBinary("localhost:9028", TSDB_EP_LEN);
|
||||
CheckBinary("master", 12);
|
||||
CheckTimestamp();
|
||||
IgnoreTimestamp();
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. PROFILE_SRC)
|
||||
add_executable(mnode_test_profile ${PROFILE_SRC})
|
||||
aux_source_directory(. MNODE_PROFILE_TEST_SRC)
|
||||
add_executable(profileTest ${MNODE_PROFILE_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_profile
|
||||
profileTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_profile
|
||||
COMMAND mnode_test_profile
|
||||
NAME profileTest
|
||||
COMMAND profileTest
|
||||
)
|
||||
|
|
|
@ -46,7 +46,7 @@ TEST_F(MndTestProfile, 01_ConnectMsg) {
|
|||
|
||||
EXPECT_EQ(connectRsp.acctId, 1);
|
||||
EXPECT_GT(connectRsp.clusterId, 0);
|
||||
EXPECT_EQ(connectRsp.connId, 1);
|
||||
EXPECT_NE(connectRsp.connId, 0);
|
||||
EXPECT_EQ(connectRsp.superUser, 1);
|
||||
|
||||
EXPECT_EQ(connectRsp.epSet.inUse, 0);
|
||||
|
@ -74,32 +74,16 @@ TEST_F(MndTestProfile, 02_ConnectMsg_InvalidDB) {
|
|||
}
|
||||
|
||||
TEST_F(MndTestProfile, 03_ConnectMsg_Show) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_CONNS, "");
|
||||
CHECK_META("show connections", 7);
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "connId");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "user");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, "program");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "pid");
|
||||
CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, "ip:port");
|
||||
CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "login_time");
|
||||
CHECK_SCHEMA(6, TSDB_DATA_TYPE_TIMESTAMP, 8, "last_access");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckInt32(1);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("mnode_test_profile", TSDB_APP_NAME_LEN);
|
||||
CheckInt32(1234);
|
||||
IgnoreBinary(TSDB_IPv4ADDR_LEN + 6);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_CONNS, "connections", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
TEST_F(MndTestProfile, 04_HeartBeatMsg) {
|
||||
SClientHbBatchReq batchReq = {0};
|
||||
batchReq.reqs = taosArrayInit(0, sizeof(SClientHbReq));
|
||||
SClientHbReq req = {0};
|
||||
req.connKey = {.connId = 123, .hbType = HEARTBEAT_TYPE_MQ};
|
||||
req.connKey.tscRid = 123;
|
||||
req.connKey.connType = CONN_TYPE__TMQ;
|
||||
req.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
|
||||
SKv kv = {0};
|
||||
kv.key = 123;
|
||||
|
@ -311,24 +295,6 @@ TEST_F(MndTestProfile, 08_KillQueryMsg_InvalidConn) {
|
|||
}
|
||||
|
||||
TEST_F(MndTestProfile, 09_KillQueryMsg) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QUERIES, "");
|
||||
CHECK_META("show queries", 14);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "queryId");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_INT, 4, "connId");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "user");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, "ip:port");
|
||||
CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, 22 + VARSTR_HEADER_SIZE, "qid");
|
||||
CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "created_time");
|
||||
CHECK_SCHEMA(6, TSDB_DATA_TYPE_BIGINT, 8, "time");
|
||||
CHECK_SCHEMA(7, TSDB_DATA_TYPE_BINARY, 18 + VARSTR_HEADER_SIZE, "sql_obj_id");
|
||||
CHECK_SCHEMA(8, TSDB_DATA_TYPE_INT, 4, "pid");
|
||||
CHECK_SCHEMA(9, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "ep");
|
||||
CHECK_SCHEMA(10, TSDB_DATA_TYPE_BOOL, 1, "stable_query");
|
||||
CHECK_SCHEMA(11, TSDB_DATA_TYPE_INT, 4, "sub_queries");
|
||||
CHECK_SCHEMA(12, TSDB_DATA_TYPE_BINARY, TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, "sub_query_info");
|
||||
CHECK_SCHEMA(13, TSDB_DATA_TYPE_BINARY, TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, "sql");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_QUERIES, "queries", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. QTEST_SRC)
|
||||
add_executable(mnode_test_qnode ${QTEST_SRC})
|
||||
aux_source_directory(. MNODE_QNODE_TEST_SRC)
|
||||
add_executable(mqnodeTest ${MNODE_QNODE_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_qnode
|
||||
mqnodeTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_qnode
|
||||
COMMAND mnode_test_qnode
|
||||
NAME mqnodeTest
|
||||
COMMAND mqnodeTest
|
||||
)
|
||||
|
|
|
@ -39,14 +39,7 @@ Testbase MndTestQnode::test;
|
|||
TestServer MndTestQnode::server2;
|
||||
|
||||
TEST_F(MndTestQnode, 01_Show_Qnode) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, "");
|
||||
CHECK_META("show qnodes", 3);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -76,14 +69,8 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, "");
|
||||
CHECK_META("show qnodes", 3);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckBinary("localhost:9014", TSDB_EP_LEN);
|
||||
CheckTimestamp();
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -115,8 +102,7 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -132,16 +118,8 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckInt16(2);
|
||||
CheckBinary("localhost:9014", TSDB_EP_LEN);
|
||||
CheckBinary("localhost:9015", TSDB_EP_LEN);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -156,13 +134,8 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckBinary("localhost:9014", TSDB_EP_LEN);
|
||||
CheckTimestamp();
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. SHOW_SRC)
|
||||
add_executable(mnode_test_show ${SHOW_SRC})
|
||||
aux_source_directory(. MNODE_SHOW_TEST_SRC)
|
||||
add_executable(showTest ${MNODE_SHOW_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_show
|
||||
showTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_show
|
||||
COMMAND mnode_test_show
|
||||
NAME showTest
|
||||
COMMAND showTest
|
||||
)
|
||||
|
|
|
@ -34,9 +34,9 @@ TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) {
|
|||
tSerializeSShowReq(pReq, contLen, &showReq);
|
||||
tFreeSShowReq(&showReq);
|
||||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_MSG);
|
||||
}
|
||||
|
||||
TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
|
||||
|
@ -48,9 +48,9 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
|
|||
tSerializeSShowReq(pReq, contLen, &showReq);
|
||||
tFreeSShowReq(&showReq);
|
||||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen);
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_MSG);
|
||||
}
|
||||
|
||||
TEST_F(MndTestShow, 03_ShowMsg_Conn) {
|
||||
|
@ -67,42 +67,11 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_CONNS, "");
|
||||
|
||||
STableMetaRsp* pMeta = test.GetShowMeta();
|
||||
EXPECT_STREQ(pMeta->tbName, "show connections");
|
||||
EXPECT_EQ(pMeta->numOfTags, 0);
|
||||
EXPECT_EQ(pMeta->numOfColumns, 7);
|
||||
EXPECT_EQ(pMeta->precision, 0);
|
||||
EXPECT_EQ(pMeta->tableType, 0);
|
||||
EXPECT_EQ(pMeta->update, 0);
|
||||
EXPECT_EQ(pMeta->sversion, 0);
|
||||
EXPECT_EQ(pMeta->tversion, 0);
|
||||
EXPECT_EQ(pMeta->tuid, 0);
|
||||
EXPECT_EQ(pMeta->suid, 0);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
|
||||
SRetrieveTableRsp* pRetrieveRsp = test.GetRetrieveRsp();
|
||||
EXPECT_EQ(pRetrieveRsp->numOfRows, 1);
|
||||
EXPECT_EQ(pRetrieveRsp->useconds, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->completed, 1);
|
||||
EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(pRetrieveRsp->compressed, 0);
|
||||
EXPECT_EQ(pRetrieveRsp->compLen, 0);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_CONNS, "connections", "");
|
||||
// EXPECT_EQ(test.GetShowRows(), 1);
|
||||
}
|
||||
|
||||
TEST_F(MndTestShow, 04_ShowMsg_Cluster) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_CLUSTER, "");
|
||||
CHECK_META( "show cluster", 3);
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BIGINT, 8, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_CLUSTER, "cluster", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
IgnoreInt64();
|
||||
IgnoreBinary(TSDB_CLUSTER_ID_LEN);
|
||||
CheckTimestamp();
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. SMA_SRC)
|
||||
add_executable(mnode_test_sma ${SMA_SRC})
|
||||
aux_source_directory(. MNODE_SMA_TEST_SRC)
|
||||
add_executable(smaTest ${MNODE_SMA_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_sma
|
||||
smaTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_sma
|
||||
COMMAND mnode_test_sma
|
||||
NAME smaTest
|
||||
COMMAND smaTest
|
||||
)
|
||||
|
|
|
@ -207,7 +207,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
pReq = BuildCreateStbReq(stbname, &contLen);
|
||||
pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables",dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
pReq = BuildCreateTSmaReq(smaname, stbname, 0, "expr", "tagsFilter", "sql", "ast", &contLen);
|
||||
pRsp = test.SendReq(TDMT_MND_CREATE_SMA, pReq, contLen);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_INDEX, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
test.Restart();
|
||||
|
||||
{
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_INDEX, dbname);
|
||||
CHECK_META("show indexes", 3);
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
@ -239,7 +239,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
pReq = BuildDropTSmaReq(smaname, 0, &contLen);
|
||||
pRsp = test.SendReq(TDMT_MND_DROP_SMA, pReq, contLen);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_INDEX, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
@ -263,10 +263,8 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) {
|
|||
pReq = BuildCreateBSmaStbReq(stbname, &contLen);
|
||||
pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables",dbname);
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
// CheckBinary("bsmastb", TSDB_TABLE_NAME_LEN);
|
||||
}
|
||||
|
||||
test.Restart();
|
||||
|
@ -281,8 +279,7 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) {
|
|||
pReq = BuildDropStbReq(stbname, &contLen);
|
||||
pRsp = test.SendReq(TDMT_MND_DROP_STB, pReq, contLen);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables",dbname);
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. STEST_SRC)
|
||||
add_executable(mnode_test_snode ${STEST_SRC})
|
||||
aux_source_directory(. MNODE_SNODE_TEST_SRC)
|
||||
add_executable(msnodeTest ${MNODE_SNODE_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_snode
|
||||
msnodeTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_snode
|
||||
COMMAND mnode_test_snode
|
||||
NAME msnodeTest
|
||||
COMMAND msnodeTest
|
||||
)
|
||||
|
|
|
@ -39,14 +39,7 @@ Testbase MndTestSnode::test;
|
|||
TestServer MndTestSnode::server2;
|
||||
|
||||
TEST_F(MndTestSnode, 01_Show_Snode) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, "");
|
||||
CHECK_META("show snodes", 3);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -76,14 +69,8 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, "");
|
||||
CHECK_META("show snodes", 3);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckBinary("localhost:9016", TSDB_EP_LEN);
|
||||
CheckTimestamp();
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -115,8 +102,7 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -132,16 +118,8 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckInt16(2);
|
||||
CheckBinary("localhost:9016", TSDB_EP_LEN);
|
||||
CheckBinary("localhost:9017", TSDB_EP_LEN);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -156,13 +134,8 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckBinary("localhost:9016", TSDB_EP_LEN);
|
||||
CheckTimestamp();
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ target_link_libraries(
|
|||
PUBLIC sut
|
||||
)
|
||||
|
||||
#add_test(
|
||||
# NAME mnode_test_stb
|
||||
# COMMAND mnode_test_stb
|
||||
#)
|
||||
add_test(
|
||||
NAME stbTest
|
||||
COMMAND stbTest
|
||||
)
|
||||
|
|
|
@ -43,7 +43,7 @@ void* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
|
|||
createReq.numOfVgroups = 2;
|
||||
createReq.cacheBlockSize = 16;
|
||||
createReq.totalBlocks = 10;
|
||||
createReq.daysPerFile = 10;
|
||||
createReq.daysPerFile = 1000;
|
||||
createReq.daysToKeep0 = 3650;
|
||||
createReq.daysToKeep1 = 3650;
|
||||
createReq.daysToKeep2 = 3650;
|
||||
|
@ -314,19 +314,8 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
}
|
||||
|
||||
{
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
CHECK_META("show stables", 4);
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_INT, 4, "columns");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "tags");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname);
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(2);
|
||||
CheckInt32(3);
|
||||
}
|
||||
|
||||
// ----- meta ------
|
||||
|
@ -407,15 +396,8 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
test.Restart();
|
||||
|
||||
{
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
CHECK_META("show stables", 4);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname);
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(2);
|
||||
CheckInt32(3);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -432,9 +414,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
}
|
||||
|
||||
{
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
CHECK_META("show stables", 4);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname);
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -496,13 +476,7 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(2);
|
||||
CheckInt32(4);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -542,13 +516,8 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname);
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(2);
|
||||
CheckInt32(2);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -611,13 +580,8 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname);
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(2);
|
||||
CheckInt32(3);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -668,13 +632,8 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) {
|
|||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname);
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(2);
|
||||
CheckInt32(3);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -734,13 +693,8 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname);
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(3);
|
||||
CheckInt32(3);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -799,13 +753,8 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname);
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(2);
|
||||
CheckInt32(3);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -862,13 +811,8 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
|
|||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname);
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
|
||||
CheckTimestamp();
|
||||
CheckInt32(2);
|
||||
CheckInt32(3);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. TOPIC_SRC)
|
||||
add_executable(mnode_test_topic ${TOPIC_SRC})
|
||||
aux_source_directory(. MNODE_TOPIC_TEST_SRC)
|
||||
add_executable(topicTest ${MNODE_TOPIC_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_topic
|
||||
topicTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_topic
|
||||
COMMAND mnode_test_topic
|
||||
NAME topicTest
|
||||
COMMAND topicTest
|
||||
)
|
||||
|
|
|
@ -101,7 +101,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{ test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, ""); }
|
||||
{ test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, ""); }
|
||||
|
||||
{
|
||||
int32_t contLen = 0;
|
||||
|
@ -128,7 +128,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
|
|||
}
|
||||
|
||||
{
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, dbname);
|
||||
CHECK_META("show topics", 3);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
|
@ -145,7 +145,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
|
|||
// restart
|
||||
test.Restart();
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
|
@ -169,7 +169,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TOPIC_NOT_EXIST);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname);
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. TRANS_SRC)
|
||||
add_executable(mnode_test_trans ${TRANS_SRC})
|
||||
aux_source_directory(. MNODE_TRANS_TEST_SRC)
|
||||
add_executable(transTest ${MNODE_TRANS_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_trans
|
||||
transTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_trans
|
||||
COMMAND mnode_test_trans
|
||||
NAME transTest
|
||||
COMMAND transTest
|
||||
)
|
||||
|
|
|
@ -65,18 +65,7 @@ TestServer MndTestTrans::server2;
|
|||
|
||||
TEST_F(MndTestTrans, 00_Create_User_Crash) {
|
||||
{
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TRANS, "");
|
||||
CHECK_META("show trans", 7);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE, "stage");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "db");
|
||||
CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE, "type");
|
||||
CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "last_exec_time");
|
||||
CHECK_SCHEMA(6, TSDB_DATA_TYPE_BINARY, TSDB_TRANS_ERROR_LEN - 1 + VARSTR_HEADER_SIZE, "last_error");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_TRANS, "trans", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -109,26 +98,13 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
KillThenRestartServer();
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckBinary("u1", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("normal", 10);
|
||||
CheckBinary("super", 10);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
}
|
||||
|
||||
TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
|
||||
|
@ -144,9 +120,7 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, "");
|
||||
CHECK_META("show qnodes", 3);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
}
|
||||
|
||||
|
@ -163,9 +137,7 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_QNODE_ALREADY_EXIST);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, "");
|
||||
CHECK_META("show qnodes", 3);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
}
|
||||
}
|
||||
|
@ -185,8 +157,7 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -208,18 +179,8 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
|
|||
|
||||
{
|
||||
// show trans
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TRANS, "");
|
||||
CHECK_META("show trans", 7);
|
||||
test.SendShowRetrieveReq();
|
||||
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_TRANS, "trans", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
CheckInt32(4);
|
||||
CheckTimestamp();
|
||||
CheckBinary("undoAction", TSDB_TRANS_STAGE_LEN);
|
||||
CheckBinary("", TSDB_DB_NAME_LEN - 1);
|
||||
CheckBinary("create-qnode", TSDB_TRANS_TYPE_LEN);
|
||||
CheckTimestamp();
|
||||
CheckBinary("Unable to establish connection", TSDB_TRANS_ERROR_LEN - 1);
|
||||
}
|
||||
|
||||
// kill trans
|
||||
|
@ -238,8 +199,7 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
|
|||
|
||||
// show trans
|
||||
{
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TRANS, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_TRANS, "trans", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -258,11 +218,9 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
|
|||
ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||
}
|
||||
|
||||
uInfo("======== kill and restart server")
|
||||
KillThenRestartServer();
|
||||
uInfo("======== kill and restart server") KillThenRestartServer();
|
||||
|
||||
uInfo("======== server2 start")
|
||||
server2.DoStart();
|
||||
uInfo("======== server2 start") server2.DoStart();
|
||||
|
||||
uInfo("======== server2 started")
|
||||
|
||||
|
@ -286,14 +244,11 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
|
|||
|
||||
ASSERT_NE(retry, retryMax);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, "");
|
||||
CHECK_META("show qnodes", 3);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// create db
|
||||
// partial create stb
|
||||
// drop db failed
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. USER_SRC)
|
||||
add_executable(mnode_test_user ${USER_SRC})
|
||||
aux_source_directory(. MNODE_USER_TEST_SRC)
|
||||
add_executable(userTest ${MNODE_USER_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_user
|
||||
userTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_user
|
||||
COMMAND mnode_test_user
|
||||
NAME userTest
|
||||
COMMAND userTest
|
||||
)
|
||||
|
|
|
@ -26,21 +26,8 @@ class MndTestUser : public ::testing::Test {
|
|||
Testbase MndTestUser::test;
|
||||
|
||||
TEST_F(MndTestUser, 01_Show_User) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, 10 + VARSTR_HEADER_SIZE, "privilege");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "account");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("super", 10);
|
||||
CheckTimestamp();
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
}
|
||||
|
||||
TEST_F(MndTestUser, 02_Create_User) {
|
||||
|
@ -99,18 +86,8 @@ TEST_F(MndTestUser, 02_Create_User) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckBinary("u1", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("normal", 10);
|
||||
CheckBinary("super", 10);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -125,8 +102,7 @@ TEST_F(MndTestUser, 02_Create_User) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
}
|
||||
|
||||
|
@ -144,18 +120,8 @@ TEST_F(MndTestUser, 02_Create_User) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("u2", TSDB_USER_LEN);
|
||||
CheckBinary("super", 10);
|
||||
CheckBinary("super", 10);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -170,8 +136,7 @@ TEST_F(MndTestUser, 02_Create_User) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
}
|
||||
}
|
||||
|
@ -191,8 +156,7 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -437,8 +401,7 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
}
|
||||
}
|
||||
|
@ -497,10 +460,7 @@ TEST_F(MndTestUser, 05_Drop_User) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
}
|
||||
|
||||
|
@ -533,25 +493,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 3);
|
||||
|
||||
CheckBinary("u1", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("u2", TSDB_USER_LEN);
|
||||
CheckBinary("normal", 10);
|
||||
CheckBinary("super", 10);
|
||||
CheckBinary("normal", 10);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
|
||||
{
|
||||
SAlterUserReq alterReq = {0};
|
||||
alterReq.alterType = TSDB_ALTER_USER_PASSWD;
|
||||
|
@ -567,25 +511,8 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 3);
|
||||
|
||||
CheckBinary("u1", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("u2", TSDB_USER_LEN);
|
||||
CheckBinary("normal", 10);
|
||||
CheckBinary("super", 10);
|
||||
CheckBinary("normal", 10);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
|
||||
{
|
||||
SDropUserReq dropReq = {0};
|
||||
strcpy(dropReq.user, "u1");
|
||||
|
@ -599,37 +526,13 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("u2", TSDB_USER_LEN);
|
||||
CheckBinary("super", 10);
|
||||
CheckBinary("normal", 10);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
|
||||
// restart
|
||||
test.Restart();
|
||||
|
||||
taosMsleep(1000);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, "");
|
||||
CHECK_META("show users", 4);
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("u2", TSDB_USER_LEN);
|
||||
CheckBinary("super", 10);
|
||||
CheckBinary("normal", 10);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
CheckBinary("root", TSDB_USER_LEN);
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ target_sources(
|
|||
vnode
|
||||
PRIVATE
|
||||
# vnode
|
||||
"src/vnd/vnodeOpen.c"
|
||||
"src/vnd/vnodeArenaMAImpl.c"
|
||||
"src/vnd/vnodeBufferPool.c"
|
||||
# "src/vnd/vnodeBufferPool2.c"
|
||||
"src/vnd/vnodeCfg.c"
|
||||
"src/vnd/vnodeCommit.c"
|
||||
"src/vnd/vnodeInt.c"
|
||||
"src/vnd/vnodeMain.c"
|
||||
"src/vnd/vnodeQuery.c"
|
||||
"src/vnd/vnodeStateMgr.c"
|
||||
"src/vnd/vnodeWrite.c"
|
||||
|
|
|
@ -42,11 +42,12 @@ typedef struct STsdbCfg STsdbCfg; // todo: remove
|
|||
typedef struct STqCfg STqCfg; // todo: remove
|
||||
typedef struct SVnodeCfg SVnodeCfg;
|
||||
|
||||
int vnodeInit();
|
||||
int vnodeInit(int nthreads);
|
||||
void vnodeCleanup();
|
||||
int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs);
|
||||
void vnodeDestroy(const char *path);
|
||||
SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg);
|
||||
void vnodeClose(SVnode *pVnode);
|
||||
void vnodeDestroy(const char *path);
|
||||
void vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs);
|
||||
int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||
int vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||
|
@ -123,12 +124,12 @@ struct STsdbCfg {
|
|||
int8_t precision;
|
||||
int8_t update;
|
||||
int8_t compression;
|
||||
int32_t daysPerFile;
|
||||
int32_t minRowsPerFileBlock;
|
||||
int32_t maxRowsPerFileBlock;
|
||||
int32_t keep;
|
||||
int32_t keep1;
|
||||
int32_t days;
|
||||
int32_t minRows;
|
||||
int32_t maxRows;
|
||||
int32_t keep2;
|
||||
int32_t keep0;
|
||||
int32_t keep1;
|
||||
uint64_t lruCacheSize;
|
||||
SArray *retentions;
|
||||
};
|
||||
|
|
|
@ -30,6 +30,8 @@ extern "C" {
|
|||
#define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }} while(0)
|
||||
// clang-format on
|
||||
|
||||
// vnodeCfg ====================
|
||||
|
||||
// vnodeModule ====================
|
||||
int vnodeScheduleTask(int (*execute)(void*), void* arg);
|
||||
|
||||
|
@ -38,6 +40,11 @@ int vnodeQueryOpen(SVnode* pVnode);
|
|||
void vnodeQueryClose(SVnode* pVnode);
|
||||
int vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
||||
|
||||
// vnodeCommit ====================
|
||||
int vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg);
|
||||
int vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo);
|
||||
int vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo);
|
||||
|
||||
#if 1
|
||||
// SVBufPool
|
||||
int vnodeOpenBufPool(SVnode* pVnode);
|
||||
|
@ -75,9 +82,9 @@ void vmaFree(SVMemAllocator* pVMA, void* ptr);
|
|||
bool vmaIsFull(SVMemAllocator* pVMA);
|
||||
|
||||
// vnodeCfg.h
|
||||
extern const SVnodeCfg defaultVnodeOptions;
|
||||
extern const SVnodeCfg vnodeCfgDefault;
|
||||
|
||||
int vnodeValidateOptions(const SVnodeCfg*);
|
||||
int vnodeCheckCfg(const SVnodeCfg*);
|
||||
void vnodeOptionsCopy(SVnodeCfg* pDest, const SVnodeCfg* pSrc);
|
||||
|
||||
// For commit
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "tdbInt.h"
|
||||
#include "tfs.h"
|
||||
#include "tglobal.h"
|
||||
#include "tjson.h"
|
||||
#include "tlist.h"
|
||||
#include "tlockfree.h"
|
||||
#include "tlosertree.h"
|
||||
|
@ -43,6 +44,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SVnodeInfo SVnodeInfo;
|
||||
typedef struct SMeta SMeta;
|
||||
typedef struct STsdb STsdb;
|
||||
typedef struct STQ STQ;
|
||||
|
@ -72,6 +74,11 @@ struct SVState {
|
|||
int64_t applied;
|
||||
};
|
||||
|
||||
struct SVnodeInfo {
|
||||
SVnodeCfg config;
|
||||
SVState state;
|
||||
};
|
||||
|
||||
struct SVnode {
|
||||
int32_t vgId;
|
||||
char* path;
|
||||
|
|
|
@ -55,7 +55,7 @@ typedef struct {
|
|||
#define TSDB_COMMIT_BUF(ch) TSDB_READ_BUF(&((ch)->readh))
|
||||
#define TSDB_COMMIT_COMP_BUF(ch) TSDB_READ_COMP_BUF(&((ch)->readh))
|
||||
#define TSDB_COMMIT_EXBUF(ch) TSDB_READ_EXBUF(&((ch)->readh))
|
||||
#define TSDB_COMMIT_DEFAULT_ROWS(ch) TSDB_DEFAULT_BLOCK_ROWS(TSDB_COMMIT_REPO(ch)->config.maxRowsPerFileBlock)
|
||||
#define TSDB_COMMIT_DEFAULT_ROWS(ch) TSDB_DEFAULT_BLOCK_ROWS(TSDB_COMMIT_REPO(ch)->config.maxRows)
|
||||
#define TSDB_COMMIT_TXN_VERSION(ch) FS_TXN_VERSION(REPO_FS(TSDB_COMMIT_REPO(ch)))
|
||||
|
||||
static void tsdbStartCommit(STsdb *pRepo);
|
||||
|
@ -217,14 +217,14 @@ void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn) {
|
|||
TSKEY minKey, midKey, maxKey, now;
|
||||
|
||||
now = taosGetTimestamp(pCfg->precision);
|
||||
minKey = now - pCfg->keep * tsTickPerDay[pCfg->precision];
|
||||
midKey = now - pCfg->keep2 * tsTickPerDay[pCfg->precision];
|
||||
maxKey = now - pCfg->keep1 * tsTickPerDay[pCfg->precision];
|
||||
minKey = now - pCfg->keep2 * tsTickPerDay[pCfg->precision];
|
||||
midKey = now - pCfg->keep1 * tsTickPerDay[pCfg->precision];
|
||||
maxKey = now - pCfg->keep0 * tsTickPerDay[pCfg->precision];
|
||||
|
||||
pRtn->minKey = minKey;
|
||||
pRtn->minFid = (int)(TSDB_KEY_FID(minKey, pCfg->daysPerFile, pCfg->precision));
|
||||
pRtn->midFid = (int)(TSDB_KEY_FID(midKey, pCfg->daysPerFile, pCfg->precision));
|
||||
pRtn->maxFid = (int)(TSDB_KEY_FID(maxKey, pCfg->daysPerFile, pCfg->precision));
|
||||
pRtn->minFid = (int)(TSDB_KEY_FID(minKey, pCfg->days, pCfg->precision));
|
||||
pRtn->midFid = (int)(TSDB_KEY_FID(midKey, pCfg->days, pCfg->precision));
|
||||
pRtn->maxFid = (int)(TSDB_KEY_FID(maxKey, pCfg->days, pCfg->precision));
|
||||
tsdbDebug("vgId:%d now:%" PRId64 " minKey:%" PRId64 " minFid:%d, midFid:%d, maxFid:%d", REPO_ID(pRepo), now, minKey,
|
||||
pRtn->minFid, pRtn->midFid, pRtn->maxFid);
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ static int tsdbInitCommitH(SCommitH *pCommith, STsdb *pRepo) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
pCommith->pDataCols = tdNewDataCols(0, pCfg->maxRowsPerFileBlock);
|
||||
pCommith->pDataCols = tdNewDataCols(0, pCfg->maxRows);
|
||||
if (pCommith->pDataCols == NULL) {
|
||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||
tsdbDestroyCommitH(pCommith);
|
||||
|
@ -319,7 +319,7 @@ static int tsdbNextCommitFid(SCommitH *pCommith) {
|
|||
if (nextKey == TSDB_DATA_TIMESTAMP_NULL) {
|
||||
continue;
|
||||
} else {
|
||||
int tfid = (int)(TSDB_KEY_FID(nextKey, pCfg->daysPerFile, pCfg->precision));
|
||||
int tfid = (int)(TSDB_KEY_FID(nextKey, pCfg->days, pCfg->precision));
|
||||
if (fid == TSDB_IVLD_FID || fid > tfid) {
|
||||
fid = tfid;
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ static int tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) {
|
|||
ASSERT(pSet == NULL || pSet->fid == fid);
|
||||
|
||||
tsdbResetCommitFile(pCommith);
|
||||
tsdbGetFidKeyRange(pCfg->daysPerFile, pCfg->precision, fid, &(pCommith->minKey), &(pCommith->maxKey));
|
||||
tsdbGetFidKeyRange(pCfg->days, pCfg->precision, fid, &(pCommith->minKey), &(pCommith->maxKey));
|
||||
|
||||
// Set and open files
|
||||
if (tsdbSetAndOpenCommitFile(pCommith, pSet, fid) < 0) {
|
||||
|
@ -1210,8 +1210,8 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
|||
int64_t offset = 0, offsetAggr = 0;
|
||||
int rowsToWrite = pDataCols->numOfRows;
|
||||
|
||||
ASSERT(rowsToWrite > 0 && rowsToWrite <= pCfg->maxRowsPerFileBlock);
|
||||
ASSERT((!isLast) || rowsToWrite < pCfg->minRowsPerFileBlock);
|
||||
ASSERT(rowsToWrite > 0 && rowsToWrite <= pCfg->maxRows);
|
||||
ASSERT((!isLast) || rowsToWrite < pCfg->minRows);
|
||||
|
||||
// Make buffer space
|
||||
if (tsdbMakeRoom(ppBuf, tsdbBlockStatisSize(pDataCols->numOfCols, SBlockVerLatest)) < 0) {
|
||||
|
@ -1460,7 +1460,7 @@ static int tsdbCommitMemData(SCommitH *pCommith, SCommitIter *pIter, TSKEY keyLi
|
|||
|
||||
if (pCommith->pDataCols->numOfRows <= 0) break;
|
||||
|
||||
if (toData || pCommith->pDataCols->numOfRows >= pCfg->minRowsPerFileBlock) {
|
||||
if (toData || pCommith->pDataCols->numOfRows >= pCfg->minRows) {
|
||||
pDFile = TSDB_COMMIT_DATA_FILE(pCommith);
|
||||
isLast = false;
|
||||
} else {
|
||||
|
@ -1619,7 +1619,7 @@ static int tsdbMergeBlockData(SCommitH *pCommith, SCommitIter *pIter, SDataCols
|
|||
if (pCommith->pDataCols->numOfRows == 0) break;
|
||||
|
||||
if (isLastOneBlock) {
|
||||
if (pCommith->pDataCols->numOfRows < pCfg->minRowsPerFileBlock) {
|
||||
if (pCommith->pDataCols->numOfRows < pCfg->minRows) {
|
||||
pDFile = TSDB_COMMIT_LAST_FILE(pCommith);
|
||||
isLast = true;
|
||||
} else {
|
||||
|
@ -1667,7 +1667,8 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
|
|||
if (tdGetColDataOfRow(&sVal, pDataCols->cols + i, *iter, pDataCols->bitmapMode) < 0) {
|
||||
TASSERT(0);
|
||||
}
|
||||
tdAppendValToDataCol(pTarget->cols + i, sVal.valType, sVal.val, pTarget->numOfRows, pTarget->maxPoints, pTarget->bitmapMode);
|
||||
tdAppendValToDataCol(pTarget->cols + i, sVal.valType, sVal.val, pTarget->numOfRows, pTarget->maxPoints,
|
||||
pTarget->bitmapMode);
|
||||
}
|
||||
|
||||
++pTarget->numOfRows;
|
||||
|
@ -1774,11 +1775,11 @@ static bool tsdbCanAddSubBlock(SCommitH *pCommith, SBlock *pBlock, SMergeInfo *p
|
|||
|
||||
ASSERT(mergeRows > 0);
|
||||
|
||||
if (pBlock->numOfSubBlocks < TSDB_MAX_SUBBLOCKS && pInfo->nOperations <= pCfg->maxRowsPerFileBlock) {
|
||||
if (pBlock->numOfSubBlocks < TSDB_MAX_SUBBLOCKS && pInfo->nOperations <= pCfg->maxRows) {
|
||||
if (pBlock->last) {
|
||||
if (pCommith->isLFileSame && mergeRows < pCfg->minRowsPerFileBlock) return true;
|
||||
if (pCommith->isLFileSame && mergeRows < pCfg->minRows) return true;
|
||||
} else {
|
||||
if (pCommith->isDFileSame && mergeRows <= pCfg->maxRowsPerFileBlock) return true;
|
||||
if (pCommith->isDFileSame && mergeRows <= pCfg->maxRows) return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -190,8 +190,8 @@ static int tsdbAddDFileSetToStatus(SFSStatus *pStatus, const SDFileSet *pSet) {
|
|||
|
||||
// ================== STsdbFS
|
||||
STsdbFS *tsdbNewFS(const STsdbCfg *pCfg) {
|
||||
int keep = pCfg->keep;
|
||||
int days = pCfg->daysPerFile;
|
||||
int keep = pCfg->keep2;
|
||||
int days = pCfg->days;
|
||||
int maxFSet = TSDB_MAX_FSETS(keep, days);
|
||||
STsdbFS *pfs;
|
||||
|
||||
|
|
|
@ -263,8 +263,8 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) {
|
|||
SSubmitBlkIter blkIter = {0};
|
||||
STSRow *row = NULL;
|
||||
TSKEY now = taosGetTimestamp(pTsdb->config.precision);
|
||||
TSKEY minKey = now - tsTickPerDay[pTsdb->config.precision] * pTsdb->config.keep;
|
||||
TSKEY maxKey = now + tsTickPerDay[pTsdb->config.precision] * pTsdb->config.daysPerFile;
|
||||
TSKEY minKey = now - tsTickPerDay[pTsdb->config.precision] * pTsdb->config.keep2;
|
||||
TSKEY maxKey = now + tsTickPerDay[pTsdb->config.precision] * pTsdb->config.days;
|
||||
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
pMsg->length = htonl(pMsg->length);
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
const STsdbCfg defautlTsdbOptions = {.precision = 0,
|
||||
.lruCacheSize = 0,
|
||||
.daysPerFile = 10,
|
||||
.minRowsPerFileBlock = 100,
|
||||
.maxRowsPerFileBlock = 4096,
|
||||
.keep = 3650,
|
||||
.keep1 = 3650,
|
||||
.days = 10,
|
||||
.minRows = 100,
|
||||
.maxRows = 4096,
|
||||
.keep2 = 3650,
|
||||
.keep0 = 3650,
|
||||
.keep1 = 3650,
|
||||
.update = 0,
|
||||
.compression = TWO_STAGE_COMP};
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ static int64_t getEarliestValidTimestamp(STsdb* pTsdb) {
|
|||
STsdbCfg* pCfg = &pTsdb->config;
|
||||
|
||||
int64_t now = taosGetTimestamp(pCfg->precision);
|
||||
return now - (tsTickPerDay[pCfg->precision] * pCfg->keep) + 1; // needs to add one tick
|
||||
return now - (tsTickPerDay[pCfg->precision] * pCfg->keep2) + 1; // needs to add one tick
|
||||
}
|
||||
|
||||
static void setQueryTimewindow(STsdbReadHandle* pTsdbReadHandle, STsdbQueryCond* pCond) {
|
||||
|
@ -404,7 +404,7 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, STsdbQueryCond* pCond,
|
|||
pReadHandle->defaultLoadColumn = getDefaultLoadColumns(pReadHandle, true);
|
||||
}
|
||||
|
||||
pReadHandle->pDataCols = tdNewDataCols(1000, pReadHandle->pTsdb->config.maxRowsPerFileBlock);
|
||||
pReadHandle->pDataCols = tdNewDataCols(1000, pReadHandle->pTsdb->config.maxRows);
|
||||
if (pReadHandle->pDataCols == NULL) {
|
||||
tsdbError("%p failed to malloc buf for pDataCols, %s", pReadHandle, pReadHandle->idStr);
|
||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||
|
@ -2199,7 +2199,7 @@ static int32_t getFirstFileDataBlock(STsdbReadHandle* pTsdbReadHandle, bool* exi
|
|||
break;
|
||||
}
|
||||
|
||||
tsdbGetFidKeyRange(pCfg->daysPerFile, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey);
|
||||
tsdbGetFidKeyRange(pCfg->days, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey);
|
||||
|
||||
// current file are not overlapped with query time window, ignore remain files
|
||||
if ((ASCENDING_TRAVERSE(pTsdbReadHandle->order) && win.skey > pTsdbReadHandle->window.ekey) ||
|
||||
|
@ -2295,7 +2295,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo*
|
|||
// find the start data block in file
|
||||
pTsdbReadHandle->locateStart = true;
|
||||
STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config;
|
||||
int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->daysPerFile, pCfg->precision);
|
||||
int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->days, pCfg->precision);
|
||||
|
||||
tsdbRLockFS(pFileHandle);
|
||||
tsdbFSIterInit(&pTsdbReadHandle->fileIter, pFileHandle, pTsdbReadHandle->order);
|
||||
|
@ -2321,7 +2321,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo*
|
|||
break;
|
||||
}
|
||||
|
||||
tsdbGetFidKeyRange(pCfg->daysPerFile, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey);
|
||||
tsdbGetFidKeyRange(pCfg->days, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey);
|
||||
|
||||
// current file are not overlapped with query time window, ignore remain files
|
||||
if ((ascTraverse && win.skey > pTsdbReadHandle->window.ekey) ||
|
||||
|
@ -2396,7 +2396,7 @@ static int32_t getDataBlocksInFiles(STsdbReadHandle* pTsdbReadHandle, bool* exis
|
|||
if (!pTsdbReadHandle->locateStart) {
|
||||
pTsdbReadHandle->locateStart = true;
|
||||
STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config;
|
||||
int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->daysPerFile, pCfg->precision);
|
||||
int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->days, pCfg->precision);
|
||||
|
||||
tsdbRLockFS(pFileHandle);
|
||||
tsdbFSIterInit(&pTsdbReadHandle->fileIter, pFileHandle, pTsdbReadHandle->order);
|
||||
|
|
|
@ -43,14 +43,14 @@ int tsdbInitReadH(SReadH *pReadh, STsdb *pRepo) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
pReadh->pDCols[0] = tdNewDataCols(0, pCfg->maxRowsPerFileBlock);
|
||||
pReadh->pDCols[0] = tdNewDataCols(0, pCfg->maxRows);
|
||||
if (pReadh->pDCols[0] == NULL) {
|
||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||
tsdbDestroyReadH(pReadh);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pReadh->pDCols[1] = tdNewDataCols(0, pCfg->maxRowsPerFileBlock);
|
||||
pReadh->pDCols[1] = tdNewDataCols(0, pCfg->maxRows);
|
||||
if (pReadh->pDCols[1] == NULL) {
|
||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||
tsdbDestroyReadH(pReadh);
|
||||
|
@ -276,8 +276,8 @@ int tsdbLoadBlockData(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, const int16_t *colIds,
|
||||
int numOfColsIds, bool mergeBitmap) {
|
||||
int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, const int16_t *colIds, int numOfColsIds,
|
||||
bool mergeBitmap) {
|
||||
ASSERT(pBlock->numOfSubBlocks > 0);
|
||||
int8_t update = pReadh->pRepo->config.update;
|
||||
|
||||
|
@ -836,7 +836,7 @@ static int tsdbLoadColData(SReadH *pReadh, SDFile *pDFile, SBlock *pBlock, SBloc
|
|||
}
|
||||
|
||||
if (tsdbCheckAndDecodeColumnData(pDataCol, pReadh->pBuf, pBlockCol->len, pBlockCol->blen, pBlock->algorithm,
|
||||
pBlock->numOfRows, tLenBitmap, pCfg->maxRowsPerFileBlock, pReadh->pCBuf,
|
||||
pBlock->numOfRows, tLenBitmap, pCfg->maxRows, pReadh->pCBuf,
|
||||
(int32_t)taosTSizeof(pReadh->pCBuf)) < 0) {
|
||||
tsdbError("vgId:%d file %s is broken at column %d offset %" PRId64, REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile),
|
||||
pBlockCol->colId, offset);
|
||||
|
|
|
@ -106,7 +106,8 @@ struct SSmaStat {
|
|||
|
||||
// expired window
|
||||
static int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t version);
|
||||
static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, int64_t version);
|
||||
static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey,
|
||||
int64_t version);
|
||||
static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat);
|
||||
static void *tsdbFreeSmaStatItem(SSmaStatItem *pSmaStatItem);
|
||||
static int32_t tsdbDestroySmaState(SSmaStat *pSmaStat);
|
||||
|
@ -544,7 +545,8 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
};
|
||||
|
||||
static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, int64_t version) {
|
||||
static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey,
|
||||
int64_t version) {
|
||||
SSmaStatItem *pItem = taosHashGet(pItemsHash, &indexUid, sizeof(indexUid));
|
||||
if (pItem == NULL) {
|
||||
// TODO: use TSDB_SMA_STAT_EXPIRED and update by stream computing later
|
||||
|
@ -946,7 +948,7 @@ static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, int64_t indexUid, int32_t
|
|||
*/
|
||||
static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLevel) {
|
||||
STsdbCfg *pCfg = REPO_CFG(pTsdb);
|
||||
int32_t daysPerFile = pCfg->daysPerFile;
|
||||
int32_t daysPerFile = pCfg->days;
|
||||
|
||||
if (storageLevel == SMA_STORAGE_LEVEL_TSDB) {
|
||||
int32_t days = SMA_STORAGE_TSDB_TIMES * (interval / tsTickPerDay[pCfg->precision]);
|
||||
|
|
|
@ -15,14 +15,15 @@
|
|||
|
||||
#include "vnodeInt.h"
|
||||
|
||||
const SVnodeCfg defaultVnodeOptions = {
|
||||
.wsize = 96 * 1024 * 1024, .ssize = 1 * 1024 * 1024, .lsize = 1024, .walCfg = {.level = TAOS_WAL_WRITE}}; /* TODO */
|
||||
const SVnodeCfg vnodeCfgDefault = {
|
||||
.wsize = 96 * 1024 * 1024, .ssize = 1 * 1024 * 1024, .lsize = 1024, .walCfg = {.level = TAOS_WAL_WRITE}};
|
||||
|
||||
int vnodeValidateOptions(const SVnodeCfg *pVnodeOptions) {
|
||||
int vnodeCheckCfg(const SVnodeCfg *pCfg) {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 1 //======================================================================
|
||||
void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc) {
|
||||
memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg));
|
||||
}
|
||||
|
@ -46,3 +47,5 @@ int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) {
|
|||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -15,11 +15,128 @@
|
|||
|
||||
#include "vnodeInt.h"
|
||||
|
||||
#define VND_INFO_FNAME "vnode.json"
|
||||
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
||||
|
||||
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData);
|
||||
static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo);
|
||||
static int vnodeStartCommit(SVnode *pVnode);
|
||||
static int vnodeEndCommit(SVnode *pVnode);
|
||||
static int vnodeCommit(void *arg);
|
||||
static void vnodeWaitCommit(SVnode *pVnode);
|
||||
|
||||
int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
TdFilePtr pFile;
|
||||
char *data;
|
||||
|
||||
snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP);
|
||||
|
||||
// encode info
|
||||
data = NULL;
|
||||
|
||||
if (vnodeEncodeInfo(pInfo, &data) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// save info to a vnode_tmp.json
|
||||
pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosWriteFile(pFile, data, strlen(data)) < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
if (taosFsyncFile(pFile) < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
taosCloseFile(&pFile);
|
||||
|
||||
// free info binary
|
||||
taosMemoryFree(data);
|
||||
|
||||
vInfo("vgId: %d vnode info is saved, fname: %s", pInfo->config.vgId, fname);
|
||||
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
taosCloseFile(&pFile);
|
||||
taosMemoryFree(data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int vnodeCommitInfo(const char *dir, const SVnodeInfo *pInfo) {
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
char tfname[TSDB_FILENAME_LEN];
|
||||
|
||||
snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME);
|
||||
snprintf(tfname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP);
|
||||
|
||||
if (taosRenameFile(tfname, fname) < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vInfo("vgId: %d vnode info is committed", pInfo->config.vgId);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) {
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
TdFilePtr pFile = NULL;
|
||||
char *pData = NULL;
|
||||
int64_t size;
|
||||
|
||||
snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME);
|
||||
|
||||
// read info
|
||||
pFile = taosOpenFile(fname, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pData = taosMemoryMalloc(size);
|
||||
if (pData == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
if (taosReadFile(pFile, pData, size) < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
taosCloseFile(&pFile);
|
||||
|
||||
// decode info
|
||||
if (vnodeDecodeInfo(pData, pInfo) < 0) {
|
||||
taosMemoryFree(pData);
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosMemoryFree(pData);
|
||||
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
taosCloseFile(&pFile);
|
||||
taosMemoryFree(pData);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int vnodeAsyncCommit(SVnode *pVnode) {
|
||||
vnodeWaitCommit(pVnode);
|
||||
|
||||
|
@ -61,3 +178,132 @@ static int vnodeEndCommit(SVnode *pVnode) {
|
|||
}
|
||||
|
||||
static FORCE_INLINE void vnodeWaitCommit(SVnode *pVnode) { tsem_wait(&pVnode->canCommit); }
|
||||
|
||||
static int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
|
||||
const SVnodeCfg *pCfg = (SVnodeCfg *)pObj;
|
||||
|
||||
if (tjsonAddIntegerToObject(pJson, "vgId", pCfg->vgId) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "dbId", pCfg->dbId) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "wsize", pCfg->wsize) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "ssize", pCfg->ssize) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "lsize", pCfg->lsize) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "isHeap", pCfg->isHeapAllocator) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "ttl", pCfg->ttl) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "keep", pCfg->keep) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "streamMode", pCfg->streamMode) < 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, "update", pCfg->tsdbCfg.update) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "compression", pCfg->tsdbCfg.compression) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "daysPerFile", pCfg->tsdbCfg.days) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "minRows", pCfg->tsdbCfg.minRows) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "maxRows", pCfg->tsdbCfg.maxRows) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||
SVnodeCfg *pCfg = (SVnodeCfg *)pObj;
|
||||
|
||||
if (tjsonGetNumberValue(pJson, "vgId", pCfg->vgId) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "dbId", pCfg->dbId) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "wsize", pCfg->wsize) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "ssize", pCfg->ssize) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "lsize", pCfg->lsize) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "isHeap", pCfg->isHeapAllocator) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "ttl", pCfg->ttl) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "keep", pCfg->keep) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "streamMode", pCfg->streamMode) < 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, "update", pCfg->tsdbCfg.update) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "compression", pCfg->tsdbCfg.compression) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "daysPerFile", pCfg->tsdbCfg.days) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "minRows", pCfg->tsdbCfg.minRows) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "maxRows", pCfg->tsdbCfg.maxRows) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vnodeEncodeState(const void *pObj, SJson *pJson) {
|
||||
const SVState *pState = (SVState *)pObj;
|
||||
|
||||
if (tjsonAddIntegerToObject(pJson, "commit version", pState->committed) < 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vnodeDecodeState(const SJson *pJson, void *pObj) {
|
||||
SVState *pState = (SVState *)pObj;
|
||||
|
||||
if (tjsonGetNumberValue(pJson, "commit version", pState->committed) < 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData) {
|
||||
SJson *pJson;
|
||||
char *pData;
|
||||
|
||||
*ppData = NULL;
|
||||
|
||||
pJson = tjsonCreateObject();
|
||||
if (pJson == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tjsonAddObject(pJson, "config", vnodeEncodeConfig, (void *)&pInfo->config) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
if (tjsonAddObject(pJson, "state", vnodeEncodeState, (void *)&pInfo->state) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pData = tjsonToString(pJson);
|
||||
if (pData == NULL) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
tjsonDelete(pJson);
|
||||
|
||||
*ppData = pData;
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
tjsonDelete(pJson);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo) {
|
||||
SJson *pJson = NULL;
|
||||
|
||||
pJson = tjsonCreateObject();
|
||||
if (pJson == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tjsonToObject(pJson, "config", vnodeDecodeConfig, (void *)&pInfo->config) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
if (tjsonToObject(pJson, "state", vnodeDecodeState, (void *)&pInfo->state) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
tjsonDelete(pJson);
|
||||
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
tjsonDelete(pJson);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -20,11 +20,42 @@ static void vnodeFree(SVnode *pVnode);
|
|||
static int vnodeOpenImpl(SVnode *pVnode);
|
||||
static void vnodeCloseImpl(SVnode *pVnode);
|
||||
|
||||
int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
||||
SVnodeInfo info = {0};
|
||||
char dir[TSDB_FILENAME_LEN];
|
||||
|
||||
// TODO: check if directory exists
|
||||
|
||||
// check config
|
||||
if (vnodeCheckCfg(pCfg) < 0) {
|
||||
vError("vgId: %d failed to create vnode since: %s", pCfg->vgId, tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// create vnode env
|
||||
if (tfsMkdir(pTfs, path) < 0) {
|
||||
vError("vgId: %d failed to create vnode since: %s", pCfg->vgId, tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path);
|
||||
info.config = *pCfg;
|
||||
|
||||
if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir, &info) < 0) {
|
||||
vError("vgId: %d failed to save vnode config since %s", pCfg->vgId, tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
vInfo("vgId: %d vnode is created", pCfg->vgId);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) {
|
||||
SVnode *pVnode = NULL;
|
||||
|
||||
// Set default options
|
||||
SVnodeCfg cfg = defaultVnodeOptions;
|
||||
SVnodeCfg cfg = vnodeCfgDefault;
|
||||
if (pVnodeCfg != NULL) {
|
||||
cfg.vgId = pVnodeCfg->vgId;
|
||||
cfg.msgCb = pVnodeCfg->msgCb;
|
||||
|
@ -36,7 +67,7 @@ SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) {
|
|||
}
|
||||
|
||||
// Validate options
|
||||
if (vnodeValidateOptions(&cfg) < 0) {
|
||||
if (vnodeCheckCfg(&cfg) < 0) {
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
|
@ -227,20 +227,20 @@ typedef struct SCtgAction {
|
|||
#define CTG_FLAG_STB 0x1
|
||||
#define CTG_FLAG_NOT_STB 0x2
|
||||
#define CTG_FLAG_UNKNOWN_STB 0x4
|
||||
#define CTG_FLAG_INF_DB 0x8
|
||||
#define CTG_FLAG_SYS_DB 0x8
|
||||
#define CTG_FLAG_FORCE_UPDATE 0x10
|
||||
|
||||
#define CTG_FLAG_IS_STB(_flag) ((_flag) & CTG_FLAG_STB)
|
||||
#define CTG_FLAG_IS_NOT_STB(_flag) ((_flag) & CTG_FLAG_NOT_STB)
|
||||
#define CTG_FLAG_IS_UNKNOWN_STB(_flag) ((_flag) & CTG_FLAG_UNKNOWN_STB)
|
||||
#define CTG_FLAG_IS_INF_DB(_flag) ((_flag) & CTG_FLAG_INF_DB)
|
||||
#define CTG_FLAG_IS_SYS_DB(_flag) ((_flag) & CTG_FLAG_SYS_DB)
|
||||
#define CTG_FLAG_IS_FORCE_UPDATE(_flag) ((_flag) & CTG_FLAG_FORCE_UPDATE)
|
||||
#define CTG_FLAG_SET_INF_DB(_flag) ((_flag) |= CTG_FLAG_INF_DB)
|
||||
#define CTG_FLAG_SET_SYS_DB(_flag) ((_flag) |= CTG_FLAG_SYS_DB)
|
||||
#define CTG_FLAG_SET_STB(_flag, tbType) do { (_flag) |= ((tbType) == TSDB_SUPER_TABLE) ? CTG_FLAG_STB : ((tbType) > TSDB_SUPER_TABLE ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB); } while (0)
|
||||
#define CTG_FLAG_MAKE_STB(_isStb) (((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB))
|
||||
#define CTG_FLAG_MATCH_STB(_flag, tbType) (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE))
|
||||
|
||||
#define CTG_IS_INF_DBNAME(_dbname) ((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB)))
|
||||
#define CTG_IS_SYS_DBNAME(_dbname) (((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) || ((*(_dbname) == 'p') && (0 == strcmp(_dbname, TSDB_PERFORMANCE_SCHEMA_DB))))
|
||||
|
||||
#define CTG_META_SIZE(pMeta) (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfTags + (pMeta)->tableInfo.numOfColumns) * sizeof(SSchema))
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ int32_t ctgPushRmDBMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId)
|
|||
}
|
||||
|
||||
char *p = strchr(dbFName, '.');
|
||||
if (p && CTG_IS_INF_DBNAME(p + 1)) {
|
||||
if (p && CTG_IS_SYS_DBNAME(p + 1)) {
|
||||
dbFName = p + 1;
|
||||
}
|
||||
|
||||
|
@ -304,7 +304,7 @@ int32_t ctgPushUpdateVgMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t d
|
|||
}
|
||||
|
||||
char *p = strchr(dbFName, '.');
|
||||
if (p && CTG_IS_INF_DBNAME(p + 1)) {
|
||||
if (p && CTG_IS_SYS_DBNAME(p + 1)) {
|
||||
dbFName = p + 1;
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ int32_t ctgPushUpdateTblMsgInQueue(SCatalog* pCtg, STableMetaOutput *output, boo
|
|||
}
|
||||
|
||||
char *p = strchr(output->dbFName, '.');
|
||||
if (p && CTG_IS_INF_DBNAME(p + 1)) {
|
||||
if (p && CTG_IS_SYS_DBNAME(p + 1)) {
|
||||
memmove(output->dbFName, p + 1, strlen(p + 1));
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ void ctgWReleaseVgInfo(SCtgDBCache *dbCache) {
|
|||
|
||||
int32_t ctgAcquireDBCacheImpl(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache, bool acquire) {
|
||||
char *p = strchr(dbFName, '.');
|
||||
if (p && CTG_IS_INF_DBNAME(p + 1)) {
|
||||
if (p && CTG_IS_SYS_DBNAME(p + 1)) {
|
||||
dbFName = p + 1;
|
||||
}
|
||||
|
||||
|
@ -688,7 +688,7 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
|
|||
}
|
||||
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
if (CTG_FLAG_IS_INF_DB(flag)) {
|
||||
if (CTG_FLAG_IS_SYS_DB(flag)) {
|
||||
strcpy(dbFName, pTableName->dbname);
|
||||
} else {
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
|
@ -1721,7 +1721,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
|
|||
SVgroupInfo vgroupInfo = {0};
|
||||
int32_t code = 0;
|
||||
|
||||
if (!CTG_FLAG_IS_INF_DB(flag)) {
|
||||
if (!CTG_FLAG_IS_SYS_DB(flag)) {
|
||||
CTG_ERR_RET(catalogGetTableHashVgroup(pCtg, pTrans, pMgmtEps, pTableName, &vgroupInfo));
|
||||
}
|
||||
|
||||
|
@ -1732,7 +1732,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
|
|||
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||
}
|
||||
|
||||
if (CTG_FLAG_IS_INF_DB(flag)) {
|
||||
if (CTG_FLAG_IS_SYS_DB(flag)) {
|
||||
ctgDebug("will refresh tbmeta, supposed in information_schema, tbName:%s", tNameGetTableName(pTableName));
|
||||
|
||||
CTG_ERR_JRET(ctgGetTableMetaFromMnodeImpl(pCtg, pTrans, pMgmtEps, (char *)pTableName->dbname, (char *)pTableName->tname, output));
|
||||
|
@ -1820,8 +1820,8 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
|
|||
uint64_t suid = 0;
|
||||
STableMetaOutput *output = NULL;
|
||||
|
||||
if (CTG_IS_INF_DBNAME(pTableName->dbname)) {
|
||||
CTG_FLAG_SET_INF_DB(flag);
|
||||
if (CTG_IS_SYS_DBNAME(pTableName->dbname)) {
|
||||
CTG_FLAG_SET_SYS_DB(flag);
|
||||
}
|
||||
|
||||
CTG_ERR_RET(ctgGetTableMetaFromCache(pCtg, pTableName, pTableMeta, &inCache, flag, &dbId));
|
||||
|
@ -1829,7 +1829,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
|
|||
int32_t tbType = 0;
|
||||
|
||||
if (inCache) {
|
||||
if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_INF_DB(flag)))) {
|
||||
if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_SYS_DB(flag)))) {
|
||||
goto _return;
|
||||
}
|
||||
|
||||
|
@ -1885,7 +1885,7 @@ _return:
|
|||
|
||||
if (CTG_TABLE_NOT_EXIST(code) && inCache) {
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
if (CTG_FLAG_IS_INF_DB(flag)) {
|
||||
if (CTG_FLAG_IS_SYS_DB(flag)) {
|
||||
strcpy(dbFName, pTableName->dbname);
|
||||
} else {
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
|
@ -2633,7 +2633,7 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm
|
|||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
||||
if (CTG_IS_INF_DBNAME(pTableName->dbname)) {
|
||||
if (CTG_IS_SYS_DBNAME(pTableName->dbname)) {
|
||||
ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname);
|
||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
@ -2666,7 +2666,7 @@ _return:
|
|||
int32_t catalogGetTableHashVgroup(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, SVgroupInfo *pVgroup) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
if (CTG_IS_INF_DBNAME(pTableName->dbname)) {
|
||||
if (CTG_IS_SYS_DBNAME(pTableName->dbname)) {
|
||||
ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname);
|
||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
|
|
@ -42,10 +42,6 @@
|
|||
|
||||
#define curTimeWindowIndex(_winres) ((_winres)->curIndex)
|
||||
|
||||
struct SColumnFilterElem;
|
||||
|
||||
typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, const char* val1, const char* val2, int16_t type);
|
||||
|
||||
typedef struct SGroupResInfo {
|
||||
int32_t totalGroup;
|
||||
int32_t currentGroup;
|
||||
|
|
|
@ -38,8 +38,6 @@ extern "C" {
|
|||
#include "tpagedbuf.h"
|
||||
#include "tmsg.h"
|
||||
|
||||
struct SColumnFilterElem;
|
||||
|
||||
typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order);
|
||||
|
||||
#define IS_QUERY_KILLED(_q) ((_q)->code == TSDB_CODE_TSC_QUERY_CANCELLED)
|
||||
|
@ -225,8 +223,6 @@ typedef struct STaskRuntimeEnv {
|
|||
void* qinfo;
|
||||
uint8_t scanFlag; // denotes reversed scan of data or not
|
||||
void* pTsdbReadHandle;
|
||||
|
||||
int32_t prevGroupId; // previous executed group id
|
||||
bool enableGroupData;
|
||||
SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file
|
||||
SHashObj* pResultRowHashTable; // quick locate the window object for each result
|
||||
|
@ -241,8 +237,6 @@ typedef struct STaskRuntimeEnv {
|
|||
|
||||
char* tagVal; // tag value of current data block
|
||||
struct SScalarFunctionSupport* scalarSup;
|
||||
|
||||
SSDataBlock* outputBuf;
|
||||
STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray<STableQueryInfo*> structure
|
||||
struct SOperatorInfo* proot;
|
||||
SGroupResInfo groupResInfo;
|
||||
|
@ -250,7 +244,6 @@ typedef struct STaskRuntimeEnv {
|
|||
|
||||
STableQueryInfo* current;
|
||||
SResultInfo resultInfo;
|
||||
SHashObj* pTableRetrieveTsMap;
|
||||
struct SUdfInfo* pUdfInfo;
|
||||
} STaskRuntimeEnv;
|
||||
|
||||
|
@ -350,6 +343,7 @@ typedef struct STableScanInfo {
|
|||
int64_t elapsedTime;
|
||||
int32_t prevGroupId; // previous table group id
|
||||
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
||||
int32_t dataBlockLoadFlag;
|
||||
} STableScanInfo;
|
||||
|
||||
typedef struct STagScanInfo {
|
||||
|
@ -549,8 +543,6 @@ typedef struct SStateWindowOperatorInfo {
|
|||
|
||||
typedef struct SSortedMergeOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
bool hasVarCol;
|
||||
|
||||
SArray* pSortInfo;
|
||||
int32_t numOfSources;
|
||||
SSortHandle *pSortHandle;
|
||||
|
@ -582,6 +574,24 @@ typedef struct SSortOperatorInfo {
|
|||
uint64_t totalElapsed; // total elapsed time
|
||||
} SSortOperatorInfo;
|
||||
|
||||
typedef struct SJoinOperatorInfo {
|
||||
SSDataBlock *pRes;
|
||||
int32_t joinType;
|
||||
|
||||
SSDataBlock *pLeft;
|
||||
int32_t leftPos;
|
||||
SColumnInfo leftCol;
|
||||
|
||||
SSDataBlock *pRight;
|
||||
int32_t rightPos;
|
||||
SColumnInfo rightCol;
|
||||
|
||||
SNode *pOnCondition;
|
||||
// SJoinStatus *status;
|
||||
// int32_t numOfUpstream;
|
||||
// SRspResultInfo resultInfo;
|
||||
} SJoinOperatorInfo;
|
||||
|
||||
int32_t operatorDummyOpenFn(SOperatorInfo* pOperator);
|
||||
void operatorDummyCloseFn(void* param, int32_t numOfCols);
|
||||
int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num);
|
||||
|
@ -600,7 +610,7 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock);
|
|||
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset);
|
||||
|
||||
SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfCols, int32_t repeatTime,
|
||||
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfCols, int32_t dataLoadFlag, int32_t repeatTime,
|
||||
int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock, SNode* pCondition, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock,
|
||||
SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
||||
|
@ -628,6 +638,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
||||
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SNode* pOnCondition, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
#if 0
|
||||
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
|
||||
SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
||||
|
@ -635,9 +647,6 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim
|
|||
SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
||||
SExprInfo* pExpr, int32_t numOfOutput);
|
||||
SOperatorInfo* createTagScanOperatorInfo(SReaderHandle* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput);
|
||||
|
||||
SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pdownstream, int32_t numOfDownstream, SSchema* pSchema,
|
||||
int32_t numOfOutput);
|
||||
#endif
|
||||
|
||||
void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx, int32_t numOfOutput, SArray* pPseudoList);
|
||||
|
|
|
@ -271,7 +271,7 @@ static int compareRowData(const void* a, const void* b, const void* userData) {
|
|||
}
|
||||
|
||||
// setup the output buffer for each operator
|
||||
SSDataBlock* createOutputBuf_rv1(SDataBlockDescNode* pNode) {
|
||||
SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) {
|
||||
int32_t numOfCols = LIST_LENGTH(pNode->pSlots);
|
||||
|
||||
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||
|
@ -2004,7 +2004,7 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) {
|
|||
bool hasFirstLastFunc = false;
|
||||
bool hasOtherFunc = false;
|
||||
|
||||
if (status == BLK_DATA_ALL_NEEDED || status == BLK_DATA_DISCARD) {
|
||||
if (status == BLK_DATA_DATA_LOAD || status == BLK_DATA_FILTEROUT) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -2023,11 +2023,11 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) {
|
|||
}
|
||||
}
|
||||
|
||||
if (hasFirstLastFunc && status == BLK_DATA_NO_NEEDED) {
|
||||
if (hasFirstLastFunc && status == BLK_DATA_NOT_LOAD) {
|
||||
if (!hasOtherFunc) {
|
||||
return BLK_DATA_DISCARD;
|
||||
return BLK_DATA_FILTEROUT;
|
||||
} else {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
return BLK_DATA_DATA_LOAD;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2360,7 +2360,7 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, SVarian
|
|||
|
||||
static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock) {
|
||||
SqlFunctionCtx* pCtx = pTableScanInfo->pCtx;
|
||||
uint32_t status = BLK_DATA_NO_NEEDED;
|
||||
uint32_t status = BLK_DATA_NOT_LOAD;
|
||||
|
||||
int32_t numOfOutput = pTableScanInfo->numOfOutput;
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
|
@ -2369,11 +2369,11 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData
|
|||
|
||||
// group by + first/last should not apply the first/last block filter
|
||||
if (functionId < 0) {
|
||||
status |= BLK_DATA_ALL_NEEDED;
|
||||
status |= BLK_DATA_DATA_LOAD;
|
||||
return status;
|
||||
} else {
|
||||
// status |= aAggs[functionId].dataReqFunc(&pTableScanInfo->pCtx[i], &pBlock->info.window, colId);
|
||||
// if ((status & BLK_DATA_ALL_NEEDED) == BLK_DATA_ALL_NEEDED) {
|
||||
// if ((status & BLK_DATA_DATA_LOAD) == BLK_DATA_DATA_LOAD) {
|
||||
// return status;
|
||||
// }
|
||||
}
|
||||
|
@ -2384,7 +2384,7 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData
|
|||
|
||||
int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock,
|
||||
uint32_t* status) {
|
||||
*status = BLK_DATA_NO_NEEDED;
|
||||
*status = BLK_DATA_NOT_LOAD;
|
||||
|
||||
pBlock->pDataBlock = NULL;
|
||||
pBlock->pBlockAgg = NULL;
|
||||
|
@ -2397,36 +2397,15 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
|
|||
pCost->totalBlocks += 1;
|
||||
pCost->totalRows += pBlock->info.rows;
|
||||
#if 0
|
||||
if (pRuntimeEnv->pTsBuf != NULL) {
|
||||
(*status) = BLK_DATA_ALL_NEEDED;
|
||||
|
||||
if (pQueryAttr->stableQuery) { // todo refactor
|
||||
SExprInfo* pExprInfo = &pTableScanInfo->pExpr[0];
|
||||
int16_t tagId = (int16_t)pExprInfo->base.param[0].i;
|
||||
SColumnInfo* pColInfo = doGetTagColumnInfoById(pQueryAttr->tagColList, pQueryAttr->numOfTags, tagId);
|
||||
|
||||
// compare tag first
|
||||
SVariant t = {0};
|
||||
doSetTagValueInParam(pRuntimeEnv->current->pTable, tagId, &t, pColInfo->type, pColInfo->bytes);
|
||||
setTimestampListJoinInfo(pRuntimeEnv, &t, pRuntimeEnv->current);
|
||||
|
||||
STSElem elem = tsBufGetElem(pRuntimeEnv->pTsBuf);
|
||||
if (!tsBufIsValidElem(&elem) || (tsBufIsValidElem(&elem) && (taosVariantCompare(&t, elem.tag) != 0))) {
|
||||
(*status) = BLK_DATA_DISCARD;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate all time windows that are overlapping or contain current data block.
|
||||
// If current data block is contained by all possible time window, do not load current data block.
|
||||
if (/*pQueryAttr->pFilters || */pQueryAttr->groupbyColumn || pQueryAttr->sw.gap > 0 ||
|
||||
(QUERY_IS_INTERVAL_QUERY(pQueryAttr) && overlapWithTimeWindow(pTaskInfo, &pBlock->info))) {
|
||||
(*status) = BLK_DATA_ALL_NEEDED;
|
||||
(*status) = BLK_DATA_DATA_LOAD;
|
||||
}
|
||||
|
||||
// check if this data block is required to load
|
||||
if ((*status) != BLK_DATA_ALL_NEEDED) {
|
||||
if ((*status) != BLK_DATA_DATA_LOAD) {
|
||||
bool needFilter = true;
|
||||
|
||||
// the pCtx[i] result is belonged to previous time window since the outputBuf has not been set yet,
|
||||
|
@ -2458,18 +2437,18 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
|
|||
if (needFilter) {
|
||||
(*status) = doFilterByBlockTimeWindow(pTableScanInfo, pBlock);
|
||||
} else {
|
||||
(*status) = BLK_DATA_ALL_NEEDED;
|
||||
(*status) = BLK_DATA_DATA_LOAD;
|
||||
}
|
||||
}
|
||||
|
||||
SDataBlockInfo* pBlockInfo = &pBlock->info;
|
||||
// *status = updateBlockLoadStatus(pRuntimeEnv->pQueryAttr, *status);
|
||||
|
||||
if ((*status) == BLK_DATA_NO_NEEDED || (*status) == BLK_DATA_DISCARD) {
|
||||
if ((*status) == BLK_DATA_NOT_LOAD || (*status) == BLK_DATA_FILTEROUT) {
|
||||
//qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
|
||||
// pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||
pCost->discardBlocks += 1;
|
||||
} else if ((*status) == BLK_DATA_STATIS_NEEDED) {
|
||||
} else if ((*status) == BLK_DATA_SMA_LOAD) {
|
||||
// this function never returns error?
|
||||
pCost->loadBlockStatis += 1;
|
||||
// tsdbRetrieveDataBlockStatisInfo(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg);
|
||||
|
@ -2479,7 +2458,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
|
|||
pCost->totalCheckedRows += pBlock->info.rows;
|
||||
}
|
||||
} else {
|
||||
assert((*status) == BLK_DATA_ALL_NEEDED);
|
||||
assert((*status) == BLK_DATA_DATA_LOAD);
|
||||
|
||||
// load the data block statistics to perform further filter
|
||||
pCost->loadBlockStatis += 1;
|
||||
|
@ -2511,7 +2490,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
|
|||
pCost->discardBlocks += 1;
|
||||
//qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId,
|
||||
// pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||
(*status) = BLK_DATA_DISCARD;
|
||||
(*status) = BLK_DATA_FILTEROUT;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -2523,7 +2502,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
|
|||
// pCost->discardBlocks += 1;
|
||||
// qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
|
||||
// pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||
// (*status) = BLK_DATA_DISCARD;
|
||||
// (*status) = BLK_DATA_FILTEROUT;
|
||||
// return TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
|
||||
|
@ -6539,8 +6518,6 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
|
||||
SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput) {
|
||||
STagScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STagScanInfo));
|
||||
// pInfo->pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->capacity);
|
||||
|
||||
size_t numOfGroup = GET_NUM_OF_TABLEGROUP(pRuntimeEnv);
|
||||
assert(numOfGroup == 0 || numOfGroup == 1);
|
||||
|
||||
|
@ -6679,8 +6656,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
SFunctionNode* pFuncNode = (SFunctionNode*)pTargetNode->pExpr;
|
||||
|
||||
SDataType* pType = &pFuncNode->node.resType;
|
||||
pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
|
||||
pType->precision, pFuncNode->node.aliasName);
|
||||
pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, pType->precision, pFuncNode->node.aliasName);
|
||||
|
||||
pExp->pExpr->_function.functionId = pFuncNode->funcId;
|
||||
pExp->pExpr->_function.pFunctNode = pFuncNode;
|
||||
|
@ -6761,17 +6737,22 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
int32_t type = nodeType(pPhyNode);
|
||||
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) {
|
||||
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode;
|
||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode* ) pPhyNode;
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
tsdbReaderT pDataReader = doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId);
|
||||
SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pScanPhyNode->node.pOutputDataBlockDesc);
|
||||
tsdbReaderT pDataReader = doCreateDataReader(pTableScanNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId);
|
||||
if (pDataReader == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pScanPhyNode->count,
|
||||
SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
|
||||
|
||||
return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pTableScanNode->dataRequired, pScanPhyNode->count,
|
||||
pScanPhyNode->reverse, pColList, pResBlock, pScanPhyNode->node.pConditions, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
||||
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode;
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pExchange->node.pOutputDataBlockDesc);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pExchange->node.pOutputDataBlockDesc);
|
||||
return createExchangeOperatorInfo(pExchange->pSrcEndPoints, pResBlock, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
||||
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; // simple child table.
|
||||
|
@ -6779,7 +6760,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
int32_t code = doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo, queryId, taskId);
|
||||
SArray* tableIdList = extractTableIdList(pTableGroupInfo);
|
||||
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pScanPhyNode->node.pOutputDataBlockDesc);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
||||
|
@ -6788,7 +6769,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
return pOperator;
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
||||
SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode;
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pSysScanPhyNode->scan.node.pOutputDataBlockDesc);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pSysScanPhyNode->scan.node.pOutputDataBlockDesc);
|
||||
|
||||
struct SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan;
|
||||
SArray* colList = extractScanColumnId(pScanNode->pScanCols);
|
||||
|
@ -6802,26 +6783,29 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
}
|
||||
}
|
||||
|
||||
int32_t num = 0;
|
||||
int32_t type = nodeType(pPhyNode);
|
||||
size_t size = LIST_LENGTH(pPhyNode->pChildren);
|
||||
ASSERT(size == 1);
|
||||
|
||||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0);
|
||||
SOperatorInfo* op = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
int32_t num = 0;
|
||||
SOperatorInfo** ops = taosMemoryCalloc(size, POINTER_BYTES);
|
||||
for(int32_t i = 0; i < size; ++i) {
|
||||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i);
|
||||
ops[i] = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
}
|
||||
|
||||
SOperatorInfo* pOptr = NULL;
|
||||
if (QUERY_NODE_PHYSICAL_PLAN_PROJECT == type) {
|
||||
SProjectPhysiNode* pProjPhyNode = (SProjectPhysiNode*) pPhyNode;
|
||||
SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &num);
|
||||
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
SLimit limit = {.limit = pProjPhyNode->limit, .offset = pProjPhyNode->offset};
|
||||
SLimit slimit = {.limit = pProjPhyNode->slimit, .offset = pProjPhyNode->soffset};
|
||||
return createProjectOperatorInfo(op, pExprInfo, num, pResBlock, &limit, &slimit, pTaskInfo);
|
||||
pOptr = createProjectOperatorInfo(ops[0], pExprInfo, num, pResBlock, &limit, &slimit, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_AGG == type) {
|
||||
SAggPhysiNode* pAggNode = (SAggPhysiNode*)pPhyNode;
|
||||
SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num);
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
|
||||
SExprInfo* pScalarExprInfo = NULL;
|
||||
int32_t numOfScalarExpr = 0;
|
||||
|
@ -6831,15 +6815,15 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr);
|
||||
}
|
||||
|
||||
return createGroupOperatorInfo(op, pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL);
|
||||
pOptr = createGroupOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL);
|
||||
} else {
|
||||
return createAggregateOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo);
|
||||
pOptr = createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo);
|
||||
}
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_INTERVAL == type) {
|
||||
SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode;
|
||||
|
||||
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &num);
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
|
||||
SInterval interval = {
|
||||
.interval = pIntervalPhyNode->interval,
|
||||
|
@ -6851,33 +6835,39 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
};
|
||||
|
||||
int32_t primaryTsSlotId = ((SColumnNode*) pIntervalPhyNode->window.pTspk)->slotId;
|
||||
return createIntervalOperatorInfo(op, pExprInfo, num, pResBlock, &interval, primaryTsSlotId, pTableGroupInfo, pTaskInfo);
|
||||
pOptr = createIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, primaryTsSlotId, pTableGroupInfo, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) {
|
||||
SSortPhysiNode* pSortPhyNode = (SSortPhysiNode*)pPhyNode;
|
||||
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
SArray* info = createSortInfo(pSortPhyNode->pSortKeys, pSortPhyNode->pTargets);
|
||||
SArray* slotMap = createIndexMap(pSortPhyNode->pTargets);
|
||||
return createSortOperatorInfo(op, pResBlock, info, slotMap, pTaskInfo);
|
||||
pOptr = createSortOperatorInfo(ops[0], pResBlock, info, slotMap, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW == type) {
|
||||
SSessionWinodwPhysiNode* pSessionNode = (SSessionWinodwPhysiNode*)pPhyNode;
|
||||
|
||||
SExprInfo* pExprInfo = createExprInfo(pSessionNode->window.pFuncs, NULL, &num);
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
||||
return createSessionAggOperatorInfo(op, pExprInfo, num, pResBlock, pSessionNode->gap, pTaskInfo);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
pOptr = createSessionAggOperatorInfo(ops[0], pExprInfo, num, pResBlock, pSessionNode->gap, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_PARTITION == type) {
|
||||
SPartitionPhysiNode* pPartNode = (SPartitionPhysiNode*) pPhyNode;
|
||||
SArray* pColList = extractPartitionColInfo(pPartNode->pPartitionKeys);
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
|
||||
SExprInfo* pExprInfo = createExprInfo(pPartNode->pTargets, NULL, &num);
|
||||
return createPartitionOperatorInfo(op, pExprInfo, num, pResBlock, pColList, pTaskInfo, NULL);
|
||||
} else if (QUERY_NODE_STATE_WINDOW == type) {
|
||||
pOptr = createPartitionOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pTaskInfo, NULL);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW == type) {
|
||||
SStateWinodwPhysiNode* pStateNode = (SStateWinodwPhysiNode*) pPhyNode;
|
||||
|
||||
SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &num);
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
||||
return createStatewindowOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
pOptr = createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_JOIN == type) {
|
||||
SJoinPhysiNode* pJoinNode = (SJoinPhysiNode*) pPhyNode;
|
||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||
|
||||
SExprInfo* pExprInfo = createExprInfo(pJoinNode->pTargets, NULL, &num);
|
||||
pOptr = createJoinOperatorInfo(ops, size, pExprInfo, num, pResBlock, pJoinNode->pOnConditions, pTaskInfo);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
} /*else if (pPhyNode->info.type == OP_MultiTableAggregate) {
|
||||
|
@ -6890,7 +6880,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
return createMultiTableAggOperatorInfo(op, pPhyNode->pTargets, pTaskInfo, pTableGroupInfo);
|
||||
}
|
||||
}*/
|
||||
return NULL;
|
||||
|
||||
taosMemoryFree(ops);
|
||||
return pOptr;
|
||||
}
|
||||
|
||||
static tsdbReaderT createDataReaderImpl(STableScanPhysiNode* pTableScanNode, STableGroupInfo* pGroupInfo,
|
||||
|
@ -7374,4 +7366,135 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo *operatorInfo, SExplainExecInfo
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator, bool* newgroup) {
|
||||
SJoinOperatorInfo* pJoinInfo = pOperator->info;
|
||||
// SOptrBasicInfo* pInfo = &pJoinInfo->binfo;
|
||||
|
||||
SSDataBlock* pRes = pJoinInfo->pRes;
|
||||
blockDataCleanup(pRes);
|
||||
blockDataEnsureCapacity(pRes, 4096);
|
||||
|
||||
int32_t nrows = 0;
|
||||
|
||||
while (1) {
|
||||
bool prevVal = *newgroup;
|
||||
|
||||
if (pJoinInfo->pLeft == NULL || pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) {
|
||||
SOperatorInfo* ds1 = pOperator->pDownstream[0];
|
||||
publishOperatorProfEvent(ds1, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||
pJoinInfo->pLeft = ds1->getNextFn(ds1, newgroup);
|
||||
publishOperatorProfEvent(ds1, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||
|
||||
pJoinInfo->leftPos = 0;
|
||||
if (pJoinInfo->pLeft == NULL) {
|
||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pJoinInfo->pRight == NULL || pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) {
|
||||
SOperatorInfo* ds2 = pOperator->pDownstream[1];
|
||||
publishOperatorProfEvent(ds2, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||
pJoinInfo->pRight = ds2->getNextFn(ds2, newgroup);
|
||||
publishOperatorProfEvent(ds2, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||
|
||||
pJoinInfo->rightPos = 0;
|
||||
if (pJoinInfo->pRight == NULL) {
|
||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SColumnInfoData* pLeftCol = taosArrayGet(pJoinInfo->pLeft->pDataBlock, pJoinInfo->leftCol.slotId);
|
||||
char* pLeftVal = colDataGetData(pLeftCol, pJoinInfo->leftPos);
|
||||
|
||||
SColumnInfoData* pRightCol = taosArrayGet(pJoinInfo->pRight->pDataBlock, pJoinInfo->rightCol.slotId);
|
||||
char* pRightVal = colDataGetData(pRightCol, pJoinInfo->rightPos);
|
||||
|
||||
// only the timestamp match support for ordinary table
|
||||
ASSERT(pLeftCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
if (*(int64_t*) pLeftVal == *(int64_t*) pRightVal) {
|
||||
for(int32_t i = 0; i < pOperator->numOfOutput; ++i) {
|
||||
SColumnInfoData* pDst = taosArrayGet(pRes->pDataBlock, i);
|
||||
|
||||
SExprInfo* pExprInfo = &pOperator->pExpr[i];
|
||||
|
||||
int32_t blockId = pExprInfo->base.pParam[0].pCol->dataBlockId;
|
||||
int32_t slotId = pExprInfo->base.pParam[0].pCol->slotId;
|
||||
|
||||
SColumnInfoData* pSrc = NULL;
|
||||
if (pJoinInfo->pLeft->info.blockId == blockId) {
|
||||
pSrc = taosArrayGet(pJoinInfo->pLeft->pDataBlock, slotId);
|
||||
} else {
|
||||
pSrc = taosArrayGet(pJoinInfo->pRight->pDataBlock, slotId);
|
||||
}
|
||||
|
||||
if (colDataIsNull_s(pSrc, pJoinInfo->leftPos)) {
|
||||
colDataAppendNULL(pDst, nrows);
|
||||
} else {
|
||||
char* p = colDataGetData(pSrc, pJoinInfo->leftPos);
|
||||
colDataAppend(pDst, nrows, p, false);
|
||||
}
|
||||
}
|
||||
|
||||
pJoinInfo->leftPos += 1;
|
||||
pJoinInfo->rightPos += 1;
|
||||
|
||||
nrows += 1;
|
||||
} else if (*(int64_t*) pLeftVal < *(int64_t*) pRightVal) {
|
||||
pJoinInfo->leftPos += 1;
|
||||
|
||||
if (pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) {
|
||||
continue;
|
||||
}
|
||||
} else if (*(int64_t*) pLeftVal > *(int64_t*) pRightVal) {
|
||||
pJoinInfo->rightPos += 1;
|
||||
if (pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// the pDataBlock are always the same one, no need to call this again
|
||||
pRes->info.rows = nrows;
|
||||
if (pRes->info.rows >= pOperator->resultInfo.threshold) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (pRes->info.rows > 0) ? pRes : NULL;
|
||||
}
|
||||
|
||||
SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SNode* pOnCondition, SExecTaskInfo* pTaskInfo) {
|
||||
SJoinOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SJoinOperatorInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pOperator == NULL || pInfo == NULL) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pOperator->resultInfo.capacity = 4096;
|
||||
pOperator->resultInfo.threshold = 4096 * 0.75;
|
||||
|
||||
// initResultRowInf
|
||||
// o(&pInfo->binfo.resultRowInfo, 8);
|
||||
pInfo->pRes = pResBlock;
|
||||
|
||||
pOperator->name = "JoinOperator";
|
||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_JOIN;
|
||||
pOperator->blockingOptr = true;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->pExpr = pExprInfo;
|
||||
pOperator->numOfOutput = numOfCols;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pOperator->getNextFn = doMergeJoin;
|
||||
pOperator->closeFn = destroyBasicOperatorInfo;
|
||||
|
||||
int32_t code = appendDownstream(pOperator, pDownstream, numOfDownstream);
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
taosMemoryFree(pInfo);
|
||||
taosMemoryFree(pOperator);
|
||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
|
@ -64,16 +64,19 @@ static void setupQueryRangeForReverseScan(STableScanInfo* pTableScanInfo) {
|
|||
#endif
|
||||
}
|
||||
|
||||
int32_t loadDataBlock(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) {
|
||||
int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) {
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
STableScanInfo* pInfo = pOperator->info;
|
||||
|
||||
STaskCostInfo* pCost = &pTaskInfo->cost;
|
||||
|
||||
pCost->totalBlocks += 1;
|
||||
pCost->totalRows += pBlock->info.rows;
|
||||
|
||||
pCost->totalCheckedRows += pBlock->info.rows;
|
||||
pCost->loadBlocks += 1;
|
||||
|
||||
*status = BLK_DATA_ALL_NEEDED;
|
||||
pCost->totalRows += pBlock->info.rows;
|
||||
pCost->totalCheckedRows += pBlock->info.rows;
|
||||
|
||||
*status = pInfo->dataBlockLoadFlag;
|
||||
|
||||
SArray* pCols = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL);
|
||||
if (pCols == NULL) {
|
||||
|
@ -138,15 +141,15 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
// }
|
||||
|
||||
// this function never returns error?
|
||||
uint32_t status = BLK_DATA_ALL_NEEDED;
|
||||
int32_t code = loadDataBlock(pTaskInfo, pTableScanInfo, pBlock, &status);
|
||||
uint32_t status = BLK_DATA_DATA_LOAD;
|
||||
int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status);
|
||||
// int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
longjmp(pOperator->pTaskInfo->env, code);
|
||||
}
|
||||
|
||||
// current block is ignored according to filter result by block statistics data, continue load the next block
|
||||
if (status == BLK_DATA_DISCARD || pBlock->info.rows == 0) {
|
||||
if (status == BLK_DATA_FILTEROUT || pBlock->info.rows == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -217,7 +220,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
return p;
|
||||
}
|
||||
|
||||
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput,
|
||||
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput, int32_t dataLoadFlag,
|
||||
int32_t repeatTime, int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock,
|
||||
SNode* pCondition, SExecTaskInfo* pTaskInfo) {
|
||||
assert(repeatTime > 0);
|
||||
|
@ -232,6 +235,7 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pInfo->dataBlockLoadFlag= dataLoadFlag;
|
||||
pInfo->pResBlock = pResBlock;
|
||||
pInfo->pFilterNode = pCondition;
|
||||
pInfo->dataReader = pTsdbReadHandle;
|
||||
|
|
|
@ -796,6 +796,26 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.sprocessFunc = timeDiffFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "now",
|
||||
.type = FUNCTION_TYPE_NOW,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = nowFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "today",
|
||||
.type = FUNCTION_TYPE_TODAY,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = todayFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_rowts",
|
||||
.type = FUNCTION_TYPE_ROWTS,
|
||||
|
@ -866,16 +886,6 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.sprocessFunc = winDurFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "now",
|
||||
.type = FUNCTION_TYPE_NOW,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = winDurFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "to_json",
|
||||
.type = FUNCTION_TYPE_TO_JSON,
|
||||
|
|
|
@ -58,9 +58,9 @@ void functionFinalize(SqlFunctionCtx *pCtx) {
|
|||
EFuncDataRequired countDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) {
|
||||
SNode* pParam = nodesListGetNode(pFunc->pParameterList, 0);
|
||||
if (QUERY_NODE_COLUMN == nodeType(pParam) && PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pParam)->colId) {
|
||||
return FUNC_DATA_REQUIRED_NO_NEEDED;
|
||||
return FUNC_DATA_REQUIRED_NOT_LOAD;
|
||||
}
|
||||
return FUNC_DATA_REQUIRED_STATIS_NEEDED;
|
||||
return FUNC_DATA_REQUIRED_STATIS_LOAD;
|
||||
}
|
||||
|
||||
bool getCountFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
||||
|
|
|
@ -78,10 +78,10 @@ int32_t fmGetFuncResultType(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
|||
|
||||
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) {
|
||||
if (pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) {
|
||||
return FUNC_DATA_REQUIRED_ALL_NEEDED;
|
||||
return FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||
}
|
||||
if (NULL == funcMgtBuiltins[pFunc->funcId].dataRequiredFunc) {
|
||||
return FUNC_DATA_REQUIRED_ALL_NEEDED;
|
||||
return FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||
}
|
||||
return funcMgtBuiltins[pFunc->funcId].dataRequiredFunc(pFunc, pTimeWindow);
|
||||
}
|
||||
|
|
|
@ -557,14 +557,14 @@ static void count_func_merge(SqlFunctionCtx *pCtx) {
|
|||
*/
|
||||
int32_t countRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
|
||||
if (colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
return BLK_DATA_NO_NEEDED;
|
||||
return BLK_DATA_NOT_LOAD;
|
||||
} else {
|
||||
return BLK_DATA_STATIS_NEEDED;
|
||||
return BLK_DATA_SMA_LOAD;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t noDataRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
|
||||
return BLK_DATA_NO_NEEDED;
|
||||
return BLK_DATA_NOT_LOAD;
|
||||
}
|
||||
#define LIST_ADD_N_DOUBLE_FLOAT(x, ctx, p, t, numOfElem, tsdbType) \
|
||||
do { \
|
||||
|
@ -743,76 +743,76 @@ static void sum_func_merge(SqlFunctionCtx *pCtx) {
|
|||
}
|
||||
|
||||
static int32_t statisRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
|
||||
return BLK_DATA_STATIS_NEEDED;
|
||||
return BLK_DATA_SMA_LOAD;
|
||||
}
|
||||
|
||||
static int32_t dataBlockRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
return BLK_DATA_DATA_LOAD;
|
||||
}
|
||||
|
||||
// todo: if column in current data block are null, opt for this case
|
||||
static int32_t firstFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
|
||||
if (pCtx->order == TSDB_ORDER_DESC) {
|
||||
return BLK_DATA_NO_NEEDED;
|
||||
return BLK_DATA_NOT_LOAD;
|
||||
}
|
||||
|
||||
// no result for first query, data block is required
|
||||
if (GET_RES_INFO(pCtx) == NULL || GET_RES_INFO(pCtx)->numOfRes <= 0) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
return BLK_DATA_DATA_LOAD;
|
||||
} else {
|
||||
return BLK_DATA_NO_NEEDED;
|
||||
return BLK_DATA_NOT_LOAD;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t lastFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
|
||||
if (pCtx->order != pCtx->param[0].i) {
|
||||
return BLK_DATA_NO_NEEDED;
|
||||
return BLK_DATA_NOT_LOAD;
|
||||
}
|
||||
|
||||
if (GET_RES_INFO(pCtx) == NULL || GET_RES_INFO(pCtx)->numOfRes <= 0) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
return BLK_DATA_DATA_LOAD;
|
||||
} else {
|
||||
return BLK_DATA_NO_NEEDED;
|
||||
return BLK_DATA_NOT_LOAD;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t firstDistFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
|
||||
if (pCtx->order == TSDB_ORDER_DESC) {
|
||||
return BLK_DATA_NO_NEEDED;
|
||||
return BLK_DATA_NOT_LOAD;
|
||||
}
|
||||
|
||||
// not initialized yet, it is the first block, load it.
|
||||
if (pCtx->pOutput == NULL) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
return BLK_DATA_DATA_LOAD;
|
||||
}
|
||||
|
||||
// the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->pOutput is
|
||||
// the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid
|
||||
SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->pOutput + pCtx->inputBytes);
|
||||
if (pInfo->hasResult != DATA_SET_FLAG) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
return BLK_DATA_DATA_LOAD;
|
||||
} else { // data in current block is not earlier than current result
|
||||
return (pInfo->ts <= w->skey) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
||||
return (pInfo->ts <= w->skey) ? BLK_DATA_NOT_LOAD : BLK_DATA_DATA_LOAD;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t lastDistFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
|
||||
if (pCtx->order != pCtx->param[0].i) {
|
||||
return BLK_DATA_NO_NEEDED;
|
||||
return BLK_DATA_NOT_LOAD;
|
||||
}
|
||||
|
||||
// not initialized yet, it is the first block, load it.
|
||||
if (pCtx->pOutput == NULL) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
return BLK_DATA_DATA_LOAD;
|
||||
}
|
||||
|
||||
// the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->pOutput is
|
||||
// the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid
|
||||
SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->pOutput + pCtx->inputBytes);
|
||||
if (pInfo->hasResult != DATA_SET_FLAG) {
|
||||
return BLK_DATA_ALL_NEEDED;
|
||||
return BLK_DATA_DATA_LOAD;
|
||||
} else {
|
||||
return (pInfo->ts > w->ekey) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
||||
return (pInfo->ts > w->ekey) ? BLK_DATA_NOT_LOAD : BLK_DATA_DATA_LOAD;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1226,7 +1226,7 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
|||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
pVal->pz = pNode->datum.p;
|
||||
pVal->pz = pNode->datum.p + VARSTR_HEADER_SIZE;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_JSON:
|
||||
case TSDB_DATA_TYPE_DECIMAL:
|
||||
|
|
|
@ -93,6 +93,7 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL
|
|||
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList);
|
||||
SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName);
|
||||
SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt);
|
||||
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList);
|
||||
SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2);
|
||||
|
|
|
@ -592,8 +592,6 @@ expression_list(A) ::= expression_list(B) NK_COMMA expression(C).
|
|||
column_reference(A) ::= column_name(B). { A = createRawExprNode(pCxt, &B, createColumnNode(pCxt, NULL, &B)); }
|
||||
column_reference(A) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); }
|
||||
|
||||
pseudo_column(A) ::= NOW(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
pseudo_column(A) ::= TODAY(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
pseudo_column(A) ::= QSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
|
@ -605,6 +603,12 @@ pseudo_column(A) ::= WDURATION(B).
|
|||
function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::= CAST(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
function_expression(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); }
|
||||
|
||||
%type noarg_func { SToken }
|
||||
%destructor noarg_func { }
|
||||
noarg_func(A) ::= NOW(B). { A = B; }
|
||||
noarg_func(A) ::= TODAY(B). { A = B; }
|
||||
|
||||
%type star_func { SToken }
|
||||
%destructor star_func { }
|
||||
|
|
|
@ -367,6 +367,39 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod
|
|||
return (SNode*)func;
|
||||
}
|
||||
|
||||
SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName) {
|
||||
SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
CHECK_OUT_OF_MEM(func);
|
||||
char buf[64] = {0};
|
||||
|
||||
int32_t dataType;
|
||||
switch (pFuncName->type) {
|
||||
case TK_NOW: {
|
||||
int64_t ts = taosGetTimestamp(TSDB_TIME_PRECISION_MILLI);
|
||||
snprintf(buf, sizeof(buf), "%"PRId64, ts);
|
||||
dataType = TSDB_DATA_TYPE_BIGINT;
|
||||
break;
|
||||
}
|
||||
case TK_TODAY: {
|
||||
int64_t ts = taosGetTimestampToday(TSDB_TIME_PRECISION_MILLI);
|
||||
snprintf(buf, sizeof(buf), "%"PRId64, ts);
|
||||
dataType = TSDB_DATA_TYPE_BIGINT;
|
||||
break;
|
||||
}
|
||||
//case TK_TIMEZONE: {
|
||||
// strncpy(buf, tsTimezoneStr, strlen(tsTimezoneStr));
|
||||
// dataType = TSDB_DATA_TYPE_BINARY;
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
SToken token = {.type = pFuncName->type, .n = strlen(buf), .z = buf};
|
||||
|
||||
SNodeList *pParameterList = createNodeList(pCxt, createValueNode(pCxt, dataType, &token));
|
||||
strncpy(func->functionName, pFuncName->z, pFuncName->n);
|
||||
func->pParameterList = pParameterList;
|
||||
return (SNode*)func;
|
||||
}
|
||||
|
||||
SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt) {
|
||||
SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
CHECK_OUT_OF_MEM(func);
|
||||
|
|
|
@ -223,11 +223,15 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
|
||||
static int32_t getTableMetaImpl(SInsertParseContext* pCxt, SToken* pTname, bool isStb) {
|
||||
SParseContext* pBasicCtx = pCxt->pComCxt;
|
||||
SName name = {0};
|
||||
createSName(&name, pTname, pBasicCtx, &pCxt->msg);
|
||||
if (isStb) {
|
||||
CHECK_CODE(catalogGetSTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta));
|
||||
} else {
|
||||
CHECK_CODE(catalogGetTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta));
|
||||
}
|
||||
SVgroupInfo vg;
|
||||
CHECK_CODE(catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &vg));
|
||||
CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)));
|
||||
|
@ -235,6 +239,15 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
|
||||
return getTableMetaImpl(pCxt, pTname, false);
|
||||
}
|
||||
|
||||
static int32_t getSTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
|
||||
return getTableMetaImpl(pCxt, pTname, true);
|
||||
}
|
||||
|
||||
|
||||
static int32_t findCol(SToken* pColname, int32_t start, int32_t end, SSchema* pSchema) {
|
||||
while (start < end) {
|
||||
if (strlen(pSchema[start].name) == pColname->n && strncmp(pColname->z, pSchema[start].name, pColname->n) == 0) {
|
||||
|
@ -818,7 +831,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken)
|
|||
SToken sToken;
|
||||
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
|
||||
NEXT_TOKEN(pCxt->pSql, sToken);
|
||||
CHECK_CODE(getTableMeta(pCxt, &sToken));
|
||||
CHECK_CODE(getSTableMeta(pCxt, &sToken));
|
||||
if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) {
|
||||
return buildInvalidOperationMsg(&pCxt->msg, "create table only from super table is allowed");
|
||||
}
|
||||
|
|
|
@ -2319,6 +2319,10 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int8_t extractResultTsPrecision(const SSelectStmt* pSelect) {
|
||||
return pSelect->precision;
|
||||
}
|
||||
|
||||
static int32_t extractExplainResultSchema(int32_t* numOfCols, SSchema** pSchema) {
|
||||
*numOfCols = 1;
|
||||
*pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema));
|
||||
|
@ -2340,19 +2344,19 @@ static int32_t extractDescribeResultSchema(int32_t* numOfCols, SSchema** pSchema
|
|||
|
||||
(*pSchema)[0].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[0].bytes = DESCRIBE_RESULT_FIELD_LEN;
|
||||
strcpy((*pSchema)[0].name, "Field");
|
||||
strcpy((*pSchema)[0].name, "field");
|
||||
|
||||
(*pSchema)[1].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[1].bytes = DESCRIBE_RESULT_TYPE_LEN;
|
||||
strcpy((*pSchema)[1].name, "Type");
|
||||
strcpy((*pSchema)[1].name, "type");
|
||||
|
||||
(*pSchema)[2].type = TSDB_DATA_TYPE_INT;
|
||||
(*pSchema)[2].bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes;
|
||||
strcpy((*pSchema)[2].name, "Length");
|
||||
strcpy((*pSchema)[2].name, "length");
|
||||
|
||||
(*pSchema)[3].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[3].bytes = DESCRIBE_RESULT_NOTE_LEN;
|
||||
strcpy((*pSchema)[3].name, "Note");
|
||||
strcpy((*pSchema)[3].name, "note");
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -3033,6 +3037,8 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
if (TSDB_CODE_SUCCESS != extractResultSchema(pQuery->pRoot, &pQuery->numOfResCols, &pQuery->pResSchema)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pQuery->precision = extractResultTsPrecision((SSelectStmt*) pQuery->pRoot);
|
||||
}
|
||||
|
||||
if (NULL != pCxt->pDbs) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -200,7 +200,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
strcpy(pScan->tableName.tname, pRealTable->table.tableName);
|
||||
pScan->showRewrite = pCxt->pPlanCxt->showRewrite;
|
||||
pScan->ratio = pRealTable->ratio;
|
||||
pScan->dataRequired = FUNC_DATA_REQUIRED_ALL_NEEDED;
|
||||
pScan->dataRequired = FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||
|
||||
// set columns to scan
|
||||
SNodeList* pCols = NULL;
|
||||
|
|
|
@ -125,12 +125,12 @@ static int32_t osdMatch(SOptimizeContext* pCxt, SLogicNode* pLogicNode, SOsdInfo
|
|||
|
||||
static EFuncDataRequired osdPromoteDataRequired(EFuncDataRequired l , EFuncDataRequired r) {
|
||||
switch (l) {
|
||||
case FUNC_DATA_REQUIRED_ALL_NEEDED:
|
||||
case FUNC_DATA_REQUIRED_DATA_LOAD:
|
||||
return l;
|
||||
case FUNC_DATA_REQUIRED_STATIS_NEEDED:
|
||||
return FUNC_DATA_REQUIRED_ALL_NEEDED == r ? r : l;
|
||||
case FUNC_DATA_REQUIRED_NO_NEEDED:
|
||||
return FUNC_DATA_REQUIRED_DISCARD == r ? l : r;
|
||||
case FUNC_DATA_REQUIRED_STATIS_LOAD:
|
||||
return FUNC_DATA_REQUIRED_DATA_LOAD == r ? r : l;
|
||||
case FUNC_DATA_REQUIRED_NOT_LOAD:
|
||||
return FUNC_DATA_REQUIRED_FILTEROUT == r ? l : r;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -139,9 +139,9 @@ static EFuncDataRequired osdPromoteDataRequired(EFuncDataRequired l , EFuncDataR
|
|||
|
||||
static int32_t osdGetDataRequired(SNodeList* pFuncs) {
|
||||
if (NULL == pFuncs) {
|
||||
return FUNC_DATA_REQUIRED_ALL_NEEDED;
|
||||
return FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||
}
|
||||
EFuncDataRequired dataRequired = FUNC_DATA_REQUIRED_DISCARD;
|
||||
EFuncDataRequired dataRequired = FUNC_DATA_REQUIRED_FILTEROUT;
|
||||
SNode* pFunc = NULL;
|
||||
FOREACH(pFunc, pFuncs) {
|
||||
dataRequired = osdPromoteDataRequired(dataRequired, fmFuncDataRequired((SFunctionNode*)pFunc, NULL));
|
||||
|
|
|
@ -1020,7 +1020,7 @@ int32_t qwProcessReady(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
|||
}
|
||||
|
||||
if (ctx->phase == QW_PHASE_PRE_QUERY) {
|
||||
ctx->ctrlConnInfo.handle == qwMsg->connInfo.handle;
|
||||
ctx->ctrlConnInfo.handle = qwMsg->connInfo.handle;
|
||||
ctx->ctrlConnInfo.ahandle = qwMsg->connInfo.ahandle;
|
||||
QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_READY);
|
||||
needRsp = false;
|
||||
|
|
|
@ -1259,6 +1259,22 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
if (inputNum != 1) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 0));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
if (inputNum != 1) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 0));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
return doScalarFunctionUnique(pInput, inputNum, pOutput, atan);
|
||||
}
|
||||
|
|
|
@ -156,8 +156,8 @@ typedef struct SSchJob {
|
|||
int32_t levelNum;
|
||||
int32_t taskNum;
|
||||
void *transport;
|
||||
SArray *nodeList; // qnode/vnode list, element is SQueryNodeAddr
|
||||
SArray *levels; // Element is SQueryLevel, starting from 0. SArray<SSchLevel>
|
||||
SArray *nodeList; // qnode/vnode list, SArray<SQueryNodeAddr>
|
||||
SArray *levels; // starting from 0. SArray<SSchLevel>
|
||||
SNodeList *subPlans; // subplan pointer copied from DAG, no need to free it in scheduler
|
||||
|
||||
int32_t levelIdx;
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
*/
|
||||
|
||||
#include "catalog.h"
|
||||
#include "command.h"
|
||||
#include "query.h"
|
||||
#include "schedulerInt.h"
|
||||
#include "tmsg.h"
|
||||
#include "tref.h"
|
||||
#include "trpc.h"
|
||||
#include "command.h"
|
||||
|
||||
SSchedulerMgmt schMgmt = {0};
|
||||
|
||||
|
@ -141,7 +141,6 @@ _return:
|
|||
SCH_RET(code);
|
||||
}
|
||||
|
||||
|
||||
void schFreeRpcCtx(SRpcCtx *pCtx) {
|
||||
if (NULL == pCtx) {
|
||||
return;
|
||||
|
@ -1254,7 +1253,8 @@ int32_t schGetTaskFromTaskList(SHashObj *pTaskList, uint64_t taskId, SSchTask **
|
|||
}
|
||||
|
||||
int32_t schUpdateTaskExecNodeHandle(SSchTask *pTask, void *handle, int32_t rspCode) {
|
||||
if (rspCode || NULL == pTask->execNodes || taosArrayGetSize(pTask->execNodes) > 1 || taosArrayGetSize(pTask->execNodes) <= 0) {
|
||||
if (rspCode || NULL == pTask->execNodes || taosArrayGetSize(pTask->execNodes) > 1 ||
|
||||
taosArrayGetSize(pTask->execNodes) <= 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1264,7 +1264,6 @@ int32_t schUpdateTaskExecNodeHandle(SSchTask *pTask, void *handle, int32_t rspCo
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
||||
|
@ -1282,13 +1281,15 @@ int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, in
|
|||
if (TDMT_VND_EXPLAIN_RSP == msgType) {
|
||||
schGetTaskFromTaskList(pJob->succTasks, pParam->taskId, &pTask);
|
||||
} else {
|
||||
SCH_JOB_ELOG("task not found in execTask list, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId, pParam->taskId);
|
||||
SCH_JOB_ELOG("task not found in execTask list, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId,
|
||||
pParam->taskId);
|
||||
SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == pTask) {
|
||||
SCH_JOB_ELOG("task not found in execList & succList, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId, pParam->taskId);
|
||||
SCH_JOB_ELOG("task not found in execList & succList, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId,
|
||||
pParam->taskId);
|
||||
SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
|
@ -2655,6 +2656,33 @@ _return:
|
|||
SCH_RET(code);
|
||||
}
|
||||
|
||||
int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub) {
|
||||
int32_t code = 0;
|
||||
SSchJob *pJob = schAcquireJob(job);
|
||||
if (NULL == pJob) {
|
||||
qDebug("acquire job from jobRef list failed, may not started or dropped, refId:%" PRIx64, job);
|
||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||
}
|
||||
|
||||
if (pJob->status < JOB_TASK_STATUS_NOT_START || pJob->levelNum <= 0 || NULL == pJob->levels) {
|
||||
qDebug("job not initialized or not executable job, refId:%" PRIx64, job);
|
||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||
}
|
||||
|
||||
for (int32_t i = pJob->levelNum - 1; i >= 0; --i) {
|
||||
SSchLevel *pLevel = taosArrayGet(pJob->levels, i);
|
||||
|
||||
for (int32_t m = 0; m < pLevel->taskNum; ++m) {
|
||||
SSchTask *pTask = taosArrayGet(pLevel->subTasks, m);
|
||||
SQuerySubDesc subDesc = {.tid = pTask->taskId, .status = pTask->status};
|
||||
|
||||
taosArrayPush(pSub, &subDesc);
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t scheduleCancelJob(int64_t job) {
|
||||
SSchJob *pJob = schAcquireJob(job);
|
||||
if (NULL == pJob) {
|
||||
|
@ -2672,7 +2700,7 @@ int32_t scheduleCancelJob(int64_t job) {
|
|||
void schedulerFreeJob(int64_t job) {
|
||||
SSchJob *pJob = schAcquireJob(job);
|
||||
if (NULL == pJob) {
|
||||
qError("acquire job from jobRef list failed, may be dropped, refId:%" PRIx64, job);
|
||||
qDebug("acquire job from jobRef list failed, may be dropped, refId:%" PRIx64, job);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2706,15 +2734,17 @@ void schedulerFreeTaskList(SArray *taskList) {
|
|||
void schedulerDestroy(void) {
|
||||
if (schMgmt.jobRef) {
|
||||
SSchJob *pJob = taosIterateRef(schMgmt.jobRef, 0);
|
||||
int64_t refId = 0;
|
||||
|
||||
while (pJob) {
|
||||
refId = pJob->refId;
|
||||
|
||||
taosRemoveRef(schMgmt.jobRef, pJob->refId);
|
||||
|
||||
pJob = taosIterateRef(schMgmt.jobRef, pJob->refId);
|
||||
pJob = taosIterateRef(schMgmt.jobRef, refId);
|
||||
}
|
||||
|
||||
taosCloseRef(schMgmt.jobRef);
|
||||
schMgmt.jobRef = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) {
|
|||
|
||||
void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) {
|
||||
queue->q = taosArrayInit(2, sizeof(void*));
|
||||
queue->freeFunc = freeFunc;
|
||||
queue->freeFunc = (void (*)(const void*))freeFunc;
|
||||
}
|
||||
bool transQueuePush(STransQueue* queue, void* arg) {
|
||||
if (queue->q == NULL) {
|
||||
|
|
|
@ -156,14 +156,14 @@ TEST_F(TransCtxEnv, mergeTest) {
|
|||
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
||||
transCtxInit(src);
|
||||
{
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||
val1.val = taosMemoryMalloc(12);
|
||||
|
||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||
key++;
|
||||
}
|
||||
{
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||
val1.val = taosMemoryMalloc(12);
|
||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||
key++;
|
||||
|
@ -176,14 +176,14 @@ TEST_F(TransCtxEnv, mergeTest) {
|
|||
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
||||
transCtxInit(src);
|
||||
{
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||
val1.val = taosMemoryMalloc(12);
|
||||
|
||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||
key++;
|
||||
}
|
||||
{
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||
val1.val = taosMemoryMalloc(12);
|
||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||
key++;
|
||||
|
@ -198,7 +198,7 @@ TEST_F(TransCtxEnv, mergeTest) {
|
|||
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
||||
transCtxInit(src);
|
||||
{
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||
val1.val = taosMemoryCalloc(1, 11);
|
||||
memcpy(val1.val, val.c_str(), val.size());
|
||||
|
||||
|
@ -206,7 +206,7 @@ TEST_F(TransCtxEnv, mergeTest) {
|
|||
key++;
|
||||
}
|
||||
{
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||
val1.val = taosMemoryCalloc(1, 11);
|
||||
memcpy(val1.val, val.c_str(), val.size());
|
||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue