Merge branch '3.0' into feat/TD-28945-3.0
This commit is contained in:
commit
f123d5e245
|
@ -454,7 +454,7 @@ pipeline {
|
|||
cd ${WKC}/tests/parallel_test
|
||||
export DEFAULT_RETRY_TIME=2
|
||||
date
|
||||
''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 600 ''' + extra_param + '''
|
||||
''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 900 ''' + extra_param + '''
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
# xz
|
||||
|
||||
if (${TD_LINUX})
|
||||
ExternalProject_Add(lzma2
|
||||
GIT_REPOSITORY https://github.com/conor42/fast-lzma2.git
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/lzma2"
|
||||
#BINARY_DIR ""
|
||||
BUILD_IN_SOURCE TRUE
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
endif()
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
# xz
|
||||
|
||||
if (${TD_LINUX})
|
||||
ExternalProject_Add(xz
|
||||
GIT_REPOSITORY https://github.com/xz-mirror/xz.git
|
||||
GIT_TAG v5.4.4
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/xz"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
CMAKE_ARGS
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
endif()
|
|
@ -1,5 +1,8 @@
|
|||
|
||||
# zlib
|
||||
|
||||
|
||||
if (${TD_LINUX})
|
||||
ExternalProject_Add(zlib
|
||||
GIT_REPOSITORY https://github.com/taosdata-contrib/zlib.git
|
||||
GIT_TAG v1.2.11
|
||||
|
@ -10,4 +13,5 @@ ExternalProject_Add(zlib
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
# zstb
|
||||
|
||||
#ExternalProject_Add(zstd
|
||||
#GIT_REPOSITORY https://github.com/facebook/zstd.git
|
||||
#GIT_TAG v1.5.5
|
||||
#SOURCE_DIR "${TD_CONTRIB_DIR}/zstd"
|
||||
#DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
||||
#BINARY_DIR ""
|
||||
#CMAKE_COMMAND
|
||||
#CMAKE_ARGS ${TD_CONTRIB_DIR}/zstd/build/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/build/lib
|
||||
#BUILD_COMMAND make -j4
|
||||
#INSTALL_COMMAND ""
|
||||
#TEST_COMMAND ""
|
||||
#)
|
|
@ -109,6 +109,13 @@ cat("${TD_SUPPORT_DIR}/zlib_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
|||
# cJson
|
||||
cat("${TD_SUPPORT_DIR}/cjson_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
|
||||
# xz
|
||||
#cat("${TD_SUPPORT_DIR}/xz_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
|
||||
#lzma2
|
||||
cat("${TD_SUPPORT_DIR}/lzma_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
|
||||
|
||||
if (${BUILD_CONTRIB})
|
||||
if(${BUILD_WITH_ROCKSDB})
|
||||
cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
|
@ -127,6 +134,8 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
#cat("${TD_SUPPORT_DIR}/zstd_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
|
||||
#libuv
|
||||
if(${BUILD_WITH_UV})
|
||||
cat("${TD_SUPPORT_DIR}/libuv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
|
@ -254,6 +263,13 @@ target_include_directories(
|
|||
)
|
||||
unset(CMAKE_PROJECT_INCLUDE_BEFORE)
|
||||
|
||||
# add_subdirectory(xz EXCLUDE_FROM_ALL)
|
||||
# target_include_directories(
|
||||
# xz
|
||||
# PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/xz
|
||||
# PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/xz
|
||||
# )
|
||||
|
||||
# leveldb
|
||||
if(${BUILD_WITH_LEVELDB})
|
||||
option(LEVELDB_BUILD_TESTS "" OFF)
|
||||
|
@ -388,7 +404,6 @@ endif()
|
|||
if(${BUILD_WITH_S3})
|
||||
INCLUDE_DIRECTORIES($ENV{HOME}/.cos-local.2/include)
|
||||
MESSAGE("build with s3: ${BUILD_WITH_S3}")
|
||||
|
||||
# cos
|
||||
elseif(${BUILD_WITH_COS})
|
||||
if(${TD_LINUX})
|
||||
|
@ -427,6 +442,7 @@ if(${BUILD_PTHREAD})
|
|||
target_link_libraries(pthread INTERFACE libpthreadVC3)
|
||||
endif()
|
||||
|
||||
|
||||
# jemalloc
|
||||
if(${JEMALLOC_ENABLED})
|
||||
include(ExternalProject)
|
||||
|
|
|
@ -56,6 +56,8 @@ extern "C" {
|
|||
#define TSDB_INS_TABLE_GRANTS_FULL "ins_grants_full"
|
||||
#define TSDB_INS_TABLE_GRANTS_LOGS "ins_grants_logs"
|
||||
#define TSDB_INS_TABLE_MACHINES "ins_machines"
|
||||
#define TSDB_INS_TABLE_ENCRYPTIONS "ins_encryptions"
|
||||
#define TSDB_INS_TABLE_TSMAS "ins_tsmas"
|
||||
|
||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* 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 "taosdef.h"
|
||||
#ifndef _TD_TCOL_H_
|
||||
#define _TD_TCOL_H_
|
||||
|
||||
#define TSDB_COLUMN_ENCODE_UNKNOWN "unknown"
|
||||
#define TSDB_COLUMN_ENCODE_SIMPLE8B "simple8b"
|
||||
#define TSDB_COLUMN_ENCODE_XOR "delta-i"
|
||||
#define TSDB_COLUMN_ENCODE_RLE "bit-packing"
|
||||
#define TSDB_COLUMN_ENCODE_DELTAD "delta-d"
|
||||
#define TSDB_COLUMN_ENCODE_DISABLED "disabled"
|
||||
|
||||
#define TSDB_COLUMN_COMPRESS_UNKNOWN "unknown"
|
||||
#define TSDB_COLUMN_COMPRESS_LZ4 "lz4"
|
||||
#define TSDB_COLUMN_COMPRESS_ZLIB "zlib"
|
||||
#define TSDB_COLUMN_COMPRESS_ZSTD "zstd"
|
||||
#define TSDB_COLUMN_COMPRESS_TSZ "tsz"
|
||||
#define TSDB_COLUMN_COMPRESS_XZ "xz"
|
||||
#define TSDB_COLUMN_COMPRESS_DISABLED "disabled"
|
||||
|
||||
#define TSDB_COLUMN_LEVEL_UNKNOWN "unknown"
|
||||
#define TSDB_COLUMN_LEVEL_HIGH "high"
|
||||
#define TSDB_COLUMN_LEVEL_MEDIUM "medium"
|
||||
#define TSDB_COLUMN_LEVEL_LOW "low"
|
||||
|
||||
#define TSDB_COLVAL_ENCODE_NOCHANGE 0
|
||||
#define TSDB_COLVAL_ENCODE_SIMPLE8B 1
|
||||
#define TSDB_COLVAL_ENCODE_XOR 2
|
||||
#define TSDB_COLVAL_ENCODE_RLE 3
|
||||
#define TSDB_COLVAL_ENCODE_DELTAD 4
|
||||
#define TSDB_COLVAL_ENCODE_DISABLED 0xff
|
||||
|
||||
#define TSDB_COLVAL_COMPRESS_NOCHANGE 0
|
||||
#define TSDB_COLVAL_COMPRESS_LZ4 1
|
||||
#define TSDB_COLVAL_COMPRESS_ZLIB 2
|
||||
#define TSDB_COLVAL_COMPRESS_ZSTD 3
|
||||
#define TSDB_COLVAL_COMPRESS_TSZ 4
|
||||
#define TSDB_COLVAL_COMPRESS_XZ 5
|
||||
#define TSDB_COLVAL_COMPRESS_DISABLED 0xff
|
||||
|
||||
#define TSDB_COLVAL_LEVEL_NOCHANGE 0
|
||||
#define TSDB_COLVAL_LEVEL_LOW 1
|
||||
#define TSDB_COLVAL_LEVEL_MEDIUM 2
|
||||
#define TSDB_COLVAL_LEVEL_HIGH 3
|
||||
#define TSDB_COLVAL_LEVEL_DISABLED 0xff
|
||||
|
||||
#define TSDB_CL_COMMENT_LEN 1025
|
||||
#define TSDB_CL_COMPRESS_OPTION_LEN 12
|
||||
|
||||
extern const char* supportedEncode[5];
|
||||
extern const char* supportedCompress[6];
|
||||
extern const char* supportedLevel[3];
|
||||
|
||||
uint8_t getDefaultEncode(uint8_t type);
|
||||
uint16_t getDefaultCompress(uint8_t type);
|
||||
uint8_t getDefaultLevel(uint8_t type);
|
||||
const char* getDefaultEncodeStr(uint8_t type);
|
||||
const char* getDefaultCompressStr(uint8_t type);
|
||||
const char* getDefaultLevelStr(uint8_t type);
|
||||
|
||||
const char* columnEncodeStr(uint8_t type);
|
||||
const char* columnCompressStr(uint16_t type);
|
||||
const char* columnLevelStr(uint8_t type);
|
||||
uint8_t columnLevelVal(const char* level);
|
||||
uint8_t columnEncodeVal(const char* encode);
|
||||
uint16_t columnCompressVal(const char* compress);
|
||||
|
||||
bool useCompress(uint8_t tableType);
|
||||
bool checkColumnEncode(char encode[TSDB_CL_COMPRESS_OPTION_LEN]);
|
||||
bool checkColumnEncodeOrSetDefault(uint8_t type, char encode[TSDB_CL_COMPRESS_OPTION_LEN]);
|
||||
bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]);
|
||||
bool checkColumnCompressOrSetDefault(uint8_t type, char compress[TSDB_CL_COMPRESS_OPTION_LEN]);
|
||||
bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]);
|
||||
bool checkColumnLevelOrSetDefault(uint8_t type, char level[TSDB_CL_COMPRESS_OPTION_LEN]);
|
||||
|
||||
void setColEncode(uint32_t* compress, uint8_t encode);
|
||||
void setColCompress(uint32_t* compress, uint16_t compressType);
|
||||
void setColLevel(uint32_t* compress, uint8_t level);
|
||||
int8_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check,
|
||||
uint32_t* compress);
|
||||
|
||||
int8_t validColCompressLevel(uint8_t type, uint8_t level);
|
||||
int8_t validColCompress(uint8_t type, uint8_t l2);
|
||||
int8_t validColEncode(uint8_t type, uint8_t l1);
|
||||
|
||||
uint32_t createDefaultColCmprByType(uint8_t type);
|
||||
bool validColCmprByType(uint8_t type, uint32_t cmpr);
|
||||
#endif /*_TD_TCOL_H_*/
|
|
@ -15,8 +15,7 @@
|
|||
|
||||
#ifndef _TD_COMMON_DEF_H_
|
||||
#define _TD_COMMON_DEF_H_
|
||||
|
||||
#include "taosdef.h"
|
||||
// #include "taosdef.h"
|
||||
#include "tarray.h"
|
||||
#include "tmsg.h"
|
||||
#include "tvariant.h"
|
||||
|
@ -258,9 +257,9 @@ typedef struct SColumnInfoData {
|
|||
char* nullbitmap; // bitmap, one bit for each item in the list
|
||||
SVarColAttr varmeta;
|
||||
};
|
||||
SColumnInfo info; // column info
|
||||
bool hasNull; // if current column data has null value.
|
||||
bool reassigned; // if current column data is reassigned.
|
||||
SColumnInfo info; // column info
|
||||
bool hasNull; // if current column data has null value.
|
||||
bool reassigned; // if current column data is reassigned.
|
||||
} SColumnInfoData;
|
||||
|
||||
typedef struct SQueryTableDataCond {
|
||||
|
@ -274,13 +273,13 @@ typedef struct SQueryTableDataCond {
|
|||
STimeWindow twindows;
|
||||
int64_t startVersion;
|
||||
int64_t endVersion;
|
||||
bool notLoadData; // response the actual data, not only the rows in the attribute of info.row of ssdatablock
|
||||
bool notLoadData; // response the actual data, not only the rows in the attribute of info.row of ssdatablock
|
||||
} SQueryTableDataCond;
|
||||
|
||||
int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock);
|
||||
void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock);
|
||||
|
||||
void colDataDestroy(SColumnInfoData* pColData);
|
||||
void colDataDestroy(SColumnInfoData* pColData);
|
||||
|
||||
//======================================================================================================================
|
||||
// the following structure shared by parser and executor
|
||||
|
@ -366,8 +365,8 @@ typedef struct {
|
|||
float f;
|
||||
};
|
||||
size_t length;
|
||||
bool keyEscaped;
|
||||
bool valueEscaped;
|
||||
bool keyEscaped;
|
||||
bool valueEscaped;
|
||||
} SSmlKv;
|
||||
|
||||
#define QUERY_ASC_FORWARD_STEP 1
|
||||
|
@ -389,7 +388,6 @@ typedef struct SNonSortExecInfo {
|
|||
int32_t blkNums;
|
||||
} SNonSortExecInfo;
|
||||
|
||||
|
||||
typedef struct STUidTagInfo {
|
||||
char* name;
|
||||
uint64_t uid;
|
||||
|
@ -412,7 +410,19 @@ typedef struct STUidTagInfo {
|
|||
#define UD_GROUPID_COLUMN_INDEX 1
|
||||
#define UD_TAG_COLUMN_INDEX 2
|
||||
|
||||
int32_t taosGenCrashJsonMsg(int signum, char **pMsg, int64_t clusterId, int64_t startTime);
|
||||
int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t startTime);
|
||||
|
||||
#define TSMA_RES_STB_POSTFIX "_tsma_res_stb_"
|
||||
#define MD5_OUTPUT_LEN 32
|
||||
#define TSMA_RES_STB_EXTRA_COLUMN_NUM 4 // 3 columns: _wstart, _wend, _wduration, 1 tag: tbname
|
||||
|
||||
static inline bool isTsmaResSTb(const char* stbName) {
|
||||
const char* pos = strstr(stbName, TSMA_RES_STB_POSTFIX);
|
||||
if (pos && strlen(stbName) == (pos - stbName) + strlen(TSMA_RES_STB_POSTFIX)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -28,17 +28,18 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SSchema SSchema;
|
||||
typedef struct SSchema2 SSchema2;
|
||||
typedef struct STColumn STColumn;
|
||||
typedef struct STSchema STSchema;
|
||||
typedef struct SValue SValue;
|
||||
typedef struct SColVal SColVal;
|
||||
typedef struct SRow SRow;
|
||||
typedef struct SRowIter SRowIter;
|
||||
typedef struct STagVal STagVal;
|
||||
typedef struct STag STag;
|
||||
typedef struct SColData SColData;
|
||||
typedef struct SSchema SSchema;
|
||||
typedef struct SSchema2 SSchema2;
|
||||
typedef struct SSchemaExt SSchemaExt;
|
||||
typedef struct STColumn STColumn;
|
||||
typedef struct STSchema STSchema;
|
||||
typedef struct SValue SValue;
|
||||
typedef struct SColVal SColVal;
|
||||
typedef struct SRow SRow;
|
||||
typedef struct SRowIter SRowIter;
|
||||
typedef struct STagVal STagVal;
|
||||
typedef struct STag STag;
|
||||
typedef struct SColData SColData;
|
||||
|
||||
typedef struct SRowKey SRowKey;
|
||||
typedef struct SValueColumn SValueColumn;
|
||||
|
@ -56,9 +57,9 @@ const static uint8_t BIT2_MAP[4] = {0b11111100, 0b11110011, 0b11001111, 0b001111
|
|||
#define ONE ((uint8_t)1)
|
||||
#define THREE ((uint8_t)3)
|
||||
#define DIV_8(i) ((i) >> 3)
|
||||
#define MOD_8(i) ((i) & 7)
|
||||
#define MOD_8(i) ((i)&7)
|
||||
#define DIV_4(i) ((i) >> 2)
|
||||
#define MOD_4(i) ((i) & 3)
|
||||
#define MOD_4(i) ((i)&3)
|
||||
#define MOD_4_TIME_2(i) (MOD_4(i) << 1)
|
||||
#define BIT1_SIZE(n) (DIV_8((n)-1) + 1)
|
||||
#define BIT2_SIZE(n) (DIV_4((n)-1) + 1)
|
||||
|
@ -149,18 +150,18 @@ int32_t parseJsontoTagData(const char *json, SArray *pTagVals, STag **ppTag, voi
|
|||
|
||||
// SColData ================================
|
||||
typedef struct {
|
||||
int8_t cmprAlg; // filled by caller
|
||||
int8_t columnFlag;
|
||||
int8_t flag;
|
||||
int8_t dataType;
|
||||
int16_t columnId;
|
||||
int32_t numOfData;
|
||||
int32_t bitmapOriginalSize;
|
||||
int32_t bitmapCompressedSize;
|
||||
int32_t offsetOriginalSize;
|
||||
int32_t offsetCompressedSize;
|
||||
int32_t dataOriginalSize;
|
||||
int32_t dataCompressedSize;
|
||||
uint32_t cmprAlg; // filled by caller
|
||||
int8_t columnFlag;
|
||||
int8_t flag;
|
||||
int8_t dataType;
|
||||
int16_t columnId;
|
||||
int32_t numOfData;
|
||||
int32_t bitmapOriginalSize;
|
||||
int32_t bitmapCompressedSize;
|
||||
int32_t offsetOriginalSize;
|
||||
int32_t offsetCompressedSize;
|
||||
int32_t dataOriginalSize;
|
||||
int32_t dataCompressedSize;
|
||||
} SColDataCompressInfo;
|
||||
|
||||
typedef void *(*xMallocFn)(void *, int32_t);
|
||||
|
@ -339,10 +340,10 @@ struct SValueColumn {
|
|||
};
|
||||
|
||||
typedef struct {
|
||||
int8_t dataType; // filled by caller
|
||||
int8_t cmprAlg; // filled by caller
|
||||
int32_t originalSize; // filled by caller
|
||||
int32_t compressedSize;
|
||||
int32_t dataType; // filled by caller
|
||||
uint32_t cmprAlg; // filled by caller
|
||||
int32_t originalSize; // filled by caller
|
||||
int32_t compressedSize;
|
||||
} SCompressInfo;
|
||||
|
||||
int32_t tCompressData(void *input, // input
|
||||
|
|
|
@ -29,6 +29,17 @@ extern "C" {
|
|||
#define SLOW_LOG_TYPE_OTHERS 0x4
|
||||
#define SLOW_LOG_TYPE_ALL 0xFFFFFFFF
|
||||
|
||||
typedef enum {
|
||||
DND_CA_SM4 = 1,
|
||||
} EEncryptAlgor;
|
||||
|
||||
typedef enum {
|
||||
DND_CS_TSDB = 1,
|
||||
DND_CS_VNODE_WAL = 2,
|
||||
DND_CS_SDB = 4,
|
||||
DND_CS_MNODE_WAL = 8,
|
||||
} EEncryptScope;
|
||||
|
||||
// cluster
|
||||
extern char tsFirst[];
|
||||
extern char tsSecond[];
|
||||
|
@ -39,6 +50,12 @@ extern uint16_t tsServerPort;
|
|||
extern int32_t tsVersion;
|
||||
extern int32_t tsStatusInterval;
|
||||
extern int32_t tsNumOfSupportVnodes;
|
||||
extern char tsEncryptAlgorithm[];
|
||||
extern char tsEncryptScope[];
|
||||
extern EEncryptAlgor tsiEncryptAlgorithm;
|
||||
extern EEncryptScope tsiEncryptScope;
|
||||
//extern char tsAuthCode[];
|
||||
extern char tsEncryptKey[];
|
||||
|
||||
// common
|
||||
extern int32_t tsMaxShellConns;
|
||||
|
@ -94,8 +111,6 @@ extern char tsSnodeAddress[]; // 127.0.0.1:873
|
|||
// mnode
|
||||
extern int64_t tsMndSdbWriteDelta;
|
||||
extern int64_t tsMndLogRetention;
|
||||
extern int8_t tsGrant;
|
||||
extern int32_t tsMndGrantMode;
|
||||
extern bool tsMndSkipGrant;
|
||||
extern bool tsEnableWhiteList;
|
||||
|
||||
|
@ -104,6 +119,11 @@ extern int64_t tsDndStart;
|
|||
extern int64_t tsDndStartOsUptime;
|
||||
extern int64_t tsDndUpTime;
|
||||
|
||||
// dnode misc
|
||||
extern uint32_t tsEncryptionKeyChksum;
|
||||
extern int8_t tsEncryptionKeyStat;
|
||||
extern int8_t tsGrant;
|
||||
|
||||
// monitor
|
||||
extern bool tsEnableMonitor;
|
||||
extern int32_t tsMonitorInterval;
|
||||
|
@ -201,6 +221,8 @@ extern char tsSmlTsDefaultName[];
|
|||
|
||||
extern int32_t tmqMaxTopicNum;
|
||||
extern int32_t tmqRowSize;
|
||||
extern int32_t tsMaxTsmaNum;
|
||||
extern int32_t tsMaxTsmaCalcDelay;
|
||||
|
||||
// wal
|
||||
extern int64_t tsWalFsyncDataSizeLimit;
|
||||
|
|
|
@ -58,9 +58,11 @@ typedef enum {
|
|||
TSDB_GRANT_BACKUP_RESTORE,
|
||||
} EGrantType;
|
||||
|
||||
int32_t checkAndGetCryptKey(const char *encryptCode, const char *machineId, char **key);
|
||||
int32_t generateEncryptCode(const char *key, const char *machineId, char **encryptCode);
|
||||
int32_t grantCheck(EGrantType grant);
|
||||
int32_t grantCheckExpire(EGrantType grant);
|
||||
char* tGetMachineId();
|
||||
char *tGetMachineId();
|
||||
|
||||
// #ifndef GRANTS_CFG
|
||||
#ifdef TD_ENTERPRISE
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "taoserror.h"
|
||||
#include "tarray.h"
|
||||
#include "tcoding.h"
|
||||
#include "tcol.h"
|
||||
#include "tencode.h"
|
||||
#include "thash.h"
|
||||
#include "tlist.h"
|
||||
|
@ -110,6 +111,7 @@ enum {
|
|||
HEARTBEAT_KEY_TMQ,
|
||||
HEARTBEAT_KEY_DYN_VIEW,
|
||||
HEARTBEAT_KEY_VIEWINFO,
|
||||
HEARTBEAT_KEY_TSMA,
|
||||
};
|
||||
|
||||
typedef enum _mgmt_table {
|
||||
|
@ -145,27 +147,30 @@ typedef enum _mgmt_table {
|
|||
TSDB_MGMT_TABLE_STREAM_TASKS,
|
||||
TSDB_MGMT_TABLE_PRIVILEGES,
|
||||
TSDB_MGMT_TABLE_VIEWS,
|
||||
TSDB_MGMT_TABLE_TSMAS,
|
||||
TSDB_MGMT_TABLE_COMPACT,
|
||||
TSDB_MGMT_TABLE_COMPACT_DETAIL,
|
||||
TSDB_MGMT_TABLE_GRANTS_FULL,
|
||||
TSDB_MGMT_TABLE_GRANTS_LOGS,
|
||||
TSDB_MGMT_TABLE_MACHINES,
|
||||
TSDB_MGMT_TABLE_ARBGROUP,
|
||||
TSDB_MGMT_TABLE_ENCRYPTIONS,
|
||||
TSDB_MGMT_TABLE_MAX,
|
||||
} EShowType;
|
||||
|
||||
#define TSDB_ALTER_TABLE_ADD_TAG 1
|
||||
#define TSDB_ALTER_TABLE_DROP_TAG 2
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4
|
||||
#define TSDB_ALTER_TABLE_ADD_COLUMN 5
|
||||
#define TSDB_ALTER_TABLE_DROP_COLUMN 6
|
||||
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES 7
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_BYTES 8
|
||||
#define TSDB_ALTER_TABLE_UPDATE_OPTIONS 9
|
||||
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME 10
|
||||
#define TSDB_ALTER_TABLE_ADD_TAG_INDEX 11
|
||||
#define TSDB_ALTER_TABLE_DROP_TAG_INDEX 12
|
||||
#define TSDB_ALTER_TABLE_ADD_TAG 1
|
||||
#define TSDB_ALTER_TABLE_DROP_TAG 2
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4
|
||||
#define TSDB_ALTER_TABLE_ADD_COLUMN 5
|
||||
#define TSDB_ALTER_TABLE_DROP_COLUMN 6
|
||||
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES 7
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_BYTES 8
|
||||
#define TSDB_ALTER_TABLE_UPDATE_OPTIONS 9
|
||||
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME 10
|
||||
#define TSDB_ALTER_TABLE_ADD_TAG_INDEX 11
|
||||
#define TSDB_ALTER_TABLE_DROP_TAG_INDEX 12
|
||||
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS 13
|
||||
|
||||
#define TSDB_FILL_NONE 0
|
||||
#define TSDB_FILL_NULL 1
|
||||
|
@ -247,6 +252,8 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_VIEW,
|
||||
QUERY_NODE_WINDOW_OFFSET,
|
||||
QUERY_NODE_COUNT_WINDOW,
|
||||
QUERY_NODE_COLUMN_OPTIONS,
|
||||
QUERY_NODE_TSMA_OPTIONS,
|
||||
|
||||
// Statement nodes are used in parser and planner module.
|
||||
QUERY_NODE_SET_OPERATOR = 100,
|
||||
|
@ -368,6 +375,11 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_SHOW_GRANTS_FULL_STMT,
|
||||
QUERY_NODE_SHOW_GRANTS_LOGS_STMT,
|
||||
QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT,
|
||||
QUERY_NODE_SHOW_ENCRYPTIONS_STMT,
|
||||
QUERY_NODE_SHOW_TSMAS_STMT,
|
||||
QUERY_NODE_CREATE_TSMA_STMT,
|
||||
QUERY_NODE_SHOW_CREATE_TSMA_STMT,
|
||||
QUERY_NODE_DROP_TSMA_STMT,
|
||||
|
||||
// logic plan node
|
||||
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
|
||||
|
@ -440,9 +452,9 @@ typedef enum ENodeType {
|
|||
} ENodeType;
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
char* dbFName;
|
||||
char* tbName;
|
||||
int32_t vgId;
|
||||
const char* dbFName;
|
||||
const char* tbName;
|
||||
} SBuildTableInput;
|
||||
|
||||
typedef struct {
|
||||
|
@ -459,6 +471,13 @@ typedef struct SField {
|
|||
int8_t flags;
|
||||
int32_t bytes;
|
||||
} SField;
|
||||
typedef struct SFieldWithOptions {
|
||||
char name[TSDB_COL_NAME_LEN];
|
||||
uint8_t type;
|
||||
int8_t flags;
|
||||
int32_t bytes;
|
||||
uint32_t compress;
|
||||
} SFieldWithOptions;
|
||||
|
||||
typedef struct SRetention {
|
||||
int64_t freq;
|
||||
|
@ -537,6 +556,12 @@ struct SSchema {
|
|||
int32_t bytes;
|
||||
char name[TSDB_COL_NAME_LEN];
|
||||
};
|
||||
struct SSchemaExt {
|
||||
col_id_t colId;
|
||||
uint32_t compress;
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
struct SSchema2 {
|
||||
int8_t type;
|
||||
|
@ -544,25 +569,26 @@ struct SSchema2 {
|
|||
col_id_t colId;
|
||||
int32_t bytes;
|
||||
char name[TSDB_COL_NAME_LEN];
|
||||
char alias[TSDB_COL_NAME_LEN];
|
||||
uint32_t compress;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char tbName[TSDB_TABLE_NAME_LEN];
|
||||
char stbName[TSDB_TABLE_NAME_LEN];
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
int64_t dbId;
|
||||
int32_t numOfTags;
|
||||
int32_t numOfColumns;
|
||||
int8_t precision;
|
||||
int8_t tableType;
|
||||
int32_t sversion;
|
||||
int32_t tversion;
|
||||
uint64_t suid;
|
||||
uint64_t tuid;
|
||||
int32_t vgId;
|
||||
int8_t sysInfo;
|
||||
SSchema* pSchemas;
|
||||
char tbName[TSDB_TABLE_NAME_LEN];
|
||||
char stbName[TSDB_TABLE_NAME_LEN];
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
int64_t dbId;
|
||||
int32_t numOfTags;
|
||||
int32_t numOfColumns;
|
||||
int8_t precision;
|
||||
int8_t tableType;
|
||||
int32_t sversion;
|
||||
int32_t tversion;
|
||||
uint64_t suid;
|
||||
uint64_t tuid;
|
||||
int32_t vgId;
|
||||
int8_t sysInfo;
|
||||
SSchema* pSchemas;
|
||||
SSchemaExt* pSchemaExt;
|
||||
} STableMetaRsp;
|
||||
|
||||
typedef struct {
|
||||
|
@ -626,6 +652,54 @@ typedef struct {
|
|||
SSchema* pSchema;
|
||||
} SSchemaWrapper;
|
||||
|
||||
typedef struct {
|
||||
col_id_t id;
|
||||
uint32_t alg;
|
||||
} SColCmpr;
|
||||
|
||||
typedef struct {
|
||||
int32_t nCols;
|
||||
int32_t version;
|
||||
SColCmpr* pColCmpr;
|
||||
} SColCmprWrapper;
|
||||
|
||||
static FORCE_INLINE SColCmprWrapper* tCloneSColCmprWrapper(const SColCmprWrapper* pSrcWrapper) {
|
||||
if (pSrcWrapper->pColCmpr == NULL || pSrcWrapper->nCols == 0) return NULL;
|
||||
|
||||
SColCmprWrapper* pDstWrapper = (SColCmprWrapper*)taosMemoryMalloc(sizeof(SColCmprWrapper));
|
||||
pDstWrapper->nCols = pSrcWrapper->nCols;
|
||||
pDstWrapper->version = pSrcWrapper->version;
|
||||
|
||||
int32_t size = sizeof(SColCmpr) * pDstWrapper->nCols;
|
||||
pDstWrapper->pColCmpr = (SColCmpr*)taosMemoryCalloc(1, size);
|
||||
memcpy(pDstWrapper->pColCmpr, pSrcWrapper->pColCmpr, size);
|
||||
|
||||
return pDstWrapper;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tInitDefaultSColCmprWrapperByCols(SColCmprWrapper* pCmpr, int32_t nCols) {
|
||||
assert(!pCmpr->pColCmpr);
|
||||
pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(nCols, sizeof(SColCmpr));
|
||||
pCmpr->nCols = nCols;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tInitDefaultSColCmprWrapper(SColCmprWrapper* pCmpr, SSchemaWrapper* pSchema) {
|
||||
pCmpr->nCols = pSchema->nCols;
|
||||
assert(!pCmpr->pColCmpr);
|
||||
pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(pCmpr->nCols, sizeof(SColCmpr));
|
||||
for (int32_t i = 0; i < pCmpr->nCols; i++) {
|
||||
SColCmpr* pColCmpr = &pCmpr->pColCmpr[i];
|
||||
SSchema* pColSchema = &pSchema->pSchema[i];
|
||||
pColCmpr->id = pColSchema->colId;
|
||||
pColCmpr->alg = 0;
|
||||
}
|
||||
}
|
||||
static FORCE_INLINE void tDeleteSColCmprWrapper(SColCmprWrapper* pWrapper) {
|
||||
if (pWrapper == NULL) return;
|
||||
|
||||
taosMemoryFreeClear(pWrapper->pColCmpr);
|
||||
taosMemoryFreeClear(pWrapper);
|
||||
}
|
||||
static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* pSchemaWrapper) {
|
||||
if (pSchemaWrapper->pSchema == NULL) return NULL;
|
||||
|
||||
|
@ -694,6 +768,18 @@ static FORCE_INLINE int32_t tDecodeSSchema(SDecoder* pDecoder, SSchema* pSchema)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSSchemaExt(SEncoder* pEncoder, const SSchemaExt* pSchemaExt) {
|
||||
if (tEncodeI16v(pEncoder, pSchemaExt->colId) < 0) return -1;
|
||||
if (tEncodeU32(pEncoder, pSchemaExt->compress) < 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeSSchemaExt(SDecoder* pDecoder, SSchemaExt* pSchemaExt) {
|
||||
if (tDecodeI16v(pDecoder, &pSchemaExt->colId) < 0) return -1;
|
||||
if (tDecodeU32(pDecoder, &pSchemaExt->compress) < 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWrapper* pSW) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeVariantI32(buf, pSW->nCols);
|
||||
|
@ -777,7 +863,7 @@ typedef struct {
|
|||
int32_t commentLen;
|
||||
int32_t ast1Len;
|
||||
int32_t ast2Len;
|
||||
SArray* pColumns; // array of SField
|
||||
SArray* pColumns; // array of SFieldWithOptions
|
||||
SArray* pTags; // array of SField
|
||||
SArray* pFuncs;
|
||||
char* pComment;
|
||||
|
@ -1094,23 +1180,24 @@ typedef struct {
|
|||
} STableCfgReq;
|
||||
|
||||
typedef struct {
|
||||
char tbName[TSDB_TABLE_NAME_LEN];
|
||||
char stbName[TSDB_TABLE_NAME_LEN];
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
int32_t numOfTags;
|
||||
int32_t numOfColumns;
|
||||
int8_t tableType;
|
||||
int64_t delay1;
|
||||
int64_t delay2;
|
||||
int64_t watermark1;
|
||||
int64_t watermark2;
|
||||
int32_t ttl;
|
||||
SArray* pFuncs;
|
||||
int32_t commentLen;
|
||||
char* pComment;
|
||||
SSchema* pSchemas;
|
||||
int32_t tagsLen;
|
||||
char* pTags;
|
||||
char tbName[TSDB_TABLE_NAME_LEN];
|
||||
char stbName[TSDB_TABLE_NAME_LEN];
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
int32_t numOfTags;
|
||||
int32_t numOfColumns;
|
||||
int8_t tableType;
|
||||
int64_t delay1;
|
||||
int64_t delay2;
|
||||
int64_t watermark1;
|
||||
int64_t watermark2;
|
||||
int32_t ttl;
|
||||
SArray* pFuncs;
|
||||
int32_t commentLen;
|
||||
char* pComment;
|
||||
SSchema* pSchemas;
|
||||
int32_t tagsLen;
|
||||
char* pTags;
|
||||
SSchemaExt* pSchemaExt;
|
||||
} STableCfg;
|
||||
|
||||
typedef STableCfg STableCfgRsp;
|
||||
|
@ -1162,6 +1249,7 @@ typedef struct {
|
|||
int32_t sqlLen;
|
||||
char* sql;
|
||||
int8_t withArbitrator;
|
||||
int8_t encryptAlgorithm;
|
||||
} SCreateDbReq;
|
||||
|
||||
int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
|
||||
|
@ -1320,6 +1408,7 @@ typedef struct {
|
|||
int8_t replications;
|
||||
int8_t strict;
|
||||
int8_t cacheLast;
|
||||
int8_t encryptAlgorithm;
|
||||
int32_t s3ChunkSize;
|
||||
int32_t s3KeepLocal;
|
||||
int8_t s3Compact;
|
||||
|
@ -1397,8 +1486,14 @@ int32_t tDeserializeSDnodeListRsp(void* buf, int32_t bufLen, SDnodeListRsp* pRsp
|
|||
void tFreeSDnodeListRsp(SDnodeListRsp* pRsp);
|
||||
|
||||
typedef struct {
|
||||
SUseDbRsp* useDbRsp;
|
||||
SDbCfgRsp* cfgRsp;
|
||||
SArray* pTsmas; // SArray<STableTSMAInfo*>
|
||||
} STableTSMAInfoRsp;
|
||||
|
||||
typedef struct {
|
||||
SUseDbRsp* useDbRsp;
|
||||
SDbCfgRsp* cfgRsp;
|
||||
STableTSMAInfoRsp* pTsmaRsp;
|
||||
int32_t dbTsmaVersion;
|
||||
} SDbHbRsp;
|
||||
|
||||
typedef struct {
|
||||
|
@ -1514,13 +1609,15 @@ void tFreeSFuncInfo(SFuncInfo* pInfo);
|
|||
void tFreeSRetrieveFuncRsp(SRetrieveFuncRsp* pRsp);
|
||||
|
||||
typedef struct {
|
||||
int32_t statusInterval;
|
||||
int64_t checkTime; // 1970-01-01 00:00:00.000
|
||||
char timezone[TD_TIMEZONE_LEN]; // tsTimezone
|
||||
char locale[TD_LOCALE_LEN]; // tsLocale
|
||||
char charset[TD_LOCALE_LEN]; // tsCharset
|
||||
int8_t ttlChangeOnWrite;
|
||||
int8_t enableWhiteList;
|
||||
int32_t statusInterval;
|
||||
int64_t checkTime; // 1970-01-01 00:00:00.000
|
||||
char timezone[TD_TIMEZONE_LEN]; // tsTimezone
|
||||
char locale[TD_LOCALE_LEN]; // tsLocale
|
||||
char charset[TD_LOCALE_LEN]; // tsCharset
|
||||
int8_t ttlChangeOnWrite;
|
||||
int8_t enableWhiteList;
|
||||
int8_t encryptionKeyStat;
|
||||
uint32_t encryptionKeyChksum;
|
||||
} SClusterCfg;
|
||||
|
||||
typedef struct {
|
||||
|
@ -1732,6 +1829,7 @@ typedef struct {
|
|||
int8_t learnerSelfIndex;
|
||||
SReplica learnerReplicas[TSDB_MAX_LEARNER_REPLICA];
|
||||
int32_t changeVersion;
|
||||
int8_t encryptAlgorithm;
|
||||
} SCreateVnodeReq;
|
||||
|
||||
int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
||||
|
@ -2597,6 +2695,7 @@ typedef struct {
|
|||
SArray* pVgroupVerList;
|
||||
// 3.3.0.0
|
||||
SArray* pCols; // array of SField
|
||||
int64_t smaId;
|
||||
} SCMCreateStreamReq;
|
||||
|
||||
typedef struct {
|
||||
|
@ -2788,15 +2887,17 @@ int32_t tDecodeSRSmaParam(SDecoder* pCoder, SRSmaParam* pRSmaParam);
|
|||
|
||||
// TDMT_VND_CREATE_STB ==============
|
||||
typedef struct SVCreateStbReq {
|
||||
char* name;
|
||||
tb_uid_t suid;
|
||||
int8_t rollup;
|
||||
SSchemaWrapper schemaRow;
|
||||
SSchemaWrapper schemaTag;
|
||||
SRSmaParam rsmaParam;
|
||||
int32_t alterOriDataLen;
|
||||
void* alterOriData;
|
||||
int8_t source;
|
||||
char* name;
|
||||
tb_uid_t suid;
|
||||
int8_t rollup;
|
||||
SSchemaWrapper schemaRow;
|
||||
SSchemaWrapper schemaTag;
|
||||
SRSmaParam rsmaParam;
|
||||
int32_t alterOriDataLen;
|
||||
void* alterOriData;
|
||||
int8_t source;
|
||||
int8_t colCmpred;
|
||||
SColCmprWrapper colCmpr;
|
||||
} SVCreateStbReq;
|
||||
|
||||
int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq);
|
||||
|
@ -2834,8 +2935,9 @@ typedef struct SVCreateTbReq {
|
|||
SSchemaWrapper schemaRow;
|
||||
} ntb;
|
||||
};
|
||||
int32_t sqlLen;
|
||||
char* sql;
|
||||
int32_t sqlLen;
|
||||
char* sql;
|
||||
SColCmprWrapper colCmpr;
|
||||
} SVCreateTbReq;
|
||||
|
||||
int tEncodeSVCreateTbReq(SEncoder* pCoder, const SVCreateTbReq* pReq);
|
||||
|
@ -2858,6 +2960,7 @@ static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) {
|
|||
} else if (req->type == TSDB_NORMAL_TABLE) {
|
||||
taosMemoryFreeClear(req->ntb.schemaRow.pSchema);
|
||||
}
|
||||
taosMemoryFreeClear(req->colCmpr.pColCmpr);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -2943,12 +3046,10 @@ typedef struct {
|
|||
int32_t bytes;
|
||||
// TSDB_ALTER_TABLE_DROP_COLUMN
|
||||
// TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
|
||||
int8_t colModType;
|
||||
int32_t colModBytes;
|
||||
// TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
|
||||
char* colNewName;
|
||||
// TSDB_ALTER_TABLE_UPDATE_TAG_VAL
|
||||
char* tagName;
|
||||
int8_t colModType;
|
||||
int32_t colModBytes;
|
||||
char* colNewName; // TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
|
||||
char* tagName; // TSDB_ALTER_TABLE_UPDATE_TAG_VAL
|
||||
int8_t isNull;
|
||||
int8_t tagType;
|
||||
int8_t tagFree;
|
||||
|
@ -2956,12 +3057,13 @@ typedef struct {
|
|||
uint8_t* pTagVal;
|
||||
SArray* pTagArray;
|
||||
// TSDB_ALTER_TABLE_UPDATE_OPTIONS
|
||||
int8_t updateTTL;
|
||||
int32_t newTTL;
|
||||
int32_t newCommentLen;
|
||||
char* newComment;
|
||||
int64_t ctimeMs; // fill by vnode
|
||||
int8_t source; // TD_REQ_FROM_TAOX-taosX or TD_REQ_FROM_APP-taosClient
|
||||
int8_t updateTTL;
|
||||
int32_t newTTL;
|
||||
int32_t newCommentLen;
|
||||
char* newComment;
|
||||
int64_t ctimeMs; // fill by vnode
|
||||
int8_t source; // TD_REQ_FROM_TAOX-taosX or TD_REQ_FROM_APP-taosClient
|
||||
uint32_t compress; // TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS
|
||||
} SVAlterTbReq;
|
||||
|
||||
int32_t tEncodeSVAlterTbReq(SEncoder* pEncoder, const SVAlterTbReq* pReq);
|
||||
|
@ -3561,6 +3663,10 @@ typedef struct {
|
|||
char* ast;
|
||||
int64_t deleteMark;
|
||||
int64_t lastTs;
|
||||
int64_t normSourceTbUid; // the Uid of source tb if its a normal table, otherwise 0
|
||||
SArray* pVgroupVerList;
|
||||
int8_t recursiveTsma;
|
||||
char baseTsmaName[TSDB_TABLE_FNAME_LEN]; // base tsma name for recursively created tsma
|
||||
} SMCreateSmaReq;
|
||||
|
||||
int32_t tSerializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
|
||||
|
@ -3836,6 +3942,7 @@ int32_t tDecodeMqMetaRsp(SDecoder* pDecoder, SMqMetaRsp* pRsp);
|
|||
void tDeleteMqMetaRsp(SMqMetaRsp *pRsp);
|
||||
|
||||
#define MQ_DATA_RSP_VERSION 100
|
||||
|
||||
typedef struct {
|
||||
SMqRspHead head;
|
||||
STqOffsetVal reqOffset;
|
||||
|
@ -3847,33 +3954,27 @@ typedef struct {
|
|||
SArray* blockData;
|
||||
SArray* blockTbName;
|
||||
SArray* blockSchema;
|
||||
int64_t sleepTime;
|
||||
} SMqDataRspCommon;
|
||||
|
||||
typedef struct {
|
||||
SMqDataRspCommon common;
|
||||
int64_t sleepTime;
|
||||
} SMqDataRsp;
|
||||
|
||||
int32_t tEncodeMqDataRsp(SEncoder* pEncoder, const SMqDataRsp* pRsp);
|
||||
int32_t tDecodeMqDataRsp(SDecoder* pDecoder, SMqDataRsp* pRsp, int8_t dataVersion);
|
||||
void tDeleteMqDataRsp(SMqDataRsp* pRsp);
|
||||
int32_t tEncodeMqDataRsp(SEncoder* pEncoder, const void* pRsp);
|
||||
int32_t tDecodeMqDataRsp(SDecoder* pDecoder, void* pRsp);
|
||||
void tDeleteMqDataRsp(void* pRsp);
|
||||
|
||||
typedef struct {
|
||||
SMqRspHead head;
|
||||
STqOffsetVal reqOffset;
|
||||
STqOffsetVal rspOffset;
|
||||
int32_t blockNum;
|
||||
int8_t withTbName;
|
||||
int8_t withSchema;
|
||||
SArray* blockDataLen;
|
||||
SArray* blockData;
|
||||
SArray* blockTbName;
|
||||
SArray* blockSchema;
|
||||
// the following attributes are extended from SMqDataRsp
|
||||
int32_t createTableNum;
|
||||
SArray* createTableLen;
|
||||
SArray* createTableReq;
|
||||
SMqDataRspCommon common;
|
||||
int32_t createTableNum;
|
||||
SArray* createTableLen;
|
||||
SArray* createTableReq;
|
||||
} STaosxRsp;
|
||||
|
||||
int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const STaosxRsp* pRsp);
|
||||
int32_t tDecodeSTaosxRsp(SDecoder* pDecoder, STaosxRsp* pRsp, int8_t dateVersion);
|
||||
void tDeleteSTaosxRsp(STaosxRsp* pRsp);
|
||||
int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const void* pRsp);
|
||||
int32_t tDecodeSTaosxRsp(SDecoder* pDecoder, void* pRsp);
|
||||
void tDeleteSTaosxRsp(void* pRsp);
|
||||
|
||||
typedef struct {
|
||||
SMqRspHead head;
|
||||
|
@ -4184,6 +4285,107 @@ typedef struct {
|
|||
int32_t tSerializeSViewMetaRsp(void* buf, int32_t bufLen, const SViewMetaRsp* pRsp);
|
||||
int32_t tDeserializeSViewMetaRsp(void* buf, int32_t bufLen, SViewMetaRsp* pRsp);
|
||||
void tFreeSViewMetaRsp(SViewMetaRsp* pRsp);
|
||||
typedef struct {
|
||||
char name[TSDB_TABLE_FNAME_LEN]; // table name or tsma name
|
||||
bool fetchingWithTsmaName; // if we are fetching with tsma name
|
||||
}STableTSMAInfoReq;
|
||||
|
||||
int32_t tSerializeTableTSMAInfoReq(void* buf, int32_t bufLen, const STableTSMAInfoReq* pReq);
|
||||
int32_t tDeserializeTableTSMAInfoReq(void* buf, int32_t bufLen, STableTSMAInfoReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
int32_t funcId;
|
||||
col_id_t colId;
|
||||
} STableTSMAFuncInfo;
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_TABLE_NAME_LEN];
|
||||
uint64_t tsmaId;
|
||||
char targetTb[TSDB_TABLE_NAME_LEN];
|
||||
char targetDbFName[TSDB_DB_FNAME_LEN];
|
||||
char tb[TSDB_TABLE_NAME_LEN];
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
uint64_t suid;
|
||||
uint64_t destTbUid;
|
||||
uint64_t dbId;
|
||||
int32_t version;
|
||||
int64_t interval;
|
||||
int8_t unit;
|
||||
SArray* pFuncs; // SArray<STableTSMAFuncInfo>
|
||||
SArray* pTags; // SArray<SSchema>
|
||||
SArray* pUsedCols; // SArray<SSchema>
|
||||
char* ast;
|
||||
|
||||
int64_t streamUid;
|
||||
int64_t reqTs;
|
||||
int64_t rspTs;
|
||||
int64_t delayDuration; // ms
|
||||
bool fillHistoryFinished;
|
||||
} STableTSMAInfo;
|
||||
|
||||
int32_t tSerializeTableTSMAInfoRsp(void* buf, int32_t bufLen, const STableTSMAInfoRsp* pRsp);
|
||||
int32_t tDeserializeTableTSMAInfoRsp(void* buf, int32_t bufLen, STableTSMAInfoRsp* pRsp);
|
||||
int32_t tCloneTbTSMAInfo(STableTSMAInfo* pInfo, STableTSMAInfo** pRes);
|
||||
void tFreeTableTSMAInfo(void* p);
|
||||
void tFreeAndClearTableTSMAInfo(void* p);
|
||||
void tFreeTableTSMAInfoRsp(STableTSMAInfoRsp* pRsp);
|
||||
|
||||
#define STSMAHbRsp STableTSMAInfoRsp
|
||||
#define tSerializeTSMAHbRsp tSerializeTableTSMAInfoRsp
|
||||
#define tDeserializeTSMAHbRsp tDeserializeTableTSMAInfoRsp
|
||||
#define tFreeTSMAHbRsp tFreeTableTSMAInfoRsp
|
||||
|
||||
typedef struct SStreamProgressReq {
|
||||
int64_t streamId;
|
||||
int32_t vgId;
|
||||
int32_t fetchIdx;
|
||||
int32_t subFetchIdx;
|
||||
} SStreamProgressReq;
|
||||
|
||||
int32_t tSerializeStreamProgressReq(void* buf, int32_t bufLen, const SStreamProgressReq* pReq);
|
||||
int32_t tDeserializeStreamProgressReq(void* buf, int32_t bufLen, SStreamProgressReq* pReq);
|
||||
|
||||
typedef struct SStreamProgressRsp {
|
||||
int64_t streamId;
|
||||
int32_t vgId;
|
||||
bool fillHisFinished;
|
||||
int64_t progressDelay;
|
||||
int32_t fetchIdx;
|
||||
int32_t subFetchIdx;
|
||||
} SStreamProgressRsp;
|
||||
|
||||
int32_t tSerializeStreamProgressRsp(void* buf, int32_t bufLen, const SStreamProgressRsp* pRsp);
|
||||
int32_t tDeserializeSStreamProgressRsp(void* buf, int32_t bufLen, SStreamProgressRsp* pRsp);
|
||||
|
||||
typedef struct SDropCtbWithTsmaSingleVgReq {
|
||||
SVgroupInfo vgInfo;
|
||||
SArray* pTbs; // SVDropTbReq
|
||||
} SMDropTbReqsOnSingleVg;
|
||||
|
||||
int32_t tEncodeSMDropTbReqOnSingleVg(SEncoder* pEncoder, const SMDropTbReqsOnSingleVg* pReq);
|
||||
int32_t tDecodeSMDropTbReqOnSingleVg(SDecoder* pDecoder, SMDropTbReqsOnSingleVg* pReq);
|
||||
void tFreeSMDropTbReqOnSingleVg(void* p);
|
||||
|
||||
typedef struct SDropTbsReq {
|
||||
SArray* pVgReqs; // SMDropTbReqsOnSingleVg
|
||||
} SMDropTbsReq;
|
||||
|
||||
int32_t tSerializeSMDropTbsReq(void* buf, int32_t bufLen, const SMDropTbsReq* pReq);
|
||||
int32_t tDeserializeSMDropTbsReq(void* buf, int32_t bufLen, SMDropTbsReq* pReq);
|
||||
void tFreeSMDropTbsReq(void*);
|
||||
|
||||
typedef struct SVFetchTtlExpiredTbsRsp {
|
||||
SArray* pExpiredTbs; // SVDropTbReq
|
||||
int32_t vgId;
|
||||
} SVFetchTtlExpiredTbsRsp;
|
||||
|
||||
int32_t tEncodeVFetchTtlExpiredTbsRsp(SEncoder* pCoder, const SVFetchTtlExpiredTbsRsp* pRsp);
|
||||
int32_t tDecodeVFetchTtlExpiredTbsRsp(SDecoder* pCoder, SVFetchTtlExpiredTbsRsp* pRsp);
|
||||
|
||||
void tFreeFetchTtlExpiredTbsRsp(void* p);
|
||||
|
||||
void setDefaultOptionsForField(SFieldWithOptions* field);
|
||||
void setFieldWithOptions(SFieldWithOptions* fieldWithOptions, SField* field);
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
|
|
|
@ -106,6 +106,7 @@
|
|||
TD_DEF_MSG_TYPE(TDMT_DND_ALTER_MNODE_TYPE, "dnode-alter-mnode-type", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_ALTER_VNODE_TYPE, "dnode-alter-vnode-type", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP, "dnode-check-vnode-learner-catchup", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_CREATE_ENCRYPT_KEY, "create-encrypt-key", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_MAX_MSG, "dnd-max", NULL, NULL)
|
||||
TD_CLOSE_MSG_SEG(TDMT_END_DND_MSG)
|
||||
|
||||
|
@ -220,9 +221,16 @@
|
|||
TD_DEF_MSG_TYPE(TDMT_MND_COMPACT_TIMER, "compact-tmr", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_REQ_CHKPT, "stream-req-checkpoint", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG_CLUSTER, "config-cluster", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_ENCRYPT_KEY, "create-encrypt-key", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_S3MIGRATE_DB, "s3migrate-db", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_S3MIGRATE_DB_TIMER, "s3migrate-db-tmr", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TSMA, "create-tsma", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_TSMA, "drop-tsma", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_STB_DROP, "drop-stb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_GET_TABLE_TSMA, "get-table-tsma", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_GET_TSMA, "get-tsma", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_TB_WITH_TSMA, "drop-tb-with-tsma", NULL, NULL)
|
||||
TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8
|
||||
|
@ -267,6 +275,7 @@
|
|||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_HASHRANGE, "alter-hashrange", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_COMPACT, "vnode-compact", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TTL_TABLE, "vnode-drop-ttl-stb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_FETCH_TTL_EXPIRED_TBS, "vnode-fetch-ttl-expired-tbs", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TRIM, "vnode-trim", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_COMMIT, "vnode-commit", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_INDEX, "vnode-create-index", NULL, NULL)
|
||||
|
@ -310,6 +319,8 @@
|
|||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RESUME, "stream-task-resume", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_STOP, "stream-task-stop", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_MAX_MSG, "stream-max", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_CREATE, "stream-create", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_DROP, "stream-drop", NULL, NULL)
|
||||
TD_CLOSE_MSG_SEG(TDMT_END_STREAM_MSG)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_MON_MSG) //5 << 8
|
||||
|
@ -357,6 +368,7 @@
|
|||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_RESET, "vnode-stream-reset", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_CHECK, "vnode-stream-task-check", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_MAX_MSG, "vnd-stream-max", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_GET_STREAM_PROGRESS, "vnd-stream-progress", NULL, NULL)
|
||||
TD_CLOSE_MSG_SEG(TDMT_END_VND_STREAM_MSG)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_VND_TMQ_MSG) //8 << 8
|
||||
|
|
|
@ -88,6 +88,7 @@ char getPrecisionUnit(int32_t precision);
|
|||
int64_t convertTimePrecision(int64_t ts, int32_t fromPrecision, int32_t toPrecision);
|
||||
int64_t convertTimeFromPrecisionToUnit(int64_t ts, int32_t fromPrecision, char toUnit);
|
||||
int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec, int64_t* timeVal);
|
||||
int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision);
|
||||
|
||||
void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t ts, int32_t precision);
|
||||
|
||||
|
|
|
@ -66,79 +66,79 @@
|
|||
#define TK_WRITE 48
|
||||
#define TK_NK_DOT 49
|
||||
#define TK_WITH 50
|
||||
#define TK_DNODE 51
|
||||
#define TK_PORT 52
|
||||
#define TK_DNODES 53
|
||||
#define TK_RESTORE 54
|
||||
#define TK_NK_IPTOKEN 55
|
||||
#define TK_FORCE 56
|
||||
#define TK_UNSAFE 57
|
||||
#define TK_CLUSTER 58
|
||||
#define TK_LOCAL 59
|
||||
#define TK_QNODE 60
|
||||
#define TK_BNODE 61
|
||||
#define TK_SNODE 62
|
||||
#define TK_MNODE 63
|
||||
#define TK_VNODE 64
|
||||
#define TK_DATABASE 65
|
||||
#define TK_USE 66
|
||||
#define TK_FLUSH 67
|
||||
#define TK_TRIM 68
|
||||
#define TK_S3MIGRATE 69
|
||||
#define TK_COMPACT 70
|
||||
#define TK_IF 71
|
||||
#define TK_NOT 72
|
||||
#define TK_EXISTS 73
|
||||
#define TK_BUFFER 74
|
||||
#define TK_CACHEMODEL 75
|
||||
#define TK_CACHESIZE 76
|
||||
#define TK_COMP 77
|
||||
#define TK_DURATION 78
|
||||
#define TK_NK_VARIABLE 79
|
||||
#define TK_MAXROWS 80
|
||||
#define TK_MINROWS 81
|
||||
#define TK_KEEP 82
|
||||
#define TK_PAGES 83
|
||||
#define TK_PAGESIZE 84
|
||||
#define TK_TSDB_PAGESIZE 85
|
||||
#define TK_PRECISION 86
|
||||
#define TK_REPLICA 87
|
||||
#define TK_VGROUPS 88
|
||||
#define TK_SINGLE_STABLE 89
|
||||
#define TK_RETENTIONS 90
|
||||
#define TK_SCHEMALESS 91
|
||||
#define TK_WAL_LEVEL 92
|
||||
#define TK_WAL_FSYNC_PERIOD 93
|
||||
#define TK_WAL_RETENTION_PERIOD 94
|
||||
#define TK_WAL_RETENTION_SIZE 95
|
||||
#define TK_WAL_ROLL_PERIOD 96
|
||||
#define TK_WAL_SEGMENT_SIZE 97
|
||||
#define TK_STT_TRIGGER 98
|
||||
#define TK_TABLE_PREFIX 99
|
||||
#define TK_TABLE_SUFFIX 100
|
||||
#define TK_S3_CHUNKSIZE 101
|
||||
#define TK_S3_KEEPLOCAL 102
|
||||
#define TK_S3_COMPACT 103
|
||||
#define TK_KEEP_TIME_OFFSET 104
|
||||
#define TK_NK_COLON 105
|
||||
#define TK_BWLIMIT 106
|
||||
#define TK_START 107
|
||||
#define TK_TIMESTAMP 108
|
||||
#define TK_END 109
|
||||
#define TK_TABLE 110
|
||||
#define TK_NK_LP 111
|
||||
#define TK_NK_RP 112
|
||||
#define TK_STABLE 113
|
||||
#define TK_COLUMN 114
|
||||
#define TK_MODIFY 115
|
||||
#define TK_RENAME 116
|
||||
#define TK_TAG 117
|
||||
#define TK_SET 118
|
||||
#define TK_NK_EQ 119
|
||||
#define TK_USING 120
|
||||
#define TK_TAGS 121
|
||||
#define TK_PRIMARY 122
|
||||
#define TK_KEY 123
|
||||
#define TK_ENCRYPT_KEY 51
|
||||
#define TK_DNODE 52
|
||||
#define TK_PORT 53
|
||||
#define TK_DNODES 54
|
||||
#define TK_RESTORE 55
|
||||
#define TK_NK_IPTOKEN 56
|
||||
#define TK_FORCE 57
|
||||
#define TK_UNSAFE 58
|
||||
#define TK_CLUSTER 59
|
||||
#define TK_LOCAL 60
|
||||
#define TK_QNODE 61
|
||||
#define TK_BNODE 62
|
||||
#define TK_SNODE 63
|
||||
#define TK_MNODE 64
|
||||
#define TK_VNODE 65
|
||||
#define TK_DATABASE 66
|
||||
#define TK_USE 67
|
||||
#define TK_FLUSH 68
|
||||
#define TK_TRIM 69
|
||||
#define TK_S3MIGRATE 70
|
||||
#define TK_COMPACT 71
|
||||
#define TK_IF 72
|
||||
#define TK_NOT 73
|
||||
#define TK_EXISTS 74
|
||||
#define TK_BUFFER 75
|
||||
#define TK_CACHEMODEL 76
|
||||
#define TK_CACHESIZE 77
|
||||
#define TK_COMP 78
|
||||
#define TK_DURATION 79
|
||||
#define TK_NK_VARIABLE 80
|
||||
#define TK_MAXROWS 81
|
||||
#define TK_MINROWS 82
|
||||
#define TK_KEEP 83
|
||||
#define TK_PAGES 84
|
||||
#define TK_PAGESIZE 85
|
||||
#define TK_TSDB_PAGESIZE 86
|
||||
#define TK_PRECISION 87
|
||||
#define TK_REPLICA 88
|
||||
#define TK_VGROUPS 89
|
||||
#define TK_SINGLE_STABLE 90
|
||||
#define TK_RETENTIONS 91
|
||||
#define TK_SCHEMALESS 92
|
||||
#define TK_WAL_LEVEL 93
|
||||
#define TK_WAL_FSYNC_PERIOD 94
|
||||
#define TK_WAL_RETENTION_PERIOD 95
|
||||
#define TK_WAL_RETENTION_SIZE 96
|
||||
#define TK_WAL_ROLL_PERIOD 97
|
||||
#define TK_WAL_SEGMENT_SIZE 98
|
||||
#define TK_STT_TRIGGER 99
|
||||
#define TK_TABLE_PREFIX 100
|
||||
#define TK_TABLE_SUFFIX 101
|
||||
#define TK_S3_CHUNKSIZE 102
|
||||
#define TK_S3_KEEPLOCAL 103
|
||||
#define TK_S3_COMPACT 104
|
||||
#define TK_KEEP_TIME_OFFSET 105
|
||||
#define TK_ENCRYPT_ALGORITHM 106
|
||||
#define TK_NK_COLON 107
|
||||
#define TK_BWLIMIT 108
|
||||
#define TK_START 109
|
||||
#define TK_TIMESTAMP 110
|
||||
#define TK_END 111
|
||||
#define TK_TABLE 112
|
||||
#define TK_NK_LP 113
|
||||
#define TK_NK_RP 114
|
||||
#define TK_STABLE 115
|
||||
#define TK_COLUMN 116
|
||||
#define TK_MODIFY 117
|
||||
#define TK_RENAME 118
|
||||
#define TK_TAG 119
|
||||
#define TK_SET 120
|
||||
#define TK_NK_EQ 121
|
||||
#define TK_USING 122
|
||||
#define TK_TAGS 123
|
||||
#define TK_BOOL 124
|
||||
#define TK_TINYINT 125
|
||||
#define TK_SMALLINT 126
|
||||
|
@ -184,210 +184,217 @@
|
|||
#define TK_FULL 166
|
||||
#define TK_LOGS 167
|
||||
#define TK_MACHINES 168
|
||||
#define TK_QUERIES 169
|
||||
#define TK_SCORES 170
|
||||
#define TK_TOPICS 171
|
||||
#define TK_VARIABLES 172
|
||||
#define TK_BNODES 173
|
||||
#define TK_SNODES 174
|
||||
#define TK_TRANSACTIONS 175
|
||||
#define TK_DISTRIBUTED 176
|
||||
#define TK_CONSUMERS 177
|
||||
#define TK_SUBSCRIPTIONS 178
|
||||
#define TK_VNODES 179
|
||||
#define TK_ALIVE 180
|
||||
#define TK_VIEWS 181
|
||||
#define TK_VIEW 182
|
||||
#define TK_COMPACTS 183
|
||||
#define TK_NORMAL 184
|
||||
#define TK_CHILD 185
|
||||
#define TK_LIKE 186
|
||||
#define TK_TBNAME 187
|
||||
#define TK_QTAGS 188
|
||||
#define TK_AS 189
|
||||
#define TK_SYSTEM 190
|
||||
#define TK_INDEX 191
|
||||
#define TK_FUNCTION 192
|
||||
#define TK_ENCRYPTIONS 169
|
||||
#define TK_QUERIES 170
|
||||
#define TK_SCORES 171
|
||||
#define TK_TOPICS 172
|
||||
#define TK_VARIABLES 173
|
||||
#define TK_BNODES 174
|
||||
#define TK_SNODES 175
|
||||
#define TK_TRANSACTIONS 176
|
||||
#define TK_DISTRIBUTED 177
|
||||
#define TK_CONSUMERS 178
|
||||
#define TK_SUBSCRIPTIONS 179
|
||||
#define TK_VNODES 180
|
||||
#define TK_ALIVE 181
|
||||
#define TK_VIEWS 182
|
||||
#define TK_VIEW 183
|
||||
#define TK_COMPACTS 184
|
||||
#define TK_NORMAL 185
|
||||
#define TK_CHILD 186
|
||||
#define TK_LIKE 187
|
||||
#define TK_TBNAME 188
|
||||
#define TK_QTAGS 189
|
||||
#define TK_AS 190
|
||||
#define TK_SYSTEM 191
|
||||
#define TK_TSMA 192
|
||||
#define TK_INTERVAL 193
|
||||
#define TK_COUNT 194
|
||||
#define TK_LAST_ROW 195
|
||||
#define TK_META 196
|
||||
#define TK_ONLY 197
|
||||
#define TK_TOPIC 198
|
||||
#define TK_CONSUMER 199
|
||||
#define TK_GROUP 200
|
||||
#define TK_DESC 201
|
||||
#define TK_DESCRIBE 202
|
||||
#define TK_RESET 203
|
||||
#define TK_QUERY 204
|
||||
#define TK_CACHE 205
|
||||
#define TK_EXPLAIN 206
|
||||
#define TK_ANALYZE 207
|
||||
#define TK_VERBOSE 208
|
||||
#define TK_NK_BOOL 209
|
||||
#define TK_RATIO 210
|
||||
#define TK_NK_FLOAT 211
|
||||
#define TK_OUTPUTTYPE 212
|
||||
#define TK_AGGREGATE 213
|
||||
#define TK_BUFSIZE 214
|
||||
#define TK_LANGUAGE 215
|
||||
#define TK_REPLACE 216
|
||||
#define TK_STREAM 217
|
||||
#define TK_INTO 218
|
||||
#define TK_PAUSE 219
|
||||
#define TK_RESUME 220
|
||||
#define TK_TRIGGER 221
|
||||
#define TK_AT_ONCE 222
|
||||
#define TK_WINDOW_CLOSE 223
|
||||
#define TK_IGNORE 224
|
||||
#define TK_EXPIRED 225
|
||||
#define TK_FILL_HISTORY 226
|
||||
#define TK_UPDATE 227
|
||||
#define TK_SUBTABLE 228
|
||||
#define TK_UNTREATED 229
|
||||
#define TK_KILL 230
|
||||
#define TK_CONNECTION 231
|
||||
#define TK_TRANSACTION 232
|
||||
#define TK_BALANCE 233
|
||||
#define TK_VGROUP 234
|
||||
#define TK_LEADER 235
|
||||
#define TK_MERGE 236
|
||||
#define TK_REDISTRIBUTE 237
|
||||
#define TK_SPLIT 238
|
||||
#define TK_DELETE 239
|
||||
#define TK_INSERT 240
|
||||
#define TK_NK_BIN 241
|
||||
#define TK_NK_HEX 242
|
||||
#define TK_NULL 243
|
||||
#define TK_NK_QUESTION 244
|
||||
#define TK_NK_ALIAS 245
|
||||
#define TK_NK_ARROW 246
|
||||
#define TK_ROWTS 247
|
||||
#define TK_QSTART 248
|
||||
#define TK_QEND 249
|
||||
#define TK_QDURATION 250
|
||||
#define TK_WSTART 251
|
||||
#define TK_WEND 252
|
||||
#define TK_WDURATION 253
|
||||
#define TK_IROWTS 254
|
||||
#define TK_ISFILLED 255
|
||||
#define TK_CAST 256
|
||||
#define TK_NOW 257
|
||||
#define TK_TODAY 258
|
||||
#define TK_TIMEZONE 259
|
||||
#define TK_CLIENT_VERSION 260
|
||||
#define TK_SERVER_VERSION 261
|
||||
#define TK_SERVER_STATUS 262
|
||||
#define TK_CURRENT_USER 263
|
||||
#define TK_CASE 264
|
||||
#define TK_WHEN 265
|
||||
#define TK_THEN 266
|
||||
#define TK_ELSE 267
|
||||
#define TK_BETWEEN 268
|
||||
#define TK_IS 269
|
||||
#define TK_NK_LT 270
|
||||
#define TK_NK_GT 271
|
||||
#define TK_NK_LE 272
|
||||
#define TK_NK_GE 273
|
||||
#define TK_NK_NE 274
|
||||
#define TK_MATCH 275
|
||||
#define TK_NMATCH 276
|
||||
#define TK_CONTAINS 277
|
||||
#define TK_IN 278
|
||||
#define TK_JOIN 279
|
||||
#define TK_INNER 280
|
||||
#define TK_LEFT 281
|
||||
#define TK_RIGHT 282
|
||||
#define TK_OUTER 283
|
||||
#define TK_SEMI 284
|
||||
#define TK_ANTI 285
|
||||
#define TK_ASOF 286
|
||||
#define TK_WINDOW 287
|
||||
#define TK_WINDOW_OFFSET 288
|
||||
#define TK_JLIMIT 289
|
||||
#define TK_SELECT 290
|
||||
#define TK_NK_HINT 291
|
||||
#define TK_DISTINCT 292
|
||||
#define TK_WHERE 293
|
||||
#define TK_PARTITION 294
|
||||
#define TK_BY 295
|
||||
#define TK_SESSION 296
|
||||
#define TK_STATE_WINDOW 297
|
||||
#define TK_EVENT_WINDOW 298
|
||||
#define TK_COUNT_WINDOW 299
|
||||
#define TK_SLIDING 300
|
||||
#define TK_FILL 301
|
||||
#define TK_VALUE 302
|
||||
#define TK_VALUE_F 303
|
||||
#define TK_NONE 304
|
||||
#define TK_PREV 305
|
||||
#define TK_NULL_F 306
|
||||
#define TK_LINEAR 307
|
||||
#define TK_NEXT 308
|
||||
#define TK_HAVING 309
|
||||
#define TK_RANGE 310
|
||||
#define TK_EVERY 311
|
||||
#define TK_ORDER 312
|
||||
#define TK_SLIMIT 313
|
||||
#define TK_SOFFSET 314
|
||||
#define TK_LIMIT 315
|
||||
#define TK_OFFSET 316
|
||||
#define TK_ASC 317
|
||||
#define TK_NULLS 318
|
||||
#define TK_ABORT 319
|
||||
#define TK_AFTER 320
|
||||
#define TK_ATTACH 321
|
||||
#define TK_BEFORE 322
|
||||
#define TK_BEGIN 323
|
||||
#define TK_BITAND 324
|
||||
#define TK_BITNOT 325
|
||||
#define TK_BITOR 326
|
||||
#define TK_BLOCKS 327
|
||||
#define TK_CHANGE 328
|
||||
#define TK_COMMA 329
|
||||
#define TK_CONCAT 330
|
||||
#define TK_CONFLICT 331
|
||||
#define TK_COPY 332
|
||||
#define TK_DEFERRED 333
|
||||
#define TK_DELIMITERS 334
|
||||
#define TK_DETACH 335
|
||||
#define TK_DIVIDE 336
|
||||
#define TK_DOT 337
|
||||
#define TK_EACH 338
|
||||
#define TK_FAIL 339
|
||||
#define TK_FILE 340
|
||||
#define TK_FOR 341
|
||||
#define TK_GLOB 342
|
||||
#define TK_ID 343
|
||||
#define TK_IMMEDIATE 344
|
||||
#define TK_IMPORT 345
|
||||
#define TK_INITIALLY 346
|
||||
#define TK_INSTEAD 347
|
||||
#define TK_ISNULL 348
|
||||
#define TK_MODULES 349
|
||||
#define TK_NK_BITNOT 350
|
||||
#define TK_NK_SEMI 351
|
||||
#define TK_NOTNULL 352
|
||||
#define TK_OF 353
|
||||
#define TK_PLUS 354
|
||||
#define TK_PRIVILEGE 355
|
||||
#define TK_RAISE 356
|
||||
#define TK_RESTRICT 357
|
||||
#define TK_ROW 358
|
||||
#define TK_STAR 359
|
||||
#define TK_STATEMENT 360
|
||||
#define TK_STRICT 361
|
||||
#define TK_STRING 362
|
||||
#define TK_TIMES 363
|
||||
#define TK_VALUES 364
|
||||
#define TK_VARIABLE 365
|
||||
#define TK_WAL 366
|
||||
#define TK_RECURSIVE 194
|
||||
#define TK_TSMAS 195
|
||||
#define TK_FUNCTION 196
|
||||
#define TK_INDEX 197
|
||||
#define TK_COUNT 198
|
||||
#define TK_LAST_ROW 199
|
||||
#define TK_META 200
|
||||
#define TK_ONLY 201
|
||||
#define TK_TOPIC 202
|
||||
#define TK_CONSUMER 203
|
||||
#define TK_GROUP 204
|
||||
#define TK_DESC 205
|
||||
#define TK_DESCRIBE 206
|
||||
#define TK_RESET 207
|
||||
#define TK_QUERY 208
|
||||
#define TK_CACHE 209
|
||||
#define TK_EXPLAIN 210
|
||||
#define TK_ANALYZE 211
|
||||
#define TK_VERBOSE 212
|
||||
#define TK_NK_BOOL 213
|
||||
#define TK_RATIO 214
|
||||
#define TK_NK_FLOAT 215
|
||||
#define TK_OUTPUTTYPE 216
|
||||
#define TK_AGGREGATE 217
|
||||
#define TK_BUFSIZE 218
|
||||
#define TK_LANGUAGE 219
|
||||
#define TK_REPLACE 220
|
||||
#define TK_STREAM 221
|
||||
#define TK_INTO 222
|
||||
#define TK_PAUSE 223
|
||||
#define TK_RESUME 224
|
||||
#define TK_PRIMARY 225
|
||||
#define TK_KEY 226
|
||||
#define TK_TRIGGER 227
|
||||
#define TK_AT_ONCE 228
|
||||
#define TK_WINDOW_CLOSE 229
|
||||
#define TK_IGNORE 230
|
||||
#define TK_EXPIRED 231
|
||||
#define TK_FILL_HISTORY 232
|
||||
#define TK_UPDATE 233
|
||||
#define TK_SUBTABLE 234
|
||||
#define TK_UNTREATED 235
|
||||
#define TK_KILL 236
|
||||
#define TK_CONNECTION 237
|
||||
#define TK_TRANSACTION 238
|
||||
#define TK_BALANCE 239
|
||||
#define TK_VGROUP 240
|
||||
#define TK_LEADER 241
|
||||
#define TK_MERGE 242
|
||||
#define TK_REDISTRIBUTE 243
|
||||
#define TK_SPLIT 244
|
||||
#define TK_DELETE 245
|
||||
#define TK_INSERT 246
|
||||
#define TK_NK_BIN 247
|
||||
#define TK_NK_HEX 248
|
||||
#define TK_NULL 249
|
||||
#define TK_NK_QUESTION 250
|
||||
#define TK_NK_ALIAS 251
|
||||
#define TK_NK_ARROW 252
|
||||
#define TK_ROWTS 253
|
||||
#define TK_QSTART 254
|
||||
#define TK_QEND 255
|
||||
#define TK_QDURATION 256
|
||||
#define TK_WSTART 257
|
||||
#define TK_WEND 258
|
||||
#define TK_WDURATION 259
|
||||
#define TK_IROWTS 260
|
||||
#define TK_ISFILLED 261
|
||||
#define TK_CAST 262
|
||||
#define TK_NOW 263
|
||||
#define TK_TODAY 264
|
||||
#define TK_TIMEZONE 265
|
||||
#define TK_CLIENT_VERSION 266
|
||||
#define TK_SERVER_VERSION 267
|
||||
#define TK_SERVER_STATUS 268
|
||||
#define TK_CURRENT_USER 269
|
||||
#define TK_CASE 270
|
||||
#define TK_WHEN 271
|
||||
#define TK_THEN 272
|
||||
#define TK_ELSE 273
|
||||
#define TK_BETWEEN 274
|
||||
#define TK_IS 275
|
||||
#define TK_NK_LT 276
|
||||
#define TK_NK_GT 277
|
||||
#define TK_NK_LE 278
|
||||
#define TK_NK_GE 279
|
||||
#define TK_NK_NE 280
|
||||
#define TK_MATCH 281
|
||||
#define TK_NMATCH 282
|
||||
#define TK_CONTAINS 283
|
||||
#define TK_IN 284
|
||||
#define TK_JOIN 285
|
||||
#define TK_INNER 286
|
||||
#define TK_LEFT 287
|
||||
#define TK_RIGHT 288
|
||||
#define TK_OUTER 289
|
||||
#define TK_SEMI 290
|
||||
#define TK_ANTI 291
|
||||
#define TK_ASOF 292
|
||||
#define TK_WINDOW 293
|
||||
#define TK_WINDOW_OFFSET 294
|
||||
#define TK_JLIMIT 295
|
||||
#define TK_SELECT 296
|
||||
#define TK_NK_HINT 297
|
||||
#define TK_DISTINCT 298
|
||||
#define TK_WHERE 299
|
||||
#define TK_PARTITION 300
|
||||
#define TK_BY 301
|
||||
#define TK_SESSION 302
|
||||
#define TK_STATE_WINDOW 303
|
||||
#define TK_EVENT_WINDOW 304
|
||||
#define TK_COUNT_WINDOW 305
|
||||
#define TK_SLIDING 306
|
||||
#define TK_FILL 307
|
||||
#define TK_VALUE 308
|
||||
#define TK_VALUE_F 309
|
||||
#define TK_NONE 310
|
||||
#define TK_PREV 311
|
||||
#define TK_NULL_F 312
|
||||
#define TK_LINEAR 313
|
||||
#define TK_NEXT 314
|
||||
#define TK_HAVING 315
|
||||
#define TK_RANGE 316
|
||||
#define TK_EVERY 317
|
||||
#define TK_ORDER 318
|
||||
#define TK_SLIMIT 319
|
||||
#define TK_SOFFSET 320
|
||||
#define TK_LIMIT 321
|
||||
#define TK_OFFSET 322
|
||||
#define TK_ASC 323
|
||||
#define TK_NULLS 324
|
||||
#define TK_ABORT 325
|
||||
#define TK_AFTER 326
|
||||
#define TK_ATTACH 327
|
||||
#define TK_BEFORE 328
|
||||
#define TK_BEGIN 329
|
||||
#define TK_BITAND 330
|
||||
#define TK_BITNOT 331
|
||||
#define TK_BITOR 332
|
||||
#define TK_BLOCKS 333
|
||||
#define TK_CHANGE 334
|
||||
#define TK_COMMA 335
|
||||
#define TK_CONCAT 336
|
||||
#define TK_CONFLICT 337
|
||||
#define TK_COPY 338
|
||||
#define TK_DEFERRED 339
|
||||
#define TK_DELIMITERS 340
|
||||
#define TK_DETACH 341
|
||||
#define TK_DIVIDE 342
|
||||
#define TK_DOT 343
|
||||
#define TK_EACH 344
|
||||
#define TK_FAIL 345
|
||||
#define TK_FILE 346
|
||||
#define TK_FOR 347
|
||||
#define TK_GLOB 348
|
||||
#define TK_ID 349
|
||||
#define TK_IMMEDIATE 350
|
||||
#define TK_IMPORT 351
|
||||
#define TK_INITIALLY 352
|
||||
#define TK_INSTEAD 353
|
||||
#define TK_ISNULL 354
|
||||
#define TK_MODULES 355
|
||||
#define TK_NK_BITNOT 356
|
||||
#define TK_NK_SEMI 357
|
||||
#define TK_NOTNULL 358
|
||||
#define TK_OF 359
|
||||
#define TK_PLUS 360
|
||||
#define TK_PRIVILEGE 361
|
||||
#define TK_RAISE 362
|
||||
#define TK_RESTRICT 363
|
||||
#define TK_ROW 364
|
||||
#define TK_STAR 365
|
||||
#define TK_STATEMENT 366
|
||||
#define TK_STRICT 367
|
||||
#define TK_STRING 368
|
||||
#define TK_TIMES 369
|
||||
#define TK_VALUES 370
|
||||
#define TK_VARIABLE 371
|
||||
#define TK_WAL 372
|
||||
#define TK_ENCODE 373
|
||||
#define TK_COMPRESS 374
|
||||
#define TK_LEVEL 375
|
||||
|
||||
|
||||
|
||||
#define TK_NK_SPACE 600
|
||||
#define TK_NK_COMMENT 601
|
||||
#define TK_NK_ILLEGAL 602
|
||||
#define TK_NK_SPACE 600
|
||||
#define TK_NK_COMMENT 601
|
||||
#define TK_NK_ILLEGAL 602
|
||||
// #define TK_NK_HEX 603 // hex number 0x123
|
||||
#define TK_NK_OCT 604 // oct number
|
||||
// #define TK_NK_BIN 605 // bin format data 0b111
|
||||
|
@ -398,6 +405,7 @@
|
|||
#define TK_PARA_TABLES_SORT 610
|
||||
#define TK_SMALLDATA_TS_SORT 611
|
||||
#define TK_HASH_JOIN 612
|
||||
#define TK_SKIP_TSMA 613
|
||||
|
||||
#define TK_NK_NIL 65535
|
||||
|
||||
|
|
|
@ -268,9 +268,11 @@ typedef struct {
|
|||
#define IS_MATHABLE_TYPE(_t) \
|
||||
(IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
|
||||
|
||||
#define IS_VAR_DATA_TYPE(t) \
|
||||
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON) || ((t) == TSDB_DATA_TYPE_GEOMETRY))
|
||||
#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR))
|
||||
#define IS_VAR_DATA_TYPE(t) \
|
||||
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR) || \
|
||||
((t) == TSDB_DATA_TYPE_JSON) || ((t) == TSDB_DATA_TYPE_GEOMETRY))
|
||||
#define IS_STR_DATA_TYPE(t) \
|
||||
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR))
|
||||
|
||||
#define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX)
|
||||
#define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX)
|
||||
|
@ -340,13 +342,28 @@ typedef struct tDataTypeDescriptor {
|
|||
int32_t nBuf);
|
||||
} tDataTypeDescriptor;
|
||||
|
||||
typedef struct tDataTypeCompress {
|
||||
int16_t type;
|
||||
int16_t nameLen;
|
||||
int32_t bytes;
|
||||
char *name;
|
||||
int64_t minValue;
|
||||
int64_t maxValue;
|
||||
int32_t (*compFunc)(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
int32_t (*decompFunc)(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
} tDataTypeCompress;
|
||||
|
||||
extern tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX];
|
||||
bool isValidDataType(int32_t type);
|
||||
extern tDataTypeCompress tDataCompress[TSDB_DATA_TYPE_MAX];
|
||||
|
||||
bool isValidDataType(int32_t type);
|
||||
|
||||
int32_t operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type);
|
||||
void assignVal(char *val, const char *src, int32_t len, int32_t type);
|
||||
void *getDataMin(int32_t type, void* value);
|
||||
void *getDataMax(int32_t type, void* value);
|
||||
void assignVal(char *val, const char *src, int32_t len, int32_t type);
|
||||
void *getDataMin(int32_t type, void *value);
|
||||
void *getDataMax(int32_t type, void *value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -94,6 +94,8 @@ typedef struct SCatalogReq {
|
|||
SArray* pTableCfg; // element is SNAME
|
||||
SArray* pTableTag; // element is SNAME
|
||||
SArray* pView; // element is STablesReq
|
||||
SArray* pTableTSMAs; // element is STablesReq
|
||||
SArray* pTSMAs; // element is STablesReq
|
||||
bool qNodeRequired; // valid qnode
|
||||
bool dNodeRequired; // valid dnode
|
||||
bool svrVerRequired;
|
||||
|
@ -122,6 +124,8 @@ typedef struct SMetaData {
|
|||
SArray* pTableTag; // pRes = SArray<STagVal>*
|
||||
SArray* pDnodeList; // pRes = SArray<SEpSet>*
|
||||
SArray* pView; // pRes = SViewMeta*
|
||||
SArray* pTableTsmas; // pRes = SArray<STableTSMAInfo*>
|
||||
SArray* pTsmas; // pRes = SArray<STableTSMAInfo*>
|
||||
SMetaRes* pSvrVer; // pRes = char*
|
||||
} SMetaData;
|
||||
|
||||
|
@ -130,9 +134,11 @@ typedef struct SCatalogCfg {
|
|||
uint32_t maxViewCacheNum;
|
||||
uint32_t maxDBCacheNum;
|
||||
uint32_t maxUserCacheNum;
|
||||
uint32_t maxTSMACacheNum;
|
||||
uint32_t dbRentSec;
|
||||
uint32_t stbRentSec;
|
||||
uint32_t viewRentSec;
|
||||
uint32_t tsmaRentSec;
|
||||
} SCatalogCfg;
|
||||
|
||||
typedef struct SSTableVersion {
|
||||
|
@ -152,6 +158,7 @@ typedef struct SDbCacheInfo {
|
|||
int32_t cfgVersion;
|
||||
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
|
||||
int64_t stateTs;
|
||||
int32_t tsmaVersion;
|
||||
} SDbCacheInfo;
|
||||
|
||||
typedef struct SDynViewVersion {
|
||||
|
@ -167,6 +174,14 @@ typedef struct SViewVersion {
|
|||
int32_t version;
|
||||
} SViewVersion;
|
||||
|
||||
typedef struct STSMAVersion {
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
char tbName[TSDB_TABLE_NAME_LEN];
|
||||
char name[TSDB_TABLE_NAME_LEN];
|
||||
uint64_t dbId;
|
||||
uint64_t tsmaId;
|
||||
int32_t version;
|
||||
} STSMAVersion;
|
||||
|
||||
typedef struct STbSVersion {
|
||||
char* tbFName;
|
||||
|
@ -342,6 +357,8 @@ int32_t catalogGetExpiredDBs(SCatalog* pCatalog, SDbCacheInfo** dbs, uint32_t* n
|
|||
|
||||
int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion** users, uint32_t* num);
|
||||
|
||||
int32_t catalogGetExpiredTsmas(SCatalog* pCtg, STSMAVersion** tsmas, uint32_t* num);
|
||||
|
||||
int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, SDbCfgInfo* pDbCfg);
|
||||
|
||||
int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char* indexName, SIndexInfo* pInfo);
|
||||
|
@ -388,6 +405,16 @@ int32_t ctgdEnableDebug(char* option, bool enable);
|
|||
|
||||
int32_t ctgdHandleDbgCommand(char* command);
|
||||
|
||||
int32_t catalogAsyncUpdateTSMA(SCatalog* pCtg, STableTSMAInfo** pTsma, int32_t tsmaVersion);
|
||||
|
||||
int32_t catalogUpdateTSMA(SCatalog* pCtg, STableTSMAInfo** ppTsma);
|
||||
|
||||
int32_t catalogRemoveTSMA(SCatalog* pCtg, const STableTSMAInfo* pTsma);
|
||||
|
||||
int32_t catalogGetTableTsmas(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes);
|
||||
|
||||
int32_t catalogGetTsma(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTsmaName, STableTSMAInfo** pTsma);
|
||||
|
||||
/**
|
||||
* Destroy catalog and relase all resources
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _CRYPT_H_
|
||||
#define _CRYPT_H_
|
||||
#include "tdef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SCryptOpts{
|
||||
int32_t len;
|
||||
char* source;
|
||||
char* result;
|
||||
int32_t unitLen;
|
||||
unsigned char key[17];
|
||||
}SCryptOpts;
|
||||
|
||||
int32_t CBC_Decrypt(SCryptOpts *opts);
|
||||
int32_t CBC_Encrypt(SCryptOpts *opts);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _CRYPT_H_
|
|
@ -78,7 +78,9 @@ typedef struct SMetaEntry {
|
|||
} smaEntry;
|
||||
};
|
||||
|
||||
uint8_t* pBuf;
|
||||
uint8_t* pBuf;
|
||||
|
||||
SColCmprWrapper colCmpr; // col compress alg
|
||||
} SMetaEntry;
|
||||
|
||||
typedef struct SMetaReader {
|
||||
|
@ -368,7 +370,8 @@ typedef struct SStateStore {
|
|||
int32_t (*streamStateSessionAllocWinBuffByNextPosition)(SStreamState* pState, SStreamStateCur* pCur,
|
||||
const SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||
|
||||
int32_t (*streamStateCountWinAddIfNotExist)(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** ppVal, int32_t* pVLen);
|
||||
int32_t (*streamStateCountWinAddIfNotExist)(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount,
|
||||
void** ppVal, int32_t* pVLen);
|
||||
int32_t (*streamStateCountWinAdd)(SStreamState* pState, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||
|
||||
SUpdateInfo* (*updateInfoInit)(int64_t interval, int32_t precision, int64_t watermark, bool igUp);
|
||||
|
|
|
@ -88,6 +88,7 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_LTRIM,
|
||||
FUNCTION_TYPE_RTRIM,
|
||||
FUNCTION_TYPE_SUBSTR,
|
||||
FUNCTION_TYPE_MD5,
|
||||
|
||||
// conversion function
|
||||
FUNCTION_TYPE_CAST = 2000,
|
||||
|
@ -164,6 +165,18 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_STDDEV_MERGE,
|
||||
FUNCTION_TYPE_IRATE_PARTIAL,
|
||||
FUNCTION_TYPE_IRATE_MERGE,
|
||||
FUNCTION_TYPE_AVG_STATE,
|
||||
FUNCTION_TYPE_AVG_STATE_MERGE,
|
||||
FUNCTION_TYPE_FIRST_STATE,
|
||||
FUNCTION_TYPE_FIRST_STATE_MERGE,
|
||||
FUNCTION_TYPE_LAST_STATE,
|
||||
FUNCTION_TYPE_LAST_STATE_MERGE,
|
||||
FUNCTION_TYPE_SPREAD_STATE,
|
||||
FUNCTION_TYPE_SPREAD_STATE_MERGE,
|
||||
FUNCTION_TYPE_STDDEV_STATE,
|
||||
FUNCTION_TYPE_STDDEV_STATE_MERGE,
|
||||
FUNCTION_TYPE_HYPERLOGLOG_STATE,
|
||||
FUNCTION_TYPE_HYPERLOGLOG_STATE_MERGE,
|
||||
|
||||
// geometry functions
|
||||
FUNCTION_TYPE_GEOM_FROM_TEXT = 4250,
|
||||
|
@ -271,6 +284,13 @@ bool fmIsInvertible(int32_t funcId);
|
|||
|
||||
char* fmGetFuncName(int32_t funcId);
|
||||
|
||||
bool fmIsTSMASupportedFunc(func_id_t funcId);
|
||||
int32_t fmCreateStateFuncs(SNodeList* pFuncs);
|
||||
int32_t fmCreateStateMergeFuncs(SNodeList* pFuncs);
|
||||
int32_t fmGetFuncId(const char* name);
|
||||
bool fmIsMyStateFunc(int32_t funcId, int32_t stateFuncId);
|
||||
bool fmIsCountLikeFunc(int32_t funcId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -23,10 +23,12 @@ extern "C" {
|
|||
#include "query.h"
|
||||
#include "querynodes.h"
|
||||
|
||||
#define DESCRIBE_RESULT_COLS 4
|
||||
#define DESCRIBE_RESULT_FIELD_LEN (TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE)
|
||||
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
|
||||
#define DESCRIBE_RESULT_NOTE_LEN (16 + VARSTR_HEADER_SIZE)
|
||||
#define DESCRIBE_RESULT_COLS 4
|
||||
#define DESCRIBE_RESULT_COLS_COMPRESS 7
|
||||
#define DESCRIBE_RESULT_FIELD_LEN (TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE)
|
||||
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
|
||||
#define DESCRIBE_RESULT_NOTE_LEN (16 + VARSTR_HEADER_SIZE)
|
||||
#define DESCRIBE_RESULT_COPRESS_OPTION_LEN (TSDB_CL_COMPRESS_OPTION_LEN + VARSTR_HEADER_SIZE)
|
||||
|
||||
#define SHOW_CREATE_DB_RESULT_COLS 2
|
||||
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
|
||||
|
@ -40,13 +42,12 @@ extern "C" {
|
|||
#define SHOW_CREATE_VIEW_RESULT_FIELD1_LEN (TSDB_VIEW_FNAME_LEN + 4 + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_CREATE_VIEW_RESULT_FIELD2_LEN (TSDB_MAX_ALLOWED_SQL_LEN + VARSTR_HEADER_SIZE)
|
||||
|
||||
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 3
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE)
|
||||
|
||||
#define COMPACT_DB_RESULT_COLS 3
|
||||
#define COMPACT_DB_RESULT_COLS 3
|
||||
#define COMPACT_DB_RESULT_FIELD1_LEN 32
|
||||
#define COMPACT_DB_RESULT_FIELD3_LEN 128
|
||||
|
||||
|
@ -69,7 +70,9 @@ typedef struct SDatabaseOptions {
|
|||
int8_t cacheModel;
|
||||
int32_t cacheLastSize;
|
||||
int8_t compressionLevel;
|
||||
int8_t encryptAlgorithm;
|
||||
int32_t daysPerFile;
|
||||
char encryptAlgorithmStr[TSDB_ENCRYPT_ALGO_STR_LEN];
|
||||
SValueNode* pDaysPerFile;
|
||||
int32_t fsyncPeriod;
|
||||
int32_t maxRowsPerBlock;
|
||||
|
@ -172,13 +175,21 @@ typedef struct STableOptions {
|
|||
SNodeList* pSma;
|
||||
} STableOptions;
|
||||
|
||||
typedef struct SColumnOptions {
|
||||
ENodeType type;
|
||||
bool commentNull;
|
||||
char comment[TSDB_CL_COMMENT_LEN];
|
||||
char encode[TSDB_CL_COMPRESS_OPTION_LEN];
|
||||
char compress[TSDB_CL_COMPRESS_OPTION_LEN];
|
||||
char compressLevel[TSDB_CL_COMPRESS_OPTION_LEN];
|
||||
bool bPrimaryKey;
|
||||
} SColumnOptions;
|
||||
typedef struct SColumnDefNode {
|
||||
ENodeType type;
|
||||
char colName[TSDB_COL_NAME_LEN];
|
||||
SDataType dataType;
|
||||
char comments[TSDB_TB_COMMENT_LEN];
|
||||
SNode* pOptions;
|
||||
bool sma;
|
||||
bool is_pk;
|
||||
} SColumnDefNode;
|
||||
|
||||
typedef struct SCreateTableStmt {
|
||||
|
@ -213,11 +224,13 @@ typedef struct SDropTableClause {
|
|||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
bool ignoreNotExists;
|
||||
SArray* pTsmas;
|
||||
} SDropTableClause;
|
||||
|
||||
typedef struct SDropTableStmt {
|
||||
ENodeType type;
|
||||
SNodeList* pTables;
|
||||
bool withTsma;
|
||||
} SDropTableStmt;
|
||||
|
||||
typedef struct SDropSuperTableStmt {
|
||||
|
@ -228,36 +241,37 @@ typedef struct SDropSuperTableStmt {
|
|||
} SDropSuperTableStmt;
|
||||
|
||||
typedef struct SAlterTableStmt {
|
||||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
int8_t alterType;
|
||||
char colName[TSDB_COL_NAME_LEN];
|
||||
char newColName[TSDB_COL_NAME_LEN];
|
||||
STableOptions* pOptions;
|
||||
SDataType dataType;
|
||||
SValueNode* pVal;
|
||||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
int8_t alterType;
|
||||
char colName[TSDB_COL_NAME_LEN];
|
||||
char newColName[TSDB_COL_NAME_LEN];
|
||||
STableOptions* pOptions;
|
||||
SDataType dataType;
|
||||
SValueNode* pVal;
|
||||
SColumnOptions* pColOptions;
|
||||
} SAlterTableStmt;
|
||||
|
||||
typedef struct SCreateUserStmt {
|
||||
ENodeType type;
|
||||
char userName[TSDB_USER_LEN];
|
||||
char password[TSDB_USET_PASSWORD_LEN];
|
||||
int8_t sysinfo;
|
||||
int32_t numIpRanges;
|
||||
ENodeType type;
|
||||
char userName[TSDB_USER_LEN];
|
||||
char password[TSDB_USET_PASSWORD_LEN];
|
||||
int8_t sysinfo;
|
||||
int32_t numIpRanges;
|
||||
SIpV4Range* pIpRanges;
|
||||
|
||||
SNodeList* pNodeListIpRanges;
|
||||
} SCreateUserStmt;
|
||||
|
||||
typedef struct SAlterUserStmt {
|
||||
ENodeType type;
|
||||
char userName[TSDB_USER_LEN];
|
||||
int8_t alterType;
|
||||
char password[TSDB_USET_PASSWORD_LEN];
|
||||
int8_t enable;
|
||||
int8_t sysinfo;
|
||||
int32_t numIpRanges;
|
||||
ENodeType type;
|
||||
char userName[TSDB_USER_LEN];
|
||||
int8_t alterType;
|
||||
char password[TSDB_USET_PASSWORD_LEN];
|
||||
int8_t enable;
|
||||
int8_t sysinfo;
|
||||
int32_t numIpRanges;
|
||||
SIpV4Range* pIpRanges;
|
||||
|
||||
SNodeList* pNodeListIpRanges;
|
||||
|
@ -295,7 +309,7 @@ typedef struct SShowStmt {
|
|||
SNode* pDbName; // SValueNode
|
||||
SNode* pTbName; // SValueNode
|
||||
EOperatorType tableCondType;
|
||||
EShowKind showKind; // show databases: user/system, show tables: normal/child, others NULL
|
||||
EShowKind showKind; // show databases: user/system, show tables: normal/child, others NULL
|
||||
} SShowStmt;
|
||||
|
||||
typedef struct SShowCreateDatabaseStmt {
|
||||
|
@ -356,7 +370,7 @@ typedef struct SShowCompactsStmt {
|
|||
|
||||
typedef struct SShowCompactDetailsStmt {
|
||||
ENodeType type;
|
||||
SNode* pCompactId;
|
||||
SNode* pCompactId;
|
||||
} SShowCompactDetailsStmt;
|
||||
|
||||
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT, INDEX_TYPE_NORMAL } EIndexType;
|
||||
|
@ -534,20 +548,20 @@ typedef struct SDropFunctionStmt {
|
|||
} SDropFunctionStmt;
|
||||
|
||||
typedef struct SCreateViewStmt {
|
||||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char viewName[TSDB_VIEW_NAME_LEN];
|
||||
char* pQuerySql;
|
||||
bool orReplace;
|
||||
SNode* pQuery;
|
||||
SCMCreateViewReq createReq;
|
||||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char viewName[TSDB_VIEW_NAME_LEN];
|
||||
char* pQuerySql;
|
||||
bool orReplace;
|
||||
SNode* pQuery;
|
||||
SCMCreateViewReq createReq;
|
||||
} SCreateViewStmt;
|
||||
|
||||
typedef struct SDropViewStmt {
|
||||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char viewName[TSDB_VIEW_NAME_LEN];
|
||||
bool ignoreNotExists;
|
||||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char viewName[TSDB_VIEW_NAME_LEN];
|
||||
bool ignoreNotExists;
|
||||
} SDropViewStmt;
|
||||
|
||||
typedef struct SGrantStmt {
|
||||
|
@ -590,6 +604,34 @@ typedef struct SSplitVgroupStmt {
|
|||
int32_t vgId;
|
||||
} SSplitVgroupStmt;
|
||||
|
||||
typedef struct STSMAOptions {
|
||||
ENodeType type;
|
||||
SNodeList* pFuncs;
|
||||
SNodeList* pCols;
|
||||
SNode* pInterval;
|
||||
uint8_t tsPrecision;
|
||||
bool recursiveTsma; // true if create recursive tsma
|
||||
} STSMAOptions;
|
||||
|
||||
typedef struct SCreateTSMAStmt {
|
||||
ENodeType type;
|
||||
bool ignoreExists;
|
||||
char tsmaName[TSDB_TABLE_NAME_LEN];
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN]; // base tb name or base tsma name
|
||||
char originalTbName[TSDB_TABLE_NAME_LEN];
|
||||
STSMAOptions* pOptions;
|
||||
SNode* pPrevQuery;
|
||||
SMCreateSmaReq* pReq;
|
||||
} SCreateTSMAStmt;
|
||||
|
||||
typedef struct SDropTSMAStmt {
|
||||
ENodeType type;
|
||||
bool ignoreNotExists;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char tsmaName[TSDB_TABLE_NAME_LEN];
|
||||
} SDropTSMAStmt;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -123,6 +123,7 @@ int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
|||
int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||
int32_t nodesListMakeStrictAppendList(SNodeList** pTarget, SNodeList* pSrc);
|
||||
int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
|
||||
int32_t nodesListMakePushFront(SNodeList** pList, SNode* pNode);
|
||||
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
||||
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||
void nodesListInsertListAfterPos(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||
|
@ -169,6 +170,7 @@ int32_t nodesMsgToNode(const char* pStr, int32_t len, SNode** pNode);
|
|||
int32_t nodesNodeToSQL(SNode* pNode, char* buf, int32_t bufSize, int32_t* len);
|
||||
char* nodesGetNameFromColumnNode(SNode* pNode);
|
||||
int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots);
|
||||
void nodesSortList(SNodeList** pList, int32_t (*)(SNode* pNode1, SNode* pNode2));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -109,6 +109,9 @@ typedef struct SScanLogicNode {
|
|||
int8_t igExpired;
|
||||
int8_t igCheckUpdate;
|
||||
SArray* pSmaIndexes;
|
||||
SArray* pTsmas;
|
||||
SArray* pTsmaTargetTbVgInfo;
|
||||
SArray* pTsmaTargetTbInfo;
|
||||
SNodeList* pGroupTags;
|
||||
bool groupSort;
|
||||
SNodeList* pTags; // for create stream
|
||||
|
@ -124,6 +127,7 @@ typedef struct SScanLogicNode {
|
|||
SArray* pFuncTypes; // for last, last_row
|
||||
bool paraTablesSort; // for table merge scan
|
||||
bool smallDataTsSort; // disable row id sort for table merge scan
|
||||
bool needSplit;
|
||||
} SScanLogicNode;
|
||||
|
||||
typedef struct SJoinLogicNode {
|
||||
|
@ -169,6 +173,7 @@ typedef struct SAggLogicNode {
|
|||
bool isGroupTb;
|
||||
bool isPartTb; // true if partition keys has tbname
|
||||
bool hasGroup;
|
||||
SNodeList *pTsmaSubplans;
|
||||
} SAggLogicNode;
|
||||
|
||||
typedef struct SProjectLogicNode {
|
||||
|
@ -252,7 +257,9 @@ typedef struct SMergeLogicNode {
|
|||
SNodeList* pMergeKeys;
|
||||
SNodeList* pInputs;
|
||||
int32_t numOfChannels;
|
||||
int32_t numOfSubplans;
|
||||
int32_t srcGroupId;
|
||||
int32_t srcEndGroupId;
|
||||
bool colsMerge;
|
||||
bool needSort;
|
||||
bool groupSort;
|
||||
|
@ -305,6 +312,7 @@ typedef struct SWindowLogicNode {
|
|||
bool isPartTb;
|
||||
int64_t windowCount;
|
||||
int64_t windowSliding;
|
||||
SNodeList* pTsmaSubplans;
|
||||
} SWindowLogicNode;
|
||||
|
||||
typedef struct SFillLogicNode {
|
||||
|
@ -577,6 +585,7 @@ typedef struct SAggPhysiNode {
|
|||
SNodeList* pAggFuncs;
|
||||
bool mergeDataBlock;
|
||||
bool groupKeyOptimized;
|
||||
bool hasCountLikeFunc;
|
||||
} SAggPhysiNode;
|
||||
|
||||
typedef struct SDownstreamSourceNode {
|
||||
|
@ -606,7 +615,9 @@ typedef struct SMergePhysiNode {
|
|||
SNodeList* pMergeKeys;
|
||||
SNodeList* pTargets;
|
||||
int32_t numOfChannels;
|
||||
int32_t numOfSubplans;
|
||||
int32_t srcGroupId;
|
||||
int32_t srcEndGroupId;
|
||||
bool groupSort;
|
||||
bool ignoreGroupId;
|
||||
bool inputWithGroupId;
|
||||
|
|
|
@ -142,6 +142,7 @@ typedef enum EHintOption {
|
|||
HINT_PARA_TABLES_SORT,
|
||||
HINT_SMALLDATA_TS_SORT,
|
||||
HINT_HASH_JOIN,
|
||||
HINT_SKIP_TSMA,
|
||||
} EHintOption;
|
||||
|
||||
typedef struct SHintNode {
|
||||
|
@ -177,6 +178,8 @@ typedef struct SFunctionNode {
|
|||
int32_t udfBufSize;
|
||||
bool hasPk;
|
||||
int32_t pkBytes;
|
||||
bool hasOriginalFunc;
|
||||
int32_t originalFuncId;
|
||||
} SFunctionNode;
|
||||
|
||||
typedef struct STableNode {
|
||||
|
@ -190,6 +193,11 @@ typedef struct STableNode {
|
|||
|
||||
struct STableMeta;
|
||||
|
||||
typedef struct STsmaTargetCTbInfo {
|
||||
char tableName[TSDB_TABLE_NAME_LEN]; // child table or normal table name
|
||||
uint64_t uid;
|
||||
} STsmaTargetTbInfo;
|
||||
|
||||
typedef struct SRealTableNode {
|
||||
STableNode table; // QUERY_NODE_REAL_TABLE
|
||||
struct STableMeta* pMeta;
|
||||
|
@ -198,6 +206,9 @@ typedef struct SRealTableNode {
|
|||
double ratio;
|
||||
SArray* pSmaIndexes;
|
||||
int8_t cacheLastMode;
|
||||
SArray* pTsmas;
|
||||
SArray* tsmaTargetTbVgInfo; // SArray<SVgroupsInfo*>, used for child table or normal table only
|
||||
SArray* tsmaTargetTbInfo; // SArray<STsmaTargetTbInfo>, used for child table or normal table only
|
||||
} SRealTableNode;
|
||||
|
||||
typedef struct STempTableNode {
|
||||
|
|
|
@ -152,7 +152,8 @@ int32_t smlBindData(SQuery* handle, bool dataFormat, SArray* tags, SArray* colsS
|
|||
STableMeta* pTableMeta, char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl,
|
||||
char* msgBuf, int32_t msgBufLen);
|
||||
int32_t smlBuildOutput(SQuery* handle, SHashObj* pVgHash);
|
||||
int rawBlockBindData(SQuery *query, STableMeta* pTableMeta, void* data, SVCreateTbReq** pCreateTb, TAOS_FIELD *fields, int numFields, bool needChangeLength);
|
||||
int rawBlockBindData(SQuery *query, STableMeta* pTableMeta, void* data, SVCreateTbReq** pCreateTb, TAOS_FIELD *fields,
|
||||
int numFields, bool needChangeLength, char* errstr, int32_t errstrLen);
|
||||
|
||||
int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
|
||||
SArray* serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap);
|
||||
|
|
|
@ -118,6 +118,7 @@ typedef struct STableMeta {
|
|||
int32_t sversion;
|
||||
int32_t tversion;
|
||||
STableComInfo tableInfo;
|
||||
SSchemaExt* schemaExt; // There is no additional memory allocation, and the pointer is fixed to the next address of the schema content.
|
||||
SSchema schema[];
|
||||
} STableMeta;
|
||||
#pragma pack(pop)
|
||||
|
@ -331,7 +332,8 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
|||
|
||||
#define NEED_CLIENT_RM_TBLMETA_REQ(_type) \
|
||||
((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_MND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \
|
||||
(_type) == TDMT_MND_DROP_STB || (_type) == TDMT_MND_CREATE_VIEW || (_type) == TDMT_MND_DROP_VIEW)
|
||||
(_type) == TDMT_MND_DROP_STB || (_type) == TDMT_MND_CREATE_VIEW || (_type) == TDMT_MND_DROP_VIEW || \
|
||||
(_type) == TDMT_MND_CREATE_TSMA || (_type) == TDMT_MND_DROP_TSMA || (_type) == TDMT_MND_DROP_TB_WITH_TSMA)
|
||||
|
||||
#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \
|
||||
(SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || \
|
||||
|
|
|
@ -72,6 +72,7 @@ int32_t upperFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOut
|
|||
int32_t ltrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t rtrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t md5Function(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOutput);
|
||||
|
||||
/* Conversion functions */
|
||||
int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <time.h>
|
||||
#ifndef _SM4_H_
|
||||
#define _SM4_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int SM4_ECB_Encrypt( unsigned char *pKey,
|
||||
unsigned int KeyLen,
|
||||
unsigned char *pInData,
|
||||
unsigned int inDataLen,
|
||||
unsigned char *pOutData,
|
||||
unsigned int *pOutDataLen);
|
||||
|
||||
int SM4_ECB_Decrypt( unsigned char *pKey,
|
||||
unsigned int KeyLen,
|
||||
unsigned char *pInData,
|
||||
unsigned int inDataLen,
|
||||
unsigned char *pOutData,
|
||||
unsigned int *pOutDataLen);
|
||||
|
||||
int SM4_CBC_Encrypt( unsigned char *pKey,
|
||||
unsigned int KeyLen,
|
||||
unsigned char *pIV,
|
||||
unsigned int ivLen,
|
||||
unsigned char *pInData,
|
||||
unsigned int inDataLen,
|
||||
unsigned char *pOutData,
|
||||
unsigned int *pOutDataLen);
|
||||
|
||||
int SM4_CBC_Decrypt(unsigned char *pKey,
|
||||
unsigned int KeyLen,
|
||||
unsigned char *pIV,
|
||||
unsigned int ivLen,
|
||||
unsigned char *pInData,
|
||||
unsigned int inDataLen,
|
||||
unsigned char *pOutData,
|
||||
unsigned int *pOutDataLen);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _SM4_H_
|
|
@ -83,7 +83,8 @@ int32_t streamStateClearBuff(SStreamState* pState, void* pVal);
|
|||
void streamStateFreeVal(void* val);
|
||||
|
||||
// count window
|
||||
int32_t streamStateCountWinAddIfNotExist(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** ppVal, int32_t* pVLen);
|
||||
int32_t streamStateCountWinAddIfNotExist(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** ppVal,
|
||||
int32_t* pVLen);
|
||||
int32_t streamStateCountWinAdd(SStreamState* pState, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||
|
||||
SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key);
|
||||
|
@ -128,6 +129,8 @@ typedef struct SStateSessionKey {
|
|||
typedef struct SStreamValue {
|
||||
int64_t unixTimestamp;
|
||||
int32_t len;
|
||||
int32_t rawLen;
|
||||
int8_t compress;
|
||||
char* data;
|
||||
} SStreamValue;
|
||||
|
||||
|
|
|
@ -247,11 +247,11 @@ typedef enum {
|
|||
TASK_SCANHISTORY_CONT = 0x1,
|
||||
TASK_SCANHISTORY_QUIT = 0x2,
|
||||
TASK_SCANHISTORY_REXEC = 0x3,
|
||||
} EScanHistoryRet;
|
||||
} EScanHistoryCode;
|
||||
|
||||
typedef struct {
|
||||
EScanHistoryRet ret;
|
||||
int32_t idleTime;
|
||||
EScanHistoryCode ret;
|
||||
int32_t idleTime;
|
||||
} SScanhistoryDataInfo;
|
||||
|
||||
typedef struct {
|
||||
|
@ -384,8 +384,8 @@ typedef struct SSinkRecorder {
|
|||
|
||||
typedef struct STaskExecStatisInfo {
|
||||
int64_t created;
|
||||
int64_t init;
|
||||
int64_t start;
|
||||
int64_t checkTs;
|
||||
int64_t readyTs;
|
||||
int64_t startCheckpointId;
|
||||
int64_t startCheckpointVer;
|
||||
|
||||
|
@ -432,6 +432,22 @@ typedef struct SUpstreamInfo {
|
|||
int32_t numOfClosed;
|
||||
} SUpstreamInfo;
|
||||
|
||||
typedef struct SDownstreamStatusInfo {
|
||||
int64_t reqId;
|
||||
int32_t taskId;
|
||||
int64_t rspTs;
|
||||
int32_t status;
|
||||
} SDownstreamStatusInfo;
|
||||
|
||||
typedef struct STaskCheckInfo {
|
||||
SArray* pList;
|
||||
int64_t startTs;
|
||||
int32_t notReadyTasks;
|
||||
int32_t inCheckProcess;
|
||||
tmr_h checkRspTmr;
|
||||
TdThreadMutex checkInfoLock;
|
||||
} STaskCheckInfo;
|
||||
|
||||
struct SStreamTask {
|
||||
int64_t ver;
|
||||
SStreamTaskId id;
|
||||
|
@ -455,14 +471,12 @@ struct SStreamTask {
|
|||
SStreamState* pState; // state backend
|
||||
SArray* pRspMsgList;
|
||||
SUpstreamInfo upstreamInfo;
|
||||
STaskCheckInfo taskCheckInfo;
|
||||
|
||||
// the followings attributes don't be serialized
|
||||
SScanhistorySchedInfo schedHistoryInfo;
|
||||
|
||||
int32_t notReadyTasks;
|
||||
int32_t numOfWaitingUpstream;
|
||||
int64_t checkReqId;
|
||||
SArray* checkReqIds; // shuffle
|
||||
int32_t refCnt;
|
||||
int32_t transferStateAlignCnt;
|
||||
struct SStreamMeta* pMeta;
|
||||
|
@ -478,7 +492,7 @@ typedef struct STaskStartInfo {
|
|||
int64_t startTs;
|
||||
int64_t readyTs;
|
||||
int32_t tasksWillRestart;
|
||||
int32_t taskStarting; // restart flag, sentinel to guard the restart procedure.
|
||||
int32_t startAllTasks; // restart flag, sentinel to guard the restart procedure.
|
||||
SHashObj* pReadyTaskSet; // tasks that are all ready for running stream processing
|
||||
SHashObj* pFailedTaskSet; // tasks that are done the check downstream process, may be successful or failed
|
||||
int64_t elapsedTime;
|
||||
|
@ -811,7 +825,7 @@ int32_t streamSendCheckRsp(const SStreamMeta* pMeta, const SStreamTaskCheckReq*
|
|||
int32_t streamProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRsp);
|
||||
int32_t streamLaunchFillHistoryTask(SStreamTask* pTask);
|
||||
int32_t streamStartScanHistoryAsync(SStreamTask* pTask, int8_t igUntreated);
|
||||
int32_t streamReExecScanHistoryFuture(SStreamTask* pTask, int32_t idleDuration);
|
||||
int32_t streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration);
|
||||
bool streamHistoryTaskSetVerRangeStep2(SStreamTask* pTask, int64_t latestVer);
|
||||
|
||||
int32_t streamQueueGetNumOfItems(const SStreamQueue* pQueue);
|
||||
|
@ -821,8 +835,6 @@ void streamTaskPause(SStreamMeta* pMeta, SStreamTask* pTask);
|
|||
void streamTaskResume(SStreamTask* pTask);
|
||||
int32_t streamTaskStop(SStreamTask* pTask);
|
||||
int32_t streamTaskSetUpstreamInfo(SStreamTask* pTask, const SStreamTask* pUpstreamTask);
|
||||
void streamTaskUpdateUpstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet);
|
||||
void streamTaskUpdateDownstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet);
|
||||
void streamTaskSetFixedDownstreamInfo(SStreamTask* pTask, const SStreamTask* pDownstreamTask);
|
||||
int32_t streamTaskReleaseState(SStreamTask* pTask);
|
||||
int32_t streamTaskReloadState(SStreamTask* pTask);
|
||||
|
@ -832,6 +844,15 @@ int32_t streamTaskSetDb(SStreamMeta* pMeta, void* pTask, char* key);
|
|||
bool streamTaskIsSinkTask(const SStreamTask* pTask);
|
||||
int32_t streamTaskSendCheckpointReq(SStreamTask* pTask);
|
||||
|
||||
int32_t streamTaskInitTaskCheckInfo(STaskCheckInfo* pInfo, STaskOutputInfo* pOutputInfo, int64_t startTs);
|
||||
int32_t streamTaskAddReqInfo(STaskCheckInfo* pInfo, int64_t reqId, int32_t taskId, const char* id);
|
||||
int32_t streamTaskUpdateCheckInfo(STaskCheckInfo* pInfo, int32_t taskId, int32_t status, int64_t rspTs, int64_t reqId,
|
||||
int32_t* pNotReady, const char* id);
|
||||
void streamTaskCleanCheckInfo(STaskCheckInfo* pInfo);
|
||||
int32_t streamTaskStartCheckDownstream(STaskCheckInfo* pInfo, const char* id);
|
||||
int32_t streamTaskCompleteCheck(STaskCheckInfo* pInfo, const char* id);
|
||||
int32_t streamTaskStartMonitorCheckRsp(SStreamTask* pTask);
|
||||
|
||||
void streamTaskStatusInit(STaskStatusEntry* pEntry, const SStreamTask* pTask);
|
||||
void streamTaskStatusCopy(STaskStatusEntry* pDst, const STaskStatusEntry* pSrc);
|
||||
|
||||
|
|
|
@ -57,6 +57,8 @@ typedef struct {
|
|||
int64_t retentionSize;
|
||||
int64_t segSize;
|
||||
EWalType level; // wal level
|
||||
int32_t encryptAlgorithm;
|
||||
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
||||
} SWalCfg;
|
||||
|
||||
typedef struct {
|
||||
|
@ -196,6 +198,7 @@ SWalReader *walOpenReader(SWal *, SWalFilterCond *pCond, int64_t id);
|
|||
void walCloseReader(SWalReader *pRead);
|
||||
void walReadReset(SWalReader *pReader);
|
||||
int32_t walReadVer(SWalReader *pRead, int64_t ver);
|
||||
void decryptBody(SWalCfg* cfg, SWalCkHead* pHead, int32_t plainBodyLen, const char* func);
|
||||
int32_t walReaderSeekVer(SWalReader *pRead, int64_t ver);
|
||||
int32_t walNextValidMsg(SWalReader *pRead);
|
||||
int64_t walReaderGetCurrentVer(const SWalReader *pReader);
|
||||
|
|
|
@ -22,6 +22,8 @@ extern "C" {
|
|||
|
||||
typedef wchar_t TdWchar;
|
||||
typedef int32_t TdUcs4;
|
||||
typedef void *iconv_t;
|
||||
typedef enum { M2C = 0, C2M } ConvType;
|
||||
|
||||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||
// When you want to use this feature, you should find or add the same function in the following section.
|
||||
|
@ -59,7 +61,10 @@ int64_t taosStr2int64(const char *str);
|
|||
|
||||
int32_t taosConvInit(void);
|
||||
void taosConvDestroy();
|
||||
iconv_t taosAcquireConv(int32_t *idx, ConvType type);
|
||||
void taosReleaseConv(int32_t idx, iconv_t conv, ConvType type);
|
||||
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs);
|
||||
int32_t taosUcs4ToMbsEx(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, iconv_t conv);
|
||||
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len);
|
||||
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
||||
TdUcs4 *tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||
|
|
|
@ -33,8 +33,16 @@ extern "C" {
|
|||
const char* tstrerror(int32_t err);
|
||||
const char* terrstr();
|
||||
|
||||
#define ERR_MSG_LEN 256
|
||||
|
||||
char* taosGetErrMsgReturn();
|
||||
char* taosGetErrMsg();
|
||||
int32_t* taosGetErrno();
|
||||
#define terrno (*taosGetErrno())
|
||||
#define terrMsg (taosGetErrMsg())
|
||||
|
||||
#define SET_ERROR_MSG(MSG, ...) \
|
||||
snprintf(terrMsg, ERR_MSG_LEN, MSG, ##__VA_ARGS__)
|
||||
|
||||
#define TSDB_CODE_SUCCESS 0
|
||||
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error
|
||||
|
@ -172,7 +180,9 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TSC_NO_EXEC_NODE TAOS_DEF_ERROR_CODE(0, 0X022E)
|
||||
#define TSDB_CODE_TSC_NOT_STABLE_ERROR TAOS_DEF_ERROR_CODE(0, 0X022F)
|
||||
#define TSDB_CODE_TSC_STMT_CACHE_ERROR TAOS_DEF_ERROR_CODE(0, 0X0230)
|
||||
#define TSDB_CODE_TSC_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0X0231)
|
||||
#define TSDB_CODE_TSC_ENCODE_PARAM_ERROR TAOS_DEF_ERROR_CODE(0, 0X0231)
|
||||
#define TSDB_CODE_TSC_ENCODE_PARAM_NULL TAOS_DEF_ERROR_CODE(0, 0X0232)
|
||||
#define TSDB_CODE_TSC_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0X02FF)
|
||||
|
||||
// mnode-common
|
||||
#define TSDB_CODE_MND_REQ_REJECTED TAOS_DEF_ERROR_CODE(0, 0x0300)
|
||||
|
@ -273,6 +283,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x036E)
|
||||
#define TSDB_CODE_MND_INVALID_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x036F)
|
||||
#define TSDB_CODE_MND_FIELD_VALUE_OVERFLOW TAOS_DEF_ERROR_CODE(0, 0x0370)
|
||||
#define TSDB_CODE_MND_COLUMN_COMPRESS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0371)
|
||||
|
||||
|
||||
// mnode-func
|
||||
|
@ -303,6 +314,8 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_DB_OPTION_UNCHANGED TAOS_DEF_ERROR_CODE(0, 0x038A) //
|
||||
#define TSDB_CODE_MND_DB_INDEX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x038B)
|
||||
#define TSDB_CODE_MND_DB_RETENTION_PERIOD_ZERO TAOS_DEF_ERROR_CODE(0, 0x038C)
|
||||
#define TSDB_CODE_MND_INCONSIST_ENCRYPT_KEY TAOS_DEF_ERROR_CODE(0, 0x038D)
|
||||
#define TSDB_CODE_MND_INVALID_ENCRYPT_KEY TAOS_DEF_ERROR_CODE(0, 0x038E)
|
||||
// #define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) // 2.x
|
||||
// #define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) // 2.x
|
||||
// #define TSDB_CODE_MND_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x0392) // 2.x
|
||||
|
@ -311,6 +324,7 @@ int32_t* taosGetErrno();
|
|||
// #define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0395) // 2.x
|
||||
#define TSDB_CODE_MND_DB_IN_CREATING TAOS_DEF_ERROR_CODE(0, 0x0396) //
|
||||
#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x039A)
|
||||
#define TSDB_CODE_MND_ENCRYPT_NOT_ALLOW_CHANGE TAOS_DEF_ERROR_CODE(0, 0x039B)
|
||||
|
||||
// mnode-node
|
||||
#define TSDB_CODE_MND_MNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
|
||||
|
@ -418,11 +432,24 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MNODE_NO_NEED_RESTORE TAOS_DEF_ERROR_CODE(0, 0x0415) // internal
|
||||
#define TSDB_CODE_DNODE_ONLY_USE_WHEN_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0416)
|
||||
#define TSDB_CODE_DNODE_NO_MACHINE_CODE TAOS_DEF_ERROR_CODE(0, 0x0417)
|
||||
#define TSDB_CODE_DNODE_NO_ENCRYPT_KEY TAOS_DEF_ERROR_CODE(0, 0x0418)
|
||||
#define TSDB_CODE_DNODE_INVALID_ENCRYPT_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0419)
|
||||
#define TSDB_CODE_DNODE_INVALID_ENCRYPTKEY TAOS_DEF_ERROR_CODE(0, 0x0420)
|
||||
#define TSDB_CODE_DNODE_ENCRYPTKEY_CHANGED TAOS_DEF_ERROR_CODE(0, 0x0421)
|
||||
#define TSDB_CODE_DNODE_INVALID_ENCRYPT_KLEN TAOS_DEF_ERROR_CODE(0, 0x0422)
|
||||
#define TSDB_CODE_DNODE_INVALID_STATUS_INTERVAL TAOS_DEF_ERROR_CODE(0, 0x0423)
|
||||
#define TSDB_CODE_DNODE_INVALID_TIMEZONE TAOS_DEF_ERROR_CODE(0, 0x0424)
|
||||
#define TSDB_CODE_DNODE_INVALID_CHARSET TAOS_DEF_ERROR_CODE(0, 0x0425)
|
||||
#define TSDB_CODE_DNODE_INVALID_LOCALE TAOS_DEF_ERROR_CODE(0, 0x0426)
|
||||
#define TSDB_CODE_DNODE_INVALID_TTL_CHG_ON_WR TAOS_DEF_ERROR_CODE(0, 0x0427)
|
||||
#define TSDB_CODE_DNODE_INVALID_EN_WHITELIST TAOS_DEF_ERROR_CODE(0, 0x0428)
|
||||
|
||||
// mnode-sma
|
||||
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
|
||||
#define TSDB_CODE_MND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0481)
|
||||
#define TSDB_CODE_MND_INVALID_SMA_OPTION TAOS_DEF_ERROR_CODE(0, 0x0482)
|
||||
#define TSDB_CODE_MND_INVALID_DROP_TSMA TAOS_DEF_ERROR_CODE(0, 0x0485)
|
||||
#define TSDB_CODE_MND_MAX_TSMA_NUM_EXCEEDED TAOS_DEF_ERROR_CODE(0, 0x0486)
|
||||
|
||||
// mnode-tag-indxe
|
||||
|
||||
|
@ -475,6 +502,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_VND_ALREADY_IS_VOTER TAOS_DEF_ERROR_CODE(0, 0x0533) // internal
|
||||
#define TSDB_CODE_VND_DIR_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0534)
|
||||
#define TSDB_CODE_VND_META_DATA_UNSAFE_DELETE TAOS_DEF_ERROR_CODE(0, 0x0535)
|
||||
#define TSDB_CODE_VND_COLUMN_COMPRESS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0536)
|
||||
#define TSDB_CODE_VND_ARB_NOT_SYNCED TAOS_DEF_ERROR_CODE(0, 0x0536) // internal
|
||||
|
||||
// tsdb
|
||||
|
@ -823,6 +851,12 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3103)
|
||||
#define TSDB_CODE_TSMA_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x3104)
|
||||
#define TSDB_CODE_TSMA_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x3105)
|
||||
#define TSDB_CODE_TSMA_INVALID_TB TAOS_DEF_ERROR_CODE(0, 0x3106)
|
||||
#define TSDB_CODE_TSMA_INVALID_INTERVAL TAOS_DEF_ERROR_CODE(0, 0x3107)
|
||||
#define TSDB_CODE_TSMA_INVALID_FUNC_PARAM TAOS_DEF_ERROR_CODE(0, 0x3108)
|
||||
#define TSDB_CODE_TSMA_UNSUPPORTED_FUNC TAOS_DEF_ERROR_CODE(0, 0x3109)
|
||||
#define TSDB_CODE_TSMA_MUST_BE_DROPPED TAOS_DEF_ERROR_CODE(0, 0x3110)
|
||||
#define TSDB_CODE_TSMA_NAME_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x3111)
|
||||
|
||||
//rsma
|
||||
#define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150)
|
||||
|
|
|
@ -83,6 +83,7 @@ int32_t compareLenBinaryVal(const void *pLeft, const void *pRight);
|
|||
|
||||
int32_t comparestrRegexMatch(const void *pLeft, const void *pRight);
|
||||
int32_t comparestrRegexNMatch(const void *pLeft, const void *pRight);
|
||||
void DestoryThreadLocalRegComp();
|
||||
|
||||
int32_t comparewcsRegexMatch(const void *pLeft, const void *pRight);
|
||||
int32_t comparewcsRegexNMatch(const void *pLeft, const void *pRight);
|
||||
|
|
|
@ -24,6 +24,20 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// start compress flag
|
||||
// |----l1 compAlg----|-----l2 compAlg---|---level--|
|
||||
// |------8bit--------|------16bit-------|---8bit---|
|
||||
#define COMPRESS_L1_TYPE_U32(type) (((type) >> 24) & 0xFF)
|
||||
#define COMPRESS_L2_TYPE_U32(type) (((type) >> 8) & 0xFFFF)
|
||||
#define COMPRESS_L2_TYPE_LEVEL_U32(type) ((type)&0xFF)
|
||||
// compress flag
|
||||
// |----l2lel--|----l2Alg---|---l1Alg--|
|
||||
// |----2bit---|----3bit----|---3bit---|
|
||||
#define COMPRESS_L1_TYPE_U8(type) ((type)&0x07)
|
||||
#define COMPRESS_L2_TYPE_U8(type) (((type) >> 3) & 0x07)
|
||||
#define COMPRESS_L2_TYPE_LEVEL_U8(type) (((type) >> 6) & 0x03)
|
||||
// end compress flag
|
||||
|
||||
#define COMP_OVERFLOW_BYTES 2
|
||||
#define BITS_PER_BYTE 8
|
||||
// Masks
|
||||
|
@ -58,15 +72,17 @@ extern "C" {
|
|||
#ifdef TD_TSZ
|
||||
extern bool lossyFloat;
|
||||
extern bool lossyDouble;
|
||||
int32_t tsCompressInit(char* lossyColumns, float fPrecision, double dPrecision, uint32_t maxIntervals, uint32_t intervals,
|
||||
int32_t ifAdtFse, const char* compressor);
|
||||
int32_t tsCompressInit(char *lossyColumns, float fPrecision, double dPrecision, uint32_t maxIntervals,
|
||||
uint32_t intervals, int32_t ifAdtFse, const char *compressor);
|
||||
|
||||
void tsCompressExit();
|
||||
void tsCompressExit();
|
||||
|
||||
int32_t tsCompressFloatLossyImp(const char *const input, const int32_t nelements, char *const output);
|
||||
int32_t tsDecompressFloatLossyImp(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output);
|
||||
int32_t tsDecompressFloatLossyImp(const char *const input, int32_t compressedSize, const int32_t nelements,
|
||||
char *const output);
|
||||
int32_t tsCompressDoubleLossyImp(const char *const input, const int32_t nelements, char *const output);
|
||||
int32_t tsDecompressDoubleLossyImp(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output);
|
||||
int32_t tsDecompressDoubleLossyImp(const char *const input, int32_t compressedSize, const int32_t nelements,
|
||||
char *const output);
|
||||
|
||||
static FORCE_INLINE int32_t tsCompressFloatLossy(const char *const input, int32_t inputSize, const int32_t nelements,
|
||||
char *const output, int32_t outputSize, char algorithm,
|
||||
|
@ -139,8 +155,58 @@ int32_t getWordLength(char type);
|
|||
int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, char *const output, const char type);
|
||||
int32_t tsDecompressFloatImplAvx512(const char *const input, const int32_t nelements, char *const output);
|
||||
int32_t tsDecompressFloatImplAvx2(const char *const input, const int32_t nelements, char *const output);
|
||||
int32_t tsDecompressTimestampAvx512(const char* const input, const int32_t nelements, char *const output, bool bigEndian);
|
||||
int32_t tsDecompressTimestampAvx2(const char* const input, const int32_t nelements, char *const output, bool bigEndian);
|
||||
int32_t tsDecompressTimestampAvx512(const char *const input, const int32_t nelements, char *const output,
|
||||
bool bigEndian);
|
||||
int32_t tsDecompressTimestampAvx2(const char *const input, const int32_t nelements, char *const output, bool bigEndian);
|
||||
|
||||
/*************************************************************************
|
||||
* REGULAR COMPRESSION 2
|
||||
*************************************************************************/
|
||||
int32_t tsCompressTimestamp2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg,
|
||||
void *pBuf, int32_t nBuf);
|
||||
int32_t tsDecompressTimestamp2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg,
|
||||
void *pBuf, int32_t nBuf);
|
||||
int32_t tsCompressFloat2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
int32_t tsDecompressFloat2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
int32_t tsCompressDouble2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
int32_t tsDecompressDouble2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg,
|
||||
void *pBuf, int32_t nBuf);
|
||||
int32_t tsCompressString2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
int32_t tsDecompressString2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg,
|
||||
void *pBuf, int32_t nBuf);
|
||||
int32_t tsCompressBool2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
int32_t tsDecompressBool2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
int32_t tsCompressTinyint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
int32_t tsDecompressTinyint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg,
|
||||
void *pBuf, int32_t nBuf);
|
||||
int32_t tsCompressSmallint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg,
|
||||
void *pBuf, int32_t nBuf);
|
||||
int32_t tsDecompressSmallint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg,
|
||||
void *pBuf, int32_t nBuf);
|
||||
int32_t tsCompressInt2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
int32_t tsDecompressInt2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
int32_t tsCompressBigint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
int32_t tsDecompressBigint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint32_t cmprAlg,
|
||||
void *pBuf, int32_t nBuf);
|
||||
// for internal usage
|
||||
int32_t getWordLength(char type);
|
||||
|
||||
int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, char *const output, const char type);
|
||||
int32_t tsDecompressFloatImplAvx512(const char *const input, const int32_t nelements, char *const output);
|
||||
int32_t tsDecompressFloatImplAvx2(const char *const input, const int32_t nelements, char *const output);
|
||||
int32_t tsDecompressTimestampAvx512(const char *const input, const int32_t nelements, char *const output,
|
||||
bool bigEndian);
|
||||
int32_t tsDecompressTimestampAvx2(const char *const input, const int32_t nelements, char *const output, bool bigEndian);
|
||||
|
||||
/*************************************************************************
|
||||
* STREAM COMPRESSION
|
||||
|
@ -153,6 +219,79 @@ int32_t tCompressStart(SCompressor *pCmprsor, int8_t type, int8_t cmprAlg);
|
|||
int32_t tCompressEnd(SCompressor *pCmprsor, const uint8_t **ppOut, int32_t *nOut, int32_t *nOrigin);
|
||||
int32_t tCompress(SCompressor *pCmprsor, const void *pData, int64_t nData);
|
||||
|
||||
typedef int32_t (*__data_compress_init)(char *lossyColumns, float fPrecision, double dPrecision, uint32_t maxIntervals,
|
||||
uint32_t intervals, int32_t ifAdtFse, const char *compressor);
|
||||
typedef int32_t (*__data_compress_l1_fn_t)(const char *const input, const int32_t nelements, char *const output,
|
||||
const char type);
|
||||
typedef int32_t (*__data_decompress_l1_fn_t)(const char *const input, const int32_t nelements, char *const output,
|
||||
const char type);
|
||||
|
||||
typedef int32_t (*__data_compress_l2_fn_t)(const char *const input, const int32_t nelements, char *const output,
|
||||
int32_t outputSize, const char type, int8_t level);
|
||||
typedef int32_t (*__data_decompress_l2_fn_t)(const char *const input, const int32_t nelements, char *const output,
|
||||
int32_t outputSize, const char type);
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
__data_compress_init initFn;
|
||||
__data_compress_l1_fn_t comprFn;
|
||||
__data_decompress_l1_fn_t decomprFn;
|
||||
} TCompressL1FnSet;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
__data_compress_init initFn;
|
||||
__data_compress_l2_fn_t comprFn;
|
||||
__data_decompress_l2_fn_t decomprFn;
|
||||
} TCompressL2FnSet;
|
||||
|
||||
typedef struct {
|
||||
int8_t type;
|
||||
int8_t level;
|
||||
__data_compress_init initFn;
|
||||
__data_compress_l1_fn_t l1CmprFn;
|
||||
__data_decompress_l1_fn_t l1DecmprFn;
|
||||
__data_compress_l2_fn_t l2CmprFn;
|
||||
__data_decompress_l2_fn_t l2DecmprFn;
|
||||
} TCompressPara;
|
||||
|
||||
typedef enum L1Compress {
|
||||
L1_UNKNOWN = 0,
|
||||
L1_SIMPLE_8B,
|
||||
L1_XOR,
|
||||
L1_RLE,
|
||||
L1_DELTAD,
|
||||
L1_DISABLED = 0xFF,
|
||||
} EL1CompressFuncType;
|
||||
|
||||
typedef enum L2Compress {
|
||||
L2_UNKNOWN = 0,
|
||||
L2_LZ4,
|
||||
L2_ZLIB,
|
||||
L2_ZSTD,
|
||||
L2_TSZ,
|
||||
L2_XZ,
|
||||
L2_DISABLED = 0xFF,
|
||||
} EL2ComressFuncType;
|
||||
|
||||
int32_t tcompressDebug(uint32_t cmprAlg, uint8_t *l1Alg, uint8_t *l2Alg, uint8_t *level);
|
||||
|
||||
#define DEFINE_VAR(cmprAlg) \
|
||||
uint8_t l1 = COMPRESS_L1_TYPE_U32(cmprAlg); \
|
||||
uint8_t l2 = COMPRESS_L2_TYPE_U32(cmprAlg); \
|
||||
uint8_t lvl = COMPRESS_L2_TYPE_LEVEL_U32(cmprAlg);
|
||||
|
||||
#define SET_COMPRESS(l1, l2, lvl, cmpr) \
|
||||
do { \
|
||||
(cmpr) &= 0x00FFFFFF; \
|
||||
(cmpr) |= ((l1) << 24); \
|
||||
(cmpr) &= 0xFF0000FF; \
|
||||
(cmpr) |= ((l2) << 8); \
|
||||
(cmpr) &= 0xFFFFFF00; \
|
||||
(cmpr) |= (lvl); \
|
||||
} while (0)
|
||||
int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, uint8_t lvlDisabled, uint8_t lvlDefault,
|
||||
uint32_t *dst);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -149,7 +149,7 @@ typedef enum EOperatorType {
|
|||
OP_TYPE_BIT_OR,
|
||||
|
||||
// binary comparison operator
|
||||
OP_TYPE_GREATER_THAN = 40, // MUST KEEP IT FIRST AT COMPARE SECTION
|
||||
OP_TYPE_GREATER_THAN = 40, // MUST KEEP IT FIRST AT COMPARE SECTION
|
||||
OP_TYPE_GREATER_EQUAL,
|
||||
OP_TYPE_LOWER_THAN,
|
||||
OP_TYPE_LOWER_EQUAL,
|
||||
|
@ -170,7 +170,7 @@ typedef enum EOperatorType {
|
|||
OP_TYPE_IS_NOT_TRUE,
|
||||
OP_TYPE_IS_NOT_FALSE,
|
||||
OP_TYPE_IS_NOT_UNKNOWN,
|
||||
OP_TYPE_COMPARE_MAX_VALUE = 149, // MUST KEEP IT LAST AT COMPARE SECTION
|
||||
OP_TYPE_COMPARE_MAX_VALUE = 149, // MUST KEEP IT LAST AT COMPARE SECTION
|
||||
|
||||
// json operator
|
||||
OP_TYPE_JSON_GET_VALUE = 150,
|
||||
|
@ -188,6 +188,10 @@ typedef enum ELogicConditionType {
|
|||
LOGIC_COND_TYPE_NOT,
|
||||
} ELogicConditionType;
|
||||
|
||||
#define ENCRYPTED_LEN(len) (len/16) * 16 + (len%16?1:0) * 16
|
||||
#define ENCRYPT_KEY_LEN 16
|
||||
#define ENCRYPT_KEY_LEN_MIN 8
|
||||
|
||||
#define TSDB_INT32_ID_LEN 11
|
||||
|
||||
#define TSDB_NAME_DELIMITER_LEN 1
|
||||
|
@ -388,6 +392,14 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_CACHE_MODEL_LAST_ROW 1
|
||||
#define TSDB_CACHE_MODEL_LAST_VALUE 2
|
||||
#define TSDB_CACHE_MODEL_BOTH 3
|
||||
#define TSDB_ENCRYPT_ALGO_STR_LEN 16
|
||||
#define TSDB_ENCRYPT_ALGO_NONE_STR "none"
|
||||
#define TSDB_ENCRYPT_ALGO_SM4_STR "sm4"
|
||||
#define TSDB_ENCRYPT_ALGO_NONE 0
|
||||
#define TSDB_ENCRYPT_ALGO_SM4 1
|
||||
#define TSDB_DEFAULT_ENCRYPT_ALGO TSDB_ENCRYPT_ALGO_NONE
|
||||
#define TSDB_MIN_ENCRYPT_ALGO TSDB_ENCRYPT_ALGO_NONE
|
||||
#define TSDB_MAX_ENCRYPT_ALGO TSDB_ENCRYPT_ALGO_SM4
|
||||
#define TSDB_DEFAULT_CACHE_MODEL TSDB_CACHE_MODEL_NONE
|
||||
#define TSDB_MIN_DB_CACHE_SIZE 1 // MB
|
||||
#define TSDB_MAX_DB_CACHE_SIZE 65536
|
||||
|
@ -417,7 +429,7 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_MAX_HASH_SUFFIX (TSDB_TABLE_NAME_LEN - 2)
|
||||
#define TSDB_DEFAULT_HASH_SUFFIX 0
|
||||
|
||||
#define TSDB_MIN_S3_CHUNK_SIZE (32 * 1024)
|
||||
#define TSDB_MIN_S3_CHUNK_SIZE (128 * 1024)
|
||||
#define TSDB_MAX_S3_CHUNK_SIZE (1024 * 1024)
|
||||
#define TSDB_DEFAULT_S3_CHUNK_SIZE (256 * 1024)
|
||||
#define TSDB_MIN_S3_KEEP_LOCAL (1 * 1440) // unit minute
|
||||
|
@ -523,6 +535,7 @@ typedef enum ELogicConditionType {
|
|||
|
||||
enum { TRANS_STAT_INIT = 0, TRANS_STAT_EXECUTING, TRANS_STAT_EXECUTED, TRANS_STAT_ROLLBACKING, TRANS_STAT_ROLLBACKED };
|
||||
enum { TRANS_OPER_INIT = 0, TRANS_OPER_EXECUTE, TRANS_OPER_ROLLBACK };
|
||||
enum { ENCRYPT_KEY_STAT_UNKNOWN = 0, ENCRYPT_KEY_STAT_UNSET, ENCRYPT_KEY_STAT_SET, ENCRYPT_KEY_STAT_LOADED};
|
||||
|
||||
typedef struct {
|
||||
char dir[TSDB_FILENAME_LEN];
|
||||
|
|
|
@ -221,7 +221,11 @@ typedef struct {
|
|||
SSchemaWrapper schema;
|
||||
int32_t resIter;
|
||||
SReqResultInfo resInfo;
|
||||
SMqDataRsp rsp;
|
||||
} SMqRspObjCommon;
|
||||
|
||||
typedef struct {
|
||||
SMqRspObjCommon common;
|
||||
SMqDataRsp rsp;
|
||||
} SMqRspObj;
|
||||
|
||||
typedef struct {
|
||||
|
@ -233,14 +237,8 @@ typedef struct {
|
|||
} SMqMetaRspObj;
|
||||
|
||||
typedef struct {
|
||||
int8_t resType;
|
||||
char topic[TSDB_TOPIC_FNAME_LEN];
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int32_t vgId;
|
||||
SSchemaWrapper schema;
|
||||
int32_t resIter;
|
||||
SReqResultInfo resInfo;
|
||||
STaosxRsp rsp;
|
||||
SMqRspObjCommon common;
|
||||
STaosxRsp rsp;
|
||||
} SMqTaosxRspObj;
|
||||
|
||||
typedef struct SReqRelInfo {
|
||||
|
@ -320,7 +318,7 @@ int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols);
|
|||
|
||||
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
||||
SMqRspObj* msg = (SMqRspObj*)res;
|
||||
return (SReqResultInfo*)&msg->resInfo;
|
||||
return (SReqResultInfo*)&msg->common.resInfo;
|
||||
}
|
||||
|
||||
SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4);
|
||||
|
|
|
@ -234,6 +234,15 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
|||
catalogUpdateDbCfg(pCatalog, rsp->cfgRsp->db, rsp->cfgRsp->dbId, rsp->cfgRsp);
|
||||
rsp->cfgRsp = NULL;
|
||||
}
|
||||
if (rsp->pTsmaRsp) {
|
||||
if (rsp->pTsmaRsp->pTsmas) {
|
||||
for (int32_t i = 0; i < rsp->pTsmaRsp->pTsmas->size; ++i) {
|
||||
STableTSMAInfo* pTsma = taosArrayGetP(rsp->pTsmaRsp->pTsmas, i);
|
||||
catalogAsyncUpdateTSMA(pCatalog, &pTsma, rsp->dbTsmaVersion);
|
||||
}
|
||||
taosArrayClear(rsp->pTsmaRsp->pTsmas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_return:
|
||||
|
@ -327,6 +336,33 @@ static int32_t hbProcessViewInfoRsp(void *value, int32_t valueLen, struct SCatal
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t hbprocessTSMARsp(void* value, int32_t valueLen, struct SCatalog* pCatalog) {
|
||||
int32_t code = 0;
|
||||
|
||||
STSMAHbRsp hbRsp = {0};
|
||||
if (tDeserializeTSMAHbRsp(value, valueLen, &hbRsp)) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t numOfTsma = taosArrayGetSize(hbRsp.pTsmas);
|
||||
for (int32_t i = 0; i < numOfTsma; ++i) {
|
||||
STableTSMAInfo* pTsmaInfo = taosArrayGetP(hbRsp.pTsmas, i);
|
||||
|
||||
if (!pTsmaInfo->pFuncs) {
|
||||
tscDebug("hb to remove tsma: %s.%s", pTsmaInfo->dbFName, pTsmaInfo->name);
|
||||
catalogRemoveTSMA(pCatalog, pTsmaInfo);
|
||||
tFreeAndClearTableTSMAInfo(pTsmaInfo);
|
||||
} else {
|
||||
tscDebug("hb to update tsma: %s.%s", pTsmaInfo->dbFName, pTsmaInfo->name);
|
||||
catalogUpdateTSMA(pCatalog, &pTsmaInfo);
|
||||
tFreeAndClearTableTSMAInfo(pTsmaInfo);
|
||||
}
|
||||
}
|
||||
|
||||
taosArrayDestroy(hbRsp.pTsmas);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void hbProcessQueryRspKvs(int32_t kvNum, SArray* pKvs, struct SCatalog *pCatalog, SAppHbMgr *pAppHbMgr) {
|
||||
for (int32_t i = 0; i < kvNum; ++i) {
|
||||
|
@ -379,6 +415,13 @@ static void hbProcessQueryRspKvs(int32_t kvNum, SArray* pKvs, struct SCatalog *p
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
case HEARTBEAT_KEY_TSMA: {
|
||||
if (kv->valueLen <= 0 || !kv->value) {
|
||||
tscError("Invalid tsma info, len: %d, value: %p", kv->valueLen, kv->value);
|
||||
}
|
||||
hbprocessTSMARsp(kv->value, kv->valueLen, pCatalog);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
tscError("invalid hb key type:%d", kv->key);
|
||||
break;
|
||||
|
@ -763,6 +806,7 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
|
|||
db->cfgVersion = htonl(db->cfgVersion);
|
||||
db->numOfTable = htonl(db->numOfTable);
|
||||
db->stateTs = htobe64(db->stateTs);
|
||||
db->tsmaVersion = htonl(db->tsmaVersion);
|
||||
}
|
||||
|
||||
SKv kv = {
|
||||
|
@ -871,6 +915,39 @@ int32_t hbGetExpiredViewInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, S
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t hbGetExpiredTSMAInfo(SClientHbKey* connKey, struct SCatalog* pCatalog, SClientHbReq* pReq) {
|
||||
int32_t code = 0;
|
||||
uint32_t tsmaNum = 0;
|
||||
STSMAVersion *tsmas = NULL;
|
||||
|
||||
code = catalogGetExpiredTsmas(pCatalog, &tsmas, &tsmaNum);
|
||||
if (code) {
|
||||
taosMemoryFree(tsmas);
|
||||
return code;
|
||||
}
|
||||
|
||||
if (tsmaNum <= 0) {
|
||||
taosMemoryFree(tsmas);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < tsmaNum; ++i) {
|
||||
STSMAVersion* tsma = &tsmas[i];
|
||||
tsma->dbId = htobe64(tsma->dbId);
|
||||
tsma->tsmaId = htobe64(tsma->tsmaId);
|
||||
tsma->version = htonl(tsma->version);
|
||||
}
|
||||
|
||||
tscDebug("hb got %d expred tsmas, valueLen: %lu", tsmaNum, sizeof(STSMAVersion) * tsmaNum);
|
||||
|
||||
if (!pReq->info) {
|
||||
pReq->info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
|
||||
}
|
||||
|
||||
SKv kv = {.key = HEARTBEAT_KEY_TSMA, .valueLen = sizeof(STSMAVersion) * tsmaNum, .value = tsmas};
|
||||
taosHashPut(pReq->info, &kv.key, sizeof(kv.key), &kv, sizeof(kv));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t hbGetAppInfo(int64_t clusterId, SClientHbReq *req) {
|
||||
SAppHbReq *pApp = taosHashGet(clientHbMgr.appSummary, &clusterId, sizeof(clusterId));
|
||||
|
@ -935,6 +1012,7 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req
|
|||
return code;
|
||||
}
|
||||
#endif
|
||||
code = hbGetExpiredTSMAInfo(connKey, pCatalog, req);
|
||||
} else {
|
||||
req->app.appId = 0;
|
||||
}
|
||||
|
|
|
@ -1041,6 +1041,7 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) {
|
|||
if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code) && pRequest->sqlstr != NULL) {
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%s, tryCount:%d, reqId:0x%" PRIx64, pRequest->self,
|
||||
tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||
removeMeta(pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type));
|
||||
restartAsyncQuery(pRequest, code);
|
||||
return;
|
||||
}
|
||||
|
@ -1803,6 +1804,10 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
|
|||
}
|
||||
|
||||
static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int32_t numOfCols, int32_t* colLength) {
|
||||
int32_t idx = -1;
|
||||
iconv_t conv = taosAcquireConv(&idx, C2M);
|
||||
if (!conv) return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
int32_t type = pResultInfo->fields[i].type;
|
||||
int32_t bytes = pResultInfo->fields[i].bytes;
|
||||
|
@ -1810,6 +1815,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
|||
if (type == TSDB_DATA_TYPE_NCHAR && colLength[i] > 0) {
|
||||
char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]);
|
||||
if (p == NULL) {
|
||||
taosReleaseConv(idx, conv, C2M);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -1820,12 +1826,13 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
|||
if (pCol->offset[j] != -1) {
|
||||
char* pStart = pCol->offset[j] + pCol->pData;
|
||||
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p));
|
||||
if (len > bytes || (p + len) >= (pResultInfo->convertBuf[i] + colLength[i])) {
|
||||
int32_t len = taosUcs4ToMbsEx((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p), conv);
|
||||
if (len < 0 || len > bytes || (p + len) >= (pResultInfo->convertBuf[i] + colLength[i])) {
|
||||
tscError(
|
||||
"doConvertUCS4 error, invalid data. len:%d, bytes:%d, (p + len):%p, (pResultInfo->convertBuf[i] + "
|
||||
"colLength[i]):%p",
|
||||
len, bytes, (p + len), (pResultInfo->convertBuf[i] + colLength[i]));
|
||||
taosReleaseConv(idx, conv, C2M);
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1839,7 +1846,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
|||
pResultInfo->row[i] = pResultInfo->pCol[i].pData;
|
||||
}
|
||||
}
|
||||
|
||||
taosReleaseConv(idx, conv, C2M);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2619,8 +2626,7 @@ static void fetchCallback(void* pResult, void* param, int32_t code) {
|
|||
setQueryResultFromRsp(pResultInfo, (const SRetrieveTableRsp*)pResultInfo->pData, pResultInfo->convertUcs4);
|
||||
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
||||
pResultInfo->numOfRows = 0;
|
||||
pRequest->code = code;
|
||||
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(pRequest->code),
|
||||
pRequest->requestId);
|
||||
} else {
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||
|
|
|
@ -343,12 +343,12 @@ void taos_free_result(TAOS_RES *res) {
|
|||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
SMqTaosxRspObj *pRsp = (SMqTaosxRspObj *)res;
|
||||
tDeleteSTaosxRsp(&pRsp->rsp);
|
||||
doFreeReqResultInfo(&pRsp->resInfo);
|
||||
doFreeReqResultInfo(&pRsp->common.resInfo);
|
||||
taosMemoryFree(pRsp);
|
||||
} else if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj *pRsp = (SMqRspObj *)res;
|
||||
tDeleteMqDataRsp(&pRsp->rsp);
|
||||
doFreeReqResultInfo(&pRsp->resInfo);
|
||||
doFreeReqResultInfo(&pRsp->common.resInfo);
|
||||
taosMemoryFree(pRsp);
|
||||
} else if (TD_RES_TMQ_META(res)) {
|
||||
SMqMetaRspObj *pRspObj = (SMqMetaRspObj *)res;
|
||||
|
@ -417,7 +417,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
} else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
SMqRspObj *msg = ((SMqRspObj *)res);
|
||||
SReqResultInfo *pResultInfo;
|
||||
if (msg->resIter == -1) {
|
||||
if (msg->common.resIter == -1) {
|
||||
pResultInfo = tmqGetNextResInfo(res, true);
|
||||
} else {
|
||||
pResultInfo = tmqGetCurResInfo(res);
|
||||
|
@ -936,6 +936,8 @@ int32_t cloneCatalogReq(SCatalogReq **ppTarget, SCatalogReq *pSrc) {
|
|||
pTarget->pTableCfg = taosArrayDup(pSrc->pTableCfg, NULL);
|
||||
pTarget->pTableTag = taosArrayDup(pSrc->pTableTag, NULL);
|
||||
pTarget->pView = taosArrayDup(pSrc->pView, NULL);
|
||||
pTarget->pTableTSMAs = taosArrayDup(pSrc->pTableTSMAs, NULL);
|
||||
pTarget->pTSMAs = taosArrayDup(pSrc->pTSMAs, NULL);
|
||||
pTarget->qNodeRequired = pSrc->qNodeRequired;
|
||||
pTarget->dNodeRequired = pSrc->dNodeRequired;
|
||||
pTarget->svrVerRequired = pSrc->svrVerRequired;
|
||||
|
|
|
@ -712,11 +712,13 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
goto end;
|
||||
}
|
||||
// build create stable
|
||||
pReq.pColumns = taosArrayInit(req.schemaRow.nCols, sizeof(SField));
|
||||
pReq.pColumns = taosArrayInit(req.schemaRow.nCols, sizeof(SFieldWithOptions));
|
||||
for (int32_t i = 0; i < req.schemaRow.nCols; i++) {
|
||||
SSchema* pSchema = req.schemaRow.pSchema + i;
|
||||
SField field = {.type = pSchema->type, .flags = pSchema->flags, .bytes = pSchema->bytes};
|
||||
SFieldWithOptions field = {.type = pSchema->type, .flags = pSchema->flags, .bytes = pSchema->bytes};
|
||||
strcpy(field.name, pSchema->name);
|
||||
// todo get active compress param
|
||||
setDefaultOptionsForField(&field);
|
||||
taosArrayPush(pReq.pColumns, &field);
|
||||
}
|
||||
pReq.pTags = taosArrayInit(req.schemaTag.nCols, sizeof(SField));
|
||||
|
@ -1484,7 +1486,7 @@ int taos_write_raw_block_with_fields_with_reqid(TAOS* taos, int rows, char* pDat
|
|||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData));
|
||||
|
||||
code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, fields, numFields, false);
|
||||
code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, fields, numFields, false, NULL, 0);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
|
@ -1568,7 +1570,7 @@ int taos_write_raw_block_with_reqid(TAOS* taos, int rows, char* pData, const cha
|
|||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData));
|
||||
|
||||
code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, NULL, 0, false);
|
||||
code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, NULL, 0, false, NULL, 0);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
|
@ -1606,6 +1608,7 @@ static void* getRawDataFromRes(void* pRetrieve) {
|
|||
static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||
if (taos == NULL || data == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
SET_ERROR_MSG("taos:%p or data:%p is NULL", taos, data);
|
||||
return terrno;
|
||||
}
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -1618,17 +1621,24 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
terrno = TSDB_CODE_SUCCESS;
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
|
||||
if (!pRequest) {
|
||||
SET_ERROR_MSG("pRequest is NULL");
|
||||
return terrno;
|
||||
}
|
||||
|
||||
uDebug(LOG_ID_TAG " write raw data, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
||||
pRequest->syncQuery = true;
|
||||
rspObj.resIter = -1;
|
||||
rspObj.resType = RES_TYPE__TMQ;
|
||||
rspObj.common.resIter = -1;
|
||||
rspObj.common.resType = RES_TYPE__TMQ;
|
||||
|
||||
int8_t dataVersion = *(int8_t*)data;
|
||||
if (dataVersion >= MQ_DATA_RSP_VERSION){
|
||||
data = POINTER_SHIFT(data, sizeof(int8_t) + sizeof(int32_t));
|
||||
dataLen -= sizeof(int8_t) + sizeof(int32_t);
|
||||
}
|
||||
tDecoderInit(&decoder, data, dataLen);
|
||||
code = tDecodeMqDataRsp(&decoder, &rspObj.rsp, *(int8_t*)data);
|
||||
code = tDecodeMqDataRsp(&decoder, &rspObj.rsp);
|
||||
if (code != 0) {
|
||||
SET_ERROR_MSG("decode mq data rsp failed");
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1641,6 +1651,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
struct SCatalog* pCatalog = NULL;
|
||||
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SET_ERROR_MSG("cata log get handle failed");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1653,17 +1664,19 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
pQuery = smlInitHandle();
|
||||
if (pQuery == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
SET_ERROR_MSG("init sml handle failed");
|
||||
goto end;
|
||||
}
|
||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
||||
void* pRetrieve = taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
||||
if (!rspObj.rsp.withSchema) {
|
||||
while (++rspObj.common.resIter < rspObj.rsp.common.blockNum) {
|
||||
void* pRetrieve = taosArrayGetP(rspObj.rsp.common.blockData, rspObj.common.resIter);
|
||||
if (!rspObj.rsp.common.withSchema) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.blockTbName, rspObj.resIter);
|
||||
const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.common.blockTbName, rspObj.common.resIter);
|
||||
if (!tbName) {
|
||||
SET_ERROR_MSG("block tbname is null");
|
||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1679,12 +1692,14 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
// continue;
|
||||
// }
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SET_ERROR_MSG("cata log get table:%s meta failed", tbName);
|
||||
goto end;
|
||||
}
|
||||
|
||||
SVgroupInfo vg;
|
||||
code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SET_ERROR_MSG("cata log get table:%s vgroup failed", tbName);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1693,9 +1708,11 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg));
|
||||
}
|
||||
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.blockSchema, rspObj.resIter);
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.common.blockSchema, rspObj.common.resIter);
|
||||
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
||||
if (fields == NULL) {
|
||||
SET_ERROR_MSG("calloc fields failed");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
for (int i = 0; i < pSW->nCols; i++) {
|
||||
|
@ -1704,16 +1721,18 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
|
||||
}
|
||||
void* rawData = getRawDataFromRes(pRetrieve);
|
||||
code = rawBlockBindData(pQuery, pTableMeta, rawData, NULL, fields, pSW->nCols, true);
|
||||
char err[ERR_MSG_LEN] = {0};
|
||||
code = rawBlockBindData(pQuery, pTableMeta, rawData, NULL, fields, pSW->nCols, true, err, ERR_MSG_LEN);
|
||||
taosMemoryFree(fields);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SET_ERROR_MSG("table:%s, err:%s", tbName, err);
|
||||
goto end;
|
||||
}
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
}
|
||||
|
||||
code = smlBuildOutput(pQuery, pVgHash);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SET_ERROR_MSG("sml build output failed");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1735,6 +1754,7 @@ end:
|
|||
static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||
if (taos == NULL || data == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
SET_ERROR_MSG("taos:%p or data:%p is NULL", taos, data);
|
||||
return terrno;
|
||||
}
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -1748,16 +1768,24 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
terrno = TSDB_CODE_SUCCESS;
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
|
||||
if (!pRequest) {
|
||||
SET_ERROR_MSG("pRequest is NULL");
|
||||
return terrno;
|
||||
}
|
||||
uDebug(LOG_ID_TAG " write raw metadata, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
||||
pRequest->syncQuery = true;
|
||||
rspObj.resIter = -1;
|
||||
rspObj.resType = RES_TYPE__TMQ_METADATA;
|
||||
rspObj.common.resIter = -1;
|
||||
rspObj.common.resType = RES_TYPE__TMQ_METADATA;
|
||||
|
||||
int8_t dataVersion = *(int8_t*)data;
|
||||
if (dataVersion >= MQ_DATA_RSP_VERSION){
|
||||
data = POINTER_SHIFT(data, sizeof(int8_t) + sizeof(int32_t));
|
||||
dataLen -= sizeof(int8_t) + sizeof(int32_t);
|
||||
}
|
||||
|
||||
tDecoderInit(&decoder, data, dataLen);
|
||||
code = tDecodeSTaosxRsp(&decoder, &rspObj.rsp, *(int8_t*)data);
|
||||
code = tDecodeSTaosxRsp(&decoder, &rspObj.rsp);
|
||||
if (code != 0) {
|
||||
SET_ERROR_MSG("decode mq taosx data rsp failed");
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1770,6 +1798,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
struct SCatalog* pCatalog = NULL;
|
||||
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SET_ERROR_MSG("cata log get handle failed");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1781,20 +1810,22 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
|
||||
pQuery = smlInitHandle();
|
||||
if (pQuery == NULL) {
|
||||
SET_ERROR_MSG("init sml handle failed");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
|
||||
uDebug(LOG_ID_TAG " write raw metadata block num:%d", LOG_ID_VALUE, rspObj.rsp.blockNum);
|
||||
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
||||
void* pRetrieve = taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
||||
if (!rspObj.rsp.withSchema) {
|
||||
uDebug(LOG_ID_TAG " write raw metadata block num:%d", LOG_ID_VALUE, rspObj.rsp.common.blockNum);
|
||||
while (++rspObj.common.resIter < rspObj.rsp.common.blockNum) {
|
||||
void* pRetrieve = taosArrayGetP(rspObj.rsp.common.blockData, rspObj.common.resIter);
|
||||
if (!rspObj.rsp.common.withSchema) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.blockTbName, rspObj.resIter);
|
||||
const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.common.blockTbName, rspObj.common.resIter);
|
||||
if (!tbName) {
|
||||
SET_ERROR_MSG("block tbname is null");
|
||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1816,6 +1847,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
tDecoderClear(&decoderTmp);
|
||||
tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE);
|
||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
||||
SET_ERROR_MSG("decode create table:%s req failed", tbName);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1823,6 +1855,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
code = TSDB_CODE_TSC_INVALID_VALUE;
|
||||
tDecoderClear(&decoderTmp);
|
||||
tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE);
|
||||
SET_ERROR_MSG("create table req type is not child table: %s, type: %d", tbName, pCreateReq.type);
|
||||
goto end;
|
||||
}
|
||||
if (strcmp(tbName, pCreateReq.name) == 0) {
|
||||
|
@ -1839,6 +1872,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
SVgroupInfo vg;
|
||||
code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SET_ERROR_MSG("cata log get table:%s vgroup failed", tbName);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1852,6 +1886,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
// continue;
|
||||
// }
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SET_ERROR_MSG("cata log get table:%s meta failed", tbName);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1865,9 +1900,11 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg));
|
||||
}
|
||||
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.blockSchema, rspObj.resIter);
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.common.blockSchema, rspObj.common.resIter);
|
||||
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
||||
if (fields == NULL) {
|
||||
SET_ERROR_MSG("calloc fields failed");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
for (int i = 0; i < pSW->nCols; i++) {
|
||||
|
@ -1876,12 +1913,13 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
|
||||
}
|
||||
void* rawData = getRawDataFromRes(pRetrieve);
|
||||
code = rawBlockBindData(pQuery, pTableMeta, rawData, &pCreateReqDst, fields, pSW->nCols, true);
|
||||
char err[ERR_MSG_LEN] = {0};
|
||||
code = rawBlockBindData(pQuery, pTableMeta, rawData, &pCreateReqDst, fields, pSW->nCols, true, err, ERR_MSG_LEN);
|
||||
taosMemoryFree(fields);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SET_ERROR_MSG("table:%s, err:%s", tbName, err);
|
||||
goto end;
|
||||
}
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
}
|
||||
|
||||
code = smlBuildOutput(pQuery, pVgHash);
|
||||
|
@ -1944,6 +1982,64 @@ char* tmq_get_json_meta(TAOS_RES* res) {
|
|||
|
||||
void tmq_free_json_meta(char* jsonMeta) { taosMemoryFreeClear(jsonMeta); }
|
||||
|
||||
static int32_t getOffSetLen(const void *rsp){
|
||||
const SMqDataRspCommon *pRsp = rsp;
|
||||
SEncoder coder = {0};
|
||||
tEncoderInit(&coder, NULL, 0);
|
||||
if (tEncodeSTqOffsetVal(&coder, &pRsp->reqOffset) < 0) return -1;
|
||||
if (tEncodeSTqOffsetVal(&coder, &pRsp->rspOffset) < 0) return -1;
|
||||
int32_t pos = coder.pos;
|
||||
tEncoderClear(&coder);
|
||||
return pos;
|
||||
}
|
||||
|
||||
typedef int32_t __encode_func__(SEncoder *pEncoder, const void *pRsp);
|
||||
|
||||
static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, void* rspObj, tmq_raw_data* raw){
|
||||
int32_t len = 0;
|
||||
int32_t code = 0;
|
||||
SEncoder encoder = {0};
|
||||
void* buf = NULL;
|
||||
tEncodeSize(encodeFunc, rspObj, len, code);
|
||||
if (code < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto FAILED;
|
||||
}
|
||||
len += sizeof(int8_t) + sizeof(int32_t);
|
||||
buf = taosMemoryCalloc(1, len);
|
||||
if(buf == NULL){
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto FAILED;
|
||||
}
|
||||
tEncoderInit(&encoder, buf, len);
|
||||
if (tEncodeI8(&encoder, MQ_DATA_RSP_VERSION) < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto FAILED;
|
||||
}
|
||||
int32_t offsetLen = getOffSetLen(rspObj);
|
||||
if(offsetLen <= 0){
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto FAILED;
|
||||
}
|
||||
if (tEncodeI32(&encoder, offsetLen) < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto FAILED;
|
||||
}
|
||||
if(encodeFunc(&encoder, rspObj) < 0){
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto FAILED;
|
||||
}
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
raw->raw = buf;
|
||||
raw->raw_len = len;
|
||||
return 0;
|
||||
FAILED:
|
||||
tEncoderClear(&encoder);
|
||||
taosMemoryFree(buf);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) {
|
||||
if (!raw || !res) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
|
@ -1957,42 +2053,19 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) {
|
|||
uDebug("tmq get raw type meta:%p", raw);
|
||||
} else if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj* rspObj = ((SMqRspObj*)res);
|
||||
|
||||
int32_t len = 0;
|
||||
int32_t code = 0;
|
||||
tEncodeSize(tEncodeMqDataRsp, &rspObj->rsp, len, code);
|
||||
if (code < 0) {
|
||||
return -1;
|
||||
if(encodeMqDataRsp(tEncodeMqDataRsp, &rspObj->rsp, raw) != 0){
|
||||
uError("tmq get raw type error:%d", terrno);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
void* buf = taosMemoryCalloc(1, len);
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, len);
|
||||
tEncodeMqDataRsp(&encoder, &rspObj->rsp);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
raw->raw = buf;
|
||||
raw->raw_len = len;
|
||||
raw->raw_type = RES_TYPE__TMQ;
|
||||
uDebug("tmq get raw type data:%p", raw);
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
SMqTaosxRspObj* rspObj = ((SMqTaosxRspObj*)res);
|
||||
|
||||
int32_t len = 0;
|
||||
int32_t code = 0;
|
||||
tEncodeSize(tEncodeSTaosxRsp, &rspObj->rsp, len, code);
|
||||
if (code < 0) {
|
||||
return -1;
|
||||
if(encodeMqDataRsp(tEncodeSTaosxRsp, &rspObj->rsp, raw) != 0){
|
||||
uError("tmq get raw type error:%d", terrno);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
void* buf = taosMemoryCalloc(1, len);
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, len);
|
||||
tEncodeSTaosxRsp(&encoder, &rspObj->rsp);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
raw->raw = buf;
|
||||
raw->raw_len = len;
|
||||
raw->raw_type = RES_TYPE__TMQ_METADATA;
|
||||
uDebug("tmq get raw type metadata:%p", raw);
|
||||
} else {
|
||||
|
@ -2008,6 +2081,7 @@ void tmq_free_raw(tmq_raw_data raw) {
|
|||
if (raw.raw_type == RES_TYPE__TMQ || raw.raw_type == RES_TYPE__TMQ_METADATA) {
|
||||
taosMemoryFree(raw.raw);
|
||||
}
|
||||
memset(terrMsg, 0, ERR_MSG_LEN);
|
||||
}
|
||||
|
||||
int32_t tmq_write_raw(TAOS* taos, tmq_raw_data raw) {
|
||||
|
|
|
@ -108,7 +108,7 @@ int64_t smlToMilli[] = {3600000LL, 60000LL, 1000LL};
|
|||
int64_t smlFactorNS[] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1};
|
||||
int64_t smlFactorS[] = {1000LL, 1000000LL, 1000000000LL};
|
||||
|
||||
static int32_t smlCheckAuth(SSmlHandle *info, SRequestConnInfo* conn, const char* pTabName, AUTH_TYPE type){
|
||||
static int32_t smlCheckAuth(SSmlHandle *info, SRequestConnInfo *conn, const char *pTabName, AUTH_TYPE type) {
|
||||
SUserAuthInfo pAuth = {0};
|
||||
snprintf(pAuth.user, sizeof(pAuth.user), "%s", info->taos->user);
|
||||
if (NULL == pTabName) {
|
||||
|
@ -124,8 +124,9 @@ static int32_t smlCheckAuth(SSmlHandle *info, SRequestConnInfo* conn, const cha
|
|||
code = catalogChkAuth(info->pCatalog, conn, &pAuth, &authRes);
|
||||
nodesDestroyNode(authRes.pCond[AUTH_RES_BASIC]);
|
||||
|
||||
return (code == TSDB_CODE_SUCCESS) ? (authRes.pass[AUTH_RES_BASIC] ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED) : code;
|
||||
|
||||
return (code == TSDB_CODE_SUCCESS)
|
||||
? (authRes.pass[AUTH_RES_BASIC] ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED)
|
||||
: code;
|
||||
}
|
||||
|
||||
int32_t smlBuildInvalidDataMsg(SSmlMsgBuf *pBuf, const char *msg1, const char *msg2) {
|
||||
|
@ -182,7 +183,7 @@ cleanup:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void smlBuildTsKv(SSmlKv *kv, int64_t ts){
|
||||
void smlBuildTsKv(SSmlKv *kv, int64_t ts) {
|
||||
kv->key = tsSmlTsDefaultName;
|
||||
kv->keyLen = strlen(tsSmlTsDefaultName);
|
||||
kv->type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
|
@ -190,10 +191,10 @@ void smlBuildTsKv(SSmlKv *kv, int64_t ts){
|
|||
kv->length = (size_t)tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes;
|
||||
}
|
||||
|
||||
SSmlSTableMeta* smlBuildSuperTableInfo(SSmlHandle *info, SSmlLineInfo *currElement){
|
||||
SSmlSTableMeta* sMeta = NULL;
|
||||
char *measure = currElement->measure;
|
||||
int measureLen = currElement->measureLen;
|
||||
SSmlSTableMeta *smlBuildSuperTableInfo(SSmlHandle *info, SSmlLineInfo *currElement) {
|
||||
SSmlSTableMeta *sMeta = NULL;
|
||||
char *measure = currElement->measure;
|
||||
int measureLen = currElement->measureLen;
|
||||
if (currElement->measureEscaped) {
|
||||
measure = (char *)taosMemoryMalloc(measureLen);
|
||||
memcpy(measure, currElement->measure, measureLen);
|
||||
|
@ -211,7 +212,7 @@ SSmlSTableMeta* smlBuildSuperTableInfo(SSmlHandle *info, SSmlLineInfo *currEleme
|
|||
return sMeta;
|
||||
}
|
||||
sMeta = smlBuildSTableMeta(info->dataFormat);
|
||||
if(sMeta == NULL){
|
||||
if (sMeta == NULL) {
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return sMeta;
|
||||
|
@ -223,22 +224,23 @@ SSmlSTableMeta* smlBuildSuperTableInfo(SSmlHandle *info, SSmlLineInfo *currEleme
|
|||
SSmlKv kv = {.key = col->name, .keyLen = strlen(col->name), .type = col->type};
|
||||
if (col->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
kv.length = (col->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
||||
} else if (col->type == TSDB_DATA_TYPE_BINARY || col->type == TSDB_DATA_TYPE_GEOMETRY || col->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||
} else if (col->type == TSDB_DATA_TYPE_BINARY || col->type == TSDB_DATA_TYPE_GEOMETRY ||
|
||||
col->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||
kv.length = col->bytes - VARSTR_HEADER_SIZE;
|
||||
} else{
|
||||
} else {
|
||||
kv.length = col->bytes;
|
||||
}
|
||||
|
||||
if(i < pTableMeta->tableInfo.numOfColumns){
|
||||
if (i < pTableMeta->tableInfo.numOfColumns) {
|
||||
taosArrayPush(sMeta->cols, &kv);
|
||||
}else{
|
||||
} else {
|
||||
taosArrayPush(sMeta->tags, &kv);
|
||||
}
|
||||
}
|
||||
return sMeta;
|
||||
}
|
||||
|
||||
bool isSmlColAligned(SSmlHandle *info, int cnt, SSmlKv *kv){
|
||||
bool isSmlColAligned(SSmlHandle *info, int cnt, SSmlKv *kv) {
|
||||
// cnt begin 0, add ts so + 2
|
||||
if (unlikely(cnt + 2 > info->currSTableMeta->tableInfo.numOfColumns)) {
|
||||
info->dataFormat = false;
|
||||
|
@ -273,7 +275,7 @@ bool isSmlColAligned(SSmlHandle *info, int cnt, SSmlKv *kv){
|
|||
return true;
|
||||
}
|
||||
|
||||
bool isSmlTagAligned(SSmlHandle *info, int cnt, SSmlKv *kv){
|
||||
bool isSmlTagAligned(SSmlHandle *info, int cnt, SSmlKv *kv) {
|
||||
if (unlikely(cnt + 1 > info->currSTableMeta->tableInfo.numOfTags)) {
|
||||
goto END;
|
||||
}
|
||||
|
@ -299,9 +301,9 @@ END:
|
|||
return false;
|
||||
}
|
||||
|
||||
int32_t smlJoinMeasureTag(SSmlLineInfo *elements){
|
||||
int32_t smlJoinMeasureTag(SSmlLineInfo *elements) {
|
||||
elements->measureTag = (char *)taosMemoryMalloc(elements->measureLen + elements->tagsLen);
|
||||
if(elements->measureTag == NULL){
|
||||
if (elements->measureTag == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
memcpy(elements->measureTag, elements->measure, elements->measureLen);
|
||||
|
@ -322,7 +324,7 @@ static bool smlIsPKTable(STableMeta *pTableMeta){
|
|||
|
||||
int32_t smlProcessSuperTable(SSmlHandle *info, SSmlLineInfo *elements) {
|
||||
bool isSameMeasure = IS_SAME_SUPER_TABLE;
|
||||
if(isSameMeasure) {
|
||||
if (isSameMeasure) {
|
||||
return 0;
|
||||
}
|
||||
SSmlSTableMeta **tmp = (SSmlSTableMeta **)taosHashGet(info->superTables, elements->measure, elements->measureLen);
|
||||
|
@ -330,8 +332,8 @@ int32_t smlProcessSuperTable(SSmlHandle *info, SSmlLineInfo *elements) {
|
|||
SSmlSTableMeta *sMeta = NULL;
|
||||
if (unlikely(tmp == NULL)) {
|
||||
sMeta = smlBuildSuperTableInfo(info, elements);
|
||||
if(sMeta == NULL) return -1;
|
||||
}else{
|
||||
if (sMeta == NULL) return -1;
|
||||
} else {
|
||||
sMeta = *tmp;
|
||||
}
|
||||
ASSERT(sMeta != NULL);
|
||||
|
@ -346,7 +348,7 @@ int32_t smlProcessSuperTable(SSmlHandle *info, SSmlLineInfo *elements) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t smlProcessChildTable(SSmlHandle *info, SSmlLineInfo *elements){
|
||||
int32_t smlProcessChildTable(SSmlHandle *info, SSmlLineInfo *elements) {
|
||||
SSmlTableInfo **oneTable =
|
||||
(SSmlTableInfo **)taosHashGet(info->childTables, elements->measureTag, elements->measureTagsLen);
|
||||
SSmlTableInfo *tinfo = NULL;
|
||||
|
@ -375,7 +377,7 @@ int32_t smlProcessChildTable(SSmlHandle *info, SSmlLineInfo *elements){
|
|||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
tinfo = *oneTable;
|
||||
}
|
||||
ASSERT(tinfo != NULL);
|
||||
|
@ -383,7 +385,7 @@ int32_t smlProcessChildTable(SSmlHandle *info, SSmlLineInfo *elements){
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t smlParseEndTelnetJson(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *kvTs, SSmlKv *kv){
|
||||
int32_t smlParseEndTelnetJson(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *kvTs, SSmlKv *kv) {
|
||||
if (info->dataFormat) {
|
||||
uDebug("SML:0x%" PRIx64 " smlParseEndTelnetJson format true, ts:%" PRId64, info->id, kvTs->i);
|
||||
int32_t ret = smlBuildCol(info->currTableDataCtx, info->currSTableMeta->schema, kvTs, 0);
|
||||
|
@ -411,7 +413,7 @@ int32_t smlParseEndTelnetJson(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t smlParseEndLine(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *kvTs){
|
||||
int32_t smlParseEndLine(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *kvTs) {
|
||||
if (info->dataFormat) {
|
||||
uDebug("SML:0x%" PRIx64 " smlParseEndLine format true, ts:%" PRId64, info->id, kvTs->i);
|
||||
int32_t ret = smlBuildCol(info->currTableDataCtx, info->currSTableMeta->schema, kvTs, 0);
|
||||
|
@ -434,31 +436,31 @@ int32_t smlParseEndLine(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *kvTs){
|
|||
}
|
||||
|
||||
static int32_t smlParseTableName(SArray *tags, char *childTableName) {
|
||||
bool autoChildName = false;
|
||||
bool autoChildName = false;
|
||||
size_t delimiter = strlen(tsSmlAutoChildTableNameDelimiter);
|
||||
if(delimiter > 0){
|
||||
if (delimiter > 0) {
|
||||
size_t totalNameLen = delimiter * (taosArrayGetSize(tags) - 1);
|
||||
for (int i = 0; i < taosArrayGetSize(tags); i++) {
|
||||
SSmlKv *tag = (SSmlKv *)taosArrayGet(tags, i);
|
||||
totalNameLen += tag->length;
|
||||
}
|
||||
if(totalNameLen < TSDB_TABLE_NAME_LEN){
|
||||
if (totalNameLen < TSDB_TABLE_NAME_LEN) {
|
||||
autoChildName = true;
|
||||
}
|
||||
}
|
||||
if(autoChildName){
|
||||
if (autoChildName) {
|
||||
memset(childTableName, 0, TSDB_TABLE_NAME_LEN);
|
||||
for (int i = 0; i < taosArrayGetSize(tags); i++) {
|
||||
SSmlKv *tag = (SSmlKv *)taosArrayGet(tags, i);
|
||||
strncat(childTableName, tag->value, tag->length);
|
||||
if(i != taosArrayGetSize(tags) - 1){
|
||||
if (i != taosArrayGetSize(tags) - 1) {
|
||||
strcat(childTableName, tsSmlAutoChildTableNameDelimiter);
|
||||
}
|
||||
}
|
||||
if(tsSmlDot2Underline){
|
||||
if (tsSmlDot2Underline) {
|
||||
smlStrReplace(childTableName, strlen(childTableName));
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
size_t childTableNameLen = strlen(tsSmlChildTableName);
|
||||
if (childTableNameLen <= 0) return TSDB_CODE_SUCCESS;
|
||||
|
||||
|
@ -468,7 +470,7 @@ static int32_t smlParseTableName(SArray *tags, char *childTableName) {
|
|||
if (childTableNameLen == tag->keyLen && strncmp(tag->key, tsSmlChildTableName, tag->keyLen) == 0) {
|
||||
memset(childTableName, 0, TSDB_TABLE_NAME_LEN);
|
||||
strncpy(childTableName, tag->value, (tag->length < TSDB_TABLE_NAME_LEN ? tag->length : TSDB_TABLE_NAME_LEN));
|
||||
if(tsSmlDot2Underline){
|
||||
if (tsSmlDot2Underline) {
|
||||
smlStrReplace(childTableName, strlen(childTableName));
|
||||
}
|
||||
taosArrayRemove(tags, i);
|
||||
|
@ -484,15 +486,15 @@ int32_t smlSetCTableName(SSmlTableInfo *oneTable) {
|
|||
smlParseTableName(oneTable->tags, oneTable->childTableName);
|
||||
|
||||
if (strlen(oneTable->childTableName) == 0) {
|
||||
SArray *dst = taosArrayDup(oneTable->tags, NULL);
|
||||
SArray *dst = taosArrayDup(oneTable->tags, NULL);
|
||||
ASSERT(oneTable->sTableNameLen < TSDB_TABLE_NAME_LEN);
|
||||
char superName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
char superName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
RandTableName rName = {dst, NULL, (uint8_t)oneTable->sTableNameLen, oneTable->childTableName};
|
||||
if(tsSmlDot2Underline){
|
||||
if (tsSmlDot2Underline) {
|
||||
memcpy(superName, oneTable->sTableName, oneTable->sTableNameLen);
|
||||
smlStrReplace(superName, oneTable->sTableNameLen);
|
||||
rName.stbFullName = superName;
|
||||
}else{
|
||||
} else {
|
||||
rName.stbFullName = oneTable->sTableName;
|
||||
}
|
||||
|
||||
|
@ -506,7 +508,7 @@ void getTableUid(SSmlHandle *info, SSmlLineInfo *currElement, SSmlTableInfo *tin
|
|||
char key[TSDB_TABLE_NAME_LEN * 2 + 1] = {0};
|
||||
size_t nLen = strlen(tinfo->childTableName);
|
||||
memcpy(key, currElement->measure, currElement->measureLen);
|
||||
if(tsSmlDot2Underline){
|
||||
if (tsSmlDot2Underline) {
|
||||
smlStrReplace(key, currElement->measureLen);
|
||||
}
|
||||
memcpy(key + currElement->measureLen + 1, tinfo->childTableName, nLen);
|
||||
|
@ -522,7 +524,7 @@ void getTableUid(SSmlHandle *info, SSmlLineInfo *currElement, SSmlTableInfo *tin
|
|||
}
|
||||
|
||||
static void smlDestroySTableMeta(void *para) {
|
||||
SSmlSTableMeta *meta = *(SSmlSTableMeta**)para;
|
||||
SSmlSTableMeta *meta = *(SSmlSTableMeta **)para;
|
||||
taosHashCleanup(meta->tagHash);
|
||||
taosHashCleanup(meta->colHash);
|
||||
taosArrayDestroy(meta->tags);
|
||||
|
@ -783,7 +785,8 @@ static int32_t smlGenerateSchemaAction(SSchema *colField, SHashObj *colHash, SSm
|
|||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (((colField[*index].type == TSDB_DATA_TYPE_VARCHAR || colField[*index].type == TSDB_DATA_TYPE_VARBINARY || colField[*index].type == TSDB_DATA_TYPE_GEOMETRY) &&
|
||||
if (((colField[*index].type == TSDB_DATA_TYPE_VARCHAR || colField[*index].type == TSDB_DATA_TYPE_VARBINARY ||
|
||||
colField[*index].type == TSDB_DATA_TYPE_GEOMETRY) &&
|
||||
(colField[*index].bytes - VARSTR_HEADER_SIZE) < kv->length) ||
|
||||
(colField[*index].type == TSDB_DATA_TYPE_NCHAR &&
|
||||
((colField[*index].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE < kv->length))) {
|
||||
|
@ -814,7 +817,8 @@ static int32_t smlFindNearestPowerOf2(int32_t length, uint8_t type) {
|
|||
}
|
||||
}
|
||||
|
||||
if ((type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY || type == TSDB_DATA_TYPE_GEOMETRY) && result > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) {
|
||||
if ((type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY || type == TSDB_DATA_TYPE_GEOMETRY) &&
|
||||
result > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) {
|
||||
result = TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE;
|
||||
} else if (type == TSDB_DATA_TYPE_NCHAR && result > (TSDB_MAX_NCHAR_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
||||
result = (TSDB_MAX_NCHAR_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
||||
|
@ -866,7 +870,8 @@ static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols, bool
|
|||
}
|
||||
|
||||
static int32_t getBytes(uint8_t type, int32_t length) {
|
||||
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY || type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY || type == TSDB_DATA_TYPE_NCHAR ||
|
||||
type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
return smlFindNearestPowerOf2(length, type);
|
||||
} else {
|
||||
return tDataTypes[type].bytes;
|
||||
|
@ -907,7 +912,7 @@ static int32_t smlBuildFieldsList(SSmlHandle *info, SSchema *schemaField, SHashO
|
|||
SField *field = taosArrayGet(results, j);
|
||||
len += field->bytes;
|
||||
}
|
||||
if(len > maxLen){
|
||||
if (len > maxLen) {
|
||||
return isTag ? TSDB_CODE_PAR_INVALID_TAGS_LENGTH : TSDB_CODE_PAR_INVALID_ROW_LENGTH;
|
||||
}
|
||||
|
||||
|
@ -924,7 +929,15 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SArray *pColumns,
|
|||
|
||||
// put front for free
|
||||
pReq.numOfColumns = taosArrayGetSize(pColumns);
|
||||
pReq.pColumns = pColumns;
|
||||
pReq.pColumns = taosArrayInit(pReq.numOfColumns, sizeof(SFieldWithOptions));
|
||||
for (int32_t i = 0; i < pReq.numOfColumns; ++i) {
|
||||
SField *pField = taosArrayGet(pColumns, i);
|
||||
SFieldWithOptions fieldWithOption;
|
||||
setFieldWithOptions(&fieldWithOption, pField);
|
||||
setDefaultOptionsForField(&fieldWithOption);
|
||||
taosArrayPush(pReq.pColumns, &fieldWithOption);
|
||||
}
|
||||
|
||||
pReq.numOfTags = taosArrayGetSize(pTags);
|
||||
pReq.pTags = pTags;
|
||||
|
||||
|
@ -946,7 +959,7 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SArray *pColumns,
|
|||
pReq.suid = pTableMeta->uid;
|
||||
pReq.source = TD_REQ_FROM_TAOX;
|
||||
pSql = (action == SCHEMA_ACTION_ADD_COLUMN) ? "sml_add_column" : "sml_modify_column_size";
|
||||
} else{
|
||||
} else {
|
||||
uError("SML:0x%" PRIx64 " invalid action:%d", info->id, action);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1044,7 +1057,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
|
||||
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_MND_STB_NOT_EXIST) {
|
||||
code = smlCheckAuth(info, &conn, NULL, AUTH_TYPE_WRITE);
|
||||
if(code != TSDB_CODE_SUCCESS){
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
uDebug("SML:0x%" PRIx64 " smlModifyDBSchemas create table:%s", info->id, pName.tname);
|
||||
|
@ -1065,6 +1078,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
goto end;
|
||||
}
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, NULL, SCHEMA_ACTION_CREATE_STABLE);
|
||||
taosArrayDestroy(pColumns);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
|
@ -1098,7 +1112,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
}
|
||||
if (action != SCHEMA_ACTION_NULL) {
|
||||
code = smlCheckAuth(info, &conn, pName.tname, AUTH_TYPE_WRITE);
|
||||
if(code != TSDB_CODE_SUCCESS){
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
uDebug("SML:0x%" PRIx64 " smlModifyDBSchemas change table tag, table:%s, action:%d", info->id, pName.tname,
|
||||
|
@ -1144,6 +1158,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
}
|
||||
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action);
|
||||
taosArrayDestroy(pColumns);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
|
@ -1172,7 +1187,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
}
|
||||
if (action != SCHEMA_ACTION_NULL) {
|
||||
code = smlCheckAuth(info, &conn, pName.tname, AUTH_TYPE_WRITE);
|
||||
if(code != TSDB_CODE_SUCCESS){
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
uDebug("SML:0x%" PRIx64 " smlModifyDBSchemas change table col, table:%s, action:%d", info->id, pName.tname,
|
||||
|
@ -1212,6 +1227,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
}
|
||||
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action);
|
||||
taosArrayDestroy(pColumns);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
|
@ -1324,7 +1340,7 @@ static int32_t smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols
|
|||
}
|
||||
|
||||
void smlDestroyTableInfo(void *para) {
|
||||
SSmlTableInfo *tag = *(SSmlTableInfo**)para;
|
||||
SSmlTableInfo *tag = *(SSmlTableInfo **)para;
|
||||
for (size_t i = 0; i < taosArrayGetSize(tag->cols); i++) {
|
||||
SHashObj *kvHash = (SHashObj *)taosArrayGetP(tag->cols, i);
|
||||
taosHashCleanup(kvHash);
|
||||
|
@ -1508,7 +1524,7 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
|
|||
uDebug("SML:0x%" PRIx64 " smlParseLineBottom add meta, format:%d, linenum:%d", info->id, info->dataFormat,
|
||||
info->lineNum);
|
||||
SSmlSTableMeta *meta = smlBuildSTableMeta(info->dataFormat);
|
||||
if(meta == NULL){
|
||||
if (meta == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
taosHashPut(info->superTables, elements->measure, elements->measureLen, &meta, POINTER_BYTES);
|
||||
|
@ -1563,7 +1579,7 @@ static int32_t smlInsertData(SSmlHandle *info) {
|
|||
conn.mgmtEps = getEpSet_s(&info->taos->pAppInfo->mgmtEp);
|
||||
|
||||
code = smlCheckAuth(info, &conn, pName.tname, AUTH_TYPE_WRITE);
|
||||
if(code != TSDB_CODE_SUCCESS){
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(measure);
|
||||
taosHashCancelIterate(info->childTables, oneTable);
|
||||
return code;
|
||||
|
@ -1633,7 +1649,6 @@ static void smlPrintStatisticInfo(SSmlHandle *info) {
|
|||
info->cost.numOfAlterColSTables, info->cost.schemaTime - info->cost.parseTime,
|
||||
info->cost.insertBindTime - info->cost.schemaTime, info->cost.insertRpcTime - info->cost.insertBindTime,
|
||||
info->cost.endTime - info->cost.insertRpcTime, info->cost.endTime - info->cost.parseTime);
|
||||
|
||||
}
|
||||
|
||||
int32_t smlClearForRerun(SSmlHandle *info) {
|
||||
|
@ -1661,8 +1676,8 @@ int32_t smlClearForRerun(SSmlHandle *info) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static bool getLine(SSmlHandle *info, char *lines[], char **rawLine, char *rawLineEnd,
|
||||
int numLines, int i, char** tmp, int *len){
|
||||
static bool getLine(SSmlHandle *info, char *lines[], char **rawLine, char *rawLineEnd, int numLines, int i, char **tmp,
|
||||
int *len) {
|
||||
if (lines) {
|
||||
*tmp = lines[i];
|
||||
*len = strlen(*tmp);
|
||||
|
@ -1679,15 +1694,15 @@ static bool getLine(SSmlHandle *info, char *lines[], char **rawLine, char *rawLi
|
|||
}
|
||||
}
|
||||
|
||||
if(*rawLine != NULL && (uDebugFlag & DEBUG_DEBUG)){
|
||||
char* print = taosMemoryCalloc(*len + 1, 1);
|
||||
if (*rawLine != NULL && (uDebugFlag & DEBUG_DEBUG)) {
|
||||
char *print = taosMemoryCalloc(*len + 1, 1);
|
||||
memcpy(print, *tmp, *len);
|
||||
uDebug("SML:0x%" PRIx64 " smlParseLine is raw, numLines:%d, protocol:%d, len:%d, data:%s", info->id,
|
||||
numLines, info->protocol, *len, print);
|
||||
uDebug("SML:0x%" PRIx64 " smlParseLine is raw, numLines:%d, protocol:%d, len:%d, data:%s", info->id, numLines,
|
||||
info->protocol, *len, print);
|
||||
taosMemoryFree(print);
|
||||
}else{
|
||||
uDebug("SML:0x%" PRIx64 " smlParseLine is not numLines:%d, protocol:%d, len:%d, data:%s", info->id,
|
||||
numLines, info->protocol, *len, *tmp);
|
||||
} else {
|
||||
uDebug("SML:0x%" PRIx64 " smlParseLine is not numLines:%d, protocol:%d, len:%d, data:%s", info->id, numLines,
|
||||
info->protocol, *len, *tmp);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1713,7 +1728,7 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char
|
|||
while (i < numLines) {
|
||||
char *tmp = NULL;
|
||||
int len = 0;
|
||||
if(!getLine(info, lines, &rawLine, rawLineEnd, numLines, i, &tmp, &len)){
|
||||
if (!getLine(info, lines, &rawLine, rawLineEnd, numLines, i, &tmp, &len)) {
|
||||
continue;
|
||||
}
|
||||
if (info->protocol == TSDB_SML_LINE_PROTOCOL) {
|
||||
|
@ -1735,12 +1750,12 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char
|
|||
code = TSDB_CODE_SML_INVALID_PROTOCOL_TYPE;
|
||||
}
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
if(rawLine != NULL){
|
||||
char* print = taosMemoryCalloc(len + 1, 1);
|
||||
if (rawLine != NULL) {
|
||||
char *print = taosMemoryCalloc(len + 1, 1);
|
||||
memcpy(print, tmp, len);
|
||||
uError("SML:0x%" PRIx64 " smlParseLine failed. line %d : %s", info->id, i, print);
|
||||
taosMemoryFree(print);
|
||||
}else{
|
||||
} else {
|
||||
uError("SML:0x%" PRIx64 " smlParseLine failed. line %d : %s", info->id, i, tmp);
|
||||
}
|
||||
return code;
|
||||
|
@ -1787,7 +1802,8 @@ static int smlProcess(SSmlHandle *info, char *lines[], char *rawLine, char *rawL
|
|||
|
||||
do {
|
||||
code = smlModifyDBSchemas(info);
|
||||
if (code != TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER && code != TSDB_CODE_SDB_OBJ_CREATING && code != TSDB_CODE_MND_TRANS_CONFLICT) {
|
||||
if (code != TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER && code != TSDB_CODE_SDB_OBJ_CREATING &&
|
||||
code != TSDB_CODE_MND_TRANS_CONFLICT) {
|
||||
break;
|
||||
}
|
||||
taosMsleep(100);
|
||||
|
@ -1813,7 +1829,7 @@ void smlSetReqSQL(SRequestObj *request, char *lines[], char *rawLine, char *rawL
|
|||
if (tsSlowLogScope & SLOW_LOG_TYPE_INSERT) {
|
||||
int32_t len = 0;
|
||||
int32_t rlen = 0;
|
||||
char* p = NULL;
|
||||
char *p = NULL;
|
||||
|
||||
if (lines && lines[0]) {
|
||||
len = strlen(lines[0]);
|
||||
|
@ -1912,8 +1928,8 @@ TAOS_RES *taos_schemaless_insert_inner(TAOS *taos, char *lines[], char *rawLine,
|
|||
request->code = code;
|
||||
info->cost.endTime = taosGetTimestampUs();
|
||||
info->cost.code = code;
|
||||
if (NEED_CLIENT_HANDLE_ERROR(code) || code == TSDB_CODE_SDB_OBJ_CREATING ||
|
||||
code == TSDB_CODE_PAR_VALUE_TOO_LONG || code == TSDB_CODE_MND_TRANS_CONFLICT) {
|
||||
if (NEED_CLIENT_HANDLE_ERROR(code) || code == TSDB_CODE_SDB_OBJ_CREATING || code == TSDB_CODE_PAR_VALUE_TOO_LONG ||
|
||||
code == TSDB_CODE_MND_TRANS_CONFLICT) {
|
||||
if (cnt++ >= 10) {
|
||||
uInfo("SML:%" PRIx64 " retry:%d/10 end code:%d, msg:%s", info->id, cnt, code, tstrerror(code));
|
||||
break;
|
||||
|
@ -1976,7 +1992,7 @@ TAOS_RES *taos_schemaless_insert_with_reqid(TAOS *taos, char *lines[], int numLi
|
|||
reqid);
|
||||
}
|
||||
|
||||
static void getRawLineLen(char *lines, int len, int32_t *totalRows, int protocol){
|
||||
static void getRawLineLen(char *lines, int len, int32_t *totalRows, int protocol) {
|
||||
int numLines = 0;
|
||||
*totalRows = 0;
|
||||
char *tmp = lines;
|
||||
|
|
|
@ -622,9 +622,9 @@ static void asyncCommitFromResult(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_c
|
|||
|
||||
if (TD_RES_TMQ(pRes)) {
|
||||
SMqRspObj* pRspObj = (SMqRspObj*)pRes;
|
||||
pTopicName = pRspObj->topic;
|
||||
vgId = pRspObj->vgId;
|
||||
offsetVal = pRspObj->rsp.rspOffset;
|
||||
pTopicName = pRspObj->common.topic;
|
||||
vgId = pRspObj->common.vgId;
|
||||
offsetVal = pRspObj->rsp.common.rspOffset;
|
||||
} else if (TD_RES_TMQ_META(pRes)) {
|
||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)pRes;
|
||||
pTopicName = pMetaRspObj->topic;
|
||||
|
@ -632,9 +632,9 @@ static void asyncCommitFromResult(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_c
|
|||
offsetVal = pMetaRspObj->metaRsp.rspOffset;
|
||||
} else if (TD_RES_TMQ_METADATA(pRes)) {
|
||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)pRes;
|
||||
pTopicName = pRspObj->topic;
|
||||
vgId = pRspObj->vgId;
|
||||
offsetVal = pRspObj->rsp.rspOffset;
|
||||
pTopicName = pRspObj->common.topic;
|
||||
vgId = pRspObj->common.vgId;
|
||||
offsetVal = pRspObj->rsp.common.rspOffset;
|
||||
} else {
|
||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
||||
goto end;
|
||||
|
@ -1056,17 +1056,17 @@ static void tmqMgmtInit(void) {
|
|||
}
|
||||
}
|
||||
|
||||
#define SET_ERROR_MSG(MSG) \
|
||||
#define SET_ERROR_MSG_TMQ(MSG) \
|
||||
if (errstr != NULL) snprintf(errstr, errstrLen, MSG);
|
||||
tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
||||
if (conf == NULL) {
|
||||
SET_ERROR_MSG("configure is null")
|
||||
SET_ERROR_MSG_TMQ("configure is null")
|
||||
return NULL;
|
||||
}
|
||||
taosThreadOnce(&tmqInit, tmqMgmtInit);
|
||||
if (tmqInitRes != 0) {
|
||||
terrno = tmqInitRes;
|
||||
SET_ERROR_MSG("tmq timer init error")
|
||||
SET_ERROR_MSG_TMQ("tmq timer init error")
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1074,7 +1074,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
if (pTmq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tscError("failed to create consumer, groupId:%s, code:%s", conf->groupId, terrstr());
|
||||
SET_ERROR_MSG("malloc tmq failed")
|
||||
SET_ERROR_MSG_TMQ("malloc tmq failed")
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1090,7 +1090,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
conf->groupId[0] == 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
||||
SET_ERROR_MSG("malloc tmq element failed or group is empty")
|
||||
SET_ERROR_MSG_TMQ("malloc tmq element failed or group is empty")
|
||||
goto _failed;
|
||||
}
|
||||
|
||||
|
@ -1123,7 +1123,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
if (tsem_init(&pTmq->rspSem, 0, 0) != 0) {
|
||||
tscError("consumer:0x %" PRIx64 " setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(),
|
||||
pTmq->groupId);
|
||||
SET_ERROR_MSG("init t_sem failed")
|
||||
SET_ERROR_MSG_TMQ("init t_sem failed")
|
||||
goto _failed;
|
||||
}
|
||||
|
||||
|
@ -1132,13 +1132,13 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
if (pTmq->pTscObj == NULL) {
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
||||
tsem_destroy(&pTmq->rspSem);
|
||||
SET_ERROR_MSG("init tscObj failed")
|
||||
SET_ERROR_MSG_TMQ("init tscObj failed")
|
||||
goto _failed;
|
||||
}
|
||||
|
||||
pTmq->refId = taosAddRef(tmqMgmt.rsetId, pTmq);
|
||||
if (pTmq->refId < 0) {
|
||||
SET_ERROR_MSG("add tscObj ref failed")
|
||||
SET_ERROR_MSG_TMQ("add tscObj ref failed")
|
||||
goto _failed;
|
||||
}
|
||||
|
||||
|
@ -1377,7 +1377,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (rspType == TMQ_MSG_TYPE__POLL_DATA_RSP) {
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
||||
if(tDecodeMqDataRsp(&decoder, &pRspWrapper->dataRsp, *(int8_t*)POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead))) < 0){
|
||||
if(tDecodeMqDataRsp(&decoder, &pRspWrapper->dataRsp) < 0){
|
||||
tDecoderClear(&decoder);
|
||||
taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1387,9 +1387,9 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead));
|
||||
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pRspWrapper->dataRsp.rspOffset);
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pRspWrapper->dataRsp.common.rspOffset);
|
||||
tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req ver:%" PRId64 ", rsp:%s type %d, reqId:0x%" PRIx64,
|
||||
tmq->consumerId, vgId, pRspWrapper->dataRsp.reqOffset.version, buf, rspType, requestId);
|
||||
tmq->consumerId, vgId, pRspWrapper->dataRsp.common.reqOffset.version, buf, rspType, requestId);
|
||||
} else if (rspType == TMQ_MSG_TYPE__POLL_META_RSP) {
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
||||
|
@ -1404,7 +1404,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
} else if (rspType == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
||||
if(tDecodeSTaosxRsp(&decoder, &pRspWrapper->taosxRsp, *(int8_t*)POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead))) < 0){
|
||||
if(tDecodeSTaosxRsp(&decoder, &pRspWrapper->taosxRsp) < 0){
|
||||
tDecoderClear(&decoder);
|
||||
taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1598,6 +1598,9 @@ void tmqBuildConsumeReqImpl(SMqPollReq* pReq, tmq_t* tmq, int64_t timeout, SMqCl
|
|||
|
||||
SMqMetaRspObj* tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
||||
SMqMetaRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqMetaRspObj));
|
||||
if(pRspObj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
pRspObj->resType = RES_TYPE__TMQ_META;
|
||||
tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||
tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN);
|
||||
|
@ -1611,8 +1614,7 @@ SMqMetaRspObj* tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
|||
void changeByteEndian(char* pData){
|
||||
char* p = pData;
|
||||
|
||||
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length |
|
||||
// version:
|
||||
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length | version:
|
||||
int32_t blockVersion = *(int32_t*)p;
|
||||
ASSERT(blockVersion == BLOCK_VERSION_1);
|
||||
*(int32_t*)p = BLOCK_VERSION_2;
|
||||
|
@ -1649,7 +1651,7 @@ static void tmqGetRawDataRowsPrecisionFromRes(void *pRetrieve, void** rawData, i
|
|||
}
|
||||
}
|
||||
|
||||
static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows, SMqRspObj* pRspObj) {
|
||||
static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows, SMqRspObjCommon* pRspObj, SMqDataRspCommon* pDataRsp) {
|
||||
(*numOfRows) = 0;
|
||||
tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||
tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN);
|
||||
|
@ -1660,14 +1662,14 @@ static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg
|
|||
pRspObj->resInfo.totalRows = 0;
|
||||
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
||||
|
||||
bool needTransformSchema = !pRspObj->rsp.withSchema;
|
||||
if (!pRspObj->rsp.withSchema) { // withSchema is false if subscribe subquery, true if subscribe db or stable
|
||||
pRspObj->rsp.withSchema = true;
|
||||
pRspObj->rsp.blockSchema = taosArrayInit(pRspObj->rsp.blockNum, sizeof(void*));
|
||||
bool needTransformSchema = !pDataRsp->withSchema;
|
||||
if (!pDataRsp->withSchema) { // withSchema is false if subscribe subquery, true if subscribe db or stable
|
||||
pDataRsp->withSchema = true;
|
||||
pDataRsp->blockSchema = taosArrayInit(pDataRsp->blockNum, sizeof(void*));
|
||||
}
|
||||
// extract the rows in this data packet
|
||||
for (int32_t i = 0; i < pRspObj->rsp.blockNum; ++i) {
|
||||
void* pRetrieve = taosArrayGetP(pRspObj->rsp.blockData, i);
|
||||
for (int32_t i = 0; i < pDataRsp->blockNum; ++i) {
|
||||
void* pRetrieve = taosArrayGetP(pDataRsp->blockData, i);
|
||||
void* rawData = NULL;
|
||||
int64_t rows = 0;
|
||||
// deal with compatibility
|
||||
|
@ -1679,7 +1681,7 @@ static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg
|
|||
if (needTransformSchema) { //withSchema is false if subscribe subquery, true if subscribe db or stable
|
||||
SSchemaWrapper *schema = tCloneSSchemaWrapper(&pWrapper->topicHandle->schema);
|
||||
if(schema){
|
||||
taosArrayPush(pRspObj->rsp.blockSchema, &schema);
|
||||
taosArrayPush(pDataRsp->blockSchema, &schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1687,18 +1689,24 @@ static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg
|
|||
|
||||
SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows) {
|
||||
SMqRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqRspObj));
|
||||
pRspObj->resType = RES_TYPE__TMQ;
|
||||
if(pRspObj == NULL){
|
||||
return NULL;
|
||||
}
|
||||
pRspObj->common.resType = RES_TYPE__TMQ;
|
||||
memcpy(&pRspObj->rsp, &pWrapper->dataRsp, sizeof(SMqDataRsp));
|
||||
tmqBuildRspFromWrapperInner(pWrapper, pVg, numOfRows, pRspObj);
|
||||
tmqBuildRspFromWrapperInner(pWrapper, pVg, numOfRows, &pRspObj->common, &pRspObj->rsp.common);
|
||||
return pRspObj;
|
||||
}
|
||||
|
||||
SMqTaosxRspObj* tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows) {
|
||||
SMqTaosxRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqTaosxRspObj));
|
||||
pRspObj->resType = RES_TYPE__TMQ_METADATA;
|
||||
if(pRspObj == NULL){
|
||||
return NULL;
|
||||
}
|
||||
pRspObj->common.resType = RES_TYPE__TMQ_METADATA;
|
||||
memcpy(&pRspObj->rsp, &pWrapper->taosxRsp, sizeof(STaosxRsp));
|
||||
|
||||
tmqBuildRspFromWrapperInner(pWrapper, pVg, numOfRows, (SMqRspObj*)pRspObj);
|
||||
tmqBuildRspFromWrapperInner(pWrapper, pVg, numOfRows, &pRspObj->common, &pRspObj->rsp.common);
|
||||
return pRspObj;
|
||||
}
|
||||
|
||||
|
@ -1891,7 +1899,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)pRspWrapper;
|
||||
|
||||
int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
|
||||
SMqDataRsp* pDataRsp = &pollRspWrapper->dataRsp;
|
||||
SMqDataRspCommon* pDataRsp = (SMqDataRspCommon*)&pollRspWrapper->dataRsp;
|
||||
|
||||
if (pDataRsp->head.epoch == consumerEpoch) {
|
||||
taosWLockLatch(&tmq->lock);
|
||||
|
@ -1994,8 +2002,9 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
} else if (pRspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
||||
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)pRspWrapper;
|
||||
int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
|
||||
SMqDataRspCommon* pDataRsp = (SMqDataRspCommon*)&pollRspWrapper->taosxRsp;
|
||||
|
||||
if (pollRspWrapper->taosxRsp.head.epoch == consumerEpoch) {
|
||||
if (pDataRsp->head.epoch == consumerEpoch) {
|
||||
taosWLockLatch(&tmq->lock);
|
||||
SMqClientVg* pVg = getVgInfo(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId);
|
||||
pollRspWrapper->vgHandle = pVg;
|
||||
|
@ -2009,11 +2018,11 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
updateVgInfo(pVg, &pollRspWrapper->taosxRsp.reqOffset, &pollRspWrapper->taosxRsp.rspOffset,
|
||||
pollRspWrapper->taosxRsp.head.walsver, pollRspWrapper->taosxRsp.head.walever, tmq->consumerId,
|
||||
pollRspWrapper->taosxRsp.blockNum != 0);
|
||||
updateVgInfo(pVg, &pDataRsp->reqOffset, &pDataRsp->rspOffset,
|
||||
pDataRsp->head.walsver, pDataRsp->head.walever, tmq->consumerId,
|
||||
pDataRsp->blockNum != 0);
|
||||
|
||||
if (pollRspWrapper->taosxRsp.blockNum == 0) {
|
||||
if (pDataRsp->blockNum == 0) {
|
||||
tscDebug("consumer:0x%" PRIx64 " taosx empty block received, vgId:%d, vg total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||
tmq->consumerId, pVg->vgId, pVg->numOfRows, pollRspWrapper->reqId);
|
||||
pVg->emptyBlockReceiveTs = taosGetTimestampMs();
|
||||
|
@ -2034,7 +2043,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pVg->offsetInfo.endOffset);
|
||||
tscDebug("consumer:0x%" PRIx64 " process taosx poll rsp, vgId:%d, offset:%s, blocks:%d, rows:%" PRId64
|
||||
", vg total:%" PRId64 ", total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||
tmq->consumerId, pVg->vgId, buf, pollRspWrapper->dataRsp.blockNum, numOfRows, pVg->numOfRows,
|
||||
tmq->consumerId, pVg->vgId, buf, pDataRsp->blockNum, numOfRows, pVg->numOfRows,
|
||||
tmq->totalRows, pollRspWrapper->reqId);
|
||||
|
||||
taosFreeQitem(pRspWrapper);
|
||||
|
@ -2042,7 +2051,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
return pRsp;
|
||||
} else {
|
||||
tscInfo("consumer:0x%" PRIx64 " vgId:%d msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
||||
tmq->consumerId, pollRspWrapper->vgId, pollRspWrapper->taosxRsp.head.epoch, consumerEpoch);
|
||||
tmq->consumerId, pollRspWrapper->vgId, pDataRsp->head.epoch, consumerEpoch);
|
||||
setVgIdle(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId);
|
||||
tmqFreeRspWrapper(pRspWrapper);
|
||||
taosFreeQitem(pRspWrapper);
|
||||
|
@ -2182,7 +2191,12 @@ const char* tmq_err2str(int32_t err) {
|
|||
} else if (err == -1) {
|
||||
return "fail";
|
||||
} else {
|
||||
return tstrerror(err);
|
||||
if(*(taosGetErrMsg()) == 0){
|
||||
return tstrerror(err);
|
||||
} else{
|
||||
snprintf(taosGetErrMsgReturn(), ERR_MSG_LEN, "%s,detail:%s", tstrerror(err), taosGetErrMsg());
|
||||
return (const char*)taosGetErrMsgReturn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2205,15 +2219,11 @@ const char* tmq_get_topic_name(TAOS_RES* res) {
|
|||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||
return strchr(pRspObj->topic, '.') + 1;
|
||||
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
return strchr(((SMqRspObjCommon*)res)->topic, '.') + 1;
|
||||
} else if (TD_RES_TMQ_META(res)) {
|
||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||
return strchr(pMetaRspObj->topic, '.') + 1;
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res;
|
||||
return strchr(pRspObj->topic, '.') + 1;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2224,15 +2234,11 @@ const char* tmq_get_db_name(TAOS_RES* res) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||
return strchr(pRspObj->db, '.') + 1;
|
||||
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
return strchr(((SMqRspObjCommon*)res)->db, '.') + 1;
|
||||
} else if (TD_RES_TMQ_META(res)) {
|
||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||
return strchr(pMetaRspObj->db, '.') + 1;
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res;
|
||||
return strchr(pRspObj->db, '.') + 1;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2242,15 +2248,11 @@ int32_t tmq_get_vgroup_id(TAOS_RES* res) {
|
|||
if (res == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||
return pRspObj->vgId;
|
||||
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
return ((SMqRspObjCommon*)res)->vgId;
|
||||
} else if (TD_RES_TMQ_META(res)) {
|
||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||
return pMetaRspObj->vgId;
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res;
|
||||
return pRspObj->vgId;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
@ -2260,24 +2262,19 @@ int64_t tmq_get_vgroup_offset(TAOS_RES* res) {
|
|||
if (res == NULL) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||
STqOffsetVal* pOffset = &pRspObj->rsp.reqOffset;
|
||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
return pRspObj->rsp.reqOffset.version;
|
||||
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
SMqDataRspCommon* common = (SMqDataRspCommon*)POINTER_SHIFT(res, sizeof(SMqRspObjCommon));
|
||||
STqOffsetVal* pOffset = &common->reqOffset;
|
||||
if (common->reqOffset.type == TMQ_OFFSET__LOG) {
|
||||
return common->reqOffset.version;
|
||||
} else {
|
||||
tscError("invalid offset type:%d", pOffset->type);
|
||||
tscError("invalid offset type:%d", common->reqOffset.type);
|
||||
}
|
||||
} else if (TD_RES_TMQ_META(res)) {
|
||||
SMqMetaRspObj* pRspObj = (SMqMetaRspObj*)res;
|
||||
if (pRspObj->metaRsp.rspOffset.type == TMQ_OFFSET__LOG) {
|
||||
return pRspObj->metaRsp.rspOffset.version;
|
||||
}
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res;
|
||||
if (pRspObj->rsp.reqOffset.type == TMQ_OFFSET__LOG) {
|
||||
return pRspObj->rsp.reqOffset.version;
|
||||
}
|
||||
} else {
|
||||
tscError("invalid tmq type:%d", *(int8_t*)res);
|
||||
}
|
||||
|
@ -2290,20 +2287,15 @@ const char* tmq_get_table_name(TAOS_RES* res) {
|
|||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||
if (!pRspObj->rsp.withTbName || pRspObj->rsp.blockTbName == NULL || pRspObj->resIter < 0 ||
|
||||
pRspObj->resIter >= pRspObj->rsp.blockNum) {
|
||||
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
SMqDataRspCommon* common = (SMqDataRspCommon*)POINTER_SHIFT(res, sizeof(SMqRspObjCommon));
|
||||
|
||||
SMqRspObjCommon* pRspObj = (SMqRspObjCommon*)res;
|
||||
if (!common->withTbName || common->blockTbName == NULL || pRspObj->resIter < 0 ||
|
||||
pRspObj->resIter >= common->blockNum) {
|
||||
return NULL;
|
||||
}
|
||||
return (const char*)taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter);
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res;
|
||||
if (!pRspObj->rsp.withTbName || pRspObj->rsp.blockTbName == NULL || pRspObj->resIter < 0 ||
|
||||
pRspObj->resIter >= pRspObj->rsp.blockNum) {
|
||||
return NULL;
|
||||
}
|
||||
return (const char*)taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter);
|
||||
return (const char*)taosArrayGetP(common->blockTbName, pRspObj->resIter);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2640,17 +2632,17 @@ void commitRspCountDown(SMqCommitCbParamSet* pParamSet, int64_t consumerId, cons
|
|||
}
|
||||
|
||||
SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4) {
|
||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||
SMqDataRspCommon* common = (SMqDataRspCommon*)POINTER_SHIFT(res, sizeof(SMqRspObjCommon));
|
||||
SMqRspObjCommon* pRspObj = (SMqRspObjCommon*)res;
|
||||
pRspObj->resIter++;
|
||||
|
||||
if (pRspObj->resIter < pRspObj->rsp.blockNum) {
|
||||
if (pRspObj->rsp.withSchema) {
|
||||
if (pRspObj->resIter < common->blockNum) {
|
||||
if (common->withSchema) {
|
||||
doFreeReqResultInfo(&pRspObj->resInfo);
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(pRspObj->rsp.blockSchema, pRspObj->resIter);
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(common->blockSchema, pRspObj->resIter);
|
||||
setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols);
|
||||
}
|
||||
|
||||
void* pRetrieve = taosArrayGetP(pRspObj->rsp.blockData, pRspObj->resIter);
|
||||
void* pRetrieve = taosArrayGetP(common->blockData, pRspObj->resIter);
|
||||
void* rawData = NULL;
|
||||
int64_t rows = 0;
|
||||
int32_t precision = 0;
|
||||
|
@ -2685,14 +2677,14 @@ static int32_t tmqGetWalInfoCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
SMqDataRsp rsp;
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
||||
tDecodeMqDataRsp(&decoder, &rsp, *(int8_t*)POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)));
|
||||
tDecodeMqDataRsp(&decoder, &rsp);
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
SMqRspHead* pHead = pMsg->pData;
|
||||
|
||||
tmq_topic_assignment assignment = {.begin = pHead->walsver,
|
||||
.end = pHead->walever + 1,
|
||||
.currentOffset = rsp.rspOffset.version,
|
||||
.currentOffset = rsp.common.rspOffset.version,
|
||||
.vgId = pParam->vgId};
|
||||
|
||||
taosThreadMutexLock(&pCommon->mutex);
|
||||
|
|
|
@ -121,6 +121,7 @@ static const SSysDbTableSchema userDBSchema[] = {
|
|||
{.name = "s3_keeplocal", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "s3_compact", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
||||
{.name = "with_arbitrator", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
||||
{.name = "encrypt_algorithm", .bytes = TSDB_ENCRYPT_ALGO_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userFuncSchema[] = {
|
||||
|
@ -372,6 +373,18 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = {
|
|||
{.name = "finished", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
static const SSysDbTableSchema tsmaSchema[] = {
|
||||
{.name = "tsma_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "target_db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "target_stb", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "stream_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "interval", .bytes = 64 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "create_sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "func_list", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userGrantsFullSchema[] = {
|
||||
{.name = "grant_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
|
@ -388,12 +401,15 @@ static const SSysDbTableSchema userGrantsLogsSchema[] = {
|
|||
|
||||
static const SSysDbTableSchema userMachinesSchema[] = {
|
||||
{.name = "id", .bytes = TSDB_CLUSTER_ID_LEN + 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
#ifndef TD_UNIQ_GRANT
|
||||
{.name = "dnode_num", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
#endif
|
||||
{.name = "machine", .bytes = 7552 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema encryptionsSchema[] = {
|
||||
{.name = "dnode_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "key_status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysTableMeta infosMeta[] = {
|
||||
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true},
|
||||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
||||
|
@ -427,6 +443,8 @@ static const SSysTableMeta infosMeta[] = {
|
|||
{TSDB_INS_TABLE_GRANTS_LOGS, userGrantsLogsSchema, tListLen(userGrantsLogsSchema), true},
|
||||
{TSDB_INS_TABLE_MACHINES, userMachinesSchema, tListLen(userMachinesSchema), true},
|
||||
{TSDB_INS_TABLE_ARBGROUPS, arbGroupsSchema, tListLen(arbGroupsSchema), true},
|
||||
{TSDB_INS_TABLE_ENCRYPTIONS, encryptionsSchema, tListLen(encryptionsSchema), true},
|
||||
{TSDB_INS_TABLE_TSMAS, tsmaSchema, tListLen(tsmaSchema), false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema connectionsSchema[] = {
|
||||
|
|
|
@ -0,0 +1,406 @@
|
|||
/*
|
||||
* 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 "tcol.h"
|
||||
#include "tcompression.h"
|
||||
#include "tutil.h"
|
||||
|
||||
const char* supportedEncode[5] = {TSDB_COLUMN_ENCODE_SIMPLE8B, TSDB_COLUMN_ENCODE_XOR, TSDB_COLUMN_ENCODE_RLE,
|
||||
TSDB_COLUMN_ENCODE_DELTAD, TSDB_COLUMN_ENCODE_DISABLED};
|
||||
|
||||
const char* supportedCompress[6] = {TSDB_COLUMN_COMPRESS_LZ4, TSDB_COLUMN_COMPRESS_TSZ,
|
||||
TSDB_COLUMN_COMPRESS_XZ, TSDB_COLUMN_COMPRESS_ZLIB,
|
||||
TSDB_COLUMN_COMPRESS_ZSTD, TSDB_COLUMN_COMPRESS_DISABLED};
|
||||
|
||||
const char* supportedLevel[3] = {TSDB_COLUMN_LEVEL_HIGH, TSDB_COLUMN_LEVEL_MEDIUM, TSDB_COLUMN_LEVEL_LOW};
|
||||
|
||||
const int supportedEncodeNum = sizeof(supportedEncode) / sizeof(char*);
|
||||
const int supportedCompressNum = sizeof(supportedCompress) / sizeof(char*);
|
||||
const int supportedLevelNum = sizeof(supportedLevel) / sizeof(char*);
|
||||
|
||||
uint8_t getDefaultEncode(uint8_t type) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_NULL:
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
return TSDB_COLVAL_ENCODE_RLE;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
return TSDB_COLVAL_ENCODE_DELTAD;
|
||||
case TSDB_DATA_TYPE_VARCHAR: // TSDB_DATA_TYPE_BINARY
|
||||
return TSDB_COLVAL_ENCODE_DISABLED;
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
return TSDB_COLVAL_ENCODE_XOR;
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
return TSDB_COLVAL_ENCODE_DISABLED;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||
case TSDB_DATA_TYPE_JSON:
|
||||
return TSDB_COLVAL_ENCODE_DISABLED;
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
return TSDB_COLVAL_ENCODE_DISABLED;
|
||||
case TSDB_DATA_TYPE_DECIMAL:
|
||||
return TSDB_COLVAL_ENCODE_DELTAD;
|
||||
case TSDB_DATA_TYPE_BLOB:
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||
case TSDB_DATA_TYPE_MEDIUMBLOB:
|
||||
case TSDB_DATA_TYPE_GEOMETRY:
|
||||
return TSDB_COLVAL_ENCODE_DISABLED;
|
||||
|
||||
case TSDB_DATA_TYPE_MAX:
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||
|
||||
default:
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||
}
|
||||
}
|
||||
const char* getDefaultEncodeStr(uint8_t type) { return columnEncodeStr(getDefaultEncode(type)); }
|
||||
|
||||
uint16_t getDefaultCompress(uint8_t type) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_NULL:
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
case TSDB_DATA_TYPE_VARCHAR: // TSDB_DATA_TYPE_BINARY
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
case TSDB_DATA_TYPE_JSON:
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
case TSDB_DATA_TYPE_DECIMAL:
|
||||
case TSDB_DATA_TYPE_BLOB:
|
||||
case TSDB_DATA_TYPE_MEDIUMBLOB:
|
||||
case TSDB_DATA_TYPE_GEOMETRY:
|
||||
case TSDB_DATA_TYPE_MAX:
|
||||
return TSDB_COLVAL_COMPRESS_LZ4;
|
||||
default:
|
||||
return TSDB_COLVAL_COMPRESS_LZ4;
|
||||
}
|
||||
}
|
||||
const char* getDefaultCompressStr(uint8_t type) { return columnCompressStr(getDefaultCompress(type)); }
|
||||
|
||||
uint8_t getDefaultLevel(uint8_t type) { return TSDB_COLVAL_LEVEL_MEDIUM; }
|
||||
const char* getDefaultLevelStr(uint8_t type) { return columnLevelStr(getDefaultLevel(type)); }
|
||||
|
||||
const char* columnEncodeStr(uint8_t type) {
|
||||
const char* encode = NULL;
|
||||
switch (type) {
|
||||
case TSDB_COLVAL_ENCODE_SIMPLE8B:
|
||||
encode = TSDB_COLUMN_ENCODE_SIMPLE8B;
|
||||
break;
|
||||
case TSDB_COLVAL_ENCODE_XOR:
|
||||
encode = TSDB_COLUMN_ENCODE_XOR;
|
||||
break;
|
||||
case TSDB_COLVAL_ENCODE_RLE:
|
||||
encode = TSDB_COLUMN_ENCODE_RLE;
|
||||
break;
|
||||
case TSDB_COLVAL_ENCODE_DELTAD:
|
||||
encode = TSDB_COLUMN_ENCODE_DELTAD;
|
||||
break;
|
||||
case TSDB_COLVAL_ENCODE_DISABLED:
|
||||
encode = TSDB_COLUMN_ENCODE_DISABLED;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return encode;
|
||||
}
|
||||
|
||||
const char* columnCompressStr(uint16_t type) {
|
||||
const char* compress = NULL;
|
||||
switch (type) {
|
||||
case TSDB_COLVAL_COMPRESS_LZ4:
|
||||
compress = TSDB_COLUMN_COMPRESS_LZ4;
|
||||
break;
|
||||
case TSDB_COLVAL_COMPRESS_TSZ:
|
||||
compress = TSDB_COLUMN_COMPRESS_TSZ;
|
||||
break;
|
||||
case TSDB_COLVAL_COMPRESS_XZ:
|
||||
compress = TSDB_COLUMN_COMPRESS_XZ;
|
||||
break;
|
||||
case TSDB_COLVAL_COMPRESS_ZLIB:
|
||||
compress = TSDB_COLUMN_COMPRESS_ZLIB;
|
||||
break;
|
||||
case TSDB_COLVAL_COMPRESS_ZSTD:
|
||||
compress = TSDB_COLUMN_COMPRESS_ZSTD;
|
||||
break;
|
||||
case TSDB_COLVAL_COMPRESS_DISABLED:
|
||||
compress = TSDB_COLUMN_COMPRESS_DISABLED;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return compress;
|
||||
}
|
||||
|
||||
uint8_t columnLevelVal(const char* level) {
|
||||
uint8_t l = TSDB_COLVAL_LEVEL_MEDIUM;
|
||||
if (0 == strcmp(level, "h") || 0 == strcmp(level, TSDB_COLUMN_LEVEL_HIGH)) {
|
||||
l = TSDB_COLVAL_LEVEL_HIGH;
|
||||
} else if (0 == strcmp(level, "m") || 0 == strcmp(level, TSDB_COLUMN_LEVEL_MEDIUM)) {
|
||||
l = TSDB_COLVAL_LEVEL_MEDIUM;
|
||||
} else if (0 == strcmp(level, "l") || 0 == strcmp(level, TSDB_COLUMN_LEVEL_LOW)) {
|
||||
l = TSDB_COLVAL_LEVEL_LOW;
|
||||
} else {
|
||||
l = TSDB_COLVAL_LEVEL_NOCHANGE;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
uint16_t columnCompressVal(const char* compress) {
|
||||
uint16_t c = TSDB_COLVAL_COMPRESS_LZ4;
|
||||
if (0 == strcmp(compress, TSDB_COLUMN_COMPRESS_LZ4)) {
|
||||
c = TSDB_COLVAL_COMPRESS_LZ4;
|
||||
} else if (0 == strcmp(compress, TSDB_COLUMN_COMPRESS_TSZ)) {
|
||||
c = TSDB_COLVAL_COMPRESS_TSZ;
|
||||
} else if (0 == strcmp(compress, TSDB_COLUMN_COMPRESS_XZ)) {
|
||||
c = TSDB_COLVAL_COMPRESS_XZ;
|
||||
} else if (0 == strcmp(compress, TSDB_COLUMN_COMPRESS_ZLIB)) {
|
||||
c = TSDB_COLVAL_COMPRESS_ZLIB;
|
||||
} else if (0 == strcmp(compress, TSDB_COLUMN_COMPRESS_ZSTD)) {
|
||||
c = TSDB_COLVAL_COMPRESS_ZSTD;
|
||||
} else if (0 == strcmp(compress, TSDB_COLUMN_COMPRESS_DISABLED)) {
|
||||
c = TSDB_COLVAL_COMPRESS_DISABLED;
|
||||
} else {
|
||||
c = TSDB_COLVAL_COMPRESS_NOCHANGE;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
uint8_t columnEncodeVal(const char* encode) {
|
||||
uint8_t e = TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||
if (0 == strcmp(encode, TSDB_COLUMN_ENCODE_SIMPLE8B)) {
|
||||
e = TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||
} else if (0 == strcmp(encode, TSDB_COLUMN_ENCODE_XOR)) {
|
||||
e = TSDB_COLVAL_ENCODE_XOR;
|
||||
} else if (0 == strcmp(encode, TSDB_COLUMN_ENCODE_RLE)) {
|
||||
e = TSDB_COLVAL_ENCODE_RLE;
|
||||
} else if (0 == strcmp(encode, TSDB_COLUMN_ENCODE_DELTAD)) {
|
||||
e = TSDB_COLVAL_ENCODE_DELTAD;
|
||||
} else if (0 == strcmp(encode, TSDB_COLUMN_ENCODE_DISABLED)) {
|
||||
e = TSDB_COLVAL_ENCODE_DISABLED;
|
||||
} else {
|
||||
e = TSDB_COLVAL_ENCODE_NOCHANGE;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
const char* columnLevelStr(uint8_t type) {
|
||||
const char* level = NULL;
|
||||
switch (type) {
|
||||
case TSDB_COLVAL_LEVEL_HIGH:
|
||||
level = TSDB_COLUMN_LEVEL_HIGH;
|
||||
break;
|
||||
case TSDB_COLVAL_LEVEL_MEDIUM:
|
||||
level = TSDB_COLUMN_LEVEL_MEDIUM;
|
||||
break;
|
||||
case TSDB_COLVAL_LEVEL_LOW:
|
||||
level = TSDB_COLUMN_LEVEL_LOW;
|
||||
break;
|
||||
default:
|
||||
level = TSDB_COLUMN_LEVEL_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
bool checkColumnEncode(char encode[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||
if (0 == strlen(encode)) return true;
|
||||
strtolower(encode, encode);
|
||||
for (int i = 0; i < supportedEncodeNum; ++i) {
|
||||
if (0 == strcmp((const char*)encode, supportedEncode[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool checkColumnEncodeOrSetDefault(uint8_t type, char encode[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||
if (0 == strlen(encode)) {
|
||||
strncpy(encode, getDefaultEncodeStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||
return true;
|
||||
}
|
||||
return checkColumnEncode(encode);
|
||||
}
|
||||
bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||
if (0 == strlen(compress)) return true;
|
||||
strtolower(compress, compress);
|
||||
for (int i = 0; i < supportedCompressNum; ++i) {
|
||||
if (0 == strcmp((const char*)compress, supportedCompress[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool checkColumnCompressOrSetDefault(uint8_t type, char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||
if (0 == strlen(compress)) {
|
||||
strncpy(compress, getDefaultCompressStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||
return true;
|
||||
}
|
||||
return checkColumnCompress(compress);
|
||||
}
|
||||
bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||
if (0 == strlen(level)) return true;
|
||||
if (1 == strlen(level)) {
|
||||
if ('h' == level[0] || 'm' == level[0] || 'l' == level[0]) return true;
|
||||
} else {
|
||||
for (int i = 0; i < supportedLevelNum; ++i) {
|
||||
if (0 == strcmp((const char*)level, supportedLevel[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool checkColumnLevelOrSetDefault(uint8_t type, char level[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||
if (0 == strlen(level)) {
|
||||
strncpy(level, getDefaultLevelStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||
return true;
|
||||
}
|
||||
return checkColumnLevel(level);
|
||||
}
|
||||
|
||||
void setColEncode(uint32_t* compress, uint8_t l1) {
|
||||
*compress &= 0x00FFFFFF;
|
||||
*compress |= (l1 << 24);
|
||||
return;
|
||||
}
|
||||
void setColCompress(uint32_t* compress, uint16_t l2) {
|
||||
*compress &= 0xFF0000FF;
|
||||
*compress |= (l2 << 8);
|
||||
return;
|
||||
}
|
||||
void setColLevel(uint32_t* compress, uint8_t level) {
|
||||
*compress &= 0xFFFFFF00;
|
||||
*compress |= level;
|
||||
return;
|
||||
}
|
||||
|
||||
int8_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check,
|
||||
uint32_t* compress) {
|
||||
if (check && !validColEncode(type, encode)) return 0;
|
||||
setColEncode(compress, encode);
|
||||
|
||||
if (compressType == TSDB_COLVAL_COMPRESS_DISABLED) {
|
||||
setColCompress(compress, compressType);
|
||||
setColLevel(compress, TSDB_COLVAL_LEVEL_DISABLED);
|
||||
} else {
|
||||
if (check && !validColCompress(type, compressType)) return 0;
|
||||
setColCompress(compress, compressType);
|
||||
|
||||
if (check && !validColCompressLevel(type, level)) return 0;
|
||||
setColLevel(compress, level);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool useCompress(uint8_t tableType) { return TSDB_SUPER_TABLE == tableType || TSDB_NORMAL_TABLE == tableType; }
|
||||
|
||||
int8_t validColCompressLevel(uint8_t type, uint8_t level) {
|
||||
if (level == TSDB_COLVAL_LEVEL_DISABLED) return 1;
|
||||
if (level < TSDB_COLVAL_LEVEL_NOCHANGE || level > TSDB_COLVAL_LEVEL_HIGH) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int8_t validColCompress(uint8_t type, uint8_t l2) {
|
||||
if (l2 > TSDB_COLVAL_COMPRESS_XZ && l2 < TSDB_COLVAL_COMPRESS_DISABLED) {
|
||||
return 0;
|
||||
}
|
||||
if (l2 == TSDB_COLVAL_COMPRESS_TSZ) {
|
||||
if (type == TSDB_DATA_TYPE_FLOAT || type == TSDB_DATA_TYPE_DOUBLE) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// | --------type----------|----- supported encode ----|
|
||||
// |tinyint/smallint/int/bigint/utinyint/usmallinit/uint/ubiginint| simple8b |
|
||||
// | timestamp/bigint/ubigint | delta-i |
|
||||
// | bool | bit-packing |
|
||||
// | flout/double | delta-d |
|
||||
//
|
||||
int8_t validColEncode(uint8_t type, uint8_t l1) {
|
||||
if (l1 == TSDB_COLVAL_ENCODE_NOCHANGE) {
|
||||
return 1;
|
||||
}
|
||||
if (type == TSDB_DATA_TYPE_BOOL) {
|
||||
return TSDB_COLVAL_ENCODE_RLE == l1 ? 1 : 0;
|
||||
} else if (type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_INT) {
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 ? 1 : 0;
|
||||
} else if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 || TSDB_COLVAL_ENCODE_XOR == l1 ? 1 : 0;
|
||||
} else if (type >= TSDB_DATA_TYPE_FLOAT && type <= TSDB_DATA_TYPE_DOUBLE) {
|
||||
return TSDB_COLVAL_ENCODE_DELTAD == l1 ? 1 : 0;
|
||||
} else if ((type == TSDB_DATA_TYPE_VARCHAR || type == TSDB_DATA_TYPE_NCHAR) || type == TSDB_DATA_TYPE_JSON ||
|
||||
type == TSDB_DATA_TYPE_VARBINARY || type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
return l1 == TSDB_COLVAL_ENCODE_DISABLED ? 1 : 0;
|
||||
// if (l1 >= TSDB_COLVAL_ENCODE_NOCHANGE || l1 <= TSDB_COLVAL_ENCODE_DELTAD) {
|
||||
// return 1;
|
||||
// } else if (l1 == TSDB_COLVAL_ENCODE_DISABLED) {
|
||||
// return 1;
|
||||
// } else {
|
||||
// return 0;
|
||||
// }
|
||||
} else if (type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
return TSDB_COLVAL_ENCODE_XOR == l1 ? 1 : 0;
|
||||
} else if (type >= TSDB_DATA_TYPE_UTINYINT && type <= TSDB_DATA_TYPE_UINT) {
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 ? 1 : 0;
|
||||
} else if (type == TSDB_DATA_TYPE_UBIGINT) {
|
||||
return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 || TSDB_COLVAL_ENCODE_XOR == l1 ? 1 : 0;
|
||||
} else if (type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t createDefaultColCmprByType(uint8_t type) {
|
||||
uint32_t ret = 0;
|
||||
uint8_t encode = getDefaultEncode(type);
|
||||
uint8_t compress = getDefaultCompress(type);
|
||||
uint8_t lvl = getDefaultLevel(type);
|
||||
|
||||
SET_COMPRESS(encode, compress, lvl, ret);
|
||||
return ret;
|
||||
}
|
||||
bool validColCmprByType(uint8_t type, uint32_t cmpr) {
|
||||
DEFINE_VAR(cmpr);
|
||||
if (validColEncode(type, l1) && validColCompress(type, l2) && validColCompressLevel(type, lvl)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -1524,8 +1524,6 @@ void* blockDataDestroy(SSDataBlock* pBlock) {
|
|||
}
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pBlock->info.pks[0].type)) {
|
||||
uInfo("1====free pk:%p, %p pBlock", pBlock->info.pks[0].pData, pBlock);
|
||||
uInfo("2====free pk:%p, %p pBlock", pBlock->info.pks[1].pData, pBlock);
|
||||
taosMemoryFreeClear(pBlock->info.pks[0].pData);
|
||||
taosMemoryFreeClear(pBlock->info.pks[1].pData);
|
||||
}
|
||||
|
@ -1705,10 +1703,6 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) {
|
|||
p->pData = taosMemoryCalloc(1, pDataBlock->info.pks[1].nData);
|
||||
p->nData = pDataBlock->info.pks[1].nData;
|
||||
memcpy(p->pData, pDataBlock->info.pks[1].pData, p->nData);
|
||||
uInfo("===========clone block, with varchar, %p, 0---addr:%p, src:%p, %p", pBlock, pBlock->info.pks[0].pData, pDataBlock, pDataBlock->info.pks[0].pData);
|
||||
uInfo("===========clone block, with varchar, %p, 1---addr:%p, src:%p, %p", pBlock, pBlock->info.pks[1].pData, pDataBlock, pDataBlock->info.pks[1].pData);
|
||||
} else {
|
||||
uInfo("===========clone block without varchar pk, %p, src:%p", pBlock, pDataBlock);
|
||||
}
|
||||
|
||||
if (copyData) {
|
||||
|
|
|
@ -2450,7 +2450,7 @@ static int32_t tColDataUpdateValue72(SColData *pColData, uint8_t *pData, uint32_
|
|||
pColData->numOfValue--;
|
||||
pColData->nVal--;
|
||||
if (pColData->numOfValue) {
|
||||
if (IS_STR_DATA_TYPE(pColData->type)) {
|
||||
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||
pColData->nData = pColData->aOffset[pColData->nVal];
|
||||
} else {
|
||||
pColData->nData -= TYPE_BYTES[pColData->type];
|
||||
|
@ -4278,7 +4278,7 @@ int32_t tCompressData(void *input, // input
|
|||
if (info->cmprAlg == NO_COMPRESSION) {
|
||||
memcpy(output, input, info->originalSize);
|
||||
info->compressedSize = info->originalSize;
|
||||
} else {
|
||||
} else if (info->cmprAlg == ONE_STAGE_COMP || info->cmprAlg == TWO_STAGE_COMP) {
|
||||
SBuffer local;
|
||||
|
||||
tBufferInit(&local);
|
||||
|
@ -4310,6 +4310,38 @@ int32_t tCompressData(void *input, // input
|
|||
}
|
||||
|
||||
tBufferDestroy(&local);
|
||||
} else {
|
||||
DEFINE_VAR(info->cmprAlg)
|
||||
if ((l1 == L1_UNKNOWN && l2 == L2_UNKNOWN) || (l1 == L1_DISABLED && l2 == L2_DISABLED)) {
|
||||
memcpy(output, input, info->originalSize);
|
||||
info->compressedSize = info->originalSize;
|
||||
return 0;
|
||||
}
|
||||
SBuffer local;
|
||||
|
||||
tBufferInit(&local);
|
||||
if (buffer == NULL) {
|
||||
buffer = &local;
|
||||
}
|
||||
code = tBufferEnsureCapacity(buffer, extraSizeNeeded);
|
||||
|
||||
info->compressedSize = tDataCompress[info->dataType].compFunc( //
|
||||
input, // input
|
||||
info->originalSize, // input size
|
||||
info->originalSize / tDataTypes[info->dataType].bytes, // number of elements
|
||||
output, // output
|
||||
outputSize, // output size
|
||||
info->cmprAlg, // compression algorithm
|
||||
buffer->data, // buffer
|
||||
buffer->capacity // buffer size
|
||||
);
|
||||
if (info->compressedSize < 0) {
|
||||
tBufferDestroy(&local);
|
||||
return TSDB_CODE_COMPRESS_ERROR;
|
||||
}
|
||||
|
||||
tBufferDestroy(&local);
|
||||
// new col compress
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -4328,7 +4360,7 @@ int32_t tDecompressData(void *input, // input
|
|||
if (info->cmprAlg == NO_COMPRESSION) {
|
||||
ASSERT(info->compressedSize == info->originalSize);
|
||||
memcpy(output, input, info->compressedSize);
|
||||
} else {
|
||||
} else if (info->cmprAlg == ONE_STAGE_COMP || info->cmprAlg == TWO_STAGE_COMP) {
|
||||
SBuffer local;
|
||||
|
||||
tBufferInit(&local);
|
||||
|
@ -4359,6 +4391,37 @@ int32_t tDecompressData(void *input, // input
|
|||
return TSDB_CODE_COMPRESS_ERROR;
|
||||
}
|
||||
|
||||
ASSERT(decompressedSize == info->originalSize);
|
||||
tBufferDestroy(&local);
|
||||
} else {
|
||||
DEFINE_VAR(info->cmprAlg);
|
||||
if (l1 == L1_DISABLED && l2 == L2_DISABLED) {
|
||||
memcpy(output, input, info->compressedSize);
|
||||
return 0;
|
||||
}
|
||||
SBuffer local;
|
||||
|
||||
tBufferInit(&local);
|
||||
if (buffer == NULL) {
|
||||
buffer = &local;
|
||||
}
|
||||
code = tBufferEnsureCapacity(buffer, info->originalSize + COMP_OVERFLOW_BYTES);
|
||||
|
||||
int32_t decompressedSize = tDataCompress[info->dataType].decompFunc(
|
||||
input, // input
|
||||
info->compressedSize, // inputSize
|
||||
info->originalSize / tDataTypes[info->dataType].bytes, // number of elements
|
||||
output, // output
|
||||
outputSize, // output size
|
||||
info->cmprAlg, // compression algorithm
|
||||
buffer->data, // helper buffer
|
||||
buffer->capacity // extra buffer size
|
||||
);
|
||||
if (decompressedSize < 0) {
|
||||
tBufferDestroy(&local);
|
||||
return TSDB_CODE_COMPRESS_ERROR;
|
||||
}
|
||||
|
||||
ASSERT(decompressedSize == info->originalSize);
|
||||
tBufferDestroy(&local);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,13 @@ uint16_t tsServerPort = 6030;
|
|||
int32_t tsVersion = 30000000;
|
||||
int32_t tsStatusInterval = 1; // second
|
||||
int32_t tsNumOfSupportVnodes = 256;
|
||||
char tsEncryptAlgorithm[16] = {0};
|
||||
char tsEncryptScope[100] = {0};
|
||||
EEncryptAlgor tsiEncryptAlgorithm = 0;
|
||||
EEncryptScope tsiEncryptScope = 0;
|
||||
//char tsAuthCode[500] = {0};
|
||||
//char tsEncryptKey[17] = {0};
|
||||
char tsEncryptKey[17] = {0};
|
||||
|
||||
// common
|
||||
int32_t tsMaxShellConns = 50000;
|
||||
|
@ -77,8 +84,6 @@ int32_t tsSnapReplMaxWaitN = 128;
|
|||
// mnode
|
||||
int64_t tsMndSdbWriteDelta = 200;
|
||||
int64_t tsMndLogRetention = 2000;
|
||||
int8_t tsGrant = 1;
|
||||
int32_t tsMndGrantMode = 0;
|
||||
bool tsMndSkipGrant = false;
|
||||
bool tsEnableWhiteList = false; // ip white list cfg
|
||||
|
||||
|
@ -92,6 +97,11 @@ int64_t tsDndStart = 0;
|
|||
int64_t tsDndStartOsUptime = 0;
|
||||
int64_t tsDndUpTime = 0;
|
||||
|
||||
// dnode misc
|
||||
uint32_t tsEncryptionKeyChksum = 0;
|
||||
int8_t tsEncryptionKeyStat = ENCRYPT_KEY_STAT_UNSET;
|
||||
int8_t tsGrant = 1;
|
||||
|
||||
// monitor
|
||||
bool tsEnableMonitor = true;
|
||||
int32_t tsMonitorInterval = 30;
|
||||
|
@ -298,6 +308,9 @@ int32_t tsS3UploadDelaySec = 60;
|
|||
|
||||
bool tsExperimental = true;
|
||||
|
||||
int32_t tsMaxTsmaNum = 8;
|
||||
int32_t tsMaxTsmaCalcDelay = 600;
|
||||
|
||||
#ifndef _STORAGE
|
||||
int32_t taosSetTfsCfg(SConfig *pCfg) {
|
||||
SConfigItem *pItem = cfgGetItem(pCfg, "dataDir");
|
||||
|
@ -553,6 +566,11 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, CFG_SCOPE_BOTH, CFG_DYN_NONE) != 0) return -1;
|
||||
|
||||
if (cfgAddBool(pCfg, "multiResultFunctionStarReturnTags", tsMultiResultFunctionStarReturnTags, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, CFG_SCOPE_BOTH, CFG_DYN_CLIENT) != 0)
|
||||
return -1;
|
||||
if (cfgAddInt32(pCfg, "maxTsmaCalcDelay", tsMaxTsmaCalcDelay, 600, 86400, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) !=
|
||||
0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -601,14 +619,16 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsNumOfSupportVnodes = TMAX(tsNumOfSupportVnodes, 2);
|
||||
if (cfgAddInt32(pCfg, "supportVnodes", tsNumOfSupportVnodes, 0, 4096, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
||||
|
||||
if (cfgAddString(pCfg, "encryptAlgorithm", tsEncryptAlgorithm, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||
if (cfgAddString(pCfg, "encryptScope", tsEncryptScope, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||
//if (cfgAddString(pCfg, "authCode", tsAuthCode, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||
|
||||
if (cfgAddInt32(pCfg, "statusInterval", tsStatusInterval, 1, 30, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "minSlidingTime", tsMinSlidingTime, 1, 1000000, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0)
|
||||
return -1;
|
||||
if (cfgAddInt32(pCfg, "minIntervalTime", tsMinIntervalTime, 1, 1000000, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, CFG_SCOPE_BOTH, CFG_DYN_CLIENT) != 0)
|
||||
return -1;
|
||||
if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0)
|
||||
return -1;
|
||||
if (cfgAddInt32(pCfg, "queryRspPolicy", tsQueryRspPolicy, 0, 1, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
||||
|
@ -699,7 +719,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
return -1;
|
||||
if (cfgAddInt64(pCfg, "mndLogRetention", tsMndLogRetention, 500, 10000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0)
|
||||
return -1;
|
||||
if (cfgAddInt32(pCfg, "grantMode", tsMndGrantMode, 0, 10000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||
if (cfgAddBool(pCfg, "skipGrant", tsMndSkipGrant, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||
|
||||
if (cfgAddString(pCfg, "monitorFqdn", tsMonitorFqdn, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||
|
@ -732,6 +751,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "tmqRowSize", tmqRowSize, 1, 1000000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddInt32(pCfg, "maxTsmaNum", tsMaxTsmaNum, 0, 12, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "transPullupInterval", tsTransPullupInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) !=
|
||||
0)
|
||||
return -1;
|
||||
|
@ -1109,6 +1129,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
|||
if (taosSetSlowLogScope(cfgGetItem(pCfg, "slowLogScope")->str)) {
|
||||
return -1;
|
||||
}
|
||||
tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32;
|
||||
|
||||
tsMaxRetryWaitTime = cfgGetItem(pCfg, "maxRetryWaitTime")->i32;
|
||||
|
||||
|
@ -1122,6 +1143,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
|||
tsExperimental = cfgGetItem(pCfg, "experimental")->bval;
|
||||
|
||||
tsMultiResultFunctionStarReturnTags = cfgGetItem(pCfg, "multiResultFunctionStarReturnTags")->bval;
|
||||
tsMaxTsmaCalcDelay = cfgGetItem(pCfg, "maxTsmaCalcDelay")->i32;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1153,8 +1175,10 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32;
|
||||
tsMinSlidingTime = cfgGetItem(pCfg, "minSlidingTime")->i32;
|
||||
tsMinIntervalTime = cfgGetItem(pCfg, "minIntervalTime")->i32;
|
||||
tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32;
|
||||
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
|
||||
tstrncpy(tsEncryptAlgorithm, cfgGetItem(pCfg, "encryptAlgorithm")->str, 16);
|
||||
tstrncpy(tsEncryptScope, cfgGetItem(pCfg, "encryptScope")->str, 100);
|
||||
//tstrncpy(tsAuthCode, cfgGetItem(pCfg, "authCode")->str, 100);
|
||||
|
||||
tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32;
|
||||
tsNumOfRpcSessions = cfgGetItem(pCfg, "numOfRpcSessions")->i32;
|
||||
|
@ -1203,6 +1227,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
|
||||
tmqMaxTopicNum = cfgGetItem(pCfg, "tmqMaxTopicNum")->i32;
|
||||
tmqRowSize = cfgGetItem(pCfg, "tmqRowSize")->i32;
|
||||
tsMaxTsmaNum = cfgGetItem(pCfg, "maxTsmaNum")->i32;
|
||||
|
||||
tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32;
|
||||
tsCompactPullupInterval = cfgGetItem(pCfg, "compactPullupInterval")->i32;
|
||||
|
@ -1229,7 +1254,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsMndSdbWriteDelta = cfgGetItem(pCfg, "mndSdbWriteDelta")->i64;
|
||||
tsMndLogRetention = cfgGetItem(pCfg, "mndLogRetention")->i64;
|
||||
tsMndSkipGrant = cfgGetItem(pCfg, "skipGrant")->bval;
|
||||
tsMndGrantMode = cfgGetItem(pCfg, "grantMode")->i32;
|
||||
tsEnableWhiteList = cfgGetItem(pCfg, "enableWhiteList")->bval;
|
||||
|
||||
tsStartUdfd = cfgGetItem(pCfg, "udf")->bval;
|
||||
|
@ -1548,7 +1572,8 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, char *name) {
|
|||
{"s3PageCacheSize", &tsS3PageCacheSize},
|
||||
{"s3UploadDelaySec", &tsS3UploadDelaySec},
|
||||
{"supportVnodes", &tsNumOfSupportVnodes},
|
||||
{"experimental", &tsExperimental}};
|
||||
{"experimental", &tsExperimental},
|
||||
{"maxTsmaNum", &tsMaxTsmaNum}};
|
||||
|
||||
if (taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true) != 0) {
|
||||
taosCfgSetOption(options, tListLen(options), pItem, false);
|
||||
|
@ -1766,7 +1791,8 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, char *name) {
|
|||
{"slowLogThreshold", &tsSlowLogThreshold},
|
||||
{"useAdapter", &tsUseAdapter},
|
||||
{"experimental", &tsExperimental},
|
||||
{"multiResultFunctionStarReturnTags", &tsMultiResultFunctionStarReturnTags} };
|
||||
{"multiResultFunctionStarReturnTags", &tsMultiResultFunctionStarReturnTags},
|
||||
{"maxTsmaCalcDelay", &tsMaxTsmaCalcDelay}};
|
||||
|
||||
if (taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true) != 0) {
|
||||
taosCfgSetOption(options, tListLen(options), pItem, false);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -581,7 +581,7 @@ int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
|
||||
int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
|
||||
switch (unit) {
|
||||
case 's':
|
||||
if (val > INT64_MAX / MILLISECOND_PER_SECOND) {
|
||||
|
|
|
@ -61,13 +61,44 @@ tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX] = {
|
|||
{TSDB_DATA_TYPE_UINT, 12, INT_BYTES, "INT UNSIGNED", 0, UINT32_MAX, tsCompressInt, tsDecompressInt},
|
||||
{TSDB_DATA_TYPE_UBIGINT, 15, LONG_BYTES, "BIGINT UNSIGNED", 0, UINT64_MAX, tsCompressBigint, tsDecompressBigint},
|
||||
{TSDB_DATA_TYPE_JSON, 4, TSDB_MAX_JSON_TAG_LEN, "JSON", 0, 0, tsCompressString, tsDecompressString},
|
||||
{TSDB_DATA_TYPE_VARBINARY, 9, 1, "VARBINARY", 0, 0, tsCompressString, tsDecompressString}, // placeholder, not implemented
|
||||
{TSDB_DATA_TYPE_VARBINARY, 9, 1, "VARBINARY", 0, 0, tsCompressString,
|
||||
tsDecompressString}, // placeholder, not implemented
|
||||
{TSDB_DATA_TYPE_DECIMAL, 7, 1, "DECIMAL", 0, 0, NULL, NULL}, // placeholder, not implemented
|
||||
{TSDB_DATA_TYPE_BLOB, 4, 1, "BLOB", 0, 0, NULL, NULL}, // placeholder, not implemented
|
||||
{TSDB_DATA_TYPE_MEDIUMBLOB, 10, 1, "MEDIUMBLOB", 0, 0, NULL, NULL}, // placeholder, not implemented
|
||||
{TSDB_DATA_TYPE_GEOMETRY, 8, 1, "GEOMETRY", 0, 0, tsCompressString, tsDecompressString},
|
||||
};
|
||||
|
||||
tDataTypeCompress tDataCompress[TSDB_DATA_TYPE_MAX] = {
|
||||
{TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", 0, 0, NULL, NULL},
|
||||
{TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", false, true, tsCompressBool2, tsDecompressBool2},
|
||||
{TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", INT8_MIN, INT8_MAX, tsCompressTinyint2, tsDecompressTinyint2},
|
||||
{TSDB_DATA_TYPE_SMALLINT, 8, SHORT_BYTES, "SMALLINT", INT16_MIN, INT16_MAX, tsCompressSmallint2,
|
||||
tsDecompressSmallint2},
|
||||
{TSDB_DATA_TYPE_INT, 3, INT_BYTES, "INT", INT32_MIN, INT32_MAX, tsCompressInt2, tsDecompressInt2},
|
||||
{TSDB_DATA_TYPE_BIGINT, 6, LONG_BYTES, "BIGINT", INT64_MIN, INT64_MAX, tsCompressBigint2, tsDecompressBigint2},
|
||||
{TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", 0, 0, tsCompressFloat2, tsDecompressFloat2},
|
||||
{TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", 0, 0, tsCompressDouble2, tsDecompressDouble2},
|
||||
{TSDB_DATA_TYPE_VARCHAR, 6, 1, "VARCHAR", 0, 0, tsCompressString2, tsDecompressString2},
|
||||
{TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", INT64_MIN, INT64_MAX, tsCompressTimestamp2,
|
||||
tsDecompressTimestamp2},
|
||||
{TSDB_DATA_TYPE_NCHAR, 5, 1, "NCHAR", 0, 0, tsCompressString2, tsDecompressString2},
|
||||
{TSDB_DATA_TYPE_UTINYINT, 16, CHAR_BYTES, "TINYINT UNSIGNED", 0, UINT8_MAX, tsCompressTinyint2,
|
||||
tsDecompressTinyint2},
|
||||
{TSDB_DATA_TYPE_USMALLINT, 17, SHORT_BYTES, "SMALLINT UNSIGNED", 0, UINT16_MAX, tsCompressSmallint2,
|
||||
tsDecompressSmallint2},
|
||||
{TSDB_DATA_TYPE_UINT, 12, INT_BYTES, "INT UNSIGNED", 0, UINT32_MAX, tsCompressInt2, tsDecompressInt2},
|
||||
{TSDB_DATA_TYPE_UBIGINT, 15, LONG_BYTES, "BIGINT UNSIGNED", 0, UINT64_MAX, tsCompressBigint2, tsDecompressBigint2},
|
||||
{TSDB_DATA_TYPE_JSON, 4, TSDB_MAX_JSON_TAG_LEN, "JSON", 0, 0, tsCompressString2, tsDecompressString2},
|
||||
{TSDB_DATA_TYPE_VARBINARY, 9, 1, "VARBINARY", 0, 0, tsCompressString2,
|
||||
tsDecompressString2}, // placeholder, not implemented
|
||||
{TSDB_DATA_TYPE_DECIMAL, 7, 1, "DECIMAL", 0, 0, NULL, NULL}, // placeholder, not implemented
|
||||
{TSDB_DATA_TYPE_BLOB, 4, 1, "BLOB", 0, 0, NULL, NULL}, // placeholder, not implemented
|
||||
{TSDB_DATA_TYPE_MEDIUMBLOB, 10, 1, "MEDIUMBLOB", 0, 0, NULL, NULL}, // placeholder, not implemented
|
||||
{TSDB_DATA_TYPE_GEOMETRY, 8, 1, "GEOMETRY", 0, 0, tsCompressString2, tsDecompressString2},
|
||||
|
||||
};
|
||||
|
||||
static float floatMin = -FLT_MAX, floatMax = FLT_MAX;
|
||||
static double doubleMin = -DBL_MAX, doubleMax = DBL_MAX;
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ ENDIF ()
|
|||
|
||||
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||
ADD_DEPENDENCIES(taosd jemalloc)
|
||||
target_link_libraries(taosd dnode ${LINK_JEMALLOC})
|
||||
target_link_libraries(taosd dnode crypt ${LINK_JEMALLOC})
|
||||
ELSE ()
|
||||
target_link_libraries(taosd dnode)
|
||||
target_link_libraries(taosd dnode crypt)
|
||||
ENDIF ()
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#ifdef TD_JEMALLOC_ENABLED
|
||||
#include "jemalloc/jemalloc.h"
|
||||
#endif
|
||||
#include "dmUtil.h"
|
||||
|
||||
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
||||
#include "cus_name.h"
|
||||
|
@ -49,6 +50,8 @@
|
|||
#define DM_VERSION "Print program version."
|
||||
#define DM_EMAIL "<support@taosdata.com>"
|
||||
#define DM_MEM_DBG "Enable memory debug"
|
||||
#define DM_SET_ENCRYPTKEY "Set encrypt key. such as: -y 1234567890abcdef, the length should be less or equal to 16."
|
||||
|
||||
// clang-format on
|
||||
static struct {
|
||||
#ifdef WINDOWS
|
||||
|
@ -67,6 +70,8 @@ static struct {
|
|||
const char **envCmd;
|
||||
SArray *pArgs; // SConfigPair
|
||||
int64_t startTime;
|
||||
bool generateCode;
|
||||
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
||||
} global = {0};
|
||||
|
||||
static void dmSetDebugFlag(int32_t signum, void *sigInfo, void *context) { taosSetGlobalDebugFlag(143); }
|
||||
|
@ -195,6 +200,23 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
|||
}
|
||||
} else if (strcmp(argv[i], "-k") == 0) {
|
||||
global.generateGrant = true;
|
||||
} else if (strcmp(argv[i], "-y") == 0) {
|
||||
global.generateCode = true;
|
||||
if(i < argc - 1) {
|
||||
int32_t len = strlen(argv[++i]);
|
||||
if (len < ENCRYPT_KEY_LEN_MIN) {
|
||||
printf("encrypt key is too short, it should be great or equal to %d\n", ENCRYPT_KEY_LEN_MIN);
|
||||
return -1;
|
||||
}
|
||||
if (len > ENCRYPT_KEY_LEN) {
|
||||
printf("encrypt key overflow, it should be less or equal to %d\n", ENCRYPT_KEY_LEN);
|
||||
return -1;
|
||||
}
|
||||
tstrncpy(global.encryptKey, argv[i], ENCRYPT_KEY_LEN);
|
||||
} else {
|
||||
printf("'-y' requires a parameter\n");
|
||||
return -1;
|
||||
}
|
||||
} else if (strcmp(argv[i], "-C") == 0) {
|
||||
global.dumpConfig = true;
|
||||
} else if (strcmp(argv[i], "-V") == 0) {
|
||||
|
@ -259,6 +281,7 @@ static void dmPrintHelp() {
|
|||
printf("%s%s%s%s\n", indent, "-e,", indent, DM_ENV_CMD);
|
||||
printf("%s%s%s%s\n", indent, "-E,", indent, DM_ENV_FILE);
|
||||
printf("%s%s%s%s\n", indent, "-k,", indent, DM_MACHINE_CODE);
|
||||
printf("%s%s%s%s\n", indent, "-y,", indent, DM_SET_ENCRYPTKEY);
|
||||
printf("%s%s%s%s\n", indent, "-dm,", indent, DM_MEM_DBG);
|
||||
printf("%s%s%s%s\n", indent, "-V,", indent, DM_VERSION);
|
||||
|
||||
|
@ -364,6 +387,24 @@ int mainWindows(int argc, char **argv) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if(global.generateCode) {
|
||||
if(dmCheckRunning(tsDataDir) == NULL) {
|
||||
dError("failed to generate encrypt code since taosd is running, please stop it first");
|
||||
return -1;
|
||||
}
|
||||
int ret = dmUpdateEncryptKey(global.encryptKey);
|
||||
taosCloseLog();
|
||||
taosCleanupArgs();
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(dmGetEncryptKey() != 0){
|
||||
dError("failed to start since failed to get encrypt key");
|
||||
taosCloseLog();
|
||||
taosCleanupArgs();
|
||||
return -1;
|
||||
};
|
||||
|
||||
if (taosConvInit() != 0) {
|
||||
dError("failed to init conv");
|
||||
taosCloseLog();
|
||||
|
|
|
@ -57,6 +57,7 @@ int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
|||
int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg);
|
||||
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg);
|
||||
int32_t dmProcessCreateEncryptKeyReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
||||
// dmWorker.c
|
||||
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "dmInt.h"
|
||||
#include "systable.h"
|
||||
#include "tchecksum.h"
|
||||
|
||||
extern SConfig *tsCfg;
|
||||
|
||||
|
@ -113,6 +114,8 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
|||
req.clusterCfg.checkTime = 0;
|
||||
req.clusterCfg.ttlChangeOnWrite = tsTtlChangeOnWrite;
|
||||
req.clusterCfg.enableWhiteList = tsEnableWhiteList ? 1 : 0;
|
||||
req.clusterCfg.encryptionKeyStat = tsEncryptionKeyStat;
|
||||
req.clusterCfg.encryptionKeyChksum = tsEncryptionKeyChksum;
|
||||
char timestr[32] = "1970-01-01 00:00:00.00";
|
||||
(void)taosParseTime(timestr, &req.clusterCfg.checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
||||
memcpy(req.clusterCfg.timezone, tsTimezoneStr, TD_TIMEZONE_LEN);
|
||||
|
@ -221,6 +224,32 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t dmProcessCreateEncryptKeyReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
#ifdef TD_ENTERPRISE
|
||||
int32_t code = 0;
|
||||
SDCfgDnodeReq cfgReq = {0};
|
||||
if (tDeserializeSDCfgDnodeReq(pMsg->pCont, pMsg->contLen, &cfgReq) != 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
code = dmUpdateEncryptKey(cfgReq.value);
|
||||
if (code == 0) {
|
||||
tsEncryptionKeyChksum = taosCalcChecksum(0, cfgReq.value, strlen(cfgReq.value));
|
||||
tsEncryptionKeyStat = ENCRYPT_KEY_STAT_LOADED;
|
||||
tstrncpy(tsEncryptKey, cfgReq.value, ENCRYPT_KEY_LEN + 1);
|
||||
}
|
||||
|
||||
_exit:
|
||||
pMsg->code = code;
|
||||
pMsg->info.rsp = NULL;
|
||||
pMsg->info.rspLen = 0;
|
||||
return code;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void dmGetServerRunStatus(SDnodeMgmt *pMgmt, SServerStatusRsp *pStatus) {
|
||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_OK;
|
||||
pStatus->details[0] = 0;
|
||||
|
@ -421,6 +450,7 @@ SArray *dmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_DND_SERVER_STATUS, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_SYSTABLE_RETRIEVE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_ALTER_MNODE_TYPE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_ENCRYPT_KEY, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
// Requests handled by MNODE
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -359,6 +359,9 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
case TDMT_MND_GRANT_NOTIFY:
|
||||
code = dmProcessGrantNotify(NULL, pMsg);
|
||||
break;
|
||||
case TDMT_DND_CREATE_ENCRYPT_KEY:
|
||||
code = dmProcessCreateEncryptKeyReq(pMgmt, pMsg);
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
dGError("msg:%p, not processed in mgmt queue", pMsg);
|
||||
|
|
|
@ -113,6 +113,7 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_DND_ALTER_VNODE_TYPE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CONFIG_CHANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_ENCRYPT_KEY_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONNECT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ACCT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -164,6 +165,14 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_PAUSE_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_RESUME_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STB_DROP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STB_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TB_WITH_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TABLE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_IP_WHITE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_USER_WHITELIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -196,6 +205,7 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_COMPACT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_CLUSTER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_COMPACT_PROGRESS_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ENCRYPT_KEY, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
|
@ -222,6 +232,10 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_PAUSE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RESUME_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_STOP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_CREATE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_DROP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_CREATE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_CHECK_POINT_SOURCE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_UPDATE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -91,6 +91,7 @@ SArray *smGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_HEARTBEAT_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_REQ_CHKPT_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_GET_STREAM_PROGRESS, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
_OVER:
|
||||
|
|
|
@ -142,6 +142,14 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
if ((pRetention->freq >= 0 && pRetention->keep > 0)) pCfg->isRsma = 1;
|
||||
}
|
||||
}
|
||||
#if defined(TD_ENTERPRISE)
|
||||
pCfg->tsdbCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
||||
if(pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4){
|
||||
strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
}
|
||||
#else
|
||||
pCfg->tsdbCfg.encryptAlgorithm = 0;
|
||||
#endif
|
||||
|
||||
pCfg->walCfg.vgId = pCreate->vgId;
|
||||
pCfg->walCfg.fsyncPeriod = pCreate->walFsyncPeriod;
|
||||
|
@ -150,6 +158,23 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
pCfg->walCfg.retentionSize = pCreate->walRetentionSize;
|
||||
pCfg->walCfg.segSize = pCreate->walSegmentSize;
|
||||
pCfg->walCfg.level = pCreate->walLevel;
|
||||
#if defined(TD_ENTERPRISE)
|
||||
pCfg->walCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
||||
if(pCfg->walCfg.encryptAlgorithm == DND_CA_SM4){
|
||||
strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
}
|
||||
#else
|
||||
pCfg->walCfg.encryptAlgorithm = 0;
|
||||
#endif
|
||||
|
||||
#if defined(TD_ENTERPRISE)
|
||||
pCfg->tdbEncryptAlgorithm = pCreate->encryptAlgorithm;
|
||||
if(pCfg->tdbEncryptAlgorithm == DND_CA_SM4){
|
||||
strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
}
|
||||
#else
|
||||
pCfg->tdbEncryptAlgorithm = 0;
|
||||
#endif
|
||||
|
||||
pCfg->sttTrigger = pCreate->sstTrigger;
|
||||
pCfg->hashBegin = pCreate->hashBegin;
|
||||
|
@ -246,14 +271,15 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
"precision:%d compression:%d minRows:%d maxRows:%d"
|
||||
", wal fsync:%d level:%d retentionPeriod:%d retentionSize:%" PRId64 " rollPeriod:%d segSize:%" PRId64
|
||||
", hash method:%d begin:%u end:%u prefix:%d surfix:%d replica:%d selfIndex:%d "
|
||||
"learnerReplica:%d learnerSelfIndex:%d strict:%d changeVersion:%d",
|
||||
"learnerReplica:%d learnerSelfIndex:%d strict:%d changeVersion:%d encryptAlgorithm:%d",
|
||||
req.vgId, TMSG_INFO(pMsg->msgType), req.pages, req.pageSize, req.buffer, req.pageSize * 1024,
|
||||
(uint64_t)req.buffer * 1024 * 1024, req.cacheLast, req.cacheLastSize, req.sstTrigger, req.tsdbPageSize,
|
||||
req.tsdbPageSize * 1024, req.db, req.dbUid, req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2,
|
||||
req.keepTimeOffset, req.s3ChunkSize, req.s3KeepLocal, req.s3Compact, req.isTsma, req.precision, req.compression,
|
||||
req.minRows, req.maxRows, req.walFsyncPeriod, req.walLevel, req.walRetentionPeriod, req.walRetentionSize,
|
||||
req.walRollPeriod, req.walSegmentSize, req.hashMethod, req.hashBegin, req.hashEnd, req.hashPrefix, req.hashSuffix,
|
||||
req.replica, req.selfIndex, req.learnerReplica, req.learnerSelfIndex, req.strict, req.changeVersion);
|
||||
req.replica, req.selfIndex, req.learnerReplica, req.learnerSelfIndex, req.strict, req.changeVersion,
|
||||
req.encryptAlgorithm);
|
||||
|
||||
for (int32_t i = 0; i < req.replica; ++i) {
|
||||
dInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", req.vgId, i, req.replicas[i].fqdn, req.replicas[i].port,
|
||||
|
@ -278,6 +304,14 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if(req.encryptAlgorithm == DND_CA_SM4){
|
||||
if(strlen(tsEncryptKey) == 0){
|
||||
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
dError("vgId:%d, failed to create vnode since encrypt key is empty", req.vgId);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
vmGenerateVnodeCfg(&req, &vnodeCfg);
|
||||
|
||||
if (vmTsmaAdjustDays(&vnodeCfg, &req) < 0) {
|
||||
|
@ -884,6 +918,7 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_SCH_TASK_NOTIFY, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TTL_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_TTL_EXPIRED_TBS, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -930,6 +965,7 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_HEARTBEAT_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_REQ_CHKPT_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_GET_STREAM_PROGRESS, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -161,6 +161,46 @@ int32_t dmInitVars(SDnode *pDnode) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
#if defined(TD_ENTERPRISE)
|
||||
tsiEncryptAlgorithm = pData->encryptAlgorigthm;
|
||||
tsiEncryptScope = pData->encryptScope;
|
||||
/*
|
||||
if(tsiEncryptAlgorithm != 0) {
|
||||
if(pData->machineId != NULL && strlen(pData->machineId) > 0){
|
||||
dInfo("get crypt key at startup, machineId:%s", pData->machineId);
|
||||
int32_t code = 0;
|
||||
|
||||
//code = taosGetCryptKey(tsAuthCode, pData->machineId, tsCryptKey);
|
||||
code = 0;
|
||||
strncpy(tsEncryptKey, tsAuthCode, 16);
|
||||
|
||||
if(code != 0) {
|
||||
if(code == -1){
|
||||
terrno = TSDB_CODE_DNODE_NO_ENCRYPT_KEY;
|
||||
dError("machine code changed, can't get crypt key");
|
||||
}
|
||||
if(code == -2){
|
||||
terrno = TSDB_CODE_DNODE_NO_ENCRYPT_KEY;
|
||||
dError("failed to get crypt key");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(strlen(tsEncryptKey) == 0){
|
||||
terrno = TSDB_CODE_DNODE_NO_ENCRYPT_KEY;
|
||||
dError("failed to get crypt key at startup since key is null, machineId:%s", pData->machineId);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
terrno = TSDB_CODE_DNODE_NO_MACHINE_CODE;
|
||||
dError("failed to get crypt key at startup, machineId:%s", pData->machineId);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
if (pData->dropped) {
|
||||
dError("dnode will not start since its already dropped");
|
||||
return -1;
|
||||
|
|
|
@ -110,6 +110,8 @@ typedef struct {
|
|||
bool validMnodeEps;
|
||||
int64_t ipWhiteVer;
|
||||
char machineId[TSDB_MACHINE_ID_LEN + 1];
|
||||
EEncryptAlgor encryptAlgorigthm;
|
||||
EEncryptScope encryptScope;
|
||||
} SDnodeData;
|
||||
|
||||
typedef struct {
|
||||
|
@ -191,7 +193,8 @@ void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet);
|
|||
bool dmUpdateDnodeInfo(void *pData, int32_t *dnodeId, int64_t *clusterId, char *fqdn, uint16_t *port);
|
||||
void dmRemoveDnodePairs(SDnodeData *pData);
|
||||
void dmGetDnodeEp(void *pData, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort);
|
||||
|
||||
int32_t dmUpdateEncryptKey(char *key);
|
||||
int32_t dmGetEncryptKey();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -64,7 +64,12 @@ static int32_t dmDecodeEps(SJson *pJson, SDnodeData *pData) {
|
|||
if (code < 0) return -1;
|
||||
tjsonGetInt32ValueFromDouble(pJson, "dropped", pData->dropped, code);
|
||||
if (code < 0) return -1;
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
tjsonGetInt32ValueFromDouble(pJson, "encryptAlgor", pData->encryptAlgorigthm, code);
|
||||
if (code < 0) return -1;
|
||||
tjsonGetInt32ValueFromDouble(pJson, "encryptScope", pData->encryptScope, code);
|
||||
if (code < 0) return -1;
|
||||
#endif
|
||||
SJson *dnodes = tjsonGetObjectItem(pJson, "dnodes");
|
||||
if (dnodes == NULL) return 0;
|
||||
int32_t numOfDnodes = tjsonGetArraySize(dnodes);
|
||||
|
@ -89,6 +94,25 @@ static int32_t dmDecodeEps(SJson *pJson, SDnodeData *pData) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int dmOccurrences(char *str, char *toSearch) {
|
||||
int count = 0;
|
||||
char *ptr = str;
|
||||
while ((ptr = strstr(ptr, toSearch)) != NULL) {
|
||||
count++;
|
||||
ptr++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void dmSplitStr(char** arr, char* str, const char* del) {
|
||||
char *lasts;
|
||||
char* s = strsep(&str, del);
|
||||
while (s != NULL) {
|
||||
*arr++ = s;
|
||||
s = strsep(&str, del);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t dmReadEps(SDnodeData *pData) {
|
||||
int32_t code = -1;
|
||||
TdFilePtr pFile = NULL;
|
||||
|
@ -106,6 +130,74 @@ int32_t dmReadEps(SDnodeData *pData) {
|
|||
|
||||
if (taosStatFile(file, NULL, NULL, NULL) < 0) {
|
||||
dInfo("dnode file:%s not exist", file);
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
if(strlen(tsEncryptAlgorithm) > 0){
|
||||
if(strcmp(tsEncryptAlgorithm, "sm4") == 0) {
|
||||
pData->encryptAlgorigthm = DND_CA_SM4;
|
||||
}
|
||||
else{
|
||||
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPT_CONFIG;
|
||||
dError("invalid tsEncryptAlgorithm:%s", tsEncryptAlgorithm);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
dInfo("start to parse encryptScope:%s", tsEncryptScope);
|
||||
int32_t scopeLen = strlen(tsEncryptScope);
|
||||
if(scopeLen == 0){
|
||||
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPT_CONFIG;
|
||||
dError("invalid tsEncryptScope:%s", tsEncryptScope);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
char* tmp = taosMemoryMalloc(scopeLen + 1);
|
||||
memset(tmp, 0, scopeLen + 1);
|
||||
memcpy(tmp, tsEncryptScope, scopeLen);
|
||||
|
||||
int32_t count = dmOccurrences(tmp, ",");
|
||||
|
||||
char** array = taosMemoryMalloc(sizeof(char*) * (count + 1));
|
||||
memset(array, 0, sizeof(char*) * (count + 1));
|
||||
dmSplitStr(array, tmp, ",");
|
||||
|
||||
for(int32_t i = 0; i < count + 1; i++){
|
||||
char* str = *(array + i);
|
||||
|
||||
bool success = false;
|
||||
|
||||
if(strcasecmp(str, "tsdb") == 0 || strcasecmp(str, "all") == 0){
|
||||
pData->encryptScope |= DND_CS_TSDB;
|
||||
success = true;
|
||||
}
|
||||
if(strcasecmp(str, "vnode_wal") == 0 || strcasecmp(str, "all") == 0){
|
||||
pData->encryptScope |= DND_CS_VNODE_WAL;
|
||||
success = true;
|
||||
}
|
||||
if(strcasecmp(str, "sdb") == 0 || strcasecmp(str, "all") == 0){
|
||||
pData->encryptScope |= DND_CS_SDB;
|
||||
success = true;
|
||||
}
|
||||
if(strcasecmp(str, "mnode_wal") == 0 || strcasecmp(str, "all") == 0){
|
||||
pData->encryptScope |= DND_CS_MNODE_WAL;
|
||||
success = true;
|
||||
}
|
||||
|
||||
if(!success){
|
||||
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPT_CONFIG;
|
||||
taosMemoryFree(tmp);
|
||||
taosMemoryFree(array);
|
||||
dError("invalid tsEncryptScope:%s", tsEncryptScope);
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
taosMemoryFree(tmp);
|
||||
taosMemoryFree(array);
|
||||
|
||||
dInfo("set tsCryptAlgorithm:%s, tsCryptScope:%s from cfg", tsEncryptAlgorithm, tsEncryptScope);
|
||||
}
|
||||
|
||||
#endif
|
||||
code = 0;
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -191,7 +283,10 @@ static int32_t dmEncodeEps(SJson *pJson, SDnodeData *pData) {
|
|||
if (tjsonAddIntegerToObject(pJson, "engineVer", pData->engineVer) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "clusterId", pData->clusterId) < 0) return -1;
|
||||
if (tjsonAddDoubleToObject(pJson, "dropped", pData->dropped) < 0) return -1;
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
if (tjsonAddDoubleToObject(pJson, "encryptAlgor", pData->encryptAlgorigthm) < 0) return -1;
|
||||
if (tjsonAddDoubleToObject(pJson, "encryptScope", pData->encryptScope) < 0) return -1;
|
||||
#endif
|
||||
SJson *dnodes = tjsonCreateArray();
|
||||
if (dnodes == NULL) return -1;
|
||||
if (tjsonAddItemToObject(pJson, "dnodes", dnodes) < 0) return -1;
|
||||
|
|
|
@ -16,8 +16,14 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "dmUtil.h"
|
||||
#include "tjson.h"
|
||||
#include "tgrant.h"
|
||||
#include "crypt.h"
|
||||
#include "tchecksum.h"
|
||||
|
||||
#define MAXLEN 1024
|
||||
#define DM_KEY_INDICATOR "this indicator!"
|
||||
#define DM_ENCRYPT_CODE_FILE "encryptCode.cfg"
|
||||
#define DM_CHECK_CODE_FILE "checkCode.bin"
|
||||
|
||||
static int32_t dmDecodeFile(SJson *pJson, bool *deployed) {
|
||||
int32_t code = 0;
|
||||
|
@ -177,3 +183,296 @@ TdFilePtr dmCheckRunning(const char *dataDir) {
|
|||
dDebug("lock file:%s to prevent repeated starts", filepath);
|
||||
return pFile;
|
||||
}
|
||||
|
||||
extern int32_t generateEncryptCode(const char *key, const char *machineId, char **encryptCode);
|
||||
|
||||
static int32_t dmWriteCheckCodeFile(char* file, char* realfile, char* key){
|
||||
TdFilePtr pFile = NULL;
|
||||
char *result = NULL;
|
||||
int32_t code = -1;
|
||||
|
||||
int32_t len = ENCRYPTED_LEN(sizeof(DM_KEY_INDICATOR));
|
||||
result = taosMemoryMalloc(len);
|
||||
|
||||
SCryptOpts opts;
|
||||
strncpy(opts.key, key, ENCRYPT_KEY_LEN);
|
||||
opts.len = len;
|
||||
opts.source = DM_KEY_INDICATOR;
|
||||
opts.result = result;
|
||||
opts.unitLen = 16;
|
||||
CBC_Encrypt(&opts);
|
||||
|
||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFile == NULL) goto _OVER;
|
||||
|
||||
if (taosWriteFile(pFile, opts.result, len) <= 0) goto _OVER;
|
||||
if (taosFsyncFile(pFile) < 0) goto _OVER;
|
||||
|
||||
taosCloseFile(&pFile);
|
||||
if (taosRenameFile(file, realfile) != 0) goto _OVER;
|
||||
|
||||
dInfo("succeed to write checkCode file:%s", realfile);
|
||||
code = 0;
|
||||
_OVER:
|
||||
if(pFile != NULL) taosCloseFile(&pFile);
|
||||
if(result != NULL) taosMemoryFree(result);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t dmWriteEncryptCodeFile(char* file, char* realfile, char* encryptCode){
|
||||
TdFilePtr pFile = NULL;
|
||||
int32_t code = -1;
|
||||
|
||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFile == NULL) goto _OVER;
|
||||
|
||||
int32_t len = strlen(encryptCode);
|
||||
if (taosWriteFile(pFile, encryptCode, len) <= 0) goto _OVER;
|
||||
if (taosFsyncFile(pFile) < 0) goto _OVER;
|
||||
|
||||
taosCloseFile(&pFile);
|
||||
if (taosRenameFile(file, realfile) != 0) goto _OVER;
|
||||
|
||||
dInfo("succeed to write encryptCode file:%s", realfile);
|
||||
|
||||
code = 0;
|
||||
_OVER:
|
||||
if(pFile != NULL) taosCloseFile(&pFile);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t dmCompareEncryptKey(char* file, char* key){
|
||||
char *content = NULL;
|
||||
int64_t size = 0;
|
||||
TdFilePtr pFile = NULL;
|
||||
char *result = NULL;
|
||||
int32_t code = -1;
|
||||
|
||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to open dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to fstat dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
content = taosMemoryMalloc(size);
|
||||
if (content == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (taosReadFile(pFile, content, size) != size) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to read dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
dInfo("succeed to read checkCode file:%s", file);
|
||||
|
||||
int len = ENCRYPTED_LEN(size);
|
||||
result = taosMemoryMalloc(len);
|
||||
|
||||
SCryptOpts opts = {0};
|
||||
strncpy(opts.key, key, ENCRYPT_KEY_LEN);
|
||||
opts.len = len;
|
||||
opts.source = content;
|
||||
opts.result = result;
|
||||
opts.unitLen = 16;
|
||||
CBC_Decrypt(&opts);
|
||||
|
||||
if(strcmp(opts.result, DM_KEY_INDICATOR) != 0) {
|
||||
terrno = TSDB_CODE_DNODE_ENCRYPTKEY_CHANGED;
|
||||
dError("failed to compare decrypted result");
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
dInfo("succeed to compare checkCode file:%s", file);
|
||||
code = 0;
|
||||
_OVER:
|
||||
if(result != NULL) taosMemoryFree(result);
|
||||
if(content != NULL) taosMemoryFree(content);
|
||||
if(pFile != NULL) taosCloseFile(&pFile);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t dmUpdateEncryptKey(char *key) {
|
||||
#ifdef TD_ENTERPRISE
|
||||
int32_t code = -1;
|
||||
char *machineId = NULL;
|
||||
char *encryptCode = NULL;
|
||||
|
||||
char folder[PATH_MAX] = {0};
|
||||
|
||||
char encryptFile[PATH_MAX] = {0};
|
||||
char realEncryptFile[PATH_MAX] = {0};
|
||||
|
||||
char checkFile[PATH_MAX] = {0};
|
||||
char realCheckFile[PATH_MAX] = {0};
|
||||
|
||||
snprintf(folder, sizeof(folder), "%s%sdnode", tsDataDir, TD_DIRSEP);
|
||||
snprintf(encryptFile, sizeof(realEncryptFile), "%s%s%s.bak", folder, TD_DIRSEP, DM_ENCRYPT_CODE_FILE);
|
||||
snprintf(realEncryptFile, sizeof(realEncryptFile), "%s%s%s", folder, TD_DIRSEP, DM_ENCRYPT_CODE_FILE);
|
||||
snprintf(checkFile, sizeof(checkFile), "%s%s%s.bak", folder, TD_DIRSEP, DM_CHECK_CODE_FILE);
|
||||
snprintf(realCheckFile, sizeof(realCheckFile), "%s%s%s", folder, TD_DIRSEP, DM_CHECK_CODE_FILE);
|
||||
|
||||
terrno = 0;
|
||||
|
||||
if (taosMkDir(folder) != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to create dir:%s since %s", folder, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if(taosCheckExistFile(realCheckFile)){
|
||||
if(dmCompareEncryptKey(realCheckFile, key) != 0){
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(machineId = tGetMachineId())) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (generateEncryptCode(key, machineId, &encryptCode) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if(dmWriteEncryptCodeFile(encryptFile, realEncryptFile, encryptCode) != 0){
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if(dmWriteCheckCodeFile(checkFile, realCheckFile, key) != 0){
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = 0;
|
||||
_OVER:
|
||||
taosMemoryFree(encryptCode);
|
||||
taosMemoryFree(machineId);
|
||||
if (code != 0) {
|
||||
if (terrno == 0) terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to update encrypt key since %s", terrstr());
|
||||
}
|
||||
return code;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern int32_t checkAndGetCryptKey(const char *encryptCode, const char *machineId, char **key);
|
||||
|
||||
static int32_t dmReadEncryptCodeFile(char* file, char** output){
|
||||
TdFilePtr pFile = NULL;
|
||||
int32_t code = -1;
|
||||
char *content = NULL;
|
||||
|
||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to open dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int64_t size = 0;
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to fstat dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
content = taosMemoryMalloc(size + 1);
|
||||
if (content == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (taosReadFile(pFile, content, size) != size) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to read dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
content[size] = '\0';
|
||||
|
||||
*output = content;
|
||||
|
||||
dInfo("succeed to read encryptCode file:%s", file);
|
||||
code = 0;
|
||||
_OVER:
|
||||
if(pFile != NULL) taosCloseFile(&pFile);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t dmGetEncryptKey(){
|
||||
#ifdef TD_ENTERPRISE
|
||||
int32_t code = -1;
|
||||
char encryptFile[PATH_MAX] = {0};
|
||||
char checkFile[PATH_MAX] = {0};
|
||||
char *machineId = NULL;
|
||||
char *encryptKey = NULL;
|
||||
char *content = NULL;
|
||||
|
||||
snprintf(encryptFile, sizeof(encryptFile), "%s%sdnode%s%s", tsDataDir, TD_DIRSEP, TD_DIRSEP, DM_ENCRYPT_CODE_FILE);
|
||||
snprintf(checkFile, sizeof(checkFile), "%s%sdnode%s%s", tsDataDir, TD_DIRSEP, TD_DIRSEP, DM_CHECK_CODE_FILE);
|
||||
|
||||
if(!taosCheckExistFile(encryptFile)){
|
||||
dInfo("no exist, checkCode file:%s", encryptFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(dmReadEncryptCodeFile(encryptFile, &content) != 0){
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (!(machineId = tGetMachineId())) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if(checkAndGetCryptKey(content, machineId, &encryptKey) != 0){
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(machineId);
|
||||
taosMemoryFreeClear(content);
|
||||
|
||||
if(encryptKey[0] == '\0'){
|
||||
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
dError("failed to read key since %s", terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if(dmCompareEncryptKey(checkFile, encryptKey) != 0){
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
strncpy(tsEncryptKey, encryptKey, ENCRYPT_KEY_LEN);
|
||||
taosMemoryFreeClear(encryptKey);
|
||||
tsEncryptionKeyChksum = taosCalcChecksum(0, tsEncryptKey, strlen(tsEncryptKey));
|
||||
tsEncryptionKeyStat = ENCRYPT_KEY_STAT_LOADED;
|
||||
|
||||
code = 0;
|
||||
_OVER:
|
||||
if (content != NULL) taosMemoryFree(content);
|
||||
if (encryptKey != NULL) taosMemoryFree(encryptKey);
|
||||
if (machineId != NULL) taosMemoryFree(machineId);
|
||||
if (code != 0) {
|
||||
if (terrno == 0) terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to get encrypt key since %s", terrstr());
|
||||
}
|
||||
return code;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
|
@ -29,6 +29,7 @@ void mndReleaseDb(SMnode *pMnode, SDbObj *pDb);
|
|||
int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, void **ppRsp, int32_t *pRspLen);
|
||||
int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq);
|
||||
bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb);
|
||||
void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList);
|
||||
|
||||
SSdbRaw *mndDbActionEncode(SDbObj *pDb);
|
||||
const char *mndGetDbStr(const char *src);
|
||||
|
|
|
@ -141,6 +141,7 @@ typedef enum {
|
|||
DND_REASON_CHARSET_NOT_MATCH,
|
||||
DND_REASON_TTL_CHANGE_ON_WRITE_NOT_MATCH,
|
||||
DND_REASON_ENABLE_WHITELIST_NOT_MATCH,
|
||||
DND_REASON_ENCRYPTION_KEY_NOT_MATCH,
|
||||
DND_REASON_OTHERS
|
||||
} EDndReason;
|
||||
|
||||
|
@ -215,6 +216,8 @@ typedef struct {
|
|||
int64_t memAvail;
|
||||
int64_t memUsed;
|
||||
EDndReason offlineReason;
|
||||
uint32_t encryptionKeyChksum;
|
||||
int8_t encryptionKeyStat;
|
||||
uint16_t port;
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
char ep[TSDB_EP_LEN];
|
||||
|
@ -383,6 +386,7 @@ typedef struct {
|
|||
int32_t s3KeepLocal;
|
||||
int8_t s3Compact;
|
||||
int8_t withArbitrator;
|
||||
int8_t encryptAlgorithm;
|
||||
} SDbCfg;
|
||||
|
||||
typedef struct {
|
||||
|
@ -398,6 +402,7 @@ typedef struct {
|
|||
SRWLatch lock;
|
||||
int64_t stateTs;
|
||||
int64_t compactStartTime;
|
||||
int32_t tsmaVersion;
|
||||
} SDbObj;
|
||||
|
||||
typedef struct {
|
||||
|
@ -457,12 +462,14 @@ typedef struct {
|
|||
int32_t tagsFilterLen;
|
||||
int32_t sqlLen;
|
||||
int32_t astLen;
|
||||
int32_t version;
|
||||
char* expr;
|
||||
char* tagsFilter;
|
||||
char* sql;
|
||||
char* ast;
|
||||
SSchemaWrapper schemaRow; // for dstVgroup
|
||||
SSchemaWrapper schemaTag; // for dstVgroup
|
||||
char baseSmaName[TSDB_TABLE_FNAME_LEN];
|
||||
} SSmaObj;
|
||||
|
||||
typedef struct {
|
||||
|
@ -478,33 +485,38 @@ typedef struct {
|
|||
} SIdxObj;
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_TABLE_FNAME_LEN];
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int64_t createdTime;
|
||||
int64_t updateTime;
|
||||
int64_t uid;
|
||||
int64_t dbUid;
|
||||
int32_t tagVer;
|
||||
int32_t colVer;
|
||||
int32_t smaVer;
|
||||
int32_t nextColId;
|
||||
int64_t maxdelay[2];
|
||||
int64_t watermark[2];
|
||||
int32_t ttl;
|
||||
int32_t numOfColumns;
|
||||
int32_t numOfTags;
|
||||
int32_t numOfFuncs;
|
||||
int32_t commentLen;
|
||||
int32_t ast1Len;
|
||||
int32_t ast2Len;
|
||||
SArray* pFuncs;
|
||||
SSchema* pColumns;
|
||||
SSchema* pTags;
|
||||
char* comment;
|
||||
char* pAst1;
|
||||
char* pAst2;
|
||||
SRWLatch lock;
|
||||
int8_t source;
|
||||
col_id_t colId;
|
||||
int32_t cmprAlg;
|
||||
} SCmprObj;
|
||||
typedef struct {
|
||||
char name[TSDB_TABLE_FNAME_LEN];
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int64_t createdTime;
|
||||
int64_t updateTime;
|
||||
int64_t uid;
|
||||
int64_t dbUid;
|
||||
int32_t tagVer;
|
||||
int32_t colVer;
|
||||
int32_t smaVer;
|
||||
int32_t nextColId;
|
||||
int64_t maxdelay[2];
|
||||
int64_t watermark[2];
|
||||
int32_t ttl;
|
||||
int32_t numOfColumns;
|
||||
int32_t numOfTags;
|
||||
int32_t numOfFuncs;
|
||||
int32_t commentLen;
|
||||
int32_t ast1Len;
|
||||
int32_t ast2Len;
|
||||
SArray* pFuncs;
|
||||
SSchema* pColumns;
|
||||
SSchema* pTags;
|
||||
char* comment;
|
||||
char* pAst1;
|
||||
char* pAst2;
|
||||
SRWLatch lock;
|
||||
int8_t source;
|
||||
SColCmpr* pCmpr;
|
||||
} SStbObj;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -104,6 +104,13 @@ typedef struct {
|
|||
int64_t timeseriesAllowed;
|
||||
} SGrantInfo;
|
||||
|
||||
typedef struct {
|
||||
int8_t encrypting;
|
||||
int16_t nEncrypt;
|
||||
int16_t nSuccess;
|
||||
int16_t nFailed;
|
||||
} SEncryptMgmt;
|
||||
|
||||
typedef struct SMnode {
|
||||
int32_t selfDnodeId;
|
||||
int64_t clusterId;
|
||||
|
@ -127,6 +134,7 @@ typedef struct SMnode {
|
|||
SProfileMgmt profileMgmt;
|
||||
STelemMgmt telemMgmt;
|
||||
SSyncMgmt syncMgmt;
|
||||
SEncryptMgmt encryptMgmt;
|
||||
SGrantInfo grant;
|
||||
MndMsgFp msgFp[TDMT_MAX];
|
||||
SMsgCb msgCb;
|
||||
|
|
|
@ -29,6 +29,9 @@ void mndReleaseSma(SMnode *pMnode, SSmaObj *pSma);
|
|||
int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb);
|
||||
int32_t mndDropSmasByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
||||
int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool *exist);
|
||||
int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t numOfTsmas, void **ppRsp,
|
||||
int32_t *pRspLen);
|
||||
int32_t mndGetDbTsmas(SMnode *pMnode, const char *dbFName, uint64_t dbUid, STableTSMAInfoRsp *pRsp, bool *exist);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -648,7 +648,6 @@ static SMqConsumerObj* buildSubConsumer(SMnode *pMnode, SCMSubscribeReq *subscri
|
|||
_over:
|
||||
mndReleaseConsumer(pMnode, pExistedConsumer);
|
||||
tDeleteSMqConsumerObj(pConsumerNew);
|
||||
taosArrayDestroyP(subscribe->topicNames, (FDelete)taosMemoryFree);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "tjson.h"
|
||||
|
||||
#define DB_VER_NUMBER 1
|
||||
#define DB_RESERVE_SIZE 32
|
||||
#define DB_RESERVE_SIZE 27
|
||||
|
||||
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
|
||||
static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb);
|
||||
|
@ -146,6 +146,8 @@ SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
|||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.s3KeepLocal, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.s3Compact, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.withArbitrator, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.encryptAlgorithm, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->tsmaVersion, _OVER);
|
||||
|
||||
SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
||||
|
@ -241,6 +243,8 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.s3KeepLocal, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.s3Compact, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.withArbitrator, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.encryptAlgorithm, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->tsmaVersion, _OVER);
|
||||
|
||||
SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
||||
taosInitRWLatch(&pDb->lock);
|
||||
|
@ -347,6 +351,7 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) {
|
|||
pOld->cfg.s3Compact = pNew->cfg.s3Compact;
|
||||
pOld->cfg.withArbitrator = pNew->cfg.withArbitrator;
|
||||
pOld->compactStartTime = pNew->compactStartTime;
|
||||
pOld->tsmaVersion = pNew->tsmaVersion;
|
||||
taosWUnLockLatch(&pOld->lock);
|
||||
return 0;
|
||||
}
|
||||
|
@ -422,9 +427,12 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
|||
if (pCfg->replications < TSDB_MIN_DB_REPLICA || pCfg->replications > TSDB_MAX_DB_REPLICA) return -1;
|
||||
#ifdef TD_ENTERPRISE
|
||||
if ((pCfg->replications == 2) ^ (pCfg->withArbitrator == TSDB_MAX_DB_WITH_ARBITRATOR)) return -1;
|
||||
if (pCfg->encryptAlgorithm < TSDB_MIN_ENCRYPT_ALGO || pCfg->encryptAlgorithm > TSDB_MAX_ENCRYPT_ALGO) return -1;
|
||||
#else
|
||||
if (pCfg->replications != 1 && pCfg->replications != 3) return -1;
|
||||
if (pCfg->encryptAlgorithm != TSDB_DEFAULT_ENCRYPT_ALGO) return -1;
|
||||
#endif
|
||||
|
||||
if (pCfg->strict < TSDB_DB_STRICT_OFF || pCfg->strict > TSDB_DB_STRICT_ON) return -1;
|
||||
if (pCfg->schemaless < TSDB_DB_SCHEMALESS_OFF || pCfg->schemaless > TSDB_DB_SCHEMALESS_ON) return -1;
|
||||
if (pCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return -1;
|
||||
|
@ -541,6 +549,7 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
|
|||
if (pCfg->s3KeepLocal <= 0) pCfg->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
||||
if (pCfg->s3Compact <= 0) pCfg->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
||||
if (pCfg->withArbitrator < 0) pCfg->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
|
||||
if (pCfg->encryptAlgorithm < 0) pCfg->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
|
||||
}
|
||||
|
||||
static int32_t mndSetCreateDbPrepareAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||
|
@ -681,6 +690,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
|
|||
dbObj.uid = mndGenerateUid(dbObj.name, TSDB_DB_FNAME_LEN);
|
||||
dbObj.cfgVersion = 1;
|
||||
dbObj.vgVersion = 1;
|
||||
dbObj.tsmaVersion = 1;
|
||||
memcpy(dbObj.createUser, pUser->user, TSDB_USER_LEN);
|
||||
dbObj.cfg = (SDbCfg){
|
||||
.numOfVgroups = pCreate->numOfVgroups,
|
||||
|
@ -717,6 +727,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
|
|||
.s3Compact = pCreate->s3Compact,
|
||||
.tsdbPageSize = pCreate->tsdbPageSize,
|
||||
.withArbitrator = pCreate->withArbitrator,
|
||||
.encryptAlgorithm = pCreate->encryptAlgorithm,
|
||||
};
|
||||
|
||||
dbObj.cfg.numOfRetensions = pCreate->numOfRetensions;
|
||||
|
@ -802,6 +813,46 @@ static void mndBuildAuditDetailInt64(char *detail, char *tmp, char *format, int6
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t mndCheckDbEncryptKey(SMnode *pMnode, SCreateDbReq *pReq) {
|
||||
int32_t code = 0;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
SDnodeObj *pDnode = NULL;
|
||||
void *pIter = NULL;
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
if (pReq->encryptAlgorithm == TSDB_ENCRYPT_ALGO_NONE) goto _exit;
|
||||
if (tsEncryptionKeyStat != ENCRYPT_KEY_STAT_LOADED) {
|
||||
code = TSDB_CODE_MND_INVALID_ENCRYPT_KEY;
|
||||
mError("db:%s, failed to check encryption key:%" PRIi8 " in mnode leader since it's not loaded", pReq->db,
|
||||
tsEncryptionKeyStat);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
int64_t curMs = taosGetTimestampMs();
|
||||
while ((pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode))) {
|
||||
bool online = false;
|
||||
if ((pDnode->encryptionKeyStat != tsEncryptionKeyStat || pDnode->encryptionKeyChksum != tsEncryptionKeyChksum) &&
|
||||
(online = mndIsDnodeOnline(pDnode, curMs))) {
|
||||
code = TSDB_CODE_MND_INVALID_ENCRYPT_KEY;
|
||||
mError("db:%s, failed to check encryption key:%" PRIi8
|
||||
"-%u in dnode:%d since it's inconsitent with mnode leader:%" PRIi8 "-%u",
|
||||
pReq->db, pDnode->encryptionKeyStat, pDnode->encryptionKeyChksum, pDnode->id, tsEncryptionKeyStat,
|
||||
tsEncryptionKeyChksum);
|
||||
sdbRelease(pSdb, pDnode);
|
||||
break;
|
||||
}
|
||||
sdbRelease(pSdb, pDnode);
|
||||
}
|
||||
#else
|
||||
if (pReq->encryptAlgorithm != TSDB_ENCRYPT_ALGO_NONE) {
|
||||
code = TSDB_CODE_MND_INVALID_DB_OPTION;
|
||||
goto _exit;
|
||||
}
|
||||
#endif
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
int32_t code = -1;
|
||||
|
@ -852,6 +903,11 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
|||
}
|
||||
}
|
||||
|
||||
if ((code = mndCheckDbEncryptKey(pMnode, &createReq)) != 0) {
|
||||
terrno = code;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pUser = mndAcquireUser(pMnode, pReq->info.conn.user);
|
||||
if (pUser == NULL) {
|
||||
goto _OVER;
|
||||
|
@ -1203,6 +1259,7 @@ static void mndDumpDbCfgInfo(SDbCfgRsp *cfgRsp, SDbObj *pDb) {
|
|||
cfgRsp->s3KeepLocal = pDb->cfg.s3KeepLocal;
|
||||
cfgRsp->s3Compact = pDb->cfg.s3Compact;
|
||||
cfgRsp->withArbitrator = pDb->cfg.withArbitrator;
|
||||
cfgRsp->encryptAlgorithm = pDb->cfg.encryptAlgorithm;
|
||||
}
|
||||
|
||||
static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq) {
|
||||
|
@ -1521,7 +1578,7 @@ static int32_t mndGetDBTableNum(SDbObj *pDb, SMnode *pMnode) {
|
|||
return numOfTables;
|
||||
}
|
||||
|
||||
static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) {
|
||||
void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) {
|
||||
int32_t vindex = 0;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
|
@ -1682,6 +1739,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
pDbCacheInfo->cfgVersion = htonl(pDbCacheInfo->cfgVersion);
|
||||
pDbCacheInfo->numOfTable = htonl(pDbCacheInfo->numOfTable);
|
||||
pDbCacheInfo->stateTs = be64toh(pDbCacheInfo->stateTs);
|
||||
pDbCacheInfo->tsmaVersion = htonl(pDbCacheInfo->tsmaVersion);
|
||||
|
||||
SDbHbRsp rsp = {0};
|
||||
|
||||
|
@ -1720,7 +1778,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
int32_t numOfTable = mndGetDBTableNum(pDb, pMnode);
|
||||
|
||||
if (pDbCacheInfo->vgVersion >= pDb->vgVersion && pDbCacheInfo->cfgVersion >= pDb->cfgVersion &&
|
||||
numOfTable == pDbCacheInfo->numOfTable && pDbCacheInfo->stateTs == pDb->stateTs) {
|
||||
numOfTable == pDbCacheInfo->numOfTable && pDbCacheInfo->stateTs == pDb->stateTs &&
|
||||
pDbCacheInfo->tsmaVersion >= pDb->tsmaVersion) {
|
||||
mTrace("db:%s, valid dbinfo, vgVersion:%d cfgVersion:%d stateTs:%" PRId64
|
||||
" numOfTables:%d, not changed vgVersion:%d cfgVersion:%d stateTs:%" PRId64 " numOfTables:%d",
|
||||
pDbCacheInfo->dbFName, pDbCacheInfo->vgVersion, pDbCacheInfo->cfgVersion, pDbCacheInfo->stateTs,
|
||||
|
@ -1739,6 +1798,16 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
mndDumpDbCfgInfo(rsp.cfgRsp, pDb);
|
||||
}
|
||||
|
||||
if (pDbCacheInfo->tsmaVersion != pDb->tsmaVersion) {
|
||||
rsp.pTsmaRsp = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp));
|
||||
if (rsp.pTsmaRsp) rsp.pTsmaRsp->pTsmas = taosArrayInit(4, POINTER_BYTES);
|
||||
if (rsp.pTsmaRsp && rsp.pTsmaRsp->pTsmas) {
|
||||
rsp.dbTsmaVersion = pDb->tsmaVersion;
|
||||
bool exist = false;
|
||||
mndGetDbTsmas(pMnode, 0, pDb->uid, rsp.pTsmaRsp, &exist);
|
||||
}
|
||||
}
|
||||
|
||||
if (pDbCacheInfo->vgVersion < pDb->vgVersion || numOfTable != pDbCacheInfo->numOfTable ||
|
||||
pDbCacheInfo->stateTs != pDb->stateTs) {
|
||||
rsp.useDbRsp = taosMemoryCalloc(1, sizeof(SUseDbRsp));
|
||||
|
@ -2012,6 +2081,18 @@ static const char *getCacheModelStr(int8_t cacheModel) {
|
|||
return "unknown";
|
||||
}
|
||||
|
||||
static const char *getEncryptAlgorithmStr(int8_t encryptAlgorithm) {
|
||||
switch (encryptAlgorithm) {
|
||||
case TSDB_ENCRYPT_ALGO_NONE:
|
||||
return TSDB_ENCRYPT_ALGO_NONE_STR;
|
||||
case TSDB_ENCRYPT_ALGO_SM4:
|
||||
return TSDB_ENCRYPT_ALGO_SM4_STR;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb) {
|
||||
if (pDb->cfg.replications == 1) return true;
|
||||
|
||||
|
@ -2232,6 +2313,12 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
|||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.withArbitrator, false);
|
||||
|
||||
const char *encryptAlgorithmStr = getEncryptAlgorithmStr(pDb->cfg.encryptAlgorithm);
|
||||
char encryptAlgorithmVStr[24] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(encryptAlgorithmVStr, encryptAlgorithmStr, 24);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)encryptAlgorithmVStr, false);
|
||||
}
|
||||
|
||||
taosMemoryFree(buf);
|
||||
|
|
|
@ -42,11 +42,13 @@ static const char *offlineReason[] = {
|
|||
"version not match",
|
||||
"dnodeId not match",
|
||||
"clusterId not match",
|
||||
"interval not match",
|
||||
"statusInterval not match",
|
||||
"timezone not match",
|
||||
"locale not match",
|
||||
"charset not match",
|
||||
"ttlChangeOnWrite not match",
|
||||
"enableWhiteList not match",
|
||||
"encryptionKey not match",
|
||||
"unknown",
|
||||
};
|
||||
|
||||
|
@ -78,6 +80,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq);
|
|||
static int32_t mndProcessNotifyReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessRestoreDnodeReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessStatisReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessCreateEncryptKeyReq(SRpcMsg *pRsp);
|
||||
static int32_t mndProcessCreateEncryptKeyRsp(SRpcMsg *pRsp);
|
||||
|
||||
static int32_t mndRetrieveConfigs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||
static void mndCancelGetNextConfig(SMnode *pMnode, void *pIter);
|
||||
|
@ -114,6 +118,8 @@ int32_t mndInitDnode(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_MND_SHOW_VARIABLES, mndProcessShowVariablesReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_RESTORE_DNODE, mndProcessRestoreDnodeReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_STATIS, mndProcessStatisReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_ENCRYPT_KEY, mndProcessCreateEncryptKeyReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_ENCRYPT_KEY_RSP, mndProcessCreateEncryptKeyRsp);
|
||||
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndRetrieveConfigs);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndCancelGetNextConfig);
|
||||
|
@ -372,7 +378,7 @@ int32_t mndGetDbSize(SMnode *pMnode) {
|
|||
bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs) {
|
||||
int64_t interval = TABS(pDnode->lastAccessTime - curMs);
|
||||
if (interval > 5000 * (int64_t)tsStatusInterval) {
|
||||
if (pDnode->rebootTime > 0) {
|
||||
if (pDnode->rebootTime > 0 && pDnode->offlineReason == DND_REASON_ONLINE) {
|
||||
pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT;
|
||||
}
|
||||
return false;
|
||||
|
@ -436,37 +442,51 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const S
|
|||
if (pCfg->statusInterval != tsStatusInterval) {
|
||||
mError("dnode:%d, statusInterval:%d inconsistent with cluster:%d", pDnode->id, pCfg->statusInterval,
|
||||
tsStatusInterval);
|
||||
terrno = TSDB_CODE_DNODE_INVALID_STATUS_INTERVAL;
|
||||
return DND_REASON_STATUS_INTERVAL_NOT_MATCH;
|
||||
}
|
||||
|
||||
if ((0 != strcasecmp(pCfg->timezone, tsTimezoneStr)) && (pMnode->checkTime != pCfg->checkTime)) {
|
||||
mError("dnode:%d, timezone:%s checkTime:%" PRId64 " inconsistent with cluster %s %" PRId64, pDnode->id,
|
||||
pCfg->timezone, pCfg->checkTime, tsTimezoneStr, pMnode->checkTime);
|
||||
terrno = TSDB_CODE_DNODE_INVALID_TIMEZONE;
|
||||
return DND_REASON_TIME_ZONE_NOT_MATCH;
|
||||
}
|
||||
|
||||
if (0 != strcasecmp(pCfg->locale, tsLocale)) {
|
||||
mError("dnode:%d, locale:%s inconsistent with cluster:%s", pDnode->id, pCfg->locale, tsLocale);
|
||||
terrno = TSDB_CODE_DNODE_INVALID_LOCALE;
|
||||
return DND_REASON_LOCALE_NOT_MATCH;
|
||||
}
|
||||
|
||||
if (0 != strcasecmp(pCfg->charset, tsCharset)) {
|
||||
mError("dnode:%d, charset:%s inconsistent with cluster:%s", pDnode->id, pCfg->charset, tsCharset);
|
||||
terrno = TSDB_CODE_DNODE_INVALID_CHARSET;
|
||||
return DND_REASON_CHARSET_NOT_MATCH;
|
||||
}
|
||||
|
||||
if (pCfg->ttlChangeOnWrite != tsTtlChangeOnWrite) {
|
||||
mError("dnode:%d, ttlChangeOnWrite:%d inconsistent with cluster:%d", pDnode->id, pCfg->ttlChangeOnWrite,
|
||||
tsTtlChangeOnWrite);
|
||||
terrno = TSDB_CODE_DNODE_INVALID_TTL_CHG_ON_WR;
|
||||
return DND_REASON_TTL_CHANGE_ON_WRITE_NOT_MATCH;
|
||||
}
|
||||
int8_t enable = tsEnableWhiteList ? 1 : 0;
|
||||
if (pCfg->enableWhiteList != enable) {
|
||||
mError("dnode:%d, enable :%d inconsistent with cluster:%d", pDnode->id, pCfg->enableWhiteList, enable);
|
||||
mError("dnode:%d, enableWhiteList:%d inconsistent with cluster:%d", pDnode->id, pCfg->enableWhiteList, enable);
|
||||
terrno = TSDB_CODE_DNODE_INVALID_EN_WHITELIST;
|
||||
return DND_REASON_ENABLE_WHITELIST_NOT_MATCH;
|
||||
}
|
||||
|
||||
return 0;
|
||||
if (!atomic_load_8(&pMnode->encryptMgmt.encrypting) &&
|
||||
(pCfg->encryptionKeyStat != tsEncryptionKeyStat || pCfg->encryptionKeyChksum != tsEncryptionKeyChksum)) {
|
||||
mError("dnode:%d, encryptionKey:%" PRIi8 "-%u inconsistent with cluster:%" PRIi8 "-%u", pDnode->id,
|
||||
pCfg->encryptionKeyStat, pCfg->encryptionKeyChksum, tsEncryptionKeyStat, tsEncryptionKeyChksum);
|
||||
terrno = pCfg->encryptionKeyChksum ? TSDB_CODE_DNODE_INVALID_ENCRYPTKEY : TSDB_CODE_DNODE_NO_ENCRYPT_KEY;
|
||||
return DND_REASON_ENCRYPTION_KEY_NOT_MATCH;
|
||||
}
|
||||
|
||||
return DND_REASON_ONLINE;
|
||||
}
|
||||
|
||||
static bool mndUpdateVnodeState(int32_t vgId, SVnodeGid *pGid, SVnodeLoad *pVload) {
|
||||
|
@ -795,8 +815,9 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
bool dnodeChanged = (statusReq.dnodeVer == 0) || (statusReq.dnodeVer != dnodeVer);
|
||||
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
||||
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
|
||||
bool needCheck =
|
||||
!online || dnodeChanged || reboot || supportVnodesChanged || pMnode->ipWhiteVer != statusReq.ipWhiteVer;
|
||||
bool encryptKeyChanged = pDnode->encryptionKeyChksum != statusReq.clusterCfg.encryptionKeyChksum;
|
||||
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged ||
|
||||
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged;
|
||||
|
||||
const STraceId *trace = &pReq->info.traceId;
|
||||
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||
|
@ -891,7 +912,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
pDnode->offlineReason = mndCheckClusterCfgPara(pMnode, pDnode, &statusReq.clusterCfg);
|
||||
if (pDnode->offlineReason != 0) {
|
||||
mError("dnode:%d, cluster cfg inconsistent since:%s", pDnode->id, offlineReason[pDnode->offlineReason]);
|
||||
terrno = TSDB_CODE_MND_INVALID_CLUSTER_CFG;
|
||||
if (terrno == 0) terrno = TSDB_CODE_MND_INVALID_CLUSTER_CFG;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -909,6 +930,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
pDnode->numOfDiskCfg = statusReq.numOfDiskCfg;
|
||||
pDnode->memAvail = statusReq.memAvail;
|
||||
pDnode->memTotal = statusReq.memTotal;
|
||||
pDnode->encryptionKeyStat = statusReq.clusterCfg.encryptionKeyStat;
|
||||
pDnode->encryptionKeyChksum = statusReq.clusterCfg.encryptionKeyChksum;
|
||||
if (memcmp(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN) != 0) {
|
||||
tstrncpy(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN + 1);
|
||||
mndUpdateDnodeObj(pMnode, pDnode);
|
||||
|
@ -1494,6 +1517,136 @@ static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateEncryptKeyReqImpl(SRpcMsg *pReq, int32_t dnodeId, SDCfgDnodeReq *pDcfgReq) {
|
||||
int32_t code = 0;
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
int8_t encrypting = 0;
|
||||
|
||||
const STraceId *trace = &pReq->info.traceId;
|
||||
|
||||
int32_t klen = strlen(pDcfgReq->value);
|
||||
if (klen > ENCRYPT_KEY_LEN || klen < ENCRYPT_KEY_LEN_MIN) {
|
||||
code = TSDB_CODE_DNODE_INVALID_ENCRYPT_KLEN;
|
||||
mGError("msg:%p, failed to create encrypt_key since invalid key length:%d, valid range:[%d, %d]", pReq, klen,
|
||||
ENCRYPT_KEY_LEN_MIN, ENCRYPT_KEY_LEN);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (0 != (encrypting = atomic_val_compare_exchange_8(&pMnode->encryptMgmt.encrypting, 0, 1))) {
|
||||
code = TSDB_CODE_QRY_DUPLICATED_OPERATION;
|
||||
mGWarn("msg:%p, failed to create encrypt key since %s, encrypting:%" PRIi8, pReq, tstrerror(code), encrypting);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (tsEncryptionKeyStat == ENCRYPT_KEY_STAT_SET || tsEncryptionKeyStat == ENCRYPT_KEY_STAT_LOADED) {
|
||||
atomic_store_8(&pMnode->encryptMgmt.encrypting, 0);
|
||||
code = TSDB_CODE_QRY_DUPLICATED_OPERATION;
|
||||
mGWarn("msg:%p, failed to create encrypt key since %s, stat:%" PRIi8 ", checksum:%u", pReq, tstrerror(code),
|
||||
tsEncryptionKeyStat, tsEncryptionKeyChksum);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
atomic_store_16(&pMnode->encryptMgmt.nEncrypt, 0);
|
||||
atomic_store_16(&pMnode->encryptMgmt.nSuccess, 0);
|
||||
atomic_store_16(&pMnode->encryptMgmt.nFailed, 0);
|
||||
|
||||
while (1) {
|
||||
SDnodeObj *pDnode = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
|
||||
if (pIter == NULL) break;
|
||||
if (pDnode->offlineReason != DND_REASON_ONLINE) {
|
||||
mGWarn("msg:%p, don't send create encrypt_key req since dnode:%d in offline state:%s", pReq, pDnode->id,
|
||||
offlineReason[pDnode->offlineReason]);
|
||||
sdbRelease(pSdb, pDnode);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dnodeId == -1 || pDnode->id == dnodeId || dnodeId == 0) {
|
||||
SEpSet epSet = mndGetDnodeEpset(pDnode);
|
||||
int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, pDcfgReq);
|
||||
void *pBuf = rpcMallocCont(bufLen);
|
||||
|
||||
if (pBuf != NULL) {
|
||||
tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CREATE_ENCRYPT_KEY, .pCont = pBuf, .contLen = bufLen};
|
||||
if (0 == tmsgSendReq(&epSet, &rpcMsg)) {
|
||||
atomic_add_fetch_16(&pMnode->encryptMgmt.nEncrypt, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sdbRelease(pSdb, pDnode);
|
||||
}
|
||||
|
||||
if (atomic_load_16(&pMnode->encryptMgmt.nEncrypt) <= 0) {
|
||||
atomic_store_8(&pMnode->encryptMgmt.encrypting, 0);
|
||||
}
|
||||
|
||||
_exit:
|
||||
if (code != 0) {
|
||||
if (terrno == 0) terrno = code;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateEncryptKeyReq(SRpcMsg *pReq) {
|
||||
#ifdef TD_ENTERPRISE
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SMCfgDnodeReq cfgReq = {0};
|
||||
if (tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE) != 0) {
|
||||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
return -1;
|
||||
}
|
||||
const STraceId *trace = &pReq->info.traceId;
|
||||
SDCfgDnodeReq dcfgReq = {0};
|
||||
if (strncasecmp(cfgReq.config, "encrypt_key", 12) == 0) {
|
||||
strcpy(dcfgReq.config, cfgReq.config);
|
||||
strcpy(dcfgReq.value, cfgReq.value);
|
||||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
return mndProcessCreateEncryptKeyReqImpl(pReq, cfgReq.dnodeId, &dcfgReq);
|
||||
} else {
|
||||
terrno = TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateEncryptKeyRsp(SRpcMsg *pRsp) {
|
||||
SMnode *pMnode = pRsp->info.node;
|
||||
int16_t nSuccess = 0;
|
||||
int16_t nFailed = 0;
|
||||
|
||||
if (0 == pRsp->code) {
|
||||
nSuccess = atomic_add_fetch_16(&pMnode->encryptMgmt.nSuccess, 1);
|
||||
} else {
|
||||
nFailed = atomic_add_fetch_16(&pMnode->encryptMgmt.nFailed, 1);
|
||||
}
|
||||
|
||||
int16_t nReq = atomic_load_16(&pMnode->encryptMgmt.nEncrypt);
|
||||
bool finished = nSuccess + nFailed >= nReq;
|
||||
|
||||
if (finished) {
|
||||
atomic_store_8(&pMnode->encryptMgmt.encrypting, 0);
|
||||
}
|
||||
|
||||
const STraceId *trace = &pRsp->info.traceId;
|
||||
mGInfo("msg:%p, create encrypt key rsp, nReq:%" PRIi16 ", nSucess:%" PRIi16 ", nFailed:%" PRIi16 ", %s", pRsp, nReq,
|
||||
nSuccess, nFailed, finished ? "encrypt done" : "in encrypting");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveConfigs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
int32_t totalRows = 0;
|
||||
|
@ -1550,7 +1703,7 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
ESdbStatus objStatus = 0;
|
||||
SDnodeObj *pDnode = NULL;
|
||||
int64_t curMs = taosGetTimestampMs();
|
||||
char buf[TSDB_CONN_ACTIVE_KEY_LEN + VARSTR_HEADER_SIZE]; // make sure TSDB_CONN_ACTIVE_KEY_LEN >= TSDB_EP_LEN
|
||||
char buf[TSDB_EP_LEN + VARSTR_HEADER_SIZE];
|
||||
|
||||
while (numOfRows < rows) {
|
||||
pShow->pIter = sdbFetchAll(pSdb, SDB_DNODE, pShow->pIter, (void **)&pDnode, &objStatus, true);
|
||||
|
|
|
@ -104,6 +104,7 @@ void dumpDb(SSdb *pSdb, SJson *json) {
|
|||
tjsonAddStringToObject(item, "maxRows", i642str(pObj->cfg.maxRows));
|
||||
tjsonAddStringToObject(item, "precision", i642str(pObj->cfg.precision));
|
||||
tjsonAddStringToObject(item, "compression", i642str(pObj->cfg.compression));
|
||||
tjsonAddStringToObject(item, "encryptAlgorithm", i642str(pObj->cfg.encryptAlgorithm));
|
||||
tjsonAddStringToObject(item, "replications", i642str(pObj->cfg.replications));
|
||||
tjsonAddStringToObject(item, "strict", i642str(pObj->cfg.strict));
|
||||
tjsonAddStringToObject(item, "cacheLast", i642str(pObj->cfg.cacheLast));
|
||||
|
|
|
@ -58,6 +58,7 @@ static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
static int32_t mndRetrieveGrantFull(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||
static int32_t mndRetrieveGrantLogs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||
static int32_t mndRetrieveMachines(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||
static int32_t mndRetrieveEncryptions(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||
|
||||
static int32_t mndProcessGrantHB(SRpcMsg *pReq) { return TSDB_CODE_SUCCESS; }
|
||||
|
||||
|
@ -66,6 +67,7 @@ int32_t mndInitGrant(SMnode *pMnode) {
|
|||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_FULL, mndRetrieveGrantFull);
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_LOGS, mndRetrieveGrantLogs);
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MACHINES, mndRetrieveMachines);
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_ENCRYPTIONS, mndRetrieveEncryptions);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_GRANT_HB_TIMER, mndProcessGrantHB);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -668,6 +668,7 @@ _OVER:
|
|||
if (newStb.pTags != NULL) {
|
||||
taosMemoryFree(newStb.pTags);
|
||||
taosMemoryFree(newStb.pColumns);
|
||||
taosMemoryFree(newStb.pCmpr);
|
||||
}
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
|
@ -784,6 +785,7 @@ static int32_t mndDropIdx(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SIdxObj *p
|
|||
_OVER:
|
||||
taosMemoryFree(newObj.pTags);
|
||||
taosMemoryFree(newObj.pColumns);
|
||||
taosMemoryFree(newObj.pCmpr);
|
||||
|
||||
mndTransDrop(pTrans);
|
||||
mndReleaseStb(pMnode, pStb);
|
||||
|
|
|
@ -88,7 +88,6 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
*pRsp = *pMeta;
|
||||
|
||||
pRsp->pSchemas = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchema));
|
||||
|
@ -130,6 +129,8 @@ int32_t mndBuildInsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbN
|
|||
}
|
||||
|
||||
memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema));
|
||||
|
||||
pRsp->pSchemaExt = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchemaExt));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -485,8 +485,23 @@ static int32_t mndInitWal(SMnode *pMnode) {
|
|||
.retentionPeriod = 0,
|
||||
.retentionSize = 0,
|
||||
.level = TAOS_WAL_FSYNC,
|
||||
.encryptAlgorithm = 0,
|
||||
.encryptKey = {0}
|
||||
};
|
||||
|
||||
#if defined(TD_ENTERPRISE)
|
||||
if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_MNODE_WAL) == DND_CS_MNODE_WAL){
|
||||
cfg.encryptAlgorithm = (tsiEncryptScope & DND_CS_MNODE_WAL)? tsiEncryptAlgorithm : 0;
|
||||
if(tsEncryptKey[0] == '\0'){
|
||||
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
return -1;
|
||||
}
|
||||
else{
|
||||
strncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
pMnode->pWal = walOpen(path, &cfg);
|
||||
if (pMnode->pWal == NULL) {
|
||||
mError("failed to open wal since %s. wal:%s", terrstr(), path);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "mndStb.h"
|
||||
#include "mndUser.h"
|
||||
#include "mndView.h"
|
||||
#include "mndSma.h"
|
||||
#include "tglobal.h"
|
||||
#include "tversion.h"
|
||||
|
||||
|
@ -606,6 +607,16 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
case HEARTBEAT_KEY_TSMA: {
|
||||
void * rspMsg = NULL;
|
||||
int32_t rspLen = 0;
|
||||
mndValidateTSMAInfo(pMnode, kv->value, kv->valueLen / sizeof(STSMAVersion), &rspMsg, &rspLen);
|
||||
if (rspMsg && rspLen > 0) {
|
||||
SKv kv = {.key = HEARTBEAT_KEY_TSMA, .valueLen = rspLen, .value = rspMsg};
|
||||
taosArrayPush(hbRsp.info, &kv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
mError("invalid kv key:%d", kv->key);
|
||||
hbRsp.status = TSDB_CODE_APP_ERROR;
|
||||
|
|
|
@ -109,7 +109,7 @@ int32_t mndSetSinkTaskInfo(SStreamObj* pStream, SStreamTask* pTask) {
|
|||
|
||||
mDebug("mndSetSinkTaskInfo to sma or table, taskId:%s", pTask->id.idStr);
|
||||
|
||||
if (pStream->smaId != 0) {
|
||||
if (pStream->smaId != 0 && pStream->subTableWithoutMd5 != 1) {
|
||||
pInfo->type = TASK_OUTPUT__SMA;
|
||||
pInfo->smaSink.smaId = pStream->smaId;
|
||||
} else {
|
||||
|
|
|
@ -131,6 +131,10 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
|||
type = TSDB_MGMT_TABLE_GRANTS_LOGS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_MACHINES;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_ENCRYPTIONS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_ENCRYPTIONS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_TSMAS;
|
||||
} else {
|
||||
mError("invalid show name:%s len:%d", name, len);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -33,7 +33,7 @@
|
|||
#include "mndVgroup.h"
|
||||
#include "tname.h"
|
||||
|
||||
#define STB_VER_NUMBER 1
|
||||
#define STB_VER_NUMBER 2
|
||||
#define STB_RESERVE_SIZE 64
|
||||
|
||||
static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw);
|
||||
|
@ -62,6 +62,10 @@ static int32_t mndAlterStbAndUpdateTagIdxImp(SMnode *pMnode, SRpcMsg *pReq, SDb
|
|||
static int32_t mndProcessCreateIndexReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessDropIndexReq(SRpcMsg *pReq);
|
||||
|
||||
static int32_t mndProcessDropStbReqFromMNode(SRpcMsg *pReq);
|
||||
static int32_t mndProcessDropTbWithTsma(SRpcMsg* pReq);
|
||||
static int32_t mndProcessFetchTtlExpiredTbs(SRpcMsg *pReq);
|
||||
|
||||
int32_t mndInitStb(SMnode *pMnode) {
|
||||
SSdbTable table = {
|
||||
.sdbType = SDB_STB,
|
||||
|
@ -87,6 +91,11 @@ int32_t mndInitStb(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_VND_S3MIGRATE_RSP, mndProcessS3MigrateDbRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_S3MIGRATE_DB_TIMER, mndProcessS3MigrateDbTimer);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TABLE_CFG, mndProcessTableCfgReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_STB_DROP, mndProcessDropStbReqFromMNode);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_STB_DROP_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_TB_WITH_TSMA, mndProcessDropTbWithTsma);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP, mndProcessFetchTtlExpiredTbs);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_DROP_TABLE_RSP, mndTransProcessRsp);
|
||||
// mndSetMsgHandle(pMnode, TDMT_MND_SYSTABLE_RETRIEVE, mndProcessRetrieveStbReq);
|
||||
|
||||
// mndSetMsgHandle(pMnode, TDMT_MND_CREATE_INDEX, mndProcessCreateIndexReq);
|
||||
|
@ -109,7 +118,8 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
|||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
int32_t size = sizeof(SStbObj) + (pStb->numOfColumns + pStb->numOfTags) * sizeof(SSchema) + pStb->commentLen +
|
||||
pStb->ast1Len + pStb->ast2Len + STB_RESERVE_SIZE + taosArrayGetSize(pStb->pFuncs) * TSDB_FUNC_NAME_LEN;
|
||||
pStb->ast1Len + pStb->ast2Len + pStb->numOfColumns * sizeof(SColCmpr) + STB_RESERVE_SIZE +
|
||||
taosArrayGetSize(pStb->pFuncs) * TSDB_FUNC_NAME_LEN;
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_STB, STB_VER_NUMBER, size);
|
||||
if (pRaw == NULL) goto _OVER;
|
||||
|
||||
|
@ -171,6 +181,13 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
|||
SDB_SET_BINARY(pRaw, dataPos, pStb->pAst2, pStb->ast2Len, _OVER)
|
||||
}
|
||||
|
||||
if (pStb->pCmpr != NULL) {
|
||||
for (int i = 0; i < pStb->numOfColumns; i++) {
|
||||
SColCmpr *p = &pStb->pCmpr[i];
|
||||
SDB_SET_INT16(pRaw, dataPos, p->id, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, p->alg, _OVER)
|
||||
}
|
||||
}
|
||||
SDB_SET_RESERVE(pRaw, dataPos, STB_RESERVE_SIZE, _OVER)
|
||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
||||
|
||||
|
@ -195,7 +212,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
|
|||
int8_t sver = 0;
|
||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER;
|
||||
|
||||
if (sver != STB_VER_NUMBER) {
|
||||
if (sver > STB_VER_NUMBER) {
|
||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -277,6 +294,25 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
|
|||
if (pStb->pAst2 == NULL) goto _OVER;
|
||||
SDB_GET_BINARY(pRaw, dataPos, pStb->pAst2, pStb->ast2Len, _OVER)
|
||||
}
|
||||
|
||||
pStb->pCmpr = taosMemoryCalloc(pStb->numOfColumns, sizeof(SColCmpr));
|
||||
if (sver < STB_VER_NUMBER) {
|
||||
// compatible with old data, setup default compress value
|
||||
// impl later
|
||||
for (int i = 0; i < pStb->numOfColumns; i++) {
|
||||
SSchema *pSchema = &pStb->pColumns[i];
|
||||
SColCmpr *pCmpr = &pStb->pCmpr[i];
|
||||
pCmpr->id = pSchema->colId;
|
||||
pCmpr->alg = createDefaultColCmprByType(pSchema->type);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < pStb->numOfColumns; i++) {
|
||||
SColCmpr *pCmpr = &pStb->pCmpr[i];
|
||||
SDB_GET_INT16(pRaw, dataPos, &pCmpr->id, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, (int32_t *)&pCmpr->alg, _OVER) // compatiable
|
||||
}
|
||||
}
|
||||
|
||||
SDB_GET_RESERVE(pRaw, dataPos, STB_RESERVE_SIZE, _OVER)
|
||||
|
||||
terrno = 0;
|
||||
|
@ -288,6 +324,7 @@ _OVER:
|
|||
taosMemoryFreeClear(pStb->pColumns);
|
||||
taosMemoryFreeClear(pStb->pTags);
|
||||
taosMemoryFreeClear(pStb->comment);
|
||||
taosMemoryFree(pStb->pCmpr);
|
||||
}
|
||||
taosMemoryFreeClear(pRow);
|
||||
return NULL;
|
||||
|
@ -304,6 +341,7 @@ void mndFreeStb(SStbObj *pStb) {
|
|||
taosMemoryFreeClear(pStb->comment);
|
||||
taosMemoryFreeClear(pStb->pAst1);
|
||||
taosMemoryFreeClear(pStb->pAst2);
|
||||
taosMemoryFreeClear(pStb->pCmpr);
|
||||
}
|
||||
|
||||
static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb) {
|
||||
|
@ -321,7 +359,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
|
|||
mTrace("stb:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew);
|
||||
|
||||
taosWLockLatch(&pOld->lock);
|
||||
|
||||
int32_t numOfColumns = pOld->numOfColumns;
|
||||
if (pOld->numOfColumns < pNew->numOfColumns) {
|
||||
void *pColumns = taosMemoryMalloc(pNew->numOfColumns * sizeof(SSchema));
|
||||
if (pColumns != NULL) {
|
||||
|
@ -409,6 +447,14 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
|
|||
memcpy(pOld->pAst2, pNew->pAst2, pNew->ast2Len);
|
||||
pOld->ast2Len = pNew->ast2Len;
|
||||
}
|
||||
if (numOfColumns < pNew->numOfColumns) {
|
||||
taosMemoryFree(pOld->pCmpr);
|
||||
pOld->pCmpr = taosMemoryCalloc(pNew->numOfColumns, sizeof(SColCmpr));
|
||||
memcpy(pOld->pCmpr, pNew->pCmpr, pNew->numOfColumns * sizeof(SColCmpr));
|
||||
} else {
|
||||
memcpy(pOld->pCmpr, pNew->pCmpr, pNew->numOfColumns * sizeof(SColCmpr));
|
||||
}
|
||||
|
||||
taosWUnLockLatch(&pOld->lock);
|
||||
return 0;
|
||||
}
|
||||
|
@ -471,6 +517,18 @@ void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int3
|
|||
req.schemaTag.version = pStb->tagVer;
|
||||
req.schemaTag.pSchema = pStb->pTags;
|
||||
|
||||
req.colCmpred = 1;
|
||||
SColCmprWrapper *pCmpr = &req.colCmpr;
|
||||
pCmpr->version = pStb->colVer;
|
||||
pCmpr->nCols = pStb->numOfColumns;
|
||||
|
||||
req.colCmpr.pColCmpr = taosMemoryCalloc(pCmpr->nCols, sizeof(SColCmpr));
|
||||
for (int32_t i = 0; i < pStb->numOfColumns; i++) {
|
||||
SColCmpr *p = &pCmpr->pColCmpr[i];
|
||||
p->alg = pStb->pCmpr[i].alg;
|
||||
p->id = pStb->pCmpr[i].id;
|
||||
}
|
||||
|
||||
if (req.rollup) {
|
||||
req.rsmaParam.maxdelay[0] = pStb->maxdelay[0];
|
||||
req.rsmaParam.maxdelay[1] = pStb->maxdelay[1];
|
||||
|
@ -521,10 +579,12 @@ void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int3
|
|||
*pContLen = contLen;
|
||||
taosMemoryFreeClear(req.rsmaParam.qmsg[0]);
|
||||
taosMemoryFreeClear(req.rsmaParam.qmsg[1]);
|
||||
taosMemoryFreeClear(req.colCmpr.pColCmpr);
|
||||
return pHead;
|
||||
_err:
|
||||
taosMemoryFreeClear(req.rsmaParam.qmsg[0]);
|
||||
taosMemoryFreeClear(req.rsmaParam.qmsg[1]);
|
||||
taosMemoryFreeClear(req.colCmpr.pColCmpr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -587,7 +647,7 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < pCreate->numOfColumns; ++i) {
|
||||
SField *pField1 = taosArrayGet(pCreate->pColumns, i);
|
||||
SFieldWithOptions *pField1 = taosArrayGet(pCreate->pColumns, i);
|
||||
if (pField1->type >= TSDB_DATA_TYPE_MAX) {
|
||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||
return -1;
|
||||
|
@ -829,8 +889,8 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < pDst->numOfColumns; ++i) {
|
||||
SField *pField = taosArrayGet(pCreate->pColumns, i);
|
||||
SSchema *pSchema = &pDst->pColumns[i];
|
||||
SFieldWithOptions *pField = taosArrayGet(pCreate->pColumns, i);
|
||||
SSchema *pSchema = &pDst->pColumns[i];
|
||||
pSchema->type = pField->type;
|
||||
pSchema->bytes = pField->bytes;
|
||||
pSchema->flags = pField->flags;
|
||||
|
@ -851,6 +911,16 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
|
|||
pSchema->colId = pDst->nextColId;
|
||||
pDst->nextColId++;
|
||||
}
|
||||
// set col compress
|
||||
pDst->pCmpr = taosMemoryCalloc(1, pDst->numOfColumns * sizeof(SCmprObj));
|
||||
for (int32_t i = 0; i < pDst->numOfColumns; i++) {
|
||||
SFieldWithOptions *pField = taosArrayGet(pCreate->pColumns, i);
|
||||
SSchema *pSchema = &pDst->pColumns[i];
|
||||
|
||||
SColCmpr *pColCmpr = &pDst->pCmpr[i];
|
||||
pColCmpr->id = pSchema->colId;
|
||||
pColCmpr->alg = pField->compress;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static int32_t mndGenIdxNameForFirstTag(char *fullname, char *dbname, char *stbname, char *tagname) {
|
||||
|
@ -936,7 +1006,7 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) {
|
|||
pHead->vgId = htonl(pVgroup->vgId);
|
||||
tSerializeSVDropTtlTableReq((char *)pHead + sizeof(SMsgHead), reqLen, &ttlReq);
|
||||
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_VND_DROP_TTL_TABLE, .pCont = pHead, .contLen = contLen, .info = pReq->info};
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_VND_FETCH_TTL_EXPIRED_TBS, .pCont = pHead, .contLen = contLen, .info = pReq->info};
|
||||
SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
int32_t code = tmsgSendReq(&epSet, &rpcMsg);
|
||||
if (code != 0) {
|
||||
|
@ -1069,7 +1139,9 @@ static int32_t mndBuildStbFromAlter(SStbObj *pStb, SStbObj *pDst, SMCreateStbReq
|
|||
pDst->numOfTags = createReq->numOfTags;
|
||||
pDst->pColumns = taosMemoryCalloc(1, pDst->numOfColumns * sizeof(SSchema));
|
||||
pDst->pTags = taosMemoryCalloc(1, pDst->numOfTags * sizeof(SSchema));
|
||||
if (pDst->pColumns == NULL || pDst->pTags == NULL) {
|
||||
pDst->pCmpr = taosMemoryCalloc(1, pDst->numOfColumns * sizeof(SColCmpr));
|
||||
|
||||
if (pDst->pColumns == NULL || pDst->pTags == NULL || pDst->pCmpr == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
@ -1080,8 +1152,8 @@ static int32_t mndBuildStbFromAlter(SStbObj *pStb, SStbObj *pDst, SMCreateStbReq
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < pDst->numOfColumns; ++i) {
|
||||
SField *pField = taosArrayGet(createReq->pColumns, i);
|
||||
SSchema *pSchema = &pDst->pColumns[i];
|
||||
SFieldWithOptions *pField = taosArrayGet(createReq->pColumns, i);
|
||||
SSchema *pSchema = &pDst->pColumns[i];
|
||||
pSchema->type = pField->type;
|
||||
pSchema->bytes = pField->bytes;
|
||||
pSchema->flags = pField->flags;
|
||||
|
@ -1107,6 +1179,17 @@ static int32_t mndBuildStbFromAlter(SStbObj *pStb, SStbObj *pDst, SMCreateStbReq
|
|||
pSchema->colId = pDst->nextColId++;
|
||||
}
|
||||
}
|
||||
for (int32_t i = 0; i < pDst->numOfColumns; i++) {
|
||||
SColCmpr *p = pDst->pCmpr + i;
|
||||
SFieldWithOptions *pField = taosArrayGet(createReq->pColumns, i);
|
||||
SSchema *pSchema = &pDst->pColumns[i];
|
||||
p->id = pSchema->colId;
|
||||
if (pField->compress == 0) {
|
||||
p->alg = createDefaultColCmprByType(pSchema->type);
|
||||
} else {
|
||||
p->alg = pField->compress;
|
||||
}
|
||||
}
|
||||
pDst->tagVer = createReq->tagVer;
|
||||
pDst->colVer = createReq->colVer;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1151,10 +1234,8 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
|||
mInfo("stb:%s, schema version is not incremented and nothing needs to be done", createReq.name);
|
||||
code = 0;
|
||||
goto _OVER;
|
||||
} else if ((tagDelta == 1 && colDelta == 0) ||
|
||||
(tagDelta == 0 && colDelta == 1) ||
|
||||
(pStb->colVer == 1 && createReq.colVer > 1) ||
|
||||
(pStb->tagVer == 1 && createReq.tagVer > 1)) {
|
||||
} else if ((tagDelta == 1 && colDelta == 0) || (tagDelta == 0 && colDelta == 1) ||
|
||||
(pStb->colVer == 1 && createReq.colVer > 1) || (pStb->tagVer == 1 && createReq.tagVer > 1)) {
|
||||
isAlter = true;
|
||||
mInfo("stb:%s, schema version is only increased by 1 number, do alter operation", createReq.name);
|
||||
} else {
|
||||
|
@ -1212,12 +1293,14 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
|||
if (mndBuildStbFromAlter(pStb, &pDst, &createReq) != 0) {
|
||||
taosMemoryFreeClear(pDst.pTags);
|
||||
taosMemoryFreeClear(pDst.pColumns);
|
||||
taosMemoryFreeClear(pDst.pCmpr);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = mndAlterStbImp(pMnode, pReq, pDb, &pDst, needRsp, NULL, 0);
|
||||
taosMemoryFreeClear(pDst.pTags);
|
||||
taosMemoryFreeClear(pDst.pColumns);
|
||||
taosMemoryFreeClear(pDst.pCmpr);
|
||||
} else {
|
||||
code = mndCreateStb(pMnode, pReq, &createReq, pDb);
|
||||
}
|
||||
|
@ -1270,13 +1353,16 @@ static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
|
|||
int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
|
||||
pNew->pTags = taosMemoryCalloc(pNew->numOfTags, sizeof(SSchema));
|
||||
pNew->pColumns = taosMemoryCalloc(pNew->numOfColumns, sizeof(SSchema));
|
||||
if (pNew->pTags == NULL || pNew->pColumns == NULL) {
|
||||
pNew->pCmpr = taosMemoryCalloc(pNew->numOfColumns, sizeof(SColCmpr));
|
||||
if (pNew->pTags == NULL || pNew->pColumns == NULL || pNew->pCmpr == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(pNew->pColumns, pOld->pColumns, sizeof(SSchema) * pOld->numOfColumns);
|
||||
memcpy(pNew->pTags, pOld->pTags, sizeof(SSchema) * pOld->numOfTags);
|
||||
memcpy(pNew->pCmpr, pOld->pCmpr, sizeof(SColCmpr) * pOld->numOfColumns);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1644,6 +1730,53 @@ static int32_t mndAlterStbTagBytes(SMnode *pMnode, const SStbObj *pOld, SStbObj
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndUpdateSuperTableColumnCompress(SMnode *pMnode, const SStbObj *pOld, SStbObj *pNew, SArray *pField,
|
||||
int32_t nCols) {
|
||||
// if (pColCmpr == NULL || colName == NULL) return -1;
|
||||
|
||||
ASSERT(taosArrayGetSize(pField) == nCols);
|
||||
TAOS_FIELD *p = taosArrayGet(pField, 0);
|
||||
|
||||
int32_t code = 0;
|
||||
int32_t idx = mndFindSuperTableColumnIndex(pOld, p->name);
|
||||
if (idx == -1) {
|
||||
terrno = TSDB_CODE_MND_COLUMN_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
SSchema *pTarget = &pOld->pColumns[idx];
|
||||
col_id_t colId = pTarget->colId;
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->name, pOld->uid, colId) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (!validColCmprByType(pTarget->type, p->bytes)) {
|
||||
terrno = TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int8_t updated = 0;
|
||||
for (int i = 0; i < pNew->numOfColumns; i++) {
|
||||
SColCmpr *pCmpr = &pNew->pCmpr[i];
|
||||
if (pCmpr->id == colId) {
|
||||
uint32_t dst = 0;
|
||||
updated = tUpdateCompress(pCmpr->alg, p->bytes, TSDB_COLVAL_COMPRESS_DISABLED, TSDB_COLVAL_LEVEL_DISABLED,
|
||||
TSDB_COLVAL_LEVEL_MEDIUM, &dst);
|
||||
if (updated) pCmpr->alg = dst;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (updated == 0) {
|
||||
terrno = TSDB_CODE_MND_COLUMN_COMPRESS_ALREADY_EXIST;
|
||||
return -1;
|
||||
}
|
||||
pNew->colVer++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray *pFields, int32_t ncols) {
|
||||
if (pOld->numOfColumns + ncols + pOld->numOfTags > TSDB_MAX_COLUMNS) {
|
||||
terrno = TSDB_CODE_MND_TOO_MANY_COLUMNS;
|
||||
|
@ -1660,6 +1793,7 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
|
|||
}
|
||||
|
||||
pNew->numOfColumns = pNew->numOfColumns + ncols;
|
||||
|
||||
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -1688,6 +1822,10 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
|
|||
pSchema->colId = pNew->nextColId;
|
||||
pNew->nextColId++;
|
||||
|
||||
SColCmpr *pCmpr = &pNew->pCmpr[pOld->numOfColumns + i];
|
||||
pCmpr->id = pSchema->colId;
|
||||
pCmpr->alg = createDefaultColCmprByType(pSchema->type);
|
||||
|
||||
mInfo("stb:%s, start to add column %s", pNew->name, pSchema->name);
|
||||
}
|
||||
|
||||
|
@ -1721,7 +1859,9 @@ static int32_t mndDropSuperTableColumn(SMnode *pMnode, const SStbObj *pOld, SStb
|
|||
return -1;
|
||||
}
|
||||
|
||||
memmove(pNew->pColumns + col, pNew->pColumns + col + 1, sizeof(SSchema) * (pNew->numOfColumns - col - 1));
|
||||
int32_t sz = pNew->numOfColumns - col - 1;
|
||||
memmove(pNew->pColumns + col, pNew->pColumns + col + 1, sizeof(SSchema) * sz);
|
||||
memmove(pNew->pCmpr + col, pNew->pCmpr + col + 1, sizeof(SColCmpr) * sz);
|
||||
pNew->numOfColumns--;
|
||||
|
||||
pNew->colVer++;
|
||||
|
@ -1884,6 +2024,12 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
|
|||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pRsp->pSchemaExt = taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchemaExt));
|
||||
if (pRsp->pSchemaExt == NULL) {
|
||||
taosRUnLockLatch(&pStb->lock);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tstrncpy(pRsp->dbFName, pStb->db, sizeof(pRsp->dbFName));
|
||||
tstrncpy(pRsp->tbName, tbName, sizeof(pRsp->tbName));
|
||||
|
@ -1917,6 +2063,12 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
|
|||
pSchema->colId = pSrcSchema->colId;
|
||||
pSchema->bytes = pSrcSchema->bytes;
|
||||
}
|
||||
for (int32_t i = 0; i < pStb->numOfColumns; i++) {
|
||||
SColCmpr *pCmpr = &pStb->pCmpr[i];
|
||||
SSchemaExt *pSchEx = &pRsp->pSchemaExt[i];
|
||||
pSchEx->colId = pCmpr->id;
|
||||
pSchEx->compress = pCmpr->alg;
|
||||
}
|
||||
|
||||
taosRUnLockLatch(&pStb->lock);
|
||||
return 0;
|
||||
|
@ -1973,6 +2125,15 @@ static int32_t mndBuildStbCfgImp(SDbObj *pDb, SStbObj *pStb, const char *tbName,
|
|||
pRsp->pFuncs = taosArrayDup(pStb->pFuncs, NULL);
|
||||
}
|
||||
|
||||
pRsp->pSchemaExt = taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchemaExt));
|
||||
for (int32_t i = 0; i < pStb->numOfColumns; i++) {
|
||||
SColCmpr *pCmpr = &pStb->pCmpr[i];
|
||||
|
||||
SSchemaExt *pSchExt = &pRsp->pSchemaExt[i];
|
||||
pSchExt->colId = pCmpr->id;
|
||||
pSchExt->compress = pCmpr->alg;
|
||||
}
|
||||
|
||||
taosRUnLockLatch(&pStb->lock);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2275,6 +2436,8 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
|
|||
taosRUnLockLatch(&pOld->lock);
|
||||
stbObj.pColumns = NULL;
|
||||
stbObj.pTags = NULL;
|
||||
stbObj.pFuncs = NULL;
|
||||
stbObj.pCmpr = NULL;
|
||||
stbObj.updateTime = taosGetTimestampMs();
|
||||
stbObj.lock = 0;
|
||||
bool updateTagIndex = false;
|
||||
|
@ -2310,6 +2473,9 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
|
|||
needRsp = false;
|
||||
code = mndUpdateStbCommentAndTTL(pOld, &stbObj, pAlter->comment, pAlter->commentLen, pAlter->ttl);
|
||||
break;
|
||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS:
|
||||
code = mndUpdateSuperTableColumnCompress(pMnode, pOld, &stbObj, pAlter->pFields, pAlter->numOfFields);
|
||||
break;
|
||||
default:
|
||||
needRsp = false;
|
||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||
|
@ -2326,6 +2492,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
|
|||
_OVER:
|
||||
taosMemoryFreeClear(stbObj.pTags);
|
||||
taosMemoryFreeClear(stbObj.pColumns);
|
||||
taosMemoryFreeClear(stbObj.pCmpr);
|
||||
if (pAlter->commentLen > 0) {
|
||||
taosMemoryFreeClear(stbObj.comment);
|
||||
}
|
||||
|
@ -2532,11 +2699,6 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName,
|
|||
pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (pStream->smaId != 0) {
|
||||
sdbRelease(pSdb, pStream);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pStream->targetStbUid == suid) {
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
sdbRelease(pSdb, pStream);
|
||||
|
@ -3227,6 +3389,11 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
continue;
|
||||
}
|
||||
|
||||
if (isTsmaResSTb(pStb->name)) {
|
||||
sdbRelease(pSdb, pStb);
|
||||
continue;
|
||||
}
|
||||
|
||||
cols = 0;
|
||||
|
||||
SName name = {0};
|
||||
|
@ -3693,3 +3860,376 @@ static int32_t mndProcessDropIndexReq(SRpcMsg *pReq) {
|
|||
_OVER:
|
||||
return code;
|
||||
}*/
|
||||
|
||||
static int32_t mndProcessDropStbReqFromMNode(SRpcMsg *pReq) {
|
||||
int32_t code = mndProcessDropStbReq(pReq);
|
||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
pReq->info.rsp = rpcMallocCont(1);
|
||||
pReq->info.rspLen = 1;
|
||||
pReq->info.noResp = false;
|
||||
pReq->code = code;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
typedef struct SVDropTbVgReqs {
|
||||
SVDropTbBatchReq req;
|
||||
SVgroupInfo info;
|
||||
} SVDropTbVgReqs;
|
||||
|
||||
typedef struct SMDropTbDbInfo {
|
||||
SArray *dbVgInfos;
|
||||
int32_t hashPrefix;
|
||||
int32_t hashSuffix;
|
||||
int32_t hashMethod;
|
||||
} SMDropTbDbInfo;
|
||||
|
||||
typedef struct SMDropTbTsmaInfo {
|
||||
char tsmaResTbDbFName[TSDB_DB_FNAME_LEN];
|
||||
char tsmaResTbNamePrefix[TSDB_TABLE_NAME_LEN];
|
||||
int32_t suid;
|
||||
SMDropTbDbInfo dbInfo; // reference to DbInfo in pDbMap
|
||||
} SMDropTbTsmaInfo;
|
||||
|
||||
typedef struct SMDropTbTsmaInfos {
|
||||
SArray* pTsmaInfos; // SMDropTbTsmaInfo
|
||||
} SMDropTbTsmaInfos;
|
||||
|
||||
typedef struct SMndDropTbsWithTsmaCtx {
|
||||
SHashObj* pTsmaMap; // <suid, SMDropTbTsmaInfos>
|
||||
SHashObj* pDbMap; // <dbuid, SMDropTbDbInfo>
|
||||
SHashObj* pVgMap; // <vgId, SVDropTbVgReqs>
|
||||
SArray* pResTbNames; // SArray<char*>
|
||||
} SMndDropTbsWithTsmaCtx;
|
||||
|
||||
static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWithTsmaCtx* pCtx, SArray* pTbs, int32_t vgId);
|
||||
|
||||
static void mndDestroyDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx* p) {
|
||||
if (!p) return;
|
||||
|
||||
if (p->pDbMap) {
|
||||
void* pIter = taosHashIterate(p->pDbMap, NULL);
|
||||
while (pIter) {
|
||||
SMDropTbDbInfo* pInfo = pIter;
|
||||
taosArrayDestroy(pInfo->dbVgInfos);
|
||||
pIter = taosHashIterate(p->pDbMap, pIter);
|
||||
}
|
||||
taosHashCleanup(p->pDbMap);
|
||||
}
|
||||
if (p->pResTbNames) {
|
||||
taosArrayDestroyP(p->pResTbNames, taosMemoryFree);
|
||||
}
|
||||
if (p->pTsmaMap) {
|
||||
void* pIter = taosHashIterate(p->pTsmaMap, NULL);
|
||||
while (pIter) {
|
||||
SMDropTbTsmaInfos* pInfos = pIter;
|
||||
taosArrayDestroy(pInfos->pTsmaInfos);
|
||||
pIter = taosHashIterate(p->pTsmaMap, pIter);
|
||||
}
|
||||
taosHashCleanup(p->pTsmaMap);
|
||||
}
|
||||
|
||||
if (p->pVgMap) {
|
||||
void* pIter = taosHashIterate(p->pVgMap, NULL);
|
||||
while (pIter) {
|
||||
SVDropTbVgReqs *pReqs = pIter;
|
||||
taosArrayDestroy(pReqs->req.pArray);
|
||||
pIter = taosHashIterate(p->pVgMap, pIter);
|
||||
}
|
||||
taosHashCleanup(p->pVgMap);
|
||||
}
|
||||
taosMemoryFree(p);
|
||||
}
|
||||
|
||||
static int32_t mndInitDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx** ppCtx) {
|
||||
int32_t code = 0;
|
||||
SMndDropTbsWithTsmaCtx* pCtx = taosMemoryCalloc(1, sizeof(SMndDropTbsWithTsmaCtx));
|
||||
if (!pCtx) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
pCtx->pTsmaMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||
if (!pCtx->pTsmaMap) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
pCtx->pDbMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
if (!pCtx->pDbMap) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _end;
|
||||
}
|
||||
pCtx->pResTbNames = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES);
|
||||
|
||||
pCtx->pVgMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
if (!pCtx->pVgMap) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _end;
|
||||
}
|
||||
*ppCtx = pCtx;
|
||||
_end:
|
||||
if (code) mndDestroyDropTbsWithTsmaCtx(pCtx);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
static void* mndBuildVDropTbsReq(SMnode* pMnode, const SVgroupInfo* pVgInfo, const SVDropTbBatchReq* pReq, int32_t *len) {
|
||||
int32_t contLen = 0;
|
||||
int32_t ret = 0;
|
||||
SMsgHead *pHead = NULL;
|
||||
SEncoder encoder = {0};
|
||||
|
||||
tEncodeSize(tEncodeSVDropTbBatchReq, pReq, contLen, ret);
|
||||
if (ret < 0) return NULL;
|
||||
|
||||
contLen += sizeof(SMsgHead);
|
||||
pHead = taosMemoryMalloc(contLen);
|
||||
if (pHead == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pHead->contLen = htonl(contLen);
|
||||
pHead->vgId = htonl(pVgInfo->vgId);
|
||||
|
||||
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
||||
|
||||
tEncoderInit(&encoder, pBuf, contLen - sizeof(SMsgHead));
|
||||
tEncodeSVDropTbBatchReq(&encoder, pReq);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
*len = contLen;
|
||||
return pHead;
|
||||
}
|
||||
|
||||
static int32_t mndSetDropTbsRedoActions(SMnode* pMnode, STrans* pTrans, const SVDropTbVgReqs* pVgReqs, void* pCont, int32_t contLen) {
|
||||
STransAction action = {0};
|
||||
action.epSet = pVgReqs->info.epSet;
|
||||
action.pCont = pCont;
|
||||
action.contLen = contLen;
|
||||
action.msgType = TDMT_VND_DROP_TABLE;
|
||||
action.acceptableCode = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||
return mndTransAppendRedoAction(pTrans, &action);
|
||||
}
|
||||
|
||||
static int32_t mndCreateDropTbsTxnPrepare(SRpcMsg* pRsp, SMndDropTbsWithTsmaCtx* pCtx) {
|
||||
SMnode *pMnode = pRsp->info.node;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pRsp, "drop-tbs");
|
||||
mndTransSetChangeless(pTrans);
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
if (mndTransCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
void* pIter = taosHashIterate(pCtx->pVgMap, NULL);
|
||||
while (pIter) {
|
||||
const SVDropTbVgReqs* pVgReqs = pIter;
|
||||
int32_t len = 0;
|
||||
void* p = mndBuildVDropTbsReq(pMnode, &pVgReqs->info, &pVgReqs->req, &len);
|
||||
if (!p || mndSetDropTbsRedoActions(pMnode, pTrans, pVgReqs, p, len) != 0) {
|
||||
taosHashCancelIterate(pCtx->pVgMap, pIter);
|
||||
goto _OVER;
|
||||
}
|
||||
pIter = taosHashIterate(pCtx->pVgMap, pIter);
|
||||
}
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
_OVER:
|
||||
mndTransDrop(pTrans);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropTbWithTsma(SRpcMsg* pReq) {
|
||||
int32_t code = -1;
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SDbObj *pDb = NULL;
|
||||
SStbObj *pStb = NULL;
|
||||
SMDropTbsReq dropReq = {0};
|
||||
bool locked = false;
|
||||
if (tDeserializeSMDropTbsReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
SMndDropTbsWithTsmaCtx* pCtx = NULL;
|
||||
terrno = mndInitDropTbsWithTsmaCtx(&pCtx);
|
||||
if (terrno) goto _OVER;
|
||||
for (int32_t i = 0; i < dropReq.pVgReqs->size; ++i) {
|
||||
SMDropTbReqsOnSingleVg* pReq = taosArrayGet(dropReq.pVgReqs, i);
|
||||
terrno = mndDropTbAddTsmaResTbsForSingleVg(pMnode, pCtx, pReq->pTbs, pReq->vgInfo.vgId);
|
||||
if (terrno) goto _OVER;
|
||||
}
|
||||
if (mndCreateDropTbsTxnPrepare(pReq, pCtx) == 0)
|
||||
code = 0;
|
||||
_OVER:
|
||||
tFreeSMDropTbsReq(&dropReq);
|
||||
if (pCtx) mndDestroyDropTbsWithTsmaCtx(pCtx);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndDropTbAdd(SMnode *pMnode, SHashObj *pVgHashMap, const SVgroupInfo *pVgInfo, char *name, tb_uid_t suid,
|
||||
bool ignoreNotExists) {
|
||||
SVDropTbReq req = {.name = name, .suid = suid, .igNotExists = ignoreNotExists};
|
||||
|
||||
SVDropTbVgReqs * pReqs = taosHashGet(pVgHashMap, &pVgInfo->vgId, sizeof(pVgInfo->vgId));
|
||||
SVDropTbVgReqs reqs = {0};
|
||||
if (pReqs == NULL) {
|
||||
reqs.info = *pVgInfo;
|
||||
reqs.req.pArray = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SVDropTbReq));
|
||||
taosArrayPush(reqs.req.pArray, &req);
|
||||
taosHashPut(pVgHashMap, &pVgInfo->vgId, sizeof(pVgInfo->vgId), &reqs, sizeof(reqs));
|
||||
} else {
|
||||
taosArrayPush(pReqs->req.pArray, &req);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndGetDbVgInfoForTsma(SMnode* pMnode, const char* dbname, SMDropTbTsmaInfo* pInfo) {
|
||||
int32_t code = 0;
|
||||
SDbObj* pDb = mndAcquireDb(pMnode, dbname);
|
||||
if (!pDb) {
|
||||
code = TSDB_CODE_MND_DB_NOT_EXIST;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
pInfo->dbInfo.dbVgInfos = taosArrayInit(pDb->cfg.numOfVgroups, sizeof(SVgroupInfo));
|
||||
if ( !pInfo->dbInfo.dbVgInfos) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _end;
|
||||
}
|
||||
mndBuildDBVgroupInfo(pDb, pMnode, pInfo->dbInfo.dbVgInfos);
|
||||
|
||||
pInfo->dbInfo.hashPrefix = pDb->cfg.hashPrefix;
|
||||
pInfo->dbInfo.hashSuffix = pDb->cfg.hashSuffix;
|
||||
pInfo->dbInfo.hashMethod = pDb->cfg.hashMethod;
|
||||
|
||||
_end:
|
||||
if (pDb) mndReleaseDb(pMnode, pDb);
|
||||
if (code && pInfo->dbInfo.dbVgInfos) {
|
||||
taosArrayDestroy(pInfo->dbInfo.dbVgInfos);
|
||||
pInfo->dbInfo.dbVgInfos = NULL;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t vgHashValCmp(const void* lp, const void* rp) {
|
||||
uint32_t* key = (uint32_t*)lp;
|
||||
SVgroupInfo* pVg = (SVgroupInfo*)rp;
|
||||
|
||||
if (*key < pVg->hashBegin) {
|
||||
return -1;
|
||||
} else if (*key > pVg->hashEnd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWithTsmaCtx* pCtx, SArray* pTbs, int32_t vgId) {
|
||||
int32_t code = 0;
|
||||
|
||||
SVgObj* pVgObj = mndAcquireVgroup(pMnode, vgId);
|
||||
if (!pVgObj) {
|
||||
code = 0;
|
||||
goto _end;
|
||||
}
|
||||
SVgroupInfo vgInfo = {.hashBegin = pVgObj->hashBegin, .hashEnd = pVgObj->hashEnd, .numOfTable = pVgObj->numOfTables, .vgId = pVgObj->vgId};
|
||||
vgInfo.epSet = mndGetVgroupEpset(pMnode, pVgObj);
|
||||
mndReleaseVgroup(pMnode, pVgObj);
|
||||
|
||||
// get all stb uids
|
||||
for (int32_t i = 0; i < pTbs->size; ++i) {
|
||||
const SVDropTbReq* pTb = taosArrayGet(pTbs, i);
|
||||
if (taosHashGet(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid))) {
|
||||
|
||||
} else {
|
||||
SMDropTbTsmaInfos infos = {0};
|
||||
infos.pTsmaInfos = taosArrayInit(2, sizeof(SMDropTbTsmaInfo));
|
||||
if (!infos.pTsmaInfos) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _end;
|
||||
}
|
||||
taosHashPut(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid), &infos, sizeof(infos));
|
||||
}
|
||||
}
|
||||
|
||||
void *pIter = NULL;
|
||||
SSmaObj *pSma = NULL;
|
||||
char buf[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
// get used tsmas and it's dbs
|
||||
while (1) {
|
||||
pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void **)&pSma);
|
||||
if (!pIter) break;
|
||||
SMDropTbTsmaInfos* pInfos = taosHashGet(pCtx->pTsmaMap, &pSma->stbUid, sizeof(pSma->stbUid));
|
||||
if (pInfos) {
|
||||
SMDropTbTsmaInfo info = {0};
|
||||
int32_t len = sprintf(buf, "%s", pSma->name);
|
||||
len = taosCreateMD5Hash(buf, len);
|
||||
sprintf(info.tsmaResTbDbFName, "%s", pSma->db);
|
||||
snprintf(info.tsmaResTbNamePrefix, TSDB_TABLE_NAME_LEN, "%s", buf);
|
||||
SMDropTbDbInfo* pDbInfo = taosHashGet(pCtx->pDbMap, pSma->db, TSDB_DB_FNAME_LEN);
|
||||
info.suid = pSma->dstTbUid;
|
||||
if (!pDbInfo) {
|
||||
code = mndGetDbVgInfoForTsma(pMnode, pSma->db, &info);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||
sdbRelease(pMnode->pSdb, pSma);
|
||||
goto _end;
|
||||
}
|
||||
taosHashPut(pCtx->pDbMap, pSma->db, TSDB_DB_FNAME_LEN, &info.dbInfo, sizeof(SMDropTbDbInfo));
|
||||
} else {
|
||||
info.dbInfo = *pDbInfo;
|
||||
}
|
||||
taosArrayPush(pInfos->pTsmaInfos, &info);
|
||||
}
|
||||
sdbRelease(pMnode->pSdb, pSma);
|
||||
}
|
||||
|
||||
// generate vg req map
|
||||
for (int32_t i = 0; i < pTbs->size; ++i) {
|
||||
SVDropTbReq* pTb = taosArrayGet(pTbs, i);
|
||||
mndDropTbAdd(pMnode, pCtx->pVgMap, &vgInfo, pTb->name, pTb->suid, pTb->igNotExists);
|
||||
|
||||
SMDropTbTsmaInfos *pInfos = taosHashGet(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid));
|
||||
SArray *pVgInfos = NULL;
|
||||
char buf[TSDB_TABLE_FNAME_LEN];
|
||||
for (int32_t j = 0; j < pInfos->pTsmaInfos->size; ++j) {
|
||||
SMDropTbTsmaInfo *pInfo = taosArrayGet(pInfos->pTsmaInfos, j);
|
||||
int32_t len = sprintf(buf, "%s.%s_%s", pInfo->tsmaResTbDbFName, pInfo->tsmaResTbNamePrefix, pTb->name);
|
||||
uint32_t hashVal =
|
||||
taosGetTbHashVal(buf, len, pInfo->dbInfo.hashMethod, pInfo->dbInfo.hashPrefix, pInfo->dbInfo.hashSuffix);
|
||||
const SVgroupInfo *pVgInfo = taosArraySearch(pInfo->dbInfo.dbVgInfos, &hashVal, vgHashValCmp, TD_EQ);
|
||||
void* p = taosStrdup(buf + strlen(pInfo->tsmaResTbDbFName) + TSDB_NAME_DELIMITER_LEN);
|
||||
taosArrayPush(pCtx->pResTbNames, &p);
|
||||
mndDropTbAdd(pMnode, pCtx->pVgMap, pVgInfo, p, pInfo->suid, true);
|
||||
}
|
||||
}
|
||||
_end:
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessFetchTtlExpiredTbs(SRpcMsg *pRsp) {
|
||||
int32_t code = -1;
|
||||
SDecoder decoder = {0};
|
||||
SMnode *pMnode = pRsp->info.node;
|
||||
SVFetchTtlExpiredTbsRsp rsp = {0};
|
||||
SMndDropTbsWithTsmaCtx *pCtx = NULL;
|
||||
if (pRsp->code != TSDB_CODE_SUCCESS) goto _end;
|
||||
if (pRsp->contLen == 0) {
|
||||
code = 0;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
tDecoderInit(&decoder, pRsp->pCont, pRsp->contLen);
|
||||
terrno = tDecodeVFetchTtlExpiredTbsRsp(&decoder, &rsp);
|
||||
if (terrno) goto _end;
|
||||
|
||||
terrno = mndInitDropTbsWithTsmaCtx(&pCtx);
|
||||
if (terrno) goto _end;
|
||||
|
||||
terrno = mndDropTbAddTsmaResTbsForSingleVg(pMnode, pCtx, rsp.pExpiredTbs, rsp.vgId);
|
||||
if (terrno) goto _end;
|
||||
if (mndCreateDropTbsTxnPrepare(pRsp, pCtx) == 0)
|
||||
code = 0;
|
||||
_end:
|
||||
if (pCtx) mndDestroyDropTbsWithTsmaCtx(pCtx);
|
||||
tDecoderClear(&decoder);
|
||||
tFreeFetchTtlExpiredTbsRsp(&rsp);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,10 @@ static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream);
|
|||
static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pOldStream, SStreamObj *pNewStream);
|
||||
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessDropStreamReq(SRpcMsg *pReq);
|
||||
|
||||
static int32_t mndProcessCreateStreamReqFromMNode(SRpcMsg *pReq);
|
||||
static int32_t mndProcessDropStreamReqFromMNode(SRpcMsg *pReq);
|
||||
|
||||
static int32_t mndProcessStreamCheckpointTmr(SRpcMsg *pReq);
|
||||
static int32_t mndProcessStreamDoCheckpoint(SRpcMsg *pReq);
|
||||
static int32_t mndProcessStreamCheckpointInCandid(SRpcMsg *pReq);
|
||||
|
@ -102,6 +106,13 @@ int32_t mndInitStream(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_VND_STREAM_TASK_UPDATE_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_STREAM_TASK_RESET_RSP, mndTransProcessRsp);
|
||||
|
||||
// for msgs inside mnode
|
||||
// TODO change the name
|
||||
mndSetMsgHandle(pMnode, TDMT_STREAM_CREATE, mndProcessCreateStreamReqFromMNode);
|
||||
mndSetMsgHandle(pMnode, TDMT_STREAM_CREATE_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_STREAM_DROP, mndProcessDropStreamReqFromMNode);
|
||||
mndSetMsgHandle(pMnode, TDMT_STREAM_DROP_RSP, mndTransProcessRsp);
|
||||
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_STREAM_CHECK_POINT_SOURCE_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_CHECKPOINT_TIMER, mndProcessStreamCheckpointTmr);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_BEGIN_CHECKPOINT, mndProcessStreamDoCheckpoint);
|
||||
|
@ -335,7 +346,10 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
|||
pObj->createTime = taosGetTimestampMs();
|
||||
pObj->updateTime = pObj->createTime;
|
||||
pObj->version = 1;
|
||||
pObj->smaId = 0;
|
||||
if (pCreate->smaId > 0) {
|
||||
pObj->subTableWithoutMd5 = 1;
|
||||
}
|
||||
pObj->smaId = pCreate->smaId;
|
||||
pObj->indexForMultiAggBalance = -1;
|
||||
|
||||
pObj->uid = mndGenerateUid(pObj->name, strlen(pObj->name));
|
||||
|
@ -555,15 +569,16 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
|
|||
tstrncpy(createReq.name, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
||||
createReq.numOfColumns = pStream->outputSchema.nCols;
|
||||
createReq.numOfTags = 1; // group id
|
||||
createReq.pColumns = taosArrayInit_s(sizeof(SField), createReq.numOfColumns);
|
||||
createReq.pColumns = taosArrayInit_s(sizeof(SFieldWithOptions), createReq.numOfColumns);
|
||||
|
||||
// build fields
|
||||
for (int32_t i = 0; i < createReq.numOfColumns; i++) {
|
||||
SField *pField = taosArrayGet(createReq.pColumns, i);
|
||||
SFieldWithOptions *pField = taosArrayGet(createReq.pColumns, i);
|
||||
tstrncpy(pField->name, pStream->outputSchema.pSchema[i].name, TSDB_COL_NAME_LEN);
|
||||
pField->flags = pStream->outputSchema.pSchema[i].flags;
|
||||
pField->type = pStream->outputSchema.pSchema[i].type;
|
||||
pField->bytes = pStream->outputSchema.pSchema[i].bytes;
|
||||
pField->compress = createDefaultColCmprByType(pField->type);
|
||||
}
|
||||
|
||||
if (pStream->tagSchema.nCols == 0) {
|
||||
|
@ -642,7 +657,9 @@ _OVER:
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int32_t checkForNumOfStreams(SMnode *pMnode, SStreamObj *pStreamObj) { // check for number of existed tasks
|
||||
// 1. stream number check
|
||||
// 2. target stable can not be target table of other existed streams.
|
||||
static int32_t doStreamCheck(SMnode *pMnode, SStreamObj *pStreamObj) {
|
||||
int32_t numOfStream = 0;
|
||||
SStreamObj *pStream = NULL;
|
||||
void *pIter = NULL;
|
||||
|
@ -655,14 +672,16 @@ static int32_t checkForNumOfStreams(SMnode *pMnode, SStreamObj *pStreamObj) { /
|
|||
sdbRelease(pMnode->pSdb, pStream);
|
||||
|
||||
if (numOfStream > MND_STREAM_MAX_NUM) {
|
||||
mError("too many streams, no more than %d for each database", MND_STREAM_MAX_NUM);
|
||||
mError("too many streams, no more than %d for each database, failed to create stream:%s", MND_STREAM_MAX_NUM,
|
||||
pStreamObj->name);
|
||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||
terrno = TSDB_CODE_MND_TOO_MANY_STREAMS;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (pStream->targetStbUid == pStreamObj->targetStbUid) {
|
||||
mError("Cannot write the same stable as other stream:%s", pStream->name);
|
||||
mError("Cannot write the same stable as other stream:%s, failed to create stream:%s", pStream->name,
|
||||
pStreamObj->name);
|
||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||
terrno = TSDB_CODE_MND_INVALID_TARGET_TABLE;
|
||||
return terrno;
|
||||
|
@ -727,11 +746,12 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
if (checkForNumOfStreams(pMnode, &streamObj) < 0) {
|
||||
if (doStreamCheck(pMnode, &streamObj) < 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
STrans *pTrans = doCreateTrans(pMnode, &streamObj, pReq, TRN_CONFLICT_DB, MND_STREAM_CREATE_NAME, "create stream tasks on dnodes");
|
||||
STrans *pTrans =
|
||||
doCreateTrans(pMnode, &streamObj, pReq, TRN_CONFLICT_DB, MND_STREAM_CREATE_NAME, "create stream tasks on dnodes");
|
||||
if (pTrans == NULL) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -817,23 +837,57 @@ _OVER:
|
|||
return terrno;
|
||||
}
|
||||
|
||||
int64_t mndStreamGenChkpId(SMnode *pMnode) {
|
||||
int64_t mndStreamGenChkptId(SMnode *pMnode, bool lock) {
|
||||
SStreamObj *pStream = NULL;
|
||||
void *pIter = NULL;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int64_t maxChkpId = 0;
|
||||
int64_t maxChkptId = 0;
|
||||
while (1) {
|
||||
pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
maxChkpId = TMAX(maxChkpId, pStream->checkpointId);
|
||||
maxChkptId = TMAX(maxChkptId, pStream->checkpointId);
|
||||
mDebug("stream:%p, %s id:%" PRIx64 "checkpoint %" PRId64 "", pStream, pStream->name, pStream->uid,
|
||||
pStream->checkpointId);
|
||||
sdbRelease(pSdb, pStream);
|
||||
}
|
||||
|
||||
mDebug("generated checkpoint %" PRId64 "", maxChkpId + 1);
|
||||
return maxChkpId + 1;
|
||||
{ // check the max checkpoint id from all vnodes.
|
||||
int64_t maxCheckpointId = -1;
|
||||
if (lock) {
|
||||
taosThreadMutexLock(&execInfo.lock);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < taosArrayGetSize(execInfo.pTaskList); ++i) {
|
||||
STaskId *p = taosArrayGet(execInfo.pTaskList, i);
|
||||
|
||||
STaskStatusEntry *pEntry = taosHashGet(execInfo.pTaskMap, p, sizeof(*p));
|
||||
if (pEntry == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pEntry->checkpointInfo.failed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (maxCheckpointId < pEntry->checkpointInfo.latestId) {
|
||||
maxCheckpointId = pEntry->checkpointInfo.latestId;
|
||||
}
|
||||
}
|
||||
|
||||
if (lock) {
|
||||
taosThreadMutexUnlock(&execInfo.lock);
|
||||
}
|
||||
|
||||
if (maxCheckpointId > maxChkptId) {
|
||||
mDebug("max checkpointId in mnode:%" PRId64 ", smaller than max checkpointId in vnode:%" PRId64, maxChkptId,
|
||||
maxCheckpointId);
|
||||
maxChkptId = maxCheckpointId;
|
||||
}
|
||||
}
|
||||
|
||||
mDebug("generated checkpoint %" PRId64 "", maxChkptId + 1);
|
||||
return maxChkptId + 1;
|
||||
}
|
||||
|
||||
static int32_t mndProcessStreamCheckpointTmr(SRpcMsg *pReq) {
|
||||
|
@ -844,7 +898,7 @@ static int32_t mndProcessStreamCheckpointTmr(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
SMStreamDoCheckpointMsg *pMsg = rpcMallocCont(sizeof(SMStreamDoCheckpointMsg));
|
||||
pMsg->checkpointId = mndStreamGenChkpId(pMnode);
|
||||
pMsg->checkpointId = mndStreamGenChkptId(pMnode, true);
|
||||
|
||||
int32_t size = sizeof(SMStreamDoCheckpointMsg);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_BEGIN_CHECKPOINT, .pCont = pMsg, .contLen = size};
|
||||
|
@ -928,7 +982,6 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre
|
|||
int32_t code = -1;
|
||||
int64_t ts = taosGetTimestampMs();
|
||||
if (mndTrigger == 1 && (ts - pStream->checkpointFreq < tsStreamCheckpointInterval * 1000)) {
|
||||
// mWarn("checkpoint interval less than the threshold, ignore it");
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -940,7 +993,8 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre
|
|||
return -1;
|
||||
}
|
||||
|
||||
STrans *pTrans = doCreateTrans(pMnode, pStream, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_CHECKPOINT_NAME, "gen checkpoint for stream");
|
||||
STrans *pTrans = doCreateTrans(pMnode, pStream, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_CHECKPOINT_NAME,
|
||||
"gen checkpoint for stream");
|
||||
if (pTrans == NULL) {
|
||||
mError("failed to checkpoint of stream name%s, checkpointId: %" PRId64 ", reason:%s", pStream->name, checkpointId,
|
||||
tstrerror(TSDB_CODE_MND_TRANS_CONFLICT));
|
||||
|
@ -1179,6 +1233,24 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
|||
}
|
||||
}
|
||||
|
||||
if (pStream->smaId != 0) {
|
||||
void *pIter = NULL;
|
||||
SSmaObj *pSma = NULL;
|
||||
pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void**)&pSma);
|
||||
while (pIter) {
|
||||
if (pSma && pSma->uid == pStream->smaId) {
|
||||
sdbRelease(pMnode->pSdb, pSma);
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||
tFreeMDropStreamReq(&dropReq);
|
||||
terrno = TSDB_CODE_TSMA_MUST_BE_DROPPED;
|
||||
return -1;
|
||||
}
|
||||
if (pSma) sdbRelease(pMnode->pSdb, pSma);
|
||||
pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void**)&pSma);
|
||||
}
|
||||
}
|
||||
|
||||
if (mndCheckDbPrivilegeByName(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pStream->targetDb) != 0) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
tFreeMDropStreamReq(&dropReq);
|
||||
|
@ -1327,6 +1399,15 @@ int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void int64ToHexStr(int64_t id, char *pBuf, int32_t bufLen) {
|
||||
memset(pBuf, 0, bufLen);
|
||||
pBuf[2] = '0';
|
||||
pBuf[3] = 'x';
|
||||
|
||||
int32_t len = tintToHex(id, &pBuf[4]);
|
||||
varDataSetLen(pBuf, len + 2);
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
@ -1351,19 +1432,14 @@ static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
|
||||
// stream id
|
||||
char buf[128] = {0};
|
||||
int32_t len = tintToHex(pStream->uid, &buf[4]);
|
||||
buf[2] = '0';
|
||||
buf[3] = 'x';
|
||||
varDataSetLen(buf, len + 2);
|
||||
int64ToHexStr(pStream->uid, buf, tListLen(buf));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
|
||||
// related fill-history stream id
|
||||
memset(buf, 0, tListLen(buf));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
if (pStream->hTaskUid != 0) {
|
||||
len = tintToHex(pStream->hTaskUid, &buf[4]);
|
||||
varDataSetLen(buf, len + 2);
|
||||
int64ToHexStr(pStream->hTaskUid, buf, tListLen(buf));
|
||||
colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
} else {
|
||||
colDataSetVal(pColInfo, numOfRows, buf, true);
|
||||
|
@ -1462,11 +1538,8 @@ static int32_t setTaskAttrInResBlock(SStreamObj *pStream, SStreamTask *pTask, SS
|
|||
// task id
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
||||
char idstr[128] = {0};
|
||||
int32_t len = tintToHex(pTask->id.taskId, &idstr[4]);
|
||||
idstr[2] = '0';
|
||||
idstr[3] = 'x';
|
||||
varDataSetLen(idstr, len + 2);
|
||||
char idstr[128] = {0};
|
||||
int64ToHexStr(pTask->id.taskId, idstr, tListLen(idstr));
|
||||
colDataSetVal(pColInfo, numOfRows, idstr, false);
|
||||
|
||||
// node type
|
||||
|
@ -1582,11 +1655,7 @@ static int32_t setTaskAttrInResBlock(SStreamObj *pStream, SStreamTask *pTask, SS
|
|||
// history_task_id
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
if (pe->hTaskId != 0) {
|
||||
memset(idstr, 0, tListLen(idstr));
|
||||
len = tintToHex(pe->hTaskId, &idstr[4]);
|
||||
idstr[2] = '0';
|
||||
idstr[3] = 'x';
|
||||
varDataSetLen(idstr, len + 2);
|
||||
int64ToHexStr(pe->hTaskId, idstr, tListLen(idstr));
|
||||
colDataSetVal(pColInfo, numOfRows, idstr, false);
|
||||
} else {
|
||||
colDataSetVal(pColInfo, numOfRows, 0, true);
|
||||
|
@ -1670,7 +1739,7 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) {
|
|||
}
|
||||
}
|
||||
|
||||
mInfo("stream:%s,%"PRId64 " start to pause stream", pauseReq.name, pStream->uid);
|
||||
mInfo("stream:%s,%" PRId64 " start to pause stream", pauseReq.name, pStream->uid);
|
||||
|
||||
if (pStream->status == STREAM_STATUS__PAUSE) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
|
@ -1695,7 +1764,8 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
STrans *pTrans = doCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_PAUSE_NAME, "pause the stream");
|
||||
STrans *pTrans =
|
||||
doCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_PAUSE_NAME, "pause the stream");
|
||||
if (pTrans == NULL) {
|
||||
mError("stream:%s failed to pause stream since %s", pauseReq.name, terrstr());
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
|
@ -1784,7 +1854,8 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
STrans *pTrans = doCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_RESUME_NAME, "resume the stream");
|
||||
STrans *pTrans =
|
||||
doCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_RESUME_NAME, "resume the stream");
|
||||
if (pTrans == NULL) {
|
||||
mError("stream:%s, failed to resume stream since %s", resumeReq.name, terrstr());
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
|
@ -1917,7 +1988,8 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange
|
|||
|
||||
// here create only one trans
|
||||
if (pTrans == NULL) {
|
||||
pTrans = doCreateTrans(pMnode, pStream, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_TASK_UPDATE_NAME, "update task epsets");
|
||||
pTrans =
|
||||
doCreateTrans(pMnode, pStream, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_TASK_UPDATE_NAME, "update task epsets");
|
||||
if (pTrans == NULL) {
|
||||
sdbRelease(pSdb, pStream);
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
|
@ -1957,7 +2029,7 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange
|
|||
}
|
||||
}
|
||||
|
||||
// no need to build the trans to handle the vgroup upddate
|
||||
// no need to build the trans to handle the vgroup update
|
||||
if (pTrans == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -2269,12 +2341,13 @@ int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) {
|
|||
|
||||
SStreamObj *pStream = mndGetStreamObj(pMnode, req.streamId);
|
||||
if (pStream == NULL) {
|
||||
mWarn("failed to find the stream:0x%" PRIx64 ", not handle the checkpoint req, try to acquire in buf", req.streamId);
|
||||
mWarn("failed to find the stream:0x%" PRIx64 ", not handle the checkpoint req, try to acquire in buf",
|
||||
req.streamId);
|
||||
|
||||
// not in meta-store yet, try to acquire the task in exec buffer
|
||||
// the checkpoint req arrives too soon before the completion of the create stream trans.
|
||||
STaskId id = {.streamId = req.streamId, .taskId = req.taskId};
|
||||
void* p = taosHashGet(execInfo.pTaskMap, &id, sizeof(id));
|
||||
void *p = taosHashGet(execInfo.pTaskMap, &id, sizeof(id));
|
||||
if (p == NULL) {
|
||||
mError("failed to find the stream:0x%" PRIx64 " in buf, not handle the checkpoint req", req.streamId);
|
||||
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||
|
@ -2286,7 +2359,7 @@ int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t numOfTasks = (pStream == NULL)? 0: mndGetNumOfStreamTasks(pStream);
|
||||
int32_t numOfTasks = (pStream == NULL) ? 0 : mndGetNumOfStreamTasks(pStream);
|
||||
|
||||
SArray **pReqTaskList = (SArray **)taosHashGet(execInfo.pTransferStateStreams, &req.streamId, sizeof(req.streamId));
|
||||
if (pReqTaskList == NULL) {
|
||||
|
@ -2301,10 +2374,10 @@ int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) {
|
|||
|
||||
int32_t total = taosArrayGetSize(*pReqTaskList);
|
||||
if (total == numOfTasks) { // all tasks has send the reqs
|
||||
int64_t checkpointId = mndStreamGenChkpId(pMnode);
|
||||
int64_t checkpointId = mndStreamGenChkptId(pMnode, false);
|
||||
mInfo("stream:0x%" PRIx64 " all tasks req checkpoint, start checkpointId:%" PRId64, req.streamId, checkpointId);
|
||||
|
||||
if (pStream != NULL) { // TODO:handle error
|
||||
if (pStream != NULL) { // TODO:handle error
|
||||
int32_t code = mndProcessStreamCheckpointTrans(pMnode, pStream, checkpointId, 0, false);
|
||||
} else {
|
||||
// todo: wait for the create stream trans completed, and launch the checkpoint trans
|
||||
|
@ -2328,13 +2401,35 @@ int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) {
|
|||
{
|
||||
SRpcMsg rsp = {.code = 0, .info = pReq->info, .contLen = sizeof(SMStreamReqCheckpointRspMsg)};
|
||||
rsp.pCont = rpcMallocCont(rsp.contLen);
|
||||
SMsgHead* pHead = rsp.pCont;
|
||||
SMsgHead *pHead = rsp.pCont;
|
||||
pHead->vgId = htonl(req.nodeId);
|
||||
|
||||
tmsgSendRsp(&rsp);
|
||||
|
||||
pReq->info.handle = NULL; // disable auto rsp
|
||||
pReq->info.handle = NULL; // disable auto rsp
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateStreamReqFromMNode(SRpcMsg *pReq) {
|
||||
int32_t code = mndProcessCreateStreamReq(pReq);
|
||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
pReq->info.rsp = rpcMallocCont(1);
|
||||
pReq->info.rspLen = 1;
|
||||
pReq->info.noResp = false;
|
||||
pReq->code = code;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropStreamReqFromMNode(SRpcMsg *pReq) {
|
||||
int32_t code = mndProcessDropStreamReq(pReq);
|
||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
pReq->info.rsp = rpcMallocCont(1);
|
||||
pReq->info.rspLen = 1;
|
||||
pReq->info.noResp = false;
|
||||
pReq->code = code;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
|||
|
||||
int32_t numOfUpdated = taosArrayGetSize(req.pUpdateNodes);
|
||||
if (numOfUpdated > 0) {
|
||||
mDebug("%d stream node(s) need updated from report of hbMsg(vgId:%d)", numOfUpdated, req.vgId);
|
||||
mDebug("%d stream node(s) need updated from hbMsg(vgId:%d)", numOfUpdated, req.vgId);
|
||||
setNodeEpsetExpiredFlag(req.pUpdateNodes);
|
||||
}
|
||||
|
||||
|
|
|
@ -307,6 +307,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
|||
createReq.hashSuffix = pDb->cfg.hashSuffix;
|
||||
createReq.tsdbPageSize = pDb->cfg.tsdbPageSize;
|
||||
createReq.changeVersion = ++(pVgroup->syncConfChangeVer);
|
||||
createReq.encryptAlgorithm = pDb->cfg.encryptAlgorithm;
|
||||
|
||||
for (int32_t v = 0; v < pVgroup->replica; ++v) {
|
||||
SReplica *pReplica = NULL;
|
||||
|
|
|
@ -5,5 +5,5 @@ target_include_directories(
|
|||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_link_libraries(
|
||||
sdb os common util wal sync
|
||||
sdb os common util wal sync crypt
|
||||
)
|
||||
|
|
|
@ -352,6 +352,11 @@ void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2
|
|||
*/
|
||||
int32_t sdbGetSize(SSdb *pSdb, ESdbType type);
|
||||
|
||||
/**
|
||||
* @brief get valid number of rows, removed rows are ignored
|
||||
*/
|
||||
int32_t sdbGetValidSize(SSdb* pSdb, ESdbType type);
|
||||
|
||||
/**
|
||||
* @brief Get the max id of the table, keyType of table should be INT32
|
||||
*
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include "sync.h"
|
||||
#include "tchecksum.h"
|
||||
#include "wal.h"
|
||||
#include "tglobal.h"
|
||||
#include "crypt.h"
|
||||
|
||||
#define SDB_TABLE_SIZE 24
|
||||
#define SDB_RESERVE_SIZE 512
|
||||
|
@ -276,6 +278,9 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
}
|
||||
|
||||
readLen = pRaw->dataLen + sizeof(int32_t);
|
||||
if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_SDB) == DND_CS_SDB ){
|
||||
readLen = ENCRYPTED_LEN(pRaw->dataLen) + sizeof(int32_t);
|
||||
}
|
||||
if (readLen >= bufLen) {
|
||||
bufLen = pRaw->dataLen * 2;
|
||||
SSdbRaw *pNewRaw = taosMemoryMalloc(bufLen + 100);
|
||||
|
@ -303,6 +308,27 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_SDB) == DND_CS_SDB ){
|
||||
int32_t count = 0;
|
||||
|
||||
char *plantContent = taosMemoryMalloc(ENCRYPTED_LEN(pRaw->dataLen));
|
||||
|
||||
SCryptOpts opts;
|
||||
opts.len = ENCRYPTED_LEN(pRaw->dataLen);
|
||||
opts.source = pRaw->pData;
|
||||
opts.result = plantContent;
|
||||
opts.unitLen = 16;
|
||||
strncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
|
||||
count = CBC_Decrypt(&opts);
|
||||
|
||||
//mDebug("read sdb, CBC_Decrypt dataLen:%d, descrypted len:%d, %s", pRaw->dataLen, count, __FUNCTION__);
|
||||
|
||||
memcpy(pRaw->pData, plantContent, pRaw->dataLen);
|
||||
taosMemoryFree(plantContent);
|
||||
memcpy(pRaw->pData + pRaw->dataLen, &pRaw->pData[ENCRYPTED_LEN(pRaw->dataLen)], sizeof(int32_t));
|
||||
}
|
||||
|
||||
int32_t totalLen = sizeof(SSdbRaw) + pRaw->dataLen + sizeof(int32_t);
|
||||
if ((!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen)) != 0) {
|
||||
code = TSDB_CODE_CHECKSUM_ERROR;
|
||||
|
@ -401,14 +427,50 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
|||
SSdbRaw *pRaw = (*encodeFp)(pRow->pObj);
|
||||
if (pRaw != NULL) {
|
||||
pRaw->status = pRow->status;
|
||||
int32_t writeLen = sizeof(SSdbRaw) + pRaw->dataLen;
|
||||
if (taosWriteFile(pFile, pRaw, writeLen) != writeLen) {
|
||||
|
||||
if (taosWriteFile(pFile, pRaw, sizeof(SSdbRaw)) != sizeof(SSdbRaw)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosHashCancelIterate(hash, ppRow);
|
||||
sdbFreeRaw(pRaw);
|
||||
break;
|
||||
}
|
||||
|
||||
int32_t newDataLen = pRaw->dataLen;
|
||||
char* newData = pRaw->pData;
|
||||
if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_SDB) == DND_CS_SDB ){
|
||||
newDataLen = ENCRYPTED_LEN(pRaw->dataLen);
|
||||
newData = taosMemoryMalloc(newDataLen);
|
||||
if (newData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosHashCancelIterate(hash, ppRow);
|
||||
sdbFreeRaw(pRaw);
|
||||
break;
|
||||
}
|
||||
|
||||
SCryptOpts opts;
|
||||
opts.len = newDataLen;
|
||||
opts.source = pRaw->pData;
|
||||
opts.result = newData;
|
||||
opts.unitLen = 16;
|
||||
strncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
|
||||
int32_t count = CBC_Encrypt(&opts);
|
||||
|
||||
//mDebug("write sdb, CBC_Encrypt encryptedDataLen:%d, dataLen:%d, %s",
|
||||
// newDataLen, pRaw->dataLen, __FUNCTION__);
|
||||
}
|
||||
|
||||
if (taosWriteFile(pFile, newData, newDataLen) != newDataLen) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosHashCancelIterate(hash, ppRow);
|
||||
sdbFreeRaw(pRaw);
|
||||
break;
|
||||
}
|
||||
|
||||
if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_SDB) == DND_CS_SDB ){
|
||||
taosMemoryFree(newData);
|
||||
}
|
||||
|
||||
int32_t cksum = taosCalcChecksum(0, (const uint8_t *)pRaw, sizeof(SSdbRaw) + pRaw->dataLen);
|
||||
if (taosWriteFile(pFile, &cksum, sizeof(int32_t)) != sizeof(int32_t)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
|
|
|
@ -510,3 +510,15 @@ int64_t sdbGetTableVer(SSdb *pSdb, ESdbType type) {
|
|||
|
||||
return pSdb->tableVer[type];
|
||||
}
|
||||
|
||||
bool countValid(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
|
||||
int32_t* pInt = p1;
|
||||
(*pInt) += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t sdbGetValidSize(SSdb* pSdb, ESdbType type) {
|
||||
int32_t num = 0;
|
||||
sdbTraverse(pSdb, type, countValid, &num, 0, 0);
|
||||
return num;
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ if (${BUILD_CONTRIB})
|
|||
PUBLIC "inc"
|
||||
PUBLIC "src/inc"
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/crypt"
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/dnode/vnode"
|
||||
PUBLIC "${TD_SOURCE_DIR}/contrib/rocksdb/include"
|
||||
)
|
||||
|
@ -130,10 +131,11 @@ else()
|
|||
PUBLIC "inc"
|
||||
PUBLIC "src/inc"
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/crypt"
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/dnode/vnode"
|
||||
)
|
||||
if (${TD_LINUX})
|
||||
target_include_directories(
|
||||
target_include_directories(
|
||||
vnode
|
||||
PUBLIC "${TD_SOURCE_DIR}/deps/${TD_DEPS_DIR}/rocksdb_static"
|
||||
)
|
||||
|
@ -144,6 +146,11 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
target_link_directories(
|
||||
vnode
|
||||
PUBLIC "${CMAKE_BINARY_DIR}/build/lib"
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
vnode
|
||||
PUBLIC os
|
||||
|
@ -157,9 +164,11 @@ target_link_libraries(
|
|||
PUBLIC scheduler
|
||||
PUBLIC tdb
|
||||
PUBLIC audit
|
||||
PUBLIC crypt
|
||||
|
||||
# PUBLIC bdb
|
||||
# PUBLIC scalar
|
||||
#PUBLIC zstd
|
||||
PUBLIC rocksdb
|
||||
PUBLIC transport
|
||||
PUBLIC stream
|
||||
|
|
|
@ -181,7 +181,7 @@ void tsdbReaderSetNotifyCb(STsdbReader *pReader, TsdReaderNotifyCbFn not
|
|||
int32_t tsdbReuseCacherowsReader(void *pReader, void *pTableIdList, int32_t numOfTables);
|
||||
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||
SArray *pCidList, int32_t *pSlotIds, uint64_t suid, void **pReader, const char *idstr,
|
||||
SArray* pFuncTypeList, SColumnInfo* pkCol, int32_t numOfPks);
|
||||
SArray *pFuncTypeList, SColumnInfo* pkCol, int32_t numOfPks);
|
||||
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, const int32_t *dstSlotIds,
|
||||
SArray *pTableUids);
|
||||
void *tsdbCacherowsReaderClose(void *pReader);
|
||||
|
@ -278,6 +278,8 @@ struct STsdbCfg {
|
|||
int32_t keep2; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
||||
int32_t keepTimeOffset; // just for save config, use STsdbKeepCfg in STsdb instead
|
||||
SRetention retentions[TSDB_RETENTION_MAX];
|
||||
int32_t encryptAlgorithm;
|
||||
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
@ -319,6 +321,8 @@ struct SVnodeCfg {
|
|||
int16_t hashPrefix;
|
||||
int16_t hashSuffix;
|
||||
int32_t tsdbPageSize;
|
||||
int32_t tdbEncryptAlgorithm;
|
||||
char tdbEncryptKey[ENCRYPT_KEY_LEN];
|
||||
int32_t s3ChunkSize;
|
||||
int32_t s3KeepLocal;
|
||||
int8_t s3Compact;
|
||||
|
@ -328,6 +332,10 @@ struct SVnodeCfg {
|
|||
#define TABLE_IS_ROLLUP(FLG) (((FLG) & (TABLE_ROLLUP_ON)) != 0)
|
||||
#define TABLE_SET_ROLLUP(FLG) ((FLG) |= TABLE_ROLLUP_ON)
|
||||
|
||||
#define TABLE_COL_COMPRESSED ((int8_t)0x2)
|
||||
#define TABLE_IS_COL_COMPRESSED(FLG) (((FLG) & (TABLE_COL_COMPRESSED)) != 0)
|
||||
#define TABLE_SET_COL_COMPRESSED(FLG) ((FLG) |= TABLE_COL_COMPRESSED)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -160,11 +160,12 @@ int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void* pTagData, int32_
|
|||
STagIdxKey** ppTagIdxKey, int32_t* nTagIdxKey);
|
||||
|
||||
// TODO, refactor later
|
||||
int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *param, SArray *results);
|
||||
int32_t metaFilterCreateTime(void *pVnode, SMetaFltParam *parm, SArray *pUids);
|
||||
int32_t metaFilterTableName(void *pVnode, SMetaFltParam *param, SArray *pUids);
|
||||
int32_t metaFilterTtl(void *pVnode, SMetaFltParam *param, SArray *pUids);
|
||||
int32_t metaFilterTableIds(void* pVnode, SMetaFltParam* param, SArray* results);
|
||||
int32_t metaFilterCreateTime(void* pVnode, SMetaFltParam* parm, SArray* pUids);
|
||||
int32_t metaFilterTableName(void* pVnode, SMetaFltParam* param, SArray* pUids);
|
||||
int32_t metaFilterTtl(void* pVnode, SMetaFltParam* param, SArray* pUids);
|
||||
|
||||
int32_t metaGetColCmpr(SMeta* pMeta, tb_uid_t uid, SHashObj** colCmprObj);
|
||||
#ifndef META_REFACT
|
||||
// SMetaDB
|
||||
int metaOpenDB(SMeta* pMeta);
|
||||
|
|
|
@ -119,8 +119,8 @@ int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, uint64_t
|
|||
|
||||
// tqExec
|
||||
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded);
|
||||
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision);
|
||||
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp,
|
||||
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOfCols, int8_t precision);
|
||||
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const void* pRsp,
|
||||
int32_t type, int32_t vgId);
|
||||
int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId);
|
||||
|
||||
|
@ -154,9 +154,9 @@ int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname);
|
|||
// tq util
|
||||
int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type);
|
||||
int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg);
|
||||
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp* pRsp, int32_t epoch, int64_t consumerId,
|
||||
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const void* pRsp, int32_t epoch, int64_t consumerId,
|
||||
int32_t type, int64_t sver, int64_t ever);
|
||||
int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset);
|
||||
int32_t tqInitDataRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset);
|
||||
void tqUpdateNodeStage(STQ* pTq, bool isLeader);
|
||||
int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
||||
SSubmitTbData* pTableData, const char* id);
|
||||
|
|
|
@ -94,7 +94,7 @@ typedef struct STsdbRowKey STsdbRowKey;
|
|||
#define PAGE_CONTENT_SIZE(PAGE) ((PAGE) - sizeof(TSCKSUM))
|
||||
#define LOGIC_TO_FILE_OFFSET(LOFFSET, PAGE) \
|
||||
((LOFFSET) / PAGE_CONTENT_SIZE(PAGE) * (PAGE) + (LOFFSET) % PAGE_CONTENT_SIZE(PAGE))
|
||||
#define FILE_TO_LOGIC_OFFSET(OFFSET, PAGE) ((OFFSET) / (PAGE) * PAGE_CONTENT_SIZE(PAGE) + (OFFSET) % (PAGE))
|
||||
#define FILE_TO_LOGIC_OFFSET(OFFSET, PAGE) ((OFFSET) / (PAGE)*PAGE_CONTENT_SIZE(PAGE) + (OFFSET) % (PAGE))
|
||||
#define PAGE_OFFSET(PGNO, PAGE) (((PGNO)-1) * (PAGE))
|
||||
#define OFFSET_PGNO(OFFSET, PAGE) ((OFFSET) / (PAGE) + 1)
|
||||
|
||||
|
@ -146,8 +146,8 @@ int32_t tTABLEIDCmprFn(const void *p1, const void *p2);
|
|||
#define MIN_TSDBKEY(KEY1, KEY2) ((tsdbKeyCmprFn(&(KEY1), &(KEY2)) < 0) ? (KEY1) : (KEY2))
|
||||
#define MAX_TSDBKEY(KEY1, KEY2) ((tsdbKeyCmprFn(&(KEY1), &(KEY2)) > 0) ? (KEY1) : (KEY2))
|
||||
// SBlockCol
|
||||
int32_t tPutBlockCol(SBuffer *buffer, const SBlockCol *pBlockCol);
|
||||
int32_t tGetBlockCol(SBufferReader *br, SBlockCol *pBlockCol);
|
||||
int32_t tPutBlockCol(SBuffer *buffer, const SBlockCol *pBlockCol, int32_t ver, uint32_t cmprAlg);
|
||||
int32_t tGetBlockCol(SBufferReader *br, SBlockCol *pBlockCol, int32_t ver, uint32_t cmprAlg);
|
||||
int32_t tBlockColCmprFn(const void *p1, const void *p2);
|
||||
// SDataBlk
|
||||
void tDataBlkReset(SDataBlk *pBlock);
|
||||
|
@ -179,7 +179,7 @@ int32_t tBlockDataUpdateRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
|
|||
int32_t tBlockDataTryUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, int64_t uid);
|
||||
int32_t tBlockDataUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema, int64_t uid);
|
||||
void tBlockDataClear(SBlockData *pBlockData);
|
||||
int32_t tBlockDataCompress(SBlockData *bData, int8_t cmprAlg, SBuffer *buffers, SBuffer *assist);
|
||||
int32_t tBlockDataCompress(SBlockData *bData, void *pCmprInfo, SBuffer *buffers, SBuffer *assist);
|
||||
int32_t tBlockDataDecompress(SBufferReader *br, SBlockData *blockData, SBuffer *assist);
|
||||
int32_t tBlockDataDecompressKeyPart(const SDiskDataHdr *hdr, SBufferReader *br, SBlockData *blockData, SBuffer *assist);
|
||||
int32_t tBlockDataDecompressColData(const SDiskDataHdr *hdr, const SBlockCol *blockCol, SBufferReader *br,
|
||||
|
@ -225,10 +225,10 @@ void tsdbMemTableDestroy(SMemTable *pMemTable, bool proactive);
|
|||
STbData *tsdbGetTbDataFromMemTable(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid);
|
||||
int32_t tsdbRefMemTable(SMemTable *pMemTable, SQueryNode *pQNode);
|
||||
int32_t tsdbUnrefMemTable(SMemTable *pMemTable, SQueryNode *pNode, bool proactive);
|
||||
SArray *tsdbMemTableGetTbDataArray(SMemTable *pMemTable);
|
||||
SArray * tsdbMemTableGetTbDataArray(SMemTable *pMemTable);
|
||||
// STbDataIter
|
||||
int32_t tsdbTbDataIterCreate(STbData *pTbData, STsdbRowKey *pFrom, int8_t backward, STbDataIter **ppIter);
|
||||
void *tsdbTbDataIterDestroy(STbDataIter *pIter);
|
||||
void * tsdbTbDataIterDestroy(STbDataIter *pIter);
|
||||
void tsdbTbDataIterOpen(STbData *pTbData, STsdbRowKey *pFrom, int8_t backward, STbDataIter *pIter);
|
||||
bool tsdbTbDataIterNext(STbDataIter *pIter);
|
||||
void tsdbMemTableCountRows(SMemTable *pMemTable, SSHashObj *pTableMap, int64_t *rowsNum);
|
||||
|
@ -281,7 +281,7 @@ int32_t tsdbGetTableSchema(SMeta *pMeta, int64_t uid, STSchema **pSchema, int64_
|
|||
|
||||
// tsdbMerge.c ==============================================================================================
|
||||
typedef struct {
|
||||
STsdb *tsdb;
|
||||
STsdb * tsdb;
|
||||
int32_t fid;
|
||||
} SMergeArg;
|
||||
|
||||
|
@ -312,22 +312,22 @@ int32_t tsdbDataIterNext2(STsdbDataIter2 *pIter, STsdbFilterInfo *pFilterInfo);
|
|||
// structs =======================
|
||||
struct STsdbFS {
|
||||
SDelFile *pDelFile;
|
||||
SArray *aDFileSet; // SArray<SDFileSet>
|
||||
SArray * aDFileSet; // SArray<SDFileSet>
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
rocksdb_t *db;
|
||||
rocksdb_comparator_t *my_comparator;
|
||||
rocksdb_cache_t *blockcache;
|
||||
rocksdb_t * db;
|
||||
rocksdb_comparator_t * my_comparator;
|
||||
rocksdb_cache_t * blockcache;
|
||||
rocksdb_block_based_table_options_t *tableoptions;
|
||||
rocksdb_options_t *options;
|
||||
rocksdb_flushoptions_t *flushoptions;
|
||||
rocksdb_writeoptions_t *writeoptions;
|
||||
rocksdb_readoptions_t *readoptions;
|
||||
rocksdb_writebatch_t *writebatch;
|
||||
rocksdb_writebatch_t *rwritebatch;
|
||||
rocksdb_options_t * options;
|
||||
rocksdb_flushoptions_t * flushoptions;
|
||||
rocksdb_writeoptions_t * writeoptions;
|
||||
rocksdb_readoptions_t * readoptions;
|
||||
rocksdb_writebatch_t * writebatch;
|
||||
rocksdb_writebatch_t * rwritebatch;
|
||||
TdThreadMutex rMutex;
|
||||
STSchema *pTSchema;
|
||||
STSchema * pTSchema;
|
||||
} SRocksCache;
|
||||
|
||||
typedef struct {
|
||||
|
@ -336,22 +336,22 @@ typedef struct {
|
|||
} SCacheFlushState;
|
||||
|
||||
struct STsdb {
|
||||
char *path;
|
||||
SVnode *pVnode;
|
||||
char * path;
|
||||
SVnode * pVnode;
|
||||
STsdbKeepCfg keepCfg;
|
||||
TdThreadMutex mutex;
|
||||
bool bgTaskDisabled;
|
||||
SMemTable *mem;
|
||||
SMemTable *imem;
|
||||
SMemTable * mem;
|
||||
SMemTable * imem;
|
||||
STsdbFS fs; // old
|
||||
SLRUCache *lruCache;
|
||||
SLRUCache * lruCache;
|
||||
SCacheFlushState flushState;
|
||||
TdThreadMutex lruMutex;
|
||||
SLRUCache *biCache;
|
||||
SLRUCache * biCache;
|
||||
TdThreadMutex biMutex;
|
||||
SLRUCache *bCache;
|
||||
SLRUCache * bCache;
|
||||
TdThreadMutex bMutex;
|
||||
SLRUCache *pgCache;
|
||||
SLRUCache * pgCache;
|
||||
TdThreadMutex pgMutex;
|
||||
struct STFileSystem *pFS; // new
|
||||
SRocksCache rCache;
|
||||
|
@ -380,17 +380,17 @@ struct STbData {
|
|||
TSKEY minKey;
|
||||
TSKEY maxKey;
|
||||
SRWLatch lock;
|
||||
SDelData *pHead;
|
||||
SDelData *pTail;
|
||||
SDelData * pHead;
|
||||
SDelData * pTail;
|
||||
SMemSkipList sl;
|
||||
STbData *next;
|
||||
STbData * next;
|
||||
SRBTreeNode rbtn[1];
|
||||
};
|
||||
|
||||
struct SMemTable {
|
||||
SRWLatch latch;
|
||||
STsdb *pTsdb;
|
||||
SVBufPool *pPool;
|
||||
STsdb * pTsdb;
|
||||
SVBufPool * pPool;
|
||||
volatile int32_t nRef;
|
||||
int64_t minVer;
|
||||
int64_t maxVer;
|
||||
|
@ -400,7 +400,7 @@ struct SMemTable {
|
|||
int64_t nDel;
|
||||
int32_t nTbData;
|
||||
int32_t nBucket;
|
||||
STbData **aBucket;
|
||||
STbData ** aBucket;
|
||||
SRBTree tbDataTree[1];
|
||||
};
|
||||
|
||||
|
@ -409,7 +409,7 @@ struct TSDBROW {
|
|||
union {
|
||||
struct {
|
||||
int64_t version;
|
||||
SRow *pTSRow;
|
||||
SRow * pTSRow;
|
||||
};
|
||||
struct {
|
||||
SBlockData *pBlockData;
|
||||
|
@ -444,15 +444,16 @@ struct SMapData {
|
|||
};
|
||||
|
||||
struct SBlockCol {
|
||||
int16_t cid;
|
||||
int8_t type;
|
||||
int8_t cflag;
|
||||
int8_t flag; // HAS_NONE|HAS_NULL|HAS_VALUE
|
||||
int32_t szOrigin; // original column value size (only save for variant data type)
|
||||
int32_t szBitmap; // bitmap size, 0 only for flag == HAS_VAL
|
||||
int32_t szOffset; // offset size, 0 only for non-variant-length type
|
||||
int32_t szValue; // value size, 0 when flag == (HAS_NULL | HAS_NONE)
|
||||
int32_t offset;
|
||||
int16_t cid;
|
||||
int8_t type;
|
||||
int8_t cflag;
|
||||
int8_t flag; // HAS_NONE|HAS_NULL|HAS_VALUE
|
||||
int32_t szOrigin; // original column value size (only save for variant data type)
|
||||
int32_t szBitmap; // bitmap size, 0 only for flag == HAS_VAL
|
||||
int32_t szOffset; // offset size, 0 only for non-variant-length type
|
||||
int32_t szValue; // value size, 0 when flag == (HAS_NULL | HAS_NONE)
|
||||
int32_t offset;
|
||||
uint32_t alg;
|
||||
};
|
||||
|
||||
struct SBlockInfo {
|
||||
|
@ -509,9 +510,9 @@ struct SBlockData {
|
|||
int64_t suid; // 0 means normal table block data, otherwise child table block data
|
||||
int64_t uid; // 0 means block data in .last file, otherwise in .data file
|
||||
int32_t nRow; // number of rows
|
||||
int64_t *aUid; // uids of each row, only exist in block data in .last file (uid == 0)
|
||||
int64_t *aVersion; // versions of each row
|
||||
TSKEY *aTSKEY; // timestamp of each row
|
||||
int64_t * aUid; // uids of each row, only exist in block data in .last file (uid == 0)
|
||||
int64_t * aVersion; // versions of each row
|
||||
TSKEY * aTSKEY; // timestamp of each row
|
||||
int32_t nColData;
|
||||
SColData *aColData;
|
||||
};
|
||||
|
@ -522,10 +523,10 @@ struct TABLEID {
|
|||
};
|
||||
|
||||
struct STbDataIter {
|
||||
STbData *pTbData;
|
||||
STbData * pTbData;
|
||||
int8_t backward;
|
||||
SMemSkipListNode *pNode;
|
||||
TSDBROW *pRow;
|
||||
TSDBROW * pRow;
|
||||
TSDBROW row;
|
||||
};
|
||||
|
||||
|
@ -553,7 +554,7 @@ struct SDiskDataHdr {
|
|||
int32_t szKey;
|
||||
int32_t szBlkCol;
|
||||
int32_t nRow;
|
||||
int8_t cmprAlg;
|
||||
uint32_t cmprAlg;
|
||||
|
||||
// fmtVer == 1
|
||||
int8_t numOfPKs;
|
||||
|
@ -603,9 +604,9 @@ struct SDFileSet {
|
|||
int32_t fid;
|
||||
SHeadFile *pHeadF;
|
||||
SDataFile *pDataF;
|
||||
SSmaFile *pSmaF;
|
||||
SSmaFile * pSmaF;
|
||||
uint8_t nSttF;
|
||||
SSttFile *aSttF[TSDB_STT_TRIGGER_ARRAY_SIZE];
|
||||
SSttFile * aSttF[TSDB_STT_TRIGGER_ARRAY_SIZE];
|
||||
};
|
||||
|
||||
struct STSDBRowIter {
|
||||
|
@ -621,18 +622,18 @@ struct STSDBRowIter {
|
|||
struct SRowMerger {
|
||||
STSchema *pTSchema;
|
||||
int64_t version;
|
||||
SArray *pArray; // SArray<SColVal>
|
||||
SArray * pArray; // SArray<SColVal>
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *path;
|
||||
char * path;
|
||||
int32_t szPage;
|
||||
int32_t flag;
|
||||
TdFilePtr pFD;
|
||||
int64_t pgno;
|
||||
uint8_t *pBuf;
|
||||
uint8_t * pBuf;
|
||||
int64_t szFile;
|
||||
STsdb *pTsdb;
|
||||
STsdb * pTsdb;
|
||||
const char *objName;
|
||||
uint8_t s3File;
|
||||
int32_t lcn;
|
||||
|
@ -642,7 +643,7 @@ typedef struct {
|
|||
} STsdbFD;
|
||||
|
||||
struct SDelFWriter {
|
||||
STsdb *pTsdb;
|
||||
STsdb * pTsdb;
|
||||
SDelFile fDel;
|
||||
STsdbFD *pWriteH;
|
||||
uint8_t *aBuf[1];
|
||||
|
@ -702,15 +703,15 @@ int32_t tDeserializeTsdbRepOpts(void *buf, int32_t bufLen, STsdbRepOpts *pInfo);
|
|||
|
||||
// snap read
|
||||
struct STsdbReadSnap {
|
||||
SMemTable *pMem;
|
||||
SQueryNode *pNode;
|
||||
SMemTable *pIMem;
|
||||
SQueryNode *pINode;
|
||||
SMemTable * pMem;
|
||||
SQueryNode * pNode;
|
||||
SMemTable * pIMem;
|
||||
SQueryNode * pINode;
|
||||
TFileSetArray *pfSetArray;
|
||||
};
|
||||
|
||||
struct SDataFWriter {
|
||||
STsdb *pTsdb;
|
||||
STsdb * pTsdb;
|
||||
SDFileSet wSet;
|
||||
|
||||
STsdbFD *pHeadFD;
|
||||
|
@ -727,13 +728,13 @@ struct SDataFWriter {
|
|||
};
|
||||
|
||||
struct SDataFReader {
|
||||
STsdb *pTsdb;
|
||||
STsdb * pTsdb;
|
||||
SDFileSet *pSet;
|
||||
STsdbFD *pHeadFD;
|
||||
STsdbFD *pDataFD;
|
||||
STsdbFD *pSmaFD;
|
||||
STsdbFD *aSttFD[TSDB_STT_TRIGGER_ARRAY_SIZE];
|
||||
uint8_t *aBuf[3];
|
||||
STsdbFD * pHeadFD;
|
||||
STsdbFD * pDataFD;
|
||||
STsdbFD * pSmaFD;
|
||||
STsdbFD * aSttFD[TSDB_STT_TRIGGER_ARRAY_SIZE];
|
||||
uint8_t * aBuf[3];
|
||||
};
|
||||
|
||||
// NOTE: do NOT change the order of the fields
|
||||
|
@ -768,10 +769,10 @@ typedef struct {
|
|||
|
||||
typedef struct SSttBlockLoadInfo {
|
||||
SBlockDataInfo blockData[2]; // buffered block data
|
||||
SArray *aSttBlk;
|
||||
SArray * aSttBlk;
|
||||
int32_t currentLoadBlockIndex;
|
||||
STSchema *pSchema;
|
||||
int16_t *colIds;
|
||||
STSchema * pSchema;
|
||||
int16_t * colIds;
|
||||
int32_t numOfCols;
|
||||
bool checkRemainingRow; // todo: no assign value?
|
||||
bool isLast;
|
||||
|
@ -808,7 +809,7 @@ struct SDiskData {
|
|||
const uint8_t *pUid;
|
||||
const uint8_t *pVer;
|
||||
const uint8_t *pKey;
|
||||
SArray *aDiskCol; // SArray<SDiskCol>
|
||||
SArray * aDiskCol; // SArray<SDiskCol>
|
||||
};
|
||||
|
||||
struct SDiskDataBuilder {
|
||||
|
@ -821,15 +822,15 @@ struct SDiskDataBuilder {
|
|||
SCompressor *pVerC;
|
||||
SCompressor *pKeyC;
|
||||
int32_t nBuilder;
|
||||
SArray *aBuilder; // SArray<SDiskColBuilder>
|
||||
uint8_t *aBuf[2];
|
||||
SArray * aBuilder; // SArray<SDiskColBuilder>
|
||||
uint8_t * aBuf[2];
|
||||
SDiskData dd;
|
||||
SBlkInfo bi;
|
||||
};
|
||||
|
||||
struct SLDataIter {
|
||||
SRBTreeNode node;
|
||||
SSttBlk *pSttBlk;
|
||||
SSttBlk * pSttBlk;
|
||||
int64_t cid; // for debug purpose
|
||||
int8_t backward;
|
||||
int32_t iSttBlk;
|
||||
|
@ -838,8 +839,8 @@ struct SLDataIter {
|
|||
uint64_t uid;
|
||||
STimeWindow timeWindow;
|
||||
SVersionRange verRange;
|
||||
SSttBlockLoadInfo *pBlockLoadInfo;
|
||||
SRowKey* pStartRowKey; // current row key
|
||||
SSttBlockLoadInfo * pBlockLoadInfo;
|
||||
SRowKey * pStartRowKey; // current row key
|
||||
bool ignoreEarlierTs;
|
||||
struct SSttFileReader *pReader;
|
||||
};
|
||||
|
@ -852,21 +853,21 @@ typedef int32_t (*_load_tomb_fn)(STsdbReader *pReader, struct SSttFileReader *pS
|
|||
|
||||
typedef struct SMergeTreeConf {
|
||||
int8_t backward;
|
||||
STsdb *pTsdb;
|
||||
STsdb * pTsdb;
|
||||
uint64_t suid;
|
||||
uint64_t uid;
|
||||
STimeWindow timewindow;
|
||||
SVersionRange verRange;
|
||||
bool strictTimeRange;
|
||||
SArray *pSttFileBlockIterArray;
|
||||
void *pCurrentFileset;
|
||||
STSchema *pSchema;
|
||||
int16_t *pCols;
|
||||
SArray * pSttFileBlockIterArray;
|
||||
void * pCurrentFileset;
|
||||
STSchema * pSchema;
|
||||
int16_t * pCols;
|
||||
int32_t numOfCols;
|
||||
SRowKey *pCurRowKey;
|
||||
SRowKey * pCurRowKey;
|
||||
_load_tomb_fn loadTombFn;
|
||||
void *pReader;
|
||||
void *idstr;
|
||||
void * pReader;
|
||||
void * idstr;
|
||||
bool rspRows; // response the rows in stt-file, if possible
|
||||
} SMergeTreeConf;
|
||||
|
||||
|
@ -884,8 +885,8 @@ bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree);
|
|||
void tMergeTreeClose(SMergeTree *pMTree);
|
||||
|
||||
SSttBlockLoadInfo *tCreateSttBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols);
|
||||
void *destroySttBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo);
|
||||
void *destroySttBlockReader(SArray *pLDataIterArray, SSttBlockLoadCostInfo *pLoadCost);
|
||||
void * destroySttBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo);
|
||||
void * destroySttBlockReader(SArray *pLDataIterArray, SSttBlockLoadCostInfo *pLoadCost);
|
||||
|
||||
// tsdbCache ==============================================================================================
|
||||
typedef enum {
|
||||
|
@ -974,7 +975,7 @@ struct STsdbDataIter2 {
|
|||
// TSDB_DATA_FILE_DATA_ITER
|
||||
struct {
|
||||
SDataFReader *pReader;
|
||||
SArray *aBlockIdx; // SArray<SBlockIdx>
|
||||
SArray * aBlockIdx; // SArray<SBlockIdx>
|
||||
SMapData mDataBlk;
|
||||
SBlockData bData;
|
||||
int32_t iBlockIdx;
|
||||
|
@ -986,7 +987,7 @@ struct STsdbDataIter2 {
|
|||
struct {
|
||||
SDataFReader *pReader;
|
||||
int32_t iStt;
|
||||
SArray *aSttBlk;
|
||||
SArray * aSttBlk;
|
||||
SBlockData bData;
|
||||
int32_t iSttBlk;
|
||||
int32_t iRow;
|
||||
|
@ -994,8 +995,8 @@ struct STsdbDataIter2 {
|
|||
// TSDB_TOMB_FILE_DATA_ITER
|
||||
struct {
|
||||
SDelFReader *pReader;
|
||||
SArray *aDelIdx;
|
||||
SArray *aDelData;
|
||||
SArray * aDelIdx;
|
||||
SArray * aDelData;
|
||||
int32_t iDelIdx;
|
||||
int32_t iDelData;
|
||||
} tIter;
|
||||
|
|
|
@ -120,6 +120,7 @@ void vnodeQueryClose(SVnode* pVnode);
|
|||
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
||||
int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
||||
int32_t vnodeGetBatchMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
||||
int32_t vnodeGetStreamProgress(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
||||
|
||||
// vnodeCommit.c
|
||||
int32_t vnodeBegin(SVnode* pVnode);
|
||||
|
|
|
@ -117,8 +117,8 @@ typedef struct SQueryNode SQueryNode;
|
|||
#define VNODE_METRIC_TAG_NAME_RESULT "result"
|
||||
|
||||
#define VNODE_METRIC_TAG_VALUE_INSERT_AFFECTED_ROWS "inserted_rows"
|
||||
//#define VNODE_METRIC_TAG_VALUE_INSERT "insert"
|
||||
//#define VNODE_METRIC_TAG_VALUE_DELETE "delete"
|
||||
// #define VNODE_METRIC_TAG_VALUE_INSERT "insert"
|
||||
// #define VNODE_METRIC_TAG_VALUE_DELETE "delete"
|
||||
|
||||
// vnd.h
|
||||
typedef int32_t (*_query_reseek_func_t)(void* pQHandle);
|
||||
|
@ -294,6 +294,7 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg);
|
|||
int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqStreamProgressRetrieveReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
|
||||
// sma
|
||||
int32_t smaInit();
|
||||
|
|
|
@ -15,6 +15,50 @@
|
|||
|
||||
#include "meta.h"
|
||||
|
||||
int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
|
||||
const SColCmprWrapper *pw = &pME->colCmpr;
|
||||
if (tEncodeI32v(pCoder, pw->nCols) < 0) return -1;
|
||||
if (tEncodeI32v(pCoder, pw->version) < 0) return -1;
|
||||
uDebug("encode cols:%d", pw->nCols);
|
||||
|
||||
for (int32_t i = 0; i < pw->nCols; i++) {
|
||||
SColCmpr *p = &pw->pColCmpr[i];
|
||||
if (tEncodeI16v(pCoder, p->id) < 0) return -1;
|
||||
if (tEncodeU32(pCoder, p->alg) < 0) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
|
||||
SColCmprWrapper *pWrapper = &pME->colCmpr;
|
||||
if (tDecodeI32v(pDecoder, &pWrapper->nCols) < 0) return -1;
|
||||
if (tDecodeI32v(pDecoder, &pWrapper->version) < 0) return -1;
|
||||
uDebug("dencode cols:%d", pWrapper->nCols);
|
||||
|
||||
pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
|
||||
if (pWrapper->pColCmpr == NULL) return -1;
|
||||
|
||||
for (int i = 0; i < pWrapper->nCols; i++) {
|
||||
SColCmpr *p = &pWrapper->pColCmpr[i];
|
||||
if (tDecodeI16v(pDecoder, &p->id) < 0) goto END;
|
||||
if (tDecodeU32(pDecoder, &p->alg) < 0) goto END;
|
||||
}
|
||||
return 0;
|
||||
END:
|
||||
// taosMemoryFree(pWrapper->pColCmpr);
|
||||
return -1;
|
||||
}
|
||||
static FORCE_INLINE void metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
|
||||
SSchemaWrapper *pSchema) {
|
||||
pCmpr->nCols = pSchema->nCols;
|
||||
pCmpr->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pCmpr->nCols * sizeof(SColCmpr));
|
||||
for (int32_t i = 0; i < pCmpr->nCols; i++) {
|
||||
SColCmpr *pColCmpr = &pCmpr->pColCmpr[i];
|
||||
SSchema *pColSchema = &pSchema->pSchema[i];
|
||||
pColCmpr->id = pColSchema->colId;
|
||||
pColCmpr->alg = createDefaultColCmprByType(pColSchema->type);
|
||||
}
|
||||
}
|
||||
|
||||
int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
|
||||
if (tStartEncode(pCoder) < 0) return -1;
|
||||
|
||||
|
@ -55,6 +99,7 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
|
|||
|
||||
return -1;
|
||||
}
|
||||
if (meteEncodeColCmprEntry(pCoder, pME) < 0) return -1;
|
||||
|
||||
tEndEncode(pCoder);
|
||||
return 0;
|
||||
|
@ -102,9 +147,25 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
|
|||
if (tDecodeTSma(pCoder, pME->smaEntry.tsma, true) < 0) return -1;
|
||||
} else {
|
||||
metaError("meta/entry: invalide table type: %" PRId8 " decode failed.", pME->type);
|
||||
|
||||
return -1;
|
||||
}
|
||||
if (pME->type == TSDB_SUPER_TABLE) {
|
||||
if (TABLE_IS_COL_COMPRESSED(pME->flags)) {
|
||||
if (meteDecodeColCmprEntry(pCoder, pME) < 0) return -1;
|
||||
} else {
|
||||
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow);
|
||||
TABLE_SET_COL_COMPRESSED(pME->flags);
|
||||
}
|
||||
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
||||
if (!tDecodeIsEnd(pCoder)) {
|
||||
uDebug("set type: %d, tableName:%s", pME->type, pME->name);
|
||||
if (meteDecodeColCmprEntry(pCoder, pME) < 0) return -1;
|
||||
} else {
|
||||
uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
|
||||
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow);
|
||||
}
|
||||
TABLE_SET_COL_COMPRESSED(pME->flags);
|
||||
}
|
||||
|
||||
tEndDecode(pCoder);
|
||||
return 0;
|
||||
|
|
|
@ -69,7 +69,8 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
|||
taosMkDir(pMeta->path);
|
||||
|
||||
// open env
|
||||
ret = tdbOpen(pMeta->path, pVnode->config.szPage, pVnode->config.szCache, &pMeta->pEnv, rollback);
|
||||
ret = tdbOpen(pMeta->path, pVnode->config.szPage, pVnode->config.szCache, &pMeta->pEnv, rollback,
|
||||
pVnode->config.tdbEncryptAlgorithm, pVnode->config.tdbEncryptKey);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta env since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
|
|
|
@ -63,6 +63,7 @@ int metaGetTableEntryByVersion(SMetaReader *pReader, int64_t version, tb_uid_t u
|
|||
if (metaDecodeEntry(&pReader->coder, &pReader->me) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
// taosMemoryFreeClear(pReader->me.colCmpr.pColCmpr);
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -363,6 +364,7 @@ _query:
|
|||
version = ((SUidIdxVal *)pData)[0].version;
|
||||
|
||||
tdbTbGet(pMeta->pTbDb, &(STbDbKey){.uid = uid, .version = version}, sizeof(STbDbKey), &pData, &nData);
|
||||
|
||||
SMetaEntry me = {0};
|
||||
tDecoderInit(&dc, pData, nData);
|
||||
metaDecodeEntry(&dc, &me);
|
||||
|
@ -410,9 +412,8 @@ _err:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
SMCtbCursor *metaOpenCtbCursor(void* pVnode, tb_uid_t uid, int lock) {
|
||||
SMeta* pMeta = ((SVnode*)pVnode)->pMeta;
|
||||
SMCtbCursor *metaOpenCtbCursor(void *pVnode, tb_uid_t uid, int lock) {
|
||||
SMeta *pMeta = ((SVnode *)pVnode)->pMeta;
|
||||
SMCtbCursor *pCtbCur = NULL;
|
||||
SCtbIdxKey ctbIdxKey;
|
||||
int ret = 0;
|
||||
|
@ -449,9 +450,9 @@ void metaCloseCtbCursor(SMCtbCursor *pCtbCur) {
|
|||
taosMemoryFree(pCtbCur);
|
||||
}
|
||||
|
||||
void metaPauseCtbCursor(SMCtbCursor* pCtbCur) {
|
||||
void metaPauseCtbCursor(SMCtbCursor *pCtbCur) {
|
||||
if (!pCtbCur->paused) {
|
||||
tdbTbcClose((TBC*)pCtbCur->pCur);
|
||||
tdbTbcClose((TBC *)pCtbCur->pCur);
|
||||
if (pCtbCur->lock) {
|
||||
metaULock(pCtbCur->pMeta);
|
||||
}
|
||||
|
@ -459,7 +460,7 @@ void metaPauseCtbCursor(SMCtbCursor* pCtbCur) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t metaResumeCtbCursor(SMCtbCursor* pCtbCur, int8_t first) {
|
||||
int32_t metaResumeCtbCursor(SMCtbCursor *pCtbCur, int8_t first) {
|
||||
if (pCtbCur->paused) {
|
||||
pCtbCur->paused = 0;
|
||||
|
||||
|
@ -467,14 +468,14 @@ int32_t metaResumeCtbCursor(SMCtbCursor* pCtbCur, int8_t first) {
|
|||
metaRLock(pCtbCur->pMeta);
|
||||
}
|
||||
int ret = 0;
|
||||
ret = tdbTbcOpen(pCtbCur->pMeta->pCtbIdx, (TBC**)&pCtbCur->pCur, NULL);
|
||||
ret = tdbTbcOpen(pCtbCur->pMeta->pCtbIdx, (TBC **)&pCtbCur->pCur, NULL);
|
||||
if (ret < 0) {
|
||||
metaCloseCtbCursor(pCtbCur);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (first) {
|
||||
SCtbIdxKey ctbIdxKey;
|
||||
SCtbIdxKey ctbIdxKey;
|
||||
// move to the suid
|
||||
ctbIdxKey.suid = pCtbCur->suid;
|
||||
ctbIdxKey.uid = INT64_MIN;
|
||||
|
@ -1478,23 +1479,23 @@ int32_t metaGetInfo(SMeta *pMeta, int64_t uid, SMetaInfo *pInfo, SMetaReader *pR
|
|||
lock = 1;
|
||||
}
|
||||
|
||||
if(!lock) metaRLock(pMeta);
|
||||
if (!lock) metaRLock(pMeta);
|
||||
|
||||
// search cache
|
||||
if (metaCacheGet(pMeta, uid, pInfo) == 0) {
|
||||
if(!lock) metaULock(pMeta);
|
||||
if (!lock) metaULock(pMeta);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// search TDB
|
||||
if (tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData) < 0) {
|
||||
// not found
|
||||
if(!lock) metaULock(pMeta);
|
||||
if (!lock) metaULock(pMeta);
|
||||
code = TSDB_CODE_NOT_FOUND;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if(!lock) metaULock(pMeta);
|
||||
if (!lock) metaULock(pMeta);
|
||||
|
||||
pInfo->uid = uid;
|
||||
pInfo->suid = ((SUidIdxVal *)pData)->suid;
|
||||
|
|
|
@ -528,6 +528,7 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe
|
|||
req.schemaTag = me.stbEntry.schemaTag;
|
||||
req.schemaRow.version = 1;
|
||||
req.schemaTag.version = 1;
|
||||
req.colCmpr = me.colCmpr;
|
||||
|
||||
ret = buildSuperTableInfo(&req, pBuf, contLen);
|
||||
*type = TDMT_VND_CREATE_STB;
|
||||
|
@ -603,6 +604,7 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe
|
|||
req.uid = me.uid;
|
||||
req.commentLen = -1;
|
||||
req.ntb.schemaRow = me.ntbEntry.schemaRow;
|
||||
req.colCmpr = me.colCmpr;
|
||||
ret = buildNormalChildTableInfo(&req, pBuf, contLen);
|
||||
*type = TDMT_VND_CREATE_TABLE;
|
||||
} else {
|
||||
|
|
|
@ -36,6 +36,36 @@ static int metaDeleteBtimeIdx(SMeta *pMeta, const SMetaEntry *pME);
|
|||
static int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||
static int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||
|
||||
int8_t updataTableColCmpr(SColCmprWrapper *pWp, SSchema *pSchema, int8_t add) {
|
||||
int32_t nCols = pWp->nCols;
|
||||
int32_t ver = pWp->version;
|
||||
if (add) {
|
||||
SColCmpr *p = taosMemoryCalloc(1, sizeof(SColCmpr) * (nCols + 1));
|
||||
memcpy(p, pWp->pColCmpr, sizeof(SColCmpr) * nCols);
|
||||
|
||||
SColCmpr *pCol = p + nCols;
|
||||
pCol->id = pSchema->colId;
|
||||
pCol->alg = createDefaultColCmprByType(pSchema->type);
|
||||
pWp->nCols = nCols + 1;
|
||||
pWp->version = ver;
|
||||
pWp->pColCmpr = p;
|
||||
} else {
|
||||
for (int32_t i = 0; i < nCols; i++) {
|
||||
SColCmpr *pOCmpr = &pWp->pColCmpr[i];
|
||||
if (pOCmpr->id == pSchema->colId) {
|
||||
int32_t left = (nCols - i - 1) * sizeof(SColCmpr);
|
||||
if (left) {
|
||||
memmove(pWp->pColCmpr + i, pWp->pColCmpr + i + 1, left);
|
||||
}
|
||||
nCols--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pWp->nCols = nCols;
|
||||
pWp->version = ver;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) {
|
||||
pInfo->uid = pEntry->uid;
|
||||
pInfo->version = pEntry->version;
|
||||
|
@ -55,11 +85,14 @@ static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) {
|
|||
|
||||
static int metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema, STableMetaRsp *pMetaRsp) {
|
||||
pMetaRsp->pSchemas = taosMemoryMalloc(pSchema->nCols * sizeof(SSchema));
|
||||
|
||||
if (NULL == pMetaRsp->pSchemas) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
pMetaRsp->pSchemaExt = taosMemoryMalloc(pSchema->nCols * sizeof(SSchemaExt));
|
||||
|
||||
tstrncpy(pMetaRsp->tbName, tbName, TSDB_TABLE_NAME_LEN);
|
||||
pMetaRsp->numOfColumns = pSchema->nCols;
|
||||
pMetaRsp->tableType = TSDB_NORMAL_TABLE;
|
||||
|
@ -241,10 +274,20 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
me.name = pReq->name;
|
||||
me.stbEntry.schemaRow = pReq->schemaRow;
|
||||
me.stbEntry.schemaTag = pReq->schemaTag;
|
||||
// me.stbEntry.colCmpr = pReq->colCmpr;
|
||||
// me.stbEntry.colCmpr = pReq->
|
||||
if (pReq->rollup) {
|
||||
TABLE_SET_ROLLUP(me.flags);
|
||||
me.stbEntry.rsmaParam = pReq->rsmaParam;
|
||||
}
|
||||
if (pReq->colCmpred) {
|
||||
TABLE_SET_COL_COMPRESSED(me.flags);
|
||||
me.colCmpr = pReq->colCmpr;
|
||||
} else {
|
||||
TABLE_SET_COL_COMPRESSED(me.flags);
|
||||
// TODO(yihao)
|
||||
// SETUP default compress algr
|
||||
}
|
||||
|
||||
if (metaHandleEntry(pMeta, &me) < 0) goto _err;
|
||||
|
||||
|
@ -432,6 +475,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
nStbEntry.name = pReq->name;
|
||||
nStbEntry.stbEntry.schemaRow = pReq->schemaRow;
|
||||
nStbEntry.stbEntry.schemaTag = pReq->schemaTag;
|
||||
nStbEntry.colCmpr = pReq->colCmpr;
|
||||
TABLE_SET_COL_COMPRESSED(nStbEntry.flags);
|
||||
|
||||
int nCols = pReq->schemaRow.nCols;
|
||||
int onCols = oStbEntry.stbEntry.schemaRow.nCols;
|
||||
|
@ -638,6 +683,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
nStbEntry.name = pReq->name;
|
||||
nStbEntry.stbEntry.schemaRow = pReq->schemaRow;
|
||||
nStbEntry.stbEntry.schemaTag = pReq->schemaTag;
|
||||
nStbEntry.colCmpr = pReq->colCmpr;
|
||||
|
||||
metaWLock(pMeta);
|
||||
// update table.db
|
||||
|
@ -771,12 +817,16 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
|||
nStbEntry.uid = oStbEntry.uid;
|
||||
nStbEntry.name = oStbEntry.name;
|
||||
|
||||
SSchemaWrapper *row = tCloneSSchemaWrapper(&oStbEntry.stbEntry.schemaRow);
|
||||
SSchemaWrapper *tag = tCloneSSchemaWrapper(&oStbEntry.stbEntry.schemaTag);
|
||||
SSchemaWrapper *row = tCloneSSchemaWrapper(&oStbEntry.stbEntry.schemaRow);
|
||||
SSchemaWrapper *tag = tCloneSSchemaWrapper(&oStbEntry.stbEntry.schemaTag);
|
||||
SColCmprWrapper *cmpr = tCloneSColCmprWrapper(&oStbEntry.colCmpr);
|
||||
|
||||
nStbEntry.stbEntry.schemaRow = *row;
|
||||
nStbEntry.stbEntry.schemaTag = *tag;
|
||||
nStbEntry.stbEntry.rsmaParam = oStbEntry.stbEntry.rsmaParam;
|
||||
nStbEntry.colCmpr = *cmpr;
|
||||
|
||||
nStbEntry.colCmpr = oStbEntry.colCmpr;
|
||||
|
||||
metaWLock(pMeta);
|
||||
// update table.db
|
||||
|
@ -787,6 +837,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
|||
|
||||
tDeleteSchemaWrapper(tag);
|
||||
tDeleteSchemaWrapper(row);
|
||||
tDeleteSColCmprWrapper(cmpr);
|
||||
|
||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||
tDecoderClear(&dc);
|
||||
|
@ -901,6 +952,8 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
|
|||
me.ntbEntry.comment = pReq->comment;
|
||||
me.ntbEntry.schemaRow = pReq->ntb.schemaRow;
|
||||
me.ntbEntry.ncid = me.ntbEntry.schemaRow.pSchema[me.ntbEntry.schemaRow.nCols - 1].colId + 1;
|
||||
me.colCmpr = pReq->colCmpr;
|
||||
TABLE_SET_COL_COMPRESSED(me.flags);
|
||||
|
||||
++pStats->numOfNTables;
|
||||
pStats->numOfNTimeSeries += me.ntbEntry.schemaRow.nCols - 1;
|
||||
|
@ -925,6 +978,11 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
|
|||
strcpy((*pMetaRsp)->tbName, pReq->name);
|
||||
} else {
|
||||
metaUpdateMetaRsp(pReq->uid, pReq->name, &pReq->ntb.schemaRow, *pMetaRsp);
|
||||
for (int32_t i = 0; i < pReq->colCmpr.nCols; i++) {
|
||||
SColCmpr *p = &pReq->colCmpr.pColCmpr[i];
|
||||
(*pMetaRsp)->pSchemaExt[i].colId = p->id;
|
||||
(*pMetaRsp)->pSchemaExt[i].compress = p->alg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1337,7 +1395,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
SMetaEntry entry = {0};
|
||||
SSchemaWrapper *pSchema;
|
||||
int c;
|
||||
|
||||
bool freeColCmpr = false;
|
||||
if (pAlterTbReq->colName == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
metaError("meta/table: null pAlterTbReq->colName");
|
||||
|
@ -1434,6 +1492,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
entry.version = version;
|
||||
int tlen;
|
||||
SSchema *pNewSchema = NULL;
|
||||
SSchema tScheam;
|
||||
switch (pAlterTbReq->action) {
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||
if (pColumn) {
|
||||
|
@ -1466,6 +1525,10 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
int8_t col_type = pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].type;
|
||||
(void)tsdbCacheNewNTableColumn(pMeta->pVnode->pTsdb, entry.uid, cid, col_type);
|
||||
}
|
||||
SSchema *pCol = &pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1];
|
||||
updataTableColCmpr(&entry.colCmpr, pCol, 1);
|
||||
freeColCmpr = true;
|
||||
ASSERT(entry.colCmpr.nCols == pSchema->nCols);
|
||||
break;
|
||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||
if (pColumn == NULL) {
|
||||
|
@ -1485,6 +1548,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
hasPrimayKey = pSchema->pSchema[1].flags & COL_IS_KEY ? true : false;
|
||||
}
|
||||
|
||||
memcpy(&tScheam, pColumn, sizeof(SSchema));
|
||||
pSchema->version++;
|
||||
tlen = (pSchema->nCols - iCol - 1) * sizeof(SSchema);
|
||||
if (tlen) {
|
||||
|
@ -1499,6 +1563,9 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
|
||||
(void)tsdbCacheDropNTableColumn(pMeta->pVnode->pTsdb, entry.uid, cid, hasPrimayKey);
|
||||
}
|
||||
|
||||
updataTableColCmpr(&entry.colCmpr, &tScheam, 0);
|
||||
ASSERT(entry.colCmpr.nCols == pSchema->nCols);
|
||||
break;
|
||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||
if (pColumn == NULL) {
|
||||
|
@ -1557,9 +1624,16 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
metaULock(pMeta);
|
||||
|
||||
metaUpdateMetaRsp(uid, pAlterTbReq->tbName, pSchema, pMetaRsp);
|
||||
for (int32_t i = 0; i < entry.colCmpr.nCols; i++) {
|
||||
SColCmpr *p = &entry.colCmpr.pColCmpr[i];
|
||||
pMetaRsp->pSchemaExt[i].colId = p->id;
|
||||
pMetaRsp->pSchemaExt[i].compress = p->alg;
|
||||
}
|
||||
|
||||
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
||||
if (pNewSchema) taosMemoryFree(pNewSchema);
|
||||
if (freeColCmpr) taosMemoryFree(entry.colCmpr.pColCmpr);
|
||||
|
||||
tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
tDecoderClear(&dc);
|
||||
|
@ -2109,6 +2183,91 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT
|
|||
_err:
|
||||
return -1;
|
||||
}
|
||||
int32_t metaUpdateTableColCompress(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq) {
|
||||
// impl later
|
||||
SMetaEntry tbEntry = {0};
|
||||
void *pVal = NULL;
|
||||
int nVal = 0;
|
||||
int ret;
|
||||
int c;
|
||||
tb_uid_t suid;
|
||||
int64_t oversion;
|
||||
const void *pData = NULL;
|
||||
int nData = 0;
|
||||
SDecoder dc = {0};
|
||||
ret = tdbTbGet(pMeta->pNameIdx, pReq->tbName, strlen(pReq->tbName) + 1, &pVal, &nVal);
|
||||
if (ret < 0) {
|
||||
terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
suid = *(tb_uid_t *)pVal;
|
||||
tdbFree(pVal);
|
||||
pVal = NULL;
|
||||
|
||||
if (tdbTbGet(pMeta->pUidIdx, &suid, sizeof(tb_uid_t), &pVal, &nVal) == -1) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
ret = -1;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
STbDbKey tbDbKey = {0};
|
||||
tbDbKey.uid = suid;
|
||||
tbDbKey.version = ((SUidIdxVal *)pVal)[0].version;
|
||||
if (tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pVal, &nVal) < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
tdbFree(pVal);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
tDecoderInit(&dc, pVal, nVal);
|
||||
ret = metaDecodeEntry(&dc, &tbEntry);
|
||||
if (ret < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
tdbFree(pVal);
|
||||
tDecoderClear(&dc);
|
||||
goto _err;
|
||||
}
|
||||
if (tbEntry.type != TSDB_NORMAL_TABLE && tbEntry.type != TSDB_SUPER_TABLE) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
tdbFree(pVal);
|
||||
tDecoderClear(&dc);
|
||||
goto _err;
|
||||
}
|
||||
int8_t updated = 0;
|
||||
SColCmprWrapper *wp = &tbEntry.colCmpr;
|
||||
for (int32_t i = 0; i < wp->nCols; i++) {
|
||||
SColCmpr *p = &wp->pColCmpr[i];
|
||||
if (p->id == pReq->colId) {
|
||||
uint32_t dst = 0;
|
||||
updated = tUpdateCompress(p->alg, pReq->compress, TSDB_COLVAL_COMPRESS_DISABLED, TSDB_COLVAL_LEVEL_DISABLED,
|
||||
TSDB_COLVAL_LEVEL_MEDIUM, &dst);
|
||||
if (updated) {
|
||||
p->alg = dst;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (updated == 0) {
|
||||
tdbFree(pVal);
|
||||
tDecoderClear(&dc);
|
||||
terrno = TSDB_CODE_VND_COLUMN_COMPRESS_ALREADY_EXIST;
|
||||
goto _err;
|
||||
}
|
||||
tbEntry.version = version;
|
||||
|
||||
metaWLock(pMeta);
|
||||
metaSaveToTbDb(pMeta, &tbEntry);
|
||||
metaUpdateUidIdx(pMeta, &tbEntry);
|
||||
metaUpdateChangeTime(pMeta, suid, pReq->ctimeMs);
|
||||
|
||||
metaULock(pMeta);
|
||||
|
||||
tdbFree(pVal);
|
||||
tDecoderClear(&dc);
|
||||
|
||||
return 0;
|
||||
_err:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int metaAlterTable(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMetaRsp *pMetaRsp) {
|
||||
pMeta->changed = true;
|
||||
|
@ -2126,6 +2285,8 @@ int metaAlterTable(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMeta
|
|||
return metaAddTagIndex(pMeta, version, pReq);
|
||||
case TSDB_ALTER_TABLE_DROP_TAG_INDEX:
|
||||
return metaDropTagIndex(pMeta, version, pReq);
|
||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS:
|
||||
return metaUpdateTableColCompress(pMeta, version, pReq);
|
||||
default:
|
||||
terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION;
|
||||
return -1;
|
||||
|
@ -2463,6 +2624,9 @@ int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
VND_CHECK_CODE(code, line, _err);
|
||||
}
|
||||
|
||||
if (pME->type == TSDB_SUPER_TABLE || pME->type == TSDB_NORMAL_TABLE) {
|
||||
}
|
||||
|
||||
metaULock(pMeta);
|
||||
metaDebug("vgId:%d, handle meta entry, ver:%" PRId64 ", uid:%" PRId64 ", name:%s", TD_VID(pMeta->pVnode),
|
||||
pME->version, pME->uid, pME->name);
|
||||
|
@ -2475,6 +2639,79 @@ _err:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t colCompressDebug(SHashObj *pColCmprObj) {
|
||||
void *p = taosHashIterate(pColCmprObj, NULL);
|
||||
while (p) {
|
||||
uint32_t cmprAlg = *(uint32_t *)p;
|
||||
col_id_t colId = *(col_id_t *)taosHashGetKey(p, NULL);
|
||||
p = taosHashIterate(pColCmprObj, p);
|
||||
|
||||
uint8_t l1, l2, lvl;
|
||||
tcompressDebug(cmprAlg, &l1, &l2, &lvl);
|
||||
|
||||
const char *l1str = columnEncodeStr(l1);
|
||||
const char *l2str = columnCompressStr(l2);
|
||||
const char *lvlstr = columnLevelStr(lvl);
|
||||
metaDebug("colId: %d, encode:%s, compress:%s,level:%s", colId, l1str, l2str, lvlstr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) {
|
||||
int rc = 0;
|
||||
|
||||
SHashObj *pColCmprObj = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
|
||||
void *pData = NULL;
|
||||
int nData = 0;
|
||||
SMetaEntry e = {0};
|
||||
SDecoder dc = {0};
|
||||
|
||||
metaRLock(pMeta);
|
||||
rc = tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData);
|
||||
if (rc < 0) {
|
||||
taosHashClear(pColCmprObj);
|
||||
metaULock(pMeta);
|
||||
return -1;
|
||||
}
|
||||
int64_t version = ((SUidIdxVal *)pData)[0].version;
|
||||
rc = tdbTbGet(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pData, &nData);
|
||||
if (rc < 0) {
|
||||
metaULock(pMeta);
|
||||
taosHashClear(pColCmprObj);
|
||||
metaError("failed to get table entry");
|
||||
return rc;
|
||||
}
|
||||
|
||||
tDecoderInit(&dc, pData, nData);
|
||||
rc = metaDecodeEntry(&dc, &e);
|
||||
if (rc < 0) {
|
||||
tDecoderClear(&dc);
|
||||
tdbFree(pData);
|
||||
metaULock(pMeta);
|
||||
taosHashClear(pColCmprObj);
|
||||
return -1;
|
||||
}
|
||||
if (useCompress(e.type)) {
|
||||
SColCmprWrapper *p = &e.colCmpr;
|
||||
for (int32_t i = 0; i < p->nCols; i++) {
|
||||
SColCmpr *pCmpr = &p->pColCmpr[i];
|
||||
taosHashPut(pColCmprObj, &pCmpr->id, sizeof(pCmpr->id), &pCmpr->alg, sizeof(pCmpr->alg));
|
||||
}
|
||||
} else {
|
||||
tDecoderClear(&dc);
|
||||
tdbFree(pData);
|
||||
metaULock(pMeta);
|
||||
taosHashClear(pColCmprObj);
|
||||
return 0;
|
||||
}
|
||||
tDecoderClear(&dc);
|
||||
tdbFree(pData);
|
||||
metaULock(pMeta);
|
||||
|
||||
*ppColCmprObj = pColCmprObj;
|
||||
colCompressDebug(pColCmprObj);
|
||||
|
||||
return 0;
|
||||
}
|
||||
// refactor later
|
||||
void *metaGetIdx(SMeta *pMeta) { return pMeta->pTagIdx; }
|
||||
void *metaGetIvtIdx(SMeta *pMeta) { return pMeta->pTagIvtIdx; }
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue