Merge branch '3.0' of https://github.com/taosdata/TDengine into 3.0
This commit is contained in:
commit
1ad07dc554
|
@ -47,27 +47,20 @@ IF(${TD_WINDOWS})
|
||||||
|
|
||||||
MESSAGE("build wingetopt Win32")
|
MESSAGE("build wingetopt Win32")
|
||||||
option(
|
option(
|
||||||
BUILD_WINGETOPT
|
BUILD_WINGETOPT
|
||||||
"If build wingetopt on Windows"
|
"If build wingetopt on Windows"
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
TDENGINE_3
|
TDENGINE_3
|
||||||
"TDengine 3.x for taos-tools"
|
"TDengine 3.x for taos-tools"
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_CRASHDUMP
|
BUILD_CRASHDUMP
|
||||||
"If build crashdump on Windows"
|
"If build crashdump on Windows"
|
||||||
ON
|
|
||||||
)
|
|
||||||
|
|
||||||
MESSAGE("build geos Win32")
|
|
||||||
option(
|
|
||||||
BUILD_GEOS
|
|
||||||
"If build geos on Windows"
|
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -79,7 +72,7 @@ ENDIF ()
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_GEOS
|
BUILD_GEOS
|
||||||
"If build geos on Windows"
|
"If build with geos"
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -95,6 +88,12 @@ option(
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(
|
||||||
|
BUILD_PCRE2
|
||||||
|
"If build with pcre2"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
JEMALLOC_ENABLED
|
JEMALLOC_ENABLED
|
||||||
"If build with jemalloc"
|
"If build with jemalloc"
|
||||||
|
@ -114,14 +113,14 @@ option(
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_LEVELDB
|
BUILD_WITH_LEVELDB
|
||||||
"If build with leveldb"
|
"If build with leveldb"
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_ROCKSDB
|
BUILD_WITH_ROCKSDB
|
||||||
"If build with rocksdb"
|
"If build with rocksdb"
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -170,46 +169,46 @@ ENDIF ()
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_SQLITE
|
BUILD_WITH_SQLITE
|
||||||
"If build with sqlite"
|
"If build with sqlite"
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_BDB
|
BUILD_WITH_BDB
|
||||||
"If build with BDB"
|
"If build with BDB"
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_LUCENE
|
BUILD_WITH_LUCENE
|
||||||
"If build with lucene"
|
"If build with lucene"
|
||||||
off
|
off
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_NURAFT
|
BUILD_WITH_NURAFT
|
||||||
"If build with NuRaft"
|
"If build with NuRaft"
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_UV
|
BUILD_WITH_UV
|
||||||
"If build with libuv"
|
"If build with libuv"
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_UV_TRANS
|
BUILD_WITH_UV_TRANS
|
||||||
"If build with libuv_trans "
|
"If build with libuv_trans "
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(${TD_LINUX} MATCHES TRUE)
|
IF(${TD_LINUX} MATCHES TRUE)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_DEPENDENCY_TESTS
|
BUILD_DEPENDENCY_TESTS
|
||||||
"If build dependency tests"
|
"If build dependency tests"
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -217,14 +216,14 @@ ENDIF ()
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_DOCS
|
BUILD_DOCS
|
||||||
"If use doxygen build documents"
|
"If use doxygen build documents"
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_INVERTEDINDEX
|
BUILD_WITH_INVERTEDINDEX
|
||||||
"If use invertedIndex"
|
"If use invertedIndex"
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
# pcre2
|
||||||
|
ExternalProject_Add(pcre2
|
||||||
|
GIT_REPOSITORY https://github.com/PCRE2Project/pcre2.git
|
||||||
|
GIT_TAG pcre2-10.43
|
||||||
|
SOURCE_DIR "${TD_CONTRIB_DIR}/pcre2"
|
||||||
|
#BINARY_DIR "${TD_CONTRIB_DIR}/pcre2"
|
||||||
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
TEST_COMMAND ""
|
||||||
|
)
|
|
@ -121,7 +121,7 @@ if (${BUILD_CONTRIB})
|
||||||
cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
add_definitions(-DUSE_ROCKSDB)
|
add_definitions(-DUSE_ROCKSDB)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if (NOT ${TD_LINUX})
|
if (NOT ${TD_LINUX})
|
||||||
if(${BUILD_WITH_ROCKSDB})
|
if(${BUILD_WITH_ROCKSDB})
|
||||||
cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
@ -183,6 +183,11 @@ if(${BUILD_GEOS})
|
||||||
cat("${TD_SUPPORT_DIR}/geos_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/geos_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
if(${BUILD_PCRE2})
|
||||||
|
cat("${TD_SUPPORT_DIR}/pcre2_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
endif()
|
||||||
|
|
||||||
# download dependencies
|
# download dependencies
|
||||||
configure_file(${CONTRIB_TMP_FILE} "${TD_CONTRIB_DIR}/deps-download/CMakeLists.txt")
|
configure_file(${CONTRIB_TMP_FILE} "${TD_CONTRIB_DIR}/deps-download/CMakeLists.txt")
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
||||||
|
@ -270,8 +275,8 @@ unset(CMAKE_PROJECT_INCLUDE_BEFORE)
|
||||||
# add_subdirectory(xz EXCLUDE_FROM_ALL)
|
# add_subdirectory(xz EXCLUDE_FROM_ALL)
|
||||||
# target_include_directories(
|
# target_include_directories(
|
||||||
# xz
|
# xz
|
||||||
# PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/xz
|
# PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/xz
|
||||||
# PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/xz
|
# PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/xz
|
||||||
# )
|
# )
|
||||||
|
|
||||||
# leveldb
|
# leveldb
|
||||||
|
@ -351,7 +356,7 @@ if (${BUILD_WITH_ROCKSDB})
|
||||||
rocksdb
|
rocksdb
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/include>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/include>
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
if (NOT ${TD_LINUX})
|
if (NOT ${TD_LINUX})
|
||||||
MESSAGE(STATUS "ROCKSDB CXX STATUS CONFIG: " ${CMAKE_CXX_FLAGS})
|
MESSAGE(STATUS "ROCKSDB CXX STATUS CONFIG: " ${CMAKE_CXX_FLAGS})
|
||||||
MESSAGE(STATUS "ROCKSDB C STATUS CONFIG: " ${CMAKE_C_FLAGS})
|
MESSAGE(STATUS "ROCKSDB C STATUS CONFIG: " ${CMAKE_C_FLAGS})
|
||||||
|
@ -400,8 +405,8 @@ if (${BUILD_WITH_ROCKSDB})
|
||||||
rocksdb
|
rocksdb
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/include>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/include>
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -605,6 +610,10 @@ if(${BUILD_GEOS})
|
||||||
)
|
)
|
||||||
endif(${BUILD_GEOS})
|
endif(${BUILD_GEOS})
|
||||||
|
|
||||||
|
if (${BUILD_PCRE2})
|
||||||
|
add_subdirectory(pcre2 EXCLUDE_FROM_ALL)
|
||||||
|
endif(${BUILD_PCRE2})
|
||||||
|
|
||||||
# ================================================================================================
|
# ================================================================================================
|
||||||
# Build test
|
# Build test
|
||||||
# ================================================================================================
|
# ================================================================================================
|
||||||
|
|
|
@ -95,6 +95,15 @@ const static uint8_t BIT2_MAP[4] = {0b11111100, 0b11110011, 0b11001111, 0b001111
|
||||||
#define COL_VAL_IS_NULL(CV) ((CV)->flag == CV_FLAG_NULL)
|
#define COL_VAL_IS_NULL(CV) ((CV)->flag == CV_FLAG_NULL)
|
||||||
#define COL_VAL_IS_VALUE(CV) ((CV)->flag == CV_FLAG_VALUE)
|
#define COL_VAL_IS_VALUE(CV) ((CV)->flag == CV_FLAG_VALUE)
|
||||||
|
|
||||||
|
#define tRowGetKey(_pRow, _pKey) \
|
||||||
|
do { \
|
||||||
|
(_pKey)->ts = (_pRow)->ts; \
|
||||||
|
(_pKey)->numOfPKs = 0; \
|
||||||
|
if ((_pRow)->numOfPKs > 0) { \
|
||||||
|
tRowGetPrimaryKey((_pRow), (_pKey)); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
// SValueColumn ================================
|
// SValueColumn ================================
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t cmprAlg; // filled by caller
|
int8_t cmprAlg; // filled by caller
|
||||||
|
@ -125,8 +134,8 @@ void tRowDestroy(SRow *pRow);
|
||||||
int32_t tRowSort(SArray *aRowP);
|
int32_t tRowSort(SArray *aRowP);
|
||||||
int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag);
|
int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag);
|
||||||
int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag);
|
int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag);
|
||||||
void tRowGetKey(SRow *pRow, SRowKey *key);
|
void tRowGetPrimaryKey(SRow *pRow, SRowKey *key);
|
||||||
int32_t tRowKeyCompare(const void *p1, const void *p2);
|
int32_t tRowKeyCompare(const SRowKey *key1, const SRowKey *key2);
|
||||||
int32_t tRowKeyAssign(SRowKey *pDst, SRowKey *pSrc);
|
int32_t tRowKeyAssign(SRowKey *pDst, SRowKey *pSrc);
|
||||||
|
|
||||||
// SRowIter ================================
|
// SRowIter ================================
|
||||||
|
|
|
@ -258,7 +258,7 @@ extern bool tsExperimental;
|
||||||
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
||||||
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc);
|
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc);
|
||||||
int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs,
|
int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs,
|
||||||
bool tsc);
|
bool tsc, bool isDumpCfg);
|
||||||
void taosCleanupCfg();
|
void taosCleanupCfg();
|
||||||
|
|
||||||
int32_t taosCfgDynamicOptions(SConfig *pCfg, const char *name, bool forServer);
|
int32_t taosCfgDynamicOptions(SConfig *pCfg, const char *name, bool forServer);
|
||||||
|
|
|
@ -56,6 +56,10 @@ typedef enum {
|
||||||
TSDB_GRANT_VIEW,
|
TSDB_GRANT_VIEW,
|
||||||
TSDB_GRANT_MULTI_TIER,
|
TSDB_GRANT_MULTI_TIER,
|
||||||
TSDB_GRANT_BACKUP_RESTORE,
|
TSDB_GRANT_BACKUP_RESTORE,
|
||||||
|
TSDB_GRANT_OBJECT_STORAGE,
|
||||||
|
TSDB_GRANT_ACTIVE_ACTIVE,
|
||||||
|
TSDB_GRANT_DUAL_REPLICA_HA,
|
||||||
|
TSDB_GRANT_DB_ENCRYPTION,
|
||||||
} EGrantType;
|
} EGrantType;
|
||||||
|
|
||||||
int32_t checkAndGetCryptKey(const char *encryptCode, const char *machineId, char **key);
|
int32_t checkAndGetCryptKey(const char *encryptCode, const char *machineId, char **key);
|
||||||
|
|
|
@ -327,6 +327,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_DB_IN_CREATING TAOS_DEF_ERROR_CODE(0, 0x0396) //
|
#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_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x039A)
|
||||||
#define TSDB_CODE_MND_ENCRYPT_NOT_ALLOW_CHANGE TAOS_DEF_ERROR_CODE(0, 0x039B)
|
#define TSDB_CODE_MND_ENCRYPT_NOT_ALLOW_CHANGE TAOS_DEF_ERROR_CODE(0, 0x039B)
|
||||||
|
#define TSDB_CODE_MND_DB_ENCRYPT_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x039C)
|
||||||
|
|
||||||
// mnode-node
|
// mnode-node
|
||||||
#define TSDB_CODE_MND_MNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
|
#define TSDB_CODE_MND_MNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
|
||||||
|
|
|
@ -21,6 +21,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <geos_c.h>
|
#include <geos_c.h>
|
||||||
|
#include <tpcre2.h>
|
||||||
|
|
||||||
typedef struct SGeosContext {
|
typedef struct SGeosContext {
|
||||||
GEOSContextHandle_t handle;
|
GEOSContextHandle_t handle;
|
||||||
|
@ -31,6 +32,9 @@ typedef struct SGeosContext {
|
||||||
GEOSWKBReader *WKBReader;
|
GEOSWKBReader *WKBReader;
|
||||||
GEOSWKBWriter *WKBWriter;
|
GEOSWKBWriter *WKBWriter;
|
||||||
|
|
||||||
|
pcre2_code *WKTRegex;
|
||||||
|
pcre2_match_data *WKTMatchData;
|
||||||
|
|
||||||
char errMsg[512];
|
char errMsg[512];
|
||||||
} SGeosContext;
|
} SGeosContext;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_ULIT_PCRE2_H_
|
||||||
|
#define _TD_ULIT_PCRE2_H_
|
||||||
|
|
||||||
|
#define PCRE2_CODE_UNIT_WIDTH 8
|
||||||
|
#include "pcre2.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int32_t doRegComp(pcre2_code** ppRegex, pcre2_match_data** ppMatchData, const char* pattern);
|
||||||
|
int32_t doRegExec(const char* pString, pcre2_code* pRegex, pcre2_match_data* pMatchData);
|
||||||
|
void destroyRegexes(pcre2_code* pWktRegex, pcre2_match_data* pWktMatchData);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // _TD_UTIL_PAGEDBUF_H_
|
|
@ -725,7 +725,7 @@ void taos_init_imp(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1) != 0) {
|
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1, true) != 0) {
|
||||||
tscInitRes = -1;
|
tscInitRes = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,11 @@ static tb_uid_t processSuid(tb_uid_t suid, char* db) { return suid + MurmurHash3
|
||||||
|
|
||||||
static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id,
|
static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id,
|
||||||
int8_t t, SColCmprWrapper* pColCmprRow) {
|
int8_t t, SColCmprWrapper* pColCmprRow) {
|
||||||
|
int8_t buildDefaultCompress = 0;
|
||||||
|
if (pColCmprRow->nCols <= 0) {
|
||||||
|
buildDefaultCompress = 1;
|
||||||
|
}
|
||||||
|
|
||||||
char* string = NULL;
|
char* string = NULL;
|
||||||
cJSON* json = cJSON_CreateObject();
|
cJSON* json = cJSON_CreateObject();
|
||||||
if (json == NULL) {
|
if (json == NULL) {
|
||||||
|
@ -70,13 +75,20 @@ static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* sch
|
||||||
cJSON_AddItemToObject(column, "isPrimarykey", isPk);
|
cJSON_AddItemToObject(column, "isPrimarykey", isPk);
|
||||||
cJSON_AddItemToArray(columns, column);
|
cJSON_AddItemToArray(columns, column);
|
||||||
|
|
||||||
if (pColCmprRow == NULL || pColCmprRow->nCols <= i) {
|
if (pColCmprRow == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SColCmpr* pColCmpr = pColCmprRow->pColCmpr + i;
|
|
||||||
const char* encode = columnEncodeStr(COMPRESS_L1_TYPE_U32(pColCmpr->alg));
|
uint32_t alg = 0;
|
||||||
const char* compress = columnCompressStr(COMPRESS_L2_TYPE_U32(pColCmpr->alg));
|
if (buildDefaultCompress) {
|
||||||
const char* level = columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pColCmpr->alg));
|
alg = createDefaultColCmprByType(s->type);
|
||||||
|
} else {
|
||||||
|
SColCmpr* pColCmpr = pColCmprRow->pColCmpr + i;
|
||||||
|
alg = pColCmpr->alg;
|
||||||
|
}
|
||||||
|
const char* encode = columnEncodeStr(COMPRESS_L1_TYPE_U32(alg));
|
||||||
|
const char* compress = columnCompressStr(COMPRESS_L2_TYPE_U32(alg));
|
||||||
|
const char* level = columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(alg));
|
||||||
|
|
||||||
cJSON* encodeJson = cJSON_CreateString(encode);
|
cJSON* encodeJson = cJSON_CreateString(encode);
|
||||||
cJSON_AddItemToObject(column, "encode", encodeJson);
|
cJSON_AddItemToObject(column, "encode", encodeJson);
|
||||||
|
@ -767,14 +779,25 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
code = TSDB_CODE_INVALID_PARA;
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int8_t createDefaultCompress = 0;
|
||||||
|
SColCmprWrapper* p = &req.colCmpr;
|
||||||
|
if (p->nCols == 0) {
|
||||||
|
createDefaultCompress = 1;
|
||||||
|
}
|
||||||
// build create stable
|
// build create stable
|
||||||
pReq.pColumns = taosArrayInit(req.schemaRow.nCols, sizeof(SFieldWithOptions));
|
pReq.pColumns = taosArrayInit(req.schemaRow.nCols, sizeof(SFieldWithOptions));
|
||||||
for (int32_t i = 0; i < req.schemaRow.nCols; i++) {
|
for (int32_t i = 0; i < req.schemaRow.nCols; i++) {
|
||||||
SSchema* pSchema = req.schemaRow.pSchema + i;
|
SSchema* pSchema = req.schemaRow.pSchema + i;
|
||||||
SFieldWithOptions 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);
|
strcpy(field.name, pSchema->name);
|
||||||
SColCmpr *p = &req.colCmpr.pColCmpr[i];
|
|
||||||
field.compress = p->alg;
|
if (createDefaultCompress) {
|
||||||
|
field.compress = createDefaultColCmprByType(pSchema->type);
|
||||||
|
} else {
|
||||||
|
SColCmpr* p = &req.colCmpr.pColCmpr[i];
|
||||||
|
field.compress = p->alg;
|
||||||
|
}
|
||||||
taosArrayPush(pReq.pColumns, &field);
|
taosArrayPush(pReq.pColumns, &field);
|
||||||
}
|
}
|
||||||
pReq.pTags = taosArrayInit(req.schemaTag.nCols, sizeof(SField));
|
pReq.pTags = taosArrayInit(req.schemaTag.nCols, sizeof(SField));
|
||||||
|
|
|
@ -27,6 +27,8 @@ static S3UriStyle uriStyleG = S3UriStylePath;
|
||||||
static int retriesG = 5;
|
static int retriesG = 5;
|
||||||
static int timeoutMsG = 0;
|
static int timeoutMsG = 0;
|
||||||
|
|
||||||
|
extern int8_t tsS3Oss;
|
||||||
|
|
||||||
int32_t s3Begin() {
|
int32_t s3Begin() {
|
||||||
S3Status status;
|
S3Status status;
|
||||||
const char *hostname = tsS3Hostname;
|
const char *hostname = tsS3Hostname;
|
||||||
|
@ -42,6 +44,9 @@ int32_t s3Begin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protocolG = !tsS3Https;
|
protocolG = !tsS3Https;
|
||||||
|
if (tsS3Oss) {
|
||||||
|
uriStyleG = S3UriStyleVirtualHost;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +63,11 @@ static int32_t s3ListBucket(char const *bucketname);
|
||||||
int32_t s3CheckCfg() {
|
int32_t s3CheckCfg() {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (!tsS3Enabled) {
|
||||||
|
fprintf(stderr, "s3 not configured.\n");
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
code = s3Begin();
|
code = s3Begin();
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
fprintf(stderr, "failed to initialize s3.\n");
|
fprintf(stderr, "failed to initialize s3.\n");
|
||||||
|
|
|
@ -250,7 +250,7 @@ bool checkColumnEncodeOrSetDefault(uint8_t type, char encode[TSDB_CL_COMPRESS_OP
|
||||||
strncpy(encode, getDefaultEncodeStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
strncpy(encode, getDefaultEncodeStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return checkColumnEncode(encode);
|
return checkColumnEncode(encode) && validColEncode(type, columnEncodeVal(encode));
|
||||||
}
|
}
|
||||||
bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||||
if (0 == strlen(compress)) return true;
|
if (0 == strlen(compress)) return true;
|
||||||
|
@ -267,7 +267,8 @@ bool checkColumnCompressOrSetDefault(uint8_t type, char compress[TSDB_CL_COMPRES
|
||||||
strncpy(compress, getDefaultCompressStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
strncpy(compress, getDefaultCompressStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return checkColumnCompress(compress);
|
|
||||||
|
return checkColumnCompress(compress) && validColCompress(type, columnCompressVal(compress));
|
||||||
}
|
}
|
||||||
bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||||
if (0 == strlen(level)) return true;
|
if (0 == strlen(level)) return true;
|
||||||
|
@ -288,7 +289,7 @@ bool checkColumnLevelOrSetDefault(uint8_t type, char level[TSDB_CL_COMPRESS_OPTI
|
||||||
strncpy(level, getDefaultLevelStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
strncpy(level, getDefaultLevelStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return checkColumnLevel(level);
|
return checkColumnLevel(level) && validColCompressLevel(type, columnLevelVal(level));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setColEncode(uint32_t* compress, uint8_t l1) {
|
void setColEncode(uint32_t* compress, uint8_t l1) {
|
||||||
|
|
|
@ -1183,8 +1183,7 @@ int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tRowGetKey(SRow *row, SRowKey *key) {
|
void tRowGetPrimaryKey(SRow *row, SRowKey *key) {
|
||||||
key->ts = row->ts;
|
|
||||||
key->numOfPKs = row->numOfPKs;
|
key->numOfPKs = row->numOfPKs;
|
||||||
|
|
||||||
if (key->numOfPKs == 0) {
|
if (key->numOfPKs == 0) {
|
||||||
|
@ -1283,10 +1282,7 @@ int32_t tValueCompare(const SValue *tv1, const SValue *tv2) {
|
||||||
// NOTE:
|
// NOTE:
|
||||||
// set key->numOfPKs to 0 as the smallest key with ts
|
// set key->numOfPKs to 0 as the smallest key with ts
|
||||||
// set key->numOfPKs to (TD_MAX_PK_COLS + 1) as the largest key with ts
|
// set key->numOfPKs to (TD_MAX_PK_COLS + 1) as the largest key with ts
|
||||||
int32_t tRowKeyCompare(const void *p1, const void *p2) {
|
FORCE_INLINE int32_t tRowKeyCompare(const SRowKey *key1, const SRowKey *key2) {
|
||||||
SRowKey *key1 = (SRowKey *)p1;
|
|
||||||
SRowKey *key2 = (SRowKey *)p2;
|
|
||||||
|
|
||||||
if (key1->ts < key2->ts) {
|
if (key1->ts < key2->ts) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (key1->ts > key2->ts) {
|
} else if (key1->ts > key2->ts) {
|
||||||
|
|
|
@ -32,22 +32,22 @@
|
||||||
SConfig *tsCfg = NULL;
|
SConfig *tsCfg = NULL;
|
||||||
|
|
||||||
// cluster
|
// cluster
|
||||||
char tsFirst[TSDB_EP_LEN] = {0};
|
char tsFirst[TSDB_EP_LEN] = {0};
|
||||||
char tsSecond[TSDB_EP_LEN] = {0};
|
char tsSecond[TSDB_EP_LEN] = {0};
|
||||||
char tsLocalFqdn[TSDB_FQDN_LEN] = {0};
|
char tsLocalFqdn[TSDB_FQDN_LEN] = {0};
|
||||||
char tsLocalEp[TSDB_EP_LEN] = {0}; // Local End Point, hostname:port
|
char tsLocalEp[TSDB_EP_LEN] = {0}; // Local End Point, hostname:port
|
||||||
char tsVersionName[16] = "community";
|
char tsVersionName[16] = "community";
|
||||||
uint16_t tsServerPort = 6030;
|
uint16_t tsServerPort = 6030;
|
||||||
int32_t tsVersion = 30000000;
|
int32_t tsVersion = 30000000;
|
||||||
int32_t tsStatusInterval = 1; // second
|
int32_t tsStatusInterval = 1; // second
|
||||||
int32_t tsNumOfSupportVnodes = 256;
|
int32_t tsNumOfSupportVnodes = 256;
|
||||||
char tsEncryptAlgorithm[16] = {0};
|
char tsEncryptAlgorithm[16] = {0};
|
||||||
char tsEncryptScope[100] = {0};
|
char tsEncryptScope[100] = {0};
|
||||||
EEncryptAlgor tsiEncryptAlgorithm = 0;
|
EEncryptAlgor tsiEncryptAlgorithm = 0;
|
||||||
EEncryptScope tsiEncryptScope = 0;
|
EEncryptScope tsiEncryptScope = 0;
|
||||||
//char tsAuthCode[500] = {0};
|
// char tsAuthCode[500] = {0};
|
||||||
//char tsEncryptKey[17] = {0};
|
// char tsEncryptKey[17] = {0};
|
||||||
char tsEncryptKey[17] = {0};
|
char tsEncryptKey[17] = {0};
|
||||||
|
|
||||||
// common
|
// common
|
||||||
int32_t tsMaxShellConns = 50000;
|
int32_t tsMaxShellConns = 50000;
|
||||||
|
@ -240,8 +240,8 @@ int64_t tsTickPerMin[] = {60000L, 60000000L, 60000000000L};
|
||||||
int64_t tsTickPerHour[] = {3600000L, 3600000000L, 3600000000000L};
|
int64_t tsTickPerHour[] = {3600000L, 3600000000L, 3600000000000L};
|
||||||
|
|
||||||
// lossy compress 7
|
// lossy compress 7
|
||||||
char tsLossyColumns[32] = ""; // "float|double" means all float and double columns can be lossy compressed. set empty
|
char tsLossyColumns[32] = "float|double"; // "float|double" means all float and double columns can be lossy compressed.
|
||||||
// can close lossy compress.
|
// set empty can close lossy compress.
|
||||||
// below option can take effect when tsLossyColumns not empty
|
// below option can take effect when tsLossyColumns not empty
|
||||||
float tsFPrecision = 1E-8; // float column precision
|
float tsFPrecision = 1E-8; // float column precision
|
||||||
double tsDPrecision = 1E-16; // double column precision
|
double tsDPrecision = 1E-16; // double column precision
|
||||||
|
@ -296,6 +296,8 @@ char tsS3AccessKeySecret[TSDB_FQDN_LEN] = "<accesskeysecrect>";
|
||||||
char tsS3BucketName[TSDB_FQDN_LEN] = "<bucketname>";
|
char tsS3BucketName[TSDB_FQDN_LEN] = "<bucketname>";
|
||||||
char tsS3AppId[TSDB_FQDN_LEN] = "<appid>";
|
char tsS3AppId[TSDB_FQDN_LEN] = "<appid>";
|
||||||
int8_t tsS3Enabled = false;
|
int8_t tsS3Enabled = false;
|
||||||
|
int8_t tsS3EnabledCfg = false;
|
||||||
|
int8_t tsS3Oss = false;
|
||||||
int8_t tsS3StreamEnabled = false;
|
int8_t tsS3StreamEnabled = false;
|
||||||
|
|
||||||
int8_t tsS3Https = true;
|
int8_t tsS3Https = true;
|
||||||
|
@ -310,7 +312,7 @@ bool tsExperimental = true;
|
||||||
|
|
||||||
int32_t tsMaxTsmaNum = 3;
|
int32_t tsMaxTsmaNum = 3;
|
||||||
int32_t tsMaxTsmaCalcDelay = 600;
|
int32_t tsMaxTsmaCalcDelay = 600;
|
||||||
int64_t tsmaDataDeleteMark = 1000 * 60 * 60 * 24; // in ms, default to 1d
|
int64_t tsmaDataDeleteMark = 1000 * 60 * 60 * 24; // in ms, default to 1d
|
||||||
|
|
||||||
#ifndef _STORAGE
|
#ifndef _STORAGE
|
||||||
int32_t taosSetTfsCfg(SConfig *pCfg) {
|
int32_t taosSetTfsCfg(SConfig *pCfg) {
|
||||||
|
@ -366,10 +368,15 @@ int32_t taosSetS3Cfg(SConfig *pCfg) {
|
||||||
tstrncpy(tsS3AppId, appid + 1, TSDB_FQDN_LEN);
|
tstrncpy(tsS3AppId, appid + 1, TSDB_FQDN_LEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
char *oss = strstr(tsS3Endpoint, "aliyuncs.");
|
||||||
|
if (oss) {
|
||||||
|
tsS3Oss = true;
|
||||||
|
}
|
||||||
if (tsS3BucketName[0] != '<') {
|
if (tsS3BucketName[0] != '<') {
|
||||||
#if defined(USE_COS) || defined(USE_S3)
|
#if defined(USE_COS) || defined(USE_S3)
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
/*if (tsDiskCfgNum > 1) */ tsS3Enabled = true;
|
/*if (tsDiskCfgNum > 1) */ tsS3Enabled = true;
|
||||||
|
tsS3EnabledCfg = true;
|
||||||
#endif
|
#endif
|
||||||
tsS3StreamEnabled = true;
|
tsS3StreamEnabled = true;
|
||||||
#endif
|
#endif
|
||||||
|
@ -563,11 +570,12 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
||||||
if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, CFG_SCOPE_BOTH, CFG_DYN_BOTH) != 0) return -1;
|
if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, CFG_SCOPE_BOTH, CFG_DYN_BOTH) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, CFG_SCOPE_BOTH, CFG_DYN_NONE) != 0) return -1;
|
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 (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)
|
if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, CFG_SCOPE_BOTH, CFG_DYN_CLIENT) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (cfgAddInt32(pCfg, "maxTsmaCalcDelay", tsMaxTsmaCalcDelay, 600, 86400, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) !=
|
if (cfgAddInt32(pCfg, "maxTsmaCalcDelay", tsMaxTsmaCalcDelay, 600, 86400, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0)
|
||||||
0)
|
|
||||||
return -1;
|
return -1;
|
||||||
if (cfgAddInt32(pCfg, "tsmaDataDeleteMark", tsmaDataDeleteMark, 60 * 60 * 1000, INT64_MAX, CFG_SCOPE_CLIENT,
|
if (cfgAddInt32(pCfg, "tsmaDataDeleteMark", tsmaDataDeleteMark, 60 * 60 * 1000, INT64_MAX, CFG_SCOPE_CLIENT,
|
||||||
CFG_DYN_CLIENT) != 0)
|
CFG_DYN_CLIENT) != 0)
|
||||||
|
@ -618,11 +626,12 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
tsNumOfSupportVnodes = tsNumOfCores * 2;
|
tsNumOfSupportVnodes = tsNumOfCores * 2;
|
||||||
tsNumOfSupportVnodes = TMAX(tsNumOfSupportVnodes, 2);
|
tsNumOfSupportVnodes = TMAX(tsNumOfSupportVnodes, 2);
|
||||||
if (cfgAddInt32(pCfg, "supportVnodes", tsNumOfSupportVnodes, 0, 4096, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
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, "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, "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 (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, "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)
|
if (cfgAddInt32(pCfg, "minSlidingTime", tsMinSlidingTime, 1, 1000000, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0)
|
||||||
|
@ -749,8 +758,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
if (cfgAddInt32(pCfg, "tmqMaxTopicNum", tmqMaxTopicNum, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0)
|
if (cfgAddInt32(pCfg, "tmqMaxTopicNum", tmqMaxTopicNum, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (cfgAddInt32(pCfg, "tmqRowSize", tmqRowSize, 1, 1000000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0)
|
if (cfgAddInt32(pCfg, "tmqRowSize", tmqRowSize, 1, 1000000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (cfgAddInt32(pCfg, "maxTsmaNum", tsMaxTsmaNum, 0, 3, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1;
|
if (cfgAddInt32(pCfg, "maxTsmaNum", tsMaxTsmaNum, 0, 3, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "transPullupInterval", tsTransPullupInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) !=
|
if (cfgAddInt32(pCfg, "transPullupInterval", tsTransPullupInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) !=
|
||||||
|
@ -807,7 +815,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
CFG_DYN_ENT_SERVER) != 0)
|
CFG_DYN_ENT_SERVER) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (cfgAddString(pCfg, "lossyColumns", tsLossyColumns, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
|
||||||
if (cfgAddFloat(pCfg, "fPrecision", tsFPrecision, 0.0f, 100000.0f, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
if (cfgAddFloat(pCfg, "fPrecision", tsFPrecision, 0.0f, 100000.0f, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
if (cfgAddFloat(pCfg, "dPrecision", tsDPrecision, 0.0f, 1000000.0f, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
if (cfgAddFloat(pCfg, "dPrecision", tsDPrecision, 0.0f, 1000000.0f, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "maxRange", tsMaxRange, 0, 65536, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
if (cfgAddInt32(pCfg, "maxRange", tsMaxRange, 0, 65536, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
|
@ -1181,7 +1188,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
|
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
|
||||||
tstrncpy(tsEncryptAlgorithm, cfgGetItem(pCfg, "encryptAlgorithm")->str, 16);
|
tstrncpy(tsEncryptAlgorithm, cfgGetItem(pCfg, "encryptAlgorithm")->str, 16);
|
||||||
tstrncpy(tsEncryptScope, cfgGetItem(pCfg, "encryptScope")->str, 100);
|
tstrncpy(tsEncryptScope, cfgGetItem(pCfg, "encryptScope")->str, 100);
|
||||||
//tstrncpy(tsAuthCode, cfgGetItem(pCfg, "authCode")->str, 100);
|
// tstrncpy(tsAuthCode, cfgGetItem(pCfg, "authCode")->str, 100);
|
||||||
|
|
||||||
tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32;
|
tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32;
|
||||||
tsNumOfRpcSessions = cfgGetItem(pCfg, "numOfRpcSessions")->i32;
|
tsNumOfRpcSessions = cfgGetItem(pCfg, "numOfRpcSessions")->i32;
|
||||||
|
@ -1268,7 +1275,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
tsCacheLazyLoadThreshold = cfgGetItem(pCfg, "cacheLazyLoadThreshold")->i32;
|
tsCacheLazyLoadThreshold = cfgGetItem(pCfg, "cacheLazyLoadThreshold")->i32;
|
||||||
|
|
||||||
tstrncpy(tsLossyColumns, cfgGetItem(pCfg, "lossyColumns")->str, sizeof(tsLossyColumns));
|
|
||||||
tsFPrecision = cfgGetItem(pCfg, "fPrecision")->fval;
|
tsFPrecision = cfgGetItem(pCfg, "fPrecision")->fval;
|
||||||
tsDPrecision = cfgGetItem(pCfg, "dPrecision")->fval;
|
tsDPrecision = cfgGetItem(pCfg, "dPrecision")->fval;
|
||||||
tsMaxRange = cfgGetItem(pCfg, "maxRange")->i32;
|
tsMaxRange = cfgGetItem(pCfg, "maxRange")->i32;
|
||||||
|
@ -1388,7 +1394,7 @@ static int32_t taosCheckGlobalCfg() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs,
|
int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs,
|
||||||
bool tsc) {
|
bool tsc, bool isDumpCfg) {
|
||||||
if (tsCfg != NULL) return 0;
|
if (tsCfg != NULL) return 0;
|
||||||
tsCfg = cfgInit();
|
tsCfg = cfgInit();
|
||||||
|
|
||||||
|
@ -1435,7 +1441,7 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile
|
||||||
|
|
||||||
taosSetAllDebugFlag(tsCfg, cfgGetItem(tsCfg, "debugFlag")->i32);
|
taosSetAllDebugFlag(tsCfg, cfgGetItem(tsCfg, "debugFlag")->i32);
|
||||||
|
|
||||||
cfgDumpCfg(tsCfg, tsc, false);
|
if(isDumpCfg) cfgDumpCfg(tsCfg, tsc, false);
|
||||||
|
|
||||||
if (taosCheckGlobalCfg() != 0) {
|
if (taosCheckGlobalCfg() != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -228,6 +228,8 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
||||||
blockDataEnsureCapacity(pBlock, cfgGetSize(pConf));
|
blockDataEnsureCapacity(pBlock, cfgGetSize(pConf));
|
||||||
SConfigIter* pIter = cfgCreateIter(pConf);
|
SConfigIter* pIter = cfgCreateIter(pConf);
|
||||||
|
|
||||||
|
cfgLock(pConf);
|
||||||
|
|
||||||
while ((pItem = cfgNextIter(pIter)) != NULL) {
|
while ((pItem = cfgNextIter(pIter)) != NULL) {
|
||||||
col = startCol;
|
col = startCol;
|
||||||
|
|
||||||
|
@ -253,6 +255,8 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfgUnLock(pConf);
|
||||||
|
|
||||||
pBlock->info.rows = numOfRows;
|
pBlock->info.rows = numOfRows;
|
||||||
|
|
||||||
cfgDestroyIter(pIter);
|
cfgDestroyIter(pIter);
|
||||||
|
|
|
@ -205,11 +205,11 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
||||||
if(i < argc - 1) {
|
if(i < argc - 1) {
|
||||||
int32_t len = strlen(argv[++i]);
|
int32_t len = strlen(argv[++i]);
|
||||||
if (len < ENCRYPT_KEY_LEN_MIN) {
|
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);
|
printf("Error: Encrypt key should be at least %d characters\n", ENCRYPT_KEY_LEN_MIN);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (len > ENCRYPT_KEY_LEN) {
|
if (len > ENCRYPT_KEY_LEN) {
|
||||||
printf("encrypt key overflow, it should be less or equal to %d\n", ENCRYPT_KEY_LEN);
|
printf("Error: Encrypt key overflow, it should be at most %d characters\n", ENCRYPT_KEY_LEN);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tstrncpy(global.encryptKey, argv[i], ENCRYPT_KEY_LEN);
|
tstrncpy(global.encryptKey, argv[i], ENCRYPT_KEY_LEN);
|
||||||
|
@ -325,7 +325,7 @@ int main(int argc, char const *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmParseArgs(argc, argv) != 0) {
|
if (dmParseArgs(argc, argv) != 0) {
|
||||||
printf("failed to start since parse args error\n");
|
//printf("failed to start since parse args error\n");
|
||||||
taosCleanupArgs();
|
taosCleanupArgs();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,11 @@ int mainWindows(int argc, char **argv) {
|
||||||
|
|
||||||
dmPrintArgs(argc, argv);
|
dmPrintArgs(argc, argv);
|
||||||
|
|
||||||
if (taosInitCfg(configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0) != 0) {
|
bool isDumpCfg = true;
|
||||||
|
if(global.generateCode) {
|
||||||
|
isDumpCfg = false;
|
||||||
|
}
|
||||||
|
if (taosInitCfg(configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0, isDumpCfg) != 0) {
|
||||||
dError("failed to start since read config error");
|
dError("failed to start since read config error");
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
taosCleanupArgs();
|
taosCleanupArgs();
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
#include "audit.h"
|
#include "audit.h"
|
||||||
#include "libs/function/tudf.h"
|
#include "libs/function/tudf.h"
|
||||||
|
#include "tgrant.h"
|
||||||
|
|
||||||
#define DM_INIT_AUDIT() \
|
#define DM_INIT_AUDIT() \
|
||||||
do { \
|
do { \
|
||||||
|
@ -150,6 +151,7 @@ static bool dmCheckDataDirVersion() {
|
||||||
|
|
||||||
extern int32_t s3Begin();
|
extern int32_t s3Begin();
|
||||||
extern void s3End();
|
extern void s3End();
|
||||||
|
extern int8_t tsS3Enabled;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,10 @@
|
||||||
#include "dmNodes.h"
|
#include "dmNodes.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
#include "qworker.h"
|
#include "qworker.h"
|
||||||
#include "tstream.h"
|
|
||||||
#ifdef TD_TSZ
|
|
||||||
#include "tcompression.h"
|
#include "tcompression.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tgrant.h"
|
#include "tgrant.h"
|
||||||
#endif
|
#include "tstream.h"
|
||||||
|
|
||||||
static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
||||||
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
||||||
|
@ -48,10 +46,8 @@ int32_t dmInitDnode(SDnode *pDnode) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TD_TSZ
|
|
||||||
// compress module init
|
// compress module init
|
||||||
tsCompressInit(tsLossyColumns, tsFPrecision, tsDPrecision, tsMaxRange, tsCurRange, (int)tsIfAdtFse, tsCompressor);
|
tsCompressInit(tsLossyColumns, tsFPrecision, tsDPrecision, tsMaxRange, tsCurRange, (int)tsIfAdtFse, tsCompressor);
|
||||||
#endif
|
|
||||||
|
|
||||||
pDnode->wrappers[DNODE].func = dmGetMgmtFunc();
|
pDnode->wrappers[DNODE].func = dmGetMgmtFunc();
|
||||||
pDnode->wrappers[MNODE].func = mmGetMgmtFunc();
|
pDnode->wrappers[MNODE].func = mmGetMgmtFunc();
|
||||||
|
@ -88,7 +84,7 @@ int32_t dmInitDnode(SDnode *pDnode) {
|
||||||
streamMetaInit();
|
streamMetaInit();
|
||||||
|
|
||||||
dmInitStatusClient(pDnode);
|
dmInitStatusClient(pDnode);
|
||||||
dmInitSyncClient(pDnode);
|
dmInitSyncClient(pDnode);
|
||||||
|
|
||||||
dmReportStartup("dnode-transport", "initialized");
|
dmReportStartup("dnode-transport", "initialized");
|
||||||
dDebug("dnode is created, ptr:%p", pDnode);
|
dDebug("dnode is created, ptr:%p", pDnode);
|
||||||
|
@ -120,10 +116,8 @@ void dmCleanupDnode(SDnode *pDnode) {
|
||||||
indexCleanup();
|
indexCleanup();
|
||||||
taosConvDestroy();
|
taosConvDestroy();
|
||||||
|
|
||||||
#ifdef TD_TSZ
|
|
||||||
// compress destroy
|
// compress destroy
|
||||||
tsCompressExit();
|
tsCompressExit();
|
||||||
#endif
|
|
||||||
|
|
||||||
dDebug("dnode is closed, ptr:%p", pDnode);
|
dDebug("dnode is closed, ptr:%p", pDnode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -821,6 +821,10 @@ static int32_t mndCheckDbEncryptKey(SMnode *pMnode, SCreateDbReq *pReq) {
|
||||||
|
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
if (pReq->encryptAlgorithm == TSDB_ENCRYPT_ALGO_NONE) goto _exit;
|
if (pReq->encryptAlgorithm == TSDB_ENCRYPT_ALGO_NONE) goto _exit;
|
||||||
|
if (grantCheck(TSDB_GRANT_DB_ENCRYPTION) != 0) {
|
||||||
|
code = TSDB_CODE_MND_DB_ENCRYPT_GRANT_EXPIRED;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
if (tsEncryptionKeyStat != ENCRYPT_KEY_STAT_LOADED) {
|
if (tsEncryptionKeyStat != ENCRYPT_KEY_STAT_LOADED) {
|
||||||
code = TSDB_CODE_MND_INVALID_ENCRYPT_KEY;
|
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,
|
mError("db:%s, failed to check encryption key:%" PRIi8 " in mnode leader since it's not loaded", pReq->db,
|
||||||
|
@ -903,6 +907,13 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (createReq.replications == 2) {
|
||||||
|
if ((terrno = grantCheck(TSDB_GRANT_DUAL_REPLICA_HA)) != 0) {
|
||||||
|
code = terrno;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((code = mndCheckDbEncryptKey(pMnode, &createReq)) != 0) {
|
if ((code = mndCheckDbEncryptKey(pMnode, &createReq)) != 0) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -1163,6 +1174,12 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alterReq.replications == 2) {
|
||||||
|
if ((code = grantCheck(TSDB_GRANT_DUAL_REPLICA_HA)) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t numOfTopics = 0;
|
int32_t numOfTopics = 0;
|
||||||
if (mndGetNumOfTopics(pMnode, pDb->name, &numOfTopics) != 0) {
|
if (mndGetNumOfTopics(pMnode, pDb->name, &numOfTopics) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
|
|
@ -120,12 +120,32 @@ static FORCE_INLINE int64_t tsdbLogicToFileSize(int64_t lSize, int32_t szPage) {
|
||||||
#define tsdbRowFromBlockData(BLOCKDATA, IROW) \
|
#define tsdbRowFromBlockData(BLOCKDATA, IROW) \
|
||||||
((TSDBROW){.type = TSDBROW_COL_FMT, .pBlockData = (BLOCKDATA), .iRow = (IROW)})
|
((TSDBROW){.type = TSDBROW_COL_FMT, .pBlockData = (BLOCKDATA), .iRow = (IROW)})
|
||||||
|
|
||||||
|
#define TSDBROW_INIT_KEY(_ROW, _KEY) \
|
||||||
|
{ \
|
||||||
|
if ((_ROW)->type == TSDBROW_ROW_FMT) { \
|
||||||
|
_KEY.version = (_ROW)->version; \
|
||||||
|
_KEY.ts = (_ROW)->pTSRow->ts; \
|
||||||
|
} else { \
|
||||||
|
_KEY.version = (_ROW)->pBlockData->aVersion[(_ROW)->iRow]; \
|
||||||
|
_KEY.ts = (_ROW)->pBlockData->aTSKEY[(_ROW)->iRow]; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define tColRowGetKey(_pBlock, _irow, _key) \
|
||||||
|
{ \
|
||||||
|
(_key)->ts = (_pBlock)->aTSKEY[(_irow)]; \
|
||||||
|
(_key)->numOfPKs = 0; \
|
||||||
|
if ((_pBlock)->nColData > 0) { \
|
||||||
|
tColRowGetPrimaryKey((_pBlock), (_irow), (_key)); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
|
void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
|
||||||
int32_t tsdbRowCompare(const void *p1, const void *p2);
|
int32_t tsdbRowCompare(const void *p1, const void *p2);
|
||||||
int32_t tsdbRowCompareWithoutVersion(const void *p1, const void *p2);
|
int32_t tsdbRowCompareWithoutVersion(const void *p1, const void *p2);
|
||||||
int32_t tsdbRowKeyCmpr(const STsdbRowKey *key1, const STsdbRowKey *key2);
|
int32_t tsdbRowKeyCmpr(const STsdbRowKey *key1, const STsdbRowKey *key2);
|
||||||
void tsdbRowGetKey(TSDBROW *row, STsdbRowKey *key);
|
void tsdbRowGetKey(TSDBROW *row, STsdbRowKey *key);
|
||||||
void tColRowGetKey(SBlockData *pBlock, int32_t irow, SRowKey *key);
|
void tColRowGetPrimaryKey(SBlockData *pBlock, int32_t irow, SRowKey *key);
|
||||||
|
|
||||||
|
|
||||||
// STSDBRowIter
|
// STSDBRowIter
|
||||||
|
@ -946,7 +966,28 @@ static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
|
||||||
// #define SL_NODE_FORWARD(n, l) ((n)->forwards[l])
|
// #define SL_NODE_FORWARD(n, l) ((n)->forwards[l])
|
||||||
// #define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)])
|
// #define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)])
|
||||||
|
|
||||||
TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter);
|
static FORCE_INLINE TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) {
|
||||||
|
if (pIter == NULL) return NULL;
|
||||||
|
|
||||||
|
if (pIter->pRow) {
|
||||||
|
return pIter->pRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pIter->backward) {
|
||||||
|
if (pIter->pNode == pIter->pTbData->sl.pHead) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (pIter->pNode == pIter->pTbData->sl.pTail) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter->pRow = &pIter->row;
|
||||||
|
pIter->row = pIter->pNode->row;
|
||||||
|
|
||||||
|
return pIter->pRow;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t suid;
|
int64_t suid;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "tsdbDataFileRW.h"
|
#include "tsdbDataFileRW.h"
|
||||||
|
#include "tsdbIter.h"
|
||||||
#include "tsdbReadUtil.h"
|
#include "tsdbReadUtil.h"
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
|
||||||
|
@ -359,7 +360,10 @@ static int32_t tsdbCacheDeserializeV0(char const *value, SLastCol *pLastCol) {
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
|
||||||
pLastCol->colVal.value.nData = pLastColV0->colVal.value.nData;
|
pLastCol->colVal.value.nData = pLastColV0->colVal.value.nData;
|
||||||
pLastCol->colVal.value.pData = (uint8_t *)(&pLastColV0[1]);
|
pLastCol->colVal.value.pData = NULL;
|
||||||
|
if (pLastCol->colVal.value.nData > 0) {
|
||||||
|
pLastCol->colVal.value.pData = (uint8_t *)(&pLastColV0[1]);
|
||||||
|
}
|
||||||
return sizeof(SLastColV0) + pLastColV0->colVal.value.nData;
|
return sizeof(SLastColV0) + pLastColV0->colVal.value.nData;
|
||||||
} else {
|
} else {
|
||||||
pLastCol->colVal.value.val = pLastColV0->colVal.value.val;
|
pLastCol->colVal.value.val = pLastColV0->colVal.value.val;
|
||||||
|
@ -401,8 +405,11 @@ static SLastCol *tsdbCacheDeserialize(char const *value, size_t size) {
|
||||||
offset += sizeof(SValue);
|
offset += sizeof(SValue);
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pLastCol->rowKey.pks[i].type)) {
|
if (IS_VAR_DATA_TYPE(pLastCol->rowKey.pks[i].type)) {
|
||||||
pLastCol->rowKey.pks[i].pData = (uint8_t *)value + offset;
|
pLastCol->rowKey.pks[i].pData = NULL;
|
||||||
offset += pLastCol->rowKey.pks[i].nData;
|
if (pLastCol->rowKey.pks[i].nData > 0) {
|
||||||
|
pLastCol->rowKey.pks[i].pData = (uint8_t *)value + offset;
|
||||||
|
offset += pLastCol->rowKey.pks[i].nData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -940,10 +947,37 @@ typedef struct {
|
||||||
SLastKey key;
|
SLastKey key;
|
||||||
} SIdxKey;
|
} SIdxKey;
|
||||||
|
|
||||||
static void tsdbCacheUpdateLastCol(SLastCol *pLastCol, SRowKey *pRowKey, SColVal *pColVal) {
|
static int32_t tsdbCacheUpdateValue(SValue *pOld, SValue *pNew) {
|
||||||
uint8_t *pVal = NULL;
|
uint8_t *pFree = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(pOld->type)) {
|
||||||
|
pFree = pOld->pData;
|
||||||
|
nData = pOld->nData;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pOld = *pNew;
|
||||||
|
if (IS_VAR_DATA_TYPE(pNew->type)) {
|
||||||
|
if (nData < pNew->nData) {
|
||||||
|
pOld->pData = taosMemoryCalloc(1, pNew->nData);
|
||||||
|
} else {
|
||||||
|
pOld->pData = pFree;
|
||||||
|
pFree = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pNew->nData) {
|
||||||
|
memcpy(pOld->pData, pNew->pData, pNew->nData);
|
||||||
|
} else {
|
||||||
|
pFree = pOld->pData;
|
||||||
|
pOld->pData = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(pFree);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tsdbCacheUpdateLastCol(SLastCol *pLastCol, SRowKey *pRowKey, SColVal *pColVal) {
|
||||||
// update rowkey
|
// update rowkey
|
||||||
pLastCol->rowKey.ts = pRowKey->ts;
|
pLastCol->rowKey.ts = pRowKey->ts;
|
||||||
pLastCol->rowKey.numOfPKs = pRowKey->numOfPKs;
|
pLastCol->rowKey.numOfPKs = pRowKey->numOfPKs;
|
||||||
|
@ -951,41 +985,13 @@ static void tsdbCacheUpdateLastCol(SLastCol *pLastCol, SRowKey *pRowKey, SColVal
|
||||||
SValue *pPKValue = &pLastCol->rowKey.pks[i];
|
SValue *pPKValue = &pLastCol->rowKey.pks[i];
|
||||||
SValue *pNewPKValue = &pRowKey->pks[i];
|
SValue *pNewPKValue = &pRowKey->pks[i];
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pPKValue->type)) {
|
(void)tsdbCacheUpdateValue(pPKValue, pNewPKValue);
|
||||||
pVal = pPKValue->pData;
|
|
||||||
nData = pPKValue->nData;
|
|
||||||
}
|
|
||||||
*pPKValue = *pNewPKValue;
|
|
||||||
if (IS_VAR_DATA_TYPE(pPKValue->type)) {
|
|
||||||
if (nData < pPKValue->nData) {
|
|
||||||
taosMemoryFree(pVal);
|
|
||||||
pPKValue->pData = taosMemoryCalloc(1, pNewPKValue->nData);
|
|
||||||
} else {
|
|
||||||
pPKValue->pData = pVal;
|
|
||||||
}
|
|
||||||
if (pNewPKValue->nData) {
|
|
||||||
memcpy(pPKValue->pData, pNewPKValue->pData, pNewPKValue->nData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update colval
|
// update colval
|
||||||
if (IS_VAR_DATA_TYPE(pColVal->value.type)) {
|
pLastCol->colVal.cid = pColVal->cid;
|
||||||
nData = pLastCol->colVal.value.nData;
|
pLastCol->colVal.flag = pColVal->flag;
|
||||||
pVal = pLastCol->colVal.value.pData;
|
(void)tsdbCacheUpdateValue(&pLastCol->colVal.value, &pColVal->value);
|
||||||
}
|
|
||||||
pLastCol->colVal = *pColVal;
|
|
||||||
if (IS_VAR_DATA_TYPE(pColVal->value.type)) {
|
|
||||||
if (nData < pColVal->value.nData) {
|
|
||||||
taosMemoryFree(pVal);
|
|
||||||
pLastCol->colVal.value.pData = taosMemoryCalloc(1, pColVal->value.nData);
|
|
||||||
} else {
|
|
||||||
pLastCol->colVal.value.pData = pVal;
|
|
||||||
}
|
|
||||||
if (pColVal->value.nData) {
|
|
||||||
memcpy(pLastCol->colVal.value.pData, pColVal->value.pData, pColVal->value.nData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pLastCol->dirty) {
|
if (!pLastCol->dirty) {
|
||||||
pLastCol->dirty = 1;
|
pLastCol->dirty = 1;
|
||||||
|
|
|
@ -806,26 +806,3 @@ SArray *tsdbMemTableGetTbDataArray(SMemTable *pMemTable) {
|
||||||
_exit:
|
_exit:
|
||||||
return aTbDataP;
|
return aTbDataP;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) {
|
|
||||||
if (pIter == NULL) return NULL;
|
|
||||||
|
|
||||||
if (pIter->pRow) {
|
|
||||||
return pIter->pRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pIter->backward) {
|
|
||||||
if (pIter->pNode == pIter->pTbData->sl.pHead) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (pIter->pNode == pIter->pTbData->sl.pTail) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pIter->pRow = &pIter->row;
|
|
||||||
pIter->row = pIter->pNode->row;
|
|
||||||
|
|
||||||
return pIter->pRow;
|
|
||||||
}
|
|
||||||
|
|
|
@ -828,7 +828,7 @@ static FORCE_INLINE int32_t tLDataIterCmprFn(const SRBTreeNode *p1, const SRBTre
|
||||||
SLDataIter *pIter1 = (SLDataIter *)(((uint8_t *)p1) - offsetof(SLDataIter, node));
|
SLDataIter *pIter1 = (SLDataIter *)(((uint8_t *)p1) - offsetof(SLDataIter, node));
|
||||||
SLDataIter *pIter2 = (SLDataIter *)(((uint8_t *)p2) - offsetof(SLDataIter, node));
|
SLDataIter *pIter2 = (SLDataIter *)(((uint8_t *)p2) - offsetof(SLDataIter, node));
|
||||||
|
|
||||||
SRowKey rkey1, rkey2;
|
SRowKey rkey1 = {0}, rkey2 = {0};
|
||||||
tRowGetKeyEx(&pIter1->rInfo.row, &rkey1);
|
tRowGetKeyEx(&pIter1->rInfo.row, &rkey1);
|
||||||
tRowGetKeyEx(&pIter2->rInfo.row, &rkey2);
|
tRowGetKeyEx(&pIter2->rInfo.row, &rkey2);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,16 @@
|
||||||
|
|
||||||
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
|
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
|
||||||
#define getCurrentKeyInSttBlock(_r) (&((_r)->currentKey))
|
#define getCurrentKeyInSttBlock(_r) (&((_r)->currentKey))
|
||||||
|
#define tColRowGetKeyDeepCopy(_pBlock, _irow, _slotId, _pKey) \
|
||||||
|
do { \
|
||||||
|
(_pKey)->ts = (_pBlock)->aTSKEY[(_irow)]; \
|
||||||
|
(_pKey)->numOfPKs = 0; \
|
||||||
|
if ((_slotId) != -1) { \
|
||||||
|
tColRowGetPriamyKeyDeepCopy(_pBlock, _irow, _slotId, _pKey); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define outOfTimeWindow(_ts, _window) (((_ts) > (_window)->ekey) || ((_ts) < (_window)->skey))
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool overlapWithNeighborBlock;
|
bool overlapWithNeighborBlock;
|
||||||
|
@ -75,11 +85,9 @@ static void getMemTableTimeRange(STsdbReader* pReader, int64_t* pMaxKey
|
||||||
static void updateComposedBlockInfo(STsdbReader* pReader, double el, STableBlockScanInfo* pBlockScanInfo);
|
static void updateComposedBlockInfo(STsdbReader* pReader, double el, STableBlockScanInfo* pBlockScanInfo);
|
||||||
static int32_t buildFromPreFilesetBuffer(STsdbReader* pReader);
|
static int32_t buildFromPreFilesetBuffer(STsdbReader* pReader);
|
||||||
|
|
||||||
static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); }
|
|
||||||
|
|
||||||
static void resetPreFilesetMemTableListIndex(SReaderStatus* pStatus);
|
static void resetPreFilesetMemTableListIndex(SReaderStatus* pStatus);
|
||||||
|
|
||||||
int32_t pkCompEx(SRowKey* p1, SRowKey* p2) {
|
FORCE_INLINE int32_t pkCompEx(SRowKey* p1, SRowKey* p2) {
|
||||||
if (p2 == NULL) {
|
if (p2 == NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -101,13 +109,7 @@ int32_t pkCompEx(SRowKey* p1, SRowKey* p2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tColRowGetKeyDeepCopy(SBlockData* pBlock, int32_t irow, int32_t slotId, SRowKey* pKey) {
|
static void tColRowGetPriamyKeyDeepCopy(SBlockData* pBlock, int32_t irow, int32_t slotId, SRowKey* pKey) {
|
||||||
pKey->ts = pBlock->aTSKEY[irow];
|
|
||||||
if (slotId == -1) {
|
|
||||||
pKey->numOfPKs = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SColData* pColData = &pBlock->aColData[slotId];
|
SColData* pColData = &pBlock->aColData[slotId];
|
||||||
SColVal cv;
|
SColVal cv;
|
||||||
tColDataGetValue(pColData, irow, &cv);
|
tColDataGetValue(pColData, irow, &cv);
|
||||||
|
@ -131,13 +133,7 @@ static int32_t tGetPrimaryKeyIndex(uint8_t *p, SPrimaryKeyIndex *index) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tRowGetKeyDeepCopy(SRow* pRow, SRowKey* pKey) {
|
static void tRowGetPrimaryKeyDeepCopy(SRow* pRow, SRowKey* pKey) {
|
||||||
pKey->ts = pRow->ts;
|
|
||||||
pKey->numOfPKs = pRow->numOfPKs;
|
|
||||||
if (pKey->numOfPKs == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SPrimaryKeyIndex indices[TD_MAX_PK_COLS];
|
SPrimaryKeyIndex indices[TD_MAX_PK_COLS];
|
||||||
ASSERT(pKey->numOfPKs <= TD_MAX_PK_COLS);
|
ASSERT(pKey->numOfPKs <= TD_MAX_PK_COLS);
|
||||||
|
|
||||||
|
@ -1735,7 +1731,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
|
||||||
pSttKey = getCurrentKeyInSttBlock(pSttBlockReader);
|
pSttKey = getCurrentKeyInSttBlock(pSttBlockReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
SRowKey k;
|
SRowKey k = {0};
|
||||||
tRowGetKeyEx(pRow, &k);
|
tRowGetKeyEx(pRow, &k);
|
||||||
|
|
||||||
STSchema* pSchema = NULL;
|
STSchema* pSchema = NULL;
|
||||||
|
@ -1939,7 +1935,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
|
||||||
pfKey = NULL;
|
pfKey = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRowKey k, ik;
|
SRowKey k = {0}, ik = {0};
|
||||||
tRowGetKeyEx(pRow, &k);
|
tRowGetKeyEx(pRow, &k);
|
||||||
tRowGetKeyEx(piRow, &ik);
|
tRowGetKeyEx(piRow, &ik);
|
||||||
|
|
||||||
|
@ -2086,7 +2082,7 @@ int32_t doInitMemDataIter(STsdbReader* pReader, STbData** pData, STableBlockScan
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doForwardDataIter(SRowKey* pKey, SIterInfo* pIter, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader) {
|
static void doForwardDataIter(SRowKey* pKey, SIterInfo* pIter, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader) {
|
||||||
SRowKey rowKey;
|
SRowKey rowKey = {0};
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
TSDBROW* pRow = getValidMemRow(pIter, pBlockScanInfo->delSkyline, pReader);
|
TSDBROW* pRow = getValidMemRow(pIter, pBlockScanInfo->delSkyline, pReader);
|
||||||
|
@ -3559,7 +3555,7 @@ bool hasBeenDropped(const SArray* pDelList, int32_t* index, int64_t key, int64_t
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSDBROW* getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader) {
|
FORCE_INLINE TSDBROW* getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader) {
|
||||||
if (!pIter->hasVal) {
|
if (!pIter->hasVal) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -3567,7 +3563,8 @@ TSDBROW* getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* p
|
||||||
int32_t order = pReader->info.order;
|
int32_t order = pReader->info.order;
|
||||||
TSDBROW* pRow = tsdbTbDataIterGet(pIter->iter);
|
TSDBROW* pRow = tsdbTbDataIterGet(pIter->iter);
|
||||||
|
|
||||||
TSDBKEY key = TSDBROW_KEY(pRow);
|
TSDBKEY key;
|
||||||
|
TSDBROW_INIT_KEY(pRow, key);
|
||||||
if (outOfTimeWindow(key.ts, &pReader->info.window)) {
|
if (outOfTimeWindow(key.ts, &pReader->info.window)) {
|
||||||
pIter->hasVal = false;
|
pIter->hasVal = false;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -3593,7 +3590,7 @@ TSDBROW* getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* p
|
||||||
|
|
||||||
pRow = tsdbTbDataIterGet(pIter->iter);
|
pRow = tsdbTbDataIterGet(pIter->iter);
|
||||||
|
|
||||||
key = TSDBROW_KEY(pRow);
|
TSDBROW_INIT_KEY(pRow, key);
|
||||||
if (outOfTimeWindow(key.ts, &pReader->info.window)) {
|
if (outOfTimeWindow(key.ts, &pReader->info.window)) {
|
||||||
pIter->hasVal = false;
|
pIter->hasVal = false;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -3632,10 +3629,12 @@ int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, SRowKey *pCurKey, SArra
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRowKey nextKey = {0};
|
if (pCurKey->numOfPKs > 0) {
|
||||||
tRowGetKeyEx(pRow, &nextKey);
|
SRowKey nextKey = {0};
|
||||||
if (pkCompEx(pCurKey, &nextKey) != 0) {
|
tRowGetKeyEx(pRow, &nextKey);
|
||||||
break;
|
if (pkCompEx(pCurKey, &nextKey) != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STSchema* pTSchema = NULL;
|
STSchema* pTSchema = NULL;
|
||||||
|
@ -3785,12 +3784,14 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, SRowKey* pKey, uint64_t uid, SIt
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRowKey nextRowKey = {0};
|
if (pKey->numOfPKs > 0) {
|
||||||
tRowGetKeyEx(pNextRow, &nextRowKey);
|
SRowKey nextRowKey = {0};
|
||||||
if (pKey->numOfPKs > 0 && pkCompEx(pKey, &nextRowKey) != 0) {
|
tRowGetKeyEx(pNextRow, &nextRowKey);
|
||||||
*pResRow = current;
|
if (pkCompEx(pKey, &nextRowKey) != 0) {
|
||||||
*freeTSRow = false;
|
*pResRow = current;
|
||||||
return TSDB_CODE_SUCCESS;
|
*freeTSRow = false;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3801,7 +3802,7 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, SRowKey* pKey, uint64_t uid, SIt
|
||||||
// start to merge duplicated rows
|
// start to merge duplicated rows
|
||||||
STSchema* pTSchema = NULL;
|
STSchema* pTSchema = NULL;
|
||||||
if (current.type == TSDBROW_ROW_FMT) { // get the correct schema for row-wise data in memory
|
if (current.type == TSDBROW_ROW_FMT) { // get the correct schema for row-wise data in memory
|
||||||
pTSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(¤t), pReader, uid);
|
pTSchema = doGetSchemaForTSRow(current.pTSRow->sver, pReader, uid);
|
||||||
if (pTSchema == NULL) {
|
if (pTSchema == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -3814,7 +3815,7 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, SRowKey* pKey, uint64_t uid, SIt
|
||||||
|
|
||||||
STSchema* pTSchema1 = NULL;
|
STSchema* pTSchema1 = NULL;
|
||||||
if (pNextRow->type == TSDBROW_ROW_FMT) { // get the correct schema for row-wise data in memory
|
if (pNextRow->type == TSDBROW_ROW_FMT) { // get the correct schema for row-wise data in memory
|
||||||
pTSchema1 = doGetSchemaForTSRow(TSDBROW_SVERSION(pNextRow), pReader, uid);
|
pTSchema1 = doGetSchemaForTSRow(pNextRow->pTSRow->sver, pReader, uid);
|
||||||
if (pTSchema1 == NULL) {
|
if (pTSchema1 == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -3926,37 +3927,49 @@ static int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
||||||
// todo refactor
|
// todo refactor
|
||||||
bool asc = ASCENDING_TRAVERSE(pReader->info.order);
|
bool asc = ASCENDING_TRAVERSE(pReader->info.order);
|
||||||
if (piter->hasVal) {
|
if (piter->hasVal) {
|
||||||
TSDBKEY k = TSDBROW_KEY(pRow);
|
tRowGetKeyEx(pRow, &rowKey);
|
||||||
if ((k.ts >= endKey && asc) || (k.ts <= endKey && !asc)) {
|
if ((rowKey.ts >= endKey && asc) || (rowKey.ts <= endKey && !asc)) {
|
||||||
pRow = NULL;
|
pRow = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (piiter->hasVal) {
|
if (piiter->hasVal) {
|
||||||
TSDBKEY k = TSDBROW_KEY(piRow);
|
tRowGetKeyEx(piRow, &irowKey);
|
||||||
if ((k.ts >= endKey && asc) || (k.ts <= endKey && !asc)) {
|
if ((irowKey.ts >= endKey && asc) || (irowKey.ts <= endKey && !asc)) {
|
||||||
piRow = NULL;
|
piRow = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (piter->hasVal && piiter->hasVal && pRow != NULL && piRow != NULL) {
|
if (pRow != NULL && piRow != NULL) {
|
||||||
tRowGetKeyEx(pRow, &rowKey);
|
|
||||||
tRowGetKeyEx(piRow, &irowKey);
|
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t ret = pkCompEx(&rowKey, &irowKey);
|
if (rowKey.numOfPKs == 0) {
|
||||||
if (ret != 0) {
|
if ((rowKey.ts > irowKey.ts && asc) || (rowKey.ts < irowKey.ts && (!asc))) { // ik.ts < k.ts
|
||||||
if ((ret > 0 && asc) || (ret < 0 && (!asc))) { // ik.ts < k.ts
|
|
||||||
code = doMergeMemTableMultiRows(piRow, &irowKey, uid, piiter, pDelList, pResRow, pReader, freeTSRow);
|
code = doMergeMemTableMultiRows(piRow, &irowKey, uid, piiter, pDelList, pResRow, pReader, freeTSRow);
|
||||||
} else if ((ret < 0 && asc) || (ret > 0 && (!asc))) {
|
} else if ((rowKey.ts < irowKey.ts && asc) || (rowKey.ts > irowKey.ts && (!asc))) {
|
||||||
code = doMergeMemTableMultiRows(pRow, &rowKey, uid, piter, pDelList, pResRow, pReader, freeTSRow);
|
code = doMergeMemTableMultiRows(pRow, &rowKey, uid, piter, pDelList, pResRow, pReader, freeTSRow);
|
||||||
|
} else { // ik.ts == k.ts
|
||||||
|
*freeTSRow = true;
|
||||||
|
pResRow->type = TSDBROW_ROW_FMT;
|
||||||
|
code = doMergeMemIMemRows(pRow, &rowKey, piRow, &irowKey, pBlockScanInfo, pReader, &pResRow->pTSRow);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else { // ik.ts == k.ts
|
} else {
|
||||||
*freeTSRow = true;
|
int32_t ret = pkCompEx(&rowKey, &irowKey);
|
||||||
pResRow->type = TSDBROW_ROW_FMT;
|
if (ret != 0) {
|
||||||
code = doMergeMemIMemRows(pRow, &rowKey, piRow, &irowKey, pBlockScanInfo, pReader, &pResRow->pTSRow);
|
if ((ret > 0 && asc) || (ret < 0 && (!asc))) { // ik.ts < k.ts
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
code = doMergeMemTableMultiRows(piRow, &irowKey, uid, piiter, pDelList, pResRow, pReader, freeTSRow);
|
||||||
return code;
|
} else if ((ret < 0 && asc) || (ret > 0 && (!asc))) {
|
||||||
|
code = doMergeMemTableMultiRows(pRow, &rowKey, uid, piter, pDelList, pResRow, pReader, freeTSRow);
|
||||||
|
}
|
||||||
|
} else { // ik.ts == k.ts
|
||||||
|
*freeTSRow = true;
|
||||||
|
pResRow->type = TSDBROW_ROW_FMT;
|
||||||
|
code = doMergeMemIMemRows(pRow, &rowKey, piRow, &irowKey, pBlockScanInfo, pReader, &pResRow->pTSRow);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3964,12 +3977,10 @@ static int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
||||||
}
|
}
|
||||||
|
|
||||||
if (piter->hasVal && pRow != NULL) {
|
if (piter->hasVal && pRow != NULL) {
|
||||||
tRowGetKeyEx(pRow, &rowKey);
|
|
||||||
return doMergeMemTableMultiRows(pRow, &rowKey, uid, piter, pDelList, pResRow, pReader, freeTSRow);
|
return doMergeMemTableMultiRows(pRow, &rowKey, uid, piter, pDelList, pResRow, pReader, freeTSRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (piiter->hasVal && piRow != NULL) {
|
if (piiter->hasVal && piRow != NULL) {
|
||||||
tRowGetKeyEx(piRow, &irowKey);
|
|
||||||
return doMergeMemTableMultiRows(piRow, &irowKey, uid, piiter, pDelList, pResRow, pReader, freeTSRow);
|
return doMergeMemTableMultiRows(piRow, &irowKey, uid, piiter, pDelList, pResRow, pReader, freeTSRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4095,7 +4106,11 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
|
||||||
if (row.type == TSDBROW_ROW_FMT) {
|
if (row.type == TSDBROW_ROW_FMT) {
|
||||||
code = doAppendRowFromTSRow(pBlock, pReader, row.pTSRow, pBlockScanInfo);
|
code = doAppendRowFromTSRow(pBlock, pReader, row.pTSRow, pBlockScanInfo);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
tRowGetKeyDeepCopy(row.pTSRow, &pBlockScanInfo->lastProcKey);
|
pBlockScanInfo->lastProcKey.ts = row.pTSRow->ts;
|
||||||
|
pBlockScanInfo->lastProcKey.numOfPKs = row.pTSRow->numOfPKs;
|
||||||
|
if (row.pTSRow->numOfPKs > 0) {
|
||||||
|
tRowGetPrimaryKeyDeepCopy(row.pTSRow, &pBlockScanInfo->lastProcKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (freeTSRow) {
|
if (freeTSRow) {
|
||||||
|
|
|
@ -212,7 +212,7 @@ static void initLastProcKey(STableBlockScanInfo *pScanInfo, STsdbReader* pReader
|
||||||
int32_t numOfPks = pReader->suppInfo.numOfPks;
|
int32_t numOfPks = pReader->suppInfo.numOfPks;
|
||||||
bool asc = ASCENDING_TRAVERSE(pReader->info.order);
|
bool asc = ASCENDING_TRAVERSE(pReader->info.order);
|
||||||
int8_t type = pReader->suppInfo.pk.type;
|
int8_t type = pReader->suppInfo.pk.type;
|
||||||
int8_t bytes = pReader->suppInfo.pk.bytes;
|
int32_t bytes = pReader->suppInfo.pk.bytes;
|
||||||
|
|
||||||
SRowKey* pRowKey = &pScanInfo->lastProcKey;
|
SRowKey* pRowKey = &pScanInfo->lastProcKey;
|
||||||
if (asc) {
|
if (asc) {
|
||||||
|
@ -1056,7 +1056,7 @@ static int32_t sortUidComparFn(const void* p1, const void* p2) {
|
||||||
const SSttKeyRange* px1 = p1;
|
const SSttKeyRange* px1 = p1;
|
||||||
const SSttKeyRange* px2 = p2;
|
const SSttKeyRange* px2 = p2;
|
||||||
|
|
||||||
int32_t ret = tRowKeyCompare(&px1, px2);
|
int32_t ret = tRowKeyCompare(&px1->skey, &px2->skey);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,14 +38,20 @@ extern "C" {
|
||||||
(_k)->ekey.ts = INT64_MIN; \
|
(_k)->ekey.ts = INT64_MIN; \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
#define tRowGetKeyEx(_pRow, _pKey) \
|
#define tRowGetKeyEx(_pRow, _pKey) \
|
||||||
do { \
|
{ \
|
||||||
if ((_pRow)->type == TSDBROW_ROW_FMT) { \
|
if ((_pRow)->type == TSDBROW_ROW_FMT) { \
|
||||||
tRowGetKey((_pRow)->pTSRow, (_pKey)); \
|
(_pKey)->ts = (_pRow)->pTSRow->ts; \
|
||||||
} else { \
|
if ((_pRow)->pTSRow->numOfPKs > 0) { \
|
||||||
tColRowGetKey((_pRow)->pBlockData, (_pRow)->iRow, (_pKey)); \
|
tRowGetPrimaryKey((_pRow)->pTSRow, (_pKey)); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} else { \
|
||||||
|
(_pKey)->ts = (_pRow)->pBlockData->aTSKEY[(_pRow)->iRow]; \
|
||||||
|
if ((_pRow)->pBlockData->nColData > 0) { \
|
||||||
|
tColRowGetPrimaryKey((_pRow)->pBlockData, (_pRow)->iRow, (_pKey)); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
READER_STATUS_SUSPEND = 0x1,
|
READER_STATUS_SUSPEND = 0x1,
|
||||||
|
|
|
@ -757,6 +757,16 @@ _exit:
|
||||||
int32_t tsdbS3Migrate(STsdb *tsdb, int64_t now, int32_t sync) {
|
int32_t tsdbS3Migrate(STsdb *tsdb, int64_t now, int32_t sync) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
extern int8_t tsS3EnabledCfg;
|
||||||
|
|
||||||
|
int32_t expired = grantCheck(TSDB_GRANT_OBJECT_STORAGE);
|
||||||
|
if (expired && tsS3Enabled) {
|
||||||
|
tsdbWarn("s3 grant expired: %d", expired);
|
||||||
|
tsS3Enabled = false;
|
||||||
|
} else if (!expired && tsS3EnabledCfg) {
|
||||||
|
tsS3Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!tsS3Enabled) {
|
if (!tsS3Enabled) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -628,10 +628,7 @@ void tsdbRowGetKey(TSDBROW *row, STsdbRowKey *key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tColRowGetKey(SBlockData *pBlock, int32_t irow, SRowKey *key) {
|
void tColRowGetPrimaryKey(SBlockData *pBlock, int32_t irow, SRowKey *key) {
|
||||||
key->ts = pBlock->aTSKEY[irow];
|
|
||||||
key->numOfPKs = 0;
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pBlock->nColData; i++) {
|
for (int32_t i = 0; i < pBlock->nColData; i++) {
|
||||||
SColData *pColData = &pBlock->aColData[i];
|
SColData *pColData = &pBlock->aColData[i];
|
||||||
if (pColData->cflag & COL_IS_KEY) {
|
if (pColData->cflag & COL_IS_KEY) {
|
||||||
|
|
|
@ -3226,14 +3226,24 @@ int32_t ctgGetTbTSMAFromCache(SCatalog* pCtg, SCtgTbTSMACtx* pCtx, int32_t dbIdx
|
||||||
// get tb cache
|
// get tb cache
|
||||||
pName = taosArrayGet(pList, i);
|
pName = taosArrayGet(pList, i);
|
||||||
pTbCache = taosHashAcquire(dbCache->tbCache, pName->tname, strlen(pName->tname));
|
pTbCache = taosHashAcquire(dbCache->tbCache, pName->tname, strlen(pName->tname));
|
||||||
if (!pTbCache || !pTbCache->pMeta) {
|
if (!pTbCache) {
|
||||||
ctgDebug("tb: %s.%s not in cache", dbFName, pName->tname);
|
ctgDebug("tb: %s.%s not in cache", dbFName, pName->tname);
|
||||||
ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag, FETCH_TSMA_SOURCE_TB_META, NULL);
|
ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag, FETCH_TSMA_SOURCE_TB_META, NULL);
|
||||||
taosArrayPush(pCtx->pResList, &(SMetaRes){0});
|
taosArrayPush(pCtx->pResList, &(SMetaRes){0});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
CTG_LOCK(CTG_READ, &pTbCache->metaLock);
|
||||||
|
if (!pTbCache->pMeta) {
|
||||||
|
CTG_UNLOCK(CTG_READ, &pTbCache->metaLock);
|
||||||
|
ctgDebug("tb: %s.%s not in cache", dbFName, pName->tname);
|
||||||
|
ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag, FETCH_TSMA_SOURCE_TB_META, NULL);
|
||||||
|
taosArrayPush(pCtx->pResList, &(SMetaRes){0});
|
||||||
|
taosHashRelease(dbCache->tbCache, pTbCache);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
uint64_t suid = pTbCache->pMeta->suid;
|
uint64_t suid = pTbCache->pMeta->suid;
|
||||||
int8_t tbType = pTbCache->pMeta->tableType;
|
int8_t tbType = pTbCache->pMeta->tableType;
|
||||||
|
CTG_UNLOCK(CTG_READ, &pTbCache->metaLock);
|
||||||
taosHashRelease(dbCache->tbCache, pTbCache);
|
taosHashRelease(dbCache->tbCache, pTbCache);
|
||||||
SName tsmaSourceTbName = *pName;
|
SName tsmaSourceTbName = *pName;
|
||||||
|
|
||||||
|
|
|
@ -824,14 +824,17 @@ int32_t qKillTask(qTaskInfo_t tinfo, int32_t rspCode) {
|
||||||
qDebug("%s sync killed execTask", GET_TASKID(pTaskInfo));
|
qDebug("%s sync killed execTask", GET_TASKID(pTaskInfo));
|
||||||
setTaskKilled(pTaskInfo, TSDB_CODE_TSC_QUERY_KILLED);
|
setTaskKilled(pTaskInfo, TSDB_CODE_TSC_QUERY_KILLED);
|
||||||
|
|
||||||
taosWLockLatch(&pTaskInfo->lock);
|
while(1) {
|
||||||
while (qTaskIsExecuting(pTaskInfo)) {
|
taosWLockLatch(&pTaskInfo->lock);
|
||||||
taosMsleep(10);
|
if (qTaskIsExecuting(pTaskInfo)) { // let's wait for 100 ms and try again
|
||||||
|
taosWUnLockLatch(&pTaskInfo->lock);
|
||||||
|
taosMsleep(100);
|
||||||
|
} else { // not running now
|
||||||
|
pTaskInfo->code = rspCode;
|
||||||
|
taosWUnLockLatch(&pTaskInfo->lock);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pTaskInfo->code = rspCode;
|
|
||||||
taosWUnLockLatch(&pTaskInfo->lock);
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qTaskIsExecuting(qTaskInfo_t qinfo) {
|
bool qTaskIsExecuting(qTaskInfo_t qinfo) {
|
||||||
|
|
|
@ -1424,7 +1424,7 @@ int main(int argc, char *argv[]) {
|
||||||
printf("failed to start since init log error\n");
|
printf("failed to start since init log error\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 0) != 0) {
|
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 0, true) != 0) {
|
||||||
fnError("failed to start since read config error");
|
fnError("failed to start since read config error");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ int aggregateFuncTest() {
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
parseArgs(argc, argv);
|
parseArgs(argc, argv);
|
||||||
initLog();
|
initLog();
|
||||||
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 0) != 0) {
|
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 0, true) != 0) {
|
||||||
fnError("failed to start since read config error");
|
fnError("failed to start since read config error");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,67 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData) {
|
||||||
|
int ret = 0;
|
||||||
|
char *wktPatternWithSpace = taosMemoryCalloc(4, 1024);
|
||||||
|
sprintf(
|
||||||
|
wktPatternWithSpace,
|
||||||
|
"^( *)point( *)z?m?( *)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *)\\)))|linestring( *)z?m?( "
|
||||||
|
"*)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}(( *)(,)( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))|polygon( *)z?m?( "
|
||||||
|
"*)((empty)|(\\(( *)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}(( *)(,)( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))(( *)(,)( "
|
||||||
|
"*)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}(( *)(,)( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))( *))*( "
|
||||||
|
"*)\\)))|multipoint( *)z?m?( *)((empty)|(\\(( "
|
||||||
|
"*)((([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}|((empty)|(\\(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *)\\))))(( *)(,)( "
|
||||||
|
"*)((([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}|((empty)|(\\(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *)\\))))( *))*( "
|
||||||
|
"*)\\)))|multilinestring( *)z?m?( *)((empty)|(\\(( *)((empty)|(\\(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}(( *)(,)( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))(( *)(,)( "
|
||||||
|
"*)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}(( *)(,)( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))( *))*( "
|
||||||
|
"*)\\)))|multipolygon( *)z?m?( *)((empty)|(\\(( *)((empty)|(\\(( *)((empty)|(\\(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}(( *)(,)( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))(( *)(,)( "
|
||||||
|
"*)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}(( *)(,)( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))( *))*( *)\\)))(( *)(,)( "
|
||||||
|
"*)((empty)|(\\(( *)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}(( *)(,)( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))(( *)(,)( "
|
||||||
|
"*)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}(( *)(,)( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))( *))*( *)\\)))( *))*( "
|
||||||
|
"*)\\)))|(GEOCOLLECTION\\((?R)(( *)(,)( *)(?R))*( *)\\))( *)$");
|
||||||
|
|
||||||
|
ret = doRegComp(ppRegex, ppMatchData, wktPatternWithSpace);
|
||||||
|
taosMemoryFree(wktPatternWithSpace);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t initCtxGeomFromText() {
|
int32_t initCtxGeomFromText() {
|
||||||
int32_t code = TSDB_CODE_FAILED;
|
int32_t code = TSDB_CODE_FAILED;
|
||||||
SGeosContext* geosCtx = getThreadLocalGeosCtx();
|
SGeosContext* geosCtx = getThreadLocalGeosCtx();
|
||||||
|
@ -113,6 +174,10 @@ int32_t initCtxGeomFromText() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (geosCtx->WKTRegex == NULL) {
|
||||||
|
if (initWktRegex(&geosCtx->WKTRegex, &geosCtx->WKTMatchData) != 0) return code;
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +190,11 @@ int32_t doGeomFromText(const char *inputWKT, unsigned char **outputGeom, size_t
|
||||||
GEOSGeometry *geom = NULL;
|
GEOSGeometry *geom = NULL;
|
||||||
unsigned char *wkb = NULL;
|
unsigned char *wkb = NULL;
|
||||||
|
|
||||||
|
if (doRegExec(inputWKT, geosCtx->WKTRegex, geosCtx->WKTMatchData) != 0) {
|
||||||
|
code = TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
geom = GEOSWKTReader_read_r(geosCtx->handle, geosCtx->WKTReader, inputWKT);
|
geom = GEOSWKTReader_read_r(geosCtx->handle, geosCtx->WKTReader, inputWKT);
|
||||||
if (geom == NULL) {
|
if (geom == NULL) {
|
||||||
code = TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
code = TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
||||||
|
|
|
@ -42,7 +42,6 @@ int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placehol
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
|
int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
|
||||||
SAstCreateContext cxt;
|
SAstCreateContext cxt;
|
||||||
initAstCreateContext(pParseCxt, &cxt);
|
initAstCreateContext(pParseCxt, &cxt);
|
||||||
|
@ -534,6 +533,10 @@ static int32_t collectMetaKeyFromShowTables(SCollectMetaKeyCxt* pCxt, SShowStmt*
|
||||||
static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TAGS,
|
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TAGS,
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal,
|
||||||
|
((SValueNode*)pStmt->pTbName)->literal, pCxt->pMetaCache);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
|
code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
|
@ -631,8 +634,8 @@ static int32_t collectMetaKeyFromShowCompacts(SCollectMetaKeyCxt* pCxt, SShowStm
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowCompactDetails(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowCompactDetails(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_COMPACT_DETAILS,
|
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
|
||||||
pCxt->pMetaCache);
|
TSDB_INS_TABLE_COMPACT_DETAILS, pCxt->pMetaCache);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,7 +690,7 @@ static int32_t collectMetaKeyFromShowCreateView(SCollectMetaKeyCxt* pCxt, SShowC
|
||||||
int32_t code = catalogRemoveViewMeta(pCxt->pParseCxt->pCatalog, dbFName, 0, pStmt->viewName, 0);
|
int32_t code = catalogRemoveViewMeta(pCxt->pParseCxt->pCatalog, dbFName, 0, pStmt->viewName, 0);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->viewName,
|
code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->viewName,
|
||||||
AUTH_TYPE_READ, pCxt->pMetaCache);
|
AUTH_TYPE_READ, pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, pCxt->pMetaCache);
|
code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, pCxt->pMetaCache);
|
||||||
|
@ -696,7 +699,6 @@ static int32_t collectMetaKeyFromShowCreateView(SCollectMetaKeyCxt* pCxt, SShowC
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowApps(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowApps(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_APPS,
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_APPS,
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
|
@ -755,24 +757,22 @@ static int32_t collectMetaKeyFromRevoke(SCollectMetaKeyCxt* pCxt, SRevokeStmt* p
|
||||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, pCxt->pMetaCache);
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromCreateViewStmt(SCollectMetaKeyCxt* pCxt, SCreateViewStmt* pStmt) {
|
static int32_t collectMetaKeyFromCreateViewStmt(SCollectMetaKeyCxt* pCxt, SCreateViewStmt* pStmt) {
|
||||||
int32_t code =
|
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, pCxt->pMetaCache);
|
||||||
reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, pCxt->pMetaCache);
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, AUTH_TYPE_WRITE,
|
code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, NULL, AUTH_TYPE_WRITE,
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->viewName, AUTH_TYPE_ALTER,
|
code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->viewName,
|
||||||
pCxt->pMetaCache);
|
AUTH_TYPE_ALTER, pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromDropViewStmt(SCollectMetaKeyCxt* pCxt, SDropViewStmt* pStmt) {
|
static int32_t collectMetaKeyFromDropViewStmt(SCollectMetaKeyCxt* pCxt, SDropViewStmt* pStmt) {
|
||||||
int32_t code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->viewName, AUTH_TYPE_ALTER,
|
int32_t code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName,
|
||||||
pCxt->pMetaCache);
|
pStmt->viewName, AUTH_TYPE_ALTER, pCxt->pMetaCache);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,7 +783,7 @@ static int32_t collectMetaKeyFromCreateTSMAStmt(SCollectMetaKeyCxt* pCxt, SCreat
|
||||||
code = reserveTSMAInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
code = reserveTSMAInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
char dstTbName[TSDB_TABLE_NAME_LEN] = {0};
|
char dstTbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
snprintf(dstTbName, TSDB_TABLE_NAME_LEN, "%s"TSMA_RES_STB_POSTFIX, pStmt->tableName);
|
snprintf(dstTbName, TSDB_TABLE_NAME_LEN, "%s" TSMA_RES_STB_POSTFIX, pStmt->tableName);
|
||||||
code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, dstTbName, pCxt->pMetaCache);
|
code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, dstTbName, pCxt->pMetaCache);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, dstTbName, pCxt->pMetaCache);
|
code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, dstTbName, pCxt->pMetaCache);
|
||||||
|
@ -921,7 +921,7 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
case QUERY_NODE_SHOW_COMPACTS_STMT:
|
case QUERY_NODE_SHOW_COMPACTS_STMT:
|
||||||
return collectMetaKeyFromShowCompacts(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowCompacts(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT:
|
case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT:
|
||||||
return collectMetaKeyFromShowCompactDetails(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowCompactDetails(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
return collectMetaKeyFromShowGrantsFull(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowGrantsFull(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
|
|
|
@ -4338,7 +4338,7 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
|
||||||
}
|
}
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
if (TSDB_VIEW_TABLE == pRealTable->pMeta->tableType) {
|
if (TSDB_VIEW_TABLE == pRealTable->pMeta->tableType && !pCurrSmt->tagScan) {
|
||||||
return translateView(pCxt, pTable, &name);
|
return translateView(pCxt, pTable, &name);
|
||||||
}
|
}
|
||||||
translateAudit(pCxt, pRealTable, &name);
|
translateAudit(pCxt, pRealTable, &name);
|
||||||
|
@ -11867,6 +11867,37 @@ static int32_t rewriteShowVgroups(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkShowTags(STranslateContext* pCxt, const SShowStmt* pShow) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SName name;
|
||||||
|
STableMeta* pTableMeta = NULL;
|
||||||
|
code = getTargetMeta(pCxt,
|
||||||
|
toName(pCxt->pParseCxt->acctId, ((SValueNode*)pShow->pDbName)->literal,
|
||||||
|
((SValueNode*)pShow->pTbName)->literal, &name),
|
||||||
|
&pTableMeta, true);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
if (TSDB_SUPER_TABLE != pTableMeta->tableType && TSDB_CHILD_TABLE != pTableMeta->tableType) {
|
||||||
|
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAGS_PC,
|
||||||
|
"The _TAGS pseudo column can only be used for child table and super table queries");
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
taosMemoryFreeClear(pTableMeta);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t rewriteShowTags(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
|
int32_t code = checkShowTags(pCxt, (SShowStmt*)pQuery->pRoot);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = rewriteShow(pCxt, pQuery);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static SNode* createTagsFunction() {
|
static SNode* createTagsFunction() {
|
||||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
if (NULL == pFunc) {
|
if (NULL == pFunc) {
|
||||||
|
@ -13170,7 +13201,6 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
case QUERY_NODE_SHOW_APPS_STMT:
|
case QUERY_NODE_SHOW_APPS_STMT:
|
||||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
|
||||||
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
||||||
case QUERY_NODE_SHOW_VIEWS_STMT:
|
case QUERY_NODE_SHOW_VIEWS_STMT:
|
||||||
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
|
@ -13181,6 +13211,9 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
case QUERY_NODE_SHOW_TSMAS_STMT:
|
case QUERY_NODE_SHOW_TSMAS_STMT:
|
||||||
code = rewriteShow(pCxt, pQuery);
|
code = rewriteShow(pCxt, pQuery);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
|
code = rewriteShowTags(pCxt, pQuery);
|
||||||
|
break;
|
||||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||||
code = rewriteShowVgroups(pCxt, pQuery);
|
code = rewriteShowVgroups(pCxt, pQuery);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1631,6 +1631,8 @@ int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32_t ta
|
||||||
streamMetaAddTaskLaunchResult(pMeta, hId.streamId, hId.taskId, startTs, now, false);
|
streamMetaAddTaskLaunchResult(pMeta, hId.streamId, hId.taskId, startTs, now, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
streamMetaRUnLock(pMeta);
|
||||||
|
|
||||||
stError("failed to locate the stream task:0x%" PRIx64 "-0x%x (vgId:%d), it may have been destroyed or stopped",
|
stError("failed to locate the stream task:0x%" PRIx64 "-0x%x (vgId:%d), it may have been destroyed or stopped",
|
||||||
streamId, taskId, pMeta->vgId);
|
streamId, taskId, pMeta->vgId);
|
||||||
code = TSDB_CODE_STREAM_TASK_NOT_EXIST;
|
code = TSDB_CODE_STREAM_TASK_NOT_EXIST;
|
||||||
|
|
|
@ -21,29 +21,29 @@ target_include_directories(
|
||||||
PRIVATE "${TD_SOURCE_DIR}/utils/TSZ/sz/inc"
|
PRIVATE "${TD_SOURCE_DIR}/utils/TSZ/sz/inc"
|
||||||
PRIVATE "${TD_SOURCE_DIR}/utils/TSZ/zstd/"
|
PRIVATE "${TD_SOURCE_DIR}/utils/TSZ/zstd/"
|
||||||
PRIVATE "${TD_SOURCE_DIR}/contrib/lzma2/"
|
PRIVATE "${TD_SOURCE_DIR}/contrib/lzma2/"
|
||||||
|
PRIVATE "${TD_SOURCE_DIR}/contrib/pcre2/"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_directories(
|
target_link_directories(
|
||||||
util
|
util
|
||||||
PUBLIC "${TD_SOURCE_DIR}/contrib/lzma2"
|
PUBLIC "${TD_SOURCE_DIR}/contrib/lzma2"
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/contrib/pcre2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if (TD_LINUX)
|
if (TD_LINUX)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
util
|
util
|
||||||
PUBLIC os common
|
PUBLIC os common
|
||||||
PUBLIC lz4_static fast-lzma2
|
PUBLIC lz4_static fast-lzma2 pcre2-8
|
||||||
PUBLIC api cjson geos_c TSZ
|
PUBLIC api cjson geos_c TSZ
|
||||||
|
)
|
||||||
)
|
else()
|
||||||
else()
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
util
|
util
|
||||||
PUBLIC os common
|
PUBLIC os common
|
||||||
PUBLIC lz4_static
|
PUBLIC lz4_static pcre2-8
|
||||||
PUBLIC api cjson geos_c TSZ
|
PUBLIC api cjson geos_c TSZ
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
|
|
|
@ -61,9 +61,7 @@
|
||||||
#include "zstd.h"
|
#include "zstd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TD_TSZ
|
|
||||||
#include "td_sz.h"
|
#include "td_sz.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
int32_t tsCompressPlain2(const char *const input, const int32_t nelements, char *const output, const char type);
|
int32_t tsCompressPlain2(const char *const input, const int32_t nelements, char *const output, const char type);
|
||||||
int32_t tsDecompressPlain2(const char *const input, const int32_t nelements, char *const output, const char type);
|
int32_t tsDecompressPlain2(const char *const input, const int32_t nelements, char *const output, const char type);
|
||||||
|
@ -322,7 +320,6 @@ static const int32_t TEST_NUMBER = 1;
|
||||||
|
|
||||||
#define safeInt64Add(a, b) (((a >= 0) && (b <= INT64_MAX - a)) || ((a < 0) && (b >= INT64_MIN - a)))
|
#define safeInt64Add(a, b) (((a >= 0) && (b <= INT64_MAX - a)) || ((a < 0) && (b >= INT64_MIN - a)))
|
||||||
|
|
||||||
#ifdef TD_TSZ
|
|
||||||
bool lossyFloat = false;
|
bool lossyFloat = false;
|
||||||
bool lossyDouble = false;
|
bool lossyDouble = false;
|
||||||
|
|
||||||
|
@ -341,8 +338,6 @@ int32_t tsCompressInit(char *lossyColumns, float fPrecision, double dPrecision,
|
||||||
// exit call
|
// exit call
|
||||||
void tsCompressExit() { tdszExit(); }
|
void tsCompressExit() { tdszExit(); }
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compress Integer (Simple8B).
|
* Compress Integer (Simple8B).
|
||||||
*/
|
*/
|
||||||
|
@ -1214,7 +1209,6 @@ int32_t tsDecompressFloatImp(const char *const input, const int32_t nelements, c
|
||||||
return nelements * FLOAT_BYTES;
|
return nelements * FLOAT_BYTES;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TD_TSZ
|
|
||||||
//
|
//
|
||||||
// ---------- float double lossy -----------
|
// ---------- float double lossy -----------
|
||||||
//
|
//
|
||||||
|
@ -1283,7 +1277,6 @@ int32_t tsDecompressDoubleLossyImp(const char *input, int32_t compressedSize, co
|
||||||
// decompressed with sz
|
// decompressed with sz
|
||||||
return tdszDecompress(SZ_DOUBLE, input + 1, compressedSize - 1, nelements, output);
|
return tdszDecompress(SZ_DOUBLE, input + 1, compressedSize - 1, nelements, output);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUILD_NO_CALL
|
#ifdef BUILD_NO_CALL
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -2463,13 +2456,11 @@ int32_t tsDecompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut,
|
||||||
// Float =====================================================
|
// Float =====================================================
|
||||||
int32_t tsCompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
|
int32_t tsCompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
|
||||||
int32_t nBuf) {
|
int32_t nBuf) {
|
||||||
#ifdef TD_TSZ
|
|
||||||
// lossy mode
|
// lossy mode
|
||||||
if (lossyFloat) {
|
if (lossyFloat) {
|
||||||
return tsCompressFloatLossyImp(pIn, nEle, pOut);
|
return tsCompressFloatLossyImp(pIn, nEle, pOut);
|
||||||
// lossless mode
|
// lossless mode
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
if (cmprAlg == ONE_STAGE_COMP) {
|
if (cmprAlg == ONE_STAGE_COMP) {
|
||||||
return tsCompressFloatImp(pIn, nEle, pOut);
|
return tsCompressFloatImp(pIn, nEle, pOut);
|
||||||
} else if (cmprAlg == TWO_STAGE_COMP) {
|
} else if (cmprAlg == TWO_STAGE_COMP) {
|
||||||
|
@ -2479,19 +2470,15 @@ int32_t tsCompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_
|
||||||
ASSERTS(0, "compress algo invalid");
|
ASSERTS(0, "compress algo invalid");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef TD_TSZ
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsDecompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
|
int32_t tsDecompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
|
||||||
int32_t nBuf) {
|
int32_t nBuf) {
|
||||||
#ifdef TD_TSZ
|
|
||||||
if (HEAD_ALGO(((uint8_t *)pIn)[0]) == ALGO_SZ_LOSSY) {
|
if (HEAD_ALGO(((uint8_t *)pIn)[0]) == ALGO_SZ_LOSSY) {
|
||||||
// decompress lossy
|
// decompress lossy
|
||||||
return tsDecompressFloatLossyImp(pIn, nIn, nEle, pOut);
|
return tsDecompressFloatLossyImp(pIn, nIn, nEle, pOut);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
// decompress lossless
|
// decompress lossless
|
||||||
if (cmprAlg == ONE_STAGE_COMP) {
|
if (cmprAlg == ONE_STAGE_COMP) {
|
||||||
return tsDecompressFloatImp(pIn, nEle, pOut);
|
return tsDecompressFloatImp(pIn, nEle, pOut);
|
||||||
|
@ -2502,20 +2489,16 @@ int32_t tsDecompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int3
|
||||||
ASSERTS(0, "compress algo invalid");
|
ASSERTS(0, "compress algo invalid");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef TD_TSZ
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Double =====================================================
|
// Double =====================================================
|
||||||
int32_t tsCompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
|
int32_t tsCompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
|
||||||
int32_t nBuf) {
|
int32_t nBuf) {
|
||||||
#ifdef TD_TSZ
|
|
||||||
if (lossyDouble) {
|
if (lossyDouble) {
|
||||||
// lossy mode
|
// lossy mode
|
||||||
return tsCompressDoubleLossyImp(pIn, nEle, pOut);
|
return tsCompressDoubleLossyImp(pIn, nEle, pOut);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
// lossless mode
|
// lossless mode
|
||||||
if (cmprAlg == ONE_STAGE_COMP) {
|
if (cmprAlg == ONE_STAGE_COMP) {
|
||||||
return tsCompressDoubleImp(pIn, nEle, pOut);
|
return tsCompressDoubleImp(pIn, nEle, pOut);
|
||||||
|
@ -2526,19 +2509,15 @@ int32_t tsCompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32
|
||||||
ASSERTS(0, "compress algo invalid");
|
ASSERTS(0, "compress algo invalid");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef TD_TSZ
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsDecompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
|
int32_t tsDecompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
|
||||||
int32_t nBuf) {
|
int32_t nBuf) {
|
||||||
#ifdef TD_TSZ
|
|
||||||
if (HEAD_ALGO(((uint8_t *)pIn)[0]) == ALGO_SZ_LOSSY) {
|
if (HEAD_ALGO(((uint8_t *)pIn)[0]) == ALGO_SZ_LOSSY) {
|
||||||
// decompress lossy
|
// decompress lossy
|
||||||
return tsDecompressDoubleLossyImp(pIn, nIn, nEle, pOut);
|
return tsDecompressDoubleLossyImp(pIn, nIn, nEle, pOut);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
// decompress lossless
|
// decompress lossless
|
||||||
if (cmprAlg == ONE_STAGE_COMP) {
|
if (cmprAlg == ONE_STAGE_COMP) {
|
||||||
return tsDecompressDoubleImp(pIn, nEle, pOut);
|
return tsDecompressDoubleImp(pIn, nEle, pOut);
|
||||||
|
@ -2549,9 +2528,7 @@ int32_t tsDecompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int
|
||||||
ASSERTS(0, "compress algo invalid");
|
ASSERTS(0, "compress algo invalid");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef TD_TSZ
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binary =====================================================
|
// Binary =====================================================
|
||||||
|
|
|
@ -259,6 +259,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_IN_CREATING, "Database in creating
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_ENCRYPT_NOT_ALLOW_CHANGE, "Encryption is not allowed to be changed after database is created")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_ENCRYPT_NOT_ALLOW_CHANGE, "Encryption is not allowed to be changed after database is created")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INCONSIST_ENCRYPT_KEY, "Inconsistent encryption key")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INCONSIST_ENCRYPT_KEY, "Inconsistent encryption key")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ENCRYPT_KEY, "The cluster has not been set properly for database encryption")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ENCRYPT_KEY, "The cluster has not been set properly for database encryption")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_ENCRYPT_GRANT_EXPIRED, "The database encryption function grant expired")
|
||||||
|
|
||||||
// mnode-node
|
// mnode-node
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_MNODE_ALREADY_EXIST, "Mnode already exists")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_MNODE_ALREADY_EXIST, "Mnode already exists")
|
||||||
|
|
|
@ -43,6 +43,10 @@ void destroyThreadLocalGeosCtx() {
|
||||||
tlGeosCtx.WKBWriter = NULL;
|
tlGeosCtx.WKBWriter = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tlGeosCtx.WKTRegex) {
|
||||||
|
destroyRegexes(tlGeosCtx.WKTRegex, tlGeosCtx.WKTMatchData);
|
||||||
|
}
|
||||||
|
|
||||||
if(tlGeosCtx.handle) {
|
if(tlGeosCtx.handle) {
|
||||||
GEOS_finish_r(tlGeosCtx.handle);
|
GEOS_finish_r(tlGeosCtx.handle);
|
||||||
tlGeosCtx.handle = NULL;
|
tlGeosCtx.handle = NULL;
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
#include "tpcre2.h"
|
||||||
|
|
||||||
|
int32_t doRegComp(pcre2_code** ppRegex, pcre2_match_data** ppMatchData, const char* pattern) {
|
||||||
|
uint32_t options = PCRE2_CASELESS;
|
||||||
|
int errorcode;
|
||||||
|
PCRE2_SIZE erroroffset;
|
||||||
|
|
||||||
|
*ppRegex = pcre2_compile((PCRE2_SPTR8)pattern, PCRE2_ZERO_TERMINATED, options, &errorcode, &erroroffset, NULL);
|
||||||
|
if (*ppRegex == NULL) {
|
||||||
|
PCRE2_UCHAR buffer[256];
|
||||||
|
pcre2_get_error_message(errorcode, buffer, sizeof(buffer));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppMatchData = pcre2_match_data_create_from_pattern(*ppRegex, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t doRegExec(const char* pString, pcre2_code* pRegex, pcre2_match_data* pMatchData) {
|
||||||
|
int32_t ret = 0;
|
||||||
|
ret = pcre2_match(pRegex, (PCRE2_SPTR)pString, PCRE2_ZERO_TERMINATED, 0, 0, pMatchData, NULL);
|
||||||
|
if (ret < 0) {
|
||||||
|
PCRE2_UCHAR buffer[256];
|
||||||
|
pcre2_get_error_message(ret, buffer, sizeof(buffer));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ret > 0) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroyRegexes(pcre2_code* pWktRegex, pcre2_match_data* pWktMatchData) {
|
||||||
|
pcre2_code_free(pWktRegex);
|
||||||
|
pcre2_match_data_free(pWktMatchData);
|
||||||
|
}
|
|
@ -0,0 +1,181 @@
|
||||||
|
from frame.log import *
|
||||||
|
from frame.cases import *
|
||||||
|
from frame.sql import *
|
||||||
|
from frame.caseBase import *
|
||||||
|
from frame import *
|
||||||
|
from frame.eos import *
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
|
||||||
|
class TDTestCase(TBase):
|
||||||
|
"""Add test case to test column and tag boundary for task TD-28586
|
||||||
|
"""
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
# define the max properties of column and tag
|
||||||
|
self.super_table_max_column_num = 4096
|
||||||
|
self.max_tag_num = 128
|
||||||
|
self.max_tag_length = 16382
|
||||||
|
self.max_column_length = 65517
|
||||||
|
self.child_table_num = 1
|
||||||
|
self.insert_round_num = 700
|
||||||
|
self.row_num_per_round = 15
|
||||||
|
|
||||||
|
def prepare_data(self):
|
||||||
|
# database
|
||||||
|
tdSql.execute("create database db;")
|
||||||
|
tdSql.execute("use db;")
|
||||||
|
|
||||||
|
def test_binary_boundary(self):
|
||||||
|
# create tables
|
||||||
|
tdSql.execute(f"create table st_binary (ts timestamp, c1 binary({self.max_column_length})) tags (t1 binary({self.max_tag_length}));")
|
||||||
|
for i in range(self.child_table_num):
|
||||||
|
# create child table with max column and tag length
|
||||||
|
tag = ''.join(random.sample(string.ascii_lowercase, 1)) * self.max_tag_length
|
||||||
|
tdSql.execute(f"create table ct_binary{i+1} using st_binary tags('{tag}');")
|
||||||
|
# insert data
|
||||||
|
for j in range(self.insert_round_num):
|
||||||
|
sql = "insert into ct_binary%s values" % (i+1)
|
||||||
|
for k in range(self.row_num_per_round):
|
||||||
|
sql += "(now+%ss, '%s')," % (str(j * 10 + k + 1), 'a' * self.max_column_length)
|
||||||
|
tdSql.execute(sql)
|
||||||
|
tdLog.info(f"Insert {self.row_num_per_round} rows data into ct_binary{i+1} {j+1} times successfully")
|
||||||
|
tdSql.execute("flush database db;")
|
||||||
|
# check the data
|
||||||
|
for i in range(self.child_table_num):
|
||||||
|
tdSql.query(f"select * from ct_binary{i+1};")
|
||||||
|
tdSql.checkRows(10500)
|
||||||
|
row_num = random.randint(0, 9999)
|
||||||
|
tdSql.checkData(row_num, 1, 'a' * self.max_column_length)
|
||||||
|
tdSql.query(f"show tags from ct_binary{i+1};")
|
||||||
|
tdSql.checkData(0, 5, tag)
|
||||||
|
|
||||||
|
def test_varchar_boundary(self):
|
||||||
|
# create tables
|
||||||
|
tdSql.execute(f"create table st_varchar (ts timestamp, c1 varchar({self.max_column_length})) tags (t1 varchar({self.max_tag_length}));")
|
||||||
|
for i in range(self.child_table_num):
|
||||||
|
# create child table with max column and tag length
|
||||||
|
tag = ''.join(random.sample(string.ascii_lowercase, 1)) * self.max_tag_length
|
||||||
|
tdSql.execute(f"create table ct_varchar{i+1} using st_varchar tags('{tag}');")
|
||||||
|
# insert data
|
||||||
|
for j in range(self.insert_round_num):
|
||||||
|
sql = "insert into ct_varchar%s values" % (i+1)
|
||||||
|
for k in range(self.row_num_per_round):
|
||||||
|
sql += "(now+%ss, '%s')," % (str(j * 10 + k + 1), 'b' * self.max_column_length)
|
||||||
|
tdSql.execute(sql)
|
||||||
|
tdLog.info(f"Insert {self.row_num_per_round} rows data into ct_varchar{i+1} {j+1} times successfully")
|
||||||
|
tdSql.execute("flush database db;")
|
||||||
|
# check the data
|
||||||
|
for i in range(self.child_table_num):
|
||||||
|
tdSql.query(f"select * from ct_varchar{i+1};")
|
||||||
|
tdSql.checkRows(10500)
|
||||||
|
row_num = random.randint(0, 9999)
|
||||||
|
tdSql.checkData(row_num, 1, 'b' * self.max_column_length)
|
||||||
|
tdSql.query(f"show tags from ct_varchar{i+1};")
|
||||||
|
tdSql.checkData(0, 5, tag)
|
||||||
|
|
||||||
|
def gen_chinese_string(self, length):
|
||||||
|
start = 0x4e00
|
||||||
|
end = 0x9fa5
|
||||||
|
chinese_string = ''
|
||||||
|
for _ in range(length):
|
||||||
|
chinese_string += chr(random.randint(start, end))
|
||||||
|
return chinese_string
|
||||||
|
|
||||||
|
def test_nchar_boundary(self):
|
||||||
|
max_nchar_column_length = self.max_column_length // 4
|
||||||
|
max_nchar_tag_length = self.max_tag_length // 4
|
||||||
|
# create tables
|
||||||
|
tdSql.execute(f"create table st_nchar (ts timestamp, c1 nchar({max_nchar_column_length})) tags (t1 nchar({max_nchar_tag_length}));")
|
||||||
|
for i in range(self.child_table_num):
|
||||||
|
# create child table with max column and tag length
|
||||||
|
tag = self.gen_chinese_string(max_nchar_tag_length)
|
||||||
|
column = self.gen_chinese_string(max_nchar_column_length)
|
||||||
|
tdSql.execute(f"create table ct_nchar{i+1} using st_nchar tags('{tag}');")
|
||||||
|
# insert data
|
||||||
|
for j in range(self.insert_round_num):
|
||||||
|
sql = "insert into ct_nchar%s values" % (i+1)
|
||||||
|
for k in range(self.row_num_per_round):
|
||||||
|
sql += "(now+%ss, '%s')," % (str(j * 10 + k + 1), column)
|
||||||
|
tdSql.execute(sql)
|
||||||
|
tdLog.info(f"Insert {self.row_num_per_round} rows data into ct_nchar{i+1} {j+1} times successfully")
|
||||||
|
tdSql.execute("flush database db;")
|
||||||
|
# check the data
|
||||||
|
for i in range(self.child_table_num):
|
||||||
|
tdSql.query(f"select * from ct_nchar{i+1};")
|
||||||
|
tdSql.checkRows(10500)
|
||||||
|
row_num = random.randint(0, 9999)
|
||||||
|
tdSql.checkData(row_num, 1, column)
|
||||||
|
tdSql.query(f"show tags from ct_nchar{i+1};")
|
||||||
|
tdSql.checkData(0, 5, tag)
|
||||||
|
|
||||||
|
def test_varbinary_boundary(self):
|
||||||
|
row_num_per_round = 8
|
||||||
|
# create tables
|
||||||
|
tdSql.execute(f"create table st_varbinary (ts timestamp, c1 varbinary({self.max_column_length})) tags (t1 varbinary({self.max_tag_length}));")
|
||||||
|
for i in range(self.child_table_num):
|
||||||
|
# create child table with max column and tag length
|
||||||
|
tag = (''.join(random.sample(string.ascii_lowercase, 1)) * self.max_tag_length).encode().hex()
|
||||||
|
column = (''.join(random.sample(string.ascii_lowercase, 1)) * self.max_column_length).encode().hex()
|
||||||
|
tdSql.execute("create table ct_varbinary%s using st_varbinary tags('%s');" % (str(i+1), '\\x' + tag))
|
||||||
|
# insert data
|
||||||
|
for j in range(self.insert_round_num):
|
||||||
|
sql = "insert into ct_varbinary%s values" % (i+1)
|
||||||
|
for k in range(row_num_per_round):
|
||||||
|
sql += "(now+%ss, '%s')," % (str(j * 10 + k + 1), '\\x' + column)
|
||||||
|
tdSql.execute(sql)
|
||||||
|
tdLog.info(f"Insert {row_num_per_round} rows data into ct_varbinary{i+1} {j+1} times successfully")
|
||||||
|
tdSql.execute("flush database db;")
|
||||||
|
# check the data
|
||||||
|
for i in range(self.child_table_num):
|
||||||
|
tdSql.query(f"select * from ct_varbinary{i+1};")
|
||||||
|
tdSql.checkRows(5600)
|
||||||
|
row_num = random.randint(0, 5599)
|
||||||
|
tdSql.checkData(row_num, 1, bytes.fromhex(column))
|
||||||
|
tdSql.query(f"show tags from ct_varbinary{i+1};")
|
||||||
|
tdSql.checkData(0, 5, '\\x' + tag.upper())
|
||||||
|
|
||||||
|
def test_json_tag_boundary(self):
|
||||||
|
row_num_per_round = 8
|
||||||
|
max_json_tag_length = 4095
|
||||||
|
max_json_tag_key_length = 256
|
||||||
|
# create tables
|
||||||
|
tdSql.execute(f"create table st_json_tag (ts timestamp, c1 varbinary({self.max_column_length})) tags (t1 json);")
|
||||||
|
for i in range(self.child_table_num):
|
||||||
|
# create child table with max column and tag length
|
||||||
|
tag_key = ''.join(random.sample(string.ascii_lowercase, 1)) * max_json_tag_key_length
|
||||||
|
tag_value = ''.join(random.sample(string.ascii_lowercase, 1)) * (max_json_tag_length - max_json_tag_key_length - 7)
|
||||||
|
column = (''.join(random.sample(string.ascii_lowercase, 1)) * self.max_column_length).encode().hex()
|
||||||
|
tdSql.execute("create table ct_json_tag%s using st_json_tag tags('%s');" % (str(i+1), f'{{"{tag_key}":"{tag_value}"}}'))
|
||||||
|
# insert data
|
||||||
|
for j in range(self.insert_round_num):
|
||||||
|
sql = "insert into ct_json_tag%s values" % (i+1)
|
||||||
|
for k in range(row_num_per_round):
|
||||||
|
sql += "(now+%ss, '%s')," % (str(j * 10 + k + 1), '\\x' + column)
|
||||||
|
tdSql.execute(sql)
|
||||||
|
tdLog.info(f"Insert {row_num_per_round} rows data into ct_json_tag{i+1} {j+1} times successfully")
|
||||||
|
tdSql.execute("flush database db;")
|
||||||
|
# check the data
|
||||||
|
for i in range(self.child_table_num):
|
||||||
|
tdSql.query(f"select * from ct_json_tag{i+1} where t1->'{tag_key}' = '{tag_value}';")
|
||||||
|
tdSql.checkRows(5600)
|
||||||
|
row_num = random.randint(0, 5599)
|
||||||
|
tdSql.checkData(row_num, 1, bytes.fromhex(column))
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.prepare_data()
|
||||||
|
self.test_binary_boundary()
|
||||||
|
self.test_varchar_boundary()
|
||||||
|
self.test_nchar_boundary()
|
||||||
|
self.test_varbinary_boundary()
|
||||||
|
self.test_json_tag_boundary()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.execute("drop database db;")
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -102,6 +102,22 @@ class TDTestCase(TBase):
|
||||||
allRows = self.insert_rows * self.childtable_count
|
allRows = self.insert_rows * self.childtable_count
|
||||||
tdSql.checkFirstValue(sql, allRows)
|
tdSql.checkFirstValue(sql, allRows)
|
||||||
|
|
||||||
|
def checkShowTags(self):
|
||||||
|
# verification for TD-29904
|
||||||
|
tdSql.error("show tags from t100000", expectErrInfo='Fail to get table info, error: Table does not exist')
|
||||||
|
|
||||||
|
sql = "show tags from child1"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(5)
|
||||||
|
|
||||||
|
sql = f"show tags from child1 from {self.db}"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(5)
|
||||||
|
|
||||||
|
sql = f"show tags from {self.db}.child1"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(5)
|
||||||
|
|
||||||
def checkShow(self):
|
def checkShow(self):
|
||||||
# not support
|
# not support
|
||||||
sql = "show accounts;"
|
sql = "show accounts;"
|
||||||
|
@ -125,10 +141,12 @@ class TDTestCase(TBase):
|
||||||
sqls = [
|
sqls = [
|
||||||
"show scores;",
|
"show scores;",
|
||||||
"SHOW CLUSTER VARIABLES",
|
"SHOW CLUSTER VARIABLES",
|
||||||
"SHOW BNODES;",
|
# "SHOW BNODES;",
|
||||||
]
|
]
|
||||||
tdSql.executes(sqls)
|
tdSql.executes(sqls)
|
||||||
|
|
||||||
|
self.checkShowTags()
|
||||||
|
|
||||||
|
|
||||||
# run
|
# run
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -143,6 +161,9 @@ class TDTestCase(TBase):
|
||||||
# do action
|
# do action
|
||||||
self.doQuery()
|
self.doQuery()
|
||||||
|
|
||||||
|
# check show
|
||||||
|
self.checkShow()
|
||||||
|
|
||||||
|
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
|
|
@ -47,14 +47,20 @@ class TDTestCase(TBase):
|
||||||
dtypes = [ "tinyint","tinyint unsigned","smallint","smallint unsigned","int","int unsigned",
|
dtypes = [ "tinyint","tinyint unsigned","smallint","smallint unsigned","int","int unsigned",
|
||||||
"bigint","bigint unsigned","timestamp","bool","float","double","binary(16)","nchar(16)",
|
"bigint","bigint unsigned","timestamp","bool","float","double","binary(16)","nchar(16)",
|
||||||
"varchar(16)","varbinary(16)"]
|
"varchar(16)","varbinary(16)"]
|
||||||
|
|
||||||
|
def combineValid(self, datatype, encode, compress):
|
||||||
|
if datatype != "float" and datatype != "double":
|
||||||
|
if compress == "tsz":
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def genAllSqls(self, stbName, max):
|
def genAllSqls(self, stbName, max):
|
||||||
# encode
|
# encode
|
||||||
encodes = [
|
encodes = [
|
||||||
[["tinyint","tinyint unsigned","smallint","smallint unsigned","int","int unsigned","bigint","bigint unsigned"], ["simple8b"]],
|
[["tinyint","tinyint unsigned","smallint","smallint unsigned","int","int unsigned","bigint","bigint unsigned"], ["simple8B"]],
|
||||||
[["timestamp","bigint","bigint unsigned"], ["delta-i"]],
|
[["timestamp","bigint","bigint unsigned"], ["Delta-i"]],
|
||||||
[["bool"], ["bit-packing"]],
|
[["bool"], ["Bit-packing"]],
|
||||||
[["float","double"], ["delta-d"]]
|
[["float","double"], ["Delta-d"]]
|
||||||
]
|
]
|
||||||
|
|
||||||
c = 0 # column number
|
c = 0 # column number
|
||||||
|
@ -65,7 +71,6 @@ class TDTestCase(TBase):
|
||||||
|
|
||||||
# loop append sqls
|
# loop append sqls
|
||||||
for lines in encodes:
|
for lines in encodes:
|
||||||
print(lines)
|
|
||||||
for datatype in lines[0]:
|
for datatype in lines[0]:
|
||||||
for encode in lines[1]:
|
for encode in lines[1]:
|
||||||
for compress in self.compresses:
|
for compress in self.compresses:
|
||||||
|
@ -74,8 +79,9 @@ class TDTestCase(TBase):
|
||||||
# first
|
# first
|
||||||
sql = f"create table {self.db}.st{t} (ts timestamp"
|
sql = f"create table {self.db}.st{t} (ts timestamp"
|
||||||
else:
|
else:
|
||||||
sql += f", c{c} {datatype} ENCODE '{encode}' COMPRESS '{compress}' LEVEL '{level}'"
|
if self.combineValid(datatype, encode, compress):
|
||||||
c += 1
|
sql += f", c{c} {datatype} ENCODE '{encode}' COMPRESS '{compress}' LEVEL '{level}'"
|
||||||
|
c += 1
|
||||||
|
|
||||||
if c >= max:
|
if c >= max:
|
||||||
# append sqls
|
# append sqls
|
||||||
|
@ -97,9 +103,11 @@ class TDTestCase(TBase):
|
||||||
# check error create
|
# check error create
|
||||||
def errorCreate(self):
|
def errorCreate(self):
|
||||||
sqls = [
|
sqls = [
|
||||||
f"create table terr(ts timestamp, c0 int ENCODE 'abc') ",
|
f"create table terr(ts timestamp, c0 int ENCODE 'simple8B' COMPRESS 'tsz' LEVEL 'high') ",
|
||||||
f""
|
f"create table terr(ts timestamp, bi bigint encode 'bit-packing') tags (area int);"
|
||||||
|
f"create table terr(ts timestamp, ic int encode 'delta-d') tags (area int);"
|
||||||
]
|
]
|
||||||
|
tdSql.errors(sqls)
|
||||||
|
|
||||||
for dtype in self.dtypes:
|
for dtype in self.dtypes:
|
||||||
# encode
|
# encode
|
||||||
|
@ -111,6 +119,11 @@ class TDTestCase(TBase):
|
||||||
# level
|
# level
|
||||||
sql = f"create table terr(ts timestamp, c0 {dtype} LEVEL 'hig') "
|
sql = f"create table terr(ts timestamp, c0 {dtype} LEVEL 'hig') "
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
|
|
||||||
|
# tsz check
|
||||||
|
if dtype != "float" and dtype != "double":
|
||||||
|
sql = f"create table terr(ts timestamp, c0 {dtype} COMPRESS 'tsz') "
|
||||||
|
tdSql.error(sql)
|
||||||
|
|
||||||
# default value correct
|
# default value correct
|
||||||
def defaultCorrect(self):
|
def defaultCorrect(self):
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/query/function/test_func_elapsed.py
|
,,y,army,./pytest.sh python3 ./test.py -f community/query/function/test_func_elapsed.py
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/query/test_join.py
|
,,y,army,./pytest.sh python3 ./test.py -f community/query/test_join.py
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/query/test_compare.py
|
,,y,army,./pytest.sh python3 ./test.py -f community/query/test_compare.py
|
||||||
|
,,y,army,./pytest.sh python3 ./test.py -f community/insert/test_column_tag_boundary.py
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/query/fill/fill_desc.py -N 3 -L 3 -D 2
|
,,y,army,./pytest.sh python3 ./test.py -f community/query/fill/fill_desc.py -N 3 -L 3 -D 2
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/incSnapshot.py -N 3
|
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/incSnapshot.py -N 3
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/query/query_basic.py -N 3
|
,,y,army,./pytest.sh python3 ./test.py -f community/query/query_basic.py -N 3
|
||||||
|
|
|
@ -72,7 +72,12 @@ python_error=$(cat ${LOG_DIR}/*.info | grep -w "stack" | wc -l)
|
||||||
|
|
||||||
#0 0x7f2d64f5a808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
|
#0 0x7f2d64f5a808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
|
||||||
#1 0x7f2d63fcf459 in strerror /build/glibc-SzIz7B/glibc-2.31/string/strerror.c:38
|
#1 0x7f2d63fcf459 in strerror /build/glibc-SzIz7B/glibc-2.31/string/strerror.c:38
|
||||||
runtime_error=$(cat ${LOG_DIR}/*.asan | grep "runtime error" | grep -v "trees.c:873" | grep -v "sclfunc.c.*outside the range of representable values of type" | grep -v "signed integer overflow" | grep -v "strerror.c" | grep -v "asan_malloc_linux.cc" | grep -v "strerror.c" | grep -v "asan_malloc_linux.cpp" | grep -v "sclvector.c" | wc -l)
|
|
||||||
|
# TD-29953
|
||||||
|
#/home/TDinternal/community/utils/TSZ/sz/src/sz_double.c:388:59: runtime error: 2.64021e+25 is outside the range of representable values of type 'long unsigned int'
|
||||||
|
#/home/TDinternal/community/utils/TSZ/sz/src/sz_float.c:407:59: runtime error: 5.76041e+19 is outside the range of representable values of type 'long unsigned int'
|
||||||
|
#/home/TDinternal/community/source/libs/scalar/src/sclfunc.c:808:11: runtime error: -3.40401e+18 is outside the range of representable values of type 'int'
|
||||||
|
runtime_error=$(cat ${LOG_DIR}/*.asan | grep "runtime error" | grep -v "trees.c:873" | grep -v "sclfunc.c.*outside the range of representable values of type" | grep -v "signed integer overflow" | grep -v "strerror.c" | grep -v "asan_malloc_linux.cc" | grep -v "strerror.c" | grep -v "asan_malloc_linux.cpp" | grep -v "sclvector.c" | grep -v "sclfunc.c:808"| grep -v "sz_double.c:388" | grep -v "sz_float.c:407:59"| wc -l)
|
||||||
|
|
||||||
echo -e "\033[44;32;1m"asan error_num: $error_num"\033[0m"
|
echo -e "\033[44;32;1m"asan error_num: $error_num"\033[0m"
|
||||||
echo -e "\033[44;32;1m"asan memory_leak: $memory_leak"\033[0m"
|
echo -e "\033[44;32;1m"asan memory_leak: $memory_leak"\033[0m"
|
||||||
|
|
|
@ -269,13 +269,17 @@ class TDTestCase:
|
||||||
|
|
||||||
def ins_grants_check(self):
|
def ins_grants_check(self):
|
||||||
grant_name_dict = {
|
grant_name_dict = {
|
||||||
'stream':'stream',
|
'stream':'Stream',
|
||||||
'subscription':'subscription',
|
'subscription':'Subscription',
|
||||||
'view':'view',
|
'view':'View',
|
||||||
'audit':'audit',
|
'audit':'Audit',
|
||||||
'csv':'csv',
|
'csv':'CSV',
|
||||||
'storage':'multi_tier_storage',
|
'storage':'Multi-Tier Storage',
|
||||||
'backup_restore':'backup_restore',
|
'backup_restore':'Data Backup & Restore',
|
||||||
|
'object_storage':'Object Storage',
|
||||||
|
'active_active':'Active-Active',
|
||||||
|
'dual_replica':'Dual-Replica HA',
|
||||||
|
'db_encryption':'Database Encryption',
|
||||||
'opc_da':'OPC_DA',
|
'opc_da':'OPC_DA',
|
||||||
'opc_ua':'OPC_UA',
|
'opc_ua':'OPC_UA',
|
||||||
'pi':'Pi',
|
'pi':'Pi',
|
||||||
|
@ -285,7 +289,10 @@ class TDTestCase:
|
||||||
'avevahistorian':'avevaHistorian',
|
'avevahistorian':'avevaHistorian',
|
||||||
'opentsdb':'OpenTSDB',
|
'opentsdb':'OpenTSDB',
|
||||||
'td2.6':'TDengine2.6',
|
'td2.6':'TDengine2.6',
|
||||||
'td3.0':'TDengine3.0'
|
'td3.0':'TDengine3.0',
|
||||||
|
'mysql':'MySQL',
|
||||||
|
'postgres':'PostgreSQL',
|
||||||
|
'oracle':'Oracle',
|
||||||
}
|
}
|
||||||
|
|
||||||
tdSql.execute('drop database if exists db2')
|
tdSql.execute('drop database if exists db2')
|
||||||
|
@ -297,7 +304,7 @@ class TDTestCase:
|
||||||
if result[i][0] in grant_name_dict:
|
if result[i][0] in grant_name_dict:
|
||||||
tdSql.checkEqual(result[i][1], grant_name_dict[result[i][0]])
|
tdSql.checkEqual(result[i][1], grant_name_dict[result[i][0]])
|
||||||
index += 1
|
index += 1
|
||||||
tdSql.checkEqual(index, 17)
|
tdSql.checkEqual(index, 24)
|
||||||
tdSql.query(f'select * from information_schema.ins_grants_logs')
|
tdSql.query(f'select * from information_schema.ins_grants_logs')
|
||||||
result = tdSql.queryResult
|
result = tdSql.queryResult
|
||||||
tdSql.checkEqual(True, len(result) >= 0)
|
tdSql.checkEqual(True, len(result) >= 0)
|
||||||
|
|
|
@ -78,6 +78,11 @@ class TDTestCase:
|
||||||
tdSql.execute(f'create table stb (ts timestamp, c0 int) tags (t0 int, t1 int)')
|
tdSql.execute(f'create table stb (ts timestamp, c0 int) tags (t0 int, t1 int)')
|
||||||
tdSql.execute(f'create table ctb1 using stb tags (1, 1)')
|
tdSql.execute(f'create table ctb1 using stb tags (1, 1)')
|
||||||
tdSql.execute(f'create table ctb2 using stb tags (2, 2)')
|
tdSql.execute(f'create table ctb2 using stb tags (2, 2)')
|
||||||
|
tdSql.execute(f'create table ntb (ts timestamp, c0 int)')
|
||||||
|
tdSql.execute(f'create view vtb as select * from stb')
|
||||||
|
tdSql.execute(f'create view vtb1 as select * from ctb1')
|
||||||
|
tdSql.execute(f'create view vtb2 as select * from ctb2')
|
||||||
|
tdSql.execute(f'create view vtbn as select * from ntb')
|
||||||
tdSql.execute(f'insert into ctb1 values (now, 1)')
|
tdSql.execute(f'insert into ctb1 values (now, 1)')
|
||||||
tdSql.execute(f'insert into ctb2 values (now, 2)')
|
tdSql.execute(f'insert into ctb2 values (now, 2)')
|
||||||
|
|
||||||
|
@ -113,6 +118,14 @@ class TDTestCase:
|
||||||
tdSql.error(f'show tags from `db`.`stb` from db')
|
tdSql.error(f'show tags from `db`.`stb` from db')
|
||||||
tdSql.error(f'show tags from db.ctb1 from db')
|
tdSql.error(f'show tags from db.ctb1 from db')
|
||||||
tdSql.error(f'show tags from `db`.`ctb1` from db')
|
tdSql.error(f'show tags from `db`.`ctb1` from db')
|
||||||
|
tdSql.error(f'show tags from tb_undef from db', expectErrInfo='Fail to get table info, error: Table does not exist')
|
||||||
|
tdSql.error(f'show tags from db.tb_undef', expectErrInfo='Fail to get table info, error: Table does not exist')
|
||||||
|
tdSql.error(f'show tags from tb_undef', expectErrInfo='Fail to get table info, error: Table does not exist')
|
||||||
|
tdSql.error(f'show tags from ntb', expectErrInfo='Tags can only applied to super table and child table')
|
||||||
|
tdSql.error(f'show tags from vtb', expectErrInfo='Tags can only applied to super table and child table')
|
||||||
|
tdSql.error(f'show tags from vtb1', expectErrInfo='Tags can only applied to super table and child table')
|
||||||
|
tdSql.error(f'show tags from vtb2', expectErrInfo='Tags can only applied to super table and child table')
|
||||||
|
tdSql.error(f'show tags from vtbn', expectErrInfo='Tags can only applied to super table and child table')
|
||||||
|
|
||||||
# show table tags
|
# show table tags
|
||||||
tdSql.query(f'show table tags from stb')
|
tdSql.query(f'show table tags from stb')
|
||||||
|
@ -145,6 +158,14 @@ class TDTestCase:
|
||||||
tdSql.error(f'show table tags from `db`.`stb` from db')
|
tdSql.error(f'show table tags from `db`.`stb` from db')
|
||||||
tdSql.error(f'show table tags from db.ctb1 from db')
|
tdSql.error(f'show table tags from db.ctb1 from db')
|
||||||
tdSql.error(f'show table tags from `db`.`ctb1` from db')
|
tdSql.error(f'show table tags from `db`.`ctb1` from db')
|
||||||
|
tdSql.error(f'show table tags from tb_undef from db', expectErrInfo='Fail to get table info, error: Table does not exist')
|
||||||
|
tdSql.error(f'show table tags from db.tb_undef', expectErrInfo='Fail to get table info, error: Table does not exist')
|
||||||
|
tdSql.error(f'show table tags from tb_undef', expectErrInfo='Fail to get table info, error: Table does not exist')
|
||||||
|
tdSql.error(f'show table tags from ntb', expectErrInfo='Tags can only applied to super table and child table')
|
||||||
|
tdSql.error(f'show table tags from vtb', expectErrInfo='Tags can only applied to super table and child table')
|
||||||
|
tdSql.error(f'show table tags from vtb1', expectErrInfo='Tags can only applied to super table and child table')
|
||||||
|
tdSql.error(f'show table tags from vtb2', expectErrInfo='Tags can only applied to super table and child table')
|
||||||
|
tdSql.error(f'show table tags from vtbn', expectErrInfo='Tags can only applied to super table and child table')
|
||||||
|
|
||||||
# show indexes
|
# show indexes
|
||||||
tdSql.execute(f'create index idx1 on stb (t1)')
|
tdSql.execute(f'create index idx1 on stb (t1)')
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,7 +28,7 @@ extern bool simExecSuccess;
|
||||||
|
|
||||||
int32_t simInitCfg() {
|
int32_t simInitCfg() {
|
||||||
taosCreateLog("simlog", 1, configDir, NULL, NULL, NULL, NULL, 1);
|
taosCreateLog("simlog", 1, configDir, NULL, NULL, NULL, NULL, 1);
|
||||||
taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1);
|
taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1, true);
|
||||||
|
|
||||||
SConfig *pCfg = taosGetCfg();
|
SConfig *pCfg = taosGetCfg();
|
||||||
tstrncpy(simScriptDir, cfgGetItem(pCfg, "scriptDir")->str, PATH_MAX);
|
tstrncpy(simScriptDir, cfgGetItem(pCfg, "scriptDir")->str, PATH_MAX);
|
||||||
|
|
Loading…
Reference in New Issue