Merge branch '3.0' of https://github.com/taosdata/TDengine into test/td-14999
This commit is contained in:
commit
6848237831
|
@ -46,7 +46,7 @@ ENDIF ()
|
||||||
|
|
||||||
IF (TD_WINDOWS)
|
IF (TD_WINDOWS)
|
||||||
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
||||||
SET(COMMON_FLAGS "/W3 /D_WIN32 /vmg")
|
SET(COMMON_FLAGS "/W3 /D_WIN32")
|
||||||
|
|
||||||
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
||||||
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
||||||
|
|
|
@ -195,7 +195,7 @@ DLL_EXPORT void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char *tableNameList);
|
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char *tableNameList);
|
||||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision, bool dataFormat);
|
DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision);
|
||||||
|
|
||||||
/* --------------------------TMQ INTERFACE------------------------------- */
|
/* --------------------------TMQ INTERFACE------------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,12 @@ enum {
|
||||||
STREAM_TRIGGER__BY_EVENT_TIME,
|
STREAM_TRIGGER__BY_EVENT_TIME,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum EStreamType {
|
||||||
|
STREAM_NORMAL = 1,
|
||||||
|
STREAM_INVERT,
|
||||||
|
STREAM_INVALID,
|
||||||
|
} EStreamType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t numOfTables;
|
uint32_t numOfTables;
|
||||||
SArray* pGroupList;
|
SArray* pGroupList;
|
||||||
|
@ -71,6 +77,7 @@ typedef struct SDataBlockInfo {
|
||||||
int16_t numOfCols;
|
int16_t numOfCols;
|
||||||
int16_t hasVarCol;
|
int16_t hasVarCol;
|
||||||
int32_t capacity;
|
int32_t capacity;
|
||||||
|
EStreamType type;
|
||||||
} SDataBlockInfo;
|
} SDataBlockInfo;
|
||||||
|
|
||||||
typedef struct SSDataBlock {
|
typedef struct SSDataBlock {
|
||||||
|
@ -115,8 +122,6 @@ void* tDecodeDataBlocks(const void* buf, SArray** blocks);
|
||||||
void colDataDestroy(SColumnInfoData* pColData);
|
void colDataDestroy(SColumnInfoData* pColData);
|
||||||
|
|
||||||
static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
|
static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
|
||||||
// WARNING: do not use info.numOfCols,
|
|
||||||
// sometimes info.numOfCols != array size
|
|
||||||
int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock);
|
int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock);
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
|
|
@ -135,6 +135,8 @@ typedef enum _mgmt_table {
|
||||||
#define TSDB_ALTER_USER_ADD_WRITE_DB 0x6
|
#define TSDB_ALTER_USER_ADD_WRITE_DB 0x6
|
||||||
#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x7
|
#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x7
|
||||||
#define TSDB_ALTER_USER_CLEAR_WRITE_DB 0x8
|
#define TSDB_ALTER_USER_CLEAR_WRITE_DB 0x8
|
||||||
|
#define TSDB_ALTER_USER_ADD_ALL_DB 0x9
|
||||||
|
#define TSDB_ALTER_USER_REMOVE_ALL_DB 0xA
|
||||||
|
|
||||||
#define TSDB_ALTER_USER_PRIVILEGES 0x2
|
#define TSDB_ALTER_USER_PRIVILEGES 0x2
|
||||||
|
|
||||||
|
@ -326,11 +328,11 @@ typedef struct {
|
||||||
int8_t alterType;
|
int8_t alterType;
|
||||||
int32_t numOfFields;
|
int32_t numOfFields;
|
||||||
SArray* pFields;
|
SArray* pFields;
|
||||||
} SMAltertbReq;
|
} SMAlterStbReq;
|
||||||
|
|
||||||
int32_t tSerializeSMAlterStbReq(void* buf, int32_t bufLen, SMAltertbReq* pReq);
|
int32_t tSerializeSMAlterStbReq(void* buf, int32_t bufLen, SMAlterStbReq* pReq);
|
||||||
int32_t tDeserializeSMAlterStbReq(void* buf, int32_t bufLen, SMAltertbReq* pReq);
|
int32_t tDeserializeSMAlterStbReq(void* buf, int32_t bufLen, SMAlterStbReq* pReq);
|
||||||
void tFreeSMAltertbReq(SMAltertbReq* pReq);
|
void tFreeSMAltertbReq(SMAlterStbReq* pReq);
|
||||||
|
|
||||||
typedef struct SEpSet {
|
typedef struct SEpSet {
|
||||||
int8_t inUse;
|
int8_t inUse;
|
||||||
|
@ -338,8 +340,8 @@ typedef struct SEpSet {
|
||||||
SEp eps[TSDB_MAX_REPLICA];
|
SEp eps[TSDB_MAX_REPLICA];
|
||||||
} SEpSet;
|
} SEpSet;
|
||||||
|
|
||||||
int32_t tEncodeSEpSet(SCoder* pEncoder, const SEpSet* pEp);
|
int32_t tEncodeSEpSet(SEncoder* pEncoder, const SEpSet* pEp);
|
||||||
int32_t tDecodeSEpSet(SCoder* pDecoder, SEpSet* pEp);
|
int32_t tDecodeSEpSet(SDecoder* pDecoder, SEpSet* pEp);
|
||||||
int32_t taosEncodeSEpSet(void** buf, const SEpSet* pEp);
|
int32_t taosEncodeSEpSet(void** buf, const SEpSet* pEp);
|
||||||
void* taosDecodeSEpSet(const void* buf, SEpSet* pEp);
|
void* taosDecodeSEpSet(const void* buf, SEpSet* pEp);
|
||||||
|
|
||||||
|
@ -611,8 +613,8 @@ typedef struct {
|
||||||
|
|
||||||
int32_t tSerializeSUseDbRsp(void* buf, int32_t bufLen, const SUseDbRsp* pRsp);
|
int32_t tSerializeSUseDbRsp(void* buf, int32_t bufLen, const SUseDbRsp* pRsp);
|
||||||
int32_t tDeserializeSUseDbRsp(void* buf, int32_t bufLen, SUseDbRsp* pRsp);
|
int32_t tDeserializeSUseDbRsp(void* buf, int32_t bufLen, SUseDbRsp* pRsp);
|
||||||
int32_t tSerializeSUseDbRspImp(SCoder* pEncoder, const SUseDbRsp* pRsp);
|
int32_t tSerializeSUseDbRspImp(SEncoder* pEncoder, const SUseDbRsp* pRsp);
|
||||||
int32_t tDeserializeSUseDbRspImp(SCoder* pDecoder, SUseDbRsp* pRsp);
|
int32_t tDeserializeSUseDbRspImp(SDecoder* pDecoder, SUseDbRsp* pRsp);
|
||||||
void tFreeSUsedbRsp(SUseDbRsp* pRsp);
|
void tFreeSUsedbRsp(SUseDbRsp* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1527,8 +1529,8 @@ typedef struct {
|
||||||
char* qmsg2; // pAst2:qmsg2:SRetention2 => trigger aggr task2
|
char* qmsg2; // pAst2:qmsg2:SRetention2 => trigger aggr task2
|
||||||
} SRSmaParam;
|
} SRSmaParam;
|
||||||
|
|
||||||
int32_t tEncodeSRSmaParam(SCoder* pCoder, const SRSmaParam* pRSmaParam);
|
int32_t tEncodeSRSmaParam(SEncoder* pCoder, const SRSmaParam* pRSmaParam);
|
||||||
int32_t tDecodeSRSmaParam(SCoder* pCoder, SRSmaParam* pRSmaParam);
|
int32_t tDecodeSRSmaParam(SDecoder* pCoder, SRSmaParam* pRSmaParam);
|
||||||
|
|
||||||
// TDMT_VND_CREATE_STB ==============
|
// TDMT_VND_CREATE_STB ==============
|
||||||
typedef struct SVCreateStbReq {
|
typedef struct SVCreateStbReq {
|
||||||
|
@ -1540,8 +1542,8 @@ typedef struct SVCreateStbReq {
|
||||||
SRSmaParam pRSmaParam;
|
SRSmaParam pRSmaParam;
|
||||||
} SVCreateStbReq;
|
} SVCreateStbReq;
|
||||||
|
|
||||||
int tEncodeSVCreateStbReq(SCoder* pCoder, const SVCreateStbReq* pReq);
|
int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq);
|
||||||
int tDecodeSVCreateStbReq(SCoder* pCoder, SVCreateStbReq* pReq);
|
int tDecodeSVCreateStbReq(SDecoder* pCoder, SVCreateStbReq* pReq);
|
||||||
|
|
||||||
// TDMT_VND_DROP_STB ==============
|
// TDMT_VND_DROP_STB ==============
|
||||||
typedef struct SVDropStbReq {
|
typedef struct SVDropStbReq {
|
||||||
|
@ -1549,8 +1551,8 @@ typedef struct SVDropStbReq {
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
} SVDropStbReq;
|
} SVDropStbReq;
|
||||||
|
|
||||||
int32_t tEncodeSVDropStbReq(SCoder* pCoder, const SVDropStbReq* pReq);
|
int32_t tEncodeSVDropStbReq(SEncoder* pCoder, const SVDropStbReq* pReq);
|
||||||
int32_t tDecodeSVDropStbReq(SCoder* pCoder, SVDropStbReq* pReq);
|
int32_t tDecodeSVDropStbReq(SDecoder* pCoder, SVDropStbReq* pReq);
|
||||||
|
|
||||||
#define TD_CREATE_IF_NOT_EXISTS 0x1
|
#define TD_CREATE_IF_NOT_EXISTS 0x1
|
||||||
typedef struct SVCreateTbReq {
|
typedef struct SVCreateTbReq {
|
||||||
|
@ -1563,7 +1565,7 @@ typedef struct SVCreateTbReq {
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
const void* pTag;
|
const uint8_t* pTag;
|
||||||
} ctb;
|
} ctb;
|
||||||
struct {
|
struct {
|
||||||
SSchemaWrapper schema;
|
SSchemaWrapper schema;
|
||||||
|
@ -1571,8 +1573,8 @@ typedef struct SVCreateTbReq {
|
||||||
};
|
};
|
||||||
} SVCreateTbReq;
|
} SVCreateTbReq;
|
||||||
|
|
||||||
int tEncodeSVCreateTbReq(SCoder* pCoder, const SVCreateTbReq* pReq);
|
int tEncodeSVCreateTbReq(SEncoder* pCoder, const SVCreateTbReq* pReq);
|
||||||
int tDecodeSVCreateTbReq(SCoder* pCoder, SVCreateTbReq* pReq);
|
int tDecodeSVCreateTbReq(SDecoder* pCoder, SVCreateTbReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t nReqs;
|
int32_t nReqs;
|
||||||
|
@ -1582,15 +1584,15 @@ typedef struct {
|
||||||
};
|
};
|
||||||
} SVCreateTbBatchReq;
|
} SVCreateTbBatchReq;
|
||||||
|
|
||||||
int tEncodeSVCreateTbBatchReq(SCoder* pCoder, const SVCreateTbBatchReq* pReq);
|
int tEncodeSVCreateTbBatchReq(SEncoder* pCoder, const SVCreateTbBatchReq* pReq);
|
||||||
int tDecodeSVCreateTbBatchReq(SCoder* pCoder, SVCreateTbBatchReq* pReq);
|
int tDecodeSVCreateTbBatchReq(SDecoder* pCoder, SVCreateTbBatchReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
} SVCreateTbRsp, SVUpdateTbRsp;
|
} SVCreateTbRsp, SVUpdateTbRsp;
|
||||||
|
|
||||||
int tEncodeSVCreateTbRsp(SCoder* pCoder, const SVCreateTbRsp* pRsp);
|
int tEncodeSVCreateTbRsp(SEncoder* pCoder, const SVCreateTbRsp* pRsp);
|
||||||
int tDecodeSVCreateTbRsp(SCoder* pCoder, SVCreateTbRsp* pRsp);
|
int tDecodeSVCreateTbRsp(SDecoder* pCoder, SVCreateTbRsp* pRsp);
|
||||||
|
|
||||||
int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq);
|
int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq);
|
||||||
void* tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pReq);
|
void* tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pReq);
|
||||||
|
@ -1603,8 +1605,8 @@ typedef struct {
|
||||||
};
|
};
|
||||||
} SVCreateTbBatchRsp;
|
} SVCreateTbBatchRsp;
|
||||||
|
|
||||||
int tEncodeSVCreateTbBatchRsp(SCoder* pCoder, const SVCreateTbBatchRsp* pRsp);
|
int tEncodeSVCreateTbBatchRsp(SEncoder* pCoder, const SVCreateTbBatchRsp* pRsp);
|
||||||
int tDecodeSVCreateTbBatchRsp(SCoder* pCoder, SVCreateTbBatchRsp* pRsp);
|
int tDecodeSVCreateTbBatchRsp(SDecoder* pCoder, SVCreateTbBatchRsp* pRsp);
|
||||||
|
|
||||||
int32_t tSerializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
|
int32_t tSerializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
|
||||||
int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
|
int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
|
||||||
|
@ -1627,8 +1629,8 @@ typedef struct {
|
||||||
};
|
};
|
||||||
} SVDropTbBatchReq;
|
} SVDropTbBatchReq;
|
||||||
|
|
||||||
int32_t tEncodeSVDropTbBatchReq(SCoder* pCoder, const SVDropTbBatchReq* pReq);
|
int32_t tEncodeSVDropTbBatchReq(SEncoder* pCoder, const SVDropTbBatchReq* pReq);
|
||||||
int32_t tDecodeSVDropTbBatchReq(SCoder* pCoder, SVDropTbBatchReq* pReq);
|
int32_t tDecodeSVDropTbBatchReq(SDecoder* pCoder, SVDropTbBatchReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t nRsps;
|
int32_t nRsps;
|
||||||
|
@ -1638,8 +1640,8 @@ typedef struct {
|
||||||
};
|
};
|
||||||
} SVDropTbBatchRsp;
|
} SVDropTbBatchRsp;
|
||||||
|
|
||||||
int32_t tEncodeSVDropTbBatchRsp(SCoder* pCoder, const SVDropTbBatchRsp* pRsp);
|
int32_t tEncodeSVDropTbBatchRsp(SEncoder* pCoder, const SVDropTbBatchRsp* pRsp);
|
||||||
int32_t tDecodeSVDropTbBatchRsp(SCoder* pCoder, SVDropTbBatchRsp* pRsp);
|
int32_t tDecodeSVDropTbBatchRsp(SDecoder* pCoder, SVDropTbBatchRsp* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMsgHead head;
|
SMsgHead head;
|
||||||
|
@ -1821,14 +1823,14 @@ static FORCE_INLINE void tFreeClientHbBatchRsp(void* pRsp) {
|
||||||
int32_t tSerializeSClientHbBatchRsp(void* buf, int32_t bufLen, const SClientHbBatchRsp* pBatchRsp);
|
int32_t tSerializeSClientHbBatchRsp(void* buf, int32_t bufLen, const SClientHbBatchRsp* pBatchRsp);
|
||||||
int32_t tDeserializeSClientHbBatchRsp(void* buf, int32_t bufLen, SClientHbBatchRsp* pBatchRsp);
|
int32_t tDeserializeSClientHbBatchRsp(void* buf, int32_t bufLen, SClientHbBatchRsp* pBatchRsp);
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSKv(SCoder* pEncoder, const SKv* pKv) {
|
static FORCE_INLINE int32_t tEncodeSKv(SEncoder* pEncoder, const SKv* pKv) {
|
||||||
if (tEncodeI32(pEncoder, pKv->key) < 0) return -1;
|
if (tEncodeI32(pEncoder, pKv->key) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pKv->valueLen) < 0) return -1;
|
if (tEncodeI32(pEncoder, pKv->valueLen) < 0) return -1;
|
||||||
if (tEncodeBinary(pEncoder, (const char*)pKv->value, pKv->valueLen) < 0) return -1;
|
if (tEncodeBinary(pEncoder, (uint8_t*)pKv->value, pKv->valueLen) < 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeSKv(SCoder* pDecoder, SKv* pKv) {
|
static FORCE_INLINE int32_t tDecodeSKv(SDecoder* pDecoder, SKv* pKv) {
|
||||||
if (tDecodeI32(pDecoder, &pKv->key) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pKv->key) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pKv->valueLen) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pKv->valueLen) < 0) return -1;
|
||||||
pKv->value = taosMemoryMalloc(pKv->valueLen + 1);
|
pKv->value = taosMemoryMalloc(pKv->valueLen + 1);
|
||||||
|
@ -1837,13 +1839,13 @@ static FORCE_INLINE int32_t tDecodeSKv(SCoder* pDecoder, SKv* pKv) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSClientHbKey(SCoder* pEncoder, const SClientHbKey* pKey) {
|
static FORCE_INLINE int32_t tEncodeSClientHbKey(SEncoder* pEncoder, const SClientHbKey* pKey) {
|
||||||
if (tEncodeI64(pEncoder, pKey->tscRid) < 0) return -1;
|
if (tEncodeI64(pEncoder, pKey->tscRid) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pKey->connType) < 0) return -1;
|
if (tEncodeI8(pEncoder, pKey->connType) < 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeSClientHbKey(SCoder* pDecoder, SClientHbKey* pKey) {
|
static FORCE_INLINE int32_t tDecodeSClientHbKey(SDecoder* pDecoder, SClientHbKey* pKey) {
|
||||||
if (tDecodeI64(pDecoder, &pKey->tscRid) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pKey->tscRid) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pKey->connType) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pKey->connType) < 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2046,10 +2048,10 @@ typedef struct {
|
||||||
int32_t reserved;
|
int32_t reserved;
|
||||||
} SMqCMCommitOffsetRsp;
|
} SMqCMCommitOffsetRsp;
|
||||||
|
|
||||||
int32_t tEncodeSMqOffset(SCoder* encoder, const SMqOffset* pOffset);
|
int32_t tEncodeSMqOffset(SEncoder* encoder, const SMqOffset* pOffset);
|
||||||
int32_t tDecodeSMqOffset(SCoder* decoder, SMqOffset* pOffset);
|
int32_t tDecodeSMqOffset(SDecoder* decoder, SMqOffset* pOffset);
|
||||||
int32_t tEncodeSMqCMCommitOffsetReq(SCoder* encoder, const SMqCMCommitOffsetReq* pReq);
|
int32_t tEncodeSMqCMCommitOffsetReq(SEncoder* encoder, const SMqCMCommitOffsetReq* pReq);
|
||||||
int32_t tDecodeSMqCMCommitOffsetReq(SCoder* decoder, SMqCMCommitOffsetReq* pReq);
|
int32_t tDecodeSMqCMCommitOffsetReq(SDecoder* decoder, SMqCMCommitOffsetReq* pReq);
|
||||||
|
|
||||||
static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* pSchemaWrapper) {
|
static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* pSchemaWrapper) {
|
||||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
|
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
|
||||||
|
@ -2089,7 +2091,7 @@ static FORCE_INLINE void* taosDecodeSSchema(const void* buf, SSchema* pSchema) {
|
||||||
return (void*)buf;
|
return (void*)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSchema) {
|
static FORCE_INLINE int32_t tEncodeSSchema(SEncoder* pEncoder, const SSchema* pSchema) {
|
||||||
if (tEncodeI8(pEncoder, pSchema->type) < 0) return -1;
|
if (tEncodeI8(pEncoder, pSchema->type) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pSchema->flags) < 0) return -1;
|
if (tEncodeI8(pEncoder, pSchema->flags) < 0) return -1;
|
||||||
if (tEncodeI32v(pEncoder, pSchema->bytes) < 0) return -1;
|
if (tEncodeI32v(pEncoder, pSchema->bytes) < 0) return -1;
|
||||||
|
@ -2098,7 +2100,7 @@ static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSch
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeSSchema(SCoder* pDecoder, SSchema* pSchema) {
|
static FORCE_INLINE int32_t tDecodeSSchema(SDecoder* pDecoder, SSchema* pSchema) {
|
||||||
if (tDecodeI8(pDecoder, &pSchema->type) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pSchema->type) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pSchema->flags) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pSchema->flags) < 0) return -1;
|
||||||
if (tDecodeI32v(pDecoder, &pSchema->bytes) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pSchema->bytes) < 0) return -1;
|
||||||
|
@ -2131,7 +2133,7 @@ static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapp
|
||||||
return (void*)buf;
|
return (void*)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SCoder* pEncoder, const SSchemaWrapper* pSW) {
|
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSchemaWrapper* pSW) {
|
||||||
if (tEncodeI32v(pEncoder, pSW->nCols) < 0) return -1;
|
if (tEncodeI32v(pEncoder, pSW->nCols) < 0) return -1;
|
||||||
if (tEncodeI32v(pEncoder, pSW->sver) < 0) return -1;
|
if (tEncodeI32v(pEncoder, pSW->sver) < 0) return -1;
|
||||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||||
|
@ -2141,7 +2143,7 @@ static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SCoder* pEncoder, const SSchem
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SCoder* pDecoder, SSchemaWrapper* pSW) {
|
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWrapper* pSW) {
|
||||||
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
|
||||||
if (tDecodeI32v(pDecoder, &pSW->sver) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pSW->sver) < 0) return -1;
|
||||||
|
|
||||||
|
@ -2596,8 +2598,8 @@ typedef struct {
|
||||||
int64_t suid;
|
int64_t suid;
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
int32_t sver;
|
int32_t sver;
|
||||||
uint64_t nData;
|
uint32_t nData;
|
||||||
const void* pData;
|
const uint8_t* pData;
|
||||||
SVCreateTbReq cTbReq;
|
SVCreateTbReq cTbReq;
|
||||||
} SVSubmitBlk;
|
} SVSubmitBlk;
|
||||||
|
|
||||||
|
@ -2610,8 +2612,8 @@ typedef struct {
|
||||||
};
|
};
|
||||||
} SVSubmitReq;
|
} SVSubmitReq;
|
||||||
|
|
||||||
int32_t tEncodeSVSubmitReq(SCoder* pCoder, const SVSubmitReq* pReq);
|
int32_t tEncodeSVSubmitReq(SEncoder* pCoder, const SVSubmitReq* pReq);
|
||||||
int32_t tDecodeSVSubmitReq(SCoder* pCoder, SVSubmitReq* pReq);
|
int32_t tDecodeSVSubmitReq(SDecoder* pCoder, SVSubmitReq* pReq);
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|
|
@ -51,201 +51,208 @@
|
||||||
#define TK_USER 33
|
#define TK_USER 33
|
||||||
#define TK_PRIVILEGE 34
|
#define TK_PRIVILEGE 34
|
||||||
#define TK_DROP 35
|
#define TK_DROP 35
|
||||||
#define TK_DNODE 36
|
#define TK_GRANT 36
|
||||||
#define TK_PORT 37
|
#define TK_ON 37
|
||||||
#define TK_NK_INTEGER 38
|
#define TK_TO 38
|
||||||
#define TK_DNODES 39
|
#define TK_REVOKE 39
|
||||||
#define TK_NK_IPTOKEN 40
|
#define TK_FROM 40
|
||||||
#define TK_LOCAL 41
|
#define TK_NK_COMMA 41
|
||||||
#define TK_QNODE 42
|
#define TK_READ 42
|
||||||
#define TK_ON 43
|
#define TK_WRITE 43
|
||||||
#define TK_BNODE 44
|
#define TK_NK_DOT 44
|
||||||
#define TK_SNODE 45
|
#define TK_DNODE 45
|
||||||
#define TK_MNODE 46
|
#define TK_PORT 46
|
||||||
#define TK_DATABASE 47
|
#define TK_NK_INTEGER 47
|
||||||
#define TK_USE 48
|
#define TK_DNODES 48
|
||||||
#define TK_IF 49
|
#define TK_NK_IPTOKEN 49
|
||||||
#define TK_NOT 50
|
#define TK_LOCAL 50
|
||||||
#define TK_EXISTS 51
|
#define TK_QNODE 51
|
||||||
#define TK_BUFFER 52
|
#define TK_BNODE 52
|
||||||
#define TK_CACHELAST 53
|
#define TK_SNODE 53
|
||||||
#define TK_COMP 54
|
#define TK_MNODE 54
|
||||||
#define TK_DAYS 55
|
#define TK_DATABASE 55
|
||||||
#define TK_NK_VARIABLE 56
|
#define TK_USE 56
|
||||||
#define TK_FSYNC 57
|
#define TK_IF 57
|
||||||
#define TK_MAXROWS 58
|
#define TK_NOT 58
|
||||||
#define TK_MINROWS 59
|
#define TK_EXISTS 59
|
||||||
#define TK_KEEP 60
|
#define TK_BUFFER 60
|
||||||
#define TK_PAGES 61
|
#define TK_CACHELAST 61
|
||||||
#define TK_PAGESIZE 62
|
#define TK_COMP 62
|
||||||
#define TK_PRECISION 63
|
#define TK_DAYS 63
|
||||||
#define TK_REPLICA 64
|
#define TK_NK_VARIABLE 64
|
||||||
#define TK_STRICT 65
|
#define TK_FSYNC 65
|
||||||
#define TK_WAL 66
|
#define TK_MAXROWS 66
|
||||||
#define TK_VGROUPS 67
|
#define TK_MINROWS 67
|
||||||
#define TK_SINGLE_STABLE 68
|
#define TK_KEEP 68
|
||||||
#define TK_RETENTIONS 69
|
#define TK_PAGES 69
|
||||||
#define TK_NK_COMMA 70
|
#define TK_PAGESIZE 70
|
||||||
#define TK_NK_COLON 71
|
#define TK_PRECISION 71
|
||||||
#define TK_TABLE 72
|
#define TK_REPLICA 72
|
||||||
#define TK_NK_LP 73
|
#define TK_STRICT 73
|
||||||
#define TK_NK_RP 74
|
#define TK_WAL 74
|
||||||
#define TK_STABLE 75
|
#define TK_VGROUPS 75
|
||||||
#define TK_ADD 76
|
#define TK_SINGLE_STABLE 76
|
||||||
#define TK_COLUMN 77
|
#define TK_RETENTIONS 77
|
||||||
#define TK_MODIFY 78
|
#define TK_NK_COLON 78
|
||||||
#define TK_RENAME 79
|
#define TK_TABLE 79
|
||||||
#define TK_TAG 80
|
#define TK_NK_LP 80
|
||||||
#define TK_SET 81
|
#define TK_NK_RP 81
|
||||||
#define TK_NK_EQ 82
|
#define TK_STABLE 82
|
||||||
#define TK_USING 83
|
#define TK_ADD 83
|
||||||
#define TK_TAGS 84
|
#define TK_COLUMN 84
|
||||||
#define TK_NK_DOT 85
|
#define TK_MODIFY 85
|
||||||
#define TK_COMMENT 86
|
#define TK_RENAME 86
|
||||||
#define TK_BOOL 87
|
#define TK_TAG 87
|
||||||
#define TK_TINYINT 88
|
#define TK_SET 88
|
||||||
#define TK_SMALLINT 89
|
#define TK_NK_EQ 89
|
||||||
#define TK_INT 90
|
#define TK_USING 90
|
||||||
#define TK_INTEGER 91
|
#define TK_TAGS 91
|
||||||
#define TK_BIGINT 92
|
#define TK_COMMENT 92
|
||||||
#define TK_FLOAT 93
|
#define TK_BOOL 93
|
||||||
#define TK_DOUBLE 94
|
#define TK_TINYINT 94
|
||||||
#define TK_BINARY 95
|
#define TK_SMALLINT 95
|
||||||
#define TK_TIMESTAMP 96
|
#define TK_INT 96
|
||||||
#define TK_NCHAR 97
|
#define TK_INTEGER 97
|
||||||
#define TK_UNSIGNED 98
|
#define TK_BIGINT 98
|
||||||
#define TK_JSON 99
|
#define TK_FLOAT 99
|
||||||
#define TK_VARCHAR 100
|
#define TK_DOUBLE 100
|
||||||
#define TK_MEDIUMBLOB 101
|
#define TK_BINARY 101
|
||||||
#define TK_BLOB 102
|
#define TK_TIMESTAMP 102
|
||||||
#define TK_VARBINARY 103
|
#define TK_NCHAR 103
|
||||||
#define TK_DECIMAL 104
|
#define TK_UNSIGNED 104
|
||||||
#define TK_DELAY 105
|
#define TK_JSON 105
|
||||||
#define TK_FILE_FACTOR 106
|
#define TK_VARCHAR 106
|
||||||
#define TK_NK_FLOAT 107
|
#define TK_MEDIUMBLOB 107
|
||||||
#define TK_ROLLUP 108
|
#define TK_BLOB 108
|
||||||
#define TK_TTL 109
|
#define TK_VARBINARY 109
|
||||||
#define TK_SMA 110
|
#define TK_DECIMAL 110
|
||||||
#define TK_SHOW 111
|
#define TK_DELAY 111
|
||||||
#define TK_DATABASES 112
|
#define TK_FILE_FACTOR 112
|
||||||
#define TK_TABLES 113
|
#define TK_NK_FLOAT 113
|
||||||
#define TK_STABLES 114
|
#define TK_ROLLUP 114
|
||||||
#define TK_MNODES 115
|
#define TK_TTL 115
|
||||||
#define TK_MODULES 116
|
#define TK_SMA 116
|
||||||
#define TK_QNODES 117
|
#define TK_SHOW 117
|
||||||
#define TK_FUNCTIONS 118
|
#define TK_DATABASES 118
|
||||||
#define TK_INDEXES 119
|
#define TK_TABLES 119
|
||||||
#define TK_FROM 120
|
#define TK_STABLES 120
|
||||||
#define TK_ACCOUNTS 121
|
#define TK_MNODES 121
|
||||||
#define TK_APPS 122
|
#define TK_MODULES 122
|
||||||
#define TK_CONNECTIONS 123
|
#define TK_QNODES 123
|
||||||
#define TK_LICENCE 124
|
#define TK_FUNCTIONS 124
|
||||||
#define TK_GRANTS 125
|
#define TK_INDEXES 125
|
||||||
#define TK_QUERIES 126
|
#define TK_ACCOUNTS 126
|
||||||
#define TK_SCORES 127
|
#define TK_APPS 127
|
||||||
#define TK_TOPICS 128
|
#define TK_CONNECTIONS 128
|
||||||
#define TK_VARIABLES 129
|
#define TK_LICENCE 129
|
||||||
#define TK_BNODES 130
|
#define TK_GRANTS 130
|
||||||
#define TK_SNODES 131
|
#define TK_QUERIES 131
|
||||||
#define TK_CLUSTER 132
|
#define TK_SCORES 132
|
||||||
#define TK_LIKE 133
|
#define TK_TOPICS 133
|
||||||
#define TK_INDEX 134
|
#define TK_VARIABLES 134
|
||||||
#define TK_FULLTEXT 135
|
#define TK_BNODES 135
|
||||||
#define TK_FUNCTION 136
|
#define TK_SNODES 136
|
||||||
#define TK_INTERVAL 137
|
#define TK_CLUSTER 137
|
||||||
#define TK_TOPIC 138
|
#define TK_TRANSACTIONS 138
|
||||||
#define TK_AS 139
|
#define TK_LIKE 139
|
||||||
#define TK_WITH 140
|
#define TK_INDEX 140
|
||||||
#define TK_SCHEMA 141
|
#define TK_FULLTEXT 141
|
||||||
#define TK_DESC 142
|
#define TK_FUNCTION 142
|
||||||
#define TK_DESCRIBE 143
|
#define TK_INTERVAL 143
|
||||||
#define TK_RESET 144
|
#define TK_TOPIC 144
|
||||||
#define TK_QUERY 145
|
#define TK_AS 145
|
||||||
#define TK_CACHE 146
|
#define TK_WITH 146
|
||||||
#define TK_EXPLAIN 147
|
#define TK_SCHEMA 147
|
||||||
#define TK_ANALYZE 148
|
#define TK_DESC 148
|
||||||
#define TK_VERBOSE 149
|
#define TK_DESCRIBE 149
|
||||||
#define TK_NK_BOOL 150
|
#define TK_RESET 150
|
||||||
#define TK_RATIO 151
|
#define TK_QUERY 151
|
||||||
#define TK_COMPACT 152
|
#define TK_CACHE 152
|
||||||
#define TK_VNODES 153
|
#define TK_EXPLAIN 153
|
||||||
#define TK_IN 154
|
#define TK_ANALYZE 154
|
||||||
#define TK_OUTPUTTYPE 155
|
#define TK_VERBOSE 155
|
||||||
#define TK_AGGREGATE 156
|
#define TK_NK_BOOL 156
|
||||||
#define TK_BUFSIZE 157
|
#define TK_RATIO 157
|
||||||
#define TK_STREAM 158
|
#define TK_COMPACT 158
|
||||||
#define TK_INTO 159
|
#define TK_VNODES 159
|
||||||
#define TK_TRIGGER 160
|
#define TK_IN 160
|
||||||
#define TK_AT_ONCE 161
|
#define TK_OUTPUTTYPE 161
|
||||||
#define TK_WINDOW_CLOSE 162
|
#define TK_AGGREGATE 162
|
||||||
#define TK_WATERMARK 163
|
#define TK_BUFSIZE 163
|
||||||
#define TK_KILL 164
|
#define TK_STREAM 164
|
||||||
#define TK_CONNECTION 165
|
#define TK_INTO 165
|
||||||
#define TK_MERGE 166
|
#define TK_TRIGGER 166
|
||||||
#define TK_VGROUP 167
|
#define TK_AT_ONCE 167
|
||||||
#define TK_REDISTRIBUTE 168
|
#define TK_WINDOW_CLOSE 168
|
||||||
#define TK_SPLIT 169
|
#define TK_WATERMARK 169
|
||||||
#define TK_SYNCDB 170
|
#define TK_KILL 170
|
||||||
#define TK_NULL 171
|
#define TK_CONNECTION 171
|
||||||
#define TK_NK_QUESTION 172
|
#define TK_TRANSACTION 172
|
||||||
#define TK_NK_ARROW 173
|
#define TK_MERGE 173
|
||||||
#define TK_ROWTS 174
|
#define TK_VGROUP 174
|
||||||
#define TK_TBNAME 175
|
#define TK_REDISTRIBUTE 175
|
||||||
#define TK_QSTARTTS 176
|
#define TK_SPLIT 176
|
||||||
#define TK_QENDTS 177
|
#define TK_SYNCDB 177
|
||||||
#define TK_WSTARTTS 178
|
#define TK_NULL 178
|
||||||
#define TK_WENDTS 179
|
#define TK_NK_QUESTION 179
|
||||||
#define TK_WDURATION 180
|
#define TK_NK_ARROW 180
|
||||||
#define TK_CAST 181
|
#define TK_ROWTS 181
|
||||||
#define TK_NOW 182
|
#define TK_TBNAME 182
|
||||||
#define TK_TODAY 183
|
#define TK_QSTARTTS 183
|
||||||
#define TK_TIMEZONE 184
|
#define TK_QENDTS 184
|
||||||
#define TK_COUNT 185
|
#define TK_WSTARTTS 185
|
||||||
#define TK_FIRST 186
|
#define TK_WENDTS 186
|
||||||
#define TK_LAST 187
|
#define TK_WDURATION 187
|
||||||
#define TK_LAST_ROW 188
|
#define TK_CAST 188
|
||||||
#define TK_BETWEEN 189
|
#define TK_NOW 189
|
||||||
#define TK_IS 190
|
#define TK_TODAY 190
|
||||||
#define TK_NK_LT 191
|
#define TK_TIMEZONE 191
|
||||||
#define TK_NK_GT 192
|
#define TK_COUNT 192
|
||||||
#define TK_NK_LE 193
|
#define TK_FIRST 193
|
||||||
#define TK_NK_GE 194
|
#define TK_LAST 194
|
||||||
#define TK_NK_NE 195
|
#define TK_LAST_ROW 195
|
||||||
#define TK_MATCH 196
|
#define TK_BETWEEN 196
|
||||||
#define TK_NMATCH 197
|
#define TK_IS 197
|
||||||
#define TK_CONTAINS 198
|
#define TK_NK_LT 198
|
||||||
#define TK_JOIN 199
|
#define TK_NK_GT 199
|
||||||
#define TK_INNER 200
|
#define TK_NK_LE 200
|
||||||
#define TK_SELECT 201
|
#define TK_NK_GE 201
|
||||||
#define TK_DISTINCT 202
|
#define TK_NK_NE 202
|
||||||
#define TK_WHERE 203
|
#define TK_MATCH 203
|
||||||
#define TK_PARTITION 204
|
#define TK_NMATCH 204
|
||||||
#define TK_BY 205
|
#define TK_CONTAINS 205
|
||||||
#define TK_SESSION 206
|
#define TK_JOIN 206
|
||||||
#define TK_STATE_WINDOW 207
|
#define TK_INNER 207
|
||||||
#define TK_SLIDING 208
|
#define TK_SELECT 208
|
||||||
#define TK_FILL 209
|
#define TK_DISTINCT 209
|
||||||
#define TK_VALUE 210
|
#define TK_WHERE 210
|
||||||
#define TK_NONE 211
|
#define TK_PARTITION 211
|
||||||
#define TK_PREV 212
|
#define TK_BY 212
|
||||||
#define TK_LINEAR 213
|
#define TK_SESSION 213
|
||||||
#define TK_NEXT 214
|
#define TK_STATE_WINDOW 214
|
||||||
#define TK_GROUP 215
|
#define TK_SLIDING 215
|
||||||
#define TK_HAVING 216
|
#define TK_FILL 216
|
||||||
#define TK_ORDER 217
|
#define TK_VALUE 217
|
||||||
#define TK_SLIMIT 218
|
#define TK_NONE 218
|
||||||
#define TK_SOFFSET 219
|
#define TK_PREV 219
|
||||||
#define TK_LIMIT 220
|
#define TK_LINEAR 220
|
||||||
#define TK_OFFSET 221
|
#define TK_NEXT 221
|
||||||
#define TK_ASC 222
|
#define TK_GROUP 222
|
||||||
#define TK_NULLS 223
|
#define TK_HAVING 223
|
||||||
#define TK_ID 224
|
#define TK_ORDER 224
|
||||||
#define TK_NK_BITNOT 225
|
#define TK_SLIMIT 225
|
||||||
#define TK_INSERT 226
|
#define TK_SOFFSET 226
|
||||||
#define TK_VALUES 227
|
#define TK_LIMIT 227
|
||||||
#define TK_IMPORT 228
|
#define TK_OFFSET 228
|
||||||
#define TK_NK_SEMI 229
|
#define TK_ASC 229
|
||||||
#define TK_FILE 230
|
#define TK_NULLS 230
|
||||||
|
#define TK_ID 231
|
||||||
|
#define TK_NK_BITNOT 232
|
||||||
|
#define TK_INSERT 233
|
||||||
|
#define TK_VALUES 234
|
||||||
|
#define TK_IMPORT 235
|
||||||
|
#define TK_NK_SEMI 236
|
||||||
|
#define TK_FILE 237
|
||||||
|
|
||||||
#define TK_NK_SPACE 300
|
#define TK_NK_SPACE 300
|
||||||
#define TK_NK_COMMENT 301
|
#define TK_NK_COMMENT 301
|
||||||
|
|
|
@ -165,15 +165,6 @@ int32_t qGetQualifiedTableIdList(void* pTableList, const char* tagCond, int32_t
|
||||||
*/
|
*/
|
||||||
int32_t qUpdateQueriedTableIdList(qTaskInfo_t tinfo, int64_t uid, int32_t type);
|
int32_t qUpdateQueriedTableIdList(qTaskInfo_t tinfo, int64_t uid, int32_t type);
|
||||||
|
|
||||||
/**
|
|
||||||
* release the query handle and decrease the reference count in cache
|
|
||||||
* @param pMgmt
|
|
||||||
* @param pQInfo
|
|
||||||
* @param freeHandle
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void** qReleaseTask(void* pMgmt, void* pQInfo, bool freeHandle);
|
|
||||||
|
|
||||||
void qProcessFetchRsp(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet);
|
void qProcessFetchRsp(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet);
|
||||||
|
|
||||||
int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, int32_t *resNum, SExplainExecInfo **pRes);
|
int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, int32_t *resNum, SExplainExecInfo **pRes);
|
||||||
|
|
|
@ -168,6 +168,9 @@ EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWin
|
||||||
int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
||||||
int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet);
|
int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet);
|
||||||
int32_t fmGetUdafExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
int32_t fmGetUdafExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
||||||
|
int32_t fmSetInvertFunc(int32_t funcId, SFuncExecFuncs* pFpSet);
|
||||||
|
int32_t fmSetNormalFunc(int32_t funcId, SFuncExecFuncs* pFpSet);
|
||||||
|
bool fmIsInvertible(int32_t funcId);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,6 +310,29 @@ typedef struct SCreateFunctionStmt {
|
||||||
int32_t bufSize;
|
int32_t bufSize;
|
||||||
} SCreateFunctionStmt;
|
} SCreateFunctionStmt;
|
||||||
|
|
||||||
|
typedef struct SDropFunctionStmt {
|
||||||
|
ENodeType type;
|
||||||
|
char funcName[TSDB_FUNC_NAME_LEN];
|
||||||
|
bool ignoreNotExists;
|
||||||
|
} SDropFunctionStmt;
|
||||||
|
|
||||||
|
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
|
||||||
|
|
||||||
|
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
|
||||||
|
#define PRIVILEGE_TYPE_READ PRIVILEGE_TYPE_MASK(1)
|
||||||
|
#define PRIVILEGE_TYPE_WRITE PRIVILEGE_TYPE_MASK(2)
|
||||||
|
|
||||||
|
#define PRIVILEGE_TYPE_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
||||||
|
|
||||||
|
typedef struct SGrantStmt {
|
||||||
|
ENodeType type;
|
||||||
|
char userName[TSDB_USER_LEN];
|
||||||
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
|
int64_t privileges;
|
||||||
|
} SGrantStmt;
|
||||||
|
|
||||||
|
typedef SGrantStmt SRevokeStmt;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -143,6 +143,8 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_REDISTRIBUTE_VGROUP_STMT,
|
QUERY_NODE_REDISTRIBUTE_VGROUP_STMT,
|
||||||
QUERY_NODE_SPLIT_VGROUP_STMT,
|
QUERY_NODE_SPLIT_VGROUP_STMT,
|
||||||
QUERY_NODE_SYNCDB_STMT,
|
QUERY_NODE_SYNCDB_STMT,
|
||||||
|
QUERY_NODE_GRANT_STMT,
|
||||||
|
QUERY_NODE_REVOKE_STMT,
|
||||||
QUERY_NODE_SHOW_DNODES_STMT,
|
QUERY_NODE_SHOW_DNODES_STMT,
|
||||||
QUERY_NODE_SHOW_MNODES_STMT,
|
QUERY_NODE_SHOW_MNODES_STMT,
|
||||||
QUERY_NODE_SHOW_MODULES_STMT,
|
QUERY_NODE_SHOW_MODULES_STMT,
|
||||||
|
@ -174,8 +176,10 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
|
QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
|
||||||
QUERY_NODE_SHOW_CREATE_TABLE_STMT,
|
QUERY_NODE_SHOW_CREATE_TABLE_STMT,
|
||||||
QUERY_NODE_SHOW_CREATE_STABLE_STMT,
|
QUERY_NODE_SHOW_CREATE_STABLE_STMT,
|
||||||
|
QUERY_NODE_SHOW_TRANSACTIONS_STMT,
|
||||||
QUERY_NODE_KILL_CONNECTION_STMT,
|
QUERY_NODE_KILL_CONNECTION_STMT,
|
||||||
QUERY_NODE_KILL_QUERY_STMT,
|
QUERY_NODE_KILL_QUERY_STMT,
|
||||||
|
QUERY_NODE_KILL_TRANSACTION_STMT,
|
||||||
|
|
||||||
// logic plan node
|
// logic plan node
|
||||||
QUERY_NODE_LOGIC_PLAN_SCAN,
|
QUERY_NODE_LOGIC_PLAN_SCAN,
|
||||||
|
|
|
@ -35,8 +35,6 @@ typedef struct SPlanContext {
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
int32_t placeholderNum;
|
int32_t placeholderNum;
|
||||||
void* pTransporter;
|
|
||||||
struct SCatalog* pCatalog;
|
|
||||||
char* pMsg;
|
char* pMsg;
|
||||||
int32_t msgLen;
|
int32_t msgLen;
|
||||||
} SPlanContext;
|
} SPlanContext;
|
||||||
|
|
|
@ -154,8 +154,8 @@ typedef struct {
|
||||||
} SStreamTask;
|
} SStreamTask;
|
||||||
|
|
||||||
SStreamTask* tNewSStreamTask(int64_t streamId);
|
SStreamTask* tNewSStreamTask(int64_t streamId);
|
||||||
int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask);
|
int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask);
|
||||||
int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask);
|
int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask);
|
||||||
void tFreeSStreamTask(SStreamTask* pTask);
|
void tFreeSStreamTask(SStreamTask* pTask);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -36,7 +36,7 @@ typedef struct SUpdateInfo {
|
||||||
|
|
||||||
SUpdateInfo *updateInfoInitP(SInterval* pInterval, int64_t watermark);
|
SUpdateInfo *updateInfoInitP(SInterval* pInterval, int64_t watermark);
|
||||||
SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark);
|
SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark);
|
||||||
bool isUpdated(SUpdateInfo *pInfo, tb_uid_t tableId, TSKEY ts);
|
bool updateInfoIsUpdated(SUpdateInfo *pInfo, tb_uid_t tableId, TSKEY ts);
|
||||||
void updateInfoDestroy(SUpdateInfo *pInfo);
|
void updateInfoDestroy(SUpdateInfo *pInfo);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -327,29 +327,32 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_TDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0601)
|
#define TSDB_CODE_TDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0601)
|
||||||
#define TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0602)
|
#define TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0602)
|
||||||
#define TSDB_CODE_TDB_TABLE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0603)
|
#define TSDB_CODE_TDB_TABLE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0603)
|
||||||
#define TSDB_CODE_TDB_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0604)
|
#define TSDB_CODE_TDB_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0604)
|
||||||
#define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0605)
|
#define TSDB_CODE_TDB_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0605)
|
||||||
#define TSDB_CODE_TDB_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0606)
|
#define TSDB_CODE_TDB_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0606)
|
||||||
#define TSDB_CODE_TDB_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0607)
|
#define TSDB_CODE_TDB_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0607)
|
||||||
#define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608)
|
#define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0608)
|
||||||
#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609)
|
#define TSDB_CODE_TDB_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0609)
|
||||||
#define TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE TAOS_DEF_ERROR_CODE(0, 0x060A)
|
#define TSDB_CODE_TDB_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x060A)
|
||||||
#define TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x060B)
|
#define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x060B)
|
||||||
#define TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x060C)
|
#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x060C)
|
||||||
#define TSDB_CODE_TDB_INVALID_ACTION TAOS_DEF_ERROR_CODE(0, 0x060D)
|
#define TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE TAOS_DEF_ERROR_CODE(0, 0x060D)
|
||||||
#define TSDB_CODE_TDB_INVALID_CREATE_TB_MSG TAOS_DEF_ERROR_CODE(0, 0x060E)
|
#define TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x060E)
|
||||||
#define TSDB_CODE_TDB_NO_TABLE_DATA_IN_MEM TAOS_DEF_ERROR_CODE(0, 0x060F)
|
#define TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x060F)
|
||||||
#define TSDB_CODE_TDB_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0610)
|
#define TSDB_CODE_TDB_INVALID_ACTION TAOS_DEF_ERROR_CODE(0, 0x0600)
|
||||||
#define TSDB_CODE_TDB_TABLE_RECONFIGURE TAOS_DEF_ERROR_CODE(0, 0x0611)
|
#define TSDB_CODE_TDB_INVALID_CREATE_TB_MSG TAOS_DEF_ERROR_CODE(0, 0x0601)
|
||||||
#define TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO TAOS_DEF_ERROR_CODE(0, 0x0612)
|
#define TSDB_CODE_TDB_NO_TABLE_DATA_IN_MEM TAOS_DEF_ERROR_CODE(0, 0x0602)
|
||||||
#define TSDB_CODE_TDB_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0613)
|
#define TSDB_CODE_TDB_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0613)
|
||||||
#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614)
|
#define TSDB_CODE_TDB_TABLE_RECONFIGURE TAOS_DEF_ERROR_CODE(0, 0x0614)
|
||||||
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615)
|
#define TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO TAOS_DEF_ERROR_CODE(0, 0x0615)
|
||||||
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616)
|
#define TSDB_CODE_TDB_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0616)
|
||||||
#define TSDB_CODE_TDB_TABLE_RECREATED TAOS_DEF_ERROR_CODE(0, 0x0617)
|
#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0617)
|
||||||
#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0618)
|
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0618)
|
||||||
#define TSDB_CODE_TDB_NO_SMA_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x0619)
|
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0619)
|
||||||
#define TSDB_CODE_TDB_INVALID_SMA_STAT TAOS_DEF_ERROR_CODE(0, 0x0620)
|
#define TSDB_CODE_TDB_TABLE_RECREATED TAOS_DEF_ERROR_CODE(0, 0x061A)
|
||||||
|
#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x061B)
|
||||||
|
#define TSDB_CODE_TDB_NO_SMA_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x061C)
|
||||||
|
#define TSDB_CODE_TDB_INVALID_SMA_STAT TAOS_DEF_ERROR_CODE(0, 0x062D)
|
||||||
|
|
||||||
// query
|
// query
|
||||||
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
||||||
|
@ -629,6 +632,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_PAR_INVALID_FIRST_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2641)
|
#define TSDB_CODE_PAR_INVALID_FIRST_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2641)
|
||||||
#define TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN TAOS_DEF_ERROR_CODE(0, 0x2642)
|
#define TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN TAOS_DEF_ERROR_CODE(0, 0x2642)
|
||||||
#define TSDB_CODE_PAR_INVALID_TAGS_NUM TAOS_DEF_ERROR_CODE(0, 0x2643)
|
#define TSDB_CODE_PAR_INVALID_TAGS_NUM TAOS_DEF_ERROR_CODE(0, 0x2643)
|
||||||
|
#define TSDB_CODE_PAR_PERMISSION_DENIED TAOS_DEF_ERROR_CODE(0, 0x2644)
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||||
|
|
|
@ -24,6 +24,29 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct SEncoderNode SEncoderNode;
|
||||||
|
typedef struct SDecoderNode SDecoderNode;
|
||||||
|
|
||||||
|
typedef struct SCoderMem {
|
||||||
|
struct SCoderMem* next;
|
||||||
|
} SCoderMem;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t* data;
|
||||||
|
uint32_t size;
|
||||||
|
uint32_t pos;
|
||||||
|
SCoderMem* mList;
|
||||||
|
SEncoderNode* eStack;
|
||||||
|
} SEncoder;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const uint8_t* data;
|
||||||
|
uint32_t size;
|
||||||
|
uint32_t pos;
|
||||||
|
SCoderMem* mList;
|
||||||
|
SDecoderNode* dStack;
|
||||||
|
} SDecoder;
|
||||||
|
|
||||||
#define tPut(TYPE, BUF, VAL) ((TYPE*)(BUF))[0] = (VAL)
|
#define tPut(TYPE, BUF, VAL) ((TYPE*)(BUF))[0] = (VAL)
|
||||||
#define tGet(TYPE, BUF, VAL) (VAL) = ((TYPE*)(BUF))[0]
|
#define tGet(TYPE, BUF, VAL) (VAL) = ((TYPE*)(BUF))[0]
|
||||||
|
|
||||||
|
@ -51,131 +74,84 @@ extern "C" {
|
||||||
#define tRGet32 tRPut32
|
#define tRGet32 tRPut32
|
||||||
#define tRGet64 tRPut64
|
#define tRGet64 tRPut64
|
||||||
|
|
||||||
typedef enum { TD_ENCODER, TD_DECODER } td_coder_t;
|
|
||||||
|
|
||||||
#define CODER_NODE_FIELDS \
|
|
||||||
uint8_t* data; \
|
|
||||||
int32_t size; \
|
|
||||||
int32_t pos;
|
|
||||||
|
|
||||||
struct SCoderNode {
|
|
||||||
TD_SLIST_NODE(SCoderNode);
|
|
||||||
CODER_NODE_FIELDS
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct SCoderMem {
|
|
||||||
struct SCoderMem* next;
|
|
||||||
} SCoderMem;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
td_coder_t type;
|
|
||||||
td_endian_t endian;
|
|
||||||
SCoderMem* mList;
|
|
||||||
CODER_NODE_FIELDS
|
|
||||||
TD_SLIST(SCoderNode) stack;
|
|
||||||
} SCoder;
|
|
||||||
|
|
||||||
#define TD_CODER_POS(CODER) ((CODER)->pos)
|
#define TD_CODER_POS(CODER) ((CODER)->pos)
|
||||||
#define TD_CODER_CURRENT(CODER) ((CODER)->data + (CODER)->pos)
|
#define TD_CODER_CURRENT(CODER) ((CODER)->data + (CODER)->pos)
|
||||||
#define TD_CODER_MOVE_POS(CODER, MOVE) ((CODER)->pos += (MOVE))
|
#define TD_CODER_MOVE_POS(CODER, MOVE) ((CODER)->pos += (MOVE))
|
||||||
#define TD_CODER_CHECK_CAPACITY_FAILED(CODER, EXPSIZE) (((CODER)->size - (CODER)->pos) < (EXPSIZE))
|
#define TD_CODER_CHECK_CAPACITY_FAILED(CODER, EXPSIZE) (((CODER)->size - (CODER)->pos) < (EXPSIZE))
|
||||||
static FORCE_INLINE void* tCoderMalloc(SCoder* pCoder, int32_t size) {
|
|
||||||
void* ptr = NULL;
|
|
||||||
SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(SCoderMem*) + size);
|
|
||||||
if (pMem) {
|
|
||||||
pMem->next = pCoder->mList;
|
|
||||||
pCoder->mList = pMem;
|
|
||||||
ptr = (void*)&pMem[1];
|
|
||||||
}
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define tEncodeSize(E, S, SIZE, RET) \
|
#define tEncodeSize(E, S, SIZE, RET) \
|
||||||
do { \
|
do { \
|
||||||
SCoder coder = {0}; \
|
SEncoder coder = {0}; \
|
||||||
RET = 0; \
|
tEncoderInit(&coder, NULL, 0); \
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER); \
|
|
||||||
if ((E)(&coder, S) == 0) { \
|
if ((E)(&coder, S) == 0) { \
|
||||||
SIZE = coder.pos; \
|
SIZE = coder.pos; \
|
||||||
|
RET = 0; \
|
||||||
} else { \
|
} else { \
|
||||||
RET = -1; \
|
RET = -1; \
|
||||||
} \
|
} \
|
||||||
tCoderClear(&coder); \
|
tEncoderClear(&coder); \
|
||||||
} while (0)
|
} while (0)
|
||||||
// #define tEncodeSize(E, S, SIZE) \
|
|
||||||
// ({ \
|
|
||||||
// SCoder coder = {0}; \
|
|
||||||
// int ret = 0; \
|
|
||||||
// tCoderInit(&coder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER); \
|
|
||||||
// if ((E)(&coder, S) == 0) { \
|
|
||||||
// SIZE = coder.pos; \
|
|
||||||
// } else { \
|
|
||||||
// ret = -1; \
|
|
||||||
// } \
|
|
||||||
// tCoderClear(&coder); \
|
|
||||||
// ret; \
|
|
||||||
// })
|
|
||||||
|
|
||||||
void tCoderInit(SCoder* pCoder, td_endian_t endian, uint8_t* data, int32_t size, td_coder_t type);
|
static void* tEncoderMalloc(SEncoder* pCoder, int32_t size);
|
||||||
void tCoderClear(SCoder* pCoder);
|
static void* tDecoderMalloc(SDecoder* pCoder, int32_t size);
|
||||||
|
|
||||||
/* ------------------------ ENCODE ------------------------ */
|
/* ------------------------ ENCODE ------------------------ */
|
||||||
int32_t tStartEncode(SCoder* pEncoder);
|
void tEncoderInit(SEncoder* pCoder, uint8_t* data, uint32_t size);
|
||||||
void tEndEncode(SCoder* pEncoder);
|
void tEncoderClear(SEncoder* pCoder);
|
||||||
static int32_t tEncodeU8(SCoder* pEncoder, uint8_t val);
|
int32_t tStartEncode(SEncoder* pCoder);
|
||||||
static int32_t tEncodeI8(SCoder* pEncoder, int8_t val);
|
void tEndEncode(SEncoder* pCoder);
|
||||||
static int32_t tEncodeU16(SCoder* pEncoder, uint16_t val);
|
static int32_t tEncodeU8(SEncoder* pCoder, uint8_t val);
|
||||||
static int32_t tEncodeI16(SCoder* pEncoder, int16_t val);
|
static int32_t tEncodeI8(SEncoder* pCoder, int8_t val);
|
||||||
static int32_t tEncodeU32(SCoder* pEncoder, uint32_t val);
|
static int32_t tEncodeU16(SEncoder* pCoder, uint16_t val);
|
||||||
static int32_t tEncodeI32(SCoder* pEncoder, int32_t val);
|
static int32_t tEncodeI16(SEncoder* pCoder, int16_t val);
|
||||||
static int32_t tEncodeU64(SCoder* pEncoder, uint64_t val);
|
static int32_t tEncodeU32(SEncoder* pCoder, uint32_t val);
|
||||||
static int32_t tEncodeI64(SCoder* pEncoder, int64_t val);
|
static int32_t tEncodeI32(SEncoder* pCoder, int32_t val);
|
||||||
static int32_t tEncodeU16v(SCoder* pEncoder, uint16_t val);
|
static int32_t tEncodeU64(SEncoder* pCoder, uint64_t val);
|
||||||
static int32_t tEncodeI16v(SCoder* pEncoder, int16_t val);
|
static int32_t tEncodeI64(SEncoder* pCoder, int64_t val);
|
||||||
static int32_t tEncodeU32v(SCoder* pEncoder, uint32_t val);
|
static int32_t tEncodeU16v(SEncoder* pCoder, uint16_t val);
|
||||||
static int32_t tEncodeI32v(SCoder* pEncoder, int32_t val);
|
static int32_t tEncodeI16v(SEncoder* pCoder, int16_t val);
|
||||||
static int32_t tEncodeU64v(SCoder* pEncoder, uint64_t val);
|
static int32_t tEncodeU32v(SEncoder* pCoder, uint32_t val);
|
||||||
static int32_t tEncodeI64v(SCoder* pEncoder, int64_t val);
|
static int32_t tEncodeI32v(SEncoder* pCoder, int32_t val);
|
||||||
static int32_t tEncodeFloat(SCoder* pEncoder, float val);
|
static int32_t tEncodeU64v(SEncoder* pCoder, uint64_t val);
|
||||||
static int32_t tEncodeDouble(SCoder* pEncoder, double val);
|
static int32_t tEncodeI64v(SEncoder* pCoder, int64_t val);
|
||||||
static int32_t tEncodeBinary(SCoder* pEncoder, const void* val, uint64_t len);
|
static int32_t tEncodeFloat(SEncoder* pCoder, float val);
|
||||||
static int32_t tEncodeCStrWithLen(SCoder* pEncoder, const char* val, uint64_t len);
|
static int32_t tEncodeDouble(SEncoder* pCoder, double val);
|
||||||
static int32_t tEncodeCStr(SCoder* pEncoder, const char* val);
|
static int32_t tEncodeBinary(SEncoder* pCoder, const uint8_t* val, uint32_t len);
|
||||||
|
static int32_t tEncodeCStrWithLen(SEncoder* pCoder, const char* val, uint32_t len);
|
||||||
|
static int32_t tEncodeCStr(SEncoder* pCoder, const char* val);
|
||||||
|
|
||||||
/* ------------------------ DECODE ------------------------ */
|
/* ------------------------ DECODE ------------------------ */
|
||||||
int32_t tStartDecode(SCoder* pDecoder);
|
void tDecoderInit(SDecoder* pCoder, const uint8_t* data, uint32_t size);
|
||||||
void tEndDecode(SCoder* pDecoder);
|
void tDecoderClear(SDecoder* SDecoder);
|
||||||
static bool tDecodeIsEnd(SCoder* pCoder);
|
int32_t tStartDecode(SDecoder* pCoder);
|
||||||
static int32_t tDecodeU8(SCoder* pDecoder, uint8_t* val);
|
void tEndDecode(SDecoder* pCoder);
|
||||||
static int32_t tDecodeI8(SCoder* pDecoder, int8_t* val);
|
static bool tDecodeIsEnd(SDecoder* pCoder);
|
||||||
static int32_t tDecodeU16(SCoder* pDecoder, uint16_t* val);
|
static int32_t tDecodeU8(SDecoder* pCoder, uint8_t* val);
|
||||||
static int32_t tDecodeI16(SCoder* pDecoder, int16_t* val);
|
static int32_t tDecodeI8(SDecoder* pCoder, int8_t* val);
|
||||||
static int32_t tDecodeU32(SCoder* pDecoder, uint32_t* val);
|
static int32_t tDecodeU16(SDecoder* pCoder, uint16_t* val);
|
||||||
static int32_t tDecodeI32(SCoder* pDecoder, int32_t* val);
|
static int32_t tDecodeI16(SDecoder* pCoder, int16_t* val);
|
||||||
static int32_t tDecodeU64(SCoder* pDecoder, uint64_t* val);
|
static int32_t tDecodeU32(SDecoder* pCoder, uint32_t* val);
|
||||||
static int32_t tDecodeI64(SCoder* pDecoder, int64_t* val);
|
static int32_t tDecodeI32(SDecoder* pCoder, int32_t* val);
|
||||||
static int32_t tDecodeU16v(SCoder* pDecoder, uint16_t* val);
|
static int32_t tDecodeU64(SDecoder* pCoder, uint64_t* val);
|
||||||
static int32_t tDecodeI16v(SCoder* pDecoder, int16_t* val);
|
static int32_t tDecodeI64(SDecoder* pCoder, int64_t* val);
|
||||||
static int32_t tDecodeU32v(SCoder* pDecoder, uint32_t* val);
|
static int32_t tDecodeU16v(SDecoder* pCoder, uint16_t* val);
|
||||||
static int32_t tDecodeI32v(SCoder* pDecoder, int32_t* val);
|
static int32_t tDecodeI16v(SDecoder* pCoder, int16_t* val);
|
||||||
static int32_t tDecodeU64v(SCoder* pDecoder, uint64_t* val);
|
static int32_t tDecodeU32v(SDecoder* pCoder, uint32_t* val);
|
||||||
static int32_t tDecodeI64v(SCoder* pDecoder, int64_t* val);
|
static int32_t tDecodeI32v(SDecoder* pCoder, int32_t* val);
|
||||||
static int32_t tDecodeFloat(SCoder* pDecoder, float* val);
|
static int32_t tDecodeU64v(SDecoder* pCoder, uint64_t* val);
|
||||||
static int32_t tDecodeDouble(SCoder* pDecoder, double* val);
|
static int32_t tDecodeI64v(SDecoder* pCoder, int64_t* val);
|
||||||
static int32_t tDecodeBinary(SCoder* pDecoder, const void** val, uint64_t* len);
|
static int32_t tDecodeFloat(SDecoder* pCoder, float* val);
|
||||||
static int32_t tDecodeCStrAndLen(SCoder* pDecoder, const char** val, uint64_t* len);
|
static int32_t tDecodeDouble(SDecoder* pCoder, double* val);
|
||||||
static int32_t tDecodeCStr(SCoder* pDecoder, const char** val);
|
static int32_t tDecodeBinary(SDecoder* pCoder, const uint8_t** val, uint32_t* len);
|
||||||
static int32_t tDecodeCStrTo(SCoder* pDecoder, char* val);
|
static int32_t tDecodeCStrAndLen(SDecoder* pCoder, const char** val, uint32_t* len);
|
||||||
|
static int32_t tDecodeCStr(SDecoder* pCoder, const char** val);
|
||||||
|
static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val);
|
||||||
|
|
||||||
/* ------------------------ IMPL ------------------------ */
|
/* ------------------------ IMPL ------------------------ */
|
||||||
#define TD_ENCODE_MACRO(CODER, VAL, TYPE, BITS) \
|
#define TD_ENCODE_MACRO(CODER, VAL, TYPE, BITS) \
|
||||||
if ((CODER)->data) { \
|
if ((CODER)->data) { \
|
||||||
if (TD_CODER_CHECK_CAPACITY_FAILED(CODER, sizeof(VAL))) return -1; \
|
if (TD_CODER_CHECK_CAPACITY_FAILED(CODER, sizeof(VAL))) return -1; \
|
||||||
if (TD_RT_ENDIAN() == (CODER)->endian) { \
|
|
||||||
tPut(TYPE, TD_CODER_CURRENT(CODER), (VAL)); \
|
tPut(TYPE, TD_CODER_CURRENT(CODER), (VAL)); \
|
||||||
} else { \
|
|
||||||
tRPut##BITS(TD_CODER_CURRENT(CODER), &(VAL)); \
|
|
||||||
} \
|
|
||||||
} \
|
} \
|
||||||
TD_CODER_MOVE_POS(CODER, sizeof(VAL)); \
|
TD_CODER_MOVE_POS(CODER, sizeof(VAL)); \
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -200,12 +176,7 @@ static int32_t tDecodeCStrTo(SCoder* pDecoder, char* val);
|
||||||
|
|
||||||
#define TD_DECODE_MACRO(CODER, PVAL, TYPE, BITS) \
|
#define TD_DECODE_MACRO(CODER, PVAL, TYPE, BITS) \
|
||||||
if (TD_CODER_CHECK_CAPACITY_FAILED(CODER, sizeof(*(PVAL)))) return -1; \
|
if (TD_CODER_CHECK_CAPACITY_FAILED(CODER, sizeof(*(PVAL)))) return -1; \
|
||||||
if (TD_RT_ENDIAN() == (CODER)->endian) { \
|
|
||||||
tGet(TYPE, TD_CODER_CURRENT(CODER), *(PVAL)); \
|
tGet(TYPE, TD_CODER_CURRENT(CODER), *(PVAL)); \
|
||||||
} else { \
|
|
||||||
tRGet##BITS(PVAL, TD_CODER_CURRENT(CODER)); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
TD_CODER_MOVE_POS(CODER, sizeof(*(PVAL))); \
|
TD_CODER_MOVE_POS(CODER, sizeof(*(PVAL))); \
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -217,140 +188,134 @@ static int32_t tDecodeCStrTo(SCoder* pDecoder, char* val);
|
||||||
TYPE tval = TD_CODER_CURRENT(CODER)[0]; \
|
TYPE tval = TD_CODER_CURRENT(CODER)[0]; \
|
||||||
if (tval < ENCODE_LIMIT) { \
|
if (tval < ENCODE_LIMIT) { \
|
||||||
*(PVAL) |= (tval << (7 * i)); \
|
*(PVAL) |= (tval << (7 * i)); \
|
||||||
TD_CODER_MOVE_POS(pDecoder, 1); \
|
TD_CODER_MOVE_POS(pCoder, 1); \
|
||||||
break; \
|
break; \
|
||||||
} else { \
|
} else { \
|
||||||
*(PVAL) |= (((tval) & (ENCODE_LIMIT - 1)) << (7 * i)); \
|
*(PVAL) |= (((tval) & (ENCODE_LIMIT - 1)) << (7 * i)); \
|
||||||
i++; \
|
i++; \
|
||||||
TD_CODER_MOVE_POS(pDecoder, 1); \
|
TD_CODER_MOVE_POS(pCoder, 1); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// 8
|
// 8
|
||||||
static FORCE_INLINE int32_t tEncodeU8(SCoder* pEncoder, uint8_t val) {
|
static FORCE_INLINE int32_t tEncodeU8(SEncoder* pCoder, uint8_t val) {
|
||||||
if (pEncoder->data) {
|
if (pCoder->data) {
|
||||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1;
|
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, sizeof(val))) return -1;
|
||||||
tPut(uint8_t, TD_CODER_CURRENT(pEncoder), val);
|
tPut(uint8_t, TD_CODER_CURRENT(pCoder), val);
|
||||||
}
|
}
|
||||||
TD_CODER_MOVE_POS(pEncoder, sizeof(val));
|
TD_CODER_MOVE_POS(pCoder, sizeof(val));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeI8(SCoder* pEncoder, int8_t val) {
|
static FORCE_INLINE int32_t tEncodeI8(SEncoder* pCoder, int8_t val) {
|
||||||
if (pEncoder->data) {
|
if (pCoder->data) {
|
||||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1;
|
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, sizeof(val))) return -1;
|
||||||
tPut(int8_t, TD_CODER_CURRENT(pEncoder), val);
|
tPut(int8_t, TD_CODER_CURRENT(pCoder), val);
|
||||||
}
|
}
|
||||||
TD_CODER_MOVE_POS(pEncoder, sizeof(val));
|
TD_CODER_MOVE_POS(pCoder, sizeof(val));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 16
|
// 16
|
||||||
static FORCE_INLINE int32_t tEncodeU16(SCoder* pEncoder, uint16_t val) { TD_ENCODE_MACRO(pEncoder, val, uint16_t, 16); }
|
static FORCE_INLINE int32_t tEncodeU16(SEncoder* pCoder, uint16_t val) { TD_ENCODE_MACRO(pCoder, val, uint16_t, 16); }
|
||||||
static FORCE_INLINE int32_t tEncodeI16(SCoder* pEncoder, int16_t val) { TD_ENCODE_MACRO(pEncoder, val, int16_t, 16); }
|
static FORCE_INLINE int32_t tEncodeI16(SEncoder* pCoder, int16_t val) { TD_ENCODE_MACRO(pCoder, val, int16_t, 16); }
|
||||||
// 32
|
// 32
|
||||||
static FORCE_INLINE int32_t tEncodeU32(SCoder* pEncoder, uint32_t val) { TD_ENCODE_MACRO(pEncoder, val, uint32_t, 32); }
|
static FORCE_INLINE int32_t tEncodeU32(SEncoder* pCoder, uint32_t val) { TD_ENCODE_MACRO(pCoder, val, uint32_t, 32); }
|
||||||
static FORCE_INLINE int32_t tEncodeI32(SCoder* pEncoder, int32_t val) { TD_ENCODE_MACRO(pEncoder, val, int32_t, 32); }
|
static FORCE_INLINE int32_t tEncodeI32(SEncoder* pCoder, int32_t val) { TD_ENCODE_MACRO(pCoder, val, int32_t, 32); }
|
||||||
// 64
|
// 64
|
||||||
static FORCE_INLINE int32_t tEncodeU64(SCoder* pEncoder, uint64_t val) { TD_ENCODE_MACRO(pEncoder, val, uint64_t, 64); }
|
static FORCE_INLINE int32_t tEncodeU64(SEncoder* pCoder, uint64_t val) { TD_ENCODE_MACRO(pCoder, val, uint64_t, 64); }
|
||||||
static FORCE_INLINE int32_t tEncodeI64(SCoder* pEncoder, int64_t val) { TD_ENCODE_MACRO(pEncoder, val, int64_t, 64); }
|
static FORCE_INLINE int32_t tEncodeI64(SEncoder* pCoder, int64_t val) { TD_ENCODE_MACRO(pCoder, val, int64_t, 64); }
|
||||||
// 16v
|
// 16v
|
||||||
static FORCE_INLINE int32_t tEncodeU16v(SCoder* pEncoder, uint16_t val) { TD_ENCODE_VARIANT_MACRO(pEncoder, val); }
|
static FORCE_INLINE int32_t tEncodeU16v(SEncoder* pCoder, uint16_t val) { TD_ENCODE_VARIANT_MACRO(pCoder, val); }
|
||||||
static FORCE_INLINE int32_t tEncodeI16v(SCoder* pEncoder, int16_t val) {
|
static FORCE_INLINE int32_t tEncodeI16v(SEncoder* pCoder, int16_t val) {
|
||||||
return tEncodeU16v(pEncoder, ZIGZAGE(int16_t, val));
|
return tEncodeU16v(pCoder, ZIGZAGE(int16_t, val));
|
||||||
}
|
}
|
||||||
// 32v
|
// 32v
|
||||||
static FORCE_INLINE int32_t tEncodeU32v(SCoder* pEncoder, uint32_t val) { TD_ENCODE_VARIANT_MACRO(pEncoder, val); }
|
static FORCE_INLINE int32_t tEncodeU32v(SEncoder* pCoder, uint32_t val) { TD_ENCODE_VARIANT_MACRO(pCoder, val); }
|
||||||
static FORCE_INLINE int32_t tEncodeI32v(SCoder* pEncoder, int32_t val) {
|
static FORCE_INLINE int32_t tEncodeI32v(SEncoder* pCoder, int32_t val) {
|
||||||
return tEncodeU32v(pEncoder, ZIGZAGE(int32_t, val));
|
return tEncodeU32v(pCoder, ZIGZAGE(int32_t, val));
|
||||||
}
|
}
|
||||||
// 64v
|
// 64v
|
||||||
static FORCE_INLINE int32_t tEncodeU64v(SCoder* pEncoder, uint64_t val) { TD_ENCODE_VARIANT_MACRO(pEncoder, val); }
|
static FORCE_INLINE int32_t tEncodeU64v(SEncoder* pCoder, uint64_t val) { TD_ENCODE_VARIANT_MACRO(pCoder, val); }
|
||||||
static FORCE_INLINE int32_t tEncodeI64v(SCoder* pEncoder, int64_t val) {
|
static FORCE_INLINE int32_t tEncodeI64v(SEncoder* pCoder, int64_t val) {
|
||||||
return tEncodeU64v(pEncoder, ZIGZAGE(int64_t, val));
|
return tEncodeU64v(pCoder, ZIGZAGE(int64_t, val));
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeFloat(SCoder* pEncoder, float val) {
|
static FORCE_INLINE int32_t tEncodeFloat(SEncoder* pCoder, float val) {
|
||||||
union {
|
union {
|
||||||
uint32_t ui;
|
uint32_t ui;
|
||||||
float f;
|
float f;
|
||||||
} v;
|
} v;
|
||||||
v.f = val;
|
v.f = val;
|
||||||
|
|
||||||
return tEncodeU32(pEncoder, v.ui);
|
return tEncodeU32(pCoder, v.ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeDouble(SCoder* pEncoder, double val) {
|
static FORCE_INLINE int32_t tEncodeDouble(SEncoder* pCoder, double val) {
|
||||||
union {
|
union {
|
||||||
uint64_t ui;
|
uint64_t ui;
|
||||||
double d;
|
double d;
|
||||||
} v;
|
} v;
|
||||||
v.d = val;
|
v.d = val;
|
||||||
|
|
||||||
return tEncodeU64(pEncoder, v.ui);
|
return tEncodeU64(pCoder, v.ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeBinary(SCoder* pEncoder, const void* val, uint64_t len) {
|
static FORCE_INLINE int32_t tEncodeBinary(SEncoder* pCoder, const uint8_t* val, uint32_t len) {
|
||||||
if (tEncodeU64v(pEncoder, len) < 0) return -1;
|
if (tEncodeU32v(pCoder, len) < 0) return -1;
|
||||||
if (pEncoder->data) {
|
if (pCoder->data) {
|
||||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pEncoder, len)) return -1;
|
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, len)) return -1;
|
||||||
memcpy(TD_CODER_CURRENT(pEncoder), val, len);
|
memcpy(TD_CODER_CURRENT(pCoder), val, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
TD_CODER_MOVE_POS(pEncoder, len);
|
TD_CODER_MOVE_POS(pCoder, len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeCStrWithLen(SCoder* pEncoder, const char* val, uint64_t len) {
|
static FORCE_INLINE int32_t tEncodeCStrWithLen(SEncoder* pCoder, const char* val, uint32_t len) {
|
||||||
return tEncodeBinary(pEncoder, (void*)val, len + 1);
|
return tEncodeBinary(pCoder, (uint8_t*)val, len + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeCStr(SCoder* pEncoder, const char* val) {
|
static FORCE_INLINE int32_t tEncodeCStr(SEncoder* pCoder, const char* val) {
|
||||||
return tEncodeCStrWithLen(pEncoder, val, (uint64_t)strlen(val));
|
return tEncodeCStrWithLen(pCoder, val, (uint32_t)strlen(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------ FOR DECODER ------------------------ */
|
/* ------------------------ FOR DECODER ------------------------ */
|
||||||
// 8
|
// 8
|
||||||
static FORCE_INLINE int32_t tDecodeU8(SCoder* pDecoder, uint8_t* val) {
|
static FORCE_INLINE int32_t tDecodeU8(SDecoder* pCoder, uint8_t* val) {
|
||||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pDecoder, sizeof(*val))) return -1;
|
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, sizeof(*val))) return -1;
|
||||||
tGet(uint8_t, TD_CODER_CURRENT(pDecoder), *val);
|
tGet(uint8_t, TD_CODER_CURRENT(pCoder), *val);
|
||||||
TD_CODER_MOVE_POS(pDecoder, sizeof(*val));
|
TD_CODER_MOVE_POS(pCoder, sizeof(*val));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeI8(SCoder* pDecoder, int8_t* val) {
|
static FORCE_INLINE int32_t tDecodeI8(SDecoder* pCoder, int8_t* val) {
|
||||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pDecoder, sizeof(*val))) return -1;
|
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, sizeof(*val))) return -1;
|
||||||
tGet(int8_t, TD_CODER_CURRENT(pDecoder), *val);
|
tGet(int8_t, TD_CODER_CURRENT(pCoder), *val);
|
||||||
TD_CODER_MOVE_POS(pDecoder, sizeof(*val));
|
TD_CODER_MOVE_POS(pCoder, sizeof(*val));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 16
|
// 16
|
||||||
static FORCE_INLINE int32_t tDecodeU16(SCoder* pDecoder, uint16_t* val) {
|
static FORCE_INLINE int32_t tDecodeU16(SDecoder* pCoder, uint16_t* val) { TD_DECODE_MACRO(pCoder, val, uint16_t, 16); }
|
||||||
TD_DECODE_MACRO(pDecoder, val, uint16_t, 16);
|
static FORCE_INLINE int32_t tDecodeI16(SDecoder* pCoder, int16_t* val) { TD_DECODE_MACRO(pCoder, val, int16_t, 16); }
|
||||||
}
|
|
||||||
static FORCE_INLINE int32_t tDecodeI16(SCoder* pDecoder, int16_t* val) { TD_DECODE_MACRO(pDecoder, val, int16_t, 16); }
|
|
||||||
// 32
|
// 32
|
||||||
static FORCE_INLINE int32_t tDecodeU32(SCoder* pDecoder, uint32_t* val) {
|
static FORCE_INLINE int32_t tDecodeU32(SDecoder* pCoder, uint32_t* val) { TD_DECODE_MACRO(pCoder, val, uint32_t, 32); }
|
||||||
TD_DECODE_MACRO(pDecoder, val, uint32_t, 32);
|
static FORCE_INLINE int32_t tDecodeI32(SDecoder* pCoder, int32_t* val) { TD_DECODE_MACRO(pCoder, val, int32_t, 32); }
|
||||||
}
|
|
||||||
static FORCE_INLINE int32_t tDecodeI32(SCoder* pDecoder, int32_t* val) { TD_DECODE_MACRO(pDecoder, val, int32_t, 32); }
|
|
||||||
// 64
|
// 64
|
||||||
static FORCE_INLINE int32_t tDecodeU64(SCoder* pDecoder, uint64_t* val) {
|
static FORCE_INLINE int32_t tDecodeU64(SDecoder* pCoder, uint64_t* val) { TD_DECODE_MACRO(pCoder, val, uint64_t, 64); }
|
||||||
TD_DECODE_MACRO(pDecoder, val, uint64_t, 64);
|
static FORCE_INLINE int32_t tDecodeI64(SDecoder* pCoder, int64_t* val) { TD_DECODE_MACRO(pCoder, val, int64_t, 64); }
|
||||||
}
|
|
||||||
static FORCE_INLINE int32_t tDecodeI64(SCoder* pDecoder, int64_t* val) { TD_DECODE_MACRO(pDecoder, val, int64_t, 64); }
|
|
||||||
|
|
||||||
// 16v
|
// 16v
|
||||||
static FORCE_INLINE int32_t tDecodeU16v(SCoder* pDecoder, uint16_t* val) {
|
static FORCE_INLINE int32_t tDecodeU16v(SDecoder* pCoder, uint16_t* val) {
|
||||||
TD_DECODE_VARIANT_MACRO(pDecoder, val, uint16_t);
|
TD_DECODE_VARIANT_MACRO(pCoder, val, uint16_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeI16v(SCoder* pDecoder, int16_t* val) {
|
static FORCE_INLINE int32_t tDecodeI16v(SDecoder* pCoder, int16_t* val) {
|
||||||
uint16_t tval;
|
uint16_t tval;
|
||||||
if (tDecodeU16v(pDecoder, &tval) < 0) {
|
if (tDecodeU16v(pCoder, &tval) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*val = ZIGZAGD(int16_t, tval);
|
*val = ZIGZAGD(int16_t, tval);
|
||||||
|
@ -358,13 +323,13 @@ static FORCE_INLINE int32_t tDecodeI16v(SCoder* pDecoder, int16_t* val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 32v
|
// 32v
|
||||||
static FORCE_INLINE int32_t tDecodeU32v(SCoder* pDecoder, uint32_t* val) {
|
static FORCE_INLINE int32_t tDecodeU32v(SDecoder* pCoder, uint32_t* val) {
|
||||||
TD_DECODE_VARIANT_MACRO(pDecoder, val, uint32_t);
|
TD_DECODE_VARIANT_MACRO(pCoder, val, uint32_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeI32v(SCoder* pDecoder, int32_t* val) {
|
static FORCE_INLINE int32_t tDecodeI32v(SDecoder* pCoder, int32_t* val) {
|
||||||
uint32_t tval;
|
uint32_t tval;
|
||||||
if (tDecodeU32v(pDecoder, &tval) < 0) {
|
if (tDecodeU32v(pCoder, &tval) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*val = ZIGZAGD(int32_t, tval);
|
*val = ZIGZAGD(int32_t, tval);
|
||||||
|
@ -372,26 +337,26 @@ static FORCE_INLINE int32_t tDecodeI32v(SCoder* pDecoder, int32_t* val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 64v
|
// 64v
|
||||||
static FORCE_INLINE int32_t tDecodeU64v(SCoder* pDecoder, uint64_t* val) {
|
static FORCE_INLINE int32_t tDecodeU64v(SDecoder* pCoder, uint64_t* val) {
|
||||||
TD_DECODE_VARIANT_MACRO(pDecoder, val, uint64_t);
|
TD_DECODE_VARIANT_MACRO(pCoder, val, uint64_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeI64v(SCoder* pDecoder, int64_t* val) {
|
static FORCE_INLINE int32_t tDecodeI64v(SDecoder* pCoder, int64_t* val) {
|
||||||
uint64_t tval;
|
uint64_t tval;
|
||||||
if (tDecodeU64v(pDecoder, &tval) < 0) {
|
if (tDecodeU64v(pCoder, &tval) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*val = ZIGZAGD(int64_t, tval);
|
*val = ZIGZAGD(int64_t, tval);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeFloat(SCoder* pDecoder, float* val) {
|
static FORCE_INLINE int32_t tDecodeFloat(SDecoder* pCoder, float* val) {
|
||||||
union {
|
union {
|
||||||
uint32_t ui;
|
uint32_t ui;
|
||||||
float f;
|
float f;
|
||||||
} v;
|
} v;
|
||||||
|
|
||||||
if (tDecodeU32(pDecoder, &(v.ui)) < 0) {
|
if (tDecodeU32(pCoder, &(v.ui)) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,13 +364,13 @@ static FORCE_INLINE int32_t tDecodeFloat(SCoder* pDecoder, float* val) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeDouble(SCoder* pDecoder, double* val) {
|
static FORCE_INLINE int32_t tDecodeDouble(SDecoder* pCoder, double* val) {
|
||||||
union {
|
union {
|
||||||
uint64_t ui;
|
uint64_t ui;
|
||||||
double d;
|
double d;
|
||||||
} v;
|
} v;
|
||||||
|
|
||||||
if (tDecodeU64(pDecoder, &(v.ui)) < 0) {
|
if (tDecodeU64(pCoder, &(v.ui)) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,62 +378,84 @@ static FORCE_INLINE int32_t tDecodeDouble(SCoder* pDecoder, double* val) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeBinary(SCoder* pDecoder, const void** val, uint64_t* len) {
|
static FORCE_INLINE int32_t tDecodeBinary(SDecoder* pCoder, const uint8_t** val, uint32_t* len) {
|
||||||
if (tDecodeU64v(pDecoder, len) < 0) return -1;
|
if (tDecodeU32v(pCoder, len) < 0) return -1;
|
||||||
|
|
||||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pDecoder, *len)) return -1;
|
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, *len)) return -1;
|
||||||
if (val) {
|
if (val) {
|
||||||
*val = (void*)TD_CODER_CURRENT(pDecoder);
|
*val = (uint8_t*)TD_CODER_CURRENT(pCoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
TD_CODER_MOVE_POS(pDecoder, *len);
|
TD_CODER_MOVE_POS(pCoder, *len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeCStrAndLen(SCoder* pDecoder, const char** val, uint64_t* len) {
|
static FORCE_INLINE int32_t tDecodeCStrAndLen(SDecoder* pCoder, const char** val, uint32_t* len) {
|
||||||
if (tDecodeBinary(pDecoder, (const void**)val, len) < 0) return -1;
|
if (tDecodeBinary(pCoder, (const uint8_t**)val, len) < 0) return -1;
|
||||||
(*len) -= 1;
|
(*len) -= 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeCStr(SCoder* pDecoder, const char** val) {
|
static FORCE_INLINE int32_t tDecodeCStr(SDecoder* pCoder, const char** val) {
|
||||||
uint64_t len;
|
uint32_t len;
|
||||||
return tDecodeCStrAndLen(pDecoder, val, &len);
|
return tDecodeCStrAndLen(pCoder, val, &len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tDecodeCStrTo(SCoder* pDecoder, char* val) {
|
static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val) {
|
||||||
const char* pStr;
|
const char* pStr;
|
||||||
uint64_t len;
|
uint32_t len;
|
||||||
if (tDecodeCStrAndLen(pDecoder, &pStr, &len) < 0) return -1;
|
if (tDecodeCStrAndLen(pCoder, &pStr, &len) < 0) return -1;
|
||||||
|
|
||||||
memcpy(val, pStr, len + 1);
|
memcpy(val, pStr, len + 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeBinaryAlloc(SCoder* pDecoder, void** val, uint64_t* len) {
|
static FORCE_INLINE int32_t tDecodeBinaryAlloc(SDecoder* pCoder, void** val, uint64_t* len) {
|
||||||
if (tDecodeU64v(pDecoder, len) < 0) return -1;
|
if (tDecodeU64v(pCoder, len) < 0) return -1;
|
||||||
|
|
||||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pDecoder, *len)) return -1;
|
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, *len)) return -1;
|
||||||
*val = taosMemoryMalloc(*len);
|
*val = taosMemoryMalloc(*len);
|
||||||
if (*val == NULL) return -1;
|
if (*val == NULL) return -1;
|
||||||
memcpy(*val, TD_CODER_CURRENT(pDecoder), *len);
|
memcpy(*val, TD_CODER_CURRENT(pCoder), *len);
|
||||||
|
|
||||||
TD_CODER_MOVE_POS(pDecoder, *len);
|
TD_CODER_MOVE_POS(pCoder, *len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeCStrAndLenAlloc(SCoder* pDecoder, char** val, uint64_t* len) {
|
static FORCE_INLINE int32_t tDecodeCStrAndLenAlloc(SDecoder* pCoder, char** val, uint64_t* len) {
|
||||||
if (tDecodeBinaryAlloc(pDecoder, (void**)val, len) < 0) return -1;
|
if (tDecodeBinaryAlloc(pCoder, (void**)val, len) < 0) return -1;
|
||||||
(*len) -= 1;
|
(*len) -= 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeCStrAlloc(SCoder* pDecoder, char** val) {
|
static FORCE_INLINE int32_t tDecodeCStrAlloc(SDecoder* pCoder, char** val) {
|
||||||
uint64_t len;
|
uint64_t len;
|
||||||
return tDecodeCStrAndLenAlloc(pDecoder, val, &len);
|
return tDecodeCStrAndLenAlloc(pCoder, val, &len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE bool tDecodeIsEnd(SCoder* pCoder) { return (pCoder->size == pCoder->pos); }
|
static FORCE_INLINE bool tDecodeIsEnd(SDecoder* pCoder) { return (pCoder->size == pCoder->pos); }
|
||||||
|
|
||||||
|
static FORCE_INLINE void* tEncoderMalloc(SEncoder* pCoder, int32_t size) {
|
||||||
|
void* p = NULL;
|
||||||
|
SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size);
|
||||||
|
if (pMem) {
|
||||||
|
pMem->next = pCoder->mList;
|
||||||
|
pCoder->mList = pMem;
|
||||||
|
p = (void*)&pMem[1];
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void* tDecoderMalloc(SDecoder* pCoder, int32_t size) {
|
||||||
|
void* p = NULL;
|
||||||
|
SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size);
|
||||||
|
if (pMem) {
|
||||||
|
pMem->next = pCoder->mList;
|
||||||
|
pCoder->mList = pMem;
|
||||||
|
p = (void*)&pMem[1];
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,8 +162,7 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj*
|
||||||
int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb) {
|
int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb) {
|
||||||
STscObj* pTscObj = pRequest->pTscObj;
|
STscObj* pTscObj = pRequest->pTscObj;
|
||||||
|
|
||||||
SParseContext cxt = {
|
SParseContext cxt = {.requestId = pRequest->requestId,
|
||||||
.requestId = pRequest->requestId,
|
|
||||||
.acctId = pTscObj->acctId,
|
.acctId = pTscObj->acctId,
|
||||||
.db = pRequest->pDb,
|
.db = pRequest->pDb,
|
||||||
.topicQuery = topicQuery,
|
.topicQuery = topicQuery,
|
||||||
|
@ -173,7 +172,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC
|
||||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||||
.pTransporter = pTscObj->pAppInfo->pTransporter,
|
.pTransporter = pTscObj->pAppInfo->pTransporter,
|
||||||
.pStmtCb = pStmtCb,
|
.pStmtCb = pStmtCb,
|
||||||
};
|
.pUser = pTscObj->user};
|
||||||
|
|
||||||
cxt.mgmtEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
cxt.mgmtEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
||||||
int32_t code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &cxt.pCatalog);
|
int32_t code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &cxt.pCatalog);
|
||||||
|
@ -232,11 +231,15 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
|
||||||
.mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp),
|
.mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp),
|
||||||
.pAstRoot = pQuery->pRoot,
|
.pAstRoot = pQuery->pRoot,
|
||||||
.showRewrite = pQuery->showRewrite,
|
.showRewrite = pQuery->showRewrite,
|
||||||
.pTransporter = pRequest->pTscObj->pAppInfo->pTransporter,
|
|
||||||
.pMsg = pRequest->msgBuf,
|
.pMsg = pRequest->msgBuf,
|
||||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||||
.placeholderNum = pQuery->placeholderNum};
|
.placeholderNum = pQuery->placeholderNum};
|
||||||
int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &cxt.pCatalog);
|
SEpSet mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp);
|
||||||
|
SCatalog* pCatalog = NULL;
|
||||||
|
int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = catalogGetQnodeList(pCatalog, pRequest->pTscObj->pAppInfo->pTransporter, &mgmtEpSet, pNodeList);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = qCreateQueryPlan(&cxt, pPlan, pNodeList);
|
code = qCreateQueryPlan(&cxt, pPlan, pNodeList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1724,13 +1724,13 @@ cleanup:
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision, bool dataFormat) {
|
TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision) {
|
||||||
SRequestObj* request = createRequest(taos, NULL, NULL, TSDB_SQL_INSERT);
|
SRequestObj* request = createRequest(taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
if(!request){
|
if(!request){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSmlHandle* info = smlBuildSmlInfo(taos, request, protocol, precision, dataFormat);
|
SSmlHandle* info = smlBuildSmlInfo(taos, request, protocol, precision, false);
|
||||||
if(!info){
|
if(!info){
|
||||||
return (TAOS_RES*)request;
|
return (TAOS_RES*)request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -547,21 +547,21 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
||||||
req.offsets = (SMqOffset*)offsets->container.pData;
|
req.offsets = (SMqOffset*)offsets->container.pData;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCoder encoder;
|
SEncoder encoder;
|
||||||
|
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER);
|
tEncoderInit(&encoder, NULL, 0);
|
||||||
tEncodeSMqCMCommitOffsetReq(&encoder, &req);
|
tEncodeSMqCMCommitOffsetReq(&encoder, &req);
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
void* buf = taosMemoryMalloc(tlen);
|
void* buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, tlen, TD_ENCODER);
|
tEncoderInit(&encoder, buf, tlen);
|
||||||
tEncodeSMqCMCommitOffsetReq(&encoder, &req);
|
tEncodeSMqCMCommitOffsetReq(&encoder, &req);
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_MND_MQ_COMMIT_OFFSET);
|
pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_MND_MQ_COMMIT_OFFSET);
|
||||||
if (pRequest == NULL) {
|
if (pRequest == NULL) {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -101,6 +101,7 @@ void qmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
||||||
dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, qmProcessQueryMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, qmProcessQueryMsg, QNODE_HANDLE);
|
||||||
dmSetMsgHandle(pWrapper, TDMT_VND_FETCH, qmProcessFetchMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_FETCH, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
dmSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, qmProcessFetchMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
|
dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
|
|
||||||
dmSetMsgHandle(pWrapper, TDMT_VND_RES_READY, qmProcessFetchMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_RES_READY, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
dmSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, qmProcessFetchMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
|
|
|
@ -115,7 +115,10 @@ typedef enum {
|
||||||
TRN_TYPE_STB_SCOPE_END,
|
TRN_TYPE_STB_SCOPE_END,
|
||||||
} ETrnType;
|
} ETrnType;
|
||||||
|
|
||||||
typedef enum { TRN_POLICY_ROLLBACK = 0, TRN_POLICY_RETRY = 1 } ETrnPolicy;
|
typedef enum {
|
||||||
|
TRN_POLICY_ROLLBACK = 0,
|
||||||
|
TRN_POLICY_RETRY = 1,
|
||||||
|
} ETrnPolicy;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DND_REASON_ONLINE = 0,
|
DND_REASON_ONLINE = 0,
|
||||||
|
@ -131,6 +134,15 @@ typedef enum {
|
||||||
DND_REASON_OTHERS
|
DND_REASON_OTHERS
|
||||||
} EDndReason;
|
} EDndReason;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CONSUMER_UPDATE__TOUCH = 1,
|
||||||
|
CONSUMER_UPDATE__ADD,
|
||||||
|
CONSUMER_UPDATE__REMOVE,
|
||||||
|
CONSUMER_UPDATE__LOST,
|
||||||
|
CONSUMER_UPDATE__RECOVER,
|
||||||
|
CONSUMER_UPDATE__MODIFY,
|
||||||
|
} ECsmUpdateType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t id;
|
int32_t id;
|
||||||
ETrnStage stage;
|
ETrnStage stage;
|
||||||
|
@ -386,7 +398,6 @@ typedef struct {
|
||||||
int32_t codeSize;
|
int32_t codeSize;
|
||||||
char* pComment;
|
char* pComment;
|
||||||
char* pCode;
|
char* pCode;
|
||||||
char pData[];
|
|
||||||
} SFuncObj;
|
} SFuncObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -425,18 +436,8 @@ typedef struct {
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
} SMqOffsetObj;
|
} SMqOffsetObj;
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSMqOffsetObj(void** buf, const SMqOffsetObj* pOffset) {
|
int32_t tEncodeSMqOffsetObj(void** buf, const SMqOffsetObj* pOffset);
|
||||||
int32_t tlen = 0;
|
void* tDecodeSMqOffsetObj(void* buf, SMqOffsetObj* pOffset);
|
||||||
tlen += taosEncodeString(buf, pOffset->key);
|
|
||||||
tlen += taosEncodeFixedI64(buf, pOffset->offset);
|
|
||||||
return tlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void* tDecodeSMqOffsetObj(void* buf, SMqOffsetObj* pOffset) {
|
|
||||||
buf = taosDecodeStringTo(buf, pOffset->key);
|
|
||||||
buf = taosDecodeFixedI64(buf, &pOffset->offset);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TOPIC_FNAME_LEN];
|
char name[TSDB_TOPIC_FNAME_LEN];
|
||||||
|
@ -459,15 +460,6 @@ typedef struct {
|
||||||
SSchemaWrapper schema;
|
SSchemaWrapper schema;
|
||||||
} SMqTopicObj;
|
} SMqTopicObj;
|
||||||
|
|
||||||
enum {
|
|
||||||
CONSUMER_UPDATE__TOUCH = 1,
|
|
||||||
CONSUMER_UPDATE__ADD,
|
|
||||||
CONSUMER_UPDATE__REMOVE,
|
|
||||||
CONSUMER_UPDATE__LOST,
|
|
||||||
CONSUMER_UPDATE__RECOVER,
|
|
||||||
CONSUMER_UPDATE__MODIFY,
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t consumerId;
|
int64_t consumerId;
|
||||||
char cgroup[TSDB_CGROUP_LEN];
|
char cgroup[TSDB_CGROUP_LEN];
|
||||||
|
@ -475,10 +467,8 @@ typedef struct {
|
||||||
int8_t updateType; // used only for update
|
int8_t updateType; // used only for update
|
||||||
int32_t epoch;
|
int32_t epoch;
|
||||||
int32_t status;
|
int32_t status;
|
||||||
// hbStatus is not applicable to serialization
|
int32_t hbStatus; // hbStatus is not applicable to serialization
|
||||||
int32_t hbStatus;
|
SRWLatch lock; // lock is used for topics update
|
||||||
// lock is used for topics update
|
|
||||||
SRWLatch lock;
|
|
||||||
SArray* currentTopics; // SArray<char*>
|
SArray* currentTopics; // SArray<char*>
|
||||||
SArray* rebNewTopics; // SArray<char*>
|
SArray* rebNewTopics; // SArray<char*>
|
||||||
SArray* rebRemovedTopics; // SArray<char*>
|
SArray* rebRemovedTopics; // SArray<char*>
|
||||||
|
@ -492,7 +482,6 @@ typedef struct {
|
||||||
int64_t upTime;
|
int64_t upTime;
|
||||||
int64_t subscribeTime;
|
int64_t subscribeTime;
|
||||||
int64_t rebalanceTime;
|
int64_t rebalanceTime;
|
||||||
|
|
||||||
} SMqConsumerObj;
|
} SMqConsumerObj;
|
||||||
|
|
||||||
SMqConsumerObj* tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_LEN]);
|
SMqConsumerObj* tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_LEN]);
|
||||||
|
@ -593,7 +582,6 @@ typedef struct {
|
||||||
int32_t vgNum;
|
int32_t vgNum;
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
int8_t status;
|
int8_t status;
|
||||||
// int32_t sqlLen;
|
|
||||||
int8_t createdBy; // STREAM_CREATED_BY__USER or SMA
|
int8_t createdBy; // STREAM_CREATED_BY__USER or SMA
|
||||||
int32_t fixedSinkVgId; // 0 for shuffle
|
int32_t fixedSinkVgId; // 0 for shuffle
|
||||||
int64_t smaId; // 0 for unused
|
int64_t smaId; // 0 for unused
|
||||||
|
@ -606,8 +594,8 @@ typedef struct {
|
||||||
SSchemaWrapper outputSchema;
|
SSchemaWrapper outputSchema;
|
||||||
} SStreamObj;
|
} SStreamObj;
|
||||||
|
|
||||||
int32_t tEncodeSStreamObj(SCoder* pEncoder, const SStreamObj* pObj);
|
int32_t tEncodeSStreamObj(SEncoder* pEncoder, const SStreamObj* pObj);
|
||||||
int32_t tDecodeSStreamObj(SCoder* pDecoder, SStreamObj* pObj);
|
int32_t tDecodeSStreamObj(SDecoder* pDecoder, SStreamObj* pObj);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ void mndReleaseUser(SMnode *pMnode, SUserObj *pUser);
|
||||||
|
|
||||||
// for trans test
|
// for trans test
|
||||||
SSdbRaw *mndUserActionEncode(SUserObj *pUser);
|
SSdbRaw *mndUserActionEncode(SUserObj *pUser);
|
||||||
int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp, int32_t *pRspLen);
|
int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp,
|
||||||
|
int32_t *pRspLen);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#include "mndCluster.h"
|
#include "mndCluster.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
|
|
||||||
#define TSDB_CLUSTER_VER_NUMBE 1
|
#define CLUSTER_VER_NUMBE 1
|
||||||
#define TSDB_CLUSTER_RESERVE_SIZE 64
|
#define CLUSTER_RESERVE_SIZE 64
|
||||||
|
|
||||||
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster);
|
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster);
|
||||||
static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw);
|
static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw);
|
||||||
|
@ -30,14 +30,16 @@ static int32_t mndRetrieveClusters(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock
|
||||||
static void mndCancelGetNextCluster(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextCluster(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
int32_t mndInitCluster(SMnode *pMnode) {
|
int32_t mndInitCluster(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_CLUSTER,
|
SSdbTable table = {
|
||||||
|
.sdbType = SDB_CLUSTER,
|
||||||
.keyType = SDB_KEY_INT64,
|
.keyType = SDB_KEY_INT64,
|
||||||
.deployFp = (SdbDeployFp)mndCreateDefaultCluster,
|
.deployFp = (SdbDeployFp)mndCreateDefaultCluster,
|
||||||
.encodeFp = (SdbEncodeFp)mndClusterActionEncode,
|
.encodeFp = (SdbEncodeFp)mndClusterActionEncode,
|
||||||
.decodeFp = (SdbDecodeFp)mndClusterActionDecode,
|
.decodeFp = (SdbDecodeFp)mndClusterActionDecode,
|
||||||
.insertFp = (SdbInsertFp)mndClusterActionInsert,
|
.insertFp = (SdbInsertFp)mndClusterActionInsert,
|
||||||
.updateFp = (SdbUpdateFp)mndClusterActionUpdate,
|
.updateFp = (SdbUpdateFp)mndClusterActionUpdate,
|
||||||
.deleteFp = (SdbDeleteFp)mndClusterActionDelete};
|
.deleteFp = (SdbDeleteFp)mndClusterActionDelete,
|
||||||
|
};
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndRetrieveClusters);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndRetrieveClusters);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndCancelGetNextCluster);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndCancelGetNextCluster);
|
||||||
|
@ -79,19 +81,19 @@ int64_t mndGetClusterId(SMnode *pMnode) {
|
||||||
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster) {
|
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_CLUSTER, TSDB_CLUSTER_VER_NUMBE, sizeof(SClusterObj) + TSDB_CLUSTER_RESERVE_SIZE);
|
SSdbRaw *pRaw = sdbAllocRaw(SDB_CLUSTER, CLUSTER_VER_NUMBE, sizeof(SClusterObj) + CLUSTER_RESERVE_SIZE);
|
||||||
if (pRaw == NULL) goto CLUSTER_ENCODE_OVER;
|
if (pRaw == NULL) goto _OVER;
|
||||||
|
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
SDB_SET_INT64(pRaw, dataPos, pCluster->id, CLUSTER_ENCODE_OVER)
|
SDB_SET_INT64(pRaw, dataPos, pCluster->id, _OVER)
|
||||||
SDB_SET_INT64(pRaw, dataPos, pCluster->createdTime, CLUSTER_ENCODE_OVER)
|
SDB_SET_INT64(pRaw, dataPos, pCluster->createdTime, _OVER)
|
||||||
SDB_SET_INT64(pRaw, dataPos, pCluster->updateTime, CLUSTER_ENCODE_OVER)
|
SDB_SET_INT64(pRaw, dataPos, pCluster->updateTime, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pCluster->name, TSDB_CLUSTER_ID_LEN, CLUSTER_ENCODE_OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pCluster->name, TSDB_CLUSTER_ID_LEN, _OVER)
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_CLUSTER_RESERVE_SIZE, CLUSTER_ENCODE_OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, CLUSTER_RESERVE_SIZE, _OVER)
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
CLUSTER_ENCODE_OVER:
|
_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("cluster:%" PRId64 ", failed to encode to raw:%p since %s", pCluster->id, pRaw, terrstr());
|
mError("cluster:%" PRId64 ", failed to encode to raw:%p since %s", pCluster->id, pRaw, terrstr());
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
|
@ -106,29 +108,29 @@ static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
int8_t sver = 0;
|
int8_t sver = 0;
|
||||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto CLUSTER_DECODE_OVER;
|
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER;
|
||||||
|
|
||||||
if (sver != TSDB_CLUSTER_VER_NUMBE) {
|
if (sver != CLUSTER_VER_NUMBE) {
|
||||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||||
goto CLUSTER_DECODE_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSdbRow *pRow = sdbAllocRow(sizeof(SClusterObj));
|
SSdbRow *pRow = sdbAllocRow(sizeof(SClusterObj));
|
||||||
if (pRow == NULL) goto CLUSTER_DECODE_OVER;
|
if (pRow == NULL) goto _OVER;
|
||||||
|
|
||||||
SClusterObj *pCluster = sdbGetRowObj(pRow);
|
SClusterObj *pCluster = sdbGetRowObj(pRow);
|
||||||
if (pCluster == NULL) goto CLUSTER_DECODE_OVER;
|
if (pCluster == NULL) goto _OVER;
|
||||||
|
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pCluster->id, CLUSTER_DECODE_OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pCluster->id, _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pCluster->createdTime, CLUSTER_DECODE_OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pCluster->createdTime, _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pCluster->updateTime, CLUSTER_DECODE_OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pCluster->updateTime, _OVER)
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pCluster->name, TSDB_CLUSTER_ID_LEN, CLUSTER_DECODE_OVER)
|
SDB_GET_BINARY(pRaw, dataPos, pCluster->name, TSDB_CLUSTER_ID_LEN, _OVER)
|
||||||
SDB_GET_RESERVE(pRaw, dataPos, TSDB_CLUSTER_RESERVE_SIZE, CLUSTER_DECODE_OVER)
|
SDB_GET_RESERVE(pRaw, dataPos, CLUSTER_RESERVE_SIZE, _OVER)
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
CLUSTER_DECODE_OVER:
|
_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("cluster:%" PRId64 ", failed to decode from raw:%p since %s", pCluster->id, pRaw, terrstr());
|
mError("cluster:%" PRId64 ", failed to decode from raw:%p since %s", pCluster->id, pRaw, terrstr());
|
||||||
taosMemoryFreeClear(pRow);
|
taosMemoryFreeClear(pRow);
|
||||||
|
@ -161,7 +163,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
|
||||||
|
|
||||||
int32_t code = taosGetSystemUUID(clusterObj.name, TSDB_CLUSTER_ID_LEN);
|
int32_t code = taosGetSystemUUID(clusterObj.name, TSDB_CLUSTER_ID_LEN);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
strcpy(clusterObj.name, "tdengine2.0");
|
strcpy(clusterObj.name, "tdengine3.0");
|
||||||
mError("failed to get name from system, set to default val %s", clusterObj.name);
|
mError("failed to get name from system, set to default val %s", clusterObj.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,8 +192,8 @@ static int32_t mndRetrieveClusters(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock
|
||||||
if (pShow->pIter == NULL) break;
|
if (pShow->pIter == NULL) break;
|
||||||
|
|
||||||
cols = 0;
|
cols = 0;
|
||||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char*) &pCluster->id, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pCluster->id, false);
|
||||||
|
|
||||||
char buf[tListLen(pCluster->name) + VARSTR_HEADER_SIZE] = {0};
|
char buf[tListLen(pCluster->name) + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, pCluster->name, pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(buf, pCluster->name, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
@ -200,7 +202,7 @@ static int32_t mndRetrieveClusters(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock
|
||||||
colDataAppend(pColInfo, numOfRows, buf, false);
|
colDataAppend(pColInfo, numOfRows, buf, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char*) &pCluster->createdTime, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pCluster->createdTime, false);
|
||||||
|
|
||||||
sdbRelease(pSdb, pCluster);
|
sdbRelease(pSdb, pCluster);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
|
|
@ -13,12 +13,14 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndDef.h"
|
#include "mndDef.h"
|
||||||
#include "mndConsumer.h"
|
#include "mndConsumer.h"
|
||||||
|
|
||||||
SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_LEN]) {
|
SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_LEN]) {
|
||||||
SMqConsumerObj *pConsumer = taosMemoryCalloc(1, sizeof(SMqConsumerObj));
|
SMqConsumerObj *pConsumer = taosMemoryCalloc(1, sizeof(SMqConsumerObj));
|
||||||
if (pConsumer == NULL) {
|
if (pConsumer == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +411,7 @@ void *tDecodeSMqSubActionLogObj(const void *buf, SMqSubActionLogObj *pLog) {
|
||||||
return (void *)buf;
|
return (void *)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
|
int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
||||||
int32_t sz = 0;
|
int32_t sz = 0;
|
||||||
/*int32_t outputNameSz = 0;*/
|
/*int32_t outputNameSz = 0;*/
|
||||||
if (tEncodeCStr(pEncoder, pObj->name) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->name) < 0) return -1;
|
||||||
|
@ -460,7 +462,7 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
|
||||||
return pEncoder->pos;
|
return pEncoder->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
|
int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
|
||||||
if (tDecodeCStrTo(pDecoder, pObj->name) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, pObj->name) < 0) return -1;
|
||||||
if (tDecodeCStrTo(pDecoder, pObj->sourceDb) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, pObj->sourceDb) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &pObj->createTime) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pObj->createTime) < 0) return -1;
|
||||||
|
@ -515,3 +517,16 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tEncodeSMqOffsetObj(void **buf, const SMqOffsetObj *pOffset) {
|
||||||
|
int32_t tlen = 0;
|
||||||
|
tlen += taosEncodeString(buf, pOffset->key);
|
||||||
|
tlen += taosEncodeFixedI64(buf, pOffset->offset);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *tDecodeSMqOffsetObj(void *buf, SMqOffsetObj *pOffset) {
|
||||||
|
buf = taosDecodeStringTo(buf, pOffset->key);
|
||||||
|
buf = taosDecodeFixedI64(buf, &pOffset->offset);
|
||||||
|
return buf;
|
||||||
|
}
|
|
@ -157,8 +157,8 @@ static int32_t mndProcessCommitOffsetReq(SNodeMsg *pMsg) {
|
||||||
SMnode *pMnode = pMsg->pNode;
|
SMnode *pMnode = pMsg->pNode;
|
||||||
char *msgStr = pMsg->rpcMsg.pCont;
|
char *msgStr = pMsg->rpcMsg.pCont;
|
||||||
SMqCMCommitOffsetReq commitOffsetReq;
|
SMqCMCommitOffsetReq commitOffsetReq;
|
||||||
SCoder decoder;
|
SDecoder decoder;
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, msgStr, pMsg->rpcMsg.contLen, TD_DECODER);
|
tDecoderInit(&decoder, msgStr, pMsg->rpcMsg.contLen);
|
||||||
|
|
||||||
tDecodeSMqCMCommitOffsetReq(&decoder, &commitOffsetReq);
|
tDecodeSMqCMCommitOffsetReq(&decoder, &commitOffsetReq);
|
||||||
|
|
||||||
|
|
|
@ -83,12 +83,12 @@ END:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet* pEpSet, tmsg_t type, int32_t nodeId) {
|
int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet* pEpSet, tmsg_t type, int32_t nodeId) {
|
||||||
SCoder encoder;
|
SEncoder encoder;
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER);
|
tEncoderInit(&encoder, NULL, 0);
|
||||||
tEncodeSStreamTask(&encoder, pTask);
|
tEncodeSStreamTask(&encoder, pTask);
|
||||||
int32_t size = encoder.pos;
|
int32_t size = encoder.pos;
|
||||||
int32_t tlen = sizeof(SMsgHead) + size;
|
int32_t tlen = sizeof(SMsgHead) + size;
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
void* buf = taosMemoryMalloc(tlen);
|
void* buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -96,9 +96,9 @@ int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet
|
||||||
}
|
}
|
||||||
((SMsgHead*)buf)->vgId = htonl(nodeId);
|
((SMsgHead*)buf)->vgId = htonl(nodeId);
|
||||||
void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, abuf, size, TD_ENCODER);
|
tEncoderInit(&encoder, abuf, size);
|
||||||
tEncodeSStreamTask(&encoder, pTask);
|
tEncodeSStreamTask(&encoder, pTask);
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
STransAction action = {0};
|
STransAction action = {0};
|
||||||
memcpy(&action.epSet, pEpSet, sizeof(SEpSet));
|
memcpy(&action.epSet, pEpSet, sizeof(SEpSet));
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
|
||||||
#define TSDB_STB_VER_NUMBER 1
|
#define STB_VER_NUMBER 1
|
||||||
#define TSDB_STB_RESERVE_SIZE 64
|
#define STB_RESERVE_SIZE 64
|
||||||
|
|
||||||
static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw);
|
static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw);
|
||||||
static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb);
|
static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb);
|
||||||
|
@ -46,13 +46,15 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
static void mndCancelGetNextStb(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextStb(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
int32_t mndInitStb(SMnode *pMnode) {
|
int32_t mndInitStb(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_STB,
|
SSdbTable table = {
|
||||||
|
.sdbType = SDB_STB,
|
||||||
.keyType = SDB_KEY_BINARY,
|
.keyType = SDB_KEY_BINARY,
|
||||||
.encodeFp = (SdbEncodeFp)mndStbActionEncode,
|
.encodeFp = (SdbEncodeFp)mndStbActionEncode,
|
||||||
.decodeFp = (SdbDecodeFp)mndStbActionDecode,
|
.decodeFp = (SdbDecodeFp)mndStbActionDecode,
|
||||||
.insertFp = (SdbInsertFp)mndStbActionInsert,
|
.insertFp = (SdbInsertFp)mndStbActionInsert,
|
||||||
.updateFp = (SdbUpdateFp)mndStbActionUpdate,
|
.updateFp = (SdbUpdateFp)mndStbActionUpdate,
|
||||||
.deleteFp = (SdbDeleteFp)mndStbActionDelete};
|
.deleteFp = (SdbDeleteFp)mndStbActionDelete,
|
||||||
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STB, mndProcessMCreateStbReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STB, mndProcessMCreateStbReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessMAlterStbReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessMAlterStbReq);
|
||||||
|
@ -74,8 +76,8 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
int32_t size = sizeof(SStbObj) + (pStb->numOfColumns + pStb->numOfTags) * sizeof(SSchema) + +pStb->commentLen +
|
int32_t size = sizeof(SStbObj) + (pStb->numOfColumns + pStb->numOfTags) * sizeof(SSchema) + +pStb->commentLen +
|
||||||
pStb->ast1Len + pStb->ast2Len + TSDB_STB_RESERVE_SIZE;
|
pStb->ast1Len + pStb->ast2Len + STB_RESERVE_SIZE;
|
||||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_STB, TSDB_STB_VER_NUMBER, size);
|
SSdbRaw *pRaw = sdbAllocRaw(SDB_STB, STB_VER_NUMBER, size);
|
||||||
if (pRaw == NULL) goto _OVER;
|
if (pRaw == NULL) goto _OVER;
|
||||||
|
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
|
@ -99,6 +101,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
||||||
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {
|
||||||
SSchema *pSchema = &pStb->pColumns[i];
|
SSchema *pSchema = &pStb->pColumns[i];
|
||||||
SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER)
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pSchema->flags, _OVER)
|
||||||
SDB_SET_INT16(pRaw, dataPos, pSchema->colId, _OVER)
|
SDB_SET_INT16(pRaw, dataPos, pSchema->colId, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
||||||
|
@ -107,6 +110,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
||||||
for (int32_t i = 0; i < pStb->numOfTags; ++i) {
|
for (int32_t i = 0; i < pStb->numOfTags; ++i) {
|
||||||
SSchema *pSchema = &pStb->pTags[i];
|
SSchema *pSchema = &pStb->pTags[i];
|
||||||
SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER)
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pSchema->flags, _OVER)
|
||||||
SDB_SET_INT16(pRaw, dataPos, pSchema->colId, _OVER)
|
SDB_SET_INT16(pRaw, dataPos, pSchema->colId, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
||||||
|
@ -121,7 +125,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
||||||
if (pStb->ast2Len > 0) {
|
if (pStb->ast2Len > 0) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pStb->pAst2, pStb->ast2Len, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pStb->pAst2, pStb->ast2Len, _OVER)
|
||||||
}
|
}
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_STB_RESERVE_SIZE, _OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, STB_RESERVE_SIZE, _OVER)
|
||||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
@ -143,7 +147,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
|
||||||
int8_t sver = 0;
|
int8_t sver = 0;
|
||||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER;
|
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER;
|
||||||
|
|
||||||
if (sver != TSDB_STB_VER_NUMBER) {
|
if (sver != STB_VER_NUMBER) {
|
||||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -183,6 +187,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
|
||||||
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {
|
||||||
SSchema *pSchema = &pStb->pColumns[i];
|
SSchema *pSchema = &pStb->pColumns[i];
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pSchema->type, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pSchema->type, _OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &pSchema->flags, _OVER)
|
||||||
SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, _OVER)
|
SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, _OVER)
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
||||||
|
@ -191,6 +196,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
|
||||||
for (int32_t i = 0; i < pStb->numOfTags; ++i) {
|
for (int32_t i = 0; i < pStb->numOfTags; ++i) {
|
||||||
SSchema *pSchema = &pStb->pTags[i];
|
SSchema *pSchema = &pStb->pTags[i];
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pSchema->type, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pSchema->type, _OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &pSchema->flags, _OVER)
|
||||||
SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, _OVER)
|
SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, _OVER)
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
||||||
|
@ -211,7 +217,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
|
||||||
if (pStb->pAst2 == NULL) goto _OVER;
|
if (pStb->pAst2 == NULL) goto _OVER;
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pStb->pAst2, pStb->ast2Len, _OVER)
|
SDB_GET_BINARY(pRaw, dataPos, pStb->pAst2, pStb->ast2Len, _OVER)
|
||||||
}
|
}
|
||||||
SDB_GET_RESERVE(pRaw, dataPos, TSDB_STB_RESERVE_SIZE, _OVER)
|
SDB_GET_RESERVE(pRaw, dataPos, STB_RESERVE_SIZE, _OVER)
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
|
@ -363,7 +369,7 @@ static FORCE_INLINE int schemaExColIdCompare(const void *colId, const void *pSch
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int32_t *pContLen) {
|
static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int32_t *pContLen) {
|
||||||
SCoder coder = {0};
|
SEncoder encoder = {0};
|
||||||
int32_t contLen;
|
int32_t contLen;
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
SVCreateStbReq req = {0};
|
SVCreateStbReq req = {0};
|
||||||
|
@ -416,11 +422,11 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
||||||
pHead->vgId = htonl(pVgroup->vgId);
|
pHead->vgId = htonl(pVgroup->vgId);
|
||||||
|
|
||||||
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pBuf, contLen - sizeof(SMsgHead), TD_ENCODER);
|
tEncoderInit(&encoder, pBuf, contLen - sizeof(SMsgHead));
|
||||||
if (tEncodeSVCreateStbReq(&coder, &req) < 0) {
|
if (tEncodeSVCreateStbReq(&encoder, &req) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tCoderClear(&coder);
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
taosMemoryFreeClear(req.pRSmaParam.qmsg1);
|
taosMemoryFreeClear(req.pRSmaParam.qmsg1);
|
||||||
|
@ -434,7 +440,7 @@ static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb,
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
SMsgHead *pHead = NULL;
|
SMsgHead *pHead = NULL;
|
||||||
SCoder coder = {0};
|
SEncoder encoder = {0};
|
||||||
|
|
||||||
tNameFromString(&name, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
tNameFromString(&name, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
|
|
||||||
|
@ -456,9 +462,9 @@ static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb,
|
||||||
|
|
||||||
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
||||||
|
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pBuf, contLen - sizeof(SMsgHead), TD_ENCODER);
|
tEncoderInit(&encoder, pBuf, contLen - sizeof(SMsgHead));
|
||||||
tEncodeSVDropStbReq(&coder, &req);
|
tEncodeSVDropStbReq(&encoder, &req);
|
||||||
tCoderClear(&coder);
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
return pHead;
|
return pHead;
|
||||||
|
@ -488,7 +494,7 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < pCreate->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pCreate->numOfColumns; ++i) {
|
||||||
SField *pField1 = taosArrayGet(pCreate->pColumns, i);
|
SField *pField1 = taosArrayGet(pCreate->pColumns, i);
|
||||||
if (pField->type < 0) {
|
if (pField1->type < 0) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -574,6 +580,7 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
action.pCont = pReq;
|
action.pCont = pReq;
|
||||||
action.contLen = contLen;
|
action.contLen = contLen;
|
||||||
action.msgType = TDMT_VND_CREATE_STB;
|
action.msgType = TDMT_VND_CREATE_STB;
|
||||||
|
action.acceptableCode = TSDB_CODE_TDB_STB_ALREADY_EXIST;
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
|
@ -613,6 +620,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
action.pCont = pReq;
|
action.pCont = pReq;
|
||||||
action.contLen = contLen;
|
action.contLen = contLen;
|
||||||
action.msgType = TDMT_VND_DROP_STB;
|
action.msgType = TDMT_VND_DROP_STB;
|
||||||
|
action.acceptableCode = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
|
@ -733,6 +741,7 @@ _OVER:
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
||||||
mndTransSetDbInfo(pTrans, pDb);
|
mndTransSetDbInfo(pTrans, pDb);
|
||||||
if (mndSetCreateStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) return -1;
|
if (mndSetCreateStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) return -1;
|
||||||
|
@ -792,7 +801,10 @@ static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfStbs = -1;
|
int32_t numOfStbs = -1;
|
||||||
mndGetNumOfStbs(pMnode, pDb->name, &numOfStbs);
|
if (mndGetNumOfStbs(pMnode, pDb->name, &numOfStbs) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (pDb->cfg.numOfStables == 1 && numOfStbs != 0) {
|
if (pDb->cfg.numOfStables == 1 && numOfStbs != 0) {
|
||||||
terrno = TSDB_CODE_MND_SINGLE_STB_MODE_DB;
|
terrno = TSDB_CODE_MND_SINGLE_STB_MODE_DB;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -819,7 +831,7 @@ static int32_t mndProcessVCreateStbRsp(SNodeMsg *pRsp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCheckAlterStbReq(SMAltertbReq *pAlter) {
|
static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
|
||||||
if (pAlter->numOfFields < 1 || pAlter->numOfFields != (int32_t)taosArrayGetSize(pAlter->pFields)) {
|
if (pAlter->numOfFields < 1 || pAlter->numOfFields != (int32_t)taosArrayGetSize(pAlter->pFields)) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1170,7 +1182,7 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndAlterStb(SMnode *pMnode, SNodeMsg *pReq, const SMAltertbReq *pAlter, SDbObj *pDb, SStbObj *pOld) {
|
static int32_t mndAlterStb(SMnode *pMnode, SNodeMsg *pReq, const SMAlterStbReq *pAlter, SDbObj *pDb, SStbObj *pOld) {
|
||||||
SStbObj stbObj = {0};
|
SStbObj stbObj = {0};
|
||||||
taosRLockLatch(&pOld->lock);
|
taosRLockLatch(&pOld->lock);
|
||||||
memcpy(&stbObj, pOld, sizeof(SStbObj));
|
memcpy(&stbObj, pOld, sizeof(SStbObj));
|
||||||
|
@ -1239,7 +1251,7 @@ static int32_t mndProcessMAlterStbReq(SNodeMsg *pReq) {
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
SUserObj *pUser = NULL;
|
||||||
SMAltertbReq alterReq = {0};
|
SMAlterStbReq alterReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSMAlterStbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &alterReq) != 0) {
|
if (tDeserializeSMAlterStbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &alterReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
|
|
@ -70,14 +70,14 @@ SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
|
|
||||||
SCoder encoder;
|
SEncoder encoder;
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER);
|
tEncoderInit(&encoder, NULL, 0);
|
||||||
if (tEncodeSStreamObj(&encoder, pStream) < 0) {
|
if (tEncodeSStreamObj(&encoder, pStream) < 0) {
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
goto STREAM_ENCODE_OVER;
|
goto STREAM_ENCODE_OVER;
|
||||||
}
|
}
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
int32_t size = sizeof(int32_t) + tlen + MND_STREAM_RESERVE_SIZE;
|
int32_t size = sizeof(int32_t) + tlen + MND_STREAM_RESERVE_SIZE;
|
||||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_STREAM, MND_STREAM_VER_NUMBER, size);
|
SSdbRaw *pRaw = sdbAllocRaw(SDB_STREAM, MND_STREAM_VER_NUMBER, size);
|
||||||
|
@ -86,12 +86,12 @@ SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) {
|
||||||
buf = taosMemoryMalloc(tlen);
|
buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) goto STREAM_ENCODE_OVER;
|
if (buf == NULL) goto STREAM_ENCODE_OVER;
|
||||||
|
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, tlen, TD_ENCODER);
|
tEncoderInit(&encoder, buf, tlen);
|
||||||
if (tEncodeSStreamObj(&encoder, pStream) < 0) {
|
if (tEncodeSStreamObj(&encoder, pStream) < 0) {
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
goto STREAM_ENCODE_OVER;
|
goto STREAM_ENCODE_OVER;
|
||||||
}
|
}
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
SDB_SET_INT32(pRaw, dataPos, tlen, STREAM_ENCODE_OVER);
|
SDB_SET_INT32(pRaw, dataPos, tlen, STREAM_ENCODE_OVER);
|
||||||
|
@ -138,8 +138,8 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) {
|
||||||
if (buf == NULL) goto STREAM_DECODE_OVER;
|
if (buf == NULL) goto STREAM_DECODE_OVER;
|
||||||
SDB_GET_BINARY(pRaw, dataPos, buf, tlen, STREAM_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, buf, tlen, STREAM_DECODE_OVER);
|
||||||
|
|
||||||
SCoder decoder;
|
SDecoder decoder;
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, tlen + 1, TD_DECODER);
|
tDecoderInit(&decoder, buf, tlen + 1);
|
||||||
if (tDecodeSStreamObj(&decoder, pStream) < 0) {
|
if (tDecodeSStreamObj(&decoder, pStream) < 0) {
|
||||||
goto STREAM_DECODE_OVER;
|
goto STREAM_DECODE_OVER;
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,10 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfStbs = -1;
|
int32_t numOfStbs = -1;
|
||||||
mndGetNumOfStbs(pMnode, pDb->name, &numOfStbs);
|
if (mndGetNumOfStbs(pMnode, pDb->name, &numOfStbs) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (pDb->cfg.numOfStables == 1 && numOfStbs != 0) {
|
if (pDb->cfg.numOfStables == 1 && numOfStbs != 0) {
|
||||||
terrno = TSDB_CODE_MND_SINGLE_STB_MODE_DB;
|
terrno = TSDB_CODE_MND_SINGLE_STB_MODE_DB;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
|
|
@ -412,7 +412,7 @@ static int32_t mndProcessAlterUserReq(SNodeMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alterReq.pass[0] == 0) {
|
if (TSDB_ALTER_USER_PASSWD == alterReq.alterType && alterReq.pass[0] == 0) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_PASS_FORMAT;
|
terrno = TSDB_CODE_MND_INVALID_PASS_FORMAT;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ void* MndTestStb::BuildCreateStbReq(const char* stbname, int32_t* pContLen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* MndTestStb::BuildAlterStbAddTagReq(const char* stbname, const char* tagname, int32_t* pContLen) {
|
void* MndTestStb::BuildAlterStbAddTagReq(const char* stbname, const char* tagname, int32_t* pContLen) {
|
||||||
SMAltertbReq req = {0};
|
SMAlterStbReq req = {0};
|
||||||
strcpy(req.name, stbname);
|
strcpy(req.name, stbname);
|
||||||
req.numOfFields = 1;
|
req.numOfFields = 1;
|
||||||
req.pFields = taosArrayInit(1, sizeof(SField));
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
|
@ -158,7 +158,7 @@ void* MndTestStb::BuildAlterStbAddTagReq(const char* stbname, const char* tagnam
|
||||||
}
|
}
|
||||||
|
|
||||||
void* MndTestStb::BuildAlterStbDropTagReq(const char* stbname, const char* tagname, int32_t* pContLen) {
|
void* MndTestStb::BuildAlterStbDropTagReq(const char* stbname, const char* tagname, int32_t* pContLen) {
|
||||||
SMAltertbReq req = {0};
|
SMAlterStbReq req = {0};
|
||||||
strcpy(req.name, stbname);
|
strcpy(req.name, stbname);
|
||||||
req.numOfFields = 1;
|
req.numOfFields = 1;
|
||||||
req.pFields = taosArrayInit(1, sizeof(SField));
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
|
@ -180,7 +180,7 @@ void* MndTestStb::BuildAlterStbDropTagReq(const char* stbname, const char* tagna
|
||||||
|
|
||||||
void* MndTestStb::BuildAlterStbUpdateTagNameReq(const char* stbname, const char* tagname, const char* newtagname,
|
void* MndTestStb::BuildAlterStbUpdateTagNameReq(const char* stbname, const char* tagname, const char* newtagname,
|
||||||
int32_t* pContLen) {
|
int32_t* pContLen) {
|
||||||
SMAltertbReq req = {0};
|
SMAlterStbReq req = {0};
|
||||||
strcpy(req.name, stbname);
|
strcpy(req.name, stbname);
|
||||||
req.numOfFields = 2;
|
req.numOfFields = 2;
|
||||||
req.pFields = taosArrayInit(2, sizeof(SField));
|
req.pFields = taosArrayInit(2, sizeof(SField));
|
||||||
|
@ -208,7 +208,7 @@ void* MndTestStb::BuildAlterStbUpdateTagNameReq(const char* stbname, const char*
|
||||||
|
|
||||||
void* MndTestStb::BuildAlterStbUpdateTagBytesReq(const char* stbname, const char* tagname, int32_t bytes,
|
void* MndTestStb::BuildAlterStbUpdateTagBytesReq(const char* stbname, const char* tagname, int32_t bytes,
|
||||||
int32_t* pContLen) {
|
int32_t* pContLen) {
|
||||||
SMAltertbReq req = {0};
|
SMAlterStbReq req = {0};
|
||||||
strcpy(req.name, stbname);
|
strcpy(req.name, stbname);
|
||||||
req.numOfFields = 1;
|
req.numOfFields = 1;
|
||||||
req.pFields = taosArrayInit(1, sizeof(SField));
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
|
@ -229,7 +229,7 @@ void* MndTestStb::BuildAlterStbUpdateTagBytesReq(const char* stbname, const char
|
||||||
}
|
}
|
||||||
|
|
||||||
void* MndTestStb::BuildAlterStbAddColumnReq(const char* stbname, const char* colname, int32_t* pContLen) {
|
void* MndTestStb::BuildAlterStbAddColumnReq(const char* stbname, const char* colname, int32_t* pContLen) {
|
||||||
SMAltertbReq req = {0};
|
SMAlterStbReq req = {0};
|
||||||
strcpy(req.name, stbname);
|
strcpy(req.name, stbname);
|
||||||
req.numOfFields = 1;
|
req.numOfFields = 1;
|
||||||
req.pFields = taosArrayInit(1, sizeof(SField));
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
|
@ -250,7 +250,7 @@ void* MndTestStb::BuildAlterStbAddColumnReq(const char* stbname, const char* col
|
||||||
}
|
}
|
||||||
|
|
||||||
void* MndTestStb::BuildAlterStbDropColumnReq(const char* stbname, const char* colname, int32_t* pContLen) {
|
void* MndTestStb::BuildAlterStbDropColumnReq(const char* stbname, const char* colname, int32_t* pContLen) {
|
||||||
SMAltertbReq req = {0};
|
SMAlterStbReq req = {0};
|
||||||
strcpy(req.name, stbname);
|
strcpy(req.name, stbname);
|
||||||
req.numOfFields = 1;
|
req.numOfFields = 1;
|
||||||
req.pFields = taosArrayInit(1, sizeof(SField));
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
|
@ -272,7 +272,7 @@ void* MndTestStb::BuildAlterStbDropColumnReq(const char* stbname, const char* co
|
||||||
|
|
||||||
void* MndTestStb::BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes,
|
void* MndTestStb::BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes,
|
||||||
int32_t* pContLen) {
|
int32_t* pContLen) {
|
||||||
SMAltertbReq req = {0};
|
SMAlterStbReq req = {0};
|
||||||
strcpy(req.name, stbname);
|
strcpy(req.name, stbname);
|
||||||
req.numOfFields = 1;
|
req.numOfFields = 1;
|
||||||
req.pFields = taosArrayInit(1, sizeof(SField));
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
|
|
|
@ -84,6 +84,8 @@ int32_t qndProcessFetchMsg(SQnode *pQnode, SRpcMsg *pMsg) {
|
||||||
// return vnodeGetTableMeta(pQnode, pMsg);
|
// return vnodeGetTableMeta(pQnode, pMsg);
|
||||||
case TDMT_VND_CONSUME:
|
case TDMT_VND_CONSUME:
|
||||||
// return tqProcessConsumeReq(pQnode->pTq, pMsg);
|
// return tqProcessConsumeReq(pQnode->pTq, pMsg);
|
||||||
|
case TDMT_VND_QUERY_HEARTBEAT:
|
||||||
|
return qWorkerProcessHbMsg(pQnode, pQnode->pQuery, pMsg);
|
||||||
default:
|
default:
|
||||||
qError("unknown msg type:%d in fetch queue", pMsg->msgType);
|
qError("unknown msg type:%d in fetch queue", pMsg->msgType);
|
||||||
return TSDB_CODE_VND_APP_ERROR;
|
return TSDB_CODE_VND_APP_ERROR;
|
||||||
|
|
|
@ -99,10 +99,10 @@ void sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SCoder decoder;
|
SDecoder decoder;
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, msg, pMsg->contLen - sizeof(SMsgHead), TD_DECODER);
|
tDecoderInit(&decoder, msg, pMsg->contLen - sizeof(SMsgHead));
|
||||||
tDecodeSStreamTask(&decoder, pTask);
|
tDecodeSStreamTask(&decoder, pTask);
|
||||||
tCoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
sndMetaDeployTask(pSnode->pMeta, pTask);
|
sndMetaDeployTask(pSnode->pMeta, pTask);
|
||||||
} else if (pMsg->msgType == TDMT_SND_TASK_EXEC) {
|
} else if (pMsg->msgType == TDMT_SND_TASK_EXEC) {
|
||||||
|
|
|
@ -108,7 +108,7 @@ int32_t tsdbQuerySTableByTagCond(void *pMeta, uint64_t uid, TSKEY skey, con
|
||||||
int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT *pHandle);
|
int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT *pHandle);
|
||||||
bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle);
|
bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle);
|
||||||
void tsdbRetrieveDataBlockInfo(tsdbReaderT *pTsdbReadHandle, SDataBlockInfo *pBlockInfo);
|
void tsdbRetrieveDataBlockInfo(tsdbReaderT *pTsdbReadHandle, SDataBlockInfo *pBlockInfo);
|
||||||
int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT *pTsdbReadHandle, SColumnDataAgg ***pBlockStatis, bool* allHave);
|
int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT *pTsdbReadHandle, SColumnDataAgg ***pBlockStatis, bool *allHave);
|
||||||
SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumnIdList);
|
SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumnIdList);
|
||||||
void tsdbResetReadHandle(tsdbReaderT queryHandle, SQueryTableDataCond *pCond);
|
void tsdbResetReadHandle(tsdbReaderT queryHandle, SQueryTableDataCond *pCond);
|
||||||
void tsdbDestroyTableGroup(STableGroupInfo *pGroupList);
|
void tsdbDestroyTableGroup(STableGroupInfo *pGroupList);
|
||||||
|
@ -126,8 +126,8 @@ int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList
|
||||||
int tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList);
|
int tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList);
|
||||||
int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver);
|
int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver);
|
||||||
bool tqNextDataBlock(STqReadHandle *pHandle);
|
bool tqNextDataBlock(STqReadHandle *pHandle);
|
||||||
int32_t tqRetrieveDataBlock(SArray **ppCols, STqReadHandle *pHandle, uint64_t *pGroupId, uint64_t* pUid, int32_t *pNumOfRows,
|
int32_t tqRetrieveDataBlock(SArray **ppCols, STqReadHandle *pHandle, uint64_t *pGroupId, uint64_t *pUid,
|
||||||
int16_t *pNumOfCols);
|
int32_t *pNumOfRows, int16_t *pNumOfCols);
|
||||||
|
|
||||||
// need to reposition
|
// need to reposition
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ struct SMetaEntry {
|
||||||
int64_t ctime;
|
int64_t ctime;
|
||||||
int32_t ttlDays;
|
int32_t ttlDays;
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
const void *pTags;
|
const uint8_t *pTags;
|
||||||
} ctbEntry;
|
} ctbEntry;
|
||||||
struct {
|
struct {
|
||||||
int64_t ctime;
|
int64_t ctime;
|
||||||
|
@ -205,7 +205,7 @@ struct SMetaEntry {
|
||||||
struct SMetaReader {
|
struct SMetaReader {
|
||||||
int32_t flags;
|
int32_t flags;
|
||||||
SMeta *pMeta;
|
SMeta *pMeta;
|
||||||
SCoder coder;
|
SDecoder coder;
|
||||||
SMetaEntry me;
|
SMetaEntry me;
|
||||||
void *pBuf;
|
void *pBuf;
|
||||||
int szBuf;
|
int szBuf;
|
||||||
|
|
|
@ -39,8 +39,8 @@ typedef struct SMSmaCursor SMSmaCursor;
|
||||||
// metaOpen ==================
|
// metaOpen ==================
|
||||||
|
|
||||||
// metaEntry ==================
|
// metaEntry ==================
|
||||||
int metaEncodeEntry(SCoder* pCoder, const SMetaEntry* pME);
|
int metaEncodeEntry(SEncoder* pCoder, const SMetaEntry* pME);
|
||||||
int metaDecodeEntry(SCoder* pCoder, SMetaEntry* pME);
|
int metaDecodeEntry(SDecoder* pCoder, SMetaEntry* pME);
|
||||||
|
|
||||||
// metaTable ==================
|
// metaTable ==================
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
|
||||||
int metaEncodeEntry(SCoder *pCoder, const SMetaEntry *pME) {
|
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
|
||||||
if (tStartEncode(pCoder) < 0) return -1;
|
if (tStartEncode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
if (tEncodeI64(pCoder, pME->version) < 0) return -1;
|
if (tEncodeI64(pCoder, pME->version) < 0) return -1;
|
||||||
|
@ -43,8 +43,8 @@ int metaEncodeEntry(SCoder *pCoder, const SMetaEntry *pME) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaDecodeEntry(SCoder *pCoder, SMetaEntry *pME) {
|
int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
|
||||||
uint64_t len;
|
uint32_t len;
|
||||||
if (tStartDecode(pCoder) < 0) return -1;
|
if (tStartDecode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
if (tDecodeI64(pCoder, &pME->version) < 0) return -1;
|
if (tDecodeI64(pCoder, &pME->version) < 0) return -1;
|
||||||
|
|
|
@ -22,7 +22,7 @@ void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void metaReaderClear(SMetaReader *pReader) {
|
void metaReaderClear(SMetaReader *pReader) {
|
||||||
tCoderClear(&pReader->coder);
|
tDecoderClear(&pReader->coder);
|
||||||
tdbFree(pReader->pBuf);
|
tdbFree(pReader->pBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ int metaGetTableEntryByVersion(SMetaReader *pReader, int64_t version, tb_uid_t u
|
||||||
}
|
}
|
||||||
|
|
||||||
// decode the entry
|
// decode the entry
|
||||||
tCoderInit(&pReader->coder, TD_LITTLE_ENDIAN, pReader->pBuf, pReader->szBuf, TD_DECODER);
|
tDecoderInit(&pReader->coder, pReader->pBuf, pReader->szBuf);
|
||||||
|
|
||||||
if (metaDecodeEntry(&pReader->coder, &pReader->me) < 0) {
|
if (metaDecodeEntry(&pReader->coder, &pReader->me) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -147,7 +147,7 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
|
||||||
SSchemaWrapper *pSW = NULL;
|
SSchemaWrapper *pSW = NULL;
|
||||||
SSchema *pSchema = NULL;
|
SSchema *pSchema = NULL;
|
||||||
void *pBuf;
|
void *pBuf;
|
||||||
SCoder coder = {0};
|
SDecoder coder = {0};
|
||||||
|
|
||||||
// fetch
|
// fetch
|
||||||
skmDbKey.uid = uid;
|
skmDbKey.uid = uid;
|
||||||
|
@ -163,11 +163,11 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
|
||||||
pBuf = pVal;
|
pBuf = pVal;
|
||||||
pSW = taosMemoryMalloc(sizeof(SSchemaWrapper));
|
pSW = taosMemoryMalloc(sizeof(SSchemaWrapper));
|
||||||
|
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pVal, vLen, TD_DECODER);
|
tDecoderInit(&coder, pVal, vLen);
|
||||||
tDecodeSSchemaWrapper(&coder, pSW);
|
tDecodeSSchemaWrapper(&coder, pSW);
|
||||||
pSchema = taosMemoryMalloc(sizeof(SSchema) * pSW->nCols);
|
pSchema = taosMemoryMalloc(sizeof(SSchema) * pSW->nCols);
|
||||||
memcpy(pSchema, pSW->pSchema, sizeof(SSchema) * pSW->nCols);
|
memcpy(pSchema, pSW->pSchema, sizeof(SSchema) * pSW->nCols);
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
|
|
||||||
pSW->pSchema = pSchema;
|
pSW->pSchema = pSchema;
|
||||||
|
|
||||||
|
|
|
@ -1,843 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "vnodeInt.h"
|
|
||||||
|
|
||||||
#ifndef META_REFACT
|
|
||||||
|
|
||||||
typedef struct SPoolMem {
|
|
||||||
int64_t size;
|
|
||||||
struct SPoolMem *prev;
|
|
||||||
struct SPoolMem *next;
|
|
||||||
} SPoolMem;
|
|
||||||
|
|
||||||
#define META_TDB_SMA_TEST
|
|
||||||
|
|
||||||
static SPoolMem *openPool();
|
|
||||||
static void clearPool(SPoolMem *pPool);
|
|
||||||
static void closePool(SPoolMem *pPool);
|
|
||||||
static void *poolMalloc(void *arg, size_t size);
|
|
||||||
static void poolFree(void *arg, void *ptr);
|
|
||||||
|
|
||||||
struct SMetaDB {
|
|
||||||
TXN txn;
|
|
||||||
TENV *pEnv;
|
|
||||||
TDB *pTbDB;
|
|
||||||
TDB *pSchemaDB;
|
|
||||||
TDB *pNameIdx;
|
|
||||||
TDB *pStbIdx;
|
|
||||||
TDB *pNtbIdx;
|
|
||||||
TDB *pCtbIdx;
|
|
||||||
SPoolMem *pPool;
|
|
||||||
#ifdef META_TDB_SMA_TEST
|
|
||||||
TDB *pSmaDB;
|
|
||||||
TDB *pSmaIdx;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
typedef struct {
|
|
||||||
tb_uid_t uid;
|
|
||||||
int32_t sver;
|
|
||||||
} SSchemaDbKey;
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char *name;
|
|
||||||
tb_uid_t uid;
|
|
||||||
} SNameIdxKey;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
tb_uid_t suid;
|
|
||||||
tb_uid_t uid;
|
|
||||||
} SCtbIdxKey;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
tb_uid_t uid;
|
|
||||||
int64_t smaUid;
|
|
||||||
} SSmaIdxKey;
|
|
||||||
|
|
||||||
static int metaEncodeTbInfo(void **buf, STbCfg *pTbCfg);
|
|
||||||
static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg);
|
|
||||||
static int metaEncodeSchema(void **buf, SSchemaWrapper *pSW);
|
|
||||||
static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW);
|
|
||||||
static int metaEncodeSchemaEx(void **buf, SSchemaWrapper *pSW);
|
|
||||||
static void *metaDecodeSchemaEx(void *buf, SSchemaWrapper *pSW, bool isGetEx);
|
|
||||||
|
|
||||||
static SSchemaWrapper *metaGetTableSchemaImpl(SMeta *pMeta, tb_uid_t uid, int32_t sver, bool isinline, bool isGetEx);
|
|
||||||
|
|
||||||
static inline int metaUidCmpr(const void *arg1, int len1, const void *arg2, int len2) {
|
|
||||||
tb_uid_t uid1, uid2;
|
|
||||||
|
|
||||||
ASSERT(len1 == sizeof(tb_uid_t));
|
|
||||||
ASSERT(len2 == sizeof(tb_uid_t));
|
|
||||||
|
|
||||||
uid1 = ((tb_uid_t *)arg1)[0];
|
|
||||||
uid2 = ((tb_uid_t *)arg2)[0];
|
|
||||||
|
|
||||||
if (uid1 < uid2) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (uid1 == uid2) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int metaSchemaKeyCmpr(const void *arg1, int len1, const void *arg2, int len2) {
|
|
||||||
int c;
|
|
||||||
SSchemaDbKey *pKey1 = (SSchemaDbKey *)arg1;
|
|
||||||
SSchemaDbKey *pKey2 = (SSchemaDbKey *)arg2;
|
|
||||||
|
|
||||||
c = metaUidCmpr(arg1, sizeof(tb_uid_t), arg2, sizeof(tb_uid_t));
|
|
||||||
if (c) return c;
|
|
||||||
|
|
||||||
if (pKey1->sver > pKey2->sver) {
|
|
||||||
return 1;
|
|
||||||
} else if (pKey1->sver == pKey2->sver) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int metaNameIdxCmpr(const void *arg1, int len1, const void *arg2, int len2) {
|
|
||||||
return strcmp((char *)arg1, (char *)arg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int metaCtbIdxCmpr(const void *arg1, int len1, const void *arg2, int len2) {
|
|
||||||
int c;
|
|
||||||
SCtbIdxKey *pKey1 = (SCtbIdxKey *)arg1;
|
|
||||||
SCtbIdxKey *pKey2 = (SCtbIdxKey *)arg2;
|
|
||||||
|
|
||||||
c = metaUidCmpr(arg1, sizeof(tb_uid_t), arg2, sizeof(tb_uid_t));
|
|
||||||
if (c) return c;
|
|
||||||
|
|
||||||
return metaUidCmpr(&pKey1->uid, sizeof(tb_uid_t), &pKey2->uid, sizeof(tb_uid_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int metaSmaIdxCmpr(const void *arg1, int len1, const void *arg2, int len2) {
|
|
||||||
int c;
|
|
||||||
SSmaIdxKey *pKey1 = (SSmaIdxKey *)arg1;
|
|
||||||
SSmaIdxKey *pKey2 = (SSmaIdxKey *)arg2;
|
|
||||||
|
|
||||||
c = metaUidCmpr(arg1, sizeof(tb_uid_t), arg2, sizeof(tb_uid_t));
|
|
||||||
if (c) return c;
|
|
||||||
|
|
||||||
return metaUidCmpr(&pKey1->smaUid, sizeof(int64_t), &pKey2->smaUid, sizeof(int64_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
int metaOpenDB(SMeta *pMeta) {
|
|
||||||
SMetaDB *pMetaDb;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
// allocate DB handle
|
|
||||||
pMetaDb = taosMemoryCalloc(1, sizeof(*pMetaDb));
|
|
||||||
if (pMetaDb == NULL) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// open the ENV
|
|
||||||
ret = tdbEnvOpen(pMeta->path, 4096, 256, &(pMetaDb->pEnv));
|
|
||||||
if (ret < 0) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// open table DB
|
|
||||||
ret = tdbDbOpen("table.db", sizeof(tb_uid_t), TDB_VARIANT_LEN, metaUidCmpr, pMetaDb->pEnv, &(pMetaDb->pTbDB));
|
|
||||||
if (ret < 0) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef META_TDB_SMA_TEST
|
|
||||||
ret = tdbDbOpen("sma.db", sizeof(int64_t), TDB_VARIANT_LEN, metaUidCmpr, pMetaDb->pEnv, &(pMetaDb->pSmaDB));
|
|
||||||
if (ret < 0) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// open schema DB
|
|
||||||
ret = tdbDbOpen("schema.db", sizeof(SSchemaDbKey), TDB_VARIANT_LEN, metaSchemaKeyCmpr, pMetaDb->pEnv,
|
|
||||||
&(pMetaDb->pSchemaDB));
|
|
||||||
if (ret < 0) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = tdbDbOpen("name.idx", TDB_VARIANT_LEN, 0, metaNameIdxCmpr, pMetaDb->pEnv, &(pMetaDb->pNameIdx));
|
|
||||||
if (ret < 0) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = tdbDbOpen("stb.idx", sizeof(tb_uid_t), 0, metaUidCmpr, pMetaDb->pEnv, &(pMetaDb->pStbIdx));
|
|
||||||
if (ret < 0) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = tdbDbOpen("ntb.idx", sizeof(tb_uid_t), 0, metaUidCmpr, pMetaDb->pEnv, &(pMetaDb->pNtbIdx));
|
|
||||||
if (ret < 0) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = tdbDbOpen("ctb.idx", sizeof(SCtbIdxKey), 0, metaCtbIdxCmpr, pMetaDb->pEnv, &(pMetaDb->pCtbIdx));
|
|
||||||
if (ret < 0) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef META_TDB_SMA_TEST
|
|
||||||
ret = tdbDbOpen("sma.idx", sizeof(SSmaIdxKey), 0, metaSmaIdxCmpr, pMetaDb->pEnv, &(pMetaDb->pSmaIdx));
|
|
||||||
if (ret < 0) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pMetaDb->pPool = openPool();
|
|
||||||
tdbTxnOpen(&pMetaDb->txn, 0, poolMalloc, poolFree, pMetaDb->pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
|
||||||
tdbBegin(pMetaDb->pEnv, NULL);
|
|
||||||
|
|
||||||
pMeta->pDB = pMetaDb;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void metaCloseDB(SMeta *pMeta) {
|
|
||||||
if (pMeta->pDB) {
|
|
||||||
tdbCommit(pMeta->pDB->pEnv, &pMeta->pDB->txn);
|
|
||||||
tdbTxnClose(&pMeta->pDB->txn);
|
|
||||||
clearPool(pMeta->pDB->pPool);
|
|
||||||
#ifdef META_TDB_SMA_TEST
|
|
||||||
tdbDbClose(pMeta->pDB->pSmaIdx);
|
|
||||||
#endif
|
|
||||||
tdbDbClose(pMeta->pDB->pCtbIdx);
|
|
||||||
tdbDbClose(pMeta->pDB->pNtbIdx);
|
|
||||||
tdbDbClose(pMeta->pDB->pStbIdx);
|
|
||||||
tdbDbClose(pMeta->pDB->pNameIdx);
|
|
||||||
#ifdef META_TDB_SMA_TEST
|
|
||||||
tdbDbClose(pMeta->pDB->pSmaDB);
|
|
||||||
#endif
|
|
||||||
tdbDbClose(pMeta->pDB->pSchemaDB);
|
|
||||||
tdbDbClose(pMeta->pDB->pTbDB);
|
|
||||||
taosMemoryFree(pMeta->pDB);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg, STbDdlH *pHandle) {
|
|
||||||
tb_uid_t uid;
|
|
||||||
SMetaDB *pMetaDb;
|
|
||||||
void *pKey;
|
|
||||||
void *pVal;
|
|
||||||
int kLen;
|
|
||||||
int vLen;
|
|
||||||
int ret;
|
|
||||||
char buf[512];
|
|
||||||
void *pBuf;
|
|
||||||
SCtbIdxKey ctbIdxKey;
|
|
||||||
SSchemaDbKey schemaDbKey;
|
|
||||||
SSchemaWrapper schemaWrapper;
|
|
||||||
|
|
||||||
pMetaDb = pMeta->pDB;
|
|
||||||
|
|
||||||
// TODO: make this operation pre-process
|
|
||||||
if (pTbCfg->type == META_SUPER_TABLE) {
|
|
||||||
uid = pTbCfg->stbCfg.suid;
|
|
||||||
} else {
|
|
||||||
uid = metaGenerateUid(pMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check name and uid unique
|
|
||||||
if (tdbDbGet(pMetaDb->pTbDB, &uid, sizeof(uid), NULL, NULL) == 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (tdbDbGet(pMetaDb->pNameIdx, pTbCfg->name, strlen(pTbCfg->name) + 1, NULL, NULL) == 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// save to table.db
|
|
||||||
pKey = &uid;
|
|
||||||
kLen = sizeof(uid);
|
|
||||||
pVal = pBuf = buf;
|
|
||||||
metaEncodeTbInfo(&pBuf, pTbCfg);
|
|
||||||
vLen = POINTER_DISTANCE(pBuf, buf);
|
|
||||||
ret = tdbDbInsert(pMetaDb->pTbDB, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
|
||||||
if (ret < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// save to schema.db for META_SUPER_TABLE and META_NORMAL_TABLE
|
|
||||||
if (pTbCfg->type != META_CHILD_TABLE) {
|
|
||||||
schemaDbKey.uid = uid;
|
|
||||||
schemaDbKey.sver = 0; // TODO
|
|
||||||
pKey = &schemaDbKey;
|
|
||||||
kLen = sizeof(schemaDbKey);
|
|
||||||
|
|
||||||
if (pTbCfg->type == META_SUPER_TABLE) {
|
|
||||||
schemaWrapper.nCols = pTbCfg->stbCfg.nCols;
|
|
||||||
schemaWrapper.pSchema = pTbCfg->stbCfg.pSchema;
|
|
||||||
} else {
|
|
||||||
schemaWrapper.nCols = pTbCfg->ntbCfg.nCols;
|
|
||||||
schemaWrapper.pSchema = pTbCfg->ntbCfg.pSchema;
|
|
||||||
}
|
|
||||||
pVal = pBuf = buf;
|
|
||||||
metaEncodeSchemaEx(&pBuf, &schemaWrapper);
|
|
||||||
vLen = POINTER_DISTANCE(pBuf, buf);
|
|
||||||
ret = tdbDbInsert(pMetaDb->pSchemaDB, pKey, kLen, pVal, vLen, &pMeta->pDB->txn);
|
|
||||||
if (ret < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update name.idx
|
|
||||||
int nameLen = strlen(pTbCfg->name);
|
|
||||||
memcpy(buf, pTbCfg->name, nameLen + 1);
|
|
||||||
((tb_uid_t *)(buf + nameLen + 1))[0] = uid;
|
|
||||||
pKey = buf;
|
|
||||||
kLen = nameLen + 1 + sizeof(uid);
|
|
||||||
pVal = NULL;
|
|
||||||
vLen = 0;
|
|
||||||
ret = tdbDbInsert(pMetaDb->pNameIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
|
||||||
if (ret < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update other index
|
|
||||||
if (pTbCfg->type == META_SUPER_TABLE) {
|
|
||||||
pKey = &uid;
|
|
||||||
kLen = sizeof(uid);
|
|
||||||
pVal = NULL;
|
|
||||||
vLen = 0;
|
|
||||||
ret = tdbDbInsert(pMetaDb->pStbIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
|
||||||
if (ret < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else if (pTbCfg->type == META_CHILD_TABLE) {
|
|
||||||
ctbIdxKey.suid = pTbCfg->ctbCfg.suid;
|
|
||||||
ctbIdxKey.uid = uid;
|
|
||||||
pKey = &ctbIdxKey;
|
|
||||||
kLen = sizeof(ctbIdxKey);
|
|
||||||
pVal = NULL;
|
|
||||||
vLen = 0;
|
|
||||||
ret = tdbDbInsert(pMetaDb->pCtbIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
|
||||||
if (ret < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
// child table handle for rsma
|
|
||||||
if (pHandle && pHandle->fp) {
|
|
||||||
if (((*pHandle->fp)(pHandle->ahandle, &pHandle->result, &ctbIdxKey.suid, &uid)) < 0) {
|
|
||||||
return -1;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} else if (pTbCfg->type == META_NORMAL_TABLE) {
|
|
||||||
pKey = &uid;
|
|
||||||
kLen = sizeof(uid);
|
|
||||||
pVal = NULL;
|
|
||||||
vLen = 0;
|
|
||||||
ret = tdbDbInsert(pMetaDb->pNtbIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
|
||||||
if (ret < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pMeta->pDB->pPool->size > 0) {
|
|
||||||
metaCommit(pMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SSchemaWrapper *metaGetTableSchemaImpl(SMeta *pMeta, tb_uid_t uid, int32_t sver, bool isinline, bool isGetEx) {
|
|
||||||
void *pKey;
|
|
||||||
void *pVal;
|
|
||||||
int kLen;
|
|
||||||
int vLen;
|
|
||||||
int ret;
|
|
||||||
SSchemaDbKey schemaDbKey;
|
|
||||||
SSchemaWrapper *pSchemaWrapper;
|
|
||||||
void *pBuf;
|
|
||||||
|
|
||||||
// fetch
|
|
||||||
schemaDbKey.uid = uid;
|
|
||||||
schemaDbKey.sver = sver;
|
|
||||||
pKey = &schemaDbKey;
|
|
||||||
kLen = sizeof(schemaDbKey);
|
|
||||||
pVal = NULL;
|
|
||||||
ret = tdbDbGet(pMeta->pDB->pSchemaDB, pKey, kLen, &pVal, &vLen);
|
|
||||||
if (ret < 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// decode
|
|
||||||
pBuf = pVal;
|
|
||||||
pSchemaWrapper = taosMemoryMalloc(sizeof(*pSchemaWrapper));
|
|
||||||
metaDecodeSchemaEx(pBuf, pSchemaWrapper, isGetEx);
|
|
||||||
|
|
||||||
tdbFree(pVal);
|
|
||||||
|
|
||||||
return pSchemaWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SMSmaCursor {
|
|
||||||
TDBC *pCur;
|
|
||||||
tb_uid_t uid;
|
|
||||||
void *pKey;
|
|
||||||
void *pVal;
|
|
||||||
int kLen;
|
|
||||||
int vLen;
|
|
||||||
};
|
|
||||||
|
|
||||||
STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
|
|
||||||
// TODO
|
|
||||||
// ASSERT(0);
|
|
||||||
// return NULL;
|
|
||||||
#ifdef META_TDB_SMA_TEST
|
|
||||||
STSmaWrapper *pSW = NULL;
|
|
||||||
|
|
||||||
SMSmaCursor *pCur = metaOpenSmaCursor(pMeta, uid);
|
|
||||||
if (pCur == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *pBuf = NULL;
|
|
||||||
SSmaIdxKey *pSmaIdxKey = NULL;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
// TODO: lock during iterate?
|
|
||||||
if (tdbDbcNext(pCur->pCur, &pCur->pKey, &pCur->kLen, NULL, &pCur->vLen) == 0) {
|
|
||||||
pSmaIdxKey = pCur->pKey;
|
|
||||||
ASSERT(pSmaIdxKey != NULL);
|
|
||||||
|
|
||||||
void *pSmaVal = metaGetSmaInfoByIndex(pMeta, pSmaIdxKey->smaUid, false);
|
|
||||||
|
|
||||||
if (pSmaVal == NULL) {
|
|
||||||
tsdbWarn("no tsma exists for indexUid: %" PRIi64, pSmaIdxKey->smaUid);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((pSW == NULL) && ((pSW = taosMemoryCalloc(1, sizeof(*pSW))) == NULL)) {
|
|
||||||
tdbFree(pSmaVal);
|
|
||||||
metaCloseSmaCursor(pCur);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
++pSW->number;
|
|
||||||
STSma *tptr = (STSma *)taosMemoryRealloc(pSW->tSma, pSW->number * sizeof(STSma));
|
|
||||||
if (tptr == NULL) {
|
|
||||||
tdbFree(pSmaVal);
|
|
||||||
metaCloseSmaCursor(pCur);
|
|
||||||
tdDestroyTSmaWrapper(pSW);
|
|
||||||
taosMemoryFreeClear(pSW);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
pSW->tSma = tptr;
|
|
||||||
pBuf = pSmaVal;
|
|
||||||
if (tDecodeTSma(pBuf, pSW->tSma + pSW->number - 1) == NULL) {
|
|
||||||
tdbFree(pSmaVal);
|
|
||||||
metaCloseSmaCursor(pCur);
|
|
||||||
tdDestroyTSmaWrapper(pSW);
|
|
||||||
taosMemoryFreeClear(pSW);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
tdbFree(pSmaVal);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
metaCloseSmaCursor(pCur);
|
|
||||||
|
|
||||||
return pSW;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int metaRemoveSmaFromDb(SMeta *pMeta, int64_t indexUid) {
|
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
#ifndef META_TDB_SMA_TEST
|
|
||||||
DBT key = {0};
|
|
||||||
|
|
||||||
key.data = (void *)indexName;
|
|
||||||
key.size = strlen(indexName);
|
|
||||||
|
|
||||||
metaDBWLock(pMeta->pDB);
|
|
||||||
// TODO: No guarantee of consistence.
|
|
||||||
// Use transaction or DB->sync() for some guarantee.
|
|
||||||
pMeta->pDB->pSmaDB->del(pMeta->pDB->pSmaDB, NULL, &key, 0);
|
|
||||||
metaDBULock(pMeta->pDB);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) {
|
|
||||||
// TODO
|
|
||||||
// ASSERT(0);
|
|
||||||
|
|
||||||
#ifdef META_TDB_SMA_TEST
|
|
||||||
int32_t ret = 0;
|
|
||||||
SMetaDB *pMetaDb = pMeta->pDB;
|
|
||||||
void *pBuf = NULL, *qBuf = NULL;
|
|
||||||
void *key = {0}, *val = {0};
|
|
||||||
|
|
||||||
// save sma info
|
|
||||||
int32_t len = tEncodeTSma(NULL, pSmaCfg);
|
|
||||||
pBuf = taosMemoryCalloc(1, len);
|
|
||||||
if (pBuf == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
key = (void *)&pSmaCfg->indexUid;
|
|
||||||
qBuf = pBuf;
|
|
||||||
tEncodeTSma(&qBuf, pSmaCfg);
|
|
||||||
val = pBuf;
|
|
||||||
|
|
||||||
int32_t kLen = sizeof(pSmaCfg->indexUid);
|
|
||||||
int32_t vLen = POINTER_DISTANCE(qBuf, pBuf);
|
|
||||||
|
|
||||||
ret = tdbDbInsert(pMeta->pDB->pSmaDB, key, kLen, val, vLen, &pMetaDb->txn);
|
|
||||||
if (ret < 0) {
|
|
||||||
taosMemoryFreeClear(pBuf);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add sma idx
|
|
||||||
SSmaIdxKey smaIdxKey;
|
|
||||||
smaIdxKey.uid = pSmaCfg->tableUid;
|
|
||||||
smaIdxKey.smaUid = pSmaCfg->indexUid;
|
|
||||||
key = &smaIdxKey;
|
|
||||||
kLen = sizeof(smaIdxKey);
|
|
||||||
val = NULL;
|
|
||||||
vLen = 0;
|
|
||||||
|
|
||||||
ret = tdbDbInsert(pMeta->pDB->pSmaIdx, key, kLen, val, vLen, &pMetaDb->txn);
|
|
||||||
if (ret < 0) {
|
|
||||||
taosMemoryFreeClear(pBuf);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// release
|
|
||||||
taosMemoryFreeClear(pBuf);
|
|
||||||
|
|
||||||
if (pMeta->pDB->pPool->size > 0) {
|
|
||||||
metaCommit(pMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param pMeta
|
|
||||||
* @param uid 0 means iterate all uids.
|
|
||||||
* @return SMSmaCursor*
|
|
||||||
*/
|
|
||||||
SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid) {
|
|
||||||
// TODO
|
|
||||||
// ASSERT(0);
|
|
||||||
// return NULL;
|
|
||||||
#ifdef META_TDB_SMA_TEST
|
|
||||||
SMSmaCursor *pCur = NULL;
|
|
||||||
SMetaDB *pDB = pMeta->pDB;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
pCur = (SMSmaCursor *)taosMemoryCalloc(1, sizeof(*pCur));
|
|
||||||
if (pCur == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pCur->uid = uid;
|
|
||||||
ret = tdbDbcOpen(pDB->pSmaIdx, &(pCur->pCur));
|
|
||||||
if ((ret != 0) || (pCur->pCur == NULL)) {
|
|
||||||
taosMemoryFree(pCur);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uid != 0) {
|
|
||||||
// TODO: move to the specific uid
|
|
||||||
}
|
|
||||||
|
|
||||||
return pCur;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @param pCur
|
|
||||||
* @return int64_t smaIndexUid
|
|
||||||
*/
|
|
||||||
int64_t metaSmaCursorNext(SMSmaCursor *pCur) {
|
|
||||||
// TODO
|
|
||||||
// ASSERT(0);
|
|
||||||
// return NULL;
|
|
||||||
#ifdef META_TDB_SMA_TEST
|
|
||||||
int ret;
|
|
||||||
void *pBuf;
|
|
||||||
SSmaIdxKey *smaIdxKey;
|
|
||||||
|
|
||||||
ret = tdbDbcNext(pCur->pCur, &pCur->pKey, &pCur->kLen, &pCur->pVal, &pCur->vLen);
|
|
||||||
if (ret < 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
smaIdxKey = pCur->pKey;
|
|
||||||
return smaIdxKey->smaUid;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void metaCloseSmaCursor(SMSmaCursor *pCur) {
|
|
||||||
// TODO
|
|
||||||
// ASSERT(0);
|
|
||||||
#ifdef META_TDB_SMA_TEST
|
|
||||||
if (pCur) {
|
|
||||||
if (pCur->pCur) {
|
|
||||||
tdbDbcClose(pCur->pCur);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFree(pCur);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static int metaEncodeSchema(void **buf, SSchemaWrapper *pSW) {
|
|
||||||
int tlen = 0;
|
|
||||||
SSchema *pSchema;
|
|
||||||
|
|
||||||
tlen += taosEncodeFixedU32(buf, pSW->nCols);
|
|
||||||
for (int i = 0; i < pSW->nCols; i++) {
|
|
||||||
pSchema = pSW->pSchema + i;
|
|
||||||
tlen += taosEncodeFixedI8(buf, pSchema->type);
|
|
||||||
tlen += taosEncodeFixedI8(buf, pSchema->flags);
|
|
||||||
tlen += taosEncodeFixedI16(buf, pSchema->colId);
|
|
||||||
tlen += taosEncodeFixedI32(buf, pSchema->bytes);
|
|
||||||
tlen += taosEncodeString(buf, pSchema->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) {
|
|
||||||
SSchema *pSchema;
|
|
||||||
|
|
||||||
buf = taosDecodeFixedU32(buf, &pSW->nCols);
|
|
||||||
pSW->pSchema = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * pSW->nCols);
|
|
||||||
for (int i = 0; i < pSW->nCols; i++) {
|
|
||||||
pSchema = pSW->pSchema + i;
|
|
||||||
buf = taosDecodeFixedI8(buf, &pSchema->type);
|
|
||||||
buf = taosSkipFixedLen(buf, sizeof(int8_t));
|
|
||||||
buf = taosDecodeFixedI16(buf, &pSchema->colId);
|
|
||||||
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
|
|
||||||
buf = taosDecodeStringTo(buf, pSchema->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int metaEncodeSchemaEx(void **buf, SSchemaWrapper *pSW) {
|
|
||||||
int tlen = 0;
|
|
||||||
SSchema *pSchema;
|
|
||||||
|
|
||||||
tlen += taosEncodeFixedU32(buf, pSW->nCols);
|
|
||||||
for (int i = 0; i < pSW->nCols; ++i) {
|
|
||||||
pSchema = pSW->pSchema + i;
|
|
||||||
tlen += taosEncodeFixedI8(buf, pSchema->type);
|
|
||||||
tlen += taosEncodeFixedI8(buf, pSchema->flags);
|
|
||||||
tlen += taosEncodeFixedI16(buf, pSchema->colId);
|
|
||||||
tlen += taosEncodeFixedI32(buf, pSchema->bytes);
|
|
||||||
tlen += taosEncodeString(buf, pSchema->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *metaDecodeSchemaEx(void *buf, SSchemaWrapper *pSW, bool isGetEx) {
|
|
||||||
buf = taosDecodeFixedU32(buf, &pSW->nCols);
|
|
||||||
if (isGetEx) {
|
|
||||||
pSW->pSchema = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * pSW->nCols);
|
|
||||||
for (int i = 0; i < pSW->nCols; i++) {
|
|
||||||
SSchema *pSchema = pSW->pSchema + i;
|
|
||||||
buf = taosDecodeFixedI8(buf, &pSchema->type);
|
|
||||||
buf = taosDecodeFixedI8(buf, &pSchema->flags);
|
|
||||||
buf = taosDecodeFixedI16(buf, &pSchema->colId);
|
|
||||||
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
|
|
||||||
buf = taosDecodeStringTo(buf, pSchema->name);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pSW->pSchema = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * pSW->nCols);
|
|
||||||
for (int i = 0; i < pSW->nCols; i++) {
|
|
||||||
SSchema *pSchema = pSW->pSchema + i;
|
|
||||||
buf = taosDecodeFixedI8(buf, &pSchema->type);
|
|
||||||
buf = taosSkipFixedLen(buf, sizeof(int8_t));
|
|
||||||
buf = taosDecodeFixedI16(buf, &pSchema->colId);
|
|
||||||
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
|
|
||||||
buf = taosDecodeStringTo(buf, pSchema->name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int metaEncodeTbInfo(void **buf, STbCfg *pTbCfg) {
|
|
||||||
int tsize = 0;
|
|
||||||
|
|
||||||
tsize += taosEncodeString(buf, pTbCfg->name);
|
|
||||||
tsize += taosEncodeFixedU32(buf, pTbCfg->ttl);
|
|
||||||
tsize += taosEncodeFixedU32(buf, pTbCfg->keep);
|
|
||||||
tsize += taosEncodeFixedU8(buf, pTbCfg->info);
|
|
||||||
|
|
||||||
if (pTbCfg->type == META_SUPER_TABLE) {
|
|
||||||
SSchemaWrapper sw = {.nCols = pTbCfg->stbCfg.nTagCols, .pSchema = pTbCfg->stbCfg.pTagSchema};
|
|
||||||
tsize += metaEncodeSchema(buf, &sw);
|
|
||||||
} else if (pTbCfg->type == META_CHILD_TABLE) {
|
|
||||||
tsize += taosEncodeFixedU64(buf, pTbCfg->ctbCfg.suid);
|
|
||||||
tsize += tdEncodeKVRow(buf, pTbCfg->ctbCfg.pTag);
|
|
||||||
} else if (pTbCfg->type == META_NORMAL_TABLE) {
|
|
||||||
// TODO
|
|
||||||
} else {
|
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tsize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg) {
|
|
||||||
buf = taosDecodeString(buf, &(pTbCfg->name));
|
|
||||||
buf = taosDecodeFixedU32(buf, &(pTbCfg->ttl));
|
|
||||||
buf = taosDecodeFixedU32(buf, &(pTbCfg->keep));
|
|
||||||
buf = taosDecodeFixedU8(buf, &(pTbCfg->info));
|
|
||||||
|
|
||||||
if (pTbCfg->type == META_SUPER_TABLE) {
|
|
||||||
SSchemaWrapper sw;
|
|
||||||
buf = metaDecodeSchema(buf, &sw);
|
|
||||||
pTbCfg->stbCfg.nTagCols = sw.nCols;
|
|
||||||
pTbCfg->stbCfg.pTagSchema = sw.pSchema;
|
|
||||||
} else if (pTbCfg->type == META_CHILD_TABLE) {
|
|
||||||
buf = taosDecodeFixedU64(buf, &(pTbCfg->ctbCfg.suid));
|
|
||||||
buf = tdDecodeKVRow(buf, &(pTbCfg->ctbCfg.pTag));
|
|
||||||
} else if (pTbCfg->type == META_NORMAL_TABLE) {
|
|
||||||
// TODO
|
|
||||||
} else {
|
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
int metaCommit(SMeta *pMeta) {
|
|
||||||
TXN *pTxn = &pMeta->pDB->txn;
|
|
||||||
|
|
||||||
// Commit current txn
|
|
||||||
tdbCommit(pMeta->pDB->pEnv, pTxn);
|
|
||||||
tdbTxnClose(pTxn);
|
|
||||||
clearPool(pMeta->pDB->pPool);
|
|
||||||
|
|
||||||
// start a new txn
|
|
||||||
tdbTxnOpen(&pMeta->pDB->txn, 0, poolMalloc, poolFree, pMeta->pDB->pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
|
||||||
tdbBegin(pMeta->pDB->pEnv, pTxn);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SPoolMem *openPool() {
|
|
||||||
SPoolMem *pPool = (SPoolMem *)tdbOsMalloc(sizeof(*pPool));
|
|
||||||
|
|
||||||
pPool->prev = pPool->next = pPool;
|
|
||||||
pPool->size = 0;
|
|
||||||
|
|
||||||
return pPool;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void clearPool(SPoolMem *pPool) {
|
|
||||||
SPoolMem *pMem;
|
|
||||||
|
|
||||||
do {
|
|
||||||
pMem = pPool->next;
|
|
||||||
|
|
||||||
if (pMem == pPool) break;
|
|
||||||
|
|
||||||
pMem->next->prev = pMem->prev;
|
|
||||||
pMem->prev->next = pMem->next;
|
|
||||||
pPool->size -= pMem->size;
|
|
||||||
|
|
||||||
tdbOsFree(pMem);
|
|
||||||
} while (1);
|
|
||||||
|
|
||||||
assert(pPool->size == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void closePool(SPoolMem *pPool) {
|
|
||||||
clearPool(pPool);
|
|
||||||
tdbOsFree(pPool);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *poolMalloc(void *arg, size_t size) {
|
|
||||||
void *ptr = NULL;
|
|
||||||
SPoolMem *pPool = (SPoolMem *)arg;
|
|
||||||
SPoolMem *pMem;
|
|
||||||
|
|
||||||
pMem = (SPoolMem *)tdbOsMalloc(sizeof(*pMem) + size);
|
|
||||||
if (pMem == NULL) {
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
pMem->size = sizeof(*pMem) + size;
|
|
||||||
pMem->next = pPool->next;
|
|
||||||
pMem->prev = pPool;
|
|
||||||
|
|
||||||
pPool->next->prev = pMem;
|
|
||||||
pPool->next = pMem;
|
|
||||||
pPool->size += pMem->size;
|
|
||||||
|
|
||||||
ptr = (void *)(&pMem[1]);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void poolFree(void *arg, void *ptr) {
|
|
||||||
SPoolMem *pPool = (SPoolMem *)arg;
|
|
||||||
SPoolMem *pMem;
|
|
||||||
|
|
||||||
pMem = &(((SPoolMem *)ptr)[-1]);
|
|
||||||
|
|
||||||
pMem->next->prev = pMem->prev;
|
|
||||||
pMem->prev->next = pMem->next;
|
|
||||||
pPool->size -= pMem->size;
|
|
||||||
|
|
||||||
tdbOsFree(pMem);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -33,7 +33,6 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
void *pBuf = NULL;
|
void *pBuf = NULL;
|
||||||
int32_t szBuf = 0;
|
int32_t szBuf = 0;
|
||||||
void *p = NULL;
|
void *p = NULL;
|
||||||
SCoder coder = {0};
|
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
|
|
||||||
// validate req
|
// validate req
|
||||||
|
@ -192,7 +191,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq) {
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
int64_t tver;
|
int64_t tver;
|
||||||
SMetaEntry me = {0};
|
SMetaEntry me = {0};
|
||||||
SCoder coder = {0};
|
SDecoder coder = {0};
|
||||||
int8_t type;
|
int8_t type;
|
||||||
int64_t ctime;
|
int64_t ctime;
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
|
@ -201,7 +200,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq) {
|
||||||
// search & delete the name idx
|
// search & delete the name idx
|
||||||
tdbDbcOpen(pMeta->pNameIdx, &pNameIdxc, &pMeta->txn);
|
tdbDbcOpen(pMeta->pNameIdx, &pNameIdxc, &pMeta->txn);
|
||||||
ret = tdbDbcMoveTo(pNameIdxc, pReq->name, strlen(pReq->name) + 1, &c);
|
ret = tdbDbcMoveTo(pNameIdxc, pReq->name, strlen(pReq->name) + 1, &c);
|
||||||
if (ret < 0 || c) {
|
if (ret < 0 || !tdbDbcIsValid(pNameIdxc) || c) {
|
||||||
tdbDbcClose(pNameIdxc);
|
tdbDbcClose(pNameIdxc);
|
||||||
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -253,7 +252,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq) {
|
||||||
// decode entry
|
// decode entry
|
||||||
void *pDataCopy = taosMemoryMalloc(nData); // remove the copy (todo)
|
void *pDataCopy = taosMemoryMalloc(nData); // remove the copy (todo)
|
||||||
memcpy(pDataCopy, pData, nData);
|
memcpy(pDataCopy, pData, nData);
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pDataCopy, nData, TD_DECODER);
|
tDecoderInit(&coder, pDataCopy, nData);
|
||||||
ret = metaDecodeEntry(&coder, &me);
|
ret = metaDecodeEntry(&coder, &me);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
@ -272,7 +271,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(pDataCopy);
|
taosMemoryFree(pDataCopy);
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
tdbDbcClose(pTbDbc);
|
tdbDbcClose(pTbDbc);
|
||||||
|
|
||||||
if (type == TSDB_CHILD_TABLE) {
|
if (type == TSDB_CHILD_TABLE) {
|
||||||
|
@ -309,7 +308,7 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
void *pVal = NULL;
|
void *pVal = NULL;
|
||||||
int kLen = 0;
|
int kLen = 0;
|
||||||
int vLen = 0;
|
int vLen = 0;
|
||||||
SCoder coder = {0};
|
SEncoder coder = {0};
|
||||||
|
|
||||||
// set key and value
|
// set key and value
|
||||||
tbDbKey.version = pME->version;
|
tbDbKey.version = pME->version;
|
||||||
|
@ -330,13 +329,13 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pVal, vLen, TD_ENCODER);
|
tEncoderInit(&coder, pVal, vLen);
|
||||||
|
|
||||||
if (metaEncodeEntry(&coder, pME) < 0) {
|
if (metaEncodeEntry(&coder, pME) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
tCoderClear(&coder);
|
tEncoderClear(&coder);
|
||||||
|
|
||||||
// write to table.db
|
// write to table.db
|
||||||
if (tdbDbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, &pMeta->txn) < 0) {
|
if (tdbDbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, &pMeta->txn) < 0) {
|
||||||
|
@ -393,7 +392,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
SCoder coder = {0};
|
SEncoder coder = {0};
|
||||||
void *pVal = NULL;
|
void *pVal = NULL;
|
||||||
int vLen = 0;
|
int vLen = 0;
|
||||||
int rcode = 0;
|
int rcode = 0;
|
||||||
|
@ -422,7 +421,7 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pVal, vLen, TD_ENCODER);
|
tEncoderInit(&coder, pVal, vLen);
|
||||||
tEncodeSSchemaWrapper(&coder, pSW);
|
tEncodeSSchemaWrapper(&coder, pSW);
|
||||||
|
|
||||||
if (tdbDbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, &pMeta->txn) < 0) {
|
if (tdbDbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, &pMeta->txn) < 0) {
|
||||||
|
@ -432,7 +431,7 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
taosMemoryFree(pVal);
|
taosMemoryFree(pVal);
|
||||||
tCoderClear(&coder);
|
tEncoderClear(&coder);
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -910,12 +910,12 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SCoder decoder;
|
SDecoder decoder;
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, (uint8_t*)msg, msgLen, TD_DECODER);
|
tDecoderInit(&decoder, (uint8_t*)msg, msgLen);
|
||||||
if (tDecodeSStreamTask(&decoder, pTask) < 0) {
|
if (tDecodeSStreamTask(&decoder, pTask) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
tCoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
if (tqExpandTask(pTq, pTask, 4) < 0) {
|
if (tqExpandTask(pTq, pTask, 4) < 0) {
|
||||||
|
|
|
@ -249,8 +249,10 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey
|
||||||
pMergeInfo->keyFirst = TMIN(pMergeInfo->keyFirst, rowKey);
|
pMergeInfo->keyFirst = TMIN(pMergeInfo->keyFirst, rowKey);
|
||||||
pMergeInfo->keyLast = TMAX(pMergeInfo->keyLast, rowKey);
|
pMergeInfo->keyLast = TMAX(pMergeInfo->keyLast, rowKey);
|
||||||
lastKey = rowKey;
|
lastKey = rowKey;
|
||||||
|
if (pCols) {
|
||||||
++pCols->numOfRows;
|
++pCols->numOfRows;
|
||||||
tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row, false);
|
tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row, false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row, true);
|
tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row, true);
|
||||||
}
|
}
|
||||||
|
@ -279,7 +281,7 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (lastKey != TSKEY_INITIAL_VAL) {
|
if (pCols && (lastKey != TSKEY_INITIAL_VAL)) {
|
||||||
++pCols->numOfRows;
|
++pCols->numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ struct SMemSkipListCurosr {
|
||||||
SMemSkipListNode *pNodeC;
|
SMemSkipListNode *pNodeC;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define HASH_BUCKET(SUID, UID, NBUCKET) (TABS((SUID) + (UID)) % (NBUCKET))
|
||||||
|
|
||||||
#define SL_NODE_SIZE(l) (sizeof(SMemSkipListNode) + sizeof(SMemSkipListNode *) * (l)*2)
|
#define SL_NODE_SIZE(l) (sizeof(SMemSkipListNode) + sizeof(SMemSkipListNode *) * (l)*2)
|
||||||
#define SL_NODE_HALF_SIZE(l) (sizeof(SMemSkipListNode) + sizeof(SMemSkipListNode *) * (l))
|
#define SL_NODE_HALF_SIZE(l) (sizeof(SMemSkipListNode) + sizeof(SMemSkipListNode *) * (l))
|
||||||
#define SL_NODE_FORWARD(n, l) ((n)->forwards[l])
|
#define SL_NODE_FORWARD(n, l) ((n)->forwards[l])
|
||||||
|
@ -71,6 +73,8 @@ struct SMemSkipListCurosr {
|
||||||
|
|
||||||
#define SL_HEAD_NODE(sl) ((sl)->pHead)
|
#define SL_HEAD_NODE(sl) ((sl)->pHead)
|
||||||
#define SL_TAIL_NODE(sl) ((SMemSkipListNode *)&SL_NODE_FORWARD(SL_HEAD_NODE(sl), (sl)->maxLevel))
|
#define SL_TAIL_NODE(sl) ((SMemSkipListNode *)&SL_NODE_FORWARD(SL_HEAD_NODE(sl), (sl)->maxLevel))
|
||||||
|
#define SL_HEAD_NODE_FORWARD(n, l) SL_NODE_FORWARD(n, l)
|
||||||
|
#define SL_TAIL_NODE_BACKWARD(n, l) SL_NODE_FORWARD(n, l)
|
||||||
|
|
||||||
// SMemTable
|
// SMemTable
|
||||||
int32_t tsdbMemTableCreate2(STsdb *pTsdb, SMemTable **ppMemTb) {
|
int32_t tsdbMemTableCreate2(STsdb *pTsdb, SMemTable **ppMemTb) {
|
||||||
|
@ -115,19 +119,14 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
|
||||||
STsdb *pTsdb = pMemTb->pTsdb;
|
STsdb *pTsdb = pMemTb->pTsdb;
|
||||||
SVnode *pVnode = pTsdb->pVnode;
|
SVnode *pVnode = pTsdb->pVnode;
|
||||||
SVBufPool *pPool = pVnode->inUse;
|
SVBufPool *pPool = pVnode->inUse;
|
||||||
int32_t hash;
|
tb_uid_t suid = pSubmitBlk->suid;
|
||||||
int32_t tlen;
|
tb_uid_t uid = pSubmitBlk->uid;
|
||||||
uint8_t buf[16];
|
int32_t iBucket;
|
||||||
int32_t rlen;
|
|
||||||
const uint8_t *p;
|
|
||||||
SMemSkipListNode *pSlNode;
|
|
||||||
const STSRow *pTSRow;
|
|
||||||
SMemSkipListCurosr slc = {0};
|
|
||||||
|
|
||||||
// search hash
|
// search SMemData by hash
|
||||||
hash = (pSubmitBlk->suid + pSubmitBlk->uid) % pMemTb->nBucket;
|
iBucket = HASH_BUCKET(suid, uid, pMemTb->nBucket);
|
||||||
for (pMemData = pMemTb->pBuckets[hash]; pMemData; pMemData = pMemData->pHashNext) {
|
for (pMemData = pMemTb->pBuckets[iBucket]; pMemData; pMemData = pMemData->pHashNext) {
|
||||||
if (pMemData->suid == pSubmitBlk->suid && pMemData->uid == pSubmitBlk->uid) break;
|
if (pMemData->suid == suid && pMemData->uid == uid) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create pMemData if need
|
// create pMemData if need
|
||||||
|
@ -143,8 +142,8 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
|
||||||
}
|
}
|
||||||
|
|
||||||
pMemData->pHashNext = NULL;
|
pMemData->pHashNext = NULL;
|
||||||
pMemData->suid = pSubmitBlk->suid;
|
pMemData->suid = suid;
|
||||||
pMemData->uid = pSubmitBlk->uid;
|
pMemData->uid = uid;
|
||||||
pMemData->minKey = TSKEY_MAX;
|
pMemData->minKey = TSKEY_MAX;
|
||||||
pMemData->maxKey = TSKEY_MIN;
|
pMemData->maxKey = TSKEY_MIN;
|
||||||
pMemData->minVer = -1;
|
pMemData->minVer = -1;
|
||||||
|
@ -159,55 +158,67 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
|
||||||
pHead->level = maxLevel;
|
pHead->level = maxLevel;
|
||||||
pTail->level = maxLevel;
|
pTail->level = maxLevel;
|
||||||
for (int iLevel = 0; iLevel < maxLevel; iLevel++) {
|
for (int iLevel = 0; iLevel < maxLevel; iLevel++) {
|
||||||
SL_NODE_FORWARD(pHead, iLevel) = pTail;
|
SL_HEAD_NODE_FORWARD(pHead, iLevel) = pTail;
|
||||||
SL_NODE_FORWARD(pTail, iLevel) = pHead;
|
SL_TAIL_NODE_BACKWARD(pTail, iLevel) = pHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add to MemTable
|
// add to hash
|
||||||
hash = (pMemData->suid + pMemData->uid) % pMemTb->nBucket;
|
if (pMemTb->nHash >= pMemTb->nBucket) {
|
||||||
pMemData->pHashNext = pMemTb->pBuckets[hash];
|
// rehash (todo)
|
||||||
pMemTb->pBuckets[hash] = pMemData;
|
}
|
||||||
|
iBucket = HASH_BUCKET(suid, uid, pMemTb->nBucket);
|
||||||
|
pMemData->pHashNext = pMemTb->pBuckets[iBucket];
|
||||||
|
pMemTb->pBuckets[iBucket] = pMemData;
|
||||||
pMemTb->nHash++;
|
pMemTb->nHash++;
|
||||||
|
|
||||||
|
// sort organize (todo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop to insert data to skiplist
|
// do insert data to SMemData
|
||||||
#if 0
|
SMemSkipListCurosr slc = {0};
|
||||||
tsdbMemSkipListCursorOpen(&slc, &pMemData->sl);
|
const uint8_t *p = pSubmitBlk->pData;
|
||||||
p = pSubmitBlk->pData;
|
const uint8_t *pt;
|
||||||
|
const STSRow *pRow;
|
||||||
|
uint64_t szRow;
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
|
||||||
|
// tCoderInit(&coder, TD_LITTLE_ENDIAN, pSubmitBlk->pData, pSubmitBlk->nData, TD_DECODER);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (p - (uint8_t *)pSubmitBlk->pData >= pSubmitBlk->nData) break;
|
// if (tDecodeIsEnd(&coder)) break;
|
||||||
|
|
||||||
const uint8_t *pt = p;
|
|
||||||
p = tGetBinary(p, &pTSRow, &rlen);
|
|
||||||
|
|
||||||
|
// if (tDecodeBinary(&coder, (const uint8_t **)&pRow, &szRow) < 0) {
|
||||||
|
// terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
// return -1;
|
||||||
|
// }
|
||||||
// check the row (todo)
|
// check the row (todo)
|
||||||
|
|
||||||
// move the cursor to position to write (todo)
|
// // move the cursor to position to write (todo)
|
||||||
int32_t c;
|
// int32_t c;
|
||||||
tsdbMemSkipListCursorMoveTo(&slc, pTSRow, version, &c);
|
// tsdbMemSkipListCursorMoveTo(&slc, pTSRow, version, &c);
|
||||||
ASSERT(c);
|
// ASSERT(c);
|
||||||
|
|
||||||
// encode row
|
// // encode row
|
||||||
int8_t level = tsdbMemSkipListRandLevel(&pMemData->sl);
|
// int8_t level = tsdbMemSkipListRandLevel(&pMemData->sl);
|
||||||
int32_t tsize = SL_NODE_SIZE(level) + sizeof(version) + (p - pt);
|
// int32_t tsize = SL_NODE_SIZE(level) + sizeof(version) + (p - pt);
|
||||||
pSlNode = vnodeBufPoolMalloc(pPool, tsize);
|
// pSlNode = vnodeBufPoolMalloc(pPool, tsize);
|
||||||
pSlNode->level = level;
|
// pSlNode->level = level;
|
||||||
|
|
||||||
uint8_t *pData = SL_NODE_DATA(pSlNode);
|
// uint8_t *pData = SL_NODE_DATA(pSlNode);
|
||||||
*(int64_t *)pData = version;
|
// *(int64_t *)pData = version;
|
||||||
pData += sizeof(version);
|
// pData += sizeof(version);
|
||||||
memcpy(pData, pt, p - pt);
|
// memcpy(pData, pt, p - pt);
|
||||||
|
|
||||||
// insert row
|
// // insert row
|
||||||
tsdbMemSkipListCursorPut(&slc, pSlNode);
|
// tsdbMemSkipListCursorPut(&slc, pSlNode);
|
||||||
|
|
||||||
// update status
|
// update status
|
||||||
if (pTSRow->ts < pMemData->minKey) pMemData->minKey = pTSRow->ts;
|
if (pRow->ts < pMemData->minKey) pMemData->minKey = pRow->ts;
|
||||||
if (pTSRow->ts > pMemData->maxKey) pMemData->maxKey = pTSRow->ts;
|
if (pRow->ts > pMemData->maxKey) pMemData->maxKey = pRow->ts;
|
||||||
}
|
}
|
||||||
tsdbMemSkipListCursorClose(&slc);
|
// tCoderClear(&coder);
|
||||||
#endif
|
// tsdbMemSkipListCursorClose(&slc);
|
||||||
|
|
||||||
|
// update status
|
||||||
if (pMemData->minVer == -1) pMemData->minVer = version;
|
if (pMemData->minVer == -1) pMemData->minVer = version;
|
||||||
if (pMemData->maxVer == -1 || pMemData->maxVer < version) pMemData->maxVer = version;
|
if (pMemData->maxVer == -1 || pMemData->maxVer < version) pMemData->maxVer = version;
|
||||||
|
|
||||||
|
@ -218,7 +229,3 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SMemData
|
|
||||||
|
|
||||||
// SMemSkipList
|
|
|
@ -2006,6 +2006,12 @@ static FORCE_INLINE int32_t tsdbExecuteRSmaImpl(STsdb *pTsdb, const void *pMsg,
|
||||||
qTaskInfo_t *taskInfo, STSchema *pTSchema, tb_uid_t suid, tb_uid_t uid,
|
qTaskInfo_t *taskInfo, STSchema *pTSchema, tb_uid_t suid, tb_uid_t uid,
|
||||||
int8_t level) {
|
int8_t level) {
|
||||||
SArray *pResult = NULL;
|
SArray *pResult = NULL;
|
||||||
|
|
||||||
|
if (!taskInfo) {
|
||||||
|
tsdbDebug("vgId:%d no qTaskInfo to execute rsma %" PRIi8 " task for suid:%" PRIu64, REPO_ID(pTsdb), level, suid);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
tsdbDebug("vgId:%d execute rsma %" PRIi8 " task for qTaskInfo:%p suid:%" PRIu64, REPO_ID(pTsdb), level, taskInfo,
|
tsdbDebug("vgId:%d execute rsma %" PRIi8 " task for qTaskInfo:%p suid:%" PRIu64, REPO_ID(pTsdb), level, taskInfo,
|
||||||
suid);
|
suid);
|
||||||
|
|
||||||
|
@ -2071,10 +2077,18 @@ static int32_t tsdbExecuteRSma(STsdb *pTsdb, const void *pMsg, int32_t inputType
|
||||||
tsdbDebug("vgId:%d no rsma info for suid:%" PRIu64, REPO_ID(pTsdb), suid);
|
tsdbDebug("vgId:%d no rsma info for suid:%" PRIu64, REPO_ID(pTsdb), suid);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
if (!pRSmaInfo->taskInfo[0]) {
|
||||||
|
tsdbDebug("vgId:%d no rsma qTaskInfo for suid:%" PRIu64, REPO_ID(pTsdb), suid);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if (inputType == STREAM_DATA_TYPE_SUBMIT_BLOCK) {
|
if (inputType == STREAM_DATA_TYPE_SUBMIT_BLOCK) {
|
||||||
// TODO: use the proper schema instead of 0, and cache STSchema in cache
|
// TODO: use the proper schema instead of 0, and cache STSchema in cache
|
||||||
STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, suid, 0);
|
STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, suid, 0);
|
||||||
|
if (!pTSchema) {
|
||||||
|
terrno = TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION;
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
tsdbExecuteRSmaImpl(pTsdb, pMsg, inputType, pRSmaInfo->taskInfo[0], pTSchema, suid, uid, TSDB_RETENTION_L1);
|
tsdbExecuteRSmaImpl(pTsdb, pMsg, inputType, pRSmaInfo->taskInfo[0], pTSchema, suid, uid, TSDB_RETENTION_L1);
|
||||||
tsdbExecuteRSmaImpl(pTsdb, pMsg, inputType, pRSmaInfo->taskInfo[1], pTSchema, suid, uid, TSDB_RETENTION_L2);
|
tsdbExecuteRSmaImpl(pTsdb, pMsg, inputType, pRSmaInfo->taskInfo[1], pTSchema, suid, uid, TSDB_RETENTION_L2);
|
||||||
taosMemoryFree(pTSchema);
|
taosMemoryFree(pTSchema);
|
||||||
|
|
|
@ -25,7 +25,7 @@ const SVnodeCfg vnodeCfgDefault = {
|
||||||
.isHeap = false,
|
.isHeap = false,
|
||||||
.isWeak = 0,
|
.isWeak = 0,
|
||||||
.tsdbCfg = {.precision = TSDB_TIME_PRECISION_MILLI,
|
.tsdbCfg = {.precision = TSDB_TIME_PRECISION_MILLI,
|
||||||
.update = 0,
|
.update = 1,
|
||||||
.compression = 2,
|
.compression = 2,
|
||||||
.slLevel = 5,
|
.slLevel = 5,
|
||||||
.days = 10,
|
.days = 10,
|
||||||
|
|
|
@ -286,7 +286,7 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
|
|
||||||
static int vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp) {
|
static int vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp) {
|
||||||
SVCreateStbReq req = {0};
|
SVCreateStbReq req = {0};
|
||||||
SCoder coder;
|
SDecoder coder;
|
||||||
|
|
||||||
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
|
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
|
||||||
pRsp->code = TSDB_CODE_SUCCESS;
|
pRsp->code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -294,7 +294,7 @@ static int vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq,
|
||||||
pRsp->contLen = 0;
|
pRsp->contLen = 0;
|
||||||
|
|
||||||
// decode and process req
|
// decode and process req
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pReq, len, TD_DECODER);
|
tDecoderInit(&coder, pReq, len);
|
||||||
|
|
||||||
if (tDecodeSVCreateStbReq(&coder, &req) < 0) {
|
if (tDecodeSVCreateStbReq(&coder, &req) < 0) {
|
||||||
pRsp->code = terrno;
|
pRsp->code = terrno;
|
||||||
|
@ -308,16 +308,16 @@ static int vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq,
|
||||||
|
|
||||||
tsdbRegisterRSma(pVnode->pTsdb, pVnode->pMeta, &req);
|
tsdbRegisterRSma(pVnode->pTsdb, pVnode->pMeta, &req);
|
||||||
|
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp) {
|
static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp) {
|
||||||
SCoder coder = {0};
|
SDecoder decoder = {0};
|
||||||
int rcode = 0;
|
int rcode = 0;
|
||||||
SVCreateTbBatchReq req = {0};
|
SVCreateTbBatchReq req = {0};
|
||||||
SVCreateTbReq *pCreateReq;
|
SVCreateTbReq *pCreateReq;
|
||||||
|
@ -332,8 +332,8 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq,
|
||||||
pRsp->contLen = 0;
|
pRsp->contLen = 0;
|
||||||
|
|
||||||
// decode
|
// decode
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pReq, len, TD_DECODER);
|
tDecoderInit(&decoder, pReq, len);
|
||||||
if (tDecodeSVCreateTbBatchReq(&coder, &req) < 0) {
|
if (tDecodeSVCreateTbBatchReq(&decoder, &req) < 0) {
|
||||||
rcode = -1;
|
rcode = -1;
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -373,12 +373,13 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq,
|
||||||
taosArrayPush(rsp.pArray, &cRsp);
|
taosArrayPush(rsp.pArray, &cRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
tsdbUpdateTbUidList(pVnode->pTsdb, pStore);
|
tsdbUpdateTbUidList(pVnode->pTsdb, pStore);
|
||||||
tsdbUidStoreFree(pStore);
|
tsdbUidStoreFree(pStore);
|
||||||
|
|
||||||
// prepare rsp
|
// prepare rsp
|
||||||
|
SEncoder encoder = {0};
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
tEncodeSize(tEncodeSVCreateTbBatchRsp, &rsp, pRsp->contLen, ret);
|
tEncodeSize(tEncodeSVCreateTbBatchRsp, &rsp, pRsp->contLen, ret);
|
||||||
pRsp->pCont = rpcMallocCont(pRsp->contLen);
|
pRsp->pCont = rpcMallocCont(pRsp->contLen);
|
||||||
|
@ -387,12 +388,14 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq,
|
||||||
rcode = -1;
|
rcode = -1;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pRsp->pCont, pRsp->contLen, TD_ENCODER);
|
tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen);
|
||||||
tEncodeSVCreateTbBatchRsp(&coder, &rsp);
|
tEncodeSVCreateTbBatchRsp(&encoder, &rsp);
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
taosArrayClear(rsp.pArray);
|
taosArrayClear(rsp.pArray);
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&decoder);
|
||||||
|
tEncoderClear(&encoder);
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,15 +419,15 @@ static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq, int32_t len, SRpc
|
||||||
static int vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SVDropStbReq req = {0};
|
SVDropStbReq req = {0};
|
||||||
int rcode = TSDB_CODE_SUCCESS;
|
int rcode = TSDB_CODE_SUCCESS;
|
||||||
SCoder coder = {0};
|
SDecoder decoder = {0};
|
||||||
|
|
||||||
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
|
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
|
||||||
pRsp->pCont = NULL;
|
pRsp->pCont = NULL;
|
||||||
pRsp->contLen = 0;
|
pRsp->contLen = 0;
|
||||||
|
|
||||||
// decode request
|
// decode request
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pReq, len, TD_DECODER);
|
tDecoderInit(&decoder, pReq, len);
|
||||||
if (tDecodeSVDropStbReq(&coder, &req) < 0) {
|
if (tDecodeSVDropStbReq(&decoder, &req) < 0) {
|
||||||
rcode = TSDB_CODE_INVALID_MSG;
|
rcode = TSDB_CODE_INVALID_MSG;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -438,7 +441,7 @@ static int vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pReq, i
|
||||||
// return rsp
|
// return rsp
|
||||||
_exit:
|
_exit:
|
||||||
pRsp->code = rcode;
|
pRsp->code = rcode;
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,7 +454,7 @@ static int vnodeProcessAlterTbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcM
|
||||||
static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SVDropTbBatchReq req = {0};
|
SVDropTbBatchReq req = {0};
|
||||||
SVDropTbBatchRsp rsp = {0};
|
SVDropTbBatchRsp rsp = {0};
|
||||||
SCoder coder = {0};
|
SDecoder decoder = {0};
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pRsp->msgType = TDMT_VND_DROP_TABLE_RSP;
|
pRsp->msgType = TDMT_VND_DROP_TABLE_RSP;
|
||||||
|
@ -460,8 +463,8 @@ static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
pRsp->code = TSDB_CODE_SUCCESS;
|
pRsp->code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
// decode req
|
// decode req
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pReq, len, TD_DECODER);
|
tDecoderInit(&decoder, pReq, len);
|
||||||
ret = tDecodeSVDropTbBatchReq(&coder, &req);
|
ret = tDecodeSVDropTbBatchReq(&decoder, &req);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
pRsp->code = terrno;
|
pRsp->code = terrno;
|
||||||
|
@ -490,7 +493,7 @@ static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&decoder);
|
||||||
// encode rsp (TODO)
|
// encode rsp (TODO)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -501,7 +504,7 @@ static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
SSubmitBlk *pBlock;
|
SSubmitBlk *pBlock;
|
||||||
SSubmitRsp rsp = {0};
|
SSubmitRsp rsp = {0};
|
||||||
SVCreateTbReq createTbReq = {0};
|
SVCreateTbReq createTbReq = {0};
|
||||||
SCoder coder = {0};
|
SDecoder decoder = {0};
|
||||||
int32_t nRows;
|
int32_t nRows;
|
||||||
|
|
||||||
pRsp->code = 0;
|
pRsp->code = 0;
|
||||||
|
@ -518,17 +521,17 @@ static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
|
|
||||||
// create table for auto create table mode
|
// create table for auto create table mode
|
||||||
if (msgIter.schemaLen > 0) {
|
if (msgIter.schemaLen > 0) {
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pBlock->data, msgIter.schemaLen, TD_DECODER);
|
tDecoderInit(&decoder, pBlock->data, msgIter.schemaLen);
|
||||||
if (tDecodeSVCreateTbReq(&coder, &createTbReq) < 0) {
|
if (tDecodeSVCreateTbReq(&decoder, &createTbReq) < 0) {
|
||||||
pRsp->code = TSDB_CODE_INVALID_MSG;
|
pRsp->code = TSDB_CODE_INVALID_MSG;
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&decoder);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaCreateTable(pVnode->pMeta, version, &createTbReq) < 0) {
|
if (metaCreateTable(pVnode->pMeta, version, &createTbReq) < 0) {
|
||||||
if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
||||||
pRsp->code = terrno;
|
pRsp->code = terrno;
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&decoder);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -540,7 +543,7 @@ static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
msgIter.suid = 0;
|
msgIter.suid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsdbInsertTableData(pVnode->pTsdb, &msgIter, pBlock, &nRows) < 0) {
|
if (tsdbInsertTableData(pVnode->pTsdb, &msgIter, pBlock, &nRows) < 0) {
|
||||||
|
|
|
@ -17,6 +17,6 @@ target_include_directories(
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
|
|
||||||
#if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
ADD_SUBDIRECTORY(test)
|
ADD_SUBDIRECTORY(test)
|
||||||
#endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
||||||
|
|
|
@ -38,6 +38,7 @@ extern "C" {
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tpagedbuf.h"
|
#include "tpagedbuf.h"
|
||||||
|
#include "tstreamUpdate.h"
|
||||||
|
|
||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
#include "executorInt.h"
|
#include "executorInt.h"
|
||||||
|
@ -325,10 +326,15 @@ typedef struct SExchangeInfo {
|
||||||
SLoadRemoteDataInfo loadInfo;
|
SLoadRemoteDataInfo loadInfo;
|
||||||
} SExchangeInfo;
|
} SExchangeInfo;
|
||||||
|
|
||||||
|
#define COL_MATCH_FROM_COL_ID 0x1
|
||||||
|
#define COL_MATCH_FROM_SLOT_ID 0x2
|
||||||
|
|
||||||
typedef struct SColMatchInfo {
|
typedef struct SColMatchInfo {
|
||||||
|
int32_t srcSlotId; // source slot id
|
||||||
int32_t colId;
|
int32_t colId;
|
||||||
int32_t targetSlotId;
|
int32_t targetSlotId;
|
||||||
bool output;
|
bool output;
|
||||||
|
int32_t matchType; // determinate the source according to col id or slot id
|
||||||
} SColMatchInfo;
|
} SColMatchInfo;
|
||||||
|
|
||||||
typedef struct SScanInfo {
|
typedef struct SScanInfo {
|
||||||
|
@ -380,6 +386,9 @@ typedef struct SStreamBlockScanInfo {
|
||||||
void* readerHandle; // stream block reader handle
|
void* readerHandle; // stream block reader handle
|
||||||
SArray* pColMatchInfo; //
|
SArray* pColMatchInfo; //
|
||||||
SNode* pCondition;
|
SNode* pCondition;
|
||||||
|
SArray* tsArray;
|
||||||
|
SUpdateInfo* pUpdateInfo;
|
||||||
|
int32_t primaryTsIndex; // primary time stamp slot id
|
||||||
} SStreamBlockScanInfo;
|
} SStreamBlockScanInfo;
|
||||||
|
|
||||||
typedef struct SSysTableScanInfo {
|
typedef struct SSysTableScanInfo {
|
||||||
|
@ -440,6 +449,7 @@ typedef struct SIntervalAggOperatorInfo {
|
||||||
SArray* pUpdatedWindow; // updated time window due to the input data block from the downstream operator.
|
SArray* pUpdatedWindow; // updated time window due to the input data block from the downstream operator.
|
||||||
STimeWindowAggSupp twAggSup;
|
STimeWindowAggSupp twAggSup;
|
||||||
struct SFillInfo* pFillInfo; // fill info
|
struct SFillInfo* pFillInfo; // fill info
|
||||||
|
bool invertible;
|
||||||
} SIntervalAggOperatorInfo;
|
} SIntervalAggOperatorInfo;
|
||||||
|
|
||||||
typedef struct SAggOperatorInfo {
|
typedef struct SAggOperatorInfo {
|
||||||
|
|
|
@ -60,4 +60,5 @@ void dsScheduleProcess(void* ahandle, void* pItem) {
|
||||||
void dsDestroyDataSinker(DataSinkHandle handle) {
|
void dsDestroyDataSinker(DataSinkHandle handle) {
|
||||||
SDataSinkHandle* pHandleImpl = (SDataSinkHandle*)handle;
|
SDataSinkHandle* pHandleImpl = (SDataSinkHandle*)handle;
|
||||||
pHandleImpl->fDestroy(pHandleImpl);
|
pHandleImpl->fDestroy(pHandleImpl);
|
||||||
|
taosMemoryFree(pHandleImpl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,21 +36,6 @@ typedef struct STaskMgmt {
|
||||||
bool closed;
|
bool closed;
|
||||||
} STaskMgmt;
|
} STaskMgmt;
|
||||||
|
|
||||||
static void taskMgmtKillTaskFn(void* handle, void* param1) {
|
|
||||||
void** fp = (void**)handle;
|
|
||||||
qKillTask(*fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void freeqinfoFn(void *qhandle) {
|
|
||||||
void** handle = qhandle;
|
|
||||||
if (handle == NULL || *handle == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
qKillTask(*handle);
|
|
||||||
qDestroyTask(*handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan,
|
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan,
|
||||||
qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, EOPTR_EXEC_MODEL model) {
|
qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, EOPTR_EXEC_MODEL model) {
|
||||||
assert(readHandle != NULL && pSubplan != NULL);
|
assert(readHandle != NULL && pSubplan != NULL);
|
||||||
|
|
|
@ -198,6 +198,7 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) {
|
||||||
|
|
||||||
pBlock->info.blockId = pNode->dataBlockId;
|
pBlock->info.blockId = pNode->dataBlockId;
|
||||||
pBlock->info.rowSize = pNode->totalRowSize; // todo ??
|
pBlock->info.rowSize = pNode->totalRowSize; // todo ??
|
||||||
|
pBlock->info.type = STREAM_INVALID;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColumnInfoData idata = {{0}};
|
SColumnInfoData idata = {{0}};
|
||||||
|
@ -1225,6 +1226,8 @@ static void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
||||||
|
|
||||||
taosVariantDestroy(&pCtx[i].tag);
|
taosVariantDestroy(&pCtx[i].tag);
|
||||||
taosMemoryFreeClear(pCtx[i].subsidiaries.pCtx);
|
taosMemoryFreeClear(pCtx[i].subsidiaries.pCtx);
|
||||||
|
taosMemoryFree(pCtx[i].input.pData);
|
||||||
|
taosMemoryFree(pCtx[i].input.pColumnDataAgg);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pCtx);
|
taosMemoryFreeClear(pCtx);
|
||||||
|
@ -2840,9 +2843,9 @@ void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray
|
||||||
int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
|
int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
|
||||||
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
|
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
|
||||||
SArray* pColList) {
|
SArray* pColList) {
|
||||||
|
if (pColList == NULL) { // data from other sources
|
||||||
blockDataEnsureCapacity(pRes, numOfRows);
|
blockDataEnsureCapacity(pRes, numOfRows);
|
||||||
|
|
||||||
if (pColList == NULL) { // data from other sources
|
|
||||||
int32_t dataLen = *(int32_t*)pData;
|
int32_t dataLen = *(int32_t*)pData;
|
||||||
pData += sizeof(int32_t);
|
pData += sizeof(int32_t);
|
||||||
|
|
||||||
|
@ -2898,20 +2901,23 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
||||||
pStart += sizeof(SSysTableSchema);
|
pStart += sizeof(SSysTableSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock block = {.pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData)), .info.numOfCols = numOfCols};
|
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
|
pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
||||||
|
pBlock->info.numOfCols = numOfCols;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColumnInfoData idata = {0};
|
SColumnInfoData idata = {0};
|
||||||
idata.info.type = pSchema[i].type;
|
idata.info.type = pSchema[i].type;
|
||||||
idata.info.bytes = pSchema[i].bytes;
|
idata.info.bytes = pSchema[i].bytes;
|
||||||
idata.info.colId = pSchema[i].colId;
|
idata.info.colId = pSchema[i].colId;
|
||||||
|
|
||||||
taosArrayPush(block.pDataBlock, &idata);
|
taosArrayPush(pBlock->pDataBlock, &idata);
|
||||||
if (IS_VAR_DATA_TYPE(idata.info.type)) {
|
if (IS_VAR_DATA_TYPE(idata.info.type)) {
|
||||||
block.info.hasVarCol = true;
|
pBlock->info.hasVarCol = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDataEnsureCapacity(&block, numOfRows);
|
blockDataEnsureCapacity(pBlock, numOfRows);
|
||||||
|
|
||||||
int32_t dataLen = *(int32_t*)pStart;
|
int32_t dataLen = *(int32_t*)pStart;
|
||||||
uint64_t groupId = *(uint64_t*)(pStart + sizeof(int32_t));
|
uint64_t groupId = *(uint64_t*)(pStart + sizeof(int32_t));
|
||||||
|
@ -2924,7 +2930,7 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
||||||
colLen[i] = htonl(colLen[i]);
|
colLen[i] = htonl(colLen[i]);
|
||||||
ASSERT(colLen[i] >= 0);
|
ASSERT(colLen[i] >= 0);
|
||||||
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(block.pDataBlock, i);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||||
pColInfoData->varmeta.length = colLen[i];
|
pColInfoData->varmeta.length = colLen[i];
|
||||||
pColInfoData->varmeta.allocLen = colLen[i];
|
pColInfoData->varmeta.allocLen = colLen[i];
|
||||||
|
@ -2943,7 +2949,10 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
||||||
}
|
}
|
||||||
|
|
||||||
// data from mnode
|
// data from mnode
|
||||||
relocateColumnData(pRes, pColList, block.pDataBlock);
|
relocateColumnData(pRes, pColList, pBlock->pDataBlock);
|
||||||
|
taosArrayDestroy(pBlock->pDataBlock);
|
||||||
|
taosMemoryFree(pBlock);
|
||||||
|
// blockDataDestroy(pBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
pRes->info.rows = numOfRows;
|
pRes->info.rows = numOfRows;
|
||||||
|
@ -4184,6 +4193,18 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) {
|
||||||
pOperator->numOfDownstream = 0;
|
pOperator->numOfDownstream = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pOperator->pExpr != NULL) {
|
||||||
|
for (int32_t i = 0; i < pOperator->numOfExprs; ++i) {
|
||||||
|
SExprInfo* pExprInfo = &pOperator->pExpr[i];
|
||||||
|
if (pExprInfo->pExpr->nodeType == QUERY_NODE_COLUMN) {
|
||||||
|
taosMemoryFree(pExprInfo->base.pParam[0].pCol);
|
||||||
|
}
|
||||||
|
taosMemoryFree(pExprInfo->base.pParam);
|
||||||
|
taosMemoryFree(pExprInfo->pExpr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pOperator->pExpr);
|
||||||
taosMemoryFreeClear(pOperator->info);
|
taosMemoryFreeClear(pOperator->info);
|
||||||
taosMemoryFreeClear(pOperator);
|
taosMemoryFreeClear(pOperator);
|
||||||
}
|
}
|
||||||
|
@ -4195,8 +4216,6 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n
|
||||||
pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput);
|
pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput);
|
||||||
pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t));
|
pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t));
|
||||||
pAggSup->pResultRowHashTable = taosHashInit(10, hashFn, true, HASH_NO_LOCK);
|
pAggSup->pResultRowHashTable = taosHashInit(10, hashFn, true, HASH_NO_LOCK);
|
||||||
// pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK);
|
|
||||||
// pAggSup->pResultRowArrayList = taosArrayInit(10, sizeof(SResultRowCell));
|
|
||||||
|
|
||||||
if (pAggSup->keyBuf == NULL /*|| pAggSup->pResultRowArrayList == NULL || pAggSup->pResultRowListSet == NULL*/ ||
|
if (pAggSup->keyBuf == NULL /*|| pAggSup->pResultRowArrayList == NULL || pAggSup->pResultRowListSet == NULL*/ ||
|
||||||
pAggSup->pResultRowHashTable == NULL) {
|
pAggSup->pResultRowHashTable == NULL) {
|
||||||
|
@ -4358,6 +4377,8 @@ void destroySFillOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput) {
|
static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
SProjectOperatorInfo* pInfo = (SProjectOperatorInfo*)param;
|
SProjectOperatorInfo* pInfo = (SProjectOperatorInfo*)param;
|
||||||
doDestroyBasicInfo(&pInfo->binfo, numOfOutput);
|
doDestroyBasicInfo(&pInfo->binfo, numOfOutput);
|
||||||
|
cleanupAggSup(&pInfo->aggSup);
|
||||||
|
taosArrayDestroy(pInfo->pPseudoColInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) {
|
void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
|
@ -4687,7 +4708,7 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
|
||||||
|
|
||||||
char* p = taosMemoryCalloc(1, 128);
|
char* p = taosMemoryCalloc(1, 128);
|
||||||
snprintf(p, 128, "TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, queryId);
|
snprintf(p, 128, "TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, queryId);
|
||||||
pTaskInfo->id.str = strdup(p);
|
pTaskInfo->id.str = p;
|
||||||
|
|
||||||
return pTaskInfo;
|
return pTaskInfo;
|
||||||
}
|
}
|
||||||
|
@ -4699,10 +4720,9 @@ static int32_t doCreateTableGroup(void* metaHandle, int32_t tableType, uint64_t
|
||||||
uint64_t queryId, uint64_t taskId);
|
uint64_t queryId, uint64_t taskId);
|
||||||
static SArray* extractTableIdList(const STableGroupInfo* pTableGroupInfo);
|
static SArray* extractTableIdList(const STableGroupInfo* pTableGroupInfo);
|
||||||
static SArray* extractColumnInfo(SNodeList* pNodeList);
|
static SArray* extractColumnInfo(SNodeList* pNodeList);
|
||||||
static SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols);
|
static SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols, int32_t type);
|
||||||
|
|
||||||
static SArray* createSortInfo(SNodeList* pNodeList);
|
static SArray* createSortInfo(SNodeList* pNodeList);
|
||||||
static SArray* createIndexMap(SNodeList* pNodeList);
|
|
||||||
static SArray* extractPartitionColInfo(SNodeList* pNodeList);
|
static SArray* extractPartitionColInfo(SNodeList* pNodeList);
|
||||||
static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode);
|
static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode);
|
||||||
static void setJoinColumnInfo(SColumnInfo* pInfo, const SColumnNode* pLeftNode);
|
static void setJoinColumnInfo(SColumnInfo* pInfo, const SColumnNode* pLeftNode);
|
||||||
|
@ -4734,9 +4754,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* pColList =
|
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
||||||
extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
|
SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID);
|
||||||
|
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
||||||
|
|
||||||
SQueryTableDataCond cond = {0};
|
SQueryTableDataCond cond = {0};
|
||||||
int32_t code = initQueryTableDataCond(&cond, pTableScanNode);
|
int32_t code = initQueryTableDataCond(&cond, pTableScanNode);
|
||||||
|
@ -4761,10 +4782,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
int32_t code = doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo, queryId, taskId);
|
int32_t code = doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo, queryId, taskId);
|
||||||
SArray* tableIdList = extractTableIdList(pTableGroupInfo);
|
SArray* tableIdList = extractTableIdList(pTableGroupInfo);
|
||||||
|
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
|
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
||||||
|
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
||||||
|
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
SArray* pCols = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
SArray* pCols = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID);
|
||||||
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle->reader, pResBlock, pCols, tableIdList, pTaskInfo,
|
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle->reader, pResBlock, pCols, tableIdList, pTaskInfo,
|
||||||
pScanPhyNode->node.pConditions);
|
pScanPhyNode->node.pConditions);
|
||||||
taosArrayDestroy(tableIdList);
|
taosArrayDestroy(tableIdList);
|
||||||
|
@ -4773,18 +4795,22 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode;
|
SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode;
|
||||||
SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan;
|
SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan;
|
||||||
|
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pScanNode->node.pOutputDataBlockDesc);
|
SDataBlockDescNode* pDescNode = pScanNode->node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
|
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
||||||
|
|
||||||
int32_t numOfOutputCols = 0;
|
int32_t numOfOutputCols = 0;
|
||||||
SArray* colList =
|
SArray* colList = extractColMatchInfo(pScanNode->pScanCols, pDescNode, &numOfOutputCols, COL_MATCH_FROM_COL_ID);
|
||||||
extractColMatchInfo(pScanNode->pScanCols, pScanNode->node.pOutputDataBlockDesc, &numOfOutputCols);
|
|
||||||
SOperatorInfo* pOperator = createSysTableScanOperatorInfo(
|
SOperatorInfo* pOperator = createSysTableScanOperatorInfo(
|
||||||
pHandle, pResBlock, &pScanNode->tableName, pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet, colList,
|
pHandle, pResBlock, &pScanNode->tableName, pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet, colList,
|
||||||
pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId);
|
pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN == type) {
|
||||||
STagScanPhysiNode* pScanPhyNode = (STagScanPhysiNode*) pPhyNode;
|
STagScanPhysiNode* pScanPhyNode = (STagScanPhysiNode*) pPhyNode;
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
|
|
||||||
|
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
|
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
||||||
|
|
||||||
int32_t code =
|
int32_t code =
|
||||||
doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo, queryId, taskId);
|
doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo, queryId, taskId);
|
||||||
|
@ -4796,8 +4822,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
SExprInfo* pExprInfo = createExprInfo(pScanPhyNode->pScanPseudoCols, NULL, &num);
|
SExprInfo* pExprInfo = createExprInfo(pScanPhyNode->pScanPseudoCols, NULL, &num);
|
||||||
|
|
||||||
int32_t numOfOutputCols = 0;
|
int32_t numOfOutputCols = 0;
|
||||||
SArray* colList =
|
SArray* colList = extractColMatchInfo(pScanPhyNode->pScanPseudoCols, pDescNode, &numOfOutputCols, COL_MATCH_FROM_COL_ID);
|
||||||
extractColMatchInfo(pScanPhyNode->pScanPseudoCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfOutputCols);
|
|
||||||
|
|
||||||
SOperatorInfo* pOperator = createTagScanOperatorInfo(pHandle, pExprInfo, num, pResBlock, colList, pTableGroupInfo, pTaskInfo);
|
SOperatorInfo* pOperator = createTagScanOperatorInfo(pHandle, pExprInfo, num, pResBlock, colList, pTableGroupInfo, pTaskInfo);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
@ -4869,15 +4894,16 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) {
|
||||||
SSortPhysiNode* pSortPhyNode = (SSortPhysiNode*)pPhyNode;
|
SSortPhysiNode* pSortPhyNode = (SSortPhysiNode*)pPhyNode;
|
||||||
|
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
SDataBlockDescNode* pDescNode = pPhyNode->pOutputDataBlockDesc;
|
||||||
|
|
||||||
|
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
||||||
SArray* info = createSortInfo(pSortPhyNode->pSortKeys);
|
SArray* info = createSortInfo(pSortPhyNode->pSortKeys);
|
||||||
|
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
SExprInfo* pExprInfo = createExprInfo(pSortPhyNode->pExprs, NULL, &numOfCols);
|
SExprInfo* pExprInfo = createExprInfo(pSortPhyNode->pExprs, NULL, &numOfCols);
|
||||||
|
|
||||||
int32_t numOfOutputCols = 0;
|
int32_t numOfOutputCols = 0;
|
||||||
SArray* pColList =
|
SArray* pColList = extractColMatchInfo(pSortPhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
|
||||||
extractColMatchInfo(pSortPhyNode->pTargets, pSortPhyNode->node.pOutputDataBlockDesc, &numOfOutputCols);
|
|
||||||
|
|
||||||
pOptr = createSortOperatorInfo(ops[0], pResBlock, info, pExprInfo, numOfCols, pColList, pTaskInfo);
|
pOptr = createSortOperatorInfo(ops[0], pResBlock, info, pExprInfo, numOfCols, pColList, pTaskInfo);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW == type) {
|
||||||
|
@ -5059,25 +5085,7 @@ SArray* createSortInfo(SNodeList* pNodeList) {
|
||||||
return pList;
|
return pList;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* createIndexMap(SNodeList* pNodeList) {
|
SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols, int32_t type) {
|
||||||
size_t numOfCols = LIST_LENGTH(pNodeList);
|
|
||||||
SArray* pList = taosArrayInit(numOfCols, sizeof(int32_t));
|
|
||||||
if (pList == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return pList;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
|
||||||
STargetNode* pTarget = (STargetNode*)nodesListGetNode(pNodeList, i);
|
|
||||||
|
|
||||||
SColumnNode* pColNode = (SColumnNode*)pTarget->pExpr;
|
|
||||||
taosArrayPush(pList, &pColNode->slotId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pList;
|
|
||||||
}
|
|
||||||
|
|
||||||
SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols) {
|
|
||||||
size_t numOfCols = LIST_LENGTH(pNodeList);
|
size_t numOfCols = LIST_LENGTH(pNodeList);
|
||||||
SArray* pList = taosArrayInit(numOfCols, sizeof(SColMatchInfo));
|
SArray* pList = taosArrayInit(numOfCols, sizeof(SColMatchInfo));
|
||||||
if (pList == NULL) {
|
if (pList == NULL) {
|
||||||
|
@ -5092,6 +5100,8 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
|
||||||
SColMatchInfo c = {0};
|
SColMatchInfo c = {0};
|
||||||
c.output = true;
|
c.output = true;
|
||||||
c.colId = pColNode->colId;
|
c.colId = pColNode->colId;
|
||||||
|
c.srcSlotId = pColNode->slotId;
|
||||||
|
c.matchType = type;
|
||||||
c.targetSlotId = pNode->slotId;
|
c.targetSlotId = pNode->slotId;
|
||||||
taosArrayPush(pList, &c);
|
taosArrayPush(pList, &c);
|
||||||
}
|
}
|
||||||
|
@ -5298,6 +5308,7 @@ void doDestroyTask(SExecTaskInfo* pTaskInfo) {
|
||||||
qDebug("%s execTask is freed", GET_TASKID(pTaskInfo));
|
qDebug("%s execTask is freed", GET_TASKID(pTaskInfo));
|
||||||
|
|
||||||
doDestroyTableQueryInfo(&pTaskInfo->tableqinfoGroupInfo);
|
doDestroyTableQueryInfo(&pTaskInfo->tableqinfoGroupInfo);
|
||||||
|
destroyOperatorInfo(pTaskInfo->pRoot);
|
||||||
// taosArrayDestroy(pTaskInfo->summary.queryProfEvents);
|
// taosArrayDestroy(pTaskInfo->summary.queryProfEvents);
|
||||||
// taosHashCleanup(pTaskInfo->summary.operatorProfResults);
|
// taosHashCleanup(pTaskInfo->summary.operatorProfResults);
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ static void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSData
|
||||||
char* val = colDataGetData(pColInfoData, rowIndex);
|
char* val = colDataGetData(pColInfoData, rowIndex);
|
||||||
if (IS_VAR_DATA_TYPE(pkey->type)) {
|
if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||||
memcpy(pkey->pData, val, varDataTLen(val));
|
memcpy(pkey->pData, val, varDataTLen(val));
|
||||||
|
ASSERT(varDataTLen(val) <= pkey->bytes);
|
||||||
} else {
|
} else {
|
||||||
memcpy(pkey->pData, val, pkey->bytes);
|
memcpy(pkey->pData, val, pkey->bytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -512,6 +512,25 @@ static void doClearBufferedBlocks(SStreamBlockScanInfo* pInfo) {
|
||||||
taosArrayClear(pInfo->pBlockLists);
|
taosArrayClear(pInfo->pBlockLists);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* getUpdateDataBlock(SStreamBlockScanInfo* pInfo) {
|
||||||
|
SColumnInfoData* pColDataInfo = taosArrayGet(pInfo->pRes->pDataBlock, pInfo->primaryTsIndex);
|
||||||
|
TSKEY* ts = (TSKEY*)pColDataInfo->pData;
|
||||||
|
for (int32_t i = 0; i < pInfo->pRes->info.rows; i++) {
|
||||||
|
if (updateInfoIsUpdated(pInfo->pUpdateInfo, pInfo->pRes->info.uid, ts[i])) {
|
||||||
|
taosArrayPush(pInfo->tsArray, ts+i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (taosArrayGetSize(pInfo->tsArray) > 0) {
|
||||||
|
//TODO(liuyao) get from tsdb
|
||||||
|
// SSDataBlock* p = createOneDataBlock(pInfo->pRes, true);
|
||||||
|
// p->info.type = STREAM_INVERT;
|
||||||
|
// taosArrayClear(pInfo->tsArray);
|
||||||
|
// return p;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
// NOTE: this operator does never check if current status is done or not
|
// NOTE: this operator does never check if current status is done or not
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
@ -523,8 +542,8 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->blockType == STREAM_DATA_TYPE_SSDATA_BLOCK) {
|
|
||||||
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
||||||
|
if (pInfo->blockType == STREAM_DATA_TYPE_SSDATA_BLOCK) {
|
||||||
if (pInfo->validBlockIndex >= total) {
|
if (pInfo->validBlockIndex >= total) {
|
||||||
doClearBufferedBlocks(pInfo);
|
doClearBufferedBlocks(pInfo);
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
|
@ -534,6 +553,14 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
int32_t current = pInfo->validBlockIndex++;
|
int32_t current = pInfo->validBlockIndex++;
|
||||||
return taosArrayGetP(pInfo->pBlockLists, current);
|
return taosArrayGetP(pInfo->pBlockLists, current);
|
||||||
} else {
|
} else {
|
||||||
|
if (total > 0) {
|
||||||
|
ASSERT(total == 2);
|
||||||
|
SSDataBlock* pRes = taosArrayGetP(pInfo->pBlockLists, 0);
|
||||||
|
SSDataBlock* pUpRes = taosArrayGetP(pInfo->pBlockLists, 1);
|
||||||
|
blockDataDestroy(pUpRes);
|
||||||
|
taosArrayClear(pInfo->pBlockLists);
|
||||||
|
return pRes;
|
||||||
|
}
|
||||||
SDataBlockInfo* pBlockInfo = &pInfo->pRes->info;
|
SDataBlockInfo* pBlockInfo = &pInfo->pRes->info;
|
||||||
blockDataCleanup(pInfo->pRes);
|
blockDataCleanup(pInfo->pRes);
|
||||||
|
|
||||||
|
@ -554,6 +581,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
pInfo->pRes->info.groupId = groupId;
|
pInfo->pRes->info.groupId = groupId;
|
||||||
pInfo->pRes->info.rows = numOfRows;
|
pInfo->pRes->info.rows = numOfRows;
|
||||||
pInfo->pRes->info.uid = uid;
|
pInfo->pRes->info.uid = uid;
|
||||||
|
pInfo->pRes->info.type = STREAM_NORMAL;
|
||||||
|
|
||||||
int32_t numOfCols = pInfo->pRes->info.numOfCols;
|
int32_t numOfCols = pInfo->pRes->info.numOfCols;
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
@ -598,6 +626,13 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
if (rows == 0) {
|
if (rows == 0) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
|
} else {
|
||||||
|
SSDataBlock* upRes = getUpdateDataBlock(pInfo);
|
||||||
|
if (upRes) {
|
||||||
|
taosArrayPush(pInfo->pBlockLists, &(pInfo->pRes));
|
||||||
|
taosArrayPush(pInfo->pBlockLists, &upRes);
|
||||||
|
return upRes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (rows == 0) ? NULL : pInfo->pRes;
|
return (rows == 0) ? NULL : pInfo->pRes;
|
||||||
|
@ -636,6 +671,21 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock*
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pInfo->tsArray = taosArrayInit(4, sizeof(TSKEY));
|
||||||
|
if (pInfo->tsArray == NULL) {
|
||||||
|
taosMemoryFreeClear(pInfo);
|
||||||
|
taosMemoryFreeClear(pOperator);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pInfo->primaryTsIndex = 0; //TODO(liuyao) get it from physical plan
|
||||||
|
pInfo->pUpdateInfo = updateInfoInit(60000, 0, 100); //TODO(liuyao) get it from physical plan
|
||||||
|
if (pInfo->pUpdateInfo == NULL) {
|
||||||
|
taosMemoryFreeClear(pInfo);
|
||||||
|
taosMemoryFreeClear(pOperator);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
pInfo->readerHandle = streamReadHandle;
|
pInfo->readerHandle = streamReadHandle;
|
||||||
pInfo->pRes = pResBlock;
|
pInfo->pRes = pResBlock;
|
||||||
pInfo->pCondition = pCondition;
|
pInfo->pCondition = pCondition;
|
||||||
|
@ -670,6 +720,8 @@ static void destroySysScanOperator(void* param, int32_t numOfOutput) {
|
||||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
metaCloseTbCursor(pInfo->pCur);
|
metaCloseTbCursor(pInfo->pCur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pInfo->scanCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
EDealRes getDBNameFromConditionWalker(SNode* pNode, void* pContext) {
|
EDealRes getDBNameFromConditionWalker(SNode* pNode, void* pContext) {
|
||||||
|
@ -1248,6 +1300,11 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) {
|
||||||
SExprInfo* pExprInfo = &pOperator->pExpr[0];
|
SExprInfo* pExprInfo = &pOperator->pExpr[0];
|
||||||
SSDataBlock* pRes = pInfo->pRes;
|
SSDataBlock* pRes = pInfo->pRes;
|
||||||
|
|
||||||
|
if (taosArrayGetSize(pInfo->pTableGroups->pGroupList) == 0) {
|
||||||
|
setTaskStatus(pTaskInfo, TASK_COMPLETED);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SArray* pa = taosArrayGetP(pInfo->pTableGroups->pGroupList, 0);
|
SArray* pa = taosArrayGetP(pInfo->pTableGroups->pGroupList, 0);
|
||||||
|
|
||||||
char str[512] = {0};
|
char str[512] = {0};
|
||||||
|
|
|
@ -87,17 +87,13 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i
|
||||||
|
|
||||||
if (p->info.rows > 0) {
|
if (p->info.rows > 0) {
|
||||||
int32_t numOfCols = taosArrayGetSize(pColMatchInfo);
|
int32_t numOfCols = taosArrayGetSize(pColMatchInfo);
|
||||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, i);
|
SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, i);
|
||||||
|
ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID);
|
||||||
|
|
||||||
for(int32_t j = 0; j < p->info.numOfCols; ++j) {
|
SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, pmInfo->srcSlotId);
|
||||||
SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, j);
|
|
||||||
if (pSrc->info.colId == pmInfo->colId) {
|
|
||||||
SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->targetSlotId);
|
SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->targetSlotId);
|
||||||
colDataAssign(pDst, pSrc, p->info.rows);
|
colDataAssign(pDst, pSrc, p->info.rows);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pDataBlock->info.rows = p->info.rows;
|
pDataBlock->info.rows = p->info.rows;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
#include "executorimpl.h"
|
#include "executorimpl.h"
|
||||||
|
#include "functionMgt.h"
|
||||||
|
|
||||||
typedef enum SResultTsInterpType {
|
typedef enum SResultTsInterpType {
|
||||||
RESULT_ROW_START_INTERP = 1,
|
RESULT_ROW_START_INTERP = 1,
|
||||||
|
@ -979,6 +980,15 @@ static void finalizeUpdatedResult(int32_t numOfOutput, SDiskbasedBuf* pBuf, SArr
|
||||||
releaseBufPage(pBuf, bufPage);
|
releaseBufPage(pBuf, bufPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static void setInverFunction(SqlFunctionCtx* pCtx, int32_t num, EStreamType type) {
|
||||||
|
for ( int i = 0; i < num; i++) {
|
||||||
|
if (type == STREAM_INVERT) {
|
||||||
|
fmSetInvertFunc(pCtx[i].functionId, &(pCtx[i].fpSet));
|
||||||
|
} else if (type == STREAM_NORMAL){
|
||||||
|
fmSetNormalFunc(pCtx[i].functionId, &(pCtx[i].fpSet));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
SIntervalAggOperatorInfo* pInfo = pOperator->info;
|
SIntervalAggOperatorInfo* pInfo = pOperator->info;
|
||||||
|
@ -1016,6 +1026,9 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfExprs);
|
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfExprs);
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order, true);
|
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order, true);
|
||||||
|
if (pInfo->invertible) {
|
||||||
|
setInverFunction(pInfo->binfo.pCtx, pOperator->numOfExprs, pBlock->info.type);
|
||||||
|
}
|
||||||
pUpdated = hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0);
|
pUpdated = hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1043,6 +1056,15 @@ void destroyIntervalOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
cleanupAggSup(&pInfo->aggSup);
|
cleanupAggSup(&pInfo->aggSup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool allInvertible(SqlFunctionCtx* pFCtx, int32_t numOfCols) {
|
||||||
|
for (int32_t i = 0; i < numOfCols; i++) {
|
||||||
|
if (!fmIsInvertible(pFCtx[i].functionId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
||||||
STimeWindowAggSupp* pTwAggSupp, const STableGroupInfo* pTableGroupInfo,
|
STimeWindowAggSupp* pTwAggSupp, const STableGroupInfo* pTableGroupInfo,
|
||||||
|
@ -1068,6 +1090,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
||||||
initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, pResBlock, keyBufSize, pTaskInfo->id.str);
|
initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, pResBlock, keyBufSize, pTaskInfo->id.str);
|
||||||
|
|
||||||
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pInfo->win);
|
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pInfo->win);
|
||||||
|
pInfo->invertible = allInvertible(pInfo->binfo.pCtx, numOfCols);
|
||||||
|
|
||||||
// pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo);
|
// pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS /* || pInfo->pTableQueryInfo == NULL*/) {
|
if (code != TSDB_CODE_SUCCESS /* || pInfo->pTableQueryInfo == NULL*/) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ typedef struct SBuiltinFuncDefinition {
|
||||||
FExecProcess processFunc;
|
FExecProcess processFunc;
|
||||||
FScalarExecProcess sprocessFunc;
|
FScalarExecProcess sprocessFunc;
|
||||||
FExecFinalize finalizeFunc;
|
FExecFinalize finalizeFunc;
|
||||||
|
FExecProcess invertFunc;
|
||||||
} SBuiltinFuncDefinition;
|
} SBuiltinFuncDefinition;
|
||||||
|
|
||||||
extern const SBuiltinFuncDefinition funcMgtBuiltins[];
|
extern const SBuiltinFuncDefinition funcMgtBuiltins[];
|
||||||
|
|
|
@ -30,10 +30,12 @@ int32_t functionFinalizeWithResultBuf(SqlFunctionCtx* pCtx, SSDataBlock* pBlock,
|
||||||
EFuncDataRequired countDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
EFuncDataRequired countDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||||
bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
int32_t countFunction(SqlFunctionCtx *pCtx);
|
int32_t countFunction(SqlFunctionCtx *pCtx);
|
||||||
|
int32_t countInvertFunction(SqlFunctionCtx *pCtx);
|
||||||
|
|
||||||
EFuncDataRequired statisDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
EFuncDataRequired statisDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||||
bool getSumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getSumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
int32_t sumFunction(SqlFunctionCtx *pCtx);
|
int32_t sumFunction(SqlFunctionCtx *pCtx);
|
||||||
|
int32_t sumInvertFunction(SqlFunctionCtx *pCtx);
|
||||||
|
|
||||||
bool minFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
bool minFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
bool maxFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
bool maxFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
|
@ -45,11 +47,13 @@ bool getAvgFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
bool avgFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
bool avgFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
int32_t avgFunction(SqlFunctionCtx* pCtx);
|
int32_t avgFunction(SqlFunctionCtx* pCtx);
|
||||||
int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
int32_t avgInvertFunction(SqlFunctionCtx* pCtx);
|
||||||
|
|
||||||
bool getStddevFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getStddevFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
bool stddevFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
bool stddevFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
int32_t stddevFunction(SqlFunctionCtx* pCtx);
|
int32_t stddevFunction(SqlFunctionCtx* pCtx);
|
||||||
int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
int32_t stddevInvertFunction(SqlFunctionCtx* pCtx);
|
||||||
|
|
||||||
bool getPercentileFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getPercentileFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
bool percentileFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
bool percentileFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
|
|
|
@ -241,7 +241,7 @@ static int32_t translateHistogram(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE };
|
pFunc->node.resType = (SDataType) { .bytes = 512, .type = TSDB_DATA_TYPE_BINARY };
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,7 +473,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getCountFuncEnv,
|
.getEnvFunc = getCountFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = countFunction,
|
.processFunc = countFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize,
|
||||||
|
.invertFunc = countInvertFunction
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "sum",
|
.name = "sum",
|
||||||
|
@ -484,7 +485,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getSumFuncEnv,
|
.getEnvFunc = getSumFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = sumFunction,
|
.processFunc = sumFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize,
|
||||||
|
.invertFunc = sumInvertFunction
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "min",
|
.name = "min",
|
||||||
|
@ -516,7 +518,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getStddevFuncEnv,
|
.getEnvFunc = getStddevFuncEnv,
|
||||||
.initFunc = stddevFunctionSetup,
|
.initFunc = stddevFunctionSetup,
|
||||||
.processFunc = stddevFunction,
|
.processFunc = stddevFunction,
|
||||||
.finalizeFunc = stddevFinalize
|
.finalizeFunc = stddevFinalize,
|
||||||
|
.invertFunc = stddevInvertFunction
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "avg",
|
.name = "avg",
|
||||||
|
@ -526,7 +529,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getAvgFuncEnv,
|
.getEnvFunc = getAvgFuncEnv,
|
||||||
.initFunc = avgFunctionSetup,
|
.initFunc = avgFunctionSetup,
|
||||||
.processFunc = avgFunction,
|
.processFunc = avgFunction,
|
||||||
.finalizeFunc = avgFinalize
|
.finalizeFunc = avgFinalize,
|
||||||
|
.invertFunc = avgInvertFunction
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "percentile",
|
.name = "percentile",
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "builtinsimpl.h"
|
#include "builtinsimpl.h"
|
||||||
|
#include "cJSON.h"
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
#include "taggfunction.h"
|
#include "taggfunction.h"
|
||||||
|
@ -106,6 +107,13 @@ typedef struct SHistoFuncInfo {
|
||||||
SHistoFuncBin bins[];
|
SHistoFuncBin bins[];
|
||||||
} SHistoFuncInfo;
|
} SHistoFuncInfo;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
UNKNOWN_BIN = 0,
|
||||||
|
USER_INPUT_BIN,
|
||||||
|
LINEAR_BIN,
|
||||||
|
LOG_BIN
|
||||||
|
} EHistoBinType;
|
||||||
|
|
||||||
|
|
||||||
#define SET_VAL(_info, numOfElem, res) \
|
#define SET_VAL(_info, numOfElem, res) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -201,11 +209,7 @@ bool getCountFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static FORCE_INLINE int32_t getNumofElem(SqlFunctionCtx* pCtx) {
|
||||||
* count function does need the finalize, if data is missing, the default value, which is 0, is used
|
|
||||||
* count function does not use the pCtx->interResBuf to keep the intermediate buffer
|
|
||||||
*/
|
|
||||||
int32_t countFunction(SqlFunctionCtx* pCtx) {
|
|
||||||
int32_t numOfElem = 0;
|
int32_t numOfElem = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -232,7 +236,14 @@ int32_t countFunction(SqlFunctionCtx* pCtx) {
|
||||||
numOfElem = pInput->numOfRows;
|
numOfElem = pInput->numOfRows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return numOfElem;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* count function does need the finalize, if data is missing, the default value, which is 0, is used
|
||||||
|
* count function does not use the pCtx->interResBuf to keep the intermediate buffer
|
||||||
|
*/
|
||||||
|
int32_t countFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
int32_t numOfElem = getNumofElem(pCtx);
|
||||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
char* buf = GET_ROWCELL_INTERBUF(pResInfo);
|
char* buf = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
*((int64_t*)buf) += numOfElem;
|
*((int64_t*)buf) += numOfElem;
|
||||||
|
@ -241,6 +252,17 @@ int32_t countFunction(SqlFunctionCtx* pCtx) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t countInvertFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
int32_t numOfElem = getNumofElem(pCtx);
|
||||||
|
|
||||||
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
char* buf = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
*((int64_t*)buf) -= numOfElem;
|
||||||
|
|
||||||
|
SET_VAL(pResInfo, *((int64_t*)buf), 1);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
#define LIST_ADD_N(_res, _col, _start, _rows, _t, numOfElem) \
|
#define LIST_ADD_N(_res, _col, _start, _rows, _t, numOfElem) \
|
||||||
do { \
|
do { \
|
||||||
_t* d = (_t*)(_col->pData); \
|
_t* d = (_t*)(_col->pData); \
|
||||||
|
@ -253,6 +275,18 @@ int32_t countFunction(SqlFunctionCtx* pCtx) {
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define LIST_SUB_N(_res, _col, _start, _rows, _t, numOfElem) \
|
||||||
|
do { \
|
||||||
|
_t* d = (_t*)(_col->pData); \
|
||||||
|
for (int32_t i = (_start); i < (_rows) + (_start); ++i) { \
|
||||||
|
if (((_col)->hasNull) && colDataIsNull_f((_col)->nullbitmap, i)) { \
|
||||||
|
continue; \
|
||||||
|
}; \
|
||||||
|
(_res) -= (d)[i]; \
|
||||||
|
(numOfElem)++; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
int32_t sumFunction(SqlFunctionCtx* pCtx) {
|
int32_t sumFunction(SqlFunctionCtx* pCtx) {
|
||||||
int32_t numOfElem = 0;
|
int32_t numOfElem = 0;
|
||||||
|
|
||||||
|
@ -312,6 +346,65 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t sumInvertFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
int32_t numOfElem = 0;
|
||||||
|
|
||||||
|
// Only the pre-computing information loaded and actual data does not loaded
|
||||||
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
|
SColumnDataAgg* pAgg = pInput->pColumnDataAgg[0];
|
||||||
|
int32_t type = pInput->pData[0]->info.type;
|
||||||
|
|
||||||
|
SSumRes* pSumRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||||
|
|
||||||
|
if (pInput->colDataAggIsSet) {
|
||||||
|
numOfElem = pInput->numOfRows - pAgg->numOfNull;
|
||||||
|
ASSERT(numOfElem >= 0);
|
||||||
|
|
||||||
|
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||||
|
pSumRes->isum -= pAgg->sum;
|
||||||
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
|
pSumRes->usum -= pAgg->sum;
|
||||||
|
} else if (IS_FLOAT_TYPE(type)) {
|
||||||
|
pSumRes->dsum -= GET_DOUBLE_VAL((const char*)&(pAgg->sum));
|
||||||
|
}
|
||||||
|
} else { // computing based on the true data block
|
||||||
|
SColumnInfoData* pCol = pInput->pData[0];
|
||||||
|
|
||||||
|
int32_t start = pInput->startRowIndex;
|
||||||
|
int32_t numOfRows = pInput->numOfRows;
|
||||||
|
|
||||||
|
if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) {
|
||||||
|
if (type == TSDB_DATA_TYPE_TINYINT || type == TSDB_DATA_TYPE_BOOL) {
|
||||||
|
LIST_SUB_N(pSumRes->isum, pCol, start, numOfRows, int8_t, numOfElem);
|
||||||
|
} else if (type == TSDB_DATA_TYPE_SMALLINT) {
|
||||||
|
LIST_SUB_N(pSumRes->isum, pCol, start, numOfRows, int16_t, numOfElem);
|
||||||
|
} else if (type == TSDB_DATA_TYPE_INT) {
|
||||||
|
LIST_SUB_N(pSumRes->isum, pCol, start, numOfRows, int32_t, numOfElem);
|
||||||
|
} else if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||||
|
LIST_SUB_N(pSumRes->isum, pCol, start, numOfRows, int64_t, numOfElem);
|
||||||
|
}
|
||||||
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
|
if (type == TSDB_DATA_TYPE_UTINYINT) {
|
||||||
|
LIST_SUB_N(pSumRes->usum, pCol, start, numOfRows, uint8_t, numOfElem);
|
||||||
|
} else if (type == TSDB_DATA_TYPE_USMALLINT) {
|
||||||
|
LIST_SUB_N(pSumRes->usum, pCol, start, numOfRows, uint16_t, numOfElem);
|
||||||
|
} else if (type == TSDB_DATA_TYPE_UINT) {
|
||||||
|
LIST_SUB_N(pSumRes->usum, pCol, start, numOfRows, uint32_t, numOfElem);
|
||||||
|
} else if (type == TSDB_DATA_TYPE_UBIGINT) {
|
||||||
|
LIST_SUB_N(pSumRes->usum, pCol, start, numOfRows, uint64_t, numOfElem);
|
||||||
|
}
|
||||||
|
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
|
LIST_SUB_N(pSumRes->dsum, pCol, start, numOfRows, double, numOfElem);
|
||||||
|
} else if (type == TSDB_DATA_TYPE_FLOAT) {
|
||||||
|
LIST_SUB_N(pSumRes->dsum, pCol, start, numOfRows, float, numOfElem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// data in the check operation are all null, not output
|
||||||
|
SET_VAL(GET_RES_INFO(pCtx), numOfElem, 1);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
bool getSumFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
bool getSumFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
||||||
pEnv->calcMemSize = sizeof(SSumRes);
|
pEnv->calcMemSize = sizeof(SSumRes);
|
||||||
return true;
|
return true;
|
||||||
|
@ -443,6 +536,69 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define LIST_AVG_N(sumT, T) \
|
||||||
|
do { \
|
||||||
|
T* plist = (T*)pCol->pData; \
|
||||||
|
for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { \
|
||||||
|
if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { \
|
||||||
|
continue; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
numOfElem += 1; \
|
||||||
|
pAvgRes->count -= 1; \
|
||||||
|
sumT -= plist[i]; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
int32_t avgInvertFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
int32_t numOfElem = 0;
|
||||||
|
|
||||||
|
// Only the pre-computing information loaded and actual data does not loaded
|
||||||
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
|
int32_t type = pInput->pData[0]->info.type;
|
||||||
|
|
||||||
|
SAvgRes* pAvgRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||||
|
|
||||||
|
// computing based on the true data block
|
||||||
|
SColumnInfoData* pCol = pInput->pData[0];
|
||||||
|
|
||||||
|
int32_t start = pInput->startRowIndex;
|
||||||
|
int32_t numOfRows = pInput->numOfRows;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case TSDB_DATA_TYPE_TINYINT: {
|
||||||
|
LIST_AVG_N(pAvgRes->sum.isum, int8_t);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_SMALLINT: {
|
||||||
|
LIST_AVG_N(pAvgRes->sum.isum, int16_t);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_INT: {
|
||||||
|
LIST_AVG_N(pAvgRes->sum.isum, int32_t);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_BIGINT: {
|
||||||
|
LIST_AVG_N(pAvgRes->sum.isum, int64_t);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_FLOAT: {
|
||||||
|
LIST_AVG_N(pAvgRes->sum.dsum, float);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
|
LIST_AVG_N(pAvgRes->sum.dsum, double);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// data in the check operation are all null, not output
|
||||||
|
SET_VAL(GET_RES_INFO(pCtx), numOfElem, 1);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
SInputColumnInfoData* pInput = &pCtx->input;
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
int32_t type = pInput->pData[0]->info.type;
|
int32_t type = pInput->pData[0]->info.type;
|
||||||
|
@ -877,6 +1033,69 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define LIST_STDDEV_SUB_N(sumT, T) \
|
||||||
|
do { \
|
||||||
|
T* plist = (T*)pCol->pData; \
|
||||||
|
for (int32_t i = start; i < numOfRows + start; ++i) { \
|
||||||
|
if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { \
|
||||||
|
continue; \
|
||||||
|
} \
|
||||||
|
numOfElem += 1; \
|
||||||
|
pStddevRes->count -= 1; \
|
||||||
|
sumT -= plist[i]; \
|
||||||
|
pStddevRes->quadraticISum -= plist[i] * plist[i]; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
int32_t stddevInvertFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
int32_t numOfElem = 0;
|
||||||
|
|
||||||
|
// Only the pre-computing information loaded and actual data does not loaded
|
||||||
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
|
int32_t type = pInput->pData[0]->info.type;
|
||||||
|
|
||||||
|
SStddevRes* pStddevRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||||
|
|
||||||
|
// computing based on the true data block
|
||||||
|
SColumnInfoData* pCol = pInput->pData[0];
|
||||||
|
|
||||||
|
int32_t start = pInput->startRowIndex;
|
||||||
|
int32_t numOfRows = pInput->numOfRows;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case TSDB_DATA_TYPE_TINYINT: {
|
||||||
|
LIST_STDDEV_SUB_N(pStddevRes->isum, int8_t);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_SMALLINT: {
|
||||||
|
LIST_STDDEV_SUB_N(pStddevRes->isum, int16_t);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_INT: {
|
||||||
|
LIST_STDDEV_SUB_N(pStddevRes->isum, int32_t);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_BIGINT: {
|
||||||
|
LIST_STDDEV_SUB_N(pStddevRes->isum, int64_t);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_FLOAT: {
|
||||||
|
LIST_STDDEV_SUB_N(pStddevRes->dsum, float);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
|
LIST_STDDEV_SUB_N(pStddevRes->dsum, double);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// data in the check operation are all null, not output
|
||||||
|
SET_VAL(GET_RES_INFO(pCtx), numOfElem, 1);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
SInputColumnInfoData* pInput = &pCtx->input;
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
int32_t type = pInput->pData[0]->info.type;
|
int32_t type = pInput->pData[0]->info.type;
|
||||||
|
@ -1438,11 +1657,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
// initial value is not set yet
|
// initial value is not set yet
|
||||||
if (numOfElems <= 0) {
|
if (numOfElems <= 0) {
|
||||||
/*
|
|
||||||
* 1. current block and blocks before are full of null
|
|
||||||
* 2. current block may be null value
|
|
||||||
*/
|
|
||||||
assert(pCtx->hasNull);
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return (isFirstBlock) ? numOfElems - 1 : numOfElems;
|
return (isFirstBlock) ? numOfElems - 1 : numOfElems;
|
||||||
|
@ -1801,28 +2015,241 @@ bool getHistogramFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool histogramFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) {
|
static int8_t getHistogramBinType(char *binTypeStr) {
|
||||||
|
int8_t binType;
|
||||||
|
if (strcasecmp(binTypeStr, "user_input") == 0) {
|
||||||
|
binType = USER_INPUT_BIN;
|
||||||
|
} else if (strcasecmp(binTypeStr, "linear_bin") == 0) {
|
||||||
|
binType = LINEAR_BIN;
|
||||||
|
} else if (strcasecmp(binTypeStr, "log_bin") == 0) {
|
||||||
|
binType = LOG_BIN;
|
||||||
|
} else {
|
||||||
|
binType = UNKNOWN_BIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return binType;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool getHistogramBinDesc(SHistoFuncInfo *pInfo, char *binDescStr, int8_t binType, bool normalized) {
|
||||||
|
cJSON* binDesc = cJSON_Parse(binDescStr);
|
||||||
|
int32_t numOfBins;
|
||||||
|
double* intervals;
|
||||||
|
if (cJSON_IsObject(binDesc)) { /* linaer/log bins */
|
||||||
|
int32_t numOfParams = cJSON_GetArraySize(binDesc);
|
||||||
|
int32_t startIndex;
|
||||||
|
if (numOfParams != 4) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON* start = cJSON_GetObjectItem(binDesc, "start");
|
||||||
|
cJSON* factor = cJSON_GetObjectItem(binDesc, "factor");
|
||||||
|
cJSON* width = cJSON_GetObjectItem(binDesc, "width");
|
||||||
|
cJSON* count = cJSON_GetObjectItem(binDesc, "count");
|
||||||
|
cJSON* infinity = cJSON_GetObjectItem(binDesc, "infinity");
|
||||||
|
|
||||||
|
if (!cJSON_IsNumber(start) || !cJSON_IsNumber(count) || !cJSON_IsBool(infinity)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count->valueint <= 0 || count->valueint > 1000) { // limit count to 1000
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isinf(start->valuedouble) || (width != NULL && isinf(width->valuedouble)) ||
|
||||||
|
(factor != NULL && isinf(factor->valuedouble)) || (count != NULL && isinf(count->valuedouble))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t counter = (int32_t)count->valueint;
|
||||||
|
if (infinity->valueint == false) {
|
||||||
|
startIndex = 0;
|
||||||
|
numOfBins = counter + 1;
|
||||||
|
} else {
|
||||||
|
startIndex = 1;
|
||||||
|
numOfBins = counter + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
intervals = taosMemoryCalloc(numOfBins, sizeof(double));
|
||||||
|
if (cJSON_IsNumber(width) && factor == NULL && binType == LINEAR_BIN) {
|
||||||
|
// linear bin process
|
||||||
|
if (width->valuedouble == 0) {
|
||||||
|
taosMemoryFree(intervals);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < counter + 1; ++i) {
|
||||||
|
intervals[startIndex] = start->valuedouble + i * width->valuedouble;
|
||||||
|
if (isinf(intervals[startIndex])) {
|
||||||
|
taosMemoryFree(intervals);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
startIndex++;
|
||||||
|
}
|
||||||
|
} else if (cJSON_IsNumber(factor) && width == NULL && binType == LOG_BIN) {
|
||||||
|
// log bin process
|
||||||
|
if (start->valuedouble == 0) {
|
||||||
|
taosMemoryFree(intervals);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (factor->valuedouble < 0 || factor->valuedouble == 0 || factor->valuedouble == 1) {
|
||||||
|
taosMemoryFree(intervals);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < counter + 1; ++i) {
|
||||||
|
intervals[startIndex] = start->valuedouble * pow(factor->valuedouble, i * 1.0);
|
||||||
|
if (isinf(intervals[startIndex])) {
|
||||||
|
taosMemoryFree(intervals);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
startIndex++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
taosMemoryFree(intervals);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (infinity->valueint == true) {
|
||||||
|
intervals[0] = -INFINITY;
|
||||||
|
intervals[numOfBins - 1] = INFINITY;
|
||||||
|
// in case of desc bin orders, -inf/inf should be swapped
|
||||||
|
ASSERT(numOfBins >= 4);
|
||||||
|
if (intervals[1] > intervals[numOfBins - 2]) {
|
||||||
|
TSWAP(intervals[0], intervals[numOfBins - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (cJSON_IsArray(binDesc)) { /* user input bins */
|
||||||
|
if (binType != USER_INPUT_BIN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
numOfBins = cJSON_GetArraySize(binDesc);
|
||||||
|
intervals = taosMemoryCalloc(numOfBins, sizeof(double));
|
||||||
|
cJSON* bin = binDesc->child;
|
||||||
|
if (bin == NULL) {
|
||||||
|
taosMemoryFree(intervals);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
while (bin) {
|
||||||
|
intervals[i] = bin->valuedouble;
|
||||||
|
if (!cJSON_IsNumber(bin)) {
|
||||||
|
taosMemoryFree(intervals);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (i != 0 && intervals[i] <= intervals[i - 1]) {
|
||||||
|
taosMemoryFree(intervals);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bin = bin->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pInfo->numOfBins = numOfBins - 1;
|
||||||
|
pInfo->normalized = normalized;
|
||||||
|
for (int32_t i = 0; i < pInfo->numOfBins; ++i) {
|
||||||
|
pInfo->bins[i].lower = intervals[i] < intervals[i + 1] ? intervals[i] : intervals[i + 1];
|
||||||
|
pInfo->bins[i].upper = intervals[i + 1] > intervals[i] ? intervals[i + 1] : intervals[i];
|
||||||
|
pInfo->bins[i].count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(intervals);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool histogramFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultInfo) {
|
||||||
if (!functionSetup(pCtx, pResultInfo)) {
|
if (!functionSetup(pCtx, pResultInfo)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(pResultInfo);
|
SHistoFuncInfo *pInfo = GET_ROWCELL_INTERBUF(pResultInfo);
|
||||||
char* binType = pCtx->param[1].param.pz;
|
|
||||||
char* binDesc = pCtx->param[2].param.pz;
|
|
||||||
int64_t nornalized = pCtx->param[3].param.i;
|
|
||||||
|
|
||||||
|
int8_t binType = getHistogramBinType(varDataVal(pCtx->param[1].param.pz));
|
||||||
|
if (binType == UNKNOWN_BIN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
char* binDesc = varDataVal(pCtx->param[2].param.pz);
|
||||||
|
int64_t normalized = pCtx->param[3].param.i;
|
||||||
|
if (normalized != 0 && normalized != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!getHistogramBinDesc(pInfo, binDesc, binType, (bool)normalized)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t histogramFunction(SqlFunctionCtx *pCtx) {
|
int32_t histogramFunction(SqlFunctionCtx *pCtx) {
|
||||||
|
SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||||
|
|
||||||
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
|
SColumnInfoData* pCol = pInput->pData[0];
|
||||||
|
|
||||||
|
int32_t type = pInput->pData[0]->info.type;
|
||||||
|
|
||||||
|
int32_t start = pInput->startRowIndex;
|
||||||
|
int32_t numOfRows = pInput->numOfRows;
|
||||||
|
|
||||||
|
int32_t numOfElems = 0;
|
||||||
|
int32_t totalElems = 0;
|
||||||
|
for (int32_t i = start; i < numOfRows + start; ++i) {
|
||||||
|
if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
|
char* data = colDataGetData(pCol, i);
|
||||||
|
double v;
|
||||||
|
GET_TYPED_DATA(v, double, type, data);
|
||||||
|
|
||||||
|
for (int32_t k = 0; k < pInfo->numOfBins; ++k) {
|
||||||
|
if (v > pInfo->bins[k].lower && v <= pInfo->bins[k].upper) {
|
||||||
|
pInfo->bins[k].count++;
|
||||||
|
totalElems++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pInfo->normalized) {
|
||||||
|
for (int32_t k = 0; k < pInfo->numOfBins; ++k) {
|
||||||
|
if(totalElems != 0) {
|
||||||
|
pInfo->bins[k].percentage = pInfo->bins[k].count / (double)totalElems;
|
||||||
|
} else {
|
||||||
|
pInfo->bins[k].percentage = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SET_VAL(GET_RES_INFO(pCtx), numOfElems, pInfo->numOfBins);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t histogramFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
int32_t histogramFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||||
//if (pInfo->hasResult == true) {
|
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
||||||
// SET_DOUBLE_VAL(&pInfo->result, pInfo->max - pInfo->min);
|
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
//}
|
|
||||||
return functionFinalize(pCtx, pBlock);
|
int32_t currentRow = pBlock->info.rows;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pResInfo->numOfRes; ++i) {
|
||||||
|
int32_t len;
|
||||||
|
char buf[512] = {0};
|
||||||
|
if (!pInfo->normalized) {
|
||||||
|
len = sprintf(buf + VARSTR_HEADER_SIZE, "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%"PRId64"}",
|
||||||
|
pInfo->bins[i].lower, pInfo->bins[i].upper, pInfo->bins[i].count);
|
||||||
|
} else {
|
||||||
|
len = sprintf(buf + VARSTR_HEADER_SIZE, "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%lf}",
|
||||||
|
pInfo->bins[i].lower, pInfo->bins[i].upper, pInfo->bins[i].percentage);
|
||||||
|
}
|
||||||
|
varDataSetLen(buf, len);
|
||||||
|
colDataAppend(pCol, currentRow, buf, false);
|
||||||
|
currentRow++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pResInfo->numOfRes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,3 +177,35 @@ void fmFuncMgtDestroy() {
|
||||||
taosHashCleanup(m);
|
taosHashCleanup(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t fmSetInvertFunc(int32_t funcId, SFuncExecFuncs* pFpSet) {
|
||||||
|
if (fmIsUserDefinedFunc(funcId) || funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
pFpSet->process = funcMgtBuiltins[funcId].invertFunc;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t fmSetNormalFunc(int32_t funcId, SFuncExecFuncs* pFpSet) {
|
||||||
|
if (fmIsUserDefinedFunc(funcId) || funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
pFpSet->process = funcMgtBuiltins[funcId].processFunc;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool fmIsInvertible(int32_t funcId) {
|
||||||
|
bool res = false;
|
||||||
|
switch (funcMgtBuiltins[funcId].type) {
|
||||||
|
case FUNCTION_TYPE_COUNT:
|
||||||
|
case FUNCTION_TYPE_SUM:
|
||||||
|
case FUNCTION_TYPE_STDDEV:
|
||||||
|
case FUNCTION_TYPE_AVG:
|
||||||
|
res = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "tcoding.h"
|
#include "tcoding.h"
|
||||||
#include "tencode.h"
|
#include "tencode.h"
|
||||||
|
|
||||||
static int32_t tEncodeSMonSysInfo(SCoder *encoder, const SMonSysInfo *pInfo) {
|
static int32_t tEncodeSMonSysInfo(SEncoder *encoder, const SMonSysInfo *pInfo) {
|
||||||
if (tEncodeDouble(encoder, pInfo->cpu_engine) < 0) return -1;
|
if (tEncodeDouble(encoder, pInfo->cpu_engine) < 0) return -1;
|
||||||
if (tEncodeDouble(encoder, pInfo->cpu_system) < 0) return -1;
|
if (tEncodeDouble(encoder, pInfo->cpu_system) < 0) return -1;
|
||||||
if (tEncodeFloat(encoder, pInfo->cpu_cores) < 0) return -1;
|
if (tEncodeFloat(encoder, pInfo->cpu_cores) < 0) return -1;
|
||||||
|
@ -37,7 +37,7 @@ static int32_t tEncodeSMonSysInfo(SCoder *encoder, const SMonSysInfo *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tDecodeSMonSysInfo(SCoder *decoder, SMonSysInfo *pInfo) {
|
static int32_t tDecodeSMonSysInfo(SDecoder *decoder, SMonSysInfo *pInfo) {
|
||||||
if (tDecodeDouble(decoder, &pInfo->cpu_engine) < 0) return -1;
|
if (tDecodeDouble(decoder, &pInfo->cpu_engine) < 0) return -1;
|
||||||
if (tDecodeDouble(decoder, &pInfo->cpu_system) < 0) return -1;
|
if (tDecodeDouble(decoder, &pInfo->cpu_system) < 0) return -1;
|
||||||
if (tDecodeFloat(decoder, &pInfo->cpu_cores) < 0) return -1;
|
if (tDecodeFloat(decoder, &pInfo->cpu_cores) < 0) return -1;
|
||||||
|
@ -56,7 +56,7 @@ static int32_t tDecodeSMonSysInfo(SCoder *decoder, SMonSysInfo *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSMonLogs(SCoder *encoder, const SMonLogs *pInfo) {
|
int32_t tEncodeSMonLogs(SEncoder *encoder, const SMonLogs *pInfo) {
|
||||||
if (tEncodeI32(encoder, pInfo->numOfErrorLogs) < 0) return -1;
|
if (tEncodeI32(encoder, pInfo->numOfErrorLogs) < 0) return -1;
|
||||||
if (tEncodeI32(encoder, pInfo->numOfInfoLogs) < 0) return -1;
|
if (tEncodeI32(encoder, pInfo->numOfInfoLogs) < 0) return -1;
|
||||||
if (tEncodeI32(encoder, pInfo->numOfDebugLogs) < 0) return -1;
|
if (tEncodeI32(encoder, pInfo->numOfDebugLogs) < 0) return -1;
|
||||||
|
@ -71,7 +71,7 @@ int32_t tEncodeSMonLogs(SCoder *encoder, const SMonLogs *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tDecodeSMonLogs(SCoder *decoder, SMonLogs *pInfo) {
|
static int32_t tDecodeSMonLogs(SDecoder *decoder, SMonLogs *pInfo) {
|
||||||
if (tDecodeI32(decoder, &pInfo->numOfErrorLogs) < 0) return -1;
|
if (tDecodeI32(decoder, &pInfo->numOfErrorLogs) < 0) return -1;
|
||||||
if (tDecodeI32(decoder, &pInfo->numOfInfoLogs) < 0) return -1;
|
if (tDecodeI32(decoder, &pInfo->numOfInfoLogs) < 0) return -1;
|
||||||
if (tDecodeI32(decoder, &pInfo->numOfDebugLogs) < 0) return -1;
|
if (tDecodeI32(decoder, &pInfo->numOfDebugLogs) < 0) return -1;
|
||||||
|
@ -96,7 +96,7 @@ static int32_t tDecodeSMonLogs(SCoder *decoder, SMonLogs *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSMonClusterInfo(SCoder *encoder, const SMonClusterInfo *pInfo) {
|
int32_t tEncodeSMonClusterInfo(SEncoder *encoder, const SMonClusterInfo *pInfo) {
|
||||||
if (tEncodeCStr(encoder, pInfo->first_ep) < 0) return -1;
|
if (tEncodeCStr(encoder, pInfo->first_ep) < 0) return -1;
|
||||||
if (tEncodeI32(encoder, pInfo->first_ep_dnode_id) < 0) return -1;
|
if (tEncodeI32(encoder, pInfo->first_ep_dnode_id) < 0) return -1;
|
||||||
if (tEncodeCStr(encoder, pInfo->version) < 0) return -1;
|
if (tEncodeCStr(encoder, pInfo->version) < 0) return -1;
|
||||||
|
@ -124,7 +124,7 @@ int32_t tEncodeSMonClusterInfo(SCoder *encoder, const SMonClusterInfo *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeSMonClusterInfo(SCoder *decoder, SMonClusterInfo *pInfo) {
|
int32_t tDecodeSMonClusterInfo(SDecoder *decoder, SMonClusterInfo *pInfo) {
|
||||||
if (tDecodeCStrTo(decoder, pInfo->first_ep) < 0) return -1;
|
if (tDecodeCStrTo(decoder, pInfo->first_ep) < 0) return -1;
|
||||||
if (tDecodeI32(decoder, &pInfo->first_ep_dnode_id) < 0) return -1;
|
if (tDecodeI32(decoder, &pInfo->first_ep_dnode_id) < 0) return -1;
|
||||||
if (tDecodeCStrTo(decoder, pInfo->version) < 0) return -1;
|
if (tDecodeCStrTo(decoder, pInfo->version) < 0) return -1;
|
||||||
|
@ -163,7 +163,7 @@ int32_t tDecodeSMonClusterInfo(SCoder *decoder, SMonClusterInfo *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSMonVgroupInfo(SCoder *encoder, const SMonVgroupInfo *pInfo) {
|
int32_t tEncodeSMonVgroupInfo(SEncoder *encoder, const SMonVgroupInfo *pInfo) {
|
||||||
if (tEncodeI32(encoder, taosArrayGetSize(pInfo->vgroups)) < 0) return -1;
|
if (tEncodeI32(encoder, taosArrayGetSize(pInfo->vgroups)) < 0) return -1;
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->vgroups); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pInfo->vgroups); ++i) {
|
||||||
SMonVgroupDesc *pDesc = taosArrayGet(pInfo->vgroups, i);
|
SMonVgroupDesc *pDesc = taosArrayGet(pInfo->vgroups, i);
|
||||||
|
@ -180,7 +180,7 @@ int32_t tEncodeSMonVgroupInfo(SCoder *encoder, const SMonVgroupInfo *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeSMonVgroupInfo(SCoder *decoder, SMonVgroupInfo *pInfo) {
|
int32_t tDecodeSMonVgroupInfo(SDecoder *decoder, SMonVgroupInfo *pInfo) {
|
||||||
int32_t arraySize = 0;
|
int32_t arraySize = 0;
|
||||||
if (tDecodeI32(decoder, &arraySize) < 0) return -1;
|
if (tDecodeI32(decoder, &arraySize) < 0) return -1;
|
||||||
|
|
||||||
|
@ -203,14 +203,14 @@ int32_t tDecodeSMonVgroupInfo(SCoder *decoder, SMonVgroupInfo *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSMonGrantInfo(SCoder *encoder, const SMonGrantInfo *pInfo) {
|
int32_t tEncodeSMonGrantInfo(SEncoder *encoder, const SMonGrantInfo *pInfo) {
|
||||||
if (tEncodeI32(encoder, pInfo->expire_time) < 0) return -1;
|
if (tEncodeI32(encoder, pInfo->expire_time) < 0) return -1;
|
||||||
if (tEncodeI64(encoder, pInfo->timeseries_used) < 0) return -1;
|
if (tEncodeI64(encoder, pInfo->timeseries_used) < 0) return -1;
|
||||||
if (tEncodeI64(encoder, pInfo->timeseries_total) < 0) return -1;
|
if (tEncodeI64(encoder, pInfo->timeseries_total) < 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeSMonGrantInfo(SCoder *decoder, SMonGrantInfo *pInfo) {
|
int32_t tDecodeSMonGrantInfo(SDecoder *decoder, SMonGrantInfo *pInfo) {
|
||||||
if (tDecodeI32(decoder, &pInfo->expire_time) < 0) return -1;
|
if (tDecodeI32(decoder, &pInfo->expire_time) < 0) return -1;
|
||||||
if (tDecodeI64(decoder, &pInfo->timeseries_used) < 0) return -1;
|
if (tDecodeI64(decoder, &pInfo->timeseries_used) < 0) return -1;
|
||||||
if (tDecodeI64(decoder, &pInfo->timeseries_total) < 0) return -1;
|
if (tDecodeI64(decoder, &pInfo->timeseries_total) < 0) return -1;
|
||||||
|
@ -218,8 +218,8 @@ int32_t tDecodeSMonGrantInfo(SCoder *decoder, SMonGrantInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
|
int32_t tSerializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
|
||||||
SCoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeSMonClusterInfo(&encoder, &pInfo->cluster) < 0) return -1;
|
if (tEncodeSMonClusterInfo(&encoder, &pInfo->cluster) < 0) return -1;
|
||||||
|
@ -230,13 +230,13 @@ int32_t tSerializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
|
int32_t tDeserializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
|
||||||
SCoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeSMonClusterInfo(&decoder, &pInfo->cluster) < 0) return -1;
|
if (tDecodeSMonClusterInfo(&decoder, &pInfo->cluster) < 0) return -1;
|
||||||
|
@ -246,7 +246,7 @@ int32_t tDeserializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
|
||||||
if (tDecodeSMonLogs(&decoder, &pInfo->log) < 0) return -1;
|
if (tDecodeSMonLogs(&decoder, &pInfo->log) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tCoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ void tFreeSMonMmInfo(SMonMmInfo *pInfo) {
|
||||||
pInfo->log.logs = NULL;
|
pInfo->log.logs = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSMonDiskDesc(SCoder *encoder, const SMonDiskDesc *pDesc) {
|
int32_t tEncodeSMonDiskDesc(SEncoder *encoder, const SMonDiskDesc *pDesc) {
|
||||||
if (tEncodeCStr(encoder, pDesc->name) < 0) return -1;
|
if (tEncodeCStr(encoder, pDesc->name) < 0) return -1;
|
||||||
if (tEncodeI8(encoder, pDesc->level) < 0) return -1;
|
if (tEncodeI8(encoder, pDesc->level) < 0) return -1;
|
||||||
if (tEncodeI64(encoder, pDesc->size.total) < 0) return -1;
|
if (tEncodeI64(encoder, pDesc->size.total) < 0) return -1;
|
||||||
|
@ -270,7 +270,7 @@ int32_t tEncodeSMonDiskDesc(SCoder *encoder, const SMonDiskDesc *pDesc) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tDecodeSMonDiskDesc(SCoder *decoder, SMonDiskDesc *pDesc) {
|
static int32_t tDecodeSMonDiskDesc(SDecoder *decoder, SMonDiskDesc *pDesc) {
|
||||||
if (tDecodeCStrTo(decoder, pDesc->name) < 0) return -1;
|
if (tDecodeCStrTo(decoder, pDesc->name) < 0) return -1;
|
||||||
if (tDecodeI8(decoder, &pDesc->level) < 0) return -1;
|
if (tDecodeI8(decoder, &pDesc->level) < 0) return -1;
|
||||||
if (tDecodeI64(decoder, &pDesc->size.total) < 0) return -1;
|
if (tDecodeI64(decoder, &pDesc->size.total) < 0) return -1;
|
||||||
|
@ -279,7 +279,7 @@ static int32_t tDecodeSMonDiskDesc(SCoder *decoder, SMonDiskDesc *pDesc) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSMonDiskInfo(SCoder *encoder, const SMonDiskInfo *pInfo) {
|
int32_t tEncodeSMonDiskInfo(SEncoder *encoder, const SMonDiskInfo *pInfo) {
|
||||||
if (tEncodeI32(encoder, taosArrayGetSize(pInfo->datadirs)) < 0) return -1;
|
if (tEncodeI32(encoder, taosArrayGetSize(pInfo->datadirs)) < 0) return -1;
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->datadirs); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pInfo->datadirs); ++i) {
|
||||||
SMonDiskDesc *pDesc = taosArrayGet(pInfo->datadirs, i);
|
SMonDiskDesc *pDesc = taosArrayGet(pInfo->datadirs, i);
|
||||||
|
@ -288,7 +288,7 @@ int32_t tEncodeSMonDiskInfo(SCoder *encoder, const SMonDiskInfo *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tDecodeSMonDiskInfo(SCoder *decoder, SMonDiskInfo *pInfo) {
|
static int32_t tDecodeSMonDiskInfo(SDecoder *decoder, SMonDiskInfo *pInfo) {
|
||||||
int32_t arraySize = 0;
|
int32_t arraySize = 0;
|
||||||
if (tDecodeI32(decoder, &arraySize) < 0) return -1;
|
if (tDecodeI32(decoder, &arraySize) < 0) return -1;
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ static int32_t tDecodeSMonDiskInfo(SCoder *decoder, SMonDiskInfo *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSVnodesStat(SCoder *encoder, const SVnodesStat *pStat) {
|
int32_t tEncodeSVnodesStat(SEncoder *encoder, const SVnodesStat *pStat) {
|
||||||
if (tEncodeI32(encoder, pStat->openVnodes) < 0) return -1;
|
if (tEncodeI32(encoder, pStat->openVnodes) < 0) return -1;
|
||||||
if (tEncodeI32(encoder, pStat->totalVnodes) < 0) return -1;
|
if (tEncodeI32(encoder, pStat->totalVnodes) < 0) return -1;
|
||||||
if (tEncodeI32(encoder, pStat->masterNum) < 0) return -1;
|
if (tEncodeI32(encoder, pStat->masterNum) < 0) return -1;
|
||||||
|
@ -317,7 +317,7 @@ int32_t tEncodeSVnodesStat(SCoder *encoder, const SVnodesStat *pStat) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tDecodeSVnodesStat(SCoder *decoder, SVnodesStat *pStat) {
|
static int32_t tDecodeSVnodesStat(SDecoder *decoder, SVnodesStat *pStat) {
|
||||||
if (tDecodeI32(decoder, &pStat->openVnodes) < 0) return -1;
|
if (tDecodeI32(decoder, &pStat->openVnodes) < 0) return -1;
|
||||||
if (tDecodeI32(decoder, &pStat->totalVnodes) < 0) return -1;
|
if (tDecodeI32(decoder, &pStat->totalVnodes) < 0) return -1;
|
||||||
if (tDecodeI32(decoder, &pStat->masterNum) < 0) return -1;
|
if (tDecodeI32(decoder, &pStat->masterNum) < 0) return -1;
|
||||||
|
@ -331,8 +331,8 @@ static int32_t tDecodeSVnodesStat(SCoder *decoder, SVnodesStat *pStat) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo) {
|
int32_t tSerializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo) {
|
||||||
SCoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeSMonDiskInfo(&encoder, &pInfo->tfs) < 0) return -1;
|
if (tEncodeSMonDiskInfo(&encoder, &pInfo->tfs) < 0) return -1;
|
||||||
|
@ -342,13 +342,13 @@ int32_t tSerializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo) {
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo) {
|
int32_t tDeserializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo) {
|
||||||
SCoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeSMonDiskInfo(&decoder, &pInfo->tfs) < 0) return -1;
|
if (tDecodeSMonDiskInfo(&decoder, &pInfo->tfs) < 0) return -1;
|
||||||
|
@ -357,7 +357,7 @@ int32_t tDeserializeSMonVmInfo(void *buf, int32_t bufLen, SMonVmInfo *pInfo) {
|
||||||
if (tDecodeSMonLogs(&decoder, &pInfo->log) < 0) return -1;
|
if (tDecodeSMonLogs(&decoder, &pInfo->log) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tCoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,8 +369,8 @@ void tFreeSMonVmInfo(SMonVmInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo) {
|
int32_t tSerializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo) {
|
||||||
SCoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1;
|
if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1;
|
||||||
|
@ -378,20 +378,20 @@ int32_t tSerializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo) {
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo) {
|
int32_t tDeserializeSMonQmInfo(void *buf, int32_t bufLen, SMonQmInfo *pInfo) {
|
||||||
SCoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1;
|
if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1;
|
||||||
if (tDecodeSMonLogs(&decoder, &pInfo->log) < 0) return -1;
|
if (tDecodeSMonLogs(&decoder, &pInfo->log) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tCoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,8 +401,8 @@ void tFreeSMonQmInfo(SMonQmInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSMonSmInfo(void *buf, int32_t bufLen, SMonSmInfo *pInfo) {
|
int32_t tSerializeSMonSmInfo(void *buf, int32_t bufLen, SMonSmInfo *pInfo) {
|
||||||
SCoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1;
|
if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1;
|
||||||
|
@ -410,20 +410,20 @@ int32_t tSerializeSMonSmInfo(void *buf, int32_t bufLen, SMonSmInfo *pInfo) {
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSMonSmInfo(void *buf, int32_t bufLen, SMonSmInfo *pInfo) {
|
int32_t tDeserializeSMonSmInfo(void *buf, int32_t bufLen, SMonSmInfo *pInfo) {
|
||||||
SCoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1;
|
if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1;
|
||||||
if (tDecodeSMonLogs(&decoder, &pInfo->log) < 0) return -1;
|
if (tDecodeSMonLogs(&decoder, &pInfo->log) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tCoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,8 +433,8 @@ void tFreeSMonSmInfo(SMonSmInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo) {
|
int32_t tSerializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo) {
|
||||||
SCoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1;
|
if (tEncodeSMonSysInfo(&encoder, &pInfo->sys) < 0) return -1;
|
||||||
|
@ -442,20 +442,20 @@ int32_t tSerializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo) {
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo) {
|
int32_t tDeserializeSMonBmInfo(void *buf, int32_t bufLen, SMonBmInfo *pInfo) {
|
||||||
SCoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1;
|
if (tDecodeSMonSysInfo(&decoder, &pInfo->sys) < 0) return -1;
|
||||||
if (tDecodeSMonLogs(&decoder, &pInfo->log) < 0) return -1;
|
if (tDecodeSMonLogs(&decoder, &pInfo->log) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tCoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,8 +465,8 @@ void tFreeSMonBmInfo(SMonBmInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo) {
|
int32_t tSerializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo) {
|
||||||
SCoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, taosArrayGetSize(pInfo->pVloads)) < 0) return -1;
|
if (tEncodeI32(&encoder, taosArrayGetSize(pInfo->pVloads)) < 0) return -1;
|
||||||
|
@ -488,13 +488,13 @@ int32_t tSerializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo)
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo) {
|
int32_t tDeserializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo) {
|
||||||
SCoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
|
||||||
|
@ -522,7 +522,7 @@ int32_t tDeserializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInf
|
||||||
}
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tCoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,8 +532,8 @@ void tFreeSMonVloadInfo(SMonVloadInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInfo) {
|
int32_t tSerializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInfo) {
|
||||||
SCoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pInfo->isMnode) < 0) return -1;
|
if (tEncodeI8(&encoder, pInfo->isMnode) < 0) return -1;
|
||||||
|
@ -541,19 +541,19 @@ int32_t tSerializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInfo)
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInfo) {
|
int32_t tDeserializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInfo) {
|
||||||
SCoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pInfo->isMnode) < 0) return -1;
|
if (tDecodeI8(&decoder, &pInfo->isMnode) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pInfo->load.syncState) < 0) return -1;
|
if (tDecodeI32(&decoder, &pInfo->load.syncState) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tCoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -112,6 +112,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
||||||
return makeNode(type, sizeof(SDropTableStmt));
|
return makeNode(type, sizeof(SDropTableStmt));
|
||||||
case QUERY_NODE_DROP_SUPER_TABLE_STMT:
|
case QUERY_NODE_DROP_SUPER_TABLE_STMT:
|
||||||
return makeNode(type, sizeof(SDropSuperTableStmt));
|
return makeNode(type, sizeof(SDropSuperTableStmt));
|
||||||
|
case QUERY_NODE_ALTER_TABLE_STMT:
|
||||||
|
return makeNode(type, sizeof(SAlterTableStmt));
|
||||||
case QUERY_NODE_CREATE_USER_STMT:
|
case QUERY_NODE_CREATE_USER_STMT:
|
||||||
return makeNode(type, sizeof(SCreateUserStmt));
|
return makeNode(type, sizeof(SCreateUserStmt));
|
||||||
case QUERY_NODE_ALTER_USER_STMT:
|
case QUERY_NODE_ALTER_USER_STMT:
|
||||||
|
@ -155,7 +157,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
||||||
case QUERY_NODE_CREATE_FUNCTION_STMT:
|
case QUERY_NODE_CREATE_FUNCTION_STMT:
|
||||||
return makeNode(type, sizeof(SCreateFunctionStmt));
|
return makeNode(type, sizeof(SCreateFunctionStmt));
|
||||||
case QUERY_NODE_DROP_FUNCTION_STMT:
|
case QUERY_NODE_DROP_FUNCTION_STMT:
|
||||||
break;
|
return makeNode(type, sizeof(SDropFunctionStmt));
|
||||||
case QUERY_NODE_CREATE_STREAM_STMT:
|
case QUERY_NODE_CREATE_STREAM_STMT:
|
||||||
return makeNode(type, sizeof(SCreateStreamStmt));
|
return makeNode(type, sizeof(SCreateStreamStmt));
|
||||||
case QUERY_NODE_DROP_STREAM_STMT:
|
case QUERY_NODE_DROP_STREAM_STMT:
|
||||||
|
@ -165,6 +167,10 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
||||||
case QUERY_NODE_SPLIT_VGROUP_STMT:
|
case QUERY_NODE_SPLIT_VGROUP_STMT:
|
||||||
case QUERY_NODE_SYNCDB_STMT:
|
case QUERY_NODE_SYNCDB_STMT:
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_GRANT_STMT:
|
||||||
|
return makeNode(type, sizeof(SGrantStmt));
|
||||||
|
case QUERY_NODE_REVOKE_STMT:
|
||||||
|
return makeNode(type, sizeof(SRevokeStmt));
|
||||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||||
|
@ -195,9 +201,11 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
return makeNode(type, sizeof(SShowStmt));
|
return makeNode(type, sizeof(SShowStmt));
|
||||||
case QUERY_NODE_KILL_CONNECTION_STMT:
|
case QUERY_NODE_KILL_CONNECTION_STMT:
|
||||||
case QUERY_NODE_KILL_QUERY_STMT:
|
case QUERY_NODE_KILL_QUERY_STMT:
|
||||||
|
case QUERY_NODE_KILL_TRANSACTION_STMT:
|
||||||
return makeNode(type, sizeof(SKillStmt));
|
return makeNode(type, sizeof(SKillStmt));
|
||||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||||
return makeNode(type, sizeof(SScanLogicNode));
|
return makeNode(type, sizeof(SScanLogicNode));
|
||||||
|
@ -1337,7 +1345,9 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY:
|
case TSDB_DATA_TYPE_VARBINARY:
|
||||||
pVal->pz = pNode->datum.p;
|
pVal->pz = taosMemoryMalloc(pVal->nLen + VARSTR_HEADER_SIZE + 1);
|
||||||
|
memcpy(pVal->pz, pNode->datum.p, pVal->nLen + VARSTR_HEADER_SIZE);
|
||||||
|
pVal->pz[pVal->nLen + VARSTR_HEADER_SIZE] = 0;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_JSON:
|
case TSDB_DATA_TYPE_JSON:
|
||||||
case TSDB_DATA_TYPE_DECIMAL:
|
case TSDB_DATA_TYPE_DECIMAL:
|
||||||
|
|
|
@ -178,7 +178,7 @@ SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt);
|
||||||
SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups);
|
SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups);
|
||||||
SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool aggFunc, const SToken* pFuncName,
|
SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool aggFunc, const SToken* pFuncName,
|
||||||
const SToken* pLibPath, SDataType dataType, int32_t bufSize);
|
const SToken* pLibPath, SDataType dataType, int32_t bufSize);
|
||||||
SNode* createDropFunctionStmt(SAstCreateContext* pCxt, const SToken* pFuncName);
|
SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName);
|
||||||
SNode* createStreamOptions(SAstCreateContext* pCxt);
|
SNode* createStreamOptions(SAstCreateContext* pCxt);
|
||||||
SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable,
|
SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable,
|
||||||
SNode* pOptions, SNode* pQuery);
|
SNode* pOptions, SNode* pQuery);
|
||||||
|
@ -188,6 +188,8 @@ SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, cons
|
||||||
SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes);
|
SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes);
|
||||||
SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId);
|
SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId);
|
||||||
SNode* createSyncdbStmt(SAstCreateContext* pCxt, const SToken* pDbName);
|
SNode* createSyncdbStmt(SAstCreateContext* pCxt, const SToken* pDbName);
|
||||||
|
SNode* createGrantStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbName, SToken* pUserName);
|
||||||
|
SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbName, SToken* pUserName);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ extern "C" {
|
||||||
|
|
||||||
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery);
|
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery);
|
||||||
int32_t parse(SParseContext* pParseCxt, SQuery** pQuery);
|
int32_t parse(SParseContext* pParseCxt, SQuery** pQuery);
|
||||||
|
int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery);
|
||||||
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery);
|
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery);
|
||||||
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
||||||
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery);
|
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery);
|
||||||
|
|
|
@ -81,6 +81,30 @@ cmd ::= ALTER USER user_name(A) PASS NK_STRING(B).
|
||||||
cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); }
|
cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); }
|
||||||
cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); }
|
cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); }
|
||||||
|
|
||||||
|
/************************************************ grant/revoke ********************************************************/
|
||||||
|
cmd ::= GRANT privileges(A) ON priv_level(B) TO user_name(C). { pCxt->pRootNode = createGrantStmt(pCxt, A, &B, &C); }
|
||||||
|
cmd ::= REVOKE privileges(A) ON priv_level(B) FROM user_name(C). { pCxt->pRootNode = createRevokeStmt(pCxt, A, &B, &C); }
|
||||||
|
|
||||||
|
%type privileges { int64_t }
|
||||||
|
%destructor privileges { }
|
||||||
|
privileges(A) ::= ALL. { A = PRIVILEGE_TYPE_ALL; }
|
||||||
|
privileges(A) ::= priv_type_list(B). { A = B; }
|
||||||
|
|
||||||
|
%type priv_type_list { int64_t }
|
||||||
|
%destructor priv_type_list { }
|
||||||
|
priv_type_list(A) ::= priv_type(B). { A = B; }
|
||||||
|
priv_type_list(A) ::= priv_type_list(B) NK_COMMA priv_type(C). { A = B | C; }
|
||||||
|
|
||||||
|
%type priv_type { int64_t }
|
||||||
|
%destructor priv_type { }
|
||||||
|
priv_type(A) ::= READ. { A = PRIVILEGE_TYPE_READ; }
|
||||||
|
priv_type(A) ::= WRITE. { A = PRIVILEGE_TYPE_WRITE; }
|
||||||
|
|
||||||
|
%type priv_level { SToken }
|
||||||
|
%destructor priv_level { }
|
||||||
|
priv_level(A) ::= NK_STAR(B) NK_DOT NK_STAR. { A = B; }
|
||||||
|
priv_level(A) ::= db_name(B) NK_DOT NK_STAR. { A = B; }
|
||||||
|
|
||||||
/************************************************ create/drop/alter dnode *********************************************/
|
/************************************************ create/drop/alter dnode *********************************************/
|
||||||
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
||||||
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
|
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
|
||||||
|
@ -337,6 +361,7 @@ cmd ::= SHOW VARIABLES.
|
||||||
cmd ::= SHOW BNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT, NULL, NULL); }
|
cmd ::= SHOW BNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT, NULL, NULL); }
|
||||||
cmd ::= SHOW SNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT, NULL, NULL); }
|
cmd ::= SHOW SNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT, NULL, NULL); }
|
||||||
cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT, NULL, NULL); }
|
cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT, NULL, NULL); }
|
||||||
|
cmd ::= SHOW TRANSACTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT, NULL, NULL); }
|
||||||
|
|
||||||
db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
|
db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
|
||||||
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
|
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
|
||||||
|
@ -413,7 +438,7 @@ cmd ::= COMPACT VNODES IN NK_LP integer_list(A) NK_RP.
|
||||||
/************************************************ create/drop function ************************************************/
|
/************************************************ create/drop function ************************************************/
|
||||||
cmd ::= CREATE agg_func_opt(A) FUNCTION not_exists_opt(F) function_name(B)
|
cmd ::= CREATE agg_func_opt(A) FUNCTION not_exists_opt(F) function_name(B)
|
||||||
AS NK_STRING(C) OUTPUTTYPE type_name(D) bufsize_opt(E). { pCxt->pRootNode = createCreateFunctionStmt(pCxt, F, A, &B, &C, D, E); }
|
AS NK_STRING(C) OUTPUTTYPE type_name(D) bufsize_opt(E). { pCxt->pRootNode = createCreateFunctionStmt(pCxt, F, A, &B, &C, D, E); }
|
||||||
cmd ::= DROP FUNCTION function_name(A). { pCxt->pRootNode = createDropFunctionStmt(pCxt, &A); }
|
cmd ::= DROP FUNCTION exists_opt(B) function_name(A). { pCxt->pRootNode = createDropFunctionStmt(pCxt, B, &A); }
|
||||||
|
|
||||||
%type agg_func_opt { bool }
|
%type agg_func_opt { bool }
|
||||||
%destructor agg_func_opt { }
|
%destructor agg_func_opt { }
|
||||||
|
@ -441,6 +466,7 @@ stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C).
|
||||||
/************************************************ kill connection/query ***********************************************/
|
/************************************************ kill connection/query ***********************************************/
|
||||||
cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); }
|
cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); }
|
||||||
cmd ::= KILL QUERY NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &A); }
|
cmd ::= KILL QUERY NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &A); }
|
||||||
|
cmd ::= KILL TRANSACTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &A); }
|
||||||
|
|
||||||
/************************************************ merge/redistribute/ vgroup ******************************************/
|
/************************************************ merge/redistribute/ vgroup ******************************************/
|
||||||
cmd ::= MERGE VGROUP NK_INTEGER(A) NK_INTEGER(B). { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &A, &B); }
|
cmd ::= MERGE VGROUP NK_INTEGER(A) NK_INTEGER(B). { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &A, &B); }
|
||||||
|
|
|
@ -363,8 +363,10 @@ SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType d
|
||||||
CHECK_OUT_OF_MEM(func);
|
CHECK_OUT_OF_MEM(func);
|
||||||
strcpy(func->functionName, "cast");
|
strcpy(func->functionName, "cast");
|
||||||
func->node.resType = dt;
|
func->node.resType = dt;
|
||||||
if (TSDB_DATA_TYPE_NCHAR == dt.type) {
|
if (TSDB_DATA_TYPE_VARCHAR == dt.type) {
|
||||||
func->node.resType.bytes = func->node.resType.bytes * TSDB_NCHAR_SIZE;
|
func->node.resType.bytes = func->node.resType.bytes + VARSTR_HEADER_SIZE;
|
||||||
|
} else if (TSDB_DATA_TYPE_NCHAR == dt.type) {
|
||||||
|
func->node.resType.bytes = func->node.resType.bytes * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE;
|
||||||
}
|
}
|
||||||
nodesListMakeAppend(&func->pParameterList, pExpr);
|
nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||||
return (SNode*)func;
|
return (SNode*)func;
|
||||||
|
@ -1258,10 +1260,12 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createDropFunctionStmt(SAstCreateContext* pCxt, const SToken* pFuncName) {
|
SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName) {
|
||||||
SNode* pStmt = nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT);
|
SDropFunctionStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
return pStmt;
|
pStmt->ignoreNotExists = ignoreNotExists;
|
||||||
|
strncpy(pStmt->funcName, pFuncName->z, pFuncName->n);
|
||||||
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createStreamOptions(SAstCreateContext* pCxt) {
|
SNode* createStreamOptions(SAstCreateContext* pCxt) {
|
||||||
|
@ -1324,3 +1328,27 @@ SNode* createSyncdbStmt(SAstCreateContext* pCxt, const SToken* pDbName) {
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
return pStmt;
|
return pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SNode* createGrantStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbName, SToken* pUserName) {
|
||||||
|
if (!checkDbName(pCxt, pDbName, false) || !checkUserName(pCxt, pUserName)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
SGrantStmt* pStmt = nodesMakeNode(QUERY_NODE_GRANT_STMT);
|
||||||
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
|
pStmt->privileges = privileges;
|
||||||
|
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
||||||
|
strncpy(pStmt->userName, pUserName->z, pUserName->n);
|
||||||
|
return (SNode*)pStmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbName, SToken* pUserName) {
|
||||||
|
if (!checkDbName(pCxt, pDbName, false) || !checkUserName(pCxt, pUserName)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
SRevokeStmt* pStmt = nodesMakeNode(QUERY_NODE_REVOKE_STMT);
|
||||||
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
|
pStmt->privileges = privileges;
|
||||||
|
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
||||||
|
strncpy(pStmt->userName, pUserName->z, pUserName->n);
|
||||||
|
return (SNode*)pStmt;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
/*
|
||||||
|
* 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 "catalog.h"
|
||||||
|
#include "parInt.h"
|
||||||
|
|
||||||
|
typedef struct SAuthCxt {
|
||||||
|
SParseContext* pParseCxt;
|
||||||
|
int32_t errCode;
|
||||||
|
} SAuthCxt;
|
||||||
|
|
||||||
|
static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt);
|
||||||
|
|
||||||
|
static int32_t checkAuth(SParseContext* pCxt, const char* dbName, AUTH_TYPE type) {
|
||||||
|
if (pCxt->isSuperUser) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
bool pass = false;
|
||||||
|
int32_t code = catalogChkAuth(pCxt->pCatalog, pCxt->pTransporter, &pCxt->mgmtEpSet, pCxt->pUser, dbName, type, &pass);
|
||||||
|
return TSDB_CODE_SUCCESS == code ? (pass ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED) : code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static EDealRes authSubquery(SAuthCxt* pCxt, SNode* pStmt) {
|
||||||
|
return TSDB_CODE_SUCCESS == authQuery(pCxt, pStmt) ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static EDealRes authSelectImpl(SNode* pNode, void* pContext) {
|
||||||
|
SAuthCxt* pCxt = pContext;
|
||||||
|
if (QUERY_NODE_REAL_TABLE == nodeType(pNode)) {
|
||||||
|
pCxt->errCode = checkAuth(pCxt->pParseCxt, ((SRealTableNode*)pNode)->table.dbName, AUTH_TYPE_READ);
|
||||||
|
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
|
||||||
|
} else if (QUERY_NODE_TEMP_TABLE == nodeType(pNode)) {
|
||||||
|
return authSubquery(pCxt, ((STempTableNode*)pNode)->pSubquery);
|
||||||
|
}
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t authSelect(SAuthCxt* pCxt, SSelectStmt* pSelect) {
|
||||||
|
nodesWalkSelectStmt(pSelect, SQL_CLAUSE_FROM, authSelectImpl, pCxt);
|
||||||
|
return pCxt->errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t authSetOperator(SAuthCxt* pCxt, SSetOperator* pSetOper) {
|
||||||
|
int32_t code = authQuery(pCxt, pSetOper->pLeft);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = authQuery(pCxt, pSetOper->pRight);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
|
||||||
|
switch (nodeType(pStmt)) {
|
||||||
|
case QUERY_NODE_SET_OPERATOR:
|
||||||
|
return authSetOperator(pCxt, (SSetOperator*)pStmt);
|
||||||
|
case QUERY_NODE_SELECT_STMT:
|
||||||
|
return authSelect(pCxt, (SSelectStmt*)pStmt);
|
||||||
|
case QUERY_NODE_VNODE_MODIF_STMT:
|
||||||
|
case QUERY_NODE_CREATE_DATABASE_STMT:
|
||||||
|
case QUERY_NODE_DROP_DATABASE_STMT:
|
||||||
|
case QUERY_NODE_ALTER_DATABASE_STMT:
|
||||||
|
case QUERY_NODE_CREATE_TABLE_STMT:
|
||||||
|
case QUERY_NODE_CREATE_SUBTABLE_CLAUSE:
|
||||||
|
case QUERY_NODE_CREATE_MULTI_TABLE_STMT:
|
||||||
|
case QUERY_NODE_DROP_TABLE_CLAUSE:
|
||||||
|
case QUERY_NODE_DROP_TABLE_STMT:
|
||||||
|
case QUERY_NODE_DROP_SUPER_TABLE_STMT:
|
||||||
|
case QUERY_NODE_ALTER_TABLE_STMT:
|
||||||
|
case QUERY_NODE_CREATE_USER_STMT:
|
||||||
|
case QUERY_NODE_ALTER_USER_STMT:
|
||||||
|
case QUERY_NODE_DROP_USER_STMT:
|
||||||
|
case QUERY_NODE_USE_DATABASE_STMT:
|
||||||
|
case QUERY_NODE_CREATE_DNODE_STMT:
|
||||||
|
case QUERY_NODE_DROP_DNODE_STMT:
|
||||||
|
case QUERY_NODE_ALTER_DNODE_STMT:
|
||||||
|
case QUERY_NODE_CREATE_INDEX_STMT:
|
||||||
|
case QUERY_NODE_DROP_INDEX_STMT:
|
||||||
|
case QUERY_NODE_CREATE_QNODE_STMT:
|
||||||
|
case QUERY_NODE_DROP_QNODE_STMT:
|
||||||
|
case QUERY_NODE_CREATE_BNODE_STMT:
|
||||||
|
case QUERY_NODE_DROP_BNODE_STMT:
|
||||||
|
case QUERY_NODE_CREATE_SNODE_STMT:
|
||||||
|
case QUERY_NODE_DROP_SNODE_STMT:
|
||||||
|
case QUERY_NODE_CREATE_MNODE_STMT:
|
||||||
|
case QUERY_NODE_DROP_MNODE_STMT:
|
||||||
|
case QUERY_NODE_CREATE_TOPIC_STMT:
|
||||||
|
case QUERY_NODE_DROP_TOPIC_STMT:
|
||||||
|
case QUERY_NODE_ALTER_LOCAL_STMT:
|
||||||
|
case QUERY_NODE_EXPLAIN_STMT:
|
||||||
|
case QUERY_NODE_DESCRIBE_STMT:
|
||||||
|
case QUERY_NODE_RESET_QUERY_CACHE_STMT:
|
||||||
|
case QUERY_NODE_COMPACT_STMT:
|
||||||
|
case QUERY_NODE_CREATE_FUNCTION_STMT:
|
||||||
|
case QUERY_NODE_DROP_FUNCTION_STMT:
|
||||||
|
case QUERY_NODE_CREATE_STREAM_STMT:
|
||||||
|
case QUERY_NODE_DROP_STREAM_STMT:
|
||||||
|
case QUERY_NODE_MERGE_VGROUP_STMT:
|
||||||
|
case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT:
|
||||||
|
case QUERY_NODE_SPLIT_VGROUP_STMT:
|
||||||
|
case QUERY_NODE_SYNCDB_STMT:
|
||||||
|
case QUERY_NODE_GRANT_STMT:
|
||||||
|
case QUERY_NODE_REVOKE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
||||||
|
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_FUNCTIONS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_INDEXES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_USERS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_SUBSCRIBES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_TRANS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_SMAS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CONFIGS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_APPS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
|
case QUERY_NODE_KILL_CONNECTION_STMT:
|
||||||
|
case QUERY_NODE_KILL_QUERY_STMT:
|
||||||
|
case QUERY_NODE_KILL_TRANSACTION_STMT:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery) {
|
||||||
|
SAuthCxt cxt = {.pParseCxt = pParseCxt, .errCode = TSDB_CODE_SUCCESS};
|
||||||
|
return authQuery(&cxt, pQuery->pRoot);
|
||||||
|
}
|
|
@ -156,7 +156,7 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq) {
|
int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq) {
|
||||||
SCoder coder = {0};
|
SEncoder coder = {0};
|
||||||
char* pBuf;
|
char* pBuf;
|
||||||
int32_t len;
|
int32_t len;
|
||||||
|
|
||||||
|
@ -176,9 +176,9 @@ int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq)
|
||||||
|
|
||||||
pBuf= pBlocks->pData + pBlocks->size;
|
pBuf= pBlocks->pData + pBlocks->size;
|
||||||
|
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pBuf, len, TD_ENCODER);
|
tEncoderInit(&coder, pBuf, len);
|
||||||
tEncodeSVCreateTbReq(&coder, pCreateTbReq);
|
tEncodeSVCreateTbReq(&coder, pCreateTbReq);
|
||||||
tCoderClear(&coder);
|
tEncoderClear(&coder);
|
||||||
|
|
||||||
pBlocks->size += len;
|
pBlocks->size += len;
|
||||||
pBlocks->createTbReqLen = len;
|
pBlocks->createTbReqLen = len;
|
||||||
|
|
|
@ -85,6 +85,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"FSYNC", TK_FSYNC},
|
{"FSYNC", TK_FSYNC},
|
||||||
{"FUNCTION", TK_FUNCTION},
|
{"FUNCTION", TK_FUNCTION},
|
||||||
{"FUNCTIONS", TK_FUNCTIONS},
|
{"FUNCTIONS", TK_FUNCTIONS},
|
||||||
|
{"GRANT", TK_GRANT},
|
||||||
{"GRANTS", TK_GRANTS},
|
{"GRANTS", TK_GRANTS},
|
||||||
{"GROUP", TK_GROUP},
|
{"GROUP", TK_GROUP},
|
||||||
{"HAVING", TK_HAVING},
|
{"HAVING", TK_HAVING},
|
||||||
|
@ -147,9 +148,12 @@ static SKeyword keywordTable[] = {
|
||||||
{"QUERIES", TK_QUERIES},
|
{"QUERIES", TK_QUERIES},
|
||||||
{"QUERY", TK_QUERY},
|
{"QUERY", TK_QUERY},
|
||||||
{"RATIO", TK_RATIO},
|
{"RATIO", TK_RATIO},
|
||||||
|
{"READ", TK_READ},
|
||||||
|
{"RENAME", TK_RENAME},
|
||||||
{"REPLICA", TK_REPLICA},
|
{"REPLICA", TK_REPLICA},
|
||||||
{"RESET", TK_RESET},
|
{"RESET", TK_RESET},
|
||||||
{"RETENTIONS", TK_RETENTIONS},
|
{"RETENTIONS", TK_RETENTIONS},
|
||||||
|
{"REVOKE", TK_REVOKE},
|
||||||
{"ROLLUP", TK_ROLLUP},
|
{"ROLLUP", TK_ROLLUP},
|
||||||
{"SCHEMA", TK_SCHEMA},
|
{"SCHEMA", TK_SCHEMA},
|
||||||
{"SCORES", TK_SCORES},
|
{"SCORES", TK_SCORES},
|
||||||
|
@ -182,9 +186,12 @@ static SKeyword keywordTable[] = {
|
||||||
{"TIMESTAMP", TK_TIMESTAMP},
|
{"TIMESTAMP", TK_TIMESTAMP},
|
||||||
{"TIMEZONE", TK_TIMEZONE},
|
{"TIMEZONE", TK_TIMEZONE},
|
||||||
{"TINYINT", TK_TINYINT},
|
{"TINYINT", TK_TINYINT},
|
||||||
|
{"TO", TK_TO},
|
||||||
{"TODAY", TK_TODAY},
|
{"TODAY", TK_TODAY},
|
||||||
{"TOPIC", TK_TOPIC},
|
{"TOPIC", TK_TOPIC},
|
||||||
{"TOPICS", TK_TOPICS},
|
{"TOPICS", TK_TOPICS},
|
||||||
|
{"TRANSACTION", TK_TRANSACTION},
|
||||||
|
{"TRANSACTIONS", TK_TRANSACTIONS},
|
||||||
{"TRIGGER", TK_TRIGGER},
|
{"TRIGGER", TK_TRIGGER},
|
||||||
{"TSERIES", TK_TSERIES},
|
{"TSERIES", TK_TSERIES},
|
||||||
{"TTL", TK_TTL},
|
{"TTL", TK_TTL},
|
||||||
|
@ -206,6 +213,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"WHERE", TK_WHERE},
|
{"WHERE", TK_WHERE},
|
||||||
{"WINDOW_CLOSE", TK_WINDOW_CLOSE},
|
{"WINDOW_CLOSE", TK_WINDOW_CLOSE},
|
||||||
{"WITH", TK_WITH},
|
{"WITH", TK_WITH},
|
||||||
|
{"WRITE", TK_WRITE},
|
||||||
{"_QENDTS", TK_QENDTS},
|
{"_QENDTS", TK_QENDTS},
|
||||||
{"_QSTARTTS", TK_QSTARTTS},
|
{"_QSTARTTS", TK_QSTARTTS},
|
||||||
{"_ROWTS", TK_ROWTS},
|
{"_ROWTS", TK_ROWTS},
|
||||||
|
@ -471,7 +479,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
|
||||||
int delim = z[0];
|
int delim = z[0];
|
||||||
bool strEnd = false;
|
bool strEnd = false;
|
||||||
for (i = 1; z[i]; i++) {
|
for (i = 1; z[i]; i++) {
|
||||||
if (z[i] == '\\') { // ignore the escaped character that follows this backslash
|
if (delim != '`' && z[i] == '\\') { // ignore the escaped character that follows this backslash
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,6 +481,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
||||||
TSDB_CODE_SUCCESS) {
|
TSDB_CODE_SUCCESS) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
}
|
}
|
||||||
|
*(int64_t*)&pVal->typeData = pVal->datum.i;
|
||||||
} else {
|
} else {
|
||||||
switch (pVal->node.resType.type) {
|
switch (pVal->node.resType.type) {
|
||||||
case TSDB_DATA_TYPE_NULL:
|
case TSDB_DATA_TYPE_NULL:
|
||||||
|
@ -2596,7 +2597,7 @@ static int32_t translateDropSuperTable(STranslateContext* pCxt, SDropSuperTableS
|
||||||
pStmt->ignoreNotExists);
|
pStmt->ignoreNotExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterReq) {
|
static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAlterStbReq* pAlterReq) {
|
||||||
pAlterReq->pFields = taosArrayInit(2, sizeof(TAOS_FIELD));
|
pAlterReq->pFields = taosArrayInit(2, sizeof(TAOS_FIELD));
|
||||||
if (NULL == pAlterReq->pFields) {
|
if (NULL == pAlterReq->pFields) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -2628,17 +2629,17 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterRe
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pAlterReq->numOfFields = taosArrayGetSize(pAlterReq->pFields);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pStmt) {
|
static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pStmt) {
|
||||||
SMAltertbReq alterReq = {0};
|
SMAlterStbReq alterReq = {0};
|
||||||
SName tableName;
|
SName tableName;
|
||||||
tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), alterReq.name);
|
tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), alterReq.name);
|
||||||
alterReq.alterType = pStmt->alterType;
|
alterReq.alterType = pStmt->alterType;
|
||||||
alterReq.numOfFields = 1;
|
if (TSDB_ALTER_TABLE_UPDATE_OPTIONS == pStmt->alterType || TSDB_ALTER_TABLE_UPDATE_TAG_VAL == pStmt->alterType) {
|
||||||
if (TSDB_ALTER_TABLE_UPDATE_OPTIONS == pStmt->alterType) {
|
return TSDB_CODE_FAILED;
|
||||||
// todo
|
|
||||||
} else {
|
} else {
|
||||||
if (TSDB_CODE_SUCCESS != setAlterTableField(pStmt, &alterReq)) {
|
if (TSDB_CODE_SUCCESS != setAlterTableField(pStmt, &alterReq)) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -3022,6 +3023,12 @@ static int32_t translateKillQuery(STranslateContext* pCxt, SKillStmt* pStmt) {
|
||||||
return buildCmdMsg(pCxt, TDMT_MND_KILL_QUERY, (FSerializeFunc)tSerializeSKillQueryReq, &killReq);
|
return buildCmdMsg(pCxt, TDMT_MND_KILL_QUERY, (FSerializeFunc)tSerializeSKillQueryReq, &killReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateKillTransaction(STranslateContext* pCxt, SKillStmt* pStmt) {
|
||||||
|
SKillTransReq killReq = {0};
|
||||||
|
killReq.transId = pStmt->targetId;
|
||||||
|
return buildCmdMsg(pCxt, TDMT_MND_KILL_TRANS, (FSerializeFunc)tSerializeSKillTransReq, &killReq);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) {
|
static int32_t translateCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) {
|
||||||
SCMCreateStreamReq createReq = {0};
|
SCMCreateStreamReq createReq = {0};
|
||||||
|
|
||||||
|
@ -3120,6 +3127,38 @@ static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionS
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) {
|
||||||
|
SAlterUserReq req = {0};
|
||||||
|
if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_ALL) ||
|
||||||
|
(PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_READ) &&
|
||||||
|
PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE))) {
|
||||||
|
req.alterType = TSDB_ALTER_USER_ADD_ALL_DB;
|
||||||
|
} else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_READ)) {
|
||||||
|
req.alterType = TSDB_ALTER_USER_ADD_READ_DB;
|
||||||
|
} else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE)) {
|
||||||
|
req.alterType = TSDB_ALTER_USER_ADD_WRITE_DB;
|
||||||
|
}
|
||||||
|
strcpy(req.user, pStmt->userName);
|
||||||
|
strcpy(req.dbname, pStmt->dbName);
|
||||||
|
return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t translateRevoke(STranslateContext* pCxt, SRevokeStmt* pStmt) {
|
||||||
|
SAlterUserReq req = {0};
|
||||||
|
if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_ALL) ||
|
||||||
|
(PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_READ) &&
|
||||||
|
PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE))) {
|
||||||
|
req.alterType = TSDB_ALTER_USER_REMOVE_ALL_DB;
|
||||||
|
} else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_READ)) {
|
||||||
|
req.alterType = TSDB_ALTER_USER_REMOVE_READ_DB;
|
||||||
|
} else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE)) {
|
||||||
|
req.alterType = TSDB_ALTER_USER_REMOVE_WRITE_DB;
|
||||||
|
}
|
||||||
|
strcpy(req.user, pStmt->userName);
|
||||||
|
strcpy(req.dbname, pStmt->dbName);
|
||||||
|
return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
switch (nodeType(pNode)) {
|
switch (nodeType(pNode)) {
|
||||||
|
@ -3215,6 +3254,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||||
case QUERY_NODE_KILL_QUERY_STMT:
|
case QUERY_NODE_KILL_QUERY_STMT:
|
||||||
code = translateKillQuery(pCxt, (SKillStmt*)pNode);
|
code = translateKillQuery(pCxt, (SKillStmt*)pNode);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_KILL_TRANSACTION_STMT:
|
||||||
|
code = translateKillTransaction(pCxt, (SKillStmt*)pNode);
|
||||||
|
break;
|
||||||
case QUERY_NODE_CREATE_STREAM_STMT:
|
case QUERY_NODE_CREATE_STREAM_STMT:
|
||||||
code = translateCreateStream(pCxt, (SCreateStreamStmt*)pNode);
|
code = translateCreateStream(pCxt, (SCreateStreamStmt*)pNode);
|
||||||
break;
|
break;
|
||||||
|
@ -3224,6 +3266,12 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||||
case QUERY_NODE_CREATE_FUNCTION_STMT:
|
case QUERY_NODE_CREATE_FUNCTION_STMT:
|
||||||
code = translateCreateFunction(pCxt, (SCreateFunctionStmt*)pNode);
|
code = translateCreateFunction(pCxt, (SCreateFunctionStmt*)pNode);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_GRANT_STMT:
|
||||||
|
code = translateGrant(pCxt, (SGrantStmt*)pNode);
|
||||||
|
break;
|
||||||
|
case QUERY_NODE_REVOKE_STMT:
|
||||||
|
code = translateRevoke(pCxt, (SRevokeStmt*)pNode);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3344,6 +3392,7 @@ static const char* getSysDbName(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
return TSDB_PERFORMANCE_SCHEMA_DB;
|
return TSDB_PERFORMANCE_SCHEMA_DB;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -3391,6 +3440,8 @@ static const char* getSysTableName(ENodeType type) {
|
||||||
return TSDB_PERFS_TABLE_QUERIES;
|
return TSDB_PERFS_TABLE_QUERIES;
|
||||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||||
return TSDB_PERFS_TABLE_TOPICS;
|
return TSDB_PERFS_TABLE_TOPICS;
|
||||||
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
|
return TSDB_PERFS_TABLE_TRANS;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3557,7 +3608,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
|
||||||
|
|
||||||
static int32_t serializeVgroupCreateTableBatch(SVgroupCreateTableBatch* pTbBatch, SArray* pBufArray) {
|
static int32_t serializeVgroupCreateTableBatch(SVgroupCreateTableBatch* pTbBatch, SArray* pBufArray) {
|
||||||
int tlen;
|
int tlen;
|
||||||
SCoder coder = {0};
|
SEncoder coder = {0};
|
||||||
|
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
tEncodeSize(tEncodeSVCreateTbBatchReq, &pTbBatch->req, tlen, ret);
|
tEncodeSize(tEncodeSVCreateTbBatchReq, &pTbBatch->req, tlen, ret);
|
||||||
|
@ -3570,9 +3621,9 @@ static int32_t serializeVgroupCreateTableBatch(SVgroupCreateTableBatch* pTbBatch
|
||||||
((SMsgHead*)buf)->contLen = htonl(tlen);
|
((SMsgHead*)buf)->contLen = htonl(tlen);
|
||||||
void* pBuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
void* pBuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||||
|
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pBuf, tlen - sizeof(SMsgHead), TD_ENCODER);
|
tEncoderInit(&coder, pBuf, tlen - sizeof(SMsgHead));
|
||||||
tEncodeSVCreateTbBatchReq(&coder, &pTbBatch->req);
|
tEncodeSVCreateTbBatchReq(&coder, &pTbBatch->req);
|
||||||
tCoderClear(&coder);
|
tEncoderClear(&coder);
|
||||||
|
|
||||||
SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks));
|
SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks));
|
||||||
if (NULL == pVgData) {
|
if (NULL == pVgData) {
|
||||||
|
@ -3957,7 +4008,7 @@ static void destroyDropTbReqBatch(SVgroupDropTableBatch* pTbBatch) { taosArrayDe
|
||||||
|
|
||||||
static int32_t serializeVgroupDropTableBatch(SVgroupDropTableBatch* pTbBatch, SArray* pBufArray) {
|
static int32_t serializeVgroupDropTableBatch(SVgroupDropTableBatch* pTbBatch, SArray* pBufArray) {
|
||||||
int tlen;
|
int tlen;
|
||||||
SCoder coder = {0};
|
SEncoder coder = {0};
|
||||||
|
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
tEncodeSize(tEncodeSVDropTbBatchReq, &pTbBatch->req, tlen, ret);
|
tEncodeSize(tEncodeSVDropTbBatchReq, &pTbBatch->req, tlen, ret);
|
||||||
|
@ -3970,9 +4021,9 @@ static int32_t serializeVgroupDropTableBatch(SVgroupDropTableBatch* pTbBatch, SA
|
||||||
((SMsgHead*)buf)->contLen = htonl(tlen);
|
((SMsgHead*)buf)->contLen = htonl(tlen);
|
||||||
void* pBuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
void* pBuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||||
|
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pBuf, tlen - sizeof(SMsgHead), TD_ENCODER);
|
tEncoderInit(&coder, pBuf, tlen - sizeof(SMsgHead));
|
||||||
tEncodeSVDropTbBatchReq(&coder, &pTbBatch->req);
|
tEncodeSVDropTbBatchReq(&coder, &pTbBatch->req);
|
||||||
tCoderClear(&coder);
|
tEncoderClear(&coder);
|
||||||
|
|
||||||
SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks));
|
SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks));
|
||||||
if (NULL == pVgData) {
|
if (NULL == pVgData) {
|
||||||
|
|
|
@ -36,6 +36,9 @@ bool isInsertSql(const char* pStr, size_t length) {
|
||||||
|
|
||||||
static int32_t parseSqlIntoAst(SParseContext* pCxt, SQuery** pQuery) {
|
static int32_t parseSqlIntoAst(SParseContext* pCxt, SQuery** pQuery) {
|
||||||
int32_t code = parse(pCxt, pQuery);
|
int32_t code = parse(pCxt, pQuery);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = authenticate(pCxt, *pQuery);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translate(pCxt, *pQuery);
|
code = translate(pCxt, *pQuery);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -181,6 +181,12 @@ int32_t __catalogGetDBCfg(SCatalog* pCtg, void* pRpc, const SEpSet* pMgmtEps, co
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t __catalogChkAuth(SCatalog* pCtg, void* pRpc, const SEpSet* pMgmtEps, const char* user, const char* dbFName,
|
||||||
|
AUTH_TYPE type, bool* pass) {
|
||||||
|
*pass = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void initMetaDataEnv() {
|
void initMetaDataEnv() {
|
||||||
mockCatalogService.reset(new MockCatalogService());
|
mockCatalogService.reset(new MockCatalogService());
|
||||||
|
|
||||||
|
@ -193,6 +199,7 @@ void initMetaDataEnv() {
|
||||||
stub.set(catalogGetDBVgVersion, __catalogGetDBVgVersion);
|
stub.set(catalogGetDBVgVersion, __catalogGetDBVgVersion);
|
||||||
stub.set(catalogGetDBVgInfo, __catalogGetDBVgInfo);
|
stub.set(catalogGetDBVgInfo, __catalogGetDBVgInfo);
|
||||||
stub.set(catalogGetDBCfg, __catalogGetDBCfg);
|
stub.set(catalogGetDBCfg, __catalogGetDBCfg);
|
||||||
|
stub.set(catalogChkAuth, __catalogChkAuth);
|
||||||
// {
|
// {
|
||||||
// AddrAny any("libcatalog.so");
|
// AddrAny any("libcatalog.so");
|
||||||
// std::map<std::string,void*> result;
|
// std::map<std::string,void*> result;
|
||||||
|
|
|
@ -24,11 +24,20 @@ class ParserExplainToSyncdbTest : public ParserTestBase {};
|
||||||
TEST_F(ParserExplainToSyncdbTest, explain) {
|
TEST_F(ParserExplainToSyncdbTest, explain) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("explain SELECT * FROM t1");
|
run("EXPLAIN SELECT * FROM t1");
|
||||||
|
|
||||||
run("explain analyze SELECT * FROM t1");
|
run("EXPLAIN ANALYZE SELECT * FROM t1");
|
||||||
|
|
||||||
run("explain analyze verbose true ratio 0.01 SELECT * FROM t1");
|
run("EXPLAIN ANALYZE VERBOSE true RATIO 0.01 SELECT * FROM t1");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserExplainToSyncdbTest, grant) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("GRANT ALL ON test.* TO wxy");
|
||||||
|
run("GRANT READ ON test.* TO wxy");
|
||||||
|
run("GRANT WRITE ON test.* TO wxy");
|
||||||
|
run("GRANT READ, WRITE ON test.* TO wxy");
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo kill connection
|
// todo kill connection
|
||||||
|
@ -37,6 +46,16 @@ TEST_F(ParserExplainToSyncdbTest, explain) {
|
||||||
// todo merge vgroup
|
// todo merge vgroup
|
||||||
// todo redistribute vgroup
|
// todo redistribute vgroup
|
||||||
// todo reset query cache
|
// todo reset query cache
|
||||||
|
|
||||||
|
TEST_F(ParserExplainToSyncdbTest, revoke) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("REVOKE ALL ON test.* FROM wxy");
|
||||||
|
run("REVOKE READ ON test.* FROM wxy");
|
||||||
|
run("REVOKE WRITE ON test.* FROM wxy");
|
||||||
|
run("REVOKE READ, WRITE ON test.* FROM wxy");
|
||||||
|
}
|
||||||
|
|
||||||
// todo syncdb
|
// todo syncdb
|
||||||
|
|
||||||
} // namespace ParserTest
|
} // namespace ParserTest
|
||||||
|
|
|
@ -24,39 +24,84 @@ class ParserInitialATest : public ParserTestBase {};
|
||||||
TEST_F(ParserInitialATest, alterAccount) {
|
TEST_F(ParserInitialATest, alterAccount) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("alter account ac_wxy pass '123456'", TSDB_CODE_PAR_EXPRIE_STATEMENT);
|
run("ALTER ACCOUNT ac_wxy PASS '123456'", TSDB_CODE_PAR_EXPRIE_STATEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialATest, alterDnode) {
|
TEST_F(ParserInitialATest, alterDnode) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("alter dnode 1 'resetLog'");
|
run("ALTER DNODE 1 'resetLog'");
|
||||||
|
|
||||||
run("alter dnode 1 'debugFlag' '134'");
|
run("ALTER DNODE 1 'debugFlag' '134'");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialATest, alterDatabase) {
|
TEST_F(ParserInitialATest, alterDatabase) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("alter database wxy_db cachelast 1 fsync 200 wal 1");
|
run("ALTER DATABASE wxy_db CACHELAST 1 FSYNC 200 WAL 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo alter local
|
// todo ALTER local
|
||||||
// todo alter stable
|
// todo ALTER stable
|
||||||
// todo alter table
|
|
||||||
|
/*
|
||||||
|
* ALTER TABLE [db_name.]tb_name alter_table_clause
|
||||||
|
*
|
||||||
|
* alter_table_clause: {
|
||||||
|
* alter_table_options
|
||||||
|
* | ADD COLUMN col_name column_type
|
||||||
|
* | DROP COLUMN col_name
|
||||||
|
* | MODIFY COLUMN col_name column_type
|
||||||
|
* | RENAME COLUMN old_col_name new_col_name
|
||||||
|
* | ADD TAG tag_name tag_type
|
||||||
|
* | DROP TAG tag_name
|
||||||
|
* | MODIFY TAG tag_name tag_type
|
||||||
|
* | RENAME TAG old_tag_name new_tag_name
|
||||||
|
* | SET TAG tag_name = new_tag_value
|
||||||
|
* | ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option]
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* alter_table_options:
|
||||||
|
* alter_table_option ...
|
||||||
|
*
|
||||||
|
* alter_table_option: {
|
||||||
|
* TTL value
|
||||||
|
* | COMMENT 'string_value'
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
TEST_F(ParserInitialATest, alterTable) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
// run("ALTER TABLE t1 TTL 10");
|
||||||
|
// run("ALTER TABLE t1 COMMENT 'test'");
|
||||||
|
run("ALTER TABLE t1 ADD COLUMN cc1 BIGINT");
|
||||||
|
run("ALTER TABLE t1 DROP COLUMN c1");
|
||||||
|
run("ALTER TABLE t1 MODIFY COLUMN c1 VARCHAR(20)");
|
||||||
|
run("ALTER TABLE t1 RENAME COLUMN c1 cc1");
|
||||||
|
|
||||||
|
run("ALTER TABLE st1 ADD TAG tag11 BIGINT");
|
||||||
|
run("ALTER TABLE st1 DROP TAG tag1");
|
||||||
|
run("ALTER TABLE st1 MODIFY TAG tag1 VARCHAR(20)");
|
||||||
|
run("ALTER TABLE st1 RENAME TAG tag1 tag11");
|
||||||
|
|
||||||
|
// run("ALTER TABLE st1s1 SET TAG tag1=10");
|
||||||
|
|
||||||
|
// todo
|
||||||
|
// ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option]
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialATest, alterUser) {
|
TEST_F(ParserInitialATest, alterUser) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("alter user wxy pass '123456'");
|
run("ALTER user wxy PASS '123456'");
|
||||||
|
|
||||||
run("alter user wxy privilege 'write'");
|
run("ALTER user wxy privilege 'write'");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialATest, bug001) {
|
TEST_F(ParserInitialATest, bug001) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("alter database db wal 0 # td-14436", TSDB_CODE_PAR_SYNTAX_ERROR);
|
run("ALTER DATABASE db WAL 0 # td-14436", TSDB_CODE_PAR_SYNTAX_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ParserTest
|
} // namespace ParserTest
|
|
@ -21,111 +21,117 @@ namespace ParserTest {
|
||||||
|
|
||||||
class ParserShowToUseTest : public ParserTestBase {};
|
class ParserShowToUseTest : public ParserTestBase {};
|
||||||
|
|
||||||
// todo show accounts
|
// todo SHOW accounts
|
||||||
// todo show apps
|
// todo SHOW apps
|
||||||
// todo show connections
|
// todo SHOW connections
|
||||||
// todo show create database
|
// todo SHOW create database
|
||||||
// todo show create stable
|
// todo SHOW create stable
|
||||||
// todo show create table
|
// todo SHOW create table
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showDatabases) {
|
TEST_F(ParserShowToUseTest, showDatabases) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show databases");
|
run("SHOW databases");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showDnodes) {
|
TEST_F(ParserShowToUseTest, showDnodes) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show dnodes");
|
run("SHOW dnodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showFunctions) {
|
TEST_F(ParserShowToUseTest, showFunctions) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show functions");
|
run("SHOW functions");
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo show licence
|
// todo SHOW licence
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showIndexes) {
|
TEST_F(ParserShowToUseTest, showIndexes) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show indexes from t1");
|
run("SHOW indexes from t1");
|
||||||
|
|
||||||
run("show indexes from t1 from test");
|
run("SHOW indexes from t1 from test");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showMnodes) {
|
TEST_F(ParserShowToUseTest, showMnodes) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show mnodes");
|
run("SHOW mnodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showModules) {
|
TEST_F(ParserShowToUseTest, showModules) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show modules");
|
run("SHOW modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showQnodes) {
|
TEST_F(ParserShowToUseTest, showQnodes) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show qnodes");
|
run("SHOW qnodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo show queries
|
// todo SHOW queries
|
||||||
// todo show scores
|
// todo SHOW scores
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showStables) {
|
TEST_F(ParserShowToUseTest, showStables) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show stables");
|
run("SHOW stables");
|
||||||
|
|
||||||
run("show test.stables");
|
run("SHOW test.stables");
|
||||||
|
|
||||||
run("show stables like 'c%'");
|
run("SHOW stables like 'c%'");
|
||||||
|
|
||||||
run("show test.stables like 'c%'");
|
run("SHOW test.stables like 'c%'");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showStreams) {
|
TEST_F(ParserShowToUseTest, showStreams) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show streams");
|
run("SHOW streams");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserShowToUseTest, showTransactions) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("SHOW TRANSACTIONS");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showTables) {
|
TEST_F(ParserShowToUseTest, showTables) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show tables");
|
run("SHOW tables");
|
||||||
|
|
||||||
run("show test.tables");
|
run("SHOW test.tables");
|
||||||
|
|
||||||
run("show tables like 'c%'");
|
run("SHOW tables like 'c%'");
|
||||||
|
|
||||||
run("show test.tables like 'c%'");
|
run("SHOW test.tables like 'c%'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo show topics
|
// todo SHOW topics
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showUsers) {
|
TEST_F(ParserShowToUseTest, showUsers) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show users");
|
run("SHOW users");
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo show variables
|
// todo SHOW variables
|
||||||
|
|
||||||
TEST_F(ParserShowToUseTest, showVgroups) {
|
TEST_F(ParserShowToUseTest, showVgroups) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("show vgroups");
|
run("SHOW vgroups");
|
||||||
|
|
||||||
run("show test.vgroups");
|
run("SHOW test.vgroups");
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo show vnodes
|
// todo SHOW vnodes
|
||||||
|
|
||||||
// todo split vgroup
|
// todo split vgroup
|
||||||
|
|
||||||
|
|
|
@ -1333,13 +1333,11 @@ int32_t createPhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryP
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
if (QUERY_POLICY_VNODE == tsQueryPolicy) {
|
||||||
if (tsQueryPolicy > QUERY_POLICY_VNODE) {
|
taosArrayClear(pExecNodeList);
|
||||||
code = catalogGetQnodeList(pCxt->pCatalog, pCxt->pTransporter, &pCxt->mgmtEpSet, pExecNodeList);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = doCreatePhysiPlan(&cxt, pLogicPlan, pPlan);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t code = doCreatePhysiPlan(&cxt, pLogicPlan, pPlan);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
setExplainInfo(pCxt, *pPlan);
|
setExplainInfo(pCxt, *pPlan);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,16 @@ using namespace std;
|
||||||
|
|
||||||
class PlanSuperTableTest : public PlannerTestBase {};
|
class PlanSuperTableTest : public PlannerTestBase {};
|
||||||
|
|
||||||
TEST_F(PlanSuperTableTest, tbname) {
|
TEST_F(PlanSuperTableTest, pseudoCol) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("select tbname from st1");
|
run("SELECT TBNAME FROM st1");
|
||||||
|
|
||||||
run("select tbname, tag1, tag2 from st1");
|
run("SELECT TBNAME, tag1, tag2 FROM st1");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(PlanSuperTableTest, orderBy) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("SELECT -1*c1, c1 FROM st1 ORDER BY -1*c1");
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ extern "C" {
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
|
#include "plannodes.h"
|
||||||
|
|
||||||
#define QW_DEFAULT_SCHEDULER_NUMBER 10000
|
#define QW_DEFAULT_SCHEDULER_NUMBER 10000
|
||||||
#define QW_DEFAULT_TASK_NUMBER 10000
|
#define QW_DEFAULT_TASK_NUMBER 10000
|
||||||
|
@ -133,6 +134,7 @@ typedef struct SQWTaskCtx {
|
||||||
|
|
||||||
void *taskHandle;
|
void *taskHandle;
|
||||||
void *sinkHandle;
|
void *sinkHandle;
|
||||||
|
SSubplan *plan;
|
||||||
} SQWTaskCtx;
|
} SQWTaskCtx;
|
||||||
|
|
||||||
typedef struct SQWSchStatus {
|
typedef struct SQWSchStatus {
|
||||||
|
|
|
@ -424,6 +424,11 @@ void qwFreeTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
||||||
dsDestroyDataSinker(ctx->sinkHandle);
|
dsDestroyDataSinker(ctx->sinkHandle);
|
||||||
ctx->sinkHandle = NULL;
|
ctx->sinkHandle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx->plan) {
|
||||||
|
nodesDestroyNode(ctx->plan);
|
||||||
|
ctx->plan = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwDropTaskCtx(QW_FPARAMS_DEF) {
|
int32_t qwDropTaskCtx(QW_FPARAMS_DEF) {
|
||||||
|
@ -440,6 +445,7 @@ int32_t qwDropTaskCtx(QW_FPARAMS_DEF) {
|
||||||
|
|
||||||
atomic_store_ptr(&ctx->taskHandle, NULL);
|
atomic_store_ptr(&ctx->taskHandle, NULL);
|
||||||
atomic_store_ptr(&ctx->sinkHandle, NULL);
|
atomic_store_ptr(&ctx->sinkHandle, NULL);
|
||||||
|
atomic_store_ptr(&ctx->plan, NULL);
|
||||||
|
|
||||||
QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_DROP);
|
QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_DROP);
|
||||||
|
|
||||||
|
@ -922,7 +928,7 @@ _return:
|
||||||
int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t explain) {
|
int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t explain) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
bool queryRsped = false;
|
bool queryRsped = false;
|
||||||
struct SSubplan *plan = NULL;
|
SSubplan* plan = NULL;
|
||||||
SQWPhaseInput input = {0};
|
SQWPhaseInput input = {0};
|
||||||
qTaskInfo_t pTaskInfo = NULL;
|
qTaskInfo_t pTaskInfo = NULL;
|
||||||
DataSinkHandle sinkHandle = NULL;
|
DataSinkHandle sinkHandle = NULL;
|
||||||
|
@ -950,6 +956,8 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t ex
|
||||||
QW_ERR_JRET(code);
|
QW_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx->plan = plan;
|
||||||
|
|
||||||
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, OPTR_EXEC_MODEL_BATCH);
|
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, OPTR_EXEC_MODEL_BATCH);
|
||||||
if (code) {
|
if (code) {
|
||||||
QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code));
|
QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code));
|
||||||
|
@ -1428,6 +1436,10 @@ void qwCloseRef(void) {
|
||||||
taosWUnLockLatch(&gQwMgmt.lock);
|
taosWUnLockLatch(&gQwMgmt.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qwDestroySchStatus(SQWSchStatus *pStatus) {
|
||||||
|
taosHashCleanup(pStatus->tasksHash);
|
||||||
|
}
|
||||||
|
|
||||||
void qwDestroyImpl(void *pMgmt) {
|
void qwDestroyImpl(void *pMgmt) {
|
||||||
SQWorker *mgmt = (SQWorker *)pMgmt;
|
SQWorker *mgmt = (SQWorker *)pMgmt;
|
||||||
|
|
||||||
|
@ -1439,6 +1451,13 @@ void qwDestroyImpl(void *pMgmt) {
|
||||||
// TODO FREE ALL
|
// TODO FREE ALL
|
||||||
|
|
||||||
taosHashCleanup(mgmt->ctxHash);
|
taosHashCleanup(mgmt->ctxHash);
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(mgmt->schHash, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SQWSchStatus *sch = (SQWSchStatus *)pIter;
|
||||||
|
qwDestroySchStatus(sch);
|
||||||
|
pIter = taosHashIterate(mgmt->schHash, pIter);
|
||||||
|
}
|
||||||
taosHashCleanup(mgmt->schHash);
|
taosHashCleanup(mgmt->schHash);
|
||||||
|
|
||||||
taosMemoryFree(mgmt);
|
taosMemoryFree(mgmt);
|
||||||
|
|
|
@ -1085,21 +1085,21 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
case TDMT_VND_CREATE_TABLE_RSP: {
|
case TDMT_VND_CREATE_TABLE_RSP: {
|
||||||
SVCreateTbBatchRsp batchRsp = {0};
|
SVCreateTbBatchRsp batchRsp = {0};
|
||||||
if (msg) {
|
if (msg) {
|
||||||
SCoder coder = {0};
|
SDecoder coder = {0};
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, msg, msgSize, TD_DECODER);
|
tDecoderInit(&coder, msg, msgSize);
|
||||||
code = tDecodeSVCreateTbBatchRsp(&coder, &batchRsp);
|
code = tDecodeSVCreateTbBatchRsp(&coder, &batchRsp);
|
||||||
if (TSDB_CODE_SUCCESS == code && batchRsp.nRsps > 0) {
|
if (TSDB_CODE_SUCCESS == code && batchRsp.nRsps > 0) {
|
||||||
for (int32_t i = 0; i < batchRsp.nRsps; ++i) {
|
for (int32_t i = 0; i < batchRsp.nRsps; ++i) {
|
||||||
SVCreateTbRsp *rsp = batchRsp.pRsps + i;
|
SVCreateTbRsp *rsp = batchRsp.pRsps + i;
|
||||||
if (NEED_CLIENT_HANDLE_ERROR(rsp->code)) {
|
if (NEED_CLIENT_HANDLE_ERROR(rsp->code)) {
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
SCH_ERR_JRET(rsp->code);
|
SCH_ERR_JRET(rsp->code);
|
||||||
} else if (TSDB_CODE_SUCCESS != rsp->code) {
|
} else if (TSDB_CODE_SUCCESS != rsp->code) {
|
||||||
code = rsp->code;
|
code = rsp->code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
SCH_ERR_JRET(code);
|
SCH_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1110,21 +1110,21 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
case TDMT_VND_DROP_TABLE_RSP: {
|
case TDMT_VND_DROP_TABLE_RSP: {
|
||||||
SVDropTbBatchRsp batchRsp = {0};
|
SVDropTbBatchRsp batchRsp = {0};
|
||||||
if (msg) {
|
if (msg) {
|
||||||
SCoder coder = {0};
|
SDecoder coder = {0};
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, msg, msgSize, TD_DECODER);
|
tDecoderInit(&coder, msg, msgSize);
|
||||||
code = tDecodeSVDropTbBatchRsp(&coder, &batchRsp);
|
code = tDecodeSVDropTbBatchRsp(&coder, &batchRsp);
|
||||||
if (TSDB_CODE_SUCCESS == code && batchRsp.nRsps > 0) {
|
if (TSDB_CODE_SUCCESS == code && batchRsp.nRsps > 0) {
|
||||||
for (int32_t i = 0; i < batchRsp.nRsps; ++i) {
|
for (int32_t i = 0; i < batchRsp.nRsps; ++i) {
|
||||||
SVDropTbRsp *rsp = batchRsp.pRsps + i;
|
SVDropTbRsp *rsp = batchRsp.pRsps + i;
|
||||||
if (NEED_CLIENT_HANDLE_ERROR(rsp->code)) {
|
if (NEED_CLIENT_HANDLE_ERROR(rsp->code)) {
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
SCH_ERR_JRET(rsp->code);
|
SCH_ERR_JRET(rsp->code);
|
||||||
} else if (TSDB_CODE_SUCCESS != rsp->code) {
|
} else if (TSDB_CODE_SUCCESS != rsp->code) {
|
||||||
code = rsp->code;
|
code = rsp->code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tCoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
SCH_ERR_JRET(code);
|
SCH_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,7 @@ SStreamTask* tNewSStreamTask(int64_t streamId) {
|
||||||
return pTask;
|
return pTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask) {
|
int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
||||||
/*if (tStartEncode(pEncoder) < 0) return -1;*/
|
/*if (tStartEncode(pEncoder) < 0) return -1;*/
|
||||||
if (tEncodeI64(pEncoder, pTask->streamId) < 0) return -1;
|
if (tEncodeI64(pEncoder, pTask->streamId) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pTask->taskId) < 0) return -1;
|
if (tEncodeI32(pEncoder, pTask->taskId) < 0) return -1;
|
||||||
|
@ -301,7 +301,7 @@ int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask) {
|
||||||
return pEncoder->pos;
|
return pEncoder->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask) {
|
int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
||||||
/*if (tStartDecode(pDecoder) < 0) return -1;*/
|
/*if (tStartDecode(pDecoder) < 0) return -1;*/
|
||||||
if (tDecodeI64(pDecoder, &pTask->streamId) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pTask->streamId) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1;
|
||||||
|
|
|
@ -138,7 +138,7 @@ static SScalableBf* getSBf(SUpdateInfo *pInfo, TSKEY ts) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isUpdated(SUpdateInfo *pInfo, tb_uid_t tableId, TSKEY ts) {
|
bool updateInfoIsUpdated(SUpdateInfo *pInfo, tb_uid_t tableId, TSKEY ts) {
|
||||||
int32_t res = TSDB_CODE_FAILED;
|
int32_t res = TSDB_CODE_FAILED;
|
||||||
uint64_t index = ((uint64_t)tableId) % pInfo->numBuckets;
|
uint64_t index = ((uint64_t)tableId) % pInfo->numBuckets;
|
||||||
SScalableBf* pSBf = getSBf(pInfo, ts);
|
SScalableBf* pSBf = getSBf(pInfo, ts);
|
||||||
|
|
|
@ -9,40 +9,40 @@ TEST(TD_STREAM_UPDATE_TEST, update) {
|
||||||
int64_t interval = 20 * 1000;
|
int64_t interval = 20 * 1000;
|
||||||
int64_t watermark = 10 * 60 * 1000;
|
int64_t watermark = 10 * 60 * 1000;
|
||||||
SUpdateInfo *pSU = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark);
|
SUpdateInfo *pSU = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark);
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU,1, 0), true);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,1, 0), true);
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU,1, -1), true);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,1, -1), true);
|
||||||
|
|
||||||
for(int i=0; i < 1024; i++) {
|
for(int i=0; i < 1024; i++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU,i, 1), false);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,i, 1), false);
|
||||||
}
|
}
|
||||||
for(int i=0; i < 1024; i++) {
|
for(int i=0; i < 1024; i++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU,i, 1), true);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,i, 1), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i < 1024; i++) {
|
for(int i=0; i < 1024; i++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU,i, 2), false);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,i, 2), false);
|
||||||
}
|
}
|
||||||
for(int i=0; i < 1024; i++) {
|
for(int i=0; i < 1024; i++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU,i, 2), true);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,i, 2), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i < 1024; i++) {
|
for(int i=0; i < 1024; i++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU,i, 1), true);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,i, 1), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=3; i < 1024; i++) {
|
for(int i=3; i < 1024; i++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU,0, i), false);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,0, i), false);
|
||||||
}
|
}
|
||||||
GTEST_ASSERT_EQ(*(int64_t*)taosArrayGet(pSU->pTsBuckets,0), 1023);
|
GTEST_ASSERT_EQ(*(int64_t*)taosArrayGet(pSU->pTsBuckets,0), 1023);
|
||||||
|
|
||||||
for(int i=3; i < 1024; i++) {
|
for(int i=3; i < 1024; i++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU,0, i), true);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,0, i), true);
|
||||||
}
|
}
|
||||||
GTEST_ASSERT_EQ(*(int64_t*)taosArrayGet(pSU->pTsBuckets,0), 1023);
|
GTEST_ASSERT_EQ(*(int64_t*)taosArrayGet(pSU->pTsBuckets,0), 1023);
|
||||||
|
|
||||||
SUpdateInfo *pSU1 = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark);
|
SUpdateInfo *pSU1 = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark);
|
||||||
for(int i=1; i <= watermark / interval; i++) {
|
for(int i=1; i <= watermark / interval; i++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU1, 1, i * interval + 5), false);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU1, 1, i * interval + 5), false);
|
||||||
GTEST_ASSERT_EQ(pSU1->minTS, interval);
|
GTEST_ASSERT_EQ(pSU1->minTS, interval);
|
||||||
GTEST_ASSERT_EQ(pSU1->numSBFs, watermark / interval);
|
GTEST_ASSERT_EQ(pSU1->numSBFs, watermark / interval);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ TEST(TD_STREAM_UPDATE_TEST, update) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i= watermark / interval + 1, j = 2 ; i <= watermark / interval + 10; i++,j++) {
|
for(int i= watermark / interval + 1, j = 2 ; i <= watermark / interval + 10; i++,j++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU1, 1, i * interval + 5), false);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU1, 1, i * interval + 5), false);
|
||||||
GTEST_ASSERT_EQ(pSU1->minTS, interval*j);
|
GTEST_ASSERT_EQ(pSU1->minTS, interval*j);
|
||||||
GTEST_ASSERT_EQ(pSU1->numSBFs, watermark / interval);
|
GTEST_ASSERT_EQ(pSU1->numSBFs, watermark / interval);
|
||||||
SScalableBf *pSBF = (SScalableBf *)taosArrayGetP(pSU1->pTsSBFs, pSU1->numSBFs - 1);
|
SScalableBf *pSBF = (SScalableBf *)taosArrayGetP(pSU1->pTsSBFs, pSU1->numSBFs - 1);
|
||||||
|
@ -62,16 +62,16 @@ TEST(TD_STREAM_UPDATE_TEST, update) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i= watermark / interval * 100, j = 0; j < 10; i+= (watermark / interval * 2), j++) {
|
for(int i= watermark / interval * 100, j = 0; j < 10; i+= (watermark / interval * 2), j++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU1, 1, i * interval + 5), false);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU1, 1, i * interval + 5), false);
|
||||||
GTEST_ASSERT_EQ(pSU1->minTS, (i-(pSU1->numSBFs-1))*interval);
|
GTEST_ASSERT_EQ(pSU1->minTS, (i-(pSU1->numSBFs-1))*interval);
|
||||||
GTEST_ASSERT_EQ(pSU1->numSBFs, watermark / interval);
|
GTEST_ASSERT_EQ(pSU1->numSBFs, watermark / interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
SUpdateInfo *pSU2 = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark);
|
SUpdateInfo *pSU2 = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark);
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU2, 1, 1 * interval + 5), false);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU2, 1, 1 * interval + 5), false);
|
||||||
GTEST_ASSERT_EQ(pSU2->minTS, interval);
|
GTEST_ASSERT_EQ(pSU2->minTS, interval);
|
||||||
for(int i= watermark / interval * 100, j = 0; j < 10; i+= (watermark / interval * 10), j++) {
|
for(int i= watermark / interval * 100, j = 0; j < 10; i+= (watermark / interval * 10), j++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU2, 1, i * interval + 5), false);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU2, 1, i * interval + 5), false);
|
||||||
GTEST_ASSERT_EQ(pSU2->minTS, (i-(pSU2->numSBFs-1))*interval);
|
GTEST_ASSERT_EQ(pSU2->minTS, (i-(pSU2->numSBFs-1))*interval);
|
||||||
GTEST_ASSERT_EQ(pSU2->numSBFs, watermark / interval);
|
GTEST_ASSERT_EQ(pSU2->numSBFs, watermark / interval);
|
||||||
GTEST_ASSERT_EQ(*(int64_t*)taosArrayGet(pSU2->pTsBuckets,1), i * interval + 5);
|
GTEST_ASSERT_EQ(*(int64_t*)taosArrayGet(pSU2->pTsBuckets,1), i * interval + 5);
|
||||||
|
@ -80,7 +80,7 @@ TEST(TD_STREAM_UPDATE_TEST, update) {
|
||||||
SUpdateInfo *pSU3 = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark);
|
SUpdateInfo *pSU3 = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark);
|
||||||
for(int j = 1; j < 100; j++) {
|
for(int j = 1; j < 100; j++) {
|
||||||
for(int i = 0; i < pSU3->numSBFs; i++) {
|
for(int i = 0; i < pSU3->numSBFs; i++) {
|
||||||
GTEST_ASSERT_EQ(isUpdated(pSU3, i, i * interval + 5 * j), false);
|
GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU3, i, i * interval + 5 * j), false);
|
||||||
GTEST_ASSERT_EQ(pSU3->minTS, 0);
|
GTEST_ASSERT_EQ(pSU3->minTS, 0);
|
||||||
GTEST_ASSERT_EQ(pSU3->numSBFs, watermark / interval);
|
GTEST_ASSERT_EQ(pSU3->numSBFs, watermark / interval);
|
||||||
GTEST_ASSERT_EQ(*(int64_t*)taosArrayGet(pSU3->pTsBuckets, i), i * interval + 5 * j);
|
GTEST_ASSERT_EQ(*(int64_t*)taosArrayGet(pSU3->pTsBuckets, i), i * interval + 5 * j);
|
||||||
|
|
|
@ -331,8 +331,8 @@ SyncPing* syncPingDeserialize2(const char* buf, uint32_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncPingSerialize3(const SyncPing* pMsg, char* buf, int32_t bufLen) {
|
int32_t syncPingSerialize3(const SyncPing* pMsg, char* buf, int32_t bufLen) {
|
||||||
SCoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
if (tStartEncode(&encoder) < 0) {
|
if (tStartEncode(&encoder) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -367,13 +367,13 @@ int32_t syncPingSerialize3(const SyncPing* pMsg, char* buf, int32_t bufLen) {
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncPing* syncPingDeserialize3(void* buf, int32_t bufLen) {
|
SyncPing* syncPingDeserialize3(void* buf, int32_t bufLen) {
|
||||||
SCoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
if (tStartDecode(&decoder) < 0) {
|
if (tStartDecode(&decoder) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -409,16 +409,16 @@ SyncPing* syncPingDeserialize3(void* buf, int32_t bufLen) {
|
||||||
if (tDecodeU32(&decoder, &pMsg->dataLen) < 0) {
|
if (tDecodeU32(&decoder, &pMsg->dataLen) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
uint64_t len;
|
uint32_t len;
|
||||||
char* data = NULL;
|
char* data = NULL;
|
||||||
if (tDecodeBinary(&decoder, (const void**)(&data), &len) < 0) {
|
if (tDecodeBinary(&decoder, (const uint8_t**)(&data), &len) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
assert(len = pMsg->dataLen);
|
assert(len = pMsg->dataLen);
|
||||||
memcpy(pMsg->data, data, len);
|
memcpy(pMsg->data, data, len);
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tCoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return pMsg;
|
return pMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,8 +590,8 @@ SyncPingReply* syncPingReplyDeserialize2(const char* buf, uint32_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncPingReplySerialize3(const SyncPingReply* pMsg, char* buf, int32_t bufLen) {
|
int32_t syncPingReplySerialize3(const SyncPingReply* pMsg, char* buf, int32_t bufLen) {
|
||||||
SCoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
if (tStartEncode(&encoder) < 0) {
|
if (tStartEncode(&encoder) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -626,13 +626,13 @@ int32_t syncPingReplySerialize3(const SyncPingReply* pMsg, char* buf, int32_t bu
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
tCoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncPingReply* syncPingReplyDeserialize3(void* buf, int32_t bufLen) {
|
SyncPingReply* syncPingReplyDeserialize3(void* buf, int32_t bufLen) {
|
||||||
SCoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
if (tStartDecode(&decoder) < 0) {
|
if (tStartDecode(&decoder) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -668,16 +668,16 @@ SyncPingReply* syncPingReplyDeserialize3(void* buf, int32_t bufLen) {
|
||||||
if (tDecodeU32(&decoder, &pMsg->dataLen) < 0) {
|
if (tDecodeU32(&decoder, &pMsg->dataLen) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
uint64_t len;
|
uint32_t len;
|
||||||
char* data = NULL;
|
char* data = NULL;
|
||||||
if (tDecodeBinary(&decoder, (const void**)(&data), &len) < 0) {
|
if (tDecodeBinary(&decoder, (const uint8_t**)(&data), &len) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
assert(len = pMsg->dataLen);
|
assert(len = pMsg->dataLen);
|
||||||
memcpy(pMsg->data, data, len);
|
memcpy(pMsg->data, data, len);
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tCoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return pMsg;
|
return pMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ int tdbDbPGet(TDB *pDb, const void *pKey, int kLen, void **ppKey, int *pkLen, vo
|
||||||
// TDBC
|
// TDBC
|
||||||
int tdbDbcOpen(TDB *pDb, TDBC **ppDbc, TXN *pTxn);
|
int tdbDbcOpen(TDB *pDb, TDBC **ppDbc, TXN *pTxn);
|
||||||
int tdbDbcClose(TDBC *pDbc);
|
int tdbDbcClose(TDBC *pDbc);
|
||||||
|
int tdbDbcIsValid(TDBC *pDbc);
|
||||||
int tdbDbcMoveTo(TDBC *pDbc, const void *pKey, int kLen, int *c);
|
int tdbDbcMoveTo(TDBC *pDbc, const void *pKey, int kLen, int *c);
|
||||||
int tdbDbcMoveToFirst(TDBC *pDbc);
|
int tdbDbcMoveToFirst(TDBC *pDbc);
|
||||||
int tdbDbcMoveToLast(TDBC *pDbc);
|
int tdbDbcMoveToLast(TDBC *pDbc);
|
||||||
|
|
|
@ -1678,6 +1678,14 @@ int tdbBtcClose(SBTC *pBtc) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tdbBtcIsValid(SBTC *pBtc) {
|
||||||
|
if (pBtc->idx < 0) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
// TDB_BTREE_CURSOR
|
// TDB_BTREE_CURSOR
|
||||||
|
|
||||||
// TDB_BTREE_DEBUG =====================
|
// TDB_BTREE_DEBUG =====================
|
||||||
|
|
|
@ -141,3 +141,5 @@ int tdbDbcClose(TDBC *pDbc) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tdbDbcIsValid(TDBC *pDbc) { return tdbBtcIsValid(&pDbc->btc); }
|
|
@ -136,6 +136,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
||||||
// SBTC
|
// SBTC
|
||||||
int tdbBtcOpen(SBTC *pBtc, SBTree *pBt, TXN *pTxn);
|
int tdbBtcOpen(SBTC *pBtc, SBTree *pBt, TXN *pTxn);
|
||||||
int tdbBtcClose(SBTC *pBtc);
|
int tdbBtcClose(SBTC *pBtc);
|
||||||
|
int tdbBtcIsValid(SBTC *pBtc);
|
||||||
int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst);
|
int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst);
|
||||||
int tdbBtcMoveToFirst(SBTC *pBtc);
|
int tdbBtcMoveToFirst(SBTC *pBtc);
|
||||||
int tdbBtcMoveToLast(SBTC *pBtc);
|
int tdbBtcMoveToLast(SBTC *pBtc);
|
||||||
|
|
|
@ -791,6 +791,10 @@ static void uvDestroyConn(uv_handle_t* handle) {
|
||||||
}
|
}
|
||||||
QUEUE_REMOVE(&conn->queue);
|
QUEUE_REMOVE(&conn->queue);
|
||||||
taosMemoryFree(conn->pTcp);
|
taosMemoryFree(conn->pTcp);
|
||||||
|
if (conn->regArg.init == 1) {
|
||||||
|
transFreeMsg(conn->regArg.msg.pCont);
|
||||||
|
conn->regArg.init = 0;
|
||||||
|
}
|
||||||
taosMemoryFree(conn);
|
taosMemoryFree(conn);
|
||||||
|
|
||||||
if (thrd->quit && QUEUE_IS_EMPTY(&thrd->conn)) {
|
if (thrd->quit && QUEUE_IS_EMPTY(&thrd->conn)) {
|
||||||
|
@ -846,7 +850,8 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (false == taosValidIpAndPort(srv->ip, srv->port)) {
|
if (false == taosValidIpAndPort(srv->ip, srv->port)) {
|
||||||
tError("failed to bind, reason: %s", terrstr());
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
tError("invalid ip/port, reason: %s", terrstr());
|
||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
if (false == addHandleToAcceptloop(srv)) {
|
if (false == addHandleToAcceptloop(srv)) {
|
||||||
|
|
|
@ -669,7 +669,7 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
|
||||||
if (taosSetSockOpt(pSocket, SOL_SOCKET, SO_REUSEADDR, (void *)&reuse, sizeof(reuse)) < 0) {
|
if (taosSetSockOpt(pSocket, SOL_SOCKET, SO_REUSEADDR, (void *)&reuse, sizeof(reuse)) < 0) {
|
||||||
// printf("setsockopt SO_REUSEADDR failed: %d (%s)", errno, strerror(errno));
|
// printf("setsockopt SO_REUSEADDR failed: %d (%s)", errno, strerror(errno));
|
||||||
taosCloseSocket(&pSocket);
|
taosCloseSocket(&pSocket);
|
||||||
return NULL;
|
return false;
|
||||||
}
|
}
|
||||||
/* bind socket to server address */
|
/* bind socket to server address */
|
||||||
if (bind(pSocket->fd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) {
|
if (bind(pSocket->fd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) {
|
||||||
|
@ -677,6 +677,11 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
|
||||||
taosCloseSocket(&pSocket);
|
taosCloseSocket(&pSocket);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (listen(pSocket->fd, 1024) < 0) {
|
||||||
|
// printf("listen tcp server socket failed, 0x%x:%hu(%s)", ip, port, strerror(errno));
|
||||||
|
taosCloseSocket(&pSocket);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
taosCloseSocket(&pSocket);
|
taosCloseSocket(&pSocket);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,48 +21,60 @@ static_assert(sizeof(float) == sizeof(uint32_t), "sizeof(float) must equal to si
|
||||||
static_assert(sizeof(double) == sizeof(uint64_t), "sizeof(double) must equal to sizeof(uint64_t)");
|
static_assert(sizeof(double) == sizeof(uint64_t), "sizeof(double) must equal to sizeof(uint64_t)");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void tCoderInit(SCoder* pCoder, td_endian_t endian, uint8_t* data, int32_t size, td_coder_t type) {
|
struct SEncoderNode {
|
||||||
if (type == TD_ENCODER) {
|
SEncoderNode* pNext;
|
||||||
if (data == NULL) size = 0;
|
uint8_t* data;
|
||||||
} else {
|
uint32_t size;
|
||||||
ASSERT(data && size > 0);
|
uint32_t pos;
|
||||||
}
|
};
|
||||||
|
|
||||||
pCoder->type = type;
|
struct SDecoderNode {
|
||||||
pCoder->endian = endian;
|
SDecoderNode* pNext;
|
||||||
pCoder->data = data;
|
const uint8_t* data;
|
||||||
pCoder->size = size;
|
uint32_t size;
|
||||||
pCoder->pos = 0;
|
uint32_t pos;
|
||||||
pCoder->mList = NULL;
|
};
|
||||||
TD_SLIST_INIT(&(pCoder->stack));
|
|
||||||
|
void tEncoderInit(SEncoder* pEncoder, uint8_t* data, uint32_t size) {
|
||||||
|
if (data == NULL) size = 0;
|
||||||
|
pEncoder->data = data;
|
||||||
|
pEncoder->size = size;
|
||||||
|
pEncoder->pos = 0;
|
||||||
|
pEncoder->mList = NULL;
|
||||||
|
pEncoder->eStack = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tCoderClear(SCoder* pCoder) {
|
void tEncoderClear(SEncoder* pCoder) {
|
||||||
SCoderMem* pMem;
|
for (SCoderMem* pMem = pCoder->mList; pMem; pMem = pCoder->mList) {
|
||||||
|
|
||||||
// clear memory
|
|
||||||
for (pMem = pCoder->mList; pMem; pMem = pCoder->mList) {
|
|
||||||
pCoder->mList = pMem->next;
|
pCoder->mList = pMem->next;
|
||||||
taosMemoryFree(pMem);
|
taosMemoryFree(pMem);
|
||||||
}
|
}
|
||||||
|
memset(pCoder, 0, sizeof(*pCoder));
|
||||||
struct SCoderNode* pNode;
|
|
||||||
for (;;) {
|
|
||||||
pNode = TD_SLIST_HEAD(&(pCoder->stack));
|
|
||||||
if (pNode == NULL) break;
|
|
||||||
TD_SLIST_POP(&(pCoder->stack));
|
|
||||||
taosMemoryFree(pNode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tStartEncode(SCoder* pCoder) {
|
void tDecoderInit(SDecoder* pDecoder, const uint8_t* data, uint32_t size) {
|
||||||
struct SCoderNode* pNode;
|
pDecoder->data = data;
|
||||||
|
pDecoder->size = size;
|
||||||
|
pDecoder->pos = 0;
|
||||||
|
pDecoder->mList = NULL;
|
||||||
|
pDecoder->dStack = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tDecoderClear(SDecoder* pCoder) {
|
||||||
|
for (SCoderMem* pMem = pCoder->mList; pMem; pMem = pCoder->mList) {
|
||||||
|
pCoder->mList = pMem->next;
|
||||||
|
taosMemoryFree(pMem);
|
||||||
|
}
|
||||||
|
memset(pCoder, 0, sizeof(*pCoder));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tStartEncode(SEncoder* pCoder) {
|
||||||
|
SEncoderNode* pNode;
|
||||||
|
|
||||||
ASSERT(pCoder->type == TD_ENCODER);
|
|
||||||
if (pCoder->data) {
|
if (pCoder->data) {
|
||||||
if (pCoder->size - pCoder->pos < sizeof(int32_t)) return -1;
|
if (pCoder->size - pCoder->pos < sizeof(int32_t)) return -1;
|
||||||
|
|
||||||
pNode = taosMemoryMalloc(sizeof(*pNode));
|
pNode = tEncoderMalloc(pCoder, sizeof(*pNode));
|
||||||
if (pNode == NULL) return -1;
|
if (pNode == NULL) return -1;
|
||||||
|
|
||||||
pNode->data = pCoder->data;
|
pNode->data = pCoder->data;
|
||||||
|
@ -73,22 +85,23 @@ int32_t tStartEncode(SCoder* pCoder) {
|
||||||
pCoder->pos = 0;
|
pCoder->pos = 0;
|
||||||
pCoder->size = pNode->size - pNode->pos - sizeof(int32_t);
|
pCoder->size = pNode->size - pNode->pos - sizeof(int32_t);
|
||||||
|
|
||||||
TD_SLIST_PUSH(&(pCoder->stack), pNode);
|
pNode->pNext = pCoder->eStack;
|
||||||
|
pCoder->eStack = pNode;
|
||||||
} else {
|
} else {
|
||||||
pCoder->pos += sizeof(int32_t);
|
pCoder->pos += sizeof(int32_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tEndEncode(SCoder* pCoder) {
|
void tEndEncode(SEncoder* pCoder) {
|
||||||
struct SCoderNode* pNode;
|
SEncoderNode* pNode;
|
||||||
int32_t len;
|
int32_t len;
|
||||||
|
|
||||||
ASSERT(pCoder->type == TD_ENCODER);
|
|
||||||
if (pCoder->data) {
|
if (pCoder->data) {
|
||||||
pNode = TD_SLIST_HEAD(&(pCoder->stack));
|
pNode = pCoder->eStack;
|
||||||
ASSERT(pNode);
|
ASSERT(pNode);
|
||||||
TD_SLIST_POP(&(pCoder->stack));
|
pCoder->eStack = pNode->pNext;
|
||||||
|
|
||||||
len = pCoder->pos;
|
len = pCoder->pos;
|
||||||
|
|
||||||
|
@ -99,19 +112,16 @@ void tEndEncode(SCoder* pCoder) {
|
||||||
tEncodeI32(pCoder, len);
|
tEncodeI32(pCoder, len);
|
||||||
|
|
||||||
TD_CODER_MOVE_POS(pCoder, len);
|
TD_CODER_MOVE_POS(pCoder, len);
|
||||||
|
|
||||||
taosMemoryFree(pNode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tStartDecode(SCoder* pCoder) {
|
int32_t tStartDecode(SDecoder* pCoder) {
|
||||||
|
SDecoderNode* pNode;
|
||||||
int32_t len;
|
int32_t len;
|
||||||
struct SCoderNode* pNode;
|
|
||||||
|
|
||||||
ASSERT(pCoder->type == TD_DECODER);
|
|
||||||
if (tDecodeI32(pCoder, &len) < 0) return -1;
|
if (tDecodeI32(pCoder, &len) < 0) return -1;
|
||||||
|
|
||||||
pNode = taosMemoryMalloc(sizeof(*pNode));
|
pNode = tDecoderMalloc(pCoder, sizeof(*pNode));
|
||||||
if (pNode == NULL) return -1;
|
if (pNode == NULL) return -1;
|
||||||
|
|
||||||
pNode->data = pCoder->data;
|
pNode->data = pCoder->data;
|
||||||
|
@ -122,23 +132,20 @@ int32_t tStartDecode(SCoder* pCoder) {
|
||||||
pCoder->size = len;
|
pCoder->size = len;
|
||||||
pCoder->pos = 0;
|
pCoder->pos = 0;
|
||||||
|
|
||||||
TD_SLIST_PUSH(&(pCoder->stack), pNode);
|
pNode->pNext = pCoder->dStack;
|
||||||
|
pCoder->dStack = pNode;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tEndDecode(SCoder* pCoder) {
|
void tEndDecode(SDecoder* pCoder) {
|
||||||
struct SCoderNode* pNode;
|
SDecoderNode* pNode;
|
||||||
|
|
||||||
ASSERT(pCoder->type == TD_DECODER);
|
pNode = pCoder->dStack;
|
||||||
|
|
||||||
pNode = TD_SLIST_HEAD(&(pCoder->stack));
|
|
||||||
ASSERT(pNode);
|
ASSERT(pNode);
|
||||||
TD_SLIST_POP(&(pCoder->stack));
|
pCoder->dStack = pNode->pNext;
|
||||||
|
|
||||||
pCoder->data = pNode->data;
|
pCoder->data = pNode->data;
|
||||||
pCoder->pos = pCoder->size + pNode->pos;
|
pCoder->pos = pCoder->size + pNode->pos;
|
||||||
pCoder->size = pNode->size;
|
pCoder->size = pNode->size;
|
||||||
|
|
||||||
taosMemoryFree(pNode);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,6 +326,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_ID, "Invalid table ID")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_TYPE, "Invalid table type")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_TYPE, "Invalid table type")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION, "Invalid table schema version")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION, "Invalid table schema version")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_ALREADY_EXIST, "Table already exists")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_ALREADY_EXIST, "Table already exists")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_NOT_EXIST, "Table not exists")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_STB_ALREADY_EXIST, "Stable already exists")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_STB_NOT_EXIST, "Stable not exists")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_CONFIG, "Invalid configuration")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_CONFIG, "Invalid configuration")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INIT_FAILED, "Tsdb init failed")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INIT_FAILED, "Tsdb init failed")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_DISKSPACE, "No diskspace for tsdb")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_DISKSPACE, "No diskspace for tsdb")
|
||||||
|
@ -445,6 +448,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QW_MSG_ERROR, "Invalid msg order")
|
||||||
|
|
||||||
// parser
|
// parser
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_TABLE_NOT_EXIST, "Table does not exist")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_TABLE_NOT_EXIST, "Table does not exist")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_PERMISSION_DENIED, "Permission denied")
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PLAN_INTERNAL_ERROR, "planner internal error")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PLAN_INTERNAL_ERROR, "planner internal error")
|
||||||
|
|
|
@ -41,9 +41,9 @@ target_sources(freelistTest
|
||||||
)
|
)
|
||||||
target_link_libraries(freelistTest os util gtest gtest_main)
|
target_link_libraries(freelistTest os util gtest gtest_main)
|
||||||
|
|
||||||
# encodeTest
|
# # encodeTest
|
||||||
add_executable(encodeTest "encodeTest.cpp")
|
# add_executable(encodeTest "encodeTest.cpp")
|
||||||
target_link_libraries(encodeTest os util gtest gtest_main)
|
# target_link_libraries(encodeTest os util gtest gtest_main)
|
||||||
|
|
||||||
# queueTest
|
# queueTest
|
||||||
add_executable(procTest "procTest.cpp")
|
add_executable(procTest "procTest.cpp")
|
||||||
|
|
|
@ -12,46 +12,47 @@
|
||||||
#define BUF_SIZE 64
|
#define BUF_SIZE 64
|
||||||
td_endian_t endian_arr[2] = {TD_LITTLE_ENDIAN, TD_BIG_ENDIAN};
|
td_endian_t endian_arr[2] = {TD_LITTLE_ENDIAN, TD_BIG_ENDIAN};
|
||||||
|
|
||||||
static int32_t encode(SCoder *pCoder, int8_t val) { return tEncodeI8(pCoder, val); }
|
static int32_t encode(SEncoder *pCoder, int8_t val) { return tEncodeI8(pCoder, val); }
|
||||||
static int32_t encode(SCoder *pCoder, uint8_t val) { return tEncodeU8(pCoder, val); }
|
static int32_t encode(SEncoder *pCoder, uint8_t val) { return tEncodeU8(pCoder, val); }
|
||||||
static int32_t encode(SCoder *pCoder, int16_t val) { return tEncodeI16(pCoder, val); }
|
static int32_t encode(SEncoder *pCoder, int16_t val) { return tEncodeI16(pCoder, val); }
|
||||||
static int32_t encode(SCoder *pCoder, uint16_t val) { return tEncodeU16(pCoder, val); }
|
static int32_t encode(SEncoder *pCoder, uint16_t val) { return tEncodeU16(pCoder, val); }
|
||||||
static int32_t encode(SCoder *pCoder, int32_t val) { return tEncodeI32(pCoder, val); }
|
static int32_t encode(SEncoder *pCoder, int32_t val) { return tEncodeI32(pCoder, val); }
|
||||||
static int32_t encode(SCoder *pCoder, uint32_t val) { return tEncodeU32(pCoder, val); }
|
static int32_t encode(SEncoder *pCoder, uint32_t val) { return tEncodeU32(pCoder, val); }
|
||||||
static int32_t encode(SCoder *pCoder, int64_t val) { return tEncodeI64(pCoder, val); }
|
static int32_t encode(SEncoder *pCoder, int64_t val) { return tEncodeI64(pCoder, val); }
|
||||||
static int32_t encode(SCoder *pCoder, uint64_t val) { return tEncodeU64(pCoder, val); }
|
static int32_t encode(SEncoder *pCoder, uint64_t val) { return tEncodeU64(pCoder, val); }
|
||||||
|
|
||||||
static int32_t decode(SCoder *pCoder, int8_t *val) { return tDecodeI8(pCoder, val); }
|
static int32_t decode(SDecoder *pCoder, int8_t *val) { return tDecodeI8(pCoder, val); }
|
||||||
static int32_t decode(SCoder *pCoder, uint8_t *val) { return tDecodeU8(pCoder, val); }
|
static int32_t decode(SDecoder *pCoder, uint8_t *val) { return tDecodeU8(pCoder, val); }
|
||||||
static int32_t decode(SCoder *pCoder, int16_t *val) { return tDecodeI16(pCoder, val); }
|
static int32_t decode(SDecoder *pCoder, int16_t *val) { return tDecodeI16(pCoder, val); }
|
||||||
static int32_t decode(SCoder *pCoder, uint16_t *val) { return tDecodeU16(pCoder, val); }
|
static int32_t decode(SDecoder *pCoder, uint16_t *val) { return tDecodeU16(pCoder, val); }
|
||||||
static int32_t decode(SCoder *pCoder, int32_t *val) { return tDecodeI32(pCoder, val); }
|
static int32_t decode(SDecoder *pCoder, int32_t *val) { return tDecodeI32(pCoder, val); }
|
||||||
static int32_t decode(SCoder *pCoder, uint32_t *val) { return tDecodeU32(pCoder, val); }
|
static int32_t decode(SDecoder *pCoder, uint32_t *val) { return tDecodeU32(pCoder, val); }
|
||||||
static int32_t decode(SCoder *pCoder, int64_t *val) { return tDecodeI64(pCoder, val); }
|
static int32_t decode(SDecoder *pCoder, int64_t *val) { return tDecodeI64(pCoder, val); }
|
||||||
static int32_t decode(SCoder *pCoder, uint64_t *val) { return tDecodeU64(pCoder, val); }
|
static int32_t decode(SDecoder *pCoder, uint64_t *val) { return tDecodeU64(pCoder, val); }
|
||||||
|
|
||||||
static int32_t encodev(SCoder *pCoder, int8_t val) { return tEncodeI8(pCoder, val); }
|
static int32_t encodev(SEncoder *pCoder, int8_t val) { return tEncodeI8(pCoder, val); }
|
||||||
static int32_t encodev(SCoder *pCoder, uint8_t val) { return tEncodeU8(pCoder, val); }
|
static int32_t encodev(SEncoder *pCoder, uint8_t val) { return tEncodeU8(pCoder, val); }
|
||||||
static int32_t encodev(SCoder *pCoder, int16_t val) { return tEncodeI16v(pCoder, val); }
|
static int32_t encodev(SEncoder *pCoder, int16_t val) { return tEncodeI16v(pCoder, val); }
|
||||||
static int32_t encodev(SCoder *pCoder, uint16_t val) { return tEncodeU16v(pCoder, val); }
|
static int32_t encodev(SEncoder *pCoder, uint16_t val) { return tEncodeU16v(pCoder, val); }
|
||||||
static int32_t encodev(SCoder *pCoder, int32_t val) { return tEncodeI32v(pCoder, val); }
|
static int32_t encodev(SEncoder *pCoder, int32_t val) { return tEncodeI32v(pCoder, val); }
|
||||||
static int32_t encodev(SCoder *pCoder, uint32_t val) { return tEncodeU32v(pCoder, val); }
|
static int32_t encodev(SEncoder *pCoder, uint32_t val) { return tEncodeU32v(pCoder, val); }
|
||||||
static int32_t encodev(SCoder *pCoder, int64_t val) { return tEncodeI64v(pCoder, val); }
|
static int32_t encodev(SEncoder *pCoder, int64_t val) { return tEncodeI64v(pCoder, val); }
|
||||||
static int32_t encodev(SCoder *pCoder, uint64_t val) { return tEncodeU64v(pCoder, val); }
|
static int32_t encodev(SEncoder *pCoder, uint64_t val) { return tEncodeU64v(pCoder, val); }
|
||||||
|
|
||||||
static int32_t decodev(SCoder *pCoder, int8_t *val) { return tDecodeI8(pCoder, val); }
|
static int32_t decodev(SDecoder *pCoder, int8_t *val) { return tDecodeI8(pCoder, val); }
|
||||||
static int32_t decodev(SCoder *pCoder, uint8_t *val) { return tDecodeU8(pCoder, val); }
|
static int32_t decodev(SDecoder *pCoder, uint8_t *val) { return tDecodeU8(pCoder, val); }
|
||||||
static int32_t decodev(SCoder *pCoder, int16_t *val) { return tDecodeI16v(pCoder, val); }
|
static int32_t decodev(SDecoder *pCoder, int16_t *val) { return tDecodeI16v(pCoder, val); }
|
||||||
static int32_t decodev(SCoder *pCoder, uint16_t *val) { return tDecodeU16v(pCoder, val); }
|
static int32_t decodev(SDecoder *pCoder, uint16_t *val) { return tDecodeU16v(pCoder, val); }
|
||||||
static int32_t decodev(SCoder *pCoder, int32_t *val) { return tDecodeI32v(pCoder, val); }
|
static int32_t decodev(SDecoder *pCoder, int32_t *val) { return tDecodeI32v(pCoder, val); }
|
||||||
static int32_t decodev(SCoder *pCoder, uint32_t *val) { return tDecodeU32v(pCoder, val); }
|
static int32_t decodev(SDecoder *pCoder, uint32_t *val) { return tDecodeU32v(pCoder, val); }
|
||||||
static int32_t decodev(SCoder *pCoder, int64_t *val) { return tDecodeI64v(pCoder, val); }
|
static int32_t decodev(SDecoder *pCoder, int64_t *val) { return tDecodeI64v(pCoder, val); }
|
||||||
static int32_t decodev(SCoder *pCoder, uint64_t *val) { return tDecodeU64v(pCoder, val); }
|
static int32_t decodev(SDecoder *pCoder, uint64_t *val) { return tDecodeU64v(pCoder, val); }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void simple_encode_decode_func(bool var_len) {
|
static void simple_encode_decode_func(bool var_len) {
|
||||||
uint8_t buf[BUF_SIZE];
|
uint8_t buf[BUF_SIZE];
|
||||||
SCoder coder;
|
SEncoder encoder = {0};
|
||||||
|
SDecoder decoder = {0};
|
||||||
T min_val, max_val;
|
T min_val, max_val;
|
||||||
T step = 1;
|
T step = 1;
|
||||||
|
|
||||||
|
@ -95,51 +96,51 @@ static void simple_encode_decode_func(bool var_len) {
|
||||||
|
|
||||||
// Encode NULL
|
// Encode NULL
|
||||||
for (td_endian_t endian : endian_arr) {
|
for (td_endian_t endian : endian_arr) {
|
||||||
tCoderInit(&coder, endian, NULL, 0, TD_ENCODER);
|
tEncoderInit(&encoder, endian, NULL, 0, TD_ENCODER);
|
||||||
|
|
||||||
if (var_len) {
|
if (var_len) {
|
||||||
GTEST_ASSERT_EQ(encodev(&coder, i), 0);
|
GTEST_ASSERT_EQ(encodev(&encoder, i), 0);
|
||||||
} else {
|
} else {
|
||||||
GTEST_ASSERT_EQ(encode(&coder, i), 0);
|
GTEST_ASSERT_EQ(encode(&encoder, i), 0);
|
||||||
GTEST_ASSERT_EQ(coder.pos, sizeof(T));
|
GTEST_ASSERT_EQ(encoder.pos, sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
tCoderClear(&coder);
|
tCoderClear(&encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode and decode
|
// Encode and decode
|
||||||
for (td_endian_t e_endian : endian_arr) {
|
for (td_endian_t e_endian : endian_arr) {
|
||||||
for (td_endian_t d_endian : endian_arr) {
|
for (td_endian_t d_endian : endian_arr) {
|
||||||
// Encode
|
// Encode
|
||||||
tCoderInit(&coder, e_endian, buf, BUF_SIZE, TD_ENCODER);
|
tCoderInit(&encoder, e_endian, buf, BUF_SIZE, TD_ENCODER);
|
||||||
|
|
||||||
if (var_len) {
|
if (var_len) {
|
||||||
GTEST_ASSERT_EQ(encodev(&coder, i), 0);
|
GTEST_ASSERT_EQ(encodev(&encoder, i), 0);
|
||||||
} else {
|
} else {
|
||||||
GTEST_ASSERT_EQ(encode(&coder, i), 0);
|
GTEST_ASSERT_EQ(encode(&encoder, i), 0);
|
||||||
GTEST_ASSERT_EQ(coder.pos, sizeof(T));
|
GTEST_ASSERT_EQ(encoder.pos, sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t epos = coder.pos;
|
int32_t epos = encoder.pos;
|
||||||
|
|
||||||
tCoderClear(&coder);
|
tCoderClear(&encoder);
|
||||||
// Decode
|
// Decode
|
||||||
tCoderInit(&coder, d_endian, buf, BUF_SIZE, TD_DECODER);
|
tCoderInit(&encoder, d_endian, buf, BUF_SIZE, TD_DECODER);
|
||||||
|
|
||||||
if (var_len) {
|
if (var_len) {
|
||||||
GTEST_ASSERT_EQ(decodev(&coder, &dval), 0);
|
GTEST_ASSERT_EQ(decodev(&encoder, &dval), 0);
|
||||||
} else {
|
} else {
|
||||||
GTEST_ASSERT_EQ(decode(&coder, &dval), 0);
|
GTEST_ASSERT_EQ(decode(&encoder, &dval), 0);
|
||||||
GTEST_ASSERT_EQ(coder.pos, sizeof(T));
|
GTEST_ASSERT_EQ(encoder.pos, sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
GTEST_ASSERT_EQ(coder.pos, epos);
|
GTEST_ASSERT_EQ(encoder.pos, epos);
|
||||||
|
|
||||||
if (typeid(T) == typeid(int8_t) || typeid(T) == typeid(uint8_t) || e_endian == d_endian) {
|
if (typeid(T) == typeid(int8_t) || typeid(T) == typeid(uint8_t) || e_endian == d_endian) {
|
||||||
GTEST_ASSERT_EQ(i, dval);
|
GTEST_ASSERT_EQ(i, dval);
|
||||||
}
|
}
|
||||||
|
|
||||||
tCoderClear(&coder);
|
tCoderClear(&encoder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -398,7 +398,7 @@ void bpAppendOperatorParam(BindData *data, int32_t *len, int32_t dataType, int32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateQuerySQL(BindData *data, int32_t tblIdx) {
|
void generateQueryCondSQL(BindData *data, int32_t tblIdx) {
|
||||||
int32_t len = sprintf(data->sql, "select * from %s%d where ", bpTbPrefix, tblIdx);
|
int32_t len = sprintf(data->sql, "select * from %s%d where ", bpTbPrefix, tblIdx);
|
||||||
if (!gCurCase->fullCol) {
|
if (!gCurCase->fullCol) {
|
||||||
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
||||||
|
@ -462,6 +462,72 @@ void generateQuerySQL(BindData *data, int32_t tblIdx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void generateQueryMiscSQL(BindData *data, int32_t tblIdx) {
|
||||||
|
int32_t len = sprintf(data->sql, "select * from %s%d where ", bpTbPrefix, tblIdx);
|
||||||
|
if (!gCurCase->fullCol) {
|
||||||
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
||||||
|
if (c) {
|
||||||
|
len += sprintf(data->sql + len, " and ");
|
||||||
|
}
|
||||||
|
switch (data->pBind[c].buffer_type) {
|
||||||
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
|
len += sprintf(data->sql + len, "booldata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
|
len += sprintf(data->sql + len, "tinydata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
|
len += sprintf(data->sql + len, "smalldata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_INT:
|
||||||
|
len += sprintf(data->sql + len, "intdata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
|
len += sprintf(data->sql + len, "bigdata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
|
len += sprintf(data->sql + len, "floatdata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
|
len += sprintf(data->sql + len, "doubledata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
|
len += sprintf(data->sql + len, "binarydata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
|
len += sprintf(data->sql + len, "ts");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
|
len += sprintf(data->sql + len, "nchardata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_UTINYINT:
|
||||||
|
len += sprintf(data->sql + len, "utinydata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_USMALLINT:
|
||||||
|
len += sprintf(data->sql + len, "usmalldata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_UINT:
|
||||||
|
len += sprintf(data->sql + len, "uintdata");
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
|
len += sprintf(data->sql + len, "ubigdata");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("!!!invalid col type:%d", data->pBind[c].buffer_type);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bpAppendOperatorParam(data, &len, data->pBind[c].buffer_type, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gCaseCtrl.printStmtSql) {
|
||||||
|
printf("\tSTMT SQL: %s\n", data->sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void generateErrorSQL(BindData *data, int32_t tblIdx) {
|
void generateErrorSQL(BindData *data, int32_t tblIdx) {
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
data->sql = taosMemoryCalloc(1, 1024);
|
data->sql = taosMemoryCalloc(1, 1024);
|
||||||
|
@ -677,7 +743,7 @@ int32_t prepareInsertData(BindData *data) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t prepareQueryData(BindData *data, int32_t tblIdx) {
|
int32_t prepareQueryCondData(BindData *data, int32_t tblIdx) {
|
||||||
static int64_t tsData = 1591060628000;
|
static int64_t tsData = 1591060628000;
|
||||||
uint64_t bindNum = gCurCase->rowNum / gCurCase->bindRowNum;
|
uint64_t bindNum = gCurCase->rowNum / gCurCase->bindRowNum;
|
||||||
|
|
||||||
|
@ -735,6 +801,63 @@ int32_t prepareQueryData(BindData *data, int32_t tblIdx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t prepareQueryMiscData(BindData *data, int32_t tblIdx) {
|
||||||
|
static int64_t tsData = 1591060628000;
|
||||||
|
uint64_t bindNum = gCurCase->rowNum / gCurCase->bindRowNum;
|
||||||
|
|
||||||
|
data->colNum = 0;
|
||||||
|
data->colTypes = taosMemoryCalloc(30, sizeof(int32_t));
|
||||||
|
data->sql = taosMemoryCalloc(1, 1024);
|
||||||
|
data->pBind = taosMemoryCalloc(bindNum*gCurCase->bindColNum, sizeof(TAOS_MULTI_BIND));
|
||||||
|
data->tsData = taosMemoryMalloc(bindNum * sizeof(int64_t));
|
||||||
|
data->boolData = taosMemoryMalloc(bindNum * sizeof(bool));
|
||||||
|
data->tinyData = taosMemoryMalloc(bindNum * sizeof(int8_t));
|
||||||
|
data->utinyData = taosMemoryMalloc(bindNum * sizeof(uint8_t));
|
||||||
|
data->smallData = taosMemoryMalloc(bindNum * sizeof(int16_t));
|
||||||
|
data->usmallData = taosMemoryMalloc(bindNum * sizeof(uint16_t));
|
||||||
|
data->intData = taosMemoryMalloc(bindNum * sizeof(int32_t));
|
||||||
|
data->uintData = taosMemoryMalloc(bindNum * sizeof(uint32_t));
|
||||||
|
data->bigData = taosMemoryMalloc(bindNum * sizeof(int64_t));
|
||||||
|
data->ubigData = taosMemoryMalloc(bindNum * sizeof(uint64_t));
|
||||||
|
data->floatData = taosMemoryMalloc(bindNum * sizeof(float));
|
||||||
|
data->doubleData = taosMemoryMalloc(bindNum * sizeof(double));
|
||||||
|
data->binaryData = taosMemoryMalloc(bindNum * gVarCharSize);
|
||||||
|
data->binaryLen = taosMemoryMalloc(bindNum * sizeof(int32_t));
|
||||||
|
if (gCurCase->bindNullNum) {
|
||||||
|
data->isNull = taosMemoryCalloc(bindNum, sizeof(char));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < bindNum; ++i) {
|
||||||
|
data->tsData[i] = tsData + tblIdx*gCurCase->rowNum + rand()%gCurCase->rowNum;
|
||||||
|
data->boolData[i] = (bool)(tblIdx*gCurCase->rowNum + rand() % gCurCase->rowNum);
|
||||||
|
data->tinyData[i] = (int8_t)(tblIdx*gCurCase->rowNum + rand() % gCurCase->rowNum);
|
||||||
|
data->utinyData[i] = (uint8_t)(tblIdx*gCurCase->rowNum + rand() % gCurCase->rowNum);
|
||||||
|
data->smallData[i] = (int16_t)(tblIdx*gCurCase->rowNum + rand() % gCurCase->rowNum);
|
||||||
|
data->usmallData[i] = (uint16_t)(tblIdx*gCurCase->rowNum + rand() % gCurCase->rowNum);
|
||||||
|
data->intData[i] = (int32_t)(tblIdx*gCurCase->rowNum + rand() % gCurCase->rowNum);
|
||||||
|
data->uintData[i] = (uint32_t)(tblIdx*gCurCase->rowNum + rand() % gCurCase->rowNum);
|
||||||
|
data->bigData[i] = (int64_t)(tblIdx*gCurCase->rowNum + rand() % gCurCase->rowNum);
|
||||||
|
data->ubigData[i] = (uint64_t)(tblIdx*gCurCase->rowNum + rand() % gCurCase->rowNum);
|
||||||
|
data->floatData[i] = (float)(tblIdx*gCurCase->rowNum + rand() % gCurCase->rowNum);
|
||||||
|
data->doubleData[i] = (double)(tblIdx*gCurCase->rowNum + rand() % gCurCase->rowNum);
|
||||||
|
memset(data->binaryData + gVarCharSize * i, 'a'+i%26, gVarCharLen);
|
||||||
|
if (gCurCase->bindNullNum) {
|
||||||
|
data->isNull[i] = i % 2;
|
||||||
|
}
|
||||||
|
data->binaryLen[i] = gVarCharLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int b = 0; b < bindNum; b++) {
|
||||||
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
||||||
|
prepareColData(data, b*gCurCase->bindColNum+c, b*gCurCase->bindRowNum, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
generateQueryMiscSQL(data, tblIdx);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void destroyData(BindData *data) {
|
void destroyData(BindData *data) {
|
||||||
|
@ -1385,7 +1508,7 @@ int querySUBTTest1(TAOS_STMT *stmt, TAOS *taos) {
|
||||||
|
|
||||||
for (int32_t t = 0; t< gCurCase->tblNum; ++t) {
|
for (int32_t t = 0; t< gCurCase->tblNum; ++t) {
|
||||||
memset(&data, 0, sizeof(data));
|
memset(&data, 0, sizeof(data));
|
||||||
prepareQueryData(&data, t);
|
prepareQueryCondData(&data, t);
|
||||||
|
|
||||||
int code = taos_stmt_prepare(stmt, data.sql, 0);
|
int code = taos_stmt_prepare(stmt, data.sql, 0);
|
||||||
if (code != 0){
|
if (code != 0){
|
||||||
|
@ -1431,7 +1554,7 @@ int querySUBTTest2(TAOS_STMT *stmt, TAOS *taos) {
|
||||||
|
|
||||||
for (int32_t t = 0; t< gCurCase->tblNum; ++t) {
|
for (int32_t t = 0; t< gCurCase->tblNum; ++t) {
|
||||||
memset(&data, 0, sizeof(data));
|
memset(&data, 0, sizeof(data));
|
||||||
prepareQueryData(&data, t);
|
prepareQueryMiscData(&data, t);
|
||||||
|
|
||||||
int code = taos_stmt_prepare(stmt, data.sql, 0);
|
int code = taos_stmt_prepare(stmt, data.sql, 0);
|
||||||
if (code != 0){
|
if (code != 0){
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
run general/stable/disk.sim
|
|
||||||
run general/stable/dnode3.sim
|
|
||||||
run general/stable/metrics.sim
|
|
||||||
run general/stable/values.sim
|
|
||||||
run general/stable/vnode3.sim
|
|
|
@ -4,11 +4,11 @@ system sh/exec.sh -n dnode1 -s start
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ============= step1
|
print ============= step1
|
||||||
sql create user read pass 'taosdata1'
|
sql create user u_read pass 'taosdata1'
|
||||||
sql create user write pass 'taosdata1'
|
sql create user u_write pass 'taosdata1'
|
||||||
|
|
||||||
sql alter user read pass 'taosdata'
|
sql alter user u_read pass 'taosdata'
|
||||||
sql alter user write pass 'taosdata'
|
sql alter user u_write pass 'taosdata'
|
||||||
|
|
||||||
sql show users
|
sql show users
|
||||||
if $rows != 3 then
|
if $rows != 3 then
|
||||||
|
@ -18,10 +18,10 @@ endi
|
||||||
print ============= step2
|
print ============= step2
|
||||||
sql close
|
sql close
|
||||||
sleep 2500
|
sleep 2500
|
||||||
print user read login
|
print user u_read login
|
||||||
sql connect read
|
sql connect u_read
|
||||||
sql alter user read pass 'taosdata'
|
sql alter user u_read pass 'taosdata'
|
||||||
sql alter user write pass 'taosdata1' -x step2
|
sql alter user u_write pass 'taosdata1' -x step2
|
||||||
return -1
|
return -1
|
||||||
step2:
|
step2:
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ endi
|
||||||
print ============= step3
|
print ============= step3
|
||||||
sql close
|
sql close
|
||||||
sleep 2500
|
sleep 2500
|
||||||
print user write login
|
print user u_write login
|
||||||
sql connect write
|
sql connect u_write
|
||||||
|
|
||||||
sql_error create user read2 pass 'taosdata1'
|
sql_error create user read2 pass 'taosdata1'
|
||||||
sql_error create user write2 pass 'taosdata1'
|
sql_error create user write2 pass 'taosdata1'
|
||||||
sql alter user write pass 'taosdata'
|
sql alter user u_write pass 'taosdata'
|
||||||
sql alter user read pass 'taosdata' -x step3
|
sql alter user u_read pass 'taosdata' -x step3
|
||||||
return -1
|
return -1
|
||||||
step3:
|
step3:
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,197 @@
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import socket
|
||||||
|
import pexpect
|
||||||
|
import os
|
||||||
|
import http.server
|
||||||
|
import gzip
|
||||||
|
import threading
|
||||||
|
import json
|
||||||
|
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
|
||||||
|
telemetryPort = '80'
|
||||||
|
|
||||||
|
#{
|
||||||
|
# "instanceId": "5cf4cd7a-acd4-43ba-8b0d-e84395b76a65",
|
||||||
|
# "reportVersion": 1,
|
||||||
|
# "os": "Ubuntu 20.04.3 LTS",
|
||||||
|
# "cpuModel": "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz",
|
||||||
|
# "numOfCpu": 6,
|
||||||
|
# "memory": "65860292 kB",
|
||||||
|
# "version": "3.0.0.0",
|
||||||
|
# "buildInfo": "Built at 2022-05-07 14:09:02",
|
||||||
|
# "gitInfo": "2139ccceb0946cde86b6b553b11e338f1ba437e5",
|
||||||
|
# "email": "user@taosdata.com",
|
||||||
|
# "numOfDnode": 1,
|
||||||
|
# "numOfMnode": 1,
|
||||||
|
# "numOfVgroup": 32,
|
||||||
|
# "numOfDatabase": 2,
|
||||||
|
# "numOfSuperTable": 0,
|
||||||
|
# "numOfChildTable": 100,
|
||||||
|
# "numOfColumn": 200,
|
||||||
|
# "numOfPoint": 300,
|
||||||
|
# "totalStorage": 400,
|
||||||
|
# "compStorage": 500
|
||||||
|
#}
|
||||||
|
|
||||||
|
def telemetryInfoCheck(infoDict=''):
|
||||||
|
if "instanceId" not in infoDict or len(infoDict["instanceId"]) == 0:
|
||||||
|
tdLog.exit("instanceId is null!")
|
||||||
|
|
||||||
|
if "reportVersion" not in infoDict or infoDict["reportVersion"] != 1:
|
||||||
|
tdLog.exit("reportVersion is null!")
|
||||||
|
|
||||||
|
if "os" not in infoDict:
|
||||||
|
tdLog.exit("os is null!")
|
||||||
|
|
||||||
|
if "cpuModel" not in infoDict:
|
||||||
|
tdLog.exit("cpuModel is null!")
|
||||||
|
|
||||||
|
if "numOfCpu" not in infoDict or infoDict["numOfCpu"] == 0:
|
||||||
|
tdLog.exit("numOfCpu is null!")
|
||||||
|
|
||||||
|
if "memory" not in infoDict:
|
||||||
|
tdLog.exit("memory is null!")
|
||||||
|
|
||||||
|
if "version" not in infoDict:
|
||||||
|
tdLog.exit("version is null!")
|
||||||
|
|
||||||
|
if "buildInfo" not in infoDict:
|
||||||
|
tdLog.exit("buildInfo is null!")
|
||||||
|
|
||||||
|
if "gitInfo" not in infoDict:
|
||||||
|
tdLog.exit("gitInfo is null!")
|
||||||
|
|
||||||
|
if "email" not in infoDict:
|
||||||
|
tdLog.exit("email is not exists!")
|
||||||
|
|
||||||
|
if "numOfDnode" not in infoDict or infoDict["numOfDnode"] < 1:
|
||||||
|
tdLog.exit("numOfDnode is null!")
|
||||||
|
|
||||||
|
if "numOfMnode" not in infoDict or infoDict["numOfMnode"] < 1:
|
||||||
|
tdLog.exit("numOfMnode is null!")
|
||||||
|
|
||||||
|
if "numOfVgroup" not in infoDict or infoDict["numOfVgroup"] <= 0:
|
||||||
|
tdLog.exit("numOfVgroup is null!")
|
||||||
|
|
||||||
|
if "numOfDatabase" not in infoDict or infoDict["numOfDatabase"] <= 0:
|
||||||
|
tdLog.exit("numOfDatabase is null!")
|
||||||
|
|
||||||
|
if "numOfSuperTable" not in infoDict or infoDict["numOfSuperTable"] < 0:
|
||||||
|
tdLog.exit("numOfSuperTable is null!")
|
||||||
|
|
||||||
|
if "numOfChildTable" not in infoDict or infoDict["numOfChildTable"] < 0:
|
||||||
|
tdLog.exit("numOfChildTable is null!")
|
||||||
|
|
||||||
|
if "numOfColumn" not in infoDict or infoDict["numOfColumn"] < 0:
|
||||||
|
tdLog.exit("numOfColumn is null!")
|
||||||
|
|
||||||
|
if "numOfPoint" not in infoDict or infoDict["numOfPoint"] < 0:
|
||||||
|
tdLog.exit("numOfPoint is null!")
|
||||||
|
|
||||||
|
if "totalStorage" not in infoDict or infoDict["totalStorage"] < 0:
|
||||||
|
tdLog.exit("totalStorage is null!")
|
||||||
|
|
||||||
|
if "compStorage" not in infoDict or infoDict["compStorage"] < 0:
|
||||||
|
tdLog.exit("compStorage is null!")
|
||||||
|
|
||||||
|
|
||||||
|
class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
|
||||||
|
def do_GET(self):
|
||||||
|
"""
|
||||||
|
process GET request
|
||||||
|
"""
|
||||||
|
|
||||||
|
def do_POST(self):
|
||||||
|
"""
|
||||||
|
process POST request
|
||||||
|
"""
|
||||||
|
contentEncoding = self.headers["Content-Encoding"]
|
||||||
|
|
||||||
|
if contentEncoding == 'gzip':
|
||||||
|
req_body = self.rfile.read(int(self.headers["Content-Length"]))
|
||||||
|
plainText = gzip.decompress(req_body).decode()
|
||||||
|
else:
|
||||||
|
plainText = self.rfile.read(int(self.headers["Content-Length"])).decode()
|
||||||
|
|
||||||
|
print("monitor info:\n%s"%plainText)
|
||||||
|
|
||||||
|
# 1. send response code and header
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
# 2. send response content
|
||||||
|
#self.wfile.write(("Hello World: " + req_body + "\n").encode("utf-8"))
|
||||||
|
|
||||||
|
# 3. check request body info
|
||||||
|
infoDict = json.loads(plainText)
|
||||||
|
#print("================")
|
||||||
|
#print(infoDict)
|
||||||
|
telemetryInfoCheck(infoDict)
|
||||||
|
|
||||||
|
# 4. shutdown the server and exit case
|
||||||
|
assassin = threading.Thread(target=httpServer.shutdown)
|
||||||
|
assassin.daemon = True
|
||||||
|
assassin.start()
|
||||||
|
print ("==== shutdown http server ====")
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
hostname = socket.gethostname()
|
||||||
|
serverPort = '7080'
|
||||||
|
rpcDebugFlagVal = '143'
|
||||||
|
clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
|
||||||
|
clientCfgDict["serverPort"] = serverPort
|
||||||
|
clientCfgDict["firstEp"] = hostname + ':' + serverPort
|
||||||
|
clientCfgDict["secondEp"] = hostname + ':' + serverPort
|
||||||
|
clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal
|
||||||
|
clientCfgDict["fqdn"] = hostname
|
||||||
|
|
||||||
|
updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
|
||||||
|
updatecfgDict["clientCfg"] = clientCfgDict
|
||||||
|
updatecfgDict["serverPort"] = serverPort
|
||||||
|
updatecfgDict["firstEp"] = hostname + ':' + serverPort
|
||||||
|
updatecfgDict["secondEp"] = hostname + ':' + serverPort
|
||||||
|
updatecfgDict["fqdn"] = hostname
|
||||||
|
|
||||||
|
updatecfgDict["telemetryReporting"] = '1'
|
||||||
|
updatecfgDict["telemetryServer"] = hostname
|
||||||
|
updatecfgDict["telemetryPort"] = telemetryPort
|
||||||
|
updatecfgDict["telemetryInterval"] = "3"
|
||||||
|
|
||||||
|
print ("===================: ", updatecfgDict)
|
||||||
|
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
|
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||||
|
tdSql.prepare()
|
||||||
|
# time.sleep(2)
|
||||||
|
vgroups = "30"
|
||||||
|
sql = "create database db3 vgroups " + vgroups
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
# loop to wait request
|
||||||
|
httpServer.serve_forever()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
# create http server: bing ip/port , and request processor
|
||||||
|
serverAddress = ("", int(telemetryPort))
|
||||||
|
httpServer = http.server.HTTPServer(serverAddress, RequestHandlerImpl)
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,12 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.error("select now()+1.5 from ntb")
|
tdSql.error("select now()+1.5 from ntb")
|
||||||
tdSql.error("select now()+1.5 from db.ntb")
|
tdSql.error("select now()+1.5 from db.ntb")
|
||||||
|
tdSql.error("select now()-1.5 from ntb")
|
||||||
|
tdSql.error("select now()-1.5 from db.ntb")
|
||||||
|
tdSql.error("select now()*1.5 from ntb")
|
||||||
|
tdSql.error("select now()*1.5 from db.ntb")
|
||||||
|
tdSql.error("select now()/1.5 from ntb")
|
||||||
|
tdSql.error("select now()/1.5 from db.ntb")
|
||||||
tdSql.error("select now()+'abc' from ntb")
|
tdSql.error("select now()+'abc' from ntb")
|
||||||
tdSql.error("select now()+'abc' from db.ntb")
|
tdSql.error("select now()+'abc' from db.ntb")
|
||||||
tdSql.error("select now()+abc from ntb")
|
tdSql.error("select now()+abc from ntb")
|
||||||
|
@ -262,7 +268,10 @@ class TDTestCase:
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.query("select now() +1 from db.stb")
|
tdSql.query("select now() +1 from db.stb")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
|
tdSql.error("select now() +1.5 from stb")
|
||||||
|
tdSql.error("select now() -1.5 from stb")
|
||||||
|
tdSql.error("select now() *1.5 from stb")
|
||||||
|
tdSql.error("select now() /1.5 from stb")
|
||||||
tdSql.error("select now() +'abc' from stb")
|
tdSql.error("select now() +'abc' from stb")
|
||||||
tdSql.error("select now() +'abc' from db.stb")
|
tdSql.error("select now() +'abc' from db.stb")
|
||||||
tdSql.error("select now() + ! from stb")
|
tdSql.error("select now() + ! from stb")
|
||||||
|
@ -272,6 +281,7 @@ class TDTestCase:
|
||||||
tdSql.error("select now() -today() from stb")
|
tdSql.error("select now() -today() from stb")
|
||||||
tdSql.error("select now() - today() from db.stb")
|
tdSql.error("select now() - today() from db.stb")
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select now()+null from stb")
|
tdSql.query("select now()+null from stb")
|
||||||
tdSql.checkData(0,0,None)
|
tdSql.checkData(0,0,None)
|
||||||
tdSql.query("select now()+null from db.stb")
|
tdSql.query("select now()+null from db.stb")
|
||||||
|
|
|
@ -0,0 +1,205 @@
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
|
def run(self): # sourcery skip: extract-duplicate-method
|
||||||
|
tdSql.prepare()
|
||||||
|
tdLog.printNoPrefix("==========step1:create tables==========")
|
||||||
|
tdSql.execute(
|
||||||
|
'''create table if not exists ntb
|
||||||
|
(ts timestamp, c1 int, c2 float,c3 double,c4 timestamp)
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
tdSql.execute(
|
||||||
|
'''create table if not exists stb
|
||||||
|
(ts timestamp, c1 int, c2 float,c3 double,c4 timestamp) tags(t0 int)
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
tdSql.execute(
|
||||||
|
'''create table if not exists stb_1 using stb tags(100)
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
tdLog.printNoPrefix("==========step2:insert data into ntb==========")
|
||||||
|
|
||||||
|
# RFC3339:2020-01-01T00:00:00+8:00
|
||||||
|
# ISO8601:2020-01-01T00:00:00.000+0800
|
||||||
|
tdSql.execute(
|
||||||
|
'insert into ntb values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())')
|
||||||
|
tdSql.execute(
|
||||||
|
'insert into stb_1 values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())')
|
||||||
|
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00') from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.query("select timediff(1,0,1d) from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff(1,0,1d) from db.ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff(1,0,1s) from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,1)
|
||||||
|
tdSql.query("select timediff(1,0,1s) from db.ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,1)
|
||||||
|
tdSql.query("select timediff(1,0,1w) from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff(1,0,1w) from db.ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff(1,0,1h) from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff(1,0,1h) from db.ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff(1,0,1m) from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff(1,0,1m) from db.ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff(1,0,1a) from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,1000)
|
||||||
|
tdSql.query("select timediff(1,0,1a) from db.ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,1000)
|
||||||
|
tdSql.query("select timediff(1,0,1u) from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,1000000)
|
||||||
|
tdSql.query("select timediff(1,0,1u) from db.ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,1000000)
|
||||||
|
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00') from stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00') from db.stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1d) from stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,1)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1d) from db.stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,1)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1h) from stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,24)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1h) from db.stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,24)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1w) from stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1m) from stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,1440)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1m) from db.stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,1440)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1s) from stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,86400)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1s) from db.stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,86400)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1a) from stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,86400000)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1a) from db.stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,86400000)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1u) from stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,86400000000)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1u) from db.stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,86400000000)
|
||||||
|
|
||||||
|
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00') from stb_1")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00') from db.stb_1")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1w) from stb_1 ")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1w) from db.stb_1 ")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1d) from stb_1 ")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1d) from db.stb_1 ")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1h) from stb_1 ")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,12)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1h) from db.stb_1 ")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,12)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1m) from stb_1" )
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,720)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1m) from db.stb_1" )
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,720)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1s) from stb_1")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,43200)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1s) from db.stb_1")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,43200)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1a) from stb_1")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,43200000)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1a) from db.stb_1")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,43200000)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1u) from stb_1")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,43200000000)
|
||||||
|
tdSql.query("select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1u) from db.stb_1")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,43200000000)
|
||||||
|
|
||||||
|
tdSql.query("select timediff('a','b') from stb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,None)
|
||||||
|
tdSql.checkData(1,0,None)
|
||||||
|
tdSql.checkData(2,0,None)
|
||||||
|
tdSql.error("select timediff(1.5,1.5) from stb")
|
||||||
|
tdSql.error("select timediff(1) from stb")
|
||||||
|
tdSql.error("select timediff(10,1,1.5) from stb")
|
||||||
|
# tdSql.error("select timediff(10,1,2s) from stb")
|
||||||
|
# tdSql.error("select timedifff(10,1,c1) from stb")
|
||||||
|
tdSql.error("select timediff(1.5,1.5) from stb_1")
|
||||||
|
tdSql.error("select timediff(1) from stb_1")
|
||||||
|
tdSql.error("select timediff(10,1,1.5) from stb_1")
|
||||||
|
# tdSql.error("select timediff(10,1,2s) from stb_1")
|
||||||
|
# tdSql.error("select timedifff(10,1,c1) from stb_1")
|
||||||
|
tdSql.error("select timediff(1.5,1.5) from ntb")
|
||||||
|
tdSql.error("select timediff(1) from ntb")
|
||||||
|
tdSql.error("select timediff(10,1,1.5) from ntb")
|
||||||
|
# tdSql.error("select timediff(10,1,2s) from ntb")
|
||||||
|
# tdSql.error("select timedifff(10,1,c1) from ntb")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -92,6 +92,21 @@ class TDTestCase:
|
||||||
tdSql.query("select to_iso8601(today()) /null from db.ntb")
|
tdSql.query("select to_iso8601(today()) /null from db.ntb")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.checkData(0,0,None)
|
tdSql.checkData(0,0,None)
|
||||||
|
# tdSql.query("select to_iso8601(-1) from ntb")
|
||||||
|
tdSql.query("select to_iso8601(9223372036854775807) from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
|
||||||
|
# tdSql.query("select to_iso8601(10000000000) from ntb")
|
||||||
|
# tdSql.checkData(0,0,None)
|
||||||
|
# tdSql.query("select to_iso8601(-1) from ntb")
|
||||||
|
# tdSql.checkRows(3)
|
||||||
|
# tdSql.query("select to_iso8601(-10000000000) from ntb")
|
||||||
|
# tdSql.checkData(0,0,None)
|
||||||
|
tdSql.error("select to_iso8601(1.5) from ntb")
|
||||||
|
tdSql.error("select to_iso8601(1.5) from db.ntb")
|
||||||
|
tdSql.error("select to_iso8601('a') from ntb")
|
||||||
|
tdSql.error("select to_iso8601(c2) from ntb")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,6 +152,8 @@ class TDTestCase:
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.checkData(0,0,None)
|
tdSql.checkData(0,0,None)
|
||||||
|
|
||||||
|
# tdSql.query("select to_iso8601(-1) from ntb")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
|
@ -0,0 +1,73 @@
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
|
def run(self): # sourcery skip: extract-duplicate-method
|
||||||
|
tdSql.prepare()
|
||||||
|
tdLog.printNoPrefix("==========step1:create tables==========")
|
||||||
|
tdSql.execute(
|
||||||
|
'''create table if not exists ntb
|
||||||
|
(ts timestamp, c1 int, c2 float,c3 double,c4 timestamp)
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
tdSql.execute(
|
||||||
|
'''create table if not exists stb
|
||||||
|
(ts timestamp, c1 int, c2 float,c3 double,c4 timestamp) tags(t0 int)
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
tdSql.execute(
|
||||||
|
'''create table if not exists stb_1 using stb tags(100)
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
tdLog.printNoPrefix("==========step2:insert data into ntb==========")
|
||||||
|
|
||||||
|
# RFC3339:2020-01-01T00:00:00+8:00
|
||||||
|
# ISO8601:2020-01-01T00:00:00.000+0800
|
||||||
|
tdSql.execute(
|
||||||
|
'insert into ntb values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())')
|
||||||
|
tdSql.execute(
|
||||||
|
'insert into stb_1 values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())')
|
||||||
|
tdSql.query("select to_unixtimestamp('1970-01-01T08:00:00+0800') from ntb")
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.checkData(1,0,0)
|
||||||
|
tdSql.checkData(2,0,0)
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.query("select to_unixtimestamp('1970-01-01T08:00:00+08:00') from ntb")
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.query("select to_unixtimestamp('1900-01-01T08:00:00+08:00') from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.query("select to_unixtimestamp('2020-01-32T08:00:00') from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,None)
|
||||||
|
tdSql.query("select to_unixtimestamp('2020-13-32T08:00:00') from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,None)
|
||||||
|
tdSql.query("select to_unixtimestamp('acd') from ntb")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0,0,None)
|
||||||
|
tdSql.error("select to_unixtimestamp(1) from ntb")
|
||||||
|
tdSql.error("select to_unixtimestamp(1.5) from ntb")
|
||||||
|
tdSql.error("select to_unixtimestamp(ts) from ntb")
|
||||||
|
|
||||||
|
tdSql.query("select ts from ntb where to_unixtimestamp('1970-01-01T08:00:00+08:00')=0")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue